--- np2/io/pit.c 2004/03/19 00:30:01 1.20 +++ np2/io/pit.c 2011/01/15 18:04:43 1.27 @@ -12,9 +12,9 @@ #define BEEPCOUNTEREX // BEEPアイドル時のカウンタをα倍に -// #if defined(CPUCORE_IA32) +#if defined(CPUCORE_IA32) #define uPD71054 -// #endif +#endif // --- Interval timer @@ -126,12 +126,18 @@ void rs232ctimer(NEVENTITEM item) { if (item->flag & NEVENT_SETEVENT) { pitch = pit.ch + 2; + if (pitch->flag & PIT_FLAG_I) { + pitch->flag &= ~PIT_FLAG_I; + rs232c_callback(); + } if ((pitch->ctrl & 0x0c) == 0x04) { // レートジェネレータ setrs232cevent(pitch->value, NEVENT_RELATIVE); } + else { + setrs232cevent(0, NEVENT_RELATIVE); + } } - rs232c_callback(); } @@ -139,17 +145,17 @@ void rs232ctimer(NEVENTITEM item) { static UINT getcount(const _PITCH *pitch) { - SINT32 clock; + SINT32 clk; switch(pitch->ch) { case 0: - clock = nevent_getremain(NEVENT_ITIMER); + clk = nevent_getremain(NEVENT_ITIMER); break; case 1: switch(pitch->ctrl & 0x06) { #ifdef uPD71054 // ? - case 0x00: +// case 0x00: #endif case 0x04: return(pitch->value); @@ -158,35 +164,37 @@ static UINT getcount(const _PITCH *pitch return(pitch->value & (~1)); #endif } - clock = nevent_getremain(NEVENT_BEEP); + clk = nevent_getremain(NEVENT_BEEP); #if defined(BEEPCOUNTEREX) - if (clock >= 0) { - clock /= pccore.multiple; + if (clk >= 0) { + clk /= pccore.multiple; if (pitch->value > 2) { - clock %= pitch->value; + clk %= pitch->value; } else { - clock = LOW16(clock); + clk = LOW16(clk); } - return(clock); + return(clk); } #else break; #endif case 2: - clock = nevent_getremain(NEVENT_RS232C); + clk = nevent_getremain(NEVENT_RS232C); break; +#if !defined(DISABLE_SOUND) case 3: return(board14_pitcount()); +#endif default: - clock = 0; + clk = 0; break; } - if (clock > 0) { - return(clock / pccore.multiple); + if (clk > 0) { + return(clk / pccore.multiple); } return(0); } @@ -335,10 +343,8 @@ static void IOOUTCALL pit_o73(UINT port, return; } setbeepevent(pitch->value, NEVENT_ABSOLUTE); - if (!(pitch->ctrl & 0x0c)) { - beep_lheventset(1); - } - else { + beep_lheventset(1); // ver0.79 + if (pitch->ctrl & 0x0c) { beep_hzset(pitch->value); } (void)port; @@ -353,6 +359,7 @@ static void IOOUTCALL pit_o75(UINT port, if (pit_setcount(pitch, dat)) { return; } + pitch->flag |= PIT_FLAG_I; rs232c_open(); setrs232cevent(pitch->value, NEVENT_ABSOLUTE); (void)port; @@ -405,7 +412,7 @@ static const IOOUT pito71[4] = { static const IOINP piti71[4] = { pit_i71, pit_i71, pit_i71, NULL}; -void itimer_reset(void) { +void itimer_reset(const NP2CFG *pConfig) { UINT16 beepcnt; @@ -419,12 +426,18 @@ void itimer_reset(void) { pit.ch[1].value = beepcnt; pit.ch[2].ctrl = 0xb6 & 0x3f; pit.ch[2].ch = 2; +#if !defined(DISABLE_SOUND) pit.ch[3].ctrl = 0x36; pit.ch[3].ch = 3; pit.ch[4].ctrl = 0x36; pit.ch[4].ch = 4; +#endif setsystimerevent(0, NEVENT_ABSOLUTE); + beep_lheventset(1); // ver0.79 beep_hzset(beepcnt); +// setrs232cevent(0, NEVENT_ABSOLUTE); + + (void)pConfig; } void itimer_bind(void) {