Updated VGMPlay.

This commit is contained in:
Chris Moeller 2016-07-02 02:57:36 -07:00
parent f35d0773b9
commit 7bb722cdec
78 changed files with 4855 additions and 3839 deletions

View file

@ -90,6 +90,11 @@
17C8F2560CBED286008D969D /* Ym2413_Emu.h in Headers */ = {isa = PBXBuildFile; fileRef = 17C8F1ED0CBED286008D969D /* Ym2413_Emu.h */; };
17C8F2570CBED286008D969D /* Ym2612_Emu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 17C8F1EE0CBED286008D969D /* Ym2612_Emu.cpp */; };
17C8F2580CBED286008D969D /* Ym2612_Emu.h in Headers */ = {isa = PBXBuildFile; fileRef = 17C8F1EF0CBED286008D969D /* Ym2612_Emu.h */; };
8342DC841D27A171007FB1C1 /* yam.h in Headers */ = {isa = PBXBuildFile; fileRef = 8342DC811D27A171007FB1C1 /* yam.h */; };
8342DC851D27A171007FB1C1 /* scsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 8342DC821D27A171007FB1C1 /* scsp.c */; };
8342DC861D27A171007FB1C1 /* scsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 8342DC831D27A171007FB1C1 /* scsp.h */; };
8342DCCB1D27C0E9007FB1C1 /* yam.c in Sources */ = {isa = PBXBuildFile; fileRef = 8342DCC91D27C0E9007FB1C1 /* yam.c */; };
8342DCCC1D27C0E9007FB1C1 /* emuconfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 8342DCCA1D27C0E9007FB1C1 /* emuconfig.h */; };
8370B73017F615FE001A4D7A /* Ay_Core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8370B68D17F615FD001A4D7A /* Ay_Core.cpp */; };
8370B73117F615FE001A4D7A /* Ay_Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 8370B68E17F615FD001A4D7A /* Ay_Core.h */; };
8370B73217F615FE001A4D7A /* blargg_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8370B68F17F615FD001A4D7A /* blargg_common.cpp */; };
@ -254,10 +259,6 @@
83BB5EA31C0842A600734457 /* saa1099.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5E0F1C0842A600734457 /* saa1099.h */; };
83BB5EA41C0842A600734457 /* scd_pcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BB5E101C0842A600734457 /* scd_pcm.c */; };
83BB5EA51C0842A600734457 /* scd_pcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5E111C0842A600734457 /* scd_pcm.h */; };
83BB5EA61C0842A600734457 /* scsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BB5E121C0842A600734457 /* scsp.c */; };
83BB5EA71C0842A600734457 /* scsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5E131C0842A600734457 /* scsp.h */; };
83BB5EA81C0842A600734457 /* scspdsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BB5E141C0842A600734457 /* scspdsp.c */; };
83BB5EA91C0842A600734457 /* scspdsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5E151C0842A600734457 /* scspdsp.h */; };
83BB5EAB1C0842A600734457 /* segapcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BB5E171C0842A600734457 /* segapcm.c */; };
83BB5EAC1C0842A600734457 /* segapcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5E181C0842A600734457 /* segapcm.h */; };
83BB5EAD1C0842A600734457 /* sn76489.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BB5E191C0842A600734457 /* sn76489.c */; };
@ -402,6 +403,11 @@
17C8F1EE0CBED286008D969D /* Ym2612_Emu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Ym2612_Emu.cpp; path = gme/Ym2612_Emu.cpp; sourceTree = "<group>"; };
17C8F1EF0CBED286008D969D /* Ym2612_Emu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Ym2612_Emu.h; path = gme/Ym2612_Emu.h; sourceTree = "<group>"; };
833F68361CDBCAB200AFB9F0 /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8342DC811D27A171007FB1C1 /* yam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yam.h; sourceTree = "<group>"; };
8342DC821D27A171007FB1C1 /* scsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = scsp.c; sourceTree = "<group>"; };
8342DC831D27A171007FB1C1 /* scsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scsp.h; sourceTree = "<group>"; };
8342DCC91D27C0E9007FB1C1 /* yam.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yam.c; sourceTree = "<group>"; };
8342DCCA1D27C0E9007FB1C1 /* emuconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = emuconfig.h; sourceTree = "<group>"; };
8370B68D17F615FD001A4D7A /* Ay_Core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Ay_Core.cpp; path = gme/Ay_Core.cpp; sourceTree = "<group>"; };
8370B68E17F615FD001A4D7A /* Ay_Core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Ay_Core.h; path = gme/Ay_Core.h; sourceTree = "<group>"; };
8370B68F17F615FD001A4D7A /* blargg_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = blargg_common.cpp; path = gme/blargg_common.cpp; sourceTree = "<group>"; };
@ -566,10 +572,6 @@
83BB5E0F1C0842A600734457 /* saa1099.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = saa1099.h; sourceTree = "<group>"; };
83BB5E101C0842A600734457 /* scd_pcm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = scd_pcm.c; sourceTree = "<group>"; };
83BB5E111C0842A600734457 /* scd_pcm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scd_pcm.h; sourceTree = "<group>"; };
83BB5E121C0842A600734457 /* scsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = scsp.c; sourceTree = "<group>"; };
83BB5E131C0842A600734457 /* scsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scsp.h; sourceTree = "<group>"; };
83BB5E141C0842A600734457 /* scspdsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = scspdsp.c; sourceTree = "<group>"; };
83BB5E151C0842A600734457 /* scspdsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scspdsp.h; sourceTree = "<group>"; };
83BB5E171C0842A600734457 /* segapcm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = segapcm.c; sourceTree = "<group>"; };
83BB5E181C0842A600734457 /* segapcm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = segapcm.h; sourceTree = "<group>"; };
83BB5E191C0842A600734457 /* sn76489.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sn76489.c; sourceTree = "<group>"; };
@ -882,6 +884,11 @@
83BB5DAC1C0842A600734457 /* chips */ = {
isa = PBXGroup;
children = (
8342DCC91D27C0E9007FB1C1 /* yam.c */,
8342DCCA1D27C0E9007FB1C1 /* emuconfig.h */,
8342DC811D27A171007FB1C1 /* yam.h */,
8342DC821D27A171007FB1C1 /* scsp.c */,
8342DC831D27A171007FB1C1 /* scsp.h */,
83BB5DAD1C0842A600734457 /* 2151intf.c */,
83BB5DAE1C0842A600734457 /* 2151intf.h */,
83BB5DAF1C0842A600734457 /* 2203intf.c */,
@ -981,10 +988,6 @@
83BB5E0F1C0842A600734457 /* saa1099.h */,
83BB5E101C0842A600734457 /* scd_pcm.c */,
83BB5E111C0842A600734457 /* scd_pcm.h */,
83BB5E121C0842A600734457 /* scsp.c */,
83BB5E131C0842A600734457 /* scsp.h */,
83BB5E141C0842A600734457 /* scspdsp.c */,
83BB5E151C0842A600734457 /* scspdsp.h */,
83BB5E171C0842A600734457 /* segapcm.c */,
83BB5E181C0842A600734457 /* segapcm.h */,
83BB5E191C0842A600734457 /* sn76489.c */,
@ -1087,6 +1090,7 @@
files = (
83BB5ECF1C0842A600734457 /* ChipMapper.h in Headers */,
83BB5E861C0842A600734457 /* nes_apu.h in Headers */,
8342DC861D27A171007FB1C1 /* scsp.h in Headers */,
8370B76C17F615FE001A4D7A /* Nes_Cpu_run.h in Headers */,
83BB5EBC1C0842A600734457 /* x1_010.h in Headers */,
8370B7B017F615FE001A4D7A /* Spc_Sfm.h in Headers */,
@ -1108,7 +1112,6 @@
83BB5E631C0842A600734457 /* c6280.h in Headers */,
83BB5ED21C0842A600734457 /* VGMPlay.h in Headers */,
83BB5E8D1C0842A600734457 /* np_nes_dmc.h in Headers */,
83BB5EA91C0842A600734457 /* scspdsp.h in Headers */,
17C8F1FC0CBED286008D969D /* blargg_endian.h in Headers */,
83FC5D5F181B47FB00B917E5 /* dsp.hpp in Headers */,
17C8F1FD0CBED286008D969D /* blargg_source.h in Headers */,
@ -1119,7 +1122,6 @@
83FC5D79181B47FB00B917E5 /* smp.hpp in Headers */,
8370B73617F615FE001A4D7A /* Blip_Buffer_impl2.h in Headers */,
83BB5E6A1C0842A600734457 /* emu2149.h in Headers */,
83BB5EA71C0842A600734457 /* scsp.h in Headers */,
8370B78117F615FE001A4D7A /* Opl_Apu.h in Headers */,
83BB5EC61C0842A600734457 /* ymf262.h in Headers */,
83BB5E721C0842A600734457 /* es5506.h in Headers */,
@ -1140,6 +1142,7 @@
83BB5E821C0842A600734457 /* mamedef.h in Headers */,
83BB5E501C0842A600734457 /* 281btone.h in Headers */,
83BB5EB91C0842A600734457 /* ws_audio.h in Headers */,
8342DCCC1D27C0E9007FB1C1 /* emuconfig.h in Headers */,
83BB5E611C0842A600734457 /* c352.h in Headers */,
83BB5E6E1C0842A600734457 /* emutypes.h in Headers */,
8370B79317F615FE001A4D7A /* Rom_Data.h in Headers */,
@ -1225,6 +1228,7 @@
83BB5E561C0842A600734457 /* 8950intf.h in Headers */,
17C8F2470CBED286008D969D /* Sms_Apu.h in Headers */,
83BB5E931C0842A600734457 /* okim6295.h in Headers */,
8342DC841D27A171007FB1C1 /* yam.h in Headers */,
8370B7AE17F615FE001A4D7A /* Spc_Filter.h in Headers */,
8370B7AA17F615FE001A4D7A /* Sgc_Impl.h in Headers */,
8370B79D17F615FE001A4D7A /* Sap_Core.h in Headers */,
@ -1355,6 +1359,7 @@
8370B7A917F615FE001A4D7A /* Sgc_Impl.cpp in Sources */,
17C8F20F0CBED286008D969D /* Gb_Oscs.cpp in Sources */,
8370B74317F615FE001A4D7A /* Downsampler.cpp in Sources */,
8342DCCB1D27C0E9007FB1C1 /* yam.c in Sources */,
17C8F2110CBED286008D969D /* Gbs_Emu.cpp in Sources */,
83BB5E831C0842A600734457 /* multipcm.c in Sources */,
8370B73317F615FE001A4D7A /* blargg_errors.cpp in Sources */,
@ -1386,7 +1391,6 @@
83BB5E731C0842A600734457 /* fm.c in Sources */,
17C8F2330CBED286008D969D /* Nes_Fme7_Apu.cpp in Sources */,
8370B7B517F615FE001A4D7A /* Vgm_Core.cpp in Sources */,
83BB5EA61C0842A600734457 /* scsp.c in Sources */,
17C8F2350CBED286008D969D /* Nes_Namco_Apu.cpp in Sources */,
8370B7A617F615FE001A4D7A /* Sgc_Cpu.cpp in Sources */,
83BB5E431C0842A600734457 /* 2203intf.c in Sources */,
@ -1418,11 +1422,11 @@
83BB5EB11C0842A600734457 /* sn764intf.c in Sources */,
8370B76817F615FE001A4D7A /* Kss_Core.cpp in Sources */,
17C8F23D0CBED286008D969D /* Nsfe_Emu.cpp in Sources */,
8342DC851D27A171007FB1C1 /* scsp.c in Sources */,
8370B7A717F615FE001A4D7A /* Sgc_Emu.cpp in Sources */,
83BB5E881C0842A600734457 /* nes_intf.c in Sources */,
17C8F23F0CBED286008D969D /* Sap_Apu.cpp in Sources */,
8370B75117F615FE001A4D7A /* Gme_Loader.cpp in Sources */,
83BB5EA81C0842A600734457 /* scspdsp.c in Sources */,
83BB5E781C0842A600734457 /* gb.c in Sources */,
17C8F2420CBED286008D969D /* Sap_Cpu.cpp in Sources */,
8370B73717F615FE001A4D7A /* Bml_Parser.cpp in Sources */,

View file

@ -139,6 +139,12 @@ static UINT32 VGMF_mem_GetSize(VGM_FILE* f)
return mf->size;
}
static UINT32 VGMF_mem_Tell(VGM_FILE* f)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
return mf->ptr;
}
blargg_err_t Vgm_Core::load_mem_( byte const data [], int size )
{
VGM_FILE_mem memFile;
@ -146,6 +152,7 @@ blargg_err_t Vgm_Core::load_mem_( byte const data [], int size )
memFile.vf.Read = &VGMF_mem_Read;
memFile.vf.Seek = &VGMF_mem_Seek;
memFile.vf.GetSize = &VGMF_mem_GetSize;
memFile.vf.Tell = &VGMF_mem_Tell;
memFile.buffer = data;
memFile.ptr = 0;
memFile.size = size;
@ -186,7 +193,11 @@ char* Vgm_Core::get_voice_name(int channel)
size_t length = strlen(name) + 16;
char * finalName = (char *) malloc(length);
if (finalName)
#ifdef _MSC_VER
sprintf_s(finalName, length, "%s #%u", name, realChannel);
#else
sprintf(finalName, "%s #%u", name, realChannel);
#endif
return finalName;
}

View file

@ -315,6 +315,12 @@ static UINT32 VGMF_mem_GetSize(VGM_FILE* f)
return mf->size;
}
static UINT32 VGMF_mem_Tell(VGM_FILE* f)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
return mf->ptr;
}
struct Vgm_File : Gme_Info_
{
Vgm_Emu::header_t h;
@ -334,6 +340,7 @@ struct Vgm_File : Gme_Info_
memFile.vf.Read = &VGMF_mem_Read;
memFile.vf.Seek = &VGMF_mem_Seek;
memFile.vf.GetSize = &VGMF_mem_GetSize;
memFile.vf.Tell = &VGMF_mem_Tell;
memFile.buffer = in;
memFile.ptr = 0;
memFile.size = file_size;

View file

@ -1,7 +1,7 @@
// ChipMapper.c - Handles Chip Write (including OPL Hardware Support)
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <wchar.h>
#include "stdbool.h"
@ -14,6 +14,18 @@
#include "ChipMapper.h"
// To finish filling out later
UINT8 chip_reg_read(void *param, UINT8 ChipType, UINT8 ChipID, UINT8 Port, UINT8 Offset)
{
VGM_PLAYER* p = (VGM_PLAYER *) param;
switch(ChipType)
{
case 0x1B: // HuC6280
return c6280_r(p->huc6280[ChipID], Offset);
}
return 0;
}
void chip_reg_write(void *param, UINT8 ChipType, UINT8 ChipID,
UINT8 Port, UINT8 Offset, UINT8 Data)
{

View file

@ -1 +1,2 @@
UINT8 chip_reg_read(void *, UINT8 ChipType, UINT8 ChipID, UINT8 Port, UINT8 Offset);
void chip_reg_write(void *, UINT8 ChipType, UINT8 ChipID, UINT8 Port, UINT8 Offset, UINT8 Data);

View file

@ -109,7 +109,7 @@ INLINE INT32 SampleVGM2Pbk_I(VGM_PLAYER*, INT32 SampleVal); // inline functions
INLINE INT32 SamplePbk2VGM_I(VGM_PLAYER*, INT32 SampleVal);
//INT32 SampleVGM2Playback(void*, INT32 SampleVal); // non-inline functions
//INT32 SamplePlayback2VGM(void*, INT32 SampleVal);
static bool SetMuteControl(VGM_PLAYER*, bool mute);
//static bool SetMuteControl(VGM_PLAYER*, bool mute);
static void InterpretFile(VGM_PLAYER*, UINT32 SampleCount);
static void AddPCMData(VGM_PLAYER*, UINT8 Type, UINT32 DataSize, const UINT8* Data);
@ -156,6 +156,7 @@ void * VGMPlay_Init(void)
p->SampleRate = 44100;
p->FadeTime = 5000;
p->HardStopOldVGMs = 0x00;
p->FadeRAWLog = false;
p->VolumeLevel = 1.0f;
//p->FullBufFill = false;
@ -381,8 +382,8 @@ static UINT32 gcd(UINT32 x, UINT32 y)
void PlayVGM(void *_p)
{
UINT8 CurChip;
UINT8 FMVal;
/*UINT8 CurChip;*/
/*UINT8 FMVal;*/
INT32 TempSLng;
VGM_PLAYER* p = (VGM_PLAYER*)_p;
@ -659,6 +660,12 @@ static UINT32 VGMF_gzgetsize(VGM_FILE* hFile)
VGM_FILE_gz* File = (VGM_FILE_gz *)hFile;
return File->Size;
}
static UINT32 VGMF_gztell(VGM_FILE* hFile)
{
VGM_FILE_gz* File = (VGM_FILE_gz *)hFile;
return gztell(File->hFile);
}
#endif
bool OpenVGMFile(void *_p, const char* FileName)
@ -683,6 +690,7 @@ bool OpenVGMFile(void *_p, const char* FileName)
vgmFile.vf.Read = VGMF_gzread;
vgmFile.vf.Seek = VGMF_gzseek;
vgmFile.vf.GetSize = VGMF_gzgetsize;
vgmFile.vf.Tell = VGMF_gztell;
vgmFile.hFile = hFile;
vgmFile.Size = FileSize;
@ -729,6 +737,7 @@ bool OpenVGMFileW(void *_p, const wchar_t* FileName)
vgmFile.vf.Read = VGMF_gzread;
vgmFile.vf.Seek = VGMF_gzseek;
vgmFile.vf.GetSize = VGMF_gzgetsize;
vgmFile.vf.Tell = VGMF_gztell;
vgmFile.hFile = hFile;
vgmFile.Size = FileSize;
@ -765,6 +774,12 @@ static bool OpenVGMFile_Internal(VGM_PLAYER* p, VGM_FILE* hFile, UINT32 FileSize
hFile->Seek(hFile, 0x00);
ReadVGMHeader(hFile, &p->VGMHead);
if (p->VGMHead.fccVGM != FCC_VGM)
{
printf("VGM signature matched on the first read, but not on the second one!\n");
printf("This is a known zlib bug where gzseek fails. Please install a fixed zlib.\n");
return false;
}
p->VGMSampleRate = 44100;
if (! p->VGMDataLen)
@ -1172,7 +1187,8 @@ static wchar_t* ReadWStrFromFile(VGM_FILE* hFile, UINT32* FilePos, UINT32 EOFPos
if (TextStr == NULL)
return NULL;
hFile->Seek(hFile, CurPos);
if (hFile->Tell(hFile) != CurPos)
hFile->Seek(hFile, CurPos);
TempStr = TextStr - 1;
StrLen = 0x00;
do
@ -1294,6 +1310,12 @@ static UINT32 GetVGMFileInfo_Internal(VGM_FILE* hFile, UINT32 FileSize,
hFile->Seek(hFile, 0x00);
ReadVGMHeader(hFile, &TempHead);
if (TempHead.fccVGM != FCC_VGM)
{
printf("VGM signature matched on the first read, but not on the second one!\n");
printf("This is a known zlib bug where gzseek fails. Please install a fixed zlib.\n");
return 0x00;
}
if (! TempHead.lngEOFOffset || TempHead.lngEOFOffset > FileSize)
TempHead.lngEOFOffset = FileSize;
@ -1416,7 +1438,7 @@ UINT32 CalcSampleMSecExt(void *_p, UINT64 Value, UINT8 Mode, VGM_HEADER* FileHea
return RetVal;
}
static UINT32 EncryptChipName(void* DstBuf, const void* SrcBuf, UINT32 Length)
/*static UINT32 EncryptChipName(void* DstBuf, const void* SrcBuf, UINT32 Length)
{
// using nineko's awesome encryption algorithm
// http://forums.sonicretro.org/index.php?showtopic=25300
@ -1446,7 +1468,7 @@ static UINT32 EncryptChipName(void* DstBuf, const void* SrcBuf, UINT32 Length)
}
return Length;
}
}*/
const char* GetChipName(UINT8 ChipID)
{
@ -1576,6 +1598,12 @@ const char* GetAccurateChipName(UINT8 ChipID, UINT8 SubType)
else
RetStr = "NES APU + FDS";
break;
case 0x19:
if (! (ChipID & 0x80))
RetStr = "K051649";
else
RetStr = "K052539";
break;
case 0x1C:
switch(SubType)
{
@ -1756,6 +1784,7 @@ UINT32 GetChipClock(void* _p, UINT8 ChipID, UINT8* RetSubType)
break;
case 0x19:
Clock = FileHead->lngHzK051649;
AllowBit31 = 0x01; // SCC/SCC+ Bit
break;
case 0x1A:
Clock = FileHead->lngHzK054539;
@ -1802,6 +1831,7 @@ UINT32 GetChipClock(void* _p, UINT8 ChipID, UINT8* RetSubType)
break;
case 0x27:
Clock = FileHead->lngHzC352;
AllowBit31 = 0x01; // disable rear channels
break;
case 0x28:
Clock = FileHead->lngHzGA20;
@ -1848,14 +1878,14 @@ static UINT16 GetChipVolume(VGM_PLAYER* p, UINT8 ChipID, UINT8 ChipNum, UINT8 Ch
0x80, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x98, // 08-0F
0x80, 0xE0/*0xCD*/, 0x100, 0xC0, 0x100, 0x40, 0x11E, 0x1C0, // 10-17
0x100/*110*/, 0xA0, 0x100, 0x100, 0x100, 0xB3, 0x100, 0x100, // 18-1F
0x100, 0x100, 0x100, 0x100, 0x40, 0x20, 0x100, 0x40, // 20-27
0x20, 0x100, 0x100, 0x100, 0x40, 0x20, 0x100, 0x40, // 20-27
0x280};
UINT16 Volume;
UINT8 CurChp;
VGMX_CHP_EXTRA16* TempCX;
VGMX_CHIP_DATA16* TempCD;
VGM_HEADER* FileHead = &p->VGMHead;
/*VGM_HEADER* FileHead = &p->VGMHead;*/
Volume = CHIP_VOLS[ChipID & 0x7F];
switch(ChipID)
@ -2695,7 +2725,7 @@ static void Chips_GeneralActions(VGM_PLAYER* p, UINT8 Mode)
{
p->ChipOpts[0x01].SCSP.SpecialFlags = p->ChipOpts[0x00].SCSP.SpecialFlags;
//ChipVol = 0x100;
//ChipVol = 0x20;
ChipCnt = (p->VGMHead.lngHzSCSP & 0x40000000) ? 0x02 : 0x01;
for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
{
@ -2708,7 +2738,7 @@ static void Chips_GeneralActions(VGM_PLAYER* p, UINT8 Mode)
CAA->StreamUpdateParam = p->scsp[CurChip];
CAA->Volume = GetChipVolume(p, CAA->ChipType, CurChip, ChipCnt);
AbsVol += CAA->Volume;
AbsVol += CAA->Volume * 8;
}
}
if (p->VGMHead.lngHzWSwan)
@ -3305,7 +3335,7 @@ INT32 SamplePlayback2VGM(void* _p, INT32 SampleVal)
static void InterpretFile(VGM_PLAYER* p, UINT32 SampleCount)
{
UINT32 TempLng;
/*UINT32 TempLng;*/
UINT8 CurChip;
if (p->DacCtrlUsed && SampleCount > 1) // handle skipping
@ -4007,6 +4037,14 @@ static void InterpretVGM(VGM_PLAYER* p, UINT32 SampleCount)
#endif
p->VGMHead.lngTotalSamples = p->VGMSmplPos;
}
if (p->HardStopOldVGMs)
{
if (p->VGMHead.lngVersion < 0x150 ||
(p->VGMHead.lngVersion == 0x150 && p->HardStopOldVGMs == 0x02))
Chips_GeneralActions(p, 0x01); // reset all chips, for instant silence
}
p->VGMEnd = true;
break;
}
@ -4803,7 +4841,7 @@ static void GeneralChipLists(VGM_PLAYER* p)
UINT16 CurBufIdx;
CA_LIST* CLstOld;
CA_LIST* CLst;
CA_LIST* CurLst;
/*CA_LIST* CurLst;*/
UINT8 CurChip;
UINT8 CurCSet;
CAUD_ATTR* CAA;

View file

@ -6,7 +6,7 @@
#include "VGMPlay_Intf.h"
#define VGMPLAY_VER_STR "0.40.6"
#define VGMPLAY_VER_STR "0.40.7"
//#define APLHA
//#define BETA
#define VGM_VER_STR "1.71b"
@ -179,6 +179,7 @@ typedef struct vgm_player
float VolumeLevel;
bool SurroundSound;
UINT8 HardStopOldVGMs;
bool FadeRAWLog;
//bool FullBufFill; // Fill Buffer until it's full

View file

@ -131,6 +131,7 @@ static UINT8 Show95Cmds;
extern float VolumeLevel;
extern bool SurroundSound;
extern UINT8 HardStopOldVGMs;
extern bool FadeRAWLog;
static UINT8 LogToWave;
//extern bool FullBufFill;
@ -1105,6 +1106,12 @@ static void ReadOptions(const char* AppName)
{
PauseTimeJ = strtoul(RStr, NULL, 0);
}
else if (! stricmp_u(LStr, "HardStopOld"))
{
HardStopOldVGMs = (UINT8)strtoul(RStr, &TempPnt, 0);
if (TempPnt == RStr)
HardStopOldVGMs = GetBoolFromStr(RStr) ? 0x01 : 0x00;
}
else if (! stricmp_u(LStr, "FadeRAWLogs"))
{
FadeRAWLog = GetBoolFromStr(RStr);
@ -2004,7 +2011,7 @@ static void ShowVGMTag(void)
}
else
{
#if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MINGW32__)
#if (defined(_MSC_VER) && _MSC_VER < 1400)// || defined(__MINGW32__)
swprintf(TitleStr, L"%.*ls", 0x70, TitleTag);
#else
swprintf(TitleStr, 0x80, L"%.*ls", 0x70, TitleTag);
@ -2014,7 +2021,7 @@ static void ShowVGMTag(void)
if (wcslen(GameTag) && StrLen < 0x6C)
{
#if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MINGW32__)
#if (defined(_MSC_VER) && _MSC_VER < 1400)// || defined(__MINGW32__)
swprintf(TitleStr + StrLen, L" (%.*ls)", 0x70 - 3 - StrLen, GameTag);
#else
swprintf(TitleStr + StrLen, 0x80, L" (%.*ls)", 0x70 - 3 - StrLen, GameTag);

View file

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <string.h>
#include "stdbool.h"
#include <math.h>

View file

@ -25,6 +25,7 @@ struct vgm_file
int (*Read)(VGM_FILE*, void*, UINT32);
int (*Seek)(VGM_FILE*, UINT32);
UINT32 (*GetSize)(VGM_FILE*);
UINT32 (*Tell)(VGM_FILE*);
};
#ifdef __cplusplus

View file

@ -15,7 +15,9 @@
#include "ym2151.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
typedef struct _ym2151_state ym2151_state;
struct _ym2151_state

View file

@ -1,5 +1,5 @@
#include <math.h>
#include <memory.h> // for memset
#include <string.h> // for memset
#include <stdlib.h> // for free
#include <stddef.h> // for NULL
#include "mamedef.h"

View file

@ -4,6 +4,7 @@
****************************************************************/
#include <stdlib.h>
#include "mamedef.h"
//#include "sndintrf.h"
//#include "streams.h"
@ -18,7 +19,9 @@
#endif
#define EC_EMU2413 0x00 // EMU2413 core from in_vgm, value 0 because it's better than MAME
#ifndef NULL
#define NULL ((void *)0)
#endif
/* for stream system */
typedef struct _ym2413_state ym2413_state;
@ -75,6 +78,7 @@ void ym2413_stream_update(void *_info, stream_sample_t **outputs, int samples)
}
}
#ifdef ENABLE_ALL_CORES
static stream_sample_t* DUMMYBUF[0x02] = {NULL, NULL};
static void _stream_update(void *param, int interval)
@ -94,6 +98,7 @@ static void _stream_update(void *param, int interval)
break;
}
}
#endif
//static DEVICE_START( ym2413 )
int device_start_ym2413(void **_info, int EMU_CORE, int clock, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE)

View file

@ -11,7 +11,7 @@
***************************************************************************/
#include <memory.h> // for memset
#include <string.h> // for memset
#include <stdlib.h> // for free
#include <stddef.h> // for NULL
#include "mamedef.h"
@ -248,6 +248,8 @@ int device_start_ym2608(void **_info, int AY_EMU_CORE, int clock, UINT8 AYDisabl
int ay_clock;
//void *pcmbufa;
//int pcmsizea;
//ym2608_state *info = get_safe_token(device);
ym2608_state *info;
#ifdef ENABLE_ALL_CORES
if (AY_EMU_CORE >= 0x02)
@ -256,9 +258,6 @@ int device_start_ym2608(void **_info, int AY_EMU_CORE, int clock, UINT8 AYDisabl
AY_EMU_CORE = EC_EMU2149;
#endif
//ym2608_state *info = get_safe_token(device);
ym2608_state *info;
info = (ym2608_state *) calloc(1, sizeof(ym2608_state));
*_info = (void *) info;

View file

@ -11,7 +11,7 @@
***************************************************************************/
#include <memory.h> // for memset
#include <string.h> // for memset
#include <stdlib.h> // for free
#include <stddef.h> // for NULL
#include "mamedef.h"
@ -243,12 +243,14 @@ int device_start_ym2610(void **_info, int AY_EMU_CORE, int clock, UINT8 AYDisabl
// 1 - YM2610B
//static const ym2610_interface generic_2610 = { 0 };
#ifdef ENABLE_ALL_CORES
static const ay8910_interface generic_ay8910 =
{
AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
AY8910_DEFAULT_LOADS
//DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
};
#endif
//const ym2610_interface *intf = device->static_config ? (const ym2610_interface *)device->static_config : &generic_2610;
//const ym2610_interface *intf = &generic_2610;
int rate;

View file

@ -48,11 +48,13 @@ struct _ymf262_state
#ifdef ENABLE_ALL_CORES
static void IRQHandler_262(void *param,int irq)
{
ymf262_state *info = (ymf262_state *)param;
//ymf262_state *info = (ymf262_state *)param;
//if (info->intf->handler) (info->intf->handler)(info->device, irq);
}
#endif
/*static TIMER_CALLBACK( timer_callback_262_0 )
{
@ -67,9 +69,10 @@ static TIMER_CALLBACK( timer_callback_262_1 )
}*/
//static void timer_handler_262(void *param,int timer, attotime period)
#ifdef ENABLE_ALL_CORES
static void timer_handler_262(void *param,int timer, int period)
{
ymf262_state *info = (ymf262_state *)param;
//ymf262_state *info = (ymf262_state *)param;
if( period == 0 )
{ /* Reset FM Timer */
//timer_enable(info->timer[timer], 0);
@ -79,6 +82,7 @@ static void timer_handler_262(void *param,int timer, int period)
//timer_adjust_oneshot(info->timer[timer], period, 0);
}
}
#endif
//static STREAM_UPDATE( ymf262_stream_update )
void ymf262_stream_update(void *param, stream_sample_t **outputs, int samples)

View file

@ -25,7 +25,7 @@
#include "3526intf.h"
#include "fmopl.h"
#include <memory.h>
#include <string.h>
typedef struct _ym3526_state ym3526_state;
struct _ym3526_state
@ -51,7 +51,7 @@ struct _ym3526_state
/* IRQ Handler */
static void IRQHandler(void *param,int irq)
{
ym3526_state *info = (ym3526_state *)param;
//ym3526_state *info = (ym3526_state *)param;
//if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
//if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE);
}
@ -70,7 +70,7 @@ static TIMER_CALLBACK( timer_callback_1 )
//static void TimerHandler(void *param,int c,attotime period)
static void TimerHandler(void *param,int c,int period)
{
ym3526_state *info = (ym3526_state *)param;
//ym3526_state *info = (ym3526_state *)param;
//if( attotime_compare(period, attotime_zero) == 0 )
if( period == 0 )
{ /* Reset FM Timer */

View file

@ -16,7 +16,7 @@
* NOTES
*
******************************************************************************/
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "mamedef.h"
@ -32,7 +32,9 @@
#define OPLTYPE_IS_OPL2
#include "adlibemu.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
#define EC_DBOPL 0x00 // DosBox OPL (AdLibEmu)
@ -62,13 +64,15 @@ struct _ym3812_state
}*/
#ifdef ENABLE_ALL_CORES
static void IRQHandler(void *param,int irq)
{
ym3812_state *info = (ym3812_state *)param;
//ym3812_state *info = (ym3812_state *)param;
//if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
//if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE);
}
#endif
/*static TIMER_CALLBACK( timer_callback_0 )
{
ym3812_state *info = (ym3812_state *)ptr;
@ -82,9 +86,10 @@ static TIMER_CALLBACK( timer_callback_1 )
}*/
//static void TimerHandler(void *param,int c,attotime period)
#ifdef ENABLE_ALL_CORES
static void TimerHandler(void *param,int c,int period)
{
ym3812_state *info = (ym3812_state *)param;
//ym3812_state *info = (ym3812_state *)param;
//if( attotime_compare(period, attotime_zero) == 0 )
if( period == 0 )
{ /* Reset FM Timer */
@ -95,6 +100,7 @@ static void TimerHandler(void *param,int c,int period)
//timer_adjust_oneshot(info->timer[c], period, 0);
}
}
#endif
//static STREAM_UPDATE( ym3812_stream_update )

View file

@ -26,9 +26,11 @@
//#include "fm.h"
#include "fmopl.h"
#include <memory.h>
#include <string.h>
#ifndef NULL
#define NULL ((void *)0)
#endif
typedef struct _y8950_state y8950_state;
@ -54,7 +56,7 @@ struct _y8950_state
static void IRQHandler(void *param,int irq)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
//if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
//if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE);
}
@ -71,7 +73,7 @@ static TIMER_CALLBACK( timer_callback_1 )
//static void TimerHandler(void *param,int c,attotime period)
static void TimerHandler(void *param,int c,int period)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
//if( attotime_compare(period, attotime_zero) == 0 )
if( period == 0 )
{ /* Reset FM Timer */
@ -86,7 +88,7 @@ static void TimerHandler(void *param,int c,int period)
static unsigned char Y8950PortHandler_r(void *param)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
/*if (info->intf->portread)
return info->intf->portread(0);*/
return 0;
@ -94,14 +96,14 @@ static unsigned char Y8950PortHandler_r(void *param)
static void Y8950PortHandler_w(void *param,unsigned char data)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
/*if (info->intf->portwrite)
info->intf->portwrite(0,data);*/
}
static unsigned char Y8950KeyboardHandler_r(void *param)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
/*if (info->intf->keyboardread)
return info->intf->keyboardread(0);*/
return 0;
@ -109,7 +111,7 @@ static unsigned char Y8950KeyboardHandler_r(void *param)
static void Y8950KeyboardHandler_w(void *param,unsigned char data)
{
y8950_state *info = (y8950_state *)param;
//y8950_state *info = (y8950_state *)param;
/*if (info->intf->keyboardwrite)
info->intf->keyboardwrite(0,data);*/
}

View file

@ -50,7 +50,7 @@ Copyright(C)2006-2012 Kitao Nakamura.
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>
#include "mamedef.h"
#include "Ootake_PSG.h"
@ -803,7 +803,7 @@ PSG_Write(
Uint32 regNum,
Uint8 data)
{
huc6280_state* info = (huc6280_state*)chip;
//huc6280_state* info = (huc6280_state*)chip;
//v1.10更新。キュー処理をここに統合して高速化。
//Kitao更新。clockは考慮せずにシンプルにして高速化した。

View file

@ -53,7 +53,7 @@ PSG_Mix(
/*void
PSG_SetSampleRate(
Uint32 sampleRate);*
Uint32 sampleRate);*/
/*void
PSGDEBUG_ShowRegs();*/

View file

@ -117,11 +117,13 @@ has twice the steps, happening twice as fast.
//#include "cpuintrf.h"
//#include "cpuexec.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdio.h>
#include "ay8910.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/*************************************
*
@ -385,6 +387,7 @@ static const ay_ym_param ay8910_param =
*
*************************************/
#if 0
INLINE void build_3D_table(double rl, const ay_ym_param *par, const ay_ym_param *par_env, int normalize, double factor, int zero_is_off, INT32 *tab)
{
int j, j1, j2, j3, e, indx;
@ -456,6 +459,7 @@ INLINE void build_3D_table(double rl, const ay_ym_param *par, const ay_ym_param
free(temp);
}
#endif
INLINE void build_single_table(double rl, const ay_ym_param *par, int normalize, INT32 *tab, int zero_is_off)
{
@ -500,6 +504,7 @@ INLINE void build_single_table(double rl, const ay_ym_param *par, int normalize,
}
#if 0
INLINE UINT16 mix_3D(ay8910_context *psg)
{
int indx = 0, chan;
@ -523,6 +528,7 @@ INLINE UINT16 mix_3D(ay8910_context *psg)
}
return psg->vol3d_table[indx];
}
#endif
/*************************************
*

View file

@ -4,7 +4,7 @@
****************************************************************/
#include <memory.h> // for memset
#include <string.h> // for memset
#include <stdlib.h> // for free
#include <stddef.h> // for NULL
#include "mamedef.h"

View file

@ -45,11 +45,13 @@ Unmapped registers:
//#include "emu.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "mamedef.h"
#include "c140.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
#define MAX_VOICE 24

View file

@ -1,7 +1,10 @@
/*
c352.c - Namco C352 custom PCM chip emulation
v1.2
By R. Belmont
v2.0
Rewritten by superctr
Original code by R. Belmont
Additional code by cync and the hoot development team
Thanks to Cap of VivaNonno for info and The_Author for preliminary reverse-engineering
@ -17,717 +20,351 @@
//#include "streams.h"
#include <math.h>
#include <stdlib.h>
#include <memory.h>
#include <stddef.h> // for NULL
#include <string.h>
#include <stddef.h> // for NULL
#include "mamedef.h"
#include "c352.h"
#define VERBOSE (0)
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
// flags
#define C352_VOICES 32
enum {
C352_FLG_BUSY = 0x8000, // channel is busy
C352_FLG_KEYON = 0x4000, // Keyon
C352_FLG_KEYOFF = 0x2000, // Keyoff
C352_FLG_LOOPTRG = 0x1000, // Loop Trigger
C352_FLG_LOOPHIST = 0x0800, // Loop History
C352_FLG_FM = 0x0400, // Frequency Modulation
C352_FLG_PHASERL = 0x0200, // Rear Left invert phase 180 degrees
C352_FLG_PHASEFL = 0x0100, // Front Left invert phase 180 degrees
C352_FLG_PHASEFR = 0x0080, // invert phase 180 degrees (e.g. flip sign of sample)
C352_FLG_LDIR = 0x0040, // loop direction
C352_FLG_LINK = 0x0020, // "long-format" sample (can't loop, not sure what else it means)
C352_FLG_NOISE = 0x0010, // play noise instead of sample
C352_FLG_MULAW = 0x0008, // sample is mulaw instead of linear 8-bit PCM
C352_FLG_FILTER = 0x0004, // don't apply filter
C352_FLG_REVLOOP = 0x0003, // loop backwards
C352_FLG_LOOP = 0x0002, // loop forward
C352_FLG_REVERSE = 0x0001, // play sample backwards
C352_FLG_BUSY = 0x8000, // channel is busy
C352_FLG_KEYON = 0x4000, // Keyon
C352_FLG_KEYOFF = 0x2000, // Keyoff
C352_FLG_LOOPTRG = 0x1000, // Loop Trigger
C352_FLG_LOOPHIST = 0x0800, // Loop History
C352_FLG_FM = 0x0400, // Frequency Modulation
C352_FLG_PHASERL = 0x0200, // Rear Left invert phase 180 degrees
C352_FLG_PHASEFL = 0x0100, // Front Left invert phase 180 degrees
C352_FLG_PHASEFR = 0x0080, // invert phase 180 degrees (e.g. flip sign of sample)
C352_FLG_LDIR = 0x0040, // loop direction
C352_FLG_LINK = 0x0020, // "long-format" sample (can't loop, not sure what else it means)
C352_FLG_NOISE = 0x0010, // play noise instead of sample
C352_FLG_MULAW = 0x0008, // sample is mulaw instead of linear 8-bit PCM
C352_FLG_FILTER = 0x0004, // don't apply filter
C352_FLG_REVLOOP = 0x0003, // loop backwards
C352_FLG_LOOP = 0x0002, // loop forward
C352_FLG_REVERSE = 0x0001 // play sample backwards
};
typedef struct
typedef struct {
UINT32 pos;
UINT32 counter;
INT16 sample;
INT16 last_sample;
UINT16 vol_f;
UINT16 vol_r;
UINT16 freq;
UINT16 flags;
UINT16 wave_bank;
UINT16 wave_start;
UINT16 wave_end;
UINT16 wave_loop;
int mute;
} C352_Voice;
typedef struct {
UINT32 rate;
UINT8 muteRear;
C352_Voice v[C352_VOICES];
UINT16 control1; // unknown purpose for both
UINT16 control2;
UINT8* wave;
UINT32 wavesize;
UINT32 wave_mask;
UINT16 random;
INT16 mulaw[256];
} C352;
void C352_generate_mulaw(C352 *c)
{
UINT8 vol_l;
UINT8 vol_r;
UINT8 vol_l2;
UINT8 vol_r2;
UINT8 bank;
UINT8 Muted;
int i;
double x_max = 32752.0;
double y_max = 127.0;
double u = 10.0;
INT16 noise;
INT16 noisebuf;
UINT16 noisecnt;
UINT16 pitch;
UINT16 start_addr;
UINT16 end_addr;
UINT16 repeat_addr;
UINT32 flag;
// generate mulaw table for mulaw format samples
for (i = 0; i < 256; i++)
{
double y = (double) (i & 0x7f);
double x = (exp (y / y_max * log (1.0 + u)) - 1.0) * x_max / u;
UINT16 start;
UINT16 repeat;
UINT32 current_addr;
UINT32 pos;
} c352_ch_t;
typedef struct _c352_state c352_state;
struct _c352_state
{
//sound_stream *stream;
c352_ch_t c352_ch[32];
unsigned char *c352_rom_samples;
UINT32 c352_rom_length;
int sample_rate_base;
/*long channel_l[2048*2];
long channel_r[2048*2];
long channel_l2[2048*2];
long channel_r2[2048*2];*/
short mulaw_table[256];
unsigned int mseq_reg;
};
/*INLINE c352_state *get_safe_token(running_device *device)
{
assert(device != NULL);
assert(device->type() == C352);
return (c352_state *)downcast<legacy_device_base *>(device)->token();
}*/
// noise generator
static int get_mseq_bit(c352_state *info)
{
unsigned int mask = (1 << (7 - 1));
unsigned int reg = info->mseq_reg;
unsigned int bit = reg & (1 << (17 - 1));
if (bit)
{
reg = ((reg ^ mask) << 1) | 1;
}
else
{
reg = reg << 1;
}
info->mseq_reg = reg;
return (reg & 1);
if (i & 0x80)
x = -x;
c->mulaw[i] = (short)x;
}
}
/* ctr: this function gets the next sample for the lerp. If the sample position pointer is adjacent to the sample end pointer,
then lerping the sample with the "nextsample" variable causes clicks. To prevent this, simply check if the next sample is
the final sample and if so go to the beginning sample.
If bidi samples causes problems, add a case for that as well. (they might)
*/
char getnextsample(c352_state *chip, c352_ch_t* c352ch, UINT32 pos)
void C352_fetch_sample(C352 *c, int i)
{
INT32 flag = c352ch->flag;
UINT32 bank = c352ch->bank << 16;
C352_Voice *v = &c->v[i];
v->last_sample = v->sample;
if( flag & C352_FLG_REVERSE)
return (char) chip->c352_rom_samples[pos+1]; // todo: Bidi samples
if(v->flags & C352_FLG_NOISE)
{
c->random = (c->random>>1) ^ (-(c->random&1)) & 0xfff6;
v->sample = (c->random&4) ? 0xc000 : 0x3fff;
pos++;
if (
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) < c352ch->start) && (c352ch->start > c352ch->end_addr) ) ||
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) > c352ch->start) && (c352ch->start < c352ch->end_addr) ) ||
((pos > (bank|0xFFFF)) && (c352ch->end_addr == 0xFFFF))
)
{
if ( (flag & C352_FLG_LINK) && (flag & C352_FLG_LOOP) )
pos = ((c352ch->start_addr & 0xFF)<<16) + c352ch->repeat_addr;
else if (flag & C352_FLG_LOOP)
pos = (pos & 0xFF0000) + c352ch->repeat;
else
{
// key off at this point, just return the previous value
return (char) chip->c352_rom_samples[pos-1];
}
}
return (char) chip->c352_rom_samples[pos];
v->last_sample = v->sample; // No interpolation for noise samples
}
else
{
INT8 s;
UINT16 pos;
s = (INT8)c->wave[v->pos&0xffffff];
if(v->flags & C352_FLG_MULAW)
v->sample = c->mulaw[(uint8_t)s];
else
v->sample = s<<8;
pos = v->pos&0xffff;
if((v->flags & C352_FLG_LOOP) && v->flags & C352_FLG_REVERSE)
{
// backwards>forwards
if((v->flags & C352_FLG_LDIR) && pos == v->wave_loop)
v->flags &= ~C352_FLG_LDIR;
// forwards>backwards
else if(!(v->flags & C352_FLG_LDIR) && pos == v->wave_end)
v->flags |= C352_FLG_LDIR;
v->pos += (v->flags&C352_FLG_LDIR) ? -1 : 1;
}
else if(pos == v->wave_end)
{
if((v->flags & C352_FLG_LINK) && (v->flags & C352_FLG_LOOP))
{
v->pos = (v->wave_start<<16) | v->wave_loop;
v->flags |= C352_FLG_LOOPHIST;
}
else if(v->flags & C352_FLG_LOOP)
{
v->pos = (v->pos&0xff0000) | v->wave_loop;
v->flags |= C352_FLG_LOOPHIST;
}
else
{
v->flags |= C352_FLG_KEYOFF;
v->flags &= ~C352_FLG_BUSY;
v->sample=0;
v->last_sample=0;
}
}
else
{
v->pos += (v->flags&C352_FLG_REVERSE) ? -1 : 1;
}
}
}
static void c352_mix_one_channel(c352_state *info, unsigned long ch, stream_sample_t **outputs, long sample_count)
UINT16 C352_update_voice(C352 *c, int i)
{
c352_ch_t* c352ch;
int i;
C352_Voice *v = &c->v[i];
INT32 temp;
signed short sample, nextsample;
signed short noisebuf;
UINT16 noisecnt;
INT32 delta, offset, cnt, flag;
UINT32 bank;
UINT32 pos;
if((v->flags & C352_FLG_BUSY) == 0)
return 0;
c352ch = &info->c352_ch[ch];
delta = c352ch->pitch;
v->counter += v->freq;
pos = c352ch->current_addr; // sample pointer
offset = c352ch->pos; // 16.16 fixed-point offset into the sample
flag = c352ch->flag;
bank = c352ch->bank << 16;
if(v->counter > 0x10000)
{
v->counter &= 0xffff;
C352_fetch_sample(c,i);
}
noisecnt = c352ch->noisecnt;
noisebuf = c352ch->noisebuf;
temp = v->sample;
for(i = 0 ; (i < sample_count) && (flag & C352_FLG_BUSY) ; i++)
{
offset += delta;
cnt = (offset>>16)&0x7fff;
if (cnt) // if there is a whole sample part, chop it off now that it's been applied
{
offset &= 0xffff;
}
if((v->flags & C352_FLG_FILTER) == 0)
temp = v->last_sample + (v->counter*(v->sample-v->last_sample)>>16);
if (pos >= info->c352_rom_length) // pretty sure this should be >= instead of > -Valley Bell
{
c352ch->flag &= ~C352_FLG_BUSY;
//return;
break; // ensure that it saves the variables
}
sample = (char)info->c352_rom_samples[pos];
//nextsample = (char)info->c352_rom_samples[pos+cnt];
nextsample = getnextsample(info, c352ch, pos);
// sample is muLaw, not 8-bit linear (Fighting Layer uses this extensively)
if (flag & C352_FLG_MULAW)
{
sample = info->mulaw_table[(unsigned char)sample];
nextsample = info->mulaw_table[(unsigned char)nextsample];
}
else
{
sample <<= 8;
nextsample <<= 8;
}
// play noise instead of sample data
if (flag & C352_FLG_NOISE)
{
int noise_level = 0x8000;
sample = c352ch->noise = (c352ch->noise << 1) | get_mseq_bit(info);
sample = (sample & (noise_level - 1)) - (noise_level >> 1);
if (sample > 0x7f)
{
sample = 0x7f;
}
else if (sample < 0)
{
sample = 0xff;
}
sample = info->mulaw_table[(unsigned char)sample];
if ( (pos+cnt) == pos )
{
noisebuf += sample;
noisecnt++;
//sample = noisebuf / noisecnt;
if (noisecnt) // avoid Divide By Zero crash -Valley Bell
sample = noisebuf / noisecnt;
else
sample = info->mulaw_table[0x7f];
}
else
{
if ( noisecnt )
{
sample = noisebuf / noisecnt;
}
else
{
sample = info->mulaw_table[0x7f]; // Nearest sound(s) is here.
}
noisebuf = 0;
noisecnt = ( flag & C352_FLG_FILTER ) ? 0 : 1;
}
}
// apply linear interpolation
if ( (flag & (C352_FLG_FILTER | C352_FLG_NOISE)) == 0 )
{
sample = (short)(sample + ((nextsample-sample) * (((double)(0x0000ffff&offset) )/0x10000)));
}
if ( flag & C352_FLG_PHASEFL )
{
//info->channel_l[i] += ((-sample * c352ch->vol_l)>>8);
outputs[0][i] += ((-sample * c352ch->vol_l)>>8);
}
else
{
//info->channel_l[i] += ((sample * c352ch->vol_l)>>8);
outputs[0][i] += ((sample * c352ch->vol_l)>>8);
}
if ( flag & C352_FLG_PHASEFR )
{
//info->channel_r[i] += ((-sample * c352ch->vol_r)>>8);
outputs[1][i] += ((-sample * c352ch->vol_r)>>8);
}
else
{
//info->channel_r[i] += ((sample * c352ch->vol_r)>>8);
outputs[1][i] += ((sample * c352ch->vol_r)>>8);
}
if ( flag & C352_FLG_PHASERL )
{
//info->channel_l2[i] += ((-sample * c352ch->vol_l2)>>8);
outputs[0][i] += ((-sample * c352ch->vol_l2)>>8);
}
else
{
//info->channel_l2[i] += ((sample * c352ch->vol_l2)>>8);
outputs[0][i] += ((sample * c352ch->vol_l2)>>8);
}
//info->channel_r2[i] += ((sample * c352ch->vol_r2)>>8);
outputs[1][i] += ((sample * c352ch->vol_r2)>>8);
if ( (flag & C352_FLG_REVERSE) && (flag & C352_FLG_LOOP) )
{
if ( !(flag & C352_FLG_LDIR) )
{
pos += cnt;
if (
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) < c352ch->start) && (c352ch->start > c352ch->end_addr) ) ||
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) > c352ch->start) && (c352ch->start < c352ch->end_addr) ) ||
((pos > (bank|0xFFFF)) && (c352ch->end_addr == 0xFFFF))
)
{
c352ch->flag |= C352_FLG_LDIR;
c352ch->flag |= C352_FLG_LOOPHIST;
}
}
else
{
pos -= cnt;
if (
(((pos&0xFFFF) < c352ch->repeat) && ((pos&0xFFFF) < c352ch->end_addr) && (c352ch->end_addr > c352ch->start) ) ||
(((pos&0xFFFF) < c352ch->repeat) && ((pos&0xFFFF) > c352ch->end_addr) && (c352ch->end_addr < c352ch->start) ) ||
((pos < bank) && (c352ch->repeat == 0x0000))
)
{
c352ch->flag &= ~C352_FLG_LDIR;
c352ch->flag |= C352_FLG_LOOPHIST;
}
}
}
else if ( flag & C352_FLG_REVERSE )
{
pos -= cnt;
if (
(((pos&0xFFFF) < c352ch->end_addr) && ((pos&0xFFFF) < c352ch->start) && (c352ch->start > c352ch->end_addr) ) ||
(((pos&0xFFFF) < c352ch->end_addr) && ((pos&0xFFFF) > c352ch->start) && (c352ch->start < c352ch->end_addr) ) ||
((pos < bank) && (c352ch->end_addr == 0x0000))
)
{
if ( (flag & C352_FLG_LINK) && (flag & C352_FLG_LOOP) )
{
c352ch->bank = c352ch->start_addr & 0xFF;
c352ch->start_addr = c352ch->repeat_addr;
c352ch->start = c352ch->start_addr;
c352ch->repeat = c352ch->repeat_addr;
pos = (c352ch->bank<<16) + c352ch->start_addr;
c352ch->flag |= C352_FLG_LOOPHIST;
}
else if (flag & C352_FLG_LOOP)
{
pos = (pos & 0xFF0000) + c352ch->repeat;
c352ch->flag |= C352_FLG_LOOPHIST;
}
else
{
c352ch->flag |= C352_FLG_KEYOFF;
c352ch->flag &= ~C352_FLG_BUSY;
//return;
break;
}
}
} else {
pos += cnt;
if (
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) < c352ch->start) && (c352ch->start > c352ch->end_addr) ) ||
(((pos&0xFFFF) > c352ch->end_addr) && ((pos&0xFFFF) > c352ch->start) && (c352ch->start < c352ch->end_addr) ) ||
((pos > (bank|0xFFFF)) && (c352ch->end_addr == 0xFFFF))
)
{
if ( (flag & C352_FLG_LINK) && (flag & C352_FLG_LOOP) )
{
c352ch->bank = c352ch->start_addr & 0xFF;
c352ch->start_addr = c352ch->repeat_addr;
c352ch->start = c352ch->start_addr;
c352ch->repeat = c352ch->repeat_addr;
pos = (c352ch->bank<<16) + c352ch->start_addr;
c352ch->flag |= C352_FLG_LOOPHIST;
}
else if (flag & C352_FLG_LOOP)
{
pos = (pos & 0xFF0000) + c352ch->repeat;
c352ch->flag |= C352_FLG_LOOPHIST;
}
else
{
c352ch->flag |= C352_FLG_KEYOFF;
c352ch->flag &= ~C352_FLG_BUSY;
//return;
break;
}
}
}
}
c352ch->noisecnt = noisecnt;
c352ch->noisebuf = noisebuf;
c352ch->pos = offset;
c352ch->current_addr = pos;
return temp;
}
//static STREAM_UPDATE( c352_update )
void c352_update(void *param, stream_sample_t **outputs, int samples)
void c352_update(void *_info, stream_sample_t **outputs, int samples)
{
c352_state *info = (c352_state *)param;
int j;
/*stream_sample_t *bufferl = outputs[0];
stream_sample_t *bufferr = outputs[1];
stream_sample_t *bufferl2 = outputs[2];
stream_sample_t *bufferr2 = outputs[3];
C352 *c = (C352 *) _info;
int i, j;
INT16 s;
memset(outputs[0], 0x00, samples * sizeof(stream_sample_t));
memset(outputs[1], 0x00, samples * sizeof(stream_sample_t));
for(i = 0 ; i < samples ; i++)
{
info->channel_l[i] = info->channel_r[i] = info->channel_l2[i] = info->channel_r2[i] = 0;
}*/
memset(outputs[0], 0x00, samples * sizeof(stream_sample_t));
memset(outputs[1], 0x00, samples * sizeof(stream_sample_t));
for(i=0;i<samples;i++)
{
for(j=0;j<32;j++)
{
s = C352_update_voice(c,j);
if(!c->v[j].mute)
{
// Left
outputs[0][i] += (c->v[j].flags & C352_FLG_PHASEFL) ? (-s * (c->v[j].vol_f>>8) )>>8
: ( s * (c->v[j].vol_f>>8) )>>8;
if (!c->muteRear)
outputs[0][i] += (c->v[j].flags & C352_FLG_PHASERL) ? (-s * (c->v[j].vol_r>>8) )>>8
: ( s * (c->v[j].vol_r>>8) )>>8;
for (j = 0 ; j < 32 ; j++)
{
//c352_mix_one_channel(info, j, samples);
if ((info->c352_ch[j].flag & C352_FLG_BUSY) && ! info->c352_ch[j].Muted)
c352_mix_one_channel(info, j, outputs, samples);
}
// Right
outputs[1][i] += (c->v[j].flags & C352_FLG_PHASEFR) ? (-s * (c->v[j].vol_f&0xff))>>8
: ( s * (c->v[j].vol_f&0xff))>>8;
if (!c->muteRear)
outputs[1][i] += ( s * (c->v[j].vol_r&0xff))>>8;
}
}
/*for(i = 0 ; i < samples ; i++)
{
*bufferl++ = (short) (info->channel_l[i] >>3);
*bufferr++ = (short) (info->channel_r[i] >>3);
*bufferl2++ = (short) (info->channel_l2[i] >>3);
*bufferr2++ = (short) (info->channel_r2[i] >>3);
}*/
}
}
static unsigned short c352_read_reg16(c352_state *info, unsigned long address)
{
unsigned long chan;
unsigned short val;
//stream_update(info->stream);
chan = (address >> 4) & 0xfff;
if (chan > 31)
{
val = 0;
}
else
{
if ((address & 0xf) == 6)
{
val = info->c352_ch[chan].flag;
}
else
{
val = 0;
}
}
return val;
}
static void c352_write_reg16(c352_state *info, unsigned long address, unsigned short val)
{
unsigned long chan;
int i;
//stream_update(info->stream);
chan = (address >> 4) & 0xfff;
if ( address >= 0x400 )
{
switch(address)
{
case 0x404: // execute key-ons/offs
for ( i = 0 ; i <= 31 ; i++ )
{
if ( info->c352_ch[i].flag & C352_FLG_KEYON )
{
if (info->c352_ch[i].start_addr != info->c352_ch[i].end_addr)
{
info->c352_ch[i].current_addr = (info->c352_ch[i].bank << 16) + info->c352_ch[i].start_addr;
info->c352_ch[i].start = info->c352_ch[i].start_addr;
info->c352_ch[i].repeat = info->c352_ch[i].repeat_addr;
info->c352_ch[i].noisebuf = 0;
info->c352_ch[i].noisecnt = 0;
info->c352_ch[i].flag &= ~(C352_FLG_KEYON | C352_FLG_LOOPHIST);
info->c352_ch[i].flag |= C352_FLG_BUSY;
}
}
else if ( info->c352_ch[i].flag & C352_FLG_KEYOFF )
{
info->c352_ch[i].flag &= ~C352_FLG_BUSY;
info->c352_ch[i].flag &= ~(C352_FLG_KEYOFF);
}
}
break;
default:
break;
}
return;
}
if (chan > 31)
{
LOG(("C352 CTRL %08lx %04x\n", address, val));
return;
}
switch(address & 0xf)
{
case 0x0:
// volumes (output 1)
LOG(("CH %02ld LVOL %02x RVOL %02x\n", chan, val & 0xff, val >> 8));
info->c352_ch[chan].vol_l = val & 0xff;
info->c352_ch[chan].vol_r = val >> 8;
break;
case 0x2:
// volumes (output 2)
LOG(("CH %02ld RLVOL %02x RRVOL %02x\n", chan, val & 0xff, val >> 8));
info->c352_ch[chan].vol_l2 = val & 0xff;
info->c352_ch[chan].vol_r2 = val >> 8;
break;
case 0x4:
// pitch
LOG(("CH %02ld PITCH %04x\n", chan, val));
info->c352_ch[chan].pitch = val;
break;
case 0x6:
// flags
LOG(("CH %02ld FLAG %02x\n", chan, val));
info->c352_ch[chan].flag = val;
break;
case 0x8:
// bank (bits 16-31 of address);
info->c352_ch[chan].bank = val & 0xff;
LOG(("CH %02ld BANK %02x", chan, info->c352_ch[chan].bank));
break;
case 0xa:
// start address
LOG(("CH %02ld SADDR %04x\n", chan, val));
info->c352_ch[chan].start_addr = val;
break;
case 0xc:
// end address
LOG(("CH %02ld EADDR %04x\n", chan, val));
info->c352_ch[chan].end_addr = val;
break;
case 0xe:
// loop address
LOG(("CH %02ld LADDR %04x\n", chan, val));
info->c352_ch[chan].repeat_addr = val;
break;
default:
LOG(("CH %02ld UNKN %01lx %04x", chan, address & 0xf, val));
break;
}
}
//static DEVICE_START( c352 )
int device_start_c352(void **_info, int clock, int clkdiv)
{
//c352_state *info = get_safe_token(device);
c352_state *info;
int i;
double x_max = 32752.0;
double y_max = 127.0;
double u = 10.0;
C352 *c = calloc(1, sizeof(C352));
*_info = (void *) c;
info = (c352_state *) calloc(1, sizeof(c352_state));
*_info = (void *) info;
c->wave = NULL;
c->wavesize = 0x00;
//info->c352_rom_samples = *device->region();
//info->c352_rom_length = device->region()->bytes();
info->c352_rom_samples = NULL;
info->c352_rom_length = 0x00;
if(!clkdiv)
clkdiv = 288;
if (! clkdiv)
clkdiv = 288;
//info->sample_rate_base = device->clock() / 288;
info->sample_rate_base = clock / clkdiv;
c->rate = (clock&0x7FFFFFFF)/clkdiv;
c->muteRear = (clock&0x80000000)>>31;
//info->stream = stream_create(device, 0, 4, info->sample_rate_base, info, c352_update);
memset(c->v,0,sizeof(C352_Voice)*C352_VOICES);
// generate mulaw table for mulaw format samples
for (i = 0; i < 256; i++)
{
double y = (double) (i & 0x7f);
double x = (exp (y / y_max * log (1.0 + u)) - 1.0) * x_max / u;
c->control1 = 0;
c->control2 = 0;
c->random = 0x1234;
if (i & 0x80)
{
x = -x;
}
info->mulaw_table[i] = (short)x;
}
C352_generate_mulaw(c);
// register save state info
for (i = 0; i < 32; i++)
{
/*state_save_register_device_item(device, i, info->c352_ch[i].vol_l);
state_save_register_device_item(device, i, info->c352_ch[i].vol_r);
state_save_register_device_item(device, i, info->c352_ch[i].vol_l2);
state_save_register_device_item(device, i, info->c352_ch[i].vol_r2);
state_save_register_device_item(device, i, info->c352_ch[i].bank);
state_save_register_device_item(device, i, info->c352_ch[i].noise);
state_save_register_device_item(device, i, info->c352_ch[i].noisebuf);
state_save_register_device_item(device, i, info->c352_ch[i].noisecnt);
state_save_register_device_item(device, i, info->c352_ch[i].pitch);
state_save_register_device_item(device, i, info->c352_ch[i].start_addr);
state_save_register_device_item(device, i, info->c352_ch[i].end_addr);
state_save_register_device_item(device, i, info->c352_ch[i].repeat_addr);
state_save_register_device_item(device, i, info->c352_ch[i].flag);
state_save_register_device_item(device, i, info->c352_ch[i].start);
state_save_register_device_item(device, i, info->c352_ch[i].repeat);
state_save_register_device_item(device, i, info->c352_ch[i].current_addr);
state_save_register_device_item(device, i, info->c352_ch[i].pos);*/
info->c352_ch[i].Muted = 0x00;
}
return info->sample_rate_base;
return c->rate;
}
void device_stop_c352(void *_info)
{
c352_state *info = (c352_state *)_info;
C352 *c = (C352 *)_info;
free(info->c352_rom_samples);
info->c352_rom_samples = NULL;
free(c->wave);
c->wave = NULL;
free(info);
free(c);
return;
return;
}
void device_reset_c352(void *_info)
{
c352_state *info = (c352_state *)_info;
C352 *c = (C352 *) _info;
// clear all channels states
memset(info->c352_ch, 0, sizeof(c352_ch_t)*32);
memset(c->v,0,sizeof(C352_Voice)*C352_VOICES);
// init noise generator
info->mseq_reg = 0x12345678;
return;
return;
}
static const UINT16 C352RegMap[8] = {
offsetof(C352_Voice,vol_f) / sizeof(UINT16),
offsetof(C352_Voice,vol_r) / sizeof(UINT16),
offsetof(C352_Voice,freq) / sizeof(UINT16),
offsetof(C352_Voice,flags) / sizeof(UINT16),
offsetof(C352_Voice,wave_bank) / sizeof(UINT16),
offsetof(C352_Voice,wave_start) / sizeof(UINT16),
offsetof(C352_Voice,wave_end) / sizeof(UINT16),
offsetof(C352_Voice,wave_loop) / sizeof(UINT16),
};
//READ16_DEVICE_HANDLER( c352_r )
UINT16 c352_r(void *_info, offs_t offset)
{
c352_state *info = (c352_state *)_info;
return(c352_read_reg16(info, offset*2));
//return(c352_read_reg16(get_safe_token(device), offset*2));
C352 *c = (C352 *) _info;
if(offset < 0x100)
return *((UINT16*)&c->v[offset/8]+C352RegMap[offset%8]);
else
return 0;
}
//WRITE16_DEVICE_HANDLER( c352_w )
void c352_w(void *_info, offs_t offset, UINT16 data)
{
c352_state *info = (c352_state *)_info;
/*if (mem_mask == 0xffff)
{
c352_write_reg16(get_safe_token(device), offset*2, data);
}
else
{
logerror("C352: byte-wide write unsupported at this time!\n");
}*/
c352_write_reg16(info, offset*2, data);
C352 *c = (C352 *) _info;
int i;
if(offset < 0x100) // Channel registers, see map above.
*((UINT16*)&c->v[offset/8]+C352RegMap[offset%8]) = data;
else if(offset == 0x200) // Unknown purpose.
c->control1 = data;
else if(offset == 0x201)
c->control2 = data;
else if(offset == 0x202) // execute keyons/keyoffs
{
for(i=0;i<C352_VOICES;i++)
{
if((c->v[i].flags & C352_FLG_KEYON))
{
c->v[i].pos = (c->v[i].wave_bank<<16) | c->v[i].wave_start;
c->v[i].sample = 0;
c->v[i].last_sample = 0;
c->v[i].counter = 0x10000; // Immediate update
c->v[i].flags |= C352_FLG_BUSY;
c->v[i].flags &= ~(C352_FLG_KEYON|C352_FLG_LOOPHIST);
}
else if(c->v[i].flags & C352_FLG_KEYOFF)
{
c->v[i].sample=0;
c->v[i].last_sample=0;
c->v[i].flags &= ~(C352_FLG_BUSY|C352_FLG_KEYOFF);
}
}
}
}
void c352_write_rom(void *_info, offs_t ROMSize, offs_t DataStart, offs_t DataLength,
const UINT8* ROMData)
const UINT8* ROMData)
{
c352_state *info = (c352_state *)_info;
C352 *c = (C352 *) _info;
if (info->c352_rom_length != ROMSize)
{
info->c352_rom_samples = (UINT8*)realloc(info->c352_rom_samples, ROMSize);
info->c352_rom_length = ROMSize;
memset(info->c352_rom_samples, 0xFF, ROMSize);
}
if (DataStart > ROMSize)
return;
if (DataStart + DataLength > ROMSize)
DataLength = ROMSize - DataStart;
if (c->wavesize != ROMSize)
{
c->wave = (UINT8*)realloc(c->wave, ROMSize);
c->wavesize = ROMSize;
memset(c->wave, 0xFF, ROMSize);
}
if (DataStart > ROMSize)
return;
if (DataStart + DataLength > ROMSize)
DataLength = ROMSize - DataStart;
memcpy(info->c352_rom_samples + DataStart, ROMData, DataLength);
memcpy(c->wave + DataStart, ROMData, DataLength);
return;
return;
}
void c352_set_mute_mask(void *_info, UINT32 MuteMask)
{
c352_state *info = (c352_state *)_info;
UINT8 CurChn;
C352 *c = (C352 *) _info;
UINT8 CurChn;
for (CurChn = 0; CurChn < 32; CurChn ++)
info->c352_ch[CurChn].Muted = (MuteMask >> CurChn) & 0x01;
for (CurChn = 0; CurChn < 32; CurChn ++)
c->v[CurChn].mute = (MuteMask >> CurChn) & 0x01;
return;
return;
}
/**************************************************************************
* Generic get_info
**************************************************************************/
/*DEVICE_GET_INFO( c352 )
{
switch (state)
{
// --- the following bits of info are returned as 64-bit signed integers ---
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(c352_state); break;
// --- the following bits of info are returned as pointers to data or functions ---
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( c352 ); break;
case DEVINFO_FCT_STOP: // nothing // break;
case DEVINFO_FCT_RESET: // nothing // break;
// --- the following bits of info are returned as NULL-terminated strings ---
case DEVINFO_STR_NAME: strcpy(info->s, "C352"); break;
case DEVINFO_STR_FAMILY: strcpy(info->s, "Namco PCM"); break;
case DEVINFO_STR_VERSION: strcpy(info->s, "1.1"); break;
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
DEFINE_LEGACY_SOUND_DEVICE(C352, c352);*/

