ldy #$08 ldx #63 clc Loop: dec $d016 sty $d016 lda DYSP_DelayTableZP,x sta SMC+1 SMC: bcc *+2 and #$29 and #$29 and #$29 and #$29 and #$29 and #$29 and #$29 and #$29 and $ea nop lda CollTable1ZP,x sta $d021 lda D11Table,x sta $d011 dex bpl Loop
CalculateDelayTableDYSP: .pc = * "DYSP Delay Table" // Initialize table ldx #63 lda #$00 // 00 = no spirtes !: sta DYSP_DelayTableZP,x dex bpl !- .const kfactor = 1 // Fill in location of the sprites into the table (first and last+1 pixel) lda $d001 sec sbc #OffsetY tax lda #%00000001 sta DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor+21,x lda $d003 sec sbc #OffsetY tax lda #%00000010 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%00000010 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d005 sec sbc #OffsetY tax lda #%00000100 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%00000100 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d007 sec sbc #OffsetY tax lda #%00001000 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%00001000 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d009 sec sbc #OffsetY tax lda #%00010000 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%00010000 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d00b sec sbc #OffsetY tax lda #%00100000 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%00100000 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d00d sec sbc #OffsetY tax lda #%01000000 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%01000000 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x lda $d00f sec sbc #OffsetY tax lda #%10000000 ora DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor,x lda #%10000000 ora DYSP_DelayTableZP+kfactor+21,x sta DYSP_DelayTableZP+kfactor+21,x // EOR Fill the spritemasks lda #$00 .for (var i = 0 ; i < 64 ; i++) { eor DYSP_DelayTableZP+i sta DYSP_DelayTableZP+i } // Replace spritemasks with timing values .for (var i = 0 ; i < 64 ; i++) { ldx DYSP_DelayTableZP+i lda TimingTable,x sta DYSP_DelayTableZP+i } // Flipp Table .for (var i = 0 ; i < 32 ; i++) { lda DYSP_DelayTableZP+i+0 ldy DYSP_DelayTableZP+63-i sty DYSP_DelayTableZP+i+0 sta DYSP_DelayTableZP+63-i } rts
lda $d001 sec sbc #OffsetY tax lda #%00000001 sta DYSP_DelayTableZP+kfactor,x sta DYSP_DelayTableZP+kfactor+21,x
ldx $d001 lda #%00000001 sta DYSP_DelayTableZP+kfactor-OffsetY,x sta DYSP_DelayTableZP+kfactor+21-OffsetY,x
(might have to add $10000 to those addresses if OffsetY is greater than DYSP_DelayTableZP+1, which will add a couple of cycles to the stores, but still faster than subtracting OffsetY from X)
It won't add cycles. zp,x doesn't have page boundary handling. It just wraps around in zp. What you do is just take &$ff on the address to utilize that.