From b2ca61030edf8c659e179a76a610b2b66063fa7f Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 8 Feb 2006 15:13:06 +0000 Subject: [PATCH] Fix ROM checksum. (was broken as setupvesa modifies the rom as well) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2476 --- src/ints/int10.cpp | 1 + src/ints/int10.h | 1 + src/ints/int10_memory.cpp | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ints/int10.cpp b/src/ints/int10.cpp index 8c66058d..53a4a013 100644 --- a/src/ints/int10.cpp +++ b/src/ints/int10.cpp @@ -546,5 +546,6 @@ void INT10_Init(Section* sec) { INT10_SetupRomMemory(); INT10_Seg40Init(); INT10_SetupVESA(); + INT10_SetupRomMemoryChecksum();//SetupVesa modifies the rom as well. INT10_SetVideoMode(machine==MCH_HERC ? 0x7 : 0x3); }; diff --git a/src/ints/int10.h b/src/ints/int10.h index aa195c1b..8ae53e17 100644 --- a/src/ints/int10.h +++ b/src/ints/int10.h @@ -201,6 +201,7 @@ Bit8u VESA_GetPalette(PhysPt data,Bitu index,Bitu count); /* Sup Groups */ void INT10_SetupRomMemory(void); +void INT10_SetupRomMemoryChecksum(void); void INT10_SetupVESA(void); /* EGA RIL */ diff --git a/src/ints/int10_memory.cpp b/src/ints/int10_memory.cpp index 52f51a3d..abdedc69 100644 --- a/src/ints/int10_memory.cpp +++ b/src/ints/int10_memory.cpp @@ -72,6 +72,7 @@ void INT10_LoadFont(PhysPt font,bool reload,Bitu count,Bitu offset,Bitu map,Bitu } } +static Bitu checksumlocation = 0; //Same type as int10.rom.used void INT10_SetupRomMemory(void) { /* This should fill up certain structures inside the Video Bios Rom Area */ PhysPt rom_base=PhysMake(0xc000,0); @@ -113,16 +114,22 @@ void INT10_SetupRomMemory(void) { RealSetVec(0x1F,int10.rom.font_8_second); if (machine == MCH_VGA) { //EGA/VGA. Just to be safe - /* Sum of all bytes in rom module 256 should be 0 */ - Bit8u sum = 0; - for (i = 0;i < 32 * 1024;i++) //32 KB romsize - sum += phys_readb(rom_base + i); //OVERFLOW IS OKAY - sum = 256 - sum; - phys_writeb(rom_base+int10.rom.used++,sum); + //Reserve checksum location + checksumlocation = int10.rom.used++; } }; - +void INT10_SetupRomMemoryChecksum(void) { + if (machine == MCH_VGA) { //EGA/VGA. Just to be safe + /* Sum of all bytes in rom module 256 should be 0 */ + Bit8u sum = 0; + PhysPt rom_base = PhysMake(0xc000,0); + for (Bitu i = 0;i < 32 * 1024;i++) //32 KB romsize + sum += phys_readb(rom_base + i); //OVERFLOW IS OKAY + sum = 256 - sum; + phys_writeb(rom_base + checksumlocation,sum); + } +} Bit8u int10_font_08[256 * 8] = {