View file

@ -55,7 +55,7 @@
//#include "emu.h"
#include <stdlib.h> // for rand()
#include <memory.h> // for memset()
#include <string.h> // for memset()
#include <math.h> // for pow()
#include "mamedef.h"
#include "c6280.h"
@ -397,6 +397,8 @@ UINT8 c6280m_r(void* chip, offs_t offset)
//c6280_t *info = get_safe_token(device);
c6280_t *info = (c6280_t *)chip;
//return h6280io_get_buffer(info->cpudevice);
if (offset == 0)
return info->select;
return 0;
}

View file

@ -10,7 +10,9 @@
#endif
#define EC_OOTAKE 0x00
#ifndef NULL
#define NULL ((void *)0)
#endif
typedef struct _c6280_state
{

View file

@ -5,7 +5,7 @@
// (Custom Driver to handle PCM Streams of YM2612 DAC and PWM.)
//
// Written on 3 February 2011 by Valley Bell
// Last Update: 13 April 2014
// Last Update: 04 October 2015
//
// Only for usage in non-commercial, VGM file related software.
@ -21,8 +21,7 @@
#include "mamedef.h"
#include "dac_control.h"
//#include "../ChipMapper.h"
void chip_reg_write(void *param, UINT8 ChipType, UINT8 ChipID, UINT8 Port, UINT8 Offset, UINT8 Data);
#include "../ChipMapper.h"
#define DAC_SMPL_RATE chip->SampleRate
@ -58,7 +57,9 @@ typedef struct _dac_control
UINT32 SampleRate;
} dac_control;
#ifndef NULL
#define NULL (void*)0
#endif
INLINE void daccontrol_SendCommand(dac_control *chip)
{
@ -176,10 +177,31 @@ INLINE void daccontrol_SendCommand(dac_control *chip)
Command = (chip->DstCommand & 0x00FF) >> 0;
Data = ChipData[0x00];
if (Port != 0xFF) // Send Channel Select
if (Port == 0xFF)
{
chip_reg_write(chip->param, chip->DstChipType, chip->DstChipID, 0x00, Command & 0x0F, Data);
}
else
{
UINT8 prevChn;
prevChn = Port; // by default don't restore channel
// get current channel for supported chips
if (chip->DstChipType == 0x05)
; // TODO
else if (chip->DstChipType == 0x05)
; // TODO
else if (chip->DstChipType == 0x1B)
prevChn = chip_reg_read(chip->param, 0x1B, chip->DstChipID, 0x00, 0x00);
// Send Channel Select
chip_reg_write(chip->param, chip->DstChipType, chip->DstChipID, 0x00, Command >> 4, Port);
// Send Data
chip_reg_write(chip->param, chip->DstChipType, chip->DstChipID, 0x00, Command & 0x0F, Data);
// Send Data
chip_reg_write(chip->param, chip->DstChipType, chip->DstChipID, 0x00, Command & 0x0F, Data);
// restore old channel
if (prevChn != Port)
chip_reg_write(chip->param, chip->DstChipType, chip->DstChipID, 0x00, Command >> 4, prevChn);
}
break;
// Generic support: 8-bit Register, 16-bit Data
case 0x1F: // QSound

View file

@ -1870,8 +1870,8 @@ calc_stereo (OPLL * opll, e_int32 out[2], e_int32 ch)
{
/* Maxim: added stereo control (multiply each side by a float in opll->pan[ch][side]) */
e_int32 l=0,r=0;
/* e_int32 b[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */
/* e_int32 r[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */
/* e_int32 b[4] = { 0, 0, 0, 0 };*/ /* Ignore, Right, Left, Center */
/* e_int32 r[4] = { 0, 0, 0, 0 };*/ /* Ignore, Right, Left, Center */
e_int32 i;
e_int32 channel;

View file

@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////
//
// Configuration for emulation libraries
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __EMUCONFIG_H__
#define __EMUCONFIG_H__
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
/////////////////////////////////////////////////////////////////////////////
//
// One of these has to be defined when compiling the library.
// Shouldn't be necessary for using it.
//
#if defined(EMU_COMPILE) && !defined(EMU_BIG_ENDIAN) && !defined(EMU_LITTLE_ENDIAN)
#error "Hi I forgot to set EMU_x_ENDIAN"
#endif
#if defined(EMU_COMPILE) && defined(EMU_BIG_ENDIAN) && defined(EMU_LITTLE_ENDIAN)
#error "Both byte orders should not be defined"
#endif
/////////////////////////////////////////////////////////////////////////////
//
// WIN32 native project definitions
//
/////////////////////////////////////////////////////////////////////////////
#if defined(WIN32) && !defined(__GNUC__)
#define EMU_CALL __fastcall
#define EMU_CALL_ __cdecl
#define EMU_INLINE __inline
#define uint8 unsigned char
#define uint16 unsigned short
#define uint32 unsigned int
#define uint64 unsigned __int64
#define sint8 signed char
#define sint16 signed short
#define sint32 signed int
#define sint64 signed __int64
/////////////////////////////////////////////////////////////////////////////
//
// LINUX / other platform definitions
//
/////////////////////////////////////////////////////////////////////////////
#else
//#if defined(__GNUC__) && defined(__i386__)
//#define EMU_CALL __attribute__((__regparm__(2)))
//#else
#define EMU_CALL
//#endif
#define EMU_CALL_
#define EMU_INLINE __inline
#ifdef HAVE_STDINT_H
#include <stdint.h>
#define uint8 uint8_t
#define uint16 uint16_t
#define uint32 uint32_t
#define uint64 uint64_t
#define sint8 int8_t
#define sint16 int16_t
#define sint32 int32_t
#define sint64 int64_t
#else
#define uint8 unsigned char
#define uint16 unsigned short
#define uint32 unsigned int
#define uint64 unsigned long long
#define sint8 signed char
#define sint16 signed short
#define sint32 signed int
#define sint64 signed long long
#endif
#endif
#ifdef EMU_BIG_ENDIAN
#define EMU_ENDIAN_XOR_L2H(x) (x)
#define EMU_ENDIAN_XOR_B2H(x) (0)
#else
#define EMU_ENDIAN_XOR_L2H(x) (0)
#define EMU_ENDIAN_XOR_B2H(x) (x)
#endif
// deprecated
#define EMU_ENDIAN_XOR(x) EMU_ENDIAN_XOR_L2H(x)
/////////////////////////////////////////////////////////////////////////////
#endif

View file

@ -117,7 +117,7 @@ static void es5503_halt_osc(ES5503Chip *chip, int onum, int type, UINT32 *accumu
ES5503Osc *pOsc = &chip->oscillators[onum];
ES5503Osc *pPartner = &chip->oscillators[onum^1];
int mode = (pOsc->control>>1) & 3;
int omode = (pPartner->control>>1) & 3;
//int omode = (pPartner->control>>1) & 3;
// if 0 found in sample data or mode is not free-run, halt this oscillator
if ((mode != MODE_FREE) || (type != 0))
@ -143,7 +143,7 @@ static void es5503_halt_osc(ES5503Chip *chip, int onum, int type, UINT32 *accumu
// if swap mode, start the partner
// Note: The swap mode fix breaks Silpheed and other games.
if ((mode == MODE_SWAP) /*|| (omode == MODE_SWAP)*/)
if (/*(*/mode == MODE_SWAP/*)*/ /*|| (omode == MODE_SWAP)*/)
{
pPartner->control &= ~1; // clear the halt bit
pPartner->accumulator = 0; // and make sure it starts from the top (does this also need phase preservation?)

View file

@ -617,6 +617,9 @@ reverse:
while (samples--)
{
/* fetch two samples */
#ifdef VGM_BIG_ENDIAN
#warning "ES5506 sound emulation not Endian-Safe!"
#endif
INT32 val1 = base[accum >> 11];
INT32 val2 = base[((accum + (1 << 11)) & voice->accum_mask) >> 11];
@ -655,6 +658,9 @@ reverse:
while (samples--)
{
/* fetch two samples */
#ifdef VGM_BIG_ENDIAN
#warning "ES5506 sound emulation not Endian-Safe!"
#endif
INT32 val1 = base[accum >> 11];
INT32 val2 = base[((accum + (1 << 11)) & voice->accum_mask) >> 11];
@ -723,6 +729,9 @@ reverse:
while (samples--)
{
/* fetch two samples */
#ifdef VGM_BIG_ENDIAN
#warning "ES5506 sound emulation not Endian-Safe!"
#endif
INT32 val1 = (INT16)base[accum >> 11];
INT32 val2 = (INT16)base[((accum + (1 << 11)) & voice->accum_mask) >> 11];
@ -757,6 +766,9 @@ reverse:
while (samples--)
{
/* fetch two samples */
#ifdef VGM_BIG_ENDIAN
#warning "ES5506 sound emulation not Endian-Safe!"
#endif
INT32 val1 = (INT16)base[accum >> 11];
INT32 val2 = (INT16)base[((accum + (1 << 11)) & voice->accum_mask) >> 11];
@ -852,7 +864,9 @@ static void generate_samples(es5506_state *chip, INT32 **outputs, int offset, in
/* does this voice have it's IRQ bit raised? */
if (voice->control&CONTROL_IRQ)
{
#ifdef _DEBUG
logerror("es5506: IRQ raised on voice %d!!\n",v);
#endif
/* only update voice vector if existing IRQ is acked by host */
if (chip->irqv&0x80)
{
@ -925,7 +939,7 @@ static void es5506_start_common(es5506_state *chip, int clock, UINT8 sndtype)
chip->sndtype = sndtype;
/* only override the number of channels if the value is in the valid range 1 .. 6 */
max_chns = chip->sndtype ? 6 : 4; // 6 for ES5506, 4 for ES5505
if (chip->channels < 1|| chip->channels > max_chns)
if (chip->channels < 1 || chip->channels > max_chns)
chip->channels = 1; /* 1 channel by default, for backward compatibility */
/* debugging */
@ -2141,7 +2155,9 @@ INLINE UINT16 es5505_reg_read_high(es5506_state *chip, es5506_voice *voice, offs
if ((voice->control & CONTROL_STOPMASK) && chip->region_base[voice->control >> 14])
{
voice->o1n1 = chip->region_base[voice->control >> 14][voice->exbank + (voice->accum >> 11)];
#ifdef _DEBUG
logerror("%02x %08x ==> %08x\n",voice->o1n1,voice->control >> 14,voice->exbank + (voice->accum >> 11));
#endif
}
result = voice->o1n1;
break;

View file

@ -2480,111 +2480,6 @@ typedef YM2610 YM2608;
/* Algorithm and tables verified on real YM2608 and YM2610 */
#ifdef __clang__
#define Init_ADPCMATable()
static const int jedi_table[49 * 16] =
{
2, 6, 10, 14, 18, 22, 26, 30,
-2, -6, -10, -14, -18, -22, -26, -30,
2, 6, 10, 14, 19, 23, 27, 31,
-2, -6, -10, -14, -19, -23, -27, -31,
2, 7, 11, 16, 21, 26, 30, 35,
-2, -7, -11, -16, -21, -26, -30, -35,
2, 7, 13, 18, 23, 28, 34, 39,
-2, -7, -13, -18, -23, -28, -34, -39,
2, 8, 14, 20, 25, 31, 37, 43,
-2, -8, -14, -20, -25, -31, -37, -43,
3, 9, 15, 21, 28, 34, 40, 46,
-3, -9, -15, -21, -28, -34, -40, -46,
3, 10, 17, 24, 31, 38, 45, 52,
-3, -10, -17, -24, -31, -38, -45, -52,
3, 11, 19, 27, 34, 42, 50, 58,
-3, -11, -19, -27, -34, -42, -50, -58,
4, 12, 21, 29, 38, 46, 55, 63,
-4, -12, -21, -29, -38, -46, -55, -63,
4, 13, 23, 32, 41, 50, 60, 69,
-4, -13, -23, -32, -41, -50, -60, -69,
5, 15, 25, 35, 46, 56, 66, 76,
-5, -15, -25, -35, -46, -56, -66, -76,
5, 16, 28, 39, 50, 61, 73, 84,
-5, -16, -28, -39, -50, -61, -73, -84,
6, 18, 31, 43, 56, 68, 81, 93,
-6, -18, -31, -43, -56, -68, -81, -93,
6, 20, 34, 48, 61, 75, 89, 103,
-6, -20, -34, -48, -61, -75, -89, -103,
7, 22, 37, 52, 67, 82, 97, 112,
-7, -22, -37, -52, -67, -82, -97, -112,
8, 24, 41, 57, 74, 90, 107, 123,
-8, -24, -41, -57, -74, -90, -107, -123,
9, 27, 45, 63, 82, 100, 118, 136,
-9, -27, -45, -63, -82, -100, -118, -136,
10, 30, 50, 70, 90, 110, 130, 150,
-10, -30, -50, -70, -90, -110, -130, -150,
11, 33, 55, 77, 99, 121, 143, 165,
-11, -33, -55, -77, -99, -121, -143, -165,
12, 36, 60, 84, 109, 133, 157, 181,
-12, -36, -60, -84, -109, -133, -157, -181,
13, 40, 66, 93, 120, 147, 173, 200,
-13, -40, -66, -93, -120, -147, -173, -200,
14, 44, 73, 103, 132, 162, 191, 221,
-14, -44, -73, -103, -132, -162, -191, -221,
16, 48, 81, 113, 146, 178, 211, 243,
-16, -48, -81, -113, -146, -178, -211, -243,
17, 53, 89, 125, 160, 196, 232, 268,
-17, -53, -89, -125, -160, -196, -232, -268,
19, 58, 98, 137, 176, 215, 255, 294,
-19, -58, -98, -137, -176, -215, -255, -294,
21, 64, 108, 151, 194, 237, 281, 324,
-21, -64, -108, -151, -194, -237, -281, -324,
23, 71, 118, 166, 213, 261, 308, 356,
-23, -71, -118, -166, -213, -261, -308, -356,
26, 78, 130, 182, 235, 287, 339, 391,
-26, -78, -130, -182, -235, -287, -339, -391,
28, 86, 143, 201, 258, 316, 373, 431,
-28, -86, -143, -201, -258, -316, -373, -431,
31, 94, 158, 221, 284, 347, 411, 474,
-31, -94, -158, -221, -284, -347, -411, -474,
34, 104, 174, 244, 313, 383, 453, 523,
-34, -104, -174, -244, -313, -383, -453, -523,
38, 115, 191, 268, 345, 422, 498, 575,
-38, -115, -191, -268, -345, -422, -498, -575,
42, 126, 210, 294, 379, 463, 547, 631,
-42, -126, -210, -294, -379, -463, -547, -631,
46, 139, 231, 324, 417, 510, 602, 695,
-46, -139, -231, -324, -417, -510, -602, -695,
51, 153, 255, 357, 459, 561, 663, 765,
-51, -153, -255, -357, -459, -561, -663, -765,
56, 168, 280, 392, 505, 617, 729, 841,
-56, -168, -280, -392, -505, -617, -729, -841,
61, 185, 308, 432, 555, 679, 802, 926,
-61, -185, -308, -432, -555, -679, -802, -926,
68, 204, 340, 476, 612, 748, 884, 1020,
-68, -204, -340, -476, -612, -748, -884, -1020,
74, 224, 373, 523, 672, 822, 971, 1121,
-74, -224, -373, -523, -672, -822, -971, -1121,
82, 246, 411, 575, 740, 904, 1069, 1233,
-82, -246, -411, -575, -740, -904, -1069, -1233,
90, 271, 452, 633, 814, 995, 1176, 1357,
-90, -271, -452, -633, -814, -995, -1176, -1357,
99, 298, 497, 696, 895, 1094, 1293, 1492,
-99, -298, -497, -696, -895, -1094, -1293, -1492,
109, 328, 547, 766, 985, 1204, 1423, 1642,
-109, -328, -547, -766, -985, -1204, -1423, -1642,
120, 361, 601, 842, 1083, 1324, 1564, 1805,
-120, -361, -601, -842, -1083, -1324, -1564, -1805,
132, 397, 662, 927, 1192, 1457, 1722, 1987,
-132, -397, -662, -927, -1192, -1457, -1722, -1987,
145, 437, 728, 1020, 1311, 1603, 1894, 2186,
-145, -437, -728, -1020, -1311, -1603, -1894, -2186,
160, 480, 801, 1121, 1442, 1762, 2083, 2403,
-160, -480, -801, -1121, -1442, -1762, -2083, -2403,
176, 529, 881, 1234, 1587, 1940, 2292, 2645,
-176, -529, -881, -1234, -1587, -1940, -2292, -2645,
194, 582, 970, 1358, 1746, 2134, 2522, 2910,
-194, -582, -970, -1358, -1746, -2134, -2522, -2910,
};
#else
/* usual ADPCM table (16 * 1.1^N) */
static const int steps[49] =
{
@ -2597,29 +2492,27 @@ static const int steps[49] =
876, 963, 1060, 1166, 1282, 1411, 1552
};
/* speedup purposes only */
static int jedi_table[ 49*16 ];
/* clang with Xcode 7.2.1 mis-optimizes the !(nib&0x08) steps to zero when compiled with -Os */
static void Init_ADPCMATable(void)
{
int step, nib;
for (step = 0; step < 49; step++)
{
/* loop over all nibbles and compute the difference */
for (nib = 0; nib < 16; nib++)
{
int value = (2*(nib & 0x07) + 1) * steps[step] / 8;
jedi_table[step*16 + nib] = (nib&0x08) ? -value : value;
}
}
}
#endif
/* different from the usual ADPCM table */
static const int step_inc[8] = { -1*16, -1*16, -1*16, -1*16, 2*16, 5*16, 7*16, 9*16 };
/* speedup purposes only */
static int jedi_table[ 49*16 ];
static void Init_ADPCMATable(void)
{
int step, nib;
for (step = 0; step < 49; step++)
{
/* loop over all nibbles and compute the difference */
for (nib = 0; nib < 16; nib++)
{
int value = (2*(nib & 0x07) + 1) * steps[step] / 8;
jedi_table[step*16 + nib] = (nib&0x08) ? -value : value;
}
}
}
/* ADPCM A (Non control type) : calculate one channel output */
INLINE void ADPCMA_calc_chan( YM2610 *F2610, ADPCM_CH *ch )
@ -4072,12 +3965,16 @@ void ym2610_update_one(void *chip, FMSAMPLE **buffer, int length)
/* Check YM2610B warning message */
if( FM_KEY_IS(&F2610->CH[0].SLOT[3]) )
{
#ifdef _DEBUG
LOG(LOG_WAR,(FM_MSG_YM2610B,F2610->OPN.ST.param,0));
#endif
FM_KEY_IS(&F2610->CH[0].SLOT[3]) = 0;
}
if( FM_KEY_IS(&F2610->CH[3].SLOT[3]) )
{
#ifdef _DEBUG
LOG(LOG_WAR,(FM_MSG_YM2610B,F2610->OPN.ST.param,3));
#endif
FM_KEY_IS(&F2610->CH[3].SLOT[3]) = 0;
}
#endif
@ -4532,11 +4429,6 @@ void ym2610_reset_chip(void *chip)
}
else
F2610->deltaT.memory_size = dev->machine->region(name)->bytes();*/
F2610->pcmbuf = NULL;
F2610->pcm_size = 0x00;
F2610->deltaT.memory = NULL;
F2610->deltaT.memory_size = 0x00;
F2610->deltaT.memory_mask = 0x00;
/* Reset Prescaler */
OPNSetPres( OPN, 6*24, 6*24, 4*2); /* OPN 1/6 , SSG 1/4 */

View file

@ -130,12 +130,14 @@
//#include "emu.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>
#include "mamedef.h"
#include "fm.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/* shared function building option */
#define BUILD_OPN (BUILD_YM2203||BUILD_YM2608||BUILD_YM2610||BUILD_YM2610B||BUILD_YM2612||BUILD_YM3438)

View file

@ -73,7 +73,7 @@ Revision History:
#include <stdio.h>
#endif
#include <stdlib.h>
#include <memory.h>
#include <string.h>
//#include "sndintrf.h"
#include "fmopl.h"
#if BUILD_Y8950
@ -81,7 +81,9 @@ Revision History:
#endif
#ifndef NULL
#define NULL ((void *)0)
#endif
/* output final shift */
@ -2546,6 +2548,10 @@ void *y8950_init(UINT32 clock, UINT32 rate)
FM_OPL *Y8950 = OPLCreate(clock,rate,OPL_TYPE_Y8950);
if (Y8950)
{
Y8950->deltat->memory = NULL;
Y8950->deltat->memory_size = 0x00;
Y8950->deltat->memory_mask = 0x00;
Y8950->deltat->status_set_handler = Y8950_deltat_status_set;
Y8950->deltat->status_reset_handler = Y8950_deltat_status_reset;
Y8950->deltat->status_change_which_chip = Y8950;

View file

@ -41,7 +41,7 @@
#include "mamedef.h"
#include <stdlib.h> // for rand
#include <memory.h> // for memset
#include <string.h> // for memset
//#include "emu.h"
#include "gb.h"
//#include "streams.h"

View file

@ -28,7 +28,7 @@ Revisions:
//#include "emu.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stddef.h> // for NULL
#include "mamedef.h"
#include "iremga20.h"
@ -213,7 +213,9 @@ UINT8 irem_ga20_r(void *_info, offs_t offset)
return chip->channel[channel].play ? 1 : 0;
default:
#ifdef _DEBUG
logerror("GA20: read unk. register %d, channel %d\n", offset & 0xf, channel);
#endif
break;
}

View file

@ -24,7 +24,7 @@
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
//#include "emu.h"
//#include "streams.h"
#include "k051649.h"
@ -153,10 +153,10 @@ int device_start_k051649(void **_info, int clock)
/* get stream channels */
//info->rate = device->clock()/16;
info->rate = clock/16;
//info->stream = stream_create(device, 0, 1, info->rate, info, k051649_update);
//info->mclock = device->clock();
info->mclock = clock;
info->mclock = clock & 0x7FFFFFFF;
info->rate = info->mclock / 16;
/* allocate a buffer to mix into - 1 second's worth should be more than enough */
//info->mixer_buffer = auto_alloc_array(device->machine, short, 2 * info->rate);

View file

@ -10,10 +10,12 @@
#include <stdio.h>
#endif
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "k053260.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/* 2004-02-28: Fixed PPCM decoding. Games sound much better now.*/
@ -319,7 +321,9 @@ INLINE void check_bounds( k053260_state *ic, int channel )
int channel_end = channel_start + ic->channels[channel].size - 1;
if ( channel_start > ic->rom_size ) {
#ifdef _DEBUG
logerror("K53260: Attempting to start playing past the end of the ROM ( start = %06x, end = %06x ).\n", channel_start, channel_end );
#endif
ic->channels[channel].play = 0;
@ -327,11 +331,15 @@ INLINE void check_bounds( k053260_state *ic, int channel )
}
if ( channel_end > ic->rom_size ) {
#ifdef _DEBUG
logerror("K53260: Attempting to play past the end of the ROM ( start = %06x, end = %06x ).\n", channel_start, channel_end );
#endif
ic->channels[channel].size = ic->rom_size - channel_start;
}
#ifdef _DEBUG
if (LOG) logerror("K053260: Sample Start = %06x, Sample End = %06x, Sample rate = %04x, PPCM = %s\n", channel_start, channel_end, ic->channels[channel].rate, ic->channels[channel].ppcm ? "yes" : "no" );
#endif
}
//WRITE8_DEVICE_HANDLER( k053260_w )
@ -345,7 +353,9 @@ void k053260_w(void *_info, offs_t offset, UINT8 data)
k053260_state *ic = (k053260_state *)_info;
if ( r > 0x2f ) {
#ifdef _DEBUG
logerror("K053260: Writing past registers\n" );
#endif
return;
}
@ -480,7 +490,9 @@ UINT8 k053260_r(void *_info, offs_t offset)
if ( offs > ic->rom_size ) {
//logerror("%s: K53260: Attempting to read past ROM size in ROM Read Mode (offs = %06x, size = %06x).\n", device->machine().describe_context(),offs,ic->rom_size );
#ifdef _DEBUG
logerror("K53260: Attempting to read past ROM size in ROM Read Mode (offs = %06x, size = %06x).\n", offs,ic->rom_size );
#endif
return 0;
}

View file

@ -9,7 +9,7 @@
//#include "emu.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>
#include "mamedef.h"
#ifdef _DEBUG
@ -17,7 +17,9 @@
#endif
#include "k054539.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
#define VERBOSE 0
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
@ -149,7 +151,7 @@ void k054539_update(void *param, stream_sample_t **outputs, int samples)
static const INT16 dpcm[16] = {
0<<8, 1<<8, 4<<8, 9<<8, 16<<8, 25<<8, 36<<8, 49<<8,
-64<<8, -49<<8, -36<<8, -25<<8, -16<<8, -9<<8, -4<<8, -1<<8
-64*(1<<8), -49*(1<<8), -36*(1<<8), -25*(1<<8), -16*(1<<8), -9*(1<<8), -4*(1<<8), -1*(1<<8)
};
INT16 *rbase = (INT16 *)info->ram;
@ -331,7 +333,9 @@ void k054539_update(void *param, stream_sample_t **outputs, int samples)
break;
}
default:
#ifdef _DEBUG
LOG(("Unknown sample type %x for channel %d\n", base2[0] & 0xc, ch));
#endif
break;
}
lval += cur_val * lvol;
@ -553,12 +557,12 @@ void k054539_w(void *_info, offs_t offset, UINT8 data)
regbase[offset] = data;
}
static void reset_zones(k054539_state *info)
/*static void reset_zones(k054539_state *info)
{
int data = info->regs[0x22e];
info->cur_zone = data == 0x80 ? info->ram : info->rom + 0x20000*data;
info->cur_limit = data == 0x80 ? 0x4000 : 0x20000;
}
}*/
//READ8_DEVICE_HANDLER( k054539_r )
UINT8 k054539_r(void *_info, offs_t offset)
@ -578,7 +582,9 @@ UINT8 k054539_r(void *_info, offs_t offset)
case 0x22c:
break;
default:
#ifdef _DEBUG
LOG(("K054539 read %03x\n", offset));
#endif
break;
}
return info->regs[offset];

View file

@ -47,7 +47,9 @@ typedef INT32 stream_sample_t;
#else
#define INLINE static inline
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifdef _DEBUG
#define logerror printf

View file

@ -35,11 +35,13 @@
//#include "streams.h"
#include "mamedef.h"
#include <math.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "multipcm.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
//????
#define MULTIPCM_CLOCKDIV (180.0)

View file

@ -46,7 +46,7 @@
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stddef.h> // for NULL
//#include "emu.h"
//#include "streams.h"

View file

@ -5,7 +5,7 @@
****************************************************************/
#include "mamedef.h"
#include <memory.h> // for memset
#include <string.h> // for memset
#include <stdlib.h> // for free
#include <stddef.h> // for NULL
#include "../stdbool.h"

View file

@ -8,7 +8,7 @@
//#include <assert.h>
#include <stdlib.h>
#include <memory.h> // for memset()
#include <string.h> // for memset()
#include <stddef.h> // for NULL
#include "mamedef.h"
#include "../stdbool.h"

View file

@ -4,7 +4,7 @@
// (Note: Encoding is UTF-8)
#include <stdlib.h> // for rand()
#include <memory.h> // for memset()
#include <string.h> // for memset()
#include <stddef.h> // for NULL
#include "mamedef.h"
#include "../stdbool.h"
@ -532,7 +532,8 @@ void NES_DMC_np_SetClock(void* chip, double c)
dmc->clock = (UINT32)(c);
if (abs(dmc->clock - DEFAULT_CLK_PAL) <= 1000) // check for approximately DEFAULT_CLK_PAL
/* abs not needed, values are unsigned */
if (/*abs*/(dmc->clock - DEFAULT_CLK_PAL) <= 1000) // check for approximately DEFAULT_CLK_PAL
NES_DMC_np_SetPal(dmc, true);
else
NES_DMC_np_SetPal(dmc, false);

View file

@ -2,7 +2,7 @@
// by Valley Bell on 26 September 2013
#include <stdlib.h> // for rand()
#include <memory.h> // for memset()
#include <string.h> // for memset()
#include <stddef.h> // for NULL
#include <math.h> // for exp()
#include "mamedef.h"

View file

@ -19,7 +19,9 @@
#include <math.h>
#include "okim6258.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
#define COMMAND_STOP (1 << 0)
#define COMMAND_PLAY (1 << 1)
@ -403,7 +405,7 @@ void okim6258_set_divider(void *_info, int val)
{
//okim6258_state *info = get_safe_token(device);
okim6258_state *info = (okim6258_state *)_info;
int divider = dividers[val];
//int divider = dividers[val];
info->divider = dividers[val];
//stream_set_sample_rate(info->stream, info->master_clock / divider);
@ -500,7 +502,9 @@ static void okim6258_data_w(void *_info, /*offs_t offset, */UINT8 data)
info->data_buf_pos &= 0xF3;
if ((info->data_buf_pos >> 4) == (info->data_buf_pos & 0x0F))
{
#ifdef _DEBUG
logerror("Warning: FIFO full!\n");
#endif
info->data_buf_pos = (info->data_buf_pos & 0xF0) | ((info->data_buf_pos-1) & 0x03);
}
info->data_empty = 0x00;
@ -556,7 +560,9 @@ static void okim6258_ctrl_w(void *_info, /*offs_t offset, */UINT8 data)
if (data & COMMAND_RECORD)
{
#ifdef _DEBUG
logerror("M6258: Record enabled\n");
#endif
info->status |= STATUS_RECORDING;
}
else

View file

@ -26,7 +26,7 @@
//#include "streams.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>
#include "okim6295.h"
@ -661,7 +661,9 @@ void okim6295_write_command(okim6295_state *info, UINT8 data)
else
{
//logerror("OKIM6295:'%s' requested to play invalid sample %02x\n",device->tag(),info->command);
#ifdef _DEBUG
logerror("OKIM6295: Voice %u requested to play invalid sample %02x\n",i,info->command);
#endif
voice->playing = 0;
}
}

View file

@ -29,7 +29,7 @@
#include <math.h>
#include <stdlib.h> // rand()
#include <memory.h> // for memset()
#include <string.h> // for memset()
//#include "dosbox.h"
#include "../stdbool.h"
#include "opl.h"
@ -1158,7 +1158,7 @@ static void adlib_write(void *chip, Bitu idx, Bit8u val)
}
UINT32 ADLIBEMU(reg_read)(void *chip, UINT32 port)
Bitu ADLIBEMU(reg_read)(void *chip, UINT32 port)
{
OPL_DATA* OPL = (OPL_DATA*)chip;

View file

@ -30,6 +30,7 @@
/*
define Bits, Bitu, Bit32s, Bit32u, Bit16s, Bit16u, Bit8s, Bit8u here
*/
/*
#include <stdint.h>
typedef uintptr_t Bitu;
typedef intptr_t Bits;
@ -39,6 +40,16 @@ typedef uint16_t Bit16u;
typedef int16_t Bit16s;
typedef uint8_t Bit8u;
typedef int8_t Bit8s;
*/
typedef UINT32 Bitu;
typedef INT32 Bits;
typedef UINT32 Bit32u;
typedef INT32 Bit32s;
typedef UINT16 Bit16u;
typedef INT16 Bit16s;
typedef UINT8 Bit8u;
typedef INT8 Bit8s;
/*
define attribution that inlines/forces inlining of a function (optional)

View file

@ -553,11 +553,15 @@ static void poly_init(UINT8 *poly, int size, int left, int right, int add)
int mask = (1 << size) - 1;
int i, x = 0;
#ifdef _DEBUG
LOG_POLY(("poly %d\n", size));
#endif
for( i = 0; i < mask; i++ )
{
*poly++ = x & 1;
#ifdef _DEBUG
LOG_POLY(("%05x: %d\n", x, x&1));
#endif
/* calculate next bit */
x = ((x << left) + (x >> right) + add) & mask;
}
@ -568,14 +572,18 @@ static void rand_init(UINT8 *rng, int size, int left, int right, int add)
int mask = (1 << size) - 1;
int i, x = 0;
#ifdef _DEBUG
LOG_RAND(("rand %d\n", size));
#endif
for( i = 0; i < mask; i++ )
{
if (size == 17)
*rng = x >> 6; /* use bits 6..13 */
else
*rng = x; /* use bits 0..7 */
#ifdef _DEBUG
LOG_RAND(("%05x: %02x\n", x, *rng));
#endif
rng++;
/* calculate next bit */
x = ((x << left) + (x >> right) + add) & mask;

View file

@ -36,12 +36,14 @@
#ifdef _DEBUG
#include <stdio.h>
#endif
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "qsound.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/*
Debug defines
@ -223,7 +225,9 @@ void qsound_w(void *_info, offs_t offset, UINT8 data)
default:
//logerror("%s: unexpected qsound write to offset %d == %02X\n", device->machine().describe_context(), offset, data);
#ifdef _DEBUG
logerror("QSound: unexpected qsound write to offset %d == %02X\n", offset, data);
#endif
break;
}
}
@ -478,7 +482,7 @@ void qsound_set_mute_mask(void *_info, UINT32 MuteMask)
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}//
}*/
/**************** end of file ****************/

View file

@ -3,14 +3,16 @@
/*********************************************************/
#include "mamedef.h"
#include <memory.h>
#include <string.h>
#include <stdlib.h>
//#include "sndintrf.h"
//#include "streams.h"
#include "rf5c68.h"
#include <math.h>
#ifndef NULL
#define NULL ((void *)0)
#endif
#define NUM_CHANNELS (8)

View file

@ -66,7 +66,7 @@
//#include "emu.h"
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "saa1099.h"
@ -448,7 +448,9 @@ void saa1099_control_w(void *_info, offs_t offset, UINT8 data)
{
/* Error! */
//logerror("%s: (SAA1099 '%s') Unknown register selected\n",device->machine().describe_context(), device->tag());
#ifdef _DEBUG
logerror("SAA1099: Unknown register selected\n");
#endif
}
saa->selected_reg = data & 0x1f;
@ -537,7 +539,9 @@ void saa1099_data_w(void *_info, offs_t offset, UINT8 data)
/* Synch & Reset generators */
//logerror("%s: (SAA1099 '%s') -reg 0x1c- Chip reset\n",device->machine().describe_context(), device->tag());
#ifdef _DEBUG
logerror("SAA1099: -reg 0x1c- Chip reset\n");
#endif
for (i = 0; i < 6; i++)
{
saa->channels[i].level = 0;
@ -545,9 +549,11 @@ void saa1099_data_w(void *_info, offs_t offset, UINT8 data)
}
}
break;
#ifdef _DEBUG
default: /* Error! */
//logerror("%s: (SAA1099 '%s') Unknown operation (reg:%02x, data:%02x)\n",device->machine().describe_context(), device->tag(), reg, data);
logerror("SAA1099: Unknown operation (reg:%02x, data:%02x)\n",reg, data);
#endif
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,356 +0,0 @@
//#include "emu.h"
#include <memory.h> // for memset
#include "mamedef.h"
#include "scsp.h"
#include "scspdsp.h"
static UINT16 PACK(INT32 val)
{
UINT32 temp;
int sign,exponent,k;
sign = (val >> 23) & 0x1;
temp = (val ^ (val << 1)) & 0xFFFFFF;
exponent = 0;
for (k=0; k<12; k++)
{
if (temp & 0x800000)
break;
temp <<= 1;
exponent += 1;
}
if (exponent < 12)
val = (val << exponent) & 0x3FFFFF;
else
val <<= 11;
val >>= 11;
val &= 0x7FF;
val |= sign << 15;
val |= exponent << 11;
return (UINT16)val;
}
static INT32 UNPACK(UINT16 val)
{
int sign,exponent,mantissa;
INT32 uval;
sign = (val >> 15) & 0x1;
exponent = (val >> 11) & 0xF;
mantissa = val & 0x7FF;
uval = mantissa << 11;
if (exponent > 11)
{
exponent = 11;
uval |= sign << 22;
}
else
uval |= (sign ^ 1) << 22;
uval |= sign << 23;
uval <<= 8;
uval >>= 8;
uval >>= exponent;
return uval;
}
void SCSPDSP_Init(struct _SCSPDSP *DSP)
{
memset(DSP,0,sizeof(struct _SCSPDSP));
DSP->RBL=0x8000;
DSP->Stopped=1;
}
void SCSPDSP_Step(struct _SCSPDSP *DSP)
{
INT32 ACC=0; //26 bit
INT32 SHIFTED=0; //24 bit
INT32 X=0; //24 bit
INT32 Y=0; //13 bit
INT32 B=0; //26 bit
INT32 INPUTS=0; //24 bit
INT32 MEMVAL=0;
INT32 FRC_REG=0; //13 bit
INT32 Y_REG=0; //24 bit
UINT32 ADDR=0;
UINT32 ADRS_REG=0; //13 bit
int step;
if(DSP->Stopped)
return;
memset(DSP->EFREG,0,2*16);
#if 0
int dump=0;
FILE *f=NULL;
if(dump)
f=fopen("dsp.txt","wt");
#endif
for(step=0;step</*128*/DSP->LastStep;++step)
{
UINT16 *IPtr=DSP->MPRO+step*4;
// if(IPtr[0]==0 && IPtr[1]==0 && IPtr[2]==0 && IPtr[3]==0)
// break;
UINT32 TRA=(IPtr[0]>>8)&0x7F;
UINT32 TWT=(IPtr[0]>>7)&0x01;
UINT32 TWA=(IPtr[0]>>0)&0x7F;
UINT32 XSEL=(IPtr[1]>>15)&0x01;
UINT32 YSEL=(IPtr[1]>>13)&0x03;
UINT32 IRA=(IPtr[1]>>6)&0x3F;
UINT32 IWT=(IPtr[1]>>5)&0x01;
UINT32 IWA=(IPtr[1]>>0)&0x1F;
UINT32 TABLE=(IPtr[2]>>15)&0x01;
UINT32 MWT=(IPtr[2]>>14)&0x01;
UINT32 MRD=(IPtr[2]>>13)&0x01;
UINT32 EWT=(IPtr[2]>>12)&0x01;
UINT32 EWA=(IPtr[2]>>8)&0x0F;
UINT32 ADRL=(IPtr[2]>>7)&0x01;
UINT32 FRCL=(IPtr[2]>>6)&0x01;
UINT32 SHIFT=(IPtr[2]>>4)&0x03;
UINT32 YRL=(IPtr[2]>>3)&0x01;
UINT32 NEGB=(IPtr[2]>>2)&0x01;
UINT32 ZERO=(IPtr[2]>>1)&0x01;
UINT32 BSEL=(IPtr[2]>>0)&0x01;
UINT32 NOFL=(IPtr[3]>>15)&1; //????
UINT32 COEF=(IPtr[3]>>9)&0x3f;
UINT32 MASA=(IPtr[3]>>2)&0x1f; //???
UINT32 ADREB=(IPtr[3]>>1)&0x1;
UINT32 NXADR=(IPtr[3]>>0)&0x1;
INT64 v;
//operations are done at 24 bit precision
#if 0
if(MASA)
int a=1;
if(NOFL)
int a=1;
// int dump=0;
if(f)
{
#define DUMP(v) fprintf(f," " #v ": %04X",v);
fprintf(f,"%d: ",step);
DUMP(ACC);
DUMP(SHIFTED);
DUMP(X);
DUMP(Y);
DUMP(B);
DUMP(INPUTS);
DUMP(MEMVAL);
DUMP(FRC_REG);
DUMP(Y_REG);
DUMP(ADDR);
DUMP(ADRS_REG);
fprintf(f,"\n");
}
#endif
//INPUTS RW
// colmns97 hits this
// assert(IRA<0x32);
if(IRA<=0x1f)
INPUTS=DSP->MEMS[IRA];
else if(IRA<=0x2F)
INPUTS=DSP->MIXS[IRA-0x20]<<4; //MIXS is 20 bit
else if(IRA<=0x31)
INPUTS=0;
else
return;
INPUTS<<=8;
INPUTS>>=8;
//if(INPUTS&0x00800000)
// INPUTS|=0xFF000000;
if(IWT)
{
DSP->MEMS[IWA]=MEMVAL; //MEMVAL was selected in previous MRD
if(IRA==IWA)
INPUTS=MEMVAL;
}
//Operand sel
//B
if(!ZERO)
{
if(BSEL)
B=ACC;
else
{
B=DSP->TEMP[(TRA+DSP->DEC)&0x7F];
B<<=8;
B>>=8;
//if(B&0x00800000)
// B|=0xFF000000; //Sign extend
}
if(NEGB)
B=0-B;
}
else
B=0;
//X
if(XSEL)
X=INPUTS;
else
{
X=DSP->TEMP[(TRA+DSP->DEC)&0x7F];
X<<=8;
X>>=8;
//if(X&0x00800000)
// X|=0xFF000000;
}
//Y
if(YSEL==0)
Y=FRC_REG;
else if(YSEL==1)
Y=DSP->COEF[COEF]>>3; //COEF is 16 bits
else if(YSEL==2)
Y=(Y_REG>>11)&0x1FFF;
else if(YSEL==3)
Y=(Y_REG>>4)&0x0FFF;
if(YRL)
Y_REG=INPUTS;
//Shifter
if(SHIFT==0)
{
SHIFTED=ACC;
if(SHIFTED>0x007FFFFF)
SHIFTED=0x007FFFFF;
if(SHIFTED<(-0x00800000))
SHIFTED=-0x00800000;
}
else if(SHIFT==1)
{
SHIFTED=ACC*2;
if(SHIFTED>0x007FFFFF)
SHIFTED=0x007FFFFF;
if(SHIFTED<(-0x00800000))
SHIFTED=-0x00800000;
}
else if(SHIFT==2)
{
SHIFTED=ACC*2;
SHIFTED<<=8;
SHIFTED>>=8;
//SHIFTED&=0x00FFFFFF;
//if(SHIFTED&0x00800000)
// SHIFTED|=0xFF000000;
}
else if(SHIFT==3)
{
SHIFTED=ACC;
SHIFTED<<=8;
SHIFTED>>=8;
//SHIFTED&=0x00FFFFFF;
//if(SHIFTED&0x00800000)
// SHIFTED|=0xFF000000;
}
//ACCUM
Y<<=19;
Y>>=19;
//if(Y&0x1000)
// Y|=0xFFFFF000;
v=(((INT64) X*(INT64) Y)>>12);
ACC=(int) v+B;
if(TWT)
DSP->TEMP[(TWA+DSP->DEC)&0x7F]=SHIFTED;
if(FRCL)
{
if(SHIFT==3)
FRC_REG=SHIFTED&0x0FFF;
else
FRC_REG=(SHIFTED>>11)&0x1FFF;
}
if(MRD || MWT)
//if(0)
{
ADDR=DSP->MADRS[MASA];
if(!TABLE)
ADDR+=DSP->DEC;
if(ADREB)
ADDR+=ADRS_REG&0x0FFF;
if(NXADR)
ADDR++;
if(!TABLE)
ADDR&=DSP->RBL-1;
else
ADDR&=0xFFFF;
//ADDR<<=1;
//ADDR+=DSP->RBP<<13;
//MEMVAL=DSP->SCSPRAM[ADDR>>1];
ADDR+=DSP->RBP<<12;
if (ADDR > 0x7ffff) ADDR = 0;
if(MRD && (step&1)) //memory only allowed on odd? DoA inserts NOPs on even
{
if(NOFL)
MEMVAL=DSP->SCSPRAM[ADDR]<<8;
else
MEMVAL=UNPACK(DSP->SCSPRAM[ADDR]);
}
if(MWT && (step&1))
{
if(NOFL)
DSP->SCSPRAM[ADDR]=SHIFTED>>8;
else
DSP->SCSPRAM[ADDR]=PACK(SHIFTED);
}
}
if(ADRL)
{
if(SHIFT==3)
ADRS_REG=(SHIFTED>>12)&0xFFF;
else
ADRS_REG=(INPUTS>>16);
}
if(EWT)
DSP->EFREG[EWA]+=SHIFTED>>8;
}
--DSP->DEC;
memset(DSP->MIXS,0,4*16);
// if(f)
// fclose(f);
}
void SCSPDSP_SetSample(struct _SCSPDSP *DSP,INT32 sample,int SEL,int MXL)
{
//DSP->MIXS[SEL]+=sample<<(MXL+1)/*7*/;
DSP->MIXS[SEL]+=sample;
// if(MXL)
// int a=1;
}
void SCSPDSP_Start(struct _SCSPDSP *DSP)
{
int i;
DSP->Stopped=0;
for(i=127;i>=0;--i)
{
UINT16 *IPtr=DSP->MPRO+i*4;
if(IPtr[0]!=0 || IPtr[1]!=0 || IPtr[2]!=0 || IPtr[3]!=0)
break;
}
DSP->LastStep=i+1;
}

View file

@ -1,40 +0,0 @@
#pragma once
#ifndef __SCSPDSP_H__
#define __SCSPDSP_H__
//the DSP Context
struct _SCSPDSP
{
//Config
UINT16 *SCSPRAM;
UINT32 SCSPRAM_LENGTH;
UINT32 RBP; //Ring buf pointer
UINT32 RBL; //Delay ram (Ring buffer) size in words
//context
INT16 COEF[64]; //16 bit signed
UINT16 MADRS[32]; //offsets (in words), 16 bit
UINT16 MPRO[128*4]; //128 steps 64 bit
INT32 TEMP[128]; //TEMP regs,24 bit signed
INT32 MEMS[32]; //MEMS regs,24 bit signed
UINT32 DEC;
//input
INT32 MIXS[16]; //MIXS, 24 bit signed
INT16 EXTS[2]; //External inputs (CDDA) 16 bit signed
//output
INT16 EFREG[16]; //EFREG, 16 bit signed
int Stopped;
int LastStep;
};
void SCSPDSP_Init(struct _SCSPDSP *DSP);
void SCSPDSP_SetSample(struct _SCSPDSP *DSP, INT32 sample, INT32 SEL, INT32 MXL);
void SCSPDSP_Step(struct _SCSPDSP *DSP);
void SCSPDSP_Start(struct _SCSPDSP *DSP);
#endif /* __SCSPDSP_H__ */

View file

@ -1,165 +0,0 @@
/*
SCSP LFO handling
Part of the SCSP (YMF292-F) emulator package.
(not compiled directly, #included from scsp.c)
By ElSemi
MAME/M1 conversion and cleanup by R. Belmont
*/
#define LFO_SHIFT 8
struct _LFO
{
unsigned short phase;
UINT32 phase_step;
int *table;
int *scale;
};
#define LFIX(v) ((unsigned int) ((float) (1<<LFO_SHIFT)*(v)))
//Convert DB to multiply amplitude
#define DB(v) LFIX(pow(10.0,v/20.0))
//Convert cents to step increment
#define CENTS(v) LFIX(pow(2.0,v/1200.0))
static int PLFO_TRI[256],PLFO_SQR[256],PLFO_SAW[256],PLFO_NOI[256];
static int ALFO_TRI[256],ALFO_SQR[256],ALFO_SAW[256],ALFO_NOI[256];
static const float LFOFreq[32]=
{
0.17f,0.19f,0.23f,0.27f,0.34f,0.39f,0.45f,0.55f,0.68f,0.78f,0.92f,1.10f,1.39f,1.60f,1.87f,2.27f,
2.87f,3.31f,3.92f,4.79f,6.15f,7.18f,8.60f,10.8f,14.4f,17.2f,21.5f,28.7f,43.1f,57.4f,86.1f,172.3f
};
static const float ASCALE[8]={0.0f,0.4f,0.8f,1.5f,3.0f,6.0f,12.0f,24.0f};
static const float PSCALE[8]={0.0f,7.0f,13.5f,27.0f,55.0f,112.0f,230.0f,494.0f};
static int PSCALES[8][256];
static int ASCALES[8][256];
static UINT8 IsInit;
static void LFO_Init(/*running_machine &machine*/)
{
int i,s;
if (IsInit)
return;
for(i=0;i<256;++i)
{
int a,p;
// float TL;
//Saw
a=255-i;
if(i<128)
p=i;
else
p=i-256;
ALFO_SAW[i]=a;
PLFO_SAW[i]=p;
//Square
if(i<128)
{
a=255;
p=127;
}
else
{
a=0;
p=-128;
}
ALFO_SQR[i]=a;
PLFO_SQR[i]=p;
//Tri
if(i<128)
a=255-(i*2);
else
a=(i*2)-256;
if(i<64)
p=i*2;
else if(i<128)
p=255-i*2;
else if(i<192)
p=256-i*2;
else
p=i*2-511;
ALFO_TRI[i]=a;
PLFO_TRI[i]=p;
//noise
//a=lfo_noise[i];
//a=machine.rand()&0xff;
a=rand()&0xff;
p=128-a;
ALFO_NOI[i]=a;
PLFO_NOI[i]=p;
}
for(s=0;s<8;++s)
{
float limit=PSCALE[s];
for(i=-128;i<128;++i)
{
PSCALES[s][i+128]=CENTS(((limit*(float) i)/128.0));
}
limit=-ASCALE[s];
for(i=0;i<256;++i)
{
ASCALES[s][i]=DB(((limit*(float) i)/256.0));
}
}
IsInit = 0x01;
}
INLINE signed int PLFO_Step(struct _LFO *LFO)
{
int p;
LFO->phase+=LFO->phase_step;
#if LFO_SHIFT!=8
LFO->phase&=(1<<(LFO_SHIFT+8))-1;
#endif
p=LFO->table[LFO->phase>>LFO_SHIFT];
p=LFO->scale[p+128];
return p<<(SHIFT-LFO_SHIFT);
}
INLINE signed int ALFO_Step(struct _LFO *LFO)
{
int p;
LFO->phase+=LFO->phase_step;
#if LFO_SHIFT!=8
LFO->phase&=(1<<(LFO_SHIFT+8))-1;
#endif
p=LFO->table[LFO->phase>>LFO_SHIFT];
p=LFO->scale[p];
return p<<(SHIFT-LFO_SHIFT);
}
static void LFO_ComputeStep(struct _LFO *LFO,UINT32 LFOF,UINT32 LFOWS,UINT32 LFOS,int ALFO)
{
float step=(float) LFOFreq[LFOF]*256.0/(float)44100;
LFO->phase_step=(unsigned int) ((float) (1<<LFO_SHIFT)*step);
if(ALFO)
{
switch(LFOWS)
{
case 0: LFO->table=ALFO_SAW; break;
case 1: LFO->table=ALFO_SQR; break;
case 2: LFO->table=ALFO_TRI; break;
case 3: LFO->table=ALFO_NOI; break;
}
LFO->scale=ASCALES[LFOS];
}
else
{
switch(LFOWS)
{
case 0: LFO->table=PLFO_SAW; break;
case 1: LFO->table=PLFO_SQR; break;
case 2: LFO->table=PLFO_TRI; break;
case 3: LFO->table=PLFO_NOI; break;
}
LFO->scale=PSCALES[LFOS];
}
}

View file

@ -3,7 +3,7 @@
/*********************************************************/
#include "mamedef.h"
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
//#include "sndintrf.h"

View file

@ -32,7 +32,7 @@
static const int PSGVolumeValues[16] = {
/* These values are taken from a real SMS2's output */
/* {892,892,892,760,623,497,404,323,257,198,159,123,96,75,60,0}, /* I can't remember why 892... :P some scaling I did at some point */
/* {892,892,892,760,623,497,404,323,257,198,159,123,96,75,60,0},*/ /* I can't remember why 892... :P some scaling I did at some point */
/* these values are true volumes for 2dB drops at each step (multiply previous by 10^-0.1) */
/*1516,1205,957,760,603,479,381,303,240,191,152,120,96,76,60,0*/
// The MAME core uses 0x2000 as maximum volume (0x1000 for bipolar output)

View file

@ -124,11 +124,13 @@
#endif
//#include "emu.h"
//#include "streams.h"
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "sn76496.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
//#define MAX_OUTPUT 0x7fff
@ -418,7 +420,7 @@ void SN76496Update(void *chip, stream_sample_t **outputs, int samples)
out += vol[i] * R->Volume[i] * ggst[0];
out2 += vol[i] * R->Volume[i] * ggst[1];
}
else
else if (R->MuteMsk[i])
{
// Make Bipolar Output with PCM possible
//out += (2 * R->Volume[i] - R->VolTable[5]) * ggst[0];
@ -458,7 +460,7 @@ void SN76496Update(void *chip, stream_sample_t **outputs, int samples)
out += vol[i] * R->Volume[i] * ggst[0];
out2 += vol[i] * R2->Volume[i] * ggst[1];
}
else
else if (R->MuteMsk[i])
{
// Make Bipolar Output with PCM possible
out += R->Volume[i] * ggst[0];
@ -870,7 +872,7 @@ DEVICE_GET_INFO( smsiii )
case DEVINFO_STR_NAME: strcpy(info->s, "SMSIII PSG"); break;
default: DEVICE_GET_INFO_CALL(sn76496); break;
}
}
}*/
/*DEFINE_LEGACY_SOUND_DEVICE(SN76496, sn76496);

View file

@ -18,7 +18,9 @@
#define EC_MAXIM 0x01 // SN76489 core by Maxim (from in_vgm)
#endif
#ifndef NULL
#define NULL ((void *)0)
#endif
/* for stream system */
typedef struct _sn764xx_state sn764xx_state;

