gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > GB emulator Memory Mmanagement

#91507 - thegamefreak0134 - Fri Jul 07, 2006 5:24 pm

Hello all. (been a while, no internet.) I have been working on the basics for a regular old GB emulator, just to brush up on the skills so I can work on something much more challenging, like the DS. Anywho, a whole three supported opcodes in, I am starting to have concerns.

The GB has the wierdest memory management I've ever seen. (remember, it's the only one I've seen as well.) All memory is accessed through one 16-bit number from 0000 to FFFF, but certain areas of it represent cart memory, certain areas of it represent external RAM/accessories. Also, there are lots of areas that represent registers, and many of those can only be accessed at certain times or cannot even be accessed at all.

The cart memory I think I can handle alright by putting a catch in there that checks any memory requests and simply loads the appropriate cart location (or writes it) instead. My real concern is how to go about enabling/disabling different parts of the memory. I realise that most games will check the appropriate registers and avoid this anyway, but it still needs to be done.

I am in Visual Basic .NET, which I have concluded will be more than fast enough for the job. I also have a lot of the main things like video routine and such covered, and a nice fast system for finding and eecuting the proper commands. What I need to know is, from experience, what is the best way to either block memory from changing, (in an array, mind you) or quickly copy it out and replace it. I do not yet kno how to overwrite only a part of an array without a loop of some sort. Any help here would be greatly appreciated.

-gamefreak
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#91512 - tepples - Fri Jul 07, 2006 5:44 pm

thegamefreak0134 wrote:
The [Game Boy] has the wierdest memory management I've ever seen. (remember, it's the only one I've seen as well.) All memory is accessed through one 16-bit number from 0000 to FFFF, but certain areas of it represent cart memory, certain areas of it represent external RAM/accessories. Also, there are lots of areas that represent registers, and many of those can only be accessed at certain times or cannot even be accessed at all.

This is typical of any computer system.

Quote:
The cart memory I think I can handle alright by putting a catch in there that checks any memory requests and simply loads the appropriate cart location (or writes it) instead.

The GB/GBC memory space is divided largely into eight memory regions each 8 KiB in size: five for the cart (0x0000, 0x2000, 0x4000, 0x6000, 0x8000), and three for the hardware itself (0xA000, 0xC000, 0xE000). Only for the last of the eight will you have to do complicated decoding, as it's where all the I/O registers lie.

Quote:
My real concern is how to go about enabling/disabling different parts of the memory.

That's a mapper issue.

Quote:
I am in Visual Basic .NET, which I have concluded will be more than fast enough for the job.

It should, given that it uses the same compiler back-end as Microsoft's C# compiler, on which Microsoft was briefly betting the proverbial farm.

Quote:
What I need to know is, from experience, what is the best way to either block memory from changing, (in an array, mind you) or quickly copy it out and replace it.

Pointers. Lots of pointers. (In the case of VB, it might be called "references to arrays.") See the NES emulator development guides on nesdev.

Quote:
I do not yet kno how to overwrite only a part of an array without a loop of some sort.

The machine will execute loops anyway.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.