2018-04-14 23:46:15 +00:00
|
|
|
//
|
|
|
|
// AppleII.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/04/2018.
|
|
|
|
// Copyright © 2018 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "AppleII.hpp"
|
|
|
|
|
2018-05-11 02:17:13 +00:00
|
|
|
#include "../../Activity/Source.hpp"
|
2018-04-22 04:21:57 +00:00
|
|
|
#include "../ConfigurationTarget.hpp"
|
2018-04-14 23:46:15 +00:00
|
|
|
#include "../CRTMachine.hpp"
|
2018-04-16 01:11:30 +00:00
|
|
|
#include "../KeyboardMachine.hpp"
|
2018-04-15 01:41:26 +00:00
|
|
|
#include "../Utility/MemoryFuzzer.hpp"
|
2018-05-13 17:57:19 +00:00
|
|
|
#include "../Utility/StringSerialiser.hpp"
|
2018-04-15 01:41:26 +00:00
|
|
|
|
|
|
|
#include "../../Processors/6502/6502.hpp"
|
2018-04-18 02:28:13 +00:00
|
|
|
#include "../../Components/AudioToggle/AudioToggle.hpp"
|
|
|
|
|
|
|
|
#include "../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
2018-04-14 23:46:15 +00:00
|
|
|
|
2018-04-24 04:14:45 +00:00
|
|
|
#include "Card.hpp"
|
2018-04-24 05:11:31 +00:00
|
|
|
#include "DiskIICard.hpp"
|
2018-04-14 23:46:15 +00:00
|
|
|
#include "Video.hpp"
|
|
|
|
|
2018-04-24 04:14:45 +00:00
|
|
|
#include "../../Analyser/Static/AppleII/Target.hpp"
|
|
|
|
|
2018-05-11 02:17:13 +00:00
|
|
|
#include <array>
|
2018-04-14 23:46:15 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class ConcreteMachine:
|
|
|
|
public CRTMachine::Machine,
|
2018-04-22 04:21:57 +00:00
|
|
|
public ConfigurationTarget::Machine,
|
2018-04-16 01:11:30 +00:00
|
|
|
public KeyboardMachine::Machine,
|
2018-04-15 01:41:26 +00:00
|
|
|
public CPU::MOS6502::BusHandler,
|
2018-04-16 01:11:30 +00:00
|
|
|
public Inputs::Keyboard,
|
2018-05-11 02:17:13 +00:00
|
|
|
public AppleII::Machine,
|
|
|
|
public Activity::Source {
|
2018-04-15 23:35:08 +00:00
|
|
|
private:
|
|
|
|
struct VideoBusHandler : public AppleII::Video::BusHandler {
|
|
|
|
public:
|
|
|
|
VideoBusHandler(uint8_t *ram) : ram_(ram) {}
|
|
|
|
|
|
|
|
uint8_t perform_read(uint16_t address) {
|
|
|
|
return ram_[address];
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *ram_;
|
|
|
|
};
|
|
|
|
|
|
|
|
CPU::MOS6502::Processor<ConcreteMachine, false> m6502_;
|
|
|
|
VideoBusHandler video_bus_handler_;
|
|
|
|
std::unique_ptr<AppleII::Video::Video<VideoBusHandler>> video_;
|
|
|
|
int cycles_into_current_line_ = 0;
|
|
|
|
Cycles cycles_since_video_update_;
|
|
|
|
|
|
|
|
void update_video() {
|
|
|
|
video_->run_for(cycles_since_video_update_.flush());
|
|
|
|
}
|
2018-04-21 21:56:50 +00:00
|
|
|
static const int audio_divider = 8;
|
2018-04-18 02:28:13 +00:00
|
|
|
void update_audio() {
|
2018-04-21 21:56:50 +00:00
|
|
|
speaker_.run_for(audio_queue_, cycles_since_audio_update_.divide(Cycles(audio_divider)));
|
2018-04-18 02:28:13 +00:00
|
|
|
}
|
2018-04-24 04:14:45 +00:00
|
|
|
void update_cards() {
|
2018-05-11 02:17:13 +00:00
|
|
|
for(const auto &card : cards_) {
|
|
|
|
if(card) card->run_for(cycles_since_card_update_, stretched_cycles_since_card_update_);
|
2018-04-24 04:14:45 +00:00
|
|
|
}
|
|
|
|
cycles_since_card_update_ = 0;
|
|
|
|
stretched_cycles_since_card_update_ = 0;
|
|
|
|
}
|
2018-04-15 23:35:08 +00:00
|
|
|
|
2018-05-06 20:17:11 +00:00
|
|
|
uint8_t ram_[65536], aux_ram_[65536];
|
2018-05-03 23:37:32 +00:00
|
|
|
std::vector<uint8_t> apple2_rom_, apple2plus_rom_, rom_;
|
2018-04-15 23:35:08 +00:00
|
|
|
std::vector<uint8_t> character_rom_;
|
2018-04-16 01:11:30 +00:00
|
|
|
uint8_t keyboard_input_ = 0x00;
|
2018-04-14 23:46:15 +00:00
|
|
|
|
2018-04-18 02:28:13 +00:00
|
|
|
Concurrency::DeferringAsyncTaskQueue audio_queue_;
|
|
|
|
Audio::Toggle audio_toggle_;
|
|
|
|
Outputs::Speaker::LowpassSpeaker<Audio::Toggle> speaker_;
|
|
|
|
Cycles cycles_since_audio_update_;
|
|
|
|
|
2018-04-24 04:14:45 +00:00
|
|
|
ROMMachine::ROMFetcher rom_fetcher_;
|
2018-05-11 02:17:13 +00:00
|
|
|
std::array<std::unique_ptr<AppleII::Card>, 7> cards_;
|
2018-04-24 04:14:45 +00:00
|
|
|
Cycles cycles_since_card_update_;
|
|
|
|
int stretched_cycles_since_card_update_ = 0;
|
|
|
|
|
2018-05-06 00:24:03 +00:00
|
|
|
struct MemoryBlock {
|
|
|
|
uint8_t *read_pointer = nullptr;
|
|
|
|
uint8_t *write_pointer = nullptr;
|
|
|
|
} memory_blocks_[4]; // The IO page isn't included.
|
|
|
|
|
2018-05-06 20:17:11 +00:00
|
|
|
// MARK: - The language card.
|
|
|
|
struct {
|
|
|
|
bool bank1 = false;
|
|
|
|
bool read = false;
|
|
|
|
bool pre_write = false;
|
|
|
|
bool write = false;
|
|
|
|
} language_card_;
|
|
|
|
bool has_language_card_ = true;
|
|
|
|
void set_language_card_paging() {
|
|
|
|
if(has_language_card_ && !language_card_.write) {
|
|
|
|
memory_blocks_[2].write_pointer = &ram_[48*1024 + (language_card_.bank1 ? 0x1000 : 0x0000)];
|
|
|
|
memory_blocks_[3].write_pointer = &ram_[56*1024];
|
|
|
|
} else {
|
|
|
|
memory_blocks_[2].write_pointer = memory_blocks_[3].write_pointer = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(has_language_card_ && language_card_.read) {
|
|
|
|
memory_blocks_[2].read_pointer = &ram_[48*1024 + (language_card_.bank1 ? 0x1000 : 0x0000)];
|
|
|
|
memory_blocks_[3].read_pointer = &ram_[56*1024];
|
|
|
|
} else {
|
|
|
|
memory_blocks_[2].read_pointer = rom_.data();
|
|
|
|
memory_blocks_[3].read_pointer = rom_.data() + 0x1000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-13 15:30:04 +00:00
|
|
|
// MARK - typing
|
2018-05-13 17:57:19 +00:00
|
|
|
std::unique_ptr<Utility::StringSerialiser> string_serialiser_;
|
2018-05-13 15:30:04 +00:00
|
|
|
|
2018-04-15 23:35:08 +00:00
|
|
|
public:
|
2018-04-15 01:41:26 +00:00
|
|
|
ConcreteMachine():
|
2018-04-15 23:35:08 +00:00
|
|
|
m6502_(*this),
|
2018-04-18 02:28:13 +00:00
|
|
|
video_bus_handler_(ram_),
|
|
|
|
audio_toggle_(audio_queue_),
|
|
|
|
speaker_(audio_toggle_) {
|
2018-04-19 01:52:22 +00:00
|
|
|
// The system's master clock rate.
|
|
|
|
const float master_clock = 14318180.0;
|
|
|
|
|
|
|
|
// This is where things get slightly convoluted: establish the machine as having a clock rate
|
|
|
|
// equal to the number of cycles of work the 6502 will actually achieve. Which is less than
|
|
|
|
// the master clock rate divided by 14 because every 65th cycle is extended by one seventh.
|
|
|
|
set_clock_rate((master_clock / 14.0) * 65.0 / (65.0 + 1.0 / 7.0));
|
|
|
|
|
|
|
|
// The speaker, however, should think it is clocked at half the master clock, per a general
|
|
|
|
// decision to sample it at seven times the CPU clock (plus stretches).
|
2018-04-21 21:56:50 +00:00
|
|
|
speaker_.set_input_rate(static_cast<float>(master_clock / (2.0 * static_cast<float>(audio_divider))));
|
2018-04-19 01:52:22 +00:00
|
|
|
|
|
|
|
// Also, start with randomised memory contents.
|
2018-04-15 01:41:26 +00:00
|
|
|
Memory::Fuzz(ram_, sizeof(ram_));
|
2018-04-14 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
2018-05-06 20:17:11 +00:00
|
|
|
~ConcreteMachine() {
|
|
|
|
audio_queue_.flush();
|
|
|
|
}
|
|
|
|
|
2018-04-14 23:46:15 +00:00
|
|
|
void setup_output(float aspect_ratio) override {
|
2018-04-15 23:35:08 +00:00
|
|
|
video_.reset(new AppleII::Video::Video<VideoBusHandler>(video_bus_handler_));
|
|
|
|
video_->set_character_rom(character_rom_);
|
2018-04-14 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void close_output() override {
|
|
|
|
video_.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs::CRT::CRT *get_crt() override {
|
|
|
|
return video_->get_crt();
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs::Speaker::Speaker *get_speaker() override {
|
2018-04-18 02:28:13 +00:00
|
|
|
return &speaker_;
|
2018-04-14 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 01:41:26 +00:00
|
|
|
Cycles perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
2018-04-15 19:13:07 +00:00
|
|
|
++ cycles_since_video_update_;
|
2018-04-24 04:14:45 +00:00
|
|
|
++ cycles_since_card_update_;
|
2018-04-18 02:28:13 +00:00
|
|
|
cycles_since_audio_update_ += Cycles(7);
|
2018-04-15 19:13:07 +00:00
|
|
|
|
2018-05-06 00:24:03 +00:00
|
|
|
/*
|
|
|
|
There are five distinct zones of memory on an Apple II:
|
|
|
|
|
|
|
|
0000 — 0200 : the zero and stack pages, which can be paged independently on a IIe
|
|
|
|
0200 — c000 : the main block of RAM, which can be paged on a IIe
|
|
|
|
c000 — d000 : the IO area, including card ROMs
|
|
|
|
d000 — e000 : the low ROM area, which can contain indepdently-paged RAM with a language card
|
|
|
|
e000 — : the rest of ROM, also potentially replaced with RAM by a language card
|
|
|
|
*/
|
|
|
|
MemoryBlock *block = nullptr;
|
|
|
|
if(address < 0x200) block = &memory_blocks_[0];
|
2018-05-11 00:48:57 +00:00
|
|
|
else if(address < 0xc000) {
|
|
|
|
if(address < 0x6000 && !isReadOperation(operation)) update_video();
|
|
|
|
block = &memory_blocks_[1];
|
|
|
|
address -= 0x200;
|
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
else if(address < 0xd000) block = nullptr;
|
|
|
|
else if(address < 0xe000) {block = &memory_blocks_[2]; address -= 0xd000; }
|
|
|
|
else {block = &memory_blocks_[3]; address -= 0xe000; }
|
|
|
|
|
|
|
|
if(block) {
|
|
|
|
if(isReadOperation(operation)) *value = block->read_pointer[address];
|
|
|
|
else if(block->write_pointer) block->write_pointer[address] = *value;
|
|
|
|
} else {
|
|
|
|
switch(address) {
|
|
|
|
default:
|
|
|
|
if(isReadOperation(operation)) {
|
|
|
|
// Read-only switches.
|
2018-04-15 19:13:07 +00:00
|
|
|
switch(address) {
|
2018-05-06 00:24:03 +00:00
|
|
|
default: break;
|
|
|
|
|
2018-04-15 19:13:07 +00:00
|
|
|
case 0xc000:
|
2018-05-13 17:57:19 +00:00
|
|
|
if(string_serialiser_) {
|
|
|
|
*value = string_serialiser_->head() | 0x80;
|
2018-05-13 15:30:04 +00:00
|
|
|
} else {
|
|
|
|
*value = keyboard_input_;
|
|
|
|
}
|
2018-04-15 19:13:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
} else {
|
|
|
|
// Write-only switches.
|
2018-04-15 19:13:07 +00:00
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Read-write switches. */
|
|
|
|
case 0xc050: update_video(); video_->set_graphics_mode(); break;
|
|
|
|
case 0xc051: update_video(); video_->set_text_mode(); break;
|
|
|
|
case 0xc052: update_video(); video_->set_mixed_mode(false); break;
|
|
|
|
case 0xc053: update_video(); video_->set_mixed_mode(true); break;
|
|
|
|
case 0xc054: update_video(); video_->set_video_page(0); break;
|
|
|
|
case 0xc055: update_video(); video_->set_video_page(1); break;
|
|
|
|
case 0xc056: update_video(); video_->set_low_resolution(); break;
|
|
|
|
case 0xc057: update_video(); video_->set_high_resolution(); break;
|
|
|
|
|
|
|
|
case 0xc010:
|
|
|
|
keyboard_input_ &= 0x7f;
|
2018-05-13 17:57:19 +00:00
|
|
|
if(string_serialiser_) {
|
|
|
|
if(!string_serialiser_->advance())
|
|
|
|
string_serialiser_.reset();
|
2018-05-13 15:30:04 +00:00
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xc030:
|
|
|
|
update_audio();
|
|
|
|
audio_toggle_.set_output(!audio_toggle_.get_output());
|
|
|
|
break;
|
2018-05-06 20:17:11 +00:00
|
|
|
|
|
|
|
case 0xc080: case 0xc084: case 0xc088: case 0xc08c:
|
|
|
|
case 0xc081: case 0xc085: case 0xc089: case 0xc08d:
|
|
|
|
case 0xc082: case 0xc086: case 0xc08a: case 0xc08e:
|
|
|
|
case 0xc083: case 0xc087: case 0xc08b: case 0xc08f:
|
|
|
|
// Quotes below taken from Understanding the Apple II, p. 5-28 and 5-29.
|
|
|
|
|
|
|
|
// "A3 controls the 4K bank selection"
|
|
|
|
language_card_.bank1 = (address&8);
|
|
|
|
|
|
|
|
// "Access to $C080, $C083, $C084, $0087, $C088, $C08B, $C08C, or $C08F sets the READ ENABLE flip-flop"
|
|
|
|
// (other accesses reset it)
|
|
|
|
language_card_.read = !(((address&2) >> 1) ^ (address&1));
|
|
|
|
|
|
|
|
// "The WRITE ENABLE' flip-flop is reset by an odd read access to the $C08X range when the PRE-WRITE flip-flop is set."
|
|
|
|
if(language_card_.pre_write && isReadOperation(operation) && (address&1)) language_card_.write = false;
|
|
|
|
|
|
|
|
// "[The WRITE ENABLE' flip-flop] is set by an even access in the $C08X range."
|
|
|
|
if(!(address&1)) language_card_.write = true;
|
|
|
|
|
|
|
|
// ("Any other type of access causes the WRITE ENABLE' flip-flop to hold its current state.")
|
|
|
|
|
|
|
|
// "The PRE-WRITE flip-flop is set by an odd read access in the $C08X range. It is reset by an even access or a write access."
|
|
|
|
language_card_.pre_write = isReadOperation(operation) ? (address&1) : false;
|
|
|
|
|
|
|
|
set_language_card_paging();
|
|
|
|
break;
|
2018-04-24 04:14:45 +00:00
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
|
|
|
|
if(address >= 0xc100 && address < 0xc800) {
|
|
|
|
/*
|
|
|
|
Decode the area conventionally used by cards for ROMs:
|
|
|
|
0xCn00 — 0xCnff: card n.
|
|
|
|
*/
|
2018-05-12 01:46:30 +00:00
|
|
|
const size_t card_number = (address - 0xc100) >> 8;
|
2018-05-06 00:24:03 +00:00
|
|
|
if(cards_[card_number]) {
|
|
|
|
update_cards();
|
|
|
|
cards_[card_number]->perform_bus_operation(operation, address & 0xff, value);
|
|
|
|
}
|
|
|
|
} else if(address >= 0xc090 && address < 0xc100) {
|
|
|
|
/*
|
|
|
|
Decode the area conventionally used by cards for registers:
|
|
|
|
C0n0--C0nF: card n - 8.
|
|
|
|
*/
|
2018-05-12 01:46:30 +00:00
|
|
|
const size_t card_number = (address - 0xc090) >> 4;
|
2018-05-06 00:24:03 +00:00
|
|
|
if(cards_[card_number]) {
|
|
|
|
update_cards();
|
|
|
|
cards_[card_number]->perform_bus_operation(operation, 0x100 | (address&0xf), value);
|
|
|
|
}
|
2018-04-24 04:14:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-15 19:13:07 +00:00
|
|
|
// The Apple II has a slightly weird timing pattern: every 65th CPU cycle is stretched
|
|
|
|
// by an extra 1/7th. That's because one cycle lasts 3.5 NTSC colour clocks, so after
|
|
|
|
// 65 cycles a full line of 227.5 colour clocks have passed. But the high-rate binary
|
|
|
|
// signal approximation that produces colour needs to be in phase, so a stretch of exactly
|
2018-04-18 02:28:13 +00:00
|
|
|
// 0.5 further colour cycles is added. The video class handles that implicitly, but it
|
|
|
|
// needs to be accumulated here for the audio.
|
2018-04-15 19:13:07 +00:00
|
|
|
cycles_into_current_line_ = (cycles_into_current_line_ + 1) % 65;
|
|
|
|
if(!cycles_into_current_line_) {
|
2018-04-18 02:28:13 +00:00
|
|
|
++ cycles_since_audio_update_;
|
2018-04-24 04:14:45 +00:00
|
|
|
++ stretched_cycles_since_card_update_;
|
2018-04-15 19:13:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 01:41:26 +00:00
|
|
|
return Cycles(1);
|
|
|
|
}
|
|
|
|
|
2018-04-15 19:13:07 +00:00
|
|
|
void flush() {
|
|
|
|
update_video();
|
2018-04-18 02:28:13 +00:00
|
|
|
update_audio();
|
2018-04-24 16:03:30 +00:00
|
|
|
update_cards();
|
2018-04-18 02:28:13 +00:00
|
|
|
audio_queue_.perform();
|
2018-04-15 19:13:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-24 04:14:45 +00:00
|
|
|
bool set_rom_fetcher(const ROMMachine::ROMFetcher &roms_with_names) override {
|
2018-04-15 01:41:26 +00:00
|
|
|
auto roms = roms_with_names(
|
|
|
|
"AppleII",
|
|
|
|
{
|
2018-04-15 23:35:08 +00:00
|
|
|
"apple2o.rom",
|
2018-05-03 23:37:32 +00:00
|
|
|
"apple2.rom",
|
2018-04-20 02:14:22 +00:00
|
|
|
"apple2-character.rom"
|
2018-04-15 01:41:26 +00:00
|
|
|
});
|
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
if(!roms[0] || !roms[1] || !roms[2]) return false;
|
|
|
|
|
|
|
|
apple2_rom_ = std::move(*roms[0]);
|
|
|
|
apple2plus_rom_ = std::move(*roms[1]);
|
2018-04-15 01:41:26 +00:00
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
character_rom_ = std::move(*roms[2]);
|
2018-04-15 23:35:08 +00:00
|
|
|
|
2018-04-24 04:14:45 +00:00
|
|
|
rom_fetcher_ = roms_with_names;
|
|
|
|
|
2018-04-15 01:41:26 +00:00
|
|
|
return true;
|
2018-04-14 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 19:13:07 +00:00
|
|
|
void run_for(const Cycles cycles) override {
|
|
|
|
m6502_.run_for(cycles);
|
|
|
|
}
|
2018-04-16 01:11:30 +00:00
|
|
|
|
|
|
|
void set_key_pressed(Key key, char value, bool is_pressed) override {
|
2018-04-24 16:03:30 +00:00
|
|
|
if(key == Key::F12) {
|
|
|
|
m6502_.set_reset_line(is_pressed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-16 01:11:30 +00:00
|
|
|
if(is_pressed) {
|
2018-04-19 02:23:31 +00:00
|
|
|
// If no ASCII value is supplied, look for a few special cases.
|
|
|
|
if(!value) {
|
|
|
|
switch(key) {
|
|
|
|
case Key::Left: value = 8; break;
|
|
|
|
case Key::Right: value = 21; break;
|
|
|
|
case Key::Down: value = 10; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-16 01:11:30 +00:00
|
|
|
keyboard_input_ = static_cast<uint8_t>(value | 0x80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Inputs::Keyboard &get_keyboard() override {
|
|
|
|
return *this;
|
|
|
|
}
|
2018-04-22 04:21:57 +00:00
|
|
|
|
2018-05-13 15:30:04 +00:00
|
|
|
void type_string(const std::string &string) override {
|
2018-05-13 17:57:19 +00:00
|
|
|
string_serialiser_.reset(new Utility::StringSerialiser(string, true));
|
2018-05-13 15:30:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-22 04:21:57 +00:00
|
|
|
// MARK: ConfigurationTarget
|
|
|
|
void configure_as_target(const Analyser::Static::Target *target) override {
|
2018-05-03 23:37:32 +00:00
|
|
|
using Target = Analyser::Static::AppleII::Target;
|
|
|
|
auto *const apple_target = dynamic_cast<const Target *>(target);
|
|
|
|
|
|
|
|
if(apple_target->disk_controller != Target::DiskController::None) {
|
|
|
|
cards_[5].reset(new AppleII::DiskIICard(rom_fetcher_, apple_target->disk_controller == Target::DiskController::SixteenSector));
|
2018-04-24 04:14:45 +00:00
|
|
|
}
|
2018-04-25 02:44:45 +00:00
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
rom_ = (apple_target->model == Target::Model::II) ? apple2_rom_ : apple2plus_rom_;
|
|
|
|
if(rom_.size() > 12*1024) {
|
|
|
|
rom_.erase(rom_.begin(), rom_.begin() + static_cast<off_t>(rom_.size()) - 12*1024);
|
|
|
|
}
|
2018-05-06 00:24:03 +00:00
|
|
|
|
|
|
|
// Set up the default memory blocks.
|
|
|
|
memory_blocks_[0].read_pointer = memory_blocks_[0].write_pointer = ram_;
|
|
|
|
memory_blocks_[1].read_pointer = memory_blocks_[1].write_pointer = &ram_[0x200];
|
2018-05-06 20:17:11 +00:00
|
|
|
set_language_card_paging();
|
2018-05-03 23:37:32 +00:00
|
|
|
|
2018-04-25 02:44:45 +00:00
|
|
|
insert_media(apple_target->media);
|
2018-04-22 04:21:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool insert_media(const Analyser::Static::Media &media) override {
|
2018-04-25 03:24:44 +00:00
|
|
|
if(!media.disks.empty() && cards_[5]) {
|
|
|
|
dynamic_cast<AppleII::DiskIICard *>(cards_[5].get())->set_disk(media.disks[0], 0);
|
2018-04-25 02:44:45 +00:00
|
|
|
}
|
2018-04-22 04:21:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-05-11 02:17:13 +00:00
|
|
|
|
|
|
|
// MARK: Activity::Source
|
|
|
|
void set_activity_observer(Activity::Observer *observer) override {
|
|
|
|
for(const auto &card: cards_) {
|
|
|
|
if(card) card->set_activity_observer(observer);
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 23:46:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace AppleII;
|
|
|
|
|
|
|
|
Machine *Machine::AppleII() {
|
|
|
|
return new ConcreteMachine;
|
|
|
|
}
|
|
|
|
|
|
|
|
Machine::~Machine() {}
|