It is currently Tue May 23, 2017 9:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jan 17, 2007 10:11 pm 
Offline

Joined: Fri Jul 29, 2005 3:40 pm
Posts: 345
Location: near chicago
how and when do i invert sprites vertically ? (sprite_attribute & 0x80)

matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 10:30 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
When the sprite is evaluated -- the attributes are fetched first to see if they're to be flipped vertically.

The 'normal' CHR is determined by the subtraction of the current scanline and the sprite Y coord (also used to determine whether or not the sprite is in-range). Ex:

Code:
u16 is_in_range = current_scanline - sprite_Y;
if(is_in_range < 8)
{
  // sprite is in range
  //  fetch CHR according to is_in_range
  //  ie:  if is_in_range == 5, CHR comes from $xxx5 and $xxxD
}


To flip vertically -- simply XOR is_in_range with $7 (8x8 sprites) or $F (8x16 sprites) after the sprite is found to be in range.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 10:24 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
In case anyone misses it, Disch is using a trick of unsigned values in the comparison with 8. These are equivalent:
Code:
unsigned n = current_scanline - sprite_y;
if ( n < 8 )
    ...

int n = current_scanline - sprite_y;
if ( n >= 0 && n < 8 )
    ...

This works because a negative value converted to unsigned becomes a large positive value. It's a good trick to learn.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 3:27 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 2988
Location: Brazil
There's a detail which I handle inside the own rendering core: the PPU clipping. So, instead of ">= 0" I use ">= ppu_clip_sprites", 0 or 8.

_________________
Zepper
RockNES developer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 9:29 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
I think you're mixing up sprite clipping with in-range evaluations.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 5:49 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 2988
Location: Brazil
I guess so... :lol:
Anyway, thanks for the unsigned tip.

_________________
Zepper
RockNES developer


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: No registered users and 3 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