This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mcr3 wip driver-add (work in progress)
- Loading branch information
Showing
9 changed files
with
2,822 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// Cheap Squeak Deluxe audio module | ||
// based on MAME sources by Aaron Giles | ||
|
||
#include "burnint.h" | ||
#include "m68000_intf.h" | ||
#include "6821pia.h" | ||
#include "dac.h" | ||
|
||
static UINT16 dacvalue; | ||
static UINT16 csd_status; | ||
static INT32 csd_in_reset; | ||
static INT32 csd_is_intialized = 0; | ||
|
||
static void csd_porta_w(UINT16, UINT8 data) | ||
{ | ||
dacvalue = (data << 2) | (dacvalue & 3); | ||
// if (dacvalue !=0) bprintf(0, _T("%X,"), dacvalue); | ||
if (dacvalue == 0x02 || dacvalue == 0x03) dacvalue = 0xFE; // silly hack gets rid of pops in spyhunter when the music starts/stops | ||
DACWrite16Signed(0, dacvalue << 6); | ||
} | ||
|
||
static void csd_portb_w(UINT16, UINT8 data) | ||
{ | ||
dacvalue = (dacvalue & ~0x3) | (data >> 6); | ||
// if (dacvalue !=0) bprintf(0, _T("%X,"), dacvalue); | ||
if (dacvalue == 0x02 || dacvalue == 0x03) dacvalue = 0xFE; // see "silly hack", above | ||
DACWrite16Signed(0, dacvalue << 6); | ||
|
||
//if (~pia_get_ddr_b(0) & 0x30) csd_status = (data >> 4) & 3; | ||
UINT8 z_mask = pia_get_ddr_b(0); | ||
if (~z_mask & 0x10) csd_status = (csd_status & ~1) | ((data >> 4) & 1); | ||
if (~z_mask & 0x20) csd_status = (csd_status & ~2) | ((data >> 4) & 2); | ||
|
||
} | ||
|
||
static void csd_irq(int state) | ||
{ | ||
SekSetIRQLine(4, state ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE); | ||
} | ||
|
||
void csd_reset_write(int state) | ||
{ | ||
if (csd_is_intialized == 0) return; | ||
|
||
csd_in_reset = state; | ||
|
||
if (state) { | ||
INT32 cpu_active = SekGetActive(); | ||
if (cpu_active == -1) SekOpen(0); | ||
SekReset(); | ||
if (cpu_active == -1) SekClose(); | ||
} | ||
} | ||
|
||
static void __fastcall csd_write_word(UINT32 address, UINT16 data) | ||
{ | ||
if ((address & 0x1fff8) == 0x18000) { | ||
pia_write(0, (address / 2) & 3, data & 0xff); | ||
return; | ||
} | ||
} | ||
|
||
static void __fastcall csd_write_byte(UINT32 address, UINT8 data) | ||
{ | ||
if ((address & 0x1fff8) == 0x18000) { | ||
pia_write(0, (address / 2) & 3, data); | ||
return; | ||
} | ||
} | ||
|
||
static UINT16 __fastcall csd_read_word(UINT32 address) | ||
{ | ||
if ((address & 0x1fff8) == 0x18000) { | ||
UINT8 ret = pia_read(0, (address / 2) & 3); | ||
return ret | (ret << 8); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static UINT8 __fastcall csd_read_byte(UINT32 address) | ||
{ | ||
if ((address & 0x1fff8) == 0x18000) { | ||
return pia_read(0, (address / 2) & 3); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void csd_data_write(UINT16 data) | ||
{ | ||
if (csd_is_intialized == 0) return; | ||
|
||
pia_set_input_b(0, data & 0x0f); | ||
pia_set_input_ca1(0, ~data & 0x10); | ||
} | ||
|
||
UINT8 csd_status_read() | ||
{ | ||
if (csd_is_intialized == 0) return 0; | ||
|
||
return csd_status; | ||
} | ||
|
||
INT32 csd_reset_status() | ||
{ | ||
if (csd_is_intialized == 0) return 1; | ||
|
||
return csd_in_reset; | ||
} | ||
|
||
INT32 csd_initialized() | ||
{ | ||
return csd_is_intialized; | ||
} | ||
|
||
void csd_reset() | ||
{ | ||
if (csd_is_intialized == 0) return; | ||
|
||
SekOpen(0); | ||
SekReset(); | ||
DACReset(); | ||
SekClose(); | ||
|
||
pia_reset(); | ||
|
||
csd_status = 0; | ||
csd_in_reset = 0; | ||
dacvalue = 0; | ||
} | ||
|
||
static const pia6821_interface pia_intf = { | ||
0, 0, 0, 0, 0, 0, | ||
csd_porta_w, csd_portb_w, 0, 0, | ||
csd_irq, csd_irq | ||
}; | ||
|
||
void csd_init(UINT8 *rom, UINT8 *ram) | ||
{ | ||
SekInit(0, 0x68000); | ||
SekOpen(0); | ||
SekMapMemory(rom, 0x000000, 0x007fff, MAP_ROM); | ||
SekMapMemory(ram, 0x01c000, 0x01cfff, MAP_RAM); | ||
SekSetWriteWordHandler(0, csd_write_word); | ||
SekSetWriteByteHandler(0, csd_write_byte); | ||
SekSetReadWordHandler(0, csd_read_word); | ||
SekSetReadByteHandler(0, csd_read_byte); | ||
SekClose(); | ||
|
||
pia_init(); | ||
pia_config(0, PIA_ALTERNATE_ORDERING, &pia_intf); | ||
|
||
DACInit(0, 0, 1, SekTotalCycles, 8000000); | ||
DACSetRoute(0, 1.00, BURN_SND_ROUTE_BOTH); | ||
DACDCBlock(1); | ||
|
||
csd_is_intialized = 1; | ||
} | ||
|
||
void csd_exit() | ||
{ | ||
if (csd_is_intialized == 0) return; | ||
|
||
SekExit(); | ||
pia_init(); | ||
DACExit(); | ||
csd_is_intialized = 0; | ||
} | ||
|
||
void csd_scan(INT32 nAction, INT32 *pnMin) | ||
{ | ||
if (csd_is_intialized == 0) return; | ||
|
||
if (nAction & ACB_VOLATILE) | ||
{ | ||
SekScan(nAction); | ||
DACScan(nAction, pnMin); | ||
pia_scan(nAction, pnMin); | ||
|
||
SCAN_VAR(csd_status); | ||
SCAN_VAR(csd_in_reset); | ||
SCAN_VAR(dacvalue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
void csd_data_write(UINT16 data); | ||
UINT8 csd_status_read(); | ||
void csd_reset_write(int state); | ||
|
||
void csd_reset(); | ||
void csd_init(UINT8 *rom, UINT8 *ram); | ||
void csd_exit(); | ||
void csd_scan(INT32 nAction, INT32 *pnMin); | ||
INT32 csd_reset_status(); | ||
INT32 csd_initialized(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// Midway Sounds Good audio module | ||
// based on MAME sources by Aaron Giles | ||
|
||
#include "burnint.h" | ||
#include "m68000_intf.h" | ||
#include "6821pia.h" | ||
#include "dac.h" | ||
|
||
static UINT16 dacvalue; | ||
static UINT16 soundsgood_status; | ||
static INT32 soundsgood_in_reset; | ||
static INT32 soundsgood_is_initialized; | ||
|
||
static void soundsgood_porta_w(UINT16, UINT8 data) | ||
{ | ||
dacvalue = (dacvalue & 3) | (data << 2); | ||
DACWrite16Signed(0, dacvalue << 6); | ||
} | ||
|
||
static void soundsgood_portb_w(UINT16, UINT8 data) | ||
{ | ||
dacvalue = (dacvalue & ~3) | (data >> 6); | ||
DACWrite16Signed(0, dacvalue << 6); | ||
|
||
if (pia_get_ddr_b(0) & 0x30) soundsgood_status = (data >> 4) & 3; | ||
} | ||
|
||
static void soundsgood_irq(int state) | ||
{ | ||
SekSetIRQLine(4, state ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE); | ||
} | ||
|
||
void soundsgood_data_write(UINT16 data) | ||
{ | ||
pia_set_input_b(0, (data >> 1) & 0xf); | ||
pia_set_input_ca1(0, ~data & 0x01); | ||
} | ||
|
||
UINT8 soundsgood_status_read() | ||
{ | ||
if (soundsgood_is_initialized == 0) return 0; | ||
return soundsgood_status; | ||
} | ||
|
||
void soundsgood_reset_write(int state) | ||
{ | ||
if (soundsgood_is_initialized == 0) return; | ||
|
||
soundsgood_in_reset = state; | ||
|
||
if (state) | ||
{ | ||
INT32 cpu_active = SekGetActive(); | ||
if (cpu_active == -1) SekOpen(0); | ||
SekReset(); | ||
if (cpu_active == -1) SekClose(); | ||
} | ||
} | ||
|
||
static void __fastcall soundsgood_write_word(UINT32 address, UINT16 data) | ||
{ | ||
if ((address & 0xffff8) == 0x060000) { | ||
// bprintf (0, _T("SGWW: %5.5x, %4.4x\n"), address, data); | ||
pia_write(0, (address / 2) & 3, data & 0xff); | ||
return; | ||
} | ||
} | ||
|
||
static void __fastcall soundsgood_write_byte(UINT32 address, UINT8 data) | ||
{ | ||
if ((address & 0xffff8) == 0x060000) { | ||
// bprintf (0, _T("SGWB: %5.5x, %2.2x\n"), address, data); | ||
pia_write(0, (address / 2) & 3, data); | ||
return; | ||
} | ||
} | ||
|
||
static UINT16 __fastcall soundsgood_read_word(UINT32 address) | ||
{ | ||
if ((address & 0xffff8) == 0x060000) { | ||
// bprintf (0, _T("SGRW: %5.5x\n"), address); | ||
UINT8 ret = pia_read(0, (address / 2) & 3); | ||
return ret | (ret << 8); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static UINT8 __fastcall soundsgood_read_byte(UINT32 address) | ||
{ | ||
if ((address & 0xffff8) == 0x060000) { | ||
// bprintf (0, _T("SGRB: %5.5x\n"), address); | ||
return pia_read(0, (address / 2) & 3); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void soundsgood_reset() | ||
{ | ||
if (soundsgood_is_initialized == 0) return; | ||
|
||
SekOpen(0); | ||
SekReset(); | ||
DACReset(); | ||
SekClose(); | ||
|
||
pia_reset(); | ||
|
||
soundsgood_status = 0; | ||
soundsgood_in_reset = 0; | ||
dacvalue = 0; | ||
} | ||
|
||
static const pia6821_interface pia_intf = { | ||
0, 0, 0, 0, 0, 0, | ||
soundsgood_porta_w, soundsgood_portb_w, 0, 0, | ||
soundsgood_irq, soundsgood_irq | ||
}; | ||
|
||
void soundsgood_init(UINT8 *rom, UINT8 *ram) | ||
{ | ||
SekInit(0, 0x68000); | ||
SekOpen(0); | ||
SekMapMemory(rom, 0x000000, 0x03ffff, MAP_ROM); | ||
SekMapMemory(ram, 0x070000, 0x070fff, MAP_RAM); | ||
SekSetWriteWordHandler(0, soundsgood_write_word); | ||
SekSetWriteByteHandler(0, soundsgood_write_byte); | ||
SekSetReadWordHandler(0, soundsgood_read_word); | ||
SekSetReadByteHandler(0, soundsgood_read_byte); | ||
SekClose(); | ||
|
||
pia_init(); | ||
pia_config(0, PIA_ALTERNATE_ORDERING, &pia_intf); | ||
|
||
DACInit(0, 0, 0, SekTotalCycles, 8000000); | ||
DACSetRoute(0, 1.00, BURN_SND_ROUTE_BOTH); | ||
DACDCBlock(1); | ||
|
||
soundsgood_is_initialized = 1; | ||
} | ||
|
||
void soundsgood_exit() | ||
{ | ||
if (soundsgood_is_initialized == 0) return; | ||
|
||
SekExit(); | ||
pia_init(); | ||
DACExit(); | ||
|
||
soundsgood_is_initialized = 0; | ||
} | ||
|
||
void soundsgood_scan(INT32 nAction, INT32 *pnMin) | ||
{ | ||
if (soundsgood_is_initialized == 0) return; | ||
|
||
if (nAction & ACB_VOLATILE) | ||
{ | ||
SekScan(nAction); | ||
DACScan(nAction, pnMin); | ||
pia_scan(nAction, pnMin); | ||
|
||
SCAN_VAR(soundsgood_status); | ||
SCAN_VAR(soundsgood_in_reset); | ||
SCAN_VAR(dacvalue); | ||
} | ||
} | ||
|
||
INT32 soundsgood_reset_status() | ||
{ | ||
if (soundsgood_is_initialized == 0) return 1; | ||
return soundsgood_in_reset; | ||
} | ||
|
||
INT32 soundsgood_initialized() | ||
{ | ||
return soundsgood_is_initialized; | ||
} |
Oops, something went wrong.
8a50847
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new driver is crashing dat file generation on the libretro port, i'm not sure what it is about because i couldn't get a trace.
8a50847
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but incase you don't want to wait for me to fix it for your side, here's what usually breaks dat generation:
typos:
1: romset and clone romset name are the same, so it gets stuck in an endless loop while generating
f.ex:
"superpie", "superpie", NULL, NULL, "1984",
2: something in the sample "set" field, but no samples hooked up (like today):
"crater", NULL, NULL, "midssio", "1984",
should have been:
"crater", NULL, "midssio", NULL, "1984",
best regards,