****************************** SECRET OF MANA MAP COMPRESSION ****************************** By Michael1 (Alchemic) Symbol (prevByteN) indicates the value of a byte processed in the past. For (N=1), the last byte before this command; (N=2), the byte before (N=1); and so on. These work based on the decompressed results of past commands, not the compressed commands themselves. N is a decimal value. The first two bytes of a map specify width and height, respectively. To convert them to real values, divide each byte by two and add one. Map data is pointed to from a table at D0200. ------------------------------------------------------------------------------------------- B1: Indicates a "stationary door" tile. How door details (destination, tile graphic, etc) are specified is unknown. B4: Indicates a "walking door" tile. These are seen with town entrances; you step on a tile and lose control, as your characters automatically walk in/out of town for you. Door details, as with B1, are unknown. C0: Fill the next byte with (prevByte1). C1: Fill the next 2 bytes with (prevByte1). C2: Fill the next 3 bytes with (prevByte1). C3: Fill the next 4 bytes with (prevByte1). C4: Fill the next 5 bytes with (prevByte1). C5: Fill the next 6 bytes with (prevByte1). C6: Fill the next 7 bytes with (prevByte1). C7: Fill the next 8 bytes with (prevByte1). C8: Fill the next byte with (prevByte2). C9: Fill the next 2 bytes with (prevByte2). CA: Fill the next 3 bytes with (prevByte2). CB: Fill the next 4 bytes with (prevByte2). CC: Fill the next 5 bytes with (prevByte2). CD: Fill the next 6 bytes with (prevByte2). CE: Fill the next 7 bytes with (prevByte2). CF: Fill the next 8 bytes with (prevByte2). D0: Fill the next byte with (prevByte3). D1: Fill the next 2 bytes with (prevByte3). D2: Fill the next 3 bytes with (prevByte3). D3: Fill the next 4 bytes with (prevByte3). D4: Fill the next 5 bytes with (prevByte3). D5: Fill the next 6 bytes with (prevByte3). D6: Fill the next 7 bytes with (prevByte3). D7: Fill the next 8 bytes with (prevByte3). D8: Fill the next byte with (prevByte4). D9: Fill the next 2 bytes with (prevByte4). DA: Fill the next 3 bytes with (prevByte4). DB: Fill the next 4 bytes with (prevByte4). DC: Fill the next 5 bytes with (prevByte4). DD: Fill the next 6 bytes with (prevByte4). DE: Fill the next 7 bytes with (prevByte4). DF: Fill the next 8 bytes with (prevByte4). ------------------------------------------------------------------------------------------- For the following code: XX = 7F or FF will fill 128 bytes. E0 XX: XX = 00-7F: Repeat (XX + 1) bytes from 1 row above the current tile (0x80 previous in RAM). XX = 80-FF: Repeat (XX + 1) bytes from 2 rows above the current tile (0x100 previous in RAM). E1: Repeat 2 bytes from the previous row (0x80 previous in RAM). E2: Repeat 3 bytes from the previous row (0x80 previous in RAM). E3: Repeat 4 bytes from the previous row (0x80 previous in RAM). E4: Repeat 5 bytes from the previous row (0x80 previous in RAM). E5: Repeat 6 bytes from the previous row (0x80 previous in RAM). E6: Repeat 7 bytes from the previous row (0x80 previous in RAM). E7: Repeat 8 bytes from the previous row (0x80 previous in RAM). ------------------------------------------------------------------------------------------- For the following codes: XX = 7F or FF will fill 128 bytes. XX = 00-7F: use the lower prevByteN value (odd values) XX = 80-FF: use the higher prevByteN value (even values) IMPORTANT NOTE!: These functions CAN and DO collide with themselves. Take, say, E8 02; it repeats prevByte1, and then hits itself. So it gets prevByte1 again, and hits itself again... this isn't an infinite loop due to the behaviour of the argument - after XX + 1 (in this case, 3) bytes, it stops dead. Pretty nifty. E8 XX: Repeat the decompressed data from (prevByte1/2) forward, filling (XX + 1) spaces. E9 XX: Repeat the decompressed data from (prevByte3/4) forward, filling (XX + 1) spaces. EA XX: Repeat the decompressed data from (prevByte5/6) forward, filling (XX + 1) spaces. EB XX: Repeat the decompressed data from (prevByte7/8) forward, filling (XX + 1) spaces. EC XX: Repeat the decompressed data from (prevByte9/10) forward, filling (XX + 1) spaces. ED XX: Repeat the decompressed data from (prevByte11/12) forward, filling (XX + 1) spaces. EE XX: Repeat the decompressed data from (prevByte13/14) forward, filling (XX + 1) spaces. EF XX: Repeat the decompressed data from (prevByte15/16) forward, filling (XX + 1) spaces. ------------------------------------------------------------------------------------------- The first value filled for all of these codes is (prevByte1 + 1). F0 XX: Fill the next (XX + 1) bytes, the value incrementing with each byte. F1: Fill the next 2 bytes, the value incrementing with each byte. F2: Fill the next 3 bytes, the value incrementing with each byte. F3: Fill the next 4 bytes, the value incrementing with each byte. F4: Fill the next 5 bytes, the value incrementing with each byte. F5: Fill the next 6 bytes, the value incrementing with each byte. F6: Fill the next 7 bytes, the value incrementing with each byte. F7: Fill the next 8 bytes, the value incrementing with each byte. ------------------------------------------------------------------------------------------- If the codes breach the width value of the map, the following tiles are placed automatically on the next line. (Autowrap, in a sense.) ------------------------------------------------------------------------------------------- ERRORS IN THE POSTULATED COMPRESSION SCHEME ABOVE (mismatches between WRAM and prediction) ------------------------------------------------------------------------------------------- AREA ASSOCIATED TILE/TILES 2084=0x824 to 2084=0x824 (1 bytes) Elder's House door 2448=0x990 to 2448=0x990 (1 bytes) Potos northwest house door 2948=0xB84 to 2948=0xB84 (1 bytes) Potos west exit 3076=0xC04 to 3076=0xC04 (1 bytes) Potos west exit 3099=0xC1B to 3099=0xC1B (1 bytes) Potos bar door 3613=0xE1D to 3615=0xE1F (3 bytes) Hole to Mantis Ant's lair (event-based map change) 3741=0xE9D to 3743=0xE9F (3 bytes) Hole to Mantis Ant's lair (event-based map change) 3853=0xF0D to 3853=0xF0D (1 bytes) Potos item shop door 4882=0x1312 to 4882=0x1312 (1 bytes) Potos inn door 5409=0x1521 to 5410=0x1522 (2 bytes) Potos south exit