RIP-Comm / clementine

Gameboy Advance emulator.
MIT License
49 stars 13 forks source link

Move `Lcd` out of `InternalMemory` #210

Closed AlessioC31 closed 1 year ago

AlessioC31 commented 1 year ago

The idea of this PR is to propose a new way to manage memory and hardware components. Before we had everything under InternalMemory but every field was just containing registers. This is not suitable now that we approach implementing the LCD since it has also its login instead of just a bunch of registers.

Also, having everything under InternalMemory was not "semantically" correct in my opinion, hardware components are external components to the CPU.

If we agree with this type of refactoring, we would also get rid of the IORegister struct which is useless at this point. I added it many months ago to try to handle read/write access through it but then we saw that it was not possible.

To manage read/write access we could do something like this:

I also changed a bit the read/write functions in Bus. Now we have write_raw and read_raw that map every address to the correct component and we have wrappers like read_word, write_word, read_half_word, etc... that should calculate how many wait cycles the CPU has to be stopped (depending on wait cycles and bus width of the component).

AlessioC31 commented 1 year ago

LGTM, left a couple of comments... Also we should consider the trait pub trait IoDevice { Is this still useful? Or should we change it?

Thanks, I think that once we move to this new approach the IoDevice trait will be unused