But not good enough to put it into practice and make working code!
I now struggle displaying a sprite on screen. Using UDG's I can achieve this but I am trying to display sprites. Here I have an 8x8 sprite, but I am hoping my code will display sprites of much larger without much modification.
But why doesn't my 'sprite data' (ie. "face") seem to get output on screen, I just get a black square where I expected it to be.
Code: Select all
ENTRY_POINT EQU 32768
org ENTRY_POINT
;screen memory starts 16384 / 0x4000
call 0xdaf
ld b,2
ld c,5
call GetColourMemAddress
ld a,%00000011
ld (de),a
call GetScreenAddress
ld hl,face
ld b,8
; this function will take input in bc=xy position
; out hl= screen memory address
GetScreenAddress:
ld a,c
and %00111000
rlca
rlca
or b
ld e,a
ld a,c
and %00000111
ld d,a
ld a,c
and %11000000
rrca
rrca
rrca
or d
or 0x40 ;0x4000 = screen base
ld d,a
ret
GetNextLine:
inc d
ld a,d
and %00000111
ret nz
ld a,e
and %00100000
ld e,a
ret c
ld a,d
sub %00001000
ld d,a
ret
; input bc=xy (x in bytes, so 32 across)
; output hl=screen memory address
GetColourMemAddress:
ld a,c
and %11000000
rlca
rlca
add a,0x58
ld d,a
ld a,c
and %00111000
rlca
rlca
add a, b
ld e,a
ret
GetNextColoutLine:
ld a,e
add a,32
ld e,a
ret nc
inc d
ret
SpriteNextLine:
ld a,(hl)
ld (de),a
inc hl
call GetNextLine
djnz SpriteNextLine
ret
;include "face.asm" ;tried this and got black square only. Same when data is in this file as below.
face:
db %00000000
db %00100100
db %00100100
db %00000000
db %01000010
db %01111110
db %00111100
db %00000000
end ENTRY_POINT