Usgard Problem
[Prev][Next][Index][Thread]
Usgard Problem
I am writing a program for Usgard and I'm trying
to work out a sprite routine. This is what I have so far, and it
consistently causes a crash. Help, what am I doing wrong?
#include "usgard.h"
.org 0
.db
"Adol",0
ld a,4
out (5),a
call
CLEARLCD
ld hl,0
ld (CURSOR_ROW),hl
ld
hl,&Sprite
push hl
pop ix
ld bc,$0000
ld
d,1
call &PutSprite
WaitKey:
call GET_KEY
cp
K_EXIT
jr nz,WaitKey
ret
PutSprite: ;; Put
Sprite (hl) at Video Mem $FC00 + bc
push
hl ;; save
value of HL for ret command
push
ix ;; Push
value previously stored in IX to
stack
pop
hl ;;
And load it into HL for use
ld
a,(hl) ;; Load the Value
at address HL->A
push
hl ;; Push HL
onto stack
push
af ;; Push AF
onto stack
ld hl,$FC00
add
hl,bc ;; Add VM start to
bc to get absolute
pop
af ;;
restore AF
ld
(hl),a ;; load AF into VM
address HL
push
hl ;; Push HL
onto stack
pop
bc ;;
Load Value into BC
NewRow:
pop
hl
;; restore HL
ld de,$0001
add
hl,de ;; Get value
for next byte
push
hl ;;
Preserve HL by pushing onto stack
ld hl,$0010
add
hl,bc ;; get address
for new row
push hl
pop
bc
;; Place value of HL into BC
pop
hl
;; Restore HL
ld a,(hl)
push
hl ;;
push HL onto stack for preserve
push bc
pop
hl
;; place value of BC into HL
ld (hl),a
inc
d
;; increment d for looping
ld a,$08
cp
d
;; check d against a
jr nz,NewRow ;; if the result is not
zero, loop
pop
hl
;; return value of HL for return
ret
Sprite:
.db %11000011
.db
%10000001
.db %10000001
.db %00000000
.db
%00000000
.db %10000001
.db %10000001
.db
%11000011
.end