From 37d91eea182ded2fa70b7ecd8fb35a6e3664c50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Wed, 21 Sep 2005 11:37:35 +0000 Subject: [PATCH] update ps2 mouse; fix mousecursor in mode13 Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2317 --- include/mouse.h | 4 ++-- src/ints/bios.cpp | 36 +++++++++++++++++++++++------------- src/ints/mouse.cpp | 36 +++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/include/mouse.h b/include/mouse.h index 99c7ffd5..891e3a55 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: mouse.h,v 1.9 2005-03-24 10:32:09 qbix79 Exp $ */ +/* $Id: mouse.h,v 1.10 2005-09-21 11:37:35 c2woody Exp $ */ #ifndef DOSBOX_MOUSE_H #define DOSBOX_MOUSE_H @@ -24,7 +24,7 @@ void Mouse_ShowCursor(void); void Mouse_HideCursor(void); -void Mouse_SetPS2State(bool use); +bool Mouse_SetPS2State(bool use); void Mouse_ChangePS2Callback(Bit16u pseg, Bit16u pofs); void Mouse_CursorMoved(float x,float y); diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index c8de907c..1abdfef9 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.45 2005-09-11 13:06:00 qbix79 Exp $ */ +/* $Id: bios.cpp,v 1.46 2005-09-21 11:37:35 c2woody Exp $ */ #include "dosbox.h" #include "mem.h" @@ -520,20 +520,27 @@ static Bitu INT15_Handler(void) { reg_ah=0; CALLBACK_SCF(false); } else if (reg_bh==0x01) { //enable - Mouse_SetPS2State(true); + if (!Mouse_SetPS2State(true)) { + reg_ah=5; + CALLBACK_SCF(true); + break; + } reg_ah=0; CALLBACK_SCF(false); - } else CALLBACK_SCF(true); + } else { + CALLBACK_SCF(true); + reg_ah=1; + } break; case 0x01: // reset - Mouse_SetPS2State(false); reg_bx=0x00aa; // mouse - CALLBACK_SCF(false); - break; - case 0x02: // set sampling rate + // fall through + case 0x05: // initialize + Mouse_SetPS2State(false); CALLBACK_SCF(false); reg_ah=0; break; + case 0x02: // set sampling rate case 0x03: // set resolution CALLBACK_SCF(false); reg_ah=0; @@ -543,20 +550,23 @@ static Bitu INT15_Handler(void) { CALLBACK_SCF(false); reg_ah=0; break; - case 0x05: // initialize - CALLBACK_SCF(false); - reg_ah=0; - break; case 0x06: // extended commands - if ((reg_bh==0x01) || (reg_bh==0x02)) { CALLBACK_SCF(false); reg_ah=0;} - else CALLBACK_SCF(true); + if ((reg_bh==0x01) || (reg_bh==0x02)) { + CALLBACK_SCF(false); + reg_ah=0; + } else { + CALLBACK_SCF(true); + reg_ah=1; + } break; case 0x07: // set callback Mouse_ChangePS2Callback(SegValue(es),reg_bx); CALLBACK_SCF(false); + reg_ah=0; break; default: CALLBACK_SCF(true); + reg_ah=1; break; } break; diff --git a/src/ints/mouse.cpp b/src/ints/mouse.cpp index ec1f1195..8fa4c3d3 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.53 2005-09-13 18:44:45 qbix79 Exp $ */ +/* $Id: mouse.cpp,v 1.54 2005-09-21 11:37:35 c2woody Exp $ */ #include #include @@ -36,7 +36,7 @@ static Bitu call_int33,call_int74; static Bit16u ps2cbseg,ps2cbofs; -static bool useps2callback; +static bool useps2callback,ps2callbackinit; static Bit16u call_ps2; static RealPt ps2_callback; static Bit16s oldmouseX, oldmouseY; @@ -121,19 +121,28 @@ static struct { Bit16s oldshown; } mouse; -void Mouse_SetPS2State(bool use) { - if ((SegValue(es)!=0) && (reg_bx!=0)) useps2callback = use; - else useps2callback = false; +bool Mouse_SetPS2State(bool use) { + if (use && (!ps2callbackinit)) { + useps2callback = false; + PIC_SetIRQMask(MOUSE_IRQ,true); + return false; + } + useps2callback = use; Mouse_AutoLock(useps2callback); PIC_SetIRQMask(MOUSE_IRQ,!useps2callback); + return true; } void Mouse_ChangePS2Callback(Bit16u pseg, Bit16u pofs) { - if ((pseg==0) && (pofs==0)) useps2callback = false; - else useps2callback = true; - ps2cbseg = pseg; - ps2cbofs = pofs; - Mouse_AutoLock(useps2callback); + if ((pseg==0) && (pofs==0)) { + ps2callbackinit = false; + Mouse_AutoLock(false); + } else { + ps2callbackinit = true; + ps2cbseg = pseg; + ps2cbofs = pofs; + } + Mouse_AutoLock(ps2callbackinit); } void DoPS2Callback(Bit16u data, Bit16s mouseX, Bit16s mouseY) { @@ -247,8 +256,8 @@ void SaveVgaRegisters() gfxReg[i] = IO_Read(0x3CF); } /* Setup some default values in GFX regs that should work */ - IO_Write (0x3CE,3);IO_Write(0x3Cf,0); //disable rotate and operation - IO_Write (0x3CE,5);IO_Write(0x3Cf,0); //Force read/write mode 0 + IO_Write(0x3CE,3); IO_Write(0x3Cf,0); //disable rotate and operation + IO_Write(0x3CE,5); IO_Write(0x3Cf,gfxReg[5]&0xf0); //Force read/write mode 0 } void RestoreVgaRegisters() @@ -398,6 +407,7 @@ void Mouse_CursorMoved(float x,float y) { if((fabs(x) > 1.0) || (mouse.senv_x < 1.0)) dx *= mouse.senv_x; if((fabs(y) > 1.0) || (mouse.senv_y < 1.0)) dy *= mouse.senv_y; + if (useps2callback) dy *= 2; mouse.mickey_x += dx; mouse.mickey_y += dy; @@ -916,7 +926,7 @@ void MOUSE_Init(Section* sec) { } else { real_writed(0,((0x8+MOUSE_IRQ)<<2),CALLBACK_RealPointer(call_int74)); } - useps2callback = false; + 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);