sm500: small cleanup (nw)

This commit is contained in:
hap 2017-06-25 18:33:38 +02:00
parent c318e49ab2
commit d36944fbb0
4 changed files with 31 additions and 33 deletions

View File

@ -83,7 +83,7 @@ public:
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);
sm500_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_pins, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data);
virtual void device_start() override;
virtual void device_reset() override;
@ -99,7 +99,7 @@ protected:
devcb_write8 m_write_o;
virtual void lcd_update() override;
int m_o_mask; // number of 4-bit O pins minus 1
int m_o_pins; // number of 4-bit O pins
u8 m_ox[9]; // W' latch, max 9
u8 m_o[9]; // W latch
u8 m_cn;
@ -153,7 +153,7 @@ public:
sm5a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
sm5a_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);
sm5a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_pins, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data);
virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override;
virtual void execute_one() override;

View File

@ -35,18 +35,26 @@ ADDRESS_MAP_END
// device definitions
sm500_device::sm500_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: sm500_device(mconfig, SM500, tag, owner, clock, 1 /* stack levels */, 6 /* o mask */, 11 /* prg width */, ADDRESS_MAP_NAME(program_1_2k), 6 /* data width */, ADDRESS_MAP_NAME(data_4x10x4))
: sm500_device(mconfig, SM500, tag, owner, clock, 1 /* stack levels */, 7 /* o group pins */, 11 /* prg width */, ADDRESS_MAP_NAME(program_1_2k), 6 /* data width */, ADDRESS_MAP_NAME(data_4x10x4))
{
}
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)
sm500_device::sm500_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_pins, 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)
m_o_pins(o_pins)
{
}
// disasm
offs_t sm500_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options)
{
extern CPU_DISASSEMBLE(sm500);
return CPU_DISASSEMBLE_NAME(sm500)(this, stream, pc, oprom, opram, options);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -100,15 +108,6 @@ void sm500_device::device_reset()
// disasm
offs_t sm500_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options)
{
extern CPU_DISASSEMBLE(sm500);
return CPU_DISASSEMBLE_NAME(sm500)(this, stream, pc, oprom, opram, options);
}
//-------------------------------------------------
// lcd driver
//-------------------------------------------------
@ -118,7 +117,7 @@ void sm500_device::lcd_update()
// 2 columns
for (int h = 0; h < 2; h++)
{
for (int o = 0; o <= m_o_mask; o++)
for (int o = 0; o < m_o_pins; o++)
{
// 4 segments per group
u8 seg = h ? m_o[o] : m_ox[o];

View File

@ -12,7 +12,7 @@
void sm500_device::shift_w()
{
// shifts internal W' latches
for (int i = 0; i < m_o_mask; i++)
for (int i = 0; i < (m_o_pins-1); i++)
m_ox[i] = m_ox[i + 1];
}
@ -37,9 +37,8 @@ u8 sm500_device::get_digit()
void sm500_device::op_lb()
{
// LB x: load BM/BL with 4-bit immediate value (partial)
// BL bit 2 is clearned, bit 3 is param bit 2|3
m_bm = (m_op & 3);
m_bl = ((m_op << 1 | m_op) & 8) | (m_op >> 2 & 3);
m_bm = m_op & 3;
m_bl = (m_op >> 2 & 3) | ((m_op & 0xc) ? 8 : 0);
}
void sm500_device::op_incb()
@ -122,43 +121,43 @@ void sm500_device::op_atbp()
void sm500_device::op_ptw()
{
// PTW: partial transfer W' to W
m_o[m_o_mask] = m_ox[m_o_mask];
m_o[m_o_mask-1] = m_ox[m_o_mask-1];
m_o[m_o_pins-1] = m_ox[m_o_pins-1];
m_o[m_o_pins-2] = m_ox[m_o_pins-2];
}
void sm500_device::op_tw()
{
// TW: transfer W' to W
for (int i = 0; i <= m_o_mask; i++)
for (int i = 0; i < m_o_pins; i++)
m_o[i] = m_ox[i];
}
void sm500_device::op_pdtw()
{
// PDTW: partial shift digit into W'
m_ox[m_o_mask-1] = m_ox[m_o_mask];
m_ox[m_o_mask] = get_digit();
m_ox[m_o_pins-2] = m_ox[m_o_pins-1];
m_ox[m_o_pins-1] = get_digit();
}
void sm500_device::op_dtw()
{
// DTW: shift digit into W'
shift_w();
m_ox[m_o_mask] = get_digit();
m_ox[m_o_pins-1] = get_digit();
}
void sm500_device::op_wr()
{
// WR: shift ACC into W', reset last bit
shift_w();
m_ox[m_o_mask] = m_acc & 7;
m_ox[m_o_pins-1] = m_acc & 7;
}
void sm500_device::op_ws()
{
// WR: shift ACC into W', set last bit
shift_w();
m_ox[m_o_mask] = m_acc | 8;
m_ox[m_o_pins-1] = m_acc | 8;
}

View File

@ -42,22 +42,22 @@ ADDRESS_MAP_END
// device definitions
sm5a_device::sm5a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: sm5a_device(mconfig, SM5A, tag, owner, clock, 1 /* stack levels */, 8 /* o mask */, 11 /* prg width */, ADDRESS_MAP_NAME(program_1_8k), 7 /* data width */, ADDRESS_MAP_NAME(data_5x13x4))
: sm5a_device(mconfig, SM5A, tag, owner, clock, 1 /* stack levels */, 9 /* o group pins */, 11 /* prg width */, ADDRESS_MAP_NAME(program_1_8k), 7 /* data width */, ADDRESS_MAP_NAME(data_5x13x4))
{
}
sm5a_device::sm5a_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)
: sm500_device(mconfig, type, tag, owner, clock, stack_levels, o_mask, prgwidth, program, datawidth, data)
sm5a_device::sm5a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int stack_levels, int o_pins, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data)
: sm500_device(mconfig, type, tag, owner, clock, stack_levels, o_pins, prgwidth, program, datawidth, data)
{
}
sm5l_device::sm5l_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: sm5a_device(mconfig, SM5L, tag, owner, clock, 1, 8, 11, ADDRESS_MAP_NAME(program_1_8k), 7, ADDRESS_MAP_NAME(data_5x13x4))
: sm5a_device(mconfig, SM5L, tag, owner, clock, 1, 9, 11, ADDRESS_MAP_NAME(program_1_8k), 7, ADDRESS_MAP_NAME(data_5x13x4))
{
}
kb1013vk12_device::kb1013vk12_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: sm5a_device(mconfig, KB1013VK12, tag, owner, clock, 1, 8, 11, ADDRESS_MAP_NAME(program_1_8k), 7, ADDRESS_MAP_NAME(data_5x13x4))
: sm5a_device(mconfig, KB1013VK12, tag, owner, clock, 1, 9, 11, ADDRESS_MAP_NAME(program_1_8k), 7, ADDRESS_MAP_NAME(data_5x13x4))
{
}