1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 00:29:34 +00:00

Eliminates static where constexpra aren't class members; adds some if constexprs for clarity.

This commit is contained in:
Thomas Harte 2019-12-22 13:42:24 -05:00
parent 66d9b60b98
commit 5456a4a39d
9 changed files with 65 additions and 55 deletions

View File

@ -877,8 +877,10 @@ template <bool has_fdc> class ConcreteMachine:
// Pump the AY
ay_.run_for(cycle.length);
// Clock the FDC, if connected, using a lazy scale by two
time_since_fdc_update_ += cycle.length;
if constexpr (has_fdc) {
// Clock the FDC, if connected, using a lazy scale by two
time_since_fdc_update_ += cycle.length;
}
// Update typing activity
if(typer_) typer_->run_for(cycle.length);
@ -904,9 +906,11 @@ template <bool has_fdc> class ConcreteMachine:
}
// Check for an upper ROM selection
if(has_fdc && !(address&0x2000)) {
upper_rom_ = (*cycle.value == 7) ? ROMType::AMSDOS : ROMType::BASIC;
if(upper_rom_is_paged_) read_pointers_[3] = roms_[upper_rom_].data();
if constexpr (has_fdc) {
if(!(address&0x2000)) {
upper_rom_ = (*cycle.value == 7) ? ROMType::AMSDOS : ROMType::BASIC;
if(upper_rom_is_paged_) read_pointers_[3] = roms_[upper_rom_].data();
}
}
// Check for a CRTC access
@ -923,16 +927,18 @@ template <bool has_fdc> class ConcreteMachine:
i8255_.set_register((address >> 8) & 3, *cycle.value);
}
// Check for an FDC access
if(has_fdc && (address & 0x580) == 0x100) {
flush_fdc();
fdc_.set_register(address & 1, *cycle.value);
}
if constexpr (has_fdc) {
// Check for an FDC access
if((address & 0x580) == 0x100) {
flush_fdc();
fdc_.set_register(address & 1, *cycle.value);
}
// Check for a disk motor access
if(has_fdc && !(address & 0x580)) {
flush_fdc();
fdc_.set_motor_on(!!(*cycle.value));
// Check for a disk motor access
if(!(address & 0x580)) {
flush_fdc();
fdc_.set_motor_on(!!(*cycle.value));
}
}
break;
case CPU::Z80::PartialMachineCycle::Input:
@ -945,9 +951,11 @@ template <bool has_fdc> class ConcreteMachine:
}
// Check for an FDC access
if(has_fdc && (address & 0x580) == 0x100) {
flush_fdc();
*cycle.value &= fdc_.get_register(address & 1);
if constexpr (has_fdc) {
if((address & 0x580) == 0x100) {
flush_fdc();
*cycle.value &= fdc_.get_register(address & 1);
}
}
// Check for a CRTC access; the below is not a typo, the CRTC can be selected
@ -1065,7 +1073,7 @@ template <bool has_fdc> class ConcreteMachine:
// MARK: - Activity Source
void set_activity_observer(Activity::Observer *observer) override {
if(has_fdc) fdc_.set_activity_observer(observer);
if constexpr (has_fdc) fdc_.set_activity_observer(observer);
}
// MARK: - Configuration options.
@ -1155,11 +1163,13 @@ template <bool has_fdc> class ConcreteMachine:
FDC fdc_;
HalfCycles time_since_fdc_update_;
void flush_fdc() {
// Clock the FDC, if connected, using a lazy scale by two
if(has_fdc && !fdc_is_sleeping_) {
fdc_.run_for(Cycles(time_since_fdc_update_.as_integral()));
if constexpr (has_fdc) {
// Clock the FDC, if connected, using a lazy scale by two
if(!fdc_is_sleeping_) {
fdc_.run_for(Cycles(time_since_fdc_update_.as_integral()));
}
time_since_fdc_update_ = HalfCycles(0);
}
time_since_fdc_update_ = HalfCycles(0);
}
InterruptTimer interrupt_timer_;

View File

@ -18,7 +18,7 @@
namespace Apple {
namespace Macintosh {
static constexpr uint16_t KeypadMask = 0x100;
constexpr uint16_t KeypadMask = 0x100;
/*!
Defines the keycodes that could be passed directly to a Macintosh via set_key_pressed.

View File

@ -152,7 +152,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
scc_.set_delegate(this);
// Also watch for changes in clocking requirement from the SCSI chip.
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
if constexpr (model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
scsi_bus_.set_clocking_hint_observer(this);
}
@ -514,7 +514,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
void set_activity_observer(Activity::Observer *observer) override {
iwm_->set_activity_observer(observer);
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
if constexpr (model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
scsi_bus_.set_activity_observer(observer);
}
}
@ -642,7 +642,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
}
// Update the SCSI if currently active.
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
if constexpr (model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
if(scsi_bus_is_clocked_) scsi_bus_.run_for(duration);
}
}

View File

@ -17,11 +17,11 @@
namespace Apple {
namespace Macintosh {
static constexpr HalfCycles line_length(704);
static constexpr int number_of_lines = 370;
static constexpr HalfCycles frame_length(line_length * HalfCycles(number_of_lines));
static constexpr int sync_start = 36;
static constexpr int sync_end = 38;
constexpr HalfCycles line_length(704);
constexpr int number_of_lines = 370;
constexpr HalfCycles frame_length(line_length * HalfCycles(number_of_lines));
constexpr int sync_start = 36;
constexpr int sync_end = 38;
/*!
Models the 68000-era Macintosh video hardware, producing a 512x348 pixel image,

View File

@ -16,24 +16,24 @@ using namespace Electron;
#define graphics_column(v) ((((v) & 127) - first_graphics_cycle + 128) & 127)
namespace {
static constexpr int cycles_per_line = 128;
static constexpr int lines_per_frame = 625;
static constexpr int cycles_per_frame = lines_per_frame * cycles_per_line;
static constexpr int crt_cycles_multiplier = 8;
static constexpr int crt_cycles_per_line = crt_cycles_multiplier * cycles_per_line;
constexpr int cycles_per_line = 128;
constexpr int lines_per_frame = 625;
constexpr int cycles_per_frame = lines_per_frame * cycles_per_line;
constexpr int crt_cycles_multiplier = 8;
constexpr int crt_cycles_per_line = crt_cycles_multiplier * cycles_per_line;
static constexpr int field_divider_line = 312; // i.e. the line, simultaneous with which, the first field's sync ends. So if
// the first line with pixels in field 1 is the 20th in the frame, the first line
// with pixels in field 2 will be 20+field_divider_line
static constexpr int first_graphics_line = 31;
static constexpr int first_graphics_cycle = 33;
constexpr int field_divider_line = 312; // i.e. the line, simultaneous with which, the first field's sync ends. So if
// the first line with pixels in field 1 is the 20th in the frame, the first line
// with pixels in field 2 will be 20+field_divider_line
constexpr int first_graphics_line = 31;
constexpr int first_graphics_cycle = 33;
static constexpr int display_end_interrupt_line = 256;
constexpr int display_end_interrupt_line = 256;
static constexpr int real_time_clock_interrupt_1 = 16704;
static constexpr int real_time_clock_interrupt_2 = 56704;
static constexpr int display_end_interrupt_1 = (first_graphics_line + display_end_interrupt_line)*cycles_per_line;
static constexpr int display_end_interrupt_2 = (first_graphics_line + field_divider_line + display_end_interrupt_line)*cycles_per_line;
constexpr int real_time_clock_interrupt_1 = 16704;
constexpr int real_time_clock_interrupt_2 = 56704;
constexpr int display_end_interrupt_1 = (first_graphics_line + display_end_interrupt_line)*cycles_per_line;
constexpr int display_end_interrupt_2 = (first_graphics_line + field_divider_line + display_end_interrupt_line)*cycles_per_line;
}
// MARK: - Lifecycle

View File

@ -224,7 +224,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
tape_player_.set_delegate(this);
Memory::Fuzz(ram_, sizeof(ram_));
if(disk_interface == Analyser::Static::Oric::Target::DiskInterface::Pravetz) {
if constexpr (disk_interface == Analyser::Static::Oric::Target::DiskInterface::Pravetz) {
diskii_.set_clocking_hint_observer(this);
}
@ -630,7 +630,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
// Helper to discern current IRQ state
inline void set_interrupt_line() {
bool irq_line = via_.get_interrupt_line();
if(disk_interface == Analyser::Static::Oric::Target::DiskInterface::Microdisc)
if constexpr (disk_interface == Analyser::Static::Oric::Target::DiskInterface::Microdisc)
irq_line |= microdisc_.get_interrupt_request_line();
m6502_.set_irq_line(irq_line);
}

View File

@ -86,7 +86,7 @@ template<bool is_zx81> class ConcreteMachine:
rom_ = std::move(*roms[0]);
rom_.resize(use_zx81_rom ? 8192 : 4096);
if(is_zx81) {
if constexpr (is_zx81) {
tape_trap_address_ = 0x37c;
tape_return_address_ = 0x380;
vsync_start_ = HalfCycles(32);
@ -158,7 +158,7 @@ template<bool is_zx81> class ConcreteMachine:
video_.run_for(cycle.length);
}
if(is_zx81) horizontal_counter_ %= HalfCycles(Cycles(207));
if constexpr (is_zx81) horizontal_counter_ %= HalfCycles(Cycles(207));
if(!tape_advance_delay_) {
tape_player_.run_for(cycle.length);
} else {
@ -185,7 +185,7 @@ template<bool is_zx81> class ConcreteMachine:
if(!(address & 1)) nmi_is_enabled_ = is_zx81;
// The below emulates the ZonX AY expansion device.
if(is_zx81) {
if constexpr (is_zx81) {
if((address&0xef) == 0xcf) {
ay_set_register(*cycle.value);
} else if((address&0xef) == 0x0f) {
@ -209,7 +209,7 @@ template<bool is_zx81> class ConcreteMachine:
}
// The below emulates the ZonX AY expansion device.
if(is_zx81) {
if constexpr (is_zx81) {
if((address&0xef) == 0xcf) {
value &= ay_read_data();
}
@ -308,7 +308,7 @@ template<bool is_zx81> class ConcreteMachine:
forceinline void flush() {
video_.flush();
if(is_zx81) {
if constexpr (is_zx81) {
update_audio();
audio_queue_.perform();
}

View File

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

View File

@ -21,7 +21,7 @@ namespace SCSI {
typedef int BusState;
static constexpr BusState DefaultBusState = 0;
constexpr BusState DefaultBusState = 0;
/*!
SCSI bus state is encoded entirely within an int.