A86: Will this work?
[Prev][Next][Index][Thread]
A86: Will this work?
***expand this window to read commments easier***
I'm attempting to fully grasp the concept of drawing sprites... Will the
following code work???
PutSprite: ;8x8 sprites ONLY
;hl -> Sprite
;b = xCoord (1-16) ;Like in the OS, except max is 16, instead of 21,
;c = yCoord (1-8) ;because OS uses 8x6 sprites.
;This routine destroys all registers.
push hl ;Save the pointer
dec b ;duh =)
dec c ;duh =)
ld (hl),c
add hl,hl ;*2
add hl,hl ;*4
add hl,hl ;*8
add hl,hl ;*16
add hl,hl ;*32
add hl,hl ;*64
add hl,hl ;*128 - Skip 16 bytes for each row * 8 rows for each sprite
push hl ;ld hl
pop de ;in de
ld (hl),b
add hl,de ;add the xCoord
push hl ;ld hl
pop de ;in de
ld hl,VIDEO_MEM
add hl,de ;Now the sprite is aligned. (I think)
pop de ;Get the pointer to the sprite
ld b,8 ;8 bytes to be transferred
PutSpriteLoop:
push bc ;Save bit counter
ld a,(de) ;copy 1 byte from de
ld (hl),a ;to hl
ld bc,16 ;Skip 16 bytes ahead
add hl,bc
push hl
push de
pop hl
add hl,bc
push hl
pop de
pop hl
pop bc
djnz PutSpriteLoop
ret ;Return