2012-04-21 00:04:34 +00:00
|
|
|
/*
|
|
|
|
epple2
|
2015-07-29 01:14:58 +00:00
|
|
|
Copyright (C) 2008 by Christopher A. Mosher <cmosher01@gmail.com>
|
2012-04-21 00:04:34 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY, without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2022-12-10 16:26:39 +00:00
|
|
|
*/
|
2012-04-21 00:04:34 +00:00
|
|
|
#include "apple2.h"
|
|
|
|
#include "slots.h"
|
|
|
|
#include "videomode.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "addressbus.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "picturegenerator.h"
|
|
|
|
#include "textcharacters.h"
|
|
|
|
#include "video.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "paddles.h"
|
|
|
|
#include "paddlebuttonstates.h"
|
|
|
|
#include "speakerclicker.h"
|
|
|
|
#include "analogtv.h"
|
|
|
|
#include "powerupreset.h"
|
|
|
|
#include "diskcontroller.h"
|
|
|
|
#include "languagecard.h"
|
|
|
|
#include "screenimage.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
2013-12-20 00:44:06 +00:00
|
|
|
#include <istream>
|
2012-04-21 00:04:34 +00:00
|
|
|
#include <fstream>
|
|
|
|
|
2022-12-10 16:26:39 +00:00
|
|
|
Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates, AnalogTV& tv, HyperMode& fhyper, KeyboardBufferMode& buffered, ScreenImage& gui) :
|
|
|
|
slts(gui),
|
|
|
|
kbd(keypresses, fhyper, buffered),
|
|
|
|
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
|
|
|
ram(revision),
|
|
|
|
cassetteIn(gui),
|
|
|
|
cassetteOut(gui),
|
|
|
|
addressBus(gui, revision, ram, rom, kbd, videoMode, paddles, paddleButtonStates, speaker, cassetteIn, cassetteOut, slts),
|
|
|
|
picgen(tv, videoMode, revision),
|
|
|
|
video(videoMode, addressBus, picgen, textRows),
|
|
|
|
transistors("transistors"), // TODO load file from resources
|
|
|
|
cpu(NULL),
|
|
|
|
powerUpReset(*this),
|
|
|
|
revision(1) {
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|
|
|
|
|
2022-12-06 23:00:53 +00:00
|
|
|
Apple2::~Apple2() {
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|
|
|
|
|
2022-11-03 22:26:07 +00:00
|
|
|
void Apple2::useEpple2Cpu() {
|
|
|
|
if (this->cpu == NULL) {
|
|
|
|
std::cout << "Using fast Epple2 CPU emulator" << std::endl;
|
|
|
|
this->cpu = new CPU(this->addressBus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Apple2::useVisual6502Cpu() {
|
|
|
|
if (this->cpu == NULL) {
|
|
|
|
std::cout << "Using http://www.visual6502.org/ CPU emulation (which will be slow)." << std::endl;
|
|
|
|
this->cpu = new Emu6502(this->transistors, this->addressBus);
|
|
|
|
}
|
|
|
|
}
|
2012-04-21 00:04:34 +00:00
|
|
|
|
2018-12-27 20:03:46 +00:00
|
|
|
void Apple2::tick() {
|
2022-12-10 16:26:39 +00:00
|
|
|
useEpple2Cpu(); // default, if not already set
|
2022-11-03 22:26:07 +00:00
|
|
|
this->cpu->tick();
|
2018-12-27 20:03:46 +00:00
|
|
|
this->slts.tick();
|
|
|
|
this->video.tick();
|
|
|
|
this->paddles.tick();
|
|
|
|
this->speaker.tick();
|
2019-01-21 05:12:47 +00:00
|
|
|
this->cassetteIn.tick();
|
|
|
|
this->cassetteOut.tick();
|
2012-04-21 00:04:34 +00:00
|
|
|
|
2018-12-27 20:03:46 +00:00
|
|
|
if (this->revision > 0) {
|
|
|
|
this->powerUpReset.tick();
|
|
|
|
}
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|
|
|
|
|
2022-12-10 16:26:39 +00:00
|
|
|
void Apple2::powerOn() {
|
2022-12-04 04:18:52 +00:00
|
|
|
useEpple2Cpu(); // default, if not already set
|
2022-11-03 03:50:54 +00:00
|
|
|
this->ram.powerOn();
|
2022-11-03 22:26:07 +00:00
|
|
|
this->cpu->powerOn();
|
2022-11-03 03:50:54 +00:00
|
|
|
this->videoMode.powerOn();
|
|
|
|
this->video.powerOn();
|
|
|
|
this->picgen.powerOn();
|
|
|
|
this->powerUpReset.powerOn();
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|
|
|
|
|
2022-12-10 16:26:39 +00:00
|
|
|
void Apple2::powerOff() {
|
2022-11-03 03:50:54 +00:00
|
|
|
this->ram.powerOff();
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|
|
|
|
|
2022-12-10 16:26:39 +00:00
|
|
|
void Apple2::reset() {
|
|
|
|
useEpple2Cpu(); // default, if not already set
|
2022-11-03 22:26:07 +00:00
|
|
|
this->cpu->reset();
|
2022-11-03 03:50:54 +00:00
|
|
|
this->slts.reset();
|
2012-04-21 00:04:34 +00:00
|
|
|
}
|