1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Merge pull request #697 from TomHarte/MoreConstexpr

Further propagates `constexpr`.
This commit is contained in:
Thomas Harte 2019-12-22 13:53:44 -05:00 committed by GitHub
commit 6edd3c9698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
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,10 +906,12 @@ template <bool has_fdc> class ConcreteMachine:
}
// Check for an upper ROM selection
if(has_fdc && !(address&0x2000)) {
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
if(!(address & 0x4000)) {
@ -923,17 +927,19 @@ template <bool has_fdc> class ConcreteMachine:
i8255_.set_register((address >> 8) & 3, *cycle.value);
}
if constexpr (has_fdc) {
// Check for an FDC access
if(has_fdc && (address & 0x580) == 0x100) {
if((address & 0x580) == 0x100) {
flush_fdc();
fdc_.set_register(address & 1, *cycle.value);
}
// Check for a disk motor access
if(has_fdc && !(address & 0x580)) {
if(!(address & 0x580)) {
flush_fdc();
fdc_.set_motor_on(!!(*cycle.value));
}
}
break;
case CPU::Z80::PartialMachineCycle::Input:
// Default to nothing answering
@ -945,10 +951,12 @@ template <bool has_fdc> class ConcreteMachine:
}
// Check for an FDC access
if(has_fdc && (address & 0x580) == 0x100) {
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
// for writing via an input, and will sample whatever happens to be available
@ -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,12 +1163,14 @@ template <bool has_fdc> class ConcreteMachine:
FDC fdc_;
HalfCycles time_since_fdc_update_;
void flush_fdc() {
if constexpr (has_fdc) {
// Clock the FDC, if connected, using a lazy scale by two
if(has_fdc && !fdc_is_sleeping_) {
if(!fdc_is_sleeping_) {
fdc_.run_for(Cycles(time_since_fdc_update_.as_integral()));
}
time_since_fdc_update_ = HalfCycles(0);
}
}
InterruptTimer interrupt_timer_;
Storage::Tape::BinaryTapePlayer tape_player_;

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
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 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.