summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/devices/cpu/ht1130/ht1130.cpp61
-rw-r--r--src/devices/cpu/ht1130/ht1130.h5
-rw-r--r--src/devices/cpu/ht1130/ht1130d.cpp20
3 files changed, 50 insertions, 36 deletions
diff --git a/src/devices/cpu/ht1130/ht1130.cpp b/src/devices/cpu/ht1130/ht1130.cpp
index df5a89cfe5d..0f2aaefa836 100644
--- a/src/devices/cpu/ht1130/ht1130.cpp
+++ b/src/devices/cpu/ht1130/ht1130.cpp
@@ -3,12 +3,14 @@
/*
- TODO:
- - Interrupts (not used by brke23p2)
- - Sound (needs internal frequency ROM data?)
- - 1 machine cycle (eg. a 1 byte opcode) takes 4 system clock cycles (from OSC pins).
- - The timer rate can be configured with a mask option (system clock / 2^n), n=0-13 (except 6 for some reason).
- So, timer rate can be faster or slower than machine cycle rate.
+Holtek HT1130 MCU family
+
+TODO:
+- Interrupts (not used by brke23p2)
+- Sound (needs internal frequency ROM data?)
+- 1 machine cycle (eg. a 1 byte opcode) takes 4 system clock cycles (from OSC pins).
+- The timer rate can be configured with a mask option (system clock / 2^n), n=0-13 (except 6 for some reason).
+ So, timer rate can be faster or slower than machine cycle rate.
*/
@@ -45,13 +47,11 @@ ht1130_device::ht1130_device(const machine_config &mconfig, device_type type, co
ht1130_device::ht1130_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: ht1130_device(mconfig, HT1130, tag, owner, clock, address_map_constructor(FUNC(ht1130_device::internal_data_map), this))
{
- m_compins = 4;
}
ht1190_device::ht1190_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: ht1130_device(mconfig, HT1190, tag, owner, clock, address_map_constructor(FUNC(ht1190_device::internal_data_map_ht1190), this))
{
- m_compins = 8;
}
std::unique_ptr<util::disasm_interface> ht1130_device::create_disassembler()
@@ -189,19 +189,19 @@ void ht1190_device::internal_data_map_ht1190(address_map &map)
map(0xb0, 0xff).ram().w(FUNC(ht1190_device::displayram_w)).share(m_displayram);
}
-void ht1130_device::init_lcd()
+void ht1130_device::init_lcd(u8 compins)
{
m_lcd_timer = timer_alloc(FUNC(ht1130_device::update_lcd), this);
// LCD refresh rate is ~64Hz (not affected by system OSC)
- attotime period = attotime::from_hz(64 * m_compins);
- m_lcd_timer->adjust(period, 0, period);
+ attotime period = attotime::from_hz(64 * compins);
+ m_lcd_timer->adjust(period, compins, period);
}
TIMER_CALLBACK_MEMBER(ht1130_device::update_lcd)
{
m_segment_out(m_comcount, m_inhalt ? 0 : get_segs(m_comcount));
- m_comcount = (m_comcount + 1) % m_compins;
+ m_comcount = (m_comcount + 1) % param;
}
u64 ht1130_device::get_segs(u8 com)
@@ -222,15 +222,14 @@ u64 ht1190_device::get_segs(u8 com)
return segs;
}
-void ht1130_device::device_start()
+void ht1130_device::init_common()
{
space(AS_PROGRAM).specific(m_space);
space(AS_DATA).specific(m_data);
- init_lcd();
-
set_icountptr(m_icount);
+ // debugger
state_add(HT1130_PC, "PC", m_pc);
state_add(STATE_GENPC, "GENPC", m_pc).noshow();
state_add(STATE_GENPCBASE, "CURPC", m_pc).noshow();
@@ -243,6 +242,7 @@ void ht1130_device::device_start()
state_add(HT1130_TIMER_EN, "TIMER_EN", m_timer_en);
state_add(HT1130_TIMER, "TIMER", m_timer);
+ // zerofill
std::fill(std::begin(m_regs), std::end(m_regs), 0);
m_acc = 0;
m_stackaddr = 0;
@@ -258,6 +258,7 @@ void ht1130_device::device_start()
m_timer = 0;
m_comcount = 0;
+ // savestates
save_item(NAME(m_pc));
save_item(NAME(m_regs));
save_item(NAME(m_acc));
@@ -273,6 +274,18 @@ void ht1130_device::device_start()
save_item(NAME(m_stackcarry));
}
+void ht1130_device::device_start()
+{
+ init_common();
+ init_lcd(4); // 4 COM pins
+}
+
+void ht1190_device::device_start()
+{
+ init_common();
+ init_lcd(8); // 8 COM pins
+}
+
void ht1130_device::device_reset()
{
m_pc = 0;
@@ -591,7 +604,7 @@ void ht1130_device::do_op()
return;
}
- case 0b00001010: // SBC A,[R1R0] : Subtract data memory contents and carry from ACC
+ case 0b00001010: // SBC A,[R1R0] : Subtract data memory contents and carry from accumulator
{
const u8 data = getr1r0_data();
@@ -693,7 +706,7 @@ void ht1130_device::do_op()
return;
}
- case 0b01000001: // (with 4-bit immediate) : SUB A,XH : Subtract immediate data from accumulator0
+ case 0b01000001: // (with 4-bit immediate) : SUB A,XH : Subtract immediate data from accumulator
{
const u8 operand = fetch() & 0x0f;
u8 acc = getacc();
@@ -714,7 +727,7 @@ void ht1130_device::do_op()
return;
}
- //case 0b0111dddd: // MOV A,XH : Move immediate data to accumulator
+ // case 0b0111dddd: // MOV A,XH : Move immediate data to accumulator
case 0b01110000: case 0b01110001: case 0b01110010: case 0b01110011:
case 0b01110100: case 0b01110101: case 0b01110110: case 0b01110111:
case 0b01111000: case 0b01111001: case 0b01111010: case 0b01111011:
@@ -757,7 +770,7 @@ void ht1130_device::do_op()
return;
}
- //case 0b0010nnn0: MOV Rn,A : Move accumulator to register
+ // case 0b0010nnn0: MOV Rn,A : Move accumulator to register
case 0b00100000: case 0b00100010: case 0b00100100: case 0b00100110:
case 0b00101000:
{
@@ -771,7 +784,7 @@ void ht1130_device::do_op()
// 2 reg Move ops
///////////////////////////////////////////////////////////////////////////////////////
- //case 0b0101dddd: // (with 4-bit immediate) : MOV R1R0,XXH : Move immediate data to R1 and R0
+ // case 0b0101dddd: // (with 4-bit immediate) : MOV R1R0,XXH : Move immediate data to R1 and R0
case 0b01010000: case 0b01010001: case 0b01010010: case 0b01010011:
case 0b01010100: case 0b01010101: case 0b01010110: case 0b01010111:
case 0b01011000: case 0b01011001: case 0b01011010: case 0b01011011:
@@ -783,7 +796,7 @@ void ht1130_device::do_op()
return;
}
- //case 0b0110dddd: // (with 4-bit immediate) : MOV R3R2,XXH : Move immediate data to R3 and R2
+ // case 0b0110dddd: // (with 4-bit immediate) : MOV R3R2,XXH : Move immediate data to R3 and R2
case 0b01100000: case 0b01100001: case 0b01100010: case 0b01100011:
case 0b01100100: case 0b01100101: case 0b01100110: case 0b01100111:
case 0b01101000: case 0b01101001: case 0b01101010: case 0b01101011:
@@ -934,7 +947,7 @@ void ht1130_device::do_op()
return;
}
- //case 0b100nnaaa: // (with 8-bit immediate) : JAn address : Jump if accumulator bit n is set
+ // case 0b100nnaaa: // (with 8-bit immediate) : JAn address : Jump if accumulator bit n is set
case 0b10000000: case 0b10000001: case 0b10000010: case 0b10000011:
case 0b10000100: case 0b10000101: case 0b10000110: case 0b10000111:
case 0b10001000: case 0b10001001: case 0b10001010: case 0b10001011:
@@ -1017,7 +1030,7 @@ void ht1130_device::do_op()
// SOUND Ops (unimplemented)
///////////////////////////////////////////////////////////////////////////////////////
- case 0b01001011: // SOUND A : Activate SOUND channel with accumulator
+ case 0b01001011: // SOUND A : Activate sound channel with accumulator
{
LOGMASKED(LOG_UNHANDLED_SOUND_OPS, "SOUND A");
return;
@@ -1041,7 +1054,7 @@ void ht1130_device::do_op()
return;
}
- case 0b01000101: // (with 4 bit immediate) : SOUND n : Activate SOUND channel n
+ case 0b01000101: // (with 4 bit immediate) : SOUND n : Activate sound channel n
{
u8 operand = fetch() & 0x0f;
LOGMASKED(LOG_UNHANDLED_SOUND_OPS, "SOUND %d", operand);
diff --git a/src/devices/cpu/ht1130/ht1130.h b/src/devices/cpu/ht1130/ht1130.h
index 8ab854116d2..f500ef7553a 100644
--- a/src/devices/cpu/ht1130/ht1130.h
+++ b/src/devices/cpu/ht1130/ht1130.h
@@ -88,7 +88,8 @@ protected:
u8 gettimer_upper();
u8 gettimer_lower();
- void init_lcd();
+ void init_common();
+ void init_lcd(u8 compins);
TIMER_CALLBACK_MEMBER(update_lcd);
virtual u64 get_segs(u8 com);
@@ -109,7 +110,6 @@ protected:
u8 m_timerover;
u16 m_timer;
- u8 m_compins;
u8 m_comcount;
emu_timer *m_lcd_timer;
@@ -131,6 +131,7 @@ public:
ht1190_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
+ virtual void device_start() override;
virtual u64 get_segs(u8 coms) override;
private:
diff --git a/src/devices/cpu/ht1130/ht1130d.cpp b/src/devices/cpu/ht1130/ht1130d.cpp
index 0f504870b3f..8861578bba3 100644
--- a/src/devices/cpu/ht1130/ht1130d.cpp
+++ b/src/devices/cpu/ht1130/ht1130d.cpp
@@ -254,13 +254,13 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 1;
}
- case 0b00001010: // SBC A,[R1R0] : Subtract data memory contents and carry from ACC
+ case 0b00001010: // SBC A,[R1R0] : Subtract data memory contents and carry from accumulator
{
stream << "SBC A,[R1R0]";
return 1;
}
- case 0b01001011: // SOUND A : Activate SOUND channel with accumulator
+ case 0b01001011: // SOUND A : Activate sound channel with accumulator
{
stream << "SOUND A";
return 1;
@@ -378,7 +378,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 2;
}
- case 0b01000001: // (with 4-bit immediate) : SUB A,XH : Subtract immediate data from accumulator0
+ case 0b01000001: // (with 4-bit immediate) : SUB A,XH : Subtract immediate data from accumulator
{
u8 operand = opcodes.r8(pc + 1);
if (!(operand & 0xf0))
@@ -406,7 +406,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 2;
}
- //case 0b0111dddd: // MOV A,XH : Move immediate data to accumulator
+ // case 0b0111dddd: // MOV A,XH : Move immediate data to accumulator
case 0b01110000: case 0b01110001: case 0b01110010: case 0b01110011:
case 0b01110100: case 0b01110101: case 0b01110110: case 0b01110111:
case 0b01111000: case 0b01111001: case 0b01111010: case 0b01111011:
@@ -446,7 +446,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 1;
}
- //case 0b0010nnn0: MOV Rn,A : Move accumulator to register
+ // case 0b0010nnn0: MOV Rn,A : Move accumulator to register
case 0b00100000: case 0b00100010: case 0b00100100: case 0b00100110:
case 0b00101000:
{
@@ -457,7 +457,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
// dual move ops
- //case 0b0101dddd: // (with 4-bit immediate) : MOV R1R0,XXH : Move immediate data to R1 and R0
+ // case 0b0101dddd: // (with 4-bit immediate) : MOV R1R0,XXH : Move immediate data to R1 and R0
case 0b01010000: case 0b01010001: case 0b01010010: case 0b01010011:
case 0b01010100: case 0b01010101: case 0b01010110: case 0b01010111:
case 0b01011000: case 0b01011001: case 0b01011010: case 0b01011011:
@@ -476,7 +476,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 2;
}
- //case 0b0110dddd: // (with 4-bit immediate) : MOV R3R2,XXH : Move immediate data to R3 and R2
+ // case 0b0110dddd: // (with 4-bit immediate) : MOV R3R2,XXH : Move immediate data to R3 and R2
case 0b01100000: case 0b01100001: case 0b01100010: case 0b01100011:
case 0b01100100: case 0b01100101: case 0b01100110: case 0b01100111:
case 0b01101000: case 0b01101001: case 0b01101010: case 0b01101011:
@@ -603,7 +603,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 2;
}
- //case 0b100nnaaa: // (with 8-bit immediate) : JAn address : Jump if accumulator bit n is set
+ // case 0b100nnaaa: // (with 8-bit immediate) : JAn address : Jump if accumulator bit n is set
case 0b10000000: case 0b10000001: case 0b10000010: case 0b10000011:
case 0b10000100: case 0b10000101: case 0b10000110: case 0b10000111:
case 0b10001000: case 0b10001001: case 0b10001010: case 0b10001011:
@@ -621,7 +621,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
}
// other Ops
- case 0b01000101: // (with 4 bit immediate) : SOUND n : Activate SOUND channel n
+ case 0b01000101: // (with 4 bit immediate) : SOUND n : Activate sound channel n
{
u8 operand = opcodes.r8(pc + 1);
if (!(operand & 0xf0))
@@ -635,7 +635,7 @@ offs_t ht1130_disassembler::disassemble(std::ostream &stream, offs_t pc, const h
return 2;
}
- case 0b00110111: // (with 00111110) : HALT Halt system clock
+ case 0b00110111: // (with 00111110) : HALT : Halt system clock
{
u8 operand = opcodes.r8(pc + 1);
if (operand == 0b00111110)