Hi Tom, today I tried to change some graphics and I was able to do some stuff:
To this particular example I used Hiei- advice of using the decompressed graphics from Vram. So I got the graphic and edited it using photoshop (you can see some artifacts in the logo. I' m not a graphics editor and I did this edtion very fast).
The problem was the reinsertion, because the SPC7110 has 3 algorithms, and they are a little complex to understand and to create a compressor in a short time, at least for me.
So I studied the SPC7110 and tried some approachs.
1-) After some study I found that the SPC7110 put the decompressed data in $50:0000. So the game asks the chip to decompress the graphics and after the decompression is done it reads from $50:0000 and, after some work, send to Vram (more of that later).
So my first approach was, after the chip decompression (we can know when the data is ready), to overwrite the decompressed data in $50:0000 with my new translated graphics. This way the game should work as usual but showing the new graphics, and the solution would be very simple.
But seems that writing to $50:0000 is not allowed, at least in Bsnes. I tried to change Bsnes code to allow this write but it is cheating, so I gave up this idea. But I don't know if the real chip doesn't allow this writing to $50:0000, or if it was a Byuu's decision, assuming that it's not the supposed way to work.
So this approach didn't work.
2-) My next approach was find some register inside SPC7110 that allowed a "uncompressed mode". After some read I found that $480b could do the job, at least according to no$cash and neviksti:
480Bh - Decompression Mode
00 - manual decompression, $4800 is used to read directly from the data rom
02 - hardware decompression, decompressed data is mapped to $50:0000,
$4800 can be used to read sequentially from bank $50
Seems that Feoez only uses $02 to $480b, so I tried to use this $00 mode, but Bsnes v086 doesn' t implement this behaviour. I searched in the last Higan version and seems that $480b is used in some places, but for what I understood it's not related to this "uncompressed mode" we was looking for. Again, I don' t know if it's still an unsuported feature that could work on the real chip.
3-) My last approach was to change the code that send the decompressed data to Vram and change it to send my translated graphics. After some debugging I saw that the game uses some kind of DMA queue, and in some moment it sends the data to Vram in blocks of 0x20 bytes.
So first I changed the routine that send the decompression command to SPC7110. In the beggining of this function we have some kind of pointer to the compressed graphics, and this pointer the game sends to the chip. So if the pointer is the intro logo pointer I set a flag in some Ram position (I had to find some unused Ram space, but it's just for now). With this flag enabled I changed the DMA queue routine to send my data, instead of the SPC7110 decompressed data, to Vram, based on this flag.
This way I could take this picture with the graphics inserted.
This worked, but I faced a lot of problems.
a-) I had to find a unused Ram space, specifically 3 bytes. The region I used ($7ffff0) was unused in the part I tested, but who knows if later in the game this region is used. I tried to use Sram, but the Sram usage is weird because you have to set a register to map the Sram, and seems that this change broke the memory map when I tried to use.
b-) The tile order of the decompressed graphics isn' t in the same order when it is sent to Vram. So I had to reorder the tiles in the image to show it properly.
c-) My last solution doesn' t have a big impact in timing because I'm only changing the Dma address by a new address, so the only impact is my new code. But I don' t know if "not using the uncompressed data" could do some harm in some situations, because inside SPC7110 there are some counters that are decremented when you read the data through $4800. But seems to work as far I can tell.
d-)The SPC7110 has 3 compression modes, and seems that the game follows different paths based on the mode. So I only changed the mode used by this intro logo.
And that is it Tom. I hope you enjoyed. But don't think I can work in this game. My romhacking skills are only intermediary. I'm not an experienced romhaker like LostTemplar and Ddtranslation, even less a guru like Byuu and Nightcrawler. And I'm working in other projects right now. I did this little debugging only for fun and as a proof of concept showing that we can change the graphics in this game. The idea is encourage other people to work on this game.
PS: I can share my code and feel free to ask any details if you (or you team) need.