bazz

mednafen debugger mute sound channel PCE patch

Oct 17th, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.54 KB | None | 0 0
  1. diff --git a/src/debug.h b/src/debug.h
  2. index 6e101a6..75d9502 100644
  3. --- a/src/debug.h
  4. +++ b/src/debug.h
  5. @@ -174,7 +174,7 @@ typedef struct
  6.   void (*SetGraphicsDecode)(MDFN_Surface *surface, int line, int which, int xscroll, int yscroll, int pbn);
  7.  
  8.   void (*SetLogFunc)(void (*logfunc)(const char *type, const char *text));
  9. -
  10. + void (*MuteChannel)(uint8 chan);
  11.   // Game emulation code shouldn't touch these directly.
  12.   std::vector<AddressSpaceType> *AddressSpaces;
  13.   std::vector<RegGroupType*> *RegGroups;
  14. diff --git a/src/drivers/debugger.cpp b/src/drivers/debugger.cpp
  15. index 1cf404c..a8da6e0 100644
  16. --- a/src/drivers/debugger.cpp
  17. +++ b/src/drivers/debugger.cpp
  18. @@ -1486,6 +1486,29 @@ void Debugger_GT_Event(const SDL_Event *event)
  19.       default: break;
  20.      }
  21.     }
  22. +   else if(event->key.keysym.mod & KMOD_SHIFT)
  23. +   {
  24. +    switch(event->key.keysym.sym)
  25. +    {
  26. +     if (CurGame->Debugger->MuteChannel)
  27. +     {
  28. +      case SDLK_1: CurGame->Debugger->MuteChannel(0);
  29. +       break;
  30. +      case SDLK_2: CurGame->Debugger->MuteChannel(1);
  31. +       break;
  32. +      case SDLK_3: CurGame->Debugger->MuteChannel(2);
  33. +       break;
  34. +      case SDLK_4: CurGame->Debugger->MuteChannel(3);
  35. +       break;
  36. +      case SDLK_5: CurGame->Debugger->MuteChannel(4);
  37. +       break;
  38. +      case SDLK_6: CurGame->Debugger->MuteChannel(5);
  39. +       break;
  40. +     }
  41. +
  42. +     default: break;
  43. +    }
  44. +   }
  45.    }
  46.  
  47.    if(WhichMode == 1)
  48. diff --git a/src/hw_sound/pce_psg/pce_psg.cpp b/src/hw_sound/pce_psg/pce_psg.cpp
  49. index 8217bdf..d6afcbf 100644
  50. --- a/src/hw_sound/pce_psg/pce_psg.cpp
  51. +++ b/src/hw_sound/pce_psg/pce_psg.cpp
  52. @@ -291,6 +291,16 @@ uint32 PCE_PSG::GetRegister(const unsigned int id, char *special, const uint32 s
  53.   return(value);
  54.  }
  55.  
  56. +void PCE_PSG::MuteChannel(uint8 chan)
  57. +{
  58. +  uint32 val = 0;
  59. +  if (channel_mute & (1<<chan))
  60. +    val = 0xFF;
  61. +  channel[chan].balance = val & 0xFF;
  62. +  //SetRegister(PSG_GSREG_CH0_BALANCE | (channel << 8), 0);
  63. +  channel_mute ^= (1<<chan);
  64. +}
  65. +
  66.  
  67.  void PCE_PSG::SetRegister(const unsigned int id, const uint32 value)
  68.  {
  69. @@ -333,7 +343,8 @@ void PCE_PSG::SetRegister(const unsigned int id, const uint32 value)
  70.     break;
  71.  
  72.    case PSG_GSREG_CH0_BALANCE:
  73. -   channel[ch].balance = value & 0xFF;
  74. +  if (!(channel_mute & (1<<ch)))
  75. +    channel[ch].balance = value & 0xFF;
  76.     break;
  77.  
  78.    case PSG_GSREG_CH0_WINDEX:
  79. @@ -434,6 +445,8 @@ PCE_PSG::PCE_PSG(int32* hr_l, int32* hr_r, int want_revision)
  80.      channel[ch].lastts = 0;
  81.     }
  82.  
  83. +  channel_mute = 0;
  84. +
  85.     SetVolume(1.0); // Will build dbtable in the process.
  86.     Power(0);
  87.  }
  88. @@ -531,7 +544,8 @@ void PCE_PSG::Write(int32 timestamp, uint8 A, uint8 V)
  89.  
  90.          case 0x05: /* Channel balance */
  91.         if(select > 5) return; // no more than 6 channels, silly game.
  92. -            ch->balance = V;
  93. +            if (!(channel_mute & (1<<select)))
  94. +              ch->balance = V;
  95.  
  96.         vol_pending = true;
  97.              break;
  98. diff --git a/src/hw_sound/pce_psg/pce_psg.h b/src/hw_sound/pce_psg/pce_psg.h
  99. index 4405ac3..af471b3 100644
  100. --- a/src/hw_sound/pce_psg/pce_psg.h
  101. +++ b/src/hw_sound/pce_psg/pce_psg.h
  102. @@ -129,6 +129,8 @@ class PCE_PSG
  103.          PCE_PSG(int32* hr_l, int32* hr_r, int want_revision);
  104.          ~PCE_PSG();
  105.  
  106. +        void MuteChannel(const uint8 chan);
  107. +
  108.     void StateAction(StateMem *sm, const unsigned load, const bool data_only);
  109.  
  110.          void Power(const int32 timestamp);
  111. @@ -166,6 +168,7 @@ class PCE_PSG
  112.     void RecalcNoiseFreqCache(int chnum);
  113.     void RunChannel(int chc, int32 timestamp, bool LFO_On);
  114.  
  115. +        uint8 channel_mute;         /* bit flags */
  116.          uint8 select;               /* Selected channel (0-5) */
  117.          uint8 globalbalance;        /* Global sound balance */
  118.          uint8 lfofreq;              /* LFO frequency */
  119. diff --git a/src/pce/debug.cpp b/src/pce/debug.cpp
  120. index 1021b11..4f0712e 100644
  121. --- a/src/pce/debug.cpp
  122. +++ b/src/pce/debug.cpp
  123. @@ -1116,6 +1116,7 @@ DebuggerInfoStruct PCEDBGInfo =
  124.   GetBranchTrace,
  125.   SetGraphicsDecode,
  126.   PCEDBG_SetLogFunc,
  127. + PCEDBG_MuteChannel,
  128.  };
  129.  
  130.  static void Cleanup(void)
  131. @@ -1127,6 +1128,11 @@ static void Cleanup(void)
  132.   }
  133.  }
  134.  
  135. +void PCEDBG_MuteChannel(uint8 chan)
  136. +{
  137. +  psg->MuteChannel(chan);
  138. +}
  139. +
  140.  void PCEDBG_Kill(void)
  141.  {
  142.   Cleanup();
  143. diff --git a/src/pce/debug.h b/src/pce/debug.h
  144. index 792b855..14bf4c1 100644
  145. --- a/src/pce/debug.h
  146. +++ b/src/pce/debug.h
  147. @@ -7,7 +7,7 @@
  148.  
  149.  namespace MDFN_IEN_PCE
  150.  {
  151. -
  152. +void PCEDBG_MuteChannel(uint8 channel);
  153.  void PCEDBG_MachineStateChanged(void);
  154.  
  155.  void PCEDBG_FlushBreakPoints(int type);
Advertisement
Add Comment
Please, Sign In to add comment