| version 1.7, 2003/11/30 12:32:04 | version 1.8, 2003/12/08 00:55:32 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
| #include        "i286.h" | #include        "cpucore.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 | #include        "iocore.h" | #include        "iocore.h" | 
 |  |  | 
| Line 79  static void pic_rolpry(PICITEM pi) { | Line 79  static void pic_rolpry(PICITEM pi) { | 
 | } | } | 
 |  |  | 
 |  |  | 
| static void pic_downbylevel(PICITEM picp, BYTE level) { | static void pic_downbylevel(PICITEM picp, UINT level) { | 
 |  |  | 
 | int             i; | int             i; | 
 |  |  | 
| Line 93  static void pic_downbylevel(PICITEM picp | Line 93  static void pic_downbylevel(PICITEM picp | 
 |  |  | 
 |  |  | 
 | // eoi処理 | // eoi処理 | 
| static void pic_forceeoibylevel(PICITEM picp, BYTE level) { | static void pic_forceeoibylevel(PICITEM picp, UINT level) { | 
 |  |  | 
 | int             i; | int             i; | 
 |  |  | 
 | if (picp->isr & (1 << level)) { | if (picp->isr & (1 << level)) { | 
 | picp->isr &= ~(1 << level); | picp->isr &= ~(1 << level); | 
| (picp->levels)--; | picp->levels--; | 
 | for (i=0; (i<picp->levels) && (picp->level[i] != level); i++) { } | for (i=0; (i<picp->levels) && (picp->level[i] != level); i++) { } | 
 | for (; i<picp->levels; i++) { | for (; i<picp->levels; i++) { | 
 | picp->level[i] = picp->level[i+1]; | picp->level[i] = picp->level[i+1]; | 
| Line 121  void pic_irq(void) { | Line 121  void pic_irq(void) { | 
 | p = &pic; | p = &pic; | 
 |  |  | 
 | // 割込み許可で 要求あり? | // 割込み許可で 要求あり? | 
| if ((isI286EI) && (!p->ext_irq) && | if ((CPU_isEI) && (!p->ext_irq) && | 
 | ((p->pi[0].irr & (~p->pi[0].imr)) || | ((p->pi[0].irr & (~p->pi[0].imr)) || | 
 | (p->pi[1].irr & (~p->pi[1].imr)))) { | (p->pi[1].irr & (~p->pi[1].imr)))) { | 
 |  |  | 
| Line 134  void pic_irq(void) { | Line 134  void pic_irq(void) { | 
 | } | } | 
 | irq = 0xff; | irq = 0xff; | 
 | targetbit = 0; | targetbit = 0; | 
| for (bit=1, i=0; bit; bit<<=1, i++) { | for (bit=1, i=0; i<8; bit<<=1, i++) { | 
 | if ((p->pi[0].irr & bit) && | if ((p->pi[0].irr & bit) && | 
 | (!((p->pi[0].imr | p->pi[0].isr) & bit))) { | (!((p->pi[0].imr | p->pi[0].isr) & bit))) { | 
 | if ((SINT8)p->pi[0].pry[i] > pry) { | if ((SINT8)p->pi[0].pry[i] > pry) { | 
| Line 170  void pic_irq(void) { | Line 170  void pic_irq(void) { | 
 | if (irq == 0) {                                                                 // ver0.28 | if (irq == 0) {                                                                 // ver0.28 | 
 | nevent_reset(NEVENT_PICMASK); | nevent_reset(NEVENT_PICMASK); | 
 | } | } | 
 | i286_interrupt((BYTE)((p->pi[0].icw[1] & 0xf8) | irq)); |  | 
 | // TRACEOUT(("hardware-int %.2x", (p->pi[0].icw[1] & 0xf8) | irq)); | // TRACEOUT(("hardware-int %.2x", (p->pi[0].icw[1] & 0xf8) | irq)); | 
 |  | CPU_INTERRUPT((REG8)((p->pi[0].icw[1] & 0xf8) | irq)); | 
 | return; | return; | 
 | } | } | 
 | if ((!p->pi[0].levels) || | if ((!p->pi[0].levels) || | 
| Line 187  void pic_irq(void) { | Line 187  void pic_irq(void) { | 
 | pry = (SINT8)p->pi[1].pry[p->pi[1].level[p->pi[1].levels - 1]]; | pry = (SINT8)p->pi[1].pry[p->pi[1].level[p->pi[1].levels - 1]]; | 
 | } | } | 
 | targetbit = 0; | targetbit = 0; | 
| for (bit=1, i=0; bit; bit<<=1, i++) { | for (bit=1, i=0; i<8; bit<<=1, i++) { | 
 | if ((p->pi[1].irr & bit) && | if ((p->pi[1].irr & bit) && | 
 | (!((p->pi[1].imr | p->pi[1].isr) & bit))) { | (!((p->pi[1].imr | p->pi[1].isr) & bit))) { | 
 | if ((SINT8)p->pi[1].pry[i] > pry) { | if ((SINT8)p->pi[1].pry[i] > pry) { | 
| Line 213  void pic_irq(void) { | Line 213  void pic_irq(void) { | 
 | p->pi[0].level[p->pi[0].levels++] = sirq; | p->pi[0].level[p->pi[0].levels++] = sirq; | 
 | } | } | 
 | // TRACEOUT(("hardware-int %.2x", (p->pi[1].icw[1] & 0xf8) | irq)); | // TRACEOUT(("hardware-int %.2x", (p->pi[1].icw[1] & 0xf8) | irq)); | 
| i286_interrupt((BYTE)((p->pi[1].icw[1] & 0xf8) | irq)); | CPU_INTERRUPT((REG8)((p->pi[1].icw[1] & 0xf8) | irq)); | 
 | } | } | 
 | } | } | 
 | } | } | 
| Line 231  void picmask(NEVENTITEM item) { | Line 231  void picmask(NEVENTITEM item) { | 
 | } | } | 
 | } | } | 
 |  |  | 
| void pic_setirq(BYTE irq) { | void pic_setirq(REG8 irq) { | 
 |  |  | 
 | PICITEM pi; | PICITEM pi; | 
| BYTE    bit; | REG8    bit; | 
 |  |  | 
 | pi = pic.pi; | pi = pic.pi; | 
 | bit = 1 << (irq & 7); | bit = 1 << (irq & 7); | 
| Line 267  void pic_setirq(BYTE irq) { | Line 267  void pic_setirq(BYTE irq) { | 
 | } | } | 
 | } | } | 
 |  |  | 
| void pic_resetirq(BYTE irq) { | void pic_resetirq(REG8 irq) { | 
 |  |  | 
 | PICITEM         pi; | PICITEM         pi; | 
 |  |  | 
| Line 275  void pic_resetirq(BYTE irq) { | Line 275  void pic_resetirq(BYTE irq) { | 
 | pi->irr &= ~(1 << (irq & 7)); | pi->irr &= ~(1 << (irq & 7)); | 
 | } | } | 
 |  |  | 
|  | void pic_registext(REG8 irq) { | 
| void pic_registext(BYTE irq) { |  | 
 |  |  | 
 | PICITEM         pi; | PICITEM         pi; | 
 |  |  | 
| Line 287  void pic_registext(BYTE irq) { | Line 286  void pic_registext(BYTE irq) { | 
 |  |  | 
 | // ---- I/O | // ---- I/O | 
 |  |  | 
| static void IOOUTCALL pic_o00(UINT port, BYTE dat) { | static void IOOUTCALL pic_o00(UINT port, REG8 dat) { | 
 |  |  | 
 | PICITEM         picp; | PICITEM         picp; | 
| BYTE            level; | UINT            level; | 
 |  |  | 
 | //      TRACEOUT(("pic %x %x", port, dat)); | //      TRACEOUT(("pic %x %x", port, dat)); | 
 | picp = &pic.pi[(port >> 3) & 1]; | picp = &pic.pi[(port >> 3) & 1]; | 
| Line 342  static void IOOUTCALL pic_o00(UINT port, | Line 341  static void IOOUTCALL pic_o00(UINT port, | 
 | extern int piccnt; | extern int piccnt; | 
 | #endif | #endif | 
 |  |  | 
| static void IOOUTCALL pic_o02(UINT port, BYTE dat) { | static void IOOUTCALL pic_o02(UINT port, REG8 dat) { | 
 |  |  | 
 | PICITEM         picp; | PICITEM         picp; | 
 |  |  | 
| Line 350  static void IOOUTCALL pic_o02(UINT port, | Line 349  static void IOOUTCALL pic_o02(UINT port, | 
 | picp = &pic.pi[(port >> 3) & 1]; | picp = &pic.pi[(port >> 3) & 1]; | 
 | if (!picp->writeicw) { | if (!picp->writeicw) { | 
 | #if 1   // マスクのセットだけなら nevent_forceexit()をコールしない | #if 1   // マスクのセットだけなら nevent_forceexit()をコールしない | 
| if ((isI286DI) || (pic.ext_irq) || | if ((CPU_isDI) || (pic.ext_irq) || | 
 | ((picp->imr & dat) == picp->imr)) { | ((picp->imr & dat) == picp->imr)) { | 
 | picp->imr = dat; | picp->imr = dat; | 
 | return; | return; | 
| Line 376  static void IOOUTCALL pic_o02(UINT port, | Line 375  static void IOOUTCALL pic_o02(UINT port, | 
 | nevent_forceexit(); | nevent_forceexit(); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL pic_i00(UINT port) { | static REG8 IOINPCALL pic_i00(UINT port) { | 
 |  |  | 
 | PICITEM         picp; | PICITEM         picp; | 
 |  |  | 
| Line 393  static BYTE IOINPCALL pic_i00(UINT port) | Line 392  static BYTE IOINPCALL pic_i00(UINT port) | 
 | } | } | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL pic_i02(UINT port) { | static REG8 IOINPCALL pic_i02(UINT port) { | 
 |  |  | 
 | PICITEM         picp; | PICITEM         picp; | 
 |  |  |