PutSprite Help
[Prev][Next][Index][Thread]
PutSprite Help
I'm a beginner when it comes to assembly programming (although I am not
a beginner when it comes to programming in general) and I'm having a
little bit of trouble with the following code. It assembles alright but
when I try running it garbage fills the screen. Other than that the
program seems to be running fine (it exits when the Exit key is
pressed). I am using USGARD 1.5.
#include "usgard.h"
.org 0
.db "Graphics Test",0
ld a,4
out (5),a
call CLEARLCD
ld b,$01
ld c,$01
ld hl,Block
call &PutSprite
Loop:
call GET_KEY
cp $37 ; Exit key
jr nz, Loop
ret
PutSprite: ; PutSprite routine by Jimmy Merdell
push bc ; Puts sprite stored at (HL) at B,C
push de
ld a,63
sub c
ld c,a
push hl
push hl
call FIND_PIXEL
ld de,VIDEO_MEM
add hl,de
ex de,hl
pop hl
ld b,(hl)
inc hl
ld c,(hl)
inc hl
push hl
pop ix
ex de,hl
PS_NewRow:
push bc
ld d,(ix)
inc ix
push af
push hl
PS_NewCol:
rl d
ld e,a
jr nc,PS_NoPixel
or (hl)
ld (hl),a
jr PS_NextPixel
PS_NoPixel:
cpl
and (hl)
ld (hl),a
PS_NextPixel:
ld a,e
rrca
jr nc,PS_SameByte
inc hl
PS_SameByte:
djnz PS_NewCol
pop hl
pop af
ld de,16
add hl,de
pop bc
dec c
jr nz,PS_NewRow
pop hl
pop de
pop bc
ret
Block:
.db 8,8
.db %00111100
.db %01111110
.db %11111111
.db %11111111
.db %11111111
.db %11111111
.db %01111110
.db %00111100
.end
Any help would be GREATLY appreciated. Thanks!
- Jim
Follow-Ups: