mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
Attempts to route Disk II requests to the thing itself.
This commit is contained in:
parent
7463edaa1b
commit
4bff44377a
@ -7,3 +7,31 @@
|
||||
//
|
||||
|
||||
#include "DiskII.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
using namespace Apple;
|
||||
|
||||
void DiskII::set_control(Control control, bool on) {
|
||||
printf("Set control %d %s\n", control, on ? "on" : "off");
|
||||
}
|
||||
|
||||
void DiskII::set_mode(Mode mode) {
|
||||
printf("Set mode %d\n", mode);
|
||||
}
|
||||
|
||||
void DiskII::select_drive(int drive) {
|
||||
printf("Select drive %d\n", drive);
|
||||
}
|
||||
|
||||
void DiskII::set_shift_register(uint8_t value) {
|
||||
printf("Set shift register\n");
|
||||
}
|
||||
|
||||
uint8_t DiskII::get_shift_register() {
|
||||
printf("Get shift register\n");
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
void DiskII::run_for(const Cycles cycles) {
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
||||
|
||||
#include "Card.hpp"
|
||||
#include "DiskIICard.hpp"
|
||||
#include "Video.hpp"
|
||||
|
||||
#include "../../Analyser/Static/AppleII/Target.hpp"
|
||||
@ -61,11 +62,8 @@ class ConcreteMachine:
|
||||
speaker_.run_for(audio_queue_, cycles_since_audio_update_.divide(Cycles(audio_divider)));
|
||||
}
|
||||
void update_cards() {
|
||||
cycles_since_card_update_ += stretched_cycles_since_card_update_ / 7;
|
||||
stretched_cycles_since_card_update_ %= 7;
|
||||
for(int c = 0; c < 7; ++c) {
|
||||
if(cards_[c])
|
||||
cards_[c]->run_for(cycles_since_card_update_, stretched_cycles_since_card_update_);
|
||||
if(cards_[c]) cards_[c]->run_for(cycles_since_card_update_, stretched_cycles_since_card_update_);
|
||||
}
|
||||
cycles_since_card_update_ = 0;
|
||||
stretched_cycles_since_card_update_ = 0;
|
||||
@ -83,7 +81,7 @@ class ConcreteMachine:
|
||||
Cycles cycles_since_audio_update_;
|
||||
|
||||
ROMMachine::ROMFetcher rom_fetcher_;
|
||||
AppleII::Card *cards_[7] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
|
||||
std::unique_ptr<AppleII::Card> cards_[7];
|
||||
Cycles cycles_since_card_update_;
|
||||
int stretched_cycles_since_card_update_ = 0;
|
||||
|
||||
@ -193,10 +191,10 @@ class ConcreteMachine:
|
||||
Decode the area conventionally used by cards for registers:
|
||||
C0n0--C0nF: card n - 8.
|
||||
*/
|
||||
const int card_number = (address - 0xc080) >> 4;
|
||||
const int card_number = (address - 0xc090) >> 4;
|
||||
if(cards_[card_number]) {
|
||||
update_cards();
|
||||
cards_[card_number]->perform_bus_operation(operation, address, value);
|
||||
cards_[card_number]->perform_bus_operation(operation, 0x100 | (address&0xf), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +266,7 @@ class ConcreteMachine:
|
||||
void configure_as_target(const Analyser::Static::Target *target) override {
|
||||
auto *const apple_target = dynamic_cast<const Analyser::Static::AppleII::Target *>(target);
|
||||
if(apple_target->has_disk) {
|
||||
// ... add Disk II
|
||||
cards_[6].reset(new AppleII::DiskIICard(rom_fetcher_, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef Card_h
|
||||
#define Card_h
|
||||
|
||||
#include "../../Processors/6502/6502.hpp"
|
||||
#include "../../ClockReceiver/ClockReceiver.hpp"
|
||||
|
||||
namespace AppleII {
|
||||
|
64
Machines/AppleII/DiskIICard.cpp
Normal file
64
Machines/AppleII/DiskIICard.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// DiskII.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 23/04/2018.
|
||||
// Copyright © 2018 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "DiskIICard.hpp"
|
||||
|
||||
using namespace AppleII;
|
||||
|
||||
DiskIICard::DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector) {
|
||||
auto roms = rom_fetcher(
|
||||
"DiskII",
|
||||
{
|
||||
"boot.rom",
|
||||
"state-machine.rom"
|
||||
});
|
||||
boot_ = std::move(*roms[0]);
|
||||
state_machine_ = std::move(*roms[1]);
|
||||
}
|
||||
|
||||
void DiskIICard::perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
if(isReadOperation(operation) && address < 0x100) {
|
||||
*value &= boot_[address];
|
||||
} else {
|
||||
using Control = Apple::DiskII::Control;
|
||||
using Mode = Apple::DiskII::Mode;
|
||||
switch(address & 0xf) {
|
||||
case 0x0: diskii_.set_control(Control::P0, false); break;
|
||||
case 0x1: diskii_.set_control(Control::P0, true); break;
|
||||
case 0x2: diskii_.set_control(Control::P1, false); break;
|
||||
case 0x3: diskii_.set_control(Control::P1, true); break;
|
||||
case 0x4: diskii_.set_control(Control::P2, false); break;
|
||||
case 0x5: diskii_.set_control(Control::P2, true); break;
|
||||
case 0x6: diskii_.set_control(Control::P3, false); break;
|
||||
case 0x7: diskii_.set_control(Control::P3, true); break;
|
||||
|
||||
case 0x8: diskii_.set_control(Control::Motor, false); break;
|
||||
case 0x9: diskii_.set_control(Control::Motor, true); break;
|
||||
|
||||
case 0xa: diskii_.select_drive(0); break;
|
||||
case 0xb: diskii_.select_drive(1); break;
|
||||
|
||||
case 0xc:
|
||||
/* shift register? */
|
||||
if(isReadOperation(operation))
|
||||
*value = diskii_.get_shift_register();
|
||||
break;
|
||||
case 0xd:
|
||||
/* data register? */
|
||||
diskii_.set_shift_register(*value);
|
||||
break;
|
||||
|
||||
case 0xe: diskii_.set_mode(Mode::Read); break;
|
||||
case 0xf: diskii_.set_mode(Mode::Write); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiskIICard::run_for(Cycles cycles, int stretches) {
|
||||
diskii_.run_for(cycles);
|
||||
}
|
35
Machines/AppleII/DiskIICard.hpp
Normal file
35
Machines/AppleII/DiskIICard.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// DiskII.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 23/04/2018.
|
||||
// Copyright © 2018 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef DiskIICard_hpp
|
||||
#define DiskIICard_hpp
|
||||
|
||||
#include "Card.hpp"
|
||||
#include "../ROMMachine.hpp"
|
||||
#include "../../Components/DiskII/DiskII.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace AppleII {
|
||||
|
||||
class DiskIICard: public Card {
|
||||
public:
|
||||
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 run_for(Cycles cycles, int stretches) override;
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> boot_;
|
||||
std::vector<uint8_t> state_machine_;
|
||||
Apple::DiskII diskii_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DiskIICard_hpp */
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ROMMachine {
|
||||
|
@ -606,6 +606,8 @@
|
||||
4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99121C8FBA6F0075DAFB /* TextureTarget.cpp */; };
|
||||
4BBFBB6C1EE8401E00C01E7A /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFBB6A1EE8401E00C01E7A /* ZX8081.cpp */; };
|
||||
4BBFFEE61F7B27F1005F3FEB /* TrackSerialiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFFEE51F7B27F1005F3FEB /* TrackSerialiser.cpp */; };
|
||||
4BC39568208EE6CF0044766B /* DiskIICard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC39566208EE6CF0044766B /* DiskIICard.cpp */; };
|
||||
4BC39569208EE6CF0044766B /* DiskIICard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC39566208EE6CF0044766B /* DiskIICard.cpp */; };
|
||||
4BC3B74F1CD194CC00F86E85 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3B74D1CD194CC00F86E85 /* Shader.cpp */; };
|
||||
4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3B7501CD1956900F86E85 /* OutputShader.cpp */; };
|
||||
4BC751B21D157E61006C31D9 /* 6522Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC751B11D157E61006C31D9 /* 6522Tests.swift */; };
|
||||
@ -1333,6 +1335,8 @@
|
||||
4BBFBB6B1EE8401E00C01E7A /* ZX8081.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ZX8081.hpp; path = Parsers/ZX8081.hpp; sourceTree = "<group>"; };
|
||||
4BBFFEE51F7B27F1005F3FEB /* TrackSerialiser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TrackSerialiser.cpp; sourceTree = "<group>"; };
|
||||
4BC39565208EDFCE0044766B /* Card.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Card.hpp; sourceTree = "<group>"; };
|
||||
4BC39566208EE6CF0044766B /* DiskIICard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DiskIICard.cpp; sourceTree = "<group>"; };
|
||||
4BC39567208EE6CF0044766B /* DiskIICard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DiskIICard.hpp; sourceTree = "<group>"; };
|
||||
4BC3B74D1CD194CC00F86E85 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = "<group>"; };
|
||||
4BC3B74E1CD194CC00F86E85 /* Shader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Shader.hpp; sourceTree = "<group>"; };
|
||||
4BC3B7501CD1956900F86E85 /* OutputShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OutputShader.cpp; sourceTree = "<group>"; };
|
||||
@ -1553,10 +1557,12 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4B15AA0C2082C799005E6C8D /* AppleII.cpp */,
|
||||
4BC39566208EE6CF0044766B /* DiskIICard.cpp */,
|
||||
4B15AA0A2082C799005E6C8D /* Video.cpp */,
|
||||
4B15AA092082C799005E6C8D /* AppleII.hpp */,
|
||||
4B15AA0B2082C799005E6C8D /* Video.hpp */,
|
||||
4BC39565208EDFCE0044766B /* Card.hpp */,
|
||||
4BC39567208EE6CF0044766B /* DiskIICard.hpp */,
|
||||
4B15AA0B2082C799005E6C8D /* Video.hpp */,
|
||||
);
|
||||
path = AppleII;
|
||||
sourceTree = "<group>";
|
||||
@ -3607,6 +3613,7 @@
|
||||
4B15AA0E2082C799005E6C8D /* Video.cpp in Sources */,
|
||||
4B055A991FAE85CB0060FFFF /* DiskController.cpp in Sources */,
|
||||
4B055ACC1FAE9B030060FFFF /* Electron.cpp in Sources */,
|
||||
4BC39569208EE6CF0044766B /* DiskIICard.cpp in Sources */,
|
||||
4B055AB11FAE86070060FFFF /* Tape.cpp in Sources */,
|
||||
4BFE7B881FC39D8900160B38 /* StandardOptions.cpp in Sources */,
|
||||
4B894533201967B4007DE474 /* 6502.cpp in Sources */,
|
||||
@ -3711,6 +3718,7 @@
|
||||
4B595FAD2086DFBA0083CAA8 /* AudioToggle.cpp in Sources */,
|
||||
4B1497921EE4B5A800CE2596 /* ZX8081.cpp in Sources */,
|
||||
4B643F3F1D77B88000D431D6 /* DocumentController.swift in Sources */,
|
||||
4BC39568208EE6CF0044766B /* DiskIICard.cpp in Sources */,
|
||||
4B4518861F75E91A00926311 /* MFMDiskController.cpp in Sources */,
|
||||
4B54C0BF1F8D8F450050900F /* Keyboard.cpp in Sources */,
|
||||
4B3FE75E1F3CF68B00448EE4 /* CPM.cpp in Sources */,
|
||||
|
Loading…
Reference in New Issue
Block a user