Re: A83: more questions + some code
[Prev][Next][Index][Thread]
Re: A83: more questions + some code
On Mon, 26 Jul 1999 15:53:18 PDT, the homonerdicus wrote:
>
>Hi everybody....
>
>Here I have the code of one of mine routines.
>It works in the following way.
>In mem at the location
>
>(attackingh)
> 30 bytes
>(unit1)
> 10 bytes unit1's data
>(unit2)
> 10 bytes
>(unit3)
> 10 bytes
>
>So for that hero I loop 3 times for the first (de=30) second (de=40) and
>third (de=50) units. It draws each unit and then ret's....
>
>I make ix pont to the attakingh then add the desired offset with de and
>then
>add other offsets with ix for the unit data....
>
>;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
>Draw_units:
> ld de,001Eh ; 30 -> e wich is my counter
>
>left_unit_loop: ;
> push ix ; push 001
> ld (tmpw),ix ;
>
>
> ld ix,(attackingh) ; begin mem location
> add ix,de ;
> ld a,(ix+Nofunits) ;
> ld (tmp),a ;
> jr z,left_unit_loop2 ;
> ld a,(ix+x) ;
> ld b,a ; x coordinate in to b
> ld a,(ix+y) ;
> ld c,a ; y in to c
> ld a,(ix+kind) ; and kind in to a
>
> cp 2d ;
> jr z,load_lich ; depending on
> ; kind... i load the appropriate sprite
>
>load_skeleton:
> ld ix,skeleton_grfx ;
> jr continue_1 ;
>
>load_lich:
> ld ix,lich_grfx ;
>
>
>continue_1:
>
> push de ;push 002
> call convert_cur ; converts bc to the
> ;right coordinates and puts
> ; it in to de
>
> call DRW_SPRW ; sprite routine
> call _grbufcpy_v ;
>
>
> pop de ;pop 002
> pop ix ;pop 001
>
>
>
>
>left_unit_loop2:
> ld a,e ;
> cp 50 ;
> jr z,left_unit_loop_end ; check if e is 50
> add a,10 ; if not add 10
> ld e,a ;
> jr left_unit_loop ;
>
>left_unit_loop_end:
> ret ;
>
>;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
>
>The problem .....
>When I call it once it works fine.
>But if I call it a second time it bugs
>
>I tried calling it twice and I called _dispHL after to verify if it wasn't
>looping infinetly but it came to that command and gave an
>ERR: RESERVED
>I'm out of ideas.... can anybody help ?
>thanks.
>
>any optimisation ?
>
>Q2:
>Do I have to push/pop ix before and after every time I use it ?
>
>
>PS. sorry about the large e-mail....
>
>()()()()()()()()()()()()()()()() ()()()()()()
>() www.homonerdicus.cjb.net () ()visit me()
>()()()()()()()()()()()()()()() ()()()()()()
I haven't read over all the code.. but in answer to Q2, no you shouldn't
have to push/pop ix before and after everytime you use it (at least I don't
think so). In the game I've just finished writing I didn't and it works
fine. I'm sure you know that you have to push/pop iy if you use it though as
it points to the mode flags.
Just as a matter of interest.. I found that the mode flags are at $8567.
James Vernon
jimbob_v@hotmail.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com