We have been analyzing the sources, trying to find some spots where we could optimize them, and we have been intrigued by a variable named ARM9_REG, in the MMU.h file.
It is a really huge array (16 MB). The thing is that we have tracked the accesses to that array in our Xbox port, and all the accesses seem to be made to really small directions. It even seems that decreasing the size of that array to, let's say, 2 MB, would be apparently safe, as we have not seen superior accesses.
This is really important for us, because having an extra amount of 14 MB of RAM in Xbox, could fix some really important things for us, like these ones:
* We could have savestates support!! (savestates currently don't work, because we don't have the needed free RAM to create the EMUFILE_MEMORY of the savestate)
* Several games that allocate memory over the time and don't free it (like Scribblenauts) are crashing now. With this extra RAM they could work now, or at least, they would be playable for a longer time.
So we are really interested in this matter, as decreasing that size (if possible) would be very helpful in the Xbox port. We guess that this variable is 16 MB because PC owners can afford that amount of RAM and nobody cared about decreasing it... Or is there anything that we have not seen in our beta tests, and we could have wrong behaviours?
Thank you very much; keep up with the good work!!
yes, arm9_reg is stupid. that whole array should not exist. there's no reason to keep it around.
the variable is 16MB because early on it easily 'fixed' a lot of games by allowing unknown registers to be read back after they were written to, without us having to emulate it.
Change it to 2MB if you want in your fork. The actual way to solve it is to remove all uses of it to store values and store them in nicely named variables instead.
Thank you very much for confirming that! After doing that change, we have more free RAM now, and I have been able to play Professor Layton during a long time without crashes! (it is one of those games where allocated RAM is increasing over the gameplay). It has been a very important improvement in the Xbox port!
On the other hand, I have to admit that I was too over-optimistic with the savestates matter: it seems that the EMUFILE_MEMORY object needs more memory than I thought (even if we don't save the WRAX, we still crash when we try to do it). So savestates support will have to wait. Anyways, this has been a very important step for us.
I know that in PC, RAM is not a critical matter, but if we are sure that this change is safe, maybe some day you can do it in the main Desmume project too...
Thank you very much!