gr-sim: add bload support

This commit is contained in:
Vince Weaver 2017-05-03 10:50:15 -04:00
parent b52890bfeb
commit 737c56cfd0
2 changed files with 34 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);