Here’s what I did to accomplish this.
1. Using Geiger’s Snes9x
I figure, it doesn’t matter that the game compresses images. At some point the game has to decompress these images and send the tiles to vram. So I logged the cpu during where the image is loaded. There is a section in RAM that holds decompressed images right before being sent with dma. So I also logged dma, and found two instances of reads from ram. One for size 0x6400 (the title screen tiles) and one for size 0x700 (the tile map to be used). Using Geiger’s, I was able to do a dump (or save ram contents externally). I dumped both the tiles and tilemap. If I look at the tiles in tlp, I see this .
You can KINDA see the words there.
Using the cpu log, I was able to figure out where the cpu pointed to ram and said, “Hey! Your image is here!” I changed that pointer to somewhere in ROM and pasted my tile dump there.
2. Using C#
C# is my programming language of choice. Here is where I manipulated those tiles so I could reorganize them. Ultimately, 3 files were used. A vanilla dkc2 ROM, my tile dump, and my tilemap dump. The main idea is to organize tiles the way ROM does. This required the tilemap. Tiles are only so good. You need the tilemap to arrange them. So, to start, I broke down my tile dump into 0x20 byte chunks. A 4bpp tile is just 0x20 bytes. I organized similar to how the ROM and vram does it. Afterwards, I looped through the tilemap creating a new tile for each index, being careful if in the tilemap bit 14 or 15 were on (14 signifies x flip, 15 y flip). If they were, I applied a Flip4000 (for bit 14) or Flip8000 (for bit 15). In that loop, I created a new tilemap, since the old one wouldn’t be valid.
After reorganizing, I applied both to free space in ROM. Looking at these tiles in tlp, I see .
A much easier way to modify! But there is still more to do!
3. Back to cpu!
Back to the cpu, those dma calls from before. By default, 0x7f is loaded in X and 0 is loaded in A. (X << 16) | A represents a 24-bit pointer to data, or X is bank, A is 16 bits. Y is loaded with the size. So, what used to be 0x6400 before was now 0x7000. That’s because we are using a different tile for each space, rather than the original, which reused but transformed some.
Here are the exact numbers I used
Spoiler!
This likely hasn’t been implemented before as this requires A LOT of space. Expanding your ROM is likely the best option here.
Kingizor, can you please link your compressed image doc