mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-08-15 08:27:41 +00:00
tfv: add more cycle annotations
This commit is contained in:
@@ -1340,7 +1340,8 @@ hlin_loop:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hlin_double(int page, int x1, int x2, int at) {
|
int hlin_setup(int page, int x1, int x2, int at) {
|
||||||
|
|
||||||
// page, y, V2, A
|
// page, y, V2, A
|
||||||
a=at;
|
a=at;
|
||||||
y=at/2;
|
y=at/2;
|
||||||
@@ -1351,6 +1352,15 @@ int hlin_double(int page, int x1, int x2, int at) {
|
|||||||
ram[GBASH]+=(page);
|
ram[GBASH]+=(page);
|
||||||
|
|
||||||
ram[GBASL]+=x1;
|
ram[GBASL]+=x1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int hlin_double(int page, int x1, int x2, int at) {
|
||||||
|
|
||||||
|
hlin_setup(page,x1,x2,at);
|
||||||
|
|
||||||
hlin_double_continue(x2-x1+1);
|
hlin_double_continue(x2-x1+1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -24,6 +24,7 @@ void basic_print(char *string);
|
|||||||
void basic_inverse(void);
|
void basic_inverse(void);
|
||||||
void basic_normal(void);
|
void basic_normal(void);
|
||||||
int hlin(int page, int x1, int x2, int at);
|
int hlin(int page, int x1, int x2, int at);
|
||||||
|
int hlin_setup(int page, int x1, int x2, int at);
|
||||||
int hlin_continue(int width);
|
int hlin_continue(int width);
|
||||||
int hlin_double_continue(int width);
|
int hlin_double_continue(int width);
|
||||||
int hlin_double(int page, int x1, int x2, int at);
|
int hlin_double(int page, int x1, int x2, int at);
|
||||||
|
@@ -183,6 +183,17 @@ static unsigned char horizontal_lookup[7][16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cycle_counts {
|
||||||
|
int flying;
|
||||||
|
int getkey;
|
||||||
|
int page_flip;
|
||||||
|
int mode7;
|
||||||
|
int multiply;
|
||||||
|
int lookup_map;
|
||||||
|
int put_sprite;
|
||||||
|
} cycles;
|
||||||
|
|
||||||
|
|
||||||
static void fixed_add(unsigned char x_i,unsigned char x_f,
|
static void fixed_add(unsigned char x_i,unsigned char x_f,
|
||||||
unsigned char y_i, unsigned char y_f,
|
unsigned char y_i, unsigned char y_f,
|
||||||
unsigned char *z_i, unsigned char *z_f) {
|
unsigned char *z_i, unsigned char *z_f) {
|
||||||
@@ -211,14 +222,23 @@ static void fixed_mul(unsigned char x_i, unsigned char x_f,
|
|||||||
int result3;
|
int result3;
|
||||||
int result2,result1,result0;
|
int result2,result1,result0;
|
||||||
int aa,xx,cc=0,cc2,yy;
|
int aa,xx,cc=0,cc2,yy;
|
||||||
int negate=0;
|
unsigned char negate;
|
||||||
|
|
||||||
num1h=x_i;
|
num1h=x_i;
|
||||||
num1l=x_f;
|
num1l=x_f;
|
||||||
|
|
||||||
if (!(num1h&0x80)) goto check_num2; // bpl check_num2
|
negate=0; // lda #0 2
|
||||||
|
// sta NEGATE 4
|
||||||
|
|
||||||
negate++; // inc negate
|
// lda NUM1H 4
|
||||||
|
|
||||||
|
cycles.multiply+=13;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(num1h&0x80)) goto check_num2; // bpl check_num2 2nt/3
|
||||||
|
cycles.multiply--;
|
||||||
|
|
||||||
|
negate++; // inc NEGATE 6
|
||||||
|
|
||||||
num1l=~num1l;
|
num1l=~num1l;
|
||||||
num1h=~num1h;
|
num1h=~num1h;
|
||||||
@@ -232,13 +252,15 @@ static void fixed_mul(unsigned char x_i, unsigned char x_f,
|
|||||||
|
|
||||||
num1l&=0xff;
|
num1l&=0xff;
|
||||||
num1h&=0xff;
|
num1h&=0xff;
|
||||||
|
// total=26
|
||||||
|
cycles.multiply+=26;
|
||||||
check_num2:
|
check_num2:
|
||||||
|
|
||||||
num2h=y_i;
|
num2h=y_i;
|
||||||
num2l=y_f;
|
num2l=y_f;
|
||||||
|
cycles.multiply+=7;
|
||||||
if (!(num2h&0x80)) goto unsigned_multiply;
|
if (!(num2h&0x80)) goto unsigned_multiply;
|
||||||
|
cycles.multiply--;
|
||||||
negate++;
|
negate++;
|
||||||
|
|
||||||
num2l=~num2l;
|
num2l=~num2l;
|
||||||
@@ -253,7 +275,7 @@ check_num2:
|
|||||||
|
|
||||||
num2l&=0xff;
|
num2l&=0xff;
|
||||||
num2h&=0xff;
|
num2h&=0xff;
|
||||||
|
cycles.multiply+=30;
|
||||||
unsigned_multiply:
|
unsigned_multiply:
|
||||||
|
|
||||||
// if (debug) {
|
// if (debug) {
|
||||||
@@ -266,7 +288,8 @@ unsigned_multiply:
|
|||||||
aa=0; // lda #0 (sz)
|
aa=0; // lda #0 (sz)
|
||||||
result2=aa; // sta result+2
|
result2=aa; // sta result+2
|
||||||
xx=16; // ldx #16 (sz)
|
xx=16; // ldx #16 (sz)
|
||||||
label_l1:
|
cycles.multiply+=8;
|
||||||
|
multiply_mainloop:
|
||||||
cc=(num2h&1); //lsr NUM2+1 (szc)
|
cc=(num2h&1); //lsr NUM2+1 (szc)
|
||||||
num2h>>=1;
|
num2h>>=1;
|
||||||
num2h&=0x7f;
|
num2h&=0x7f;
|
||||||
@@ -281,8 +304,9 @@ label_l1:
|
|||||||
|
|
||||||
num2l|=(cc<<7);
|
num2l|=(cc<<7);
|
||||||
cc=cc2;
|
cc=cc2;
|
||||||
|
cycles.multiply+=15;
|
||||||
if (cc==0) goto label_l2; // bcc L2
|
if (cc==0) goto shift_output; // bcc L2
|
||||||
|
cycles.multiply--;
|
||||||
|
|
||||||
yy=aa; // tay (sz)
|
yy=aa; // tay (sz)
|
||||||
cc=0; // clc
|
cc=0; // clc
|
||||||
@@ -295,8 +319,8 @@ label_l1:
|
|||||||
aa=aa+cc+num1h; // adc NUM1+1
|
aa=aa+cc+num1h; // adc NUM1+1
|
||||||
cc=!!(aa&0x100);
|
cc=!!(aa&0x100);
|
||||||
aa=aa&0xff;
|
aa=aa&0xff;
|
||||||
|
cycles.multiply+=22;
|
||||||
label_l2:
|
shift_output:
|
||||||
cc2=aa&1;
|
cc2=aa&1;
|
||||||
aa=aa>>1;
|
aa=aa>>1;
|
||||||
aa&=0x7f;
|
aa&=0x7f;
|
||||||
@@ -322,8 +346,9 @@ label_l2:
|
|||||||
cc=cc2; // ror result+0
|
cc=cc2; // ror result+0
|
||||||
|
|
||||||
xx--; // dex
|
xx--; // dex
|
||||||
if (xx!=0) goto label_l1; // bne L1
|
cycles.multiply+=25;
|
||||||
|
if (xx!=0) goto multiply_mainloop; // bne L1
|
||||||
|
cycles.multiply--;
|
||||||
result3=aa&0xff; // sta result+3
|
result3=aa&0xff; // sta result+3
|
||||||
|
|
||||||
|
|
||||||
@@ -331,10 +356,10 @@ label_l2:
|
|||||||
// printf("RAW RESULT = %02x:%02x:%02x:%02x\n",
|
// printf("RAW RESULT = %02x:%02x:%02x:%02x\n",
|
||||||
// result3&0xff,result2&0xff,result1&0xff,result0&0xff);
|
// result3&0xff,result2&0xff,result1&0xff,result0&0xff);
|
||||||
// }
|
// }
|
||||||
|
cycles.multiply+=13;
|
||||||
if (negate&1) {
|
if (negate&1) {
|
||||||
// printf("NEGATING!\n");
|
// printf("NEGATING!\n");
|
||||||
|
cycles.multiply--;
|
||||||
cc=0;
|
cc=0;
|
||||||
|
|
||||||
aa=0;
|
aa=0;
|
||||||
@@ -356,7 +381,7 @@ label_l2:
|
|||||||
aa-=result3+cc;
|
aa-=result3+cc;
|
||||||
cc=!!(aa&0x100);
|
cc=!!(aa&0x100);
|
||||||
result3=aa;
|
result3=aa;
|
||||||
|
cycles.multiply+=50;
|
||||||
}
|
}
|
||||||
|
|
||||||
*z_i=result2&0xff;
|
*z_i=result2&0xff;
|
||||||
@@ -385,7 +410,7 @@ label_l2:
|
|||||||
// a2=(result3<<24)|(result2<<16)|(result1<<8)|result0;
|
// a2=(result3<<24)|(result2<<16)|(result1<<8)|result0;
|
||||||
// printf("%d * %d = %d (0x%x)\n",s1,s2,a2,a2);
|
// printf("%d * %d = %d (0x%x)\n",s1,s2,a2,a2);
|
||||||
|
|
||||||
|
cycles.multiply+=6;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -400,14 +425,18 @@ void draw_background_mode7(void) {
|
|||||||
/* Draw Sky */
|
/* Draw Sky */
|
||||||
/* Originally wanted to be fancy and have sun too, but no */
|
/* Originally wanted to be fancy and have sun too, but no */
|
||||||
color_equals(COLOR_MEDIUMBLUE);
|
color_equals(COLOR_MEDIUMBLUE);
|
||||||
|
cycles.mode7+=10;
|
||||||
|
|
||||||
for(ram[SCREEN_Y]=0;ram[SCREEN_Y]<6;ram[SCREEN_Y]+=2) {
|
for(ram[SCREEN_Y]=0;ram[SCREEN_Y]<6;ram[SCREEN_Y]+=2) {
|
||||||
hlin_double(ram[DRAW_PAGE], 0, 40, ram[SCREEN_Y]);
|
hlin_double(ram[DRAW_PAGE], 0, 40, ram[SCREEN_Y]);
|
||||||
}
|
}
|
||||||
|
cycles.mode7+=(63+(16*40)+23)*5;
|
||||||
/* Draw hazy horizon */
|
/* Draw hazy horizon */
|
||||||
color_equals(COLOR_GREY);
|
color_equals(COLOR_GREY);
|
||||||
hlin_double(ram[DRAW_PAGE], 0, 40, 6);
|
hlin_double(ram[DRAW_PAGE], 0, 40, 6);
|
||||||
|
cycles.mode7+=14+63+(16*40);
|
||||||
|
|
||||||
|
cycles.mode7+=28;
|
||||||
fixed_mul(ram[SPACEZ_I],ram[SPACEZ_F],
|
fixed_mul(ram[SPACEZ_I],ram[SPACEZ_F],
|
||||||
CONST_BETA_I,CONST_BETA_F,
|
CONST_BETA_I,CONST_BETA_F,
|
||||||
&ram[FACTOR_I],&ram[FACTOR_F]);
|
&ram[FACTOR_I],&ram[FACTOR_F]);
|
||||||
@@ -423,15 +452,21 @@ void draw_background_mode7(void) {
|
|||||||
// fixed_to_double(ram[SPACEZ_I],ram[SPACEZ_F],),
|
// fixed_to_double(ram[SPACEZ_I],ram[SPACEZ_F],),
|
||||||
// fixed_to_double(&BETA),
|
// fixed_to_double(&BETA),
|
||||||
// fixed_to_double(ram[FACTOR_I],ram[FACTOR_F]));
|
// fixed_to_double(ram[FACTOR_I],ram[FACTOR_F]));
|
||||||
|
cycles.mode7+=22;
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
|
y=0;
|
||||||
|
hlin_setup(ram[DRAW_PAGE],y,0,ram[SCREEN_Y]);
|
||||||
|
cycles.mode7+=43;
|
||||||
|
|
||||||
// then calculate the horizontal scale, or the distance between
|
// then calculate the horizontal scale, or the distance between
|
||||||
// space points on this horizontal line
|
// space points on this horizontal line
|
||||||
ram[HORIZ_SCALE_I]=0;
|
ram[HORIZ_SCALE_I]=0;
|
||||||
ram[HORIZ_SCALE_F]=
|
ram[HORIZ_SCALE_F]=
|
||||||
horizontal_lookup[ram[SPACEZ_I]&0xf]
|
horizontal_lookup[ram[SPACEZ_I]&0xf]
|
||||||
[(ram[SCREEN_Y]-8)/2];
|
[(ram[SCREEN_Y]-8)/2];
|
||||||
|
cycles.mode7+=44;
|
||||||
|
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("HORIZ_SCALE %x %x\n",
|
printf("HORIZ_SCALE %x %x\n",
|
||||||
@@ -442,7 +477,7 @@ void draw_background_mode7(void) {
|
|||||||
fixed_mul(ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
fixed_mul(ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
||||||
CONST_SCALE_I,CONST_SCALE_F,
|
CONST_SCALE_I,CONST_SCALE_F,
|
||||||
&ram[DISTANCE_I],&ram[DISTANCE_F]);
|
&ram[DISTANCE_I],&ram[DISTANCE_F]);
|
||||||
|
cycles.mode7+=44;
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("DISTANCE %x:%x\n",ram[DISTANCE_I],ram[DISTANCE_F]);
|
printf("DISTANCE %x:%x\n",ram[DISTANCE_I],ram[DISTANCE_F]);
|
||||||
}
|
}
|
||||||
@@ -451,10 +486,12 @@ void draw_background_mode7(void) {
|
|||||||
// through all points on this line
|
// through all points on this line
|
||||||
ram[DX_I]=fixed_sin[(ram[ANGLE]+8)&0xf].i; // -sin()
|
ram[DX_I]=fixed_sin[(ram[ANGLE]+8)&0xf].i; // -sin()
|
||||||
ram[DX_F]=fixed_sin[(ram[ANGLE]+8)&0xf].f; // -sin()
|
ram[DX_F]=fixed_sin[(ram[ANGLE]+8)&0xf].f; // -sin()
|
||||||
|
cycles.mode7+=29;
|
||||||
|
|
||||||
fixed_mul(ram[DX_I],ram[DX_F],
|
fixed_mul(ram[DX_I],ram[DX_F],
|
||||||
ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
||||||
&ram[DX_I],&ram[DX_F]);
|
&ram[DX_I],&ram[DX_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("DX %x:%x\n",ram[DX_I],ram[DX_F]);
|
printf("DX %x:%x\n",ram[DX_I],ram[DX_F]);
|
||||||
}
|
}
|
||||||
@@ -462,10 +499,11 @@ void draw_background_mode7(void) {
|
|||||||
|
|
||||||
ram[DY_I]=fixed_sin[(ram[ANGLE]+4)&0xf].i; // cos()
|
ram[DY_I]=fixed_sin[(ram[ANGLE]+4)&0xf].i; // cos()
|
||||||
ram[DY_F]=fixed_sin[(ram[ANGLE]+4)&0xf].f; // cos()
|
ram[DY_F]=fixed_sin[(ram[ANGLE]+4)&0xf].f; // cos()
|
||||||
|
cycles.mode7+=29;
|
||||||
fixed_mul(ram[DY_I],ram[DY_F],
|
fixed_mul(ram[DY_I],ram[DY_F],
|
||||||
ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
ram[HORIZ_SCALE_I],ram[HORIZ_SCALE_F],
|
||||||
&ram[DY_I],&ram[DY_F]);
|
&ram[DY_I],&ram[DY_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("DY %x:%x\n",ram[DY_I],ram[DY_F]);
|
printf("DY %x:%x\n",ram[DY_I],ram[DY_F]);
|
||||||
}
|
}
|
||||||
@@ -474,48 +512,62 @@ void draw_background_mode7(void) {
|
|||||||
fixed_add(ram[DISTANCE_I],ram[DISTANCE_F],
|
fixed_add(ram[DISTANCE_I],ram[DISTANCE_F],
|
||||||
ram[FACTOR_I],ram[FACTOR_F],
|
ram[FACTOR_I],ram[FACTOR_F],
|
||||||
&ram[SPACEX_I],&ram[SPACEX_F]);
|
&ram[SPACEX_I],&ram[SPACEX_F]);
|
||||||
|
fixed_add(ram[DISTANCE_I],ram[DISTANCE_F],
|
||||||
|
ram[FACTOR_I],ram[FACTOR_F],
|
||||||
|
&ram[SPACEY_I],&ram[SPACEY_F]);
|
||||||
|
cycles.mode7+=26;
|
||||||
|
|
||||||
ram[TEMP_I]=fixed_sin[(ram[ANGLE]+4)&0xf].i; // cos
|
ram[TEMP_I]=fixed_sin[(ram[ANGLE]+4)&0xf].i; // cos
|
||||||
ram[TEMP_F]=fixed_sin[(ram[ANGLE]+4)&0xf].f; // cos
|
ram[TEMP_F]=fixed_sin[(ram[ANGLE]+4)&0xf].f; // cos
|
||||||
|
cycles.mode7+=29;
|
||||||
|
|
||||||
fixed_mul(ram[SPACEX_I],ram[SPACEX_F],
|
fixed_mul(ram[SPACEX_I],ram[SPACEX_F],
|
||||||
ram[TEMP_I],ram[TEMP_F],
|
ram[TEMP_I],ram[TEMP_F],
|
||||||
&ram[SPACEX_I],&ram[SPACEX_F]);
|
&ram[SPACEX_I],&ram[SPACEX_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
|
|
||||||
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
||||||
ram[CX_I],ram[CX_F],
|
ram[CX_I],ram[CX_F],
|
||||||
&ram[SPACEX_I],&ram[SPACEX_F]);
|
&ram[SPACEX_I],&ram[SPACEX_F]);
|
||||||
ram[TEMP_I]=0xec; // -20 (LOWRES_W/2)
|
ram[TEMP_I]=0xec; // -20 (LOWRES_W/2)
|
||||||
ram[TEMP_F]=0;
|
ram[TEMP_F]=0;
|
||||||
|
cycles.mode7+=30;
|
||||||
|
|
||||||
fixed_mul(ram[TEMP_I],ram[TEMP_F],
|
fixed_mul(ram[TEMP_I],ram[TEMP_F],
|
||||||
ram[DX_I],ram[DX_F],
|
ram[DX_I],ram[DX_F],
|
||||||
&ram[TEMP_I],&ram[TEMP_F]);
|
&ram[TEMP_I],&ram[TEMP_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
|
|
||||||
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
fixed_add(ram[SPACEX_I],ram[SPACEX_F],
|
||||||
ram[TEMP_I],ram[TEMP_F],
|
ram[TEMP_I],ram[TEMP_F],
|
||||||
&ram[SPACEX_I],&ram[SPACEX_F]);
|
&ram[SPACEX_I],&ram[SPACEX_F]);
|
||||||
|
cycles.mode7+=20;
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("SPACEX! %x:%x\n",
|
printf("SPACEX! %x:%x\n",
|
||||||
ram[SPACEX_I],ram[SPACEX_F]);
|
ram[SPACEX_I],ram[SPACEX_F]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_add(ram[DISTANCE_I],ram[DISTANCE_F],
|
|
||||||
ram[FACTOR_I],ram[FACTOR_F],
|
|
||||||
&ram[SPACEY_I],&ram[SPACEY_F]);
|
|
||||||
ram[TEMP_I]=fixed_sin[ram[ANGLE]&0xf].i;
|
ram[TEMP_I]=fixed_sin[ram[ANGLE]&0xf].i;
|
||||||
ram[TEMP_F]=fixed_sin[ram[ANGLE]&0xf].f;
|
ram[TEMP_F]=fixed_sin[ram[ANGLE]&0xf].f;
|
||||||
|
cycles.mode7+=25;
|
||||||
fixed_mul(ram[SPACEY_I],ram[SPACEY_F],
|
fixed_mul(ram[SPACEY_I],ram[SPACEY_F],
|
||||||
ram[TEMP_I],ram[TEMP_F],
|
ram[TEMP_I],ram[TEMP_F],
|
||||||
&ram[SPACEY_I],&ram[SPACEY_F]);
|
&ram[SPACEY_I],&ram[SPACEY_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
||||||
ram[CY_I],ram[CY_F],
|
ram[CY_I],ram[CY_F],
|
||||||
&ram[SPACEY_I],&ram[SPACEY_F]);
|
&ram[SPACEY_I],&ram[SPACEY_F]);
|
||||||
ram[TEMP_I]=0xec; // -20 (LOWRES_W/2)
|
ram[TEMP_I]=0xec; // -20 (LOWRES_W/2)
|
||||||
ram[TEMP_F]=0;
|
ram[TEMP_F]=0;
|
||||||
|
cycles.mode7+=30;
|
||||||
fixed_mul(ram[TEMP_I],ram[TEMP_F],
|
fixed_mul(ram[TEMP_I],ram[TEMP_F],
|
||||||
ram[DY_I],ram[DY_F],
|
ram[DY_I],ram[DY_F],
|
||||||
&ram[TEMP_I],&ram[TEMP_F]);
|
&ram[TEMP_I],&ram[TEMP_F]);
|
||||||
|
cycles.mode7+=48;
|
||||||
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
||||||
ram[TEMP_I],ram[TEMP_F],
|
ram[TEMP_I],ram[TEMP_F],
|
||||||
&ram[SPACEY_I],&ram[SPACEY_F]);
|
&ram[SPACEY_I],&ram[SPACEY_F]);
|
||||||
|
cycles.mode7+=25;
|
||||||
if (!displayed) {
|
if (!displayed) {
|
||||||
printf("SPACEY! %x:%x\n",ram[SPACEY_I],ram[SPACEY_F]);
|
printf("SPACEY! %x:%x\n",ram[SPACEY_I],ram[SPACEY_F]);
|
||||||
}
|
}
|
||||||
@@ -533,8 +585,8 @@ void draw_background_mode7(void) {
|
|||||||
if (map_color==COLOR_DARKBLUE) ram[OVER_WATER]=1;
|
if (map_color==COLOR_DARKBLUE) ram[OVER_WATER]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hlin_double(ram[DRAW_PAGE], ram[SCREEN_X], ram[SCREEN_X]+1,
|
hlin_double_continue(1);
|
||||||
ram[SCREEN_Y]);
|
cycles.mode7+=42;
|
||||||
|
|
||||||
// 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],
|
||||||
@@ -543,19 +595,17 @@ void draw_background_mode7(void) {
|
|||||||
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
fixed_add(ram[SPACEY_I],ram[SPACEY_F],
|
||||||
ram[DY_I],ram[DY_F],
|
ram[DY_I],ram[DY_F],
|
||||||
&ram[SPACEY_I],&ram[SPACEY_F]);
|
&ram[SPACEY_I],&ram[SPACEY_F]);
|
||||||
|
cycles.mode7+=53;
|
||||||
}
|
}
|
||||||
|
cycles.mode7+=17;
|
||||||
}
|
}
|
||||||
displayed=1;
|
displayed=1;
|
||||||
|
cycles.mode7+=6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct cycle_counts {
|
|
||||||
int flying;
|
|
||||||
int getkey;
|
|
||||||
int page_flip;
|
|
||||||
} cycles;
|
|
||||||
|
|
||||||
static int iterations=0;
|
static int iterations=0;
|
||||||
|
|
||||||
@@ -775,10 +825,16 @@ int flying(void) {
|
|||||||
if (iterations==100) {
|
if (iterations==100) {
|
||||||
int total_cycles;
|
int total_cycles;
|
||||||
total_cycles=cycles.flying+cycles.getkey+
|
total_cycles=cycles.flying+cycles.getkey+
|
||||||
cycles.page_flip;
|
cycles.page_flip+cycles.multiply+
|
||||||
|
cycles.mode7+cycles.lookup_map+
|
||||||
|
cycles.put_sprite;
|
||||||
printf("Cycles: flying=%d\n",cycles.flying);
|
printf("Cycles: flying=%d\n",cycles.flying);
|
||||||
printf("Cycles: getkey=%d\n",cycles.getkey);
|
printf("Cycles: getkey=%d\n",cycles.getkey);
|
||||||
printf("Cycles: page_flip=%d\n",cycles.page_flip);
|
printf("Cycles: page_flip=%d\n",cycles.page_flip);
|
||||||
|
printf("Cycles: multiply=%d\n",cycles.multiply);
|
||||||
|
printf("Cycles: mode7=%d\n",cycles.mode7);
|
||||||
|
printf("Cycles: lookup_map=%d\n",cycles.lookup_map);
|
||||||
|
printf("Cycles: put_sprite=%d\n",cycles.put_sprite);
|
||||||
printf("Total = %d\n",total_cycles);
|
printf("Total = %d\n",total_cycles);
|
||||||
printf("Frame Rate = %.2lf fps\n",
|
printf("Frame Rate = %.2lf fps\n",
|
||||||
(1000000.0 / (double)total_cycles));
|
(1000000.0 / (double)total_cycles));
|
||||||
|
6
tfv/TODO
6
tfv/TODO
@@ -1,3 +1,9 @@
|
|||||||
|
mode7 speed fixes:
|
||||||
|
+ Don't draw sky every frame, only if needed
|
||||||
|
+ faster multiply routine
|
||||||
|
+ move multiply vars to zero page
|
||||||
|
+ leave one of multiply results in accumulator at end?
|
||||||
|
|
||||||
short term:
|
short term:
|
||||||
|
|
||||||
longer term:
|
longer term:
|
||||||
|
651
tfv/tfv_flying.s
651
tfv/tfv_flying.s
@@ -550,66 +550,60 @@ draw_ship:
|
|||||||
draw_background_mode7:
|
draw_background_mode7:
|
||||||
|
|
||||||
; Draw Sky
|
; Draw Sky
|
||||||
|
; FIXME: the sky never changes?
|
||||||
|
|
||||||
lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color
|
lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color ; 2
|
||||||
sta COLOR
|
sta COLOR ; 3
|
||||||
|
|
||||||
lda #0
|
lda #0 ; 2
|
||||||
sta OVER_WATER
|
sta OVER_WATER ; 3
|
||||||
|
;===========
|
||||||
|
; 10
|
||||||
|
|
||||||
sky_loop: ; draw line across screen
|
sky_loop: ; draw line across screen
|
||||||
ldy #40 ; from y=0 to y=6
|
ldy #40 ; from y=0 to y=6 ; 2
|
||||||
sty V2
|
sty V2 ; 3
|
||||||
ldy #0
|
ldy #0 ; 2
|
||||||
pha
|
pha ; 3
|
||||||
jsr hlin_double ; hlin y,V2 at A
|
jsr hlin_double ; hlin y,V2 at A ; 63+(X*16)
|
||||||
pla
|
pla ; 4
|
||||||
clc
|
clc ; 2
|
||||||
adc #2
|
adc #2 ; 2
|
||||||
cmp #6
|
cmp #6 ; 2
|
||||||
bne sky_loop
|
bne sky_loop ; 3/2nt
|
||||||
|
;=============
|
||||||
|
; (23+63+(X*16))*5
|
||||||
; Draw Horizon
|
; Draw Horizon
|
||||||
|
|
||||||
lda #COLOR_BOTH_GREY ; Horizon is Grey
|
lda #COLOR_BOTH_GREY ; Horizon is Grey ; 2
|
||||||
sta COLOR
|
sta COLOR ; 3
|
||||||
lda #6 ; draw single line at 6/7
|
lda #6 ; draw single line at 6/7 ; 2
|
||||||
ldy #40
|
ldy #40 ; 2
|
||||||
sty V2 ; hlin Y,V2 at A
|
sty V2 ; hlin Y,V2 at A ; 3
|
||||||
ldy #0
|
ldy #0 ; 2
|
||||||
jsr hlin_double ; hlin 0,40 at 6
|
jsr hlin_double ; hlin 0,40 at 6 ; 63+(X*16)
|
||||||
|
;===========
|
||||||
|
; 63+(X*16)+14
|
||||||
; fixed_mul(&space_z,&BETA,&factor);
|
; fixed_mul(&space_z,&BETA,&factor);
|
||||||
|
|
||||||
lda SPACEZ_I
|
lda SPACEZ_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 3
|
||||||
lda SPACEZ_F
|
lda SPACEZ_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 3
|
||||||
|
|
||||||
lda #$ff ; BETA_I
|
lda #$ff ; BETA_I ; 2
|
||||||
sta NUM2H
|
sta NUM2H ; 3
|
||||||
lda #$80 ; BETA_F
|
lda #$80 ; BETA_F ; 2
|
||||||
sta NUM2L
|
sta NUM2L ; 3
|
||||||
|
|
||||||
;; TEST
|
jsr multiply ; 6
|
||||||
;; lda #$0
|
;===========
|
||||||
;; sta NUM1H
|
; 28
|
||||||
;; lda #$2
|
|
||||||
;; sta NUM1L
|
|
||||||
|
|
||||||
;; lda #$0
|
lda RESULT+2 ; 4
|
||||||
;; sta NUM2H
|
sta FACTOR_I ; 4
|
||||||
;; lda #$3
|
lda RESULT+1 ; 4
|
||||||
;; sta NUM2L
|
sta FACTOR_F ; 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsr multiply
|
|
||||||
|
|
||||||
lda RESULT+2
|
|
||||||
sta FACTOR_I
|
|
||||||
lda RESULT+1
|
|
||||||
sta FACTOR_F
|
|
||||||
|
|
||||||
;; SPACEZ=78 * ff80 = FACTOR=66
|
;; SPACEZ=78 * ff80 = FACTOR=66
|
||||||
|
|
||||||
@@ -617,329 +611,356 @@ sky_loop: ; draw line across screen
|
|||||||
;; GOOD 4 80 * ffffffff 80 = fffffffd c0
|
;; GOOD 4 80 * ffffffff 80 = fffffffd c0
|
||||||
;; BAD 4 80 * ffffffff 80 = 42 40
|
;; BAD 4 80 * ffffffff 80 = 42 40
|
||||||
|
|
||||||
lda #8
|
lda #8 ; 2
|
||||||
sta SCREEN_Y
|
sta SCREEN_Y ; 4
|
||||||
|
;=============
|
||||||
|
; 22
|
||||||
screeny_loop:
|
screeny_loop:
|
||||||
ldy #0
|
ldy #0 ; 2
|
||||||
jsr hlin_setup ; y-coord in a, x-coord in y
|
jsr hlin_setup ; y-coord in a, x-coord in y ; 41
|
||||||
; sets up GBASL/GBASH
|
; sets up GBASL/GBASH
|
||||||
|
;=============
|
||||||
|
; 43
|
||||||
|
|
||||||
lda #0 ; horizontal_scale.i = 0
|
lda #0 ; horizontal_scale.i = 0 ; 2
|
||||||
sta HORIZ_SCALE_I
|
sta HORIZ_SCALE_I ; 3
|
||||||
|
|
||||||
;horizontal_scale.f=
|
;horizontal_scale.f=
|
||||||
; horizontal_lookup[space_z.i&0xf][(screen_y-8)/2];
|
; horizontal_lookup[space_z.i&0xf][(screen_y-8)/2];
|
||||||
|
|
||||||
lda SPACEZ_I
|
lda SPACEZ_I ; 3
|
||||||
and #$f
|
and #$f ; 2
|
||||||
asl
|
asl ; 2
|
||||||
asl
|
asl ; 2
|
||||||
asl
|
asl ; 2
|
||||||
asl
|
asl ; 2
|
||||||
sta TEMP_I
|
sta TEMP_I ; 3
|
||||||
|
|
||||||
sec
|
|
||||||
lda SCREEN_Y
|
|
||||||
sbc #8
|
|
||||||
lsr
|
|
||||||
clc
|
|
||||||
adc TEMP_I
|
|
||||||
tay
|
|
||||||
lda horizontal_lookup,Y
|
|
||||||
sta HORIZ_SCALE_F
|
|
||||||
|
|
||||||
|
sec ; 2
|
||||||
|
lda SCREEN_Y ; 3
|
||||||
|
sbc #8 ; 2
|
||||||
|
lsr ; 2
|
||||||
|
clc ; 2
|
||||||
|
adc TEMP_I ; 3
|
||||||
|
tay ; 2
|
||||||
|
lda horizontal_lookup,Y ; 4
|
||||||
|
sta HORIZ_SCALE_F ; 3
|
||||||
|
;============
|
||||||
|
; 44
|
||||||
;; brk ASM, horiz_scale = 00:73
|
;; brk ASM, horiz_scale = 00:73
|
||||||
|
|
||||||
; calculate the distance of the line we are drawing
|
; calculate the distance of the line we are drawing
|
||||||
; fixed_mul(&horizontal_scale,&scale,&distance);
|
; fixed_mul(&horizontal_scale,&scale,&distance);
|
||||||
lda HORIZ_SCALE_I
|
lda HORIZ_SCALE_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda HORIZ_SCALE_F
|
lda HORIZ_SCALE_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda #$14 ; SCALE_I
|
lda #$14 ; SCALE_I ; 2
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda #$00 ; SCALE_F
|
lda #$00 ; SCALE_F ; 2
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta DISTANCE_I
|
sta DISTANCE_I ; 2
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta DISTANCE_F
|
sta DISTANCE_F ; 2
|
||||||
|
;==========
|
||||||
|
; 44
|
||||||
;; brk ASM, distance = 08:fc
|
;; brk ASM, distance = 08:fc
|
||||||
|
|
||||||
; calculate the dx and dy of points in space when we step
|
; calculate the dx and dy of points in space when we step
|
||||||
; through all points on this line
|
; through all points on this line
|
||||||
|
|
||||||
lda ANGLE ; dx.i=fixed_sin[(angle+8)&0xf].i; // -sin()
|
lda ANGLE ; dx.i=fixed_sin[(angle+8)&0xf].i; // -sin() ; 3
|
||||||
clc
|
clc ; 2
|
||||||
adc #8
|
adc #8 ; 2
|
||||||
and #$f
|
and #$f ; 2
|
||||||
asl
|
asl ; 2
|
||||||
tay
|
tay ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta DX_I
|
sta DX_I ; 3
|
||||||
iny ; dx.f=fixed_sin[(angle+8)&0xf].f; // -sin()
|
iny ; dx.f=fixed_sin[(angle+8)&0xf].f; // -sin() ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta DX_F
|
sta DX_F ; 3
|
||||||
|
;==========
|
||||||
|
; 29
|
||||||
|
|
||||||
; fixed_mul(&dx,&horizontal_scale,&dx);
|
; fixed_mul(&dx,&horizontal_scale,&dx);
|
||||||
lda HORIZ_SCALE_I
|
lda HORIZ_SCALE_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda HORIZ_SCALE_F
|
lda HORIZ_SCALE_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda DX_I
|
lda DX_I ; 3
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda DX_F
|
lda DX_F ; 3
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta DX_I
|
sta DX_I ; 3
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta DX_F
|
sta DX_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
;; ANGLE
|
;; ANGLE
|
||||||
;; brk ASM, dx = 00:00
|
;; brk ASM, dx = 00:00
|
||||||
|
|
||||||
lda ANGLE ; dy.i=fixed_sin[(angle+4)&0xf].i; // cos()
|
lda ANGLE ; dy.i=fixed_sin[(angle+4)&0xf].i; // cos() ; 3
|
||||||
clc
|
clc ; 2
|
||||||
adc #4
|
adc #4 ; 2
|
||||||
and #$f
|
and #$f ; 2
|
||||||
asl
|
asl ; 2
|
||||||
tay
|
tay ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta DY_I
|
sta DY_I ; 3
|
||||||
iny ; dy.f=fixed_sin[(angle+4)&0xf].f; // cos()
|
iny ; dy.f=fixed_sin[(angle+4)&0xf].f; // cos() ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta DY_F
|
sta DY_F ; 3
|
||||||
|
;==========
|
||||||
|
; 29
|
||||||
; fixed_mul(&dy,&horizontal_scale,&dy);
|
; fixed_mul(&dy,&horizontal_scale,&dy);
|
||||||
lda HORIZ_SCALE_I
|
lda HORIZ_SCALE_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda HORIZ_SCALE_F
|
lda HORIZ_SCALE_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda DY_I
|
lda DY_I ; 3
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda DY_F
|
lda DY_F ; 3
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta DY_I
|
sta DY_I ; 3
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta DY_F
|
sta DY_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
;; brk ASM, dy = 00:73
|
;; brk ASM, dy = 00:73
|
||||||
|
|
||||||
; calculate the starting position
|
; calculate the starting position
|
||||||
|
|
||||||
; fixed_add(&distance,&factor,&space_x);
|
; fixed_add(&distance,&factor,&space_x);
|
||||||
clc ; fixed_add(&distance,&factor,&space_y);
|
clc ; fixed_add(&distance,&factor,&space_y); ; 2
|
||||||
lda DISTANCE_F
|
lda DISTANCE_F ; 3
|
||||||
adc FACTOR_F
|
adc FACTOR_F ; 3
|
||||||
sta SPACEY_F
|
sta SPACEY_F ; 3
|
||||||
sta SPACEX_F
|
sta SPACEX_F ; 3
|
||||||
lda DISTANCE_I
|
lda DISTANCE_I ; 3
|
||||||
adc FACTOR_I
|
adc FACTOR_I ; 3
|
||||||
sta SPACEY_I
|
sta SPACEY_I ; 3
|
||||||
sta SPACEX_I
|
sta SPACEX_I ; 3
|
||||||
|
;==========
|
||||||
|
; 26
|
||||||
;; brk space_x = 06:bc
|
;; brk space_x = 06:bc
|
||||||
|
|
||||||
lda ANGLE ; fixed_temp.i=fixed_sin[(angle+4)&0xf].i; // cos
|
lda ANGLE ; temp.i=fixed_sin[(angle+4)&0xf].i; // cos ; 3
|
||||||
clc
|
clc ; 2
|
||||||
adc #4
|
adc #4 ; 2
|
||||||
and #$f
|
and #$f ; 2
|
||||||
asl
|
asl ; 2
|
||||||
tay
|
tay ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta TEMP_I
|
sta TEMP_I ; 3
|
||||||
iny ; fixed_temp.f=fixed_sin[(angle+4)&0xf].f; // cos
|
iny ; temp.f=fixed_sin[(angle+4)&0xf].f; // cos ; 2
|
||||||
lda fixed_sin,Y
|
lda fixed_sin,Y ; 4
|
||||||
sta TEMP_F
|
sta TEMP_F ; 3
|
||||||
|
;==========
|
||||||
|
; 29
|
||||||
|
|
||||||
; fixed_mul(&space_x,&fixed_temp,&space_x);
|
; fixed_mul(&space_x,&temp,&space_x);
|
||||||
lda SPACEX_I
|
lda SPACEX_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda SPACEX_F
|
lda SPACEX_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda TEMP_I
|
lda TEMP_I ; 3
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda TEMP_F
|
lda TEMP_F ; 3
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta SPACEX_I
|
sta SPACEX_I ; 3
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta SPACEX_F
|
sta SPACEX_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
|
|
||||||
|
clc ; fixed_add(&space_x,&cx,&space_x); ; 2
|
||||||
|
lda SPACEX_F ; 3
|
||||||
|
adc CX_F ; 3
|
||||||
|
sta SPACEX_F ; 3
|
||||||
|
lda SPACEX_I ; 3
|
||||||
|
adc CX_I ; 3
|
||||||
|
sta SPACEX_I ; 3
|
||||||
|
|
||||||
|
lda #$ec ; temp.i=0xec; // -20 (LOWRES_W/2) ; 2
|
||||||
|
sta TEMP_I ; 3
|
||||||
|
lda #0 ; temp.f=0; ; 2
|
||||||
|
sta TEMP_F ; 3
|
||||||
|
;==========
|
||||||
|
; 30
|
||||||
|
; fixed_mul(&temp,&dx,&temp);
|
||||||
|
lda TEMP_I ; 3
|
||||||
|
sta NUM1H ; 4
|
||||||
|
lda TEMP_F ; 3
|
||||||
|
sta NUM1L ; 4
|
||||||
|
lda DX_I ; 3
|
||||||
|
sta NUM2H ; 4
|
||||||
|
lda DX_F ; 3
|
||||||
|
sta NUM2L ; 4
|
||||||
|
jsr multiply ; 6
|
||||||
|
lda RESULT+2 ; 4
|
||||||
|
sta TEMP_I ; 3
|
||||||
|
lda RESULT+1 ; 4
|
||||||
|
sta TEMP_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
|
|
||||||
|
|
||||||
clc ; fixed_add(&space_x,&cx,&space_x);
|
|
||||||
lda SPACEX_F
|
|
||||||
adc CX_F
|
|
||||||
sta SPACEX_F
|
|
||||||
lda SPACEX_I
|
|
||||||
adc CX_I
|
|
||||||
sta SPACEX_I
|
|
||||||
|
|
||||||
lda #$ec ; fixed_temp.i=0xec; // -20 (LOWRES_W/2)
|
clc ; fixed_add(&space_x,&temp,&space_x); ; 2
|
||||||
sta TEMP_I
|
lda SPACEX_F ; 3
|
||||||
lda #0 ; fixed_temp.f=0;
|
adc TEMP_F ; 3
|
||||||
sta TEMP_F
|
sta SPACEX_F ; 3
|
||||||
|
lda SPACEX_I ; 3
|
||||||
; fixed_mul(&fixed_temp,&dx,&fixed_temp);
|
adc TEMP_I ; 3
|
||||||
lda TEMP_I
|
sta SPACEX_I ; 3
|
||||||
sta NUM1H
|
;==========
|
||||||
lda TEMP_F
|
; 20
|
||||||
sta NUM1L
|
; brk ; space_x = 06:bc
|
||||||
lda DX_I
|
|
||||||
sta NUM2H
|
|
||||||
lda DX_F
|
|
||||||
sta NUM2L
|
|
||||||
jsr multiply
|
|
||||||
lda RESULT+2
|
|
||||||
sta TEMP_I
|
|
||||||
lda RESULT+1
|
|
||||||
sta TEMP_F
|
|
||||||
|
|
||||||
|
|
||||||
clc ; fixed_add(&space_x,&fixed_temp,&space_x);
|
|
||||||
lda SPACEX_F
|
|
||||||
adc TEMP_F
|
|
||||||
sta SPACEX_F
|
|
||||||
lda SPACEX_I
|
|
||||||
adc TEMP_I
|
|
||||||
sta SPACEX_I
|
|
||||||
|
|
||||||
;;brk ;; brk space_x = 06:bc
|
|
||||||
|
|
||||||
lda ANGLE ; fixed_temp.i=fixed_sin[angle&0xf].i;
|
|
||||||
and #$f
|
|
||||||
asl
|
|
||||||
tay
|
|
||||||
lda fixed_sin,Y
|
|
||||||
sta TEMP_I
|
|
||||||
iny ; fixed_temp.f=fixed_sin[angle&0xf].f;
|
|
||||||
lda fixed_sin,Y
|
|
||||||
sta TEMP_F
|
|
||||||
|
|
||||||
|
lda ANGLE ; temp.i=fixed_sin[angle&0xf].i; ; 3
|
||||||
|
and #$f ; 2
|
||||||
|
asl ; 2
|
||||||
|
tay ; 2
|
||||||
|
lda fixed_sin,Y ; 4
|
||||||
|
sta TEMP_I ; 3
|
||||||
|
iny ; fixed_temp.f=fixed_sin[angle&0xf].f; ; 2
|
||||||
|
lda fixed_sin,Y ; 4
|
||||||
|
sta TEMP_F ; 3
|
||||||
|
;==========
|
||||||
|
; 25
|
||||||
|
|
||||||
; fixed_mul(&space_y,&fixed_temp,&space_y);
|
; fixed_mul(&space_y,&fixed_temp,&space_y);
|
||||||
lda SPACEY_I
|
lda SPACEY_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda SPACEY_F
|
lda SPACEY_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda TEMP_I
|
lda TEMP_I ; 3
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda TEMP_F
|
lda TEMP_F ; 3
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta SPACEY_I
|
sta SPACEY_I ; 3
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta SPACEY_F
|
sta SPACEY_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
|
|
||||||
|
clc ; fixed_add(&space_y,&cy,&space_y); ; 2
|
||||||
|
lda SPACEY_F ; 3
|
||||||
|
adc CY_F ; 3
|
||||||
|
sta SPACEY_F ; 3
|
||||||
|
lda SPACEY_I ; 3
|
||||||
|
adc CY_I ; 3
|
||||||
|
sta SPACEY_I ; 3
|
||||||
|
|
||||||
clc ; fixed_add(&space_y,&cy,&space_y);
|
lda #$ec ; temp.i=0xec; // -20 (LOWRES_W/2) ; 2
|
||||||
lda SPACEY_F
|
sta TEMP_I ; 3
|
||||||
adc CY_F
|
lda #0 ; temp.f=0; ; 2
|
||||||
sta SPACEY_F
|
sta TEMP_F ; 3
|
||||||
lda SPACEY_I
|
;==========
|
||||||
adc CY_I
|
; 30
|
||||||
sta SPACEY_I
|
|
||||||
|
|
||||||
lda #$ec ; fixed_temp.i=0xec; // -20 (LOWRES_W/2)
|
|
||||||
sta TEMP_I
|
|
||||||
lda #0 ; fixed_temp.f=0;
|
|
||||||
sta TEMP_F
|
|
||||||
|
|
||||||
; fixed_mul(&fixed_temp,&dy,&fixed_temp);
|
; fixed_mul(&fixed_temp,&dy,&fixed_temp);
|
||||||
lda TEMP_I
|
lda TEMP_I ; 3
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
lda TEMP_F
|
lda TEMP_F ; 3
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
lda DY_I
|
lda DY_I ; 3
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
lda DY_F
|
lda DY_F ; 3
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
jsr multiply
|
jsr multiply ; 6
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
sta TEMP_I
|
sta TEMP_I ; 3
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
sta TEMP_F
|
sta TEMP_F ; 3
|
||||||
|
;==========
|
||||||
|
; 48
|
||||||
|
|
||||||
|
clc ; fixed_add(&space_y,&fixed_temp,&space_y); ; 2
|
||||||
|
lda SPACEY_F ; 3
|
||||||
|
adc TEMP_F ; 3
|
||||||
|
sta SPACEY_F ; 3
|
||||||
|
lda SPACEY_I ; 3
|
||||||
|
adc TEMP_I ; 3
|
||||||
|
sta SPACEY_I ; 3
|
||||||
|
|
||||||
clc ; fixed_add(&space_y,&fixed_temp,&space_y);
|
; brk ; space_y = f7:04
|
||||||
lda SPACEY_F
|
|
||||||
adc TEMP_F
|
|
||||||
sta SPACEY_F
|
|
||||||
lda SPACEY_I
|
|
||||||
adc TEMP_I
|
|
||||||
sta SPACEY_I
|
|
||||||
|
|
||||||
;;brk ;; brk space_y = f7:04
|
lda #0 ; 2
|
||||||
|
sta SCREEN_X ; 3
|
||||||
lda #0
|
;==========
|
||||||
sta SCREEN_X
|
; 25
|
||||||
screenx_loop:
|
screenx_loop:
|
||||||
|
|
||||||
jsr lookup_map ; get color in A
|
jsr lookup_map ; get color in A ; 6
|
||||||
|
|
||||||
ldy #0
|
ldy #0 ; 2
|
||||||
sta (GBASL),Y ; plot double height
|
sta (GBASL),Y ; plot double height ; 6
|
||||||
inc GBASL ; point to next pixel
|
inc GBASL ; point to next pixel ; 5
|
||||||
|
|
||||||
; Check if over water
|
; Check if over water
|
||||||
cmp #$22 ; see if dark blue
|
cmp #$22 ; see if dark blue ; 2
|
||||||
bne not_watery
|
bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda SCREEN_Y ; only check pixel in middle of screen
|
lda SCREEN_Y ; only check pixel in middle of screen ; 3
|
||||||
cmp #38
|
cmp #38 ; 2
|
||||||
bne not_watery
|
bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda SCREEN_X ; only check pixel in middle of screen
|
lda SCREEN_X ; only check pixel in middle of screen ; 3
|
||||||
cmp #20
|
cmp #20 ; 2
|
||||||
bne not_watery
|
bne not_watery ; 2nt/3
|
||||||
|
|
||||||
lda #$1 ; set over water
|
|
||||||
sta OVER_WATER
|
|
||||||
|
|
||||||
|
lda #$1 ; set over water ; 2
|
||||||
|
sta OVER_WATER ; 3
|
||||||
|
;============
|
||||||
|
; 42
|
||||||
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);
|
clc ; fixed_add(&space_x,&dx,&space_x); ; 2
|
||||||
lda SPACEX_F
|
lda SPACEX_F ; 3
|
||||||
adc DX_F
|
adc DX_F ; 3
|
||||||
sta SPACEX_F
|
sta SPACEX_F ; 3
|
||||||
lda SPACEX_I
|
lda SPACEX_I ; 3
|
||||||
adc DX_I
|
adc DX_I ; 3
|
||||||
sta SPACEX_I
|
sta SPACEX_I ; 3
|
||||||
|
|
||||||
clc ; fixed_add(&space_y,&dy,&space_y);
|
clc ; fixed_add(&space_y,&dy,&space_y); ; 2
|
||||||
lda SPACEY_F
|
lda SPACEY_F ; 3
|
||||||
adc DY_F
|
adc DY_F ; 3
|
||||||
sta SPACEY_F
|
sta SPACEY_F ; 3
|
||||||
lda SPACEY_I
|
lda SPACEY_I ; 3
|
||||||
adc DY_I
|
adc DY_I ; 3
|
||||||
sta SPACEY_I
|
sta SPACEY_I ; 3
|
||||||
|
|
||||||
|
inc SCREEN_X ; 5
|
||||||
|
lda SCREEN_X ; 3
|
||||||
|
cmp #40 ; LOWRES width ; 2
|
||||||
|
bne screenx_loop ; 2nt/3
|
||||||
|
;=============
|
||||||
|
; 53
|
||||||
|
|
||||||
|
lda SCREEN_Y ; 3
|
||||||
inc SCREEN_X
|
clc ; 2
|
||||||
lda SCREEN_X
|
adc #2 ; 2
|
||||||
cmp #40 ; LOWRES width
|
sta SCREEN_Y ; 3
|
||||||
bne screenx_loop
|
cmp #40 ; LOWRES height ; 2
|
||||||
|
beq done_screeny ; 2nt/3
|
||||||
|
jmp screeny_loop ; 3
|
||||||
lda SCREEN_Y
|
;=============
|
||||||
clc
|
; 17
|
||||||
adc #2
|
|
||||||
sta SCREEN_Y
|
|
||||||
cmp #40 ; LOWRES height
|
|
||||||
beq done_screeny
|
|
||||||
jmp screeny_loop
|
|
||||||
done_screeny:
|
done_screeny:
|
||||||
rts
|
rts ; 6
|
||||||
|
|
||||||
|
|
||||||
;====================
|
;====================
|
||||||
|
@@ -15,96 +15,96 @@ NEGATE: .byte 0
|
|||||||
|
|
||||||
multiply:
|
multiply:
|
||||||
|
|
||||||
lda #$0
|
lda #$0 ; 2
|
||||||
sta NEGATE
|
sta NEGATE ; 4
|
||||||
|
|
||||||
; Handle Signed
|
; Handle Signed
|
||||||
lda NUM1H
|
lda NUM1H ; 4
|
||||||
bpl check_num2
|
bpl check_num2 ; 2nt/3
|
||||||
|
|
||||||
inc NEGATE
|
inc NEGATE ; 4
|
||||||
|
|
||||||
clc
|
clc ; 2s-complement NUM1H/NUM1L ; 2
|
||||||
lda NUM1L
|
lda NUM1L ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$1
|
adc #$1 ; 2
|
||||||
sta NUM1L
|
sta NUM1L ; 4
|
||||||
|
|
||||||
lda NUM1H
|
lda NUM1H ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$0
|
adc #$0 ; 2
|
||||||
sta NUM1H
|
sta NUM1H ; 4
|
||||||
|
|
||||||
check_num2:
|
check_num2:
|
||||||
lda NUM2H
|
lda NUM2H ; 4
|
||||||
bpl unsigned_multiply
|
bpl unsigned_multiply ; 2nt/3
|
||||||
|
|
||||||
inc NEGATE
|
inc NEGATE ; 4
|
||||||
|
|
||||||
clc
|
clc ; 2
|
||||||
lda NUM2L
|
lda NUM2L ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$1
|
adc #$1 ; 2
|
||||||
sta NUM2L
|
sta NUM2L ; 4
|
||||||
|
|
||||||
lda NUM2H
|
lda NUM2H ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$0
|
adc #$0 ; 2
|
||||||
sta NUM2H
|
sta NUM2H ; 4
|
||||||
|
|
||||||
unsigned_multiply:
|
unsigned_multiply:
|
||||||
|
|
||||||
lda #0 ; Initialize RESULT to 0
|
lda #0 ; Initialize RESULT to 0 ; 2
|
||||||
sta RESULT+2
|
sta RESULT+2 ; 4
|
||||||
ldx #16 ; 16x16 multiply
|
ldx #16 ; 16x16 multiply ; 2
|
||||||
multiply_mainloop:
|
multiply_mainloop:
|
||||||
lsr NUM2H ; Shift right 16-bit NUM2
|
lsr NUM2H ; Shift right 16-bit NUM2 ; 6
|
||||||
ror NUM2L ; low bit goes into carry
|
ror NUM2L ; low bit goes into carry ; 6
|
||||||
bcc shift_output ; 0 or 1?
|
bcc shift_output ; 0 or 1? ; 2nt/3
|
||||||
tay ; If 1, add NUM1 (hi byte of RESULT is in A)
|
tay ; If 1, add NUM1 (hi byte RESULT in A) ; 2
|
||||||
clc
|
clc ; 2
|
||||||
lda NUM1L
|
lda NUM1L ; 4
|
||||||
adc RESULT+2
|
adc RESULT+2 ; 4
|
||||||
sta RESULT+2
|
sta RESULT+2 ; 4
|
||||||
tya
|
tya ; 2
|
||||||
adc NUM1H
|
adc NUM1H ; 4
|
||||||
shift_output:
|
shift_output:
|
||||||
ror A ; "Stairstep" shift
|
ror A ; "Stairstep" shift ; 2
|
||||||
ror RESULT+2
|
ror RESULT+2 ; 6
|
||||||
ror RESULT+1
|
ror RESULT+1 ; 6
|
||||||
ror RESULT
|
ror RESULT ; 6
|
||||||
dex
|
dex ; 2
|
||||||
bne multiply_mainloop
|
bne multiply_mainloop ; 2nt/3
|
||||||
sta RESULT+3
|
sta RESULT+3 ; 4
|
||||||
|
|
||||||
;; Negate if necessary
|
;; Negate if necessary
|
||||||
|
|
||||||
lda NEGATE
|
lda NEGATE ; 4
|
||||||
and #$1
|
and #$1 ; 2
|
||||||
beq positive
|
beq positive ; 2nt/3
|
||||||
|
|
||||||
clc
|
clc ; 2
|
||||||
lda RESULT+0
|
lda RESULT+0 ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$1
|
adc #$1 ; 2
|
||||||
sta RESULT+0
|
sta RESULT+0 ; 4
|
||||||
|
|
||||||
lda RESULT+1
|
lda RESULT+1 ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$0
|
adc #$0 ; 2
|
||||||
sta RESULT+1
|
sta RESULT+1 ; 4
|
||||||
|
|
||||||
lda RESULT+2
|
lda RESULT+2 ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$0
|
adc #$0 ; 2
|
||||||
sta RESULT+2
|
sta RESULT+2 ; 4
|
||||||
|
|
||||||
lda RESULT+3
|
lda RESULT+3 ; 4
|
||||||
eor #$ff
|
eor #$ff ; 2
|
||||||
adc #$0
|
adc #$0 ; 2
|
||||||
sta RESULT+3
|
sta RESULT+3 ; 4
|
||||||
|
|
||||||
positive:
|
positive:
|
||||||
|
|
||||||
rts
|
rts ; 6
|
||||||
|
|
||||||
|
@@ -579,19 +579,20 @@ vlin_too_slow:
|
|||||||
; put address in GBASL/GBASH
|
; put address in GBASL/GBASH
|
||||||
; Ycoord in A, Xcoord in Y
|
; Ycoord in A, Xcoord in Y
|
||||||
hlin_setup:
|
hlin_setup:
|
||||||
sty TEMPY
|
sty TEMPY ; 3
|
||||||
tay ; y=A
|
tay ; y=A ; 2
|
||||||
lda gr_offsets,Y ; lookup low-res memory address
|
lda gr_offsets,Y ; lookup low-res memory address ; 4
|
||||||
clc
|
clc ; 2
|
||||||
adc TEMPY
|
adc TEMPY ; 3
|
||||||
sta GBASL
|
sta GBASL ; 3
|
||||||
iny
|
iny ; 2
|
||||||
|
|
||||||
lda gr_offsets,Y
|
|
||||||
adc DRAW_PAGE ; add in draw page offset
|
|
||||||
sta GBASH
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
lda gr_offsets,Y ; 4
|
||||||
|
adc DRAW_PAGE ; add in draw page offset ; 3
|
||||||
|
sta GBASH ; 3
|
||||||
|
rts ; 6
|
||||||
|
;===========
|
||||||
|
; 35
|
||||||
;================================
|
;================================
|
||||||
; hlin_double:
|
; hlin_double:
|
||||||
;================================
|
;================================
|
||||||
@@ -601,18 +602,16 @@ hlin_setup:
|
|||||||
hlin_double:
|
hlin_double:
|
||||||
;int hlin_double(int page, int x1, int x2, int at) {
|
;int hlin_double(int page, int x1, int x2, int at) {
|
||||||
|
|
||||||
jsr hlin_setup
|
jsr hlin_setup ; 41
|
||||||
|
|
||||||
sec
|
sec ; 2
|
||||||
lda V2
|
lda V2 ; 3
|
||||||
sbc TEMPY
|
sbc TEMPY ; 3
|
||||||
|
|
||||||
tax
|
tax ; 2
|
||||||
inx
|
inx ; 2
|
||||||
|
;===========
|
||||||
; jsr hlin_double_continue
|
; 53
|
||||||
|
|
||||||
; rts
|
|
||||||
; fallthrough
|
; fallthrough
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
@@ -622,16 +621,17 @@ hlin_double:
|
|||||||
|
|
||||||
hlin_double_continue:
|
hlin_double_continue:
|
||||||
|
|
||||||
|
ldy #0 ; 2
|
||||||
|
lda COLOR ; 3
|
||||||
hlin_double_loop:
|
hlin_double_loop:
|
||||||
ldy #0
|
sta (GBASL),Y ; 6
|
||||||
lda COLOR
|
inc GBASL ; 5
|
||||||
sta (GBASL),Y
|
dex ; 2
|
||||||
inc GBASL
|
bne hlin_double_loop ; 2nt/3
|
||||||
dex
|
|
||||||
bne hlin_double_loop
|
|
||||||
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
rts ; 6
|
||||||
|
;=============
|
||||||
|
; 53+5+X*16+5
|
||||||
|
|
||||||
;================================
|
;================================
|
||||||
; hlin_single:
|
; hlin_single:
|
||||||
|
Reference in New Issue
Block a user