From 842efa863d7633840def77bb7dd85e5f039e885a Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 18 Sep 2022 00:28:58 +0200 Subject: upd7810: refresh port C on MCC related output changes --- src/devices/cpu/upd7810/upd7810.cpp | 42 +++++++++++++++++------------ src/devices/cpu/upd7810/upd7810.h | 1 + src/devices/cpu/upd7810/upd7810_opcodes.cpp | 6 +++-- src/mame/handheld/gmaster.cpp | 22 +++++++-------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/devices/cpu/upd7810/upd7810.cpp b/src/devices/cpu/upd7810/upd7810.cpp index 37bd57f7ff0..1fe74beca9e 100644 --- a/src/devices/cpu/upd7810/upd7810.cpp +++ b/src/devices/cpu/upd7810/upd7810.cpp @@ -897,6 +897,15 @@ void upd7801_device::upd7810_take_irq() } } +void upd7810_device::upd7810_to_output_change(int state) +{ + TO = state & 1; + m_to_func(TO); + + if (m_mcc & 0x10) + WP(UPD7810_PORTC, m_pc_out); +} + void upd7810_device::upd7810_co0_output_change() { /* Output LV0 Content to CO0 */ @@ -907,6 +916,8 @@ void upd7810_device::upd7810_co0_output_change() LV0 ^= 1; m_co0_func(CO0); + if (m_mcc & 0x40) + WP(UPD7810_PORTC, m_pc_out); } void upd7810_device::upd7810_co1_output_change() { @@ -918,6 +929,8 @@ void upd7810_device::upd7810_co1_output_change() LV1 ^= 1; m_co1_func(CO1); + if (m_mcc & 0x80) + WP(UPD7810_PORTC, m_pc_out); } void upd7810_device::upd7810_write_EOM() @@ -972,6 +985,8 @@ void upd7810_device::upd7810_sio_output() { TXD = m_txs & 1; m_txd_func(TXD); + if (m_mcc & 0x01) + WP(UPD7810_PORTC, m_pc_out); m_txs >>= 1; m_txcnt--; if (0 == m_txcnt) @@ -1267,8 +1282,7 @@ void upd7810_device::upd7810_handle_timer0(int cycles, int clkdiv) /* timer F/F source is timer 0 ? */ if (0x00 == (TMM & 0x03)) { - TO ^= 1; - m_to_func(TO); + upd7810_to_output_change(TO ^ 1); } /* timer 1 chained with timer 0 ? */ if ((TMM & 0xe0) == 0x60) @@ -1281,8 +1295,7 @@ void upd7810_device::upd7810_handle_timer0(int cycles, int clkdiv) /* timer F/F source is timer 1 ? */ if (0x01 == (TMM & 0x03)) { - TO ^= 1; - m_to_func(TO); + upd7810_to_output_change(TO ^ 1); } } } @@ -1304,8 +1317,7 @@ void upd7810_device::upd7810_handle_timer1(int cycles, int clkdiv) /* timer F/F source is timer 1 ? */ if (0x01 == (TMM & 0x03)) { - TO ^= 1; - m_to_func(TO); + upd7810_to_output_change(TO ^ 1); } } } @@ -1360,8 +1372,7 @@ void upd7810_device::handle_timers(int cycles) OVCF += cycles; while (OVCF >= 1) { - TO ^= 1; - m_to_func(TO); + upd7810_to_output_change(TO ^ 1); OVCF -= 1; } } @@ -1526,8 +1537,7 @@ void upd7801_device::handle_timers(int cycles) IRR |= INTFT0; /* Reset the timer flip/fliop */ - TO = 0; - m_to_func(TO); + upd7810_to_output_change(0); /* Reload the timer */ m_ovc0 = 8 * ( TM0 + ( ( TM1 & 0x0f ) << 8 ) ); @@ -1540,16 +1550,14 @@ void upd78c05_device::handle_timers(int cycles) if ( m_ovc0 ) { m_ovc0 -= cycles; - if ( m_ovc0 <= 0 ) { + if ( m_ovc0 <= 0 ) + { IRR |= INTFT0; - if (0x00 == (TMM & 0x03)) { - TO ^= 1; - m_to_func(TO); - } + if (0x00 == (TMM & 0x03)) + upd7810_to_output_change(TO ^ 1); - while ( m_ovc0 <= 0 ) { + while ( m_ovc0 <= 0 ) m_ovc0 += ( ( TMM & 0x04 ) ? 16 * 8 : 8 ) * TM0; - } } } } diff --git a/src/devices/cpu/upd7810/upd7810.h b/src/devices/cpu/upd7810/upd7810.h index cd8377684bc..646a6a1f9fc 100644 --- a/src/devices/cpu/upd7810/upd7810.h +++ b/src/devices/cpu/upd7810/upd7810.h @@ -161,6 +161,7 @@ protected: void upd7810_handle_timer0(int cycles, int clkdiv); void upd7810_handle_timer1(int cycles, int clkdiv); + void upd7810_to_output_change(int state); void upd7810_co0_output_change(); void upd7810_co1_output_change(); diff --git a/src/devices/cpu/upd7810/upd7810_opcodes.cpp b/src/devices/cpu/upd7810/upd7810_opcodes.cpp index 46a7bd78533..7df4a498fdc 100644 --- a/src/devices/cpu/upd7810/upd7810_opcodes.cpp +++ b/src/devices/cpu/upd7810/upd7810_opcodes.cpp @@ -1047,7 +1047,10 @@ void upd7810_device::MOV_MM_A() /* 4d d1: 0100 1101 1101 0001 */ void upd7810_device::MOV_MCC_A() { + if (MCC == A) + return; MCC = A; + WP(UPD7810_PORTC, m_pc_out); } /* 4d d2: 0100 1101 1101 0010 */ @@ -9448,8 +9451,7 @@ void upd7810_device::STM() void upd7810_device::STM_7801() { /* Set the timer flip/flop */ - TO = 1; - m_to_func(TO); + upd7810_to_output_change(1); /* Reload the timer */ m_ovc0 = 16 * ( TM0 + ( ( TM1 & 0x0f ) << 8 ) ); diff --git a/src/mame/handheld/gmaster.cpp b/src/mame/handheld/gmaster.cpp index 907aec23490..69bb98878e5 100644 --- a/src/mame/handheld/gmaster.cpp +++ b/src/mame/handheld/gmaster.cpp @@ -7,7 +7,7 @@ PeT mess@utanet.at march 2002 Hardware notes: - NEC D78C11AGF (4KB internal ROM), 12.00MHz XTAL -- ?KB external RAM, cartridge slot for external ROM +- 2KB external RAM(UM6116-2L), cartridge slot for external ROM - 2*LCDC hiding under epoxy, appears to be SED1520 - 61*64 1bpp LCD screen (the odd width is correct) - 1-bit sound @@ -27,15 +27,9 @@ a copyright by Bon Treasure (a Hong Kong company that's also involved with Watara SuperVision), so perhaps it's them. TODO: -- how much external RAM does it have? 16KB seems overkill and the games - only use a little -- sound off doesn't work (usually the Select button to toggle), speaker is - connected to PC4, but upd7810.cpp doesn't automatically write to port C - on MCC related changes -- related to the note above, writing to PC4 manually when MCC4 is off won't - produce sound, the only game that does this is hspace -- hspace should have some kind of volume filter on the bgm, not sure what - controls it, maybe port B? +- does port B do anything? +- hspace should have some kind of volume filter on the bgm? not sure what + what controls it, or maybe it's a hardware quirk BTANB: - LCD flickers partially, especially bad in finitezn @@ -92,7 +86,7 @@ private: void gmaster_mem(address_map &map); - u8 m_ram[0x4000] = { }; + u8 m_ram[0x800] = { }; u8 m_chipsel = 0; }; @@ -182,7 +176,7 @@ void gmaster_state::io_w(offs_t offset, u8 data) void gmaster_state::gmaster_mem(address_map &map) { // 0x0000-0x0fff is internal ROM - map(0x4000, 0x7fff).rw(FUNC(gmaster_state::io_r), FUNC(gmaster_state::io_w)); + map(0x4000, 0x47ff).mirror(0x3800).rw(FUNC(gmaster_state::io_r), FUNC(gmaster_state::io_w)); map(0x8000, 0xfeff).r("cartslot", FUNC(generic_slot_device::read_rom)); // 0xff00-0xffff is internal RAM } @@ -200,6 +194,9 @@ void gmaster_state::portc_w(u8 data) // d0: RAM CS // d1,d2: LCD CS m_chipsel = data & 7; + + // d4: speaker out + m_speaker->level_w(BIT(data, 4)); } @@ -234,7 +231,6 @@ void gmaster_state::gmaster(machine_config &config) m_maincpu->pa_in_cb().set_ioport("JOY"); m_maincpu->pb_out_cb().set(FUNC(gmaster_state::portb_w)); m_maincpu->pc_out_cb().set(FUNC(gmaster_state::portc_w)); - m_maincpu->to_func().set(m_speaker, FUNC(speaker_sound_device::level_w)); // video hardware SCREEN(config, m_screen, SCREEN_TYPE_LCD); -- cgit v1.2.3