| version 1.1, 2003/10/16 17:58:00 | version 1.6, 2004/03/19 00:30:00 | 
| Line 7 | Line 7 | 
 | #include        "fmboard.h" | #include        "fmboard.h" | 
 |  |  | 
 |  |  | 
| // ---- intr | // どうも 8253C-2は 4MHz/16らすい? | 
|  | // とりあえず 1996800/8を入力してみる... (ver0.71) | 
|  |  | 
 |  |  | 
| static void setmusicgenevent(BOOL absolute) { | // ---- 8253C-2 | 
 |  |  | 
| SINT32  cnt; | UINT board14_pitcount(void) { | 
 |  |  | 
| if (pit.value[3].w > 8) {                                               // 根拠なし | SINT32  clock; | 
| cnt = pc.multiple * pit.value[3].w; |  | 
|  | clock = nevent_getremain(NEVENT_MUSICGEN); | 
|  | if (clock >= 0) { | 
|  | clock /= pccore.multiple; | 
|  | clock /= 8; | 
|  | if (!(pccore.cpumode & CPUMODE_8MHZ)) { | 
|  | clock = clock * 13 / 16; | 
|  | } | 
|  | return(clock); | 
|  | } | 
|  | return(0); | 
|  | } | 
|  |  | 
|  |  | 
|  | // ---- intr | 
|  |  | 
|  | static void setmusicgenevent(UINT32 cnt, BOOL absolute) { | 
|  |  | 
|  | if (cnt > 4) {                                                          // 根拠なし | 
|  | cnt *= pccore.multiple; | 
 | } | } | 
 | else { | else { | 
| cnt = pc.multiple << 16; | cnt = pccore.multiple << 16; | 
|  | } | 
|  | if (!(pccore.cpumode & CPUMODE_8MHZ)) { | 
|  | cnt = cnt * 16 / 13;                                    // cnt * 2457600 / 1996800 | 
 | } | } | 
 |  | cnt *= 8; | 
 | nevent_set(NEVENT_MUSICGEN, cnt, musicgenint, absolute); | nevent_set(NEVENT_MUSICGEN, cnt, musicgenint, absolute); | 
 | } | } | 
 |  |  | 
 | void musicgenint(NEVENTITEM item) { | void musicgenint(NEVENTITEM item) { | 
 |  |  | 
 |  | PITCH   pitch; | 
 |  |  | 
 | if (item->flag & NEVENT_SETEVENT) { | if (item->flag & NEVENT_SETEVENT) { | 
| if ((pit.mode[3] & 0x0c) == 0x04) { | pitch = pit.ch + 3; | 
|  | if ((pitch->ctrl & 0x0c) == 0x04) { | 
 | // レートジェネレータ | // レートジェネレータ | 
| setmusicgenevent(NEVENT_RELATIVE); | setmusicgenevent(pitch->value, NEVENT_RELATIVE); | 
 | } | } | 
 | } | } | 
 | pic_setirq(0x0c); | pic_setirq(0x0c); | 
| Line 37  void musicgenint(NEVENTITEM item) { | Line 65  void musicgenint(NEVENTITEM item) { | 
 |  |  | 
 | // ---- I/O | // ---- I/O | 
 |  |  | 
| static void IOOUTCALL musicgen_o088(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o088(UINT port, REG8 dat) { | 
 |  |  | 
 | musicgen.porta = dat; | musicgen.porta = dat; | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL musicgen_o08a(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o08a(UINT port, REG8 dat) { | 
 |  |  | 
 | musicgen.portb = dat; | musicgen.portb = dat; | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL musicgen_o08c(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o08c(UINT port, REG8 dat) { | 
 |  |  | 
 | if (dat & 0x80) { | if (dat & 0x80) { | 
 | if (!(musicgen.portc & 0x80)) { | if (!(musicgen.portc & 0x80)) { | 
| Line 60  static void IOOUTCALL musicgen_o08c(UINT | Line 88  static void IOOUTCALL musicgen_o08c(UINT | 
 | musicgen.sync = 0; | musicgen.sync = 0; | 
 | sound_sync(); | sound_sync(); | 
 | musicgen.key[musicgen.ch] = dat; | musicgen.key[musicgen.ch] = dat; | 
| tms3631_setkey(&tms3631, (BYTE)musicgen.ch, dat); | tms3631_setkey(&tms3631, (REG8)musicgen.ch, dat); | 
 | } | } | 
 | else if ((!(dat & 0x40)) && (musicgen.portc & 0x40)) { | else if ((!(dat & 0x40)) && (musicgen.portc & 0x40)) { | 
 | musicgen.sync = 1; | musicgen.sync = 1; | 
| Line 71  static void IOOUTCALL musicgen_o08c(UINT | Line 99  static void IOOUTCALL musicgen_o08c(UINT | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL musicgen_o188(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o188(UINT port, REG8 dat) { | 
 |  |  | 
 | sound_sync(); | sound_sync(); | 
 | musicgen.mask = dat; | musicgen.mask = dat; | 
| Line 79  static void IOOUTCALL musicgen_o188(UINT | Line 107  static void IOOUTCALL musicgen_o188(UINT | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL musicgen_o18c(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o18c(UINT port, REG8 dat) { | 
|  |  | 
|  | PITCH   pitch; | 
 |  |  | 
| itimer_setcount(3, dat); | pitch = pit.ch + 3; | 
| setmusicgenevent(NEVENT_ABSOLUTE); | if (!pit_setcount(pitch, dat)) { | 
|  | setmusicgenevent(pitch->value, NEVENT_ABSOLUTE); | 
|  | } | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static void IOOUTCALL musicgen_o18e(UINT port, BYTE dat) { | static void IOOUTCALL musicgen_o18e(UINT port, REG8 dat) { | 
 |  |  | 
| itimer_setflag(3, dat); | pit_setflag(pit.ch + 3, dat); | 
 | (void)port; | (void)port; | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i088(UINT port) { | static REG8 IOINPCALL musicgen_i088(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(musicgen.porta); | return(musicgen.porta); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i08a(UINT port) { | static REG8 IOINPCALL musicgen_i08a(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(musicgen.portb); | return(musicgen.portb); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i08c(UINT port) { | static REG8 IOINPCALL musicgen_i08c(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(musicgen.portc); | return(musicgen.portc); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i08e(UINT port) { | static REG8 IOINPCALL musicgen_i08e(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(0x08); | return(0x08); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i188(UINT port) { | static REG8 IOINPCALL musicgen_i188(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 | return(musicgen.mask); | return(musicgen.mask); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i18c(UINT port) { | static REG8 IOINPCALL musicgen_i18c(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
| return(itimer_getcount(3)); | return(pit_getstat(pit.ch + 3)); | 
 | } | } | 
 |  |  | 
| static BYTE IOINPCALL musicgen_i18e(UINT port) { | static REG8 IOINPCALL musicgen_i18e(UINT port) { | 
 |  |  | 
 | (void)port; | (void)port; | 
 |  | #if 1 | 
 |  | return(0x80);                                   // INT-5 | 
 |  | #else | 
 | return(0x40);                                   // INT-5 | return(0x40);                                   // INT-5 | 
 |  | #endif | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 165  void board14_bind(void) { | Line 201  void board14_bind(void) { | 
 |  |  | 
 | void board14_allkeymake(void) { | void board14_allkeymake(void) { | 
 |  |  | 
| int             i; | REG8    i; | 
 |  |  | 
 | for (i=0; i<8; i++) { | for (i=0; i<8; i++) { | 
| tms3631_setkey(&tms3631, (BYTE)i, musicgen.key[i]); | tms3631_setkey(&tms3631, i, musicgen.key[i]); | 
 | } | } | 
 | } | } | 
 |  |  |