Originally Posted By Ensjo
I understand the concepts. I just don't get exactly what each section of code is doing. Tell me if I get it right:

This section of code just defines the possible ranges of memory. (It neither allocates memory for the banks, nor sets which bank is active.)

(Why does the range 0x2800~0x3fff is defined differently? It just says "AM_RAM", not "AM_RAMBANK(n)"? Is this how one defines a non-switchable range?)


Then... [url=http://git.redump.net/cgit....section of code under MACHINE_START defines the banks that can be active in each range of memory.

(Is this where the memory is actually allocated for each bank? By the way, I don't see any memory allocation for the non-switchable range 0x2800~0x3fff above.)[/quote]

Memory allocation for memory maps is handled entirely by the core. If you want to be able to access the storage area directly, supply an AM_BASE() parameter for that entry in the address map, like so:

At the top of the file:

static UINT8* ramarea;


AM_RANGE(start, end) AM_RAM AM_BASE(&ramarea)

When the driver is initialized, ramarea will be automatically updated to point to the internal memory region.

Originally Posted By Ensjo
The banks that will be active are selected by means of the memory_set_bank() function call.

Then comes the bankswitch function... I would expect it to use make a lot of memory_set_bank() function calls based on the state of the machine... but it calls a memory_install_readwrite8_handler() instead. What is the difference between both functions?

mc1000_bankswitch is called by the mc6847_attr_w and mc6845_ctrl_w write handlers. In mc1000_bankswitch, the majority of what it's doing is conditionally mapping or unmapping regions of memory depending on how much expansion memory is currently installed as well as what bank is being assigned to the MC6847 and MC6845 peripheral chips.

The installed read/write functions for SMH_BANK(1) and SMH_BANK(2) never appear to change, though, so it might be a good idea to move line 42 and line 45 to a DRIVER_INIT function. There are plenty of examples of how to use DRIVER_INIT in various drivers.