diff --git a/include/callback.h b/include/callback.h index 85b9d246..dab0609d 100644 --- a/include/callback.h +++ b/include/callback.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: callback.h,v 1.16 2006-02-09 11:47:47 qbix79 Exp $ */ +/* $Id: callback.h,v 1.17 2006-04-22 15:25:44 c2woody Exp $ */ #ifndef DOSBOX_CALLBACK_H #define DOSBOX_CALLBACK_H @@ -28,10 +28,10 @@ typedef Bitu (*CallBack_Handler)(void); extern CallBack_Handler CallBack_Handlers[]; -enum { CB_RETN, CB_RETF,CB_IRET,CB_IRET_STI }; +enum { CB_RETN,CB_RETF,CB_IRET,CB_IRETD,CB_IRET_STI,CB_IRET_EOI_PIC1,CB_HOOKABLE }; #define CB_MAX 144 -#define CB_SEG 0xC800 +#define CB_SEG 0xF100 #define CB_BASE (CB_SEG << 4) enum { @@ -42,6 +42,9 @@ extern Bit8u lastint; INLINE RealPt CALLBACK_RealPointer(Bitu callback) { return RealMake(CB_SEG,callback << 4); } +INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) { + return PhysMake(CB_SEG,callback << 4); +} Bitu CALLBACK_Allocate(); @@ -52,8 +55,7 @@ void CALLBACK_RunRealInt(Bit8u intnum); void CALLBACK_RunRealFar(Bit16u seg,Bit16u off); bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* description=0); -/* Returns with the size of the extra callback */ -Bitu CALLBACK_SetupExtra(Bitu callback, Bitu type, PhysPt physAddress); +Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr); const char* CALLBACK_GetDescription(Bitu callback); bool CALLBACK_Free(Bitu callback); @@ -78,7 +80,8 @@ public: CALLBACK_HandlerObject():installed(false),m_type(NONE){vectorhandler.installed=false;} ~CALLBACK_HandlerObject(); //Install and allocate a callback. - void Install(CallBack_Handler handler,Bitu type,const char* description=0); + void Install(CallBack_Handler handler,Bitu type,const char* description); + void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description); //Only allocate a callback number void Allocate(CallBack_Handler handler,const char* description=0); Bit16u Get_callback(){return m_callback;} diff --git a/src/cpu/callback.cpp b/src/cpu/callback.cpp index 91f13f49..e4900460 100644 --- a/src/cpu/callback.cpp +++ b/src/cpu/callback.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: callback.cpp,v 1.31 2006-02-12 23:28:21 harekiet Exp $ */ +/* $Id: callback.cpp,v 1.32 2006-04-22 15:25:44 c2woody Exp $ */ #include #include @@ -133,42 +133,6 @@ const char* CALLBACK_GetDescription(Bitu nr) { return CallBack_Description[nr]; }; -bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr) { - if (callback>=CB_MAX) return false; - switch (type) { - case CB_RETF: - phys_writeb(CB_BASE+(callback<<4)+0,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+(callback<<4)+1,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+(callback<<4)+2,callback); //The immediate word - phys_writeb(CB_BASE+(callback<<4)+4,(Bit8u)0xCB); //A RETF Instruction - break; - case CB_IRET: - phys_writeb(CB_BASE+(callback<<4)+0,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+(callback<<4)+1,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+(callback<<4)+2,callback); //The immediate word - phys_writeb(CB_BASE+(callback<<4)+4,(Bit8u)0xCF); //An IRET Instruction - break; - case CB_IRET_STI: - phys_writeb(CB_BASE+(callback<<4)+0,(Bit8u)0xFB); //STI - phys_writeb(CB_BASE+(callback<<4)+1,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+(callback<<4)+2,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+(callback<<4)+3,callback); //The immediate word - phys_writeb(CB_BASE+(callback<<4)+5,(Bit8u)0xCF); //An IRET Instruction - break; - default: - E_Exit("CALLBACK:Setup:Illegal type %d",type); - } - CallBack_Handlers[callback]=handler; - CALLBACK_SetDescription(callback,descr); - return true; -} - -void CALLBACK_RemoveSetup(Bitu callback) { - for (Bitu i = 0;i < 16;i++) { - phys_writeb(CB_BASE+(callback<<4)+i ,(Bit8u) 0x00); - } -} - Bitu CALLBACK_SetupExtra(Bitu callback, Bitu type, PhysPt physAddress) { if (callback>=CB_MAX) return 0; @@ -191,6 +155,13 @@ Bitu CALLBACK_SetupExtra(Bitu callback, Bitu type, PhysPt physAddress) { phys_writew(physAddress+2,callback); //The immediate word phys_writeb(physAddress+4,(Bit8u)0xCF); //An IRET Instruction return 5; + case CB_IRETD: + phys_writeb(physAddress+0,(Bit8u)0xFE); //GRP 4 + phys_writeb(physAddress+1,(Bit8u)0x38); //Extra Callback instruction + phys_writew(physAddress+2,callback); //The immediate word + phys_writeb(physAddress+4,(Bit8u)0x66); //An IRETD Instruction + phys_writeb(physAddress+5,(Bit8u)0xCF); + return 6; case CB_IRET_STI: phys_writeb(physAddress+0,(Bit8u)0xFB); //STI phys_writeb(physAddress+1,(Bit8u)0xFE); //GRP 4 @@ -198,12 +169,59 @@ Bitu CALLBACK_SetupExtra(Bitu callback, Bitu type, PhysPt physAddress) { phys_writew(physAddress+3, callback); //The immediate word phys_writeb(physAddress+5,(Bit8u)0xCF); //An IRET Instruction return 6; + case CB_IRET_EOI_PIC1: + phys_writeb(physAddress+0,(Bit8u)0xFE); //GRP 4 + phys_writeb(physAddress+1,(Bit8u)0x38); //Extra Callback instruction + phys_writew(physAddress+2,callback); //The immediate word + phys_writeb(physAddress+4,(Bit8u)0x50); // push ax + phys_writeb(physAddress+5,(Bit8u)0xb0); // mov al, 0x20 + phys_writeb(physAddress+6,(Bit8u)0x20); + phys_writeb(physAddress+7,(Bit8u)0xe6); // out 0x20, al + phys_writeb(physAddress+8,(Bit8u)0x20); + phys_writeb(physAddress+9,(Bit8u)0x58); // pop ax + phys_writeb(physAddress+10,(Bit8u)0xcf);//An IRET Instruction + return 11; + case CB_HOOKABLE: + phys_writeb(physAddress+0,(Bit8u)0xEB); //jump near + phys_writeb(physAddress+1,(Bit8u)0x03); //offset + phys_writeb(physAddress+2,(Bit8u)0x90); //NOP + phys_writeb(physAddress+3,(Bit8u)0x90); //NOP + phys_writeb(physAddress+4,(Bit8u)0x90); //NOP + phys_writeb(physAddress+5,(Bit8u)0xFE); //GRP 4 + phys_writeb(physAddress+6,(Bit8u)0x38); //Extra Callback instruction + phys_writew(physAddress+7,callback); //The immediate word + phys_writeb(physAddress+9,(Bit8u)0xCB); //A RETF Instruction + return 10; default: E_Exit("CALLBACK:Setup:Illegal type %d",type); } return 0; } +bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr) { + if (callback>=CB_MAX) return false; + CALLBACK_SetupExtra(callback,type,CB_BASE+(callback<<4)+0); + CallBack_Handlers[callback]=handler; + CALLBACK_SetDescription(callback,descr); + return true; +} + +Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr) { + if (callback>=CB_MAX) return 0; + Bitu csize=CALLBACK_SetupExtra(callback,type,addr); + if (csize>0) { + CallBack_Handlers[callback]=handler; + CALLBACK_SetDescription(callback,descr); + } + return csize; +} + +void CALLBACK_RemoveSetup(Bitu callback) { + for (Bitu i = 0;i < 16;i++) { + phys_writeb(CB_BASE+(callback<<4)+i ,(Bit8u) 0x00); + } +} + CALLBACK_HandlerObject::~CALLBACK_HandlerObject(){ if(!installed) return; if(m_type == CALLBACK_HandlerObject::SETUP) { @@ -233,6 +251,14 @@ void CALLBACK_HandlerObject::Install(CallBack_Handler handler,Bitu type,const ch CALLBACK_Setup(m_callback,handler,type,description); } else E_Exit("Allready installed"); } +void CALLBACK_HandlerObject::Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description){ + if(!installed) { + installed=true; + m_type=SETUP; + m_callback=CALLBACK_Allocate(); + CALLBACK_Setup(m_callback,handler,type,addr,description); + } else E_Exit("Allready installed"); +} void CALLBACK_HandlerObject::Allocate(CallBack_Handler handler,const char* description) { if(!installed) { installed=true; @@ -291,7 +317,9 @@ void CALLBACK_Init(Section* sec) { rint_base+=6; } + // setup a few interrupt handlers that point to bios IRETs by default real_writed(0,0x67*4,CALLBACK_RealPointer(call_default)); + real_writed(0,0x68*4,CALLBACK_RealPointer(call_default)); real_writed(0,0x5c*4,CALLBACK_RealPointer(call_default)); //Network stuff //real_writed(0,0xf*4,0); some games don't like it diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index 506494e0..15185c96 100644 --- a/src/ints/bios.cpp +++ b/src/ints/bios.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: bios.cpp,v 1.57 2006-02-09 11:47:55 qbix79 Exp $ */ +/* $Id: bios.cpp,v 1.58 2006-04-22 15:25:45 c2woody Exp $ */ #include "dosbox.h" #include "mem.h" @@ -818,19 +818,8 @@ public: /* INT 8 Clock IRQ Handler */ //TODO Maybe give this a special callback that will also call int 8 instead of starting //a new system - callback[0].Install(INT8_Handler,CB_IRET,"Int 8 Clock"); + callback[0].Install(INT8_Handler,CB_IRET_EOI_PIC1,"Int 8 Clock"); callback[0].Set_RealVec(0x8); - Bit16u call_int8=callback[0].Get_callback(); - phys_writeb(CB_BASE+(call_int8<<4)+0,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+(call_int8<<4)+1,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+(call_int8<<4)+2,call_int8); //The immediate word - phys_writeb(CB_BASE+(call_int8<<4)+4,(Bit8u)0x50); // push ax - phys_writeb(CB_BASE+(call_int8<<4)+5,(Bit8u)0xb0); // mov al, 0x20 - phys_writeb(CB_BASE+(call_int8<<4)+6,(Bit8u)0x20); - phys_writeb(CB_BASE+(call_int8<<4)+7,(Bit8u)0xe6); // out 0x20, al - phys_writeb(CB_BASE+(call_int8<<4)+8,(Bit8u)0x20); - phys_writeb(CB_BASE+(call_int8<<4)+9,(Bit8u)0x58); // pop ax - phys_writeb(CB_BASE+(call_int8<<4)+10,(Bit8u)0xcf); // iret mem_writed(BIOS_TIMER,0); //Calculate the correct time diff --git a/src/ints/bios_disk.cpp b/src/ints/bios_disk.cpp index 90c76b8d..3c2f2695 100644 --- a/src/ints/bios_disk.cpp +++ b/src/ints/bios_disk.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: bios_disk.cpp,v 1.28 2006-04-09 13:03:24 c2woody Exp $ */ +/* $Id: bios_disk.cpp,v 1.29 2006-04-22 15:25:45 c2woody Exp $ */ #include "dosbox.h" #include "callback.h" @@ -63,24 +63,26 @@ Bits swapPosition; void updateDPT(void) { Bit32u tmpheads, tmpcyl, tmpsect, tmpsize; if(imageDiskList[2] != NULL) { + PhysPt dp0physaddr=CALLBACK_PhysPointer(diskparm0); imageDiskList[2]->Get_Geometry(&tmpheads, &tmpcyl, &tmpsect, &tmpsize); - real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0)),tmpcyl); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+2,tmpheads); - real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x3,0); - real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x5,(Bit16u)-1); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x7,0); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x8,(0xc0 | (((imageDiskList[2]->heads) > 8) << 3))); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x9,0); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xa,0); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xb,0); - real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xc,tmpcyl); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xe,tmpsect); + phys_writew(dp0physaddr,tmpcyl); + phys_writeb(dp0physaddr+0x2,tmpheads); + phys_writew(dp0physaddr+0x3,0); + phys_writew(dp0physaddr+0x5,(Bit16u)-1); + phys_writeb(dp0physaddr+0x7,0); + phys_writeb(dp0physaddr+0x8,(0xc0 | (((imageDiskList[2]->heads) > 8) << 3))); + phys_writeb(dp0physaddr+0x9,0); + phys_writeb(dp0physaddr+0xa,0); + phys_writeb(dp0physaddr+0xb,0); + phys_writew(dp0physaddr+0xc,tmpcyl); + phys_writeb(dp0physaddr+0xe,tmpsect); } if(imageDiskList[3] != NULL) { + PhysPt dp1physaddr=CALLBACK_PhysPointer(diskparm1); imageDiskList[3]->Get_Geometry(&tmpheads, &tmpcyl, &tmpsect, &tmpsize); - real_writew(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1)),tmpcyl); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+2,tmpheads); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+0xe,tmpsect); + phys_writew(dp1physaddr,tmpcyl); + phys_writeb(dp1physaddr+0x2,tmpheads); + phys_writeb(dp1physaddr+0xe,tmpsect); } } @@ -488,9 +490,11 @@ void BIOS_SetupDisks(void) { RealSetVec(0x41,CALLBACK_RealPointer(diskparm0)); RealSetVec(0x46,CALLBACK_RealPointer(diskparm1)); + PhysPt dp0physaddr=CALLBACK_PhysPointer(diskparm0); + PhysPt dp1physaddr=CALLBACK_PhysPointer(diskparm1); for(i=0;i<16;i++) { - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+i,0); - real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+i,0); + phys_writeb(dp0physaddr+i,0); + phys_writeb(dp1physaddr+i,0); } imgDTASeg = 0; diff --git a/src/ints/ems.cpp b/src/ints/ems.cpp index 0ae57537..1493b3d6 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.50 2006-04-18 13:52:24 qbix79 Exp $ */ +/* $Id: ems.cpp,v 1.51 2006-04-22 15:25:45 c2woody Exp $ */ #include #include @@ -721,12 +721,17 @@ static Bitu INT67_Handler(void) { 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) - real_writed(SegValue(ds),reg_si+0x04,0x00009a0c); // descriptor 1 - real_writed(SegValue(ds),reg_si+0x08,0x0000ffff); // descriptor 2 (data segment) - real_writed(SegValue(ds),reg_si+0x0c,0x00009200); // descriptor 2 - real_writed(SegValue(ds),reg_si+0x10,0x0000ffff); // descriptor 3 - real_writed(SegValue(ds),reg_si+0x14,0x00009200); // descriptor 3 + Bit32u cbseg_low=(CB_BASE&0xffff)<<16; + Bit32u cbseg_high=(CB_BASE&0x1f0000)>>16; + /* Descriptor 1 (code segment, callback segment) */ + real_writed(SegValue(ds),reg_si+0x00,0x0000ffff|cbseg_low); + real_writed(SegValue(ds),reg_si+0x04,0x00009a00|cbseg_high); + /* Descriptor 2 (data segment, full access) */ + real_writed(SegValue(ds),reg_si+0x08,0x0000ffff); + real_writed(SegValue(ds),reg_si+0x0c,0x00009200); + /* Descriptor 3 (full access) */ + real_writed(SegValue(ds),reg_si+0x10,0x0000ffff); + real_writed(SegValue(ds),reg_si+0x14,0x00009200); reg_ebx=(vcpi.pm_interface&0xffff); reg_ah=EMM_NO_ERROR; @@ -1185,13 +1190,9 @@ public: if (!ENABLE_VCPI) return; /* Install a callback that handles VCPI-requests in protected mode requests */ - call_vcpi.Install(&VCPI_PM_Handler,CB_RETF,"VCPI PM"); + call_vcpi.Install(&VCPI_PM_Handler,CB_IRETD,"VCPI PM"); vcpi.pm_interface=(call_vcpi.Get_callback())<<4; - /* Use IRETD instead of IRET for this protected mode callback */ - mem_writeb(CB_BASE+vcpi.pm_interface+4,(Bit8u)0x66); - mem_writeb(CB_BASE+vcpi.pm_interface+5,(Bit8u)0xCB); //A IRETD Instruction - /* Initialize private data area and set up descriptor tables */ SetupVCPI(); diff --git a/src/ints/int10_vesa.cpp b/src/ints/int10_vesa.cpp index 0330efa2..43792237 100644 --- a/src/ints/int10_vesa.cpp +++ b/src/ints/int10_vesa.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: int10_vesa.cpp,v 1.23 2006-02-12 23:06:15 harekiet Exp $ */ +/* $Id: int10_vesa.cpp,v 1.24 2006-04-22 15:25:45 c2woody Exp $ */ #include #include @@ -443,20 +443,17 @@ void INT10_SetupVESA(void) { int10.rom.pmode_interface_window = int10.rom.used - RealOff( int10.rom.pmode_interface ); phys_writew( Real2Phys(int10.rom.pmode_interface) + 0, int10.rom.pmode_interface_window ); callback.pmWindow=CALLBACK_Allocate(); - CALLBACK_Setup(callback.pmWindow, VESA_PMSetWindow, CB_RETF, "VESA PM Set Window"); - int10.rom.used += CALLBACK_SetupExtra( callback.pmWindow, CB_RETN, PhysMake(0xc000,int10.rom.used)); + int10.rom.used += CALLBACK_Setup(callback.pmWindow, VESA_PMSetWindow, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Window"); /* PM Set start call */ int10.rom.pmode_interface_start = int10.rom.used - RealOff( int10.rom.pmode_interface ); phys_writew( Real2Phys(int10.rom.pmode_interface) + 2, int10.rom.pmode_interface_start); callback.pmStart=CALLBACK_Allocate(); - CALLBACK_Setup(callback.pmStart, VESA_PMSetStart, CB_RETF, "VESA PM Set Start"); - int10.rom.used += CALLBACK_SetupExtra( callback.pmStart, CB_RETN, PhysMake(0xc000,int10.rom.used)); + int10.rom.used += CALLBACK_Setup(callback.pmStart, VESA_PMSetStart, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Start"); /* PM Set Palette call */ int10.rom.pmode_interface_palette = int10.rom.used - RealOff( int10.rom.pmode_interface ); phys_writew( Real2Phys(int10.rom.pmode_interface) + 4, int10.rom.pmode_interface_palette); callback.pmPalette=CALLBACK_Allocate(); - CALLBACK_Setup(callback.pmPalette, VESA_PMSetPalette, CB_RETF, "VESA PM Set Palette"); - int10.rom.used += CALLBACK_SetupExtra( callback.pmPalette, CB_RETN, PhysMake(0xc000,int10.rom.used)); + int10.rom.used += CALLBACK_Setup(callback.pmPalette, VESA_PMSetPalette, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Palette"); /* Finalize the size and clear the required ports pointer */ phys_writew( Real2Phys(int10.rom.pmode_interface) + 6, 0); int10.rom.pmode_interface_size=int10.rom.used - RealOff( int10.rom.pmode_interface ); diff --git a/src/ints/mouse.cpp b/src/ints/mouse.cpp index f0639d5d..257b85c9 100644 --- a/src/ints/mouse.cpp +++ b/src/ints/mouse.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: mouse.cpp,v 1.61 2006-02-13 07:48:25 qbix79 Exp $ */ +/* $Id: mouse.cpp,v 1.62 2006-04-22 15:25:45 c2woody Exp $ */ #include #include @@ -905,46 +905,26 @@ static Bitu INT74_Handler(void) { return CBRET_NONE; } -void WriteMouseIntVector(void) -{ - // Create a mouse vector with weird address - // for strange mouse detection routines in Sim City & Wasteland - real_writed(0,0x33<<2,RealMake(CB_SEG+1,(call_int33<<4)-0x10+1)); // +1 = Skip NOP -}; - -void CreateMouseCallback(void) -{ - // Create callback - call_int33=CALLBACK_Allocate(); - CALLBACK_Setup(call_int33,&INT33_Handler,CB_IRET,"Mouse"); - - // Create a mouse vector with weird address - // for strange mouse detection routines in Sim City & Wasteland - Bit16u ofs = call_int33<<4; - phys_writeb(CB_BASE+ofs+0,(Bit8u)0x90); //NOP - phys_writeb(CB_BASE+ofs+1,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+ofs+2,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+ofs+3,call_int33); //The immediate word - phys_writeb(CB_BASE+ofs+5,(Bit8u)0xCF); //An IRET Instruction - // Write weird vector - WriteMouseIntVector(); -}; - void MOUSE_Init(Section* sec) { - // Callback 0x33 - CreateMouseCallback(); + // Callback for mouse interrupt 0x33 + call_int33=CALLBACK_Allocate(); + CALLBACK_Setup(call_int33,&INT33_Handler,CB_IRET,"Mouse"); + // Wasteland needs low(seg(int33))!=0 and low(ofs(int33))!=0 + real_writed(0,0x33<<2,RealMake(CB_SEG+1,(call_int33<<4)-0x10)); + + // Callback for ps2 irq call_int74=CALLBACK_Allocate(); CALLBACK_Setup(call_int74,&INT74_Handler,CB_IRET,"int 74"); - if(MOUSE_IRQ > 7) { - real_writed(0,((0x70+MOUSE_IRQ-8)<<2),CALLBACK_RealPointer(call_int74)); - } else { - real_writed(0,((0x8+MOUSE_IRQ)<<2),CALLBACK_RealPointer(call_int74)); - } + Bit8u hwvec=(MOUSE_IRQ>7)?(0x70+MOUSE_IRQ-8):(0x8+MOUSE_IRQ); + RealSetVec(hwvec,CALLBACK_RealPointer(call_int74)); + + // Callback for ps2 user callback handling useps2callback = false; ps2callbackinit = false; call_ps2=CALLBACK_Allocate(); CALLBACK_Setup(call_ps2,&PS2_Handler,CB_IRET,"ps2 bios callback"); ps2_callback=CALLBACK_RealPointer(call_ps2); + memset(&mouse,0,sizeof(mouse)); mouse.shown=-1; //Hide mouse on startup mouse_reset_hardware(); diff --git a/src/ints/xms.cpp b/src/ints/xms.cpp index 3e367bbf..8dca90ce 100644 --- a/src/ints/xms.cpp +++ b/src/ints/xms.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: xms.cpp,v 1.40 2006-04-14 13:53:58 qbix79 Exp $ */ +/* $Id: xms.cpp,v 1.41 2006-04-22 15:25:45 c2woody Exp $ */ #include #include @@ -413,20 +413,9 @@ public: Bitu i; BIOS_ZeroExtendedSize(true); DOS_AddMultiplexHandler(multiplex_xms); - callbackhandler.Install(&XMS_Handler,CB_RETF, "XMS Handler"); - xms_callback=callbackhandler.Get_RealPointer(); - Bit16u call_xms=callbackhandler.Get_callback(); - - /* Override the callback with one that can be hooked */ - phys_writeb(CB_BASE+(call_xms<<4)+0,(Bit8u)0xeb); //jump near - phys_writeb(CB_BASE+(call_xms<<4)+1,(Bit8u)0x03); //offset - phys_writeb(CB_BASE+(call_xms<<4)+2,(Bit8u)0x90); //NOP - phys_writeb(CB_BASE+(call_xms<<4)+3,(Bit8u)0x90); //NOP - phys_writeb(CB_BASE+(call_xms<<4)+4,(Bit8u)0x90); //NOP - phys_writeb(CB_BASE+(call_xms<<4)+5,(Bit8u)0xFE); //GRP 4 - phys_writeb(CB_BASE+(call_xms<<4)+6,(Bit8u)0x38); //Extra Callback instruction - phys_writew(CB_BASE+(call_xms<<4)+7,call_xms); //The immediate word - phys_writeb(CB_BASE+(call_xms<<4)+9,(Bit8u)0xCB); //A RETF Instruction + /* place hookable callback in writable memory area */ + xms_callback=RealMake(DOS_GetMemory(0x1),0); + callbackhandler.Install(&XMS_Handler,CB_HOOKABLE,Real2Phys(xms_callback),"XMS Handler"); for (i=0;i