1
0
Fork 0

Acknowledge mouse interrupt before entering user routine; fixes sound stutter during mouse movement in Eye of the Beholder III and Casino Tournament of Champions. Clear button counters in the mouse driver reset function; prevents unintended skipping of intro in MechWarrior and others.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4188
This commit is contained in:
ripsaw8080 2019-02-04 15:15:58 +00:00
parent d4c38121c9
commit 64d25c4be4
4 changed files with 85 additions and 34 deletions

View file

@ -36,8 +36,8 @@
static Bitu call_int33,call_int74,int74_ret_callback,call_mouse_bd;
static Bit16u ps2cbseg,ps2cbofs;
static bool useps2callback,ps2callbackinit;
static Bitu call_ps2;
static RealPt ps2_callback;
static Bitu call_ps2,call_uir;
static RealPt ps2_callback,uir_callback;
static Bit16s oldmouseX, oldmouseY;
// forward
void WriteMouseIntVector(void);
@ -698,6 +698,15 @@ static void Mouse_Reset(void) {
mouse.mickey_x = 0;
mouse.mickey_y = 0;
for (Bit16u but=0; but<MOUSE_BUTTONS; but++) {
mouse.times_pressed[but] = 0;
mouse.times_released[but] = 0;
mouse.last_pressed_x[but] = 0;
mouse.last_pressed_y[but] = 0;
mouse.last_released_x[but] = 0;
mouse.last_released_y[but] = 0;
}
// Dont set max coordinates here. it is done by SetResolution!
mouse.x = static_cast<float>((mouse.max_x + 1)/ 2);
mouse.y = static_cast<float>((mouse.max_y + 1)/ 2);
@ -1030,7 +1039,7 @@ static Bitu MOUSE_BD_Handler(void) {
}
static Bitu INT74_Handler(void) {
if (mouse.events>0) {
if (mouse.events>0 && !mouse.in_UIR) {
mouse.events--;
/* Check for an active Interrupt Handler that will get called */
if (mouse.sub_mask & mouse.event_queue[mouse.events].type) {
@ -1041,10 +1050,11 @@ static Bitu INT74_Handler(void) {
reg_si=static_cast<Bit16s>(mouse.mickey_x);
reg_di=static_cast<Bit16s>(mouse.mickey_y);
CPU_Push16(RealSeg(CALLBACK_RealPointer(int74_ret_callback)));
CPU_Push16(RealOff(CALLBACK_RealPointer(int74_ret_callback)));
SegSet16(cs, mouse.sub_seg);
reg_ip = mouse.sub_ofs;
if(mouse.in_UIR) LOG(LOG_MOUSE,LOG_ERROR)("Already in UIR!");
CPU_Push16(RealOff(CALLBACK_RealPointer(int74_ret_callback))+7);
CPU_Push16(RealSeg(uir_callback));
CPU_Push16(RealOff(uir_callback));
CPU_Push16(mouse.sub_seg);
CPU_Push16(mouse.sub_ofs);
mouse.in_UIR = true;
//LOG(LOG_MOUSE,LOG_ERROR)("INT 74 %X",mouse.event_queue[mouse.events].type );
} else if (useps2callback) {
@ -1064,8 +1074,7 @@ static Bitu INT74_Handler(void) {
return CBRET_NONE;
}
Bitu MOUSE_UserInt_CB_Handler(void) {
mouse.in_UIR = false;
Bitu INT74_Ret_Handler(void) {
if (mouse.events) {
if (!mouse.timer_in_progress) {
mouse.timer_in_progress = true;
@ -1075,6 +1084,11 @@ Bitu MOUSE_UserInt_CB_Handler(void) {
return CBRET_NONE;
}
Bitu UIR_Handler(void) {
mouse.in_UIR = false;
return CBRET_NONE;
}
void MOUSE_Init(Section* /*sec*/) {
// Callback for mouse interrupt 0x33
call_int33=CALLBACK_Allocate();
@ -1100,22 +1114,29 @@ void MOUSE_Init(Section* /*sec*/) {
call_int74=CALLBACK_Allocate();
CALLBACK_Setup(call_int74,&INT74_Handler,CB_IRQ12,"int 74");
// pseudocode for CB_IRQ12:
// sti
// push ds
// push es
// pushad
// sti
// callback INT74_Handler
// doesn't return here, but rather to CB_IRQ12_RET
// (ps2 callback/user callback inbetween if requested)
// ps2 or user callback if requested
// otherwise jumps to CB_IRQ12_RET
// push ax
// mov al, 0x20
// out 0xa0, al
// out 0x20, al
// pop ax
// cld
// retf
int74_ret_callback=CALLBACK_Allocate();
CALLBACK_Setup(int74_ret_callback,&MOUSE_UserInt_CB_Handler,CB_IRQ12_RET,"int 74 ret");
CALLBACK_Setup(int74_ret_callback,&INT74_Ret_Handler,CB_IRQ12_RET,"int 74 ret");
// pseudocode for CB_IRQ12_RET:
// callback MOUSE_UserInt_CB_Handler
// cli
// mov al, 0x20
// out 0xa0, al
// out 0x20, al
// callback INT74_Ret_Handler
// popad
// pop es
// pop ds
@ -1130,6 +1151,11 @@ void MOUSE_Init(Section* /*sec*/) {
CALLBACK_Setup(call_ps2,&PS2_Handler,CB_RETF,"ps2 bios callback");
ps2_callback=CALLBACK_RealPointer(call_ps2);
// Callback for mouse user routine return
call_uir=CALLBACK_Allocate();
CALLBACK_Setup(call_uir,&UIR_Handler,CB_RETF_CLI,"mouse uir ret");
uir_callback=CALLBACK_RealPointer(call_uir);
memset(&mouse,0,sizeof(mouse));
mouse.hidden = 1; //Hide mouse on startup
mouse.timer_in_progress = false;