summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2022-08-16 01:38:21 +0200
committer hap <happppp@users.noreply.github.com>2022-08-16 01:38:21 +0200
commit93564468511c813b2f3c416a6ca104c591f6caf5 (patch)
tree25ecd427ae329f7e354b401b87c2b43b07f19f46
parent179e9b16a0665e7e98cafb38dda7e0a3d3219131 (diff)
tms2100: add event counter
-rw-r--r--src/devices/cpu/tms1000/tms2100.cpp38
-rw-r--r--src/devices/cpu/tms1000/tms2100.h8
2 files changed, 32 insertions, 14 deletions
diff --git a/src/devices/cpu/tms1000/tms2100.cpp b/src/devices/cpu/tms1000/tms2100.cpp
index 1205431ab34..9ea9bd596a3 100644
--- a/src/devices/cpu/tms1000/tms2100.cpp
+++ b/src/devices/cpu/tms1000/tms2100.cpp
@@ -22,7 +22,6 @@ Extra functions are controlled with the R register (not mapped to pins):
- R24: enable interrupts
TODO:
-- event counter (EC1 pin)
- R0-R3 I/O, TRA opcode
- A/D converter, TADM opcode
- what happens if decrementer is loaded when IVR is 0?
@@ -95,9 +94,10 @@ void tms2100_cpu_device::device_start()
m_ivr = 0xff;
m_dec = 0xff;
m_il = 0;
- m_int_pin = 0;
m_int_pending = false;
m_r_prev = 0;
+ m_int_pin = 0;
+ m_ec1_pin = 0;
m_pb_save = 0;
m_cb_save = 0;
@@ -114,9 +114,10 @@ void tms2100_cpu_device::device_start()
save_item(NAME(m_ivr));
save_item(NAME(m_dec));
save_item(NAME(m_il));
- save_item(NAME(m_int_pin));
save_item(NAME(m_int_pending));
save_item(NAME(m_r_prev));
+ save_item(NAME(m_int_pin));
+ save_item(NAME(m_ec1_pin));
save_item(NAME(m_pb_save));
save_item(NAME(m_cb_save));
@@ -151,15 +152,30 @@ void tms2100_cpu_device::device_reset()
// interrupt/timer
void tms2100_cpu_device::execute_set_input(int line, int state)
{
- if (line == TMS2100_INPUT_LINE_INT)
+ switch (line)
{
- if (state && !m_int_pin)
- {
- // load decrementer if it's not counting
- if (BIT(m_r, 15) && m_dec == 0xff)
- m_dec = m_ivr;
- }
- m_int_pin = state;
+ case TMS2100_INPUT_LINE_INT:
+ if (state && !m_int_pin)
+ {
+ // load decrementer if it's not counting
+ if (BIT(m_r, 15) && m_dec == 0xff)
+ m_dec = m_ivr;
+ }
+ m_int_pin = state;
+ break;
+
+ case TMS2100_INPUT_LINE_EC1:
+ if (state && !m_ec1_pin)
+ {
+ // clock decrementer if event counter is enabled
+ if (BIT(m_r, 18))
+ clock_decrementer();
+ }
+ m_ec1_pin = state;
+ break;
+
+ default:
+ break;
}
}
diff --git a/src/devices/cpu/tms1000/tms2100.h b/src/devices/cpu/tms1000/tms2100.h
index 7da5a58d1c4..ce0dfd7c568 100644
--- a/src/devices/cpu/tms1000/tms2100.h
+++ b/src/devices/cpu/tms1000/tms2100.h
@@ -15,7 +15,8 @@
enum
{
- TMS2100_INPUT_LINE_INT = 0
+ TMS2100_INPUT_LINE_INT = 0,
+ TMS2100_INPUT_LINE_EC1
};
@@ -79,7 +80,7 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_clock_changed() override { reset_prescaler(); }
- virtual u32 execute_input_lines() const noexcept override { return 1; }
+ virtual u32 execute_input_lines() const noexcept override { return 2; }
virtual void execute_set_input(int line, int state) override;
virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;
@@ -109,9 +110,10 @@ protected:
u8 m_ivr; // 8-bit initial value register
u8 m_dec; // 8-bit decrementer counter
u8 m_il; // interrupt latch(es)
- int m_int_pin; // INT pin state
bool m_int_pending;
u32 m_r_prev;
+ int m_int_pin; // INT pin state
+ int m_ec1_pin; // EC1 pin state
// interrupt stack
u8 m_pb_save;