Diff for /np2/sound/fmtimer.c between versions 1.5 and 1.11

version 1.5, 2003/12/08 00:55:33 version 1.11, 2005/05/13 05:47:25
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 // #include     "cpucore.h"  #include        "cpucore.h"
 #include        "pccore.h"  #include        "pccore.h"
 #include        "iocore.h"  #include        "iocore.h"
 #include        "sound.h"  #include        "sound.h"
 #include        "fmboard.h"  #include        "fmboard.h"
   
   
 static const BYTE irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c};  static const UINT8 irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c};
   
   
 void fmport_a(NEVENTITEM item) {  void fmport_a(NEVENTITEM item) {
Line 14  void fmport_a(NEVENTITEM item) { Line 14  void fmport_a(NEVENTITEM item) {
         BOOL    intreq = FALSE;          BOOL    intreq = FALSE;
   
         if (item->flag & NEVENT_SETEVENT) {          if (item->flag & NEVENT_SETEVENT) {
                   intreq = pcm86gen_intrq();
                 if (fmtimer.reg & 0x04) {                  if (fmtimer.reg & 0x04) {
                         fmtimer.status |= 0x01;                          fmtimer.status |= 0x01;
                         intreq = TRUE;                          intreq = TRUE;
                 }                  }
                 if (pcm86.fifo & 0x20) {  
                         sound_sync();  
                         if (pcm86.virbuf <= pcm86.fifosize) {  
                                 intreq = TRUE;  
                         }  
                 }  
                 if (intreq) {                  if (intreq) {
                         pcm86.write = 1;  //                      pcm86.write = 1;
                         pic_setirq(fmtimer.irq);                          pic_setirq(fmtimer.irq);
 //                      TRACEOUT(("fm int-A"));  //                      TRACEOUT(("fm int-A"));
                 }                  }
Line 40  void fmport_b(NEVENTITEM item) { Line 35  void fmport_b(NEVENTITEM item) {
         BOOL    intreq = FALSE;          BOOL    intreq = FALSE;
   
         if (item->flag & NEVENT_SETEVENT) {          if (item->flag & NEVENT_SETEVENT) {
                   intreq = pcm86gen_intrq();
                 if (fmtimer.reg & 0x08) {                  if (fmtimer.reg & 0x08) {
                         fmtimer.status |= 0x02;                          fmtimer.status |= 0x02;
                         intreq = TRUE;                          intreq = TRUE;
                 }                  }
   #if 0
                 if (pcm86.fifo & 0x20) {                  if (pcm86.fifo & 0x20) {
                         sound_sync();                          sound_sync();
                         if (pcm86.virbuf <= pcm86.fifosize) {                          if (pcm86.virbuf <= pcm86.fifosize) {
                                 intreq = TRUE;                                  intreq = TRUE;
                         }                          }
                 }                  }
   #endif
                 if (intreq) {                  if (intreq) {
                         pcm86.write = 1;  //                      pcm86.write = 1;
                         pic_setirq(fmtimer.irq);                          pic_setirq(fmtimer.irq);
 //                      TRACEOUT(("fm int-B"));  //                      TRACEOUT(("fm int-B"));
                 }                  }
Line 66  static void set_fmtimeraevent(BOOL absol Line 64  static void set_fmtimeraevent(BOOL absol
         SINT32  l;          SINT32  l;
   
         l = 18 * (1024 - fmtimer.timera);          l = 18 * (1024 - fmtimer.timera);
         if (pc.cpumode & CPUMODE_8MHz) {                // 4MHz          if (pccore.cpumode & CPUMODE_8MHZ) {            // 4MHz
                 l = (l * 1248 / 625) * pc.multiple;                  l = (l * 1248 / 625) * pccore.multiple;
         }          }
         else {                                                                  // 5MHz          else {                                                                          // 5MHz
                 l = (l * 1536 / 625) * pc.multiple;                  l = (l * 1536 / 625) * pccore.multiple;
         }          }
         nevent_set(NEVENT_FMTIMERA, l, fmport_a, absolute);          nevent_set(NEVENT_FMTIMERA, l, fmport_a, absolute);
 }  }
Line 80  static void set_fmtimerbevent(BOOL absol Line 78  static void set_fmtimerbevent(BOOL absol
         SINT32  l;          SINT32  l;
   
         l = 288 * (256 - fmtimer.timerb);          l = 288 * (256 - fmtimer.timerb);
         if (pc.cpumode & CPUMODE_8MHz) {                // 4MHz          if (pccore.cpumode & CPUMODE_8MHZ) {            // 4MHz
                 l = (l * 1248 / 625) * pc.multiple;                  l = (l * 1248 / 625) * pccore.multiple;
         }          }
         else {                                                                  // 5MHz          else {                                                                          // 5MHz
                 l = (l * 1536 / 625) * pc.multiple;                  l = (l * 1536 / 625) * pccore.multiple;
         }          }
         nevent_set(NEVENT_FMTIMERB, l, fmport_b, absolute);          nevent_set(NEVENT_FMTIMERB, l, fmport_b, absolute);
 }  }
Line 92  static void set_fmtimerbevent(BOOL absol Line 90  static void set_fmtimerbevent(BOOL absol
 void fmtimer_reset(UINT irq) {  void fmtimer_reset(UINT irq) {
   
         ZeroMemory(&fmtimer, sizeof(fmtimer));          ZeroMemory(&fmtimer, sizeof(fmtimer));
   
 #if 0                                                                                                   // move  
         fmtimer.reg = 0x3f;  
         set_fmtimeraevent(NEVENT_ABSOLUTE);  
         set_fmtimerbevent(NEVENT_ABSOLUTE);  
 #endif  
         fmtimer.intr = irq & 0xc0;          fmtimer.intr = irq & 0xc0;
         fmtimer.intdisabel = irq & 0x10;          fmtimer.intdisabel = irq & 0x10;
         fmtimer.irq = irqtable[irq >> 6];          fmtimer.irq = irqtable[irq >> 6];
         pic_registext(fmtimer.irq);  //      pic_registext(fmtimer.irq);
 }  }
   
 void fmtimer_setreg(REG8 reg, REG8 value) {  void fmtimer_setreg(UINT reg, REG8 value) {
   
 //      TRACEOUT(("fm %x %x [%.4x:%.4x]", reg, value, CPU_CS, CPU_IP));  //      TRACEOUT(("fm %x %x [%.4x:%.4x]", reg, value, CPU_CS, CPU_IP));
   
Line 122  void fmtimer_setreg(REG8 reg, REG8 value Line 114  void fmtimer_setreg(REG8 reg, REG8 value
                         break;                          break;
   
                 case 0x27:                  case 0x27:
 #if 1  
                         fmtimer.reg = value;                          fmtimer.reg = value;
                         fmtimer.status &= ~((value & 0x30) >> 4);                          fmtimer.status &= ~((value & 0x30) >> 4);
                         if (value & 0x01) {                          if (value & 0x01) {
Line 144  void fmtimer_setreg(REG8 reg, REG8 value Line 135  void fmtimer_setreg(REG8 reg, REG8 value
                         if (!(value & 0x03)) {                          if (!(value & 0x03)) {
                                 pic_resetirq(fmtimer.irq);                                  pic_resetirq(fmtimer.irq);
                         }                          }
 #else  
                         fmtimer.reg = value;  
                         fmtimer.status &= ~((value & 0x30) >> 4);  
                         if ((value & 0x10) && (!nevent_iswork(NEVENT_FMTIMERA))) {  
                                 set_fmtimeraevent(NEVENT_ABSOLUTE);  
                         }  
                         if ((value & 0x20) && (!nevent_iswork(NEVENT_FMTIMERB))) {  
                                 set_fmtimerbevent(NEVENT_ABSOLUTE);  
                         }  
 #endif  
                         break;                          break;
         }          }
 }  }

Removed from v.1.5  
changed lines
  Added in v.1.11


RetroPC.NET-CVS <cvs@retropc.net>