Where in the memory map ($0000-$ffff) does the Gameboy address the memory of these accessories? (for example, the battery or the Gameboy Printer). Is this something I should implement in an emulator?
How does the Gameboy address external hardware?
By mapping it in
Where in the memory map ($0000-$ffff) does the Gameboy address the memory of these accessories?
In general all decoding is external. The address decoding looks basically like this
- 0000h..00FFh - 256 Byte Boot-ROM - gets paged out.
- 0000h..7FFFh - ROM area usually handeled as two blocks
- 0000h..3FFFh - 16 KiB fixed game ROM (page 0)
- 4000h..7FFFh - 16 KiB swappable game ROM (page 1..n)
- 8000h..9FFFh - 8 KiB Video RAM (don't forget to take care of the memory configuration about sprites, BG, etc.)
- A000h..BFFFh - 8 KiB External RAM area
- C000h..DFFFh - 8 KiB Internal RAM
- For a Colour Game Boy this 8 KiB get split in two 4 KiB regions with the second being banked.
- E000h..FDFFh - 7.5 KiB unassigned (mirroring the RAM). Some games DO use it with externam RAM.
- FE00h..FEFFh - 256 Byte OAM RAM - Object Attribute Memory (Video/Sprites)
- FF00h..FF7Fh - 128 Bytes I/O area
- FF80h..FFFFh - HRAM
So in general the first 32 KiB and the 8 KiB at C000h can be used for external RAM - and many pages (banks) thereof. And here it gets tricky as all decoding (for cartridges) is done external. So next to any combination using the address ranges 0000h..7FFFh and A000h..BFFFh can be used for RAM/ROM and being banked as well.
To control the behaviour and mapping usually access to certain ROM location is used. Luckyly most games one of the standard memory controllers. thus the combinations are rather known.
But there is nothing that prevents games to work otherwise. In addition some games do use the 7.5 Kib starting in E000h as well (by ignoring /CS).
for example, the battery or the Gameboy Printer
I'm not so sure what you want to control with the battery, but the printer is handled via the serial link. Usually looking at the memory controllers is again a good idea to see the workings of either expansion using them. For example the contoler used with the camera is basically a MBC3, mapping the CCD into the RAM area, much like a RAM bank.
Is this something I should implement in an emulator?
Depends what you want to emulate.
(Did I mention that creating an emulator is an endless task of always being surprised when discovering a new way some game is handling it's resources)