From a3b65d60b0d3ad1637556edeedeab1e0a29e1fca Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 30 Oct 2014 03:10:39 +0100 Subject: remove some unused functions/files --- Makefile | 1 - libretro.c | 102 +-------------------- source/apu.c | 6 -- source/display.h | 3 - source/gfx.c | 1 - source/screenshot.c | 252 ---------------------------------------------------- source/screenshot.h | 96 -------------------- source/snaporig.c | 4 - source/snapshot.c | 11 --- source/soundux.c | 150 +++++++++++++------------------ source/soundux.h | 4 - 11 files changed, 66 insertions(+), 564 deletions(-) delete mode 100644 source/screenshot.c delete mode 100644 source/screenshot.h diff --git a/Makefile b/Makefile index 659aaa2..0c4311d 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,6 @@ CATSFC_SOURCES := source/apu.c source/c4.c \ source/ppu.c \ source/sa1.c \ source/sa1cpu.c \ - source/screenshot.c \ source/sdd1.c \ source/sdd1emu.c \ source/seta010.c \ diff --git a/libretro.c b/libretro.c index af29968..3c0fe26 100644 --- a/libretro.c +++ b/libretro.c @@ -182,7 +182,6 @@ void S9xExit() // if(Settings.SPC7110) // (*CleanUp7110)(); - // S9xSetSoundMute (TRUE); // S9xDeinitDisplay (); // Memory.SaveSRAM (S9xGetFilename (".srm")); // // S9xSaveCheatFile (S9xGetFilename (".chb")); // cheat binary file @@ -211,9 +210,6 @@ bool8 S9xInitUpdate() return (TRUE); } - -extern void NDSSFCDrawFrameAntialiased(void* screen_addr); - #ifdef PSP #include #include @@ -310,25 +306,10 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, } } -void S9xProcessEvents(bool8 block) -{ - -} - -void OutOfMemory() -{ -} - - -const char* S9xGetROMDirectory() -{ - return "./"; -} - const char* S9xGetSnapshotDirectory() { - return "./"; + return "."; } const char* S9xGetFilename(const char* ex) @@ -348,72 +329,11 @@ const char* S9xGetFilename(const char* ex) return (filename); } -const char* S9xGetFilenameInc(const char* e) -{ - return e; -#if 0 - static char filename [_MAX_PATH + 1]; - char drive [_MAX_DRIVE + 1]; - char dir [_MAX_DIR + 1]; - char fname [_MAX_FNAME + 1]; - char ext [_MAX_EXT + 1]; - char* ptr; - struct stat buf; - - if (strlen(S9xGetSnapshotDirectory())) - { - _splitpath(Memory.ROMFilename, drive, dir, fname, ext); - strcpy(filename, S9xGetSnapshotDirectory()); - strcat(filename, "/"); - strcat(filename, fname); - ptr = filename + strlen(filename); - strcat(filename, "00/"); - strcat(filename, e); - } - else - { - _splitpath(Memory.ROMFilename, drive, dir, fname, ext); - strcat(fname, "00/"); - _makepath(filename, drive, dir, fname, e); - ptr = strstr(filename, "00/"); - } - - do - { - if (++ * (ptr + 2) > '9') - { - * (ptr + 2) = '0'; - if (++ * (ptr + 1) > '9') - { - * (ptr + 1) = '0'; - if (++*ptr > '9') - break; - } - } - } - while (stat(filename, &buf) == 0); - - return (filename); -#endif -} - -void S9xInitInputDevices() -{ -#ifdef JOYSTICK_SUPPORT - InitJoysticks(); -#endif -} - void init_sfc_setting(void) { ZeroMemory(&Settings, sizeof(Settings)); -#ifdef JOYSTICK_SUPPORT - Settings.JoystickEnabled = TRUE; -#else Settings.JoystickEnabled = FALSE; -#endif - Settings.SoundPlaybackRate = 44100; // -> ds2sound.h for defs Settings.SoundBufferSize = 512; Settings.CyclesPercentage = 100; @@ -514,23 +434,14 @@ void retro_init(void) "Frontend supports RGB565 - will use that instead of XRGB1555.\n"); init_sfc_setting(); - - if (!Init() || !S9xInitAPU()) - OutOfMemory(); - + Init(); + S9xInitAPU(); S9xInitDisplay(); - if (!S9xGraphicsInit()) - OutOfMemory(); - + S9xGraphicsInit(); S9xInitSound(Settings.SoundPlaybackRate, TRUE, Settings.SoundBufferSize); -#ifdef JOYSTICK_SUPPORT - uint32 JoypadSkip = 0; -#endif - - } @@ -573,7 +484,6 @@ void retro_run(void) poll_cb(); S9xSetPlaybackRate(32040); - so.mute_sound = FALSE; SoundData.echo_enable = FALSE; S9xMainLoop(); @@ -608,10 +518,6 @@ void S9xSyncSpeed() { } -bool8 S9xOpenSoundDevice(int mode, bool8 stereo, int buffer_size) -{ - return (TRUE); -} void S9xGenerateSound() { diff --git a/source/apu.c b/source/apu.c index a63b42f..c816174 100644 --- a/source/apu.c +++ b/source/apu.c @@ -101,8 +101,6 @@ /* For note-triggered SPC dump support */ #include "snapshot.h" -const char* S9xGetFilenameInc(const char*); - int spc_is_dumping = 0; int spc_is_dumping_temp; uint8 spc_dump_dsp[0x100]; @@ -228,10 +226,6 @@ void S9xSetAPUDSP(uint8 byte) else { S9xSetEchoWriteEnable(!(byte & APU_ECHO_DISABLED)); - if (byte & APU_MUTE) - S9xSetSoundMute(TRUE); - else - S9xSetSoundMute(FALSE); SoundData.noise_hertz = NoiseFreq [byte & 0x1f]; for (i = 0; i < 8; i++) diff --git a/source/display.h b/source/display.h index d581562..7dec42d 100644 --- a/source/display.h +++ b/source/display.h @@ -105,7 +105,6 @@ bool8 S9xReadSuperScopePosition(int* x, int* y, uint32* buttons); void S9xUsage(); void S9xInitDisplay(void); void S9xDeinitDisplay(); -void S9xInitInputDevices(); void S9xSetTitle(const char* title); void S9xPutImage(int width, int height); void S9xToggleSoundChannel(int channel); @@ -123,10 +122,8 @@ const char* S9xBasename(const char* filename); int S9xFStrcmp(FILE*, const char*); const char* S9xGetHomeDirectory(); const char* S9xGetSnapshotDirectory(); -const char* S9xGetROMDirectory(); const char* S9xGetSRAMFilename(); const char* S9xGetFilename(const char* extension); -const char* S9xGetFilenameInc(const char*); #endif diff --git a/source/gfx.c b/source/gfx.c index c2cca59..1b57c31 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -96,7 +96,6 @@ #include "gfx.h" #include "apu.h" #include "cheats.h" -#include "screenshot.h" #define M7 19 #define M8 19 diff --git a/source/screenshot.c b/source/screenshot.c deleted file mode 100644 index fc3cccb..0000000 --- a/source/screenshot.c +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net), - funkyass (funkyass@spam.shaw.ca), - Joel Yliluoma (http://iki.fi/bisqwit/) - Kris Bleakley (codeviolation@hotmail.com), - Matthew Kendora, - Nach (n-a-c-h@users.sourceforge.net), - Peter Bortas (peter@bortas.org) and - zones (kasumitokoduck@yahoo.com) - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), - _Demo_ (_demo_@zsnes.com), and Nach - - C4 C++ code - (c) Copyright 2003 Brad Jorsch - - DSP-1 emulator code - (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, - John Weidman, neviksti (neviksti@hotmail.com), - Kris Bleakley, Andreas Naive - - DSP-2 emulator code - (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and - Lord Nightmare (lord_nightmare@users.sourceforge.net - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and - Kris Bleakley - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, John Weidman, and Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive and John Weidman - - S-RTC C emulator code - (c) Copyright 2001 John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman - - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - - Specific ports contains the works of other authors. See headers in - individual files. - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and distribute Snes9x in both binary and - source form, for non-commercial purposes, is hereby granted without fee, - providing that this license information and copyright notice appear with - all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes - charging money for Snes9x or software derived from Snes9x. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -*******************************************************************************/ - - -#ifdef HAVE_CONFIG_H -#include -#endif -#include - -#ifndef __WIN32__ -#include -#else -#include -#endif -#include -#include - -#ifdef HAVE_LIBPNG -#include -#endif - -#include "snes9x.h" -#include "memmap.h" -#include "display.h" -#include "gfx.h" -#include "ppu.h" -#include "screenshot.h" - -bool8 S9xDoScreenshot(int width, int height) -{ -#ifdef HAVE_LIBPNG - FILE* fp; - png_structp png_ptr; - png_infop info_ptr; - png_color_8 sig_bit; - png_color pngpal[256]; - int imgwidth; - int imgheight; - const char* fname = S9xGetFilenameInc(".png"); - - Settings.TakeScreenshot = FALSE; - - if ((fp = fopen(fname, "wb")) == NULL) - { - perror("Screenshot failed"); - return FALSE; - } - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - { - fclose(fp); - unlink(fname); - return FALSE; - } - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - fclose(fp); - unlink(fname); - return FALSE; - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - perror("Screenshot: setjmp"); - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - unlink(fname); - return FALSE; - } - - imgwidth = width; - imgheight = height; - if (Settings.StretchScreenshots == 1) - { - if (width <= 256 && height > SNES_HEIGHT_EXTENDED) imgwidth = width << 1; - if (width > 256 && height <= SNES_HEIGHT_EXTENDED) imgheight = height << 1; - } - else if (Settings.StretchScreenshots == 2) - { - if (width <= 256) imgwidth = width << 1; - if (height <= SNES_HEIGHT_EXTENDED) imgheight = height << 1; - } - - png_init_io(png_ptr, fp); - if (!Settings.SixteenBit) - { - // BJ: credit sanmaiwashi for the idea to do palettized pngs, and to - // S9xSetPalette in x11.cpp for how to calculate the RGB values - int b = IPPU.MaxBrightness * 140; - for (int i = 0; i < 256; i++) - { - pngpal[i].red = (PPU.CGDATA[i] & 0x1f) * b >> 8; - pngpal[i].green = ((PPU.CGDATA[i] >> 5) & 0x1f) * b >> 8; - pngpal[i].blue = ((PPU.CGDATA[i] >> 10) & 0x1f) * b >> 8; - } - png_set_PLTE(png_ptr, info_ptr, pngpal, 256); - } - png_set_IHDR(png_ptr, info_ptr, imgwidth, imgheight, 8, - (Settings.SixteenBit ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_PALETTE), - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - - if (Settings.SixteenBit) - { - /* 5 bits per color */ - sig_bit.red = 5; - sig_bit.green = 5; - sig_bit.blue = 5; - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, &sig_bit); - } - - png_write_info(png_ptr, info_ptr); - - png_set_packing(png_ptr); - - png_byte* row_pointer = new png_byte [png_get_rowbytes(png_ptr, info_ptr)]; - uint8* screen = GFX.Screen; - for (int y = 0; y < height; y++, screen += GFX.Pitch) - { - png_byte* rowpix = row_pointer; - for (int x = 0; x < width; x++) - { - if (Settings.SixteenBit) - { - uint32 r, g, b; - DECOMPOSE_PIXEL((*(uint16*)(screen + 2 * x)), r, g, b); - *(rowpix++) = r; - *(rowpix++) = g; - *(rowpix++) = b; - if (imgwidth != width) - { - *(rowpix++) = r; - *(rowpix++) = g; - *(rowpix++) = b; - } - } - else - { - *(rowpix++) = *(uint8*)(screen + x); - if (imgwidth != width) - *(rowpix++) = *(uint8*)(screen + x); - } - } - png_write_row(png_ptr, row_pointer); - if (imgheight != height) - png_write_row(png_ptr, row_pointer); - } - - delete [] row_pointer; - - png_write_end(png_ptr, info_ptr); - png_destroy_write_struct(&png_ptr, &info_ptr); - - fclose(fp); - fprintf(stderr, "%s saved.\n", fname); - return TRUE; -#else - perror("Screenshot support not available (libpng was not found at build time)"); - return FALSE; -#endif -} - diff --git a/source/screenshot.h b/source/screenshot.h deleted file mode 100644 index 929428e..0000000 --- a/source/screenshot.h +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net), - funkyass (funkyass@spam.shaw.ca), - Joel Yliluoma (http://iki.fi/bisqwit/) - Kris Bleakley (codeviolation@hotmail.com), - Matthew Kendora, - Nach (n-a-c-h@users.sourceforge.net), - Peter Bortas (peter@bortas.org) and - zones (kasumitokoduck@yahoo.com) - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), - _Demo_ (_demo_@zsnes.com), and Nach - - C4 C++ code - (c) Copyright 2003 Brad Jorsch - - DSP-1 emulator code - (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, - John Weidman, neviksti (neviksti@hotmail.com), - Kris Bleakley, Andreas Naive - - DSP-2 emulator code - (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and - Lord Nightmare (lord_nightmare@users.sourceforge.net - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and - Kris Bleakley - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, John Weidman, and Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive and John Weidman - - S-RTC C emulator code - (c) Copyright 2001 John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman - - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - - Specific ports contains the works of other authors. See headers in - individual files. - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and distribute Snes9x in both binary and - source form, for non-commercial purposes, is hereby granted without fee, - providing that this license information and copyright notice appear with - all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes - charging money for Snes9x or software derived from Snes9x. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -*******************************************************************************/ - -#ifndef SCREENSHOT_H -#define SCREENSHOT_H - -bool8 S9xDoScreenshot(int width, int height); - -#endif - diff --git a/source/snaporig.c b/source/snaporig.c index c68f677..1e2e19b 100644 --- a/source/snaporig.c +++ b/source/snaporig.c @@ -201,7 +201,6 @@ static int ReadOrigSnapshot(STREAM snap) } S9xReset(); - S9xSetSoundMute(TRUE); if ((result = ReadBlock("CPU:", &OrigCPU, sizeof(OrigCPU), snap)) != SUCCESS) return (result); OrigCPU.FastROMSpeed = OrigCPU.FastROMSpeed_old; @@ -444,8 +443,6 @@ static int ReadOrigSnapshot(STREAM snap) OrigSoundData.channels [i].sample_pointer; SoundData.channels [i].mode = OrigSoundData.channels [i].mode; } - - S9xSetSoundMute(FALSE); IAPU.PC = IAPU.RAM + IAPU.Registers.PC; S9xAPUUnpackStatus(); if (APUCheckDirectPage()) @@ -459,7 +456,6 @@ static int ReadOrigSnapshot(STREAM snap) { Settings.APUEnabled = FALSE; IAPU.APUExecuting = FALSE; - S9xSetSoundMute(TRUE); } S9xFixSoundAfterSnapshotLoad(); ICPU.ShiftedPB = ICPU.Registers.PB << 16; diff --git a/source/snapshot.c b/source/snapshot.c index fae963d..da0ba77 100644 --- a/source/snapshot.c +++ b/source/snapshot.c @@ -651,7 +651,6 @@ void S9xFreezeToStream(STREAM stream) char buffer [1024]; int i; - S9xSetSoundMute(TRUE); #ifdef ZSNES_FX if (Settings.SuperFX) S9xSuperFXPreSaveState(); @@ -707,7 +706,6 @@ void S9xFreezeToStream(STREAM stream) if (Settings.SPC7110RTC) FreezeStruct(stream, "RTC", &rtc_f9, SnapS7RTC, COUNT(SnapS7RTC)); - S9xSetSoundMute(FALSE); #ifdef ZSNES_FX if (Settings.SuperFX) S9xSuperFXPostSaveState(); @@ -829,7 +827,6 @@ int S9xUnfreezeFromStream(STREAM stream) uint32 old_flags = CPU.Flags; uint32 sa1_old_flags = SA1.Flags; S9xReset(); - S9xSetSoundMute(TRUE); UnfreezeStructFromCopy(&CPU, SnapCPU, COUNT(SnapCPU), local_cpu); UnfreezeStructFromCopy(&ICPU.Registers, SnapRegisters, COUNT(SnapRegisters), @@ -872,7 +869,6 @@ int S9xUnfreezeFromStream(STREAM stream) if (local_apu) { - S9xSetSoundMute(FALSE); IAPU.PC = IAPU.RAM + IAPU.Registers.PC; S9xAPUUnpackStatus(); if (APUCheckDirectPage()) @@ -886,7 +882,6 @@ int S9xUnfreezeFromStream(STREAM stream) { Settings.APUEnabled = FALSE; IAPU.APUExecuting = FALSE; - S9xSetSoundMute(TRUE); } if (local_sa1) @@ -1315,7 +1310,6 @@ bool8 S9xSPCDump(const char* filename) FILE* fs; - S9xSetSoundMute(TRUE); if (!(fs = fopen(filename, "wb"))) return (FALSE); @@ -1359,10 +1353,8 @@ bool8 S9xSPCDump(const char* filename) fwrite(APU.ExtraRAM, 64, 1, fs) != 1 || fclose(fs) < 0) { - S9xSetSoundMute(FALSE); return (FALSE); } - S9xSetSoundMute(FALSE); return (TRUE); #endif } @@ -1379,7 +1371,6 @@ bool8 S9xUnfreezeZSNES(const char* filename) strncmp((char*) t, "ZSNES Save State File V0.6", 26) == 0) { S9xReset(); - S9xSetSoundMute(TRUE); // 28 Curr cycle CPU.V_Counter = READ_WORD(&t [29]); @@ -1604,7 +1595,6 @@ bool8 S9xUnfreezeZSNES(const char* filename) S9xSetAPUDSP(t [APU_KON]); IAPU.RAM [0xf2] = saved; - S9xSetSoundMute(FALSE); IAPU.PC = IAPU.RAM + IAPU.Registers.PC; S9xAPUUnpackStatus(); if (APUCheckDirectPage()) @@ -1618,7 +1608,6 @@ bool8 S9xUnfreezeZSNES(const char* filename) { Settings.APUEnabled = FALSE; IAPU.APUExecuting = FALSE; - S9xSetSoundMute(TRUE); } if (Settings.SuperFX) diff --git a/source/soundux.c b/source/soundux.c index 4e7fe57..23b2abe 100644 --- a/source/soundux.c +++ b/source/soundux.c @@ -494,13 +494,6 @@ void S9xSetSoundType(int channel, int type_of_sound) SoundData.channels[channel].type = type_of_sound; } -bool8 S9xSetSoundMute(bool8 mute) -{ - bool8 old = so.mute_sound; - so.mute_sound = mute; - return (old); -} - void AltDecodeBlock(Channel* ch) { if (ch->block_pointer >= 0x10000 - 9) @@ -1378,100 +1371,92 @@ void S9xMixSamples(uint8* buffer, int sample_count) int J; int I; - if (!so.mute_sound) - { - if (SoundData.echo_enable) - memset(EchoBuffer, 0, sample_count * sizeof(EchoBuffer [0])); - memset(MixBuffer, 0, sample_count * sizeof(MixBuffer [0])); - MixStereo(sample_count); - } + if (SoundData.echo_enable) + memset(EchoBuffer, 0, sample_count * sizeof(EchoBuffer [0])); + memset(MixBuffer, 0, sample_count * sizeof(MixBuffer [0])); + MixStereo(sample_count); /* Mix and convert waveforms */ int byte_count = sample_count << 1; - // 16-bit sound - if (so.mute_sound) - memset(buffer, 0, byte_count); - else + if (SoundData.echo_enable && SoundData.echo_buffer_size) { - if (SoundData.echo_enable && SoundData.echo_buffer_size) + // 16-bit stereo sound with echo enabled ... + if (FilterTapDefinitionBitfield == 0) { - // 16-bit stereo sound with echo enabled ... - if (FilterTapDefinitionBitfield == 0) + // ... but no filter defined. + for (J = 0; J < sample_count; J++) { - // ... but no filter defined. - for (J = 0; J < sample_count; J++) - { - int E = Echo [SoundData.echo_ptr]; + int E = Echo [SoundData.echo_ptr]; - Echo [SoundData.echo_ptr] = (E * SoundData.echo_feedback) / 128 + - EchoBuffer [J]; + Echo [SoundData.echo_ptr] = (E * SoundData.echo_feedback) / 128 + + EchoBuffer [J]; - if ((SoundData.echo_ptr += 1) >= SoundData.echo_buffer_size) - SoundData.echo_ptr = 0; + if ((SoundData.echo_ptr += 1) >= SoundData.echo_buffer_size) + SoundData.echo_ptr = 0; - I = (MixBuffer [J] * - SoundData.master_volume [J & 1] + - E * SoundData.echo_volume [J & 1]) / VOL_DIV16; + I = (MixBuffer [J] * + SoundData.master_volume [J & 1] + + E * SoundData.echo_volume [J & 1]) / VOL_DIV16; - CLIP16(I); - ((signed short*) buffer)[J] = I; - } - } - else - { - // ... with filter defined. - for (J = 0; J < sample_count; J++) - { - int E = Echo [SoundData.echo_ptr]; - - Loop [(Z - 0) & 15] = E; - E = E * FilterTaps [0]; - if (FilterTapDefinitionBitfield & 0x02) E += Loop [(Z - 2) & 15] * - FilterTaps [1]; - if (FilterTapDefinitionBitfield & 0x04) E += Loop [(Z - 4) & 15] * - FilterTaps [2]; - if (FilterTapDefinitionBitfield & 0x08) E += Loop [(Z - 6) & 15] * - FilterTaps [3]; - if (FilterTapDefinitionBitfield & 0x10) E += Loop [(Z - 8) & 15] * - FilterTaps [4]; - if (FilterTapDefinitionBitfield & 0x20) E += Loop [(Z - 10) & 15] * - FilterTaps [5]; - if (FilterTapDefinitionBitfield & 0x40) E += Loop [(Z - 12) & 15] * - FilterTaps [6]; - if (FilterTapDefinitionBitfield & 0x80) E += Loop [(Z - 14) & 15] * - FilterTaps [7]; - E /= 128; - Z++; - - Echo [SoundData.echo_ptr] = (E * SoundData.echo_feedback) / 128 + - EchoBuffer [J]; - - if ((SoundData.echo_ptr += 1) >= SoundData.echo_buffer_size) - SoundData.echo_ptr = 0; - - I = (MixBuffer [J] * - SoundData.master_volume [J & 1] + - E * SoundData.echo_volume [J & 1]) / VOL_DIV16; - - CLIP16(I); - ((signed short*) buffer)[J] = I; - } + CLIP16(I); + ((signed short*) buffer)[J] = I; } } else { - // 16-bit mono or stereo sound, no echo + // ... with filter defined. for (J = 0; J < sample_count; J++) { + int E = Echo [SoundData.echo_ptr]; + + Loop [(Z - 0) & 15] = E; + E = E * FilterTaps [0]; + if (FilterTapDefinitionBitfield & 0x02) E += Loop [(Z - 2) & 15] * + FilterTaps [1]; + if (FilterTapDefinitionBitfield & 0x04) E += Loop [(Z - 4) & 15] * + FilterTaps [2]; + if (FilterTapDefinitionBitfield & 0x08) E += Loop [(Z - 6) & 15] * + FilterTaps [3]; + if (FilterTapDefinitionBitfield & 0x10) E += Loop [(Z - 8) & 15] * + FilterTaps [4]; + if (FilterTapDefinitionBitfield & 0x20) E += Loop [(Z - 10) & 15] * + FilterTaps [5]; + if (FilterTapDefinitionBitfield & 0x40) E += Loop [(Z - 12) & 15] * + FilterTaps [6]; + if (FilterTapDefinitionBitfield & 0x80) E += Loop [(Z - 14) & 15] * + FilterTaps [7]; + E /= 128; + Z++; + + Echo [SoundData.echo_ptr] = (E * SoundData.echo_feedback) / 128 + + EchoBuffer [J]; + + if ((SoundData.echo_ptr += 1) >= SoundData.echo_buffer_size) + SoundData.echo_ptr = 0; + I = (MixBuffer [J] * - SoundData.master_volume [J & 1]) / VOL_DIV16; + SoundData.master_volume [J & 1] + + E * SoundData.echo_volume [J & 1]) / VOL_DIV16; CLIP16(I); ((signed short*) buffer)[J] = I; } } } + else + { + // 16-bit mono or stereo sound, no echo + for (J = 0; J < sample_count; J++) + { + I = (MixBuffer [J] * + SoundData.master_volume [J & 1]) / VOL_DIV16; + + CLIP16(I); + ((signed short*) buffer)[J] = I; + } + } + } #ifdef __DJGPP @@ -1517,7 +1502,6 @@ void S9xResetSound(bool8 full) FilterTaps [6] = 0; FilterTaps [7] = 0; FilterTapDefinitionBitfield = 0; - so.mute_sound = TRUE; noise_gen = 1; so.sound_switch = 255; so.samples_mixed_so_far = 0; @@ -1568,19 +1552,9 @@ bool8 S9xInitSound(int mode, bool8 stereo, int buffer_size) so.buffer_size = 0; so.encoded = FALSE; - S9xResetSound(TRUE); - if (!(mode & 7)) return (1); - S9xSetSoundMute(TRUE); - if (!S9xOpenSoundDevice(mode, stereo, buffer_size)) - { - S9xMessage(S9X_ERROR, S9X_SOUND_DEVICE_OPEN_FAILED, - "Sound device open failed"); - return (0); - } - return (1); } diff --git a/source/soundux.h b/source/soundux.h index ecccc53..8ba2fd8 100644 --- a/source/soundux.h +++ b/source/soundux.h @@ -125,9 +125,6 @@ typedef struct int sound_switch; int playback_rate; int buffer_size; - // int noise_gen; - // Moved to soundux.cpp's noise_gen; this doesn't need volatility! [Neb] - bool8 mute_sound; bool8 encoded; #ifdef __sun int last_eof; @@ -215,7 +212,6 @@ void S9xSetSoundType(int channel, int type_of_sound); void S9xSetMasterVolume(short master_volume_left, short master_volume_right); void S9xSetEchoVolume(short echo_volume_left, short echo_volume_right); void S9xSetSoundControl(int sound_switch); -bool8 S9xSetSoundMute(bool8 mute); void S9xSetEnvelopeHeight(int channel, int height); void S9xSetSoundADSR(int channel, int attack, int decay, int sustain, int sustain_level, int release); -- cgit v1.2.3