Bitu IO_ReadD(Bitu port) { if (GCC_UNLIKELY(GETFLAG(VM) && (CPU_IO_Exception(port,4)))) { LazyFlags old_lflags; memcpy(&old_lflags,&lflags,sizeof(LazyFlags)); CPU_Decoder * old_cpudecoder; old_cpudecoder=cpudecoder; cpudecoder=&IOFaultCore; IOF_Entry * entry=&iof_queue.entries[iof_queue.used++]; entry->cs=SegValue(cs); entry->eip=reg_eip; CPU_Push16(SegValue(cs)); CPU_Push16(reg_ip); Bit16u old_dx = reg_dx; reg_dx = port; RealPt icb = CALLBACK_RealPointer(call_priv_io); SegSet16(cs,RealSeg(icb)); reg_eip = RealOff(icb)+0x04; CPU_Exception(cpu.exception.which,cpu.exception.error); DOSBOX_RunMachine(); iof_queue.used--; Bitu retval = reg_eax; reg_dx = old_dx; memcpy(&lflags,&old_lflags,sizeof(LazyFlags)); cpudecoder=old_cpudecoder; return retval; } else return io_readhandlers[2][port](port,4); }
static Bitu INT74_Handler(void) { if (mouse.events>0) { mouse.events--; /* Check for an active Interrupt Handler that will get called */ if (mouse.sub_mask & mouse.event_queue[mouse.events].type) { reg_ax=mouse.event_queue[mouse.events].type; reg_bx=mouse.event_queue[mouse.events].buttons; reg_cx=POS_X; reg_dx=POS_Y; reg_si=(Bit16s)(mouse.mickey_x*mouse.mickeysPerPixel_x); reg_di=(Bit16s)(mouse.mickey_y*mouse.mickeysPerPixel_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!"); mouse.in_UIR = true; } else if (useps2callback) { CPU_Push16(RealSeg(CALLBACK_RealPointer(int74_ret_callback))); CPU_Push16(RealOff(CALLBACK_RealPointer(int74_ret_callback))); DoPS2Callback(mouse.event_queue[mouse.events].buttons, POS_X, POS_Y); } else { SegSet16(cs, RealSeg(CALLBACK_RealPointer(int74_ret_callback))); reg_ip = RealOff(CALLBACK_RealPointer(int74_ret_callback)); } } else { SegSet16(cs, RealSeg(CALLBACK_RealPointer(int74_ret_callback))); reg_ip = RealOff(CALLBACK_RealPointer(int74_ret_callback)); } return CBRET_NONE; }
void IO_WriteW(Bitu port,Bitu val) { if (GCC_UNLIKELY(GETFLAG(VM) && (CPU_IO_Exception(port,2)))) { LazyFlags old_lflags; memcpy(&old_lflags,&lflags,sizeof(LazyFlags)); CPU_Decoder * old_cpudecoder; old_cpudecoder=cpudecoder; cpudecoder=&IOFaultCore; IOF_Entry * entry=&iof_queue.entries[iof_queue.used++]; entry->cs=SegValue(cs); entry->eip=reg_eip; CPU_Push16(SegValue(cs)); CPU_Push16(reg_ip); Bit16u old_ax = reg_ax; Bit16u old_dx = reg_dx; reg_al = val; reg_dx = port; RealPt icb = CALLBACK_RealPointer(call_priv_io); SegSet16(cs,RealSeg(icb)); reg_eip = RealOff(icb)+0x0a; CPU_Exception(cpu.exception.which,cpu.exception.error); DOSBOX_RunMachine(); iof_queue.used--; reg_ax = old_ax; reg_dx = old_dx; memcpy(&lflags,&old_lflags,sizeof(LazyFlags)); cpudecoder=old_cpudecoder; } else { IO_USEC_write_delay(); io_writehandlers[1][port](port,val,2); } }
void DoPS2Callback(Bit16u data, Bit16s mouseX, Bit16s mouseY) { if (useps2callback) { Bit16u mdat = (data & 0x03) | 0x08; Bit16s xdiff = mouseX-oldmouseX; Bit16s ydiff = oldmouseY-mouseY; oldmouseX = mouseX; oldmouseY = mouseY; if ((xdiff>0xff) || (xdiff<-0xff)) mdat |= 0x40; // x overflow if ((ydiff>0xff) || (ydiff<-0xff)) mdat |= 0x80; // y overflow xdiff %= 256; ydiff %= 256; if (xdiff<0) { xdiff = (0x100+xdiff); mdat |= 0x10; } if (ydiff<0) { ydiff = (0x100+ydiff); mdat |= 0x20; } CPU_Push16((Bit16u)mdat); CPU_Push16((Bit16u)(xdiff % 256)); CPU_Push16((Bit16u)(ydiff % 256)); CPU_Push16((Bit16u)0); CPU_Push16(RealSeg(ps2_callback)); CPU_Push16(RealOff(ps2_callback)); SegSet16(cs, ps2cbseg); reg_ip = ps2cbofs; } }