+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  What would cause an SNES game to put a sprite outside of viewable space?
Pages: [1]
Author Topic: What would cause an SNES game to put a sprite outside of viewable space?  (Read 1 times)
Gideon Zhi
Guest
« on: March 20, 2010, 10:07:32 pm »

I've been tinkering with Tactics Ogre's day calendar sprite display crap, and I've finally almost gotten it working how I want it to. If the calendar is on the left hand side of the screen, everything displays fine! If it's on the right, six of the 8x8 sprites (three on each line) "vanish." A cursory examination of a savestate in VSNES shows that they're still displaying, but that they've jumped way outside of the screen's bounds - they're exactly 256 pixels away from where they should be (xpos 432 instead of 176.)

Now, if I look at the OAM table in WRAM, everything looks fine. Entry number 27 is A820 8B 2F and displays fune. Entry number 28 is B020 8C 2F and displays way off in nowhereland. So something's gotta be going on somewhere else, but damned if I know where. Any tips? Sad

March 20, 2010, 10:43:06 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Got it fixed. For whoever's interested, it turns out there's another part of OAM after the main 512-byte table which contains two bits per tile telling whether they're on-screen or off. Or something. Either way it works :p
« Last Edit: March 20, 2010, 10:43:06 pm by Gideon Zhi »
creaothceann
Guest
« Reply #1 on: March 21, 2010, 04:06:52 am »

Quote from: anomie's regs.txt
Code:
OAM consists of 544 bytes, organized into a low table of 512 bytes and a high
table of 32 bytes. Both tables are made up of 128 records. [...]

The record format for the low table is 4 bytes:
  byte OBJ*4+0: xxxxxxxx
  byte OBJ*4+1: yyyyyyyy
  byte OBJ*4+2: cccccccc
  byte OBJ*4+3: vhoopppN

The record format for the high table is 2 bits:
  bit 0/2/4/6 of byte OBJ/4: X
  bit 1/3/5/7 of byte OBJ/4: s

The values are:
  Xxxxxxxxx = X position of the sprite. Basically, consider this signed but see
      below.
  yyyyyyyy  = Y position of the sprite. Values 0-239 are on-screen. -63 through
      -1 are "off the top", so the bottom part of the sprite comes in at the
      top of the screen. Note that this implies a really big sprite can go off
      the bottom and come back in the top.
  cccccccc  = First tile of the sprite. See below for the calculation of the
      VRAM address. Note that this could also be considered as 'rrrrcccc'
      specifying the row and column of the tile in the 16x16 character table.
  N         = Name table of the sprite. See below for the calculation of the
      VRAM address.
  ppp       = Palette of the sprite. The first palette index is 128+ppp*16.
  oo        = Sprite priority. See below for details.
  h/v       = Horizontal/Vertical flip flags. Note this flips the whole sprite,
      not just the individual tiles. However, the rectangular sprites are
      flipped vertically as if they were two square sprites (i.e. rows
      "01234567" flip to "32107654", not "76543210").
  s         = Sprite size flag. See below for details.

The sprite size is controlled by bits 5-7 of $2101, and the Size bit of OAM.
$2101 determines the two possible sizes for all sprites. If the OAM Size flag
is 0, the sprite uses the smaller size, otherwise it uses the larger size.

vSNES uses unsigned values though instead of signed ones, so there are no negative values.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC