add tms5220 speech synth, hook-up to gauntlet 1 and 2

This commit is contained in:
dinkc64 2018-02-12 12:24:45 +00:00
parent e795e0a49b
commit c79af0f834
5 changed files with 1304 additions and 16 deletions

View File

@ -96,7 +96,7 @@ depobj = burn.o burn_gun.o burn_led.o burn_shift.o burn_memory.o burn_pal.o bur
\
ay8910.o burn_y8950.o burn_ym2151.o burn_ym2203.o burn_ym2413.o burn_ym2608.o burn_ym2610.o burn_ym2612.o burn_md2612.o \
burn_ym3526.o burn_ym3812.o burn_ymf278b.o c6280.o dac.o es5506.o es8712.o flower.o flt_rc.o fm.o fmopl.o ym2612.o gaelco.o ics2115.o iremga20.o \
k005289.o k007232.o k051649.o k053260.o k054539.o msm5205.o msm5232.o msm6295.o namco_snd.o c140.o nes_apu.o tms36xx.o phoenixsound.o \
k005289.o k007232.o k051649.o k053260.o k054539.o msm5205.o msm5232.o msm6295.o namco_snd.o c140.o nes_apu.o tms5220.o tms36xx.o phoenixsound.o \
pleiadssound.o pokey.o rf5c68.o saa1099.o samples.o segapcm.o sn76477.o sn76496.o upd7759.o vlm5030.o wiping.o x1010.o ym2151.o ym2413.o \
ymdeltat.o ymf278b.o ymz280b.o snk6502_sound.o \
\

View File

