From 1f23010f44fb3784aade86c9f5b8b003152185ae Mon Sep 17 00:00:00 2001 From: Robbbert Date: Mon, 18 May 2020 00:10:22 +1000 Subject: [PATCH] (nw) junior: added pwm device --- src/mame/drivers/junior.cpp | 166 ++++++++++++++---------------------- src/mame/layout/junior.lay | 12 +-- 2 files changed, 70 insertions(+), 108 deletions(-) diff --git a/src/mame/drivers/junior.cpp b/src/mame/drivers/junior.cpp index bd051e85493..3cd24880620 100644 --- a/src/mame/drivers/junior.cpp +++ b/src/mame/drivers/junior.cpp @@ -5,7 +5,7 @@ Elektor Junior - 17/07/2009 Skeleton driver. +2009-07-17 Skeleton driver. This is heavily based on the KIM-1, the keycodes and operation being identical. @@ -23,12 +23,24 @@ Test Paste: =11^22^33^44^55^66^77^88^99^-0000 Now press up-arrow to confirm the data has been entered. +NMI and IRQ: +- When NMI is activated, it jumps to the vector located at 1A7A. +- When IRQ is activated, it jumps to the vector located at 1A7E. +- The user needs to populate these vectors before use, or the system + will crash when the debugging switches are used. Use RST to escape + from this. + + +To Do: +- Single-Step switch (and associated LED) needs to be hooked up + ****************************************************************************/ #include "emu.h" #include "cpu/m6502/m6502.h" #include "machine/mos6530n.h" #include "machine/timer.h" +#include "video/pwm.h" #include "junior.lh" @@ -39,33 +51,29 @@ public: : driver_device(mconfig, type, tag) , m_riot(*this, "riot") , m_maincpu(*this, "maincpu") - , m_line(*this, "LINE%u", 0U) - , m_digit(*this, "digit%u", 0U) - { - } + , m_display(*this, "display") + , m_io_keyboard(*this, "LINE%u", 0U) + { } DECLARE_INPUT_CHANGED_MEMBER(junior_reset); + DECLARE_INPUT_CHANGED_MEMBER(junior_stop); void junior(machine_config &config); private: - uint8_t junior_riot_a_r(); - uint8_t junior_riot_b_r(); - void junior_riot_a_w(uint8_t data); - void junior_riot_b_w(uint8_t data); + u8 riot_a_r(); + void riot_a_w(u8 data); + void riot_b_w(u8 data); + u8 m_digit; + u8 m_seg; virtual void machine_start() override; - virtual void machine_reset() override; - TIMER_DEVICE_CALLBACK_MEMBER(junior_update_leds); void junior_mem(address_map &map); required_device m_riot; - uint8_t m_port_a; - uint8_t m_port_b; - uint8_t m_led_time[6]; required_device m_maincpu; - required_ioport_array<4> m_line; - output_finder<6> m_digit; + required_device m_display; + required_ioport_array<4> m_io_keyboard; }; @@ -78,7 +86,7 @@ void junior_state::junior_mem(address_map &map) map(0x0000, 0x03ff).ram(); // 1K RAM map(0x1a00, 0x1a7f).m(m_riot, FUNC(mos6532_new_device::ram_map)); map(0x1a80, 0x1a9f).m(m_riot, FUNC(mos6532_new_device::io_map)); - map(0x1c00, 0x1fff).rom(); // Monitor + map(0x1c00, 0x1fff).rom().region("maincpu", 0); // Monitor } @@ -88,6 +96,11 @@ INPUT_CHANGED_MEMBER(junior_state::junior_reset) m_maincpu->reset(); } +INPUT_CHANGED_MEMBER(junior_state::junior_stop) +{ + m_maincpu->set_input_line(INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); +} + /* Input ports */ static INPUT_PORTS_START( junior ) @@ -123,12 +136,14 @@ PORT_START("LINE0") /* IN0 keys row 0 */ PORT_START("LINE3") /* IN3 STEP and RESET keys, MODE switch */ PORT_BIT( 0x80, 0x00, IPT_UNUSED ) - PORT_BIT( 0x40, 0x40, IPT_KEYBOARD ) PORT_NAME("sw1: ST") PORT_CODE(KEYCODE_F7) - PORT_BIT( 0x20, 0x20, IPT_KEYBOARD ) PORT_NAME("sw2: RST") PORT_CODE(KEYCODE_F3) PORT_CHANGED_MEMBER(DEVICE_SELF, junior_state, junior_reset, 0) - PORT_DIPNAME(0x10, 0x10, "sw3: SS (NumLock)") PORT_CODE(KEYCODE_NUMLOCK) PORT_TOGGLE + PORT_BIT( 0x40, 0x40, IPT_KEYBOARD ) PORT_NAME("S1: STOP") PORT_CODE(KEYCODE_F7) PORT_CHANGED_MEMBER(DEVICE_SELF, junior_state, junior_stop, 0) + PORT_BIT( 0x20, 0x20, IPT_KEYBOARD ) PORT_NAME("S2: RST") PORT_CODE(KEYCODE_F3) PORT_CHANGED_MEMBER(DEVICE_SELF, junior_state, junior_reset, 0) + PORT_DIPNAME(0x10, 0x10, "S24: SS (NumLock)") PORT_CODE(KEYCODE_NUMLOCK) PORT_TOGGLE PORT_DIPSETTING( 0x00, "single step") PORT_DIPSETTING( 0x10, "run") - PORT_BIT( 0x08, 0x00, IPT_UNUSED ) + PORT_DIPNAME(0x08, 0x08, "S25: Display") + PORT_DIPSETTING( 0x00, "Off") + PORT_DIPSETTING( 0x08, "On") PORT_BIT( 0x04, 0x00, IPT_UNUSED ) PORT_BIT( 0x02, 0x00, IPT_UNUSED ) PORT_BIT( 0x01, 0x00, IPT_UNUSED ) @@ -136,92 +151,41 @@ INPUT_PORTS_END -uint8_t junior_state::junior_riot_a_r() +u8 junior_state::riot_a_r() { - uint8_t data = 0xff; + u8 data = 0xff; + + if (m_digit < 3) + data &= m_io_keyboard[m_digit]->read(); - uint8_t const sel = ( m_port_b >> 1) & 0x0f; - switch ( sel ) - { - case 0: - case 1: - case 2: - data = m_line[sel]->read(); - break; - } return data; } - -uint8_t junior_state::junior_riot_b_r() +void junior_state::riot_a_w(u8 data) { - if ( m_port_b & 0x20 ) - return 0xFF; - - return 0x7F; - + m_seg = ~data; + if (BIT(m_io_keyboard[3]->read(), 3)) + m_display->matrix(1 << m_digit, m_seg); + else + m_display->matrix(1 << m_digit, 0); } -void junior_state::junior_riot_a_w(uint8_t data) +void junior_state::riot_b_w(u8 data) { - uint8_t idx = ( m_port_b >> 1 ) & 0x0f; - - m_port_a = data; - - if ((idx >= 4 && idx < 10) & ( m_port_a != 0xff )) - { - m_digit[idx - 4] = m_port_a ^ 0x7f; - m_led_time[idx - 4] = 10; - } -} - - -void junior_state::junior_riot_b_w(uint8_t data) -{ - uint8_t idx = ( data >> 1 ) & 0x0f; - - m_port_b = data; - - if ((idx >= 4 && idx < 10) & ( m_port_a != 0xff )) - { - m_digit[idx - 4] = m_port_a ^ 0x7f; - m_led_time[idx - 4] = 10; - } -} - - -TIMER_DEVICE_CALLBACK_MEMBER(junior_state::junior_update_leds) -{ - int i; - - for ( i = 0; i < 6; i++ ) - { - if ( m_led_time[i] ) - m_led_time[i]--; - else - m_digit[i] = 0; - } + m_digit = (data >> 1) & 15; + if (BIT(m_io_keyboard[3]->read(), 3)) + m_display->matrix(1 << m_digit, m_seg); + else + m_display->matrix(1 << m_digit, 0); } void junior_state::machine_start() { - m_digit.resolve(); - - save_item(NAME(m_port_a)); - save_item(NAME(m_port_b)); - save_item(NAME(m_led_time)); -} - - -void junior_state::machine_reset() -{ - int i; - - for ( i = 0; i < 6; i++ ) - m_led_time[i] = 0; + save_item(NAME(m_digit)); + save_item(NAME(m_seg)); } @@ -230,36 +194,34 @@ void junior_state::junior(machine_config &config) /* basic machine hardware */ M6502(config, m_maincpu, 1_MHz_XTAL); m_maincpu->set_addrmap(AS_PROGRAM, &junior_state::junior_mem); - config.set_maximum_quantum(attotime::from_hz(50)); /* video hardware */ config.set_default_layout(layout_junior); + PWM_DISPLAY(config, m_display).set_size(10, 7); + m_display->set_segmask(0x3f0, 0x7f); /* Devices */ MOS6532_NEW(config, m_riot, 1_MHz_XTAL); - m_riot->pa_rd_callback().set(FUNC(junior_state::junior_riot_a_r)); - m_riot->pa_wr_callback().set(FUNC(junior_state::junior_riot_a_w)); - m_riot->pb_rd_callback().set(FUNC(junior_state::junior_riot_b_r)); - m_riot->pb_wr_callback().set(FUNC(junior_state::junior_riot_b_w)); + m_riot->pa_rd_callback().set(FUNC(junior_state::riot_a_r)); + m_riot->pa_wr_callback().set(FUNC(junior_state::riot_a_w)); + m_riot->pb_wr_callback().set(FUNC(junior_state::riot_b_w)); m_riot->irq_wr_callback().set_inputline(m_maincpu, M6502_IRQ_LINE); - - TIMER(config, "led_timer").configure_periodic(FUNC(junior_state::junior_update_leds), attotime::from_hz(50)); } /* ROM definition */ ROM_START( junior ) - ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) + ROM_REGION( 0x0400, "maincpu", 0 ) ROM_DEFAULT_BIOS("orig") ROM_SYSTEM_BIOS( 0, "orig", "Original ESS503" ) - ROMX_LOAD( "ess503.ic2", 0x1c00, 0x0400, CRC(9e804f8c) SHA1(181bdb69fb4711cb008e7966747d4775a5e3ef69), ROM_BIOS(0)) + ROMX_LOAD( "ess503.ic2", 0x0000, 0x0400, CRC(9e804f8c) SHA1(181bdb69fb4711cb008e7966747d4775a5e3ef69), ROM_BIOS(0)) ROM_SYSTEM_BIOS( 1, "mod-orig", "Mod-Original (2708)" ) - ROMX_LOAD( "junior-mod.ic2", 0x1c00, 0x0400, CRC(ee8aa69d) SHA1(a132a51603f1a841c354815e6d868b335ac84364), ROM_BIOS(1)) + ROMX_LOAD( "junior-mod.ic2", 0x0000, 0x0400, CRC(ee8aa69d) SHA1(a132a51603f1a841c354815e6d868b335ac84364), ROM_BIOS(1)) ROM_SYSTEM_BIOS( 2, "2732", "Just monitor (2732)" ) - ROMX_LOAD( "junior27321a.ic2", 0x1c00, 0x0400, CRC(e22f24cc) SHA1(a6edb52a9eea5e99624c128065e748e5a3fb2e4c), ROM_BIOS(2)) + ROMX_LOAD( "junior27321a.ic2", 0x0000, 0x0400, CRC(e22f24cc) SHA1(a6edb52a9eea5e99624c128065e748e5a3fb2e4c), ROM_BIOS(2)) ROM_END /* Driver */ diff --git a/src/mame/layout/junior.lay b/src/mame/layout/junior.lay index d79226e4915..22d3da08a04 100644 --- a/src/mame/layout/junior.lay +++ b/src/mame/layout/junior.lay @@ -23,24 +23,24 @@ license:CC0 - + - + - + - + - + - +