diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 0b9efbe0..9b1312e5 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -871,60 +871,81 @@ static void BOOT_ProgramStart(Program * * make) { } -#if C_DEBUG -class LDGFXROM : public Program { +class LOADROM : public Program { public: void Run(void) { - if (!(cmd->FindCommand(1, temp_line))) return; + if (!(cmd->FindCommand(1, temp_line))) { + WriteOut(MSG_Get("PROGRAM_LOADROM_SPECIFY_FILE")); + return; + } Bit8u drive; char fullname[DOS_PATHLENGTH]; - localDrive* ldp=0; if (!DOS_MakeName((char *)temp_line.c_str(),fullname,&drive)) return; - try { + try { + /* try to read ROM file into buffer */ ldp=dynamic_cast(Drives[drive]); if(!ldp) return; FILE *tmpfile = ldp->GetSystemFilePtr(fullname, "rb"); if(tmpfile == NULL) { - LOG_MSG("BIOS file not accessible."); + WriteOut(MSG_Get("PROGRAM_LOADROM_CANT_OPEN")); return; } fseek(tmpfile, 0L, SEEK_END); - if (ftell(tmpfile)>0x10000) { - LOG_MSG("BIOS file too large."); + if (ftell(tmpfile)>0x8000) { + WriteOut(MSG_Get("PROGRAM_LOADROM_TOO_LARGE")); + fclose(tmpfile); return; } fseek(tmpfile, 0L, SEEK_SET); - - PhysPt rom_base=PhysMake(0xc000,0); - - Bit8u vga_buffer[0x10000]; - Bitu data_written=0; - Bitu data_read=fread(vga_buffer, 1, 0x10000, tmpfile); - for (Bitu ct=0; ct= 0x4000 && rom_buffer[0] == 0x55 && rom_buffer[1] == 0xaa && + rom_buffer[3] == 0xeb && strncmp((char*)(&rom_buffer[0x1e]), "IBM", 3) == 0) { + + if (!IS_EGAVGA_ARCH) { + WriteOut(MSG_Get("PROGRAM_LOADROM_INCOMPATIBLE")); + return; + } + rom_base = PhysMake(0xc000, 0); // video BIOS + } + else if (data_read == 0x8000 && rom_buffer[0] == 0xe9 && rom_buffer[1] == 0x8f && + rom_buffer[2] == 0x7e && strncmp((char*)(&rom_buffer[0x4cd4]), "IBM", 3) == 0) { + + rom_base = PhysMake(0xf600, 0); // BASIC + } + + if (rom_base) { + /* write buffer into ROM */ + for (Bitu i=0; i