Re: A82: My first question of many to come


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

Re: A82: My first question of many to come




In a message dated 98-02-03 15:39:08 EST, you write:

> At 12:00 1998-02-03 -0800, you wrote:
>  >
>  >David Eriksson/2GooD Productions wrote:
>  >
>  >> Why not make a loop (maybe reading the key directly from the i/o port) >
> which updates the animation, say, every 100 times? Replace 100 with > 
> whatever makes good animation speed.
>  >> 
>  >
>  >	How exactly would I go about doing this? In other words, how do I check
>  >hl for every 100th count? Or Nth count, whatever.
>  
>  I'd probably make a separate count or an inner loop, but you could also do 
> like this:
>  
>  ; HL is counter
>  LD   A, L
>  AND  15
>  JP   Z, Event
>  ; Repeat loop
>  
>  This code would make a jump to 'event' every 16 loops. As you probably know
> the bitwise AND operation extract certain bits. So you trigger an event when
> certain low bits are zero. 
>  Note: this only works with powers of two. AND with 3 to do it every four 
> loops, with 7 to do it every 8 loops, etc.
>  
>  (Somehow powers of two always appears in assembly... :-)
>  
>  
>  Regards,
>                       -/- David Eriksson -/-
>  
>  2 G o o D   P r o d u c t i o n s  ->  http://www.2goodsoft.com/

Or, as an alternative, I recommend using a memory variable and inc it every
time you go thru the main loop.  8 bits should be enough.  Then have it check
the mem var every loop and have it update the animation every nth time

push hl
ld hl, myvar
inc (hl)
ld a, (hl)
cp whatever_value
call z, UPDATE_ANIMATION
pop hl
...

where UPDATE_ANIMATION would also reset (myvar) to 0
Also, you could have UPDATE_ANIMATION set (myvar) to whatever_value and then
dec it (check for 0 with 'or a' of course).  I think this is the best method.
Looking forward to Dune2!!!

~Adamman