pandocs icon indicating copy to clipboard operation
pandocs copied to clipboard

Description of FF6Ch

Open mattrberry opened this issue 3 years ago • 10 comments

I recently learned here from @mattcurrie what the FF6C register is meant to represent in CGB mode. I thought it might be good to know and to document!

The "Object Priority Mode" is referring to bit 0 of $FF6C. This register is set by the CGB boot ROM to toggle between CGB object priority (prioritise by OAM position) and DMG object priority (prioritise by X coordinate):

https://github.com/ISSOtm/gb-bootroms/blob/master/src/cgb.asm#L23

mattrberry avatar Jul 13 '20 01:07 mattrberry

Sure! FF6C is currently listed under the "Undocumented CGB register". Do you want to open a PR for this?

avivace avatar Jul 13 '20 10:07 avivace

I'll happily open a PR today! I have no way to test anything more detailed though since I don't have a flash cart :/

mattrberry avatar Jul 13 '20 15:07 mattrberry

@mattrberry Sounds good to me! ISSOtm's bootroms are a reliable source and at least knowing what those registers are about is a great improvement. Let me know if you need help on anything :smile:

avivace avatar Jul 13 '20 16:07 avivace

I'll be happy to test this on hardware

leefogg avatar Jul 15 '20 22:07 leefogg

IIRC, bit 0 remains readable and writable after the boot ROM has finished, but no longer has any effect.

mattcurrie avatar Jul 15 '20 22:07 mattcurrie

AIUI, the bit is always writable, and is copied until or latched by the FF50 (BANK) write.

ISSOtm avatar Jul 15 '20 22:07 ISSOtm

Can we test if it has any effect after the boot ROM loading?

avivace avatar Jul 16 '20 10:07 avivace

If I can get a spec of how we think it will work after the boot ROM. I'll make a test ROM

leefogg avatar Jul 22 '20 19:07 leefogg

These apply after the boot ROM has finished:

  • For CGB running in DMG mode, it should read $FF and reads and writes are ignored.
  • For CGB running in CGB mode, the initial value is $FE and bit 0 is readable and writable, but it has no effect on object priority mode.

mattcurrie avatar Jul 22 '20 21:07 mattcurrie

Writes to FF6C have an affect after the boot ROM finishes executing if you're running in PGB mode (FF4C was written 0x80 or 0xC0), and STOP hasn't been executed yet. But you're effectively running in DMG mode with random sprite palettes and white BG palettes during that time.

LIJI32 avatar Jul 22 '20 21:07 LIJI32

Fixed by #45

ISSOtm avatar Sep 28 '23 22:09 ISSOtm