mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-03-06 03:29:46 +00:00
tfv: update with over_water optimization
This commit is contained in:
parent
3430394d99
commit
024d38ce36
@ -42,7 +42,7 @@
|
|||||||
#define DRAW_SPLASH 0x7a
|
#define DRAW_SPLASH 0x7a
|
||||||
#define SPEED 0x7b
|
#define SPEED 0x7b
|
||||||
#define SPLASH_COUNT 0x7c
|
#define SPLASH_COUNT 0x7c
|
||||||
#define OVER_WATER 0x7d
|
#define OVER_LAND 0x7d
|
||||||
#define NUM1L 0x7E
|
#define NUM1L 0x7E
|
||||||
#define NUM1H 0x7F
|
#define NUM1H 0x7F
|
||||||
#define NUM2L 0x80
|
#define NUM2L 0x80
|
||||||
@ -799,13 +799,14 @@ shift_output:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void draw_background_mode7(void) {
|
|
||||||
|
|
||||||
|
static void draw_background_mode7(void) {
|
||||||
|
|
||||||
|
|
||||||
int map_color;
|
int map_color;
|
||||||
|
|
||||||
ram[OVER_WATER]=0;
|
cycles.mode7+=6;
|
||||||
cycles.mode7+=11;
|
|
||||||
if (ram[DRAW_SKY]) {
|
if (ram[DRAW_SKY]) {
|
||||||
|
|
||||||
ram[DRAW_SKY]--;
|
ram[DRAW_SKY]--;
|
||||||
@ -828,6 +829,7 @@ void draw_background_mode7(void) {
|
|||||||
|
|
||||||
|
|
||||||
cycles.mode7+=30;
|
cycles.mode7+=30;
|
||||||
|
|
||||||
/* FIXME: only do this if SPACEZ changes? */
|
/* FIXME: only do this if SPACEZ changes? */
|
||||||
// mul1
|
// mul1
|
||||||
fixed_mul(ram[SPACEZ_I],ram[SPACEZ_F],
|
fixed_mul(ram[SPACEZ_I],ram[SPACEZ_F],
|
||||||
@ -841,10 +843,6 @@ void draw_background_mode7(void) {
|
|||||||
ram[FACTOR_I],ram[FACTOR_F]);
|
ram[FACTOR_I],ram[FACTOR_F]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("spacez=%lf beta=%lf factor=%lf\n",
|
|
||||||
// fixed_to_double(ram[SPACEZ_I],ram[SPACEZ_F],),
|
|
||||||
// fixed_to_double(&BETA),
|
|
||||||
// fixed_to_double(ram[FACTOR_I],ram[FACTOR_F]));
|
|
||||||
cycles.mode7+=12;
|
cycles.mode7+=12;
|
||||||
|
|
||||||
for (ram[SCREEN_Y] = 8; ram[SCREEN_Y] < LOWRES_H; ram[SCREEN_Y]+=2) {
|
for (ram[SCREEN_Y] = 8; ram[SCREEN_Y] < LOWRES_H; ram[SCREEN_Y]+=2) {
|
||||||
@ -977,12 +975,12 @@ void draw_background_mode7(void) {
|
|||||||
ram[COLOR]=map_color;
|
ram[COLOR]=map_color;
|
||||||
ram[COLOR]|=map_color<<4;
|
ram[COLOR]|=map_color<<4;
|
||||||
|
|
||||||
if ((ram[SCREEN_X]==20) && (ram[SCREEN_Y]==38)) {
|
// if ((ram[SCREEN_X]==20) && (ram[SCREEN_Y]==38)) {
|
||||||
if (map_color==COLOR_DARKBLUE) ram[OVER_WATER]=1;
|
// if (map_color==COLOR_DARKBLUE) ram[OVER_WATER]=1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
hlin_double_continue(1);
|
hlin_double_continue(1);
|
||||||
cycles.mode7+=42;
|
cycles.mode7+=19;
|
||||||
|
|
||||||
// advance to the next position in space
|
// advance to the next position in space
|
||||||
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
||||||
@ -1043,7 +1041,6 @@ int flying(void) {
|
|||||||
ram[DRAW_SPLASH]=0;
|
ram[DRAW_SPLASH]=0;
|
||||||
ram[SPEED]=0;
|
ram[SPEED]=0;
|
||||||
ram[SPLASH_COUNT]=0;
|
ram[SPLASH_COUNT]=0;
|
||||||
ram[OVER_WATER]=0;
|
|
||||||
|
|
||||||
ram[ANGLE]=1; /* 1 so you can see island */
|
ram[ANGLE]=1; /* 1 so you can see island */
|
||||||
|
|
||||||
@ -1140,7 +1137,6 @@ int flying(void) {
|
|||||||
|
|
||||||
/* Land the ship */
|
/* Land the ship */
|
||||||
for(loop=ram[SPACEZ_I];loop>0;loop--) {
|
for(loop=ram[SPACEZ_I];loop>0;loop--) {
|
||||||
|
|
||||||
draw_background_mode7();
|
draw_background_mode7();
|
||||||
cycles.put_sprite+=grsim_put_sprite(shadow_forward,CONST_SHIPX+3,31+ram[SPACEZ_I]);
|
cycles.put_sprite+=grsim_put_sprite(shadow_forward,CONST_SHIPX+3,31+ram[SPACEZ_I]);
|
||||||
cycles.put_sprite+=grsim_put_sprite(ship_forward,CONST_SHIPX,ram[SHIPY]);
|
cycles.put_sprite+=grsim_put_sprite(ship_forward,CONST_SHIPX,ram[SHIPY]);
|
||||||
@ -1189,7 +1185,16 @@ int flying(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draw_background_mode7();
|
draw_background_mode7();
|
||||||
cycles.flying+=6;
|
|
||||||
|
{ int landing_color,tx,ty;
|
||||||
|
tx=ram[CX_I]; ty=ram[CY_I];
|
||||||
|
|
||||||
|
landing_color=lookup_map(tx,ty);
|
||||||
|
if (landing_color==2) ram[OVER_LAND]=0;
|
||||||
|
else ram[OVER_LAND]=1;
|
||||||
|
}
|
||||||
|
cycles.flying+=31;
|
||||||
|
|
||||||
ram[DRAW_SPLASH]=0;
|
ram[DRAW_SPLASH]=0;
|
||||||
cycles.flying+=11;
|
cycles.flying+=11;
|
||||||
if (ram[SPEED]>0) {
|
if (ram[SPEED]>0) {
|
||||||
@ -1198,7 +1203,7 @@ int flying(void) {
|
|||||||
ram[SPLASH_COUNT]=1;
|
ram[SPLASH_COUNT]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ram[OVER_WATER]) && (ram[SPLASH_COUNT])) {
|
if ((!ram[OVER_LAND]) && (ram[SPLASH_COUNT])) {
|
||||||
ram[DRAW_SPLASH]=1;
|
ram[DRAW_SPLASH]=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,3 +84,16 @@ Don't draw sky every frame
|
|||||||
Total = 121,478
|
Total = 121,478
|
||||||
Frame Rate = 8.23 fps
|
Frame Rate = 8.23 fps
|
||||||
|
|
||||||
|
Move checking if over water out of critical section
|
||||||
|
|
||||||
|
Cycles: flying= 187
|
||||||
|
Cycles: getkey= 46
|
||||||
|
Cycles: page_flip= 26
|
||||||
|
Cycles: multiply= 24,935
|
||||||
|
Cycles: mode7= 54,374
|
||||||
|
Cycles: lookup_map= 24,712
|
||||||
|
Cycles: put_sprite= 2,561
|
||||||
|
=================================
|
||||||
|
Total = 106,841
|
||||||
|
Frame Rate = 9.36 fps
|
||||||
|
|
||||||
|
16
tfv/TODO
16
tfv/TODO
@ -1,18 +1,10 @@
|
|||||||
mode7 speed fixes:
|
mode7 speed fixes:
|
||||||
+ Don't draw sky every frame, only if needed
|
|
||||||
|
|
||||||
+ faster multiply routine
|
+ faster multiply routine
|
||||||
+ If result is AABBCCDD we only need BBCC for fixed point
|
- If result is AABBCCDD we only need BBCC for fixed point
|
||||||
result
|
result
|
||||||
+ Pass NUM1H in A? no because used multiple places
|
- Pass NUM1H in A? no because used multiple places
|
||||||
+ inline hlin_setup? (save 12 cycles)
|
|
||||||
|
|
||||||
+ re-arrange variables to better take advantage of self-modifying code
|
+ inline hlin_setup? (save 12 cycles)
|
||||||
+ only doing the spacez calculation if it has changed
|
|
||||||
+ update the constants to be constants
|
|
||||||
+ move the screen width constant to own set of varaibles
|
|
||||||
(instead of temp)
|
|
||||||
+ leave one of multiply results in accumulator at end?
|
|
||||||
|
|
||||||
+ Skip key parsing if no key read
|
+ Skip key parsing if no key read
|
||||||
|
|
||||||
|
BIN
tfv/tfv.dsk
BIN
tfv/tfv.dsk
Binary file not shown.
@ -42,7 +42,6 @@ flying_start:
|
|||||||
sta DRAW_SPLASH
|
sta DRAW_SPLASH
|
||||||
sta SPEED
|
sta SPEED
|
||||||
sta SPLASH_COUNT
|
sta SPLASH_COUNT
|
||||||
sta OVER_WATER
|
|
||||||
|
|
||||||
lda #1
|
lda #1
|
||||||
sta ANGLE
|
sta ANGLE
|
||||||
@ -339,6 +338,21 @@ speed_loop:
|
|||||||
draw_background:
|
draw_background:
|
||||||
jsr draw_background_mode7 ; 6
|
jsr draw_background_mode7 ; 6
|
||||||
|
|
||||||
|
check_over_water:
|
||||||
|
; See if we are over water
|
||||||
|
lda CX_I ; 3
|
||||||
|
sta SPACEX_I ; 3
|
||||||
|
lda CY_I ; 3
|
||||||
|
sta SPACEY_I ; 3
|
||||||
|
|
||||||
|
jsr lookup_map ; 6
|
||||||
|
|
||||||
|
sec ; 2
|
||||||
|
sbc #COLOR_BOTH_DARKBLUE ; 2
|
||||||
|
sta OVER_LAND ; 3
|
||||||
|
;===========
|
||||||
|
; 31
|
||||||
|
|
||||||
; Calculate whether to draw the splash
|
; Calculate whether to draw the splash
|
||||||
|
|
||||||
lda #0 ; set splash drawing to 0 ; 2
|
lda #0 ; set splash drawing to 0 ; 2
|
||||||
@ -358,8 +372,8 @@ draw_background:
|
|||||||
sta SPLASH_COUNT ; 3
|
sta SPLASH_COUNT ; 3
|
||||||
|
|
||||||
no_turning_splash:
|
no_turning_splash:
|
||||||
lda OVER_WATER ; no splash if over land ; 3
|
lda OVER_LAND ; no splash if over land ; 3
|
||||||
beq no_splash ; 2nt/3
|
bne no_splash ; 2nt/3
|
||||||
|
|
||||||
lda SPLASH_COUNT ; no splash if splash_count expired ; 3
|
lda SPLASH_COUNT ; no splash if splash_count expired ; 3
|
||||||
beq no_splash ; 2nt/3
|
beq no_splash ; 2nt/3
|
||||||
@ -533,9 +547,6 @@ draw_ship:
|
|||||||
|
|
||||||
draw_background_mode7:
|
draw_background_mode7:
|
||||||
|
|
||||||
lda #0 ; 2
|
|
||||||
sta OVER_WATER ; 3
|
|
||||||
|
|
||||||
lda DRAW_SKY ; 3
|
lda DRAW_SKY ; 3
|
||||||
beq no_draw_sky ; 2nt/3
|
beq no_draw_sky ; 2nt/3
|
||||||
|
|
||||||
@ -580,6 +591,9 @@ sky_loop: ; draw line across screen
|
|||||||
no_draw_sky:
|
no_draw_sky:
|
||||||
|
|
||||||
; FIXME: only do this if Z changes?
|
; FIXME: only do this if Z changes?
|
||||||
|
; only saves 200 cycles to do that with a lot of
|
||||||
|
; added complexity elsewhere
|
||||||
|
|
||||||
; fixed_mul(&space_z,&BETA,&factor);
|
; fixed_mul(&space_z,&BETA,&factor);
|
||||||
;mul1
|
;mul1
|
||||||
lda SPACEZ_I ; 3
|
lda SPACEZ_I ; 3
|
||||||
@ -909,22 +923,22 @@ screenx_loop:
|
|||||||
inc GBASL ; point to next pixel ; 5
|
inc GBASL ; point to next pixel ; 5
|
||||||
|
|
||||||
; Check if over water
|
; Check if over water
|
||||||
cmp #$22 ; see if dark blue ; 2
|
; cmp #$22 ; see if dark blue ; 2
|
||||||
bne not_watery ; 2nt/3
|
; bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda SCREEN_Y ; only check pixel in middle of screen ; 3
|
; lda SCREEN_Y ; only check pixel in middle of screen ; 3
|
||||||
cmp #38 ; 2
|
; cmp #38 ; 2
|
||||||
bne not_watery ; 2nt/3
|
; bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda SCREEN_X ; only check pixel in middle of screen ; 3
|
; lda SCREEN_X ; only check pixel in middle of screen ; 3
|
||||||
cmp #20 ; 2
|
; cmp #20 ; 2
|
||||||
bne not_watery ; 2nt/3
|
; bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda #$1 ; set over water ; 2
|
; lda #$1 ; set over water ; 2
|
||||||
sta OVER_WATER ; 3
|
; sta OVER_WATER ; 3
|
||||||
;============
|
;============
|
||||||
; 42
|
; 19
|
||||||
not_watery:
|
;not_watery:
|
||||||
; advance to the next position in space
|
; advance to the next position in space
|
||||||
|
|
||||||
clc ; fixed_add(&space_x,&dx,&space_x); ; 2
|
clc ; fixed_add(&space_x,&dx,&space_x); ; 2
|
||||||
|
@ -54,36 +54,36 @@ OUTH EQU $FF
|
|||||||
|
|
||||||
;; Flying Routine Only
|
;; Flying Routine Only
|
||||||
|
|
||||||
TURNING EQU $60
|
TURNING EQU $60
|
||||||
SCREEN_X EQU $61
|
SCREEN_X EQU $61
|
||||||
SCREEN_Y EQU $62
|
SCREEN_Y EQU $62
|
||||||
ANGLE EQU $63
|
ANGLE EQU $63
|
||||||
HORIZ_SCALE_I EQU $64
|
HORIZ_SCALE_I EQU $64
|
||||||
HORIZ_SCALE_F EQU $65
|
HORIZ_SCALE_F EQU $65
|
||||||
FACTOR_I EQU $66
|
FACTOR_I EQU $66
|
||||||
FACTOR_F EQU $67
|
FACTOR_F EQU $67
|
||||||
DX_I EQU $68
|
DX_I EQU $68
|
||||||
DX_F EQU $69
|
DX_F EQU $69
|
||||||
SPACEX_I EQU $6A
|
SPACEX_I EQU $6A
|
||||||
SPACEX_F EQU $6B
|
SPACEX_F EQU $6B
|
||||||
CX_I EQU $6C
|
CX_I EQU $6C
|
||||||
CX_F EQU $6D
|
CX_F EQU $6D
|
||||||
DY_I EQU $6E
|
DY_I EQU $6E
|
||||||
DY_F EQU $6F
|
DY_F EQU $6F
|
||||||
SPACEY_I EQU $70
|
SPACEY_I EQU $70
|
||||||
SPACEY_F EQU $71
|
SPACEY_F EQU $71
|
||||||
CY_I EQU $72
|
CY_I EQU $72
|
||||||
CY_F EQU $73
|
CY_F EQU $73
|
||||||
TEMP_I EQU $74
|
TEMP_I EQU $74
|
||||||
TEMP_F EQU $75
|
TEMP_F EQU $75
|
||||||
DISTANCE_I EQU $76
|
DISTANCE_I EQU $76
|
||||||
DISTANCE_F EQU $77
|
DISTANCE_F EQU $77
|
||||||
SPACEZ_I EQU $78
|
SPACEZ_I EQU $78
|
||||||
SPACEZ_F EQU $79
|
SPACEZ_F EQU $79
|
||||||
DRAW_SPLASH EQU $7A
|
DRAW_SPLASH EQU $7A
|
||||||
SPEED EQU $7B
|
SPEED EQU $7B
|
||||||
SPLASH_COUNT EQU $7C
|
SPLASH_COUNT EQU $7C
|
||||||
OVER_WATER EQU $7D
|
OVER_LAND EQU $7D
|
||||||
NUM1L EQU $7E
|
NUM1L EQU $7E
|
||||||
NUM1H EQU $7F
|
NUM1H EQU $7F
|
||||||
NUM2L EQU $80
|
NUM2L EQU $80
|
||||||
|
Loading…
x
Reference in New Issue
Block a user