Re: [stella] 1 cycle!

Subject: Re: [stella] 1 cycle!
From: Andrew Towers <mariofrog@xxxxxxxxxxx>
Date: Tue, 18 Mar 2003 11:02:10 +1100

Of course indirect LDAs in rom eat up cycles much faster than indexed
zero-page ones, and since the kernel has no WSYNCs, I have to adjust it
every time.. and ended up with one cycle in excess that I don't seem to be
able to get rid of!

You could split the level data across 7 tables in rom (level headers in one table, 6 level columns in the other 6 tables). This way you can eliminate the indirect loads and most of the DEYs, put one table in each page, and there could potentially be 256 rows across all levels.

CopyLevelToRam subroutine
LDA #12 ; offset to level + number of rows in level
STA LevelStartPtr ; for changing levels (adc #rows for next level)
STA LevelDataPtr ; for playing the level


; --- Load pointers with next row of level data (50 cycles)
        LDY LevelDataPtr        ; 3
; Unrolling loop to save some cycles...
        LDA LevelData0,Y        ; 4
        STA ptr0                ; 3
        LDA LevelData1,Y        ; 4
        STA ptr1                ; 3
        LDA LevelData2,Y        ; 4
        STA ptr2                ; 3
        LDA LevelData3,Y        ; 4
        STA ptr3                ; 3
        LDA LevelData4,Y        ; 4
        STA ptr4                ; 3
        LDA LevelData5,Y        ; 4
        STA ptr5                ; 3
        DEY                     ; 2     adjust for next row
        STY LevelDataPtr        ; 3
; ---

This will save you 16 (!) cycles and a couple of bytes of ram, which
IMHO more than makes up for the awkward rom layout ;)

- M.

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


Current Thread