1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-24 10:29:16 +00:00

Corrects out-of-order initialisations for the 1770, Atari 2600 joystick, Pitfall II bus extender, Microdisc and 6502.

This commit is contained in:
Thomas Harte 2017-11-10 22:20:44 -05:00
parent 46e7c199b2
commit 4cbc87a17d
8 changed files with 40 additions and 81 deletions

View File

@ -11,28 +11,10 @@
using namespace WD; using namespace WD;
WD1770::Status::Status() :
type(Status::One),
write_protect(false),
record_type(false),
spin_up(false),
record_not_found(false),
crc_error(false),
seek_error(false),
lost_data(false),
data_request(false),
interrupt_request(false),
busy(false) {}
WD1770::WD1770(Personality p) : WD1770::WD1770(Personality p) :
Storage::Disk::MFMController(8000000), Storage::Disk::MFMController(8000000),
interesting_event_mask_(static_cast<int>(Event1770::Command)),
resume_point_(0),
delay_time_(0),
index_hole_count_target_(-1),
delegate_(nullptr),
personality_(p), personality_(p),
head_is_loaded_(false) { interesting_event_mask_(static_cast<int>(Event1770::Command)) {
set_is_double_density(false); set_is_double_density(false);
posit_event(static_cast<int>(Event1770::Command)); posit_event(static_cast<int>(Event1770::Command));
} }

View File

@ -85,20 +85,19 @@ class WD1770: public Storage::Disk::MFMController {
inline bool has_head_load_line() { return (personality_ == P1793 ); } inline bool has_head_load_line() { return (personality_ == P1793 ); }
struct Status { struct Status {
Status(); bool write_protect = false;
bool write_protect; bool record_type = false;
bool record_type; bool spin_up = false;
bool spin_up; bool record_not_found = false;
bool record_not_found; bool crc_error = false;
bool crc_error; bool seek_error = false;
bool seek_error; bool lost_data = false;
bool lost_data; bool data_request = false;
bool data_request; bool interrupt_request = false;
bool interrupt_request; bool busy = false;
bool busy;
enum { enum {
One, Two, Three One, Two, Three
} type; } type = One;
} status_; } status_;
uint8_t track_; uint8_t track_;
uint8_t sector_; uint8_t sector_;
@ -106,7 +105,7 @@ class WD1770: public Storage::Disk::MFMController {
uint8_t command_; uint8_t command_;
int index_hole_count_; int index_hole_count_;
int index_hole_count_target_; int index_hole_count_target_ = -1;
int distance_into_section_; int distance_into_section_;
int step_direction_; int step_direction_;
@ -121,17 +120,17 @@ class WD1770: public Storage::Disk::MFMController {
}; };
void posit_event(int type); void posit_event(int type);
int interesting_event_mask_; int interesting_event_mask_;
int resume_point_; int resume_point_ = 0;
unsigned int delay_time_; unsigned int delay_time_ = 0;
// ID buffer // ID buffer
uint8_t header_[6]; uint8_t header_[6];
// 1793 head-loading logic // 1793 head-loading logic
bool head_is_loaded_; bool head_is_loaded_ = false;
// delegate // delegate
Delegate *delegate_; Delegate *delegate_ = nullptr;
}; };
} }

View File

@ -53,8 +53,8 @@ class Joystick: public Inputs::Joystick {
} }
private: private:
size_t shift_, fire_tia_input_;
Bus *bus_; Bus *bus_;
size_t shift_, fire_tia_input_;
}; };
class ConcreteMachine: class ConcreteMachine:

View File

@ -16,11 +16,7 @@ class Pitfall2: public BusExtender {
public: public:
Pitfall2(uint8_t *rom_base, size_t rom_size) : Pitfall2(uint8_t *rom_base, size_t rom_size) :
BusExtender(rom_base, rom_size), BusExtender(rom_base, rom_size),
rom_ptr_(rom_base), rom_ptr_(rom_base) {}
random_number_generator_(0),
featcher_address_{0, 0, 0, 0, 0, 0, 0, 0},
mask_{0, 0, 0, 0, 0, 0, 0, 0},
cycles_since_audio_update_(0) {}
void advance_cycles(int cycles) { void advance_cycles(int cycles) {
cycles_since_audio_update_ += cycles; cycles_since_audio_update_ += cycles;
@ -119,13 +115,13 @@ class Pitfall2: public BusExtender {
return level_table[table_position]; return level_table[table_position];
} }
uint16_t featcher_address_[8]; uint16_t featcher_address_[8] = {0, 0, 0, 0, 0, 0, 0, 0};
uint8_t top_[8], bottom_[8], mask_[8]; uint8_t top_[8], bottom_[8], mask_[8] = {0, 0, 0, 0, 0, 0, 0, 0};
uint8_t music_mode_[3]; uint8_t music_mode_[3];
uint8_t random_number_generator_; uint8_t random_number_generator_ = 0;
uint8_t *rom_ptr_; uint8_t *rom_ptr_;
uint8_t audio_channel_[3]; uint8_t audio_channel_[3];
Cycles cycles_since_audio_update_; Cycles cycles_since_audio_update_ = 0;
}; };
} }