View file

@ -102,12 +102,14 @@
#ifdef _DEBUG
#include <stdio.h>
#endif
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "mamedef.h"
#include "upd7759.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
#define DEBUG_STATES (0)
@ -279,7 +281,9 @@ static void get_fifo_data(upd7759_state *chip)
{
if (chip->dbuf_pos_read == chip->dbuf_pos_write)
{
#ifdef _DEBUG
logerror("Warning: UPD7759 reading empty FIFO!\n");
#endif
return;
}
@ -312,7 +316,9 @@ static void advance_state(upd7759_state *chip)
/* Start state: we begin here as soon as a sample is triggered */
case STATE_START:
chip->req_sample = chip->rom ? chip->fifo_in : 0x10;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: req_sample = %02X\n", chip->req_sample);
#endif
/* 35+ cycles after we get here, the /DRQ goes low
* (first byte (number of samples in ROM) should be sent in response)
@ -328,7 +334,9 @@ static void advance_state(upd7759_state *chip)
/* First request state: issue a request for the first byte */
/* The expected response will be the index of the last sample */
case STATE_FIRST_REQ:
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: first data request\n");
#endif
chip->drq = 1;
/* 44 cycles later, we will latch this value and request another byte */
@ -340,7 +348,9 @@ static void advance_state(upd7759_state *chip)
/* The second byte read will be just a dummy */
case STATE_LAST_SAMPLE:
chip->last_sample = chip->rom ? chip->rom[0] : chip->fifo_in;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: last_sample = %02X, requesting dummy 1\n", chip->last_sample);
#endif
chip->drq = 1;
/* 28 cycles later, we will latch this value and request another byte */
@ -351,7 +361,9 @@ static void advance_state(upd7759_state *chip)
/* First dummy state: ignore any data here and issue a request for the third byte */
/* The expected response will be the MSB of the sample address */
case STATE_DUMMY1:
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: dummy1, requesting offset_hi\n");
#endif
chip->drq = 1;
/* 32 cycles later, we will latch this value and request another byte */
@ -363,7 +375,9 @@ static void advance_state(upd7759_state *chip)
/* The expected response will be the LSB of the sample address */
case STATE_ADDR_MSB:
chip->offset = (chip->rom ? chip->rom[chip->req_sample * 2 + 5] : chip->fifo_in) << 9;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: offset_hi = %02X, requesting offset_lo\n", chip->offset >> 9);
#endif
chip->drq = 1;
/* 44 cycles later, we will latch this value and request another byte */
@ -375,7 +389,9 @@ static void advance_state(upd7759_state *chip)
/* The expected response will be just a dummy */
case STATE_ADDR_LSB:
chip->offset |= (chip->rom ? chip->rom[chip->req_sample * 2 + 6] : chip->fifo_in) << 1;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: offset_lo = %02X, requesting dummy 2\n", (chip->offset >> 1) & 0xff);
#endif
chip->drq = 1;
/* 36 cycles later, we will latch this value and request another byte */
@ -388,7 +404,9 @@ static void advance_state(upd7759_state *chip)
case STATE_DUMMY2:
chip->offset++;
chip->first_valid_header = 0;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: dummy2, requesting block header\n");
#endif
chip->drq = 1;
/* 36?? cycles later, we will latch this value and request another byte */
@ -406,7 +424,9 @@ static void advance_state(upd7759_state *chip)
chip->offset = chip->repeat_offset;
}
chip->block_header = chip->rom ? chip->rom[chip->offset++ & 0x1ffff] : chip->fifo_in;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: header (@%05X) = %02X, requesting next byte\n", chip->offset, chip->block_header);
#endif
chip->drq = 1;
/* our next step depends on the top two bits */
@ -449,7 +469,9 @@ static void advance_state(upd7759_state *chip)
/* The expected response will be the first data byte */
case STATE_NIBBLE_COUNT:
chip->nibbles_left = (chip->rom ? chip->rom[chip->offset++ & 0x1ffff] : chip->fifo_in) + 1;
#ifdef _DEBUG
if (DEBUG_STATES) DEBUG_METHOD("UPD7759: nibble_count = %u, requesting next byte\n", (unsigned)chip->nibbles_left);
#endif
chip->drq = 1;
/* 36?? cycles later, we will latch this value and request another byte */
@ -684,11 +706,11 @@ void device_reset_upd7759(void *_info)
//static STATE_POSTLOAD( upd7759_postload )
static void upd7759_postload(void* param)
/*static void upd7759_postload(void* param)
{
upd7759_state *chip = (upd7759_state *)param;
chip->rom = chip->rombase + chip->romoffset;
}
}*/
/*static void register_for_save(upd7759_state *chip, running_device *device)
@ -727,9 +749,9 @@ static void upd7759_postload(void* param)
//static DEVICE_START( upd7759 )
int device_start_upd7759(void **_info, int clock)
{
static const upd7759_interface defintrf = { 0 };
//static const upd7759_interface defintrf = { 0 };
//const upd7759_interface *intf = (device->baseconfig().static_config() != NULL) ? (const upd7759_interface *)device->baseconfig().static_config() : &defintrf;
const upd7759_interface *intf = &defintrf;
//const upd7759_interface *intf = &defintrf;
//upd7759_state *chip = get_safe_token(device);
upd7759_state *chip;
@ -820,7 +842,9 @@ void upd7759_start_w(void *_info, UINT8 data)
UINT8 oldstart = chip->start;
chip->start = (data != 0);
#ifdef _DEBUG
if (DEBUG_STATES) logerror("upd7759_start_w: %d->%d\n", oldstart, chip->start);
#endif
/* update the stream first */
//stream_update(chip->channel);

