News: 11 March 2016 - Forum Rules

Author Topic: Sprite Mirroring Issue *SOLVED*  (Read 1808 times)

justin3009

  • Hero Member
  • *****
  • Posts: 1660
  • Welp
    • View Profile
Sprite Mirroring Issue *SOLVED*
« on: February 03, 2016, 06:31:10 pm »
I'm a bit confused on how mirroring technically works when you have more than two 16x16 tiles or a plethora of 8x8 tiles.  Obviously the sprite gets 'mirrored', but there's got to be something more to it as there's a pretty clear bug going on.



The sprite that's actually assembled properly is what it should look like, but the moment you turn left.. it turns into that mess.  The bottom 16x16 tile is fine as it but the top two flip.. completely.  I thought it was just them interchanging positions but it's not that either as the X coordinates are also quite off.

Is there any specific method that anyone knows that games commonly use to flip them all properly?  I've noticed with MMX that it even flips tiles properly upside down, while this game will switch the two tiles and then flip them upside down.  I'm not exactly sure what MMX does as it does most of it's work using the CX4 chip so that was kind of a bust.

Any help would be greatly appreciated!
« Last Edit: February 03, 2016, 08:39:38 pm by justin3009 »
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Sprite Mirroring Issue
« Reply #1 on: February 03, 2016, 08:15:44 pm »
So..... what system?  I assume SNES.... but without CX4.

Assuming you're using the "standard" square sprite sizes and not the unofficial rectangular sprite sizes, the concept is the same as it is with 8x8 sprites.

Assuming 8x8 sprites forming a 16x16 image:
Code: [Select]
normal
AB
CD

mirrored
BA
DC

Note that you'll actually have to change where the tiles are drawn as well as actually set the 'flip-x' attribute bit.

On SNES, with 16x16 sprites, the above is all done automatically when you flip the sprite.  It will flip each 8x8 tile, and also reconfigure their drawing pattern to be mirrored as well.  But if you are constructing a larger sprite out of 16x16 sprites, you'll still have to reconfigure those on your own.

justin3009

  • Hero Member
  • *****
  • Posts: 1660
  • Welp
    • View Profile
Re: Sprite Mirroring Issue
« Reply #2 on: February 03, 2016, 08:24:55 pm »
Woop!  I figured it out, yep, SNES.

Turns out I basically had to write a check specifically to see what direction your character was facing, depending on the direction, it'd EOR (Exclusive-OR Accumulator with Memory) the current X coordinate with FF FF then add the current PC X coordinates.  It's now setting the X coordinates properly on flipping :)
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'