convenient-to-manipulate sprite size format

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

convenient-to-manipulate sprite size format

Post by jeffythedragonslayer »

In main.s of tepples' LoRom template I found:

Code: Select all

; Mark remaining sprites as offscreen, then convert sprite size
; data from the convenient-to-manipulate format described by
; psycopathicteen to the packed format that the PPU actually uses.
Where can I find this format described?
User avatar
NovaSquirrel
Posts: 483
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: convenient-to-manipulate sprite size format

Post by NovaSquirrel »

Here's the code that packs it from the convenient format to the native format.

Inferring from that code, the convenient format is just this:

Code: Select all

???????? 000000SX ???????? ????????
               ||
               |+------------------ Additional X position bit
               +------------------- Size bit
Each sprite takes up four bytes and three of them are not used. The whole table takes 512 bytes just like the main one.

The advantage here is that OAM+1 and OAMHI+1 refer to the same sprite, same for OAM+5 and OAMHI+5 and so on. This means you can use the same index to write to both of them.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: convenient-to-manipulate sprite size format

Post by jeffythedragonslayer »

Thanks, so

Code: Select all

000000SX
contains left-zero-padded bits that will go into the OAM high table as described in: https://snes.nesdev.org/wiki/OAM_layout
Post Reply