View file

@ -16,7 +16,7 @@
*/
//#include "vb.h"
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "mamedef.h"
#include "vsu.h"

View file

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stddef.h> // for NULL
#include "mamedef.h"

View file

@ -50,7 +50,7 @@ Registers:
//#include "emu.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stddef.h> // for NULL
#include "mamedef.h"
#include "x1_010.h"
@ -66,7 +66,8 @@ Registers:
#define SETA_NUM_CHANNELS 16
#define FREQ_BASE_BITS 8 // Frequency fixed decimal shift bits
//#define FREQ_BASE_BITS 8 // Frequency fixed decimal shift bits
#define FREQ_BASE_BITS 14 // Frequency fixed decimal shift bits
#define ENV_BASE_BITS 16 // wave form envelope fixed decimal shift bits
#define VOL_BASE (2*32*256/30) // Volume base
@ -148,17 +149,19 @@ void seta_update(void *param, stream_sample_t **outputs, int samples)
// Meta Fox does write the frequency register, but this is a hack to make it "work" with the current setup
// This is broken for Arbalester (it writes 8), but that'll be fixed later.
if( freq == 0 ) freq = 4;
smp_step = (UINT32)((float)info->base_clock/8192.0
*freq*(1<<FREQ_BASE_BITS)/(float)info->rate);
smp_step = (UINT32)((float)info->base_clock/8192.0f
*freq*(1<<FREQ_BASE_BITS)/(float)info->rate+0.5f);
#ifdef _DEBUG
if( smp_offs == 0 ) {
LOG_SOUND(( "Play sample %p - %p, channel %X volume %d:%d freq %X step %X offset %X\n",
start, end, ch, volL, volR, freq, smp_step, smp_offs ));
}
#endif
for( i = 0; i < samples; i++ ) {
delta = smp_offs>>FREQ_BASE_BITS;
// sample ended?
if( start+delta >= end ) {
reg->status &= 0xfe; // Key off
reg->status &= ~0x01; // Key off
break;
}
data = *(start+delta);
@ -171,22 +174,24 @@ void seta_update(void *param, stream_sample_t **outputs, int samples)
start = (INT8 *)&(info->reg[reg->volume*128+0x1000]);
smp_offs = info->smp_offset[ch];
freq = ((reg->pitch_hi<<8)+reg->frequency)>>div;
smp_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*freq*(1<<FREQ_BASE_BITS)/(float)info->rate);
smp_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*freq*(1<<FREQ_BASE_BITS)/(float)info->rate+0.5f);
env = (UINT8 *)&(info->reg[reg->end*128]);
env_offs = info->env_offset[ch];
env_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*reg->start*(1<<ENV_BASE_BITS)/(float)info->rate);
env_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*reg->start*(1<<ENV_BASE_BITS)/(float)info->rate+0.5f);
/* Print some more debug info */
#ifdef _DEBUG
if( smp_offs == 0 ) {
LOG_SOUND(( "Play waveform %X, channel %X volume %X freq %4X step %X offset %X\n",
reg->volume, ch, reg->end, freq, smp_step, smp_offs ));
}
#endif
for( i = 0; i < samples; i++ ) {
int vol;
delta = env_offs>>ENV_BASE_BITS;
// Envelope one shot mode
if( (reg->status&4) != 0 && delta >= 0x80 ) {
reg->status &= 0xfe; // Key off
reg->status &= ~0x01; // Key off
break;
}
vol = *(env+(delta&0x7f));

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
//
// yam - Emulates Yamaha SCSP and AICA
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __SEGA_YAM_H__
#define __SEGA_YAM_H__
#include "emuconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
/////////////////////////////////////////////////////////////////////////////
// version = 1 for SCSP, 2 for AICA
// ramsize must be a power of 2
sint32 EMU_CALL yam_init(void);
uint32 EMU_CALL yam_get_state_size(uint8 version);
void EMU_CALL yam_clear_state(void *state, uint8 version);
void EMU_CALL yam_enable_dry(void *state, uint8 enable);
void EMU_CALL yam_enable_dsp(void *state, uint8 enable);
void EMU_CALL yam_enable_dsp_dynarec(void *state, uint8 enable);
void EMU_CALL yam_setram(void *state, uint32 *ram, uint32 size, uint8 mbx, uint8 mwx);
void EMU_CALL yam_beginbuffer(void *state, sint16 *buf);
void EMU_CALL yam_advance(void *state, uint32 samples);
void EMU_CALL yam_flush(void *state);
uint32 EMU_CALL yam_aica_load_reg(void *state, uint32 a, uint32 mask);
void EMU_CALL yam_aica_store_reg(void *state, uint32 a, uint32 d, uint32 mask, uint8 *breakcpu);
uint32 EMU_CALL yam_scsp_load_reg(void *state, uint32 a, uint32 mask);
void EMU_CALL yam_scsp_store_reg(void *state, uint32 a, uint32 d, uint32 mask, uint8 *breakcpu);
uint8* EMU_CALL yam_get_interrupt_pending_ptr(void *state);
uint32 EMU_CALL yam_get_min_samples_until_interrupt(void *state);
void EMU_CALL yam_prepare_dynacode(void *state);
void EMU_CALL yam_unprepare_dynacode(void *state);
void EMU_CALL yam_set_mute(void *state, uint32 channel, uint32 enable);
/////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif

View file

@ -9,12 +9,14 @@
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
//#include "sndintrf.h"
//#include "streams.h"
#include "ym2151.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/* undef this to not use MAME timer system */
@ -1118,7 +1120,7 @@ void ym2151_write_reg(void *_chip, int r, int v)
chip->status &= ~1;
timer_set(chip->device->machine, attotime_zero,chip,0,irqAoff_callback);
#else
int oldstate = chip->status & 3;
//int oldstate = chip->status & 3;
chip->status &= ~1;
//if ((oldstate==1) && (chip->irqhandler)) (*chip->irqhandler)(chip->device, 0);
#endif
@ -1130,7 +1132,7 @@ void ym2151_write_reg(void *_chip, int r, int v)
chip->status &= ~2;
timer_set(chip->device->machine, attotime_zero,chip,0,irqBoff_callback);
#else
int oldstate = chip->status & 3;
//int oldstate = chip->status & 3;
chip->status &= ~2;
//if ((oldstate==2) && (chip->irqhandler)) (*chip->irqhandler)(chip->device, 0);
#endif
@ -2402,7 +2404,7 @@ INLINE signed int acc_calc(signed int value)
*/
void ym2151_update_one(void *chip, SAMP **buffers, int length)
{
int i, chn;
int i; // , chn;
signed int outl,outr;
SAMP *bufL, *bufR;
@ -2422,7 +2424,7 @@ void ym2151_update_one(void *chip, SAMP **buffers, int length)
PSG->tim_B_val += PSG->tim_B_tab[ PSG->timer_B_index ];
if ( PSG->irq_enable & 0x08 )
{
int oldstate = PSG->status & 3;
//int oldstate = PSG->status & 3;
PSG->status |= 2;
//if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(chip->device, 1);
}
@ -2500,7 +2502,7 @@ void ym2151_update_one(void *chip, SAMP **buffers, int length)
PSG->tim_A_val += PSG->tim_A_tab[ PSG->timer_A_index ];
if (PSG->irq_enable & 0x04)
{
int oldstate = PSG->status & 3;
//int oldstate = PSG->status & 3;
PSG->status |= 1;
//if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(chip->device, 1);
}

View file

@ -41,11 +41,13 @@ to do:
#include <math.h>
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
//#include "sndintrf.h"
#include "ym2413.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/* output final shift */
#if (SAMPLE_BITS==16)

View file

@ -217,8 +217,10 @@ value: START, REC, MEMDAT, REPEAT, SPOFF, x,x,RESET meaning:
DELTAT->adpcml = 0;
DELTAT->adpcmd = YM_DELTAT_DELTA_DEF;
DELTAT->now_data = 0;
#ifdef _DEBUG
if (DELTAT->start > DELTAT->end)
logerror("DeltaT-Warning: Start: %06X, End: %06X\n", DELTAT->start, DELTAT->end);
#endif
}
if( DELTAT->portstate&0x20 ) /* do we access external memory? */

View file

@ -56,11 +56,13 @@ differences between OPL2 and OPL3 shown in datasheets:
#include <math.h>
#include "mamedef.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
//#include "sndintrf.h"
#include "ymf262.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
/* output final shift */
@ -2561,7 +2563,7 @@ void ymf262_update_one(void *_chip, OPL3SAMPLE **buffers, int length)
//OPL3SAMPLE *ch_d = buffers[3];
int i;
int chn;
//int chn;
for( i=0; i < length ; i++ )
{

View file

@ -34,7 +34,7 @@
#include <stdio.h>
#endif
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "ymf271.h"
#ifndef __cplusplus // C++ already has the bool-type
@ -43,7 +43,9 @@
typedef unsigned char bool;
#endif // !__cplusplus
#ifndef NULL
#define NULL ((void *)0)
#endif
//#define DEVCB_NULL { DEVCB_TYPE_NULL }
#define DEVCB_NULL DEVCB_TYPE_NULL
@ -1243,7 +1245,9 @@ static void ymf271_write_fm(YMF271Chip *chip, int bank, UINT8 address, UINT8 dat
if (groupnum == -1)
{
#ifdef _DEBUG
logerror("ymf271_write_fm invalid group %02X %02X\n", address, data);
#endif
return;
}
@ -1340,7 +1344,9 @@ static void ymf271_write_pcm(YMF271Chip *chip, UINT8 address, UINT8 data)
YMF271Slot *slot;
if (slotnum == -1)
{
#ifdef _DEBUG
logerror("ymf271_write_pcm invalid slot %02X %02X\n", address, data);
#endif
return;
}
slot = &chip->slots[slotnum];
@ -1465,7 +1471,9 @@ static void ymf271_write_timer(YMF271Chip *chip, UINT8 address, UINT8 data)
YMF271Group *group;
if (groupnum == -1)
{
#ifdef _DEBUG
logerror("ymf271_write_timer invalid group %02X %02X\n", address, data);
#endif
return;
}
group = &chip->groups[groupnum];

View file

@ -64,13 +64,15 @@
//#include "streams.h"
//#include "cpuintrf.h"
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include "ymf262.h"
#include "ymf278b.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
typedef struct
{
@ -79,7 +81,7 @@ typedef struct
UINT32 endaddr;
UINT32 step; /* fixed-point frequency step */
UINT32 stepptr; /* fixed-point pointer into the sample */
UINT32 pos;
UINT16 pos;
INT16 sample1, sample2;
INT32 env_vol;
@ -536,9 +538,9 @@ INLINE void ymf278b_advance(YMF278BChip* chip)
INLINE UINT8 ymf278b_readMem(YMF278BChip* chip, offs_t address)
{
if (address < chip->ROMSize)
return chip->rom[address];
return chip->rom[address&0x3fffff];
else if (address < chip->ROMSize + chip->RAMSize)
return chip->ram[address - chip->ROMSize];
return chip->ram[address - chip->ROMSize&0x3fffff];
else
return 255; // TODO check
}
@ -546,9 +548,9 @@ INLINE UINT8 ymf278b_readMem(YMF278BChip* chip, offs_t address)
INLINE UINT8* ymf278b_readMemAddr(YMF278BChip* chip, offs_t address)
{
if (address < chip->ROMSize)
return &chip->rom[address];
return &chip->rom[address&0x3fffff];
else if (address < chip->ROMSize + chip->RAMSize)
return &chip->ram[address - chip->ROMSize];
return &chip->ram[address - chip->ROMSize&0x3fffff];
else
return NULL; // TODO check
}
@ -696,10 +698,12 @@ void ymf278b_pcm_update(void *_info, stream_sample_t** outputs, int samples)
{
sl->stepptr -= 0x10000;
sl->sample1 = sl->sample2;
sl->pos ++;
if (sl->pos >= sl->endaddr)
sl->pos = sl->loopaddr;
sl->sample2 = ymf278b_getSample(chip, sl);
if (sl->pos == sl->endaddr)
sl->pos = sl->pos - sl->endaddr + sl->loopaddr;
else
sl->pos ++;
}
}
ymf278b_advance(chip);
@ -826,7 +830,7 @@ void ymf278b_C_w(YMF278BChip* chip, UINT8 reg, UINT8 data)
slot->startaddr = buf[2] | (buf[1] << 8) |
((buf[0] & 0x3F) << 16);
slot->loopaddr = buf[4] + (buf[3] << 8);
slot->endaddr = (((buf[6] + (buf[5] << 8)) ^ 0xFFFF) + 1);
slot->endaddr = ((buf[6] + (buf[5] << 8)) ^ 0xFFFF);
if (chip->regs[reg + 4] & 0x080)
ymf278b_keyOnHelper(chip, slot);

View file

@ -36,11 +36,13 @@
#ifdef _DEBUG
#include <stdio.h>
#endif
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "ymz280b.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
static void update_irq_state_timer_common(void *param, int voicenum);
@ -1157,7 +1159,9 @@ static void write_to_register(ymz280b_state *chip, int data)
case 0x80: // d0-2: DSP Rch, d3: enable Rch (0: yes, 1: no), d4-6: DSP Lch, d7: enable Lch (0: yes, 1: no)
case 0x81: // d0: enable control of $82 (0: yes, 1: no)
case 0x82: // DSP data
#ifdef _DEBUG
logerror("YMZ280B: DSP register write %02X = %02X\n", chip->current_register, data);
#endif
break;
case 0x84: /* ROM readback / RAM write (high) */

View file

@ -36,13 +36,14 @@ static void gen_sinc( double rolloff, int width, double offset, double spacing,
double const step = PI / maxh * spacing;
double const to_w = maxh * 2 / width;
double const pow_a_n = pow( rolloff, maxh );
scale /= maxh * 2;
double angle = (count / 2 - 1 + offset) * -step;
scale /= maxh * 2;
while ( count-- )
{
double w;
*out++ = 0;
double w = angle * to_w;
w = angle * to_w;
if ( fabs( w ) < PI )
{
double rolloff_cos_a = rolloff * cos( angle );
@ -133,17 +134,29 @@ void resampler_set_rate( void *_r, double new_factor )
double const rolloff = 0.999;
double const gain = 1.0;
int step;
double fraction;
double filter;
double pos = 0.0;
imp_t* out;
int n;
/* determine number of sub-phases that yield lowest error */
double ratio_ = 0.0;
int res = -1;
{
double least_error = 2;
double pos = 0;
for ( int r = 1; r <= max_res; r++ )
int r;
for ( r = 1; r <= max_res; r++ )
{
double nearest, error;
pos += new_factor;
double nearest = floor( pos + 0.5 );
double error = fabs( pos - nearest );
nearest = floor( pos + 0.5 );
error = fabs( pos - nearest );
if ( error < least_error )
{
res = r;
@ -155,20 +168,21 @@ void resampler_set_rate( void *_r, double new_factor )
rs->rate_ = ratio_;
/* how much of input is used for each output sample */
int const step = stereo * (int) floor( ratio_ );
double fraction = fmod( ratio_, 1.0 );
step = stereo * (int) floor( ratio_ );
fraction = fmod( ratio_, 1.0 );
double const filter = (ratio_ < 1.0) ? 1.0 : 1.0 / ratio_;
double pos = 0.0;
filter = (ratio_ < 1.0) ? 1.0 : 1.0 / ratio_;
/*int input_per_cycle = 0;*/
imp_t* out = rs->impulses;
for ( int n = res; --n >= 0; )
out = rs->impulses;
for ( n = res; --n >= 0; )
{
int cur_step;
gen_sinc( rolloff, (int) (rs->width_ * filter + 1) & ~1, pos, filter,
(double)(imp_scale * gain * filter), (int) rs->width_, out );
out += rs->width_;
int cur_step = step;
cur_step = step;
pos += fraction;
if ( pos >= 0.9999999 )
{
@ -208,7 +222,8 @@ void resampler_write_pair(void *_r, sample_t ls, sample_t rs)
if (!r->latency)
{
for (int i = 0; i < adj_width / 2; ++i)
int i;
for (i = 0; i < adj_width / 2; ++i)
{
r->buffer_in[r->inptr + 0] = 0;
r->buffer_in[r->inptr + 1] = 0;
@ -249,11 +264,12 @@ static const sample_t * resampler_inner_loop( resampler *r, sample_t** out_,
{
/* accumulate in extended precision*/
int pt = imp [0];
int n;
intermediate_t l = (intermediate_t)pt * (intermediate_t)(in [0]);
intermediate_t r = (intermediate_t)pt * (intermediate_t)(in [1]);
if ( out >= out_end )
break;
for ( int n = (adj_width - 2) / 2; n; --n )
for ( n = (adj_width - 2) / 2; n; --n )
{
pt = imp [1];
l += (intermediate_t)pt * (intermediate_t)(in [2]);
@ -305,9 +321,10 @@ static void resampler_fill( resampler *r )
{
int writepos = ( r->outptr + r->outfilled ) % (buffer_size * stereo);
int writesize = (buffer_size * stereo) - writepos;
int inread;
if ( writesize > ( buffer_size * stereo - r->outfilled ) )
writesize = buffer_size * stereo - r->outfilled;
int inread = resampler_wrapper(r, &r->buffer_out[writepos], &writesize, &r->buffer_in[buffer_size * stereo + r->inptr - r->infilled], r->infilled);
inread = resampler_wrapper(r, &r->buffer_out[writepos], &writesize, &r->buffer_in[buffer_size * stereo + r->inptr - r->infilled], r->infilled);
r->infilled -= inread;
r->outfilled += writesize;
if (!inread)

View file

@ -27,7 +27,6 @@ int main(int argc, char *argv[]) {
FILE *outputFile;
void *vgmp;
VGM_PLAYER *p;
int EndPlay;
if (argc < 3) {
fputs("usage: vgm2pcm vgm_file pcm_file\n", stderr);
@ -58,8 +57,7 @@ int main(int argc, char *argv[]) {
return 1;
}
EndPlay = 0;
while (!EndPlay) {
while (!p->EndPlay) {
UINT32 bufferSize = p->SampleRate;
bufferedLength = FillBuffer(vgmp, sampleBuffer, bufferSize);
if (bufferedLength) {
@ -73,8 +71,6 @@ int main(int argc, char *argv[]) {
fputBE16(sampleData[currentSample], outputFile);
}
}
if (bufferedLength < bufferSize)
EndPlay = 1;
}
StopVGM(vgmp);