Compare commits
3 Commits
e0f4ad5ccc
...
1438999790
Author | SHA1 | Date |
---|---|---|
Christopher A. Mosher | 1438999790 | |
Christopher A. Mosher | 846d772b8f | |
Christopher A. Mosher | 01bc7fa02f |
|
@ -144,8 +144,8 @@ bool E2wxApp::OnInit() {
|
|||
InitBoostLog();
|
||||
|
||||
// TODO investigate redirecting wxLogs to boost
|
||||
// wxLog* logger = new wxLogStream(&std::cerr);
|
||||
// wxLog::SetActiveTarget(logger);
|
||||
wxLog* logger = new wxLogStream(&std::cerr);
|
||||
wxLog::SetActiveTarget(logger);
|
||||
// wxLogWarning("%s", "a warning has occurred");
|
||||
// wxLogInfo("%s", "informational");
|
||||
// wxLogVerbose("%s", "verbose");
|
||||
|
@ -186,19 +186,18 @@ bool E2wxApp::OnInit() {
|
|||
BOOST_LOG_TRIVIAL(info) << "Resource directory path: " << this->resdir;
|
||||
|
||||
wxXmlResource::Get()->InitAllHandlers();
|
||||
if (!wxXmlResource::Get()->LoadAllFiles(this->resdir.c_str())) {
|
||||
return false;
|
||||
}
|
||||
wxXmlResource::Get()->LoadAllFiles(this->resdir.c_str());
|
||||
|
||||
|
||||
|
||||
// note: the frame is responsible for deleting itself (via Destroy())
|
||||
frame = new E2wxFrame();
|
||||
frame->DoInit();
|
||||
frame->Show();
|
||||
|
||||
|
||||
|
||||
StartEmulator();
|
||||
// TODO option? or use last-state? StartEmulator();
|
||||
|
||||
|
||||
|
||||
|
@ -237,31 +236,39 @@ void E2wxApp::OnFnKeyPressed(const SDL_Keycode k) {
|
|||
|
||||
bool E2wxApp::CloseMainFrame() {
|
||||
bool r = false;
|
||||
BOOST_LOG_TRIVIAL(info) << "Received request to close main frame.";
|
||||
if (this->frame) {
|
||||
if (this->frame->Close(false)) {
|
||||
delete this->frame;
|
||||
BOOST_LOG_TRIVIAL(info) << "Main frame successfully deleted.";
|
||||
this->frame = nullptr;
|
||||
wxApp::ExitMainLoop();
|
||||
r = true;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << "User cancelled application shutdown.";
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << "No main frame found.";
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int E2wxApp::OnExit() {
|
||||
if (this->emu_timer) {
|
||||
delete this->emu_timer;
|
||||
this->emu_timer = nullptr;
|
||||
}
|
||||
if (this->emu) {
|
||||
delete this->emu;
|
||||
this->emu = nullptr;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "Begin application OnExit...";
|
||||
|
||||
delete wxXmlResource::Set(nullptr);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Deleting emulator instance...";
|
||||
StopEmulator();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Application OnExit complete.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void E2wxApp::OnFatalException() {
|
||||
BOOST_LOG_TRIVIAL(info) << "Application will handle fatal exception...";
|
||||
|
||||
wxDebugReport report;
|
||||
report.AddAll();
|
||||
|
||||
|
@ -383,13 +390,21 @@ void E2wxApp::InitBoostLog() {
|
|||
|
||||
|
||||
|
||||
void E2wxApp::StopEmulator() {
|
||||
if (EnsureCanQuit()) {
|
||||
if (this->emu_timer) {
|
||||
delete this->emu_timer;
|
||||
this->emu_timer = nullptr;
|
||||
}
|
||||
if (this->emu) {
|
||||
delete this->emu;
|
||||
this->emu = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void E2wxApp::StartEmulator() {
|
||||
if (this->emu_timer) {
|
||||
delete this->emu_timer;
|
||||
}
|
||||
if (this->emu) {
|
||||
delete this->emu;
|
||||
}
|
||||
StopEmulator();
|
||||
|
||||
this->emu = new Emulator();
|
||||
E2Config cfg{this->arg_configfile, this->opt_config_from_prefs_only};
|
||||
|
|
|
@ -70,7 +70,6 @@ class E2wxApp : public wxApp {
|
|||
|
||||
const std::filesystem::path BuildLogFilePath() const;
|
||||
void InitBoostLog();
|
||||
void StartEmulator();
|
||||
|
||||
public:
|
||||
E2wxApp();
|
||||
|
@ -84,6 +83,9 @@ public:
|
|||
const std::filesystem::path GetConfigDir() const;
|
||||
const std::filesystem::path GetDocumentsDir() const;
|
||||
|
||||
void StartEmulator();
|
||||
void StopEmulator();
|
||||
|
||||
void OnFnKeyPressed(const SDL_Keycode k);
|
||||
|
||||
bool CloseMainFrame();
|
||||
|
|
|
@ -22,12 +22,16 @@
|
|||
#include "E2wxApp.h"
|
||||
#include "PreferencesDialog.h"
|
||||
#include "gui.h"
|
||||
|
||||
#include <wx/menu.h>
|
||||
#include <wx/accel.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/persist/toplevel.h>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
|
||||
|
||||
enum E2MenuID {
|
||||
ID_MENUITEM_POWER = wxID_HIGHEST+1,
|
||||
|
@ -37,11 +41,13 @@ enum E2MenuID {
|
|||
ID_MENUITEM_RESET,
|
||||
ID_MENUITEM_SCREEN_SHOT,
|
||||
ID_MENUITEM_TOGGLE_BUFFERED,
|
||||
ID_MENUITEM_START_EMULATOR,
|
||||
ID_MENUITEM_STOP_EMULATOR,
|
||||
};
|
||||
|
||||
wxBEGIN_EVENT_TABLE(E2wxFrame, wxFrame)
|
||||
EVT_CLOSE(E2wxFrame::HandleUserQuitRequest)
|
||||
EVT_MENU(wxID_EXIT, E2wxFrame::OnExit)
|
||||
EVT_MENU(wxID_EXIT, E2wxFrame::OnFileExitCommand)
|
||||
EVT_MENU(wxID_PREFERENCES, E2wxFrame::OnPreferences)
|
||||
EVT_MENU(wxID_ABOUT, E2wxFrame::OnAbout)
|
||||
EVT_MENU(ID_MENUITEM_POWER, E2wxFrame::OnTogglePower)
|
||||
|
@ -52,6 +58,8 @@ wxBEGIN_EVENT_TABLE(E2wxFrame, wxFrame)
|
|||
EVT_MENU(wxID_PASTE, E2wxFrame::OnPaste)
|
||||
EVT_MENU(ID_MENUITEM_SCREEN_SHOT, E2wxFrame::OnScreenShot)
|
||||
EVT_MENU(ID_MENUITEM_TOGGLE_BUFFERED, E2wxFrame::OnToggleBuffered)
|
||||
EVT_MENU(ID_MENUITEM_START_EMULATOR, E2wxFrame::OnStartEmulator)
|
||||
EVT_MENU(ID_MENUITEM_STOP_EMULATOR, E2wxFrame::OnStopEmulator)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -80,6 +88,11 @@ void E2wxFrame::InitMenuBar() {
|
|||
|
||||
wxMenu *menuFile = new wxMenu();
|
||||
menuBar->Append(menuFile, "&File");
|
||||
wxMenuItem *miStart = menuFile->Append(ID_MENUITEM_START_EMULATOR, "Open Emulator");
|
||||
miStart->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, 'O'));
|
||||
wxMenuItem *miStop = menuFile->Append(ID_MENUITEM_STOP_EMULATOR, "Close Emulator");
|
||||
miStop->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, 'W'));
|
||||
menuFile->AppendSeparator();
|
||||
wxMenuItem *miExit = menuFile->Append(wxID_EXIT);
|
||||
miExit->AddExtraAccel(wxAcceleratorEntry(wxACCEL_NORMAL, WXK_F9));
|
||||
|
||||
|
@ -128,24 +141,35 @@ void E2wxFrame::InitStatusBar() {
|
|||
|
||||
|
||||
void E2wxFrame::HandleUserQuitRequest(wxCloseEvent& event) {
|
||||
// TODO how to handle event.CanVeto() ? I'd like to auto-save everything
|
||||
if (wxGetApp().EnsureCanQuit()) {
|
||||
event.Skip();
|
||||
BOOST_LOG_TRIVIAL(info) << "Main frame will handle request to close application...";
|
||||
if (!event.CanVeto()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Application is being forced to quit; any unsaved changes will be discarded.";
|
||||
// TODO how to handle !event.CanVeto() ?
|
||||
// I'd like to auto-save everything
|
||||
Destroy();
|
||||
} else if (wxGetApp().EnsureCanQuit()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Destroying main frame now...";
|
||||
Destroy();
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << "User cancelled closing main frame.";
|
||||
event.Veto();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void E2wxFrame::OnExit(wxCommandEvent& event) {
|
||||
void E2wxFrame::OnFileExitCommand(wxCommandEvent& event) {
|
||||
Close(false);
|
||||
}
|
||||
|
||||
void E2wxFrame::OnPreferences(wxCommandEvent& event) {
|
||||
PreferencesDialog *dlg = new PreferencesDialog(this);
|
||||
dlg->OnInit();
|
||||
dlg->ShowModal();
|
||||
if (dlg->OnInit()) {
|
||||
dlg->ShowModal();
|
||||
dlg->Destroy();
|
||||
}
|
||||
// TODO re-configure emulator here
|
||||
wxGetApp().StartEmulator();
|
||||
}
|
||||
|
||||
void E2wxFrame::OnAbout(wxCommandEvent& event) {
|
||||
|
@ -164,7 +188,7 @@ void E2wxFrame::OnAbout(wxCommandEvent& event) {
|
|||
|
||||
|
||||
void E2wxFrame::OnTogglePower(wxCommandEvent& event) {
|
||||
GUI::queueTogglePower();
|
||||
wxGetApp().TogglePower();
|
||||
}
|
||||
|
||||
void E2wxFrame::OnCycleMonitor(wxCommandEvent& event) {
|
||||
|
@ -194,3 +218,11 @@ void E2wxFrame::OnScreenShot(wxCommandEvent& event) {
|
|||
void E2wxFrame::OnToggleBuffered(wxCommandEvent& event) {
|
||||
wxGetApp().ToggleBuffered();
|
||||
}
|
||||
|
||||
void E2wxFrame::OnStartEmulator(wxCommandEvent& event) {
|
||||
wxGetApp().StartEmulator();
|
||||
}
|
||||
|
||||
void E2wxFrame::OnStopEmulator(wxCommandEvent& event){
|
||||
wxGetApp().StopEmulator();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
|
||||
void HandleUserQuitRequest(wxCloseEvent& event);
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnFileExitCommand(wxCommandEvent& event);
|
||||
void OnPreferences(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
|
@ -50,6 +50,8 @@ private:
|
|||
void OnPaste(wxCommandEvent& event);
|
||||
void OnScreenShot(wxCommandEvent& event);
|
||||
void OnToggleBuffered(wxCommandEvent& event);
|
||||
void OnStartEmulator(wxCommandEvent& event);
|
||||
void OnStopEmulator(wxCommandEvent& event);
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
|
|
@ -16,14 +16,15 @@
|
|||
#include "TransNetwork.h"
|
||||
#include "TransCache.h"
|
||||
#include "SegmentCache.h"
|
||||
#include <istream>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
class AddressBus;
|
||||
|
||||
class Emu6502 : public AbstractCpu {
|
||||
public:
|
||||
|
||||
Emu6502(std::istream& transistors, AddressBus& mem) : tn(transistors, segs, transes), c(tn), trace(segs, transes, c), cpu(mem, trace, c), cpuhelper(cpu, c) {
|
||||
Emu6502(std::filesystem::path& transistors, AddressBus& mem) : tn(transistors, segs, transes), c(tn), trace(segs, transes, c), cpu(mem, trace, c), cpuhelper(cpu, c) {
|
||||
}
|
||||
|
||||
virtual ~Emu6502() {
|
||||
|
|
|
@ -132,10 +132,14 @@ void PreferencesDialog::BuildItemTree() {
|
|||
this->GetSizer()->Layout();
|
||||
}
|
||||
|
||||
void PreferencesDialog::OnInit() {
|
||||
bool PreferencesDialog::OnInit() {
|
||||
wxConfigBase::Get()->Read("/ActivePreferences/name", &this->active, "");
|
||||
|
||||
wxXmlResource::Get()->LoadDialog(this, this->parent, "Preferences");
|
||||
const bool loaded = wxXmlResource::Get()->LoadDialog(this, this->parent, "Preferences");
|
||||
if (!loaded) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Could not load Preferences dialog resources.";
|
||||
return false;
|
||||
}
|
||||
|
||||
SetSize(SIZ_DLG);
|
||||
|
||||
|
@ -144,6 +148,8 @@ void PreferencesDialog::OnInit() {
|
|||
CTRL(wxTreeCtrl, treItems);
|
||||
treItems->SetFocus();
|
||||
treItems->SelectItem(treItems->GetRootItem());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PreferencesDialog::Save(const std::filesystem::path& to) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
PreferencesDialog(wxWindow *parent);
|
||||
~PreferencesDialog();
|
||||
|
||||
void OnInit();
|
||||
bool OnInit();
|
||||
};
|
||||
|
||||
#endif /* PREFERENCESDIALOG_H */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
/*
|
||||
* File: TransNetwork.cpp
|
||||
* Author: cmosher
|
||||
*
|
||||
*
|
||||
* Created on December 11, 2013, 10:44 AM
|
||||
*/
|
||||
|
||||
|
@ -10,12 +10,20 @@
|
|||
#include "SegmentCache.h"
|
||||
#include "StateCalculator.h"
|
||||
#include "trans.h"
|
||||
#include "E2wxApp.h"
|
||||
#include "e2filesystem.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
TransNetwork::TransNetwork(std::filesystem::path& p, SegmentCache& segs, TransCache& transes) : segs(segs), transes(transes) {
|
||||
std::filesystem::path inpath = valid_input_file(p, wxGetApp().GetResDir());
|
||||
|
||||
std::ifstream in(inpath);
|
||||
|
||||
TransNetwork::TransNetwork(std::istream& in, SegmentCache& segs, TransCache& transes) : segs(segs), transes(transes) {
|
||||
std::string c1, gate, c2;
|
||||
in >> c1 >> gate >> c2;
|
||||
while (in.good()) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef TRANSNETWORK_H
|
||||
#define TRANSNETWORK_H
|
||||
|
||||
#include <istream>
|
||||
#include <filesystem>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
|
@ -20,7 +20,7 @@ class Trans;
|
|||
class TransNetwork final {
|
||||
public:
|
||||
|
||||
TransNetwork(std::istream& readFromHere, SegmentCache& segs, TransCache& transes);
|
||||
TransNetwork(std::filesystem::path& readFromHere, SegmentCache& segs, TransCache& transes);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -48,24 +48,27 @@ 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),
|
||||
transistors("transistors"),
|
||||
cpu(nullptr),
|
||||
powerUpReset(*this),
|
||||
revision(1) {
|
||||
}
|
||||
|
||||
Apple2::~Apple2() {
|
||||
if (this->cpu) {
|
||||
delete this->cpu;
|
||||
}
|
||||
}
|
||||
|
||||
void Apple2::useEpple2Cpu() {
|
||||
if (this->cpu == NULL) {
|
||||
if (this->cpu == nullptr) {
|
||||
std::cout << "Using fast Epple2 CPU emulator" << std::endl;
|
||||
this->cpu = new CPU(this->addressBus);
|
||||
}
|
||||
}
|
||||
|
||||
void Apple2::useVisual6502Cpu() {
|
||||
if (this->cpu == NULL) {
|
||||
if (this->cpu == nullptr) {
|
||||
std::cout << "Using http://www.visual6502.org/ CPU emulation (which will be slow)." << std::endl;
|
||||
this->cpu = new Emu6502(this->transistors, this->addressBus);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
#include "cassettein.h"
|
||||
#include "cassetteout.h"
|
||||
#include "Emu6502.h"
|
||||
#include <fstream>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
class Emulator;
|
||||
class ScreenImage;
|
||||
|
||||
|
@ -57,7 +59,7 @@ class Apple2 : public Timable
|
|||
PictureGenerator picgen;
|
||||
TextCharacters textRows;
|
||||
Video video;
|
||||
std::ifstream transistors;
|
||||
std::filesystem::path transistors;
|
||||
AbstractCpu* cpu;
|
||||
PowerUpReset powerUpReset;
|
||||
int revision;
|
||||
|
|
|
@ -186,6 +186,7 @@ void E2Command::tryParseLine(const std::string& line, MemoryRandomAccess& ram, M
|
|||
trim(file);
|
||||
std::ifstream *memfile = new std::ifstream(file.c_str(), std::ios::binary);
|
||||
if (!memfile->is_open()) {
|
||||
delete memfile;
|
||||
std::filesystem::path f = wxGetApp().GetResDir();
|
||||
f /= file;
|
||||
memfile = new std::ifstream(f, std::ios::binary);
|
||||
|
@ -216,6 +217,7 @@ void E2Command::tryParseLine(const std::string& line, MemoryRandomAccess& ram, M
|
|||
throw ConfigException("error at \"" + romtype + "\"; expected rom, rom7, or rombank");
|
||||
}
|
||||
memfile->close();
|
||||
delete memfile;
|
||||
} else if (cmd == "load" || cmd == "save" || cmd == "unload") {
|
||||
std::string slotk;
|
||||
tok >> slotk;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
||||
|
@ -222,6 +224,7 @@ static bool translateKeysToAppleModernized(SDL_Keycode keycode, SDL_Keymod modif
|
|||
// Take real-world keystrokes from SDL and filter them to emulate the Apple ][ keyboard
|
||||
void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||
if (keyEvent.repeat) {
|
||||
// To repeat on the real Apple ][, you need to use the REPT key (emulated below by F10)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -235,22 +238,19 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
|||
}
|
||||
|
||||
if (sym == SDLK_F10) {
|
||||
// ...start auto-repeat
|
||||
// handle REPT key
|
||||
this->repeat = true;
|
||||
this->rept = CYCLES_PER_REPT;
|
||||
return;
|
||||
} else if (SDLK_F1 <= sym && sym <= SDLK_F12) {
|
||||
wxGetApp().OnFnKeyPressed(sym);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char key;
|
||||
const bool sendKey = translateKeysToAppleModernized(sym, mod, &key);
|
||||
|
||||
if (sendKey) {
|
||||
//printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80);
|
||||
this->keypresses.push(key);
|
||||
this->lastKeyDown = key;
|
||||
} else {
|
||||
unsigned char key;
|
||||
const bool sendKey = translateKeysToAppleModernized(sym, mod, &key);
|
||||
if (sendKey) {
|
||||
//printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80);
|
||||
this->keypresses.push(key);
|
||||
this->lastKeyDown = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,6 +296,8 @@ static int askSave() {
|
|||
}
|
||||
|
||||
bool Emulator::isSafeToQuit() {
|
||||
BOOST_LOG_TRIVIAL(info) << "Checking for any unsaved changes...";
|
||||
|
||||
this->screenImage.exitFullScreen();
|
||||
|
||||
if (!this->apple2.cassetteOut.eject()) {
|
||||
|
|
|
@ -51,14 +51,16 @@ class Emulator {
|
|||
unsigned char lastKeyDown;
|
||||
Uint32 prev_ms;
|
||||
|
||||
void dispatchKeyDown(const SDL_KeyboardEvent& keyEvent);
|
||||
void dispatchKeyUp(const SDL_KeyboardEvent& keyEvent);
|
||||
void powerOnComputer();
|
||||
void powerOffComputer();
|
||||
|
||||
void handleRepeatKey();
|
||||
void handleAnyPendingEvents();
|
||||
|
||||
void dispatchKeyDown(const SDL_KeyboardEvent& keyEvent);
|
||||
void dispatchKeyUp(const SDL_KeyboardEvent& keyEvent);
|
||||
|
||||
void handleRepeatKey();
|
||||
|
||||
public:
|
||||
Emulator();
|
||||
virtual ~Emulator();
|
||||
|
|
40
src/gui.cpp
40
src/gui.cpp
|
@ -15,18 +15,15 @@
|
|||
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 <iostream>
|
||||
|
||||
#include "gui.h"
|
||||
#include <SDL.h>
|
||||
|
||||
/*
|
||||
* Initialize SDL 2
|
||||
*/
|
||||
|
||||
|
||||
GUI::GUI() {
|
||||
const int result = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
|
||||
if (result != 0) {
|
||||
std::cerr << "Failed to initialize SDL: " << SDL_GetError() << std::endl;
|
||||
throw GUI::NotInitException();
|
||||
}
|
||||
}
|
||||
|
@ -35,40 +32,9 @@ GUI::~GUI() {
|
|||
SDL_Quit();
|
||||
}
|
||||
|
||||
static void pushSdlEvent(SDL_Event *e) {
|
||||
const int r = SDL_PushEvent(e);
|
||||
|
||||
if (r < 0) {
|
||||
std::cerr << "SDL reported error: " << SDL_GetError() << std::endl;
|
||||
} else if (r == 0) {
|
||||
std::cerr << "SDL filtered event, sorry" << std::endl;
|
||||
} else if (r == 1) {
|
||||
std::cerr << "Pushed event to SDL" << std::endl;
|
||||
} else {
|
||||
std::cerr << "SDL reported unexpected error code: " << r << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::queueTogglePower() {
|
||||
SDL_Event *e = new SDL_Event(); // note: creating struct on the stack doesn't seem to work
|
||||
e->type = SDL_KEYDOWN;
|
||||
e->key.keysym.sym = SDLK_F1;
|
||||
pushSdlEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
void GUI::queueQuit() {
|
||||
SDL_Event *e = new SDL_Event();
|
||||
e->type = SDL_KEYDOWN;
|
||||
e->key.keysym.sym = SDLK_F9;
|
||||
pushSdlEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GUI::NotInitException::NotInitException() : runtime_error("Unable to initialize SDL") {
|
||||
SDL_GetError();
|
||||
GUI::NotInitException::NotInitException() : runtime_error(SDL_GetError()) {
|
||||
}
|
||||
|
||||
GUI::NotInitException::~NotInitException() {
|
||||
|
|
|
@ -25,9 +25,6 @@ public:
|
|||
GUI();
|
||||
virtual ~GUI();
|
||||
|
||||
static void queueQuit();
|
||||
static void queueTogglePower();
|
||||
|
||||
class NotInitException : public std::runtime_error {
|
||||
public:
|
||||
NotInitException();
|
||||
|
|
|
@ -34,6 +34,9 @@ LanguageCard::LanguageCard(ScreenImage& gui, int slot):
|
|||
|
||||
LanguageCard::~LanguageCard()
|
||||
{
|
||||
for (Memory* m : this->ramBank) {
|
||||
delete m;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,15 +57,19 @@ class ScreenException {
|
|||
};
|
||||
|
||||
ScreenImage::ScreenImage() :
|
||||
fullscreen(false),
|
||||
buffer(true),
|
||||
display(AnalogTV::TV_OLD_COLOR),
|
||||
slotnames(8),
|
||||
cassInName(32, ' '),
|
||||
cassOutName(32, ' ') {
|
||||
fullscreen(false),
|
||||
buffer(true),
|
||||
display(AnalogTV::TV_OLD_COLOR),
|
||||
slotnames(8),
|
||||
cassInName(32, ' '),
|
||||
cassOutName(32, ' ') {
|
||||
createScreen();
|
||||
}
|
||||
|
||||
ScreenImage::~ScreenImage() {
|
||||
destroyScreen();
|
||||
}
|
||||
|
||||
void ScreenImage::exitFullScreen() {
|
||||
if (this->fullscreen) {
|
||||
toggleFullScreen();
|
||||
|
@ -106,6 +110,12 @@ void ScreenImage::createScreen() {
|
|||
notifyObservers();
|
||||
}
|
||||
|
||||
void ScreenImage::destroyScreen() {
|
||||
SDL_DestroyTexture(this->texture);
|
||||
SDL_DestroyRenderer(this->renderer);
|
||||
SDL_DestroyWindow(this->window);
|
||||
}
|
||||
|
||||
void ScreenImage::drawLabels() {
|
||||
drawText("EPPLE ][", 0, 141);
|
||||
drawText("ANNUNCIATORS: 0: 1: 2: 3:", 65, 17);
|
||||
|
@ -275,9 +285,6 @@ void ScreenImage::drawPower(bool on) {
|
|||
notifyObservers();
|
||||
}
|
||||
|
||||
ScreenImage::~ScreenImage() {
|
||||
}
|
||||
|
||||
void ScreenImage::notifyObservers() {
|
||||
const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW * sizeof (unsigned int));
|
||||
if (e) {
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
bool buffer;
|
||||
AnalogTV::DisplayType display;
|
||||
void createScreen();
|
||||
void destroyScreen();
|
||||
std::vector<std::string> slotnames;
|
||||
std::string cassInName;
|
||||
std::string cassOutName;
|
||||
|
|
|
@ -29,6 +29,11 @@ Slots::Slots(ScreenImage& gui):
|
|||
|
||||
Slots::~Slots()
|
||||
{
|
||||
for (Card *card : this->cards) {
|
||||
if (card != &this->empty) {
|
||||
delete card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char Slots::io(const int islot, const int iswch, const unsigned char b, const bool writing)
|
||||
|
|
Loading…
Reference in New Issue