Diff for /np2/sound/opngenc.c between versions 1.8 and 1.11

version 1.8, 2003/12/08 00:55:33 version 1.11, 2005/05/13 05:47:25
Line 52  static const int fmslot[4] = {0, 2, 1, 3 Line 52  static const int fmslot[4] = {0, 2, 1, 3
   
 void opngen_initialize(UINT rate) {  void opngen_initialize(UINT rate) {
   
           UINT    ratebit;
         int             i;          int             i;
         int             j;          int             j;
         double  pom;          double  pom;
         double  freq;          double  freq;
         UINT32  calcrate;          UINT32  calcrate;
   
         calcrate = rate * 55466 / 44100;          if (rate == 44100) {
                   ratebit = 0;
         opncfg.calc1024 = FMDIV_ENT * 44100 / 55466;          }
           else if (rate == 22050) {
                   ratebit = 1;
           }
           else {
                   ratebit = 2;
           }
           calcrate = (OPNA_CLOCK / 72) >> ratebit;
           opncfg.calc1024 = FMDIV_ENT * 44100 / (OPNA_CLOCK / 72);
   
         for (i=0; i<EVC_ENT; i++) {          for (i=0; i<EVC_ENT; i++) {
 #ifdef OPNGENX86  #ifdef OPNGENX86
Line 357  static void channleupdate(OPNCH *ch) { Line 366  static void channleupdate(OPNCH *ch) {
   
         int             i;          int             i;
         UINT32  fc = ch->keynote[0];                                            // ver0.27          UINT32  fc = ch->keynote[0];                                            // ver0.27
         BYTE    kc = ch->kcode[0];          UINT8   kc = ch->kcode[0];
         BYTE    evr;          UINT    evr;
         OPNSLOT *slot;          OPNSLOT *slot;
         int             s;          int             s;
   
Line 366  static void channleupdate(OPNCH *ch) { Line 375  static void channleupdate(OPNCH *ch) {
         if (!(ch->extop)) {          if (!(ch->extop)) {
                 for (i=0; i<4; i++, slot++) {                  for (i=0; i<4; i++, slot++) {
                         slot->freq_inc = (fc + slot->detune1[kc]) * slot->multiple;                          slot->freq_inc = (fc + slot->detune1[kc]) * slot->multiple;
                         evr = (BYTE)(kc >> slot->keyscale);                          evr = kc >> slot->keyscale;
                         if (slot->envratio != evr) {                          if (slot->envratio != evr) {
                                 slot->envratio = evr;                                  slot->envratio = evr;
                                 slot->env_inc_attack = slot->attack[evr];                                  slot->env_inc_attack = slot->attack[evr];
Line 381  static void channleupdate(OPNCH *ch) { Line 390  static void channleupdate(OPNCH *ch) {
                         s = extendslot[i];                          s = extendslot[i];
                         slot->freq_inc = (ch->keynote[s] + slot->detune1[ch->kcode[s]])                          slot->freq_inc = (ch->keynote[s] + slot->detune1[ch->kcode[s]])
                                                                                                                 * slot->multiple;                                                                                                                  * slot->multiple;
                         evr = (BYTE)(ch->kcode[s] >> slot->keyscale);                          evr = ch->kcode[s] >> slot->keyscale;
                         if (slot->envratio != evr) {                          if (slot->envratio != evr) {
                                 slot->envratio = evr;                                  slot->envratio = evr;
                                 slot->env_inc_attack = slot->attack[evr];                                  slot->env_inc_attack = slot->attack[evr];
Line 426  void opngen_reset(void) { Line 435  void opngen_reset(void) {
                 ch++;                  ch++;
         }          }
         for (i=0x30; i<0xc0; i++) {          for (i=0x30; i<0xc0; i++) {
                 opngen_setreg(0, (REG8)i, 0xff);                  opngen_setreg(0, i, 0xff);
                 opngen_setreg(3, (REG8)i, 0xff);                  opngen_setreg(3, i, 0xff);
                 opngen_setreg(6, (REG8)i, 0xff);                  opngen_setreg(6, i, 0xff);
                 opngen_setreg(9, (REG8)i, 0xff);                  opngen_setreg(9, i, 0xff);
         }          }
 }  }
   
Line 468  void opngen_setextch(UINT chnum, REG8 da Line 477  void opngen_setextch(UINT chnum, REG8 da
         ch[chnum].extop = data;          ch[chnum].extop = data;
 }  }
   
 void opngen_setreg(REG8 chbase, REG8 reg, REG8 value) {  void opngen_setreg(REG8 chbase, UINT reg, REG8 value) {
   
         UINT    chpos;          UINT    chpos;
         OPNCH   *ch;          OPNCH   *ch;
         OPNSLOT *slot;          OPNSLOT *slot;
         UINT    fn;          UINT    fn;
         BYTE    blk;          UINT8   blk;
   
         chpos = reg & 3;          chpos = reg & 3;
         if (chpos == 3) {          if (chpos == 3) {
Line 549  void opngen_setreg(REG8 chbase, REG8 reg Line 558  void opngen_setreg(REG8 chbase, REG8 reg
                                 break;                                  break;
   
                         case 0xb0:                          case 0xb0:
                                 ch->algorithm = (BYTE)(value & 7);                                  ch->algorithm = (UINT8)(value & 7);
                                 value = (value >> 3) & 7;                                  value = (value >> 3) & 7;
                                 if (value) {                                  if (value) {
                                         ch->feedback = 8 - value;                                          ch->feedback = 8 - value;
Line 561  void opngen_setreg(REG8 chbase, REG8 reg Line 570  void opngen_setreg(REG8 chbase, REG8 reg
                                 break;                                  break;
   
                         case 0xb4:                          case 0xb4:
                                 ch->pan = (BYTE)(value & 0xc0);                                  ch->pan = (UINT8)(value & 0xc0);
                                 set_algorithm(ch);                                  set_algorithm(ch);
                                 break;                                  break;
                 }                  }
Line 609  void opngen_keyon(UINT chnum, REG8 value Line 618  void opngen_keyon(UINT chnum, REG8 value
                 slot++;                  slot++;
                 bit <<= 1;                  bit <<= 1;
         }          }
         keydisp_fmkeyon((BYTE)chnum, value);          keydisp_fmkeyon((UINT8)chnum, value);
 }  }
   

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


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