void cState_LoadHex(cStatePtr csp, const char *file)
{
FILE *fp;
int ch;
uint16 len, addr, rec_type, data;
char buff[5];
fp = fopen(file, "r");
while (!feof(fp))
{
ch = fgetc(fp);
if (strchr("0123456789ABCDEF:", ch) == NULL)
continue;
if (ch == ':')
{
buff[0] = fgetc(fp);
buff[1] = fgetc(fp);
buff[2] = 0;
len = strtol(buff, NULL, 0x10);
buff[0] = fgetc(fp);
buff[1] = fgetc(fp);
buff[2] = fgetc(fp);
buff[3] = fgetc(fp);
buff[4] = 0;
addr = strtol(buff, NULL, 0x10);
buff[0] = fgetc(fp);
buff[1] = fgetc(fp);
buff[2] = 0;
rec_type = strtol(buff, NULL, 0x10);
}
else
{
continue;
}
while (len > 0)
{
buff[0] = fgetc(fp);
buff[1] = fgetc(fp);
buff[2] = 0;
csp->rom[addr++] = strtol(buff, NULL, 0x10);
len--;
}
}
fclose(fp);
}