It is currently Wed Dec 13, 2017 9:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: 8x16 Sprites
PostPosted: Sat Mar 19, 2005 9:05 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
I really dont know how exactly memory is arranged in 8x16 sprites. I mean i know when to use ppu addr 0x0000 and 0x1000 but i have tested displaying sprites as the sprite Y as a whole two diferent chunk of 16 bytes, one for bit 0 and the other for bit 1.
This method didnt worked so i thought it was like the top half of the sprites was 0..7 and 16...23 and the lower half 8...15 and 24..31:

The second method worked a little, some sprites in Castlevania (player) looks fine, but for example the items dont show correctly.

im making the emulator scan line based so to obtain FineY for sprites i do:
SLNumber - Sprite.Y.

All this work for ok for 8x8 sprites, and i have emulated hflip and vflip too
but i cant find the problem in 8x16.

I know maybe i should put some code here, so it were easier to help me, but its a little large.

Any Suggestions?

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 19, 2005 10:30 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
If you're a C/C++ guy, here's some pseudo-code to give the idea:

Code:
tempY = (BYTE)(scanline - sprite_y);
if(temp < 16)  // sprite is in range
{
  if( Vertical_Flip_Flag_On )
    tempY ^= 0xF;

  tile_to_use = sprite_tile & 0xFE;
  if(tempY & 8)
    tile_to_use++;

  tempY &= 7;

  //draw line tempY using tile_to_use here
  // pattern table determined by (sprite_tile & 0x01)
}


For that in English:

The tile number to draw is the tile number in Sprite RAM with the low bit chopped off (since the low bit determines which pattern table to use). If you're drawing the lower half of the sprite (line 8+), you simply use the next tile in the pattern table.

The top half of an 8x16 sprite will always draw an even numbered tile.
The bottom half of an 8x16 sprite will always draw an odd numbered tile.

(Reverse those for a v-flipped sprite, since the bottom would be drawn on top)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 19, 2005 10:41 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
thx disch!!

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2005 9:58 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Dish i asking you again cos i cant make it to work. Could you explain it me in detail?

Thanks

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2005 12:03 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
8x16 sprites draw from two tiles. Tile "A" is drawn on top... and tile "B" is drawn on bottom.

The tile numbers for each tile are found through the sprite's tile ID number in Sprite RAM (hereon "ID").

The tile to use when drawing tile A is: (ID & 0xFE)
The tile to use when drawing tile B is: (ID & 0xFE) + 1 -or- (ID | 0x01)

The pattern table to use (ppu $0000 or $1000) is determined by (ID & 0x01). Bit 3 of $2000 does not matter when using 8x16 sprites.


Vertically flipping works as expected -- tile B is drawn on top of tile A, and both tiles are flipped vertically.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 12:14 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
thx disch now it works ok :D

_________________
ANes


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group