From 2b3f766c703778881f5335296362b3b37ba9b62f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 4 May 2017 14:59:25 -0400 Subject: [PATCH] gr-sim: use actual code for gr --- gr-sim/gr-sim.c | 205 ++++++++++++++++++++++++++++++----------------- gr-sim/gr-sim.h | 6 +- gr-sim/kaleido.c | 4 +- gr-sim/rainbow.c | 6 +- gr-sim/sparkle.c | 18 ++--- 5 files changed, 149 insertions(+), 90 deletions(-) diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index bda30641..2fdb4530 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -38,6 +38,7 @@ unsigned char a,y,x; #define GBASH 0x27 #define BASL 0x28 #define BASH 0x29 +#define V2 0x2D #define MASK 0x2E #define COLOR 0x30 @@ -239,29 +240,10 @@ int color_equals(int new_color) { - - -int plot(unsigned char xcoord, unsigned char ycoord) { +static void plot(void) { unsigned char c; - if (ycoord>40) { - printf("Y too big %d\n",ycoord); - return -1; - } - - /* Applesoft Source Code */ - /* F225 GET X,Y Values */ - /* Y-coord in A */ - /* X-coord in Y */ - /* Check that X-coord<40 */ - a=ycoord; - y=xcoord; - - if (y>=40) { - printf("X too big %d\n",y); - return -1; - } /* Call into Monitor $F800 */ c=a&1; /* save LSB in carry */ @@ -287,32 +269,153 @@ int plot(unsigned char xcoord, unsigned char ycoord) { ram[y_indirect(GBASL,y)]=a; - return 0; } -int hlin(int x1, int x2, int at) { - int i; +int basic_plot(unsigned char xcoord, unsigned char ycoord) { - for(i=x1;i40) { + printf("Y too big %d\n",ycoord); + return -1; + } + + /* Applesoft Source Code */ + /* F225 GET X,Y Values */ + /* Y-coord in A */ + /* X-coord in Y */ + /* Check that X-coord<40 */ + a=ycoord; + y=xcoord; + + if (y>=40) { + printf("X too big %d\n",y); + return -1; + } + + plot(); return 0; } -int vlin(int y1, int y2, int at) { + +int basic_hlin(int x1, int x2, int at) { int i; - for(i=y1;i>1; + a=a&0x3; + a=a|0x4; + ram[BASH]=a; + a=s; + a=a&0x18; + if (c!=0) { + a=a+0x80; + } +// BSCLC2 + ram[BASL]=a; + a=a<<2; + a=a|ram[BASL]; + ram[BASL]=a; + +} + +static void vtabz(void) { + + bascalc(); + + a+=ram[WNDLFT]; + ram[BASL]=a; + +} + +static void vtab(void) { + + 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; +// TABV + ram[CV]=a; + vtab(); +} + +static void vline(void) { + + unsigned char s; + + // f828 +vline_loop: + s=a; + //plot(); + // FIXME + a=s; + if (a0) goto clrsc3; +} + int gr(void) { - int i; - /* Init screen */ - for(i=0x400;i<0x800;i++) ram[i]=0; + // F390 + // LDA SW.LORES + // LDA SW.MIXSET + //JMP MON.SETGR + + // FB40 + // LDA TXTCLR + // LDA MIXSET + + clrtop(); + + a=0x14; + setwnd(); return 0; } @@ -347,50 +450,6 @@ int bload(char *filename, int address) { return 0; } -static int bascalc(void) { - // FBC1 - - unsigned char s,c; - - s=a; - c=a&0x1; - - a=a>>1; - a=a&0x3; - a=a|0x4; - ram[BASH]=a; - a=s; - a=a&0x18; - if (c!=0) { - a=a+0x80; - } -// BSCLC2 - ram[BASL]=a; - a=a<<2; - a=a|ram[BASL]; - ram[BASL]=a; - - return 0; -} - -static int vtabz(void) { - - bascalc(); - - a+=ram[WNDLFT]; - ram[BASL]=a; - - return 0; -} - -static int vtab(void) { - - a=ram[CV]; - vtabz(); - - return 0; -} - static int cleolz(void) { // FC9E diff --git a/gr-sim/gr-sim.h b/gr-sim/gr-sim.h index 4a19da0f..6de8b7d4 100644 --- a/gr-sim/gr-sim.h +++ b/gr-sim/gr-sim.h @@ -3,9 +3,9 @@ int grsim_input(void); int grsim_update(void); int grsim_init(void); int color_equals(int new_color); -int plot(unsigned char xcoord, unsigned char ycoord); -int hlin(int x1, int x2, int at); -int vlin(int y1, int y2, int at); +int basic_plot(unsigned char xcoord, unsigned char ycoord); +int basic_hlin(int x1, int x2, int at); +int basic_vlin(int y1, int y2, int at); int gr(void); int bload(char *filename, int address); int scrn(unsigned char xcoord, unsigned char ycoord); diff --git a/gr-sim/kaleido.c b/gr-sim/kaleido.c index 6a4c2dc0..33b65bca 100644 --- a/gr-sim/kaleido.c +++ b/gr-sim/kaleido.c @@ -13,7 +13,7 @@ static int x,y,j,a,b,x2,y2,n; static void tooo(void) { color_equals(r[n]); - plot(x2,y2); + basic_plot(x2,y2); grsim_update(); return; } @@ -23,7 +23,7 @@ static void noo(void) { // 900 color_equals(r[0]); - plot(x,y); + basic_plot(x,y); grsim_update(); if (j==1) return; // 920 diff --git a/gr-sim/rainbow.c b/gr-sim/rainbow.c index 8ca395ae..851011de 100644 --- a/gr-sim/rainbow.c +++ b/gr-sim/rainbow.c @@ -13,14 +13,14 @@ int main(int argc, char **argv) { /* Put rainbow on screen */ for(y=0;y<40;y++) for(x=0;x<40;x++) { color_equals(y%16); - plot(x,y); + basic_plot(x,y); } color_equals(15); - vlin(0,40,20); + basic_vlin(0,40,20); color_equals(0); - hlin(0,40,20); + basic_hlin(0,40,20); while(1) { diff --git a/gr-sim/sparkle.c b/gr-sim/sparkle.c index b73c70fe..03e61bbb 100644 --- a/gr-sim/sparkle.c +++ b/gr-sim/sparkle.c @@ -64,14 +64,14 @@ label140: printf("ERROR! %d %d\n",x,r); return -1; } - plot(x+r,y+w); - plot(x+r,y-w); - plot(x-r,y-w); - plot(x-r,y+w); - plot(x+w,y+r); - plot(x+w,y-r); - plot(x-w,y-r); - plot(x-w,y+r); + basic_plot(x+r,y+w); + basic_plot(x+r,y-w); + basic_plot(x-r,y-w); + basic_plot(x-r,y+w); + basic_plot(x+w,y+r); + basic_plot(x+w,y-r); + basic_plot(x-w,y-r); + basic_plot(x-w,y+r); grsim_update(); //320 } @@ -97,7 +97,7 @@ label140: color_equals(w); for(l=(y-S);l<=(y+S);l+=(r/4)+1) { for(k=(x-S);k<=(x+S);k+=r) { - plot(k,l); + basic_plot(k,l); } } }