| version 1.5, 2003/11/21 06:51:11 | version 1.8, 2004/02/18 03:24:48 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 | #include        "mousemng.h" | #include        "mousemng.h" | 
| #include        "i286.h" | #include        "cpucore.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 | #include        "iocore.h" | #include        "iocore.h" | 
 |  | #include        "keystat.h" | 
 |  |  | 
 |  |  | 
 | // マウス ver0.28 | // マウス ver0.28 | 
| Line 19  void mouseif_sync(void) { | Line 20  void mouseif_sync(void) { | 
 | // 今回の移動量を取得 | // 今回の移動量を取得 | 
 | mouseif.b = mousemng_getstat(&mouseif.sx, &mouseif.sy, 1); | mouseif.b = mousemng_getstat(&mouseif.sx, &mouseif.sy, 1); | 
 | if (np2cfg.KEY_MODE == 3) { | if (np2cfg.KEY_MODE == 3) { | 
| mouseif.b &= keyext_getmouse(&mouseif.sx, &mouseif.sy); | mouseif.b &= keystat_getmouse(&mouseif.sx, &mouseif.sy); | 
 | } | } | 
 | mouseif.rx = mouseif.sx; | mouseif.rx = mouseif.sx; | 
 | mouseif.ry = mouseif.sy; | mouseif.ry = mouseif.sy; | 
 |  |  | 
| mouseif.lastc = I286_CLOCK + I286_BASECLOCK + I286_REMCLOCK; | mouseif.lastc = CPU_CLOCK + CPU_BASECLOCK + CPU_REMCLOCK; | 
 | } | } | 
 |  |  | 
 | static void calc_mousexy(void) { | static void calc_mousexy(void) { | 
| Line 32  static void calc_mousexy(void) { | Line 33  static void calc_mousexy(void) { | 
 | UINT32  clock; | UINT32  clock; | 
 | SINT32  diff; | SINT32  diff; | 
 |  |  | 
| clock = I286_CLOCK + I286_BASECLOCK + I286_REMCLOCK; | clock = CPU_CLOCK + CPU_BASECLOCK + CPU_REMCLOCK; | 
 | diff = clock - mouseif.lastc; | diff = clock - mouseif.lastc; | 
 | if (diff >= 2000) { | if (diff >= 2000) { | 
 | SINT32 dx; | SINT32 dx; | 
| Line 41  static void calc_mousexy(void) { | Line 42  static void calc_mousexy(void) { | 
 | diff /= 1000; | diff /= 1000; | 
 | dx = mouseif.sx; | dx = mouseif.sx; | 
 | if (dx > 0) { | if (dx > 0) { | 
| dx = dx * diff / pc.frame1000; | dx = dx * diff / mouseif.moveclock; | 
 | if (dx > mouseif.rx) { | if (dx > mouseif.rx) { | 
 | dx = mouseif.rx; | dx = mouseif.rx; | 
 | } | } | 
 | } | } | 
 | else if (dx < 0) { | else if (dx < 0) { | 
 | dx *= -1; | dx *= -1; | 
| dx = dx * diff / pc.frame1000; | dx = dx * diff / mouseif.moveclock; | 
 | dx *= -1; | dx *= -1; | 
 | if (dx < mouseif.rx) { | if (dx < mouseif.rx) { | 
 | dx = mouseif.rx; | dx = mouseif.rx; | 
| Line 59  static void calc_mousexy(void) { | Line 60  static void calc_mousexy(void) { | 
 |  |  | 
 | dy = mouseif.sy; | dy = mouseif.sy; | 
 | if (dy > 0) { | if (dy > 0) { | 
| dy = dy * diff / pc.frame1000; | dy = dy * diff / mouseif.moveclock; | 
 | if (dy > mouseif.ry) { | if (dy > mouseif.ry) { | 
 | dy = mouseif.ry; | dy = mouseif.ry; | 
 | } | } | 
 | } | } | 
 | else if (dy < 0) { | else if (dy < 0) { | 
 | dy *= -1; | dy *= -1; | 
| dy = dy * diff / pc.frame1000; | dy = dy * diff / mouseif.moveclock; | 
 | dy *= -1; | dy *= -1; | 
 | if (dy < mouseif.ry) { | if (dy < mouseif.ry) { | 
 | dy = mouseif.ry; | dy = mouseif.ry; | 
| Line 83  void mouseint(NEVENTITEM item) { | Line 84  void mouseint(NEVENTITEM item) { | 
 | if (item->flag & NEVENT_SETEVENT) { | if (item->flag & NEVENT_SETEVENT) { | 
 | if (!(mouseif.portc & 0x10)) { | if (!(mouseif.portc & 0x10)) { | 
 | pic_setirq(0x0d); | pic_setirq(0x0d); | 
| nevent_set(NEVENT_MOUSE, pc.mouseclock << mouseif.timing, | nevent_set(NEVENT_MOUSE, mouseif.intrclock << mouseif.timing, | 
 | mouseint, NEVENT_RELATIVE); | mouseint, NEVENT_RELATIVE); | 
 | } | } | 
 | } | } | 
 | } | } | 
 |  |  | 
| static void setportc(BYTE value) { | static void setportc(REG8 value) { | 
 |  |  | 
 | if ((value & 0x80) && (!(mouseif.portc & 0x80))) { | if ((value & 0x80) && (!(mouseif.portc & 0x80))) { | 
 | calc_mousexy(); | calc_mousexy(); | 
| Line 113  static void setportc(BYTE value) { | Line 114  static void setportc(BYTE value) { | 
 | if ((value ^ mouseif.portc) & 0x10) { | if ((value ^ mouseif.portc) & 0x10) { | 
 | if (!(value & 0x10)) { | if (!(value & 0x10)) { | 
 | if (!nevent_iswork(NEVENT_MOUSE)) { | if (!nevent_iswork(NEVENT_MOUSE)) { | 
| nevent_set(NEVENT_MOUSE, pc.mouseclock << mouseif.timing, | nevent_set(NEVENT_MOUSE, mouseif.intrclock << mouseif.timing, | 
 | mouseint, NEVENT_ABSOLUTE); | mouseint, NEVENT_ABSOLUTE); | 
 | } | } | 
 | } | } | 
 | } | } | 
| mouseif.portc = value; | mouseif.portc = (UINT8)value; | 
 | } | } | 
 |  |  | 
 |  |  | 
 | // ---- I/O | // ---- I/O | 
 |  |  | 
| static void IOOUTCALL mouseif_o7fdd(UINT port, BYTE dat) { | static void IOOUTCALL mouseif_o7fdd(UINT port, REG8 dat) { | 
 |  |  | 
 | setportc(dat); | setportc(dat); | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL mouseif_o7fdf(UINT port, BYTE dat) { | static void IOOUTCALL mouseif_o7fdf(UINT port, REG8 dat) { | 
 |  |  | 
 | if (dat & 0xf0) { | if (dat & 0xf0) { | 
| mouseif.mode = dat; | mouseif.mode = (UINT8)dat; | 
 | if (dat == 0x93) { | if (dat == 0x93) { | 
 | setportc(0); | setportc(0); | 
 | } | } | 
 | } | } | 
 | else { | else { | 
 | if (dat & 1) { | if (dat & 1) { | 
| setportc((BYTE)(mouseif.portc | (1 << (dat >> 1)))); | setportc((REG8)(mouseif.portc | (1 << (dat >> 1)))); | 
 | } | } | 
 | else { | else { | 
| setportc((BYTE)(mouseif.portc & (~(1 << (dat >> 1))))); | setportc((REG8)(mouseif.portc & (~(1 << (dat >> 1))))); | 
 | } | } | 
 | } | } | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL mouseif_i7fd9(UINT port) { | static REG8 IOINPCALL mouseif_i7fd9(UINT port) { | 
 |  |  | 
 | SINT16  x; | SINT16  x; | 
 | SINT16  y; | SINT16  y; | 
| BYTE    ret; | REG8    ret; | 
| BYTE    portc; | REG8    portc; | 
 |  |  | 
 | calc_mousexy(); | calc_mousexy(); | 
 | ret = mouseif.b; | ret = mouseif.b; | 
| Line 181  static BYTE IOINPCALL mouseif_i7fd9(UINT | Line 182  static BYTE IOINPCALL mouseif_i7fd9(UINT | 
 | else { | else { | 
 | ret |= (x >> 4) & 0x0f; | ret |= (x >> 4) & 0x0f; | 
 | } | } | 
| //      TRACEOUT(("%x %x mouse [%x] %d -> %x", I286_CS, I286_IP, portc & 0x20, y, ret)); | //      TRACEOUT(("%x %x mouse [%x] %d -> %x", CPU_CS, CPU_IP, portc & 0x20, y, ret)); | 
 | (void)port; | (void)port; | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL mouseif_i7fdb(UINT port) { | static REG8 IOINPCALL mouseif_i7fdb(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(0x40); | return(0x40); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL mouseif_i7fdd(UINT port) { | static REG8 IOINPCALL mouseif_i7fdd(UINT port) { | 
 |  |  | 
| BYTE    ret; | REG8    ret; | 
| BYTE    mode; | REG8    mode; | 
 |  |  | 
 | ret = mouseif.portc; | ret = mouseif.portc; | 
 | mode = mouseif.mode; | mode = mouseif.mode; | 
| Line 213  static BYTE IOINPCALL mouseif_i7fdd(UINT | Line 214  static BYTE IOINPCALL mouseif_i7fdd(UINT | 
 | } | } | 
 |  |  | 
 |  |  | 
| static void IOOUTCALL mouseif_obfdb(UINT port, BYTE dat) { | static void IOOUTCALL mouseif_obfdb(UINT port, REG8 dat) { | 
 |  |  | 
 | mouseif.timing = dat & 3; | mouseif.timing = dat & 3; | 
 | (void)port; | (void)port; | 
| Line 226  void mouseif_reset(void) { | Line 227  void mouseif_reset(void) { | 
 |  |  | 
 | ZeroMemory(&mouseif, sizeof(mouseif)); | ZeroMemory(&mouseif, sizeof(mouseif)); | 
 | mouseif.mode = 0x93; | mouseif.mode = 0x93; | 
| mouseif.portc = 0x10;                                                                                   // ver0.28 | mouseif.portc = 0x10; | 
|  | mouseif.intrclock = pccore.realclock / 120; | 
|  | mouseif.moveclock = pccore.realclock / 56400; | 
 | } | } | 
 |  |  | 
 | void mouseif_bind(void) { | void mouseif_bind(void) { |