diff --git a/gr-sim/Makefile b/gr-sim/Makefile index 63b54ed2..96135886 100644 --- a/gr-sim/Makefile +++ b/gr-sim/Makefile @@ -51,7 +51,7 @@ sparkle.o: sparkle.c $(CC) $(CFLAGS) -c sparkle.c -gr-sim.o: gr-sim.c +gr-sim.o: gr-sim.c apple2_font.h $(CC) $(CFLAGS) $(SDL_INCLUDE) -c gr-sim.c clean: diff --git a/gr-sim/apple2_font.h b/gr-sim/apple2_font.h index 1603c269..b9cd7773 100644 --- a/gr-sim/apple2_font.h +++ b/gr-sim/apple2_font.h @@ -1,4 +1,8 @@ -unsigned char a2_font[64][7]={ +/* 2513 character generator */ +unsigned char a2_font[256][7]={ + + /* Control Chars */ + {0x0e, // 01110 0x11, // 10001 0x15, // 10101 @@ -7,4 +11,467 @@ unsigned char a2_font[64][7]={ 0x10, // 10000 0x0f, // 01111 }, // @ + {0x04, // 00100 + 0x0a, // 01010 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + }, // A + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // B + {0x0e, // 01110 + 0x11, // 10001 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x11, // 10001 + 0x0e, // 01110 + }, // C + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // D + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // E + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + }, // F + {0x1e, // 01111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 10000 + 0x13, // 10011 + 0x11, // 10001 + 0x0f, // 01111 + }, // G + {0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // H + {0x0e, // 01110 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x0e, // 01110 + }, // I + {0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x11, // 10001 + 0x0e, // 01110 + }, // J + {0x11, // 10001 + 0x12, // 10010 + 0x14, // 10100 + 0x18, // 11000 + 0x14, // 10100 + 0x12, // 10010 + 0x11, // 10001 + }, // K + {0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // L + {0x11, // 10001 + 0x1b, // 11011 + 0x15, // 10101 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // M + {0x11, // 10001 + 0x11, // 10001 + 0x19, // 11001 + 0x15, // 10101 + 0x13, // 10011 + 0x11, // 10001 + 0x11, // 10001 + }, // N + {0x0e, // 01110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x0e, // 01110 + }, // O + {}, // P + {}, // Q + {}, // R + {}, // S + {}, // T + {}, // U + {}, // V + {}, // W + {}, // X + {}, // Y + {}, // Z + {}, // [ + {}, // \. + {}, // ] + {}, // ^ + {}, // _ + + /* Non-control chars */ + + {}, // + {}, // ! + {}, // " + {}, // # + {}, // $ + {}, // % + {}, // & + {}, // ' + {}, // ( + {}, // ) + {}, // * + {}, // + + {}, // , + {}, // - + {}, // . + {}, // / + {}, // 0 + {}, // 1 + {}, // 2 + {}, // 3 + {}, // 4 + {}, // 5 + {}, // 6 + {}, // 7 + {}, // 8 + {}, // 9 + {}, // : + {}, // ; + {}, // < + {}, // = + {}, // > + {}, // ? + {0x0e, // 01110 + 0x11, // 10001 + 0x15, // 10101 + 0x17, // 10111 + 0x16, // 10110 + 0x10, // 10000 + 0x0f, // 01111 + }, // @ + {0x04, // 00100 + 0x0a, // 01010 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + }, // A + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // B + {0x0e, // 01110 + 0x11, // 10001 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x11, // 10001 + 0x0e, // 01110 + }, // C + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // D + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // E + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + }, // F + {0x1e, // 01111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 10000 + 0x13, // 10011 + 0x11, // 10001 + 0x0f, // 01111 + }, // G + {0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // H + {0x0e, // 01110 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x0e, // 01110 + }, // I + {0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x11, // 10001 + 0x0e, // 01110 + }, // J + {0x11, // 10001 + 0x12, // 10010 + 0x14, // 10100 + 0x18, // 11000 + 0x14, // 10100 + 0x12, // 10010 + 0x11, // 10001 + }, // K + {0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // L + {0x11, // 10001 + 0x1b, // 11011 + 0x15, // 10101 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // M + {0x11, // 10001 + 0x11, // 10001 + 0x19, // 11001 + 0x15, // 10101 + 0x13, // 10011 + 0x11, // 10001 + 0x11, // 10001 + }, // N + {0x0e, // 01110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x0e, // 01110 + }, // O + {}, // P + {}, // Q + {}, // R + {}, // S + {}, // T + {}, // U + {}, // V + {}, // W + {}, // X + {}, // Y + {}, // Z + {}, // [ + {}, // \. + {}, // ] + {}, // ^ + {}, // _ + + /* Lowercase */ + + {0x0e, // 01110 + 0x11, // 10001 + 0x15, // 10101 + 0x17, // 10111 + 0x16, // 10110 + 0x10, // 10000 + 0x0f, // 01111 + }, // @ + {0x04, // 00100 + 0x0a, // 01010 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + }, // A + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // B + {0x0e, // 01110 + 0x11, // 10001 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x11, // 10001 + 0x0e, // 01110 + }, // C + {0x1e, // 11110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1e, // 11110 + }, // D + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // E + {0x1f, // 11111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 11110 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + }, // F + {0x1e, // 01111 + 0x10, // 10000 + 0x10, // 10000 + 0x1e, // 10000 + 0x13, // 10011 + 0x11, // 10001 + 0x0f, // 01111 + }, // G + {0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x1f, // 11111 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // H + {0x0e, // 01110 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x04, // 00100 + 0x0e, // 01110 + }, // I + {0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x01, // 00001 + 0x11, // 10001 + 0x0e, // 01110 + }, // J + {0x11, // 10001 + 0x12, // 10010 + 0x14, // 10100 + 0x18, // 11000 + 0x14, // 10100 + 0x12, // 10010 + 0x11, // 10001 + }, // K + {0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x10, // 10000 + 0x1f, // 11111 + }, // L + {0x11, // 10001 + 0x1b, // 11011 + 0x15, // 10101 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + }, // M + {0x11, // 10001 + 0x11, // 10001 + 0x19, // 11001 + 0x15, // 10101 + 0x13, // 10011 + 0x11, // 10001 + 0x11, // 10001 + }, // N + {0x0e, // 01110 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x11, // 10001 + 0x0e, // 01110 + }, // O + {}, // P + {}, // Q + {}, // R + {}, // S + {}, // T + {}, // U + {}, // V + {}, // W + {}, // X + {}, // Y + {}, // Z + {}, // [ + {}, // \. + {}, // ] + {}, // ^ + {}, // _ }; + diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index 61abdbfb..249c511b 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -8,12 +8,18 @@ #include "apple2_font.h" +/* 40x48 low-res mode */ #define XSIZE 40 #define YSIZE 48 - #define PIXEL_X_SCALE 14 #define PIXEL_Y_SCALE 8 +/* 40 column only for now */ +#define TEXT_XSIZE 40 +#define TEXT_YSIZE 24 +#define TEXT_X_SCALE 14 +#define TEXT_Y_SCALE 16 + static int xsize=XSIZE*PIXEL_X_SCALE; static int ysize=YSIZE*PIXEL_Y_SCALE; @@ -43,9 +49,56 @@ unsigned char a,y,x; #define MASK 0x2E #define COLOR 0x30 #define FIRST 0xF0 - +#define SPEEDZ 0xF1 +#define FLASH 0xF3 #define TEMP 0xFA + +/* Soft Switches */ +#define TXTCLR 0xc050 +#define TXTSET 0xc051 +#define MIXCLR 0xc052 +#define MIXSET 0xc053 +#define LOWSCR 0xc054 +#define HISCR 0xc055 +#define LORES 0xc056 +#define HIRES 0xc057 + +static int text_mode=1; +static int text_page_1=1; +static int hires_on=0; +static int mixed_graphics=1; + +static void soft_switch(unsigned short address) { + + switch(address) { + case TXTCLR: // $c050 + text_mode=0; + break; + case TXTSET: // $c051 + text_mode=1; + break; + case MIXCLR: // $c052 + mixed_graphics=0; + break; + case MIXSET: // $c053 + mixed_graphics=1; + break; + case LOWSCR: // $c054 + text_page_1=1; + break; + case LORES: // $c056 + hires_on=0; + break; + case HIRES: // $c057 + hires_on=1; + break; + default: + fprintf(stderr,"Unknown soft switch %x\n",address); + break; + } +} + static SDL_Surface *sdl_screen=NULL; int grsim_input(void) { @@ -169,22 +222,85 @@ int scrn(unsigned char xcoord, unsigned char ycoord) { return 0; } +static short gr_addr_lookup[24]={ + 0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780, + 0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8, + 0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0, +}; + int grsim_update(void) { int x,y,i,j; + int bit_set,ch,inverse,flash; unsigned int *t_pointer; t_pointer=((Uint32 *)sdl_screen->pixels); - for(y=0;y12) bit_set=0; + else if (i>10) bit_set=0; + else bit_set=(a2_font[ch][j/2])&(1<<(i/2)); + + if (inverse) { + if (bit_set) *t_pointer=color[0]; + else *t_pointer=color[15]; + } + else if (flash) { + if (bit_set) *t_pointer=color[9]; + else *t_pointer=color[0]; + } + else { + if (bit_set) *t_pointer=color[15]; + else *t_pointer=color[0]; + } + + t_pointer++; + } + } } } + } + else { + for(y=0;y=40) { + s=a; // PHA + crdo(); + a=s; // PLA + a-=40; + } + ram[CH]=a; // STA MON.CH + + + // KRW for the win! + +} + +void basic_vtab(int y) { + +} + +void basic_print(char *string) { + + int i; + + for(i=0;i