View File

@ -18,13 +18,7 @@ namespace {
const int head_load_request_counter_target = 7653333; const int head_load_request_counter_target = 7653333;
} }
Microdisc::Microdisc() : Microdisc::Microdisc() : WD1770(P1793) {
irq_enable_(false),
delegate_(nullptr),
paging_flags_(BASICDisable),
head_load_request_counter_(-1),
WD1770(P1793),
last_control_(0) {
set_control_register(last_control_, 0xff); set_control_register(last_control_, 0xff);
} }

View File

@ -45,11 +45,11 @@ class Microdisc: public WD::WD1770 {
bool get_drive_is_ready(); bool get_drive_is_ready();
std::shared_ptr<Storage::Disk::Drive> drives_[4]; std::shared_ptr<Storage::Disk::Drive> drives_[4];
int selected_drive_; int selected_drive_;
bool irq_enable_; bool irq_enable_ = false;
int paging_flags_; int paging_flags_ = BASICDisable;
int head_load_request_counter_; int head_load_request_counter_ = -1;
Delegate *delegate_; Delegate *delegate_ = nullptr;
uint8_t last_control_; uint8_t last_control_ = 0;
}; };
} }

View File

@ -244,19 +244,7 @@ const ProcessorStorage::MicroOp ProcessorStorage::operations[256][10] = {
#undef Immediate #undef Immediate
#undef Implied #undef Implied
ProcessorStorage::ProcessorStorage() : ProcessorStorage::ProcessorStorage() {
is_jammed_(false),
ready_line_is_enabled_(false),
ready_is_active_(false),
inverse_interrupt_flag_(0),
irq_request_history_(0),
s_(0),
next_bus_operation_(BusOperation::None),
interrupt_requests_(InterruptRequestFlags::PowerOn),
irq_line_(0),
nmi_line_is_enabled_(false),
set_overflow_line_is_enabled_(false),
scheduled_program_counter_(nullptr) {
// only the interrupt flag is defined upon reset but get_flags isn't going to // only the interrupt flag is defined upon reset but get_flags isn't going to
// mask the other flags so we need to do that, at least // mask the other flags so we need to do that, at least
carry_flag_ &= Flag::Carry; carry_flag_ &= Flag::Carry;

View File

@ -64,14 +64,14 @@ class ProcessorStorage {
static const MicroOp operations[256][10]; static const MicroOp operations[256][10];
const MicroOp *scheduled_program_counter_; const MicroOp *scheduled_program_counter_ = nullptr;
/* /*
Storage for the 6502 registers; F is stored as individual flags. Storage for the 6502 registers; F is stored as individual flags.
*/ */
RegisterPair pc_, last_operation_pc_; RegisterPair pc_, last_operation_pc_;
uint8_t a_, x_, y_, s_; uint8_t a_, x_, y_, s_ = 0;
uint8_t carry_flag_, negative_result_, zero_result_, decimal_flag_, overflow_flag_, inverse_interrupt_flag_; uint8_t carry_flag_, negative_result_, zero_result_, decimal_flag_, overflow_flag_, inverse_interrupt_flag_ = 0;
/* /*
Temporary state for the micro programs. Temporary state for the micro programs.
@ -83,7 +83,7 @@ class ProcessorStorage {
Temporary storage allowing a common dispatch point for calling perform_bus_operation; Temporary storage allowing a common dispatch point for calling perform_bus_operation;
possibly deferring is no longer of value. possibly deferring is no longer of value.
*/ */
BusOperation next_bus_operation_; BusOperation next_bus_operation_ = BusOperation::None;
uint16_t bus_address_; uint16_t bus_address_;
uint8_t *bus_value_; uint8_t *bus_value_;
@ -105,7 +105,7 @@ class ProcessorStorage {
*/ */
inline void set_flags(uint8_t flags); inline void set_flags(uint8_t flags);
bool is_jammed_; bool is_jammed_ = false;
Cycles cycles_left_to_run_; Cycles cycles_left_to_run_;
enum InterruptRequestFlags: uint8_t { enum InterruptRequestFlags: uint8_t {
@ -115,13 +115,13 @@ class ProcessorStorage {
PowerOn = 0x10, PowerOn = 0x10,
}; };
uint8_t interrupt_requests_; uint8_t interrupt_requests_ = InterruptRequestFlags::PowerOn;
bool ready_is_active_; bool ready_is_active_ = false;
bool ready_line_is_enabled_; bool ready_line_is_enabled_ = false;
uint8_t irq_line_, irq_request_history_; uint8_t irq_line_ = 0, irq_request_history_ = 0;
bool nmi_line_is_enabled_, set_overflow_line_is_enabled_; bool nmi_line_is_enabled_ = false, set_overflow_line_is_enabled_ = false;
/*! /*!
Gets the program representing an RST response. Gets the program representing an RST response.