So I'm porting something from SAM Coupé as my first foray into it as all the game logic will stay the same amd I just need to rewrite some platform specific code. Sees a quick win.
The 4-bit sprites on the Next are analogous to SAM's mode 4 screen format, 4 bit per pixel, 16 colours so it makes it even easier. But I seem to have a problem writing out the patterns.
The guidence at https://www.specnext.com/sprites/ says:
So I take it this means I can just select sprite pattern 0 and then squirt out the data, right, and if I send say 256 bytes (to represent two patterns worth of 4 bit per pixel sprites) then it should automatically put the first 128 bytes i Pattern 0 and the second 128 bytes into Pattern 1?Port 0x5B (W)
Once a pattern number is selected via port 0x303B, the 256-byte or 128-byte pattern can be written to this port. The internal pattern pointer auto-increments after each write so as many sequential patterns as desired can be written. The internal pattern pointer will roll over from pattern 127 to pattern 0 (4-bit patterns) or from pattern 63 to pattern 0 (8-bit patterns) automatically.
It doens't work for me. Pattern 0 is fine, Pattern 1 is a corrupt mess. This is the code:
Code: Select all
ld bc,$303b ; this sprite control port again
xor a ; first sprite
out (c),a ; select it
ld hl, tiles ; 16 tile graphics stored here
ld c,$5b ; copying sprite data goes via this port apparently
ld b,0 ; 2 sprites worth
otir
Code: Select all
ld bc,$303b ; this sprite control port again
ld a,0 ; first sprite
out (c),a ; select it
ld hl, tiles ; first tile graphic
ld c,$5b ; copying sprite data goes via this port
ld b,128 ; 128 bytes, 1 sprite pattern
otir
ld bc,$303b ; this sprite control port again
ld a,1 ; first sprite
out (c),a ; select it
ld hl, tiles+128 ; second tile graphic
ld c,$5b ; copying sprite data goes via this port
ld b,128 ; 128 bytes, another sprite pattern
otir
Thanks for reading this far if you did