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

@ -1,226 +1,237 @@
// Game_Music_Emu $vers. http://www.slack.net/~ant/
#include "Vgm_Core.h"
#include "blargg_endian.h"
#include <math.h>
#include <stdio.h>
/* Copyright (C) 2003-2008 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. This
module is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#include "blargg_source.h"
Vgm_Core::Vgm_Core()
{
vgmp = (VGM_PLAYER *) VGMPlay_Init();
vgmp->VGMMaxLoop = 0;
VGMPlay_Init2(vgmp);
}
Vgm_Core::~Vgm_Core()
{
StopVGM(vgmp);
CloseVGMFile(vgmp);
VGMPlay_Deinit(vgmp);
}
static UINT32 gcd(UINT32 x, UINT32 y)
{
UINT32 shift;
UINT32 diff;
// Thanks to Wikipedia for this algorithm
// http://en.wikipedia.org/wiki/Binary_GCD_algorithm
if (! x || ! y)
return x | y;
for (shift = 0; ((x | y) & 1) == 0; shift ++)
{
x >>= 1;
y >>= 1;
}
while((x & 1) == 0)
x >>= 1;
do
{
while((y & 1) == 0)
y >>= 1;
if (x < y)
{
y -= x;
}
else
{
diff = x - y;
x = y;
y = diff;
}
y >>= 1;
} while(y);
return x << shift;
}
void Vgm_Core::set_tempo( double t )
{
if ( file_begin() )
{
int vgm_rate_unit = header().lngRate;
if (!vgm_rate_unit)
vgm_rate_unit = 44100;
int vgm_rate = (int) (vgm_rate_unit * t + 0.5);
int old_rate = vgmp->VGMPbRate;
vgmp->VGMPbRate = vgm_rate;
vgmp->SampleRate = sample_rate;
if (vgmp->PlayingMode != 0xFF)
{
if (!old_rate)
old_rate = vgm_rate_unit;
INT32 TempSLng = gcd(vgm_rate_unit, vgmp->VGMPbRate);
vgmp->VGMPbRateMul = vgm_rate_unit / TempSLng;
vgmp->VGMPbRateDiv = vgmp->VGMPbRate / TempSLng;
vgmp->VGMSmplRateMul = vgmp->SampleRate * vgmp->VGMPbRateMul;
vgmp->VGMSmplRateDiv = vgmp->VGMSampleRate * vgmp->VGMPbRateDiv;
// same as above - to speed up the VGM <-> Playback calculation
TempSLng = gcd(vgmp->VGMSmplRateMul, vgmp->VGMSmplRateDiv);
vgmp->VGMSmplRateMul /= TempSLng;
vgmp->VGMSmplRateDiv /= TempSLng;
vgmp->VGMSmplPlayed = (INT32)((INT64)vgmp->VGMSmplPlayed * old_rate / vgm_rate);
}
}
}
struct VGM_FILE_mem
{
VGM_FILE vf;
const BOOST::uint8_t* buffer;
UINT32 ptr;
UINT32 size;
};
static int VGMF_mem_Read(VGM_FILE* f, void* out, UINT32 count)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
if (count + mf->ptr > mf->size)
count = mf->size - mf->ptr;
memcpy(out, mf->buffer + mf->ptr, count);
mf->ptr += count;
return count;
}
static int VGMF_mem_Seek(VGM_FILE* f, UINT32 offset)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
if (offset > mf->size)
offset = mf->size;
mf->ptr = offset;
return 0;
}
static UINT32 VGMF_mem_GetSize(VGM_FILE* f)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
return mf->size;
}
blargg_err_t Vgm_Core::load_mem_( byte const data [], int size )
{
VGM_FILE_mem memFile;
memFile.vf.Read = &VGMF_mem_Read;
memFile.vf.Seek = &VGMF_mem_Seek;
memFile.vf.GetSize = &VGMF_mem_GetSize;
memFile.buffer = data;
memFile.ptr = 0;
memFile.size = size;
if ( !GetVGMFileInfo_Handle( (VGM_FILE *) &memFile, &_header, 0 ) )
return blargg_err_file_type;
memFile.ptr = 0;
if ( !OpenVGMFile_Handle( vgmp, (VGM_FILE *) &memFile ) )
return blargg_err_file_type;
if ( !header().lngLoopOffset )
vgmp->VGMMaxLoop = 1;
set_tempo( 1 );
return blargg_ok;
}
int Vgm_Core::get_channel_count()
{
// XXX may support more than this, but 32 bit masks and all...
unsigned i;
UINT32 j;
for (i = 0; i < 32; i++)
{
if (!GetAccurateChipNameByChannel(vgmp, i, &j))
break;
}
return i;
}
char* Vgm_Core::get_voice_name(int channel)
{
UINT32 realChannel;
const char * name = GetAccurateChipNameByChannel(vgmp, channel, &realChannel);
size_t length = strlen(name) + 16;
char * finalName = (char *) malloc(length);
if (finalName)
sprintf(finalName, "%s #%u", name, realChannel);
return finalName;
}
void Vgm_Core::free_voice_name(char *name)
{
free(name);
}
void Vgm_Core::set_mute(int mask)
{
for (int i = 0; i < 32; i++)
{
SetChannelMute(vgmp, i, (mask >> i) & 1);
}
}
void Vgm_Core::start_track()
{
PlayVGM(vgmp);
RestartVGM(vgmp);
}
int Vgm_Core::play_( int sample_count, short out [] )
{
// to do: timing is working mostly by luck
int pairs = (unsigned) sample_count / 2;
memset(out, 0, sizeof(short) * pairs * 2);
FillBuffer(vgmp, (WAVE_16BS*) out, pairs);
return pairs * 2;
}
void Vgm_Core::skip_( int count )
{
SeekVGM( vgmp, true, count / 2 );
}
// Game_Music_Emu $vers. http://www.slack.net/~ant/
#include "Vgm_Core.h"
#include "blargg_endian.h"
#include <math.h>
#include <stdio.h>
/* Copyright (C) 2003-2008 Shay Green. This module is free software; you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. This
module is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#include "blargg_source.h"
Vgm_Core::Vgm_Core()
{
vgmp = (VGM_PLAYER *) VGMPlay_Init();
vgmp->VGMMaxLoop = 0;
VGMPlay_Init2(vgmp);
}
Vgm_Core::~Vgm_Core()
{
StopVGM(vgmp);
CloseVGMFile(vgmp);
VGMPlay_Deinit(vgmp);
}
static UINT32 gcd(UINT32 x, UINT32 y)
{
UINT32 shift;
UINT32 diff;
// Thanks to Wikipedia for this algorithm
// http://en.wikipedia.org/wiki/Binary_GCD_algorithm
if (! x || ! y)
return x | y;
for (shift = 0; ((x | y) & 1) == 0; shift ++)
{
x >>= 1;
y >>= 1;
}
while((x & 1) == 0)
x >>= 1;
do
{
while((y & 1) == 0)
y >>= 1;
if (x < y)
{
y -= x;
}
else
{
diff = x - y;
x = y;
y = diff;
}
y >>= 1;
} while(y);
return x << shift;
}
void Vgm_Core::set_tempo( double t )
{
if ( file_begin() )
{
int vgm_rate_unit = header().lngRate;
if (!vgm_rate_unit)
vgm_rate_unit = 44100;
int vgm_rate = (int) (vgm_rate_unit * t + 0.5);
int old_rate = vgmp->VGMPbRate;
vgmp->VGMPbRate = vgm_rate;
vgmp->SampleRate = sample_rate;
if (vgmp->PlayingMode != 0xFF)
{
if (!old_rate)
old_rate = vgm_rate_unit;
INT32 TempSLng = gcd(vgm_rate_unit, vgmp->VGMPbRate);
vgmp->VGMPbRateMul = vgm_rate_unit / TempSLng;
vgmp->VGMPbRateDiv = vgmp->VGMPbRate / TempSLng;
vgmp->VGMSmplRateMul = vgmp->SampleRate * vgmp->VGMPbRateMul;
vgmp->VGMSmplRateDiv = vgmp->VGMSampleRate * vgmp->VGMPbRateDiv;
// same as above - to speed up the VGM <-> Playback calculation
TempSLng = gcd(vgmp->VGMSmplRateMul, vgmp->VGMSmplRateDiv);
vgmp->VGMSmplRateMul /= TempSLng;
vgmp->VGMSmplRateDiv /= TempSLng;
vgmp->VGMSmplPlayed = (INT32)((INT64)vgmp->VGMSmplPlayed * old_rate / vgm_rate);
}
}
}
struct VGM_FILE_mem
{
VGM_FILE vf;
const BOOST::uint8_t* buffer;
UINT32 ptr;
UINT32 size;
};
static int VGMF_mem_Read(VGM_FILE* f, void* out, UINT32 count)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
if (count + mf->ptr > mf->size)
count = mf->size - mf->ptr;
memcpy(out, mf->buffer + mf->ptr, count);
mf->ptr += count;
return count;
}
static int VGMF_mem_Seek(VGM_FILE* f, UINT32 offset)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) f;
if (offset > mf->size)
offset = mf->size;
mf->ptr = offset;
return 0;
}
static UINT32 VGMF_mem_GetSize(VGM_FILE* f)
{
VGM_FILE_mem* mf = (VGM_FILE_mem *) 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;
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;
if ( !GetVGMFileInfo_Handle( (VGM_FILE *) &memFile, &_header, 0 ) )
return blargg_err_file_type;
memFile.ptr = 0;
if ( !OpenVGMFile_Handle( vgmp, (VGM_FILE *) &memFile ) )
return blargg_err_file_type;
if ( !header().lngLoopOffset )
vgmp->VGMMaxLoop = 1;
set_tempo( 1 );
return blargg_ok;
}
int Vgm_Core::get_channel_count()
{
// XXX may support more than this, but 32 bit masks and all...
unsigned i;
UINT32 j;
for (i = 0; i < 32; i++)
{
if (!GetAccurateChipNameByChannel(vgmp, i, &j))
break;
}
return i;
}
char* Vgm_Core::get_voice_name(int channel)
{
UINT32 realChannel;
const char * name = GetAccurateChipNameByChannel(vgmp, channel, &realChannel);
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;
}
void Vgm_Core::free_voice_name(char *name)
{
free(name);
}
void Vgm_Core::set_mute(int mask)
{
for (int i = 0; i < 32; i++)
{
SetChannelMute(vgmp, i, (mask >> i) & 1);
}
}
void Vgm_Core::start_track()
{
PlayVGM(vgmp);
RestartVGM(vgmp);
}
int Vgm_Core::play_( int sample_count, short out [] )
{
// to do: timing is working mostly by luck
int pairs = (unsigned) sample_count / 2;
memset(out, 0, sizeof(short) * pairs * 2);
FillBuffer(vgmp, (WAVE_16BS*) out, pairs);
return pairs * 2;
}
void Vgm_Core::skip_( int count )
{
SeekVGM( vgmp, true, count / 2 );
}

File diff suppressed because it is too large Load diff

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

File diff suppressed because it is too large Load diff

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? */
@ -673,4 +675,4 @@ void YM_DELTAT_calc_mem_mask(YM_DELTAT* DELTAT)
DELTAT->memory_mask = (MaskSize << 1) - 1; // it's Mask<<1 because of the nibbles
return;
}
}

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);