It is currently Thu Nov 23, 2017 5:13 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Aug 21, 2016 8:36 am 
Offline

Joined: Sun May 10, 2015 5:01 pm
Posts: 4
I'm having issues figuring out how to handle tile flipping (byte 2 of sprite OAM memory).

Consider if the bit is set to flip a sprite horizontally and its an 8x8 tile at 0,0 that looks like this (for simplicity):

Code:
a 0 0 0 0 0 0 b
e 0 0 0 0 0 0 f
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
c 0 0 0 0 0 0 d


Would a horizontal flip result in this? My rationale is that it flips in the middle, on a "horizon" as the pivot point.

Code:
c 0 0 0 0 0 0 d
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
e 0 0 0 0 0 0 f
a 0 0 0 0 0 0 b


For a vertical flip, same idea:

(Original)
Code:
a 0 0 0 0 0 0 b
e 0 0 0 0 0 0 f
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
c 0 0 0 0 0 0 d



(Vertical flip bit set)
Code:
b 0 0 0 0 0 0 a
f 0 0 0 0 0 0 e
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
d 0 0 0 0 0 0 c


Does any of this look right? Its rendering terribly in my emulator so I'm guessing I'm not interpreting this correctly.


Top
 Profile  
 
PostPosted: Sun Aug 21, 2016 8:54 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3951
You have 'horizontal flipping' and 'vertical flipping' switched in your post.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun Aug 21, 2016 9:18 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
Location: Brazil
Code:
unsigned int vsize = (ppu_2000 & 0x20)? 0x0F: 0x07;

         /* attributes */
         attrib = sprites[2];
         /* horizontal position +flip
          */
         if(attrib & 0x40)
            xcomp ^= 7;

         /* vertical position +flip
          */
         drawline = (current_scanline - 22 - sprites[0]) & 0x0F;
         if(attrib & 0x80)
            drawline ^= vsize;


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 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