tfv: remove old multiply code

This commit is contained in:
Vince Weaver 2017-11-26 11:21:54 -05:00
parent 024d38ce36
commit 03e7afe1ce

View File

@ -600,207 +600,6 @@ y_positive:
}
#if 0
static void fixed_mul(unsigned char x_i, unsigned char x_f,
unsigned char y_i, unsigned char y_f,
unsigned char *z_i, unsigned char *z_f) {
int num1h,num1l;
int num2h,num2l;
int result3;
int result2,result1,result0;
int aa,xx,cc=0,cc2,yy;
unsigned char negate;
num1h=x_i;
num1l=x_f;
negate=0;
cycles.multiply+=10;
if (!(num1h&0x80)) goto check_num2;
cycles.multiply--;
negate++;
num1l=~num1l;
num1h=~num1h;
num1l&=0xff;
num1h&=0xff;
num1l+=1;
cc=!!(num1l&0x100);
num1h+=cc;
num1l&=0xff;
num1h&=0xff;
cycles.multiply+=25;
check_num2:
num2h=y_i;
num2l=y_f;
cycles.multiply+=6;
if (!(num2h&0x80)) goto unsigned_multiply;
cycles.multiply--;
negate++;
num2l=~num2l;
num2h=~num2h;
num2l&=0xff;
num2h&=0xff;
num2l+=1;
cc=!!(num2l&0x100);
num2h+=cc;
num2l&=0xff;
num2h&=0xff;
cycles.multiply+=25;
unsigned_multiply:
// if (debug) {
// printf("Using %02x:%02x * %02x:%02x\n",num1h,num1l,num2h,num2l);
// }
result0=0;
result1=0;
aa=0; // lda #0 (sz)
result2=aa; // sta result+2
xx=16; // ldx #16 (sz)
cycles.multiply+=7;
multiply_mainloop:
cc=(num2h&1); //lsr NUM2+1 (szc)
num2h>>=1;
num2h&=0x7f;
// if (num2_neg) {
// num2h|=0x80;
// }
cc2=(num2l&1); // ror NUM2 (szc)
num2l>>=1;
num2l&=0x7f;
num2l|=(cc<<7);
cc=cc2;
cycles.multiply+=13;
if (cc==0) goto shift_output; // bcc L2
cycles.multiply--;
yy=aa; // tay (sz)
cc=0; // clc
aa=num1l; // lda NUM1 (sz)
aa=aa+cc+result2; // adc RESULT+2 (svzc)
cc=!!(aa&0x100);
aa&=0xff;
result2=aa; // sta RESULT+2
aa=yy; // tya
aa=aa+cc+num1h; // adc NUM1+1
cc=!!(aa&0x100);
aa=aa&0xff;
cycles.multiply+=18;
shift_output:
cc2=aa&1;
aa=aa>>1;
aa&=0x7f;
aa|=cc<<7;
cc=cc2; // ror A
cc2=result2&1;
result2=result2>>1;
result2&=0x7f;
result2|=(cc<<7);
cc=cc2; // ror result+2
cc2=result1&1;
result1=result1>>1;
result1&=0x7f;
result1|=cc<<7;
cc=cc2; // ror result+1
cc2=result0&1;
result0=result0>>1;
result0&=0x7f;
result0|=cc<<7;
cc=cc2; // ror result+0
xx--; // dex
cycles.multiply+=22;
if (xx!=0) goto multiply_mainloop; // bne L1
cycles.multiply--;
result3=aa&0xff; // sta result+3
// if (debug) {
// printf("RAW RESULT = %02x:%02x:%02x:%02x\n",
// result3&0xff,result2&0xff,result1&0xff,result0&0xff);
// }
cycles.multiply+=11;
if (negate&1) {
// printf("NEGATING!\n");
cycles.multiply--;
cc=0;
aa=0;
aa-=result0+cc;
cc=!!(aa&0x100);
result0=aa;
aa=0;
aa-=result1+cc;
cc=!!(aa&0x100);
result1=aa;
aa=0;
aa-=result2+cc;
cc=!!(aa&0x100);
result2=aa;
aa=0;
aa-=result3+cc;
cc=!!(aa&0x100);
result3=aa;
cycles.multiply+=42;
}
*z_i=result2&0xff;
*z_f=result1&0xff;
result3&=0xff;
result2&=0xff;
result1&=0xff;
result0&=0xff;
// if (debug) {
// printf("%02x:%02x * %02x:%02x = %02x:%02x:%02x:%02x\n",
// num1h,num1l,y->i,y->f,
// result3&0xff,result2&0xff,result1&0xff,result0&0xff);
// printf("%02x%02x * %02x%02x = %02x%02x%02x%02x\n",
// num1h,num1l,y->i,y->f,
// result3,result2,result1,result0);
// }
// int a2;
// int s1,s2;
// s1=(num1h<<8)|(num1l);
// s2=(y->i<<8)|(y->f);
// a2=(result3<<24)|(result2<<16)|(result1<<8)|result0;
// printf("%d * %d = %d (0x%x)\n",s1,s2,a2,a2);
cycles.multiply+=6;
return;
}
#endif
static void draw_background_mode7(void) {