I’ve filled in the other 3 frames required, and set it up so that it only loads one frame of animation into VRAM. There are enough scanlines to do this completely in VBlank with a comfortable amount of headroom; unfortunately, the method used isn’t fast enough to require me to slow it down during not-VBlank, and so this provides no speed advantage.
Anyhow, on the topic of sprite flipping. The TMS9918A provides a lovely feature which allows you to flip tile data horizontally and/or vertically. Unfortunately, this was not provided with sprites, despite the fact that there’s a blatantly unused section which would have been perfect for sticking these flags in. So you have to flip the sprites manually.
This is where we use a table to perform the flip. It looks like this:
Erm, I mean THIS:
.redefine mv_q 0
.redefine mv_x mv_q
.redefine mv_x (((mv_x<<1)&$AA)|((mv_x>>1)&$55))
.redefine mv_x (((mv_x<<2)&$CC)|((mv_x>>2)&$33))
.redefine mv_x (((mv_x<<4)&$F0)|((mv_x>>4)&$0F))
.redefine mv_q 1+mv_q
I also have one which generates a “no flip table” which is just a bunch of bytes from 0 to 255.
Here’s the code:
; load sprite
ld hl,$4000 + ($7C * 32)
ld e,(hl) ; 19
inc l ; 23
ld a,(de) ; 30
out ($BE),a ; 41 – SAFE
djnz – ; START: 12
and $02 -1
; there’s still plenty of breathing room
; mednafen reports $DA with the occasional flicker of $D5
I hope you can work out whether the walk animation is any good or not. I’ve loaded it into an unused space of VRAM. If you look carefully, you’ll notice that one of the frames involves the player bobbing up. See, I put in effort!