mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-27 11:00:27 +00:00
Add sound (sort of lol)
This commit is contained in:
parent
188a12031b
commit
6b225e5d2f
@ -504,6 +504,7 @@
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_mcr3.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_senjyo.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pst90s\d_itech32.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\snes\snes_dsp.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\taito\d_groundfx.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\taito\d_gunbuster.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\taito\d_mexico86.cpp" />
|
||||
@ -1670,7 +1671,6 @@ del build_details.exe
|
||||
<PreprocessorDefinitions>BUILD_WIN32;FASTCALL;_DEBUG;FBNEO_DEBUG;LSB_FIRST;INLINE=__inline static;INCLUDE_LIB_PNGH;C_INLINE=__inline;MAME_INLINE=__inline static;_CRT_SECURE_NO_WARNINGS;WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>Default</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -4083,6 +4083,9 @@
|
||||
<ClCompile Include="..\..\src\cpu\mips3\x64\mips3_x64.cpp">
|
||||
<Filter>cpus\mips</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\burn\drv\snes\snes_dsp.cpp">
|
||||
<Filter>Burn\drv\snes</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Burn">
|
||||
|
@ -106,6 +106,11 @@ extern double spctotal2;
|
||||
extern double spctotal3;
|
||||
void execspc();
|
||||
|
||||
extern int intthisline;
|
||||
extern int framenum;
|
||||
extern int oldnmi;
|
||||
|
||||
|
||||
static inline void clockspc(int cyc)
|
||||
{
|
||||
spccycles += cyc;
|
||||
@ -227,7 +232,6 @@ extern CPU_65816 snes_cpu;
|
||||
#define CHECK_NEGATIVE() (snes_cpu.regP.b.l & NEGATIVE_FLAG)
|
||||
|
||||
|
||||
|
||||
extern void (*opcodes[256][5])();
|
||||
// cpu stuff
|
||||
void irq65816();
|
||||
@ -235,6 +239,13 @@ void nmi65816();
|
||||
void reset65816();
|
||||
void makeopcodetable();
|
||||
|
||||
//DSP
|
||||
|
||||
void polldsp();
|
||||
void writedsp(UINT16 a, UINT8 v);
|
||||
void resetdsp();
|
||||
UINT8 readdsp(UINT16 a);
|
||||
|
||||
/*Memory*/
|
||||
extern UINT8* SNES_ram;
|
||||
extern UINT8* SNES_rom;
|
||||
@ -306,7 +317,7 @@ void snes_mapmem();
|
||||
extern UINT16 srammask;
|
||||
extern UINT8* SNES_sram;
|
||||
extern INT32 spctotal;
|
||||
|
||||
extern UINT8* spcram;
|
||||
// snes_main.cpp
|
||||
INT32 SnesInit();
|
||||
INT32 SnesExit();
|
||||
@ -315,3 +326,4 @@ INT32 SnesScan(INT32 nAction, INT32* pnMin);
|
||||
extern UINT8 DoSnesReset;
|
||||
|
||||
extern UINT8 SnesJoy1[12];
|
||||
void pollsound();
|
434
src/burn/drv/snes/snes_dsp.cpp
Normal file
434
src/burn/drv/snes/snes_dsp.cpp
Normal file
@ -0,0 +1,434 @@
|
||||
#include "snes.h"
|
||||
|
||||
FILE* sndfile;
|
||||
UINT8 dspregs[256];
|
||||
int curdspreg;
|
||||
UINT8 *spcram;
|
||||
int ratetable[] = {
|
||||
1 << 30, 2048, 1536, 1280, 1024, 768, 640, 512,
|
||||
384, 320, 256, 192, 160, 128, 96, 80,
|
||||
64, 48, 40, 32, 24, 20, 16, 12,
|
||||
10, 8, 6, 5, 4, 3, 2, 1
|
||||
};
|
||||
|
||||
#define ATTACK 1
|
||||
#define DECAY 2
|
||||
#define SUSTAIN 3
|
||||
#define RELEASE 4
|
||||
|
||||
struct
|
||||
{
|
||||
int pitchcounter[8], pitch[8];
|
||||
int volumer[8], volumel[8];
|
||||
int sourcenum[8];
|
||||
int pos[8];
|
||||
UINT16 voiceaddr[8];
|
||||
UINT8 dir;
|
||||
UINT8 brrctrl[8];
|
||||
int brrstat[8];
|
||||
int voiceon[8];
|
||||
int voiceend[8];
|
||||
|
||||
int evol[8], edelay[8], etype[8];
|
||||
UINT8 gain[8], adsr1[8], adsr2[8];
|
||||
int adsrstat[8];
|
||||
|
||||
UINT16 noise;
|
||||
int noisedelay, noiserate;
|
||||
UINT8 non;
|
||||
|
||||
UINT8 envx[8], outx[8];
|
||||
UINT8 endx;
|
||||
} dsp;
|
||||
int spcoutput;
|
||||
|
||||
|
||||
|
||||
void writedsp(UINT16 a, UINT8 v)
|
||||
{
|
||||
int c;
|
||||
unsigned long templ;
|
||||
if (a & 1)
|
||||
{
|
||||
// if (curdspreg==0x62) spcoutput=1;
|
||||
// if (curdspreg==0x4C) spcoutput=0;
|
||||
dspregs[curdspreg] = v;
|
||||
// if (!(curdspreg&0xE)) printf("Write DSP %02X %02X %04X\n",curdspreg,v,getspcpc());
|
||||
// if (curdspreg==4) spcoutput=1;
|
||||
// if (curdspreg==0x14) spcoutput=0;
|
||||
// if (v) printf("Write DSP %02X %02X %04X\n",curdspreg,v,getspcpc());
|
||||
switch (curdspreg)
|
||||
{
|
||||
case 0x00: case 0x10: case 0x20: case 0x30:
|
||||
case 0x40: case 0x50: case 0x60: case 0x70:
|
||||
dsp.volumel[curdspreg >> 4] = (int)(signed char)v;
|
||||
break;
|
||||
case 0x01: case 0x11: case 0x21: case 0x31:
|
||||
case 0x41: case 0x51: case 0x61: case 0x71:
|
||||
dsp.volumer[curdspreg >> 4] = (int)(signed char)v;
|
||||
break;
|
||||
case 0x02: case 0x12: case 0x22: case 0x32:
|
||||
case 0x42: case 0x52: case 0x62: case 0x72:
|
||||
// printf("Write pitchl %02X %04X\n",v,getspcpc());
|
||||
dsp.pitch[curdspreg >> 4] = (dsp.pitch[curdspreg >> 4] & 0x3F00) | v;
|
||||
break;
|
||||
case 0x03: case 0x13: case 0x23: case 0x33:
|
||||
case 0x43: case 0x53: case 0x63: case 0x73:
|
||||
// printf("Write pitchh %02X %04X\n",v,getspcpc());
|
||||
dsp.pitch[curdspreg >> 4] = (dsp.pitch[curdspreg >> 4] & 0xFF) | ((v & 0x3F) << 8);
|
||||
break;
|
||||
case 0x04: case 0x14: case 0x24: case 0x34:
|
||||
case 0x44: case 0x54: case 0x64: case 0x74:
|
||||
if ((v << 2) != dsp.sourcenum[curdspreg >> 4])
|
||||
{
|
||||
dsp.sourcenum[curdspreg >> 4] = v << 2;
|
||||
dsp.pos[curdspreg >> 4] = 0;
|
||||
templ = (dsp.dir << 8) + (v << 2);
|
||||
dsp.voiceaddr[curdspreg >> 4] = spcram[templ] | (spcram[templ + 1] << 8);
|
||||
// printf("Sourcenum select channel %i %02X %03X %04X %04X\n",curdspreg>>4,v,v<<2,(dsp.dir<<8)+(v<<2),dsp.voiceaddr[curdspreg>>4]);
|
||||
dsp.brrstat[curdspreg >> 4] = 0;
|
||||
}
|
||||
break;
|
||||
case 0x05: case 0x15: case 0x25: case 0x35:
|
||||
case 0x45: case 0x55: case 0x65: case 0x75:
|
||||
dsp.adsr1[curdspreg >> 4] = v;
|
||||
break;
|
||||
case 0x06: case 0x16: case 0x26: case 0x36:
|
||||
case 0x46: case 0x56: case 0x66: case 0x76:
|
||||
dsp.adsr2[curdspreg >> 4] = v;
|
||||
dsp.etype[curdspreg >> 4] = (dsp.gain[curdspreg >> 4] & 0x80) ? 1 : 0;
|
||||
dsp.etype[curdspreg >> 4] |= (dsp.adsr1[curdspreg >> 4] & 0x80) ? 2 : 0;
|
||||
break;
|
||||
case 0x07: case 0x17: case 0x27: case 0x37:
|
||||
case 0x47: case 0x57: case 0x67: case 0x77:
|
||||
dsp.gain[curdspreg >> 4] = v;
|
||||
dsp.etype[curdspreg >> 4] = (dsp.gain[curdspreg >> 4] & 0x80) ? 1 : 0;
|
||||
dsp.etype[curdspreg >> 4] |= (dsp.adsr1[curdspreg >> 4] & 0x80) ? 2 : 0;
|
||||
break;
|
||||
case 0x4C:
|
||||
// if (v) printf("Voice on %02X\n",v);
|
||||
for (c = 0; c < 8; c++)
|
||||
{
|
||||
if (v & (1 << c))
|
||||
{
|
||||
dsp.voiceon[c] = 1;
|
||||
dsp.voiceaddr[c] = spcram[(dsp.dir << 8) + dsp.sourcenum[c]] | (spcram[(dsp.dir << 8) + dsp.sourcenum[c] + 1] << 8);
|
||||
dsp.brrstat[c] = 0;
|
||||
dsp.pos[c] = 0;
|
||||
dsp.adsrstat[c] = ATTACK;
|
||||
dsp.evol[c] = 0;
|
||||
dsp.edelay[c] = 8;
|
||||
dsp.voiceend[c] = 0;
|
||||
dsp.endx &= ~(1 << c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x5C:
|
||||
// if (v) printf("Voice off %02X\n",v);
|
||||
for (c = 0; c < 8; c++)
|
||||
{
|
||||
if (v & (1 << c))
|
||||
{
|
||||
dsp.adsrstat[c] = RELEASE;
|
||||
dsp.edelay[c] = 1;
|
||||
// dsp.voiceon[c]=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x5D:
|
||||
dsp.dir = v;
|
||||
break;
|
||||
case 0x3D:
|
||||
dsp.non = v;
|
||||
break;
|
||||
case 0x6C:
|
||||
dsp.noiserate = v & 0x1F;
|
||||
dsp.noisedelay = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
curdspreg = v & 127;
|
||||
}
|
||||
|
||||
void resetdsp()
|
||||
{
|
||||
memset(&dsp, 0, sizeof(dsp));
|
||||
dsp.noise = 0x4000;
|
||||
}
|
||||
|
||||
UINT8 readdsp(UINT16 a)
|
||||
{
|
||||
if (a & 1)
|
||||
{
|
||||
switch (curdspreg & 0x7F)
|
||||
{
|
||||
case 0x08: case 0x18: case 0x28: case 0x38:
|
||||
case 0x48: case 0x58: case 0x68: case 0x78:
|
||||
return dsp.envx[curdspreg >> 4];
|
||||
case 0x09: case 0x19: case 0x29: case 0x39:
|
||||
case 0x49: case 0x59: case 0x69: case 0x79:
|
||||
return dsp.outx[curdspreg >> 4];
|
||||
case 0x7C:
|
||||
return dsp.endx;
|
||||
}
|
||||
return dspregs[curdspreg & 127];
|
||||
}
|
||||
return curdspreg;
|
||||
}
|
||||
|
||||
INT16 lastsamp[8][2];
|
||||
int range[8], filter[8];
|
||||
inline INT16 decodebrr(int v, int c)
|
||||
{
|
||||
INT16 temp = v & 0xF;
|
||||
float tempf;
|
||||
if (temp & 8) temp |= 0xFFF0;
|
||||
if (range[c] <= 12) temp <<= range[c];
|
||||
else temp = (temp & 8) ? 0xF800 : 0;
|
||||
switch (filter[c])
|
||||
{
|
||||
case 0: break;
|
||||
case 1: temp = temp + lastsamp[c][0] + ((-lastsamp[c][0]) >> 4); break;
|
||||
case 2: temp = temp + (lastsamp[c][0] << 1) + ((-((lastsamp[c][0] << 1) + lastsamp[c][0])) >> 5) - lastsamp[c][1] + (lastsamp[c][1] >> 4); break;
|
||||
case 3: temp = temp + (lastsamp[c][0] << 1) + ((-(lastsamp[c][0] + (lastsamp[c][0] << 2) + (lastsamp[c][0] << 3))) >> 6) - lastsamp[c][1] + (((lastsamp[c][1] << 1) + lastsamp[c][1]) >> 4); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
lastsamp[c][1] = lastsamp[c][0];
|
||||
lastsamp[c][0] = temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
INT16 getbrr(int c)
|
||||
{
|
||||
int temp;
|
||||
INT16 sample;
|
||||
if (!dsp.voiceon[c])
|
||||
return 0;
|
||||
|
||||
if (!dsp.brrstat[c])
|
||||
{
|
||||
dsp.brrstat[c] = 1;
|
||||
dsp.brrctrl[c] = spcram[dsp.voiceaddr[c]++];
|
||||
range[c] = dsp.brrctrl[c] >> 4;
|
||||
filter[c] = (dsp.brrctrl[c] >> 2) & 3;
|
||||
|
||||
}
|
||||
if (dsp.brrstat[c] & 1) /*First nibble*/
|
||||
{
|
||||
temp = spcram[dsp.voiceaddr[c]] >> 4;
|
||||
dsp.brrstat[c]++;
|
||||
sample = decodebrr(temp, c); //(temp<<(dsp.brrctrl[c]>>4))>>1;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = spcram[dsp.voiceaddr[c]++] & 0xF;
|
||||
// if (temp&8) (unsigned long)temp|=0xFFFFFFF0;
|
||||
dsp.brrstat[c]++;
|
||||
sample = decodebrr(temp, c);
|
||||
// sample=(temp<<(dsp.brrctrl[c]>>4))>>1;
|
||||
if (dsp.brrstat[c] == 17)
|
||||
{
|
||||
dsp.brrstat[c] = 0;
|
||||
if (dsp.brrctrl[c] & 1)
|
||||
{
|
||||
if (dsp.brrctrl[c] & 2)
|
||||
{
|
||||
dsp.voiceaddr[c] = spcram[(dsp.dir << 8) + dsp.sourcenum[c] + 2] | (spcram[(dsp.dir << 8) + dsp.sourcenum[c] + 3] << 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
dsp.voiceon[c] = 0;
|
||||
dsp.endx |= (1 << c);
|
||||
// dsp.voiceend[c]=1;
|
||||
// dsp.adsrstat[c]=RELEASE;
|
||||
// dsp.edelay[c]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
||||
INT16 dspbuffer[20000];
|
||||
INT16 dsprealbuffer[8][20000];
|
||||
int dsppos = 0;
|
||||
int dspwsel = 0, dsprsel = 0;
|
||||
//AUDIOSTREAM* as;
|
||||
|
||||
int bufferready = 0;
|
||||
void initdsp()
|
||||
{
|
||||
//install_sound(DIGI_AUTODETECT, MIDI_NONE, 0);
|
||||
//as = play_audio_stream(3200 / 5, 16, TRUE, 32000, 255, 128);
|
||||
}
|
||||
|
||||
int dspqlen = 0;
|
||||
void refillbuffer()
|
||||
{
|
||||
INT16* p = pBurnSoundOut;
|
||||
int c;
|
||||
if (!dspqlen)
|
||||
return;
|
||||
|
||||
for (c = 0; c < nBurnSoundLen; c++)
|
||||
p[c] = dsprealbuffer[dsprsel][c];
|
||||
dsprsel++;
|
||||
dsprsel &= 7;
|
||||
dspqlen--;
|
||||
}
|
||||
|
||||
void pollsound()
|
||||
{
|
||||
if (bufferready)
|
||||
{
|
||||
bufferready--;
|
||||
refillbuffer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int dspsamples[8];
|
||||
|
||||
void polldsp()
|
||||
{
|
||||
int c;
|
||||
int sample=0;
|
||||
INT16 s;
|
||||
short totalsamplel = 0, totalsampler = 0;
|
||||
for (c = 0; c < 8; c++)
|
||||
{
|
||||
// if (dsp.voiceon[0]) printf("Pitch %i %i\n",dsp.pitchcounter[c],dsp.pitch[c]);
|
||||
dsp.pitchcounter[c] += dsp.pitch[c];
|
||||
if (dsp.pitchcounter[c] < 0)// || dsp.voiceend[c])
|
||||
sample = dspsamples[c];
|
||||
else while (dsp.pitchcounter[c] >= 0 && dsp.pitch[c])
|
||||
{
|
||||
s = (INT16)getbrr(c);
|
||||
sample = (int)s;
|
||||
dspsamples[c] = sample;
|
||||
// if (sample && dsp.evol[c]) printf(":%i %i ",s,sample);
|
||||
dsp.pitchcounter[c] -= 0x1000;
|
||||
}
|
||||
if (dsp.non & (1 << c))
|
||||
{
|
||||
sample = dsp.noise & 0x3FFF;
|
||||
if (dsp.noise & 0x4000)
|
||||
sample |= 0xFFFF8000;
|
||||
}
|
||||
// if (totalsamplel<-15000 || totalsamplel>15000) printf("Overflow - %i %i %i\n",c,sample,totalsamplel);
|
||||
// if (sample && dsp.evol[c]) printf("%i %04X %04X ",c,sample,dsp.evol[c]);
|
||||
sample *= dsp.evol[c];
|
||||
sample >>= 11;
|
||||
dsp.outx[c] = sample >> 8;
|
||||
// if (sample) printf("%04X %i %i ",sample,dsp.volumel[c],dsp.volumer[c]);
|
||||
if (dsp.volumel[c]) totalsamplel += (((sample * dsp.volumel[c]) >> 7) >> 3);
|
||||
if (dsp.volumer[c]) totalsampler += (((sample * dsp.volumer[c]) >> 7) >> 3);
|
||||
// if (sample) printf("%04X %04X\n",totalsamplel,totalsampler);
|
||||
dsp.edelay[c]--;
|
||||
if (dsp.edelay[c] <= 0)
|
||||
{
|
||||
// if (c==7) printf("%i %i\n",dsp.etype[c],dsp.adsrstat[c]);
|
||||
if (dsp.adsrstat[c] == RELEASE)
|
||||
{
|
||||
dsp.edelay[c] = 1;
|
||||
dsp.evol[c] -= 8;
|
||||
}
|
||||
else switch (dsp.etype[c])
|
||||
{
|
||||
case 0: /*Direct Gain*/
|
||||
dsp.evol[c] = (dsp.gain[c] & 0x7F) << 4;
|
||||
break;
|
||||
case 1: /*Gain*/
|
||||
switch ((dsp.gain[c] >> 5) & 3)
|
||||
{
|
||||
case 0: /*Linear decrease*/
|
||||
dsp.evol[c] -= 32;
|
||||
break;
|
||||
case 1: /*Exponential decrease*/
|
||||
dsp.evol[c] -= ((dsp.evol[c] - 1) >> 8) + 1;
|
||||
break;
|
||||
case 2: /*Linear increase*/
|
||||
dsp.evol[c] += 32;
|
||||
break;
|
||||
case 3: /*Bent increase*/
|
||||
dsp.evol[c] += (dsp.evol[c] < 0x600) ? 32 : 8;
|
||||
break;
|
||||
}
|
||||
dsp.edelay[c] = ratetable[dsp.gain[c] & 0x1F];
|
||||
break;
|
||||
case 2: case 3: /*ADSR*/
|
||||
// if (c==7) printf("ADSR state now %i\n",dsp.adsrstat[c]);
|
||||
switch (dsp.adsrstat[c])
|
||||
{
|
||||
case ATTACK:
|
||||
if ((dsp.adsr1[c] & 0xF) == 0xF)
|
||||
{
|
||||
dsp.evol[c] += 1024;
|
||||
dsp.edelay[c] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsp.evol[c] += 32;
|
||||
dsp.edelay[c] = ratetable[((dsp.adsr1[c] & 0xF) << 1) | 1];
|
||||
}
|
||||
if (dsp.evol[c] >= 0x7FF)
|
||||
{
|
||||
dsp.evol[c] = 0x7FF;
|
||||
dsp.adsrstat[c] = DECAY;
|
||||
}
|
||||
break;
|
||||
case DECAY:
|
||||
dsp.evol[c] -= ((dsp.evol[c] - 1) >> 8) + 1;
|
||||
if (dsp.evol[c] <= (dsp.adsr2[c] & 0xE0) << 3)
|
||||
{
|
||||
dsp.evol[c] = (dsp.adsr2[c] & 0xE0) << 3;
|
||||
dsp.adsrstat[c] = SUSTAIN;
|
||||
}
|
||||
dsp.edelay[c] = ratetable[((dsp.adsr1[c] & 0x70) >> 2) | 1];
|
||||
break;
|
||||
case SUSTAIN:
|
||||
dsp.evol[c] -= ((dsp.evol[c] - 1) >> 8) + 1;
|
||||
// printf("Evol %i now %i\n",c,dsp.evol[c]);
|
||||
dsp.edelay[c] = ratetable[dsp.adsr2[c] & 0x1F];
|
||||
// printf("edelay now %i %02X %02X %02X\n",dsp.edelay[c],dsp.adsr1[c],dsp.adsr2[c],dsp.gain[c]);
|
||||
break;
|
||||
case RELEASE:
|
||||
dsp.edelay[c] = 1;
|
||||
dsp.evol[c] -= 8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (dsp.evol[c] > 0x7FF) dsp.evol[c] = 0x7FF;
|
||||
if (dsp.evol[c] < 0) dsp.evol[c] = 0;
|
||||
dsp.envx[c] = (dsp.evol[c] >> 4);
|
||||
}
|
||||
}
|
||||
dsp.noisedelay--;
|
||||
if (dsp.noisedelay <= 0)
|
||||
{
|
||||
dsp.noisedelay += ratetable[dsp.noiserate];
|
||||
dsp.noise = (dsp.noise >> 1) | (((dsp.noise << 14) ^ (dsp.noise << 13)) & 0x4000);
|
||||
}
|
||||
dspbuffer[dsppos++] = totalsamplel;
|
||||
dspbuffer[dsppos++] = totalsampler;
|
||||
if (dsppos >= (nBurnSoundLen))
|
||||
{
|
||||
if (dspqlen == 8)
|
||||
{
|
||||
dspwsel--;
|
||||
dspwsel &= 7;
|
||||
dspqlen--;
|
||||
}
|
||||
memcpy(dsprealbuffer[dspwsel], dspbuffer, nBurnSoundLen * 2);
|
||||
dspqlen++;
|
||||
dspwsel++;
|
||||
dspwsel &= 7;
|
||||
dsppos = 0;
|
||||
bufferready++;
|
||||
|
||||
}
|
||||
spctotal++;
|
||||
}
|
@ -3,13 +3,11 @@ I/O, or $42xx*/
|
||||
|
||||
#include "snes.h"
|
||||
|
||||
extern int intthisline;
|
||||
int dmaops = 0;
|
||||
extern int framenum;
|
||||
extern int oldnmi;
|
||||
|
||||
int padpos, padstat;
|
||||
UINT16 pad[4];
|
||||
UINT16 mulr, divc, divr;
|
||||
UINT8 mula, mulb, divb;
|
||||
|
||||
void readjoy()
|
||||
{
|
||||
@ -60,15 +58,13 @@ void writejoyold(UINT16 addr, UINT8 val)
|
||||
{
|
||||
if (addr == 0x4016)
|
||||
{
|
||||
// printf("Write 4016 %02X\n",val);
|
||||
if ((val & 1) && !(padstat & 1))
|
||||
padpos = 0;
|
||||
padstat = val;
|
||||
}
|
||||
}
|
||||
|
||||
UINT16 mulr, divc, divr;
|
||||
UINT8 mula, mulb, divb;
|
||||
|
||||
|
||||
void writeio(UINT16 addr, UINT8 val)
|
||||
{
|
||||
@ -141,14 +137,12 @@ void writeio(UINT16 addr, UINT8 val)
|
||||
{
|
||||
if (dmactrl[d] & 0x80)
|
||||
{
|
||||
// printf("Dest %04X+%04X SRC %06X %04X\n",dmadest[d],offset,dmabank[d],dmasrc[d]);
|
||||
temp = readppu(dmadest[d] + offset);
|
||||
snes_writemem((dmabank[d] << 16) | dmasrc[d], temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = snes_readmem((dmabank[d] << 16) | dmasrc[d]);
|
||||
// if (dmabank[d]==0 && dmasrc[d]<0x2000) printf("%02X %06X %04X\n",temp,dmabank[d]|dmasrc[d],dmalen[d]);
|
||||
writeppu(dmadest[d] + offset, temp);
|
||||
}
|
||||
if (!(dmactrl[d] & 8))
|
||||
@ -178,7 +172,6 @@ void writeio(UINT16 addr, UINT8 val)
|
||||
break;
|
||||
case 0x0C: /*HDMA enable*/
|
||||
hdmaena = val;
|
||||
// printf("HDMA ena : %02X %06X %i %i\n",val,pbr|pc,framenum,lines);
|
||||
break;
|
||||
case 0x0D: /*ROM speed select*/
|
||||
if (val & 1) speed = 6;
|
||||
@ -199,7 +192,6 @@ void writeio(UINT16 addr, UINT8 val)
|
||||
case 0x100: case 0x110: case 0x120: case 0x130: /*DMA control*/
|
||||
case 0x140: case 0x150: case 0x160: case 0x170:
|
||||
dmactrl[(addr >> 4) & 7] = val;
|
||||
// printf("Write ctrl %i %02X %06X\n",(addr>>4)&7,val,pbr|pc);
|
||||
break;
|
||||
case 0x101: case 0x111: case 0x121: case 0x131: /*DMA dest*/
|
||||
case 0x141: case 0x151: case 0x161: case 0x171:
|
||||
@ -232,12 +224,10 @@ void writeio(UINT16 addr, UINT8 val)
|
||||
case 0x108: case 0x118: case 0x128: case 0x138:
|
||||
case 0x148: case 0x158: case 0x168: case 0x178:
|
||||
hdmaaddr[(addr >> 4) & 7] = (hdmaaddr[(addr >> 4) & 7] & 0xFF00) | val;
|
||||
// printf("HDMA addr %i now %04X %06X\n",(addr>>4)&7,hdmaaddr[(addr>>4)&7],pbr|pc);
|
||||
break;
|
||||
case 0x109: case 0x119: case 0x129: case 0x139:
|
||||
case 0x149: case 0x159: case 0x169: case 0x179:
|
||||
hdmaaddr[(addr >> 4) & 7] = (hdmaaddr[(addr >> 4) & 7] & 0xFF) | (val << 8);
|
||||
// printf("HDMA addr %i now %04X %06X\n",(addr>>4)&7,hdmaaddr[(addr>>4)&7],pbr|pc);
|
||||
break;
|
||||
case 0x10A: case 0x11A: case 0x12A: case 0x13A: /*HDMA lines left*/
|
||||
case 0x14A: case 0x15A: case 0x16A: case 0x17A:
|
||||
@ -249,13 +239,6 @@ void writeio(UINT16 addr, UINT8 val)
|
||||
UINT8 readio(UINT16 addr)
|
||||
{
|
||||
int temp = 0;
|
||||
if (addr == 0x4016 || addr == 0x4017)
|
||||
{
|
||||
// printf("Read oldstyle joypad\n");
|
||||
// dumpregs();
|
||||
// exit(-1);
|
||||
}
|
||||
// if (addr!=0x4218 && addr!=0x4219) snemlog("Read IO %04X %02X:%04X %04X\n",addr,pbr>>16,pc,dp);
|
||||
switch (addr & 0x1FF)
|
||||
{
|
||||
case 0:
|
||||
@ -286,23 +269,17 @@ UINT8 readio(UINT16 addr)
|
||||
return 0;
|
||||
|
||||
case 0x14: /*Division Result Low*/
|
||||
// printf("Read div low\n");
|
||||
return divr;
|
||||
case 0x15: /*Division Result High*/
|
||||
// printf("Read div high\n");
|
||||
return divr >> 8;
|
||||
case 0x16: /*Multiplication Result Low*/
|
||||
// printf("Read mul low\n");
|
||||
return mulr;
|
||||
case 0x17: /*Multiplication Result High*/
|
||||
// printf("Read mul high\n");
|
||||
return mulr >> 8;
|
||||
|
||||
case 0x18: /*Joypad #1*/
|
||||
// printf("Read joy low %02X %06X %i\n",pad[0]>>8,pbr|pc,ins);
|
||||
return pad[0] & 0xFF;
|
||||
case 0x19:
|
||||
// printf("Read joy high %02X %06X\n",pad[0]&0xFF,pbr|pc);
|
||||
return pad[0] >> 8;
|
||||
|
||||
case 0x1A: case 0x1B: /*Joypad #2*/
|
||||
|
@ -300,6 +300,7 @@ void SnesReset()
|
||||
memset(AllRam, 0, RamEnd - AllRam);
|
||||
resetppu();
|
||||
resetspc();
|
||||
resetdsp();
|
||||
reset65816();
|
||||
frames = 0;
|
||||
}
|
||||
@ -460,6 +461,9 @@ INT32 SnesFrame()
|
||||
}
|
||||
|
||||
}
|
||||
if (pBurnSoundOut) {
|
||||
pollsound();
|
||||
}
|
||||
frames++;
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include "snes.h"
|
||||
|
||||
int spcoutput;
|
||||
|
||||
int spctotal,dsptotal;
|
||||
|
||||
@ -29,7 +28,7 @@ struct SPC_Struct
|
||||
} spc;
|
||||
|
||||
|
||||
UINT8 *spcram;
|
||||
|
||||
UINT8 spcrom[64]=
|
||||
{
|
||||
0xCD,0xEF,0xBD,0xE8,0x00,0xC6,0x1D,0xD0,
|
||||
@ -72,6 +71,8 @@ void writespcregs(UINT16 a, UINT8 v)
|
||||
else spcreadhigh=spcram+0xFFC0;
|
||||
// printf("Write F1 %02X %04X\n",v,spc.pc);
|
||||
break;
|
||||
case 0xF2: case 0xF3:
|
||||
writedsp(a, v);
|
||||
case 0xF4: case 0xF5: case 0xF6: case 0xF7:
|
||||
spctocpu[a&3]=v;
|
||||
// printf("SPC writes %02X to %02X\n",v,a);
|
||||
@ -95,6 +96,8 @@ UINT8 readspcregs(UINT16 a)
|
||||
UINT8 v;
|
||||
switch (a)
|
||||
{
|
||||
case 0xF2: case 0xF3:
|
||||
return readdsp(a);
|
||||
case 0xFD: case 0xFE: case 0xFF:
|
||||
// printf("Read timer %04X\n",spc.pc);
|
||||
v=spcram[a];
|
||||
@ -1912,12 +1915,7 @@ void execspc()
|
||||
if (dsptotal<=0)
|
||||
{
|
||||
dsptotal+=32;
|
||||
// snemlog("PollDSP\n");
|
||||
// polldsp();
|
||||
polldsp();
|
||||
}
|
||||
// spctotal+=spccount;
|
||||
// if (spcoutput) printf("%04X : %04X %02X %02X %02X\n",spc.pc,spc.ya.w,spc.x,spc.s,opcode);
|
||||
// if (spc.pc==0x12F7) printf("12F7 from %04X %04X\n",spc2,spc3);
|
||||
}
|
||||
// snemlog("End of execSPC\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user