While trying to port my homebrew remake of the BatteryCheck platform game to the DS I am patching the code to work around the limitations. One thing that is going to be required though is A LOT of memory to convert graphics on the DS itself. The reason I need to do this has to do with the license of the original game and that I do not own the graphics. The lowest memory usage I have measured was around 16-20MB but that was on my PC running in Linux using special tools. For the DS I also need to resize the graphics which lowers the required RAM quite a bit I think, but I still need to load the original in RAM first and allocate a second buffer to store the results in.
I have been reading a lot of examples and trying so many things to make use of the official "Memory Expansion Pak" and the "SuperCard miniSD" which both need a unlock sequence to make them writable in the GBA ROM space. It took me a while to figure out this was not working because I forgot to set the ARM9 as the SLOT-2 owner but after that it worked great! Or at least so I thought. I wrote a tiny 512 byte palette buffer into the external RAM and used DMA to copy it into VRAM. The bitmap was still stored in main ram though so I changed a few things to move that into external RAM too, and to make sure that worked I had to find a way to test it on an emulator. While desmume-cli is not perfect by any means it's what allows me to specify an R4 card with directory containing files and in the source I found the Memory expansion pak emulation option, except no way to enable it! Some digging was required to figure out it only selects the 8MB RAM in SLOT-2 when the opera ROM is loaded! So to be able to test my builds I modded the source to always enable it no matter what! And hey, it works!......except on real hardware
After many trial and error I think I have found the issue but hopefully some of you here know more about it. I think SLOT-2 can only be read and/or written in 16 bit mode! I know it's a 16bit bus ofcourse but hoped the hardware would just do it's magic in working out if I request the high or low byte. My earlier test worked with a uint16_t array so that was no problem. I wrote a small memory tester that writes a few numbers looping though an uint8_t array and it kept failing on hardware. In my modded desmume it worked fine! Until I made it an uint16_t array, and now it works on hardware too!!! While I am happy it works and for my own code I might be ok with this limitation, I also need to use zlib to decompress the original game files. And it's ZLIB that is giving me a ZLIB_DATA_ERROR each and every time I give it buffers located in external RAM.
So my question is: Does the external memory interface ONLY work in 16bit mode or do I need to setup some register to allow 8bit read and write to it?
I have been reading a lot of examples and trying so many things to make use of the official "Memory Expansion Pak" and the "SuperCard miniSD" which both need a unlock sequence to make them writable in the GBA ROM space. It took me a while to figure out this was not working because I forgot to set the ARM9 as the SLOT-2 owner but after that it worked great! Or at least so I thought. I wrote a tiny 512 byte palette buffer into the external RAM and used DMA to copy it into VRAM. The bitmap was still stored in main ram though so I changed a few things to move that into external RAM too, and to make sure that worked I had to find a way to test it on an emulator. While desmume-cli is not perfect by any means it's what allows me to specify an R4 card with directory containing files and in the source I found the Memory expansion pak emulation option, except no way to enable it! Some digging was required to figure out it only selects the 8MB RAM in SLOT-2 when the opera ROM is loaded! So to be able to test my builds I modded the source to always enable it no matter what! And hey, it works!......except on real hardware
After many trial and error I think I have found the issue but hopefully some of you here know more about it. I think SLOT-2 can only be read and/or written in 16 bit mode! I know it's a 16bit bus ofcourse but hoped the hardware would just do it's magic in working out if I request the high or low byte. My earlier test worked with a uint16_t array so that was no problem. I wrote a small memory tester that writes a few numbers looping though an uint8_t array and it kept failing on hardware. In my modded desmume it worked fine! Until I made it an uint16_t array, and now it works on hardware too!!! While I am happy it works and for my own code I might be ok with this limitation, I also need to use zlib to decompress the original game files. And it's ZLIB that is giving me a ZLIB_DATA_ERROR each and every time I give it buffers located in external RAM.
So my question is: Does the external memory interface ONLY work in 16bit mode or do I need to setup some register to allow 8bit read and write to it?
Last edited by Archerite,