summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/drivers/beta.c
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2014-09-27 08:45:17 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2014-09-27 08:45:17 +0000
commitf8ef333fb4d171a354981bf01de209ec1bf3a557 (patch)
tree7d4960c6000ee265cab6c639151c531629b5a124 /src/mess/drivers/beta.c
parent540b2f00c208de62b5d7097237640b172bf44f4a (diff)
(MESS) misc generic cartslot conversions. while at it, I have added
experimental eprom writing to the beta.c driver (pending more accurate tests). nw.
Diffstat (limited to 'src/mess/drivers/beta.c')
-rw-r--r--src/mess/drivers/beta.c118
1 files changed, 103 insertions, 15 deletions
diff --git a/src/mess/drivers/beta.c b/src/mess/drivers/beta.c
index baa93d4c466..daec10b2c1c 100644
--- a/src/mess/drivers/beta.c
+++ b/src/mess/drivers/beta.c
@@ -25,13 +25,78 @@
TODO:
- - write EPROM back to file
+ - verify whether feeding a 0xff-filled 2K binary file as cart allows
+ to write back correctly EPROM or not
*/
-#include "includes/beta.h"
+#include "emu.h"
+#include "cpu/m6502/m6502.h"
+#include "machine/6532riot.h"
+#include "machine/ram.h"
+#include "sound/speaker.h"
+
+#include "bus/generic/slot.h"
+#include "bus/generic/carts.h"
+
#include "beta.lh"
+#define SCREEN_TAG "screen"
+#define M6502_TAG "m6502"
+#define M6532_TAG "m6532"
+#define EPROM_TAG "eprom"
+//#define SPEAKER_TAG "b237"
+
+class beta_state : public driver_device
+{
+public:
+ beta_state(const machine_config &mconfig, device_type type, const char *tag)
+ : driver_device(mconfig, type, tag),
+ m_maincpu(*this, M6502_TAG),
+ m_speaker(*this, "speaker"),
+ m_eprom(*this, EPROM_TAG),
+ m_q6(*this, "Q6"),
+ m_q7(*this, "Q7"),
+ m_q8(*this, "Q8"),
+ m_q9(*this, "Q9")
+ { }
+
+ required_device<cpu_device> m_maincpu;
+ required_device<speaker_sound_device> m_speaker;
+ required_device<generic_slot_device> m_eprom;
+ required_ioport m_q6;
+ required_ioport m_q7;
+ required_ioport m_q8;
+ required_ioport m_q9;
+
+ virtual void machine_start();
+
+ DECLARE_READ8_MEMBER( riot_pa_r );
+ DECLARE_WRITE8_MEMBER( riot_pa_w );
+ DECLARE_READ8_MEMBER( riot_pb_r );
+ DECLARE_WRITE8_MEMBER( riot_pb_w );
+ DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
+
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER( beta_eprom );
+ DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( beta_eprom );
+
+ /* EPROM state */
+ int m_eprom_oe;
+ int m_eprom_ce;
+ UINT16 m_eprom_addr;
+ UINT8 m_eprom_data;
+ UINT8 m_old_data;
+ dynamic_buffer m_eprom_rom;
+
+ /* display state */
+ UINT8 m_ls145_p;
+ UINT8 m_segment;
+
+ emu_timer *m_led_refresh_timer;
+ TIMER_CALLBACK_MEMBER(led_refresh);
+};
+
+
/* Memory Maps */
static ADDRESS_MAP_START( beta_mem, AS_PROGRAM, 8, beta_state )
@@ -122,7 +187,7 @@ READ8_MEMBER( beta_state::riot_pa_r )
default:
if (!m_eprom_oe && !m_eprom_ce)
{
- data = m_eprom->base()[m_eprom_addr & 0x7ff];
+ data = m_eprom_rom[m_eprom_addr & 0x7ff];
popmessage("EPROM read %04x = %02x\n", m_eprom_addr & 0x7ff, data);
}
}
@@ -209,19 +274,34 @@ WRITE8_MEMBER( beta_state::riot_pb_w )
if (BIT(data, 6) && (!BIT(m_old_data, 7) && BIT(data, 7)))
{
popmessage("EPROM write %04x = %02x\n", m_eprom_addr & 0x7ff, m_eprom_data);
- m_eprom->base()[m_eprom_addr & 0x7ff] &= m_eprom_data;
+ m_eprom_rom[m_eprom_addr & 0x7ff] &= m_eprom_data;
}
m_old_data = data;
}
-/* Quickload */
+/* EPROM socket */
-DEVICE_IMAGE_UNLOAD_MEMBER( beta_state, beta_eprom )
+DEVICE_IMAGE_LOAD_MEMBER( beta_state, beta_eprom )
{
- UINT8 *ptr = m_eprom->base();
+ UINT32 size = m_eprom->common_get_size("rom");
+
+ if (size != 0x800)
+ {
+ image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
+ return IMAGE_INIT_FAIL;
+ }
+
+ m_eprom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
+ m_eprom->common_load_rom(m_eprom->get_rom_base(), size, "rom");
+
+ return IMAGE_INIT_PASS;
+}
- image.fwrite(ptr, 0x800);
+DEVICE_IMAGE_UNLOAD_MEMBER( beta_state, beta_eprom )
+{
+ if (image.software_entry() == NULL)
+ image.fwrite(m_eprom_rom, 0x800);
}
/* Machine Initialization */
@@ -230,12 +310,23 @@ void beta_state::machine_start()
{
m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(beta_state::led_refresh),this));
+ m_eprom_rom.resize(0x800);
+
+ if (!m_eprom->exists())
+ memset(m_eprom_rom, 0xff, 0x800);
+ else
+ {
+ astring region_tag;
+ memcpy(m_eprom_rom, memregion(region_tag.cpy(m_eprom->tag()).cat(GENERIC_ROM_REGION_TAG))->base(), 0x800);
+ }
+
// state saving
save_item(NAME(m_eprom_oe));
save_item(NAME(m_eprom_ce));
save_item(NAME(m_eprom_addr));
save_item(NAME(m_eprom_data));
save_item(NAME(m_old_data));
+ save_item(NAME(m_eprom_rom));
save_item(NAME(m_ls145_p));
save_item(NAME(m_segment));
}
@@ -264,10 +355,10 @@ static MACHINE_CONFIG_START( beta, beta_state )
MCFG_RIOT6532_IRQ_CB(INPUTLINE(M6502_TAG, M6502_IRQ_LINE))
/* EPROM socket */
- MCFG_CARTSLOT_ADD(EPROM_TAG)
- MCFG_CARTSLOT_EXTENSION_LIST("bin,rom")
- MCFG_CARTSLOT_NOT_MANDATORY
- MCFG_CARTSLOT_UNLOAD(beta_state,beta_eprom)
+ MCFG_GENERIC_CARTSLOT_ADD(EPROM_TAG, generic_plain_slot, NULL)
+ MCFG_GENERIC_EXTENSIONS("bin,rom")
+ MCFG_GENERIC_LOAD(beta_state, beta_eprom)
+ MCFG_GENERIC_UNLOAD(beta_state, beta_eprom)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
@@ -279,9 +370,6 @@ MACHINE_CONFIG_END
ROM_START( beta )
ROM_REGION( 0x10000, M6502_TAG, 0 )
ROM_LOAD( "beta.rom", 0x8000, 0x0800, CRC(d42fdb17) SHA1(595225a0cd43dd76c46b2aff6c0f27d5991cc4f0))
-
- ROM_REGION( 0x800, EPROM_TAG, ROMREGION_ERASEFF )
- ROM_CART_LOAD( EPROM_TAG, 0x0000, 0x0800, ROM_FULLSIZE )
ROM_END
/* System Drivers */