diff --git a/src/Makefile.am b/src/Makefile.am index 62ed766..8748a63 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ epple2_CPPFLAGS = $(AM_CPPFLAGS) -DETCDIR=\"$(sysconfdir)\" epple2_SOURCES = a2colorsobserved.cpp addressbus.cpp analogtv.cpp apple2.cpp \ applentsc.cpp card.cpp cassette.cpp cassettein.cpp cassetteout.cpp \ clipboardhandler.cpp clockcard.cpp \ -configep2.cpp cpu.cpp diskbytes.cpp diskcontroller.cpp drive.cpp drivemotor.cpp \ +configep2.cpp cpu.cpp diskcontroller.cpp drive.cpp drivemotor.cpp \ emptyslot.cpp emulator.cpp firmwarecard.cpp gui.cpp hypermode.cpp \ keyboard.cpp keyboardbuffermode.cpp languagecard.cpp filterchroma.cpp \ filterluma.cpp lss.cpp main.cpp memory.cpp paddlebuttonstates.cpp \ @@ -28,7 +28,7 @@ tinyfiledialogs.cpp noinst_HEADERS = a2colorsobserved.h addressbus.h analogtv.h apple2.h applentsc.h \ card.h cassette.h cassettein.h cassetteout.h \ -clipboardhandler.h clockcard.h configep2.h cpu.h diskbytes.h \ +clipboardhandler.h clockcard.h configep2.h cpu.h \ diskcontroller.h drive.h drivemotor.h e2const.h emptyslot.h emulator.h firmwarecard.h font3x5.h gui.h \ hypermode.h keyboardbuffermode.h keyboard.h languagecard.h filterchroma.h \ filterluma.h lss.h memory.h paddlebuttonstates.h paddles.h picturegenerator.h \ diff --git a/src/addressbus.cpp b/src/addressbus.cpp index f8f73bb..8813a47 100644 --- a/src/addressbus.cpp +++ b/src/addressbus.cpp @@ -26,7 +26,7 @@ #include "cassetteout.h" #include "slots.h" -AddressBus::AddressBus(ScreenImage& gui, int revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts): +AddressBus::AddressBus(ScreenImage& gui, int& revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts): gui(gui), revision(revision), ram(ram), rom(rom), kbd(kbd), vid(vid), paddles(paddles), paddleButtonStates(paddleButtonStates), speaker(speaker), cassetteIn(cassetteIn), cassetteOut(cassetteOut), slts(slts) { } diff --git a/src/addressbus.h b/src/addressbus.h index 80381a0..d820dbc 100644 --- a/src/addressbus.h +++ b/src/addressbus.h @@ -32,7 +32,7 @@ class Slots; class AddressBus { private: ScreenImage& gui; - int revision; + int& revision; Memory& ram; Memory& rom; Keyboard& kbd; @@ -47,7 +47,7 @@ class AddressBus { unsigned char data; // this emulates the (floating) data bus public: - AddressBus(ScreenImage& gui, int revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts); + AddressBus(ScreenImage& gui, int& revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts); ~AddressBus(); unsigned char read(const unsigned short address); diff --git a/src/apple2.cpp b/src/apple2.cpp index 25606a8..40c0f40 100644 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -46,7 +46,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates cassetteIn(gui), cassetteOut(gui), addressBus(gui,revision,ram,rom,kbd,videoMode,paddles,paddleButtonStates,speaker,cassetteIn,cassetteOut,slts), - picgen(tv,videoMode,this->revision), + picgen(tv,videoMode,revision), video(videoMode,addressBus,picgen,textRows), #ifdef USE_EMU transistors("transistors"), diff --git a/src/diskbytes.cpp b/src/diskbytes.cpp deleted file mode 100644 index 6fdccf0..0000000 --- a/src/diskbytes.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - epple2 - Copyright (C) 2008 by Christopher A. Mosher - - 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 . -*/ -#include "diskbytes.h" - -#include -#include -#include -#include -#include - -DiskBytes::DiskBytes(bool lss13): - lss13(lss13) -{ - unload(); -} - -DiskBytes::~DiskBytes() -{ -} - -bool DiskBytes::load(const std::string& filePath) -{ - - -// TODO better I/O error handling during disk loading and saving - std::ifstream in(filePath.c_str(),std::ios::binary|std::ios::in); - if (!in.is_open()) - { - return false; - } - if (isLoaded()) - { - unload(); - } - for (int t(0); t < TRACKS_PER_DISK; ++t) - { - this->bytes[t].resize(BYTES_PER_TRACK); - in.read((char*)&this->bytes[t][0],BYTES_PER_TRACK); - } - in.close(); - - this->filePath = filePath; - - checkForWriteProtection(); - - this->loaded = true; - this->modified = false; - - return true; -} - -void DiskBytes::checkForWriteProtection() -{ - std::ofstream outf(filePath.c_str(),std::ios::binary|std::ios::app); - this->writable = outf.is_open(); - outf.close(); -} - -void DiskBytes::save() -{ - if (isWriteProtected() || !isLoaded()) - { - return; - } - std::ofstream out(filePath.c_str(),std::ios::binary); - for (int t(0); t < TRACKS_PER_DISK; ++t) - out.write((char*)&this->bytes[t][0],BYTES_PER_TRACK); - out.flush(); - out.close(); - - this->modified = false; -} - -void DiskBytes::unload() -{ - this->byt = 0; - this->writable = true; - this->loaded = false; - this->filePath = ""; - this->modified = false; -} - -unsigned char DiskBytes::get(const int track) -{ - if (!isLoaded()) - { - return 0xFF; - } - const unsigned char ret = this->bytes[track][this->byt]; - nextByte(); - return ret; -} - -void DiskBytes::put(const unsigned char track, const unsigned char value) -{ - if (TRACKS_PER_DISK <= track) - { - throw 0; - } - if (isWriteProtected() || !isLoaded()) - { - return; - } - this->bytes[track][this->byt] = value; - this->modified = true; - nextByte(); -} - -void inline DiskBytes::nextByte() -{ - // emulates circular disk track - ++this->byt; - if (this->byt >= BYTES_PER_TRACK) - { - this->byt = 0; - } -} diff --git a/src/diskbytes.h b/src/diskbytes.h deleted file mode 100644 index 6a6b7c9..0000000 --- a/src/diskbytes.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - epple2 - Copyright (C) 2008 by Christopher A. Mosher - - 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 . -*/ -#ifndef DISKBYTES_H -#define DISKBYTES_H - -#include -#include - -class DiskBytes -{ -private: - enum { TRACKS_PER_DISK = 0x23 }; - enum { BYTES_PER_TRACK = 0x1A00 }; - - bool lss13; - - std::vector bytes[TRACKS_PER_DISK]; - - std::string fileName; - std::string filePath; - bool writable; - bool loaded; - unsigned int byt; // represents rotational position of disk - bool modified; - - void nextByte(); - void checkForWriteProtection(); - -public: - DiskBytes(bool lss13); - ~DiskBytes(); - - bool load(const std::string& filePath); - std::string getFileName() - { - return this->fileName; - } - - bool isLoaded() - { - return this->loaded; - } - - void save(); - void unload(); - unsigned char get(const int track); - void put(const unsigned char track, const unsigned char value); - bool isWriteProtected() - { - return !this->writable; - } - - bool isModified() - { - return this->modified; - } -}; - -#endif