I read in other threads how people make their sprites. It seems a lot of people goes with an approach like this:
This approach is quite simple since it's exactly the same structure as the OAM. My only issue with it was on how to flip the sprite. From what I saw and I could be wrong, you would need your sprite to be a specific ratio, for example 3x3, to be able to flip them. If not, doesn't work well.
In the case of my mega man sprite, it didn't cut it. Some sprites like the face overlay cannot be flipped that way since the is only one sprite and some parts of mega man repeats often so if you just copy/paste.. That will duplicate data for nothing.
So I came up with a simple idea of meta-meta sprite. What it means is one animation frame can be composed of more than one meta-sprite of any shape, it doesn't matter much. But I still had the problem on "how" to flip that darn things.
At first I came out with the idea of duplicating the complete data. Not very good and take too much space. Then, after talking with Tokumaru, one idea came to me: why not just add an extra byte to my tile definition? Instead of 4 bytes, let's put 5 of them. The last byte will be the flipped X location. This mean when you want to flip the X location, you just need to EOR the attribute byte for horizontal position and load the approriate X location only. There is only one if condition to check the direction of the sprite, that's it.
The data looks like this:
So the bytes are:
- byte 0 is the Y location
- Byte 1 is the hardware tile number
- Byte 2 is the attribute byte
- Byte 3 is the X location in it's original location
- Byte 4 is the X location in it's inverted location
Anybody uses a system like this? For now, it seems to be working well and the cost in data is not big. If I would have duplicated the data, it would have cost maybe 360 bytes for all frames (not shown here). By adding 1 extra byte per line, it cost 90 bytes. That's a 75% save in size.
Any other ideas on the subject will be appreciated.
Code:
mySprite:
.byte $03 ; Number of hardware tile
.byte $0F, $2A, %01000000, $00
.byte $0F, $29, %01000000, $08
.byte $0F, $29, %01000000, $10
.byte $03 ; Number of hardware tile
.byte $0F, $2A, %01000000, $00
.byte $0F, $29, %01000000, $08
.byte $0F, $29, %01000000, $10
This approach is quite simple since it's exactly the same structure as the OAM. My only issue with it was on how to flip the sprite. From what I saw and I could be wrong, you would need your sprite to be a specific ratio, for example 3x3, to be able to flip them. If not, doesn't work well.
In the case of my mega man sprite, it didn't cut it. Some sprites like the face overlay cannot be flipped that way since the is only one sprite and some parts of mega man repeats often so if you just copy/paste.. That will duplicate data for nothing.
So I came up with a simple idea of meta-meta sprite. What it means is one animation frame can be composed of more than one meta-sprite of any shape, it doesn't matter much. But I still had the problem on "how" to flip that darn things.
At first I came out with the idea of duplicating the complete data. Not very good and take too much space. Then, after talking with Tokumaru, one idea came to me: why not just add an extra byte to my tile definition? Instead of 4 bytes, let's put 5 of them. The last byte will be the flipped X location. This mean when you want to flip the X location, you just need to EOR the attribute byte for horizontal position and load the approriate X location only. There is only one if condition to check the direction of the sprite, that's it.
The data looks like this:
Code:
megamanStandStillAnim: ; tentative structure
.byte $02 ; anim frame count
.word megamanStillFrame1
.word megamanStillFrame2
megamanStillFrame1: ; Meta-meta sprite
.byte $60 ; How many frame (not used yet)
.byte $03 ; how many meta-sprite to load
.word megamanStillMSprite ; Meta sprite
.word megamanStillLegMSprite
.word megamanStillEyeOpenMSprite
megamanStillFrame2: ; Meta-meta sprite
.byte $20 ; How many frame
.byte $03 ; how many meta-sprite to load
.word megamanStillMSprite ; Meta sprite
.word megamanStillLegMSprite
.word megamanStillEyeClosedMSprite
; Hero facing right, stand still, leg not included
megamanStillMSprite:
.byte $07 ; Number of attributes required for this meta-sprite
.byte $00, $0B, %01000000, $08 , $18 ; Head top 1
.byte $00, $0A, %01000000, $10 , $10 ; Head top 2
.byte $00, $09, %01000000, $18 , $08 ; Head top 3
.byte $08, $1B, %01000000, $08 , $18 ; face/torso 1
.byte $08, $1A, %01000000, $10 , $10 ; face/torso 2
.byte $08, $19, %01000000, $18 , $08 ; face/torso 3
.byte $0F, $2B, %01000000, $08 , $18 ; Torso/feet 1
; Not moving leg for stand still
megamanStillLegMSprite:
.byte $02 ; Number of attributes required for this meta-sprite
.byte $0F, $2A, %01000000, $10 , $10 ; Torso/feet 2
.byte $0F, $29, %01000000, $18 , $08 ; Torso/feet 3
; Stand still face overlay: eyes open
megamanStillEyeOpenMSprite:
.byte $01
.byte $06, $00, %01000001, $11 , $0F ; face overlay: eye opens
; Stand still face overlay: eye closed
megamanStillEyeClosedMSprite:
.byte $01
.byte $06, $20, %01000001, $11 , $0F ; face overlay: eye closed
.byte $02 ; anim frame count
.word megamanStillFrame1
.word megamanStillFrame2
megamanStillFrame1: ; Meta-meta sprite
.byte $60 ; How many frame (not used yet)
.byte $03 ; how many meta-sprite to load
.word megamanStillMSprite ; Meta sprite
.word megamanStillLegMSprite
.word megamanStillEyeOpenMSprite
megamanStillFrame2: ; Meta-meta sprite
.byte $20 ; How many frame
.byte $03 ; how many meta-sprite to load
.word megamanStillMSprite ; Meta sprite
.word megamanStillLegMSprite
.word megamanStillEyeClosedMSprite
; Hero facing right, stand still, leg not included
megamanStillMSprite:
.byte $07 ; Number of attributes required for this meta-sprite
.byte $00, $0B, %01000000, $08 , $18 ; Head top 1
.byte $00, $0A, %01000000, $10 , $10 ; Head top 2
.byte $00, $09, %01000000, $18 , $08 ; Head top 3
.byte $08, $1B, %01000000, $08 , $18 ; face/torso 1
.byte $08, $1A, %01000000, $10 , $10 ; face/torso 2
.byte $08, $19, %01000000, $18 , $08 ; face/torso 3
.byte $0F, $2B, %01000000, $08 , $18 ; Torso/feet 1
; Not moving leg for stand still
megamanStillLegMSprite:
.byte $02 ; Number of attributes required for this meta-sprite
.byte $0F, $2A, %01000000, $10 , $10 ; Torso/feet 2
.byte $0F, $29, %01000000, $18 , $08 ; Torso/feet 3
; Stand still face overlay: eyes open
megamanStillEyeOpenMSprite:
.byte $01
.byte $06, $00, %01000001, $11 , $0F ; face overlay: eye opens
; Stand still face overlay: eye closed
megamanStillEyeClosedMSprite:
.byte $01
.byte $06, $20, %01000001, $11 , $0F ; face overlay: eye closed
So the bytes are:
- byte 0 is the Y location
- Byte 1 is the hardware tile number
- Byte 2 is the attribute byte
- Byte 3 is the X location in it's original location
- Byte 4 is the X location in it's inverted location
Anybody uses a system like this? For now, it seems to be working well and the cost in data is not big. If I would have duplicated the data, it would have cost maybe 360 bytes for all frames (not shown here). By adding 1 extra byte per line, it cost 90 bytes. That's a 75% save in size.
Any other ideas on the subject will be appreciated.