Question about Offset per Tile mode on Chrono Trigger

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Question about Offset per Tile mode on Chrono Trigger
by on (#173979)
I've been coding a SNES emulator for a few weeks, and ended with some problems related to the Offset-per-Tile mode. The only doc I found that explains how it works was Anomie registers doc. I made a implementation pretty much like it was show on the pseudocode. The first weird thing I noticed is that anomie says on the doc that the Horizontal Offset from BG3 is supposed to replace the Horizontal Offset of the current BG1/2 background, but this way the name "Trigger" on the Chrono Trigger intro gets stuck at the left side of the screen, because the HOfs value from BG3 table is always zero, but it works perfectly if I use the HOfs of the current background.

My biggest doubt through, is related to the in-game menu on Chrono Trigger. This image shows the issue:
Image
On the left image, I have offset per tile enabled, the icons are on the correct positions, but the texts aren't. With offset per tile disabled, what happens is the exact opposite. The icons get messed up, but the texts are on their correct positions. After some investigation, I figured that the game uses HDMA to change the VScroll registers from BG1 and BG3 mid-frame, and this is what places the texts on their correct positions. But at the same time, this also messes up the icons. When the offset-per-tile mode is enabled, the VScroll register on BG1 is ignored, this way the icons remain on their correct position, but the texts are no longer affected by the reg changes on HDMA, and the text is forced to have this one-tile gap.

So what I would like to ask, is that if anyone knows how CT does this effect. It doesn't seem to do any mode changes mid-scanline, so it is probably something related to the offset-per-tile mode, maybe it someway can use the VScroll register even with it enabled.
Re: Question about Offset per Tile mode on Chrono Trigger
by on (#173981)
gdkchan wrote:
I've been coding a SNES emulator for a few weeks, and ended with some problems related to the Offset-per-Tile mode. The only doc I found that explains how it works was Anomie registers doc. I made a implementation pretty much like it was show on the pseudocode. The first weird thing I noticed is that anomie says on the doc that the Horizontal Offset from BG3 is supposed to replace the Horizontal Offset of the current BG1/2 background, but this way the name "Trigger" on the Chrono Trigger intro gets stuck at the left side of the screen, because the HOfs value from BG3 table is always zero, but it works perfectly if I use the HOfs of the current background.


It sounds like you aren't handling the enable bits correctly. Each entry in the BG3 offset table only applies to BG1 if bit 0x2000 of the entry is set, and only applies to BG2 if bit 0x4000 is set. If the respective bit is zero, then that column in that layer uses the regular scroll register instead.
Re: Question about Offset per Tile mode on Chrono Trigger
by on (#173985)
AWJ wrote:
gdkchan wrote:
I've been coding a SNES emulator for a few weeks, and ended with some problems related to the Offset-per-Tile mode. The only doc I found that explains how it works was Anomie registers doc. I made a implementation pretty much like it was show on the pseudocode. The first weird thing I noticed is that anomie says on the doc that the Horizontal Offset from BG3 is supposed to replace the Horizontal Offset of the current BG1/2 background, but this way the name "Trigger" on the Chrono Trigger intro gets stuck at the left side of the screen, because the HOfs value from BG3 table is always zero, but it works perfectly if I use the HOfs of the current background.


It sounds like you aren't handling the enable bits correctly. Each entry in the BG3 offset table only applies to BG1 if bit 0x2000 of the entry is set, and only applies to BG2 if bit 0x4000 is set. If the respective bit is zero, then that column in that layer uses the regular scroll register instead.

This was exactly my problem! I was testing the enable bits correctly, but I forgot to reset the value of my Y Position variable with the ScanLine + VScrollReg when the flag was cleared, so it was using the old value again. Fixed that now and the menu looks good!
Image

I'm really thankful to you for poiting me into the right direction. Also this is the first forum that was actually able to help me, so thanks again.

It's ok if I post more questions that I may have on this thread too?
Re: Question about Offset per Tile mode on Chrono Trigger
by on (#173993)
gdkchan wrote:
It's ok if I post more questions that I may have on this thread too?

If they're about offset-per-tile, yes. If not, please open separate threads for separate subjects. I know that might be inconvenient, but the information here is public and beneficial to the dev world. It's very hard to follow a big long thread covering several subjects.