private void jmSetSamplePtr(SampledSound s) { // as: Added initialisation of sampled sounds _sfxPlayer.InitSampledSound(s.Pointer); }
/// <summary>Converts a sample sound in U8 format to S16 format.</summary> /// <param name="sampledSound">The SampledSound.</param> /// <returns>A byte array.</returns> private byte[] ConvertSamplesU8toS16(SampledSound sampledSound) { // Convert Unsigned 8-bit to Signed 16-bit Mono byte[] conversionBuffer = new byte[sampledSound.length * 2]; Array.Copy(sampledSound.Pointer.Buffer, (int) sampledSound.offset, conversionBuffer, 0, (int) sampledSound.length); for(int i = (int) sampledSound.length - 1; i >= 0; i--) { byte sample = (byte) (conversionBuffer[i] - 128); conversionBuffer[i * 2] = sample; conversionBuffer[i * 2 + 1] = sample; } return conversionBuffer; }
public void main() { #if DISABLED && !CATALOG // as: Added to remove compiler warning bool LaunchedFromShell = false; #endif _sys.textbackground(0); _sys.textcolor(7); if(_sys.argv.Length > 1 && string.Compare(_sys.argv[1], "/VER", StringComparison.OrdinalIgnoreCase) == 0) { // as: Added length check _sys.printf(_strings[Strings.main1]); // as: string replacements _sys.printf(_strings[Strings.main2]); // as: string replacements _sys.printf(_strings[Strings.main3]); // as: string replacements _sys.exit(0); } short i; #if DISABLED && !CATALOG // as: Extended to remove compiler warning for(i = 1; i < _sys.argc; i++) { switch(US_CheckParm(_sys.argv[i], EntryParmStrings)) { case 0: LaunchedFromShell = true; break; } } if(!LaunchedFromShell) { _sys.clrscr(); _sys.puts("You must type START at the DOS prompt to run HOVERTANK 3-D."); _sys.exit(0); } #endif // _sys.puts("HoverTank 3-D is executing..."); // // detect video // videocard = VideoID(); if(videocard == cardtype.EGAcard) { } // _sys.puts("EGA card detected"); else if(videocard == cardtype.VGAcard) { } // _sys.puts("VGA card detected"); else { _sys.clrscr(); _sys.puts("Hey, I don't see an EGA or VGA card here! Do you want to run the program "); _sys.puts("anyway (Y = go ahead, N = quit to dos) ?"); ClearKeys(); sbyte c = _sys.toupper((sbyte) _sys.bioskey(false)); if(c != 'Y') _sys.exit(1); } grmode = grtype.EGAgr; // // setup for sound blaster // soundblaster = true; for(i = 1; i < _sys.argc; i++) { switch(US_CheckParm(_sys.argv[i], SBlasterStrings)) { case 0: soundblaster = false; break; } } if(soundblaster) soundblaster = jmDetectSoundBlaster(-1); #if false if(string.Compare(_sys.argv[1], "NOBLASTER", StringComparison.OrdinalIgnoreCase) == 0) soundblaster = false; else soundblaster = jmDetectSoundBlaster(-1); #endif // as: Enable speaker mode when NOBLASTER command is specified if(_sys.IndexOfCommandLineArgument("NOBLASTER") != -1) _sfxPlayer.SpeakerMode = true; // as: Support for extra sound effects if(_sys.FileExists("SOUNDLNK.HOV")) { memptr soundLinksPtr; LoadIn("SOUNDLNK.HOV", out soundLinksPtr); for(int n = 0; n < SNDEX_NUMSOUNDS; n++) _sfxPlayer.SoundLinks[n] = soundLinksPtr.GetUInt8(n); } if(soundblaster) { //puts("Sound Blaster detected! (HOVER NOBLASTER to void detection)"); memptr baseptr; LoadIn("DSOUND.HOV", out baseptr); SampledSound samples = new SampledSound(baseptr); jmStartSB(); jmSetSamplePtr(samples); } //else // _sys.puts("Sound Blaster not detected"); LoadNearData(); // load some stuff before starting the memory manager MMStartup(); MMGetPtr(ref bufferseg, BUFFERSIZE); // small general purpose buffer BloadinMM("SOUNDS." + EXTENSION, ref soundseg); // as: Added initialisation of speaker sounds _sfxPlayer.InitSpeakerSound(soundseg); #if ADAPTIVE // timerspeed = 0x2147; // 140 ints / second (2/VBL) StartupSound(); // interrupt handlers that must be removed at quit SNDstarted = true; #endif StartupKbd(); KBDstarted = true; SetupGraphics(); InitRndT(true); // setup random routines InitRnd(true); LoadCtrls(); //_sys.puts ("Calculating..."); BuildTables(); SC_Setup(); SetScreenMode(grmode); SetLineWidth(SCREENWIDTH); screencenterx = 19; screencentery = 12; #if !(PROFILE || TESTCASE) if(!keydown[1]) // hold ESC to bypass intro Intro(); #endif #if PROFILE JoyXlow[1] = 16; JoyYlow[1] = 16; JoyXhigh[1] = 70; JoyYhigh[1] = 70; playermode[1] = inputtype.joystick1; #endif while(true) { #if !(PROFILE || TESTCASE) DemoLoop(); // do title, demo, etc #endif PlaySound(STARTGAMESND); PlayGame(); } }
/// <summary> /// The main() method - part 1. /// Initialises sound and graphic resources. /// </summary> /// <returns>The next state to set or null.</returns> private State main1() { soundblaster = jmDetectSoundBlaster(-1); // as: Enable PC speaker mode when NOBLASTER command is specified if(_sys.IndexOfCommandLineArgument("NOBLASTER") != -1) _sfxPlayer.SpeakerMode = true; // as: Support for extra sound effects if(_sys.FileExists("SOUNDLNK.HOV")) { memptr soundLinksPtr; LoadIn("SOUNDLNK.HOV", out soundLinksPtr); for(int n = 0; n < SNDEX_NUMSOUNDS; n++) _sfxPlayer.SoundLinks[n] = soundLinksPtr.GetUInt8(n); } if(soundblaster) { memptr baseptr; LoadIn("DSOUND.HOV", out baseptr); SampledSound samples = new SampledSound(baseptr); jmStartSB(); jmSetSamplePtr(samples); } LoadNearData(); // load some stuff before starting the memory manager MMStartup(); MMGetPtr(ref bufferseg, BUFFERSIZE); // small general purpose buffer BloadinMM("SOUNDS." + EXTENSION, ref soundseg); // as: Added initialisation of speaker sounds _sfxPlayer.InitSpeakerSound(soundseg); // timerspeed = 0x2147; // 140 ints / second (2/VBL) StartupSound(); // interrupt handlers that must be removed at quit SNDstarted = true; StartupKbd(); KBDstarted = true; SetupGraphics(); InitRndT(true); // setup random routines InitRnd(true); LoadCtrls(); BuildTables(); SC_Setup(); SetScreenMode(grmode); SetLineWidth(SCREENWIDTH); screencenterx = 19; screencentery = 12; // as: added delay to allow detection of ESC in the next step to bypass the intro _stateWaitVBL.Initialise(this, 70, _stateMain2); return _stateWaitVBL; }