Diff for /xmil/sound/psggenc.c between versions 1.1 and 1.7

version 1.1, 2004/08/01 05:31:31 version 1.7, 2005/02/04 06:42:12
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        <math.h>  
 #include        "sound.h"  #include        "sound.h"
 #include        "sndctrl.h"  #include        "sndctrl.h"
 #include        "juliet.h"  
 #include        "x1f.h"  
   
   
 extern  int             s_cnt;  
 extern  DWORD   basedclk;  
   
   
         PSGGENCFG       psggencfg;          PSGGENCFG       psggencfg;
   
 static const UINT8 psggen_deftbl[0x10] =  static const SINT32 psgvolrate[16] = {
                                      0,  508,  719, 1017, 1440, 2037, 2883, 4079,
                                   5772, 8167,11556,16351,23135,32735,46317,65536};
   
   const UINT8 psggen_deftbl[0x10] =
                                 {0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff};                                  {0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
   
 static const UINT8 psgenv_pat[16] = {  static const UINT8 psgenv_pat[16] = {
Line 36  static const UINT8 psgenv_pat[16] = { Line 33  static const UINT8 psgenv_pat[16] = {
   
 void psggen_initialize(UINT rate) {  void psggen_initialize(UINT rate) {
   
         double  pom;  
         UINT    i;          UINT    i;
   
         ZeroMemory(&psggencfg, sizeof(psggencfg));          ZeroMemory(&psggencfg, sizeof(psggencfg));
         psggencfg.rate = rate;          psggencfg.rate = rate;
         pom = (double)0x0c00;          for (i=0; i<16; i++) {
         for (i=15; i; i--) {                  psggencfg.voltbl[i] = (0x0c00 * psgvolrate[i]) >> 16;
                 psggencfg.voltbl[i] = (SINT32)pom;  
                 pom /= 1.41492;  
         }          }
         psggencfg.puchidec = (UINT16)(rate / 11025) * 2;          psggencfg.puchidec = (UINT16)(rate * 2 / 11025);
         if (psggencfg.puchidec == 0) {          if (psggencfg.puchidec == 0) {
                 psggencfg.puchidec = 1;                  psggencfg.puchidec = 1;
         }          }
Line 93  void psggen_setreg(PSGGEN psg, REG8 reg, Line 87  void psggen_setreg(PSGGEN psg, REG8 reg,
         UINT    freq;          UINT    freq;
         UINT    ch;          UINT    ch;
   
         x1f_psg(reg, value);          if (reg >= 14) {
         if (romeo_exist) {  
                 juliet2_YMF288A(reg, value, (basedclk * s_cnt / 1600));  
                 return;                  return;
         }          }
           sound_sync();
         reg &= 15;  
 //      if (reg < 14) {  
 //              sound_sync();  
 //      }  
         ((UINT8 *)&psg->reg)[reg] = value;          ((UINT8 *)&psg->reg)[reg] = value;
         switch(reg) {          switch(reg) {
                 case 0:                  case 0:
Line 118  void psggen_setreg(PSGGEN psg, REG8 reg, Line 106  void psggen_setreg(PSGGEN psg, REG8 reg,
                         }                          }
                         else {                          else {
                                 psg->tone[ch].freq = 0;                                  psg->tone[ch].freq = 0;
                                   psg->tone[ch].count = 0;        // としておかないとノイズ出ない
                         }                          }
                         break;                          break;
   
Line 134  void psggen_setreg(PSGGEN psg, REG8 reg, Line 123  void psggen_setreg(PSGGEN psg, REG8 reg,
 //                      keydisp_psgmix(psg);  //                      keydisp_psgmix(psg);
                         psg->mixer = ~value;                          psg->mixer = ~value;
                         psg->puchicount = psggencfg.puchidec;                          psg->puchicount = psggencfg.puchidec;
 //                      TRACEOUT(("psg %x 7 %d", (long)psg, value));  
                         break;                          break;
   
                 case 8:                  case 8:
Line 150  void psggen_setreg(PSGGEN psg, REG8 reg, Line 138  void psggen_setreg(PSGGEN psg, REG8 reg,
                         }                          }
                         psg->tone[ch].puchi = psggencfg.puchidec;                          psg->tone[ch].puchi = psggencfg.puchidec;
                         psg->puchicount = psggencfg.puchidec;                          psg->puchicount = psggencfg.puchidec;
 //                      TRACEOUT(("psg %x %x %d", (long)psg, reg, value));  
                         break;                          break;
   
                 case 11:                  case 11:
Line 166  void psggen_setreg(PSGGEN psg, REG8 reg, Line 153  void psggen_setreg(PSGGEN psg, REG8 reg,
                 case 13:                  case 13:
                         psg->envmode = psgenv_pat[value & 0x0f];                          psg->envmode = psgenv_pat[value & 0x0f];
                         psg->envvolcnt = 16;                          psg->envvolcnt = 16;
                         psg->envcnt = 1;                          psg->envcnt = 0;
                         break;                          break;
         }          }
 }  }

Removed from v.1.1  
changed lines
  Added in v.1.7


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