-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpcapp.cpp
More file actions
84 lines (73 loc) · 1.94 KB
/
cpcapp.cpp
File metadata and controls
84 lines (73 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* cpcapp.cpp
*
* Created on: 15 lip 2016
* Author: wpk
*/
#include "cpcapp.h"
#include "cpc.h"
wxIMPLEMENT_APP_NO_MAIN(CPCApp);
int main(int argc, char** argv)
{
// This initializes SDL
SDL_Init( SDL_INIT_EVERYTHING );
return wxEntry(argc, argv);
}
CPCApp::CPCApp() {
// TODO Auto-generated constructor stub
}
bool CPCApp::OnInit() {
SetExitOnFrameDelete(false);
emu = new CPC();
emu->parse_opts(argc, argv);
emu->initialize();
ctrlframe = new CtrlFrame("Zee80 CPC", wxPoint(50, 50), wxSize(450, 340), *this);
ctrlframe->Show( true );
return true;
}
bool CPCApp::ProcessIdle() {
for (int i=0; i<10; i++) // TODO do it dynamically? Two event loops horror :/
emu->run();
if (cycle++ % 100000 == 0) {
wxString x;
x.Printf("Zee80 CPC load %.2f", emu->getLoad());
ctrlframe->SetStatusText(x);
}
return true;
}
CPCApp::~CPCApp() {
// TODO Auto-generated destructor stub
}
CtrlFrame::CtrlFrame(const wxString& title, const wxPoint& pos, const wxSize& size, CPCApp& app)
: wxFrame(NULL, wxID_ANY, title, pos, size), app(app)
{
wxPanel *panel = new wxPanel(this, -1);
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxButton* reset = new wxButton(this, BTN_RESET, _T("Reset"),
wxDefaultPosition, wxDefaultSize, 0);
wxButton* openfloppy = new wxButton(this, BTN_OPEN_FLOPPY, _T("Open Floppy"),
wxDefaultPosition, wxDefaultSize, 0);
vbox->Add(reset, 0, wxEXPAND);
vbox->Add(openfloppy, 0, wxEXPAND);
panel->SetSizer(vbox);
CreateStatusBar();
Centre();
}
void CtrlFrame::OnClose(wxCloseEvent& event)
{
SDL_Quit();
app.ExitMainLoop();
}
void CtrlFrame::OnOpenFloppy(wxCommandEvent& event)
{
wxFileDialog
openFileDialog(this, _("Open DSK file"), "", "",
"Disk images (*.dsk)|*.dsk", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() == wxID_CANCEL)
return;
app.emu->LoadFloppy(openFileDialog.GetPath().ToStdString());
}
void CtrlFrame::OnReset(wxCommandEvent& event)
{
app.emu->reset();
}