gr-sim: uppercase the 6502 emulated registers
probably broke something, but this also was a pain as was often accidentally using the vars, especially X and Y
This commit is contained in:
parent
107b7f03f2
commit
c05084c289
|
@ -9,21 +9,21 @@
|
|||
unsigned char ram[RAMSIZE];
|
||||
|
||||
/* Registers */
|
||||
unsigned char a,y,x;
|
||||
unsigned short sp;
|
||||
unsigned char A,Y,X;
|
||||
unsigned short SP;
|
||||
|
||||
/* Flags */
|
||||
unsigned int n,z,c,v;
|
||||
unsigned int N,Z,C,V;
|
||||
|
||||
int init_6502(void) {
|
||||
|
||||
a=0;
|
||||
y=0;
|
||||
x=0;
|
||||
A=0;
|
||||
Y=0;
|
||||
X=0;
|
||||
|
||||
sp=0x1ff;
|
||||
SP=0x1ff;
|
||||
|
||||
n=0; z=0; c=0; v=0;
|
||||
N=0; Z=0; C=0; V=0;
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -42,7 +42,7 @@ unsigned short y_indirect(unsigned char base, unsigned char y) {
|
|||
}
|
||||
|
||||
void clc(void) {
|
||||
c=0;
|
||||
C=0;
|
||||
}
|
||||
|
||||
void adc(int value) {
|
||||
|
@ -51,18 +51,18 @@ void adc(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=value&0xff;
|
||||
|
||||
result=(temp_a+temp_value+c);
|
||||
result=(temp_a+temp_value+C);
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
n=(result&0x80)>>7;
|
||||
C=(result&0x100)>>8;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
v=!!((a^result)&(value^result)&0x80);
|
||||
V=!!((A^result)&(value^result)&0x80);
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -72,18 +72,18 @@ void adc_mem(int addr) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=ram[addr]&0xff;
|
||||
|
||||
result=(temp_a+temp_value+c);
|
||||
result=(temp_a+temp_value+C);
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
n=(result&0x80)>>7;
|
||||
C=(result&0x100)>>8;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
v=!!((a^result)&(temp_value^result)&0x80);
|
||||
V=!!((A^result)&(temp_value^result)&0x80);
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -92,20 +92,20 @@ void sbc(int value) {
|
|||
int result;
|
||||
int temp_value;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=(~value)&0xff;
|
||||
|
||||
result=temp_a+temp_value+c;
|
||||
result=temp_a+temp_value+C;
|
||||
|
||||
// printf("SBC: %x - %x (%x) = %x\n",a,value,c,result);
|
||||
// printf("SBC: %x - %x (%x) = %x\n",A,value,C,result);
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
n=(result&0x80)>>7;
|
||||
C=(result&0x100)>>8;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
v=!!((a^result)&((255-value)^result)&0x80);
|
||||
V=!!((A^result)&((255-value)^result)&0x80);
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -115,20 +115,20 @@ void sbc_mem(int addr) {
|
|||
int result;
|
||||
int temp_value;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=(~ram[addr])&0xff;
|
||||
|
||||
result=temp_a+temp_value+c;
|
||||
result=temp_a+temp_value+C;
|
||||
|
||||
// printf("SBC: %x - %x (%x) = %x\n",a,value,c,result);
|
||||
// printf("SBC: %x - %x (%x) = %x\n",A,value,C,result);
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
n=(result&0x80)>>7;
|
||||
C=(result&0x100)>>8;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
v=!!((a^result)&((255-ram[addr])^result)&0x80);
|
||||
V=!!((A^result)&((255-ram[addr])^result)&0x80);
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -139,17 +139,17 @@ void cmp(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=(~value)&0xff;
|
||||
|
||||
result=temp_a+temp_value+1;
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
C=(result&0x100)>>8;
|
||||
|
||||
result&=0xff;
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
z=(result==0);
|
||||
N=(result&0x80)>>7;
|
||||
Z=(result==0);
|
||||
}
|
||||
|
||||
void cpy(int value) {
|
||||
|
@ -158,17 +158,17 @@ void cpy(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_y=y&0xff;
|
||||
temp_y=Y&0xff;
|
||||
temp_value=(~value)&0xff;
|
||||
|
||||
result=temp_y+temp_value+1;
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
C=(result&0x100)>>8;
|
||||
|
||||
result&=0xff;
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
z=(result==0);
|
||||
N=(result&0x80)>>7;
|
||||
Z=(result==0);
|
||||
}
|
||||
|
||||
void cpx(int value) {
|
||||
|
@ -177,59 +177,59 @@ void cpx(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_x=x&0xff;
|
||||
temp_x=X&0xff;
|
||||
temp_value=(~value)&0xff;
|
||||
|
||||
result=temp_x+temp_value+1;
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
C=(result&0x100)>>8;
|
||||
|
||||
result&=0xff;
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
z=(result==0);
|
||||
N=(result&0x80)>>7;
|
||||
Z=(result==0);
|
||||
}
|
||||
|
||||
|
||||
void pha(void) {
|
||||
|
||||
sp--;
|
||||
ram[sp]=a;
|
||||
SP--;
|
||||
ram[SP]=A;
|
||||
}
|
||||
|
||||
void pla(void) {
|
||||
|
||||
a=ram[sp];
|
||||
sp++;
|
||||
A=ram[SP];
|
||||
SP++;
|
||||
}
|
||||
|
||||
void lsr(void) {
|
||||
int temp_a;
|
||||
|
||||
temp_a=a;
|
||||
temp_a=A;
|
||||
temp_a&=0xff;
|
||||
|
||||
c=temp_a&0x1;
|
||||
C=temp_a&0x1;
|
||||
temp_a=temp_a>>1;
|
||||
a=(temp_a&0x7f); // always shift 0 into top
|
||||
z=(a==0);
|
||||
n=!!(a&0x80); // can this ever be 1? no?
|
||||
// printf("LSR A=%x\n",a);
|
||||
A=(temp_a&0x7f); // always shift 0 into top
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80); // can this ever be 1? no?
|
||||
// printf("LSR A=%x\n",A);
|
||||
}
|
||||
|
||||
void asl(void) {
|
||||
int temp_a;
|
||||
|
||||
temp_a=a;
|
||||
temp_a=A;
|
||||
temp_a&=0xff;
|
||||
|
||||
c=!!(temp_a&0x80);
|
||||
C=!!(temp_a&0x80);
|
||||
|
||||
temp_a=temp_a<<1;
|
||||
a=(temp_a&0xff);
|
||||
z=(a==0);
|
||||
n=!!(a&0x80);
|
||||
// printf("ASL A=%x\n",a);
|
||||
A=(temp_a&0xff);
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80);
|
||||
// printf("ASL A=%x\n",A);
|
||||
}
|
||||
|
||||
void asl_mem(int addr) {
|
||||
|
@ -238,12 +238,12 @@ void asl_mem(int addr) {
|
|||
temp_a=ram[addr];
|
||||
temp_a&=0xff;
|
||||
|
||||
c=!!(temp_a&0x80);
|
||||
C=!!(temp_a&0x80);
|
||||
|
||||
temp_a=temp_a<<1;
|
||||
ram[addr]=(temp_a&0xff);
|
||||
z=(ram[addr]==0);
|
||||
n=!!(ram[addr]&0x80);
|
||||
Z=(ram[addr]==0);
|
||||
N=!!(ram[addr]&0x80);
|
||||
// printf("ASL %x=%x\n",addr,ram[addr]);
|
||||
}
|
||||
|
||||
|
@ -252,37 +252,37 @@ void ror(void) {
|
|||
int temp_a;
|
||||
int old_c;
|
||||
|
||||
old_c=c;
|
||||
temp_a=a;
|
||||
old_c=C;
|
||||
temp_a=A;
|
||||
temp_a&=0xff;
|
||||
|
||||
c=temp_a&0x1;
|
||||
C=temp_a&0x1;
|
||||
temp_a=temp_a>>1;
|
||||
a=(temp_a&0xff);
|
||||
a|=old_c<<7;
|
||||
A=(temp_a&0xff);
|
||||
A|=old_c<<7;
|
||||
|
||||
z=(a==0);
|
||||
n=!!(a&0x80);
|
||||
// printf("ROR A=%x\n",a);
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80);
|
||||
// printf("ROR A=%x\n",A);
|
||||
}
|
||||
|
||||
void rol(void) {
|
||||
int temp_a;
|
||||
int old_c;
|
||||
|
||||
old_c=c;
|
||||
temp_a=a;
|
||||
old_c=C;
|
||||
temp_a=A;
|
||||
temp_a&=0xff;
|
||||
|
||||
c=!!(temp_a&0x80);
|
||||
C=!!(temp_a&0x80);
|
||||
|
||||
temp_a=temp_a<<1;
|
||||
a=(temp_a&0xff);
|
||||
a|=old_c;
|
||||
A=(temp_a&0xff);
|
||||
A|=old_c;
|
||||
|
||||
z=(a==0);
|
||||
n=!!(a&0x80);
|
||||
// printf("ROL A=%x\n",a);
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80);
|
||||
// printf("ROL A=%x\n",A);
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,17 +291,17 @@ void ror_mem(int addr) {
|
|||
int temp_a;
|
||||
int old_c;
|
||||
|
||||
old_c=c;
|
||||
old_c=C;
|
||||
temp_a=ram[addr];
|
||||
temp_a&=0xff;
|
||||
|
||||
c=temp_a&0x1;
|
||||
C=temp_a&0x1;
|
||||
temp_a=temp_a>>1;
|
||||
ram[addr]=(temp_a&0xff);
|
||||
ram[addr]|=old_c<<7;
|
||||
|
||||
z=(ram[addr]==0);
|
||||
n=!!(ram[addr]&0x80);
|
||||
Z=(ram[addr]==0);
|
||||
N=!!(ram[addr]&0x80);
|
||||
// printf("ROR %x=%x\n",addr,ram[addr]);
|
||||
}
|
||||
|
||||
|
@ -309,60 +309,60 @@ void rol_mem(int addr) {
|
|||
int temp_a;
|
||||
int old_c;
|
||||
|
||||
old_c=c;
|
||||
old_c=C;
|
||||
temp_a=ram[addr];
|
||||
temp_a&=0xff;
|
||||
|
||||
c=!!(temp_a&0x80);
|
||||
C=!!(temp_a&0x80);
|
||||
|
||||
temp_a=temp_a<<1;
|
||||
ram[addr]=(temp_a&0xff);
|
||||
ram[addr]|=old_c;
|
||||
|
||||
z=(ram[addr]==0);
|
||||
n=!!(ram[addr]&0x80);
|
||||
Z=(ram[addr]==0);
|
||||
N=!!(ram[addr]&0x80);
|
||||
// printf("ROL %x=%x\n",addr,ram[addr]);
|
||||
}
|
||||
|
||||
|
||||
void dex(void) {
|
||||
x--;
|
||||
X--;
|
||||
|
||||
z=(x==0);
|
||||
n=!!(x&0x80);
|
||||
Z=(X==0);
|
||||
N=!!(X&0x80);
|
||||
}
|
||||
|
||||
void dey(void) {
|
||||
y--;
|
||||
Y--;
|
||||
|
||||
z=(y==0);
|
||||
n=!!(y&0x80);
|
||||
Z=(Y==0);
|
||||
N=!!(Y&0x80);
|
||||
}
|
||||
|
||||
void inx(void) {
|
||||
x++;
|
||||
X++;
|
||||
|
||||
z=(x==0);
|
||||
n=!!(x&0x80);
|
||||
Z=(X==0);
|
||||
N=!!(X&0x80);
|
||||
}
|
||||
|
||||
void iny(void) {
|
||||
y++;
|
||||
Y++;
|
||||
|
||||
z=(y==0);
|
||||
n=!!(y&0x80);
|
||||
Z=(Y==0);
|
||||
N=!!(Y&0x80);
|
||||
}
|
||||
|
||||
void bit(int value) {
|
||||
int temp_a;
|
||||
|
||||
temp_a=a&value;
|
||||
temp_a=A&value;
|
||||
temp_a&=0xff;
|
||||
|
||||
z=(temp_a==0);
|
||||
Z=(temp_a==0);
|
||||
|
||||
n=(value&0x80);
|
||||
v=(value&0x40);
|
||||
N=(value&0x80);
|
||||
V=(value&0x40);
|
||||
|
||||
}
|
||||
|
||||
|
@ -370,76 +370,76 @@ void bit(int value) {
|
|||
void bit_mem(int addr) {
|
||||
int temp_a;
|
||||
|
||||
temp_a=a&ram[addr];
|
||||
temp_a=A&ram[addr];
|
||||
temp_a&=0xff;
|
||||
|
||||
z=(temp_a==0);
|
||||
Z=(temp_a==0);
|
||||
|
||||
n=(ram[addr]&0x80);
|
||||
v=(ram[addr]&0x40);
|
||||
N=(ram[addr]&0x80);
|
||||
V=(ram[addr]&0x40);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lda(int addr) {
|
||||
|
||||
a=ram[addr];
|
||||
A=ram[addr];
|
||||
|
||||
z=(a==0);
|
||||
n=!!(a&0x80);
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80);
|
||||
}
|
||||
|
||||
void lda_const(int value) {
|
||||
|
||||
a=value;
|
||||
A=value;
|
||||
|
||||
z=(a==0);
|
||||
n=!!(a&0x80);
|
||||
Z=(A==0);
|
||||
N=!!(A&0x80);
|
||||
}
|
||||
|
||||
void ldx(int addr) {
|
||||
|
||||
x=ram[addr];
|
||||
X=ram[addr];
|
||||
|
||||
z=(x==0);
|
||||
n=!!(x&0x80);
|
||||
Z=(X==0);
|
||||
N=!!(X&0x80);
|
||||
}
|
||||
|
||||
void ldx_const(int value) {
|
||||
|
||||
x=value;
|
||||
X=value;
|
||||
|
||||
z=(x==0);
|
||||
n=!!(x&0x80);
|
||||
Z=(X==0);
|
||||
N=!!(X&0x80);
|
||||
}
|
||||
|
||||
void ldy(int addr) {
|
||||
|
||||
y=ram[addr];
|
||||
Y=ram[addr];
|
||||
|
||||
z=(y==0);
|
||||
n=!!(y&0x80);
|
||||
Z=(Y==0);
|
||||
N=!!(Y&0x80);
|
||||
}
|
||||
|
||||
void ldy_const(int value) {
|
||||
|
||||
y=value;
|
||||
Y=value;
|
||||
|
||||
z=(y==0);
|
||||
n=!!(y&0x80);
|
||||
Z=(Y==0);
|
||||
N=!!(Y&0x80);
|
||||
}
|
||||
|
||||
void sta(int addr) {
|
||||
|
||||
ram[addr]=a;
|
||||
ram[addr]=A;
|
||||
}
|
||||
|
||||
void tax(void) {
|
||||
x=a;
|
||||
X=A;
|
||||
}
|
||||
|
||||
void txa(void) {
|
||||
a=x;
|
||||
A=X;
|
||||
}
|
||||
|
||||
void eor(int value) {
|
||||
|
@ -448,15 +448,15 @@ void eor(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=value&0xff;
|
||||
|
||||
result=(temp_a^temp_value);
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -466,15 +466,15 @@ void ora(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=value&0xff;
|
||||
|
||||
result=(temp_a|temp_value);
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -484,15 +484,15 @@ void ora_mem(int addr) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=ram[addr]&0xff;
|
||||
|
||||
result=(temp_a|temp_value);
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -502,15 +502,15 @@ void and(int value) {
|
|||
int temp_value;
|
||||
int result;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_a=A&0xff;
|
||||
temp_value=value&0xff;
|
||||
|
||||
result=(temp_a&temp_value);
|
||||
|
||||
n=(result&0x80)>>7;
|
||||
N=(result&0x80)>>7;
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
A=result&0xff;
|
||||
Z=(A==0);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#define RAMSIZE 128*1024
|
||||
extern unsigned char ram[RAMSIZE];
|
||||
extern unsigned char a,y,x;
|
||||
extern unsigned short sp;
|
||||
extern unsigned int n,z,c,v;
|
||||
extern unsigned char A,Y,X;
|
||||
extern unsigned short SP;
|
||||
extern unsigned int N,Z,C,V;
|
||||
|
||||
unsigned short y_indirect(unsigned char base, unsigned char y);
|
||||
int init_6502(void);
|
||||
|
|
|
@ -9,17 +9,17 @@ static void test_adc(void) {
|
|||
/* carry in 0 */
|
||||
for(i=0;i<256;i++) {
|
||||
for(j=0;j<256;j++) {
|
||||
c=0;
|
||||
a=i;
|
||||
C=0;
|
||||
A=i;
|
||||
adc(j);
|
||||
if (a!=((i+j)&0xff)) {
|
||||
printf("ADC: Error! %d+%d should be %d, not %d\n",i,j,i+j,a);
|
||||
if (A!=((i+j)&0xff)) {
|
||||
printf("ADC: Error! %d+%d should be %d, not %d\n",i,j,i+j,A);
|
||||
}
|
||||
if (c!=(((i+j)>>8)&0x1)) {
|
||||
printf("ADC: Error! Carry should be %d, not %d\n",((i+j)>>8)&0x1,c);
|
||||
if (C!=(((i+j)>>8)&0x1)) {
|
||||
printf("ADC: Error! Carry should be %d, not %d\n",((i+j)>>8)&0x1,C);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("ADC error, zflag wrong\n");
|
||||
if ((a!=0) && (z!=0)) printf("ADC error, zflag wrong\n");
|
||||
if ((A==0) && (Z!=1)) printf("ADC error, zflag wrong\n");
|
||||
if ((A!=0) && (Z!=0)) printf("ADC error, zflag wrong\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,17 +27,17 @@ static void test_adc(void) {
|
|||
/* carry in 1 */
|
||||
for(i=0;i<256;i++) {
|
||||
for(j=0;j<256;j++) {
|
||||
c=1;
|
||||
a=i;
|
||||
C=1;
|
||||
A=i;
|
||||
adc(j);
|
||||
if (a!=((i+j+1)&0xff)) {
|
||||
printf("ADC: Error! %d+%d should be %d, not %d\n",i,j,i+j+1,a);
|
||||
if (A!=((i+j+1)&0xff)) {
|
||||
printf("ADC: Error! %d+%d should be %d, not %d\n",i,j,i+j+1,A);
|
||||
}
|
||||
if (c!=(((i+j+1)>>8)&0x1)) {
|
||||
printf("ADC: Error! Carry should be %d, not %d\n",((i+j+1)>>8)&0x1,c);
|
||||
if (C!=(((i+j+1)>>8)&0x1)) {
|
||||
printf("ADC: Error! Carry should be %d, not %d\n",((i+j+1)>>8)&0x1,C);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("ADC error, zflag wrong\n");
|
||||
if ((a!=0) && (z!=0)) printf("ADC error, zflag wrong\n");
|
||||
if ((A==0) && (Z!=1)) printf("ADC error, zflag wrong\n");
|
||||
if ((A!=0) && (Z!=0)) printf("ADC error, zflag wrong\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,34 +48,34 @@ static void test_sbc(void) {
|
|||
/* carry in 1 */
|
||||
for(i=0;i<256;i++) {
|
||||
for(j=0;j<256;j++) {
|
||||
c=1;
|
||||
a=i;
|
||||
C=1;
|
||||
A=i;
|
||||
sbc(j);
|
||||
if (a!=((i-j-0)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-0,a);
|
||||
if (A!=((i-j-0)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-0,A);
|
||||
}
|
||||
if (c==(((i-j-0)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-0)>>8)&0x1,c);
|
||||
if (C==(((i-j-0)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-0)>>8)&0x1,C);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("SBC error, zflag wrong\n");
|
||||
if ((a!=0) && (z!=0)) printf("SBC error, zflag wrong\n");
|
||||
if ((A==0) && (Z!=1)) printf("SBC error, zflag wrong\n");
|
||||
if ((A!=0) && (Z!=0)) printf("SBC error, zflag wrong\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* carry in 0 */
|
||||
for(i=0;i<256;i++) {
|
||||
for(j=0;j<256;j++) {
|
||||
c=0;
|
||||
a=i;
|
||||
C=0;
|
||||
A=i;
|
||||
sbc(j);
|
||||
if (a!=((i-j-1)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-1,a);
|
||||
if (A!=((i-j-1)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-1,A);
|
||||
}
|
||||
if (c==(((i-j-1)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-1)>>8)&0x1,c);
|
||||
if (C==(((i-j-1)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-1)>>8)&0x1,C);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("SBC error, zflag wrong\n");
|
||||
if ((a!=0) && (z!=0)) printf("SBC error, zflag wrong\n");
|
||||
if ((A==0) && (Z!=1)) printf("SBC error, zflag wrong\n");
|
||||
if ((A!=0) && (Z!=0)) printf("SBC error, zflag wrong\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ SDL_INCLUDE= `sdl-config --cflags`
|
|||
|
||||
all: gr-sim.a
|
||||
make -C 6502_test
|
||||
make -C bubble
|
||||
make -C donut
|
||||
make -C dos
|
||||
make -C dots
|
||||
make -C drops
|
||||
make -C fade
|
||||
make -C fire
|
||||
|
@ -21,12 +24,14 @@ all: gr-sim.a
|
|||
make -C mode7_demo
|
||||
make -C plasma
|
||||
make -C rasterbars
|
||||
make -C raytrace
|
||||
make -C rotate_wipe
|
||||
make -C split_screen
|
||||
make -C starfield
|
||||
make -C text
|
||||
make -C tfv
|
||||
make -C tunnel
|
||||
make -C twister
|
||||
make -C water
|
||||
|
||||
#### Library
|
||||
|
@ -58,7 +63,10 @@ hgr-sim.o: hgr-sim.c gr-sim.h
|
|||
clean:
|
||||
rm -f *~ *.o *.a
|
||||
make -C 6502_test clean
|
||||
make -C bubble clean
|
||||
make -C donut clean
|
||||
make -C dos clean
|
||||
make -C dots clean
|
||||
make -C drops clean
|
||||
make -C fade clean
|
||||
make -C fire clean
|
||||
|
@ -71,10 +79,12 @@ clean:
|
|||
make -C mode7_demo clean
|
||||
make -C plasma clean
|
||||
make -C rasterbars clean
|
||||
make -C raytrace clean
|
||||
make -C rotate_wipe clean
|
||||
make -C split_screen clean
|
||||
make -C starfield clean
|
||||
make -C text clean
|
||||
make -C tfv clean
|
||||
make -C tunnel clean
|
||||
make -C twister clean
|
||||
make -C water clean
|
||||
|
|
|
@ -6,7 +6,7 @@ SDL_LIBS= `sdl-config --libs`
|
|||
SDL_INCLUDE= `sdl-config --cflags`
|
||||
GR_SIM = ../gr-sim.a
|
||||
|
||||
all: bubble
|
||||
all: bubble bubble_orig
|
||||
|
||||
####
|
||||
|
||||
|
@ -18,5 +18,14 @@ bubble.o: bubble.c
|
|||
|
||||
####
|
||||
|
||||
bubble_orig: bubble_orig.o $(GR_SIM)
|
||||
$(CC) -o bubble_orig bubble_orig.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS)
|
||||
|
||||
bubble_orig.o: bubble_orig.c
|
||||
$(CC) $(CFLAGS) -c bubble_orig.c
|
||||
|
||||
|
||||
####
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o bubble
|
||||
rm -f *~ *.o bubble bubble_orig
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* Bubble */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gr-sim.h"
|
||||
#include "tfv_utils.h"
|
||||
#include "tfv_zp.h"
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int ch;
|
||||
int n,i,j;
|
||||
double r,rr,t,xx=0,u=0,v=0;//,sz,sw,sh;
|
||||
|
||||
grsim_init();
|
||||
|
||||
printf("XX=%lf\n",xx);
|
||||
|
||||
// HCOLOR=7
|
||||
hcolor_equals(7);
|
||||
|
||||
// N=200:R=6.28/235:T=0:SZ=200:SW=280/SZ:SH=SCRH/SZ
|
||||
n=32; r=6.28/235.0;
|
||||
t=0;
|
||||
|
||||
// HGR2:FOR I=0 TO N:RR=R*I:FOR J=0 TO N
|
||||
|
||||
hgr();
|
||||
soft_switch(MIXCLR);
|
||||
while(1) {
|
||||
hclr();
|
||||
|
||||
clear_screens();
|
||||
for(i=0;i<n;i++) {
|
||||
rr=r*i;
|
||||
for(j=0;j<n;j++) {
|
||||
//U=SIN(I+V)+SIN(RR+X)
|
||||
u=sin(i+v)+sin(rr+xx);
|
||||
//V=COS(I+V)+COS(RR+X)
|
||||
v=cos(i+v)+cos(rr+xx);
|
||||
// X=U+T
|
||||
xx=u+t;
|
||||
//HPLOT 32*U+140,32*V+96
|
||||
hplot(48*u+140,48*v+96);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
grsim_update();
|
||||
usleep(100000);
|
||||
|
||||
ch=grsim_input();
|
||||
if (ch=='q') exit(0);
|
||||
t=t+.025;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -20,28 +20,28 @@ int main(int argc, char **argv) {
|
|||
yy=0;
|
||||
printf("****yy=%d\n",yy);
|
||||
|
||||
y=yy; // ldy #0
|
||||
x=3; // ldx #3
|
||||
Y=yy; // ldy #0
|
||||
X=3; // ldx #3
|
||||
L1:
|
||||
ram[0x3c]=x; // stx $3c
|
||||
a=x; // txa
|
||||
ram[0x3c]=X; // stx $3c
|
||||
A=X; // txa
|
||||
asl(); // asl
|
||||
bit_mem(0x3c); // bit $3c
|
||||
if (z==1) goto L3; // beq L3
|
||||
if (Z==1) goto L3; // beq L3
|
||||
ora_mem(0x3c); // ora $3c
|
||||
eor(0xff); // eor #$ff
|
||||
and(0x7e); // and #$7e
|
||||
L2:
|
||||
if (c==1) goto L3; // bcs L3
|
||||
if (C==1) goto L3; // bcs L3
|
||||
lsr(); // lsr
|
||||
if (z==0) goto L2; // bne L2
|
||||
if (Z==0) goto L2; // bne L2
|
||||
|
||||
a=y; // tya
|
||||
printf("%x=%x\n",x,a); // sta nibtbl, x
|
||||
y++; // iny
|
||||
A=Y; // tya
|
||||
printf("%x=%x\n",X,A); // sta nibtbl, x
|
||||
Y++; // iny
|
||||
L3:
|
||||
x++; // inx
|
||||
if (!(x&0x80)) goto L1; // bpl L1
|
||||
X++; // inx
|
||||
if (!(X&0x80)) goto L1; // bpl L1
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "8086_emulator.h"
|
||||
|
||||
unsigned short stack[4096];
|
||||
unsigned short ax,bx,cx,dx,si,di,bp,cs,ds,es,fs;
|
||||
unsigned short ax,bx,cx,dx,si,di,bp,cs,ds,es,fs,sp;
|
||||
int cf=0,of=0,zf=0,sf=0;
|
||||
//int sp=0;
|
||||
|
||||
|
|
|
@ -535,8 +535,8 @@ int grsim_update(void) {
|
|||
|
||||
void setnorm(void) {
|
||||
|
||||
y=0xff;
|
||||
ram[INVFLG]=y;
|
||||
Y=0xff;
|
||||
ram[INVFLG]=Y;
|
||||
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ int grsim_init(void) {
|
|||
ram[WNDTOP]=0x00;
|
||||
ram[WNDBTM]=0x18;
|
||||
|
||||
a=0; y=0; x=0;
|
||||
A=0; Y=0; X=0;
|
||||
|
||||
//FA62 RESET
|
||||
|
||||
|
@ -601,9 +601,9 @@ static void monitor_plot(void) {
|
|||
|
||||
/* Call into Monitor $F800 */
|
||||
|
||||
c=a&1; /* save LSB in carry */
|
||||
a=a>>1; /* lsr A */
|
||||
gbascalc(a);
|
||||
c=A&1; /* save LSB in carry */
|
||||
A=A>>1; /* lsr A */
|
||||
gbascalc(A);
|
||||
|
||||
if (c) {
|
||||
/* If odd, mask is 0xf0 */
|
||||
|
@ -614,15 +614,15 @@ static void monitor_plot(void) {
|
|||
ram[MASK]=0x0f;
|
||||
}
|
||||
|
||||
a=ram[y_indirect(GBASL,y)];
|
||||
A=ram[y_indirect(GBASL,Y)];
|
||||
|
||||
a=a^ram[COLOR];
|
||||
A=A^ram[COLOR];
|
||||
|
||||
a=a&ram[MASK];
|
||||
A=A&ram[MASK];
|
||||
|
||||
a=a^ram[y_indirect(GBASL,y)];
|
||||
A=A^ram[y_indirect(GBASL,Y)];
|
||||
|
||||
ram[y_indirect(GBASL,y)]=a;
|
||||
ram[y_indirect(GBASL,Y)]=A;
|
||||
|
||||
}
|
||||
|
||||
|
@ -639,11 +639,11 @@ int basic_plot(unsigned char xcoord, unsigned char ycoord) {
|
|||
/* Y-coord in A */
|
||||
/* X-coord in Y */
|
||||
/* Check that X-coord<40 */
|
||||
a=ycoord;
|
||||
y=xcoord;
|
||||
A=ycoord;
|
||||
Y=xcoord;
|
||||
|
||||
if (y>=40) {
|
||||
printf("X too big %d\n",y);
|
||||
if (Y>=40) {
|
||||
printf("X too big %d\n",Y);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -668,23 +668,23 @@ static void bascalc(void) {
|
|||
|
||||
unsigned char s,c;
|
||||
|
||||
s=a;
|
||||
c=a&0x1;
|
||||
s=A;
|
||||
c=A&0x1;
|
||||
|
||||
a=a>>1;
|
||||
a=a&0x3;
|
||||
a=a|0x4;
|
||||
ram[BASH]=a;
|
||||
a=s;
|
||||
a=a&0x18;
|
||||
A=A>>1;
|
||||
A=A&0x3;
|
||||
A=A|0x4;
|
||||
ram[BASH]=A;
|
||||
A=s;
|
||||
A=A&0x18;
|
||||
if (c!=0) {
|
||||
a=a+0x80;
|
||||
A=A+0x80;
|
||||
}
|
||||
// BSCLC2
|
||||
ram[BASL]=a;
|
||||
a=a<<2;
|
||||
a=a|ram[BASL];
|
||||
ram[BASL]=a;
|
||||
ram[BASL]=A;
|
||||
A=A<<2;
|
||||
A=A|ram[BASL];
|
||||
ram[BASL]=A;
|
||||
|
||||
}
|
||||
|
||||
|
@ -692,29 +692,29 @@ static void vtabz(void) {
|
|||
|
||||
bascalc();
|
||||
|
||||
a+=ram[WNDLFT];
|
||||
ram[BASL]=a;
|
||||
A+=ram[WNDLFT];
|
||||
ram[BASL]=A;
|
||||
|
||||
}
|
||||
|
||||
static void rom_vtab(void) {
|
||||
/* fb5b */
|
||||
a=ram[CV];
|
||||
A=ram[CV];
|
||||
vtabz();
|
||||
}
|
||||
|
||||
static void setwnd(void) {
|
||||
|
||||
ram[WNDTOP]=a;
|
||||
a=0x0;
|
||||
ram[WNDLFT]=a;
|
||||
a=0x28;
|
||||
ram[WNDWDTH]=a;
|
||||
a=0x18;
|
||||
ram[WNDBTM]=a;
|
||||
a=0x17;
|
||||
ram[WNDTOP]=A;
|
||||
A=0x0;
|
||||
ram[WNDLFT]=A;
|
||||
A=0x28;
|
||||
ram[WNDWDTH]=A;
|
||||
A=0x18;
|
||||
ram[WNDBTM]=A;
|
||||
A=0x17;
|
||||
// TABV
|
||||
ram[CV]=a;
|
||||
ram[CV]=A;
|
||||
rom_vtab();
|
||||
}
|
||||
|
||||
|
@ -724,11 +724,11 @@ static void vline(void) {
|
|||
|
||||
// f828
|
||||
vline_loop:
|
||||
s=a;
|
||||
s=A;
|
||||
monitor_plot();
|
||||
a=s;
|
||||
if (a<ram[V2]) {
|
||||
a++;
|
||||
A=s;
|
||||
if (A<ram[V2]) {
|
||||
A++;
|
||||
goto vline_loop;
|
||||
}
|
||||
}
|
||||
|
@ -736,15 +736,15 @@ vline_loop:
|
|||
static void clrtop(void) {
|
||||
|
||||
// f836
|
||||
y=0x27;
|
||||
ram[V2]=y;
|
||||
y=0x27;
|
||||
Y=0x27;
|
||||
ram[V2]=Y;
|
||||
Y=0x27;
|
||||
clrsc3:
|
||||
a=0x0;
|
||||
ram[COLOR]=a;
|
||||
A=0x0;
|
||||
ram[COLOR]=A;
|
||||
vline();
|
||||
y--;
|
||||
if (y<=0x80) goto clrsc3;
|
||||
Y--;
|
||||
if (Y<=0x80) goto clrsc3;
|
||||
}
|
||||
|
||||
static void setgr(void) {
|
||||
|
@ -756,7 +756,7 @@ static void setgr(void) {
|
|||
|
||||
clrtop();
|
||||
|
||||
a=0x14;
|
||||
A=0x14;
|
||||
setwnd();
|
||||
|
||||
}
|
||||
|
@ -807,12 +807,12 @@ int bload(char *filename, int address) {
|
|||
static int cleolz(void) {
|
||||
// FC9E
|
||||
|
||||
a=0xa0;
|
||||
A=0xa0;
|
||||
clreol2:
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
y++;
|
||||
ram[y_indirect(BASL,Y)]=A;
|
||||
Y++;
|
||||
|
||||
if (y<ram[WNDWDTH]) goto clreol2;
|
||||
if (Y<ram[WNDWDTH]) goto clreol2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -822,13 +822,13 @@ static int cleop1(void) {
|
|||
unsigned char s;
|
||||
|
||||
cleop1_begin:
|
||||
s=a;
|
||||
s=A;
|
||||
vtabz();
|
||||
cleolz();
|
||||
y=0x00;
|
||||
a=s;
|
||||
a++;
|
||||
if (a<=ram[WNDBTM]) goto cleop1_begin;
|
||||
Y=0x00;
|
||||
A=s;
|
||||
A++;
|
||||
if (A<=ram[WNDBTM]) goto cleop1_begin;
|
||||
rom_vtab();
|
||||
|
||||
return 0;
|
||||
|
@ -837,10 +837,10 @@ cleop1_begin:
|
|||
int home(void) {
|
||||
|
||||
/* FC58 */
|
||||
a=ram[WNDTOP];
|
||||
ram[CV]=a;
|
||||
y=0x00;
|
||||
ram[CH]=y;
|
||||
A=ram[WNDTOP];
|
||||
ram[CV]=A;
|
||||
Y=0x00;
|
||||
ram[CH]=Y;
|
||||
cleop1();
|
||||
|
||||
return 0;
|
||||
|
@ -853,8 +853,8 @@ int grsim_unrle_original(unsigned char *rle_data, int address) {
|
|||
ram[GBASL]=0; /* input address */
|
||||
ram[GBASH]=0; /* we fake this in this environment */
|
||||
|
||||
x=0; /* Set X and Y registers to 0 */
|
||||
y=0;
|
||||
X=0; /* Set X and Y registers to 0 */
|
||||
Y=0;
|
||||
|
||||
ram[BASL]=address&0xff; /* output address? */
|
||||
ram[BASH]=(address>>8)&0xff;
|
||||
|
@ -862,51 +862,51 @@ int grsim_unrle_original(unsigned char *rle_data, int address) {
|
|||
ram[CV]=0;
|
||||
|
||||
/* Read xsize, put in CH */
|
||||
ram[CH]=rle_data[y_indirect(GBASL,y)];
|
||||
y++;
|
||||
ram[CH]=rle_data[y_indirect(GBASL,Y)];
|
||||
Y++;
|
||||
|
||||
/* Skip ysize, we won't need it */
|
||||
y++;
|
||||
Y++;
|
||||
|
||||
while(1) {
|
||||
/* Get run length into a */
|
||||
a=rle_data[y_indirect(GBASL,y)];
|
||||
A=rle_data[y_indirect(GBASL,Y)];
|
||||
|
||||
/* 0xff is a special value meaning end */
|
||||
if (a==0xff) break;
|
||||
if (A==0xff) break;
|
||||
|
||||
/* Store run length into TEMP */
|
||||
ram[TEMP]=a;
|
||||
ram[TEMP]=A;
|
||||
|
||||
/* 16-bit increment of GBASL:GBASH */
|
||||
y++;
|
||||
if (y==0) ram[GBASH]++;
|
||||
Y++;
|
||||
if (Y==0) ram[GBASH]++;
|
||||
|
||||
/* Get the color into A */
|
||||
|
||||
a=rle_data[y_indirect(GBASL,y)];
|
||||
A=rle_data[y_indirect(GBASL,Y)];
|
||||
|
||||
/* 16-bit increment of GBASL:GBASH */
|
||||
y++;
|
||||
if (y==0) ram[GBASH]++;
|
||||
Y++;
|
||||
if (Y==0) ram[GBASH]++;
|
||||
|
||||
/* Push y on stack */
|
||||
s=y;
|
||||
y=0;
|
||||
s=Y;
|
||||
Y=0;
|
||||
|
||||
while(1) {
|
||||
/* store out color */
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
ram[y_indirect(BASL,Y)]=A;
|
||||
|
||||
/* 16-bit increment of output pointer */
|
||||
ram[BASL]++;
|
||||
if (ram[BASL]==0) ram[BASH]++;
|
||||
|
||||
/* increment size */
|
||||
x++;
|
||||
X++;
|
||||
|
||||
/* if size longer than width, adjust */
|
||||
if (x>=ram[CH]) {
|
||||
if (X>=ram[CH]) {
|
||||
if (ram[BASL]>0xa7) ram[BASH]++;
|
||||
ram[BASL]+=0x58;
|
||||
ram[CV]+=2;
|
||||
|
@ -921,7 +921,7 @@ int grsim_unrle_original(unsigned char *rle_data, int address) {
|
|||
ram[BASH]=ram[BASH]-0x3;
|
||||
}
|
||||
}
|
||||
x=0;
|
||||
X=0;
|
||||
}
|
||||
|
||||
/* repeat until use up all of run length */
|
||||
|
@ -929,7 +929,7 @@ int grsim_unrle_original(unsigned char *rle_data, int address) {
|
|||
if (ram[TEMP]==0) break;
|
||||
}
|
||||
/* restore y from stack */
|
||||
y=s;
|
||||
Y=s;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -942,8 +942,8 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||
ram[GBASL]=0; /* input address */
|
||||
ram[GBASH]=0; /* we fake this in this environment */
|
||||
|
||||
x=0; /* Set X and Y registers to 0 */
|
||||
y=0;
|
||||
X=0; /* Set X and Y registers to 0 */
|
||||
Y=0;
|
||||
|
||||
ram[BASL]=address&0xff; /* output address? */
|
||||
ram[BASH]=(address>>8)&0xff;
|
||||
|
@ -951,41 +951,40 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||
ram[CV]=0;
|
||||
|
||||
/* Read xsize, put in CH */
|
||||
ram[CH]=rle_data[y_indirect(GBASL,y)];
|
||||
y++;
|
||||
ram[CH]=rle_data[y_indirect(GBASL,Y)];
|
||||
Y++;
|
||||
|
||||
/* Skip ysize, we won't need it */
|
||||
// y++;
|
||||
// Y++;
|
||||
|
||||
while(1) {
|
||||
|
||||
/* Get byte into A */
|
||||
a=rle_data[y_indirect(GBASL,y)];
|
||||
A=rle_data[y_indirect(GBASL,Y)];
|
||||
|
||||
/* 0xa1 is a special value meaning end */
|
||||
if (a==0xa1) break;
|
||||
if (A==0xa1) break;
|
||||
|
||||
/* Store run length into TEMP */
|
||||
if ((a&0xf0)==0xa0) {
|
||||
if ((a&0xf)==0) {
|
||||
if ((A&0xf0)==0xa0) {
|
||||
if ((A&0xf)==0) {
|
||||
/* 16-bit increment of GBASL:GBASH */
|
||||
y++;
|
||||
if (y==0) ram[GBASH]++;
|
||||
|
||||
a=rle_data[y_indirect(GBASL,y)];
|
||||
ram[TEMP]=a;
|
||||
Y++;
|
||||
if (Y==0) ram[GBASH]++;
|
||||
|
||||
A=rle_data[y_indirect(GBASL,Y)];
|
||||
ram[TEMP]=A;
|
||||
}
|
||||
else {
|
||||
ram[TEMP]=a&0xf;
|
||||
ram[TEMP]=A&0xf;
|
||||
}
|
||||
|
||||
/* 16-bit increment of GBASL:GBASH */
|
||||
y++;
|
||||
if (y==0) ram[GBASH]++;
|
||||
Y++;
|
||||
if (Y==0) ram[GBASH]++;
|
||||
|
||||
/* Get the color into A */
|
||||
a=rle_data[y_indirect(GBASL,y)];
|
||||
A=rle_data[y_indirect(GBASL,Y)];
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -993,31 +992,31 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||
}
|
||||
|
||||
/* 16-bit increment of GBASL:GBASH */
|
||||
y++;
|
||||
if (y==0) ram[GBASH]++;
|
||||
Y++;
|
||||
if (Y==0) ram[GBASH]++;
|
||||
|
||||
/* Push y on stack */
|
||||
s=y;
|
||||
y=0;
|
||||
s=Y;
|
||||
Y=0;
|
||||
|
||||
#if 0
|
||||
{
|
||||
printf("Run=%d Color=%x\n",ram[TEMP],a);
|
||||
printf("Run=%d Color=%x\n",ram[TEMP],A);
|
||||
}
|
||||
#endif
|
||||
while(1) {
|
||||
/* store out color */
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
ram[y_indirect(BASL,Y)]=A;
|
||||
|
||||
/* 16-bit increment of output pointer */
|
||||
ram[BASL]++;
|
||||
if (ram[BASL]==0) ram[BASH]++;
|
||||
|
||||
/* increment size */
|
||||
x++;
|
||||
X++;
|
||||
|
||||
/* if size longer than width, adjust */
|
||||
if (x>=ram[CH]) {
|
||||
if (X>=ram[CH]) {
|
||||
if (ram[BASL]>0xa7) ram[BASH]++;
|
||||
ram[BASL]+=0x58;
|
||||
ram[CV]+=2;
|
||||
|
@ -1032,7 +1031,7 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||
ram[BASH]=ram[BASH]-0x3;
|
||||
}
|
||||
}
|
||||
x=0;
|
||||
X=0;
|
||||
}
|
||||
|
||||
/* repeat until use up all of run length */
|
||||
|
@ -1040,7 +1039,7 @@ int grsim_unrle(unsigned char *rle_data, int address) {
|
|||
if (ram[TEMP]==0) break;
|
||||
}
|
||||
/* restore y from stack */
|
||||
y=s;
|
||||
Y=s;
|
||||
|
||||
#if 0
|
||||
{
|
||||
|
@ -1070,10 +1069,10 @@ int basic_vlin(int y1, int y2, int at) {
|
|||
|
||||
if (y1>y2) { ram[H2]=y1; ram[V2]=y1; ram[FIRST]=y2; }
|
||||
else { ram[H2]=y2; ram[V2]=y2; ram[FIRST]=y1; }
|
||||
x=at;
|
||||
X=at;
|
||||
|
||||
if (x>40) {
|
||||
fprintf(stderr,"Error! AT too large %d!\n",x);
|
||||
if (X>40) {
|
||||
fprintf(stderr,"Error! AT too large %d!\n",X);
|
||||
}
|
||||
|
||||
//VLIN JSR LINCOOR
|
||||
|
@ -1084,12 +1083,12 @@ int basic_vlin(int y1, int y2, int at) {
|
|||
//F24A- A5 F0 2090 LDA FIRST TOP END OF LINE IN A-REG
|
||||
//F24C- 4C 28 F8 2100 JMP MON.VLINE LET MONITOR DRAW LINE
|
||||
|
||||
y=x;
|
||||
if (y>=40) {
|
||||
fprintf(stderr,"X value to big in vline %d\n",y);
|
||||
Y=X;
|
||||
if (Y>=40) {
|
||||
fprintf(stderr,"X value to big in vline %d\n",Y);
|
||||
return -1;
|
||||
}
|
||||
a=ram[FIRST];
|
||||
A=ram[FIRST];
|
||||
|
||||
vline();
|
||||
|
||||
|
@ -1108,7 +1107,7 @@ int grsim_put_sprite_page(int page, unsigned char *sprite_data, int xpos, int yp
|
|||
int cycles=0;
|
||||
|
||||
ptr=sprite_data;
|
||||
x=*ptr;
|
||||
X=*ptr;
|
||||
ptr++;
|
||||
ram[CV]=*ptr;
|
||||
ptr++;
|
||||
|
@ -1122,29 +1121,29 @@ int grsim_put_sprite_page(int page, unsigned char *sprite_data, int xpos, int yp
|
|||
address+=(page)<<8;
|
||||
address+=xpos;
|
||||
cycles+=36;
|
||||
for(i=0;i<x;i++) {
|
||||
a=*ptr;
|
||||
for(i=0;i<X;i++) {
|
||||
A=*ptr;
|
||||
cycles+=17;
|
||||
// all transparent, skip
|
||||
if (a==0xaa) {
|
||||
if (A==0xaa) {
|
||||
}
|
||||
// bottom transparent
|
||||
else if ((a&0xf0)==0xa0) {
|
||||
else if ((A&0xf0)==0xa0) {
|
||||
cycles+=8;
|
||||
ram[address]&=0xf0;
|
||||
ram[address]|=(a&0xf);
|
||||
ram[address]|=(A&0xf);
|
||||
cycles+=19;
|
||||
}
|
||||
// top transparent
|
||||
else if ((a&0x0f)==0xa) {
|
||||
else if ((A&0x0f)==0xa) {
|
||||
cycles+=8;
|
||||
ram[address]&=0x0f;
|
||||
ram[address]|=(a&0xf0);
|
||||
ram[address]|=(A&0xf0);
|
||||
cycles+=19;
|
||||
}
|
||||
else {
|
||||
cycles+=8;
|
||||
ram[address]=a;
|
||||
ram[address]=A;
|
||||
cycles+=19;
|
||||
}
|
||||
ptr++;
|
||||
|
@ -1235,7 +1234,7 @@ int text(void) {
|
|||
|
||||
soft_switch(LOWSCR); // LDA LOWSCR ($c054)
|
||||
soft_switch(TXTSET); // LDA TXTSET ($c051);
|
||||
a=0;
|
||||
A=0;
|
||||
|
||||
setwnd();
|
||||
|
||||
|
@ -1247,42 +1246,42 @@ static void scroll(void) {
|
|||
|
||||
// fc70
|
||||
|
||||
a=ram[WNDTOP];
|
||||
s=a;
|
||||
A=ram[WNDTOP];
|
||||
s=A;
|
||||
vtabz();
|
||||
|
||||
// SCRL1
|
||||
scrl1:
|
||||
a=ram[BASL];
|
||||
ram[BAS2L]=a;
|
||||
a=ram[BASH];
|
||||
ram[BAS2H]=a;
|
||||
y=ram[WNDWDTH];
|
||||
y--;
|
||||
a=s;
|
||||
a+=1;
|
||||
if (a>=ram[WNDBTM]) {
|
||||
A=ram[BASL];
|
||||
ram[BAS2L]=A;
|
||||
A=ram[BASH];
|
||||
ram[BAS2H]=A;
|
||||
Y=ram[WNDWDTH];
|
||||
Y--;
|
||||
A=s;
|
||||
A+=1;
|
||||
if (A>=ram[WNDBTM]) {
|
||||
// SCRL3
|
||||
y=0;
|
||||
Y=0;
|
||||
cleolz();
|
||||
rom_vtab();
|
||||
return;
|
||||
}
|
||||
s=a;
|
||||
s=A;
|
||||
vtabz();
|
||||
// SCRL2
|
||||
scrl2:
|
||||
a=ram[y_indirect(BASL,y)];
|
||||
ram[y_indirect(BAS2L,y)]=a;
|
||||
y--;
|
||||
if (y<0x80) goto scrl2;
|
||||
A=ram[y_indirect(BASL,Y)];
|
||||
ram[y_indirect(BAS2L,Y)]=A;
|
||||
Y--;
|
||||
if (Y<0x80) goto scrl2;
|
||||
goto scrl1;
|
||||
}
|
||||
|
||||
static void lf(void) {
|
||||
ram[CV]=ram[CV]+1;
|
||||
a=ram[CV];
|
||||
if (a<ram[WNDBTM]) {
|
||||
A=ram[CV];
|
||||
if (A<ram[WNDBTM]) {
|
||||
vtabz();
|
||||
return;
|
||||
}
|
||||
|
@ -1291,8 +1290,8 @@ static void lf(void) {
|
|||
}
|
||||
|
||||
static void cr(void) {
|
||||
a=0x00;
|
||||
ram[CH]=a;
|
||||
A=0x00;
|
||||
ram[CH]=A;
|
||||
lf();
|
||||
}
|
||||
|
||||
|
@ -1303,8 +1302,8 @@ static void bell1(void) {
|
|||
|
||||
static void up(void) {
|
||||
|
||||
a=ram[WNDTOP];
|
||||
if (a>ram[CV]) return;
|
||||
A=ram[WNDTOP];
|
||||
if (A>ram[CV]) return;
|
||||
|
||||
ram[CV]=ram[CV]-1;
|
||||
rom_vtab();
|
||||
|
@ -1317,8 +1316,8 @@ static void bs(void) {
|
|||
/* still positive */
|
||||
if (ram[CH]<0x80) return;
|
||||
|
||||
a=ram[WNDWDTH];
|
||||
ram[CH]=a;
|
||||
A=ram[WNDWDTH];
|
||||
ram[CH]=A;
|
||||
ram[CH]=ram[CH]-1;
|
||||
|
||||
up();
|
||||
|
@ -1328,14 +1327,14 @@ static void storadv(void) {
|
|||
|
||||
// fbf0
|
||||
|
||||
y=ram[CH];
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
Y=ram[CH];
|
||||
ram[y_indirect(BASL,Y)]=A;
|
||||
|
||||
// advance
|
||||
|
||||
ram[CH]=ram[CH]+1;
|
||||
a=ram[CH];
|
||||
if (a>=ram[WNDWDTH]) {
|
||||
A=ram[CH];
|
||||
if (A>=ram[WNDWDTH]) {
|
||||
cr();
|
||||
}
|
||||
|
||||
|
@ -1344,34 +1343,34 @@ static void storadv(void) {
|
|||
static void vidout(void) {
|
||||
// fbfd
|
||||
|
||||
if (a>=0xa0) {
|
||||
if (A>=0xa0) {
|
||||
storadv();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Control Characters */
|
||||
y=a;
|
||||
Y=A;
|
||||
// if bit 7 is set then we set negative flag
|
||||
// BPL storadv
|
||||
if (a<0x80) {
|
||||
if (A<0x80) {
|
||||
storadv();
|
||||
return;
|
||||
}
|
||||
|
||||
/* carriage return */
|
||||
if (a==0x8d) {
|
||||
if (A==0x8d) {
|
||||
cr();
|
||||
return;
|
||||
}
|
||||
|
||||
/* linefeed */
|
||||
if (a==0x8a) {
|
||||
if (A==0x8a) {
|
||||
lf();
|
||||
return;
|
||||
}
|
||||
|
||||
/* backspace */
|
||||
if (a==0x88) {
|
||||
if (A==0x88) {
|
||||
bs();
|
||||
return;
|
||||
}
|
||||
|
@ -1392,19 +1391,19 @@ static void cout1(void) {
|
|||
|
||||
unsigned char s;
|
||||
|
||||
if (a<0xa0) {
|
||||
if (A<0xa0) {
|
||||
}
|
||||
else {
|
||||
a=a&ram[INVFLG];
|
||||
A=A&ram[INVFLG];
|
||||
}
|
||||
// coutz
|
||||
ram[YSAV1]=y;
|
||||
s=a;
|
||||
ram[YSAV1]=Y;
|
||||
s=A;
|
||||
|
||||
vidwait();
|
||||
|
||||
a=s;
|
||||
y=ram[YSAV1];
|
||||
A=s;
|
||||
Y=ram[YSAV1];
|
||||
|
||||
}
|
||||
|
||||
|
@ -1422,26 +1421,26 @@ static void outdo(void) {
|
|||
unsigned char s;
|
||||
|
||||
/* Print char in the accumulator */
|
||||
a=a|0x80; /* raw ascii has high bit on Apple II */
|
||||
if (a<0xa0) {
|
||||
A=A|0x80; /* raw ascii has high bit on Apple II */
|
||||
if (A<0xa0) {
|
||||
/* skip if control char? */
|
||||
}
|
||||
else {
|
||||
a=a|ram[FLASH];
|
||||
A=A|ram[FLASH];
|
||||
}
|
||||
cout();
|
||||
a=a&0x7f; // ?
|
||||
s=a; // pha
|
||||
a=ram[SPEEDZ];
|
||||
A=A&0x7f; // ?
|
||||
s=A; // pha
|
||||
A=ram[SPEEDZ];
|
||||
wait(); // this is BASIC, slow down if speed set
|
||||
a=s;
|
||||
A=s;
|
||||
}
|
||||
|
||||
static void crdo(void) {
|
||||
// DAFB
|
||||
a=13; // carriage return
|
||||
A=13; // carriage return
|
||||
outdo();
|
||||
a=a^0xff; /* negate for some reason? */
|
||||
A=A^0xff; /* negate for some reason? */
|
||||
}
|
||||
|
||||
void basic_htab(int xpos) {
|
||||
|
@ -1451,16 +1450,16 @@ void basic_htab(int xpos) {
|
|||
// F7E7
|
||||
|
||||
|
||||
x=xpos; // JSR GETBYT
|
||||
x--; // DEX
|
||||
a=x; // TXA
|
||||
while(a>=40) {
|
||||
s=a; // PHA
|
||||
X=xpos; // JSR GETBYT
|
||||
X--; // DEX
|
||||
A=X; // TXA
|
||||
while(A>=40) {
|
||||
s=A; // PHA
|
||||
crdo();
|
||||
a=s; // PLA
|
||||
a-=40;
|
||||
A=s; // PLA
|
||||
A-=40;
|
||||
}
|
||||
ram[CH]=a; // STA MON.CH
|
||||
ram[CH]=A; // STA MON.CH
|
||||
|
||||
// KRW for the win!
|
||||
|
||||
|
@ -1470,17 +1469,17 @@ static void tabv(void) {
|
|||
|
||||
// TABV
|
||||
// fb5b
|
||||
ram[CV]=a;
|
||||
ram[CV]=A;
|
||||
rom_vtab();
|
||||
}
|
||||
|
||||
void basic_vtab(int ypos) {
|
||||
// f256
|
||||
x=ypos;
|
||||
x--; /* base on zero */
|
||||
a=x;
|
||||
X=ypos;
|
||||
X--; /* base on zero */
|
||||
A=X;
|
||||
|
||||
if (a>23) {
|
||||
if (A>23) {
|
||||
fprintf(stderr,"Error, vtab %d too big\n",ypos);
|
||||
return;
|
||||
}
|
||||
|
@ -1492,7 +1491,7 @@ void basic_print(char *string) {
|
|||
int i;
|
||||
|
||||
for(i=0;i<strlen(string);i++) {
|
||||
a=string[i];
|
||||
A=string[i];
|
||||
outdo();
|
||||
}
|
||||
|
||||
|
@ -1500,20 +1499,20 @@ void basic_print(char *string) {
|
|||
|
||||
void basic_inverse(void) {
|
||||
// F277
|
||||
a=0x3f;
|
||||
x=0;
|
||||
ram[INVFLG]=a;
|
||||
ram[FLASH]=x;
|
||||
A=0x3f;
|
||||
X=0;
|
||||
ram[INVFLG]=A;
|
||||
ram[FLASH]=X;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void basic_normal(void) {
|
||||
// F273
|
||||
a=0xff;
|
||||
x=0;
|
||||
ram[INVFLG]=a;
|
||||
ram[FLASH]=x;
|
||||
A=0xff;
|
||||
X=0;
|
||||
ram[INVFLG]=A;
|
||||
ram[FLASH]=X;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1591,50 +1590,50 @@ static unsigned short vlin_hi;
|
|||
|
||||
int vlin(int y1, int y2, int at) {
|
||||
|
||||
x=y1;
|
||||
X=y1;
|
||||
ram[V2]=y2;
|
||||
y=at;
|
||||
Y=at;
|
||||
|
||||
vlin_loop:
|
||||
// for(a=y1;a<y2;a++) {
|
||||
|
||||
ram[TEMPY]=y;
|
||||
a=x;
|
||||
y=a/2;
|
||||
ram[TEMPY]=Y;
|
||||
A=X;
|
||||
Y=A/2;
|
||||
|
||||
ram[OUTL]=gr_addr_lookup[y]&0xff;
|
||||
ram[OUTH]=(gr_addr_lookup[y]>>8)&0xff;
|
||||
ram[OUTL]=gr_addr_lookup[Y]&0xff;
|
||||
ram[OUTH]=(gr_addr_lookup[Y]>>8)&0xff;
|
||||
|
||||
ram[OUTH]+=ram[DRAW_PAGE];
|
||||
|
||||
vlin_hi=x&1;
|
||||
vlin_hi=X&1;
|
||||
|
||||
y=ram[TEMPY]; // y=at;
|
||||
Y=ram[TEMPY]; // y=at;
|
||||
|
||||
if (vlin_hi) {
|
||||
ram[y_indirect(OUTL,y)]=ram[y_indirect(OUTL,y)]&0x0f;
|
||||
ram[y_indirect(OUTL,y)]|=ram[COLOR]&0xf0;
|
||||
ram[y_indirect(OUTL,Y)]=ram[y_indirect(OUTL,Y)]&0x0f;
|
||||
ram[y_indirect(OUTL,Y)]|=ram[COLOR]&0xf0;
|
||||
}
|
||||
else {
|
||||
ram[y_indirect(OUTL,y)]=ram[y_indirect(OUTL,y)]&0xf0;
|
||||
ram[y_indirect(OUTL,y)]|=ram[COLOR]&0x0f;
|
||||
ram[y_indirect(OUTL,Y)]=ram[y_indirect(OUTL,Y)]&0xf0;
|
||||
ram[y_indirect(OUTL,Y)]|=ram[COLOR]&0x0f;
|
||||
}
|
||||
x++;
|
||||
if (x<ram[V2]) goto vlin_loop;
|
||||
X++;
|
||||
if (X<ram[V2]) goto vlin_loop;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hlin_double_continue(int width) {
|
||||
|
||||
x=width;
|
||||
X=width;
|
||||
|
||||
hlin_loop:
|
||||
y=0;
|
||||
ram[y_indirect(GBASL,y)]=ram[COLOR];
|
||||
Y=0;
|
||||
ram[y_indirect(GBASL,Y)]=ram[COLOR];
|
||||
ram[GBASL]++;
|
||||
x--;
|
||||
if (x!=0) goto hlin_loop;
|
||||
X--;
|
||||
if (X!=0) goto hlin_loop;
|
||||
|
||||
// ram[GBASL]+=width;
|
||||
|
||||
|
@ -1646,11 +1645,11 @@ hlin_loop:
|
|||
int hlin_setup(int page, int x1, int x2, int at) {
|
||||
|
||||
// page, y, V2, A
|
||||
a=at;
|
||||
y=at/2;
|
||||
A=at;
|
||||
Y=at/2;
|
||||
|
||||
ram[GBASL]=(gr_addr_lookup[y])&0xff;
|
||||
ram[GBASH]=(gr_addr_lookup[y]>>8);
|
||||
ram[GBASL]=(gr_addr_lookup[Y])&0xff;
|
||||
ram[GBASH]=(gr_addr_lookup[Y]>>8);
|
||||
|
||||
ram[GBASH]+=(page);
|
||||
|
||||
|
@ -1797,32 +1796,38 @@ void move_and_print(char *string) {
|
|||
|
||||
void print(char *string) {
|
||||
|
||||
int y;
|
||||
|
||||
for(y=0;y<strlen(string);y++) {
|
||||
a=string[y];
|
||||
a=a|0x80;
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
A=string[y];
|
||||
A=A|0x80;
|
||||
ram[y_indirect(BASL,y)]=A;
|
||||
}
|
||||
ram[BASL]+=strlen(string);
|
||||
}
|
||||
|
||||
void print_inverse(char *string) {
|
||||
|
||||
for(y=0;y<strlen(string);y++) {
|
||||
a=string[y];
|
||||
if ((a>='a') && (a<='z')) a&=~0x20; // convert to uppercase
|
||||
a=(a&0x3f);
|
||||
int y;
|
||||
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
for(y=0;y<strlen(string);y++) {
|
||||
A=string[y];
|
||||
if ((A>='a') && (A<='z')) A&=~0x20; // convert to uppercase
|
||||
A=(A&0x3f);
|
||||
|
||||
ram[y_indirect(BASL,y)]=A;
|
||||
}
|
||||
ram[BASL]+=strlen(string);
|
||||
}
|
||||
|
||||
void print_flash(char *string) {
|
||||
|
||||
int y;
|
||||
|
||||
for(y=0;y<strlen(string);y++) {
|
||||
a=string[y];
|
||||
a=(a&0x3f)|0x40;
|
||||
ram[y_indirect(BASL,y)]=a;
|
||||
A=string[y];
|
||||
A=(A&0x3f)|0x40;
|
||||
ram[y_indirect(BASL,y)]=A;
|
||||
}
|
||||
ram[BASL]+=strlen(string);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extern unsigned char ram[128*1024];
|
||||
extern unsigned char a,y,x;
|
||||
extern unsigned char A,Y,X;
|
||||
|
||||
int grsim_input(void);
|
||||
int grsim_update(void);
|
||||
|
@ -120,8 +120,12 @@ void clear_bottom(void);
|
|||
void clear_screens_notext(void);
|
||||
void clear_all(void);
|
||||
|
||||
/* hgr-sim.c */
|
||||
int hgr(void);
|
||||
int hplot(int xx, int yy);
|
||||
int hplot_to(int xx, int yy);
|
||||
int hcolor_equals(int color);
|
||||
|
||||
void bkgnd(void);
|
||||
void hclr(void);
|
||||
void hposn(void);
|
||||
int hplot(int xx, int yy);
|
||||
|
|
|
@ -10,39 +10,39 @@ static void color_shift(void) {
|
|||
asl();
|
||||
cmp(0xc0);
|
||||
|
||||
if (!n) goto done_color_shift;
|
||||
if (!N) goto done_color_shift;
|
||||
|
||||
a=ram[HGR_BITS];
|
||||
a=a^0x7f;
|
||||
ram[HGR_BITS]=a;
|
||||
A=ram[HGR_BITS];
|
||||
A=A^0x7f;
|
||||
ram[HGR_BITS]=A;
|
||||
|
||||
done_color_shift:
|
||||
; // rts
|
||||
}
|
||||
|
||||
static void bkgnd(void) {
|
||||
void bkgnd(void) {
|
||||
// F3F6
|
||||
a=ram[HGR_PAGE];
|
||||
ram[HGR_SHAPE+1]=a;
|
||||
y=0;
|
||||
ram[HGR_SHAPE]=y;
|
||||
A=ram[HGR_PAGE];
|
||||
ram[HGR_SHAPE+1]=A;
|
||||
Y=0;
|
||||
ram[HGR_SHAPE]=Y;
|
||||
bkgnd_loop:
|
||||
a=ram[HGR_BITS];
|
||||
A=ram[HGR_BITS];
|
||||
|
||||
ram[y_indirect(HGR_SHAPE,y)]=a;
|
||||
ram[y_indirect(HGR_SHAPE,Y)]=A;
|
||||
|
||||
color_shift();
|
||||
|
||||
y++;
|
||||
if (y==0) {
|
||||
Y++;
|
||||
if (Y==0) {
|
||||
}
|
||||
else {
|
||||
goto bkgnd_loop;
|
||||
}
|
||||
ram[HGR_SHAPE+1]+=1;
|
||||
a=ram[HGR_SHAPE+1];
|
||||
a&=0x1f; // see if $40 or $60
|
||||
if (a!=0) {
|
||||
A=ram[HGR_SHAPE+1];
|
||||
A&=0x1f; // see if $40 or $60
|
||||
if (A!=0) {
|
||||
goto bkgnd_loop;
|
||||
}
|
||||
// rts
|
||||
|
@ -50,15 +50,15 @@ bkgnd_loop:
|
|||
|
||||
void hclr(void) {
|
||||
// F3F2
|
||||
a=0; // black background
|
||||
ram[HGR_BITS]=a;
|
||||
A=0; // black background
|
||||
ram[HGR_BITS]=A;
|
||||
bkgnd();
|
||||
|
||||
}
|
||||
|
||||
static void sethpg(void) {
|
||||
// F3EA
|
||||
ram[HGR_PAGE]=a;
|
||||
ram[HGR_PAGE]=A;
|
||||
soft_switch(HIRES); // LDA SW.HIRES
|
||||
soft_switch(TXTCLR); // LDA SW.TXTCLR
|
||||
|
||||
|
@ -69,7 +69,7 @@ static void sethpg(void) {
|
|||
int hgr(void) {
|
||||
|
||||
// F3E2
|
||||
a=0x20; // HIRES Page 1 at $2000
|
||||
A=0x20; // HIRES Page 1 at $2000
|
||||
soft_switch(LOWSCR); // BIT SW.LOWSCR Use PAGE1 ($C054)
|
||||
soft_switch(MIXSET); // BIT SW.MIXSET (Mixed text)
|
||||
sethpg();
|
||||
|
@ -82,30 +82,30 @@ int hgr2(void) {
|
|||
// F3D8
|
||||
soft_switch(HISCR); // BIT SW.HISCR Use PAGE2 ($C055)
|
||||
soft_switch(MIXCLR); // BIT SW.MIXCLR
|
||||
a=0x40; // HIRES Page 2 at $4000
|
||||
A=0x40; // HIRES Page 2 at $4000
|
||||
sethpg();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hposn(void) {
|
||||
void hposn(void) {
|
||||
|
||||
unsigned char msktbl[]={0x81,0x82,0x84,0x88,0x90,0xA0,0xC0};
|
||||
|
||||
// F411
|
||||
ram[HGR_Y]=a;
|
||||
ram[HGR_X]=x;
|
||||
ram[HGR_X+1]=y;
|
||||
ram[HGR_Y]=A;
|
||||
ram[HGR_X]=X;
|
||||
ram[HGR_X+1]=Y;
|
||||
pha();
|
||||
a=a&0xC0;
|
||||
ram[GBASL]=a;
|
||||
A=A&0xC0;
|
||||
ram[GBASL]=A;
|
||||
lsr();
|
||||
lsr();
|
||||
a=a|ram[GBASL];
|
||||
ram[GBASL]=a;
|
||||
A=A|ram[GBASL];
|
||||
ram[GBASL]=A;
|
||||
pla();
|
||||
// F423
|
||||
ram[GBASH]=a;
|
||||
ram[GBASH]=A;
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
|
@ -115,43 +115,43 @@ static void hposn(void) {
|
|||
asl();
|
||||
ror_mem(GBASL);
|
||||
lda(GBASH);
|
||||
a=a&0x1f;
|
||||
a=a|ram[HGR_PAGE];
|
||||
ram[GBASH]=a;
|
||||
A=A&0x1f;
|
||||
A=A|ram[HGR_PAGE];
|
||||
ram[GBASH]=A;
|
||||
|
||||
// F438
|
||||
a=x;
|
||||
A=X;
|
||||
cpy(0);
|
||||
if (z==1) goto hposn_2;
|
||||
if (Z==1) goto hposn_2;
|
||||
|
||||
y=35;
|
||||
Y=35;
|
||||
adc(4);
|
||||
hposn_1:
|
||||
iny();
|
||||
// f442
|
||||
hposn_2:
|
||||
sbc(7);
|
||||
if (c==1) goto hposn_1;
|
||||
ram[HGR_HORIZ]=y;
|
||||
x=a;
|
||||
a=msktbl[(x-0x100)+7]; // LDA MSKTBL-$100+7,X BIT MASK
|
||||
if (C==1) goto hposn_1;
|
||||
ram[HGR_HORIZ]=Y;
|
||||
X=A;
|
||||
A=msktbl[(X-0x100)+7]; // LDA MSKTBL-$100+7,X BIT MASK
|
||||
// MSKTBL=F5B8
|
||||
ram[HMASK]=a;
|
||||
a=y;
|
||||
ram[HMASK]=A;
|
||||
A=Y;
|
||||
lsr();
|
||||
a=ram[HGR_COLOR];
|
||||
ram[HGR_BITS]=a;
|
||||
if (c) color_shift();
|
||||
A=ram[HGR_COLOR];
|
||||
ram[HGR_BITS]=A;
|
||||
if (C) color_shift();
|
||||
}
|
||||
|
||||
static void hplot0(void) {
|
||||
// F457
|
||||
hposn();
|
||||
a=ram[HGR_BITS];
|
||||
a=a^ram[y_indirect(GBASL,y)];
|
||||
a=a&ram[HMASK];
|
||||
a=a^ram[y_indirect(GBASL,y)];
|
||||
ram[y_indirect(GBASL,y)]=a;
|
||||
A=ram[HGR_BITS];
|
||||
A=A^ram[y_indirect(GBASL,Y)];
|
||||
A=A&ram[HMASK];
|
||||
A=A^ram[y_indirect(GBASL,Y)];
|
||||
ram[y_indirect(GBASL,Y)]=A;
|
||||
}
|
||||
|
||||
static void hfns(int xx, int yy) {
|
||||
|
@ -167,9 +167,9 @@ static void hfns(int xx, int yy) {
|
|||
return;
|
||||
}
|
||||
|
||||
x=(xx&0xff);
|
||||
y=(xx>>8);
|
||||
a=yy;
|
||||
X=(xx&0xff);
|
||||
Y=(xx>>8);
|
||||
A=yy;
|
||||
|
||||
}
|
||||
|
||||
|
@ -185,56 +185,56 @@ int hplot(int xx, int yy) {
|
|||
|
||||
static void move_left_or_right(void) {
|
||||
// F465
|
||||
if (n==0) goto move_right;
|
||||
if (N==0) goto move_right;
|
||||
|
||||
a=ram[HMASK];
|
||||
A=ram[HMASK];
|
||||
lsr();
|
||||
if (c==1) goto lr_2;
|
||||
a=a^0xc0;
|
||||
if (C==1) goto lr_2;
|
||||
A=A^0xc0;
|
||||
lr_1:
|
||||
ram[HMASK]=a;
|
||||
ram[HMASK]=A;
|
||||
return;
|
||||
lr_2:
|
||||
dey();
|
||||
if (n==0) goto lr_3;
|
||||
y=39;
|
||||
if (N==0) goto lr_3;
|
||||
Y=39;
|
||||
lr_3:
|
||||
a=0xc0;
|
||||
A=0xc0;
|
||||
lr_4:
|
||||
ram[HMASK]=a;
|
||||
ram[HGR_HORIZ]=y;
|
||||
a=ram[HGR_BITS];
|
||||
ram[HMASK]=A;
|
||||
ram[HGR_HORIZ]=Y;
|
||||
A=ram[HGR_BITS];
|
||||
color_shift();
|
||||
return;
|
||||
|
||||
move_right:
|
||||
a=ram[HMASK];
|
||||
A=ram[HMASK];
|
||||
asl();
|
||||
a=a^0x80;
|
||||
if (a&0x80) goto lr_1;
|
||||
a=0x81;
|
||||
A=A^0x80;
|
||||
if (A&0x80) goto lr_1;
|
||||
A=0x81;
|
||||
iny();
|
||||
cpy(40);
|
||||
if (c==0) goto lr_4;
|
||||
y=0;
|
||||
if (C==0) goto lr_4;
|
||||
Y=0;
|
||||
goto lr_4;
|
||||
|
||||
}
|
||||
|
||||
static void move_up_or_down(void) {
|
||||
// F4D3
|
||||
if (n==1) goto move_down;
|
||||
if (N==1) goto move_down;
|
||||
|
||||
c=0;
|
||||
C=0;
|
||||
lda(GBASH);
|
||||
bit(0x1c); // CON.1C
|
||||
if (z!=1) goto mu_5;
|
||||
if (Z!=1) goto mu_5;
|
||||
asl_mem(GBASL);
|
||||
if (c==1) goto mu_3;
|
||||
if (C==1) goto mu_3;
|
||||
bit(0x03); // CON.03
|
||||
if (z==1) goto mu_1;
|
||||
if (Z==1) goto mu_1;
|
||||
adc(0x1f);
|
||||
c=1;
|
||||
C=1;
|
||||
goto mu_4;
|
||||
// F4Eb
|
||||
mu_1:
|
||||
|
@ -242,11 +242,11 @@ mu_1:
|
|||
pha();
|
||||
lda(GBASL);
|
||||
adc(0xb0);
|
||||
if (c==1) goto mu_2;
|
||||
if (C==1) goto mu_2;
|
||||
adc(0xf0);
|
||||
// f4f6
|
||||
mu_2:
|
||||
ram[GBASL]=a;
|
||||
ram[GBASL]=A;
|
||||
pla();
|
||||
goto mu_4;
|
||||
mu_3:
|
||||
|
@ -256,7 +256,7 @@ mu_4:
|
|||
mu_5:
|
||||
adc(0xfc);
|
||||
ud_1:
|
||||
ram[GBASH]=a;
|
||||
ram[GBASH]=A;
|
||||
return;
|
||||
|
||||
// f505
|
||||
|
@ -264,20 +264,20 @@ move_down:
|
|||
lda(GBASH);
|
||||
adc(4);
|
||||
bit(0x1c);
|
||||
if (z!=1) goto ud_1;
|
||||
if (Z!=1) goto ud_1;
|
||||
asl_mem(GBASL);
|
||||
if (c==0) goto md_2;
|
||||
if (C==0) goto md_2;
|
||||
adc(0xe0);
|
||||
c=0;
|
||||
C=0;
|
||||
bit(0x4);
|
||||
if (z==1) goto md_3;
|
||||
if (Z==1) goto md_3;
|
||||
lda(GBASL);
|
||||
adc(0x50);
|
||||
a=a^0xf0;
|
||||
if (a==0) goto md_1;
|
||||
a=a^0xf0;
|
||||
A=A^0xf0;
|
||||
if (A==0) goto md_1;
|
||||
A=A^0xf0;
|
||||
md_1:
|
||||
ram[GBASL]=a;
|
||||
ram[GBASL]=A;
|
||||
lda(HGR_PAGE);
|
||||
goto md_3;
|
||||
md_2:
|
||||
|
@ -292,82 +292,82 @@ static void hglin(void) {
|
|||
|
||||
// F53A
|
||||
pha();
|
||||
c=1;
|
||||
C=1;
|
||||
sbc(ram[HGR_X]);
|
||||
pha();
|
||||
a=x;
|
||||
A=X;
|
||||
sbc(ram[HGR_X+1]);
|
||||
ram[HGR_QUADRANT]=a;
|
||||
ram[HGR_QUADRANT]=A;
|
||||
// F544
|
||||
if (c==1) goto hglin_1;
|
||||
if (C==1) goto hglin_1;
|
||||
pla();
|
||||
a=a^0xff;
|
||||
A=A^0xff;
|
||||
adc(1);
|
||||
pha();
|
||||
lda_const(0);
|
||||
sbc(ram[HGR_QUADRANT]);
|
||||
// F550
|
||||
hglin_1:
|
||||
ram[HGR_DX+1]=a;
|
||||
ram[HGR_E+1]=a;
|
||||
ram[HGR_DX+1]=A;
|
||||
ram[HGR_E+1]=A;
|
||||
pla();
|
||||
ram[HGR_DX]=a;
|
||||
ram[HGR_E]=a;
|
||||
ram[HGR_DX]=A;
|
||||
ram[HGR_E]=A;
|
||||
pla();
|
||||
ram[HGR_X]=a;
|
||||
ram[HGR_X+1]=x;
|
||||
a=y;
|
||||
c=0;
|
||||
ram[HGR_X]=A;
|
||||
ram[HGR_X+1]=X;
|
||||
A=Y;
|
||||
C=0;
|
||||
sbc(ram[HGR_Y]);
|
||||
if (c==0) goto hglin_2;
|
||||
a=a^0xff;
|
||||
if (C==0) goto hglin_2;
|
||||
A=A^0xff;
|
||||
adc(0xfe);
|
||||
hglin_2:
|
||||
// F568
|
||||
ram[HGR_DY]=a;
|
||||
ram[HGR_Y]=y;
|
||||
ram[HGR_DY]=A;
|
||||
ram[HGR_Y]=Y;
|
||||
ror_mem(HGR_QUADRANT);
|
||||
c=1;
|
||||
C=1;
|
||||
sbc(ram[HGR_DX]);
|
||||
x=a;
|
||||
X=A;
|
||||
lda_const(0xff);
|
||||
sbc(ram[HGR_DX+1]);
|
||||
ram[HGR_COUNT]=a;
|
||||
ram[HGR_COUNT]=A;
|
||||
ldy(HGR_HORIZ);
|
||||
goto movex2; // always?
|
||||
// f57c
|
||||
movex:
|
||||
asl();
|
||||
move_left_or_right();
|
||||
c=1;
|
||||
C=1;
|
||||
|
||||
// f581
|
||||
movex2:
|
||||
lda(HGR_E);
|
||||
adc(ram[HGR_DY]);
|
||||
ram[HGR_E]=a;
|
||||
ram[HGR_E]=A;
|
||||
lda(HGR_E+1);
|
||||
sbc(0);
|
||||
movex2_1:
|
||||
ram[HGR_E+1]=a;
|
||||
lda(y_indirect(GBASL,y));
|
||||
a=a^ram[HGR_BITS];
|
||||
a=a&ram[HMASK];
|
||||
a=a^ram[y_indirect(GBASL,y)];
|
||||
ram[y_indirect(GBASL,y)]=a;
|
||||
ram[HGR_E+1]=A;
|
||||
lda(y_indirect(GBASL,Y));
|
||||
A=A^ram[HGR_BITS];
|
||||
A=A&ram[HMASK];
|
||||
A=A^ram[y_indirect(GBASL,Y)];
|
||||
ram[y_indirect(GBASL,Y)]=A;
|
||||
inx();
|
||||
if (z!=1) goto movex2_2;
|
||||
if (Z!=1) goto movex2_2;
|
||||
ram[HGR_COUNT]++;
|
||||
if (ram[HGR_COUNT]==0) return;
|
||||
// F59e
|
||||
movex2_2:
|
||||
lda(HGR_QUADRANT);
|
||||
if (c==1) goto movex;
|
||||
if (C==1) goto movex;
|
||||
move_up_or_down();
|
||||
c=0;
|
||||
C=0;
|
||||
lda(HGR_E);
|
||||
adc(ram[HGR_DX]);
|
||||
ram[HGR_E]=a;
|
||||
ram[HGR_E]=A;
|
||||
lda(HGR_E+1);
|
||||
adc(ram[HGR_DX+1]);
|
||||
goto movex2_1;
|
||||
|
@ -377,10 +377,10 @@ int hplot_to(int xx, int yy) {
|
|||
|
||||
// F712
|
||||
hfns(xx,yy);
|
||||
ram[DSCTMP]=y;
|
||||
y=a;
|
||||
a=x;
|
||||
x=ram[DSCTMP];
|
||||
ram[DSCTMP]=Y;
|
||||
Y=A;
|
||||
A=X;
|
||||
X=ram[DSCTMP];
|
||||
hglin();
|
||||
|
||||
return 0;
|
||||
|
@ -391,14 +391,14 @@ int hcolor_equals(int color) {
|
|||
unsigned char colortbl[8]={0x00,0x2A,0x55,0x7F,0x80,0xAA,0xD5,0xFF};
|
||||
|
||||
// F6E9
|
||||
x=color;
|
||||
if (x>7) {
|
||||
X=color;
|
||||
if (X>7) {
|
||||
printf("HCOLOR out of range!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
a=colortbl[x];
|
||||
ram[HGR_COLOR]=a;
|
||||
A=colortbl[X];
|
||||
ram[HGR_COLOR]=A;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ SDL_INCLUDE= `sdl-config --cflags`
|
|||
GR_SIM = ../gr-sim.a
|
||||
|
||||
all: fireworks fw_purple lines image_load hgr_view seven tunnel \
|
||||
random16 scroll scroll-asm plasma_new plasma_test plasma_test64
|
||||
random16 scroll scroll-asm plasma_new plasma_test plasma_test64 \
|
||||
tunnel_small
|
||||
|
||||
###
|
||||
|
||||
|
@ -49,6 +50,15 @@ tunnel: tunnel.o $(GR_SIM)
|
|||
tunnel.o: tunnel.c
|
||||
$(CC) $(CFLAGS) -c tunnel.c
|
||||
|
||||
###
|
||||
|
||||
tunnel_small: tunnel_small.o $(GR_SIM)
|
||||
$(CC) -o tunnel_small tunnel_small.o $(GR_SIM) $(LFLAGS) $(SDL_LIBS)
|
||||
|
||||
tunnel_small.o: tunnel_small.c
|
||||
$(CC) $(CFLAGS) -c tunnel_small.c
|
||||
|
||||
|
||||
|
||||
###
|
||||
|
||||
|
@ -119,4 +129,5 @@ scroll-asm.o: scroll-asm.c
|
|||
|
||||
clean:
|
||||
rm -f *~ *.o fireworks lines image_load hgr_view fw_purple seven \
|
||||
random16 scroll scroll-asm plasma_text plasma_text64 tunnel
|
||||
random16 scroll scroll-asm plasma_text plasma_text64 tunnel \
|
||||
tunnel_small
|
||||
|
|
|
@ -60,39 +60,39 @@ struct star_type {
|
|||
void random_6502(void) {
|
||||
|
||||
lda(SEED); // lda seed
|
||||
if (a==0) goto lowZero; // beq lowZero ; $0000 and $8000 are special values to test for
|
||||
if (A==0) goto lowZero; // beq lowZero ; $0000 and $8000 are special values to test for
|
||||
// ; Do a normal shift
|
||||
asl_mem(SEED); // asl seed
|
||||
lda(SEED+1); // lda seed+1
|
||||
rol(); // rol
|
||||
if (c==0) goto noEor; // bcc noEor
|
||||
if (C==0) goto noEor; // bcc noEor
|
||||
|
||||
doEor:
|
||||
// ; high byte is in .A
|
||||
a=a^0x76; // eor #>magic
|
||||
ram[SEED+1]=a; // sta seed+1
|
||||
A=A^0x76; // eor #>magic
|
||||
ram[SEED+1]=A; // sta seed+1
|
||||
lda(SEED); // lda seed
|
||||
a=a^0x57; // eor #<magic
|
||||
ram[SEED]=a; // sta seed
|
||||
A=A^0x57; // eor #<magic
|
||||
ram[SEED]=A; // sta seed
|
||||
return; // rts
|
||||
|
||||
|
||||
lowZero:
|
||||
lda(SEED+1); // lda seed+1
|
||||
if (a==0) goto doEor;
|
||||
if (A==0) goto doEor;
|
||||
// beq doEor ; High byte is also zero, so apply the EOR
|
||||
// ; For speed, you could store 'magic' into 'seed' directly
|
||||
// ; instead of running the EORs
|
||||
|
||||
// ; wasn't zero, check for $8000
|
||||
asl(); // asl
|
||||
if (a==0) goto noEor;
|
||||
if (A==0) goto noEor;
|
||||
// beq noEor ; if $00 is left after the shift, then it was $80
|
||||
if (c==1) goto doEor;
|
||||
if (C==1) goto doEor;
|
||||
// bcs doEor ; else, do the EOR based on the carry bit as usual
|
||||
|
||||
noEor:
|
||||
ram[SEED+1]=a; // sta seed+1
|
||||
ram[SEED+1]=A; // sta seed+1
|
||||
|
||||
return; // rts
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ unsigned short random16(void) {
|
|||
path|=PATH_R16;
|
||||
|
||||
lda(SEEDL); cycles+=3;
|
||||
if (a==0) {
|
||||
if (A==0) {
|
||||
cycles+=3;
|
||||
goto low_zero;
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ unsigned short random16(void) {
|
|||
asl_mem(SEEDL); cycles+=5;
|
||||
lda(SEEDH); cycles+=3;
|
||||
rol(); cycles+=2;
|
||||
if (c==1) {
|
||||
if (C==1) {
|
||||
cycles+=3;
|
||||
goto five_cycle_do_eor;
|
||||
}
|
||||
cycles+=2;
|
||||
if (c==0) {
|
||||
if (C==0) {
|
||||
cycles+=3;
|
||||
goto two_cycle_no_eor;
|
||||
}
|
||||
|
@ -63,10 +63,10 @@ three_cycle_do_eor:
|
|||
|
||||
//do_eor:
|
||||
path|=PATH_DEO;
|
||||
a=a^0x76; cycles+=2;
|
||||
A=A^0x76; cycles+=2;
|
||||
sta(SEEDH); cycles+=3;
|
||||
lda(SEEDL); cycles+=3;
|
||||
a=a^0x57; cycles+=2;
|
||||
A=A^0x57; cycles+=2;
|
||||
sta(SEEDL); cycles+=3;
|
||||
eor_rts:
|
||||
cycles+=6;
|
||||
|
@ -91,7 +91,7 @@ two_cycle_no_eor:
|
|||
low_zero:
|
||||
path|=PATH_LOZ;
|
||||
lda(SEEDH); cycles+=3;
|
||||
if (a==0) {
|
||||
if (A==0) {
|
||||
cycles+=3;
|
||||
goto eleven_cycle_do_eor;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ low_zero:
|
|||
//ceo:
|
||||
path|=PATH_CEO;
|
||||
asl(); cycles+=2;
|
||||
if (a==0) {
|
||||
if (A==0) {
|
||||
cycles+=3;
|
||||
goto six_cycles_no_eor;
|
||||
}
|
||||
|
@ -108,12 +108,12 @@ low_zero:
|
|||
|
||||
//cep:
|
||||
path|=PATH_CEP;
|
||||
if (c==0) {
|
||||
if (C==0) {
|
||||
cycles+=3;
|
||||
goto four_cycle_no_eor;
|
||||
}
|
||||
cycles+=2;
|
||||
if (c==1) {
|
||||
if (C==1) {
|
||||
cycles+=3;
|
||||
goto three_cycle_do_eor;
|
||||
}
|
||||
|
|
|
@ -96,38 +96,38 @@ scroll_loop:
|
|||
left_one_loop:
|
||||
// printf("%d %02x:%02x\n",count,ram[OUTH],ram[OUTL]);
|
||||
|
||||
for(y=0;y<40;y++) {
|
||||
ram[CURRENT]=ram[y_indirect(OUTL,y)];
|
||||
ram[NEXT]=ram[y_indirect(OUTL,y+1)];
|
||||
for(Y=0;Y<40;Y++) {
|
||||
ram[CURRENT]=ram[y_indirect(OUTL,Y)];
|
||||
ram[NEXT]=ram[y_indirect(OUTL,Y+1)];
|
||||
if ((count%7==2) || (count%7==6)) {
|
||||
ram[HIGH]=ram[NEXT]&0x80;
|
||||
}
|
||||
else {
|
||||
ram[HIGH]=ram[CURRENT]&0x80;
|
||||
}
|
||||
if (y==39) ram[NEXT]=ram[y_indirect(INL,0)];
|
||||
if (Y==39) ram[NEXT]=ram[y_indirect(INL,0)];
|
||||
|
||||
a=ram[NEXT];
|
||||
A=ram[NEXT];
|
||||
and(0x3);
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
ram[NEXT]=a;
|
||||
ram[NEXT]=A;
|
||||
|
||||
a=ram[CURRENT];
|
||||
A=ram[CURRENT];
|
||||
lsr();
|
||||
lsr(); // current>>=2;
|
||||
and(0x1f); // current&=0x1f;
|
||||
ora_mem(HIGH);
|
||||
ora_mem(NEXT);
|
||||
ram[y_indirect(OUTL,y)]=a;
|
||||
ram[y_indirect(OUTL,Y)]=A;
|
||||
}
|
||||
|
||||
for(y=0;y<40;y++) {
|
||||
ram[CURRENT]=ram[y_indirect(INL,y)];
|
||||
ram[NEXT]=ram[y_indirect(INL,y+1)];
|
||||
for(Y=0;Y<40;Y++) {
|
||||
ram[CURRENT]=ram[y_indirect(INL,Y)];
|
||||
ram[NEXT]=ram[y_indirect(INL,Y+1)];
|
||||
if ((count%7==2) ||(count%7==6)) {
|
||||
ram[HIGH]=ram[NEXT]&0x80;
|
||||
}
|
||||
|
@ -135,43 +135,43 @@ left_one_loop:
|
|||
ram[HIGH]=ram[CURRENT]&0x80;
|
||||
}
|
||||
|
||||
a=ram[NEXT];
|
||||
A=ram[NEXT];
|
||||
and(0x3);
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
asl();
|
||||
ram[NEXT]=a;
|
||||
ram[NEXT]=A;
|
||||
|
||||
a=ram[CURRENT];
|
||||
A=ram[CURRENT];
|
||||
lsr();
|
||||
lsr(); // current>>=2;
|
||||
and(0x1f); // current&=0x1f;
|
||||
ora_mem(HIGH);
|
||||
ora_mem(NEXT);
|
||||
ram[y_indirect(INL,y)]=a;
|
||||
ram[y_indirect(INL,Y)]=A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
clc();
|
||||
a=ram[INL];
|
||||
A=ram[INL];
|
||||
adc(0x80);
|
||||
ram[INL]=a;
|
||||
a=ram[INH];
|
||||
ram[INL]=A;
|
||||
A=ram[INH];
|
||||
adc(0x0);
|
||||
ram[INH]=a;
|
||||
ram[INH]=A;
|
||||
|
||||
clc();
|
||||
a=ram[OUTL];
|
||||
A=ram[OUTL];
|
||||
adc(0x80);
|
||||
ram[OUTL]=a;
|
||||
a=ram[OUTH];
|
||||
ram[OUTL]=A;
|
||||
A=ram[OUTH];
|
||||
adc(0x0);
|
||||
ram[OUTH]=a;
|
||||
ram[OUTH]=A;
|
||||
|
||||
if (a!=0x60) goto left_one_loop;
|
||||
if (A!=0x60) goto left_one_loop;
|
||||
|
||||
grsim_update();
|
||||
ch=grsim_input();
|
||||
|
|
|
@ -17,14 +17,14 @@ static void fancy_div(int d, int *q, int *r) {
|
|||
// y=xhigh x=xlow a=??
|
||||
// q in y, r in a
|
||||
|
||||
y=(d>>8)&0xff;
|
||||
x=d&0xff;
|
||||
Y=(d>>8)&0xff;
|
||||
X=d&0xff;
|
||||
|
||||
a=x;
|
||||
A=X;
|
||||
|
||||
sta(TEMP_R);
|
||||
|
||||
c=0;
|
||||
C=0;
|
||||
sta(HGR_HORIZ); // 0
|
||||
lsr(); // 0
|
||||
lsr(); // 0
|
||||
|
@ -40,7 +40,7 @@ static void fancy_div(int d, int *q, int *r) {
|
|||
|
||||
// calc remainder
|
||||
|
||||
c=0;
|
||||
C=0;
|
||||
sta(HGR_HORIZ);
|
||||
asl();
|
||||
adc_mem(HGR_HORIZ);
|
||||
|
@ -49,7 +49,7 @@ static void fancy_div(int d, int *q, int *r) {
|
|||
// HGR_HORIZ=x/7, A=HGR_HORIZ*7
|
||||
|
||||
|
||||
c=1;
|
||||
C=1;
|
||||
eor(0xff);
|
||||
// printf("%d+%d=",d&0xff,a);
|
||||
adc(d&0xff);
|
||||
|
@ -61,8 +61,8 @@ static void fancy_div(int d, int *q, int *r) {
|
|||
// sbc_mem(TEMP_R);
|
||||
// tax();
|
||||
|
||||
if (y) {
|
||||
c=0;
|
||||
if (Y) {
|
||||
C=0;
|
||||
adc(4);
|
||||
pha();
|
||||
lda(HGR_HORIZ);
|
||||
|
@ -71,16 +71,16 @@ static void fancy_div(int d, int *q, int *r) {
|
|||
pla();
|
||||
}
|
||||
|
||||
if (a>6) {
|
||||
c=1;
|
||||
if (A>6) {
|
||||
C=1;
|
||||
sbc(7);
|
||||
ram[HGR_HORIZ]++;
|
||||
}
|
||||
|
||||
y=ram[HGR_HORIZ];
|
||||
Y=ram[HGR_HORIZ];
|
||||
|
||||
*q=y;
|
||||
*r=a;
|
||||
*q=Y;
|
||||
*r=A;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static int cycles;
|
|||
|
||||
static void getsrc(void) {
|
||||
//getsrc:
|
||||
a=ram[y_indirect(LZ4_SRC,y)]; cycles+=5; // lda (LZ4_SRC), y
|
||||
A=ram[y_indirect(LZ4_SRC,Y)]; cycles+=5; // lda (LZ4_SRC), y
|
||||
ram[LZ4_SRC]++; cycles+=5; //inc LZ4_SRC
|
||||
cycles+=2;
|
||||
if (ram[LZ4_SRC]!=0) {
|
||||
|
@ -42,29 +42,29 @@ done_getsrc:
|
|||
|
||||
void buildcount(void) {
|
||||
//buildcount:
|
||||
x=1; cycles+=2; // ?? // ldx #1
|
||||
ram[COUNT+1]=x; cycles+=3; // ?? // stx COUNT+1
|
||||
X=1; cycles+=2; // ?? // ldx #1
|
||||
ram[COUNT+1]=X; cycles+=3; // ?? // stx COUNT+1
|
||||
cmp(0xf); cycles+=2; // if 15, more complicated // cmp #$0f
|
||||
cycles+=2;
|
||||
if (z==0) {
|
||||
if (Z==0) {
|
||||
cycles+=1;
|
||||
goto done_buildcount; // otherwise A is count // bne ++
|
||||
}
|
||||
buildcount_loop:
|
||||
ram[COUNT]=a; cycles+=3; //- sta count
|
||||
ram[COUNT]=A; cycles+=3; //- sta count
|
||||
getsrc(); cycles+=6; //jsr getsrc
|
||||
x=a; cycles+=2; //tax
|
||||
c=0; cycles+=2; //clc
|
||||
X=A; cycles+=2; //tax
|
||||
C=0; cycles+=2; //clc
|
||||
adc(ram[COUNT]);cycles+=3; //adc COUNT
|
||||
cycles+=2;
|
||||
if (c==0) {
|
||||
if (C==0) {
|
||||
cycles+=1;
|
||||
goto skip_buildcount; // bcc +
|
||||
}
|
||||
ram[COUNT+1]++; cycles+=5; //inc COUNT+1
|
||||
skip_buildcount:
|
||||
x++; cycles+=2; // check if x is 255 //+ inx
|
||||
if (x==0) {
|
||||
X++; cycles+=2; // check if x is 255 //+ inx
|
||||
if (X==0) {
|
||||
cycles+=1;
|
||||
goto buildcount_loop; // if so, add in next byte //beq -
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ done_buildcount:
|
|||
|
||||
static void putdst(void) {
|
||||
// putdst:
|
||||
ram[y_indirect(LZ4_DST,y)]=a; cycles+=6; // sta (LZ4_DST), y
|
||||
ram[y_indirect(LZ4_DST,Y)]=A; cycles+=6; // sta (LZ4_DST), y
|
||||
ram[LZ4_DST]++; cycles+=5; // inc LZ4_DST
|
||||
cycles+=2;
|
||||
if (ram[LZ4_DST]!=0) {
|
||||
|
@ -102,9 +102,9 @@ static void docopy(void) {
|
|||
// docopy:
|
||||
docopy_label:
|
||||
getput(); cycles+=6; // jsr getput
|
||||
x--; cycles+=2; // dex
|
||||
X--; cycles+=2; // dex
|
||||
cycles+=2;
|
||||
if (x!=0) {
|
||||
if (X!=0) {
|
||||
cycles+=1;
|
||||
goto docopy_label; // bne docopy
|
||||
}
|
||||
|
@ -132,18 +132,18 @@ int lz4_decode(void) {
|
|||
//Peter Ferrie (peter.ferrie@gmail.com)
|
||||
// lz4_decode:
|
||||
|
||||
a=ram[LZ4_SRC]; cycles+=3; // lda LZ4_SRC
|
||||
c=0; cycles+=2; // clc
|
||||
A=ram[LZ4_SRC]; cycles+=3; // lda LZ4_SRC
|
||||
C=0; cycles+=2; // clc
|
||||
adc(ram[LZ4_END]); cycles+=3; // adc LZ4_END
|
||||
ram[LZ4_END]=a; cycles+=3; // sta LZ4_END
|
||||
a=ram[LZ4_SRC+1]; cycles+=3; // lda LZ4_SRC+1
|
||||
ram[LZ4_END]=A; cycles+=3; // sta LZ4_END
|
||||
A=ram[LZ4_SRC+1]; cycles+=3; // lda LZ4_SRC+1
|
||||
adc(ram[LZ4_END+1]); cycles+=3; // adc LZ4_END+1
|
||||
ram[LZ4_END+1]=a; cycles+=3; // sta LZ4_END+1
|
||||
ram[LZ4_END+1]=A; cycles+=3; // sta LZ4_END+1
|
||||
|
||||
a=high(orgoff); cycles+=2; // lda #>orgoff ; original unpacked data offset
|
||||
ram[LZ4_DST+1]=a; cycles+=3; // sta LZ4_DST+1
|
||||
a=low(orgoff); cycles+=2; // lda #<orgoff
|
||||
ram[LZ4_DST]=a; cycles+=3; // sta LZ4_DST
|
||||
A=high(orgoff); cycles+=2; // lda #>orgoff ; original unpacked data offset
|
||||
ram[LZ4_DST+1]=A; cycles+=3; // sta LZ4_DST+1
|
||||
A=low(orgoff); cycles+=2; // lda #<orgoff
|
||||
ram[LZ4_DST]=A; cycles+=3; // sta LZ4_DST
|
||||
|
||||
// printf("packed size: raw=%x, adj=%x\n",size,paksize);
|
||||
printf("packed addr: %02X%02X\n",ram[LZ4_SRC+1],ram[LZ4_SRC]);
|
||||
|
@ -151,7 +151,7 @@ int lz4_decode(void) {
|
|||
printf("dest addr : %02X%02X\n",ram[LZ4_DST+1],ram[LZ4_DST]);
|
||||
|
||||
//unpmain:
|
||||
y=0; cycles+=2; // used for offset //ldy #0
|
||||
Y=0; cycles+=2; // used for offset //ldy #0
|
||||
|
||||
parsetoken:
|
||||
getsrc(); cycles+=6; // jsr getsrc
|
||||
|
@ -162,22 +162,22 @@ parsetoken:
|
|||
lsr(); cycles+=2; // lsr
|
||||
lsr(); cycles+=2; // lsr
|
||||
cycles+=2;
|
||||
if (a==0) {
|
||||
if (A==0) {
|
||||
cycles+=1;
|
||||
goto copymatches; // if zero, no literals // beq copymatches
|
||||
}
|
||||
|
||||
buildcount(); cycles+=6; // otherwise, build the count // jsr buildcount
|
||||
|
||||
x=a; cycles+=2; // tax
|
||||
X=A; cycles+=2; // tax
|
||||
docopy(); cycles+=6; // jsr docopy
|
||||
a=ram[LZ4_SRC]; cycles+=3; // lda LZ4_SRC
|
||||
A=ram[LZ4_SRC]; cycles+=3; // lda LZ4_SRC
|
||||
cmp(ram[end]); cycles+=3; // cmp end
|
||||
a=ram[LZ4_SRC+1]; cycles+=3; // lda LZ4_SRC+1
|
||||
A=ram[LZ4_SRC+1]; cycles+=3; // lda LZ4_SRC+1
|
||||
|
||||
sbc(ram[end+1]); cycles+=3; // sbc end+1
|
||||
cycles+=2;
|
||||
if (c) {
|
||||
if (C) {
|
||||
printf("Done!\n");
|
||||
printf("src : %02X%02X\n",ram[LZ4_SRC+1],ram[LZ4_SRC]);
|
||||
printf("packed end : %02X%02X\n",ram[end+1],ram[end]);
|
||||
|
@ -187,45 +187,45 @@ parsetoken:
|
|||
|
||||
copymatches:
|
||||
getsrc(); cycles+=6; // jsr getsrc
|
||||
ram[DELTA]=a; cycles+=3; // sta DELTA
|
||||
ram[DELTA]=A; cycles+=3; // sta DELTA
|
||||
getsrc(); cycles+=6; // jsr getsrc
|
||||
ram[DELTA+1]=a; cycles+=3; // sta DELTA+1
|
||||
ram[DELTA+1]=A; cycles+=3; // sta DELTA+1
|
||||
pla(); cycles+=3; // restore token // pla
|
||||
a=a&0xf; cycles+=2; // get bottom 4 bits // and #$0f
|
||||
A=A&0xf; cycles+=2; // get bottom 4 bits // and #$0f
|
||||
buildcount(); cycles+=6; // jsr buildcount
|
||||
|
||||
c=0; cycles+=2; // clc
|
||||
C=0; cycles+=2; // clc
|
||||
adc(4); cycles+=2; // adc #4
|
||||
x=a; cycles+=2; // tax
|
||||
X=A; cycles+=2; // tax
|
||||
cycles+=2;
|
||||
if (x==0) {
|
||||
if (X==0) {
|
||||
cycles+=1;
|
||||
goto copy_skip; //BUGFIX // beq +
|
||||
}
|
||||
cycles+=2;
|
||||
if (c==0) {
|
||||
if (C==0) {
|
||||
cycles+=1;
|
||||
goto copy_skip; // bcc +
|
||||
}
|
||||
ram[COUNT+1]++; cycles+=5; // inc count+1
|
||||
copy_skip:
|
||||
a=ram[LZ4_SRC+1]; cycles+=3; //+ lda src+1
|
||||
A=ram[LZ4_SRC+1]; cycles+=3; //+ lda src+1
|
||||
pha(); cycles+=3; // pha
|
||||
a=ram[LZ4_SRC]; cycles+=3; // lda src
|
||||
A=ram[LZ4_SRC]; cycles+=3; // lda src
|
||||
pha(); cycles+=3; // pha
|
||||
c=1; cycles+=2; // sec
|
||||
a=ram[LZ4_DST]; cycles+=3; // lda LZ4_DST
|
||||
C=1; cycles+=2; // sec
|
||||
A=ram[LZ4_DST]; cycles+=3; // lda LZ4_DST
|
||||
sbc(ram[DELTA]); cycles+=3; // sbc DELTA
|
||||
ram[LZ4_SRC]=a; cycles+=3; // sta LZ4_SRC
|
||||
a=ram[LZ4_DST+1]; cycles+=3; // lda LZ4_DST+1
|
||||
ram[LZ4_SRC]=A; cycles+=3; // sta LZ4_SRC
|
||||
A=ram[LZ4_DST+1]; cycles+=3; // lda LZ4_DST+1
|
||||
sbc(ram[DELTA+1]); cycles+=3; // sbc DELTA+1
|
||||
ram[LZ4_SRC+1]=a; cycles+=3; // sta LZ4_SRC+1
|
||||
ram[LZ4_SRC+1]=A; cycles+=3; // sta LZ4_SRC+1
|
||||
|
||||
docopy(); cycles+=6; // jsr docopy
|
||||
pla(); cycles+=3; // pla
|
||||
ram[LZ4_SRC]=a; cycles+=3; // sta LZ4_SRC
|
||||
ram[LZ4_SRC]=A; cycles+=3; // sta LZ4_SRC
|
||||
pla(); cycles+=3; // pla
|
||||
ram[LZ4_SRC+1]=a; cycles+=3; // sta LZ4_SRC+1
|
||||
ram[LZ4_SRC+1]=A; cycles+=3; // sta LZ4_SRC+1
|
||||
cycles+=3;
|
||||
goto parsetoken; // jmp parsetoken
|
||||
|
||||
|
@ -262,13 +262,13 @@ static void print_both_pages(void) {
|
|||
|
||||
for(i=0;i<ram[CH];i++) printf(" ");
|
||||
|
||||
y=0;
|
||||
Y=0;
|
||||
|
||||
while(1) {
|
||||
a=ram[y_indirect(OUTL,y)];
|
||||
if (a==0) break;
|
||||
printf("%c",a);
|
||||
y++;
|
||||
A=ram[y_indirect(OUTL,Y)];
|
||||
if (A==0) break;
|
||||
printf("%c",A);
|
||||
Y++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -276,20 +276,20 @@ static void print_both_pages(void) {
|
|||
|
||||
static void print_header_info(void) {
|
||||
|
||||
ram[CV]=a;
|
||||
ram[CV]=A;
|
||||
|
||||
y++;
|
||||
a=y;
|
||||
y=0;
|
||||
c=0;
|
||||
Y++;
|
||||
A=Y;
|
||||
Y=0;
|
||||
C=0;
|
||||
adc(ram[OUTL]);
|
||||
ram[OUTL]=a;
|
||||
a=ram[OUTH];
|
||||
ram[OUTL]=A;
|
||||
A=ram[OUTH];
|
||||
adc(0);
|
||||
ram[OUTH]=a;
|
||||
ram[OUTH]=A;
|
||||
|
||||
a=ram[y_indirect(OUTL,y)];
|
||||
ram[CH]=a;
|
||||
A=ram[y_indirect(OUTL,Y)];
|
||||
ram[CH]=A;
|
||||
|
||||
ram[OUTL]++;
|
||||
if (ram[OUTL]==0) ram[OUTH]++;
|
||||
|
@ -321,55 +321,55 @@ int main(int argc, char **argv) {
|
|||
|
||||
memcpy(&ram[LZ4_BUFFER],input,size);
|
||||
|
||||
a=high(LZ4_BUFFER);
|
||||
ram[OUTH]=a;
|
||||
a=low(LZ4_BUFFER);
|
||||
ram[OUTL]=a;
|
||||
A=high(LZ4_BUFFER);
|
||||
ram[OUTH]=A;
|
||||
A=low(LZ4_BUFFER);
|
||||
ram[OUTL]=A;
|
||||
|
||||
y=3;
|
||||
Y=3;
|
||||
|
||||
a=20;
|
||||
A=20;
|
||||
print_header_info();
|
||||
|
||||
a=21;
|
||||
A=21;
|
||||
print_header_info();
|
||||
printf("\n");
|
||||
|
||||
a=23;
|
||||
A=23;
|
||||
print_header_info();
|
||||
|
||||
y=0;
|
||||
a=high(LZ4_BUFFER+3);
|
||||
ram[LZ4_SRC+1]=a;
|
||||
a=low(LZ4_BUFFER+3);
|
||||
ram[LZ4_SRC]=a;
|
||||
Y=0;
|
||||
A=high(LZ4_BUFFER+3);
|
||||
ram[LZ4_SRC+1]=A;
|
||||
A=low(LZ4_BUFFER+3);
|
||||
ram[LZ4_SRC]=A;
|
||||
|
||||
a=ram[y_indirect(LZ4_SRC,y)];
|
||||
c=0;
|
||||
A=ram[y_indirect(LZ4_SRC,Y)];
|
||||
C=0;
|
||||
adc(ram[LZ4_SRC]);
|
||||
ram[LZ4_SRC]=a;
|
||||
a=ram[LZ4_SRC+1];
|
||||
ram[LZ4_SRC]=A;
|
||||
A=ram[LZ4_SRC+1];
|
||||
adc(0);
|
||||
ram[LZ4_SRC+1]=a;
|
||||
ram[LZ4_SRC+1]=A;
|
||||
|
||||
// next_subsong:
|
||||
|
||||
y=0;
|
||||
Y=0;
|
||||
|
||||
a=ram[y_indirect(LZ4_SRC,y)];
|
||||
ram[LZ4_END]=a;
|
||||
y++;
|
||||
a=ram[y_indirect(LZ4_SRC,y)];
|
||||
ram[LZ4_END+1]=a;
|
||||
y++;
|
||||
A=ram[y_indirect(LZ4_SRC,Y)];
|
||||
ram[LZ4_END]=A;
|
||||
Y++;
|
||||
A=ram[y_indirect(LZ4_SRC,Y)];
|
||||
ram[LZ4_END+1]=A;
|
||||
Y++;
|
||||
|
||||
a=2;
|
||||
c=0;
|
||||
A=2;
|
||||
C=0;
|
||||
adc(ram[LZ4_SRC]);
|
||||
ram[LZ4_SRC]=a;
|
||||
a=(ram[LZ4_SRC+1]);
|
||||
ram[LZ4_SRC]=A;
|
||||
A=(ram[LZ4_SRC+1]);
|
||||
adc(0);
|
||||
ram[LZ4_SRC+1]=a;
|
||||
ram[LZ4_SRC+1]=A;
|
||||
|
||||
lz4_decode();
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ static unsigned char input[MAX_INPUT];
|
|||
|
||||
static void getsrc(void) {
|
||||
//getsrc:
|
||||
a=ram[y_indirect(src,y)]; // lda (src), y
|
||||
A=ram[y_indirect(src,Y)]; // lda (src), y
|
||||
|
||||
printf("LOAD %02X%02X: %02X\n",ram[src+1],ram[src],a);
|
||||
printf("LOAD %02X%02X: %02X\n",ram[src+1],ram[src],A);
|
||||
|
||||
ram[src]++; //inc src
|
||||
if (ram[src]!=0) goto done_getsrc; //bne +
|
||||
|
@ -33,39 +33,39 @@ done_getsrc: ;
|
|||
}
|
||||
|
||||
void buildcount(void) {
|
||||
printf("\tBUILDCOUNT: A=0x%x\n",a);
|
||||
printf("\tBUILDCOUNT: A=0x%x\n",A);
|
||||
//buildcount:
|
||||
x=1; // ?? // ldx #1
|
||||
ram[count+1]=x; // ?? // stx count+1
|
||||
X=1; // ?? // ldx #1
|
||||
ram[count+1]=X; // ?? // stx count+1
|
||||
cmp(0xf); // if 15, more complicated // cmp #$0f
|
||||
if (z==0) goto done_buildcount; // otherwise A is count // bne ++
|
||||
if (Z==0) goto done_buildcount; // otherwise A is count // bne ++
|
||||
buildcount_loop:
|
||||
ram[count]=a; //- sta count
|
||||
ram[count]=A; //- sta count
|
||||
// printf("MBC ");
|
||||
getsrc(); //jsr getsrc
|
||||
printf("\tADDITIONAL BUILDCOUNT 0x%x, adding 0x%x\n",a,ram[count]);
|
||||
x=a; //tax
|
||||
c=0; //clc
|
||||
printf("\tADDITIONAL BUILDCOUNT 0x%x, adding 0x%x\n",A,ram[count]);
|
||||
X=A; //tax
|
||||
C=0; //clc
|
||||
adc(ram[count]); //adc count
|
||||
printf("\tGOT 0x%x c=%d\n",a,c);
|
||||
if (c==0) goto skip_buildcount; // bcc +
|
||||
printf("\tGOT 0x%x c=%d\n",A,C);
|
||||
if (C==0) goto skip_buildcount; // bcc +
|
||||
ram[count+1]++; //inc count+1
|
||||
skip_buildcount:
|
||||
printf("\tUPDATED COUNT %02X%02X\n",ram[count+1],a);
|
||||
x++; // check if x is 255 //+ inx
|
||||
if (x==0) goto buildcount_loop; // if so, add in next byte //beq -
|
||||
printf("\tUPDATED COUNT %02X%02X\n",ram[count+1],A);
|
||||
X++; // check if x is 255 //+ inx
|
||||
if (X==0) goto buildcount_loop; // if so, add in next byte //beq -
|
||||
done_buildcount: ; //++ rts
|
||||
printf("\tBUILDCOUNT= %02X%02X r[c+1]=%02X r[c]=%02X a=%02X x=%02X\n",
|
||||
ram[count+1],a,ram[count+1],ram[count],a,x);
|
||||
ram[count+1],A,ram[count+1],ram[count],A,X);
|
||||
}
|
||||
|
||||
|
||||
static void putdst(void) {
|
||||
// printf("PUTADDR=%04X\n",y_indirect(dst,y));
|
||||
// putdst:
|
||||
ram[y_indirect(dst,y)]=a; // sta (dst), y
|
||||
if (y!=0) printf("ERROR ERROR ERROR ERROR ERROR\n");
|
||||
printf("\t\tPUT: %02X%02X = %02X\n",ram[dst+1],ram[dst],a);
|
||||
ram[y_indirect(dst,Y)]=A; // sta (dst), y
|
||||
if (Y!=0) printf("ERROR ERROR ERROR ERROR ERROR\n");
|
||||
printf("\t\tPUT: %02X%02X = %02X\n",ram[dst+1],ram[dst],A);
|
||||
ram[dst]++; // inc dst
|
||||
if (ram[dst]!=0) goto putdst_end; // bne +
|
||||
ram[dst+1]++; // inc dst+1
|
||||
|
@ -87,13 +87,13 @@ static void getput(void) {
|
|||
// 1ff -> 1fe
|
||||
|
||||
static void docopy(void) {
|
||||
printf("\tDOCOPY ENTRY: %02X%02X\n",ram[count+1],x);
|
||||
printf("\tDOCOPY ENTRY: %02X%02X\n",ram[count+1],X);
|
||||
// docopy:
|
||||
docopy_label:
|
||||
printf("\tDOCOPY %02X%02X: ",ram[count+1],x);
|
||||
printf("\tDOCOPY %02X%02X: ",ram[count+1],X);
|
||||
getput(); // jsr getput
|
||||
x--; // dex
|
||||
if (x!=0) goto docopy_label; // bne docopy
|
||||
X--; // dex
|
||||
if (X!=0) goto docopy_label; // bne docopy
|
||||
ram[count+1]--; // dec count+1
|
||||
if (ram[count+1]!=0) goto docopy_label; //bne docopy
|
||||
//rts
|
||||
|
@ -152,18 +152,18 @@ int main(int argc, char **argv) {
|
|||
//LCBANK2 = $c083
|
||||
//MOVE = $fe2c
|
||||
|
||||
a=(pakoff&0xff); //lda #<pakoff ;packed data offset
|
||||
ram[src]=a; //sta src
|
||||
a=(pakoff+paksize)&0xff;//lda #<(pakoff+paksize) ;packed data size
|
||||
ram[end]=a; // sta end
|
||||
a=(pakoff>>8); //lda #>pakoff
|
||||
ram[src+1]=a; //sta src+1
|
||||
a=(pakoff+paksize)>>8; //lda #>(pakoff+paksize)
|
||||
ram[end+1]=a; // sta end+1
|
||||
a=(orgoff>>8); //lda #>orgoff ;original unpacked data offset
|
||||
ram[dst+1]=a; //sta dst+1
|
||||
a=(orgoff&0xff); //lda #<orgoff
|
||||
ram[dst]=a; // sta dst
|
||||
A=(pakoff&0xff); //lda #<pakoff ;packed data offset
|
||||
ram[src]=A; //sta src
|
||||
A=(pakoff+paksize)&0xff;//lda #<(pakoff+paksize) ;packed data size
|
||||
ram[end]=A; // sta end
|
||||
A=(pakoff>>8); //lda #>pakoff
|
||||
ram[src+1]=A; //sta src+1
|
||||
A=(pakoff+paksize)>>8; //lda #>(pakoff+paksize)
|
||||
ram[end+1]=A; // sta end+1
|
||||
A=(orgoff>>8); //lda #>orgoff ;original unpacked data offset
|
||||
ram[dst+1]=A; //sta dst+1
|
||||
A=(orgoff&0xff); //lda #<orgoff
|
||||
ram[dst]=A; // sta dst
|
||||
|
||||
printf("packed size: raw=%x, adj=%x\n",size,paksize);
|
||||
printf("packed addr: %02X%02X\n",ram[src+1],ram[src]);
|
||||
|
@ -184,7 +184,7 @@ int main(int argc, char **argv) {
|
|||
// goto unpmain; // jmp unpmain
|
||||
|
||||
//unpack:
|
||||
y=0; // used for offset //ldy #0
|
||||
Y=0; // used for offset //ldy #0
|
||||
|
||||
parsetoken:
|
||||
token_count++;
|
||||
|
@ -196,18 +196,18 @@ parsetoken:
|
|||
lsr(); // lsr
|
||||
lsr(); // lsr
|
||||
lsr(); // lsr
|
||||
if (a==0) goto copymatches; // if zero, no literals // beq copymatches
|
||||
if (A==0) goto copymatches; // if zero, no literals // beq copymatches
|
||||
|
||||
buildcount(); // otherwise, build the count // jsr buildcount
|
||||
|
||||
x=a; // tax
|
||||
X=A; // tax
|
||||
docopy(); // jsr docopy
|
||||
a=ram[src]; // lda src
|
||||
A=ram[src]; // lda src
|
||||
cmp(ram[end]); // cmp end
|
||||
a=ram[src+1]; // lda src+1
|
||||
A=ram[src+1]; // lda src+1
|
||||
|
||||
sbc(ram[end+1]); // sbc end+1
|
||||
if (c) {
|
||||
if (C) {
|
||||
printf("Done!\n");
|
||||
printf("src : %02X%02X\n",ram[src+1],ram[src]);
|
||||
printf("packed end : %02X%02X\n",ram[end+1],ram[end]);
|
||||
|
@ -217,41 +217,41 @@ parsetoken:
|
|||
copymatches:
|
||||
printf("\tDELTAL ");
|
||||
getsrc(); // jsr getsrc
|
||||
ram[delta]=a; // sta delta
|
||||
ram[delta]=A; // sta delta
|
||||
printf("\tDELTAH ");
|
||||
getsrc(); // jsr getsrc
|
||||
ram[delta+1]=a; // sta delta+1
|
||||
ram[delta+1]=A; // sta delta+1
|
||||
printf("\tDELTA is %02X%02X\n",ram[delta+1],ram[delta]);
|
||||
pla(); // restore token // pla
|
||||
a=a&0xf; // get bottom 4 bits // and #$0f
|
||||
A=A&0xf; // get bottom 4 bits // and #$0f
|
||||
buildcount(); // jsr buildcount
|
||||
|
||||
c=0; // clc
|
||||
C=0; // clc
|
||||
adc(4); // adc #4
|
||||
x=a; // tax
|
||||
if (x==0) goto copy_skip; //BUGFIX // beq +
|
||||
if (c==0) goto copy_skip; // bcc +
|
||||
X=A; // tax
|
||||
if (X==0) goto copy_skip; //BUGFIX // beq +
|
||||
if (C==0) goto copy_skip; // bcc +
|
||||
ram[count+1]++; // inc count+1
|
||||
copy_skip:
|
||||
a=ram[src+1]; //+ lda src+1
|
||||
A=ram[src+1]; //+ lda src+1
|
||||
pha(); // pha
|
||||
a=ram[src]; // lda src
|
||||
A=ram[src]; // lda src
|
||||
pha(); // pha
|
||||
printf("\tSAVED SRC: %02X%02X\n",ram[src+1],ram[src]);
|
||||
// printf("CALCULATING: DST %02X%02X - DELTA %02X%02X\n",ram[dst+1],ram[dst],ram[delta+1],ram[delta]);
|
||||
c=1; // sec
|
||||
a=ram[dst]; // lda dst
|
||||
C=1; // sec
|
||||
A=ram[dst]; // lda dst
|
||||
sbc(ram[delta]); // sbc delta
|
||||
ram[src]=a; // sta src
|
||||
a=ram[dst+1]; // lda dst+1
|
||||
ram[src]=A; // sta src
|
||||
A=ram[dst+1]; // lda dst+1
|
||||
sbc(ram[delta+1]); // sbc delta+1
|
||||
ram[src+1]=a; // sta src+1
|
||||
ram[src+1]=A; // sta src+1
|
||||
printf("\tNEW SRC: %02X%02X\n",ram[src+1],ram[src]);
|
||||
docopy(); // jsr docopy
|
||||
pla(); // pla
|
||||
ram[src]=a; // sta src
|
||||
ram[src]=A; // sta src
|
||||
pla(); // pla
|
||||
ram[src+1]=a; // sta src+1
|
||||
ram[src+1]=A; // sta src+1
|
||||
printf("\tRESTORED SRC: %02X%02X\n",ram[src+1],ram[src]);
|
||||
goto parsetoken; // jmp parsetoken
|
||||
|
||||
|
|
|
@ -686,14 +686,14 @@ static void draw_background_mode7(void) {
|
|||
|
||||
do {
|
||||
//screeny_loop:
|
||||
y=0;
|
||||
Y=0;
|
||||
|
||||
/* actual code does even/odd stuff here */
|
||||
|
||||
cycles.mode7+=27;
|
||||
//setup_gr_addr:
|
||||
|
||||
hlin_setup(ram[DRAW_PAGE],y,0,ram[SCREEN_Y]);
|
||||
hlin_setup(ram[DRAW_PAGE],Y,0,ram[SCREEN_Y]);
|
||||
cycles.mode7+=21;
|
||||
|
||||
//calc_horizontal_scale:
|
||||
|
@ -836,14 +836,14 @@ match:
|
|||
ram[COLOR]=(map_color&0xf);
|
||||
// ram[COLOR]|=map_color<<4;
|
||||
|
||||
y=0;
|
||||
Y=0;
|
||||
if ((ram[SCREEN_Y]&1)==0) {
|
||||
ram[y_indirect(GBASL,y)]=ram[COLOR];
|
||||
ram[y_indirect(GBASL,Y)]=ram[COLOR];
|
||||
cycles.mode7+=18;
|
||||
}
|
||||
else {
|
||||
a=ram[COLOR];
|
||||
ram[y_indirect(GBASL,y)]|=(a<<4);
|
||||
A=ram[COLOR];
|
||||
ram[y_indirect(GBASL,Y)]|=(A<<4);
|
||||
cycles.mode7+=22;
|
||||
|
||||
}
|
||||
|
|
|
@ -59,14 +59,14 @@ int select_menu(int x, int y, int num, char **items) {
|
|||
|
||||
void apple_memset(unsigned char *ptr, int value, int length) {
|
||||
|
||||
a=value;
|
||||
x=length;
|
||||
y=0;
|
||||
A=value;
|
||||
X=length;
|
||||
Y=0;
|
||||
|
||||
while(x>0) {
|
||||
ptr[y]=a;
|
||||
y++;
|
||||
x--;
|
||||
while(X>0) {
|
||||
ptr[Y]=A;
|
||||
Y++;
|
||||
X--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,4 +37,4 @@ twist_dump.o: twist_dump.c
|
|||
###
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o twist_6502 twist_dump
|
||||
rm -f *~ *.o twist_6502 twist_dump generate_sines
|
||||
|
|
Loading…
Reference in New Issue