## Re: [stella] Assymetrical Maze 2LK... help?

 Subject: Re: [stella] Assymetrical Maze 2LK... help? From: "J Parlee" Date: Wed, 29 Jan 2003 13:42:31 -0500
```Thomas wrote:
> Hm, as always exact cycle counts would have helped a lot, but anyway...

Agh!.. sorry...  The only correct counts on the original post were on the
second PF writes... here it is again with (I hope!) "correct" counting:

SkipDraw   ;4
LDA #00   ;[4]+3 = 7  waste 3 cycles
NOP   ;[7]+2 = 9
JMP Next  ;[9]+3 =12

....

LDY #90
STY ScanLine
ScanLoop
TYA                               ;[20]+2 =
TAX                               ;[22]+2 =
LDA PFData0,X             ;[24] +4 =
STA WSYNC
STA PF0                       ;[0] +3 = *3*   < 23
NOP                                  ;[3] +2 = 5
NOP                                  ;[5] +2 = 7
NOP                                  ;[7] +2 = 9
NOP                                  ;[9] +2 = 11
NOP                                  ;[11]+2 = 13
LDA PFData1,X           ;[13]+4 = 17
STA PF1                     ;[17]+3 = *20*  < 29
LDA PFData2,X           ;[20]+4
STA PF2                     ;[24]+3 = *27*  < 40
LDA PFRData0,X       ;[27]+4 = 31
STA PF0                                  ;[31]+3 = *34*
LDA PFRData1,X      ;[34]+4 = 38
STA PF1                   ;[38]+3 = *41*
LDA PFRData2,X      ;[41]+4 = 45
STA PF2                   ;[45]+3 = *48*
LDY ScanLine          ;[48]+3 = 51
TYA                           ;[51]+2 = 53
SEC                           ;[53]+2 = 55
SBC yPos0                  ;[55]+3 = 58
NOP                                  ;[61]+2 = 63
NOP                                  ;[63]+2 = 65
NOP                                  ;[65]+2 = 67
NOP                                  ;[67]+2 = 69
NOP                                  ;[69]+2 = 71
NOP                                  ;[71]+2 = 73
NOP                                  ;[73]+2 = 76
NOP                                  ;[75]+2 = 77
;    STA WSYNC
BCC SkipDraw                  ;[1]+2 = 3 3
TAY                                  ;[3]+2 = 5
LDA KcData1,Y              ;[5]+4 = 9
STA GRP0                      ;[9]+3 = *12*
Next
DEC ScanLine  ;[12]+3 = 15
LDY ScanLine  ;[15]+3 = 18
BNE ScanLoop  ;[18]+2 = 20
STA WSYNC
>
> The problem of your kernel is, that some of the writes (PF1/2) for the
right
> half of the PF come too early.

I've tried adding NOP's and "waste" instructions to move the second PF2
write around from cycle 45 to cycle 49 and the changes are almost
undetectable...

>
> Here are the timings (directly copied from my Thrust kernel):
>
> Left:
>   PF0: z <= 22
>   PF1: z <= 27
>   PF2: z <= 38
>
> Right:
>   PF0: 28 <= z <= 49
>   PF1: 38 <= z <= 54
>   PF2: 49 <= z <= 65

Now are you writing to PF2 at cycle 49 (finished at 52) or are you writing
at 46 (finished at 49)?

>
> I'm not sure if the cycles are 100% exact (IIRC right PF2 can start from
48), but
> they should give you an idea.