tc4 hooked up inputs and leds

This commit is contained in:
hap 2015-02-18 02:32:38 +01:00
parent 332965c412
commit b827e665e0
3 changed files with 147 additions and 11 deletions

View File

@ -190,7 +190,7 @@ READ8_MEMBER(splitsec_state::read_k)
WRITE16_MEMBER(splitsec_state::write_o) WRITE16_MEMBER(splitsec_state::write_o)
{ {
// O0-O6: led rows // O0-O6: led columns
// O7: N/C // O7: N/C
m_o = data; m_o = data;
display_update(); display_update();
@ -204,7 +204,7 @@ WRITE16_MEMBER(splitsec_state::splitsec_write_r)
// R9,R10: input mux // R9,R10: input mux
m_input_mux = data >> 9 & 3; m_input_mux = data >> 9 & 3;
// R0-R7: led columns // R0-R7: led rows
m_r = data & 0xff; m_r = data & 0xff;
display_update(); display_update();
} }
@ -217,7 +217,7 @@ WRITE16_MEMBER(splitsec_state::bankshot_write_r)
// R2,R3: input mux // R2,R3: input mux
m_input_mux = data >> 2 & 3; m_input_mux = data >> 2 & 3;
// R2-R10: led columns // R2-R10: led rows
m_r = data & ~3; m_r = data & ~3;
display_update(); display_update();
} }
@ -246,6 +246,7 @@ INPUT_PORTS_END
/* bankshot physical button layout and labels is like this: /* bankshot physical button layout and labels is like this:
(note: remember that you can rotate the display in MESS)
[SELECT [BALL UP] [BALL OVER] [SELECT [BALL UP] [BALL OVER]
SCORE] SCORE]

View File

@ -18,8 +18,8 @@
#include "tc4.lh" #include "tc4.lh"
// The master clock is a single stage RC oscillator: R=27.3K, C=100pf, // The master clock is a single stage RC oscillator: R=27.3K, C=100pf.
//.. // TMS1400 RC curve is unknown, so let's do an approximation until it is.
#define MASTER_CLOCK (475000) #define MASTER_CLOCK (475000)
@ -29,12 +29,12 @@ public:
tc4_state(const machine_config &mconfig, device_type type, const char *tag) tc4_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
// m_button_matrix(*this, "IN"), m_button_matrix(*this, "IN"),
m_speaker(*this, "speaker") m_speaker(*this, "speaker")
{ } { }
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
// required_ioport_array<2> m_button_matrix; required_ioport_array<6> m_button_matrix;
required_device<speaker_sound_device> m_speaker; required_device<speaker_sound_device> m_speaker;
UINT16 m_r; UINT16 m_r;
@ -49,6 +49,7 @@ public:
DECLARE_WRITE16_MEMBER(write_r); DECLARE_WRITE16_MEMBER(write_r);
TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick);
bool index_is_7segled(int index);
void display_update(); void display_update();
virtual void machine_start(); virtual void machine_start();
@ -68,6 +69,12 @@ public:
// decay time, in steps of 1ms // decay time, in steps of 1ms
#define DISPLAY_DECAY_TIME 40 #define DISPLAY_DECAY_TIME 40
inline bool tc4_state::index_is_7segled(int index)
{
// R5,7,8,9 are 7segs
return (index >= 5 && index <= 9 && index != 6);
}
void tc4_state::display_update() void tc4_state::display_update()
{ {
@ -98,8 +105,8 @@ void tc4_state::display_update()
for (int i = 0; i < 0x10; i++) for (int i = 0; i < 0x10; i++)
if (m_display_cache[i] != active_state[i]) if (m_display_cache[i] != active_state[i])
{ {
// if (index_is_7segled(i)) if (index_is_7segled(i))
// output_set_digit_value(i, BITSWAP8(active_state[i],7,0,1,2,3,4,5,6) & 0x7f); output_set_digit_value(i, active_state[i] & 0x7f);
for (int j = 0; j < 9; j++) for (int j = 0; j < 9; j++)
output_set_lamp_value(i*10 + j, active_state[i] >> j & 1); output_set_lamp_value(i*10 + j, active_state[i] >> j & 1);
@ -130,15 +137,36 @@ READ8_MEMBER(tc4_state::read_k)
{ {
UINT8 k = 0; UINT8 k = 0;
// read selected button rows
for (int i = 0; i < 6; i++)
if (m_r >> i & 1)
k |= m_button_matrix[i]->read();
// read from cartridge
if (m_r & 0x200)
k |= ioport("CART")->read();
return k; return k;
} }
WRITE16_MEMBER(tc4_state::write_o) WRITE16_MEMBER(tc4_state::write_o)
{ {
// O0-O7: leds/7segment
m_o = data;
display_update();
} }
WRITE16_MEMBER(tc4_state::write_r) WRITE16_MEMBER(tc4_state::write_r)
{ {
// R10: speaker out
m_speaker->level_w(data >> 10 & 1);
// R0-R5: input mux
// R6: led column 8
// R9: to cartridge slot
// +other: select leds
m_r = data & 0x3ff;
display_update();
} }
@ -151,6 +179,47 @@ WRITE16_MEMBER(tc4_state::write_r)
***************************************************************************/ ***************************************************************************/
static INPUT_PORTS_START( tc4 ) static INPUT_PORTS_START( tc4 )
PORT_START("IN.0") // R0
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 )
PORT_START("IN.1") // R1
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN )
PORT_START("IN.2") // R2
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN )
PORT_START("IN.3") // R3
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_PLAYER(2)
PORT_START("IN.4") // R4
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_PLAYER(2)
PORT_START("IN.5") // R5
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2)
PORT_START("CART")
PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x00, "R9:1" )
PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "R9:2" )
PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x00, "R9:3" )
PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x00, "R9:4" )
INPUT_PORTS_END INPUT_PORTS_END

