summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2017-07-27 15:21:16 -0400
committer AJR <ajrhacker@users.noreply.github.com>2017-07-27 15:21:58 -0400
commit237cde99da2328dcecae882e5c74ff9425fe7d8a (patch)
treea040b4548cabfdd73676766918d35f18c70aa6a4
parent3b07e5adbad6c54abaebb648d7f86be4fddd192b (diff)
spcforce: Add coin counters, start lamps and addressable latch device
-rw-r--r--src/mame/drivers/spcforce.cpp42
-rw-r--r--src/mame/includes/spcforce.h6
-rw-r--r--src/mame/video/spcforce.cpp4
3 files changed, 33 insertions, 19 deletions
diff --git a/src/mame/drivers/spcforce.cpp b/src/mame/drivers/spcforce.cpp
index ea8343c899d..496b1347dd0 100644
--- a/src/mame/drivers/spcforce.cpp
+++ b/src/mame/drivers/spcforce.cpp
@@ -40,6 +40,7 @@ TODO:
#include "cpu/i8085/i8085.h"
#include "cpu/mcs48/mcs48.h"
+#include "machine/74259.h"
#include "machine/gen_latch.h"
#include "screen.h"
#include "speaker.h"
@@ -105,9 +106,22 @@ WRITE8_MEMBER(spcforce_state::soundtrigger_w)
m_audiocpu->set_input_line(0, (~data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
}
-WRITE8_MEMBER(spcforce_state::irq_mask_w)
+WRITE8_MEMBER(spcforce_state::misc_outputs_w)
{
- m_irq_mask = data & 1;
+ machine().output().set_lamp_value(0, BIT(data, 0)); // 1P start lamp
+ machine().bookkeeping().coin_counter_w(0, BIT(data, 1));
+ machine().output().set_lamp_value(1, BIT(data, 2)); // 2P start lamp
+ machine().bookkeeping().coin_counter_w(1, BIT(data, 3));
+}
+
+WRITE_LINE_MEMBER(spcforce_state::irq_mask_w)
+{
+ m_irq_mask = state;
+}
+
+WRITE_LINE_MEMBER(spcforce_state::unknown_w)
+{
+ // written very frequently
}
static ADDRESS_MAP_START( spcforce_map, AS_PROGRAM, 8, spcforce_state )
@@ -115,22 +129,13 @@ static ADDRESS_MAP_START( spcforce_map, AS_PROGRAM, 8, spcforce_state )
AM_RANGE(0x4000, 0x43ff) AM_RAM
AM_RANGE(0x7000, 0x7000) AM_READ_PORT("DSW") AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0x7001, 0x7001) AM_READ_PORT("P1") AM_WRITE(soundtrigger_w)
- AM_RANGE(0x7002, 0x7002) AM_READ_PORT("P2")
- AM_RANGE(0x700b, 0x700b) AM_WRITE(flip_screen_w)
- AM_RANGE(0x700e, 0x700e) AM_WRITE(irq_mask_w)
- AM_RANGE(0x700f, 0x700f) AM_WRITENOP
+ AM_RANGE(0x7002, 0x7002) AM_READ_PORT("P2") AM_WRITE(misc_outputs_w)
+ AM_RANGE(0x7008, 0x700f) AM_DEVWRITE("mainlatch", ls259_device, write_d0)
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_SHARE("videoram")
AM_RANGE(0x9000, 0x93ff) AM_RAM AM_SHARE("colorram")
AM_RANGE(0xa000, 0xa3ff) AM_RAM AM_SHARE("scrollram")
ADDRESS_MAP_END
-static ADDRESS_MAP_START( meteors_map, AS_PROGRAM, 8, spcforce_state )
- AM_RANGE(0x700b, 0x700b) AM_WRITENOP
- AM_RANGE(0x700d, 0x700d) AM_WRITE(irq_mask_w) // ??
- AM_RANGE(0x700e, 0x700e) AM_WRITE(flip_screen_w) // irq mask isn't here, gets written too early causing the game to not boot, see startup code between sets
- AM_IMPORT_FROM(spcforce_map)
-ADDRESS_MAP_END
-
static ADDRESS_MAP_START( spcforce_sound_map, AS_PROGRAM, 8, spcforce_state )
AM_RANGE(0x0000, 0x07ff) AM_ROM
ADDRESS_MAP_END
@@ -290,6 +295,11 @@ static MACHINE_CONFIG_START( spcforce )
MCFG_MCS48_PORT_P2_OUT_CB(WRITE8(spcforce_state, SN76496_select_w))
MCFG_MCS48_PORT_T0_IN_CB(READLINE(spcforce_state, t0_r))
+ MCFG_DEVICE_ADD("mainlatch", LS259, 0)
+ MCFG_ADDRESSABLE_LATCH_Q3_OUT_CB(WRITELINE(spcforce_state, flip_screen_w))
+ MCFG_ADDRESSABLE_LATCH_Q6_OUT_CB(WRITELINE(spcforce_state, irq_mask_w))
+ MCFG_ADDRESSABLE_LATCH_Q7_OUT_CB(WRITELINE(spcforce_state, unknown_w))
+
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)
@@ -322,8 +332,10 @@ static MACHINE_CONFIG_START( spcforce )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( meteors, spcforce )
- MCFG_CPU_MODIFY("maincpu")
- MCFG_CPU_PROGRAM_MAP(meteors_map)
+ MCFG_DEVICE_MODIFY("mainlatch")
+ MCFG_ADDRESSABLE_LATCH_Q3_OUT_CB(NOOP)
+ MCFG_ADDRESSABLE_LATCH_Q5_OUT_CB(WRITELINE(spcforce_state, irq_mask_w)) // ??
+ MCFG_ADDRESSABLE_LATCH_Q6_OUT_CB(WRITELINE(spcforce_state, flip_screen_w)) // irq mask isn't here, gets written too early causing the game to not boot, see startup code
MACHINE_CONFIG_END
diff --git a/src/mame/includes/spcforce.h b/src/mame/includes/spcforce.h
index 550322457fa..2b54ec84542 100644
--- a/src/mame/includes/spcforce.h
+++ b/src/mame/includes/spcforce.h
@@ -45,8 +45,10 @@ public:
DECLARE_WRITE_LINE_MEMBER(write_sn3_ready);
DECLARE_READ_LINE_MEMBER(t0_r);
DECLARE_WRITE8_MEMBER(soundtrigger_w);
- DECLARE_WRITE8_MEMBER(irq_mask_w);
- DECLARE_WRITE8_MEMBER(flip_screen_w);
+ DECLARE_WRITE8_MEMBER(misc_outputs_w);
+ DECLARE_WRITE_LINE_MEMBER(irq_mask_w);
+ DECLARE_WRITE_LINE_MEMBER(flip_screen_w);
+ DECLARE_WRITE_LINE_MEMBER(unknown_w);
virtual void machine_start() override;
DECLARE_PALETTE_INIT(spcforce);
diff --git a/src/mame/video/spcforce.cpp b/src/mame/video/spcforce.cpp
index ffa0528cad6..28fe46ace89 100644
--- a/src/mame/video/spcforce.cpp
+++ b/src/mame/video/spcforce.cpp
@@ -12,9 +12,9 @@
#include "includes/spcforce.h"
-WRITE8_MEMBER(spcforce_state::flip_screen_w)
+WRITE_LINE_MEMBER(spcforce_state::flip_screen_w)
{
- flip_screen_set(~data & 0x01);
+ flip_screen_set(!state);
}