Re: A83: Sprite routine problem
[Prev][Next][Index][Thread]
Re: A83: Sprite routine problem
Ok - well there were a few errors in your code... See the !!!!! comments :)
Here is a version which works... Of course there are heaps of optimiztions
you could make to your routine, such as not using the ix register for the
sprite address but using the HL register (for much faster access to the
sprite data). Anyhow hope this helps. Email me if you have any questions.
Ben.
Here is a corrected version of your routine:
.NOLIST
#define equ .EQU
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h
call _clrLCDFull
call _grbufclr ;!!! Actually clear out the memory used for the graph
buffer. !!!
ld b,48 ;!!!!!!!!! NOTE the change - register b now...!!!!!!!!!
ld e,32
ld ix,big_sprite
call _Big_Sprite
call _grbufcpy_v
loop:
call _getkey
ret
;!!! Just use ret here... what if getkey returns zero??? maybe not
possible... always better to be safe than sorry.!!!
;Input: b-x coord, e-y coord, ix-sprite address
;Output: 8x16 XOR sprite written to 8e29h
_Big_Sprite:
ld hl,0
ld d,0 ;!!!!!!!You just killed one of your former sprite
coordinates!!!!!!!!!
;*********Calculate addy in graphbuf********
sla e ;Do y*12
sla e
add hl,de
add hl,de
add hl,de
ld e,b ;!!! note I've loaded e with b - reflecting the earlier changes.!!!
srl e ;Do x/8
srl e
srl e
add hl,de
ld de,8e29h
add hl,de
;!!!!Fine (now) til this point.!!!!!
ld a,b
and 00000111b
;cp 0 ;checks if sprite is aligned !!!!! This is not needed. cp will set
zero flag if result is zero!!!!!!
jr z,Aligned_Sprite ;If so, goto aligned sprite bit
;********Non-aligned sprite bit starts here********
;!!! here, a contains the number of shifts required !!!
ld de,0
ld b,a ;Shift counter
ld c,16 ;Line counter
Line_Loop:
ld d,(ix+0)
push bc
Shift_Loop:
srl d
rr e
djnz Shift_Loop
pop bc
ld a,d ;Write line to graphbuf
xor (hl)
ld (hl),a
inc hl
ld a,e
xor (hl)
ld (hl),a
ld de,11d
add hl,de
inc ix
dec c
;cp 0 ;!!! again not needed... dec will set zero flag when c reaches zero.
jr nz,Line_Loop
ret
;********Aligned sprite bit starts here********
Aligned_Sprite:
ld c,16 ;Line counter
Aligned_Loop:
ld d,(ix+0)
ld a,d
xor (hl)
ld (hl),a
ld de,12d
add hl,de
inc ix
dec c
; cp 0 ; !!! no comment !!!
jr nz,Aligned_Loop
ret
big_sprite:
.db 11111111b
.db 11000011b
.db 10100101b
.db 10011001b
.db 10011001b
.db 10100101b
.db 11000011b
.db 10000001b
.db 10000001b
.db 11000011b
.db 10100101b
.db 10011001b
.db 10011001b
.db 10100101b
.db 11000011b
.db 11111111b
.end
END
----- Original Message -----
From: Assembly-83 Digest <owner-assembly-83@lists.ticalc.org>
To: <assembly-83-digest@lists.ticalc.org>
Sent: Sunday, 5 September 1999 8:00
Subject: Assembly-83 Digest V1 #808
>
References: