Re: A86: Enhanced Checking Routine?
[Prev][Next][Index][Thread]
Re: A86: Enhanced Checking Routine?
The routine that TreyJazz is suggesting I think wouldn't work, because it would check if
there is a duck to the right of the gun (or left, but not both)
Also, in your code, the reason it is taking so lonk os because you are using the OP
registers when it's not necessary. Rather than making 2 calls per check, it would be
better to use the built in opcodes (cp)... Load the duck coord into A, the gun coord into
B, and then use cp B... it returns the same thing as _CPOP1OP2 (actually, it's the other
way around), so you can still check if the z flag is set. There is a better way, to do
it, tho, and that's with 4 checks that all require the previous one to pass before you do
the next one (i.e. jr nc,failed if the c flag is what is wanted). If you decrement the
gun's X by 3, and the gun's X<duck's X, then check if the gun's X (b4 you dec it)+3 is>the
duck's X, then proceed to do the same with the Y's... (That probably didn't come out
right, but try to bear with me)... Using the built in ld and cp routines, along with that
algorithm would greatly speed up your code...
A. El-Helw wrote:
> >
> >load the x coords of the duck into a and compare it to the x coord of
> >the gun(x2), then compare it to a and if a<=x2 keep going, then check to
> >see that a+8>=x2, if that is good go to y and do the same thing
> >
>
> But how would you do this though? You would still end up repeating the
> routine 6 times... could you write the routine, maybe I misunderstood you.
> Here is the routine i use in DuckHunt, etc.
>
> ld a,(duckx)
> call _setxxop1 ;Into Op1
> ld a,(gunx)
> call _setxxop2 ;Into Op2
> call _cpop1op2 ;Compare the Ops
> jp z,Hit ;If equal, hit [jp c,greater, jp nz,less]
> ld a,(gunx) ;Basically adding to gun 3, then subtracting 3... loop 6 times
> inc a ;Increase it
> call _setxxop2 ;Into Op2
> call _cpop1op2 ;Compare again
> jp z,Hit
>
> As you can see, it is a tiresome process... And doing it 6 times takes
> time and mem, esp. for a program that checks a lot of stuff... so if anyone
> can help, please do so...
>
> -Ahmed
--
Stephen Hicks
mailto:shicks@mindspring.com
UIN:5453914
AIM:Kupopo1
Follow-Ups:
References: