Re: A86: Erasing Old Sprites


[Prev][Next][Index][Thread]

Re: A86: Erasing Old Sprites




If you change PutSprite so that it xor's the sprite to the screen, then when
you Putsprite once it will put the sprite down, and a second time will erase
it.  If you put the putsprite routine into an e-mail, either I or someone else
can change it so it xor's to the screen.  This is probably the easiest way,
and you don't need to have the "Clear" sprite.


In a message dated 8/31/98 6:44:37 PM Central Daylight Time, diddy@apci.net
writes:

<< I am trying to learn asm, and I am working on a sprite demo.  This code
 should draw a sprite and then when I press a directional key it should
 delete the old sprite position and then draw it in the new sprite position
 (deleting the old one).  I did not include the PutSprite routine because I
 think everyone that could answer this question knows what the answer is.
 The problem is it does not do this (what I explained above) so I was
 wondering if anyone could help.
 
 Anyway in case you dont know the variables:
 
 cd = x,y coordinates
 ix = the sprite to display
 
 Also this is and 8x8 sprite rotuine that i got off of ticalc.org.
 
 If anyone could help me I would be greaty appreciated.  Oh yeah and I
 removed the comments for space concerns
 
 #include "asm86.h"
 #include "ti86asm.inc"
 
 .org _asm_exec_ram
 
     call _clrLCD
     call BUSY_OFF
     jr Setup
 
 Setup:
     ld b,0
     ld c,0
     ld ix,0
     ld ix,Dude
     call PutSprite
     jr Test
 
 Test:
     jp ClearOld
 
 Move:
     call GET_KEY
     cp K_EXIT
     jr z,Exit
     cp K_UP
     jr z,Up
     cp K_DOWN
     jr z,Down
     cp K_LEFT
     jr z,Left
     cp K_RIGHT
     jr z,Right
     jr Move
 
 Up:
     ld a,c
     sub 8
     ld c,a
     jp DrawNew
 
 Down:
     ld a,c
     add a,8
     ld c,a
     jp DrawNew
 
 Left:
     ld a,b
     sub 8
     ld b,a
     jp DrawNew
 
 Right:
     ld a,b
     add a,8
     ld b,a
     jp DrawNew
 
 Exit:
     call _clrLCD
     ret
 
 ClearOld:
     ld b,b
     ld c,c
     ld ix,0
     ld ix,Clear
     call PutSprite
     jp Move
 
 DrawNew:
     ld ix,0
     ld ix,Dude
     call PutSprite
     jp Move
 
 Dude:
 .db %01110000
 .db %01110000
 .db %00100000
 .db %00100100
 .db %01111110
 .db %00110100
 .db %00111000
 .db %01101100
 
 Clear:
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
  >>