From 597ee86941fefce910161eace22d2ad0f18a7881 Mon Sep 17 00:00:00 2001 From: arbee Date: Wed, 4 Jan 2023 19:11:12 -0500 Subject: apple2video: Created an actual API for video state information so the classes have better separation. [R. Belmont] --- src/mame/apple/apple2.cpp | 14 +++-- src/mame/apple/apple2e.cpp | 109 +++++++++++++++++-------------------- src/mame/apple/apple2gs.cpp | 118 ++++++++++++++++++----------------------- src/mame/apple/apple2video.cpp | 18 +++---- src/mame/apple/apple2video.h | 68 +++++++++++++++++------- src/mame/apple/superga2.cpp | 8 ++- src/mame/apple/tk2000.cpp | 14 +++-- 7 files changed, 175 insertions(+), 174 deletions(-) diff --git a/src/mame/apple/apple2.cpp b/src/mame/apple/apple2.cpp index df8d03ab31e..06795c6e998 100644 --- a/src/mame/apple/apple2.cpp +++ b/src/mame/apple/apple2.cpp @@ -309,10 +309,8 @@ void apple2_state::machine_start() save_item(NAME(m_anykeydown)); // setup video pointers - m_video->m_ram_ptr = m_ram_ptr; - m_video->m_aux_ptr = m_ram_ptr; - m_video->m_char_ptr = memregion("gfx1")->base(); - m_video->m_char_size = memregion("gfx1")->bytes(); + m_video->set_ram_pointers(m_ram_ptr, m_ram_ptr); + m_video->set_char_pointer(memregion("gfx1")->base(), memregion("gfx1")->bytes()); } void apple2_state::machine_reset() @@ -333,7 +331,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2_state::apple2_interrupt) // update the video system's shadow copy of the system config at the end of the frame if (scanline == 192) { - m_video->m_sysconfig = m_sysconfig->read(); + m_video->set_sysconfig(m_sysconfig->read()); // check reset if (m_resetdip.found()) // if reset DIP is present, use it @@ -678,9 +676,9 @@ u8 apple2_state::read_floatingbus() // machine state switches // - Hires = (m_video->m_hires && m_video->m_graphics) ? 1 : 0; - Mixed = m_video->m_mix ? 1 : 0; - Page2 = m_video->m_page2 ? 1 : 0; + Hires = (m_video->get_hires() && m_video->get_graphics()) ? 1 : 0; + Mixed = m_video->get_mix() ? 1 : 0; + Page2 = m_video->get_page2() ? 1 : 0; _80Store = 0; // calculate video parameters according to display standard diff --git a/src/mame/apple/apple2e.cpp b/src/mame/apple/apple2e.cpp index 3632530e79b..d9cefad78dc 100644 --- a/src/mame/apple/apple2e.cpp +++ b/src/mame/apple/apple2e.cpp @@ -422,7 +422,6 @@ private: int m_inh_slot, m_cnxx_slot; - bool m_page2; bool m_an0, m_an1, m_an2, m_an3; bool m_vbl, m_vblmask; @@ -433,7 +432,6 @@ private: int last_mx, last_my, count_x, count_y; bool m_intcxrom; - bool m_80store; bool m_slotc3rom; bool m_altzp; bool m_ramrd, m_ramwrt; @@ -941,11 +939,9 @@ void apple2e_state::machine_start() } // setup video pointers - m_video->m_ram_ptr = m_ram_ptr; - m_video->m_aux_ptr = m_aux_ptr; - m_video->m_aux_mask = m_aux_mask; - m_video->m_char_ptr = memregion("gfx1")->base(); - m_video->m_char_size = memregion("gfx1")->bytes(); + m_video->set_ram_pointers(m_ram_ptr, m_aux_ptr); + m_video->set_aux_mask(m_aux_mask); + m_video->set_char_pointer(memregion("gfx1")->base(), memregion("gfx1")->bytes()); int ram_size = 0x10000; if (m_ram_size < 0x10000) @@ -1011,7 +1007,7 @@ void apple2e_state::machine_start() // remap cec gfx1 rom // for ALTCHARSET - u8 *rom = m_video->m_char_ptr; + u8 *rom = memregion("gfx1")->base(); for(int i=0; i<0x1000; i++) { rom[i+0x1000] = rom[i]; @@ -1051,13 +1047,11 @@ void apple2e_state::machine_start() save_item(NAME(m_inh_slot)); save_item(NAME(m_inh_bank)); save_item(NAME(m_cnxx_slot)); - save_item(NAME(m_page2)); save_item(NAME(m_an0)); save_item(NAME(m_an1)); save_item(NAME(m_an2)); save_item(NAME(m_an3)); save_item(NAME(m_intcxrom)); - save_item(NAME(m_80store)); save_item(NAME(m_slotc3rom)); save_item(NAME(m_altzp)); save_item(NAME(m_ramrd)); @@ -1119,10 +1113,8 @@ void apple2e_state::machine_start() void apple2e_state::machine_reset() { - m_page2 = false; - m_video->m_page2 = false; - m_video->m_monohgr = false; - if(m_iscecm) m_video->m_monohgr = true; + m_video->page2_w(false); + m_video->monohgr_w(m_iscecm); m_an0 = m_an1 = m_an2 = m_an3 = false; m_gameio->an0_w(0); m_gameio->an1_w(0); @@ -1217,8 +1209,7 @@ void apple2e_state::machine_reset() } - m_80store = false; - m_video->m_80store = false; + m_video->a80store_w(false); m_altzp = false; m_ramrd = false; m_ramwrt = false; @@ -1304,7 +1295,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2e_state::apple2_interrupt) m_vbl = true; // update the video system's shadow copy of the system config - m_video->m_sysconfig = m_sysconfig->read(); + m_video->set_sysconfig(m_sysconfig->read()); if (m_vblmask) { @@ -1386,9 +1377,9 @@ void apple2e_state::auxbank_update() m_0000bank.select(m_altzp ? 1 : 0); m_0200bank.select(ramwr); - if (m_80store) + if (m_video->get_80store()) { - if (m_page2) + if (m_video->get_page2()) { m_0400bank.select(3); } @@ -1404,9 +1395,9 @@ void apple2e_state::auxbank_update() m_0800bank.select(ramwr); - if ((m_80store) && (m_video->m_hires)) + if ((m_video->get_80store()) && (m_video->get_hires())) { - if (m_page2) + if (m_video->get_page2()) { m_2000bank.select(3); } @@ -1771,13 +1762,13 @@ void apple2e_state::do_io(int offset, bool is_iic) break; case 0x54: // set page 1 - m_page2 = false; + m_video->page2_w(false); m_video->scr_w(0); auxbank_update(); break; case 0x55: // set page 2 - m_page2 = true; + m_video->page2_w(true); m_video->scr_w(1); auxbank_update(); break; @@ -1918,28 +1909,28 @@ u8 apple2e_state::c000_r(offs_t offset) return (m_slotc3rom ? 0x80 : 0x00) | m_transchar; case 0x18: // read 80STORE - return (m_80store ? 0x80 : 0x00) | m_transchar; + return (m_video->get_80store() ? 0x80 : 0x00) | m_transchar; case 0x19: // read VBLBAR return (m_screen->vblank() ? 0x00 : 0x80) | m_transchar; case 0x1a: // read TEXT - return (m_video->m_graphics ? 0x00 : 0x80) | m_transchar; + return (m_video->get_graphics() ? 0x00 : 0x80) | m_transchar; case 0x1b: // read MIXED - return (m_video->m_mix ? 0x80 : 0x00) | m_transchar; + return (m_video->get_mix() ? 0x80 : 0x00) | m_transchar; case 0x1c: // read PAGE2 - return (m_page2 ? 0x80 : 0x00) | m_transchar; + return (m_video->get_page2() ? 0x80 : 0x00) | m_transchar; case 0x1d: // read HIRES - return (m_video->m_hires ? 0x80 : 0x00) | m_transchar; + return (m_video->get_hires() ? 0x80 : 0x00) | m_transchar; case 0x1e: // read ALTCHARSET - return (m_video->m_altcharset ? 0x80 : 0x00) | m_transchar; + return (m_video->get_altcharset() ? 0x80 : 0x00) | m_transchar; case 0x1f: // read 80COL - return (m_video->m_80col ? 0x80 : 0x00) | m_transchar; + return (m_video->get_80col() ? 0x80 : 0x00) | m_transchar; case 0x26: // Ace 2x00 DIP switches if (m_isace2200) @@ -2002,7 +1993,7 @@ u8 apple2e_state::c000_r(offs_t offset) return (m_ioudis ? 0x00 : 0x80) | uFloatingBus7; case 0x7f: // read DHIRES - return (m_video->m_dhires ? 0x00 : 0x80) | uFloatingBus7; + return (m_video->get_dhires() ? 0x00 : 0x80) | uFloatingBus7; default: do_io(offset, false); @@ -2148,14 +2139,12 @@ void apple2e_state::c000_w(offs_t offset, u8 data) switch (offset) { case 0x00: // 80STOREOFF - m_80store = false; - m_video->m_80store = false; + m_video->a80store_w(false); auxbank_update(); break; case 0x01: // 80STOREON - m_80store = true; - m_video->m_80store = true; + m_video->a80store_w(true); auxbank_update(); break; @@ -2218,19 +2207,19 @@ void apple2e_state::c000_w(offs_t offset, u8 data) break; case 0x0c: // 80COLOFF - m_video->m_80col = false; + m_video->a80col_w(false); break; case 0x0d: // 80COLON - m_video->m_80col = true; + m_video->a80col_w(true); break; case 0x0e: // ALTCHARSETOFF - m_video->m_altcharset = false; + m_video->altcharset_w(false); break; case 0x0f: // ALTCHARSETON - m_video->m_altcharset = true; + m_video->altcharset_w(true); break; case 0x20: // cassette output @@ -2371,28 +2360,28 @@ u8 apple2e_state::c000_iic_r(offs_t offset) return (m_yirq ? 0x80 : 0x00) | m_transchar; case 0x18: // read 80STORE - return (m_80store ? 0x80 : 0x00) | m_transchar; + return (m_video->get_80store() ? 0x80 : 0x00) | m_transchar; case 0x19: // read VBL return (m_vbl ? 0x80 : 0x00) | m_transchar; case 0x1a: // read TEXT - return (m_video->m_graphics ? 0x00 : 0x80) | m_transchar; + return (m_video->get_graphics() ? 0x00 : 0x80) | m_transchar; case 0x1b: // read MIXED - return (m_video->m_mix ? 0x80 : 0x00) | m_transchar; + return (m_video->get_mix() ? 0x80 : 0x00) | m_transchar; case 0x1c: // read PAGE2 - return (m_page2 ? 0x80 : 0x00) | m_transchar; + return (m_video->get_page2() ? 0x80 : 0x00) | m_transchar; case 0x1d: // read HIRES - return (m_video->m_hires ? 0x80 : 0x00) | m_transchar; + return (m_video->get_hires() ? 0x80 : 0x00) | m_transchar; case 0x1e: // read ALTCHARSET - return (m_video->m_altcharset ? 0x80 : 0x00) | m_transchar; + return (m_video->get_altcharset() ? 0x80 : 0x00) | m_transchar; case 0x1f: // read 80COL - return (m_video->m_80col ? 0x80 : 0x00) | m_transchar; + return (m_video->get_80col() ? 0x80 : 0x00) | m_transchar; case 0x40: // read XYMask (IIc only) return m_xy ? 0x80 : 0x00; @@ -2443,7 +2432,7 @@ u8 apple2e_state::c000_iic_r(offs_t offset) return (m_ioudis ? 0x00 : 0x80) | uFloatingBus7; case 0x7f: // read DHIRES - return (m_video->m_dhires ? 0x00 : 0x80) | uFloatingBus7; + return (m_video->get_dhires() ? 0x00 : 0x80) | uFloatingBus7; default: do_io(offset, true); @@ -2470,14 +2459,12 @@ void apple2e_state::c000_iic_w(offs_t offset, u8 data) switch (offset) { case 0x00: // 80STOREOFF - m_80store = false; - m_video->m_80store = false; + m_video->a80store_w(false); auxbank_update(); break; case 0x01: // 80STOREON - m_80store = true; - m_video->m_80store = true; + m_video->a80store_w(true); auxbank_update(); break; @@ -2532,19 +2519,19 @@ void apple2e_state::c000_iic_w(offs_t offset, u8 data) break; case 0x0c: // 80COLOFF - m_video->m_80col = false; + m_video->a80col_w(false); break; case 0x0d: // 80COLON - m_video->m_80col = true; + m_video->a80col_w(true); break; case 0x0e: // ALTCHARSETOFF - m_video->m_altcharset = false; + m_video->altcharset_w(false); break; case 0x0f: // ALTCHARSETON - m_video->m_altcharset = true; + m_video->altcharset_w(true); break; case 0x5a: // IIC+ accelerator unlock @@ -2877,11 +2864,11 @@ void apple2e_state::c080_w(offs_t offset, u8 data) m_cec_bank = data; if (data & 0x10) { - m_video->m_monohgr = false; + m_video->monohgr_w(false); } else { - m_video->m_monohgr = true; + m_video->monohgr_w(true); } auxbank_update(); @@ -3385,10 +3372,10 @@ u8 apple2e_state::read_floatingbus() // machine state switches // - Hires = (m_video->m_hires && m_video->m_graphics) ? 1 : 0; - Mixed = m_video->m_mix ? 1 : 0; - Page2 = m_page2 ? 1 : 0; - _80Store = m_80store ? 1 : 0; + Hires = (m_video->get_hires() && m_video->get_graphics()) ? 1 : 0; + Mixed = m_video->get_mix() ? 1 : 0; + Page2 = m_video->get_page2() ? 1 : 0; + _80Store = m_video->get_80store() ? 1 : 0; // calculate video parameters according to display standard // we call this "PAL", but it's also for SECAM diff --git a/src/mame/apple/apple2gs.cpp b/src/mame/apple/apple2gs.cpp index ffc8e72641f..041a3bb4a82 100644 --- a/src/mame/apple/apple2gs.cpp +++ b/src/mame/apple/apple2gs.cpp @@ -420,7 +420,6 @@ private: bool m_romswitch = false; - bool m_page2 = false; bool m_an0 = false, m_an1 = false, m_an2 = false, m_an3 = false; bool m_vbl = false; @@ -428,7 +427,6 @@ private: int m_irqmask = 0; bool m_intcxrom = false; - bool m_80store = false; bool m_slotc3rom = false; bool m_altzp = false; bool m_ramrd = false, m_ramwrt = false; @@ -437,7 +435,7 @@ private: bool m_rombank = false; u8 m_shadow = 0, m_speed = 0, m_textcol = 0; - u8 m_motors_active = 0, m_slotromsel = 0, m_intflag = 0, m_vgcint = 0, m_inten = 0, m_newvideo = 0; + u8 m_motors_active = 0, m_slotromsel = 0, m_intflag = 0, m_vgcint = 0, m_inten = 0; bool m_last_speed = false; @@ -714,15 +712,13 @@ void apple2gs_state::machine_start() } // setup video pointers - m_video->m_ram_ptr = m_megaii_ram; - m_video->m_aux_ptr = &m_megaii_ram[0x10000]; - m_video->m_char_ptr = memregion("gfx1")->base(); - m_video->m_char_size = memregion("gfx1")->bytes(); - m_video->m_8bit_graphics = std::make_unique(560, 192); + m_video->set_ram_pointers(m_megaii_ram, &m_megaii_ram[0x10000]); + m_video->set_char_pointer(memregion("gfx1")->base(), memregion("gfx1")->bytes()); + m_video->setup_GS_graphics(); m_textcol = 0xf2; - m_video->m_GSfg = (m_textcol >> 4) & 0xf; - m_video->m_GSbg = m_textcol & 0xf; + m_video->set_GS_foreground((m_textcol >> 4) & 0xf); + m_video->set_GS_background(m_textcol & 0xf); m_inh_slot = -1; m_cnxx_slot = CNXX_UNCLAIMED; @@ -743,7 +739,6 @@ void apple2gs_state::machine_start() save_item(NAME(m_inh_slot)); save_item(NAME(m_inh_bank)); save_item(NAME(m_cnxx_slot)); - save_item(NAME(m_page2)); save_item(NAME(m_romswitch)); save_item(NAME(m_an0)); save_item(NAME(m_an1)); @@ -751,7 +746,6 @@ void apple2gs_state::machine_start() save_item(NAME(m_an3)); save_item(NAME(m_intcxrom)); save_item(NAME(m_rombank)); - save_item(NAME(m_80store)); save_item(NAME(m_slotc3rom)); save_item(NAME(m_altzp)); save_item(NAME(m_ramrd)); @@ -803,7 +797,6 @@ void apple2gs_state::machine_start() save_item(NAME(m_accel_temp_slowdown)); save_item(NAME(m_accel_speed)); save_item(NAME(m_motoroff_time)); - save_item(NAME(m_newvideo)); save_item(NAME(m_glu_mouse_first_read)); } @@ -812,12 +805,11 @@ void apple2gs_state::machine_reset() m_adb_p2_last = m_adb_p3_last = 0; m_glu_mouse_first_read = 3; m_adb_reset_freeze = 0; - m_page2 = false; m_romswitch = false; - m_video->m_page2 = false; - m_video->m_GSborder = 0x02; - m_video->m_GSbg = 0x02; - m_video->m_GSfg = 0x0f; + m_video->page2_w(false); + m_video->set_GS_border(0x02); + m_video->set_GS_background(0x02); + m_video->set_GS_foreground(0x0f); m_an0 = m_an1 = m_an2 = m_an3 = false; m_gameio->an0_w(0); m_gameio->an1_w(0); @@ -828,13 +820,12 @@ void apple2gs_state::machine_reset() m_irqmask = 0; m_intcxrom = false; m_rombank = false; - m_80store = false; - m_video->m_80store = false; + m_video->a80store_w(false); m_altzp = false; m_ramrd = false; m_ramwrt = false; m_ioudis = true; - m_newvideo = 0x01; // verified on ROM03 hardware + m_video->set_newvideo(0x01); // verified on ROM03 hardware m_clock_frame = 0; m_slot_irq = false; m_clkdata = 0; @@ -1009,7 +1000,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2gs_state::apple2_interrupt) m_screen->update_partial(scanline); /* check scanline interrupt bits if we're in super hi-res and the current scanline is within the active display area */ - if ((m_video->m_newvideo & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) + if ((m_video->get_newvideo() & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) { u8 scb; const int shrline = scanline - BORDER_TOP + 1; @@ -1050,7 +1041,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2gs_state::apple2_interrupt) } m_adbmicro->set_input_line(0, ASSERT_LINE); - m_video->m_sysconfig = 0; + m_video->set_sysconfig(0); m_clock_frame++; @@ -1123,7 +1114,7 @@ void apple2gs_state::palette_init(palette_device &palette) apple2gs_palette[(3*i)+1]*17, apple2gs_palette[(3*i)+2]*17); - m_video->m_GSborder_colors[i] = rgb_t(apple2gs_palette[(3*i)]*17, apple2gs_palette[(3*i)+1]*17, apple2gs_palette[(3*i)+2]*17); + m_video->set_GS_border_color(i, rgb_t(apple2gs_palette[(3*i)]*17, apple2gs_palette[(3*i)+1]*17, apple2gs_palette[(3*i)+2]*17)); } } @@ -1144,9 +1135,9 @@ void apple2gs_state::auxbank_update() m_b0_0200bank.select(ramwr); m_e0_0200bank.select(ramwr); - if (m_80store) + if (m_video->get_80store()) { - if (m_page2) + if (m_video->get_page2()) { m_b0_0400bank.select(3); m_e0_0400bank.select(3); @@ -1166,9 +1157,9 @@ void apple2gs_state::auxbank_update() m_b0_0800bank.select(ramwr); m_e0_0800bank.select(ramwr); - if ((m_80store) && (m_video->m_hires)) + if ((m_video->get_80store()) && (m_video->get_hires())) { - if (m_page2) + if (m_video->get_page2()) { m_b0_2000bank.select(3); m_e0_2000bank.select(3); @@ -1360,13 +1351,13 @@ void apple2gs_state::do_io(int offset) break; case 0x54: // set page 1 - m_page2 = false; + m_video->page2_w(false); m_video->scr_w(0); auxbank_update(); break; case 0x55: // set page 2 - m_page2 = true; + m_video->page2_w(true); m_video->scr_w(1); auxbank_update(); break; @@ -1558,28 +1549,28 @@ u8 apple2gs_state::c000_r(offs_t offset) return (uKeyboardC010 & 0x7f) | (m_slotc3rom ? 0x80 : 0x00); case 0x18: // read 80STORE - return (uKeyboardC010 & 0x7f) | (m_80store ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_80store() ? 0x80 : 0x00); case 0x19: // read VBLBAR return (uKeyboardC010 & 0x7f) | (m_screen->vblank() ? 0x00 : 0x80); case 0x1a: // read TEXT - return (uKeyboardC010 & 0x7f) | (m_video->m_graphics ? 0x00 : 0x80); + return (uKeyboardC010 & 0x7f) | (m_video->get_graphics() ? 0x00 : 0x80); case 0x1b: // read MIXED - return (uKeyboardC010 & 0x7f) | (m_video->m_mix ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_mix() ? 0x80 : 0x00); case 0x1c: // read PAGE2 - return (uKeyboardC010 & 0x7f) | (m_page2 ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_page2() ? 0x80 : 0x00); case 0x1d: // read HIRES - return (uKeyboardC010 & 0x7f) | (m_video->m_hires ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_hires() ? 0x80 : 0x00); case 0x1e: // read ALTCHARSET - return (uKeyboardC010 & 0x7f) | (m_video->m_altcharset ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_altcharset() ? 0x80 : 0x00); case 0x1f: // read 80COL - return (uKeyboardC010 & 0x7f) | (m_video->m_80col ? 0x80 : 0x00); + return (uKeyboardC010 & 0x7f) | (m_video->get_80col() ? 0x80 : 0x00); case 0x22: // TEXTCOL return m_textcol; @@ -1600,7 +1591,7 @@ u8 apple2gs_state::c000_r(offs_t offset) return keyglu_816_read(GLU_SYSSTAT); case 0x29: // NEWVIDEO - return m_newvideo; + return m_video->get_newvideo(); case 0x2d: // SLOTROMSEL return m_slotromsel; @@ -1631,7 +1622,7 @@ u8 apple2gs_state::c000_r(offs_t offset) return m_clkdata; case 0x34: // BORDERCOL - return (m_clock_control & 0xf0) | (m_video->m_GSborder & 0xf); + return (m_clock_control & 0xf0) | (m_video->get_GS_border() & 0xf); case 0x35: // SHADOW return m_shadow; @@ -1722,7 +1713,7 @@ u8 apple2gs_state::c000_r(offs_t offset) case 0x68: // STATEREG, synthesizes all the IIe state regs return (m_altzp ? 0x80 : 0x00) | - (m_page2 ? 0x40 : 0x00) | + (m_video->get_page2() ? 0x40 : 0x00) | (m_ramrd ? 0x20 : 0x00) | (m_ramwrt ? 0x10 : 0x00) | (m_lcram ? 0x00 : 0x08) | @@ -1820,14 +1811,12 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) switch (offset) { case 0x00: // 80STOREOFF - m_80store = false; - m_video->m_80store = false; + m_video->a80store_w(false); auxbank_update(); break; case 0x01: // 80STOREON - m_80store = true; - m_video->m_80store = true; + m_video->a80store_w(true); auxbank_update(); break; @@ -1882,19 +1871,19 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) break; case 0x0c: // 80COLOFF - m_video->m_80col = false; + m_video->a80col_w(false); break; case 0x0d: // 80COLON - m_video->m_80col = true; + m_video->a80col_w(true); break; case 0x0e: // ALTCHARSETOFF - m_video->m_altcharset = false; + m_video->altcharset_w(false); break; case 0x0f: // ALTCHARSETON - m_video->m_altcharset = true; + m_video->altcharset_w(true); break; case 0x10: // clear keyboard latch @@ -1905,7 +1894,7 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) break; case 0x21: // MONOCHROME - m_video->m_monochrome = data; + m_video->set_GS_monochrome(data); break; case 0x22: // TEXTCOL @@ -1914,8 +1903,8 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) m_screen->update_now(); } m_textcol = data; - m_video->m_GSfg = (data >> 4) & 0xf; - m_video->m_GSbg = data & 0xf; + m_video->set_GS_foreground((data >> 4) & 0xf); + m_video->set_GS_background(data & 0xf); break; case 0x23: // VGCINT @@ -1956,7 +1945,7 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) break; case 0x29: // NEWVIDEO - m_video->m_newvideo = m_newvideo = data; + m_video->set_newvideo(data); break; case 0x2d: // SLOTROMSEL @@ -2002,12 +1991,12 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) break; case 0x34: // CLOCKCTL - if ((data & 0xf) != (m_video->m_GSborder & 0xf)) + if ((data & 0xf) != (m_video->get_GS_border() & 0xf)) { m_screen->update_now(); } m_clock_control = data & 0x7f; - m_video->m_GSborder = data & 0xf; + m_video->set_GS_border(data & 0xf); m_rtc->ce_w(BIT(data, 7) ^ 1); if (data & 0x80) { @@ -2172,7 +2161,7 @@ void apple2gs_state::c000_w(offs_t offset, u8 data) case 0x68: // STATEREG m_altzp = (data & 0x80); - m_page2 = (data & 0x40); + m_video->page2_w(data & 0x40); m_ramrd = (data & 0x20); m_ramwrt = (data & 0x10); m_lcram = (data & 0x08) ? false : true; @@ -2792,10 +2781,10 @@ u8 apple2gs_state::read_floatingbus() // machine state switches // - Hires = (m_video->m_hires && m_video->m_graphics) ? 1 : 0; - Mixed = m_video->m_mix ? 1 : 0; - Page2 = m_page2 ? 1 : 0; - _80Store = m_80store ? 1 : 0; + Hires = (m_video->get_hires() && m_video->get_graphics()) ? 1 : 0; + Mixed = m_video->get_mix() ? 1 : 0; + Page2 = m_video->get_page2() ? 1 : 0; + _80Store = m_video->get_80store() ? 1 : 0; // calculate video parameters according to display standard // @@ -2929,7 +2918,7 @@ template void apple2gs_state::e1ram_w<0x4000>(offs_t offset, u8 data); u8 apple2gs_state::auxram0000_r(offs_t offset) { slow_cycle(); - if ((offset >= 0x2000) && (offset < 0xa000) && ((m_newvideo & 0xc0) != 0)) + if ((offset >= 0x2000) && (offset < 0xa000) && ((m_video->get_newvideo() & 0xc0) != 0)) { if (offset & 1) { @@ -2949,7 +2938,7 @@ void apple2gs_state::auxram0000_w(offs_t offset, u8 data) slow_cycle(); - if ((offset >= 0x2000) && (offset < 0xa000) && ((m_newvideo & 0xc0) != 0)) + if ((offset >= 0x2000) && (offset < 0xa000) && ((m_video->get_newvideo() & 0xc0) != 0)) { if (offset & 1) { @@ -2966,11 +2955,10 @@ void apple2gs_state::auxram0000_w(offs_t offset, u8 data) if ((orig_addr >= 0x9e00) && (orig_addr <= 0x9fff)) { int color = (orig_addr - 0x9e00) >> 1; - - m_video->m_shr_palette[color] = rgb_t( + m_video->set_SHR_color(color, rgb_t( ((m_megaii_ram[0x19f00 + color] >> 0) & 0x0f) * 17, ((m_megaii_ram[0x15f00 + color] >> 4) & 0x0f) * 17, - ((m_megaii_ram[0x15f00 + color] >> 0) & 0x0f) * 17); + ((m_megaii_ram[0x15f00 + color] >> 0) & 0x0f) * 17)); } } @@ -3397,7 +3385,7 @@ void apple2gs_state::adbmicro_p2_out(u8 data) { m_adb_reset_freeze = 2; m_maincpu->reset(); - m_video->m_newvideo = m_newvideo = 0x41; + m_video->set_newvideo(0x41); } if (!(data & 0x10)) diff --git a/src/mame/apple/apple2video.cpp b/src/mame/apple/apple2video.cpp index 6dc49dc1721..f6381302246 100644 --- a/src/mame/apple/apple2video.cpp +++ b/src/mame/apple/apple2video.cpp @@ -451,7 +451,7 @@ void a2_video_device::dlores_update(screen_device &screen, bitmap_ind16 &bitmap, unsigned const color1 = (auxcode >> (y & 4)) & 0x0F; unsigned const color2 = (code >> (y & 4)) & 0x0F; unsigned allbits = (((color1 * 0x111) >> ((col * 14) & 3)) & 0x007f) - + (((color2 * 0x8880) >> ((col * 14) & 3)) & 0x3f80); + + (((color2 * 0x8880) >> ((col * 14) & 3)) & 0x3f80); // Workaround for Github issue #10760: shift everything right by one pixel // (losing the last pixel of each row) so that the NTSC shader sees what @@ -580,14 +580,14 @@ static uint8_t const hgr_color_lut[0x80] = { // wider runs look too wide and make text annoying to read. This table is generated by // [0000]xx1 x[0000]xx [00100]xx x[00100]x [01100]xx x[01100]x [01110]x0 x[01110]x. // static uint8_t const hgr_color_lut[0x80] = { -// 0x00,0x00,0x00,0x00,0x88,0x55,0xCC,0x00,0x11,0x11,0x55,0x55,0x99,0x99,0xDD,0xFF, -// 0x22,0x55,0x55,0x22,0x55,0x55,0x55,0x55,0x33,0x33,0x55,0x77,0xBB,0x55,0xFF,0xFF, -// 0x00,0x00,0x55,0x55,0x55,0x55,0xCC,0xCC,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, -// 0x66,0x66,0x66,0x66,0x55,0x55,0xEE,0xEE,0x77,0x33,0x55,0x55,0xFF,0xFF,0xFF,0xFF, -// 0x00,0x00,0x00,0x00,0x55,0x55,0xCC,0x88,0x11,0x11,0x55,0x55,0x99,0x99,0x99,0x99, -// 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x33,0x33,0x55,0x55,0x55,0x55,0xFF,0xFF, -// 0x00,0x00,0x55,0x44,0x88,0x55,0xCC,0xCC,0x55,0x55,0x55,0x55,0xDD,0x55,0x55,0xDD, -// 0x00,0x22,0x66,0x66,0x55,0x55,0xEE,0xEE,0xFF,0x33,0x55,0x77,0xFF,0xFF,0xFF,0xFF +// 0x00,0x00,0x00,0x00,0x88,0x55,0xCC,0x00,0x11,0x11,0x55,0x55,0x99,0x99,0xDD,0xFF, +// 0x22,0x55,0x55,0x22,0x55,0x55,0x55,0x55,0x33,0x33,0x55,0x77,0xBB,0x55,0xFF,0xFF, +// 0x00,0x00,0x55,0x55,0x55,0x55,0xCC,0xCC,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, +// 0x66,0x66,0x66,0x66,0x55,0x55,0xEE,0xEE,0x77,0x33,0x55,0x55,0xFF,0xFF,0xFF,0xFF, +// 0x00,0x00,0x00,0x00,0x55,0x55,0xCC,0x88,0x11,0x11,0x55,0x55,0x99,0x99,0x99,0x99, +// 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x33,0x33,0x55,0x55,0x55,0x55,0xFF,0xFF, +// 0x00,0x00,0x55,0x44,0x88,0x55,0xCC,0xCC,0x55,0x55,0x55,0x55,0xDD,0x55,0x55,0xDD, +// 0x00,0x22,0x66,0x66,0x55,0x55,0xEE,0xEE,0xFF,0x33,0x55,0x77,0xFF,0xFF,0xFF,0xFF // }; static unsigned decode_hires_byte(uint8_t byte, unsigned last_output_bit) { diff --git a/src/mame/apple/apple2video.h b/src/mame/apple/apple2video.h index 61d7349626b..9d9b7043ce7 100644 --- a/src/mame/apple/apple2video.h +++ b/src/mame/apple/apple2video.h @@ -21,27 +21,9 @@ public: // construction/destruction a2_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - bool m_page2 = false; - bool m_flash = false; - bool m_mix = false; - bool m_graphics = false; - bool m_hires = false; - bool m_dhires = false; - bool m_80col = false; - bool m_altcharset = false; - bool m_an2 = false; - bool m_80store = false; - bool m_monohgr = false; - u8 m_GSfg = 0, m_GSbg = 0, m_GSborder = 0, m_newvideo = 0, m_monochrome = 0, m_rgbmode = 0; u32 m_GSborder_colors[16]{}, m_shr_palette[256]{}; std::unique_ptr m_8bit_graphics; - u8 *m_ram_ptr = nullptr, *m_aux_ptr = nullptr, *m_char_ptr = nullptr; - u16 m_aux_mask = 0xffff; - int m_char_size = 0; - - int m_sysconfig = 0; - DECLARE_WRITE_LINE_MEMBER(txt_w); DECLARE_WRITE_LINE_MEMBER(mix_w); DECLARE_WRITE_LINE_MEMBER(scr_w); @@ -49,9 +31,42 @@ public: DECLARE_WRITE_LINE_MEMBER(dhires_w); DECLARE_WRITE_LINE_MEMBER(an2_w); + const bool get_graphics() { return m_graphics; } + const bool get_hires() { return m_hires; } + const bool get_dhires() { return m_dhires; } + const bool get_page2() { return m_page2; } + const bool get_80col() { return m_80col; } + const bool get_80store() { return m_80store; } + const bool get_mix() { return m_mix; } + const bool get_altcharset() { return m_altcharset; } + const bool get_monohgr() { return m_monohgr; } + + void a80col_w(bool b80Col) { m_80col = b80Col; } + void a80store_w(bool b80Store) { m_80store = b80Store; } + void page2_w(bool page2) { m_page2 = page2; } + void altcharset_w(bool altch) { m_altcharset = altch; } + void monohgr_w(bool mono) { m_monohgr = mono; } + + // IIgs-specific accessors + void set_GS_monochrome(u8 mono) { m_monochrome = mono; } + void set_GS_foreground(u8 fg) { m_GSfg = fg; } + void set_GS_background(u8 bg) { m_GSbg = bg; } + const u8 get_GS_border() { return m_GSborder; } + void set_GS_border(u8 border) { m_GSborder = border; } + const u8 get_newvideo() { return m_newvideo; } + void set_newvideo(u8 newvideo) { m_newvideo = newvideo; } + void set_SHR_color(u8 color, u32 rgb) { m_shr_palette[color] = rgb; } + void set_GS_border_color(u8 color, u32 rgb) { m_GSborder_colors[color] = rgb; } + // Models with different text-mode behavior. II includes the II+ and IIE includes the IIc and IIc Plus. enum class model { II, IIE, IIGS, II_J_PLUS, IVEL_ULTRA }; + void set_ram_pointers(u8 *main, u8 *aux) { m_ram_ptr = main; m_aux_ptr = aux; } + void set_aux_mask(u16 aux_mask) { m_aux_mask = aux_mask; } + void set_char_pointer(u8 *charptr, int size) { m_char_ptr = charptr; m_char_size = size; } + void set_sysconfig(int sysconfig) { m_sysconfig = sysconfig; } + void setup_GS_graphics() { m_8bit_graphics = std::make_unique(560, 192); } + template uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -79,6 +94,23 @@ private: void dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow); bool use_page_2() const; + + u8 *m_ram_ptr = nullptr, *m_aux_ptr = nullptr, *m_char_ptr = nullptr; + u16 m_aux_mask = 0xffff; + int m_char_size = 0; + int m_sysconfig = 0; + bool m_page2 = false; + bool m_flash = false; + bool m_mix = false; + bool m_graphics = false; + bool m_hires = false; + bool m_dhires = false; + bool m_80col = false; + bool m_altcharset = false; + bool m_an2 = false; + bool m_80store = false; + bool m_monohgr = false; + u8 m_GSfg = 0, m_GSbg = 0, m_GSborder = 0, m_newvideo = 0, m_monochrome = 0, m_rgbmode = 0; }; // device type definition diff --git a/src/mame/apple/superga2.cpp b/src/mame/apple/superga2.cpp index a64c35f3015..987c3f6399b 100644 --- a/src/mame/apple/superga2.cpp +++ b/src/mame/apple/superga2.cpp @@ -102,11 +102,9 @@ void superga2_state::machine_start() save_item(NAME(m_speaker_state)); // setup video pointers - m_video->m_ram_ptr = m_ram_ptr; - m_video->m_aux_ptr = m_ram_ptr; - m_video->m_char_ptr = memregion("gfx1")->base(); - m_video->m_char_size = memregion("gfx1")->bytes(); - m_video->m_sysconfig = 0; + m_video->set_ram_pointers(m_ram_ptr, m_ram_ptr); + m_video->set_char_pointer(memregion("gfx1")->base(), memregion("gfx1")->bytes()); + m_video->set_sysconfig(0); } void superga2_state::machine_reset() diff --git a/src/mame/apple/tk2000.cpp b/src/mame/apple/tk2000.cpp index bc4ebf327cb..ca3b791ecae 100644 --- a/src/mame/apple/tk2000.cpp +++ b/src/mame/apple/tk2000.cpp @@ -151,10 +151,8 @@ void tk2000_state::machine_start() save_item(NAME(m_ctrl_key)); // setup video pointers - m_video->m_ram_ptr = m_ram_ptr; - m_video->m_aux_ptr = m_ram_ptr; - m_video->m_char_ptr = nullptr; - m_video->m_char_size = 0; + m_video->set_ram_pointers(m_ram_ptr, m_ram_ptr); + m_video->set_char_pointer(nullptr, 0); // no text modes on this machine } void tk2000_state::machine_reset() @@ -176,7 +174,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(tk2000_state::apple2_interrupt) // update the video system's shadow copy of the system config at the end of the frame if (scanline == 192) { - m_video->m_sysconfig = m_sysconfig->read(); + m_video->set_sysconfig(m_sysconfig->read()); } } @@ -344,9 +342,9 @@ uint8_t tk2000_state::read_floatingbus() // machine state switches // - Hires = 1; //m_video->m_hires ? 1 : 0; - Mixed = 0; //m_video->m_mix ? 1 : 0; - Page2 = m_video->m_page2 ? 1 : 0; + Hires = 1; + Mixed = 0; + Page2 = m_video->get_page2() ? 1 : 0; _80Store = 0; // calculate video parameters according to display standard -- cgit v1.2.3