Offset Per Tile

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
Kaisha
Posts: 14
Joined: Mon Apr 26, 2021 9:06 am

Offset Per Tile

Post by Kaisha » Sat May 15, 2021 5:58 am

I'm working on implementing OTP and well... I'm just not sure of a lot of the details.

I've read through https://wiki.superfamicom.org/backgrounds, Book1.pdf (of the official docs), and even found this forum thread: viewtopic.php?f=12&t=12396. They've all provided some insight, but still there are things I am unsure of.

When we combine the vertical/horizontal offset, does it replace the vertical/horizontal scroll (from the background scroll registers) for that tile or is it added to it?

If the left most tile is ignored/doesn't use OTP, does that mean the 0'th entry in BG3 is also ignored? Or does it correspond to the 1st tile (skipping the 0th tile)?

If the BG being offset and BG3 are different tile sizes what happens (like when BG1 is 8x8 and BG3 is 16x16, or when BG1 is 16x16 and BG3 is 8x8)?

AWJ says that BG3 can be scrolled using the usual background scroll registers, if they aren't scrolled by a multiple of 8/16 (depending on tile size) what happens? Round down? Up?

If BG3 is scrolled off the 'end' does it wrap?

The official docs say (pg. 208):

In the case of H-OFFSET, the data (D0 ~ D2) will be invalid.
In the case of the character (16x16), "D3" is effective every 3rd.

Ermm... WTF are they trying to say?

lidnariq
Posts: 10646
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Offset Per Tile

Post by lidnariq » Sat May 15, 2021 11:05 am

Kaisha wrote:
Sat May 15, 2021 5:58 am
When we combine the vertical/horizontal offset, does it replace the vertical/horizontal scroll (from the background scroll registers) for that tile or is it added to it?
Added.
If the left most tile is ignored/doesn't use OTP, does that mean the 0'th entry in BG3 is also ignored? Or does it correspond to the 1st tile (skipping the 0th tile)?
The latter.
AWJ says that BG3 can be scrolled using the usual background scroll registers, if they aren't scrolled by a multiple of 8/16 (depending on tile size) what happens? Round down? Up?
Down (i.e. truncated)
If BG3 is scrolled off the 'end' does it wrap?
Only left/right. The OPT nametable doesn't advance vertically.
In the case of H-OFFSET, the data (D0 ~ D2) will be invalid.
The horizontal OPT mode can only scroll a tile to "whole tile" quanta; there's no fine X scrolling every 8 pixels.

You may also find my OPT demo: viewtopic.php?p=174494#p174494
and my photo of hardware: viewtopic.php?p=240256#p240256
useful reference.
The actual purpose was demonstrating modes 0-6, and I only demonstrated vertical OPT in modes 2,4,6. Also note that I changed the locations of the (unmoving) sprites; you can ignore them.

Kaisha
Posts: 14
Joined: Mon Apr 26, 2021 9:06 am

Re: Offset Per Tile

Post by Kaisha » Sat May 15, 2021 3:43 pm

Very much appreciated.

Any thoughts on what happens when the backgrounds are difference tile sizes?
Only left/right. The OPT nametable doesn't advance vertically.
So we ignore BG vertical scroll when using OPT?

In the thread I linked AWJ says:
It is a tilemap in most respects; the PPU just ignores the electron beam position when deciding what row of it to read. Other than that, it is affected by all the registers that affect BG3. If you set BG3 to use 16x16 tiles then the scroll columns will have 16-pixel granularity instead of 8-pixel (for all the use that is...). Changing the BG3 scroll registers changes exactly where in VRAM the table gets fetched from (this is how you do raster splits; you can't overwrite the offset table in mid-frame because it's in VRAM and the CPU can't access VRAM outside of VBlank, but you can upload several tables during VBlank and then switch between them by HDMAing to the BG3 scroll registers)

lidnariq
Posts: 10646
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Offset Per Tile

Post by lidnariq » Sat May 15, 2021 4:33 pm

Kaisha wrote:
Sat May 15, 2021 3:43 pm
So we ignore BG vertical scroll when using OPT?
No, it sets the row containing the OPT data (or the top of the two rows containing OPT data). The demo I made and linked uses HDMA to change the starting Y to be able to use the same nametable for modes 2 and 6 (which have two rows of OPT data: one horizontal and one vertical) and mode 4 (which only has one row of OPT data). This is exactly what AWJ was talking about:
you can upload several tables during VBlank and then switch between them by HDMAing to the BG3 scroll registers)

Kaisha
Posts: 14
Joined: Mon Apr 26, 2021 9:06 am

Re: Offset Per Tile

Post by Kaisha » Sat May 15, 2021 4:37 pm

I think I found the relevant info in the anomie docs.

*edit: And thank you for the clarification :)

Post Reply