From afdd20022d6dc1d317301e280feed8bf16a72720 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 1 May 2026 14:00:45 -0400 Subject: [PATCH] Normalise `last_valid` to `get`. --- ClockReceiver/JustInTime.hpp | 6 ++--- Machines/Apple/AppleIIgs/AppleIIgs.cpp | 30 ++++++++++----------- Machines/Atari/ST/AtariST.cpp | 20 +++++++------- Machines/ColecoVision/ColecoVision.cpp | 8 +++--- Machines/Enterprise/Enterprise.cpp | 18 ++++++------- Machines/MSX/MSX.cpp | 8 +++--- Machines/MasterSystem/MasterSystem.cpp | 12 ++++----- Machines/Oric/Oric.cpp | 10 +++---- Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp | 16 +++++------ Machines/Thomson/MO/MO.cpp | 6 ++--- 10 files changed, 67 insertions(+), 67 deletions(-) diff --git a/ClockReceiver/JustInTime.hpp b/ClockReceiver/JustInTime.hpp index 160c12c60..47d1f5db1 100644 --- a/ClockReceiver/JustInTime.hpp +++ b/ClockReceiver/JustInTime.hpp @@ -150,12 +150,12 @@ public: } /// @returns a pointer to the included object, without flushing time. - [[nodiscard]] forceinline T *last_valid() { + [[nodiscard]] forceinline T *get() { return &object_; } /// @returns a const pointer to the included object, without flushing time. - [[nodiscard]] forceinline const T *last_valid() const { + [[nodiscard]] forceinline const T *get() const { return &object_; } @@ -322,7 +322,7 @@ public: } /// Returns a pointer to the included object without flushing time. - inline T *last_valid() { + inline T *get() { return &object_; } diff --git a/Machines/Apple/AppleIIgs/AppleIIgs.cpp b/Machines/Apple/AppleIIgs/AppleIIgs.cpp index 4aede116c..ce6c798de 100644 --- a/Machines/Apple/AppleIIgs/AppleIIgs.cpp +++ b/Machines/Apple/AppleIIgs/AppleIIgs.cpp @@ -231,11 +231,11 @@ public: } void set_scan_target(Outputs::Display::ScanTarget *target) override { - video_.last_valid()->set_scan_target(target); + video_.get()->set_scan_target(target); } Outputs::Display::ScanStatus get_scaled_scan_status() const override { - return video_.last_valid()->get_scaled_scan_status() * 2.0f; // TODO: expose multiplier and divider via the JustInTime template? + return video_.get()->get_scaled_scan_status() * 2.0f; // TODO: expose multiplier and divider via the JustInTime template? } void set_display_type(Outputs::Display::DisplayType display_type) final { @@ -342,7 +342,7 @@ public: // Clock and border control. case Read(0xc034): - *value = (clock_.get_control() & 0xf0) | (video_.last_valid()->get_border_colour() & 0x0f); + *value = (clock_.get_control() & 0xf0) | (video_.get()->get_border_colour() & 0x0f); break; case Write(0xc034): clock_.set_control(*value); @@ -354,7 +354,7 @@ public: video_->set_text_colour(*value); break; case Read(0xc022): - *value = video_.last_valid()->get_text_colour(); + *value = video_.get()->get_text_colour(); break; // Speed register. @@ -394,7 +394,7 @@ public: #define SwitchRead(s) *value = memory_.s ? 0x80 : 0x00; is_1Mhz = true; #define LanguageRead(s) SwitchRead(language_card_switches().state().s) #define AuxiliaryRead(s) SwitchRead(auxiliary_switches().switches().s) -#define VideoRead(s) *value = video_.last_valid()->s ? 0x80 : 0x00; is_1Mhz = true; +#define VideoRead(s) *value = video_.get()->s ? 0x80 : 0x00; is_1Mhz = true; case Read(0xc011): LanguageRead(bank2); break; case Read(0xc012): LanguageRead(read); break; case Read(0xc013): AuxiliaryRead(read_auxiliary_memory); break; @@ -590,18 +590,18 @@ public: // Monochome/colour register. case Read(0xc021): // "Uses bit 7 to determine whether composite output is colour 9) or gray scale (1)." - *value = video_.last_valid()->get_composite_is_colour() ? 0x00 : 0x80; + *value = video_.get()->get_composite_is_colour() ? 0x00 : 0x80; break; case Write(0xc021): video_->set_composite_is_colour(!(*value & 0x80)); break; case Read(0xc02e): - *value = video_.last_valid()->get_vertical_counter(video_.time_since_flush()); + *value = video_.get()->get_vertical_counter(video_.time_since_flush()); is_1Mhz = true; break; case Read(0xc02f): - *value = video_.last_valid()->get_horizontal_counter(video_.time_since_flush()); + *value = video_.get()->get_horizontal_counter(video_.time_since_flush()); is_1Mhz = true; break; @@ -876,7 +876,7 @@ public: auto ticks = cycles_since_clock_tick_.divide(CLOCK_RATE).get(); while(ticks--) { clock_.update(); - video_.last_valid()->notify_clock_tick(); // The video controller marshalls the one-second interrupt. + video_.get()->notify_clock_tick(); // The video controller marshalls the one-second interrupt. // TODO: I think I may have made a false assumption here; does // the VGC have an independent 1-second interrupt? update_interrupts(); @@ -894,8 +894,8 @@ public: if(video_.did_flush()) { update_interrupts(); - const bool is_vertical_blank = video_.last_valid()->get_is_vertical_blank(video_.time_since_flush()); - if(is_vertical_blank != adb_glu_.last_valid()->get_vertical_blank()) { + const bool is_vertical_blank = video_.get()->get_is_vertical_blank(video_.time_since_flush()); + if(is_vertical_blank != adb_glu_.get()->get_vertical_blank()) { adb_glu_->set_vertical_blank(is_vertical_blank); } } @@ -908,7 +908,7 @@ public: void update_interrupts() { // Update the interrupt line. // TODO: add ADB controller as event source. - m65816_.set_irq_line(video_.last_valid()->get_interrupt_line() || sound_glu_.get_interrupt_line()); + m65816_.set_irq_line(video_.get()->get_interrupt_line() || sound_glu_.get_interrupt_line()); } // MARK: - Input. @@ -917,15 +917,15 @@ public: } void set_key_state(uint16_t key, bool is_pressed) final { - adb_glu_.last_valid()->keyboard().set_key_pressed(Apple::ADB::Key(key), is_pressed); + adb_glu_.get()->keyboard().set_key_pressed(Apple::ADB::Key(key), is_pressed); } void clear_all_keys() final { - adb_glu_.last_valid()->keyboard().clear_all_keys(); + adb_glu_.get()->keyboard().clear_all_keys(); } Inputs::Mouse &get_mouse() final { - return adb_glu_.last_valid()->get_mouse(); + return adb_glu_.get()->get_mouse(); } const std::vector> &get_joysticks() final { diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index 7fbde34e8..7402fe5f0 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -149,19 +149,19 @@ public: // MARK: CRTMachine::Machine void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - video_.last_valid()->set_scan_target(scan_target); + video_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return video_.last_valid()->get_scaled_scan_status(); + return video_.get()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - video_.last_valid()->set_display_type(display_type); + video_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return video_.last_valid()->get_display_type(); + return video_.get()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final { @@ -550,11 +550,11 @@ private: // This is being called by one of the components; avoid any time flushing here as that's // already dealt with (and, just to be absolutely sure, to avoid recursive mania). may_defer_acias_ = - (keyboard_acia_.last_valid()->preferred_clocking() != ClockingHint::Preference::RealTime) && - (midi_acia_.last_valid()->preferred_clocking() != ClockingHint::Preference::RealTime); + (keyboard_acia_.get()->preferred_clocking() != ClockingHint::Preference::RealTime) && + (midi_acia_.get()->preferred_clocking() != ClockingHint::Preference::RealTime); keyboard_needs_clock_ = ikbd_.preferred_clocking() != ClockingHint::Preference::None; - mfp_is_realtime_ = mfp_.last_valid()->preferred_clocking() == ClockingHint::Preference::RealTime; - dma_clocking_preference_ = dma_.last_valid()->preferred_clocking(); + mfp_is_realtime_ = mfp_.get()->preferred_clocking() == ClockingHint::Preference::RealTime; + dma_clocking_preference_ = dma_.get()->preferred_clocking(); } // MARK: - GPIP input. @@ -606,8 +606,8 @@ private: void update_interrupt_input() { // Complete guess: set video interrupts pending if/when hsync of vsync // go inactive. Reset upon IACK. - const bool hsync = video_.last_valid()->hsync(); - const bool vsync = video_.last_valid()->vsync(); + const bool hsync = video_.get()->hsync(); + const bool vsync = video_.get()->vsync(); if(previous_hsync_ != hsync && previous_hsync_) { video_interrupts_pending_ |= 2; } diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index b745fbbb6..3170a413b 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -176,19 +176,19 @@ public: } void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - vdp_.last_valid()->set_scan_target(scan_target); + vdp_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return vdp_.last_valid()->get_scaled_scan_status(); + return vdp_.get()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - vdp_.last_valid()->set_display_type(display_type); + vdp_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return vdp_.last_valid()->get_display_type(); + return vdp_.get()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final { diff --git a/Machines/Enterprise/Enterprise.cpp b/Machines/Enterprise/Enterprise.cpp index 057443d2c..fff2e3e96 100644 --- a/Machines/Enterprise/Enterprise.cpp +++ b/Machines/Enterprise/Enterprise.cpp @@ -291,7 +291,7 @@ public: // MARK: - Z80::BusHandler. forceinline void advance_nick(const HalfCycles duration) { if(nick_ += duration) { - const auto nick = nick_.last_valid(); + const auto nick = nick_.get(); const bool nick_interrupt_line = nick->get_interrupt_line(); if(nick_interrupt_line && !previous_nick_interrupt_line_) { set_interrupts(uint8_t(Dave::Interrupt::Nick), nick_.last_sequence_point_overrun()); @@ -333,7 +333,7 @@ public: // Query Nick for the amount of delay that would occur with one cycle left // in this read opcode. const auto delay_time = nick_.time_since_flush(HalfCycles(2)); - const auto delay = nick_.last_valid()->get_time_until_z80_slot(delay_time); + const auto delay = nick_.get()->get_time_until_z80_slot(delay_time); penalty = nick_.back_map(delay, delay_time); } else if(wait_mode_ != WaitMode::None) { penalty = dave_delay_; @@ -354,7 +354,7 @@ public: // Get delay, in Nick cycles, for a Z80 access that occurs in 0.5 // cycles from now (i.e. with one cycle left to run). const auto delay_time = nick_.time_since_flush(HalfCycles(1)); - const auto delay = nick_.last_valid()->get_time_until_z80_slot(delay_time); + const auto delay = nick_.get()->get_time_until_z80_slot(delay_time); penalty = nick_.back_map(delay, delay_time); } break; @@ -365,7 +365,7 @@ public: // Get delay, in Nick cycles, for a Z80 access that occurs in 0.5 // cycles from now (i.e. with one cycle left to run). const auto delay_time = nick_.time_since_flush(HalfCycles(1)); - const auto delay = nick_.last_valid()->get_time_until_z80_slot(delay_time); + const auto delay = nick_.get()->get_time_until_z80_slot(delay_time); penalty = nick_.back_map(delay, delay_time); } } @@ -375,7 +375,7 @@ public: time_since_audio_update_ += full_length; advance_nick(full_length); if(dave_timer_ += full_length) { - set_interrupts(dave_timer_.last_valid()->get_new_interrupts(), dave_timer_.last_sequence_point_overrun()); + set_interrupts(dave_timer_.get()->get_new_interrupts(), dave_timer_.last_sequence_point_overrun()); } // The WD/etc runs at a nominal 8Mhz. @@ -725,19 +725,19 @@ private: // MARK: - ScanProducer void set_scan_target(Outputs::Display::ScanTarget *const scan_target) override { - nick_.last_valid()->set_scan_target(scan_target); + nick_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const override { - return nick_.last_valid()->get_scaled_scan_status(); + return nick_.get()->get_scaled_scan_status(); } void set_display_type(const Outputs::Display::DisplayType display_type) final { - nick_.last_valid()->set_display_type(display_type); + nick_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return nick_.last_valid()->get_display_type(); + return nick_.get()->get_display_type(); } // MARK: - AudioProducer diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index 0dd246d22..706077797 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -364,19 +364,19 @@ public: } void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - vdp_.last_valid()->set_scan_target(scan_target); + vdp_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return vdp_.last_valid()->get_scaled_scan_status(); + return vdp_.get()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - vdp_.last_valid()->set_display_type(display_type); + vdp_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return vdp_.last_valid()->get_display_type(); + return vdp_.get()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final { diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index 033a5ee81..b09e33260 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -185,7 +185,7 @@ public: } void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - vdp_.last_valid()->set_tv_standard( + vdp_.get()->set_tv_standard( (region_ == Target::Region::Europe) ? TI::TMS::TVStandard::PAL : TI::TMS::TVStandard::NTSC); @@ -193,19 +193,19 @@ public: // especially thread-safe and won't make a substantial difference. // time_until_debounce_ = vdp_->get_time_until_line(-1); - vdp_.last_valid()->set_scan_target(scan_target); + vdp_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return vdp_.last_valid()->get_scaled_scan_status(); + return vdp_.get()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - vdp_.last_valid()->set_display_type(display_type); + vdp_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return vdp_.last_valid()->get_display_type(); + return vdp_.get()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final { @@ -279,7 +279,7 @@ public: *cycle.value = vdp_->get_current_line(); break; case 0x41: - *cycle.value = vdp_.last_valid()->get_latched_horizontal_counter(); + *cycle.value = vdp_.get()->get_latched_horizontal_counter(); break; case 0x80: case 0x81: *cycle.value = vdp_->read(address); diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index cfbdd4364..daceed2c8 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -461,7 +461,7 @@ public: case DiskInterface::BD500: inserted |= insert_disks(media, bd500_, 4); break; case DiskInterface::Jasmin: inserted |= insert_disks(media, jasmin_, 4); break; case DiskInterface::Microdisc: inserted |= insert_disks(media, microdisc_, 4); break; - case DiskInterface::Pravetz: inserted |= insert_disks(media, *diskii_.last_valid(), 2); break; + case DiskInterface::Pravetz: inserted |= insert_disks(media, *diskii_.get(), 2); break; default: break; } } @@ -607,19 +607,19 @@ public: // to satisfy CRTMachine::Machine void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - video_.last_valid()->set_scan_target(scan_target); + video_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return video_.last_valid()->get_scaled_scan_status(); + return video_.get()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - video_.last_valid()->set_display_type(display_type); + video_.get()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return video_.last_valid()->get_display_type(); + return video_.get()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final { diff --git a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp index d56baf3f2..ec376bffe 100644 --- a/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp +++ b/Machines/Sinclair/ZXSpectrum/ZXSpectrum.cpp @@ -200,7 +200,7 @@ public: if(target.state) { const auto state = static_cast(target.state.get()); state->z80.apply(z80_); - state->video.apply(*video_.last_valid()); + state->video.apply(*video_.get()); state->ay.apply(ay_); // If this is a 48k or 16k machine, remap source data from its original @@ -290,7 +290,7 @@ public: // MARK: - ScanProducer. void set_scan_target(Outputs::Display::ScanTarget *scan_target) override { - video_.last_valid()->set_scan_target(scan_target); + video_.get()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const override { @@ -321,7 +321,7 @@ public: cycle.operation >= PartialMachineCycle::ReadOpcodeStart && cycle.operation <= PartialMachineCycle::WriteStart) { - const auto delay = video_.last_valid()->access_delay(video_.time_since_flush()); + const auto delay = video_.get()->access_delay(video_.time_since_flush()); advance(cycle.length + delay); return delay; } @@ -352,13 +352,13 @@ public: if((address & 0xc000) == 0x4000) { for(int c = 0; c < ((address & 1) ? 4 : 2); c++) { - const auto next_delay = video_.last_valid()->access_delay(time); + const auto next_delay = video_.get()->access_delay(time); delay += next_delay; time += next_delay + 2; } } else { if(!(address & 1)) { - delay = video_.last_valid()->access_delay(time + HalfCycles(2)); + delay = video_.get()->access_delay(time + HalfCycles(2)); } } @@ -372,7 +372,7 @@ public: // These all start by loading the address bus, then set MREQ // half a cycle later. if(banks_[address >> 14].is_contended) { - const auto delay = video_.last_valid()->access_delay(video_.time_since_flush()); + const auto delay = video_.get()->access_delay(video_.time_since_flush()); advance(cycle.length + delay); return delay; @@ -390,7 +390,7 @@ public: HalfCycles time = video_.time_since_flush(); HalfCycles delay; for(int c = 0; c < half_cycles; c += 2) { - const auto next_delay = video_.last_valid()->access_delay(time); + const auto next_delay = video_.get()->access_delay(time); delay += next_delay; time += next_delay + 2; } @@ -626,7 +626,7 @@ private: video_ += duration; if(video_.did_flush()) { - z80_.set_interrupt_line(video_.last_valid()->get_interrupt_line(), video_.last_sequence_point_overrun()); + z80_.set_interrupt_line(video_.get()->get_interrupt_line(), video_.last_sequence_point_overrun()); } if(!tape_player_is_sleeping_) tape_player_.run_for(Cycles(duration.get())); diff --git a/Machines/Thomson/MO/MO.cpp b/Machines/Thomson/MO/MO.cpp index 2cdbb46cf..8e4a7b623 100644 --- a/Machines/Thomson/MO/MO.cpp +++ b/Machines/Thomson/MO/MO.cpp @@ -141,7 +141,7 @@ struct ConcreteMachine: ) { static constexpr auto duration = CPU::M6809::duration(bus_phase); if(video_ += duration) { - system_pia_.template set(video_.last_valid()->irq()); + system_pia_.template set(video_.get()->irq()); } time_since_audio_update_ += duration; tape_player_.run_for(duration); @@ -597,11 +597,11 @@ private: // MARK: - ScanProducer. void set_scan_target(Outputs::Display::ScanTarget *const target) final { - video_.last_valid()->set_scan_target(target); + video_.get()->set_scan_target(target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return video_.last_valid()->get_scaled_scan_status(); + return video_.get()->get_scaled_scan_status(); } // MARK: - TimedMachine.