diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index f5050b77..1230cb4a 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -17,8 +17,10 @@ static int ysize=YSIZE*PIXEL_Y_SCALE; static unsigned char framebuffer[XSIZE][YSIZE]; + /* 128kB of RAM */ -unsigned char ram[128*1024]; +#define RAMSIZE 128*1024 +unsigned char ram[RAMSIZE]; static SDL_Surface *sdl_screen=NULL; @@ -189,3 +191,33 @@ int gr(void) { return 0; } + +int bload(char *filename, int address) { + + FILE *fff; + int count=0,ch=0; + + fff=fopen(filename,"r"); + if (fff==NULL) { + fprintf(stderr,"Could not open %s\n",filename); + return -1; + } + + while(1) { + + if ((address+count)>RAMSIZE) { + fprintf(stderr,"ERROR ram too high\n"); + return -1; + } + + + ch=fgetc(fff); + if (ch<0) break; + + ram[address+count]=ch; + count++; + } + fclose(fff); + + return 0; +} diff --git a/gr-sim/gr-sim.h b/gr-sim/gr-sim.h index 02a77a3b..5058a983 100644 --- a/gr-sim/gr-sim.h +++ b/gr-sim/gr-sim.h @@ -7,3 +7,4 @@ int plot(int x, int y); int hlin(int x1, int x2, int at); int vlin(int y1, int y2, int at); int gr(void); +int bload(char *filename, int address);