mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Merge pull request #697 from TomHarte/MoreConstexpr
Further propagates `constexpr`.
This commit is contained in:
commit
6edd3c9698
@ -877,8 +877,10 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
// Pump the AY
|
// Pump the AY
|
||||||
ay_.run_for(cycle.length);
|
ay_.run_for(cycle.length);
|
||||||
|
|
||||||
// Clock the FDC, if connected, using a lazy scale by two
|
if constexpr (has_fdc) {
|
||||||
time_since_fdc_update_ += cycle.length;
|
// Clock the FDC, if connected, using a lazy scale by two
|
||||||
|
time_since_fdc_update_ += cycle.length;
|
||||||
|
}
|
||||||
|
|
||||||
// Update typing activity
|
// Update typing activity
|
||||||
if(typer_) typer_->run_for(cycle.length);
|
if(typer_) typer_->run_for(cycle.length);
|
||||||
@ -904,9 +906,11 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for an upper ROM selection
|
// Check for an upper ROM selection
|
||||||
if(has_fdc && !(address&0x2000)) {
|
if constexpr (has_fdc) {
|
||||||
upper_rom_ = (*cycle.value == 7) ? ROMType::AMSDOS : ROMType::BASIC;
|
if(!(address&0x2000)) {
|
||||||
if(upper_rom_is_paged_) read_pointers_[3] = roms_[upper_rom_].data();
|
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
|
// Check for a CRTC access
|
||||||
@ -923,16 +927,18 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
i8255_.set_register((address >> 8) & 3, *cycle.value);
|
i8255_.set_register((address >> 8) & 3, *cycle.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an FDC access
|
if constexpr (has_fdc) {
|
||||||
if(has_fdc && (address & 0x580) == 0x100) {
|
// Check for an FDC access
|
||||||
flush_fdc();
|
if((address & 0x580) == 0x100) {
|
||||||
fdc_.set_register(address & 1, *cycle.value);
|
flush_fdc();
|
||||||
}
|
fdc_.set_register(address & 1, *cycle.value);
|
||||||
|
}
|
||||||
|
|
||||||
// Check for a disk motor access
|
// Check for a disk motor access
|
||||||
if(has_fdc && !(address & 0x580)) {
|
if(!(address & 0x580)) {
|
||||||
flush_fdc();
|
flush_fdc();
|
||||||
fdc_.set_motor_on(!!(*cycle.value));
|
fdc_.set_motor_on(!!(*cycle.value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CPU::Z80::PartialMachineCycle::Input:
|
case CPU::Z80::PartialMachineCycle::Input:
|
||||||
@ -945,9 +951,11 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for an FDC access
|
// Check for an FDC access
|
||||||
if(has_fdc && (address & 0x580) == 0x100) {
|
if constexpr (has_fdc) {
|
||||||
flush_fdc();
|
if((address & 0x580) == 0x100) {
|
||||||
*cycle.value &= fdc_.get_register(address & 1);
|
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
|
// 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
|
// MARK: - Activity Source
|
||||||
void set_activity_observer(Activity::Observer *observer) override {
|
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.
|
// MARK: - Configuration options.
|
||||||
@ -1155,11 +1163,13 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
FDC fdc_;
|
FDC fdc_;
|
||||||
HalfCycles time_since_fdc_update_;
|
HalfCycles time_since_fdc_update_;
|
||||||
void flush_fdc() {
|
void flush_fdc() {
|
||||||
// Clock the FDC, if connected, using a lazy scale by two
|
if constexpr (has_fdc) {
|
||||||
if(has_fdc && !fdc_is_sleeping_) {
|
// Clock the FDC, if connected, using a lazy scale by two
|
||||||
fdc_.run_for(Cycles(time_since_fdc_update_.as_integral()));
|
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_;
|
InterruptTimer interrupt_timer_;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
namespace Apple {
|
namespace Apple {
|
||||||
namespace Macintosh {
|
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.
|
Defines the keycodes that could be passed directly to a Macintosh via set_key_pressed.
|
||||||
|
@ -152,7 +152,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
|||||||
scc_.set_delegate(this);
|
scc_.set_delegate(this);
|
||||||
|
|
||||||
// Also watch for changes in clocking requirement from the SCSI chip.
|
// 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);
|
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 {
|
void set_activity_observer(Activity::Observer *observer) override {
|
||||||
iwm_->set_activity_observer(observer);
|
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);
|
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.
|
// 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);
|
if(scsi_bus_is_clocked_) scsi_bus_.run_for(duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
namespace Apple {
|
namespace Apple {
|
||||||
namespace Macintosh {
|
namespace Macintosh {
|
||||||
|
|
||||||
static constexpr HalfCycles line_length(704);
|
constexpr HalfCycles line_length(704);
|
||||||
static constexpr int number_of_lines = 370;
|
constexpr int number_of_lines = 370;
|
||||||
static constexpr HalfCycles frame_length(line_length * HalfCycles(number_of_lines));
|
constexpr HalfCycles frame_length(line_length * HalfCycles(number_of_lines));
|
||||||
static constexpr int sync_start = 36;
|
constexpr int sync_start = 36;
|
||||||
static constexpr int sync_end = 38;
|
constexpr int sync_end = 38;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Models the 68000-era Macintosh video hardware, producing a 512x348 pixel image,
|
Models the 68000-era Macintosh video hardware, producing a 512x348 pixel image,
|
||||||
|
@ -16,24 +16,24 @@ using namespace Electron;
|
|||||||
#define graphics_column(v) ((((v) & 127) - first_graphics_cycle + 128) & 127)
|
#define graphics_column(v) ((((v) & 127) - first_graphics_cycle + 128) & 127)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static constexpr int cycles_per_line = 128;
|
constexpr int cycles_per_line = 128;
|
||||||
static constexpr int lines_per_frame = 625;
|
constexpr int lines_per_frame = 625;
|
||||||
static constexpr int cycles_per_frame = lines_per_frame * cycles_per_line;
|
constexpr int cycles_per_frame = lines_per_frame * cycles_per_line;
|
||||||
static constexpr int crt_cycles_multiplier = 8;
|
constexpr int crt_cycles_multiplier = 8;
|
||||||
static constexpr int crt_cycles_per_line = crt_cycles_multiplier * cycles_per_line;
|
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
|
// 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
|
// with pixels in field 2 will be 20+field_divider_line
|
||||||
static constexpr int first_graphics_line = 31;
|
constexpr int first_graphics_line = 31;
|
||||||
static constexpr int first_graphics_cycle = 33;
|
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;
|
constexpr int real_time_clock_interrupt_1 = 16704;
|
||||||
static constexpr int real_time_clock_interrupt_2 = 56704;
|
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;
|
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 display_end_interrupt_2 = (first_graphics_line + field_divider_line + display_end_interrupt_line)*cycles_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
|
@ -224,7 +224,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
|
|||||||
tape_player_.set_delegate(this);
|
tape_player_.set_delegate(this);
|
||||||
Memory::Fuzz(ram_, sizeof(ram_));
|
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);
|
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
|
// Helper to discern current IRQ state
|
||||||
inline void set_interrupt_line() {
|
inline void set_interrupt_line() {
|
||||||
bool irq_line = via_.get_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();
|
irq_line |= microdisc_.get_interrupt_request_line();
|
||||||
m6502_.set_irq_line(irq_line);
|
m6502_.set_irq_line(irq_line);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
rom_ = std::move(*roms[0]);
|
rom_ = std::move(*roms[0]);
|
||||||
rom_.resize(use_zx81_rom ? 8192 : 4096);
|
rom_.resize(use_zx81_rom ? 8192 : 4096);
|
||||||
|
|
||||||
if(is_zx81) {
|
if constexpr (is_zx81) {
|
||||||
tape_trap_address_ = 0x37c;
|
tape_trap_address_ = 0x37c;
|
||||||
tape_return_address_ = 0x380;
|
tape_return_address_ = 0x380;
|
||||||
vsync_start_ = HalfCycles(32);
|
vsync_start_ = HalfCycles(32);
|
||||||
@ -158,7 +158,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
video_.run_for(cycle.length);
|
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_) {
|
if(!tape_advance_delay_) {
|
||||||
tape_player_.run_for(cycle.length);
|
tape_player_.run_for(cycle.length);
|
||||||
} else {
|
} else {
|
||||||
@ -185,7 +185,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
if(!(address & 1)) nmi_is_enabled_ = is_zx81;
|
if(!(address & 1)) nmi_is_enabled_ = is_zx81;
|
||||||
|
|
||||||
// The below emulates the ZonX AY expansion device.
|
// The below emulates the ZonX AY expansion device.
|
||||||
if(is_zx81) {
|
if constexpr (is_zx81) {
|
||||||
if((address&0xef) == 0xcf) {
|
if((address&0xef) == 0xcf) {
|
||||||
ay_set_register(*cycle.value);
|
ay_set_register(*cycle.value);
|
||||||
} else if((address&0xef) == 0x0f) {
|
} else if((address&0xef) == 0x0f) {
|
||||||
@ -209,7 +209,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The below emulates the ZonX AY expansion device.
|
// The below emulates the ZonX AY expansion device.
|
||||||
if(is_zx81) {
|
if constexpr (is_zx81) {
|
||||||
if((address&0xef) == 0xcf) {
|
if((address&0xef) == 0xcf) {
|
||||||
value &= ay_read_data();
|
value &= ay_read_data();
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
|
|
||||||
forceinline void flush() {
|
forceinline void flush() {
|
||||||
video_.flush();
|
video_.flush();
|
||||||
if(is_zx81) {
|
if constexpr (is_zx81) {
|
||||||
update_audio();
|
update_audio();
|
||||||
audio_queue_.perform();
|
audio_queue_.perform();
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
</Testables>
|
</Testables>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Release"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
enableASanStackUseAfterReturn = "YES"
|
enableASanStackUseAfterReturn = "YES"
|
||||||
|
@ -21,7 +21,7 @@ namespace SCSI {
|
|||||||
|
|
||||||
typedef int BusState;
|
typedef int BusState;
|
||||||
|
|
||||||
static constexpr BusState DefaultBusState = 0;
|
constexpr BusState DefaultBusState = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
SCSI bus state is encoded entirely within an int.
|
SCSI bus state is encoded entirely within an int.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user