RE: SPAM-LOW: Re: [stella] Reflex: Yeah! Skipdraw incorporated!

Subject: RE: SPAM-LOW: Re: [stella] Reflex: Yeah! Skipdraw incorporated!
From: "Lee Fastenau" <stella@xxxxxxxxxxxxxxx>
Date: Mon, 6 Sep 2004 11:10:03 -0500
> That got me curious to take a look. :-)
> I diffed ver 75 and 76 and found the change you mentioned.
> dey
> SLEEP 13
> beq .enterHere    (changed to jmp .enterHere in 76)

Funny thing was, I originally used a BNE instruction because I _knew_ the
DEY instruction would clear the zero flag.  And I assumed that SLEEP would
not affect the zero flag.  But at some point during my skipdraw coding, I
introduced the NO_ILLEGAL_OPCODES constant, which caused SLEEP to do exactly
that.  At least, that's what I think happened.

> If you build reflex75.asm with -lreflex75.lst (generate a listing file)
> then you can inspect what was generated for the SLEEP macro. (I've
> removed some of the macro syntax for clarity)
>      12  f099               24 00              bit    VSYNC
>      18  f09b               ea              nop
>      18  f09c               ea              nop
>      18  f09d               ea              nop
>      18  f09e               ea              nop
>      18  f09f               ea              nop
>     382  f0a0               f0 0d              beq    .enterHere

My "assemble and run" batch file generates the list every time, but I rarely
look at it...

> So what you have is the reliance on bit VSYNC setting the Z bit in the
> flags. For a bit instruction, the Z flag is set as (Accumulator AND
> VSYNC) so I think what you have proven is that 'in the wild' or at least
> on a supercharger, reading VSYNC can return a non-zero value. You also
> have a non-zero value in A. So the result must clear the Z flag. It does
> seem to be a leap of faith to read from VSYNC, AND it with the
> accumulator and hope to get a zero result in this situation.
> If you really wanted to save a byte I think you could cook up something
> in the 7 bytes that kills the 13 cycles and reliably sets the flags. For
> instance you could remove the bit VSYNC and replace it with a LDA zpage
> and then load from a known constant (or known non-zero) and do a bne...
>  - David

I feel like I have a bunch of elbow room right now, but I'll definitely keep
this in mind.  When I start getting crunched for ROM, I'll roll the longer
SLEEPs up into loops.  But for now, at least I've learned something new
about the SLEEP macro. :)

Thanks for the great analysis.

Current Thread