@ -6,6 +6,7 @@
#include "m6502_intf.h"
#include "burn_ym2151.h"
#include "pokey.h"
#include "tms5220.h"
//#define SNDCPUDBG
@ -504,7 +505,8 @@ static INT32 nCyclesSegment;
static UINT8 DrvGameType;
static UINT8 speech_val;
static UINT8 last_speech_write;
struct atarigen_modesc
@ -1657,7 +1659,8 @@ static INT32 DrvDoReset()
M6502Close();
BurnYM2151Reset();
tms5220_reset();
atarigen_SlapsticReset();
atarigen_eeprom_reset();
@ -1668,7 +1671,8 @@ static INT32 DrvDoReset()
DrvSoundtoCPUReady = 0;
DrvCPUtoSound = 0;
DrvSoundtoCPU = 0;
last_speech_write = 0x80;
return 0;
}
@ -1682,7 +1686,7 @@ UINT8 __fastcall Gauntlet68KReadByte(UINT32 a)
switch (a) {
case 0x803009: {
UINT8 Res = DrvInput[4] | (DrvVBlank ? 0x40 : 0x00);
UINT8 Res = (DrvInput[4] | (DrvVBlank ? 0x00 : 0x40)) & ~0x30;
if (DrvCPUtoSoundReady) Res ^= 0x20;
if (DrvSoundtoCPUReady) Res ^= 0x10;
return Res;
@ -1744,10 +1748,10 @@ UINT16 __fastcall Gauntlet68KReadWord(UINT32 a)
}
case 0x803008: {
UINT8 Res = DrvInput[4] | (DrvVBlank ? 0x40 : 0x00);
UINT8 Res = (DrvInput[4] | (DrvVBlank ? 0x00 : 0x40)) & ~0x30;
if (DrvCPUtoSoundReady) Res ^= 0x20;
if (DrvSoundtoCPUReady) Res ^= 0x10;
return 0xff00 | Res;
return 0x0000 | Res;
}
case 0x80300e: {
@ -1812,7 +1816,7 @@ void __fastcall Gauntlet68KWriteWord(UINT32 a, UINT16 d)
}
case 0x803140: {
// irq_ack
SekSetIRQLine(4, CPU_IRQSTATUS_NONE);
return;
}
@ -1826,9 +1830,9 @@ void __fastcall Gauntlet68KWriteWord(UINT32 a, UINT16 d)
#ifdef SNDCPUDBG
if (DrvCPUtoSoundReady) bprintf(0, _T("68k: sound command missed!\n"));
#endif
DrvCPUtoSoundReady = 1;
M6502Open(0);
soundcpuSync();
DrvCPUtoSoundReady = 1;
M6502SetIRQLine(M6502_INPUT_LINE_NMI, CPU_IRQSTATUS_ACK);
M6502Close();
return;
@ -1872,7 +1876,7 @@ UINT8 GauntletSoundRead(UINT16 Address)
if (DrvCPUtoSoundReady) Res ^= 0x80;
if (DrvSoundtoCPUReady) Res ^= 0x40;
Res ^= 0x20; // tms5220 ready status, no core yet.
if (tms5220_ready()) Res ^= 0x20; // tms5220 ready status
if (!(Input & 0x08)) Res ^= 0x10;
return Res;
}
@ -1938,8 +1942,41 @@ void GauntletSoundWrite(UINT16 Address, UINT8 Data)
case 0x1032:
case 0x1033:
case 0x1034:
case 0x1035: {
case 0x1035:
case 0x1036:
case 0x1037:
case 0x1038:
case 0x1039:
case 0x103a:
case 0x103b:
case 0x103c:
case 0x103d:
case 0x103e:
case 0x103f:
{
// sound_ctl_w
switch (Address & 7)
{
case 0:
if (!Data&0x80) BurnYM2151Reset();
break;
case 1: /* speech write, bit D7, active low */
if (((Data ^ last_speech_write) & 0x80) && (Data & 0x80))
tms5220_write(speech_val);
last_speech_write = Data;
break;
case 2: /* speech reset, bit D7, active low */
if (((Data ^ last_speech_write) & 0x80) && (Data & 0x80))
tms5220_reset();
break;
case 3: /* speech squeak, bit D7 */
Data = 5 | ((Data >> 6) & 2);
tms5220_set_frequency(14000000/2 / (16 - Data));
break;
}
return;
}
@ -1953,8 +1990,24 @@ void GauntletSoundWrite(UINT16 Address, UINT8 Data)
return;
}
case 0x1820: {
// tms5220_w
case 0x1820:
case 0x1821:
case 0x1822:
case 0x1823:
case 0x1824:
case 0x1825:
case 0x1826:
case 0x1827:
case 0x1828:
case 0x1829:
case 0x182a:
case 0x182b:
case 0x182c:
case 0x182d:
case 0x182e:
case 0x182f:
{
speech_val = Data;
return;
}
@ -2080,6 +2133,9 @@ static INT32 DrvInit()
PokeyInit(14000000/8, 2, 1.00, 1);
tms5220_init();
tms5220_set_frequency(14000000/2/11);
GenericTilesInit();
static struct atarigen_modesc gauntlet_modesc =
@ -2193,6 +2249,9 @@ static INT32 Gaunt2pInit()
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.48, BURN_SND_ROUTE_LEFT);
PokeyInit(14000000/8, 2, 1.00, 1);
tms5220_init();
tms5220_set_frequency(14000000/2/11);
GenericTilesInit();
@ -2318,6 +2377,9 @@ static INT32 Gaunt2Init()
PokeyInit(14000000/8, 2, 1.00, 1);
tms5220_init();
tms5220_set_frequency(14000000/2/11);
GenericTilesInit();
static struct atarigen_modesc gauntlet_modesc =
@ -2346,6 +2408,7 @@ static INT32 DrvExit()
M6502Exit();
BurnYM2151Exit();
tms5220_exit();
PokeyExit();
@ -2504,7 +2567,7 @@ static INT32 DrvFrame()
nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
if (i == 11*nMult) DrvVBlank = 0;
if (i == 250*nMult) DrvVBlank = 1;
if (i == 261*nMult) SekSetIRQLine(4, CPU_IRQSTATUS_AUTO);
if (i == 261*nMult) SekSetIRQLine(4, CPU_IRQSTATUS_ACK);
SekClose();
if (i%nMult==nMult-1 && i/nMult == NextScanline) {
@ -2529,8 +2592,8 @@ static INT32 DrvFrame()
{
if ((i/nMult) & 32)
M6502SetIRQLine(M6502_IRQ_LINE, CPU_IRQSTATUS_ACK);
else
M6502SetIRQLine(M6502_IRQ_LINE, CPU_IRQSTATUS_NONE);
// else
// M6502SetIRQLine(M6502_IRQ_LINE, CPU_IRQSTATUS_NONE);
}
M6502Close();
} else {
@ -2555,6 +2618,7 @@ static INT32 DrvFrame()
BurnYM2151Render(pSoundBuf, nSegmentLength);
}
pokey_update(0, pBurnSoundOut, nBurnSoundLen);
tms5220_update(pBurnSoundOut, nBurnSoundLen);
}
if (pBurnDraw) DrvDraw();
@ -2584,6 +2648,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
BurnYM2151Scan(nAction, pnMin);
pokey_scan(nAction, pnMin);
tms5220_scan(nAction, pnMin);
SCAN_VAR(DrvVBlank);
SCAN_VAR(DrvSoundResetVal);
@ -2593,6 +2658,8 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
SCAN_VAR(DrvCPUtoSound);
SCAN_VAR(DrvSoundtoCPU);
SCAN_VAR(eeprom_unlocked);
SCAN_VAR(speech_val);
SCAN_VAR(last_speech_write);
// slapstic stuff
SCAN_VAR(state);
SCAN_VAR(next_bank);

1098
src/burn/snd/tms5220.cpp Normal file

File diff suppressed because it is too large Load Diff

18
src/burn/snd/tms5220.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef tms5220_h
#define tms5220_h
void tms5220_init();
void tms5220_exit();
void tms5220_reset();
void tms5220_scan(INT32 nAction, INT32 *pnMin);
void tms5220_write(UINT8 data);
UINT8 tms5220_status(); // read
UINT8 tms5220_ready(); // read
UINT8 tms5220_cycles(); // to ready
UINT8 tms5220_irq(); // read interrupt state
void tms5220_set_frequency(UINT32 freq);
void tms5220_update(INT16 *buffer, INT32 samples_len); // render samples
#endif

View File

@ -0,0 +1,105 @@
/* TMS5220 ROM Tables */
/* This is the energy lookup table (4-bits -> 10-bits) */
const static unsigned short energytable[0x10]={
0x0000,0x00C0,0x0140,0x01C0,0x0280,0x0380,0x0500,0x0740,
0x0A00,0x0E40,0x1440,0x1C80,0x2840,0x38C0,0x5040,0x7FC0};
/* This is the pitch lookup table (6-bits -> 8-bits) */
const static unsigned short pitchtable [0x40]={
0x0000,0x1000,0x1100,0x1200,0x1300,0x1400,0x1500,0x1600,
0x1700,0x1800,0x1900,0x1A00,0x1B00,0x1C00,0x1D00,0x1E00,
0x1F00,0x2000,0x2100,0x2200,0x2300,0x2400,0x2500,0x2600,
0x2700,0x2800,0x2900,0x2A00,0x2B00,0x2D00,0x2F00,0x3100,
0x3300,0x3500,0x3600,0x3900,0x3B00,0x3D00,0x3F00,0x4200,
0x4500,0x4700,0x4900,0x4D00,0x4F00,0x5100,0x5500,0x5700,
0x5C00,0x5F00,0x6300,0x6600,0x6A00,0x6E00,0x7300,0x7700,
0x7B00,0x8000,0x8500,0x8A00,0x8F00,0x9500,0x9A00,0xA000};
/* These are the reflection coefficient lookup tables */
/* K1 is (5-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k1table [0x20]={
(short)0x82C0,(short)0x8380,(short)0x83C0,(short)0x8440,(short)0x84C0,(short)0x8540,(short)0x8600,(short)0x8780,
(short)0x8880,(short)0x8980,(short)0x8AC0,(short)0x8C00,(short)0x8D40,(short)0x8F00,(short)0x90C0,(short)0x92C0,
(short)0x9900,(short)0xA140,(short)0xAB80,(short)0xB840,(short)0xC740,(short)0xD8C0,(short)0xEBC0,0x0000,
0x1440,0x2740,0x38C0,0x47C0,0x5480,0x5EC0,0x6700,0x6D40};
/* K2 is (5-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k2table [0x20]={
(short)0xAE00,(short)0xB480,(short)0xBB80,(short)0xC340,(short)0xCB80,(short)0xD440,(short)0xDDC0,(short)0xE780,
(short)0xF180,(short)0xFBC0,0x0600,0x1040,0x1A40,0x2400,0x2D40,0x3600,
0x3E40,0x45C0,0x4CC0,0x5300,0x5880,0x5DC0,0x6240,0x6640,
0x69C0,0x6CC0,0x6F80,0x71C0,0x73C0,0x7580,0x7700,0x7E80};
/* K3 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k3table [0x10]={
(short)0x9200,(short)0x9F00,(short)0xAD00,(short)0xBA00,(short)0xC800,(short)0xD500,(short)0xE300,(short)0xF000,
(short)0xFE00,0x0B00,0x1900,0x2600,0x3400,0x4100,0x4F00,0x5C00};
/* K4 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k4table [0x10]={
(short)0xAE00,(short)0xBC00,(short)0xCA00,(short)0xD800,(short)0xE600,(short)0xF400,0x0100,0x0F00,
0x1D00,0x2B00,0x3900,0x4700,0x5500,0x6300,0x7100,0x7E00};
/* K5 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k5table [0x10]={
(short)0xAE00,(short)0xBA00,(short)0xC500,(short)0xD100,(short)0xDD00,(short)0xE800,(short)0xF400,(short)0xFF00,
0x0B00,0x1700,0x2200,0x2E00,0x3900,0x4500,0x5100,0x5C00};
/* K6 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k6table [0x10]={
(short)0xC000,(short)0xCB00,(short)0xD600,(short)0xE100,(short)0xEC00,(short)0xF700,0x0300,0x0E00,
0x1900,0x2400,0x2F00,0x3A00,0x4500,0x5000,0x5B00,0x6600};
/* K7 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k7table [0x10]={
(short)0xB300,(short)0xBF00,(short)0xCB00,(short)0xD700,(short)0xE300,(short)0xEF00,(short)0xFB00,0x0700,
0x1300,0x1F00,0x2B00,0x3700,0x4300,0x4F00,0x5A00,0x6600};
/* K8 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k8table [0x08]={
(short)0xC000,(short)0xD800,(short)0xF000,0x0700,0x1F00,0x3700,0x4F00,0x6600};
/* K9 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k9table [0x08]={
(short)0xC000,(short)0xD400,(short)0xE800,(short)0xFC00,0x1000,0x2500,0x3900,0x4D00};
/* K10 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */
const static short k10table [0x08]={
(short)0xCD00,(short)0xDF00,(short)0xF100,0x0400,0x1600,0x2000,0x3B00,0x4D00};
/* chirp table */
static char chirptable[41]={
0x00, 0x2a, (char)0xd4, 0x32,
(char)0xb2, 0x12, 0x25, 0x14,
0x02, (char)0xe1, (char)0xc5, 0x02,
0x5f, 0x5a, 0x05, 0x0f,
0x26, (char)0xfc, (char)0xa5, (char)0xa5,
(char)0xd6, (char)0xdd, (char)0xdc, (char)0xfc,
0x25, 0x2b, 0x22, 0x21,
0x0f, (char)0xff, (char)0xf8, (char)0xee,
(char)0xed, (char)0xef, (char)0xf7, (char)0xf6,
(char)0xfa, 0x00, 0x03, 0x02,
0x01
};
/* interpolation coefficients */
static char interp_coeff[8] = {
8, 8, 8, 4, 4, 2, 2, 1
};