sm500: added lcd output (nw)

This commit is contained in:
hap 2017-06-24 21:26:23 +02:00
parent a89cc32081
commit d09534c380
4 changed files with 186 additions and 5 deletions

View File

@ -16,6 +16,10 @@
// I/O ports setup
// LCD segment outputs: H1/2 as a4, O group as a0-a3, O data as d0-d3
#define MCFG_SM500_WRITE_O_CB(_devcb) \
devcb = &sm500_device::set_write_o_callback(*device, DEVCB_##_devcb);
// see sm510.h for ACL, K, R, alpha, beta
@ -75,6 +79,9 @@ class sm500_device : public sm510_base_device
public:
sm500_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
// static configuration helpers
template <class Object> static devcb_base &set_write_o_callback(device_t &device, Object &&cb) { return downcast<sm500_device &>(device).m_write_o.set_callback(std::forward<Object>(cb)); }
protected:
sm500_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_mask, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data);
@ -88,11 +95,16 @@ protected:
virtual void reset_vector() override { do_branch(0, 0xf, 0); }
virtual void wakeup_vector() override { do_branch(0, 0, 0); }
// lcd driver
devcb_write8 m_write_o;
virtual void lcd_update() override;
int m_o_mask; // number of 4-bit O pins minus 1
u8 m_ox[9]; // W' latch, max 9
u8 m_o[9]; // W latch
u8 m_cn;
u8 m_mx;
u8 m_cb;
u8 m_s;
bool m_rsub;
@ -102,7 +114,7 @@ protected:
void set_su(u8 su) { m_stack[0] = (m_stack[0] & ~0x3c0) | (su << 6); }
u8 get_su() { return m_stack[0] >> 6 & 0xf; }
virtual int get_trs_field() { return 0; }
// opcode handlers
virtual void op_lb() override;
virtual void op_incb() override;

View File

@ -7,6 +7,7 @@
TODO:
- EXKSA, EXKFA opcodes
- SM500 data book suggests that R1 divider output is selectable, but how?
- unknown which H/O pin is which W output, guessed for now
- ACL doesn't work right?
*/
@ -41,6 +42,7 @@ sm500_device::sm500_device(const machine_config &mconfig, const char *tag, devic
sm500_device::sm500_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_mask, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data)
: sm510_base_device(mconfig, type, tag, owner, clock, stack_levels, prgwidth, program, datawidth, data),
m_write_o(*this),
m_o_mask(o_mask)
{
}
@ -54,7 +56,10 @@ void sm500_device::device_start()
{
// common init (not everything is used though)
sm510_base_device::device_start();
// resolve callbacks
m_write_o.resolve_safe();
// init/zerofill
memset(m_ox, 0, sizeof(m_ox));
memset(m_o, 0, sizeof(m_o));
@ -103,6 +108,27 @@ offs_t sm500_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u
}
//-------------------------------------------------
// lcd driver
//-------------------------------------------------
void sm500_device::lcd_update()
{
// 2 columns
for (int h = 0; h < 2; h++)
{
for (int o = 0; o <= m_o_mask; o++)
{
// 4 segments per group
u8 seg = h ? m_o[o] : m_ox[o];
m_write_o(h << 4 | o, m_bp ? seg : 0, 0xff);
}
}
}
//-------------------------------------------------
// buzzer controller
//-------------------------------------------------

View File

@ -1,8 +1,9 @@
// license:BSD-3-Clause
// copyright-holders:hap, Sean Riddle
// thanks-to:Igor
/***************************************************************************
Sharp SM510/SM511 handhelds.
Sharp SM5xx family handhelds.
TODO:
- gnw_mc25 emulation is preliminary
@ -29,6 +30,7 @@
#include "gnw_dualv.lh"
#include "gnw_dualh.lh"
//#include "hh_sm510_test.lh" // common test-layout - use external artwork
#include "hh_sm500_test.lh" // "
class hh_sm510_state : public driver_device
@ -58,6 +60,7 @@ public:
virtual DECLARE_INPUT_CHANGED_MEMBER(input_changed);
virtual DECLARE_INPUT_CHANGED_MEMBER(acl_button);
virtual DECLARE_WRITE16_MEMBER(sm510_lcd_segment_w);
virtual DECLARE_WRITE8_MEMBER(sm500_lcd_segment_w);
virtual DECLARE_READ8_MEMBER(input_r);
virtual DECLARE_WRITE8_MEMBER(input_w);
virtual DECLARE_WRITE8_MEMBER(piezo_r1_w);
@ -121,6 +124,28 @@ WRITE16_MEMBER(hh_sm510_state::sm510_lcd_segment_w)
}
}
WRITE8_MEMBER(hh_sm510_state::sm500_lcd_segment_w)
{
for (int seg = 0; seg < 4; seg++)
{
int index = offset << 2 | seg;
u8 state = data >> seg & 1;
if (state != m_lcd_output_cache[index])
{
// output to row.seg.H, where:
// row = O group (0-*)
// seg = O data (0-3)
// H = H1/H2 (0/1)
char buf[0x10];
sprintf(buf, "%d.%d.%d", offset & 0xf, seg, offset >> 4);
output().set_value(buf, state);
m_lcd_output_cache[index] = state;
}
}
}
// generic input handlers - usually S output is input mux, and K input for buttons
@ -530,9 +555,16 @@ MACHINE_CONFIG_END
/***************************************************************************
Nintendo Game & Watch: Mickey Mouse (model MC-25)
Nintendo Game & Watch: Mickey Mouse (model MC-25), Egg (model EG-26)
* Sharp SM5A label ?
MC-25 and EG-26 are the same game, it's assumed that the latter was for
regions where Nintendo wasn't able to license from Disney.
In 1984, Elektronika(USSR) released a clone, Nu, Pogodi! This was followed
by several other games that were the same under the hood, only differing
in graphics.
***************************************************************************/
class mc25_state : public hh_sm510_state
@ -574,11 +606,12 @@ static MACHINE_CONFIG_START( mc25 )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", SM5A, XTAL_32_768kHz)
MCFG_SM500_WRITE_O_CB(WRITE8(hh_sm510_state, sm500_lcd_segment_w))
MCFG_SM510_READ_K_CB(READ8(hh_sm510_state, input_r))
MCFG_SM510_WRITE_R_CB(WRITE8(hh_sm510_state, piezo_input_w))
/* video hardware */
// ..
MCFG_DEFAULT_LAYOUT(layout_hh_sm500_test)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")

