Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
mcr3 wip driver-add (work in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Apr 10, 2019
1 parent a519033 commit 8a50847
Show file tree
Hide file tree
Showing 9 changed files with 2,822 additions and 13 deletions.
6 changes: 3 additions & 3 deletions makefile.burn_rules
Expand Up @@ -58,7 +58,7 @@ drvsrc = d_arcadecl.cpp d_atarig1.cpp d_badlands.cpp d_batman.cpp d_blstroid.cp
d_dynduke.o d_efdt.o d_epos.o d_espial.o d_ettrivia.o d_exedexes.o d_fantland.o d_fastfred.o d_firetrap.o d_flipjack.o d_flower.o d_foodf.o \
d_freekick.o d_funkybee.o d_galaga.o d_galivan.o d_gaplus.o d_ginganin.o d_gng.o d_goindol.o d_gunsmoke.o d_headonb.o d_higemaru.o \
d_himesiki.o d_holeland.o d_hvyunit.o d_invaders.o d_iqblock.o d_jack.o d_jedi.o d_jrpacman.o d_kangaroo.o d_kncljoe.o d_kyugo.o d_ladybug.o d_lasso.o \
d_lastduel.o d_lwings.o d_mainsnk.o d_mappy.o d_marineb.o d_mario.o d_madmotor.o d_markham.o d_mastboyo.o d_matmania.o d_mcr.o d_megasys1.o d_meijinsn.o \
d_lastduel.o d_lwings.o d_mainsnk.o d_mappy.o d_marineb.o d_mario.o d_madmotor.o d_markham.o d_mastboyo.o d_matmania.o d_mcr.o d_mcr3.o d_megasys1.o d_meijinsn.o \
d_metlfrzr.o d_mhavoc.o d_millipede.o d_mirax.o d_mitchell.o d_mole.o d_momoko.o d_mmagic.o d_mouser.o d_mrdo.o d_mrflea.o d_mrjong.o d_munchmo.o \
d_mustache.o d_mystston.o d_namcos1.o d_namcos86.o d_ninjakd2.o d_nitedrvr.o d_naughtyb.o d_olibochu.o d_omegrace.o d_pacland.o d_pacman.o \
d_pbaction.o d_pac2650.o d_pengadvb.o d_phoenix.o d_pitnrun.o d_pkunwar.o d_popeye.o d_popper.o d_prehisle.o d_psychic5.o d_pturn.o d_punchout.o \
Expand Down Expand Up @@ -100,8 +100,8 @@ depobj = burn.o burn_bitmap.o burn_gun.o burn_led.o burn_shift.o burn_memory.o
load.o tilemap_generic.o tiles_generic.o timer.o vector.o \
\
6821pia.o 8255ppi.o 8257dma.o c169.o atariic.o atarijsa.o atarimo.o atarirle.o atarivad.o avgdvg.o bsmt2000.o decobsmt.o earom.o eeprom.o \
gaelco_crypt.o joyprocess.o nb1414m4.o nb1414m4_8bit.o nmk004.o nmk112.o kaneko_tmap.o mathbox.o mb87078.o mermaid.o midsat.o midssio.o namco_c45.o namcoio.o \
pandora.o resnet.o seibusnd.o sknsspr.o slapstic.o st0020.o t5182.o timekpr.o tms34061.o v3021.o vdc.o tms9928a.o watchdog.o x2212.o \
gaelco_crypt.o joyprocess.o nb1414m4.o nb1414m4_8bit.o nmk004.o nmk112.o kaneko_tmap.o mathbox.o mb87078.o mermaid.o midcsd.o midsat.o midsg.o midssio.o midtcs.o \
namco_c45.o namcoio.o pandora.o resnet.o seibusnd.o sknsspr.o slapstic.o st0020.o t5182.o timekpr.o tms34061.o v3021.o vdc.o tms9928a.o watchdog.o x2212.o \
\
asteroids.o 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_ymf262.o burn_ymf278b.o bzone.o c6280.o dac.o es5506.o es8712.o flower.o flt_rc.o fm.o fmopl.o ym2612.o gaelco.o hc55516.o \
Expand Down
185 changes: 185 additions & 0 deletions src/burn/devices/midcsd.cpp
@@ -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);
}
}
10 changes: 10 additions & 0 deletions src/burn/devices/midcsd.h
@@ -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();
179 changes: 179 additions & 0 deletions src/burn/devices/midsg.cpp
@@ -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;
}

2 comments on commit 8a50847

@barbudreadmon
Copy link
Contributor

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.

@dinkc64
Copy link
Collaborator Author

@dinkc64 dinkc64 commented on 8a50847 Apr 10, 2019

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,

  • dink

Please sign in to comment.