diff options
author | 2023-01-11 16:31:10 -0800 | |
---|---|---|
committer | 2023-01-11 19:31:10 -0500 | |
commit | 9e8064c85eb420e61df7ba56f197877680e642c6 (patch) | |
tree | 7351d2d47a726f126d10eeab1d139751708f1e7b | |
parent | ed0bdc7cf80203609504c0d577ffbf5b4d93beb9 (diff) |
Separate Apple II video config from system config (#10806)
-rw-r--r-- | src/mame/apple/apple2.cpp | 13 | ||||
-rw-r--r-- | src/mame/apple/apple2e.cpp | 113 | ||||
-rw-r--r-- | src/mame/apple/apple2gs.cpp | 1 | ||||
-rw-r--r-- | src/mame/apple/apple2video.cpp | 279 | ||||
-rw-r--r-- | src/mame/apple/apple2video.h | 29 | ||||
-rw-r--r-- | src/mame/apple/superga2.cpp | 1 | ||||
-rw-r--r-- | src/mame/apple/tk2000.cpp | 19 |
7 files changed, 195 insertions, 260 deletions
diff --git a/src/mame/apple/apple2.cpp b/src/mame/apple/apple2.cpp index 06795c6e998..084ab6ed4ea 100644 --- a/src/mame/apple/apple2.cpp +++ b/src/mame/apple/apple2.cpp @@ -100,7 +100,7 @@ public: required_device<timer_device> m_scantimer; required_device<ram_device> m_ram; required_device<ay3600_device> m_ay3600; - required_device<a2_video_device> m_video; + required_device<a2_video_device_composite> m_video; required_device<apple2_common_device> m_a2common; required_device<a2bus_device> m_a2bus; required_device<apple2_gameio_device> m_gameio; @@ -328,11 +328,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2_state::apple2_interrupt) { int scanline = param; - // update the video system's shadow copy of the system config at the end of the frame if (scanline == 192) { - m_video->set_sysconfig(m_sysconfig->read()); - // check reset if (m_resetdip.found()) // if reset DIP is present, use it { @@ -933,12 +930,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2_state::ay3600_repeat) INPUT_PORTS_START( apple2_sysconfig ) PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") - PORT_CONFNAME(0x04, 0x04, "Shift key mod") // default to installed PORT_CONFSETTING(0x00, "Not present") PORT_CONFSETTING(0x04, "Installed") @@ -1110,7 +1101,7 @@ void apple2_state::apple2_common(machine_config &config) m_scantimer->configure_scanline(FUNC(apple2_state::apple2_interrupt), "screen", 0, 1); config.set_maximum_quantum(attotime::from_hz(60)); - APPLE2_VIDEO(config, m_video, XTAL(14'318'181)).set_screen(m_screen); + APPLE2_VIDEO_COMPOSITE(config, m_video, XTAL(14'318'181)).set_screen(m_screen); APPLE2_COMMON(config, m_a2common, XTAL(14'318'181)); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); diff --git a/src/mame/apple/apple2e.cpp b/src/mame/apple/apple2e.cpp index d9cefad78dc..a69b5a799e5 100644 --- a/src/mame/apple/apple2e.cpp +++ b/src/mame/apple/apple2e.cpp @@ -269,7 +269,7 @@ public: optional_ioport m_mouseb, m_mousex, m_mousey; optional_memory_region m_kbdrom; required_ioport m_kbspecial; - required_ioport m_sysconfig; + optional_ioport m_sysconfig; optional_ioport m_franklin_fkeys; required_device<speaker_sound_device> m_speaker; optional_device<cassette_image_device> m_cassette; @@ -531,6 +531,8 @@ private: } offs_t dasm_trampoline(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer ¶ms); + + void apple2e_common(machine_config &config, bool enhanced, bool rgb_option); }; @@ -1149,7 +1151,7 @@ void apple2e_state::machine_reset() m_35sel = false; // is Zip enabled? - if (m_sysconfig->read() & 0x10) + if (m_sysconfig.read_safe(0) & 0x10) { m_accel_present = true; } @@ -1181,7 +1183,7 @@ void apple2e_state::machine_reset() m_isiicplus = false; } - if (((m_sysconfig->read() & 0x30) == 0x30) || (m_isiicplus)) + if (((m_sysconfig.read_safe(0) & 0x30) == 0x30) || (m_isiicplus)) { m_accel_speed = 4000000; // Zip speed accel_full_speed(); @@ -1294,9 +1296,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2e_state::apple2_interrupt) { m_vbl = true; - // update the video system's shadow copy of the system config - m_video->set_sysconfig(m_sysconfig->read()); - if (m_vblmask) { raise_irq(IRQ_VBL); @@ -2231,7 +2230,7 @@ void apple2e_state::c000_w(offs_t offset, u8 data) break; case 0x5a: // Zip accelerator unlock - if (m_sysconfig->read() & 0x10) + if (m_sysconfig.read_safe(0) & 0x10) { if (data == 0x5a) { @@ -3748,15 +3747,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2e_state::ay3600_repeat) INPUT PORTS ***************************************************************************/ -static INPUT_PORTS_START( apple2_sysconfig ) +static INPUT_PORTS_START( apple2_sysconfig_accel ) PORT_START("a2_config") - PORT_CONFNAME(0x07, 0x00, "Monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") - PORT_CONFSETTING(0x04, "Video-7 RGB") - PORT_CONFNAME(0x10, 0x00, "CPU type") PORT_CONFSETTING(0x00, "Standard") PORT_CONFSETTING(0x10, "4 MHz Zip Chip") @@ -3766,23 +3758,8 @@ static INPUT_PORTS_START( apple2_sysconfig ) PORT_CONFSETTING(0x20, "4 MHz") INPUT_PORTS_END -static INPUT_PORTS_START( apple2_sysconfig_no_accel ) - PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") -INPUT_PORTS_END - static INPUT_PORTS_START( laser128_sysconfig ) PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") - PORT_CONFNAME(0x08, 0x00, "Printer type") PORT_CONFSETTING(0x00, "Serial") PORT_CONFSETTING(0x08, "Parallel") @@ -3790,12 +3767,6 @@ INPUT_PORTS_END static INPUT_PORTS_START( apple2c_sysconfig ) PORT_START("a2_config") - PORT_CONFNAME(0x07, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") - PORT_CONFNAME(0x40, 0x40, "40/80 Columns") PORT_CONFSETTING(0x00, "80 columns") PORT_CONFSETTING(0x40, "40 columns") @@ -3813,11 +3784,6 @@ INPUT_PORTS_END static INPUT_PORTS_START( apple2cp_sysconfig ) PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") PORT_CONFNAME(0x04, 0x04, "40/80 Columns") PORT_CONFSETTING(0x00, "80 columns") PORT_CONFSETTING(0x04, "40 columns") @@ -4104,8 +4070,6 @@ static INPUT_PORTS_START( ceci ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - - PORT_INCLUDE( apple2_sysconfig_no_accel ) INPUT_PORTS_END static INPUT_PORTS_START( cecm ) @@ -4217,8 +4181,6 @@ static INPUT_PORTS_START( cecm ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - - PORT_INCLUDE( apple2_sysconfig_no_accel ) INPUT_PORTS_END static INPUT_PORTS_START( zijini ) @@ -4330,14 +4292,12 @@ static INPUT_PORTS_START( zijini ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - - PORT_INCLUDE( apple2_sysconfig_no_accel ) INPUT_PORTS_END static INPUT_PORTS_START( apple2e ) PORT_INCLUDE( apple2e_common ) PORT_INCLUDE( apple2e_special ) - PORT_INCLUDE( apple2_sysconfig ) + PORT_INCLUDE( apple2_sysconfig_accel ) INPUT_PORTS_END static INPUT_PORTS_START( apple2c ) @@ -4382,12 +4342,6 @@ static INPUT_PORTS_START( ace500 ) PORT_INCLUDE( apple2e_common ) PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") - PORT_CONFNAME(0x80, 0x00, "Auto Line Feed for printer") PORT_CONFSETTING(0x80, DEF_STR(On)) PORT_CONFSETTING(0x00, DEF_STR(Off)) @@ -4558,7 +4512,7 @@ static INPUT_PORTS_START( apple2euk ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE(apple2_sysconfig) + PORT_INCLUDE(apple2_sysconfig_accel) INPUT_PORTS_END static INPUT_PORTS_START( apple2ees ) @@ -4679,7 +4633,7 @@ static INPUT_PORTS_START( apple2ees ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE(apple2_sysconfig) + PORT_INCLUDE(apple2_sysconfig_accel) INPUT_PORTS_END static INPUT_PORTS_START( apple2efr ) // French AZERTY keyboard (Apple uses the Belgian AZERTY layout in France also) @@ -4800,7 +4754,7 @@ static INPUT_PORTS_START( apple2efr ) // French AZERTY keyboard (Apple uses th PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE(apple2_sysconfig) + PORT_INCLUDE(apple2_sysconfig_accel) INPUT_PORTS_END INPUT_PORTS_START( apple2ep ) @@ -4921,7 +4875,7 @@ INPUT_PORTS_START( apple2ep ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE(apple2_sysconfig) + PORT_INCLUDE(apple2_sysconfig_accel) INPUT_PORTS_END static void apple2eaux_cards(device_slot_interface &device) @@ -4931,10 +4885,17 @@ static void apple2eaux_cards(device_slot_interface &device) device.option_add("rw3", A2EAUX_RAMWORKS3); // Applied Engineering RamWorks III } -void apple2e_state::apple2e(machine_config &config) +void apple2e_state::apple2e_common(machine_config &config, bool enhanced, bool rgb_option) { /* basic machine hardware */ - M6502(config, m_maincpu, 1021800); + if (enhanced) + { + M65C02(config, m_maincpu, 1021800); + } + else + { + M6502(config, m_maincpu, 1021800); + } m_maincpu->set_addrmap(AS_PROGRAM, &apple2e_state::base_map); m_maincpu->set_dasm_override(FUNC(apple2e_state::dasm_trampoline)); @@ -4943,7 +4904,15 @@ void apple2e_state::apple2e(machine_config &config) TIMER(config, m_acceltimer, 0).configure_generic(FUNC(apple2e_state::accel_timer)); - APPLE2_VIDEO(config, m_video, XTAL(14'318'181)).set_screen(m_screen); + if (rgb_option) + { + APPLE2_VIDEO_COMPOSITE_RGB(config, m_video, XTAL(14'318'181)).set_screen(m_screen); + } + else + { + APPLE2_VIDEO_COMPOSITE(config, m_video, XTAL(14'318'181)).set_screen(m_screen); + } + APPLE2_COMMON(config, m_a2common, XTAL(14'318'181)); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -5007,7 +4976,7 @@ void apple2e_state::apple2e(machine_config &config) /* softlist config for baseline A2E By default, filter lists where possible to compatible disks for A2E */ SOFTWARE_LIST(config, "flop_a2_clean").set_original("apple2_flop_clcracked"); - SOFTWARE_LIST(config, "flop_a2_orig").set_compatible("apple2_flop_orig").set_filter("A2E"); + SOFTWARE_LIST(config, "flop_a2_orig").set_compatible("apple2_flop_orig").set_filter(enhanced ? "A2EE" : "A2E"); SOFTWARE_LIST(config, "flop_a2_misc").set_compatible("apple2_flop_misc"); CASSETTE(config, m_cassette); @@ -5015,6 +4984,11 @@ void apple2e_state::apple2e(machine_config &config) m_cassette->add_route(ALL_OUTPUTS, "mono", 0.05); } +void apple2e_state::apple2e(machine_config &config) +{ + apple2e_common(config, false, true); +} + void apple2e_state::apple2epal(machine_config &config) { apple2e(config); @@ -5033,12 +5007,7 @@ void apple2e_state::mprof3(machine_config &config) void apple2e_state::apple2ee(machine_config &config) { - apple2e(config); - subdevice<software_list_device>("flop_a2_orig")->set_filter("A2EE"); // Filter list to compatible disks for this machine. - - M65C02(config.replace(), m_maincpu, 1021800); - m_maincpu->set_addrmap(AS_PROGRAM, &apple2e_state::base_map); - m_maincpu->set_dasm_override(FUNC(apple2e_state::dasm_trampoline)); + apple2e_common(config, true, true); } void apple2e_state::apple2eepal(machine_config &config) @@ -5082,7 +5051,7 @@ void apple2e_state::apple2ep(machine_config &config) void apple2e_state::apple2c(machine_config &config) { - apple2ee(config); + apple2e_common(config, true, false); subdevice<software_list_device>("flop_a2_orig")->set_filter("A2C"); // Filter list to compatible disks for this machine. M65C02(config.replace(), m_maincpu, 1021800); @@ -5284,7 +5253,7 @@ void apple2e_state::laser128ex2(machine_config &config) void apple2e_state::ace500(machine_config &config) { - apple2ee(config); + apple2e_common(config, true, false); subdevice<software_list_device>("flop_a2_orig")->set_filter("A2C"); // Filter list to compatible disks for this machine. M65C02(config.replace(), m_maincpu, 1021800); @@ -5328,7 +5297,7 @@ void apple2e_state::ace500(machine_config &config) void apple2e_state::ace2200(machine_config &config) { - apple2e(config); + apple2e_common(config, false, false); M65C02(config.replace(), m_maincpu, 1021800); m_maincpu->set_addrmap(AS_PROGRAM, &apple2e_state::ace2200_map); m_maincpu->set_dasm_override(FUNC(apple2e_state::dasm_trampoline)); @@ -5361,7 +5330,7 @@ void apple2e_state::ace2200(machine_config &config) void apple2e_state::cec(machine_config &config) { - apple2e(config); + apple2e_common(config, false, false); config.device_remove("sl3"); config.device_remove("sl6"); diff --git a/src/mame/apple/apple2gs.cpp b/src/mame/apple/apple2gs.cpp index 498e5a7364a..ef0fb8724cc 100644 --- a/src/mame/apple/apple2gs.cpp +++ b/src/mame/apple/apple2gs.cpp @@ -1038,7 +1038,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2gs_state::apple2_interrupt) } m_adbmicro->set_input_line(0, ASSERT_LINE); - m_video->set_sysconfig(0); m_clock_frame++; diff --git a/src/mame/apple/apple2video.cpp b/src/mame/apple/apple2video.cpp index 531c5c6edc1..5032fd853cb 100644 --- a/src/mame/apple/apple2video.cpp +++ b/src/mame/apple/apple2video.cpp @@ -34,17 +34,27 @@ #define WHITE 15 DEFINE_DEVICE_TYPE(APPLE2_VIDEO, a2_video_device, "a2video", "Apple II video") +DEFINE_DEVICE_TYPE(APPLE2_VIDEO_COMPOSITE, a2_video_device_composite, "a2video_comp", "Apple II video (composite)") +DEFINE_DEVICE_TYPE(APPLE2_VIDEO_COMPOSITE_RGB, a2_video_device_composite_rgb, "a2video_comprgb", "Apple II video (composite/RGB)") //------------------------------------------------- // a2_video_device - constructor //------------------------------------------------- -a2_video_device::a2_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, APPLE2_VIDEO, tag, owner, clock) +a2_video_device::a2_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) , device_palette_interface(mconfig, *this) , device_video_interface(mconfig, *this) -{ -} + , m_vidconfig(*this, "a2_video_config") {} + +a2_video_device::a2_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : a2_video_device(mconfig, APPLE2_VIDEO, tag, owner, clock) {} + +a2_video_device_composite::a2_video_device_composite(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : a2_video_device(mconfig, APPLE2_VIDEO_COMPOSITE, tag, owner, clock) {} + +a2_video_device_composite_rgb::a2_video_device_composite_rgb(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : a2_video_device(mconfig, APPLE2_VIDEO_COMPOSITE_RGB, tag, owner, clock) {} void a2_video_device::device_start() { @@ -82,7 +92,6 @@ void a2_video_device::device_reset() m_dhires = false; m_flash = false; m_mix = false; - m_sysconfig = 0; m_an2 = false; m_80store = false; m_monohgr = false; @@ -148,6 +157,22 @@ static inline unsigned rotl4b(unsigned n, unsigned count) { return (n >> (-count // 4-bit left rotate. Bits 4-6 of n must be zero. static inline unsigned rotl4(unsigned n, unsigned count) { return rotl4b(n * 0x11, count); } +inline bool a2_video_device::use_page_2() const { return m_page2 && !m_80store; } + +inline bool a2_video_device::monochrome_monitor() { return (m_vidconfig.read_safe(0) & 4) != 0; } + +inline bool a2_video_device::rgb_monitor() { return (m_vidconfig.read_safe(0) & 7) == 3; } + +int a2_video_device::monochrome_hue() +{ + switch (m_vidconfig.read_safe(0) & 7) + { + case 5: return GREEN; + case 6: return ORANGE; + default: return WHITE; + } +} + // This table implements a colorization scheme defined by one's complement and mirror symmetries // and the following rules: // @@ -272,20 +297,12 @@ void a2_video_device::plot_text_character(bitmap_ind16 &bitmap, int xpos, int yp } } -inline bool a2_video_device::use_page_2() const { return m_page2 && !m_80store; } - void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow) { uint32_t const start_address = use_page_2() ? 0x0800 : 0x0400; - int fg = 0; - switch (m_sysconfig & 0x03) - { - case 0: case 4: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } + bool const monochrome = monochrome_monitor(); + int const fg = monochrome_hue(); /* perform adjustments */ beginrow = (std::max)(beginrow, cliprect.top()); @@ -297,7 +314,7 @@ void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap, //printf("GR: row %d startcol %d stopcol %d left %d right %d\n", beginrow, startcol, stopcol, cliprect.left(), cliprect.right()); - if (!(m_sysconfig & 0x03)) // color + if (!monochrome) { for (int row = startrow; row <= stoprow; row += 8) { @@ -394,15 +411,9 @@ void a2_video_device::dlores_update(screen_device &screen, bitmap_ind16 &bitmap, { uint32_t const start_address = use_page_2() ? 0x0800 : 0x0400; static const int aux_colors[16] = { 0, 2, 4, 6, 8, 0xa, 0xc, 0xe, 1, 3, 5, 7, 9, 0xb, 0xd, 0xf }; - int fg = 0; - switch (m_sysconfig & 0x03) - { - case 0: case 4: fg = WHITE; break; - case 1: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } + bool const monochrome = monochrome_monitor(); + int const fg = monochrome_hue(); /* perform adjustments */ beginrow = (std::max)(beginrow, cliprect.top() - (cliprect.top() % 8)); @@ -413,7 +424,7 @@ void a2_video_device::dlores_update(screen_device &screen, bitmap_ind16 &bitmap, const int startcol = (cliprect.left() / 14); const int stopcol = ((cliprect.right() / 14) + 1); - if (!(m_sysconfig & 0x03)) + if (!monochrome) { for (int row = startrow; row <= stoprow; row += 8) { @@ -537,22 +548,8 @@ void a2_video_device::text_update(screen_device &screen, bitmap_ind16 &bitmap, c // printf("TXT: row %d startcol %d stopcol %d left %d right %d\n", beginrow, startcol, stopcol, cliprect.left(), cliprect.right()); - int fg, bg; - if (Model == model::IIGS) - { - fg = m_GSfg; - bg = m_GSbg; - } - else - { - switch (m_sysconfig & 0x03) - { - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - default: fg = WHITE; break; - } - bg = 0; - } + int fg = (Model == model::IIGS) ? m_GSfg : monochrome_hue(); + int bg = (Model == model::IIGS) ? m_GSbg : BLACK; for (int row = startrow; row < stoprow; row += 8) { @@ -573,7 +570,7 @@ void a2_video_device::text_update(screen_device &screen, bitmap_ind16 &bitmap, c { /* calculate address */ uint32_t const address = start_address + ((((row / 8) & 0x07) << 7) | (((row / 8) & 0x18) * 5 + col)); - if ((Model == model::II || Model == model::IIE) && (m_sysconfig & 7) == 4 && m_dhires) + if (Model == model::IIE && rgb_monitor() && m_dhires) { u8 tmp = aux_page[address]; fg = tmp >> 4; @@ -623,30 +620,12 @@ void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, co if (endrow < beginrow) return; - int mon_type = m_sysconfig & 0x03; - - // CEC mono HGR mode - if ((m_monohgr) && (mon_type == 0)) - { - mon_type = 1; - } - - // IIgs $C021 monochrome HGR - if (m_monochrome & 0x80) - { - mon_type = 1; - } + // B&W/Green/Amber monitor, CEC mono HGR mode, or IIgs $C021 monochrome HGR + bool const monochrome = monochrome_monitor() || m_monohgr || (m_monochrome & 0x80); - int fg; + int const fg = monochrome_hue(); int const bg = BLACK; - switch (mon_type) - { - default: fg = WHITE; break; - case 2: fg = GREEN; break; - case 3: fg = ORANGE; break; - } - uint8_t const *const vram = &m_ram_ptr[use_page_2() ? 0x4000 : 0x2000]; // verified on h/w: setting dhires w/o 80col emulates a rev. 0 Apple ][ with no orange/blue @@ -669,9 +648,8 @@ void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, co w |= decode_hires_byte(vram_row[col + 1] & bit7_mask, w >> (3 + 13)) << (3 + 14); } - switch (mon_type) + if (!monochrome) { - case 0: for (int b = 0; b < 14; b++) { if (((col * 14 + b) >= cliprect.left()) && ((col * 14 + b) <= cliprect.right())) @@ -680,9 +658,9 @@ void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, co } p++; } - break; - - default: // 1, 2, 3 + } + else + { for (int b = 0; b < 14; b++) { if (((col * 14 + b) >= cliprect.left()) && ((col * 14 + b) <= cliprect.right())) @@ -691,7 +669,6 @@ void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, co } p++; } - break; } } } @@ -701,20 +678,11 @@ void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, c { uint16_t v; int const page = use_page_2() ? 0x4000 : 0x2000; - int mon_type = m_sysconfig & 7; - bool const bIsRGB160 = (mon_type == 4 && m_rgbmode == 2); - - // IIgs force-monochrome-DHR setting - if (m_newvideo & 0x20) - { - mon_type = 1; - } + int const rgbmode = rgb_monitor() ? m_rgbmode : -1; - // IIe RGB card monochrome DHR - if (mon_type == 4 && m_rgbmode == 0) - { - mon_type = 1; - } + // B&W/Green/Amber monitor, IIgs force-monochrome-DHR setting, or IIe RGB card monochrome DHR + bool const monochrome = monochrome_monitor() || (m_newvideo & 0x20) || rgbmode == 0; + int const fg = monochrome_hue(); /* sanity checks */ if (beginrow < cliprect.top()) @@ -742,11 +710,12 @@ void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, c uint16_t *p = &bitmap.pix(row); - if (bIsRGB160) + if (rgbmode == 2) { - // RGB 160-wide mode (which has a much simpler VRAM layout). + // Video-7 RGB 160-wide mode (which has a much simpler VRAM layout). // Center a 480-wide image in the 560-wide display. // Aspect ratio won't be perfect, but it's in range. + for (int b = 0; b < 40; b++) { *p++ = BLACK; @@ -776,85 +745,61 @@ void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, c | (((uint32_t) vram_row[col+1] & 0x7f) << 7) | (((uint32_t) vram_row[col+2] & 0x7f) << 14); - switch (mon_type) + if (monochrome) { - case 0: - for (int b = 0; b < 7; b++) - { - *p++ = rotl4((w >> (b + 7-1)) & 0x0F, col * 7 + b); - } - break; - - case 1: - // Shifting by 6 instead of 7 here shifts the entire DHGR screen right one pixel, so the leftmost pixel is - // always black and the rightmost pixel is not shown. This is to work around a problem with the HLSL NTSC - // shader. See Github issues #6308 and #10759. This should be changed when there is a better solution. - w >>= 6; - for (int b = 0; b < 7; b++) - { - v = (w & 1); - w >>= 1; - *(p++) = v ? WHITE : BLACK; - } - break; - - case 2: - // See case 1 - w >>= 6; + // Shifting by 6 instead of 7 here shifts the entire DHGR screen right one pixel, so the leftmost pixel is + // always black and the rightmost pixel is not shown. This is to work around a problem with the HLSL NTSC + // shader. See Github issues #6308 and #10759. This should be changed when there is a better solution. + w >>= 6; + for (int b = 0; b < 7; b++) + { + v = (w & 1); + w >>= 1; + *(p++) = v ? fg : BLACK; + } + } + else if (rgbmode < 0) + { + for (int b = 0; b < 7; b++) + { + *p++ = rotl4((w >> (b + 7-1)) & 0x0F, col * 7 + b); + } + } + else + { + // Video-7 RGB with rgbmode == 1 (mixed) or 3 (color). In color mode, the card + // seems to produce just 7 wide pixels per 4 bytes: + // column & 3 = 0 1 2 3 + // nBBBAAAA nDDCCCCB nFEEEEDD nGGGGFFF + // + // In mixed mode, the Video-7 User's Manual says: + // + // "When [the MSB is 0] the hardware displays the remaining seven bits as bit-mapped + // video; a logic 'one' will instruct the hardware to display the next seven bits + // as color pixels. [...] color aberrations will occur at the leading and trailing + // edges of the transitions from one mode to the other. The aberrations may be + // eliminated by blanking enough bytes at the beginning and end of each transition + // to guarantee the four bit integrity of the corresponding color pixels." + // + // It's impossible to know the nature of the aberrations without hardware to test, + // but hopefully this warning means software was designed so that it doesn't matter. + + if (rgbmode == 1 && !(vram_row[col+1] & 0x80)) // monochrome + { for (int b = 0; b < 7; b++) { - v = (w & 1); - w >>= 1; - *(p++) = v ? GREEN : BLACK; + *p++ = ((w >> (b + 7)) & 1) ? WHITE : BLACK; } - break; - - case 3: - // See case 1 - w >>= 6; + } + else // color + { + // In column 0 get the color from w bits 7-10 or 11-14, + // in column 1 get the color from w bits 4-7 or 8-11, etc. for (int b = 0; b < 7; b++) { - v = (w & 1); - w >>= 1; - *(p++) = v ? ORANGE : BLACK; + *p++ = rotl4((w >> (b - ((b - col) & 3) + 7)) & 0x0F, 1); } - break; - - case 4: - // Video-7 RGB with m_rgbmode == 1 (mixed) or 3 (color). In color mode, the card - // seems to produce just 7 wide pixels per 4 bytes: - // column & 3 = 0 1 2 3 - // nBBBAAAA nDDCCCCB nFEEEEDD nGGGGFFF - // - // In mixed mode, the Video-7 User's Manual says: - // - // "When [the MSB is 0] the hardware displays the remaining seven bits as bit-mapped - // video; a logic 'one' will instruct the hardware to display the next seven bits - // as color pixels. [...] color aberrations will occur at the leading and trailing - // edges of the transitions from one mode to the other. The aberrations may be - // eliminated by blanking enough bytes at the beginning and end of each transition - // to guarantee the four bit integrity of the corresponding color pixels." - // - // It's impossible to know the nature of the aberrations without hardware to test, - // but hopefully this warning means software was designed so that it doesn't matter. - - if (m_rgbmode == 1 && !(vram_row[col+1] & 0x80)) // monochrome - { - for (int b = 0; b < 7; b++) - { - *p++ = ((w >> (b + 7)) & 1) ? WHITE : BLACK; - } - } - else // color - { - // In column 0 get the color from w bits 7-10 or 11-14, - // in column 1 get the color from w bits 4-7 or 8-11, etc. - for (int b = 0; b < 7; b++) - { - *p++ = rotl4((w >> (b - ((b - col) & 3) + 7)) & 0x0F, 1); - } - } - break; + } } } } @@ -1123,3 +1068,25 @@ template uint32_t a2_video_device::screen_update<a2_video_device::model::IIE, fa template uint32_t a2_video_device::screen_update<a2_video_device::model::IIGS, false, false>(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); template uint32_t a2_video_device::screen_update<a2_video_device::model::II_J_PLUS, true, true>(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); template uint32_t a2_video_device::screen_update<a2_video_device::model::IVEL_ULTRA, true, false>(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + +static INPUT_PORTS_START( a2_vidconfig_composite ); + PORT_START("a2_video_config") + PORT_CONFNAME(0x07, 0x00, "Monitor type") + PORT_CONFSETTING(0x00, "Color") + PORT_CONFSETTING(0x04, "B&W") + PORT_CONFSETTING(0x05, "Green") + PORT_CONFSETTING(0x06, "Amber") +INPUT_PORTS_END + +static INPUT_PORTS_START( a2_vidconfig_composite_rgb ) + PORT_START("a2_video_config") + PORT_CONFNAME(0x07, 0x00, "Monitor type") + PORT_CONFSETTING(0x00, "Color") + PORT_CONFSETTING(0x04, "B&W") + PORT_CONFSETTING(0x05, "Green") + PORT_CONFSETTING(0x06, "Amber") + PORT_CONFSETTING(0x03, "Video-7 RGB") +INPUT_PORTS_END + +ioport_constructor a2_video_device_composite::device_input_ports() const { return INPUT_PORTS_NAME(a2_vidconfig_composite); } +ioport_constructor a2_video_device_composite_rgb::device_input_ports() const { return INPUT_PORTS_NAME(a2_vidconfig_composite_rgb); } diff --git a/src/mame/apple/apple2video.h b/src/mame/apple/apple2video.h index 1a272f232bc..48104596129 100644 --- a/src/mame/apple/apple2video.h +++ b/src/mame/apple/apple2video.h @@ -64,7 +64,6 @@ public: 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<bitmap_ind16>(560, 192); } template <model Model, bool Invert, bool Flip> @@ -73,6 +72,8 @@ public: uint32_t screen_update_GS(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); protected: + a2_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); + virtual void device_reset() override; virtual void device_start() override; @@ -93,10 +94,13 @@ private: bool use_page_2() const; + bool monochrome_monitor(); + bool rgb_monitor(); + int monochrome_hue(); + 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; @@ -109,9 +113,30 @@ private: 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; + optional_ioport m_vidconfig; +}; + +// a2_video_device with composite monitor dip switch settings +class a2_video_device_composite : public a2_video_device +{ +public: + a2_video_device_composite(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +protected: + virtual ioport_constructor device_input_ports() const override; +}; + +// a2_video_device with composite settings plus Video-7 RGB card option +class a2_video_device_composite_rgb : public a2_video_device +{ +public: + a2_video_device_composite_rgb(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +protected: + virtual ioport_constructor device_input_ports() const override; }; // device type definition DECLARE_DEVICE_TYPE(APPLE2_VIDEO, a2_video_device) +DECLARE_DEVICE_TYPE(APPLE2_VIDEO_COMPOSITE, a2_video_device_composite) +DECLARE_DEVICE_TYPE(APPLE2_VIDEO_COMPOSITE_RGB, a2_video_device_composite_rgb) #endif // MAME_SHARED_APPLE2VIDEO_H diff --git a/src/mame/apple/superga2.cpp b/src/mame/apple/superga2.cpp index 538ac5eacc1..60b839e3efb 100644 --- a/src/mame/apple/superga2.cpp +++ b/src/mame/apple/superga2.cpp @@ -102,7 +102,6 @@ void superga2_state::machine_start() // setup video pointers m_video->set_ram_pointers(m_ram_ptr, m_ram_ptr); m_video->set_char_pointer(nullptr, 0); // no text modes on this machine - 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 fe9c5704b58..d803786dccf 100644 --- a/src/mame/apple/tk2000.cpp +++ b/src/mame/apple/tk2000.cpp @@ -58,7 +58,6 @@ public: m_video(*this, A2_VIDEO_TAG), m_row(*this, "ROW%u", 0U), m_kbspecial(*this, "keyb_special"), - m_sysconfig(*this, "a2_config"), m_speaker(*this, A2_SPEAKER_TAG), m_cassette(*this, A2_CASSETTE_TAG), m_upperbank(*this, A2_UPPERBANK_TAG), @@ -76,10 +75,9 @@ private: required_device<cpu_device> m_maincpu; required_device<ram_device> m_ram; required_device<screen_device> m_screen; - required_device<a2_video_device> m_video; + required_device<a2_video_device_composite> m_video; required_ioport_array<8> m_row; required_ioport m_kbspecial; - required_ioport m_sysconfig; required_device<speaker_sound_device> m_speaker; required_device<cassette_image_device> m_cassette; required_device<address_map_bank_device> m_upperbank; @@ -168,12 +166,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(tk2000_state::apple2_interrupt) if((scanline % 8) == 0) m_screen->update_partial(m_screen->vpos()); - - // update the video system's shadow copy of the system config at the end of the frame - if (scanline == 192) - { - m_video->set_sysconfig(m_sysconfig->read()); - } } /*************************************************************************** @@ -561,13 +553,6 @@ static INPUT_PORTS_START( tk2000 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED) - - PORT_START("a2_config") - PORT_CONFNAME(0x03, 0x00, "Composite monitor type") - PORT_CONFSETTING(0x00, "Color") - PORT_CONFSETTING(0x01, "B&W") - PORT_CONFSETTING(0x02, "Green") - PORT_CONFSETTING(0x03, "Amber") INPUT_PORTS_END void tk2000_state::tk2000(machine_config &config) @@ -579,7 +564,7 @@ void tk2000_state::tk2000(machine_config &config) TIMER(config, "scantimer").configure_scanline(FUNC(tk2000_state::apple2_interrupt), "screen", 0, 1); config.set_maximum_quantum(attotime::from_hz(60)); - APPLE2_VIDEO(config, m_video, XTAL(14'318'181)).set_screen(m_screen); + APPLE2_VIDEO_COMPOSITE(config, m_video, XTAL(14'318'181)).set_screen(m_screen); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); |