View File

@ -0,0 +1,110 @@
<?xml version="1.0"?>
<mamelayout version="2">
<!-- define elements -->
<!-- not really black, and not really leds either, but let's just keep the same naming as the other hh test layouts -->
<element name="static_black"><rect><color red="0.5412" green="0.57255" blue="0.5804" /></rect></element>
<element name="led" defstate="0">
<disk state="0"><color red="0.5412" green="0.57255" blue="0.5804" /></disk>
<disk state="1"><color red="0.361" green="0.326" blue="0.346" /></disk>
</element>
<!-- build screen -->
<view name="Test Layout">
<bounds left="0" right="64" top="0" bottom="64" />
<bezel element="static_black">
<bounds left="0" right="64" top="0" bottom="64" />
</bezel>
<!-- max 9*4*2 matrix -->
<!-- h1 -->
<bezel name="0.0.0" element="led"><bounds x="0" y="0" width="1" height="1" /></bezel>
<bezel name="1.0.0" element="led"><bounds x="0" y="2" width="1" height="1" /></bezel>
<bezel name="2.0.0" element="led"><bounds x="0" y="4" width="1" height="1" /></bezel>
<bezel name="3.0.0" element="led"><bounds x="0" y="6" width="1" height="1" /></bezel>
<bezel name="4.0.0" element="led"><bounds x="0" y="8" width="1" height="1" /></bezel>
<bezel name="5.0.0" element="led"><bounds x="0" y="10" width="1" height="1" /></bezel>
<bezel name="6.0.0" element="led"><bounds x="0" y="12" width="1" height="1" /></bezel>
<bezel name="7.0.0" element="led"><bounds x="0" y="14" width="1" height="1" /></bezel>
<bezel name="8.0.0" element="led"><bounds x="0" y="16" width="1" height="1" /></bezel>
<bezel name="0.1.0" element="led"><bounds x="2" y="0" width="1" height="1" /></bezel>
<bezel name="1.1.0" element="led"><bounds x="2" y="2" width="1" height="1" /></bezel>
<bezel name="2.1.0" element="led"><bounds x="2" y="4" width="1" height="1" /></bezel>
<bezel name="3.1.0" element="led"><bounds x="2" y="6" width="1" height="1" /></bezel>
<bezel name="4.1.0" element="led"><bounds x="2" y="8" width="1" height="1" /></bezel>
<bezel name="5.1.0" element="led"><bounds x="2" y="10" width="1" height="1" /></bezel>
<bezel name="6.1.0" element="led"><bounds x="2" y="12" width="1" height="1" /></bezel>
<bezel name="7.1.0" element="led"><bounds x="2" y="14" width="1" height="1" /></bezel>
<bezel name="8.1.0" element="led"><bounds x="2" y="16" width="1" height="1" /></bezel>
<bezel name="0.2.0" element="led"><bounds x="4" y="0" width="1" height="1" /></bezel>
<bezel name="1.2.0" element="led"><bounds x="4" y="2" width="1" height="1" /></bezel>
<bezel name="2.2.0" element="led"><bounds x="4" y="4" width="1" height="1" /></bezel>
<bezel name="3.2.0" element="led"><bounds x="4" y="6" width="1" height="1" /></bezel>
<bezel name="4.2.0" element="led"><bounds x="4" y="8" width="1" height="1" /></bezel>
<bezel name="5.2.0" element="led"><bounds x="4" y="10" width="1" height="1" /></bezel>
<bezel name="6.2.0" element="led"><bounds x="4" y="12" width="1" height="1" /></bezel>
<bezel name="7.2.0" element="led"><bounds x="4" y="14" width="1" height="1" /></bezel>
<bezel name="8.2.0" element="led"><bounds x="4" y="16" width="1" height="1" /></bezel>
<bezel name="0.3.0" element="led"><bounds x="6" y="0" width="1" height="1" /></bezel>
<bezel name="1.3.0" element="led"><bounds x="6" y="2" width="1" height="1" /></bezel>
<bezel name="2.3.0" element="led"><bounds x="6" y="4" width="1" height="1" /></bezel>
<bezel name="3.3.0" element="led"><bounds x="6" y="6" width="1" height="1" /></bezel>
<bezel name="4.3.0" element="led"><bounds x="6" y="8" width="1" height="1" /></bezel>
<bezel name="5.3.0" element="led"><bounds x="6" y="10" width="1" height="1" /></bezel>
<bezel name="6.3.0" element="led"><bounds x="6" y="12" width="1" height="1" /></bezel>
<bezel name="7.3.0" element="led"><bounds x="6" y="14" width="1" height="1" /></bezel>
<bezel name="8.3.0" element="led"><bounds x="6" y="16" width="1" height="1" /></bezel>
<!-- h2 -->
<bezel name="0.0.1" element="led"><bounds x="10" y="0" width="1" height="1" /></bezel>
<bezel name="1.0.1" element="led"><bounds x="10" y="2" width="1" height="1" /></bezel>
<bezel name="2.0.1" element="led"><bounds x="10" y="4" width="1" height="1" /></bezel>
<bezel name="3.0.1" element="led"><bounds x="10" y="6" width="1" height="1" /></bezel>
<bezel name="4.0.1" element="led"><bounds x="10" y="8" width="1" height="1" /></bezel>
<bezel name="5.0.1" element="led"><bounds x="10" y="10" width="1" height="1" /></bezel>
<bezel name="6.0.1" element="led"><bounds x="10" y="12" width="1" height="1" /></bezel>
<bezel name="7.0.1" element="led"><bounds x="10" y="14" width="1" height="1" /></bezel>
<bezel name="8.0.1" element="led"><bounds x="10" y="16" width="1" height="1" /></bezel>
<bezel name="0.1.1" element="led"><bounds x="12" y="0" width="1" height="1" /></bezel>
<bezel name="1.1.1" element="led"><bounds x="12" y="2" width="1" height="1" /></bezel>
<bezel name="2.1.1" element="led"><bounds x="12" y="4" width="1" height="1" /></bezel>
<bezel name="3.1.1" element="led"><bounds x="12" y="6" width="1" height="1" /></bezel>
<bezel name="4.1.1" element="led"><bounds x="12" y="8" width="1" height="1" /></bezel>
<bezel name="5.1.1" element="led"><bounds x="12" y="10" width="1" height="1" /></bezel>
<bezel name="6.1.1" element="led"><bounds x="12" y="12" width="1" height="1" /></bezel>
<bezel name="7.1.1" element="led"><bounds x="12" y="14" width="1" height="1" /></bezel>
<bezel name="8.1.1" element="led"><bounds x="12" y="16" width="1" height="1" /></bezel>
<bezel name="0.2.1" element="led"><bounds x="14" y="0" width="1" height="1" /></bezel>
<bezel name="1.2.1" element="led"><bounds x="14" y="2" width="1" height="1" /></bezel>
<bezel name="2.2.1" element="led"><bounds x="14" y="4" width="1" height="1" /></bezel>
<bezel name="3.2.1" element="led"><bounds x="14" y="6" width="1" height="1" /></bezel>
<bezel name="4.2.1" element="led"><bounds x="14" y="8" width="1" height="1" /></bezel>
<bezel name="5.2.1" element="led"><bounds x="14" y="10" width="1" height="1" /></bezel>
<bezel name="6.2.1" element="led"><bounds x="14" y="12" width="1" height="1" /></bezel>
<bezel name="7.2.1" element="led"><bounds x="14" y="14" width="1" height="1" /></bezel>
<bezel name="8.2.1" element="led"><bounds x="14" y="16" width="1" height="1" /></bezel>
<bezel name="0.3.1" element="led"><bounds x="16" y="0" width="1" height="1" /></bezel>
<bezel name="1.3.1" element="led"><bounds x="16" y="2" width="1" height="1" /></bezel>
<bezel name="2.3.1" element="led"><bounds x="16" y="4" width="1" height="1" /></bezel>
<bezel name="3.3.1" element="led"><bounds x="16" y="6" width="1" height="1" /></bezel>
<bezel name="4.3.1" element="led"><bounds x="16" y="8" width="1" height="1" /></bezel>
<bezel name="5.3.1" element="led"><bounds x="16" y="10" width="1" height="1" /></bezel>
<bezel name="6.3.1" element="led"><bounds x="16" y="12" width="1" height="1" /></bezel>
<bezel name="7.3.1" element="led"><bounds x="16" y="14" width="1" height="1" /></bezel>
<bezel name="8.3.1" element="led"><bounds x="16" y="16" width="1" height="1" /></bezel>
</view>
</mamelayout>