At the risk of sounding like a right numpty, is it something like this? (original code from Nerdy Nights 5)
Code: Select all
;INSTEAD OF DOING THIS
LoadSprites:
LDX #$00 ; start at 0
LoadSpritesLoop:
LDA sprites, x ; load data from address (sprites + x)
STA $0200, x ; store into RAM address ($0200 + x)
INX ; X = X + 1
CPX #$10 ; Compare X to hex $10, decimal 16
BNE LoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
; if compare was equal to 16, continue down
;DO THIS?
LoadSprites:
LDX #$00 ; start at 0
LoadSpritesLoop:
LDA sprites, x ; load data from address (sprites + x)
STA $0200, x ; store into RAM address ($0200 + x)
INX ; X = X + 1
LDA sprites, x ; load data from address (sprites + x)
STA $0200, x ; store into RAM address ($0200 + x)
INX ; X = X + 2
LDA sprites, x ; load data from address (sprites + x)
STA $0200, x ; store into RAM address ($0200 + x)
INX ; X = X + 3
LDA sprites, x ; load data from address (sprites + x)
STA $0200, x ; store into RAM address ($0200 + x)
INX ; X = X + 4
CPX #$10 ; Compare X to hex $10, decimal 16
BNE LoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
; if compare was equal to 16, continue downI work out the total clock cycles for the first loop to be 18 if the branch is taken, and 17 if the branch is not taken. So 18*15=270 and then add 17 for the last run through in which the branch is not taken 270+17=287.
I work out the second loop as taking 51 cycles if the branch is taken, 50 if the branch is not taken. So 51*3=153 and then add 50 for the last run through in which the branch is not taken 153+50=203.
Therefore, ya save 84 cycles?
The last time I did any serious math (though I doubt you guys would consider this serious) was when I was in school, so please, be nice!
Thanks y'all