summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Scott Stone <tafoid@users.noreply.github.com>2012-09-16 21:57:13 +0000
committer Scott Stone <tafoid@users.noreply.github.com>2012-09-16 21:57:13 +0000
commit07f0cecc5af70800d78c2f11eb70963ef637e8bf (patch)
tree1e2173eaa061823a18c50610c0cfce07645fec73 /src
parent02410126c21faefa9ec3089b2a01e14cc2691de6 (diff)
In preparation for future work (basic device structure). Should have no functional change at this point. From Haze (nw)
Diffstat (limited to 'src')
-rw-r--r--src/mame/includes/megadriv.h1
-rw-r--r--src/mame/machine/megacd.c133
-rw-r--r--src/mame/machine/megacd.h51
-rw-r--r--src/mame/machine/megadriv.c52
-rw-r--r--src/mame/mame.mak3
5 files changed, 166 insertions, 74 deletions
diff --git a/src/mame/includes/megadriv.h b/src/mame/includes/megadriv.h
index 6633184952e..77445f101f7 100644
--- a/src/mame/includes/megadriv.h
+++ b/src/mame/includes/megadriv.h
@@ -16,6 +16,7 @@
#include "machine/megavdp.h"
#include "machine/mega32x.h"
+#include "machine/megacd.h"
#include "video/315_5124.h"
#define MASTER_CLOCK_NTSC 53693175
diff --git a/src/mame/machine/megacd.c b/src/mame/machine/megacd.c
index 703395e7e77..182c4b55a3c 100644
--- a/src/mame/machine/megacd.c
+++ b/src/mame/machine/megacd.c
@@ -1,11 +1,79 @@
#include "includes/megadriv.h"
+#include "megacd.lh"
+#include "sound/cdda.h"
+#include "sound/rf5c68.h"
// the main MD emulation needs to know the state of these because it appears in the MD regs / affect DMA operations
int sega_cd_connected = 0x00;
int segacd_wordram_mapped = 0;
+
+
+
+const device_type SEGA_SEGACD_US = &device_creator<sega_segacd_us_device>;
+const device_type SEGA_SEGACD_JAPAN = &device_creator<sega_segacd_japan_device>;
+const device_type SEGA_SEGACD_EUROPE = &device_creator<sega_segacd_europe_device>;
+
+sega_segacd_device::sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type)
+ : device_t(mconfig, type, "sega_segacd_device", tag, owner, clock)
+{
+
+}
+
+sega_segacd_us_device::sega_segacd_us_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_US)
+{
+
+}
+
+sega_segacd_japan_device::sega_segacd_japan_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_JAPAN)
+{
+
+}
+
+sega_segacd_europe_device::sega_segacd_europe_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_EUROPE)
+{
+
+}
+
+
+static MACHINE_CONFIG_FRAGMENT( segacd_fragment )
+
+ MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
+ MCFG_CPU_PROGRAM_MAP(segacd_map)
+
+ MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
+
+ MCFG_DEFAULT_LAYOUT( layout_megacd )
+
+ MCFG_SOUND_ADD( "cdda", CDDA, 0 )
+ MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) // TODO: accurate volume balance
+ MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 )
+
+ MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164!
+ MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 )
+ MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 )
+
+ MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
+
+ MCFG_NVRAM_HANDLER_CLEAR()
+ MCFG_NVRAM_ADD_0FILL("backupram")
+
+ MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu
+MACHINE_CONFIG_END
+
+
+
+machine_config_constructor sega_segacd_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME( segacd_fragment );
+}
+
+
/* Sega CD stuff */
cpu_device *_segacd_68k_cpu;
@@ -153,31 +221,31 @@ segacd_t segacd;
#define CHECK_SCD_LV5_INTERRUPT \
if (segacd_irq_mask & 0x20) \
{ \
- machine.device("segacd_68k")->execute().set_input_line(5, HOLD_LINE); \
+ machine.device(":segacd:segacd_68k")->execute().set_input_line(5, HOLD_LINE); \
} \
#define CHECK_SCD_LV4_INTERRUPT \
if (segacd_irq_mask & 0x10) \
{ \
- machine.device("segacd_68k")->execute().set_input_line(4, HOLD_LINE); \
+ machine.device(":segacd:segacd_68k")->execute().set_input_line(4, HOLD_LINE); \
} \
#define CHECK_SCD_LV3_INTERRUPT \
if (segacd_irq_mask & 0x08) \
{ \
- machine.device("segacd_68k")->execute().set_input_line(3, HOLD_LINE); \
+ machine.device(":segacd:segacd_68k")->execute().set_input_line(3, HOLD_LINE); \
} \
#define CHECK_SCD_LV2_INTERRUPT \
if (segacd_irq_mask & 0x04) \
{ \
- machine.device("segacd_68k")->execute().set_input_line(2, HOLD_LINE); \
+ machine.device(":segacd:segacd_68k")->execute().set_input_line(2, HOLD_LINE); \
} \
#define CHECK_SCD_LV1_INTERRUPT \
if (segacd_irq_mask & 0x02) \
{ \
- machine.device("segacd_68k")->execute().set_input_line(1, HOLD_LINE); \
+ machine.device(":segacd:segacd_68k")->execute().set_input_line(1, HOLD_LINE); \
} \
#define CURRENT_TRACK_IS_DATA \
@@ -542,7 +610,7 @@ void CDD_Stop(running_machine &machine)
SCD_STATUS = CDD_STOPPED;
CDD_STATUS = 0x0000;
SET_CDD_DATA_MODE
- cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
+ cdda_stop_audio( machine.device( ":segacd:cdda" ) ); //stop any pending CD-DA
}
@@ -672,7 +740,7 @@ void CDD_Play(running_machine &machine)
printf("%d Track played\n",SCD_CURTRK);
CDD_MIN = to_bcd(SCD_CURTRK, false);
if(!(CURRENT_TRACK_IS_DATA))
- cdda_start_audio( machine.device( "cdda" ), SCD_CURLBA, end_msf - SCD_CURLBA );
+ cdda_start_audio( machine.device( ":segacd:cdda" ), SCD_CURLBA, end_msf - SCD_CURLBA );
SET_CDC_READ
}
@@ -699,9 +767,9 @@ void CDD_Pause(running_machine &machine)
CDD_STATUS = SCD_STATUS;
SET_CDD_DATA_MODE
- //segacd.current_frame = cdda_get_audio_lba( machine.device( "cdda" ) );
+ //segacd.current_frame = cdda_get_audio_lba( machine.device( ":segacd:cdda" ) );
//if(!(CURRENT_TRACK_IS_DATA))
- cdda_pause_audio( machine.device( "cdda" ), 1 );
+ cdda_pause_audio( machine.device( ":segacd:cdda" ), 1 );
}
void CDD_Resume(running_machine &machine)
@@ -715,7 +783,7 @@ void CDD_Resume(running_machine &machine)
CDD_MIN = to_bcd (SCD_CURTRK, false);
SET_CDC_READ
//if(!(CURRENT_TRACK_IS_DATA))
- cdda_pause_audio( machine.device( "cdda" ), 0 );
+ cdda_pause_audio( machine.device( ":segacd:cdda" ), 0 );
}
@@ -816,7 +884,7 @@ void CDC_End_Transfer(running_machine& machine)
void CDC_Do_DMA(running_machine& machine, int rate)
{
- address_space* space = machine.device("segacd_68k")->memory().space(AS_PROGRAM);
+ address_space* space = machine.device(":segacd:segacd_68k")->memory().space(AS_PROGRAM);
UINT32 dstoffset, length;
UINT8 *dest;
@@ -1174,24 +1242,24 @@ static WRITE16_HANDLER( scd_a12000_halt_reset_w )
// reset line
if (a12000_halt_reset_reg&0x0001)
{
- space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
+ space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
if (!(old_halt&0x0001)) printf("clear reset slave\n");
}
else
{
- space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
+ space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
if ((old_halt&0x0001)) printf("assert reset slave\n");
}
// request BUS
if (a12000_halt_reset_reg&0x0002)
{
- space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
+ space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
if (!(old_halt&0x0002)) printf("halt slave\n");
}
else
{
- space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
+ space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
if ((old_halt&0x0002)) printf("resume slave\n");
}
}
@@ -1480,7 +1548,7 @@ static IRQ_CALLBACK(segacd_sub_int_callback)
{
// clear this bit
a12000_halt_reset_reg &= ~0x0100;
- device->machine().device("segacd_68k")->execute().set_input_line(2, CLEAR_LINE);
+ device->machine().device(":segacd:segacd_68k")->execute().set_input_line(2, CLEAR_LINE);
}
return (0x60+irqline*4)/4; // vector address
@@ -2236,11 +2304,11 @@ void segacd_init_main_cpu( running_machine& machine )
{
address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
- segacd_font_bits = reinterpret_cast<UINT16 *>(machine.root_device().memshare("segacd_font")->ptr());
- segacd_backupram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("backupram")->ptr());
- segacd_dataram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("dataram")->ptr());
- segacd_dataram2 = reinterpret_cast<UINT16 *>(machine.root_device().memshare("dataram2")->ptr());
- segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("segacd_program")->ptr());
+ segacd_font_bits = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_font")->ptr());
+ segacd_backupram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:backupram")->ptr());
+ segacd_dataram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram")->ptr());
+ segacd_dataram2 = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram2")->ptr());
+ segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_program")->ptr());
segacd_4meg_prgbank = 0;
@@ -2272,7 +2340,7 @@ void segacd_init_main_cpu( running_machine& machine )
- machine.device("segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback);
+ machine.device(":segacd:segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback);
space->install_legacy_read_handler (0x0000070, 0x0000073, FUNC(scd_hint_vector_r) );
@@ -2354,8 +2422,8 @@ MACHINE_RESET( segacd )
if ( segacd.cd )
{
segacd.toc = cdrom_get_toc( segacd.cd );
- cdda_set_cdrom( machine.device("cdda"), segacd.cd );
- cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
+ cdda_set_cdrom( machine.device(":segacd:cdda"), segacd.cd );
+ cdda_stop_audio( machine.device( ":segacd:cdda" ) ); //stop any pending CD-DA
}
}
}
@@ -2369,7 +2437,7 @@ MACHINE_RESET( segacd )
hock_cmd = 0;
- stopwatch_timer = machine.device<timer_device>("sw_timer");
+ stopwatch_timer = machine.device<timer_device>(":segacd:sw_timer");
scd_dma_timer->adjust(attotime::zero);
@@ -2962,7 +3030,7 @@ WRITE16_HANDLER( segacd_cdfader_w )
//printf("%f\n",cdfader_vol);
- cdda_set_volume(space->machine().device("cdda"), cdfader_vol);
+ cdda_set_volume(space->machine().device(":segacd:cdda"), cdfader_vol);
}
READ16_HANDLER( segacd_backupram_r )
@@ -3062,3 +3130,16 @@ ADDRESS_MAP_START( segacd_map, AS_PROGRAM, 16, driver_device )
ADDRESS_MAP_END
+
+
+void sega_segacd_device::device_start()
+{
+
+}
+
+void sega_segacd_device::device_reset()
+{
+
+}
+
+
diff --git a/src/mame/machine/megacd.h b/src/mame/machine/megacd.h
new file mode 100644
index 00000000000..ec72a98a16d
--- /dev/null
+++ b/src/mame/machine/megacd.h
@@ -0,0 +1,51 @@
+/* Sega CD / Mega CD */
+
+
+
+class sega_segacd_device : public device_t
+{
+public:
+ sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type);
+
+ emu_timer *m_segacd_pwm_timer;
+protected:
+ virtual void device_start();
+ virtual void device_reset();
+
+ // optional information overrides
+// virtual const rom_entry *device_rom_region() const;
+ virtual machine_config_constructor device_mconfig_additions() const;
+private:
+// virtual void device_config_complete();
+
+};
+
+
+class sega_segacd_us_device : public sega_segacd_device
+{
+ public:
+ sega_segacd_us_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ protected:
+
+};
+
+class sega_segacd_japan_device : public sega_segacd_device
+{
+ public:
+ sega_segacd_japan_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ protected:
+// virtual machine_config_constructor device_mconfig_additions() const;
+};
+
+class sega_segacd_europe_device : public sega_segacd_device
+{
+ public:
+ sega_segacd_europe_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ protected:
+// virtual machine_config_constructor device_mconfig_additions() const;
+};
+
+
+extern const device_type SEGA_SEGACD_US;
+extern const device_type SEGA_SEGACD_JAPAN;
+extern const device_type SEGA_SEGACD_EUROPE;
diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c
index 6f54cd7be10..140ecb49666 100644
--- a/src/mame/machine/megadriv.c
+++ b/src/mame/machine/megadriv.c
@@ -37,15 +37,14 @@ Known Non-Issues (confirmed on Real Genesis)
#include "cpu/sh2/sh2comn.h"
#include "cpu/z80/z80.h"
#include "sound/2612intf.h"
-#include "sound/cdda.h"
+
#include "sound/dac.h"
-#include "sound/rf5c68.h"
+
#include "sound/sn76496.h"
#include "imagedev/chd_cd.h"
#include "includes/megadriv.h"
#include "machine/nvram.h"
#include "cpu/ssp1601/ssp1601.h"
-#include "megacd.lh"
#include "machine/megavdp.h"
@@ -1302,27 +1301,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED( genesis_scd, megadriv )
- MCFG_NVRAM_HANDLER_CLEAR()
- MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
- MCFG_CPU_PROGRAM_MAP(segacd_map)
-
- MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
-
- MCFG_DEFAULT_LAYOUT( layout_megacd )
-
- MCFG_NVRAM_ADD_0FILL("backupram")
-
- MCFG_SOUND_ADD( "cdda", CDDA, 0 )
- MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 ) // TODO: accurate volume balance
- MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
-
- MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164!
- MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 )
- MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
-
- MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
-
- MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu
+ MCFG_DEVICE_ADD("segacd", SEGA_SEGACD_US, 0)
MACHINE_CONFIG_END
struct cdrom_interface scd_cdrom =
@@ -1349,26 +1328,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED( genesis_32x_scd, genesis_32x )
- MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
- MCFG_CPU_PROGRAM_MAP(segacd_map)
-
- MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
- MCFG_NVRAM_ADD_0FILL("backupram")
- MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
-
- MCFG_DEFAULT_LAYOUT( layout_megacd )
-
- MCFG_SOUND_ADD( "cdda", CDDA, 0 )
- MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 )
- MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
-
- MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164
- MCFG_SOUND_ROUTE( 0, "lspeaker", 0.25 )
- MCFG_SOUND_ROUTE( 1, "rspeaker", 0.25 )
-
- MCFG_CDROM_ADD( "cdrom", scd_cdrom)
- MCFG_SOFTWARE_LIST_ADD("cd_list","segacd")
-
+ MCFG_DEVICE_ADD("segacd", SEGA_SEGACD_US, 0)
//MCFG_QUANTUM_PERFECT_CPU("32x_master_sh2")
MACHINE_CONFIG_END
@@ -1410,13 +1370,13 @@ static void megadriv_init_common(running_machine &machine)
sega_cd_connected = 0;
segacd_wordram_mapped = 0;
- _segacd_68k_cpu = machine.device<cpu_device>("segacd_68k");
+ _segacd_68k_cpu = machine.device<cpu_device>(":segacd:segacd_68k");
if (_segacd_68k_cpu != NULL)
{
printf("Sega CD secondary 68k cpu found '%s'\n", _segacd_68k_cpu->tag() );
sega_cd_connected = 1;
segacd_init_main_cpu(machine);
- scd_dma_timer = machine.device<timer_device>("scd_dma_timer");
+ scd_dma_timer = machine.device<timer_device>(":segacd:scd_dma_timer");
}
diff --git a/src/mame/mame.mak b/src/mame/mame.mak
index 7158f200f88..02b17b16840 100644
--- a/src/mame/mame.mak
+++ b/src/mame/mame.mak
@@ -2268,8 +2268,7 @@ $(DRIVERS)/zac_proto.o: $(LAYOUT)/zac_proto.lh
$(DRIVERS)/peyper.o: $(LAYOUT)/peyper.lh
-$(MACHINE)/megadriv.o: $(LAYOUT)/megacd.lh
-
+$(MACHINE)/megacd.o: $(LAYOUT)/megacd.lh
#-------------------------------------------------
# misc dependencies