diff options
| author | 2026-02-10 04:46:10 +1100 | |
|---|---|---|
| committer | 2026-02-10 04:48:14 +1100 | |
| commit | d24b0cf898d1759c746593af1c9d461705c5d6a8 (patch) | |
| tree | 1b014540fbdba0f96aec5365511ab0b3d2d8df24 | |
| parent | 1237812788d17c0afbfe8eba9b7bf8af77b1460e (diff) | |
fujitsu/fmtowns.cpp: Better serial IRQ handling.
Also cleanup.
| -rw-r--r-- | src/mame/fujitsu/fmtowns.cpp | 68 | ||||
| -rw-r--r-- | src/mame/fujitsu/fmtowns.h | 69 | ||||
| -rw-r--r-- | src/mame/ibm/ptpc110.cpp | 4 | ||||
| -rw-r--r-- | src/mame/nokia/mikromikko2.cpp | 2 | ||||
| -rw-r--r-- | src/mame/nokia/mikromikko2.h | 12 | ||||
| -rw-r--r-- | src/mame/nokia/mm2kb.cpp | 6 | ||||
| -rw-r--r-- | src/mame/nokia/mm2kb.h | 9 |
7 files changed, 100 insertions, 70 deletions
diff --git a/src/mame/fujitsu/fmtowns.cpp b/src/mame/fujitsu/fmtowns.cpp index a0c47faa9f5..b41f6b3fccd 100644 --- a/src/mame/fujitsu/fmtowns.cpp +++ b/src/mame/fujitsu/fmtowns.cpp @@ -244,6 +244,7 @@ Notes: #define LOG_SYS (1U << 1) #define LOG_CD (1U << 2) #define LOG_CD_UNKNOWN (1U << 3) +#define LOG_IRQ (1U << 4) #define VERBOSE (LOG_GENERAL | LOG_CD_UNKNOWN) #include "logmacro.h" @@ -494,7 +495,7 @@ void towns_state::mb8877a_irq_w(int state) if(m_towns_fdc_irq6mask == 0) state = 0; m_pic_master->ir6_w(state); // IRQ6 = FDC - if(IRQ_LOG) logerror("PIC: IRQ6 (FDC) set to %i\n",state); + LOGMASKED(LOG_IRQ,"PIC: IRQ6 (FDC) set to %i\n",state); } void towns_state::mb8877a_drq_w(int state) @@ -695,7 +696,7 @@ void towns_state::kb_sendcode(uint8_t scancode, int release) if(m_towns_kb_irq1_enable) { m_pic_master->ir1_w(1); - if(IRQ_LOG) logerror("PIC: IRQ1 (keyboard) set high\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ1 (keyboard) set high\n"); } //logerror("KB: sending scancode 0x%02x\n",scancode); } @@ -731,7 +732,7 @@ uint8_t towns_state::towns_keyboard_r(offs_t offset) ret = m_towns_kb_output; //logerror("KB: read keyboard output port, returning %02x\n",ret); m_pic_master->ir1_w(0); - if(IRQ_LOG) logerror("PIC: IRQ1 (keyboard) set low\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ1 (keyboard) set low\n"); if(m_towns_kb_extend != 0xff) { kb_sendcode(m_towns_kb_extend,2); @@ -876,7 +877,7 @@ uint8_t towns_state::towns_sound_ctrl_r(offs_t offset) if(m_towns_fm_irq_flag == 0) { m_pic_slave->ir5_w(0); - if(IRQ_LOG) logerror("PIC: IRQ13 (PCM) set low\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ13 (PCM) set low\n"); } break; // default: @@ -1101,7 +1102,7 @@ void towns_state::towns_cdrom_set_irq(int line,int state) { m_towns_cd.status |= 0x80; m_pic_slave->ir1_w(1); - if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM) set high\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ9 (CD-ROM) set high\n"); } } else @@ -1111,7 +1112,7 @@ void towns_state::towns_cdrom_set_irq(int line,int state) { m_towns_cd.status &= ~0x80; m_pic_slave->ir1_w(0); - if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM) set low\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ9 (CD-ROM) set low\n"); } break; case TOWNS_CD_IRQ_DMA: @@ -1123,7 +1124,7 @@ void towns_state::towns_cdrom_set_irq(int line,int state) { m_towns_cd.status |= 0x40; m_pic_slave->ir1_w(1); - if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM DMA) set high\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ9 (CD-ROM DMA) set high\n"); } } else @@ -1133,7 +1134,7 @@ void towns_state::towns_cdrom_set_irq(int line,int state) { m_towns_cd.status &= ~0x40; m_pic_slave->ir1_w(0); - if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM DMA) set low\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ9 (CD-ROM DMA) set low\n"); } break; } @@ -1761,8 +1762,7 @@ void towns_state::rtc_busy_w(int state) void towns_state::towns_scsi_irq(int state) { m_pic_slave->ir0_w(state); - if(IRQ_LOG) - logerror("PIC: IRQ8 (SCSI) set to %i\n",state); + LOGMASKED(LOG_IRQ,"PIC: IRQ8 (SCSI) set to %i\n",state); } void towns_state::towns_scsi_drq(int state) @@ -1849,7 +1849,7 @@ void towns_state::towns_fm_irq(int state) { m_towns_fm_irq_flag = 1; m_pic_slave->ir5_w(1); - if(IRQ_LOG) logerror("PIC: IRQ13 (FM) set high\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ13 (FM) set high\n"); } else { @@ -1857,7 +1857,7 @@ void towns_state::towns_fm_irq(int state) if(m_towns_pcm_irq_flag == 0) { m_pic_slave->ir5_w(0); - if(IRQ_LOG) logerror("PIC: IRQ13 (FM) set low\n"); + LOGMASKED(LOG_IRQ,"PIC: IRQ13 (FM) set low\n"); } } } @@ -1870,7 +1870,7 @@ RF5C68_SAMPLE_END_CB_MEMBER(towns_state::towns_pcm_irq) m_towns_pcm_irq_flag = 1; m_towns_pcm_channel_flag |= (1 << channel); m_pic_slave->ir5_w(1); - if(IRQ_LOG) logerror("PIC: IRQ13 (PCM) set high (channel %i)\n",channel); + LOGMASKED(LOG_IRQ,"PIC: IRQ13 (PCM) set high (channel %i)\n",channel); } } @@ -1881,7 +1881,7 @@ void towns_state::towns_pit_out0_changed(int state) if(m_towns_timer_mask & 0x01) { m_timer0 = state; - if(IRQ_LOG) logerror("PIC: IRQ0 (PIT Timer ch0) set to %i\n",state); + LOGMASKED(LOG_IRQ,"PIC: IRQ0 (PIT Timer ch0) set to %i\n",state); } else m_timer0 = 0; @@ -1896,7 +1896,7 @@ void towns_state::towns_pit_out1_changed(int state) if(m_towns_timer_mask & 0x02) { m_timer1 = state; - if(IRQ_LOG) logerror("PIC: IRQ0 (PIT Timer ch1) set to %i\n",state); + LOGMASKED(LOG_IRQ,"PIC: IRQ0 (PIT Timer ch1) set to %i\n",state); } else m_timer1 = 0; @@ -1926,6 +1926,7 @@ void towns_state::towns_serial_w(offs_t offset, uint8_t data) break; case 4: m_serial_irq_enable = data; + // TODO: should this trigger a previously masked serial IRQ, or drop a newly masked one? break; default: logerror("Invalid or unimplemented serial port write [offset=%02x, data=%02x]\n",offset,data); @@ -1949,27 +1950,45 @@ uint8_t towns_state::towns_serial_r(offs_t offset) void towns_state::towns_serial_irq(int state) { - m_serial_irq_source = state ? 0x01 : 0x00; - m_pic_master->ir2_w(state); - popmessage("Serial IRQ state: %i\n",state); + if((state ? 0x01 : 0x00) != m_serial_irq_source) + { + m_serial_irq_source = state ? 0x01 : 0x00; + m_pic_master->ir2_w(state); + popmessage("Serial IRQ state: %i\n",state); + } } void towns_state::towns_rxrdy_irq(int state) { + if(state) + m_serial_irq_state |= RXRDY_IRQ_ENABLE; + else + m_serial_irq_enable &= ~RXRDY_IRQ_ENABLE; + if(m_serial_irq_enable & RXRDY_IRQ_ENABLE) - towns_serial_irq(state); + towns_serial_irq((m_serial_irq_enable & m_serial_irq_state) ? 1 : 0); } void towns_state::towns_txrdy_irq(int state) { + if(state) + m_serial_irq_state |= TXRDY_IRQ_ENABLE; + else + m_serial_irq_enable &= ~TXRDY_IRQ_ENABLE; + if(m_serial_irq_enable & TXRDY_IRQ_ENABLE) - towns_serial_irq(state); + towns_serial_irq((m_serial_irq_enable & m_serial_irq_state) ? 1 : 0); } void towns_state::towns_syndet_irq(int state) { + if(state) + m_serial_irq_state |= SYNDET_IRQ_ENABLE; + else + m_serial_irq_enable &= ~SYNDET_IRQ_ENABLE; + if(m_serial_irq_enable & SYNDET_IRQ_ENABLE) - towns_serial_irq(state); + towns_serial_irq((m_serial_irq_enable & m_serial_irq_state) ? 1 : 0); } @@ -2409,7 +2428,11 @@ void towns_state::driver_start() save_item(NAME(m_pit_out0)); save_item(NAME(m_pit_out1)); save_item(NAME(m_pit_out2)); + save_item(NAME(m_timer0)); + save_item(NAME(m_timer1)); save_item(NAME(m_serial_irq_source)); + save_item(NAME(m_serial_irq_enable)); + save_item(NAME(m_serial_irq_state)); save_item(NAME(m_kb_prev)); save_item(NAME(m_prev_pad_mask)); @@ -2499,7 +2522,9 @@ void towns_state::machine_start() m_timer0 = 0; m_timer1 = 0; + m_serial_irq_source = 0; m_serial_irq_enable = 0; + m_serial_irq_state = 0; } void towns_state::machine_reset() @@ -2523,7 +2548,6 @@ void towns_state::machine_reset() m_intervaltimer2_irqmask = 1; // masked m_towns_kb_timer->adjust(attotime::zero,0,attotime::from_msec(10)); m_towns_freerun_counter->adjust(attotime::zero,0,attotime::from_usec(1)); - m_serial_irq_source = 0; m_rtc_d = 0; m_rtc_busy = false; m_vram_mask_addr = 0; diff --git a/src/mame/fujitsu/fmtowns.h b/src/mame/fujitsu/fmtowns.h index f498c467bf8..f17cca5c00f 100644 --- a/src/mame/fujitsu/fmtowns.h +++ b/src/mame/fujitsu/fmtowns.h @@ -36,8 +36,6 @@ #include "formats/fmtowns_dsk.h" -#define IRQ_LOG 0 // set to 1 to log IRQ line activity - struct towns_cdrom_controller { uint8_t command = 0; @@ -129,18 +127,26 @@ public: , m_serial(*this,"serial") { } - void towns_base(machine_config &config); - void towns(machine_config &config); - void townsftv(machine_config &config); - void townshr(machine_config &config); - void townsmx(machine_config &config); - void townssj(machine_config &config); + void towns(machine_config &config) ATTR_COLD; + void townsftv(machine_config &config) ATTR_COLD; + void townshr(machine_config &config) ATTR_COLD; + void townsmx(machine_config &config) ATTR_COLD; + void townssj(machine_config &config) ATTR_COLD; INTERRUPT_GEN_MEMBER(towns_vsync_irq); protected: uint16_t m_towns_machine_id; // default is 0x0101 + required_device<ram_device> m_ram; + required_device<cpu_device> m_maincpu; + + required_device_array<upd71071_device, 2> m_dma; + optional_device<fmscsi_device> m_scsi; + required_device_array<floppy_connector, 2> m_flop; + + required_device_array<msx_general_purpose_port_device, 2U> m_pad_ports; + void marty_mem(address_map &map) ATTR_COLD; void pcm_mem(address_map &map) ATTR_COLD; void towns16_io(address_map &map) ATTR_COLD; @@ -151,19 +157,12 @@ protected: void towns_mem(address_map &map) ATTR_COLD; void ux_mem(address_map &map) ATTR_COLD; - virtual void driver_start() override; + virtual void driver_start() override ATTR_COLD; virtual void machine_start() override ATTR_COLD; virtual void machine_reset() override ATTR_COLD; virtual void video_start() override ATTR_COLD; - required_device<ram_device> m_ram; - required_device<cpu_device> m_maincpu; - - required_device_array<upd71071_device, 2> m_dma; - optional_device<fmscsi_device> m_scsi; - required_device_array<floppy_connector, 2> m_flop; - - required_device_array<msx_general_purpose_port_device, 2U> m_pad_ports; + void towns_base(machine_config &config) ATTR_COLD; static void floppy_formats(format_registration &fr); @@ -194,6 +193,13 @@ private: required_memory_bank m_bank_f8000_r; required_memory_bank m_bank_f8000_w; + optional_shared_ptr<uint32_t> m_nvram; + optional_shared_ptr<uint16_t> m_nvram16; + + required_ioport_array<4> m_kb_ports; + required_memory_region m_user; + optional_memory_region m_serial; + uint16_t m_ftimer = 0; uint16_t m_freerun_timer = 0; emu_timer* m_towns_freerun_counter = nullptr; @@ -243,8 +249,9 @@ private: uint8_t m_serial_irq_source = 0; uint8_t m_serial_irq_enable = 0; // RS232 interrupt control + uint8_t m_serial_irq_state = 0; - enum + enum : uint8_t { TXC_EXTERNAL = 0x80, RXC_EXTERNAL = 0x40, @@ -268,8 +275,10 @@ private: uint8_t m_prev_x = 0; uint8_t m_prev_y = 0; - optional_shared_ptr<uint32_t> m_nvram; - optional_shared_ptr<uint16_t> m_nvram16; + u8 m_rtc_d = 0; + bool m_rtc_busy = false; + u8 m_vram_mask[4]{}; + u8 m_vram_mask_addr = 0; uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -362,10 +371,6 @@ private: uint8_t towns_cdrom_read_byte_software(); void cdda_db_to_gain(float db); - required_ioport_array<4> m_kb_ports; - required_memory_region m_user; - optional_memory_region m_serial; - TIMER_CALLBACK_MEMBER(freerun_inc); TIMER_CALLBACK_MEMBER(intervaltimer2_timeout); TIMER_CALLBACK_MEMBER(poll_keyboard); @@ -378,11 +383,6 @@ private: TIMER_CALLBACK_MEMBER(towns_delay_cdda); TIMER_CALLBACK_MEMBER(towns_delay_seek); - u8 m_rtc_d = 0; - bool m_rtc_busy = false; - u8 m_vram_mask[4]{}; - u8 m_vram_mask_addr = 0; - TIMER_CALLBACK_MEMBER(towns_cdrom_read_byte); TIMER_CALLBACK_MEMBER(towns_vblank_end); TIMER_CALLBACK_MEMBER(draw_sprites); @@ -415,24 +415,25 @@ private: class towns16_state : public towns_state { - public: +public: towns16_state(const machine_config &mconfig, device_type type, const char *tag) : towns_state(mconfig, type, tag) { } - void townsux(machine_config &config); + + void townsux(machine_config &config) ATTR_COLD; }; class marty_state : public towns_state { - public: +public: marty_state(const machine_config &mconfig, device_type type, const char *tag) : towns_state(mconfig, type, tag) { } - void marty(machine_config &config); + void marty(machine_config &config) ATTR_COLD; protected: - virtual void driver_start() override; + virtual void driver_start() override ATTR_COLD; }; #endif // MAME_FUJITSU_FMTOWNS_H diff --git a/src/mame/ibm/ptpc110.cpp b/src/mame/ibm/ptpc110.cpp index a223381cb1a..5136ef5da8a 100644 --- a/src/mame/ibm/ptpc110.cpp +++ b/src/mame/ibm/ptpc110.cpp @@ -37,6 +37,8 @@ Components: #include "screen.h" +namespace { + class ptpc110_state : public driver_device { public: @@ -98,6 +100,6 @@ ROM_START( ptpc110 ) ROM_LOAD( "pc110-flash.bin", 0, 0x40000, CRC(d68bb7a4) SHA1(b5c075842b60accae06bc78ddbf6454d9127de4f) ) ROM_END +} // anonymous namespace COMP( 1995, ptpc110, 0, 0, ptpc110, 0, ptpc110_state, empty_init, "International Business Machines", "Palm Top PC-110 (Japan)", MACHINE_NOT_WORKING | MACHINE_NO_SOUND ) - diff --git a/src/mame/nokia/mikromikko2.cpp b/src/mame/nokia/mikromikko2.cpp index b4bcbdf0d02..a3c2f0e9a3c 100644 --- a/src/mame/nokia/mikromikko2.cpp +++ b/src/mame/nokia/mikromikko2.cpp @@ -428,7 +428,7 @@ void mm2_state::mm2(machine_config &config) m_sio->txrdy_handler().set(FUNC(mm2_state::sio_txrdy_w)); m_sio->txd_handler().set(m_kb, FUNC(mm2_keyboard_device::rxd_w)); - MM2_KEYBOARD(config, m_kb, 0); + NOKIA_MM2_KBD(config, m_kb, 0); m_kb->txd_handler().set(m_sio, FUNC(i8251_device::write_rxd)); // MMC186 diff --git a/src/mame/nokia/mikromikko2.h b/src/mame/nokia/mikromikko2.h index 8773cf24290..094de17b4a8 100644 --- a/src/mame/nokia/mikromikko2.h +++ b/src/mame/nokia/mikromikko2.h @@ -5,10 +5,8 @@ #pragma once -#include "emupal.h" -#include "screen.h" -#include "speaker.h" #include "mm2kb.h" + #include "bus/nscsi/devices.h" #include "bus/rs232/rs232.h" #include "bus/scsi/s1410.h" @@ -21,15 +19,19 @@ #include "machine/nscsi_bus.h" #include "machine/nscsi_cb.h" #include "machine/nvram.h" -#include "machine/pit8253.h" #include "machine/pic8259.h" +#include "machine/pit8253.h" #include "machine/upd765.h" -#include "machine/z80sio.h" #include "machine/x2212.h" +#include "machine/z80sio.h" #include "sound/spkrdev.h" #include "video/crt9007.h" #include "video/crt9212.h" +#include "emupal.h" +#include "screen.h" +#include "speaker.h" + #define I80186_TAG "maincpu" #define UPD765_TAG "upd765" #define SCREEN_TAG "screen" diff --git a/src/mame/nokia/mm2kb.cpp b/src/mame/nokia/mm2kb.cpp index cde75a58e92..991698eec1e 100644 --- a/src/mame/nokia/mm2kb.cpp +++ b/src/mame/nokia/mm2kb.cpp @@ -9,7 +9,7 @@ #include "emu.h" #include "mm2kb.h" -DEFINE_DEVICE_TYPE(MM2_KEYBOARD, mm2_keyboard_device, "mm2_keyboard", "MikroMikko 2 Keyboard") +DEFINE_DEVICE_TYPE(NOKIA_MM2_KBD, mm2_keyboard_device, "nokia_mm2_kbd", "MikroMikko 2 Keyboard") ROM_START( mm2_keyboard ) ROM_REGION( 0x400, "keyboard", 0 ) @@ -34,7 +34,7 @@ ioport_constructor mm2_keyboard_device::device_input_ports() const } mm2_keyboard_device::mm2_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, MM2_KEYBOARD, tag, owner, clock), + device_t(mconfig, NOKIA_MM2_KBD, tag, owner, clock), m_write_txd(*this) { } @@ -45,5 +45,5 @@ void mm2_keyboard_device::device_start() void mm2_keyboard_device::device_reset() { - m_write_txd(1); + m_write_txd(1); } diff --git a/src/mame/nokia/mm2kb.h b/src/mame/nokia/mm2kb.h index e04ca48413f..2c38559cd98 100644 --- a/src/mame/nokia/mm2kb.h +++ b/src/mame/nokia/mm2kb.h @@ -11,7 +11,7 @@ #pragma once -DECLARE_DEVICE_TYPE(MM2_KEYBOARD, mm2_keyboard_device) +DECLARE_DEVICE_TYPE(NOKIA_MM2_KBD, mm2_keyboard_device) class mm2_keyboard_device : public device_t { @@ -20,14 +20,15 @@ public: mm2_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); auto txd_handler() { return m_write_txd.bind(); } - void rxd_w(int state) { } - + + void rxd_w(int state) { } + protected: virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual ioport_constructor device_input_ports() const override ATTR_COLD; - virtual void device_start() override ATTR_COLD; + virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; private: |
