
As I am finishing TX-1696, there is some more polish being added as I go through the levels one more time, and with that extra polish is the need for 5 more hardware sprites.
Having made changes and additions to the game over the last 18 months or so its hard to remember what sprites are still being used and what has been replaced therefore it would be good to see what the sprite memory on the real next hardware looks like at any given moment, to this end I have written a small sprite memory viewer which does the job for me.
Just call this function after you have uploaded your sprites to the hardware, remembering to place a break point at the bottom of the function.
I have commented the code for you and shared it so you may make use of it or even modify it to your own needs.
Sorry about the spaces, but this stupid plugin requires spaces rather than tabs.
Enjoy
REG_PALETTE_CONTROL equ $43
SPRITES_1ST_PALETTE equ %00100000
REG_PALETTE_INDEX equ $40
REG_PALETTE_COLOUR equ $41
REG_SPRITE_CLIP equ $19
REG_SPRITE_NUMBER equ $34
REG_SPRITE_ATTRIBUTE0 equ $35
REG_SPRITE_ATTRIBUTE1 equ $36
REG_SPRITE_ATTRIBUTE2 equ $37
REG_SPRITE_ATTRIBUTE3 equ $38
REG_SPRITE_ATTRIBUTE4 equ $39
VIEW_COLOUR equ 255
SPRITES_ACROSS equ 14
SPRITES_X_START equ 32
SPRITES_Y_START equ 32
spriteMemViewer:
nextreg REG_PALETTE_CONTROL,SPRITES_1ST_PALETTE // say we are changing the sprite
// first palette
ld b,16 // 16 colours
nextreg REG_PALETTE_INDEX,0 // start with colour zero
.paletteLoop:
nextreg REG_PALETTE_COLOUR,VIEW_COLOUR // send the viewer colour to the hardware
djnz .paletteLoop // do 16 colours
nextreg REG_SPRITE_CLIP,0 // make sure we
nextreg REG_SPRITE_CLIP,255 // can see all the sprites
nextreg REG_SPRITE_CLIP,0 // by resetting the clip of the screen
nextreg REG_SPRITE_CLIP,191 // to its default settings
ld b,0 // count for 128 sprites
ld c,0 // count for how many across the screen
ld hl,SPRITES_X_START // first sprite X start position
ld de,SPRITES_Y_START // first sprite Y start position
.show128Sprites:
ld a,b // get the sprite index (number)
nextreg REG_SPRITE_NUMBER,a // and tell the hardware the attributes
// are for this sprite
ld a,l // get the x pos LSB
nextreg REG_SPRITE_ATTRIBUTE0,a // set the harware x pos
ld a,e // get the y pos LSB
nextreg REG_SPRITE_ATTRIBUTE1,a // set the harware y pos
ld a,h // get the x pos MSB
and 1 // mask off the position high bit
nextreg REG_SPRITE_ATTRIBUTE2,a // set the harware x pos MSB
ld a,b // now get the sprite count
srl a // divide by two (only for 4 bit patterns)
or %11000000 // or in the visible bit using attribute 4
nextreg REG_SPRITE_ATTRIBUTE3,a // send the hardware pattern (0-63)
// and display bits
ld a,b // get the count again
and 1 // and see if its an odd number
jp nz,.notPlus128 // it is odd
ld a,%10000000 // not odd so set the 4 bit patterns bit
jp .att4 // done
.notPlus128:
ld a,%11000000 // odd so set the 4 bit patterns bit
// and last 128 bytes bit
.att4:
nextreg REG_SPRITE_ATTRIBUTE4,a // tell set the attribute 4
add hl,18 // add 18 pixels between sprites
inc c // increment the sprite number across screen
ld a,c // move for math
cp SPRITES_ACROSS // is it a full row
jp nz,.notNextRow // not yet
ld c,0 // it is so reset the count
ld hl,SPRITES_X_START // reset the start position
add de,18 // add 18 to the Y position
.notNextRow:
inc b // next sprite
bit 7,b // have we done 128 of them
jp z,.show128Sprites // not yet so keep going
ret // add a break point here