From 406935348a1e8aff5334de23a22e9c6af6039c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Sat, 3 Sep 2005 11:38:18 +0000 Subject: [PATCH] fix Inner Worlds (vasyl) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2299 --- include/paging.h | 10 +++++++++- src/hardware/vga_memory.cpp | 30 +++++++++++++++--------------- src/ints/ems.cpp | 12 ++++++------ 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/paging.h b/include/paging.h index 2839ba78..f7597265 100644 --- a/include/paging.h +++ b/include/paging.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: paging.h,v 1.16 2005-03-25 11:41:26 qbix79 Exp $ */ +/* $Id: paging.h,v 1.17 2005-09-03 11:38:18 c2woody Exp $ */ #ifndef DOSBOX_PAGING_H #define DOSBOX_PAGING_H @@ -131,6 +131,14 @@ extern PagingBlock paging; PageHandler * MEM_GetPageHandler(Bitu phys_page); +/* Use this helper function to access linear addresses in readX/writeX functions */ +INLINE PhysPt PAGING_GetLinearAddress(PhysPt addr) { + if (paging.enabled) + return (paging.tlb.phys_page[addr>>12]<<12)|(addr&0xfff); + else + return addr; +} + /* Unaligned address handlers */ Bit16u mem_unalignedreadw(PhysPt address); Bit32u mem_unalignedreadd(PhysPt address); diff --git a/src/hardware/vga_memory.cpp b/src/hardware/vga_memory.cpp index a3af1e60..73a0e181 100644 --- a/src/hardware/vga_memory.cpp +++ b/src/hardware/vga_memory.cpp @@ -138,17 +138,17 @@ static struct { class VGARead_PageHandler : public PageHandler { public: Bitu readb(PhysPt addr) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; return VGA_NormalReadHandler(addr); } Bitu readw(PhysPt addr) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; return (VGA_NormalReadHandler(addr+0) << 0) | (VGA_NormalReadHandler(addr+1) << 8); } Bitu readd(PhysPt addr) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; return (VGA_NormalReadHandler(addr+0) << 0) | (VGA_NormalReadHandler(addr+1) << 8) | @@ -163,16 +163,16 @@ public: flags=PFLAG_NOCODE; } void writeb(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_16_WriteHandler(addr+0,(Bit8u)(val >> 0)); } void writew(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_16_WriteHandler(addr+0,(Bit8u)(val >> 0)); VGA_GFX_16_WriteHandler(addr+1,(Bit8u)(val >> 8)); } void writed(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_16_WriteHandler(addr+0,(Bit8u)(val >> 0)); VGA_GFX_16_WriteHandler(addr+1,(Bit8u)(val >> 8)); VGA_GFX_16_WriteHandler(addr+2,(Bit8u)(val >> 16)); @@ -186,16 +186,16 @@ public: flags=PFLAG_NOCODE; } void writeb(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_256U_WriteHandler(addr+0,(Bit8u)(val >> 0)); } void writew(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_256U_WriteHandler(addr+0,(Bit8u)(val >> 0)); VGA_GFX_256U_WriteHandler(addr+1,(Bit8u)(val >> 8)); } void writed(PhysPt addr,Bitu val) { - addr&=0xffff; + addr = PAGING_GetLinearAddress(addr) & 0xffff; VGA_GFX_256U_WriteHandler(addr+0,(Bit8u)(val >> 0)); VGA_GFX_256U_WriteHandler(addr+1,(Bit8u)(val >> 8)); VGA_GFX_256U_WriteHandler(addr+2,(Bit8u)(val >> 16)); @@ -209,11 +209,11 @@ public: flags=PFLAG_NOCODE; } Bitu readb(PhysPt addr) { - addr&=vgapages.mask; + addr = PAGING_GetLinearAddress(addr) & vgapages.mask; return vga.draw.font[addr]; } void writeb(PhysPt addr,Bitu val){ - addr&=vgapages.mask; + addr = PAGING_GetLinearAddress(addr) & vgapages.mask; if (vga.seq.map_mask & 0x4) { vga.draw.font[addr]=(Bit8u)val; } @@ -240,7 +240,7 @@ public: //memset(®mem[0], 0, sizeof(regmem)); } void writeb(PhysPt addr,Bitu val) { - Bitu port = addr & 0xffff; + Bitu port = PAGING_GetLinearAddress(addr) & 0xffff; if(port >= 0x82E8) IO_WriteB(port, val); if(port <= 0x4000) { if(port == 0x0000) { @@ -252,7 +252,7 @@ public: //LOG_MSG("MMIO: Write byte to %x with %x", addr, val); } void writew(PhysPt addr,Bitu val) { - Bitu port = addr & 0xffff; + Bitu port = PAGING_GetLinearAddress(addr) & 0xffff; if(port >= 0x82E8) IO_WriteW(port, val); if(port == 0x8118) IO_WriteW(0x9ae8, val); if(port <= 0x4000) { @@ -265,7 +265,7 @@ public: //LOG_MSG("MMIO: Write word to %x with %x", addr, val); } void writed(PhysPt addr,Bitu val) { - Bitu port = addr & 0xffff; + Bitu port = PAGING_GetLinearAddress(addr) & 0xffff; if(port >= 0x82E8) IO_WriteD(port, val); if(port == 0x8100) { IO_WriteW(0x86e8, (val >> 16)); @@ -294,7 +294,7 @@ public: return 0x00; } Bitu readw(PhysPt addr) { - Bitu port = addr & 0xffff; + Bitu port = PAGING_GetLinearAddress(addr) & 0xffff; if(port >= 0x82E8) return IO_ReadW(port); //LOG_MSG("MMIO: Read word from %x", addr); return 0x00; diff --git a/src/ints/ems.cpp b/src/ints/ems.cpp index e00c2cff..94effec0 100644 --- a/src/ints/ems.cpp +++ b/src/ints/ems.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: ems.cpp,v 1.42 2005-08-15 13:43:44 c2woody Exp $ */ +/* $Id: ems.cpp,v 1.43 2005-09-03 11:38:18 c2woody Exp $ */ #include #include @@ -613,17 +613,17 @@ static Bitu INT67_Handler(void) { break; case 0x01: /* VCPI Get Protected Mode Interface */ /* Set up page table buffer */ - for (Bitu ct=0; ct<0xff; ct++) { + for (Bit16u ct=0; ct<0xff; ct++) { real_writeb(SegValue(es),reg_di+ct*4+0x00,0x67); // access bits - real_writew(SegValue(es),reg_di+ct*4+0x01,ct*0x10); // mapping + real_writew(SegValue(es),reg_di+ct*4+0x01,ct*0x10); // mapping real_writeb(SegValue(es),reg_di+ct*4+0x03,0x00); } - for (Bitu ct=0xff; ct<0x100; ct++) { + for (Bit16u ct=0xff; ct<0x100; ct++) { real_writeb(SegValue(es),reg_di+ct*4+0x00,0x67); // access bits real_writew(SegValue(es),reg_di+ct*4+0x01,(ct-0xff)*0x10+0x1100); // mapping real_writeb(SegValue(es),reg_di+ct*4+0x03,0x00); } - reg_di+=0x800; // advance pointer by 0x200*4 + reg_di+=0x400; // advance pointer by 0x100*4 /* Set up three descriptor table entries */ real_writed(SegValue(ds),reg_si+0x00,0x8000ffff); // descriptor 1 (code segment) @@ -991,7 +991,7 @@ static void SetupVCPI() { mem_writed(vcpi.private_area+0x1014,ds_desc_part); // descriptor 2 /* IDT setup */ - for (Bitu int_ct=0; int_ct<0x100; int_ct++) { + for (Bit16u int_ct=0; int_ct<0x100; int_ct++) { /* build a CALL NEAR V86MON, the value of IP pushed by the CALL is used to identify the interrupt number */ mem_writeb(vcpi.private_area+0x2800+int_ct*4+0,0xe8); // call