Re: A86: Erasing Old Sprites
[Prev][Next][Index][Thread]
Re: A86: Erasing Old Sprites
In a message dated 8/31/98 7:15:24 PM Central Daylight Time, diddy@apci.net
writes:
<< Here is the code.
Thanks
>>
I fixed it!!!!
I tried to comment what I could, but if you have any questions, go ahead and
ask!
;***********************************
;*Move The Dude V 0.2.10 Build ????*
;***********************************
;*This Program Should Move The Dude*
;*Except It Doesn't... But It Will!*
;*Also This Is My First ASM Program*
;***********************************
;*Programming: Super Llama *
:*GFX: Super Llama *
;***********************************
;* Known Bugs In Game: *
;***********************************
;*1. Will Not Move More Than 3 *
;* Spaces Left Or Right. *
;*2. Does Not Correctly Erase Old *
;* Dude And Put Up The New One. *
;*3. Only Erases If You Move *
;* Backwards. *
;***********************************
#include "asm86.h" ;ASM 86 Include File
#include "ti86asm.inc" ;TI's Include File
.org _asm_exec_ram ;Starting Point
call _clrLCD ;Clears The LCD
call BUSY_OFF ;Turns Off Run Thingy
jr Setup ;Goto Setup
Setup:
ld b,0 ;Loads 0 As Y-Coordinate
ld c,0 ;Loads 0 As X-Coordinate
ld ix,0 ;Clears Image Bank
ld ix,Dude ;Loads Dude As Sprite
push bc ;****Save the coordinates
call PutSprite ;Run PutSprite Routine
Move:
call GET_KEY ;Getkey Function
cp K_EXIT ;Is It Exit
jr z,Exit ;Then Goto Exit
cp K_UP ;Is It Up
jr z,Up ;Then Goto Up
cp K_DOWN ;Is It Down
jr z,Down ;Then Goto Down
cp K_LEFT ;Is It Left
jr z,Left ;Then Goto Left
cp K_RIGHT ;Is It Right
jr z,Right ;Then Goto Right
jr Move ;If None Try Again
Up:
pop bc ;****get back coords (incase something messed it up)
call ClearOld ;****Clear the old and put the new
ld a,c ;Load C Into A
sub 8 ;Subtract 8 From A
ld c,a ;Load A Into C
push bc ;****save bc again
jp DrawNew ;Goto DrawNew
Down:
pop bc ;same as above
call ClearOld ;****Clear the old and put the new
ld a,c ;Load C Into A
add a,8 ;Add 8 To A
ld c,a ;Load A Into C
push bc ;same as above
jp DrawNew ;Goto DrawNew
Left:
pop bc ;same as above
call ClearOld ;****Clear the old and put the new
ld a,b ;Load B Into A
sub 8 ;Subtract 8 From A
ld b,a ;Load A Into B
push bc ;same as above
jp DrawNew ;Goto DrawNew
Right:
pop bc ;same as above
call ClearOld ;****Clear the old and put the new
ld a,b ;Load B Into A
add a,8 ;Add 8 To A
ld b,a ;Load A Into B
push bc ;same as above
jp DrawNew ;Goto DrawNew
Exit:
pop bc ;***have to pop what has been pushed at the end
call _clrLCD ;Clear The LCD
ret ;End Program
ClearOld:
;removed ld b,b (b is already b)
ld ix,0 ;Flush Image Bank
ld ix,Dude ;Load Clear As Image
call PutSprite ;Run PutSprite Routine
ret ;changed so you can call this
DrawNew:
ld ix,0 ;Flush Image bank
ld ix,Dude ;Load Dude As Image
call PutSprite ;Run PutSprite Routine
jp Move ;Goto Move
;************************************************
;* PutSprite *
;************************************************
;*Input: BC = X,Y; IX = 8x8 Sprite Location *
;*Output: Sprite Drawn; IX Points To Next Sprite*
;*If Your Sprites Follow In Sequence *
;*HL And DE Are Destroyed *
;************************************************
;*Disclaimer: I Did Not Write This Routine!!! *
;************************************************
PutSprite:
ld h,63 ;Shifted To $FC With Add HL,HL
ld a,c
add a,a ;A*4
add a,a
ld l,a
add hl,hl ;HL*4 (What Was C Has Been MLT By 16)
add hl,hl
ld a,b ;A/8
rra
rra
rra
or l ;Add To More Significant Bytes
ld l,a
ld a,7 ;Use Bottom 7 Bits For Counter
and b
ld d,a ;Save Counter Copy In D
ld e,8 ;8 Rows
push bc
ps_loop:
ld b,d ;Get Saved Bit Offset In B
ld a,(ix) ;Get This Byte Of The Sprite In A
inc ix ;Point IX To The Next Sprite Byte
ld c,0
call bit_shift
xor (hl) ;Change This To OR If You Want
ld (hl),a
inc l
ld a,(hl)
xor c ;Also Changable To OR
ld (hl),a
ld a,15 ;Add 15 To HL (Ready For Next Row)
call add_hl_a
dec e ;Counter (8 Rows)
jr nz,ps_loop
pop bc
ret
add_hl_a: ;Add HL,A
add a,l
ld l,a
ret nc
inc h
ret
bit_shift: ;While(B=<0)
dec b ;A>>C
ret m
srl a
rr c
jr bit_shift ;End PutSprite Routine
;*****************
;* The Sprites *
;*****************
Dude:
.db %01110000 ;Start Sprite Code
.db %01110000
.db %00100000
.db %00100100
.db %01111110
.db %00110100
.db %00111000
.db %01101100 ;End Sprite Code
;Don't need Clear anymore
.end ;End ASM Code
.end ;Make Sure Compiler Understands