remove obsolete diskbytes class; fix addrbus rev reference

This commit is contained in:
Christopher Mosher 2019-01-27 14:49:34 -05:00
parent 694ff96d12
commit 2f10890b34
6 changed files with 6 additions and 212 deletions

View File

@ -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 \

View File

@ -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)
{
}

View File

@ -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);

View File

@ -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"),

View File

@ -1,132 +0,0 @@
/*
epple2
Copyright (C) 2008 by Christopher A. Mosher <cmosher01@gmail.com>
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/>.
*/
#include "diskbytes.h"
#include <vector>
#include <algorithm>
#include <istream>
#include <ostream>
#include <fstream>
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;
}
}

View File

@ -1,74 +0,0 @@
/*
epple2
Copyright (C) 2008 by Christopher A. Mosher <cmosher01@gmail.com>
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/>.
*/
#ifndef DISKBYTES_H
#define DISKBYTES_H
#include <string>
#include <vector>
class DiskBytes
{
private:
enum { TRACKS_PER_DISK = 0x23 };
enum { BYTES_PER_TRACK = 0x1A00 };
bool lss13;
std::vector<unsigned char> 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