tfv: inner loop optimization

This commit is contained in:
Vince Weaver 2017-11-29 23:17:32 -05:00
parent 863e5e5957
commit dc0827941e
3 changed files with 19 additions and 7 deletions

View File

@ -838,7 +838,7 @@ match:
ram[SCREEN_X]++;
if (ram[SCREEN_X] >= LOWRES_W) break;
cycles.mode7+=43;
cycles.mode7+=41;
/* cache last value */

View File

@ -186,5 +186,19 @@ In-line unsigned multiply inside of signed multiply (save 12 cycles)
Frame Rate = 5.42 fps
Have loop counter count down from 40 instead of count up (avoid compare)
Cycles: flying= 187
Cycles: getkey= 46
Cycles: page_flip= 26
Cycles: multiply= 40,888
Cycles: mode7= 115,538
Cycles: lookup_map= 22,747
Cycles: put_sprite= 2,561
================================
Total = 181,993
Frame Rate = 5.49 fps
Each cycle removed from inner X loop saves
32*40=1280 cycles

View File

@ -935,8 +935,7 @@ calc_horizontal_scale:
; brk ; space_y = f7:04
; FIXME: start at 40 and decrement?
ldx #0 ; was SCREEN_X ; 2
ldx #40 ; was SCREEN_X ; 2
;==========
; 22
screenx_loop:
@ -994,11 +993,10 @@ dyi_label:
adc #0 ; 2
sta SPACEY_I ; 3
inx ;inc SCREEN_X ; 2
cpx #40 ; LOWRES width ; 2
beq done_screenx_loop ; 2nt/3
dex ; decrement SCREEN_X ; 2
beq done_screenx_loop ; branch until we've done 40 ; 2nt/3
;=============
; 43
; 41
; cache color and return if same as last time