mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 23:32:28 +00:00
Makes the Apple II an activity source.
This commit is contained in:
parent
9089bf6535
commit
a43ca0db35
@ -236,3 +236,7 @@ uint8_t DiskII::trigger_address(int address, uint8_t value) {
|
|||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiskII::set_activity_observer(Activity::Observer *observer) {
|
||||||
|
drives_[0].set_activity_observer(observer, "Drive 1", true);
|
||||||
|
drives_[1].set_activity_observer(observer, "Drive 2", true);
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "../../Storage/Disk/Disk.hpp"
|
#include "../../Storage/Disk/Disk.hpp"
|
||||||
#include "../../Storage/Disk/Drive.hpp"
|
#include "../../Storage/Disk/Drive.hpp"
|
||||||
|
|
||||||
|
#include "../../Activity/Observer.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -40,6 +42,8 @@ class DiskII:
|
|||||||
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
|
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
|
||||||
bool is_sleeping() override;
|
bool is_sleeping() override;
|
||||||
|
|
||||||
|
void set_activity_observer(Activity::Observer *observer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Control {
|
enum class Control {
|
||||||
P0, P1, P2, P3,
|
P0, P1, P2, P3,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "AppleII.hpp"
|
#include "AppleII.hpp"
|
||||||
|
|
||||||
|
#include "../../Activity/Source.hpp"
|
||||||
#include "../ConfigurationTarget.hpp"
|
#include "../ConfigurationTarget.hpp"
|
||||||
#include "../CRTMachine.hpp"
|
#include "../CRTMachine.hpp"
|
||||||
#include "../KeyboardMachine.hpp"
|
#include "../KeyboardMachine.hpp"
|
||||||
@ -24,6 +25,7 @@
|
|||||||
|
|
||||||
#include "../../Analyser/Static/AppleII/Target.hpp"
|
#include "../../Analyser/Static/AppleII/Target.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -34,7 +36,8 @@ class ConcreteMachine:
|
|||||||
public KeyboardMachine::Machine,
|
public KeyboardMachine::Machine,
|
||||||
public CPU::MOS6502::BusHandler,
|
public CPU::MOS6502::BusHandler,
|
||||||
public Inputs::Keyboard,
|
public Inputs::Keyboard,
|
||||||
public AppleII::Machine {
|
public AppleII::Machine,
|
||||||
|
public Activity::Source {
|
||||||
private:
|
private:
|
||||||
struct VideoBusHandler : public AppleII::Video::BusHandler {
|
struct VideoBusHandler : public AppleII::Video::BusHandler {
|
||||||
public:
|
public:
|
||||||
@ -62,8 +65,8 @@ class ConcreteMachine:
|
|||||||
speaker_.run_for(audio_queue_, cycles_since_audio_update_.divide(Cycles(audio_divider)));
|
speaker_.run_for(audio_queue_, cycles_since_audio_update_.divide(Cycles(audio_divider)));
|
||||||
}
|
}
|
||||||
void update_cards() {
|
void update_cards() {
|
||||||
for(int c = 0; c < 7; ++c) {
|
for(const auto &card : cards_) {
|
||||||
if(cards_[c]) cards_[c]->run_for(cycles_since_card_update_, stretched_cycles_since_card_update_);
|
if(card) card->run_for(cycles_since_card_update_, stretched_cycles_since_card_update_);
|
||||||
}
|
}
|
||||||
cycles_since_card_update_ = 0;
|
cycles_since_card_update_ = 0;
|
||||||
stretched_cycles_since_card_update_ = 0;
|
stretched_cycles_since_card_update_ = 0;
|
||||||
@ -80,7 +83,7 @@ class ConcreteMachine:
|
|||||||
Cycles cycles_since_audio_update_;
|
Cycles cycles_since_audio_update_;
|
||||||
|
|
||||||
ROMMachine::ROMFetcher rom_fetcher_;
|
ROMMachine::ROMFetcher rom_fetcher_;
|
||||||
std::unique_ptr<AppleII::Card> cards_[7];
|
std::array<std::unique_ptr<AppleII::Card>, 7> cards_;
|
||||||
Cycles cycles_since_card_update_;
|
Cycles cycles_since_card_update_;
|
||||||
int stretched_cycles_since_card_update_ = 0;
|
int stretched_cycles_since_card_update_ = 0;
|
||||||
|
|
||||||
@ -372,6 +375,13 @@ class ConcreteMachine:
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Activity::Source
|
||||||
|
void set_activity_observer(Activity::Observer *observer) override {
|
||||||
|
for(const auto &card: cards_) {
|
||||||
|
if(card) card->set_activity_observer(observer);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "../../Processors/6502/6502.hpp"
|
#include "../../Processors/6502/6502.hpp"
|
||||||
#include "../../ClockReceiver/ClockReceiver.hpp"
|
#include "../../ClockReceiver/ClockReceiver.hpp"
|
||||||
|
#include "../../Activity/Observer.hpp"
|
||||||
|
|
||||||
namespace AppleII {
|
namespace AppleII {
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ class Card {
|
|||||||
|
|
||||||
/*! Performs a bus operation; the card is implicitly selected. */
|
/*! Performs a bus operation; the card is implicitly selected. */
|
||||||
virtual void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) = 0;
|
virtual void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) = 0;
|
||||||
|
|
||||||
|
/*! Supplies a target for observers. */
|
||||||
|
virtual void set_activity_observer(Activity::Observer *observer) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,3 +40,7 @@ void DiskIICard::run_for(Cycles cycles, int stretches) {
|
|||||||
void DiskIICard::set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive) {
|
void DiskIICard::set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive) {
|
||||||
diskii_.set_disk(disk, drive);
|
diskii_.set_disk(disk, drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiskIICard::set_activity_observer(Activity::Observer *observer) {
|
||||||
|
diskii_.set_activity_observer(observer);
|
||||||
|
}
|
||||||
|
@ -24,8 +24,11 @@ namespace AppleII {
|
|||||||
class DiskIICard: public Card {
|
class DiskIICard: public Card {
|
||||||
public:
|
public:
|
||||||
DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector);
|
DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector);
|
||||||
|
|
||||||
void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) override;
|
void perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) override;
|
||||||
void run_for(Cycles cycles, int stretches) override;
|
void run_for(Cycles cycles, int stretches) override;
|
||||||
|
void set_activity_observer(Activity::Observer *observer) override;
|
||||||
|
|
||||||
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
|
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user