KOALA PICTURE FILES ------------------- By Jiri Bernasek (BEWESOFT) A short time ago I made a program, which is (besides of other great functions) able to display nearly any picture from the disk. It's simple of course. But... The trouble was with loader for KOALA files. I have a lot of them (Source listings, utility etc. etc.), but the correct one is missing! Finally I was forced to crack the original KOALA MICROILLUSTRATOR program. But let's start from the begin... There are many formats of picture-files on Atari XL/XE. The most used formats are MICRO PAINTER and KOALA. MICRO PAINTER format is quite simple: The first 7680 bytes of the file contains the whole screen-memory, and the last four bytes contains colors in order: Background, color 0, color 1, and color 2. KOALA files contains packed pictures, so they are not so simple. At the begin of every KOALA file there is a header: File position Function --------------------------------------- 0...3 Identification of KOALA file. Allways FF 80 C9 C7 (hex.) 4, 5 Length of header -1 (Normal length is $1B) 6 ??? (Allways 01) 7 Compression method. It can be 00, 01, or 02. 8 ??? (Allways 0E) 9...C Position and size of window for loading the picture in. D...11 Colors. (Copy of memory range $2C4...$2C8) 12, 13 Length of the whole file -1 14...1A ??? (Allways 00 00 9B 9B 9B 9B A2) --------------------------------------- Position and size of window are defined by four bytes: Starting X-position (in bytes - NOT in pixels!), ending X-position (The first position AFTER the picture), starting Y-position, and ending Y-position. The KOALA program uses allways 00 28 00 C0 (the whole screen) while saving a picture, but there can be files with only parts of the screen - original KOALA can load them. Three compression methods can be used (see byte 7 of the header). 00 is without of compression - the rest of the file (after header) contains directly the screen-memory. (But don't forget that it needn't to be the whole screen - see above.) 01 is the most common method. It contains packed data, which will be placed on screen in well known "vertical" order: First bytes of lines 0, 2, 4, 6 etc., then first bytes of lines 1, 3, 5, 7 etc., and then next columns in the same way. Method 02 contains packed data too, but they will be placed on the screen in normal order - the same as method 00. The format of packed data is simple. There are two types of entries: - Non-packed data. The first byte has "1" in the bit D7 (128), rest of this byte is length of the data block (max. 127). If this length is zero, then there are two bytes more - they are the actual length (16 bits - High byte first!). Next bytes are data. - Packed data. The first byte has "0" in the bit D7, the rest is the length - the same as described above. There is only one data-byte, which will fill all the bytes in the block. You can also look at the example below. (All the entries will make two bytes with value FF.) There is the example: 82 FF FF ;Non-packed block 80 00 02 FF FF ;Long non-packed block 02 FF ;Packed block 00 00 02 FF ;Long packed block The trouble is that most of "Koala loaders" can load only files with standard length of header ($1B), with compression method 01, and with the whole screen. Simply: Most of loaders supports only one thing from the header: Color bytes! Another trouble is that there are mistakes in the KOALA MICROILLUSTRATOR program itself! Yes! I found three mistakes while cracking it: - It can't load files with a long headers. (There is a mistake in the program, so it'll skip one byte more.) You need to change bytes at adress $4AA0 from 20 F8 48 A5 8C D0 04 C6 8D 30 05 C6 8C to A5 8C D0 04 C6 8D 30 08 C6 8C 20 F8 48 to repair this. - With compression method 00 (no compression) it'll allways load the whole screen - never mind the X/Y ranges from the header. (There isn't any simple correction for this, but it isn't very fatal mistake.) - With compression method 00 (no compression) it'll save the screen in a wrong way: It'll add lots of nonsences before the picture-data, so the file will be very long (I think that it was about 30 kB!), and it's impossible to load such a file back. (Because the loader is reading the begin of the file, where are nonsences...) To repair this (most fatal) bug, you need to change the byte at adress $4981 from C9 to C0. And now a little test. It'll show which KOALA loaders are good, and which are not. We'll make three KOALA files. The first one can be any picture which is in the common "vertical loading" format. Load the KOALA MICROILLUSTRATOR program, and paint large horizontal lines on the screen. (For example two scanlines full of a color, two empty scanlines, and so on...) Save it on the disk - it's the second file. For the third file we'll make a little BASIC program: 10 OPEN #1,8,0,"D:PICTURE":FOR A=1 TO 7684:PUT #1,PEEK (53770):NEXT A:CLOSE #1:END This program will make a Micropainter-file with random (non-packable) contents. Then load KOALA MICROILLUSTRATOR (With the correction of the third mistake - see above), switch to the picture with SPACE BAR (this is necessary because of another bug in the program), and press "<" key. Your random picture will appear. Paint only a few lines on this screen (we'll see if is it displayed correctly then), and save it as the third file. Now try to load these files with several loaders, which you have. The first file will work well with every loaders, but the second and third file will be displayed correctly only by really good loaders. Personally I have only two good loaders: The original KOALA, and the one written by me...