mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-11 09:29:51 +00:00
tfv: add cache for the color values
This commit is contained in:
parent
71fde333c9
commit
92e9d3a055
@ -99,15 +99,29 @@ struct cycle_counts {
|
||||
int put_sprite;
|
||||
} cycles;
|
||||
|
||||
static int last_color=0,last_xx=0,last_yy=0;
|
||||
|
||||
static int lookup_map(int xx, int yy) {
|
||||
|
||||
int color,offset;
|
||||
|
||||
color=2;
|
||||
/* cache last value */
|
||||
cycles.lookup_map+=9;
|
||||
if (yy==last_yy) {
|
||||
cycles.lookup_map+=8;
|
||||
if (xx==last_xx) {
|
||||
cycles.lookup_map+=8;
|
||||
return last_color;
|
||||
}
|
||||
}
|
||||
|
||||
last_xx=xx;
|
||||
xx=xx&MASK_X;
|
||||
|
||||
last_yy=yy;
|
||||
yy=yy&MASK_Y;
|
||||
|
||||
|
||||
if (!displayed) {
|
||||
printf("XX,YY! %x,%x\n",xx,yy);
|
||||
}
|
||||
@ -119,24 +133,32 @@ static int lookup_map(int xx, int yy) {
|
||||
offset=yy<<3;
|
||||
offset+=xx;
|
||||
|
||||
// color=water_map[((yy*8)+xx)&0x1f];
|
||||
color=water_map[offset&0x1f];
|
||||
cycles.lookup_map+=37;
|
||||
|
||||
if ((yy>7) || (xx>7)) {
|
||||
cycles.lookup_map+=14;
|
||||
color=water_map[offset&0x1f];
|
||||
cycles.lookup_map+=11;
|
||||
goto update_cache;
|
||||
|
||||
}
|
||||
|
||||
/* 2 2 2 2 2 2 2 2 */
|
||||
/* e 2 2 2 2 2 2 2 */
|
||||
/* 2 2 2 2 2 2 2 2 */
|
||||
/* 2 2 2 2 e 2 2 2 */
|
||||
|
||||
if ((yy<8) && (xx<8)) {
|
||||
color=flying_map[offset];
|
||||
}
|
||||
color=flying_map[offset];
|
||||
cycles.lookup_map+=8;
|
||||
|
||||
if (!displayed) {
|
||||
printf("COLOR! %x\n",color);
|
||||
}
|
||||
|
||||
|
||||
cycles.lookup_map+=53;
|
||||
update_cache:
|
||||
cycles.lookup_map+=9;
|
||||
last_color=color;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -58,3 +58,16 @@ Update to optimize fast multiply (reusing NUM1H, return results in register)
|
||||
Total = 135,575
|
||||
Frame Rate = 7.38 fps
|
||||
|
||||
Add a cache to lookup_map
|
||||
|
||||
Cycles: flying= 162
|
||||
Cycles: getkey= 46
|
||||
Cycles: page_flip= 26
|
||||
Cycles: multiply= 24,935
|
||||
Cycles: mode7= 73,445
|
||||
Cycles: lookup_map= 24,649
|
||||
Cycles: put_sprite= 2,561
|
||||
=================================
|
||||
Total = 125,824
|
||||
Frame Rate = 7.95 fps
|
||||
|
||||
|
@ -12,7 +12,7 @@ CONST_BETA_F EQU $80
|
||||
CONST_SCALE_I EQU $14
|
||||
CONST_SCALE_F EQU $00
|
||||
CONST_LOWRES_HALF_I EQU $ec ; -(LOWRES_W/2)
|
||||
CONST_LOWRES_HALF_F EQU $00
|
||||
CONST_LOWRES_HALF_F EQU $00
|
||||
|
||||
flying_start:
|
||||
|
||||
@ -955,11 +955,27 @@ done_screeny:
|
||||
; finds value in space_x.i,space_y.i
|
||||
; returns color in A
|
||||
lookup_map:
|
||||
|
||||
; cache color and return if same as last time
|
||||
lda SPACEY_I ; 3
|
||||
cmp LAST_SPACEY_I ; 3
|
||||
bne nomatch ; 2nt/3
|
||||
lda SPACEX_I ; 3
|
||||
cmp LAST_SPACEX_I ; 3
|
||||
bne nomatch2 ; 2nt/3
|
||||
lda LAST_MAP_COLOR ; 3
|
||||
rts ; 6
|
||||
|
||||
nomatch:
|
||||
lda SPACEX_I ; 3
|
||||
nomatch2: ; 3
|
||||
sta LAST_SPACEX_I ; 3
|
||||
and #CONST_MAP_MASK ; 2
|
||||
sta TEMPY ; 3
|
||||
tay ; 2
|
||||
|
||||
lda SPACEY_I ; 3
|
||||
sta LAST_SPACEY_I ; 3
|
||||
and #CONST_MAP_MASK ; wrap to 64x64 grid ; 2
|
||||
|
||||
|
||||
@ -967,28 +983,31 @@ lookup_map:
|
||||
asl ; 2
|
||||
asl ; multiply by 8 ; 2
|
||||
clc ; 2
|
||||
adc TEMPY ; add in X value ; 2
|
||||
; (use OR instead?)
|
||||
adc TEMPY ; add in X value ; 3
|
||||
; only valid if x<8 and y<8
|
||||
|
||||
ldy SPACEX_I ; 3
|
||||
cpy #$8 ; 2
|
||||
beq ocean_color ; bgt ; 2nt/3
|
||||
bcs ocean_color ; 2nt/3
|
||||
; SPACEX_I is in y
|
||||
cpy #$9 ; 2
|
||||
;============
|
||||
; 37
|
||||
|
||||
bcs ocean_color ; bgt 8 ; 2nt/3
|
||||
ldy SPACEY_I ; 3
|
||||
cpy #$8 ; 2
|
||||
beq ocean_color ; bgt ; 2nt/3
|
||||
bcs ocean_color ; 2nt/3
|
||||
cpy #$9 ; 2
|
||||
bcs ocean_color ; bgt 8 ; 2nt/3
|
||||
|
||||
tay ; 2
|
||||
lda flying_map,Y ; load from array ; 4
|
||||
|
||||
rts ; 6
|
||||
bcc update_cache ; 3
|
||||
|
||||
ocean_color:
|
||||
and #$1f ; 2
|
||||
tay ; 2
|
||||
lda water_map,Y ; the color of the sea ; 4
|
||||
|
||||
update_cache:
|
||||
sta LAST_MAP_COLOR ; 3
|
||||
rts ; 6
|
||||
|
||||
flying_map:
|
||||
|
@ -89,7 +89,10 @@ NUM1H EQU $7F
|
||||
NUM2L EQU $80
|
||||
NUM2H EQU $81
|
||||
RESULT EQU $82 ; 83,84,85
|
||||
NEGATE EQU $86
|
||||
NEGATE EQU $86 ; UNUSED?
|
||||
LAST_SPACEX_I EQU $87
|
||||
LAST_SPACEY_I EQU $88
|
||||
LAST_MAP_COLOR EQU $89
|
||||
|
||||
SHIPY EQU $E4
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user