Re: A86: drawing a sprite to the screen.


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

Re: A86: drawing a sprite to the screen.






>From: BlAsTo1414@aol.com
>Date: Tue, 15 Sep 1998 20:38:58 EDT
>To: assembly-86@lists.ticalc.org
>Subject: Re: A86: drawing a sprite to the screen.
>Reply-To: assembly-86@lists.ticalc.org
>
>
>ye ok.  I got 1,2 and 3 but four on out left me dazed.  I know how to 
draw the
>sprite(modified putsprite)I can get the key used(I think) and I can 
jump to
>the key used(yea, I know that one).  but I dont know how to cahang ethe
>register or redraw the sprite.  can you help me there?  Maybe sample 
code on
>redrawing sprites would help.  
>
>Thanks a lot,
>BlAsTo1414
>

OK I just realized I forgot a step you have to erase the old sprite 
before you draw the new one unless you want a long line of 'em.  As for 
changing the register here's an example:

;This is just an example it will probably have to be changed 
;for your specific program
;D=x coord of sprite
;E=y coord of sprite
;HL=sprite data
;This won't work if compiled either its basically psuedo-code
;but using ASM commands to show it
;It is also for alligned sprites (on a 8X8 grid not like one
;pixel if that makes any sense) and the keys aren't the actual ones 
;that should be used but I'm to lazy to look up thier equates =)
;Oh and another thing I think the z should be nz I'm kinda rusty


draw_first_sprite:
     ld d,1
     ld e,5
     ld hl,Sprite
     call Draw_Sprite

key_loop:
     call GET_KEY
     cp K_RIGHT
     jp z,move_sprite_right
     cp K_LEFT
     jp z,move_sprite_left
     jp key_loop

move_sprite_right:
     inc d
     ld hl,Sprite
     call Draw_Sprite
     jp key_loop

move_sprite_left:
     dec d
     ld hl,Sprite
     call Draw_Sprite
     jp key_loop

Draw_Loop:
    
     {paste sprite routine here}

Sprite:

     {paste sprite here}



Ok so it turned out to be more of an actual program than I intended.  
I'm pretty sure that would work but I'm not exactly positive.  Like I 
said before I've been off Assembly for a while so could any of the more 
advanced programmers verify that this is fairly correct for its 
intentions (an example not flawless code)?  I hope that this helps you.

Matt

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com