View File

@ -3,9 +3,13 @@
<!-- define elements --> <!-- define elements -->
<element name="digit" defstate="0">
<led7seg><color red="1.0" green="0.25" blue="0.28" /></led7seg>
</element>
<element name="led" defstate="0"> <element name="led" defstate="0">
<disk state="0"><color red="0.15" green="0.03" blue="0.03" /></disk> <disk state="0"><color red="0.1" green="0.025" blue="0.028" /></disk>
<disk state="1"><color red="1.0" green="0.3" blue="0.3" /></disk> <disk state="1"><color red="1.0" green="0.25" blue="0.28" /></disk>
</element> </element>
@ -15,6 +19,68 @@
<view name="Internal Layout"> <view name="Internal Layout">
<bounds left="0" right="100" top="0" bottom="100" /> <bounds left="0" right="100" top="0" bottom="100" />
<bezel name="digit5" element="digit"><bounds x="0" y="0" width="10" height="15" /></bezel>
<bezel name="digit9" element="digit"><bounds x="10" y="0" width="10" height="15" /></bezel>
<bezel name="digit8" element="digit"><bounds x="20" y="0" width="10" height="15" /></bezel>
<bezel name="digit7" element="digit"><bounds x="20" y="0" width="10" height="15" /></bezel>
<bezel name="lamp77" element="led"><bounds x="0" y="20" width="1" height="1" /></bezel>
<bezel name="lamp87" element="led"><bounds x="2" y="20" width="1" height="1" /></bezel>
<bezel name="lamp97" element="led"><bounds x="4" y="20" width="1" height="1" /></bezel>
<bezel name="lamp57" element="led"><bounds x="6" y="20" width="1" height="1" /></bezel>
<bezel name="lamp0" element="led"><bounds x="2" y="30" width="1" height="1" /></bezel>
<bezel name="lamp1" element="led"><bounds x="4" y="30" width="1" height="1" /></bezel>
<bezel name="lamp2" element="led"><bounds x="6" y="30" width="1" height="1" /></bezel>
<bezel name="lamp3" element="led"><bounds x="8" y="30" width="1" height="1" /></bezel>
<bezel name="lamp4" element="led"><bounds x="10" y="30" width="1" height="1" /></bezel>
<bezel name="lamp5" element="led"><bounds x="12" y="30" width="1" height="1" /></bezel>
<bezel name="lamp6" element="led"><bounds x="14" y="30" width="1" height="1" /></bezel>
<bezel name="lamp7" element="led"><bounds x="16" y="30" width="1" height="1" /></bezel>
<bezel name="lamp8" element="led"><bounds x="18" y="30" width="1" height="1" /></bezel>
<bezel name="lamp10" element="led"><bounds x="2" y="32" width="1" height="1" /></bezel>
<bezel name="lamp11" element="led"><bounds x="4" y="32" width="1" height="1" /></bezel>
<bezel name="lamp12" element="led"><bounds x="6" y="32" width="1" height="1" /></bezel>
<bezel name="lamp13" element="led"><bounds x="8" y="32" width="1" height="1" /></bezel>
<bezel name="lamp14" element="led"><bounds x="10" y="32" width="1" height="1" /></bezel>
<bezel name="lamp15" element="led"><bounds x="12" y="32" width="1" height="1" /></bezel>
<bezel name="lamp16" element="led"><bounds x="14" y="32" width="1" height="1" /></bezel>
<bezel name="lamp17" element="led"><bounds x="16" y="32" width="1" height="1" /></bezel>
<bezel name="lamp18" element="led"><bounds x="18" y="32" width="1" height="1" /></bezel>
<bezel name="lamp88" element="led"><bounds x="0" y="34" width="1" height="1" /></bezel>
<bezel name="lamp20" element="led"><bounds x="2" y="34" width="1" height="1" /></bezel>
<bezel name="lamp21" element="led"><bounds x="4" y="34" width="1" height="1" /></bezel>
<bezel name="lamp22" element="led"><bounds x="6" y="34" width="1" height="1" /></bezel>
<bezel name="lamp23" element="led"><bounds x="8" y="34" width="1" height="1" /></bezel>
<bezel name="lamp24" element="led"><bounds x="10" y="34" width="1" height="1" /></bezel>
<bezel name="lamp25" element="led"><bounds x="12" y="34" width="1" height="1" /></bezel>
<bezel name="lamp26" element="led"><bounds x="14" y="34" width="1" height="1" /></bezel>
<bezel name="lamp27" element="led"><bounds x="16" y="34" width="1" height="1" /></bezel>
<bezel name="lamp28" element="led"><bounds x="18" y="34" width="1" height="1" /></bezel>
<bezel name="lamp78" element="led"><bounds x="20" y="34" width="1" height="1" /></bezel>
<bezel name="lamp30" element="led"><bounds x="2" y="36" width="1" height="1" /></bezel>
<bezel name="lamp31" element="led"><bounds x="4" y="36" width="1" height="1" /></bezel>
<bezel name="lamp32" element="led"><bounds x="6" y="36" width="1" height="1" /></bezel>
<bezel name="lamp33" element="led"><bounds x="8" y="36" width="1" height="1" /></bezel>
<bezel name="lamp34" element="led"><bounds x="10" y="36" width="1" height="1" /></bezel>
<bezel name="lamp35" element="led"><bounds x="12" y="36" width="1" height="1" /></bezel>
<bezel name="lamp36" element="led"><bounds x="14" y="36" width="1" height="1" /></bezel>
<bezel name="lamp37" element="led"><bounds x="16" y="36" width="1" height="1" /></bezel>
<bezel name="lamp38" element="led"><bounds x="18" y="36" width="1" height="1" /></bezel>
<bezel name="lamp40" element="led"><bounds x="2" y="38" width="1" height="1" /></bezel>
<bezel name="lamp41" element="led"><bounds x="4" y="38" width="1" height="1" /></bezel>
<bezel name="lamp42" element="led"><bounds x="6" y="38" width="1" height="1" /></bezel>
<bezel name="lamp43" element="led"><bounds x="8" y="38" width="1" height="1" /></bezel>
<bezel name="lamp44" element="led"><bounds x="10" y="38" width="1" height="1" /></bezel>
<bezel name="lamp45" element="led"><bounds x="12" y="38" width="1" height="1" /></bezel>
<bezel name="lamp46" element="led"><bounds x="14" y="38" width="1" height="1" /></bezel>
<bezel name="lamp47" element="led"><bounds x="16" y="38" width="1" height="1" /></bezel>
<bezel name="lamp48" element="led"><bounds x="18" y="38" width="1" height="1" /></bezel>
</view> </view>
</mamelayout> </mamelayout>