Diff for /np2/sound/opngeng.c between versions 1.5 and 1.9

version 1.5, 2003/10/26 07:50:36 version 1.9, 2005/02/04 05:32:24
Line 5 Line 5
 #include        "fmboard.h"  #include        "fmboard.h"
   
   
 extern  OPNCFG  opncfg;  #if defined(OPNGENX86)
   #error use opngen.x86
   #endif
   
 extern  SINT32  env_curve[];                            // ver0.27  
 extern  SINT32  envtable[];  extern  OPNCFG  opncfg;
 extern  SINT32  sintable[];                                     // ver0.27  
   
   
 #define CALCENV(e, c, s)                                                                                                        \  #define CALCENV(e, c, s)                                                                                                        \
Line 39  extern SINT32 sintable[];     // ver0.27 Line 40  extern SINT32 sintable[];     // ver0.27
                                 break;                                                                                                          \                                  break;                                                                                                          \
                 }                                                                                                                                       \                  }                                                                                                                                       \
         }                                                                                                                                               \          }                                                                                                                                               \
         (e) = (c)->slot[(s)].totallevel - env_curve[(c)->slot[(s)].env_cnt              \          (e) = (c)->slot[(s)].totallevel -                                                                               \
                                                                                                                         >> ENV_BITS];                                          opncfg.envcurve[(c)->slot[(s)].env_cnt >> ENV_BITS];
   
 #define SLOTOUT(s, e, c)                                                                                                        \  #define SLOTOUT(s, e, c)                                                                                                        \
                 ((sintable[(((s).freq_cnt + (c)) >> (FREQ_BITS - SIN_BITS)) &           \                  ((opncfg.sintable[(((s).freq_cnt + (c)) >>                                                      \
                         (SIN_ENT-1)] * envtable[(e)]) >> (ENVTBL_BIT+SINTBL_BIT-TL_BITS))                                                          (FREQ_BITS - SIN_BITS)) & (SIN_ENT - 1)] *              \
                                   opncfg.envtable[(e)]) >> (ENVTBL_BIT+SINTBL_BIT-TL_BITS))
   
 #if 0  
 static SINT32 calcrateenvlope(OPNSLOT *slot) {  
   
         /* calcrate phage generator */  
         slot->freq_cnt += slot->freq_inc;  
         /* calcrate envelope generator */  
         slot->env_cnt += slot->env_inc;  
         if (slot->env_cnt >= slot->env_end) {  
                 switch(slot->env_mode) {  
                         case EM_ATTACK:                                         // DECAY1 start  
                                 slot->env_mode = EM_DECAY1;  
                                 slot->env_cnt = EC_DECAY;  
                                 slot->env_end = slot->decaylevel;  
                                 slot->env_inc = slot->env_inc_decay1;  
                                 break;  
   
                         case EM_DECAY1:                                         // DECAY2 start  
                                 slot->env_mode = EM_DECAY2;  
                                 slot->env_cnt = slot->decaylevel;  
                                 slot->env_end = EC_OFF;  
                                 slot->env_inc = slot->env_inc_decay2;  
                                 break;  
   
                         case EM_RELEASE:                                        // OFF timing  
                                 slot->env_mode = EM_OFF;  
   
                         case EM_DECAY2:                                         // DECAY end  
                                 slot->env_cnt = EC_OFF;  
                                 slot->env_end = EC_OFF + 1;  
                                 slot->env_inc = 0;  
                                 break;  
                 }  
         }  
         return(slot->totallevel - env_curve[slot->env_cnt >> ENV_BITS]);  
 }  
 #endif  
   
 static void calcratechannel(OPNCH *ch) {  static void calcratechannel(OPNCH *ch) {
   
Line 93  static void calcratechannel(OPNCH *ch) { Line 59  static void calcratechannel(OPNCH *ch) {
         opngen.feedback4 = 0;          opngen.feedback4 = 0;
   
         /* SLOT 1 */          /* SLOT 1 */
 //      envout = calcrateenvlope(ch->slot + 0);  
         CALCENV(envout, ch, 0);          CALCENV(envout, ch, 0);
         if (envout > 0) {          if (envout > 0) {
                 if (ch->feedback) {                  if (ch->feedback) {
Line 116  static void calcratechannel(OPNCH *ch) { Line 81  static void calcratechannel(OPNCH *ch) {
                 }                  }
         }          }
         /* SLOT 2 */          /* SLOT 2 */
 //      envout = calcrateenvlope(ch->slot + 1);  
         CALCENV(envout, ch, 1);          CALCENV(envout, ch, 1);
         if (envout > 0) {          if (envout > 0) {
                 *ch->connect2 += SLOTOUT(ch->slot[1], envout, opngen.feedback2);                  *ch->connect2 += SLOTOUT(ch->slot[1], envout, opngen.feedback2);
         }          }
         /* SLOT 3 */          /* SLOT 3 */
 //      envout = calcrateenvlope(ch->slot + 2);  
         CALCENV(envout, ch, 2);          CALCENV(envout, ch, 2);
         if (envout > 0) {          if (envout > 0) {
                 *ch->connect3 += SLOTOUT(ch->slot[2], envout, opngen.feedback3);                  *ch->connect3 += SLOTOUT(ch->slot[2], envout, opngen.feedback3);
         }          }
         /* SLOT 4 */          /* SLOT 4 */
 //      envout = calcrateenvlope(ch->slot + 3);  
         CALCENV(envout, ch, 3);          CALCENV(envout, ch, 3);
         if (envout > 0) {          if (envout > 0) {
                 *ch->connect4 += SLOTOUT(ch->slot[3], envout, opngen.feedback4);                  *ch->connect4 += SLOTOUT(ch->slot[3], envout, opngen.feedback4);
Line 157  void SOUNDCALL opngen_getpcm(void *hdl,  Line 119  void SOUNDCALL opngen_getpcm(void *hdl, 
                         opngen.outdr = 0;                          opngen.outdr = 0;
                         playing = 0;                          playing = 0;
                         for (i=0; i<opngen.playchannels; i++) {                          for (i=0; i<opngen.playchannels; i++) {
                                 if (fm[i].playing) {                                  if (fm[i].playing & fm[i].outslot) {
                                         calcratechannel(fm + i);                                          calcratechannel(fm + i);
                                         playing++;                                          playing++;
                                 }                                  }
Line 181  void SOUNDCALL opngen_getpcm(void *hdl,  Line 143  void SOUNDCALL opngen_getpcm(void *hdl, 
                 samp_l >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);                  samp_l >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);
                 pcm[0] += samp_l;                  pcm[0] += samp_l;
                 samp_r += opngen.outdr * opngen.calcremain;                  samp_r += opngen.outdr * opngen.calcremain;
                 samp_r >>= FMDIV_BITS;                  samp_r >>= 8;
                 samp_r *= opncfg.fmvol;                  samp_r *= opncfg.fmvol;
                 samp_r >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);                  samp_r >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);
                 pcm[1] += samp_r;                  pcm[1] += samp_r;
Line 238  void SOUNDCALL opngen_getpcmvr(void *hdl Line 200  void SOUNDCALL opngen_getpcmvr(void *hdl
                 samp_l >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);                  samp_l >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);
                 pcm[0] += samp_l;                  pcm[0] += samp_l;
                 samp_r += opngen.outdr * opngen.calcremain;                  samp_r += opngen.outdr * opngen.calcremain;
                 samp_r >>= FMDIV_BITS;                  samp_r >>= 8;
                 samp_r *= opncfg.fmvol;                  samp_r *= opncfg.fmvol;
                 samp_r >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);                  samp_r >>= (OPM_OUTSB + FMDIV_BITS + 1 + 6 - FMVOL_SFTBIT - 8);
                 pcm[1] += samp_r;                  pcm[1] += samp_r;

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


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