Advertisement
Guest User

Wizardry sound fix for Boxer

a guest
Feb 13th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. --- hardware\pcspeaker.cpp 2010-05-10 18:43:54.000000000 -0000
  2. +++ hardware\pcspeaker.cpp 2013-12-30 10:27:53.000000000 -0000
  3. @@ -27,12 +27,21 @@
  4.  
  5.  
  6. #ifndef PI
  7. #define PI 3.14159265358979323846
  8. #endif
  9.  
  10. +static struct WizardryFixes
  11. +{
  12. + int mode;
  13. + float offset;
  14. + int wiz6_skip_hack;
  15. + int wiz7_ambient_hack;
  16. +}
  17. +g_wizardry;
  18. +
  19. #define SPKR_ENTRIES 1024
  20. #define SPKR_VOLUME 5000
  21. //#define SPKR_SHIFT 8
  22. #define SPKR_SPEED (float)((SPKR_VOLUME*2)/0.070f)
  23.  
  24. enum SPKR_MODES {
  25. @@ -170,18 +179,62 @@
  26. spkr.last_ticks=PIC_Ticks;
  27. float newindex=PIC_TickIndex();
  28. ForwardPIT(newindex);
  29. switch (mode) {
  30. case 0: /* Mode 0 one shot, used with realsound */
  31. if (spkr.mode!=SPKR_PIT_ON) return;
  32. - if (cntr>80) {
  33. - cntr=80;
  34. +
  35. + if ( g_wizardry.mode )
  36. + {
  37. + if ( g_wizardry.wiz6_skip_hack )
  38. + {
  39. + --g_wizardry.wiz6_skip_hack;
  40. + AddDelayEntry(newindex,spkr.pit_last);
  41. + }
  42. + else if ( cntr <= 256 )
  43. + {
  44. + if ( g_wizardry.wiz7_ambient_hack )
  45. + {
  46. + if ( cntr == 10 || cntr == 11 ) {
  47. + g_wizardry.offset = -1375.0f; // Ambient Hack.
  48. + } else {
  49. + g_wizardry.offset = -(float)SPKR_VOLUME;
  50. + }
  51. +
  52. + g_wizardry.wiz7_ambient_hack = 0;
  53. + }
  54. +
  55. + if ( cntr > 80 ) {
  56. + cntr = 80;
  57. + }
  58. +
  59. + spkr.pit_last=(((float)cntr)*(SPKR_VOLUME/40.0f))+(g_wizardry.offset);
  60. +
  61. + AddDelayEntry(newindex,spkr.pit_last);
  62. + spkr.pit_index=0;
  63. + }
  64. + else
  65. + {
  66. + if ( cntr == 65536 ) {
  67. + g_wizardry.wiz6_skip_hack = 52; // ignoring Wiz6 gibberish
  68. + }
  69. + }
  70. }
  71. - spkr.pit_last=((float)cntr-40)*(SPKR_VOLUME/40.0f);
  72. - AddDelayEntry(newindex,spkr.pit_last);
  73. - spkr.pit_index=0;
  74. + else
  75. + {
  76. + // Default DosBox behaviour
  77. +
  78. + if (cntr>80) {
  79. + cntr=80;
  80. + }
  81. +
  82. + spkr.pit_last=((float)cntr-40)*(SPKR_VOLUME/40.0f);
  83. + AddDelayEntry(newindex,spkr.pit_last);
  84. + spkr.pit_index=0;
  85. + }
  86. +
  87. break;
  88. case 1:
  89. if (spkr.mode!=SPKR_PIT_ON) return;
  90. spkr.pit_last=SPKR_VOLUME;
  91. AddDelayEntry(newindex,spkr.pit_last);
  92. break;
  93. @@ -232,20 +285,48 @@
  94. break;
  95. case 1:
  96. spkr.mode=SPKR_PIT_OFF;
  97. AddDelayEntry(newindex,-SPKR_VOLUME);
  98. break;
  99. case 2:
  100. - spkr.mode=SPKR_ON;
  101. - AddDelayEntry(newindex,SPKR_VOLUME);
  102. + if ( g_wizardry.mode )
  103. + {
  104. + // Wizardry Fix
  105. +
  106. + spkr.mode=SPKR_ON;
  107. + AddDelayEntry(newindex,spkr.pit_last);
  108. + }
  109. + else
  110. + {
  111. + // Default DosBox behaviour
  112. +
  113. + spkr.mode=SPKR_ON;
  114. + AddDelayEntry(newindex,SPKR_VOLUME);
  115. + }
  116. break;
  117. case 3:
  118. - if (spkr.mode!=SPKR_PIT_ON) {
  119. - AddDelayEntry(newindex,spkr.pit_last);
  120. - }
  121. - spkr.mode=SPKR_PIT_ON;
  122. + if ( g_wizardry.mode )
  123. + {
  124. + // Wizardry Fix
  125. +
  126. + spkr.mode=SPKR_PIT_ON;
  127. + AddDelayEntry(newindex,spkr.pit_last);
  128. +
  129. + if ( g_wizardry.mode == 7 ) {
  130. + g_wizardry.wiz7_ambient_hack = 1;
  131. + }
  132. + }
  133. + else
  134. + {
  135. + // Default DosBox behaviour
  136. +
  137. + if (spkr.mode!=SPKR_PIT_ON) {
  138. + AddDelayEntry(newindex,spkr.pit_last);
  139. + }
  140. + spkr.mode=SPKR_PIT_ON;
  141. + }
  142. break;
  143. };
  144. }
  145.  
  146. static void PCSPEAKER_CallBack(Bitu len) {
  147. Bit16s * stream=(Bit16s*)MixTemp;
  148. @@ -326,12 +407,26 @@
  149. MixerObject MixerChan;
  150. public:
  151. PCSPEAKER(Section* configuration):Module_base(configuration){
  152. spkr.chan=0;
  153. Section_prop * section=static_cast<Section_prop *>(configuration);
  154. if(!section->Get_bool("pcspeaker")) return;
  155. +
  156. + int wizpopfix = section->Get_int("wizpopfix");
  157. + if ( wizpopfix == 6 ) {
  158. + g_wizardry.mode = 6; // Custom fixes for popping.
  159. + g_wizardry.offset = 2625.0f-(float)SPKR_VOLUME;
  160. + } else if ( wizpopfix == 7 ) {
  161. + g_wizardry.mode = 7; // Custom fixes for popping.
  162. + g_wizardry.offset = -(float)SPKR_VOLUME;
  163. + } else {
  164. + g_wizardry.mode = 0; // Default DOSBOX behaviour
  165. + }
  166. + g_wizardry.wiz6_skip_hack = 0;
  167. + g_wizardry.wiz7_ambient_hack = 0;
  168. +
  169. spkr.mode=SPKR_OFF;
  170. spkr.last_ticks=0;
  171. spkr.last_index=0;
  172. spkr.rate=section->Get_int("pcrate");
  173. spkr.pit_max=(1000.0f/PIT_TICK_RATE)*65535;
  174. spkr.pit_half=spkr.pit_max/2;
  175.  
  176.  
  177.  
  178. --- dosbox.cpp 2010-05-10 18:43:54.000000000 -0000
  179. +++ dosbox.cpp 2013-12-30 01:49:42.000000000 -0000
  180. @@ -557,12 +557,17 @@
  181. Pbool->Set_help("Enable PC-Speaker emulation.");
  182.  
  183. Pint = secprop->Add_int("pcrate",Property::Changeable::WhenIdle,44100);
  184. Pint->Set_values(rates);
  185. Pint->Set_help("Sample rate of the PC-Speaker sound generation.");
  186.  
  187. + Pint = secprop->Add_int("wizpopfix",Property::Changeable::WhenIdle,0);
  188. + const char* wizpopfix[] = { "0", "6", "7", 0};
  189. + Pint->Set_values(wizpopfix);
  190. + Pint->Set_help("Reduces popping in Wizardry 6 / 7.");
  191. +
  192. secprop->AddInitFunction(&TANDYSOUND_Init,true);//done
  193. const char* tandys[] = { "auto", "on", "off", 0};
  194. Pstring = secprop->Add_string("tandy",Property::Changeable::WhenIdle,"auto");
  195. Pstring->Set_values(tandys);
  196. Pstring->Set_help("Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement