pic16c5x - standardize cpu functions

also fix sound in dragon master.
This commit is contained in:
iq_132 2014-09-15 02:25:15 +00:00
parent 2ade39e0b8
commit b2d2f8e4f6
5 changed files with 90 additions and 39 deletions

View File

@ -480,7 +480,9 @@ static INT32 DrvDoReset()
SekReset();
SekClose();
pic16c5xOpen(0);
pic16c5xReset();
pic16c5xClose();
set_oki_bank0(0);
set_oki_bank1(0);
@ -593,11 +595,13 @@ static INT32 DrvInit()
SekClose();
pic16c5xInit(0x16C55, DrvPicROM);
pPic16c5xReadPort = drgnmst_sound_readport;
pPic16c5xWritePort = drgnmst_sound_writeport;
pic16c5xOpen(0);
pic16c5xSetReadPortHandler(drgnmst_sound_readport);
pic16c5xSetWritePortHandler(drgnmst_sound_writeport);
pic16c5xClose();
MSM6295Init(0, 1000000 / 132, 0);
MSM6295Init(1, 1000000 / 132, 0);
MSM6295Init(1, 1000000 / 132, 1);
MSM6295SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
MSM6295SetRoute(1, 0.50, BURN_SND_ROUTE_BOTH);
@ -912,11 +916,13 @@ static INT32 DrvFrame()
INT32 nCycleSegment;
SekOpen(0);
pic16c5xOpen(0);
for (INT32 i = 0; i < nInterleave; i++)
{
nCycleSegment = (nCyclesTotal[0] - nCyclesDone[0]) / (nInterleave - i);
nCyclesDone[0] += SekRun(nCycleSegment);
if (i == (nInterleave - 1)) SekSetIRQLine(2, SEK_IRQSTATUS_AUTO);
nCycleSegment = (nCyclesTotal[1] - nCyclesDone[1]) / (nInterleave - i);
nCyclesDone[1] += pic16c5xRun(nCycleSegment);
@ -924,14 +930,13 @@ static INT32 DrvFrame()
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen / nInterleave;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
// memset (pSoundBuf, 0, nSegmentLength);
MSM6295Render(0, pSoundBuf, nSegmentLength);
MSM6295Render(1, pSoundBuf, nSegmentLength);
nSoundBufferPos += nSegmentLength;
}
}
SekSetIRQLine(2, SEK_IRQSTATUS_AUTO);
pic16c5xClose();
SekClose();
if (pBurnSoundOut) {
@ -939,7 +944,6 @@ static INT32 DrvFrame()
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
// memset (pSoundBuf, 0, nSegmentLength);
MSM6295Render(0, pSoundBuf, nSegmentLength);
MSM6295Render(1, pSoundBuf, nSegmentLength);
}
@ -971,7 +975,7 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
if (nAction & ACB_DRIVER_DATA) {
SekScan(nAction);
pic16c5xScan(nAction, 0);
pic16c5xScan(nAction);
MSM6295Scan(0, nAction);
MSM6295Scan(1, nAction);

View File

@ -467,7 +467,9 @@ static INT32 DrvDoReset()
SekReset();
SekClose();
pic16c5xOpen(0);
pic16c5xReset();
pic16c5xClose();
MSM6295Reset(0);
@ -1061,8 +1063,10 @@ static INT32 DrvInit()
SekClose();
pic16c5xInit(0x16C57, DrvPicRom);
pPic16c5xReadPort = PlaymarkSoundReadPort;
pPic16c5xWritePort = PlaymarkSoundWritePort;
pic16c5xOpen(0);
pic16c5xSetReadPortHandler(PlaymarkSoundReadPort);
pic16c5xSetWritePortHandler(PlaymarkSoundWritePort);
pic16c5xClose();
MSM6295Init(0, 1000000 / 132, 0);
MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
@ -1152,8 +1156,10 @@ static INT32 ExcelsrInit()
SekClose();
pic16c5xInit(0x16C57, DrvPicRom);
pPic16c5xReadPort = PlaymarkSoundReadPort;
pPic16c5xWritePort = PlaymarkSoundWritePort;
pic16c5xOpen(0);
pic16c5xSetReadPortHandler(PlaymarkSoundReadPort);
pic16c5xSetWritePortHandler(PlaymarkSoundWritePort);
pic16c5xClose();
MSM6295Init(0, 1000000 / 132, 0);
MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
@ -1254,8 +1260,10 @@ static INT32 HotmindInit()
SekClose();
pic16c5xInit(0x16C57, DrvPicRom);
pPic16c5xReadPort = PlaymarkSoundReadPort;
pPic16c5xWritePort = PlaymarkSoundWritePort;
pic16c5xOpen(0);
pic16c5xSetReadPortHandler(PlaymarkSoundReadPort);
pic16c5xSetWritePortHandler(PlaymarkSoundWritePort);
pic16c5xClose();
MSM6295Init(0, 1000000 / 132, 0);
MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
@ -1633,6 +1641,8 @@ static INT32 DrvFrame()
SekNewFrame();
SekOpen(0);
pic16c5xOpen(0);
for (INT32 i = 0; i < nInterleave; i++) {
INT32 nCurrentCPU, nNext;
@ -1657,6 +1667,8 @@ static INT32 DrvFrame()
nSoundBufferPos += nSegmentLength;
}
}
pic16c5xClose();
SekClose();
if (pBurnSoundOut) {

View File

@ -50,7 +50,7 @@ void pic16c5x_config(int data);
*/
#define PIC16C5x_T0 0x10
#define PIC16C5x_T0_In (pic16c5x_read_port((PIC16C5x_T0)))
#define PIC16C5x_T0_In (pic16c5xReadPort((PIC16C5x_T0)))
@ -58,7 +58,7 @@ void pic16c5x_config(int data);
* Input a word from given I/O port
*/
#define PIC16C5x_In(Port) (pic16c5x_read_port((Port)))
#define PIC16C5x_In(Port) (pic16c5xReadPort((Port)))
@ -66,7 +66,7 @@ void pic16c5x_config(int data);
* Output a word to given I/O port
*/
#define PIC16C5x_Out(Port,Value) (pic16c5x_write_port(Port, Value))
#define PIC16C5x_Out(Port,Value) (pic16c5xWritePort(Port, Value))
@ -74,7 +74,7 @@ void pic16c5x_config(int data);
* Read a word from given RAM memory location
*/
#define PIC16C5x_RAM_RDMEM(A) (pic16c5x_read_byte(A))
#define PIC16C5x_RAM_RDMEM(A) (pic16c5xRead(A))
@ -82,7 +82,7 @@ void pic16c5x_config(int data);
* Write a word to given RAM memory location
*/
#define PIC16C5x_RAM_WRMEM(A,V) (pic16c5x_write_byte(A, V))
#define PIC16C5x_RAM_WRMEM(A,V) (pic16c5xWrite(A, V))
@ -92,7 +92,7 @@ void pic16c5x_config(int data);
* can be used to greatly speed up emulation
*/
#define PIC16C5x_RDOP(A) pic16c5x_read_op(A)
#define PIC16C5x_RDOP(A) pic16c5xFetch(A)
/****************************************************************************
@ -101,7 +101,7 @@ void pic16c5x_config(int data);
* that use different encoding mechanisms for opcodes and opcode arguments
*/
#define PIC16C5x_RDOP_ARG(A) (pic16c5x_read_op(A))
#define PIC16C5x_RDOP_ARG(A) (pic16c5xFetch(A))

View File

@ -14,7 +14,7 @@ static UINT8 *pic16c5x_ram = NULL;
UINT8 (*pPic16c5xReadPort)(UINT16 port) = NULL;
void (*pPic16c5xWritePort)(UINT16 port, UINT8 data) = NULL;
UINT16 pic16c5x_read_op(UINT16 address)
UINT16 pic16c5xFetch(UINT16 address)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5x_read_op called without init\n"));
@ -27,7 +27,7 @@ UINT16 pic16c5x_read_op(UINT16 address)
return ROM[address];
}
UINT8 pic16c5x_read_byte(UINT16 address)
UINT8 pic16c5xRead(UINT16 address)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5x_read_byte called without init\n"));
@ -44,7 +44,7 @@ UINT8 pic16c5x_read_byte(UINT16 address)
return pic16c5x_ram[address];
}
void pic16c5x_write_byte(UINT16 address, UINT8 data)
void pic16c5xWrite(UINT16 address, UINT8 data)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5x_write_byte called without init\n"));
@ -63,7 +63,7 @@ void pic16c5x_write_byte(UINT16 address, UINT8 data)
pic16c5x_ram[address] = data;
}
UINT8 pic16c5x_read_port(UINT16 port)
UINT8 pic16c5xReadPort(UINT16 port)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5x_read_port called without init\n"));
@ -76,7 +76,7 @@ UINT8 pic16c5x_read_port(UINT16 port)
return 0;
}
void pic16c5x_write_port(UINT16 port, UINT8 data)
void pic16c5xWritePort(UINT16 port, UINT8 data)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5x_write_port called without init\n"));
@ -88,6 +88,38 @@ void pic16c5x_write_port(UINT16 port, UINT8 data)
}
}
void pic16c5xSetWritePortHandler(void (*write)(UINT16 port, UINT8 data))
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5xSetWritePortHandler called without init\n"));
#endif
pPic16c5xWritePort = write;
}
void pic16c5xSetReadPortHandler(UINT8 (*read)(UINT16 port))
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5xSetReadPortHandler called without init\n"));
#endif
pPic16c5xReadPort = read;
}
void pic16c5xOpen(INT32)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5xOpen called without init\n"));
#endif
}
void pic16c5xClose()
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5xClose called without init\n"));
#endif
}
void pic16c5xReset()
{
#if defined FBA_DEBUG
@ -124,7 +156,7 @@ void pic16c5xExit()
DebugCPU_PIC16C5XInitted = 0;
}
INT32 pic16c5xScan(INT32 nAction,INT32 */*pnMin*/)
INT32 pic16c5xScan(INT32 nAction)
{
#if defined FBA_DEBUG
if (!DebugCPU_PIC16C5XInitted) bprintf(PRINT_ERROR, _T("pic16c5xScan called without init\n"));
@ -145,7 +177,6 @@ INT32 pic16c5xScan(INT32 nAction,INT32 */*pnMin*/)
return 0;
}
static UINT8 asciitohex(UINT8 data)
{
/* Convert ASCII data to HEX */

View File

@ -1,19 +1,23 @@
UINT16 pic16c5x_read_op(UINT16 address);
UINT8 pic16c5x_read_byte(UINT16 address);
void pic16c5x_write_byte(UINT16 address, UINT8 data);
UINT8 pic16c5x_read_port(UINT16 port);
void pic16c5x_write_port(UINT16 port, UINT8 data);
UINT16 pic16c5xFetch(UINT16 address);
UINT8 pic16c5xRead(UINT16 address);
void pic16c5xWrite(UINT16 address, UINT8 data);
UINT8 pic16c5xReadPort(UINT16 port);
void pic16c5xWritePort(UINT16 port, UINT8 data);
extern UINT8 (*pPic16c5xReadPort)(UINT16 port);
extern void (*pPic16c5xWritePort)(UINT16 port, UINT8 data);
void pic16c5xSetWritePortHandler(void (*write)(UINT16 port, UINT8 data));
void pic16c5xSetReadPortHandler(UINT8 (*read)(UINT16 port));
extern INT32 pic16c5xRun(INT32 cycles);
void pic16c5xReset();
void pic16c5xExit();
void pic16c5xInit(INT32 type, UINT8 *mem);
void pic16c5xReset();
void pic16c5xOpen(INT32);
INT32 pic16c5xRun(INT32 cycles);
void pic16c5xClose();
void pic16c5xExit();
extern INT32 pic16c5xScan(INT32 nAction, INT32* pnMin);
extern void pic16c5xRunEnd();
INT32 pic16c5xScan(INT32 nAction);
void pic16c5xRunEnd();
// load & convert pic rom
INT32 BurnLoadPicROM(UINT8 *src, INT32 offset, INT32 len);