I'm trying to figure out how registers FF4C and FF6C work in order to emulate them better in SameBoy. These registers are related to DMG emulation on a CGB.
Here's what I already know about these two:
As an experiment, I modified one of my test ROMs to use %11100100 as its DMG BG palette. This means that it in DMG mode, it will display in inverted colors. I also gave it the capability to (try to) modify registers FF4C and FF6C in runtime. The results were disappointing: writing 04 or 80 to register FF4C did not toggle DMG mode. Writing 0/1 to FF6C did affect the value read from that register, but nothing else. This pretty much confirms FF4C is not readable or writable after booting.
And there comes that real surprise. I assumed that bit 2 had an effect on DMG emulation, and since that value is controlled by my ROM when it boots, I tried making the CGB boot write C4 to FF4C instead of the usual C0; expecting it to run the game in DMG mode. But after I booted the modified ROM – the Gameboy displayed absolutely nothing! The ROM was still running indeed, as my button presses did generate sounds as expected, but the screen was completely blank.
I have yet to run any tests on other values for this register.
Does anyone have any other information on these two registers? Does FF6C really do nothing? Any idea about what the specific bits of FF4C do, and why does writing C4 to that register make the screen blank?
Waiting for your insights.
Here's what I already know about these two:
- The CGB boot ROM considers a game a CGB "enabled" game if bit 7 is on in byte 143.
- If the game is a CGB enabled game, 1 is written to register FF6C; otherwise it remains as 0.
- FF6C is readable and writeable in all states; its mask is FE, so only bit 0 is accessible.
- If the game is a CGB enabled game, the value of 143 is written to register FF4C; otherwise, 04 is written. This means it is possible to make the boot ROM write any value in the range 80-FF, as well as 04, to this register.
- It appears that by the time the boot ROM has finished running, register FF4C is locked. It can't be written anymore, and can't be read anymore (returns FF).
- I have failed to find the effect of register FF6C, despite it being writable freely after boot.
- This means that register FF4C is extremely likely to be the register that controls enabling the following compatibility features:
- Alternate OAM sprite ordering
- Taking BGP/OBP0/OBP1 into account when applying colors to tiles.
- Accessibility of registers SVBK, VBK and KEY1. (They're not writable or readable in DMG mode)
As an experiment, I modified one of my test ROMs to use %11100100 as its DMG BG palette. This means that it in DMG mode, it will display in inverted colors. I also gave it the capability to (try to) modify registers FF4C and FF6C in runtime. The results were disappointing: writing 04 or 80 to register FF4C did not toggle DMG mode. Writing 0/1 to FF6C did affect the value read from that register, but nothing else. This pretty much confirms FF4C is not readable or writable after booting.
And there comes that real surprise. I assumed that bit 2 had an effect on DMG emulation, and since that value is controlled by my ROM when it boots, I tried making the CGB boot write C4 to FF4C instead of the usual C0; expecting it to run the game in DMG mode. But after I booted the modified ROM – the Gameboy displayed absolutely nothing! The ROM was still running indeed, as my button presses did generate sounds as expected, but the screen was completely blank.
I have yet to run any tests on other values for this register.
Does anyone have any other information on these two registers? Does FF6C really do nothing? Any idea about what the specific bits of FF4C do, and why does writing C4 to that register make the screen blank?
Waiting for your insights.