Re: [stella] 1 cycle!

Subject: Re: [stella] 1 cycle!
From: Dennis Debro <ddebro@xxxxxxxxxxxxx>
Date: Mon, 17 Mar 2003 16:37:41 -0500
Hi Fabrizio,

> The sub that I'm trying to get squeezed by 1 machine cycle is called
> "NextRow". It has to be 150 cycles in total at the end of its execution,
> whatever branches are taken inside of it.. This is because NextRow loads the
> pointer data for the next row of sprites and must take exactly 2 scanlines
> (minus 2 cycles for the jump to it).
> Currently it's 151 :(

I took a quick look. I looks like you could use Thomas' skipDraw for this. That is if the branch to .skipBallDraw is within 127 bytes.

[snip]
.
.
.
.skipBallDraw
  LDA #$00
  STA ENABL
  SLEEP 21
  JMP SkipDrawBall2
.
.
. 

; We have 2 blank lines minus 2 cycles here for a total of 150 cycles
; ************ MUST REMOVE 1 CYCLE FROM NextRow !!! ***************
NextRow  ; 76 cycles -2 from the jump to here
  DEC RowsNumber ; 5
  BEQ EndScreen ; 2
  LDA #0  ; 2
  STA HMOVE ; 3
  STA COLUP0 ; 3
  STA COLUP1 ; 3
 
; --- Draw Ball ---
  DEC ScanCount ; 5
  LDA ScanCount ; 3
  SEC  ; 2 
  SBC BallY ; 3
  ADC #BALL_HEIGHT; 2
;  BCS DrawBall2 ; 2/3
  BCC .skipBallDraw ; using bcc shaves off 1 cycle
;  LDA #0  ; 2
;  STA ENABL ; 3
;  SLEEP 22
;  JMP SkipDrawBall2 ; 3 47
DrawBall2
  LDY BallTabPtr ; 3
  LDA BallSizeTab,Y ; 4
  STA CTRLPF ; 3
  LDA BallEnableTab,Y ; 4
  STA ENABL ; 3
  LDA BallShiftTab,Y ; 4
  STA HMBL ; 3
  DEC BallTabPtr ; 5 ; 47
SkipDrawBall2
 
; --- Load pointers with next row of level data (62 cycles)
  LDY LevelDataPtr
; Unrolling loop to save some cycles...
  LDA (LevelPtrLo),Y ; 5
  STA ptr0 ; 3
  DEY ; 2
  LDA (LevelPtrLo),Y ; 5
  STA ptr1 ; 3
  DEY ; 2
  LDA (LevelPtrLo),Y ; 5
  STA ptr2 ; 3
  DEY ; 2
  LDA (LevelPtrLo),Y ; 5
  STA ptr3 ; 3
  DEY ; 2
  LDA (LevelPtrLo),Y ; 5
  STA ptr4 ; 3
  DEY ; 2
  LDA (LevelPtrLo),Y ; 5
  STA ptr5 ; 3
  DEY ; 2
  STY LevelDataPtr ; 3
; ---
 
  LDY #7  ; 2
  STY LoopCount ; 3
 
  LDA TilesColor,Y ; 4
  LDX ScanNumber ; 3 Next line: tiles or ball?
  BNE BgLine2 ; 2
  BIT $00  ; 3
  JMP NormalLine ; 3 13
BgLine2
  NOP  ; 2+1
  JMP X3  ; 3 13 76
 
> 

Take care,
Dennis

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


Current Thread