Re: [stella] Optimizing Qb (was: Horizontal Positioning once more...)

Subject: Re: [stella] Optimizing Qb (was: Horizontal Positioning once more...)
From: Manuel Polik <cybergoth@xxxxxxxx>
Date: Wed, 08 Aug 2001 13:17:45 +0200
Thomas Jentzsch schrieb:

> > Here's my idea:
> > ----------------------------------------
> >             STA HMP0,x
> >             INY                               ; Waste 5 cycles, 1 Byte
> >             STA WSYNC
> >             INY                               ; Waste 7(!) cycles, 1 Byte
> >             BIT 0                     ; Waste 3 cycles, 2 Byte
> >                                       ; + sum: 15 cycles, _4_ Byte!!!
> > PosDelay    dey
> >             bpl PosDelay
> >             STA RESP0,x
> > ----------------------------------------
> >
> > Apart from saving a byte, it prevents you from possibly losing another
> > two byte to the stack...
> > (Avoiding that was my original intention, in Gunfight there's _never_ a
> > subroutine call within a subroutine call within a subroutine :-))
 
> Yes, that should work, but sometimes you might waste a hole scanline when your first additional dey causes WSYNC to start to late.

Actually I had to force the routine to lose this scanline _always_,
since otherwise I didn't get a stable picture :-)
The STA WSYNC was coming late on unpredictable occassions, since I've
two different entry points into the positioning routine, one adding
#$08, one adding #$09, then there's all this branches in it...

The mess looks like this now:
-----------------------------
PosPlayer2	; For HMOVE on cycle 74
            CLC 
            ADC #$08
PosPlayer1	; For normal HMOVE
            CLC 
            ADC #$01
            CMP #$A0
            BCC NH2
            SBC #$A0
NH2
            TAY
            LSR
            LSR
            LSR
            LSR
            STA tempVar1
            TYA
            AND #15
            CLC
            ADC tempVar1
            LDY tempVar1
            CMP #15
            BCC NH
            SBC #15
            INY
NH
            STA WSYNC			; Force the line to end
            EOR #7
            ASL
            ASL
            ASL
            ASL
            STA HMP0,x
            INY                         ; Waste 5 cycles, 1 Byte
            STA WSYNC
            INY                         ; Waste 7(!) cycles, 1 Byte
            BIT 0                       ; Waste 3 cycles, 2 Byte
PosDelay    DEY
            BPL PosDelay
            STA RESP0,x
            RTS

In my case I can fortunately waste all these cycles/scanlines without
any real drawbacks :-)
 
> You might have a look at this:
> ----------------------------------------
>         sta HMP0,x
>         sta WSYNC
> 
>         iny             ; waste 7 cylces, 1 byte
>         iny             ; waste 7 cylces, 1 byte
> 
> Jiggle  dey
>         bpl Jiggle
>         sta.w RESP0,x   ; waste 1 cylce, 1 byte
>                         ; sum = 15 cylces, 3 bytes
> ----------------------------------------
> One more byte saved and the WSYNC problem is gone too :)

For some reasons this causes complete chaos... Maybe the .w cycle is
gained right _after_ it was needed?

Greetings,
	Manuel

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

Current Thread