From c05084c2894978f83037b03fd1fe65bc2b335c74 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 29 Dec 2023 13:47:18 -0500 Subject: [PATCH] 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 --- utils/gr-sim/6502_emulate.c | 302 +++++++++--------- utils/gr-sim/6502_emulate.h | 6 +- utils/gr-sim/6502_test/6502_test.c | 64 ++-- utils/gr-sim/Makefile | 10 + utils/gr-sim/bubble/Makefile | 13 +- utils/gr-sim/bubble/bubble_orig.c | 65 ++++ utils/gr-sim/dos/nibble.c | 24 +- utils/gr-sim/dots/8086_emulator.c | 2 +- utils/gr-sim/gr-sim.c | 479 +++++++++++++++-------------- utils/gr-sim/gr-sim.h | 8 +- utils/gr-sim/hgr-sim.c | 254 +++++++-------- utils/gr-sim/hgr/Makefile | 15 +- utils/gr-sim/hgr/fw_purple.c | 20 +- utils/gr-sim/hgr/random16.c | 18 +- utils/gr-sim/hgr/scroll-asm.c | 48 +-- utils/gr-sim/hgr/seven.c | 26 +- utils/gr-sim/lz4/krw_decode.c | 178 +++++------ utils/gr-sim/lz4/lz4d_verbose.c | 114 +++---- utils/gr-sim/tfv/tfv_flying_6502.c | 12 +- utils/gr-sim/tfv_utils.c | 14 +- utils/gr-sim/twister/Makefile | 2 +- 21 files changed, 889 insertions(+), 785 deletions(-) create mode 100644 utils/gr-sim/bubble/bubble_orig.c diff --git a/utils/gr-sim/6502_emulate.c b/utils/gr-sim/6502_emulate.c index 9751518f..601f55fa 100644 --- a/utils/gr-sim/6502_emulate.c +++ b/utils/gr-sim/6502_emulate.c @@ -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); } diff --git a/utils/gr-sim/6502_emulate.h b/utils/gr-sim/6502_emulate.h index 24df07dd..a7b5d466 100644 --- a/utils/gr-sim/6502_emulate.h +++ b/utils/gr-sim/6502_emulate.h @@ -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); diff --git a/utils/gr-sim/6502_test/6502_test.c b/utils/gr-sim/6502_test/6502_test.c index d0aa0262..acffdba1 100644 --- a/utils/gr-sim/6502_test/6502_test.c +++ b/utils/gr-sim/6502_test/6502_test.c @@ -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"); } } diff --git a/utils/gr-sim/Makefile b/utils/gr-sim/Makefile index bea57146..764208f3 100644 --- a/utils/gr-sim/Makefile +++ b/utils/gr-sim/Makefile @@ -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 diff --git a/utils/gr-sim/bubble/Makefile b/utils/gr-sim/bubble/Makefile index 1a27db4c..f06db1c4 100644 --- a/utils/gr-sim/bubble/Makefile +++ b/utils/gr-sim/bubble/Makefile @@ -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 diff --git a/utils/gr-sim/bubble/bubble_orig.c b/utils/gr-sim/bubble/bubble_orig.c new file mode 100644 index 00000000..af6cc872 --- /dev/null +++ b/utils/gr-sim/bubble/bubble_orig.c @@ -0,0 +1,65 @@ +/* Bubble */ + +#include +#include +#include +#include +#include +#include + +#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>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>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=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 (aram[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>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>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='a') && (a<='z')) a&=~0x20; // convert to uppercase - a=(a&0x3f); + int y; - ram[y_indirect(BASL,y)]=a; + for(y=0;y='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>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; } diff --git a/utils/gr-sim/hgr/Makefile b/utils/gr-sim/hgr/Makefile index 70b33dab..b8446fc3 100644 --- a/utils/gr-sim/hgr/Makefile +++ b/utils/gr-sim/hgr/Makefile @@ -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 diff --git a/utils/gr-sim/hgr/fw_purple.c b/utils/gr-sim/hgr/fw_purple.c index 9ceba3e7..73566a38 100644 --- a/utils/gr-sim/hgr/fw_purple.c +++ b/utils/gr-sim/hgr/fw_purple.c @@ -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 #>=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(); diff --git a/utils/gr-sim/hgr/seven.c b/utils/gr-sim/hgr/seven.c index ef766bcd..4a74399d 100644 --- a/utils/gr-sim/hgr/seven.c +++ b/utils/gr-sim/hgr/seven.c @@ -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; } diff --git a/utils/gr-sim/lz4/krw_decode.c b/utils/gr-sim/lz4/krw_decode.c index b967da9c..a614a28f 100644 --- a/utils/gr-sim/lz4/krw_decode.c +++ b/utils/gr-sim/lz4/krw_decode.c @@ -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 ; original unpacked data offset + ram[LZ4_DST+1]=A; cycles+=3; // sta LZ4_DST+1 + A=low(orgoff); cycles+=2; // lda # 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 #>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 #>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 #0) { - ptr[y]=a; - y++; - x--; + while(X>0) { + ptr[Y]=A; + Y++; + X--; } } diff --git a/utils/gr-sim/twister/Makefile b/utils/gr-sim/twister/Makefile index 7b68b9a0..03670f2b 100644 --- a/utils/gr-sim/twister/Makefile +++ b/utils/gr-sim/twister/Makefile @@ -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