Change King & Balloon to use new DAC, add emulation of the sample CPU and DAC in SF-X
This commit is contained in:
parent
3065440a4b
commit
41d8467630
|
@ -16573,7 +16573,7 @@ UINT8 __fastcall SfxSampleZ80Read(UINT16 a)
|
|||
}
|
||||
}
|
||||
|
||||
return 0xff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __fastcall SfxSampleZ80Write(UINT16 a, UINT8 d)
|
||||
|
@ -16589,29 +16589,21 @@ UINT8 __fastcall SfxSampleZ80PortRead(UINT16 a)
|
|||
{
|
||||
a &= 0xff;
|
||||
|
||||
switch (a) {
|
||||
default: {
|
||||
bprintf(PRINT_NORMAL, _T("Z80 #3 Port Read => %02X\n"), a);
|
||||
}
|
||||
}
|
||||
|
||||
return 0xff;
|
||||
UINT8 Result = 0xff;
|
||||
if (a & 0x04) Result &= ppi8255_r(2, a & 3);
|
||||
return Result;
|
||||
}
|
||||
|
||||
void __fastcall SfxSampleZ80PortWrite(UINT16 a, UINT8 d)
|
||||
{
|
||||
a &= 0xff;
|
||||
|
||||
switch (a) {
|
||||
default: {
|
||||
bprintf(PRINT_NORMAL, _T("Z80 #3 Port Write => %02X, %02X\n"), a, d);
|
||||
}
|
||||
}
|
||||
if (a & 0x04) ppi8255_w(2, a & 3, d);
|
||||
if (a & 0x10) DACSignedWrite(0, d);
|
||||
}
|
||||
|
||||
static UINT8 SfxSoundLatch2Read()
|
||||
{
|
||||
bprintf(PRINT_NORMAL, _T("Sound Latch2 Read\n"));
|
||||
return GalSoundLatch2;
|
||||
}
|
||||
|
||||
|
@ -16641,7 +16633,12 @@ static void SfxPostLoad()
|
|||
ZetSetOutHandler(SfxSampleZ80PortWrite);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 0, GalZ80Rom3);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 2, GalZ80Rom3);
|
||||
ZetClose();
|
||||
ZetMapArea(0x8000, 0x83ff, 0, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 1, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 2, GalZ80Ram3);
|
||||
ZetClose();
|
||||
|
||||
nGalCyclesTotal[2] = (14318000 / 8) / 60;
|
||||
}
|
||||
|
||||
static INT32 SfxInit()
|
||||
|
@ -16700,7 +16697,12 @@ static void SkelagonPostLoad()
|
|||
ZetSetOutHandler(SfxSampleZ80PortWrite);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 0, GalZ80Rom3);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 2, GalZ80Rom3);
|
||||
ZetClose();
|
||||
ZetMapArea(0x8000, 0x83ff, 0, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 1, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 2, GalZ80Ram3);
|
||||
ZetClose();
|
||||
|
||||
nGalCyclesTotal[2] = (14318000 / 8) / 60;
|
||||
}
|
||||
|
||||
static INT32 SkelagonInit()
|
||||
|
@ -16750,6 +16752,9 @@ static void MonsterzPostLoad()
|
|||
ZetSetOutHandler(SfxSampleZ80PortWrite);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 0, GalZ80Rom3);
|
||||
ZetMapArea(0x0000, GalZ80Rom3Size - 1, 2, GalZ80Rom3);
|
||||
ZetMapArea(0x8000, 0x83ff, 0, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 1, GalZ80Ram3);
|
||||
ZetMapArea(0x8000, 0x83ff, 2, GalZ80Ram3);
|
||||
ZetClose();
|
||||
|
||||
GalTempRom = (UINT8*)BurnMalloc(GalZ80Rom3Size);
|
||||
|
@ -16758,6 +16763,8 @@ static void MonsterzPostLoad()
|
|||
memset(GalZ80Rom3 + 0x3000, 0xff, 0x1000);
|
||||
memcpy(GalZ80Rom3 + 0x4000, GalTempRom + 0x3000, 0x2000);
|
||||
BurnFree(GalTempRom);
|
||||
|
||||
nGalCyclesTotal[2] = (14318000 / 8) / 60;
|
||||
}
|
||||
|
||||
static INT32 MonsterzInit()
|
||||
|
|
|
@ -190,6 +190,7 @@ extern UINT8 *GalZ80Rom3;
|
|||
extern UINT8 *GalS2650Rom1;
|
||||
extern UINT8 *GalZ80Ram1;
|
||||
extern UINT8 *GalZ80Ram2;
|
||||
extern UINT8 *GalZ80Ram3;
|
||||
extern UINT8 *GalVideoRam;
|
||||
extern UINT8 *GalVideoRam2;
|
||||
extern UINT8 *GalSpriteRam;
|
||||
|
@ -297,6 +298,8 @@ void FroggerSoundInit();
|
|||
void FroggerSoundNoEncryptionInit();
|
||||
void KonamiSoundInit();
|
||||
void HunchbksSoundInit();
|
||||
INT32 KingballSyncDAC();
|
||||
INT32 SfxSyncDAC();
|
||||
void GalRenderSoundSamples(INT16 *pSoundBuf, INT32 nLength);
|
||||
void GalaxianSoundWrite(UINT32 Offset, UINT8 d);
|
||||
void GalaxianLfoFreqWrite(UINT32 Offset, UINT8 d);
|
||||
|
|
|
@ -22,6 +22,7 @@ UINT8 *GalZ80Rom3 = NULL;
|
|||
UINT8 *GalS2650Rom1 = NULL;
|
||||
UINT8 *GalZ80Ram1 = NULL;
|
||||
UINT8 *GalZ80Ram2 = NULL;
|
||||
UINT8 *GalZ80Ram3 = NULL;
|
||||
UINT8 *GalVideoRam = NULL;
|
||||
UINT8 *GalVideoRam2 = NULL;
|
||||
UINT8 *GalSpriteRam = NULL;
|
||||
|
@ -113,6 +114,10 @@ static INT32 GalMemIndex()
|
|||
GalZ80Ram2 = Next; Next += 0x00400;
|
||||
}
|
||||
|
||||
if (GalZ80Rom3Size) {
|
||||
GalZ80Ram3 = Next; Next += 0x00400;
|
||||
}
|
||||
|
||||
GalRamEnd = Next;
|
||||
|
||||
GalChars = Next; Next += GalNumChars * 8 * 8;
|
||||
|
@ -1600,9 +1605,9 @@ INT32 GalFrame()
|
|||
nInterleave = nBurnSoundLen;
|
||||
GalaxianSoundUpdateTimers();
|
||||
}
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KONAMIAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_FROGGERAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_EXPLORERAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SCORPIONAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC || GalSoundType == GAL_SOUND_HARDWARE_TYPE_HUNCHBACKAY8910) nInterleave = nBurnSoundLen / 4;
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KONAMIAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_FROGGERAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_EXPLORERAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SCORPIONAY8910 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_HUNCHBACKAY8910) nInterleave = nBurnSoundLen / 4;
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC) nInterleave = 32;
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_CHECKMAJAY8910) nInterleave = 32;
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC) nInterleave = nBurnSoundLen;
|
||||
|
||||
INT32 nIrqInterleaveFire = nInterleave / 4;
|
||||
|
||||
|
@ -1759,7 +1764,7 @@ INT32 GalFrame()
|
|||
}
|
||||
}
|
||||
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC/* || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC*/) {
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC) {
|
||||
if (pBurnSoundOut) {
|
||||
INT32 nSegmentLength = nBurnSoundLen / nInterleave;
|
||||
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
|
||||
|
@ -1831,7 +1836,7 @@ INT32 GalFrame()
|
|||
}
|
||||
}
|
||||
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC/* || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC*/) {
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC) {
|
||||
if (pBurnSoundOut) {
|
||||
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
|
||||
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
|
||||
|
@ -1843,6 +1848,10 @@ INT32 GalFrame()
|
|||
}
|
||||
}
|
||||
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC) {
|
||||
if (pBurnSoundOut) DACUpdate(pBurnSoundOut, nBurnSoundLen);
|
||||
}
|
||||
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_RACKNROLSN76496 || GalSoundType == GAL_SOUND_HARDWARE_TYPE_HEXPOOLASN76496) {
|
||||
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
|
||||
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
|
||||
|
|
|
@ -186,10 +186,13 @@ void GalSoundInit()
|
|||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC) {
|
||||
AY8910Init(0, 14318000 / 8, nBurnSoundRate, NULL, NULL, &SfxSoundLatch2Write, &SfxSampleControlWrite);
|
||||
AY8910Init(1, 14318000 / 8, nBurnSoundRate, &KonamiSoundLatchRead, &KonamiSoundTimerRead, NULL, NULL);
|
||||
|
||||
DACInit(0, 0, 1, SfxSyncDAC);
|
||||
DACSetVolShift(0, 2);
|
||||
}
|
||||
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC || GalSoundType == GAL_SOUND_HARDWARE_TYPE_SFXAY8910DAC) {
|
||||
DACInit(0, 0, 1);
|
||||
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_KINGBALLDAC) {
|
||||
DACInit(0, 0, 1, KingballSyncDAC);
|
||||
DACSetVolShift(0, 2);
|
||||
}
|
||||
|
||||
|
@ -537,12 +540,17 @@ void SfxSampleControlWrite(UINT32, UINT32 d)
|
|||
if ((Old & 0x01) && !(d & 0x01)) {
|
||||
INT32 nActiveCPU = ZetGetActive();
|
||||
|
||||
if (nActiveCPU == 1) {
|
||||
if (nActiveCPU == 2) {
|
||||
ZetSetIRQLine(0, ZET_IRQSTATUS_ACK);
|
||||
nGalCyclesDone[2] += ZetRun(100);
|
||||
ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
|
||||
|
||||
} else {
|
||||
ZetClose();
|
||||
ZetOpen(1);
|
||||
ZetOpen(2);
|
||||
ZetSetIRQLine(0, ZET_IRQSTATUS_ACK);
|
||||
nGalCyclesDone[2] += ZetRun(100);
|
||||
ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
|
||||
ZetClose();
|
||||
ZetOpen(nActiveCPU);
|
||||
}
|
||||
|
@ -724,6 +732,17 @@ void HunchbksSoundInit()
|
|||
nGalCyclesTotal[1] = (14318000 / 8) / 60;
|
||||
}
|
||||
|
||||
// DAC handlers
|
||||
INT32 KingballSyncDAC()
|
||||
{
|
||||
return (INT32)(float)(nBurnSoundLen * (ZetTotalCycles() / ((nGalCyclesTotal[1] * 60.0000) / (nBurnFPS / 100.0000))));
|
||||
}
|
||||
|
||||
INT32 SfxSyncDAC()
|
||||
{
|
||||
return (INT32)(float)(nBurnSoundLen * (ZetTotalCycles() / ((nGalCyclesTotal[2] * 60.0000) / (nBurnFPS / 100.0000))));
|
||||
}
|
||||
|
||||
// Galaxian samples
|
||||
static void GalRenderShootSample(INT16 *pSoundBuf, INT32 nLength)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue