Re: [stella] skipDraw explained (I hope) (was: bipolar joustpong)

Subject: Re: [stella] skipDraw explained (I hope) (was: bipolar joustpong)
From: "Eric Ball" <ericball@xxxxxxxxxxxx>
Date: Sat, 6 Sep 2003 01:23:12 -0400
> BTW, I looked at RobotCity for an example and it's there too. Thomas
> will have to explain how he does this without moving the accumulator to
> y.
>
> .contDrawPlayer:
>     dey
>     tya
>     sbc yPosP0
>     adc #H_TANK
>     bcs.doDrawP0
>     lda #0
>     NOP_W
> .doDrawP0:
>     lda (ptrP0),y
>     sta.w GRP0

The key is the NOP_W, which is an equate for $0C, which is the opcode NOP
abs.  (An illegal/undocumented version of NOP.  The documented way is to use
$2C which is BIT abs)  So if the bcs is not taken the lda (ptrP0),y gets
absorbed into the NOP and is not executed.

The other advantage is this routine is always the same number of cycles.
2 bcs.doDrawP0 not taken
2 lda #0
4 NOP_W
8 Total

3 bcs.doDrawP0 taken
5 lda (ptrP0),y = 5

8 Total

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread