|
|
| version 1.5, 2003/11/12 20:02:54 | version 1.9, 2003/12/01 17:13:36 |
|---|---|
| Line 10 | Line 10 |
| #include "beep.h" | #include "beep.h" |
| // #define uPD71054 // NP2はuPD8253Cベース | // #define uPD71054 // NP2はuPD8253Cベース |
| #define BEEPCOUNTEREX // BEEPアイドル時のカウンタをα倍に | |
| // --- Interval timer | // --- Interval timer |
| Line 45 static void setsystimerevent(BOOL absolu | Line 46 static void setsystimerevent(BOOL absolu |
| void systimer(NEVENTITEM item) { | void systimer(NEVENTITEM item) { |
| if (item->flag & NEVENT_SETEVENT) { | if (item->flag & NEVENT_SETEVENT) { |
| if (pit.intr[0]) { | |
| pit.intr[0] = 0; | |
| pic_setirq(0); | |
| } | |
| if ((pit.mode[0] & 0x0c) == 0x04) { | if ((pit.mode[0] & 0x0c) == 0x04) { |
| // レートジェネレータ | // レートジェネレータ |
| pit.intr[0] = 1; | |
| setsystimerevent(NEVENT_RELATIVE); | setsystimerevent(NEVENT_RELATIVE); |
| } | } |
| else { | else { |
| setsystimerevent_noint(NEVENT_RELATIVE); | nevent_set(NEVENT_ITIMER, pc.multiple << 16, |
| systimer, NEVENT_RELATIVE); | |
| } | } |
| } | } |
| pic_setirq(0); | |
| } | } |
| // --- Beep | // --- Beep |
| #if defined(BEEPCOUNTEREX) | |
| static void setbeepeventex(BOOL absolute) { | |
| UINT32 cnt; | |
| cnt = pit.value[1]; | |
| if (cnt > 2) { | |
| cnt *= pc.multiple; | |
| } | |
| else { | |
| cnt = pc.multiple << 16; | |
| } | |
| while(cnt < 0x100000) { | |
| cnt <<= 1; | |
| } | |
| nevent_set(NEVENT_BEEP, (SINT32)cnt, beeponeshot, absolute); | |
| } | |
| #endif | |
| static void setbeepevent(BOOL absolute) { | static void setbeepevent(BOOL absolute) { |
| SINT32 cnt; | SINT32 cnt; |
| Line 85 void beeponeshot(NEVENTITEM item) { | Line 110 void beeponeshot(NEVENTITEM item) { |
| if (pit.mode[1] & 0x02) | if (pit.mode[1] & 0x02) |
| #endif | #endif |
| { | { |
| #if defined(BEEPCOUNTEREX) | |
| setbeepeventex(NEVENT_RELATIVE); | |
| #else | |
| setbeepevent(NEVENT_RELATIVE); | setbeepevent(NEVENT_RELATIVE); |
| #endif | |
| } | } |
| } | } |
| } | } |
| Line 117 void rs232ctimer(NEVENTITEM item) { | Line 146 void rs232ctimer(NEVENTITEM item) { |
| rs232c_callback(); | rs232c_callback(); |
| } | } |
| // --------------------------------------------------------------------------- | // --------------------------------------------------------------------------- |
| static UINT16 itimer_latch(int ch) { | static UINT16 itimer_latch(int ch) { |
| Line 133 static UINT16 itimer_latch(int ch) { | Line 163 static UINT16 itimer_latch(int ch) { |
| return(pit.value[1] & 0xfffe); | return(pit.value[1] & 0xfffe); |
| #endif | #endif |
| } | } |
| #if defined(BEEPCOUNTEREX) | |
| clock = nevent_getremain(NEVENT_ITIMER + ch); | |
| if (clock < 0) { | |
| return(0); | |
| } | |
| clock /= pc.multiple; | |
| if (pit.value[1] > 2) { | |
| clock %= pit.value[1]; | |
| } | |
| else { | |
| clock >>= 16; | |
| } | |
| return((UINT16)clock); | |
| #endif | |
| } | } |
| clock = nevent_getremain(NEVENT_ITIMER + ch); | clock = nevent_getremain(NEVENT_ITIMER + ch); |
| if (clock >= 0) { | if (clock >= 0) { |
| Line 141 static UINT16 itimer_latch(int ch) { | Line 185 static UINT16 itimer_latch(int ch) { |
| return(0); | return(0); |
| } | } |
| void itimer_setflag(int ch, BYTE value) { | void itimer_setflag(int ch, BYTE value) { |
| pit.flag[ch] = 0; | pit.flag[ch] = 0; |
| Line 215 BYTE itimer_getcount(int ch) { | Line 258 BYTE itimer_getcount(int ch) { |
| // system timer | // system timer |
| static void IOOUTCALL pit_o71(UINT port, BYTE dat) { | static void IOOUTCALL pit_o71(UINT port, BYTE dat) { |
| // TRACEOUT(("pic71: %d", dat)); | // TRACEOUT(("pic o71: %x [%.4x %.4x]", dat, I286_CS, I286_IP)); |
| if (itimer_setcount(0, dat)) { | if (itimer_setcount(0, dat)) { |
| return; | return; |
| } | } |
| pic.pi[0].irr &= (~1); | pic.pi[0].irr &= (~1); |
| pit.intr[0] = 1; | |
| setsystimerevent(NEVENT_ABSOLUTE); | setsystimerevent(NEVENT_ABSOLUTE); |
| (void)port; | (void)port; |
| } | } |
| Line 256 static void IOOUTCALL pit_o77(UINT port, | Line 300 static void IOOUTCALL pit_o77(UINT port, |
| int ch; | int ch; |
| // TRACEOUT(("pic77: %x", dat)); | // TRACEOUT(("pic o77: %x", dat)); |
| ch = (dat >> 6) & 3; | ch = (dat >> 6) & 3; |
| if (ch != 3) { | if (ch != 3) { |
| itimer_setflag(ch, dat); | itimer_setflag(ch, dat); |
| if (ch == 0) { // 書込みで itimerのirrがリセットされる… | if (ch == 0) { // 書込みで itimerのirrがリセットされる… |
| pic.pi[0].irr &= (~1); | pic.pi[0].irr &= (~1); |
| if (dat & 0x30) { // 一応ラッチ時は割り込みをセットしない | if (dat & 0x30) { // 一応ラッチ時は割り込みをセットしない |
| setsystimerevent(NEVENT_ABSOLUTE); | pit.intr[0] = 1; |
| // setsystimerevent(NEVENT_ABSOLUTE); | |
| } | } |
| } | } |
| if (ch == 1) { | if (ch == 1) { |