On Atari 2600 we have a register (REFPx) that turns the sprite horizontally, so if you have a sprite facing to right, set this register and the sprite is displayed facing to the left.
There's no such feature on Odyssey 2, you need to draw the same sprite twice, one for each facing.
Each sprite facing waste 8 bytes of ROM, so I had the idea to make a code to switch the facing by software.
There are 3 ways to make this (that I know) :
1 - Set individual pixels each time using byte shift and carry. The problem this code is very slow and need 64 loops to change all the 8 bytes of a single sprite. Probably this take more of the available time you have on VBlank.
2 - Flip each nibble at time. This is the code I'm using, still slow, and require a table of 16 bytes. The code itself including the table takes about 50 bytes of ROM space. It require 8 loops to flip the sprite.
3 - Flip each byte at time - The faster one, done in 8 loops, but require a table of 256 bytes, you can store 32 sprites in this amount of ROM.
So my code flips each nibble at time, and like I said, uses about 50 bytes of ROM. You can store 6 sprites on that amount of ROM, so this code only is useful if you need flip more than 6 individual sprites, less than that you should flip them manually and not using the code, else you're wasting ROM and VBlank Time.
How it works : put the sprite on VDC RAM normally, after that, call a subroutine and it will flip the sprite that is pointed at R0, here's the code :
(no RAM needed and uses registers R0 to R4)
mov R0,#080h ;Sprite to be mirrored (80 or 88 or 90 or 98)
call Mirroring ;go to mirror code
;----------------------------------------------
Mirroring ;Subroutine
;----------------------------------------------
mov R4,#8
GetNibble
movx a,@R0
mov R1,a
;---
anl a,#00Fh
mov R2,#TableMirror & 0ffh
add a,R2
movp a,@a
swap a
mov R3,a
;---
mov a,R1 ;xxxx0000
swap a ;0000xxxx
anl a,#00Fh
mov R2,#TableMirror & 0ffh
add a,R2
movp a,@a
orl a,R3
movx @R0,a
inc R0
djnz R4,GetNibble
ret
TableMirror
db 0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15
The code needs to be run during Vblank (VDC Off) but you can store the result on extra RAM and later update to the sprite RAM, for calculate it off VBlank time.
EDIT : Code was optimized