28 |
29 | Historical note:
30 |
31 | openMSX Catapult was originally developed by Manuel Bilderbeek in Qt 3 (for
32 | Linux), with the help of Michael Goettsche. Soon Herman Oudejans made a Windows
33 | version in Visual Studio with MFC. However, we wanted to make a common program
34 | that is portable to different operating systems, so we started a total rewrite
35 | based on wxWidgets and added it as a subproject to openMSX CVS. This is the
36 | result!
37 |
--------------------------------------------------------------------------------
/doc/manual/audio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/audio.png
--------------------------------------------------------------------------------
/doc/manual/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | openMSX Catapult Manuals
9 |
10 |
11 |
12 |
13 | openMSX Catapult Manuals
14 |
15 |
16 | The openMSX Catapult documentation is split into a number of separate documents,
17 | each with their own purpose and intended audience.
18 |
19 |
20 |
21 |
22 | - Compilation Guide
23 | -
24 | This guide describes how you can get the openMSX Catapult sources and compile them.
25 | If you downloaded a binary release, you can skip this.
26 |
27 |
28 | - User's Manual
29 | -
30 | This manual describes all the things you can do with openMSX Catapult
31 | once it is fully running.
32 |
33 |
34 |
35 |
36 |
37 | Please also read all documentation of openMSX itself. You can find it here.
38 |
39 |
40 |
41 | To the
42 | openMSX Home Page.
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/doc/manual/input.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/input.png
--------------------------------------------------------------------------------
/doc/manual/mainscreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/mainscreen.png
--------------------------------------------------------------------------------
/doc/manual/manual-minty.css:
--------------------------------------------------------------------------------
1 | @import "manual.css";
2 | p.version {
3 | border-top: 2px groove #60C090;
4 | }
5 | h1 {
6 | border-bottom: 2px groove #60C090;
7 | }
8 | h2 {
9 | background-color: #90FFC0;
10 | padding-left: 4pt;
11 | }
12 | h3 {
13 | background-color: #C8FFE0;
14 | padding-left: 4pt;
15 | }
16 | h4 {
17 | background-color: #E8FFF0;
18 | padding-left: 4pt;
19 | }
20 | a.internal, a.external:visited {
21 | color: #184830;
22 | }
23 | a.external:link {
24 | color: #30A860;
25 | }
26 | a.external:active {
27 | color: #40F080;
28 | }
29 |
--------------------------------------------------------------------------------
/doc/manual/manual-purple.css:
--------------------------------------------------------------------------------
1 | @import "manual.css";
2 | p.version {
3 | border-top: 2px groove #8070C0;
4 | }
5 | h1 {
6 | border-bottom: 2px groove #8070C0;
7 | }
8 | h2 {
9 | background-color: #C8C0FF;
10 | padding-left: 4pt;
11 | }
12 | h3 {
13 | background-color: #E8E4FF;
14 | padding-left: 4pt;
15 | }
16 | h4 {
17 | background-color: #F4F0FF;
18 | padding-left: 4pt;
19 | }
20 |
--------------------------------------------------------------------------------
/doc/manual/manual.css:
--------------------------------------------------------------------------------
1 | body, h1, h2, h3, h4 {
2 | color: black;
3 | background-color: white;
4 | }
5 |
6 | ol.toc {
7 | list-style: none;
8 | padding-left: 16pt;
9 | }
10 |
11 | p,ul,dl {
12 | margin-left: 16pt;
13 | }
14 |
15 | table {
16 | margin-left: 32pt;
17 | }
18 |
19 | p.image {
20 | text-align: center;
21 | }
22 |
23 | p.version {
24 | padding-top: 1em;
25 | margin-left: 0pt;
26 | font-size: 50%;
27 | text-align: right;
28 | }
29 | dt.toc {
30 | font-size: 150%;
31 | font-weight: bold;
32 | }
33 | dd {
34 | margin-left: 16pt;
35 | margin-bottom: 0.5em;
36 | }
37 | div.commandline {
38 | font-family: monospace;
39 | margin-left: 32pt;
40 | margin-top: 0.5em;
41 | margin-bottom: 0.5em;
42 | }
43 | p.todo {
44 | background-color: white;
45 | color: red;
46 | }
47 | a.internal, a.external:visited {
48 | color: #000080;
49 | background-color: white;
50 | }
51 | a.external:link {
52 | color: #0000FF;
53 | background-color: white;
54 | }
55 | a.external:active {
56 | color: #8080FF;
57 | background-color: white;
58 | }
59 |
60 | th {
61 | text-align: left;
62 | }
63 |
--------------------------------------------------------------------------------
/doc/manual/misc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/misc.png
--------------------------------------------------------------------------------
/doc/manual/session.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/session.png
--------------------------------------------------------------------------------
/doc/manual/status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/status.png
--------------------------------------------------------------------------------
/doc/manual/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/doc/manual/video.png
--------------------------------------------------------------------------------
/doc/release-notes.txt:
--------------------------------------------------------------------------------
1 | Release Notes for openMSX Catapult for openMSX 19.0 (2023-07-25)
2 | ================================================================
3 |
4 | Catapult release to match openMSX 19.0.
5 |
6 | This release we again didn't change much, but is the full list of news:
7 | - migrated to wxWidgets 3.2.1 and libxml2 2.9.14 (latest stable releases)
8 | - adjusted code for changes in the openMSX type command
9 |
10 | Known issues / caveats:
11 | - not feature complete, especially for newer features you will have to revert
12 | to the openMSX console (press F10/Cmd+L) or the OSD menu (MENU key/Cmd+O)
13 |
14 | openMSX Home Page:
15 | http://openmsx.org/
16 | Project page on GitHub:
17 | http://github.com/openMSX/
18 | Contact options:
19 | - Talk to us on #openmsx on irc.libera.chat.
20 | - Use the forum on http://www.msx.org/forum/semi-msx-talk/openmsx
21 | - File a ticket on https://github.com/openMSX/wxCatapult/issues (for Catapult)
22 | - File a ticket on https://github.com/openMSX/openMSX/issues (for openMSX)
23 |
24 | Have fun with your emulated MSX!
25 | the openMSX developers
26 |
--------------------------------------------------------------------------------
/doc/release-process.txt:
--------------------------------------------------------------------------------
1 | openMSX Catapult Release Process
2 | ================================
3 |
4 | This is a kind of recipe for doing releases. Having it written down
5 | decreases the chance of forgetting a small but crucial step during the
6 | hectic work of getting a release out.
7 |
8 | Preparing for a release
9 | -----------------------
10 |
11 | - Tell all developers to commit only fixes.
12 | - Verify the documentation is up-to-date.
13 | Currently most documentation is in "doc".
14 | - Write release notes in "doc/release-notes.txt".
15 | - Add the change list to "doc/release-history.txt".
16 |
17 | Creating a release candidate
18 | ----------------------------
19 |
20 | - If you're creating the very first release candidate for this release, use a
21 | version number that ends with -rc1, so 1.2.3-rc1. Only the final release will
22 | be without the -rc suffix (in both tag and version numbers.)
23 | - Update the copyright year in src/catapult.rc and src/wxCatapultFrm.cpp
24 | - Edit the version number in build/version.mk:
25 | VERSION=1.2.3
26 | The version should be the version of openMSX for which this Catapult
27 | release is intended.
28 | Set RELEASE_FLAG to true.
29 | - Update build/version.py similar to build/version.mk.
30 | - Update the release date in "doc/release-notes.txt" and
31 | "doc/release-history.txt".
32 | - Don't forget to commit and push all these last changes before tagging!
33 | - Tag the git archive:
34 | git tag -a RELEASE_1_2_3 -m "Tagging release 1.2.3."
35 | git push --tags
36 | - Get the tagged code from this URL:
37 | https://github.com/openMSX/wxcatapult/archive/RELEASE_1_2_3.tar.gz
38 | This step makes sure that exactly the tagged code will be released.
39 | - Extract this archive and chdir to the herewith created
40 | wxcatapult-RELEASE_1_2_3 directory
41 | - Create the distribution tar.gz file:
42 | make dist
43 | - Save the created file somewhere you can find it again:
44 | mv derived/dist/openmsx-catapult-1.2.3.tar.gz
45 | /openmsx-catapult-1.2.3.tar.gz
46 | This is the release candidate.
47 |
48 | Sanity check on release candidate
49 | ---------------------------------
50 |
51 | This is a small check to be performed by the release coordinator.
52 |
53 | - Test build:
54 | * Compile and check for warnings:
55 | make
56 | * Test installation:
57 | su
58 | make install
59 | - Start openMSX Catapult with the supported openMSX releases.
60 | - Verify the version number in the About dialog.
61 |
62 | If the sanity check is passed, distribute tar.gz to fellow developers and
63 | testers.
64 |
65 | Post-release
66 | ------------
67 |
68 | - Set RELEASE_FLAG to false in build/version.mk and build/version.py.
69 |
--------------------------------------------------------------------------------
/resources/bitmaps/about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/about.png
--------------------------------------------------------------------------------
/resources/bitmaps/diskimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/diskimage.png
--------------------------------------------------------------------------------
/resources/bitmaps/eject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/eject.png
--------------------------------------------------------------------------------
/resources/bitmaps/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/file.png
--------------------------------------------------------------------------------
/resources/bitmaps/harddisk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/harddisk.png
--------------------------------------------------------------------------------
/resources/bitmaps/ledoff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/ledoff.png
--------------------------------------------------------------------------------
/resources/bitmaps/ledon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/ledon.png
--------------------------------------------------------------------------------
/resources/bitmaps/openMSX-Catapult-logo.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/openMSX-Catapult-logo.xcf
--------------------------------------------------------------------------------
/resources/bitmaps/romimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/romimage.png
--------------------------------------------------------------------------------
/resources/bitmaps/tapeimage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/resources/bitmaps/tapeimage.png
--------------------------------------------------------------------------------
/src/AboutDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "AboutDlg.h"
2 | #include
3 | #include
4 |
5 | IMPLEMENT_CLASS(AboutDlg, wxDialog)
6 | BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
7 | EVT_BUTTON(XRCID("AboutCloseButton"), AboutDlg::OnClose)
8 | END_EVENT_TABLE()
9 |
10 | AboutDlg::AboutDlg(wxWindow* parent)
11 | {
12 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("AboutDialog"));
13 | }
14 |
15 | void AboutDlg::OnClose(wxCommandEvent& event)
16 | {
17 | EndModal(wxID_OK);
18 | }
19 |
--------------------------------------------------------------------------------
/src/AboutDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef ABOUTDLG_H
2 | #define ABOUTDLG_H
3 |
4 | #include
5 |
6 | class AboutDlg : public wxDialog
7 | {
8 | public:
9 | AboutDlg(wxWindow* parent);
10 |
11 | private:
12 | void OnClose(wxCommandEvent& event);
13 |
14 | DECLARE_CLASS(AboutDlg)
15 | DECLARE_EVENT_TABLE()
16 | };
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/src/AudioControlPage.h:
--------------------------------------------------------------------------------
1 | #ifndef AUDIOCONTROLPAGE_H
2 | #define AUDIOCONTROLPAGE_H
3 |
4 | #include "CatapultPage.h"
5 | #include
6 |
7 | class openMSXController;
8 | class wxStaticText;
9 | class wxBitmapButton;
10 |
11 | class AudioControlPage : public CatapultPage
12 | {
13 | public:
14 | AudioControlPage(wxWindow* parent, openMSXController& controller);
15 |
16 | void SetChannelVolume(const wxString& name, const wxString& value);
17 | void SetChannelMode (const wxString& name, const wxString& value);
18 | void InitAudioChannels();
19 | void AddChannelType(const wxString& name, const wxString& type);
20 | void SetupAudioMixer();
21 | void DestroyAudioMixer();
22 | void DisableAudioPanel();
23 | void InitAudioIO();
24 | void UpdateMidiPlug(const wxString& connector, const wxString& data);
25 |
26 | private:
27 | void InvalidMidiInReader();
28 | void InvalidMidiOutLogger();
29 | void InvalidSampleFilename();
30 | void AddChannel(int channelnumber);
31 | int FindChannel(const wxString& name) const;
32 | void OnChangeVolume(wxScrollEvent& event);
33 | void OnChangeMode(wxCommandEvent& event);
34 | void OnMute(wxCommandEvent& event);
35 | void OnChangeMidiInPlug(wxCommandEvent& event);
36 | void OnChangeMidiOutPlug(wxCommandEvent& event);
37 | void OnChangeSampleInPlug(wxCommandEvent& event);
38 | void OnBrowseMidiInFile(wxCommandEvent& event);
39 | void OnBrowseMidiOutFile(wxCommandEvent& event);
40 | void OnBrowseSampleInFile(wxCommandEvent& event);
41 |
42 | openMSXController& m_controller;
43 | wxPanel* m_audioPanel;
44 |
45 | struct ChannelInfo {
46 | wxString name;
47 | wxString type;
48 | wxString displayType; // includes 2-char sort-id
49 | };
50 | std::vector m_audioChannels;
51 | wxString m_midiInConnector;
52 | wxString m_midiOutConnector;
53 |
54 | wxStaticText* m_midiInLabel;
55 | wxStaticText* m_midiOutLabel;
56 | wxStaticText* m_sampleInLabel;
57 | wxStaticText* m_midiInFileLabel;
58 | wxStaticText* m_midiOutFileLabel;
59 | wxStaticText* m_sampleInFileLabel;
60 |
61 | wxBitmapButton* m_browseMidiInButton;
62 | wxBitmapButton* m_browseMidiOutButton;
63 | wxBitmapButton* m_browseSampleInputButton;
64 |
65 | DECLARE_CLASS(AudioControlPage)
66 | DECLARE_EVENT_TABLE()
67 | };
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/src/CatapultConfigDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "CatapultConfigDlg.h"
2 | #include "ConfigurationData.h"
3 | #include "wxCatapultFrm.h"
4 | #include "openMSXController.h"
5 | #include "config.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | IMPLEMENT_CLASS(CatapultConfigDlg, wxDialog)
15 | BEGIN_EVENT_TABLE(CatapultConfigDlg, wxDialog)
16 | EVT_BUTTON(XRCID("ConfigOk"), CatapultConfigDlg::OnOk)
17 | EVT_BUTTON(XRCID("ConfigCancel"), CatapultConfigDlg::OnCancel)
18 | EVT_BUTTON(XRCID("ConfigBrowseExec"), CatapultConfigDlg::OnBrowseExec)
19 | END_EVENT_TABLE()
20 |
21 | CatapultConfigDlg::CatapultConfigDlg(wxWindow* parent, openMSXController& controller)
22 | : m_parent(parent), m_controller(controller)
23 | {
24 | wxString guess;
25 | wxXmlResource::Get()->LoadDialog(this, m_parent, wxT("ConfigurationDialog"));
26 | m_ExecPath = (wxTextCtrl*)FindWindowByName(wxT("ConfigExecData"));
27 | m_ConfigCheck = (wxCheckBox*)FindWindowByName(wxT("configCheck"));
28 | auto* OkButton = (wxTextCtrl *)FindWindowByName(wxT("ConfigOk"));
29 | wxString temp;
30 | auto& config = ConfigurationData::instance();
31 | OkButton->SetFocus(); // avoid strange behaviour of the execpath textctrl
32 | if (config.GetParameter(ConfigurationData::CD_EXECPATH, temp)) {
33 | m_ExecPath->SetValue(temp);
34 | }
35 | if (temp.IsEmpty()) {
36 | #ifdef __WXMSW__
37 | guess = ((wxCatapultApp&)wxGetApp()).GetResourceDir();
38 | guess.Replace(wxT("/"), wxT("\\"));
39 | for (int i = 0; i < 2; ++i) {
40 | while (guess.Last() == '\\') {
41 | guess.RemoveLast();
42 | }
43 | int pos = guess.Find('\\', true);
44 | if (pos != wxNOT_FOUND) {
45 | guess = guess.Left(pos + 1);
46 | }
47 | }
48 | guess += wxT("openmsx.exe");
49 | #else
50 | guess = CATAPULT_OPENMSX_BINARY;
51 | #endif
52 | if (wxFileExists(guess)) {
53 | m_ExecPath->SetValue(guess);
54 | }
55 | }
56 | SetSize(GetBestSize());
57 | Centre();
58 | }
59 |
60 | void CatapultConfigDlg::OnOk(wxCommandEvent& event)
61 | {
62 | wxString tempExec = m_ExecPath->GetValue();
63 | if (!::wxFileExists(tempExec)) {
64 | wxMessageBox(wxT("That's not a valid executable..."));
65 | } else if (m_controller.CheckVersion(tempExec)) {
66 | auto& config = ConfigurationData::instance();
67 | config.SetParameter(ConfigurationData::CD_EXECPATH, tempExec);
68 | config.SaveData();
69 | if (m_ConfigCheck->IsChecked()) {
70 | // TODO: make this cleaner... (It works though...)
71 | ((wxCatapultFrame*)m_parent)->CheckConfigs();
72 | }
73 | EndModal(wxID_OK);
74 | }
75 | }
76 |
77 | void CatapultConfigDlg::OnCancel(wxCommandEvent& event)
78 | {
79 | EndModal(wxID_CANCEL);
80 | }
81 |
82 | void CatapultConfigDlg::OnBrowseExec(wxCommandEvent& event)
83 | {
84 | wxString defaultpath = ::wxPathOnly(m_ExecPath->GetValue());
85 |
86 | #if defined(_WIN32)
87 | wxString executable = wxT(".exe");
88 | #else
89 | wxString executable;
90 | #endif
91 |
92 | wxFileDialog filedlg(
93 | this, wxT("Select openMSX executable"), defaultpath,
94 | wxT("openmsx") + executable, wxT("*") + executable, wxFD_OPEN);
95 | if (filedlg.ShowModal() == wxID_OK) {
96 | m_ExecPath->SetValue(filedlg.GetPath());
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/CatapultConfigDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef CATAPULTCONFIGDLG_H
2 | #define CATAPULTCONFIGDLG_H
3 |
4 | #include
5 | #include
6 |
7 | class openMSXController;
8 | class wxCheckBox;
9 |
10 | class CatapultConfigDlg : public wxDialog
11 | {
12 | public:
13 | CatapultConfigDlg(wxWindow* parent, openMSXController& controller);
14 |
15 | private:
16 | void OnBrowseExec(wxCommandEvent& event);
17 | void OnCancel(wxCommandEvent& event);
18 | void OnOk(wxCommandEvent& event);
19 |
20 | wxTextCtrl* m_ExecPath;
21 | wxCheckBox* m_ConfigCheck;
22 | wxWindow* m_parent;
23 | openMSXController& m_controller;
24 |
25 | DECLARE_CLASS(CatapultConfigDlg)
26 | DECLARE_EVENT_TABLE()
27 | };
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/CatapultPage.cpp:
--------------------------------------------------------------------------------
1 | #include "CatapultPage.h"
2 | #include
3 |
4 | void CatapultPage::OnClickCombo(wxCommandEvent& event)
5 | {
6 | auto* box = (wxComboBox*)event.GetEventObject();
7 | wxString sel = box->GetString(box->GetSelection());
8 | if (sel != box->GetValue()) {
9 | box->SetValue(sel);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/CatapultPage.h:
--------------------------------------------------------------------------------
1 | #ifndef CATAPULTPAGE_H
2 | #define CATAPULTPAGE_H
3 |
4 | #include
5 |
6 | class CatapultPage : public wxPanel
7 | {
8 | public:
9 | void OnClickCombo(wxCommandEvent& event);
10 | virtual void HandleFocusChange(wxWindow* oldFocus, wxWindow* newFocus) {}
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/CatapultXMLParser.cpp:
--------------------------------------------------------------------------------
1 | #include "wxCatapultApp.h"
2 | #include "CatapultXMLParser.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | CatapultXMLParser::ParseResult CatapultXMLParser::parseResult;
9 | xmlSAXHandler CatapultXMLParser::handler;
10 | xmlParserCtxt* CatapultXMLParser::context;
11 | wxWindow* CatapultXMLParser::m_target;
12 |
13 | CatapultXMLParser::CatapultXMLParser(wxWindow* target)
14 | {
15 | m_target = target;
16 | parseResult.parseState = STATE_START;
17 | parseResult.unknownLevel = 0;
18 | parseResult.contents.Clear();
19 | memset(&handler, 0, sizeof(handler));
20 | handler.startElement = (startElementSAXFunc)cb_start_element;
21 | handler.endElement = (endElementSAXFunc)cb_end_element;
22 | handler.characters = (charactersSAXFunc)cb_text;
23 | context = xmlCreatePushParserCtxt(&handler, this, 0, 0, 0);
24 | }
25 |
26 | void CatapultXMLParser::cb_start_element(
27 | CatapultXMLParser* parser, const xmlChar* name, const xmlChar** attrs)
28 | {
29 | if (parser->parseResult.unknownLevel) {
30 | ++(parser->parseResult.unknownLevel);
31 | return;
32 | }
33 | switch (parser->parseResult.parseState) {
34 | case STATE_START:
35 | if (!strcmp((const char*)name, "openmsx-output")) {
36 | parser->parseResult.parseState = TAG_OPENMSX;
37 | } else {
38 | ++(parser->parseResult.unknownLevel);
39 | }
40 | break;
41 | case TAG_OPENMSX:
42 | if (!strcmp((const char*)name, "reply")) {
43 | parser->parseResult.parseState = TAG_REPLY;
44 | parser->parseReply((const char**)attrs);
45 | } else if (!strcmp((const char*)name, "log")) {
46 | parser->parseResult.parseState = TAG_LOG;
47 | parser->parseLog((const char**)attrs);
48 | } else if (!strcmp((const char*)name, "update")) {
49 | parser->parseResult.parseState = TAG_UPDATE;
50 | parser->parseUpdate((const char**)attrs);
51 | } else {
52 | ++(parser->parseResult.unknownLevel);
53 | }
54 | break;
55 | default:
56 | ++(parser->parseResult.unknownLevel);
57 | break;
58 | }
59 | parser->parseResult.contents.Clear();
60 | }
61 |
62 | void CatapultXMLParser::cb_end_element(CatapultXMLParser* parser, const xmlChar* name)
63 | {
64 | if (parser->parseResult.unknownLevel) {
65 | --(parser->parseResult.unknownLevel);
66 | return;
67 | }
68 | switch (parser->parseResult.parseState) {
69 | case STATE_START:
70 | assert(false);
71 | break;
72 | case TAG_OPENMSX:
73 | parser->parseResult.parseState = STATE_START;
74 | break;
75 | case TAG_UPDATE:
76 | case TAG_LOG:
77 | case TAG_REPLY:
78 | SendParsedData();
79 | parser->parseResult.parseState = TAG_OPENMSX;
80 | break;
81 | }
82 | }
83 |
84 | void CatapultXMLParser::cb_text(CatapultXMLParser* parser, const xmlChar* chars, int len)
85 | {
86 | assert(len >= 0);
87 | switch (parser->parseResult.parseState) {
88 | case TAG_UPDATE:
89 | case TAG_LOG:
90 | case TAG_REPLY:
91 | parser->parseResult.contents.Append(wxString(
92 | (const char*)chars, wxConvUTF8, (size_t)len));
93 | break;
94 | default:
95 | break;
96 | }
97 | }
98 |
99 | void CatapultXMLParser::SendParsedData()
100 | {
101 | wxCommandEvent parseEvent(EVT_CONTROLLER);
102 | auto* result = new ParseResult;
103 | result->contents = parseResult.contents;
104 | result->openMSXID = parseResult.openMSXID;
105 | // handle both new and deprecated messages
106 | switch (parseResult.parseState) {
107 | case STATE_START:
108 | case TAG_OPENMSX:
109 | assert(false);
110 | break;
111 | case TAG_LOG:
112 | result->parseState = TAG_LOG;
113 | result->logLevel = parseResult.logLevel;
114 | break;
115 | case TAG_REPLY:
116 | result->parseState = TAG_REPLY;
117 | result->replyState = parseResult.replyState;
118 | break;
119 | case TAG_UPDATE:
120 | result->parseState = TAG_UPDATE;
121 | result->name = parseResult.name;
122 | result->updateType = parseResult.updateType;
123 | break;
124 | }
125 |
126 | parseEvent.SetClientData(result);
127 | parseEvent.SetId(MSGID_PARSED);
128 | wxPostEvent(m_target, parseEvent);
129 | }
130 |
131 | void CatapultXMLParser::ParseXmlInput(wxString input, unsigned id)
132 | {
133 | parseResult.openMSXID = id;
134 | xmlParseChunk(context, (const char*)(input.mb_str(wxConvUTF8)), input.Len(), 0);
135 | }
136 |
137 | void CatapultXMLParser::parseReply(const char** attrs)
138 | {
139 | parseResult.replyState = REPLY_UNKNOWN;
140 | if (!attrs) return;
141 | for (/**/; *attrs; attrs += 2) {
142 | if (strcmp(attrs[0], "result") == 0) {
143 | if (strcmp(attrs[1], "ok") == 0) {
144 | parseResult.replyState = REPLY_OK;
145 | } else if (strcmp(attrs[1], "nok") == 0) {
146 | parseResult.replyState = REPLY_NOK;
147 | }
148 | }
149 | }
150 | }
151 |
152 | void CatapultXMLParser::parseLog(const char** attrs)
153 | {
154 | parseResult.logLevel = LOG_UNKNOWN;
155 | if (!attrs) return;
156 | for (/**/; *attrs; attrs += 2) {
157 | if (strcmp(attrs[0], "level") == 0) {
158 | if (strcmp(attrs[1], "info") == 0) {
159 | parseResult.logLevel = LOG_INFO;
160 | } else if (strcmp(attrs[1], "warning") == 0) {
161 | parseResult.logLevel = LOG_WARNING;
162 | }
163 | }
164 | }
165 | }
166 |
167 | void CatapultXMLParser::parseUpdate(const char** attrs)
168 | {
169 | parseResult.updateType = UPDATE_UNKNOWN;
170 | if (!attrs) return;
171 | for (/**/; *attrs; attrs += 2) {
172 | if (strcmp(attrs[0], "type") == 0) {
173 | if (strcmp(attrs[1], "led") == 0) {
174 | parseResult.updateType = UPDATE_LED;
175 | } else if (strcmp(attrs[1], "setting") == 0) {
176 | parseResult.updateType = UPDATE_SETTING;
177 | } else if (strcmp(attrs[1], "plug") == 0) {
178 | parseResult.updateType = UPDATE_PLUG;
179 | } else if (strcmp(attrs[1], "media") == 0) {
180 | parseResult.updateType = UPDATE_MEDIA;
181 | } else if (strcmp(attrs[1], "status") == 0) {
182 | parseResult.updateType = UPDATE_STATE;
183 | } else if (strcmp(attrs[1], "hardware") == 0) {
184 | parseResult.updateType = UPDATE_HARDWARE;
185 | } else if (strcmp(attrs[1], "extension") == 0) {
186 | parseResult.updateType = UPDATE_EXTENSION;
187 | } else if (strcmp(attrs[1], "connector") == 0) {
188 | parseResult.updateType = UPDATE_CONNECTOR;
189 | }
190 | } else if (strcmp(attrs[0], "name") == 0) {
191 | parseResult.name = wxString(attrs[1], wxConvUTF8);
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/src/CatapultXMLParser.h:
--------------------------------------------------------------------------------
1 | #ifndef CATAPULTXMLPARSER_H
2 | #define CATAPULTXMLPARSER_H
3 |
4 | #include
5 | #include
6 |
7 | class wxWindow;
8 |
9 | class CatapultXMLParser
10 | {
11 | public:
12 | CatapultXMLParser(wxWindow* target);
13 | void ParseXmlInput(wxString input, unsigned id);
14 |
15 | enum ParseState {
16 | STATE_START,
17 | TAG_OPENMSX,
18 | TAG_REPLY,
19 | TAG_LOG,
20 | TAG_UPDATE,
21 |
22 | };
23 | enum ReplyStatus {
24 | REPLY_UNKNOWN,
25 | REPLY_OK,
26 | REPLY_NOK
27 | };
28 | enum LogLevel {
29 | LOG_UNKNOWN,
30 | LOG_INFO,
31 | LOG_WARNING
32 | };
33 | enum UpdateType {
34 | UPDATE_UNKNOWN,
35 | UPDATE_LED,
36 | UPDATE_SETTING,
37 | UPDATE_PLUG,
38 | UPDATE_MEDIA,
39 | UPDATE_STATE,
40 | UPDATE_HARDWARE,
41 | UPDATE_EXTENSION,
42 | UPDATE_CONNECTOR
43 | };
44 | struct ParseResult {
45 | ParseState parseState;
46 | unsigned unknownLevel;
47 | ReplyStatus replyState;
48 | LogLevel logLevel;
49 | UpdateType updateType;
50 | wxString contents;
51 | wxString name;
52 | unsigned openMSXID;
53 | };
54 |
55 | private:
56 | static wxWindow* m_target;
57 | static xmlSAXHandler handler;
58 | static xmlParserCtxt* context;
59 | static ParseResult parseResult;
60 |
61 | static void cb_start_element(CatapultXMLParser* parser, const xmlChar* name, const xmlChar** attrs);
62 | static void cb_end_element(CatapultXMLParser* parser, const xmlChar* name);
63 | static void cb_text(CatapultXMLParser* parser, const xmlChar* chars, int len);
64 | static void SendParsedData();
65 | void parseReply(const char** attrs);
66 | void parseLog(const char** attrs);
67 | void parseUpdate(const char** attrs);
68 | };
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/CheckConfigsDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "CheckConfigsDlg.h"
2 | #include "wxCatapultApp.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #define MSGID_SETCURRENTOBJECT 0
12 | #define MSGID_UPDATESTATS 1
13 |
14 | // this is for an ugly hack: these extensions only work on certain machines and
15 | // typically it's not the machine that Catapult is using to test the extension
16 | // with. However, the goal of the testing was almost exclusively to find out
17 | // about missing/uninstalled system ROMs. As these extensions do not have
18 | // system ROMs, we treat them specially (see below where this vector is
19 | // used)... TODO: implement a better solution.
20 | static const std::vector extensionsWithoutROMs = { "advram", "Casio_KB-7", "Casio_KB-10" };
21 |
22 | IMPLEMENT_CLASS(CheckConfigsDlg, wxDialog)
23 | BEGIN_EVENT_TABLE(CheckConfigsDlg, wxDialog)
24 | EVT_BUTTON(XRCID("CheckConfigsUserButton"), CheckConfigsDlg::OnUserButton)
25 | EVT_COMMAND (-1, EVT_TESTCONFIG, CheckConfigsDlg::OnTestConfigEvent)
26 | END_EVENT_TABLE()
27 |
28 | CheckConfigsDlg::CheckConfigsDlg(wxWindow* parent)
29 | {
30 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("CheckConfigs"));
31 | m_completemachines = (wxStaticText*)FindWindowByName(wxT("CompleteMachinesCount"));
32 | m_incompletemachines = (wxStaticText*)FindWindowByName(wxT("IncompleteMachinesCount"));
33 | m_workingextensions = (wxStaticText*)FindWindowByName(wxT("CompleteExtensionsCount"));
34 | m_nonworkingextensions = (wxStaticText*)FindWindowByName(wxT("InCompleteExtensionsCount"));
35 | m_currentconfig = (wxStaticText*)FindWindowByName(wxT("CheckingObject"));
36 | m_progressbar = (wxGauge*)FindWindowByName(wxT("ProgressGauge"));
37 | m_progressbar->SetRange(100);
38 | m_userbutton = (wxButton*)FindWindowByName(wxT("CheckConfigsUserButton"));
39 | m_log = (wxTextCtrl*)FindWindowByName(wxT("MissingObjects"));
40 | m_validmachinecount = 0;
41 | m_invalidmachinecount = 0;
42 | m_validextensioncount = 0;
43 | m_invalidextensioncount = 0;
44 | }
45 |
46 | int CheckConfigsDlg::Present(wxString cmd, wxArrayString& machines, wxArrayString& extensions)
47 | {
48 | m_auditThread.reset(new CheckConfigsDlg::CheckConfigsThread(this));
49 | m_auditThread->Create();
50 | m_auditThread->SetParameters(cmd, &machines, &extensions);
51 | m_auditThread->Run();
52 | return ShowModal();
53 | }
54 |
55 | void CheckConfigsDlg::EndModal(int retCode) // TODO: check if this is also called for posix systems
56 | {
57 | m_auditThread->m_running = false;
58 | m_auditThread->Wait();
59 | wxDialog::EndModal(retCode);
60 | }
61 |
62 | void CheckConfigsDlg::OnUserButton(wxCommandEvent& event)
63 | {
64 | if (!m_auditThread->m_running) {
65 | EndModal(wxID_OK);
66 | } else {
67 | m_auditThread->m_running = false;
68 | EndModal(wxID_CANCEL);
69 | }
70 | }
71 |
72 | void CheckConfigsDlg::OnTestConfigEvent(wxCommandEvent& event)
73 | {
74 | std::unique_ptr data(
75 | (CheckConfigsData*)event.GetClientData());
76 | switch (event.GetId()) {
77 | case MSGID_SETCURRENTOBJECT:
78 | HandleSetCurrentObject(data->m_currentObject);
79 | break;
80 | case MSGID_UPDATESTATS:
81 | HandleUpdateStats(data->m_checkmachine, data->m_succes, data->m_progress);
82 | break;
83 | }
84 | }
85 |
86 | void CheckConfigsDlg::HandleUpdateStats(bool checkmachine, bool succes, int progress)
87 | {
88 | if (succes) {
89 | if (checkmachine) {
90 | m_completemachines->SetLabel(wxString::Format(
91 | wxT("%d"), ++m_validmachinecount));
92 | } else {
93 | m_workingextensions->SetLabel(wxString::Format(
94 | wxT("%d"), ++m_validextensioncount));
95 | }
96 | } else {
97 | if (checkmachine) {
98 | m_incompletemachines->SetLabel(wxString::Format(
99 | wxT("%d"), ++m_invalidmachinecount));
100 | m_log->AppendText(wxT("machine: "));
101 | } else {
102 | m_nonworkingextensions->SetLabel(wxString::Format(
103 | wxT("%d"), ++m_invalidextensioncount));
104 | m_log->AppendText(wxT("extension: "));
105 | }
106 | m_log->AppendText(m_currentObject);
107 | m_log->AppendText(wxT("\n"));
108 | }
109 | m_progressbar->SetValue(progress);
110 | }
111 |
112 | void CheckConfigsDlg::HandleSetCurrentObject(wxString object)
113 | {
114 | m_currentObject = object;
115 | wxString tmp = m_currentObject;
116 | tmp.Replace(wxT("_"), wxT(" "));
117 | m_currentconfig->SetLabel(tmp);
118 | }
119 |
120 | void CheckConfigsDlg::FinishCheck()
121 | {
122 | m_userbutton->SetLabel(wxT("Done"));
123 | m_currentconfig->SetLabel(wxT("Done"));
124 | }
125 |
126 | CheckConfigsDlg::CheckConfigsThread::CheckConfigsThread(CheckConfigsDlg* target)
127 | : wxThread(wxTHREAD_JOINABLE)
128 | {
129 | m_target = target;
130 | }
131 |
132 | wxThread::ExitCode CheckConfigsDlg::CheckConfigsThread::Entry()
133 | {
134 | m_running = true;
135 | std::vector workingMachines;
136 | int numberOfMachines = m_machines->Count();
137 | int numberOfExtensions = m_extensions->Count();
138 | int config = 0;
139 | size_t machineIndex = 0;
140 | while ((machineIndex < m_machines->Count()) && m_running) {
141 | wxString machine(m_machines->Item(machineIndex));
142 | wxString fullCommand;
143 | fullCommand << m_cmd << wxT(" -testconfig -machine \"")
144 | << machine << wxT("\"");
145 | SetCurrentObject(machine);
146 | int progress = (50 * (config + 1)) / numberOfMachines;
147 | bool success = doCheckConfigs(fullCommand);
148 | if (success) {
149 | workingMachines.push_back(machine);
150 | ++machineIndex;
151 | } else {
152 | m_machines->RemoveAt(machineIndex);
153 | }
154 | ++config;
155 | if (m_running) {
156 | UpdateStats(true, success, progress);
157 | }
158 |
159 | }
160 | config = 0;
161 | if (!workingMachines.empty()) {
162 | wxString workingMachine(workingMachines[0]);
163 | // check if this machine is working. If so, prefer that.
164 | const wxString preferredMachine(wxT("C-BIOS_MSX2+"));
165 | if (std::find(workingMachines.begin(), workingMachines.end(), preferredMachine) != workingMachines.end()) {
166 | workingMachine = preferredMachine;
167 | }
168 | // note that all of this won't work for non-MSX extensions...
169 | size_t extIndex = 0;
170 | while ((extIndex < m_extensions->Count()) && m_running) {
171 | wxString fullCommand;
172 | wxString extension = m_extensions->Item(extIndex);
173 | fullCommand << m_cmd << wxT(" -testconfig -machine \"")
174 | << workingMachine << wxT("\" -ext \"")
175 | << extension << wxT("\"");
176 | SetCurrentObject(extension);
177 | int progress = ((50 * (config + 1)) / numberOfExtensions) + 50;
178 | bool success;
179 | if (std::find(extensionsWithoutROMs.begin(), extensionsWithoutROMs.end(), std::string(extension.mb_str())) == extensionsWithoutROMs.end()) {
180 | success = doCheckConfigs(fullCommand);
181 | } else {
182 | success = true;
183 | }
184 | if (!success) {
185 | m_extensions->RemoveAt(extIndex);
186 | } else {
187 | ++extIndex;
188 | }
189 | ++config;
190 | if (m_running) {
191 | UpdateStats(false, success, progress);
192 | }
193 | }
194 | }
195 | if (m_running) {
196 | m_target->FinishCheck();
197 | }
198 | m_running = false;
199 | return 0;
200 | }
201 |
202 | void CheckConfigsDlg::CheckConfigsThread::UpdateStats(bool checkmachine, bool succes, int progress)
203 | {
204 | wxCommandEvent checkConfigEvent(EVT_TESTCONFIG);
205 | CheckConfigsData* data = new CheckConfigsData;
206 | data->m_checkmachine = checkmachine;
207 | data->m_succes = succes;
208 | data->m_progress = progress;
209 | checkConfigEvent.SetClientData(data);
210 | checkConfigEvent.SetId(MSGID_UPDATESTATS);
211 | wxPostEvent(m_target, checkConfigEvent);
212 | }
213 |
214 |
215 | void CheckConfigsDlg::CheckConfigsThread::SetCurrentObject(wxString object)
216 | {
217 | wxCommandEvent checkConfigEvent(EVT_TESTCONFIG);
218 | CheckConfigsData* data = new CheckConfigsData;
219 | data->m_currentObject = object;
220 | checkConfigEvent.SetClientData(data);
221 | checkConfigEvent.SetId(MSGID_SETCURRENTOBJECT);
222 | wxPostEvent(m_target, checkConfigEvent);
223 | }
224 |
225 | void CheckConfigsDlg::CheckConfigsThread::SetParameters(
226 | wxString cmd, wxArrayString* machines, wxArrayString* extensions)
227 | {
228 | m_machines = machines;
229 | m_extensions = extensions;
230 | m_cmd = cmd;
231 | }
232 |
233 | bool CheckConfigsDlg::CheckConfigsThread::doCheckConfigs(wxString cmd)
234 | {
235 | unsigned long result = 1;
236 | #ifndef __WXMSW__
237 | char buffer[1000];
238 | cmd += wxT(" > /dev/null 2>&1");
239 | strcpy(buffer, (const char*)(cmd.mb_str(wxConvUTF8)));
240 | result = system(buffer);
241 | #else
242 | DWORD dwProcessFlags = CREATE_NO_WINDOW | CREATE_DEFAULT_ERROR_MODE;
243 | PROCESS_INFORMATION pi;
244 | STARTUPINFO si;
245 | ZeroMemory(&si, sizeof(si));
246 | si.cb = sizeof(si);
247 | si.dwFlags = STARTF_USESHOWWINDOW;
248 | si.wShowWindow = SW_HIDE;
249 |
250 | if (LPTSTR szCmdLine = _tcsdup(cmd.c_str())) {
251 | BOOL created = CreateProcess(
252 | nullptr, szCmdLine, nullptr, nullptr, false,
253 | dwProcessFlags, nullptr, nullptr, &si, &pi);
254 | if (created) {
255 | WaitForSingleObject(pi.hProcess, INFINITE);
256 | GetExitCodeProcess(pi.hProcess, &result);
257 | CloseHandle(pi.hProcess);
258 | CloseHandle(pi.hThread);
259 | }
260 | }
261 | #endif
262 | return result == 0;
263 | }
264 |
--------------------------------------------------------------------------------
/src/CheckConfigsDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef CHECKCONFIGSDLG_H
2 | #define CHECKCONFIGSDLG_H
3 |
4 | #include
5 | #include
6 | #include // required here for windows
7 |
8 | class wxStaticText;
9 | class wxButton;
10 | class wxTextCtrl;
11 |
12 | class CheckConfigsDlg : public wxDialog
13 | {
14 | public:
15 | CheckConfigsDlg(wxWindow* parent);
16 |
17 | int Present(wxString cmd, wxArrayString& machines, wxArrayString& extensions);
18 |
19 | private:
20 | void HandleUpdateStats(bool checkmachine, bool succes, int progress);
21 | void HandleSetCurrentObject(wxString object);
22 | void EndModal(int retCode);
23 | void FinishCheck();
24 | void OnUserButton(wxCommandEvent& event);
25 | void OnTestConfigEvent(wxCommandEvent& event);
26 |
27 | struct CheckConfigsData {
28 | bool m_checkmachine;
29 | bool m_succes;
30 | int m_progress;
31 | wxString m_currentObject;
32 | };
33 | class CheckConfigsThread : public wxThread {
34 | public:
35 | CheckConfigsThread(CheckConfigsDlg* target);
36 | wxThread::ExitCode Entry();
37 | void SetParameters(wxString cmd, wxArrayString* machines, wxArrayString* extensions);
38 | bool m_running;
39 |
40 | private:
41 | bool doCheckConfigs(wxString cmd);
42 | void UpdateStats(bool checkmachine, bool succes, int progress);
43 | void SetCurrentObject(wxString object);
44 |
45 | CheckConfigsDlg* m_target;
46 | wxString m_cmd;
47 | wxArrayString* m_machines;
48 | wxArrayString* m_extensions;
49 | };
50 | friend class CheckConfigsThread;
51 |
52 | int m_validmachinecount;
53 | int m_invalidmachinecount;
54 | int m_validextensioncount;
55 | int m_invalidextensioncount;
56 |
57 | std::unique_ptr m_auditThread;
58 | wxStaticText* m_completemachines;
59 | wxStaticText* m_incompletemachines;
60 | wxStaticText* m_workingextensions;
61 | wxStaticText* m_nonworkingextensions;
62 | wxStaticText* m_currentconfig;
63 | wxGauge* m_progressbar;
64 | wxButton* m_userbutton;
65 | wxTextCtrl* m_log;
66 | wxString m_currentObject;
67 |
68 | DECLARE_CLASS(CheckConfigsDlg)
69 | DECLARE_EVENT_TABLE()
70 | };
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/src/ConfigurationData.cpp:
--------------------------------------------------------------------------------
1 | #include "ConfigurationData.h"
2 | #include
3 |
4 | ConfigurationData::ConfigurationData()
5 | {
6 | ConfigData = wxConfigBase::Create();
7 | ConfigData->SetExpandEnvVars(false); // we will not write env vars
8 | ConfigData->Read(wxT("/openMSXpaths/ExecPath"), &m_openMSXExecPath);
9 | ConfigData->Read(wxT("/configuration/InstalledMachines"), &m_installedMachines);
10 | ConfigData->Read(wxT("/configuration/InstalledExtensions"), &m_installedExtensions);
11 | ConfigData->Read(wxT("/history/DiskA"), &m_diskaHistory);
12 | ConfigData->Read(wxT("/history/DiskB"), &m_diskbHistory);
13 | ConfigData->Read(wxT("/history/CartA"), &m_cartaHistory);
14 | ConfigData->Read(wxT("/history/CartB"), &m_cartbHistory);
15 | ConfigData->Read(wxT("/history/Cassette"), &m_cassetteHistory);
16 | ConfigData->Read(wxT("/history/Harddisk"), &m_hardDiskHistory);
17 | ConfigData->Read(wxT("/history/IpsDiskA"), &m_diskaIps);
18 | ConfigData->Read(wxT("/history/IpsDiskB"), &m_diskbIps);
19 | ConfigData->Read(wxT("/history/IpsCartA"), &m_cartaIps);
20 | ConfigData->Read(wxT("/history/IpsCartB"), &m_cartbIps);
21 | ConfigData->Read(wxT("/history/TypeCartA"), &m_typeHistCartA);
22 | ConfigData->Read(wxT("/history/TypeCartB"), &m_typeHistCartB);
23 | ConfigData->Read(wxT("/history/MediaInserted"), &m_mediaInserted);
24 | ConfigData->Read(wxT("/history/UsedMachine"), &m_usedMachine);
25 | ConfigData->Read(wxT("/history/UsedExtensions"), &m_usedExtensions);
26 | ConfigData->Read(wxT("/preferences/ShowFullScreenWarning"), &m_showFullScreenWarning);
27 | ConfigData->Read(wxT("/preferences/ShowScreenshotInfo"), &m_showScreenshotInfo);
28 | ConfigData->Read(wxT("/preferences/AutoCreateCassetteRecordFile"), &m_cassetteAutoCreate);
29 | ConfigData->Read(wxT("/connectors/UsedJoyport1"), &m_usedJoyport1);
30 | ConfigData->Read(wxT("/connectors/UsedJoyport2"), &m_usedjoyport2);
31 | ConfigData->Read(wxT("/configuration/ViewFlags"), &m_viewFlags);
32 | // ConfigData->Read(wxT("/connectors/UsedPrinterport"), &m_usedPrinterport); // saving disabled
33 | // ConfigData->Read(wxT("/connectors/UsedPrinterfile"), &m_usedPrinterfile);
34 | }
35 |
36 | ConfigurationData& ConfigurationData::instance()
37 | {
38 | static ConfigurationData oneInstance;
39 | return oneInstance;
40 | }
41 |
42 | bool ConfigurationData::HaveRequiredSettings() const
43 | {
44 | if (m_openMSXExecPath.IsEmpty() || !::wxFileExists(m_openMSXExecPath)) {
45 | return false;
46 | }
47 | return true;
48 | }
49 |
50 | bool ConfigurationData::SetParameter(int p_iId, wxVariant p_data)
51 | {
52 | switch (p_iId) {
53 | case CD_EXECPATH:
54 | m_openMSXExecPath = p_data.GetString();
55 | break;
56 | case CD_MACHINES:
57 | m_installedMachines = p_data.GetString();
58 | break;
59 | case CD_EXTENSIONS:
60 | m_installedExtensions = p_data.GetString();
61 | break;
62 | case CD_HISTDISKA:
63 | m_diskaHistory = p_data.GetString();
64 | break;
65 | case CD_HISTDISKB:
66 | m_diskbHistory = p_data.GetString();
67 | break;
68 | case CD_HISTCARTA:
69 | m_cartaHistory = p_data.GetString();
70 | break;
71 | case CD_HISTCARTB:
72 | m_cartbHistory = p_data.GetString();
73 | break;
74 | case CD_HISTCASSETTE:
75 | m_cassetteHistory = p_data.GetString();
76 | break;
77 | case CD_HISTHDD:
78 | m_hardDiskHistory = p_data.GetString();
79 | break;
80 | case CD_IPSDISKA:
81 | m_diskaIps = p_data.GetString();
82 | break;
83 | case CD_IPSDISKB:
84 | m_diskbIps = p_data.GetString();
85 | break;
86 | case CD_IPSCARTA:
87 | m_cartaIps = p_data.GetString();
88 | break;
89 | case CD_IPSCARTB:
90 | m_cartbIps = p_data.GetString();
91 | break;
92 | case CD_TYPEHISTCARTA:
93 | m_typeHistCartA = p_data.GetString();
94 | break;
95 | case CD_TYPEHISTCARTB:
96 | m_typeHistCartB = p_data.GetString();
97 | break;
98 | case CD_USEDMACHINE:
99 | m_usedMachine = p_data.GetString();
100 | break;
101 | case CD_USEDEXTENSIONS:
102 | m_usedExtensions = p_data.GetString();
103 | break;
104 | case CD_MEDIAINSERTED:
105 | m_mediaInserted = p_data.GetLong();
106 | break;
107 | case CD_FULLSCREENWARN:
108 | m_showFullScreenWarning = p_data.GetLong();
109 | break;
110 | case CD_AUTORECORD:
111 | m_cassetteAutoCreate = p_data.GetLong();
112 | break;
113 | case CD_SCREENSHOTINFO:
114 | m_showScreenshotInfo = p_data.GetLong();
115 | break;
116 | case CD_JOYPORT1:
117 | m_usedJoyport1 = p_data.GetString();
118 | break;
119 | case CD_JOYPORT2:
120 | m_usedjoyport2 = p_data.GetString();
121 | break;
122 | case CD_PRINTERPORT:
123 | m_usedPrinterport = p_data.GetString();
124 | break;
125 | case CD_PRINTERFILE:
126 | m_usedPrinterfile = p_data.GetString();
127 | break;
128 | case CD_VIEWFLAGS:
129 | m_viewFlags = p_data.GetLong();
130 | break;
131 | default:
132 | return false; // unknown ID
133 | }
134 | return true;
135 | }
136 |
137 | bool ConfigurationData::GetParameter(int p_iId, wxString& p_data) const
138 | {
139 | switch (p_iId) {
140 | case CD_EXECPATH:
141 | p_data = m_openMSXExecPath;
142 | break;
143 | case CD_MACHINES:
144 | p_data = m_installedMachines;
145 | break;
146 | case CD_EXTENSIONS:
147 | p_data = m_installedExtensions;
148 | break;
149 | case CD_HISTDISKA:
150 | p_data = m_diskaHistory;
151 | break;
152 | case CD_HISTDISKB:
153 | p_data = m_diskbHistory;
154 | break;
155 | case CD_HISTCARTA:
156 | p_data = m_cartaHistory;
157 | break;
158 | case CD_HISTCARTB:
159 | p_data = m_cartbHistory;
160 | break;
161 | case CD_HISTCASSETTE:
162 | p_data = m_cassetteHistory;
163 | break;
164 | case CD_HISTHDD:
165 | p_data = m_hardDiskHistory;
166 | break;
167 | case CD_IPSDISKA:
168 | p_data = m_diskaIps;
169 | break;
170 | case CD_IPSDISKB:
171 | p_data = m_diskbIps;
172 | break;
173 | case CD_IPSCARTA:
174 | p_data = m_cartaIps;
175 | break;
176 | case CD_IPSCARTB:
177 | p_data = m_cartbIps;
178 | break;
179 | case CD_TYPEHISTCARTA:
180 | p_data = m_typeHistCartA;
181 | break;
182 | case CD_TYPEHISTCARTB:
183 | p_data = m_typeHistCartB;
184 | break;
185 | case CD_USEDMACHINE:
186 | p_data = m_usedMachine;
187 | break;
188 | case CD_USEDEXTENSIONS:
189 | p_data = m_usedExtensions;
190 | break;
191 | case CD_JOYPORT1:
192 | p_data = m_usedJoyport1;
193 | break;
194 | case CD_JOYPORT2:
195 | p_data = m_usedjoyport2;
196 | break;
197 | case CD_PRINTERPORT:
198 | p_data = m_usedPrinterport;
199 | break;
200 | case CD_PRINTERFILE:
201 | p_data = m_usedPrinterfile;
202 | break;
203 | default:
204 | return false; // unknown ID
205 | }
206 | return true;
207 | }
208 |
209 | bool ConfigurationData::GetParameter(int p_iId, int* p_data) const
210 | {
211 | switch (p_iId) {
212 | case CD_MEDIAINSERTED:
213 | *p_data = m_mediaInserted;
214 | break;
215 | case CD_FULLSCREENWARN:
216 | *p_data = m_showFullScreenWarning;
217 | break;
218 | case CD_AUTORECORD:
219 | *p_data = m_cassetteAutoCreate;
220 | break;
221 | case CD_SCREENSHOTINFO:
222 | *p_data = m_showScreenshotInfo;
223 | break;
224 | case CD_VIEWFLAGS:
225 | *p_data = m_viewFlags;
226 | break;
227 | default:
228 | return false;
229 | }
230 | return true;
231 | }
232 |
233 | bool ConfigurationData::SaveData() const
234 | {
235 | bool retVal = true;
236 | retVal &= ConfigData->Write(wxT("/openMSXpaths/ExecPath"), m_openMSXExecPath);
237 | retVal &= ConfigData->Write(wxT("/configuration/InstalledMachines"), m_installedMachines);
238 | retVal &= ConfigData->Write(wxT("/configuration/InstalledExtensions"), m_installedExtensions);
239 | retVal &= ConfigData->Write(wxT("/history/DiskA"), m_diskaHistory);
240 | retVal &= ConfigData->Write(wxT("/history/DiskB"), m_diskbHistory);
241 | retVal &= ConfigData->Write(wxT("/history/CartA"), m_cartaHistory);
242 | retVal &= ConfigData->Write(wxT("/history/CartB"), m_cartbHistory);
243 | retVal &= ConfigData->Write(wxT("/history/Cassette"), m_cassetteHistory);
244 | retVal &= ConfigData->Write(wxT("/history/Harddisk"), m_hardDiskHistory);
245 | retVal &= ConfigData->Write(wxT("/history/IpsDiskA"), m_diskaIps);
246 | retVal &= ConfigData->Write(wxT("/history/IpsDiskB"), m_diskbIps);
247 | retVal &= ConfigData->Write(wxT("/history/IpsCartA"), m_cartaIps);
248 | retVal &= ConfigData->Write(wxT("/history/IpsCartB"), m_cartbIps);
249 | retVal &= ConfigData->Write(wxT("/history/TypeCartA"), m_typeHistCartA);
250 | retVal &= ConfigData->Write(wxT("/history/TypeCartB"), m_typeHistCartB);
251 | retVal &= ConfigData->Write(wxT("/history/MediaInserted"), m_mediaInserted);
252 | retVal &= ConfigData->Write(wxT("/history/UsedMachine"), m_usedMachine);
253 | retVal &= ConfigData->Write(wxT("/history/UsedExtensions"), m_usedExtensions);
254 | retVal &= ConfigData->Write(wxT("/preferences/ShowFullScreenWarning"), m_showFullScreenWarning);
255 | retVal &= ConfigData->Write(wxT("/preferences/ShowScreenshotInfo"), m_showScreenshotInfo);
256 | retVal &= ConfigData->Write(wxT("/preferences/AutoCreateCassetteRecordFile"), m_cassetteAutoCreate);
257 | retVal &= ConfigData->Write(wxT("/connectors/UsedJoyport1"), m_usedJoyport1);
258 | retVal &= ConfigData->Write(wxT("/connectors/UsedJoyport2"), m_usedjoyport2);
259 | retVal &= ConfigData->Write(wxT("/configuration/ViewFlags"), m_viewFlags);
260 | // retVal &= ConfigData->Write(wxT("/connectors/UsedPrinterport"), m_usedPrinterport); //saving disabled
261 | // retVal &= ConfigData->Write(wxT("/connectors/UsedPrinterfile"), m_usedPrinterfile);
262 | return retVal;
263 | }
264 |
--------------------------------------------------------------------------------
/src/ConfigurationData.h:
--------------------------------------------------------------------------------
1 | #ifndef CONFIGURATIONDATA_H
2 | #define CONFIGURATIONDATA_H
3 |
4 | #include "wxCatapultApp.h"
5 | #include
6 |
7 | class wxConfigBase;
8 |
9 | class ConfigurationData
10 | {
11 | public:
12 | enum ID {
13 | CD_NONE = 0,
14 | CD_EXECPATH, CD_MACHINES, CD_EXTENSIONS,
15 | CD_HISTDISKA, CD_HISTDISKB, CD_HISTCARTA, CD_HISTCARTB,
16 | CD_HISTCASSETTE, CD_HISTHDD, CD_TYPEHISTCARTA,
17 | CD_TYPEHISTCARTB, CD_IPSDISKA, CD_IPSDISKB, CD_IPSCARTA,
18 | CD_IPSCARTB, CD_MEDIAINSERTED, CD_USEDMACHINE,
19 | CD_USEDEXTENSIONS, CD_FULLSCREENWARN, CD_SCREENSHOTINFO,
20 | CD_JOYPORT1, CD_JOYPORT2, CD_PRINTERPORT, CD_PRINTERFILE,
21 | CD_VIEWFLAGS, CD_AUTORECORD
22 | };
23 | enum MediaBits {
24 | MB_DISKA = 1,
25 | MB_DISKB = 2,
26 | MB_CARTA = 4,
27 | MB_CARTB = 8,
28 | MB_CASSETTE = 16,
29 | MB_HDD = 32,
30 | };
31 | enum ViewFlags {
32 | VF_BROKEN = 1
33 | };
34 |
35 | static ConfigurationData& instance();
36 |
37 | bool SaveData() const;
38 | bool GetParameter(int p_iId, wxString& p_data) const;
39 | bool GetParameter(int p_iId, int* p_data) const;
40 | bool SetParameter(int p_iId, wxVariant p_data);
41 | bool HaveRequiredSettings() const;
42 |
43 | private:
44 | ConfigurationData();
45 |
46 | int m_mediaInserted;
47 | int m_viewFlags;
48 | int m_showFullScreenWarning;
49 | int m_showScreenshotInfo;
50 | int m_cassetteAutoCreate;
51 | wxString m_openMSXExecPath;
52 | wxString m_installedMachines;
53 | wxString m_installedExtensions;
54 | wxString m_diskaHistory;
55 | wxString m_diskbHistory;
56 | wxString m_cartaHistory;
57 | wxString m_cartbHistory;
58 | wxString m_cassetteHistory;
59 | wxString m_hardDiskHistory;
60 | wxString m_diskaIps;
61 | wxString m_diskbIps;
62 | wxString m_cartaIps;
63 | wxString m_cartbIps;
64 | wxString m_typeHistCartA;
65 | wxString m_typeHistCartB;
66 | wxString m_usedMachine;
67 | wxString m_usedExtensions;
68 | wxString m_usedJoyport1;
69 | wxString m_usedjoyport2;
70 | wxString m_usedPrinterport;
71 | wxString m_usedPrinterfile;
72 |
73 | wxConfigBase* ConfigData;
74 | };
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/src/FullScreenDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "FullScreenDlg.h"
2 | #include "ConfigurationData.h"
3 | #include
4 | #include
5 | #include
6 |
7 | IMPLEMENT_CLASS(FullScreenDlg, wxDialog)
8 | BEGIN_EVENT_TABLE(FullScreenDlg, wxDialog)
9 | EVT_BUTTON(XRCID("OkButton"), FullScreenDlg::OnOk)
10 | EVT_BUTTON(XRCID("CancelButton"), FullScreenDlg::OnCancel)
11 | END_EVENT_TABLE()
12 |
13 | FullScreenDlg::FullScreenDlg(wxWindow* parent)
14 | {
15 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("FullScreenDialog"));
16 | }
17 |
18 | void FullScreenDlg::OnCancel(wxCommandEvent& event)
19 | {
20 | EndModal(wxID_CANCEL);
21 | }
22 |
23 | void FullScreenDlg::OnOk(wxCommandEvent& event)
24 | {
25 | auto& config = ConfigurationData::instance();
26 | auto* box = (wxCheckBox*)FindWindowByName(wxT("DoNotShow"));
27 | long notwarn = 0;
28 | if (box->IsChecked()) {
29 | notwarn = 1;
30 | }
31 | config.SetParameter(ConfigurationData::CD_FULLSCREENWARN, notwarn);
32 | config.SaveData();
33 | EndModal(wxID_OK);
34 | }
35 |
--------------------------------------------------------------------------------
/src/FullScreenDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef FULLSCREENDLG_H
2 | #define FULLSCREENDLG_H
3 |
4 | #include
5 |
6 | class FullScreenDlg : public wxDialog
7 | {
8 | public:
9 | FullScreenDlg(wxWindow* parent = nullptr);
10 |
11 | private:
12 | void OnCancel(wxCommandEvent& event);
13 | void OnOk(wxCommandEvent& event);
14 |
15 | DECLARE_CLASS(FullScreenDlg)
16 | DECLARE_EVENT_TABLE()
17 | };
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/IPSSelectionDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "IPSSelectionDlg.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | IMPLEMENT_CLASS(IPSSelectionDlg, wxDialog)
12 | BEGIN_EVENT_TABLE(IPSSelectionDlg, wxDialog)
13 | EVT_BUTTON( XRCID("IPSOkButton"), IPSSelectionDlg::OnOk)
14 | EVT_BUTTON( XRCID("IPSCancelButton"), IPSSelectionDlg::OnCancel)
15 | EVT_BUTTON( XRCID("AddIPSButton"), IPSSelectionDlg::OnAddIPS)
16 | EVT_BUTTON( XRCID("RemoveIPSButton"), IPSSelectionDlg::OnRemoveIPS)
17 | EVT_BUTTON( XRCID("MoveIPSUpButton"), IPSSelectionDlg::OnMoveUp)
18 | EVT_BUTTON( XRCID("MoveIPSDownButton"),IPSSelectionDlg::OnMoveDown)
19 | EVT_LISTBOX(XRCID("IPSList"), IPSSelectionDlg::OnSelectIPS)
20 | END_EVENT_TABLE()
21 |
22 | IPSSelectionDlg::IPSSelectionDlg(wxWindow* parent)
23 | {
24 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("IPSSelectionDialog"));
25 | m_ipsDisplay = (wxListBox*)FindWindowByName(wxT("IPSList"));
26 | m_ipsRemoveButton = (wxButton*)FindWindowByName(wxT("RemoveIPSButton"));
27 | m_ipsMoveDownButton = (wxButton*)FindWindowByName(wxT("MoveIPSDownButton"));
28 | m_ipsMoveUpButton = (wxButton*)FindWindowByName(wxT("MoveIPSUpButton"));
29 | m_ipsDisplay->Clear();
30 | m_ipsMoveUpButton ->Enable(false);
31 | m_ipsMoveDownButton->Enable(false);
32 | m_ipsRemoveButton ->Enable(false);
33 | }
34 |
35 | int IPSSelectionDlg::Present(const wxArrayString& patches, const wxString& targetDir)
36 | {
37 | m_lastBrowseLocation = targetDir;
38 | m_ipsDisplay->Clear();
39 | for (auto& p : patches) {
40 | m_ipsDisplay->Append(p);
41 | }
42 | wxMemoryDC tempDC;
43 | tempDC.SetFont(m_ipsDisplay->GetFont());
44 | int wMax = 392;
45 | int items = m_ipsDisplay->GetCount();
46 | for (int index = 0; index < items; ++index) {
47 | int w, h;
48 | tempDC.GetTextExtent(m_ipsDisplay->GetString(index) + wxT("W"), &w, &h);
49 | wMax = std::max(wMax, w);
50 | }
51 | m_ipsDisplay->SetSizeHints(wMax + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X), 118);
52 | Fit();
53 | return ShowModal();
54 | }
55 |
56 | void IPSSelectionDlg::OnCancel(wxCommandEvent& event)
57 | {
58 | EndModal(wxID_CANCEL);
59 | }
60 |
61 | void IPSSelectionDlg::OnOk(wxCommandEvent& event)
62 | {
63 | EndModal (wxID_OK);
64 | }
65 |
66 | void IPSSelectionDlg::OnAddIPS(wxCommandEvent& event)
67 | {
68 | wxString path = wxT("All known patchfiles|*.ips;*.IPS;*.gz;*.GZ;*.zip;*.ZIP|Uncompressed patchfiles (*.ips)|*.ips;*.IPS|Compressed patchfiles|*.gz;*.GZ;*.zip;*.ZIP|All files|*.*||");
69 | wxFileDialog filedlg(this, wxT("Select ips patchfile"), m_lastBrowseLocation,
70 | wxT(""), path, wxFD_OPEN | wxFD_MULTIPLE);
71 | if (filedlg.ShowModal() == wxID_OK) {
72 | wxArrayString results;
73 | filedlg.GetPaths(results);
74 | for (auto& path: results) {
75 | m_ipsDisplay->Append(path);
76 | m_lastBrowseLocation = ::wxPathOnly(path);
77 | }
78 | CheckSelections();
79 | }
80 | }
81 |
82 | void IPSSelectionDlg::OnRemoveIPS(wxCommandEvent& event)
83 | {
84 | wxArrayInt selections;
85 | int num = m_ipsDisplay->GetSelections(selections);
86 | for (int i = num - 1; i >= 0; --i) {
87 | m_ipsDisplay->Delete(selections[i]);
88 | }
89 | CheckSelections();
90 | }
91 |
92 | void IPSSelectionDlg::OnMoveUp(wxCommandEvent& event)
93 | {
94 | wxArrayInt selections;
95 | int num = m_ipsDisplay->GetSelections(selections);
96 | for (int i = 0; i < num; ++i) {
97 | wxString temp = m_ipsDisplay->GetString(selections[i]);
98 | m_ipsDisplay->Delete(selections[i]);
99 | m_ipsDisplay->InsertItems(1, &temp, selections[i] - 1);
100 | m_ipsDisplay->SetSelection(selections[i] - 1, true);
101 | }
102 | CheckSelections();
103 | }
104 |
105 | void IPSSelectionDlg::OnMoveDown(wxCommandEvent& event)
106 | {
107 | wxArrayInt selections;
108 | int num = m_ipsDisplay->GetSelections(selections);
109 | for (int i = num - 1; i >= 0; --i) {
110 | wxString temp = m_ipsDisplay->GetString(selections[i]);
111 | m_ipsDisplay->Delete(selections[i]);
112 | m_ipsDisplay->InsertItems(1, &temp, selections[i] + 1);
113 | m_ipsDisplay->SetSelection(selections[i] + 1, true);
114 | }
115 | CheckSelections();
116 | }
117 |
118 | void IPSSelectionDlg::OnSelectIPS(wxCommandEvent& event)
119 | {
120 | CheckSelections();
121 | }
122 |
123 | wxArrayString IPSSelectionDlg::GetIPSList() const
124 | {
125 | wxArrayString result;
126 | for (size_t i = 0; i < m_ipsDisplay->GetCount(); ++i) {
127 | result.Add(m_ipsDisplay->GetString(i));
128 | }
129 | return result;
130 | }
131 |
132 | wxString IPSSelectionDlg::GetLastBrowseLocation()
133 | {
134 | return m_lastBrowseLocation;
135 | }
136 |
137 | void IPSSelectionDlg::CheckSelections()
138 | {
139 | wxArrayInt selections;
140 | int num = m_ipsDisplay->GetSelections(selections);
141 | if (num == 0) {
142 | m_ipsRemoveButton->Enable(false);
143 | m_ipsMoveUpButton->Enable(false);
144 | m_ipsMoveDownButton->Enable(false);
145 | } else {
146 | m_ipsRemoveButton->Enable(true);
147 | m_ipsMoveUpButton->Enable(selections[0] != 0);
148 | m_ipsMoveDownButton->Enable(
149 | selections[num - 1] != int(m_ipsDisplay->GetCount()) - 1);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/src/IPSSelectionDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef IPSSELECTIONDLG_H
2 | #define IPSSELECTIONDLG_H
3 |
4 | #include
5 |
6 | class wxListBox;
7 | class wxButton;
8 |
9 | class IPSSelectionDlg : public wxDialog
10 | {
11 | public:
12 | IPSSelectionDlg(wxWindow* parent);
13 |
14 | wxArrayString GetIPSList() const;
15 | wxString GetLastBrowseLocation();
16 | int Present(const wxArrayString& patches, const wxString& targetDir);
17 |
18 | private:
19 | void CheckSelections();
20 | void OnCancel (wxCommandEvent& event);
21 | void OnOk (wxCommandEvent& event);
22 | void OnAddIPS (wxCommandEvent& event);
23 | void OnRemoveIPS(wxCommandEvent& event);
24 | void OnSelectIPS(wxCommandEvent& event);
25 | void OnMoveUp (wxCommandEvent& event);
26 | void OnMoveDown (wxCommandEvent& event);
27 |
28 | wxListBox* m_ipsDisplay;
29 | wxString m_lastBrowseLocation;
30 | wxButton* m_ipsRemoveButton;
31 | wxButton* m_ipsMoveUpButton;
32 | wxButton* m_ipsMoveDownButton;
33 |
34 | DECLARE_CLASS(IPSSelectionDlg)
35 | DECLARE_EVENT_TABLE()
36 | };
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/InputPage.cpp:
--------------------------------------------------------------------------------
1 | #include "InputPage.h"
2 | #include "wxCatapultApp.h"
3 | #include "openMSXController.h"
4 | #include "utils.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | IMPLEMENT_CLASS(InputPage, wxPanel)
11 | BEGIN_EVENT_TABLE(InputPage, wxPanel)
12 | EVT_BUTTON(XRCID("TypeTextButton"), InputPage::OnTypeText)
13 | EVT_BUTTON(XRCID("ClearTextButton"), InputPage::OnClearText)
14 | EVT_TEXT( XRCID("InputText"), InputPage::OnTextChange)
15 | END_EVENT_TABLE()
16 |
17 | InputPage::InputPage(wxWindow* parent, openMSXController& controller)
18 | : m_controller(controller)
19 | {
20 | wxXmlResource::Get()->LoadPanel(this, parent, wxT("InputPage"));
21 | m_inputtext = (wxTextCtrl*)FindWindowByName(wxT("InputText"));
22 | m_typeTextButton = (wxButton*)FindWindowByName(wxT("TypeTextButton"));
23 | m_clearTextButton = (wxButton*)FindWindowByName(wxT("ClearTextButton"));
24 |
25 | m_typeTextButton->Enable(false);
26 | m_clearTextButton->Enable(false);
27 | }
28 |
29 | void InputPage::OnTypeText(wxCommandEvent& event)
30 | {
31 | wxString text = utils::tclEscapeWord(m_inputtext->GetValue());
32 | m_controller.WriteCommand(wxT("type -- ") + text);
33 | }
34 |
35 | void InputPage::OnClearText(wxCommandEvent& event)
36 | {
37 | m_inputtext->Clear();
38 | }
39 |
40 | void InputPage::OnTextChange(wxCommandEvent& event)
41 | {
42 | bool anyText = !m_inputtext->GetValue().IsEmpty();
43 | m_clearTextButton->Enable(anyText);
44 | m_typeTextButton->Enable(m_controller.IsOpenMSXRunning() && anyText);
45 | }
46 |
47 | void InputPage::SetControlsOnEnd()
48 | {
49 | m_typeTextButton->Enable(false);
50 | }
51 |
52 | void InputPage::SetControlsOnLaunch()
53 | {
54 | m_typeTextButton->Enable(!m_inputtext->GetValue().IsEmpty());
55 | }
56 |
--------------------------------------------------------------------------------
/src/InputPage.h:
--------------------------------------------------------------------------------
1 | #ifndef INPUTPAGE_H
2 | #define INPUTPAGE_H
3 |
4 | #include "CatapultPage.h"
5 |
6 | class wxTextCtrl;
7 | class wxButton;
8 |
9 | class openMSXController;
10 |
11 | class InputPage : public CatapultPage
12 | {
13 | public:
14 | InputPage(wxWindow* parent, openMSXController& controller);
15 |
16 | void SetControlsOnEnd();
17 | void SetControlsOnLaunch();
18 |
19 | private:
20 | void OnTypeText(wxCommandEvent& event);
21 | void OnClearText(wxCommandEvent& event);
22 | void OnTextChange(wxCommandEvent& event);
23 |
24 | openMSXController& m_controller;
25 | wxTextCtrl* m_inputtext;
26 | wxButton* m_typeTextButton;
27 | wxButton* m_clearTextButton;
28 |
29 | DECLARE_CLASS(InputPage)
30 | DECLARE_EVENT_TABLE()
31 | };
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/MiscControlPage.h:
--------------------------------------------------------------------------------
1 | #ifndef MISCCONTROLPAGE_H
2 | #define MISCCONTROLPAGE_H
3 |
4 | #include "CatapultPage.h"
5 | #include
6 | #include
7 |
8 | class openMSXController;
9 | class wxBitmapButton;
10 | class wxButton;
11 | class wxComboBox;
12 | class wxStaticText;
13 | class wxTextCtrl;
14 | class wxToggleButton;
15 |
16 | class MiscControlPage : public CatapultPage
17 | {
18 | public:
19 | MiscControlPage(wxWindow* parent, openMSXController& controller);
20 |
21 | void SetControlsOnEnd();
22 | void SetControlsOnLaunch();
23 | void EnableFirmware(wxString setting);
24 | void EnableRenShaTurbo();
25 | void InitConnectorPanel();
26 | void FillInitialJoystickPortValues();
27 |
28 | private:
29 | void InvalidPrinterLogFilename();
30 | void InitJoystickOrPrinterPort(wxString connector, wxString control, wxString connectorClass);
31 | void OnSetCmdTiming(wxCommandEvent& event);
32 | void OnSetNormalSpeed(wxCommandEvent& event);
33 | void OnSetFastForward(wxCommandEvent& event);
34 | void OnSetFastLoading(wxCommandEvent& event);
35 | void OnSpeedChange(wxScrollEvent& event);
36 | void OnSetDefaultFastForwardSpeed(wxCommandEvent& event);
37 | void OnSetDefaultMaxFrameSkip(wxCommandEvent& event);
38 | void OnFastForwardSpeedChange(wxScrollEvent& event);
39 | void OnMaxFrameSkipChange(wxScrollEvent& event);
40 | void OnFirmware(wxCommandEvent& event);
41 | void OnPower(wxCommandEvent& event);
42 | void OnPause(wxCommandEvent& event);
43 | void OnReset(wxCommandEvent& event);
44 | void OnInputFastForwardSpeed(wxCommandEvent& event);
45 | void OnInputMaxFrameskip(wxCommandEvent& event);
46 | void OnChangeJoystick(wxCommandEvent& event);
47 | void OnChangePrinterPort(wxCommandEvent& event);
48 | void OnChangePrinterLogFile(wxCommandEvent& event);
49 | void OnBrowsePrinterLogFile(wxCommandEvent& event);
50 | void OnChangeRenShaTurbo(wxScrollEvent& event);
51 | void OnJoystickChangedTimer(wxTimerEvent& event);
52 | void OnInputSpeed(wxCommandEvent& event);
53 | void OnPrinterportChanged(bool save);
54 | void OnJoystickChanged();
55 |
56 | openMSXController& m_controller;
57 | wxBitmapButton* m_browsePrinterLog;
58 |
59 | wxButton* m_resetButton;
60 | wxButton* m_speedNormalButton;
61 | wxToggleButton* m_fastForwardButton;
62 | wxButton* m_defaultFastForwardSpeedButton;
63 | wxToggleButton* m_fastLoadingButton;
64 | wxButton* m_defaultMaxFrameSkipButton;
65 |
66 | wxStaticText* m_emulationSpeedLabel;
67 | wxStaticText* m_fastForwardSpeedLabel;
68 | wxStaticText* m_frameskipMaxLabel;
69 | wxStaticText* m_printerportLabel;
70 | wxStaticText* m_renshaLabel;
71 | wxStaticText* m_printerportFileLabel;
72 |
73 | wxToggleButton* m_powerButton;
74 | wxToggleButton* m_pauseButton;
75 | wxToggleButton* m_firmwareButton;
76 | wxSlider* m_speedSlider;
77 | wxSlider* m_maxFrameSkipSlider;
78 | wxSlider* m_fastForwardSpeedSlider;
79 | wxSlider* m_renshaTurboSlider;
80 | wxTextCtrl* m_speedIndicator;
81 | wxTextCtrl* m_fastForwardSpeedIndicator;
82 | wxTextCtrl* m_maxFrameSkipIndicator;
83 | wxTextCtrl* m_printerLogFile;
84 | wxString m_oldJoy1;
85 | wxString m_oldJoy2;
86 | wxString m_firmwareSetting;
87 | wxComboBox* m_lastUpdatedCombo;
88 | wxComboBox* m_printerportSelector;
89 |
90 | #ifdef __UNIX__
91 | wxTimer m_joystick_update_timer; // bad solution for a worse bug in (wx?)gtk
92 | #endif
93 | DECLARE_CLASS(MiscControlPage)
94 | DECLARE_EVENT_TABLE()
95 | };
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/src/PipeConnectThread.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "wxCatapultApp.h"
5 | #include "PipeConnectThread.h"
6 |
7 | PipeConnectThread::PipeConnectThread(wxWindow* target)
8 | {
9 | m_target = target;
10 | }
11 |
12 | wxThread::ExitCode PipeConnectThread::Entry()
13 | {
14 | if (!ConnectNamedPipe(m_pipeHandle, nullptr)) {
15 | wxMessageBox(wxString::Format(
16 | wxT("Error connection pipe: %ld"), GetLastError()));
17 | }
18 | wxCommandEvent endEvent(EVT_CONTROLLER);
19 | endEvent.SetId(MSGID_PIPECREATED);
20 | wxPostEvent(m_target, endEvent);
21 | return 0;
22 | }
23 |
24 | void PipeConnectThread::SetHandle(HANDLE pipeHandle)
25 | {
26 | m_pipeHandle = pipeHandle;
27 | }
28 |
--------------------------------------------------------------------------------
/src/PipeConnectThread.h:
--------------------------------------------------------------------------------
1 | #ifndef PIPECONNECTTHREAD_H
2 | #define PIPECONNECTTHREAD_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class PipeConnectThread : public wxThread
11 | {
12 | public:
13 | PipeConnectThread(wxWindow* target);
14 |
15 | void SetHandle(HANDLE pipeHandle);
16 | wxThread::ExitCode Entry();
17 |
18 | private:
19 | wxWindow* m_target;
20 | HANDLE m_pipeHandle;
21 | };
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/PipeReadThread.cpp:
--------------------------------------------------------------------------------
1 | #include "PipeReadThread.h"
2 | #include "wxCatapultApp.h"
3 | #include
4 | #ifdef __UNIX__
5 | #include
6 | #endif
7 |
8 | PipeReadThread::PipeReadThread(wxWindow* target, int id, wxThreadKind kind)
9 | : wxThread(kind)
10 | {
11 | m_target = target;
12 | m_id = id;
13 | }
14 |
15 | wxThread::ExitCode PipeReadThread::Entry()
16 | {
17 | while (true) {
18 | char buffer[1000];
19 | #ifdef __UNIX__
20 | ssize_t bytesRead = read(m_descriptor, buffer, 1000);
21 | if (bytesRead <= 0) break;
22 | #else
23 | DWORD bytesRead;
24 | if (!ReadFile(m_hTarget, buffer, 1000, &bytesRead, nullptr)) break;
25 | #endif
26 | wxString* eventClientData = new wxString(buffer, wxConvUTF8, bytesRead);
27 | wxCommandEvent event(EVT_CONTROLLER);
28 | event.SetId(m_id);
29 | event.SetClientData(eventClientData);
30 | wxPostEvent(m_target, event);
31 | }
32 | #ifdef __UNIX__
33 | close(m_descriptor);
34 | #endif
35 | wxCommandEvent endEvent(EVT_CONTROLLER);
36 | endEvent.SetId(MSGID_ENDPROCESS);
37 | wxPostEvent(m_target, endEvent);
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/src/PipeReadThread.h:
--------------------------------------------------------------------------------
1 | #ifndef PIPEREADTHREAD_H
2 | #define PIPEREADTHREAD_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #ifdef __WXMSW__
9 | #include
10 | #undef Yield
11 | #endif
12 |
13 | class PipeReadThread : public wxThread
14 | {
15 | public:
16 | PipeReadThread(wxWindow* target, int id, wxThreadKind kind = wxTHREAD_DETACHED);
17 |
18 | #ifdef __WXMSW__
19 | void SetHandle(HANDLE hTarget) { m_hTarget = hTarget; }
20 | #else
21 | void SetFileDescriptor(int descriptor) { m_descriptor = descriptor; }
22 | #endif
23 | wxThread::ExitCode Entry();
24 |
25 | private:
26 | int m_id;
27 | wxWindow* m_target;
28 |
29 | #ifdef __WXMSW__
30 | HANDLE m_hTarget;
31 | #else
32 | int m_descriptor;
33 | #endif
34 | };
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/src/RomTypeDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "RomTypeDlg.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | IMPLEMENT_CLASS(RomTypeDlg, wxDialog)
10 | BEGIN_EVENT_TABLE(RomTypeDlg, wxDialog)
11 | EVT_BUTTON( XRCID("RomTypeOkButton"), RomTypeDlg::OnOk)
12 | EVT_LISTBOX_DCLICK(XRCID("RomTypeList"), RomTypeDlg::OnOk)
13 | EVT_BUTTON( XRCID("RomTypeCancelButton"), RomTypeDlg::OnCancel)
14 | END_EVENT_TABLE()
15 |
16 | RomTypeDlg::RomTypeDlg(wxWindow* parent)
17 | {
18 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("RomTypeDialog"));
19 | m_romTypeList = (wxListBox*)FindWindowByName(wxT("RomTypeList"));
20 | m_romTypeList->Clear();
21 | }
22 |
23 | int RomTypeDlg::Present(wxString type)
24 | {
25 | wxMemoryDC tempDC;
26 | tempDC.SetFont(m_romTypeList->GetFont());
27 | int dx, dy;
28 | m_romTypeList->GetSize(&dx, &dy); //default size
29 | int wMax = dx;
30 | int items = m_romTypeList->GetCount();
31 | for (int i = 0; i < items; ++i) {
32 | int w, h;
33 | tempDC.GetTextExtent(m_romTypeList->GetString(i) + wxT("W"), &w, &h);
34 | wMax = std::max(wMax, w);
35 | }
36 | m_romTypeList->SetSizeHints(wMax + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X), 280);
37 | if (!type.IsEmpty()) {
38 | wxString fullName = ConvertRomType(type, false);
39 | int pos = m_romTypeList->FindString(fullName);
40 | if (pos != wxNOT_FOUND) {
41 | m_romTypeList->SetSelection(pos, true);
42 | }
43 | } else {
44 | m_romTypeList->SetSelection(0, true);
45 | }
46 | Fit();
47 | return ShowModal();
48 | }
49 |
50 | void RomTypeDlg::OnCancel(wxCommandEvent& event)
51 | {
52 | EndModal(wxID_CANCEL);
53 | }
54 |
55 | void RomTypeDlg::OnOk(wxCommandEvent& event)
56 | {
57 | wxString fullTypeName = m_romTypeList->GetStringSelection();
58 | m_selectedType = ConvertRomType(fullTypeName, true);
59 | EndModal(wxID_OK);
60 | }
61 |
62 | wxString RomTypeDlg::GetSelectedType()
63 | {
64 | return m_selectedType;
65 | }
66 |
67 | void RomTypeDlg::AddRomType(wxString type)
68 | {
69 | int index = FindRomType(type);
70 | if (index == wxNOT_FOUND) {
71 | m_romTypes.Add(type);
72 | m_romTypes.Add(wxT("_")); // empty name
73 | }
74 | }
75 |
76 | void RomTypeDlg::SetRomTypeFullName(wxString type, wxString name)
77 | {
78 | int index = FindRomType(type);
79 | if (index != wxNOT_FOUND) {
80 | m_romTypes[index + 1] = name;
81 | if (m_romTypeList->FindString(name) == wxNOT_FOUND) {
82 | m_romTypeList->Append(name);
83 | }
84 | }
85 | }
86 |
87 | int RomTypeDlg::FindRomType(wxString type)
88 | {
89 | for (size_t counter = 0; counter < m_romTypes.GetCount(); counter += 2) {
90 | if (m_romTypes[counter] == type) return counter;
91 | }
92 | return wxNOT_FOUND;
93 | }
94 |
95 | int RomTypeDlg::FindRomFullTypeName(wxString name)
96 | {
97 | for (size_t counter = 1; counter < m_romTypes.GetCount(); counter += 2) {
98 | if (m_romTypes[counter] == name) return counter;
99 | }
100 | return wxNOT_FOUND;
101 | }
102 |
103 | wxString RomTypeDlg::ConvertRomType(wxString source, bool backwards)
104 | {
105 | int index = backwards
106 | ? FindRomFullTypeName(source) - 1
107 | : FindRomType(source) + 1;
108 | return (index != wxNOT_FOUND) ? m_romTypes[index] : wxString();
109 | }
110 |
--------------------------------------------------------------------------------
/src/RomTypeDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef ROMTYPEDLG_H
2 | #define ROMTYPEDLG_H
3 |
4 | #include
5 |
6 | class wxListBox;
7 |
8 | class RomTypeDlg : public wxDialog
9 | {
10 | public:
11 | RomTypeDlg(wxWindow* parent);
12 |
13 | wxString GetSelectedType();
14 | void AddRomType(wxString type);
15 | void SetRomTypeFullName(wxString type, wxString name);
16 | int Present(wxString type);
17 |
18 | private:
19 | void OnCancel(wxCommandEvent& event);
20 | void OnOk(wxCommandEvent& event);
21 | int FindRomType(wxString type);
22 | int FindRomFullTypeName(wxString name);
23 | wxString ConvertRomType(wxString source, bool backwards);
24 |
25 | wxListBox* m_romTypeList;
26 | wxArrayString m_romTypes;
27 | wxString m_selectedType;
28 |
29 | DECLARE_CLASS(RomTypeDlg)
30 | DECLARE_EVENT_TABLE()
31 | };
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/ScreenShotDlg.cpp:
--------------------------------------------------------------------------------
1 | #include "ScreenShotDlg.h"
2 | #include "ConfigurationData.h"
3 | #include
4 | #include
5 | #include
6 |
7 | IMPLEMENT_CLASS(ScreenshotDlg, wxDialog)
8 | BEGIN_EVENT_TABLE(ScreenshotDlg, wxDialog)
9 | EVT_BUTTON(XRCID("OkButton"), ScreenshotDlg::OnOk)
10 | END_EVENT_TABLE()
11 |
12 | ScreenshotDlg::ScreenshotDlg(wxWindow* parent)
13 | {
14 | wxXmlResource::Get()->LoadDialog(this, parent, wxT("ScreenshotDialog"));
15 | }
16 |
17 | void ScreenshotDlg::OnOk(wxCommandEvent& event)
18 | {
19 | auto& config = ConfigurationData::instance();
20 | auto* box = (wxCheckBox*)FindWindowByName(wxT("DoNotShow"));
21 | long notwarn = 0;
22 | if (box->IsChecked()) {
23 | notwarn = 1;
24 | }
25 | config.SetParameter(ConfigurationData::CD_SCREENSHOTINFO, notwarn);
26 | config.SaveData();
27 | EndModal(wxID_OK);
28 | }
29 |
--------------------------------------------------------------------------------
/src/ScreenShotDlg.h:
--------------------------------------------------------------------------------
1 | #ifndef SCREENSHOTDLG_H
2 | #define SCREENSHOTDLG_H
3 |
4 | #include
5 |
6 | class ScreenshotDlg : public wxDialog
7 | {
8 | public:
9 | ScreenshotDlg(wxWindow* parent);
10 |
11 | private:
12 | void OnOk(wxCommandEvent& event);
13 |
14 | DECLARE_CLASS(ScreenshotDlg)
15 | DECLARE_EVENT_TABLE()
16 | };
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/src/SessionPage.h:
--------------------------------------------------------------------------------
1 | #ifndef SESSIONPAGE_H
2 | #define SESSIONPAGE_H
3 |
4 | #include "ConfigurationData.h"
5 | #include "CatapultPage.h"
6 | #include
7 | #include
8 |
9 | class RomTypeDlg;
10 | class IPSSelectionDlg;
11 | class openMSXController;
12 | class wxCatapultFrame;
13 | class wxComboBox;
14 | class wxButton;
15 | class wxBitmapButton;
16 | class wxStaticText;
17 | class wxToggleButton;
18 | class wxListBox;
19 |
20 |
21 | class SessionPage : public CatapultPage
22 | {
23 | public:
24 | SessionPage(wxWindow* parent, openMSXController& controller);
25 |
26 | void SetupHardware(bool initial, bool reset);
27 | void SetControlsOnLaunch();
28 | void SetControlsOnEnd();
29 | void SetCassetteControl();
30 | /**
31 | * Set enabledness for hard disk controls.
32 | * @param forcedDisable Force disabling controls, instead of relying on
33 | * internal parameter evaluation. should only be used in very special
34 | * cases (see cpp file). This is a 'hack'.
35 | */
36 | void SetHardDiskControl(bool forcedDisable = false);
37 | void EnableCassettePort(wxString data);
38 | void SetCassetteMode(wxString data);
39 | const wxArrayString& GetDetectedMachines() const;
40 | const wxArrayString& GetDetectedExtensions() const;
41 | void GetRomTypes();
42 | void RestoreHistory();
43 | void FixLayout();
44 | wxString getStartupCommandLineOptions() const;
45 |
46 | friend class SessionDropTarget;
47 |
48 | private:
49 | enum MediaType { DISKETTE, CARTRIDGE, CASSETTE, HARDDISK };
50 | struct MediaInfo {
51 | MediaInfo(wxMenu& menu_, const wxString& deviceName_,
52 | const wxString& control_,
53 | ConfigurationData::MediaBits bits,
54 | ConfigurationData::ID id,
55 | ConfigurationData::ID typeId_,
56 | ConfigurationData::ID ipsId_,
57 | wxButton* button_, MediaType mediaType_,
58 | int ipsLabel_, int typeLabel_)
59 | : menu(menu_)
60 | , deviceName(deviceName_)
61 | , control(*(wxComboBox*)FindWindowByName(control_))
62 | , mediaBits(bits)
63 | , confId(id)
64 | , typeId(typeId_)
65 | , ipsId(ipsId_)
66 | , button(button_)
67 | , mediaType(mediaType_)
68 | , ipsLabel(ipsLabel_)
69 | , typeLabel(typeLabel_) {}
70 | wxMenu& menu;
71 | const wxString deviceName;
72 | wxComboBox& control;
73 | const ConfigurationData::MediaBits mediaBits;
74 | const ConfigurationData::ID confId;
75 | const ConfigurationData::ID typeId;
76 | const ConfigurationData::ID ipsId;
77 | wxButton* button;
78 | wxString ipsdir;
79 | wxArrayString ips;
80 | wxString type; // only for carts at the moment
81 | wxString lastContents;
82 | const MediaType mediaType;
83 | const int ipsLabel;
84 | const int typeLabel;
85 | };
86 | struct HistoryData : public wxClientData {
87 | HistoryData(const wxString& type_, const wxArrayString& ips_)
88 | : type(type_), ips(ips_) {}
89 | wxString type;
90 | wxArrayString ips;
91 | };
92 |
93 | virtual void HandleFocusChange(wxWindow* oldFocus, wxWindow* newFocus);
94 | void checkLooseFocus(wxWindow* oldFocus, MediaInfo& media);
95 | void insertMedia(MediaInfo& m);
96 | void insertMediaClear(MediaInfo& m);
97 | void OnBrowseDiskA(wxCommandEvent& event);
98 | void OnBrowseDiskB(wxCommandEvent& event);
99 | void OnBrowseCartA(wxCommandEvent& event);
100 | void OnBrowseCartB(wxCommandEvent& event);
101 | void OnBrowseCassette(wxCommandEvent& event);
102 | void OnBrowseHardDisk(wxCommandEvent& event);
103 | void OnEjectDiskB(wxCommandEvent& event);
104 | void OnEjectDiskA(wxCommandEvent& event);
105 | void OnEjectCartA(wxCommandEvent& event);
106 | void OnEjectCartB(wxCommandEvent& event);
107 | void OnClearCassette(wxCommandEvent& event);
108 | void OnEjectHardDisk(wxCommandEvent& event);
109 | void OnRewind(wxCommandEvent& event);
110 | void OnMotorControl(wxCommandEvent& event);
111 | void OnModePlay(wxCommandEvent& event);
112 | void OnModeRecord(wxCommandEvent& event);
113 | void OnAutoCassettefile(wxCommandEvent& event);
114 | void OnClickDiskACombo(wxCommandEvent& event);
115 | void OnClickDiskBCombo(wxCommandEvent& event);
116 | void OnClickCartACombo(wxCommandEvent& event);
117 | void OnClickCartBCombo(wxCommandEvent& event);
118 | void OnClickCassetteCombo(wxCommandEvent& event);
119 | void OnClickHardDiskCombo(wxCommandEvent& event);
120 | void OnClickMediaMenu(wxCommandEvent& event);
121 | void OnInsertEmptyDiskByMenu(wxCommandEvent& event);
122 | void OnBrowseDiskByMenu(wxCommandEvent& event);
123 | void OnBrowseIps(wxCommandEvent& event);
124 | void OnBrowseDiskDirByMenu(wxCommandEvent& event);
125 | void OnBrowseCartByMenu(wxCommandEvent& event);
126 | void OnEjectByMenu(wxCommandEvent& event);
127 | void OnSelectMapper(wxCommandEvent& event);
128 | void OnMachineOrExtensionListChanged(wxCommandEvent& event);
129 |
130 | void SetupRomType(wxString romtype, wxString fullname);
131 | MediaInfo* GetLastMenuTarget() const;
132 | void SetIpsList(MediaInfo& m, const wxArrayString& ips);
133 | void SetMapperType(MediaInfo& media, const wxString& type);
134 | void BrowseDisk(MediaInfo& media);
135 | void BrowseCart(MediaInfo& media);
136 | void BrowseMedia(MediaInfo& m, const wxString& path, const wxString title);
137 | void ClickMediaCombo(wxCommandEvent& event, MediaInfo& media);
138 | void prepareMachines ();
139 | void prepareExtensions();
140 | void AddHistory(MediaInfo& media);
141 | void SaveHistory();
142 | void EjectMedia(MediaInfo& media);
143 | wxArrayString getHardware() const; // TODO rewrite this
144 |
145 | wxComboBox* m_machineList;
146 | wxListBox* m_extensionList;
147 |
148 | enum { DISKA, DISKB, CARTA, CARTB, CAS, HDD, NUM_MEDIA };
149 | std::unique_ptr media[NUM_MEDIA];
150 |
151 | wxToggleButton* m_playButton;
152 | wxToggleButton* m_recordButton;
153 | wxButton* m_rewindButton;
154 |
155 | wxButton* m_diskAButton;
156 | wxButton* m_diskBButton;
157 | wxButton* m_cartAButton;
158 | wxButton* m_cartBButton;
159 | wxButton* m_cassetteButton;
160 | wxButton* m_hardDiskButton;
161 |
162 | wxBitmapButton* m_browseCassette;
163 | wxBitmapButton* m_clearCassette;
164 | bool m_hasCassettePort;
165 |
166 | wxBitmapButton* m_browseHardDisk;
167 | wxBitmapButton* m_clearHardDisk;
168 |
169 | wxStaticText* m_machineListLabel;
170 | wxStaticText* m_extensionListLabel;
171 | wxArrayString m_machineArray;
172 | wxArrayString m_extensionArray;
173 |
174 | openMSXController& m_controller;
175 |
176 | wxMenu* m_diskMenu[2];
177 | wxMenu* m_cartMenu[2];
178 | wxMenu* m_casMenu;
179 | wxMenu* m_hardDiskMenu;
180 |
181 | wxButton* m_lastUsedPopup;
182 | std::unique_ptr m_romTypeDialog;
183 | std::unique_ptr m_ipsDialog;
184 | bool m_cassetteControl;
185 | bool m_cassetteAutoCreate;
186 |
187 | DECLARE_CLASS(SessionPage)
188 | DECLARE_EVENT_TABLE()
189 | };
190 |
191 | class SessionDropTarget : public wxFileDropTarget
192 | {
193 | public:
194 | SessionDropTarget(SessionPage::MediaInfo* target, SessionPage* sessionPage);
195 | bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
196 |
197 | private:
198 | SessionPage::MediaInfo* m_target;
199 | SessionPage* m_sessionPage;
200 | };
201 |
202 |
203 | #endif
204 |
--------------------------------------------------------------------------------
/src/StatusPage.cpp:
--------------------------------------------------------------------------------
1 | #include "StatusPage.h"
2 | #include "wxCatapultApp.h"
3 | #include
4 | #include
5 | #include
6 |
7 | IMPLEMENT_CLASS(StatusPage, wxPanel)
8 | BEGIN_EVENT_TABLE(StatusPage, wxPanel)
9 | END_EVENT_TABLE()
10 |
11 | StatusPage::StatusPage(wxWindow* parent)
12 | {
13 | wxXmlResource::Get()->LoadPanel(this, parent, wxT("StatusPage"));
14 | m_outputtext = (wxTextCtrl*)FindWindowByName(wxT("OutputText"));
15 | }
16 |
17 | void StatusPage::Clear()
18 | {
19 | m_outputtext->Clear();
20 | }
21 |
22 | void StatusPage::Add(const wxColour& col, const wxString& str)
23 | {
24 | m_outputtext->SetDefaultStyle(wxTextAttr(
25 | col, wxNullColour,
26 | wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)));
27 | m_outputtext->AppendText(str);
28 | }
29 |
--------------------------------------------------------------------------------
/src/StatusPage.h:
--------------------------------------------------------------------------------
1 | #ifndef STATUSPAGE_H
2 | #define STATUSPAGE_H
3 |
4 | #include "CatapultPage.h"
5 |
6 | class wxTextCtrl;
7 |
8 | class StatusPage : public CatapultPage
9 | {
10 | public:
11 | StatusPage(wxWindow* parent);
12 |
13 | void Clear();
14 | void Add(const wxColour& col, const wxString& str);
15 |
16 | private:
17 | wxTextCtrl* m_outputtext;
18 |
19 | DECLARE_CLASS(StatusPage)
20 | DECLARE_EVENT_TABLE()
21 | };
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/Version.cpp:
--------------------------------------------------------------------------------
1 | #include "Version.h"
2 | #include "Version.ii"
3 |
4 | const std::string Version::FULL_VERSION =
5 | "openMSX Catapult " + Version::VERSION +
6 | (Version::RELEASE ? "" : "-" + Version::REVISION);
7 |
--------------------------------------------------------------------------------
/src/Version.h:
--------------------------------------------------------------------------------
1 | #ifndef VERSION_HH
2 | #define VERSION_HH
3 |
4 | #include
5 |
6 | class Version {
7 | public:
8 | // Defined by build system:
9 | static const bool RELEASE;
10 | static const std::string VERSION;
11 | static const std::string REVISION;
12 |
13 | // Computed using constants above:
14 | static const std::string FULL_VERSION;
15 | };
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/src/VideoControlPage.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEOCONTROLPAGE_H
2 | #define VIDEOCONTROLPAGE_H
3 |
4 | #include "CatapultPage.h"
5 | #include
6 |
7 | class openMSXController;
8 | class wxComboBox;
9 | class wxButton;
10 | class wxStaticText;
11 | class wxToggleButton;
12 | class wxSlider;
13 | class wxTextCtrl;
14 |
15 | class VideoControlPage : public CatapultPage
16 | {
17 | public:
18 | VideoControlPage(wxWindow* parent, openMSXController& controller);
19 |
20 | void SetControlsOnEnd();
21 | void SetControlsOnLaunch();
22 | void SetSliderDefaults();
23 |
24 | private:
25 | void UpdateScreenshotCounter();
26 | void OnInputScanline(wxCommandEvent& event);
27 | void OnInputGamma(wxCommandEvent& event);
28 | void OnInputNoise(wxCommandEvent& event);
29 | void OnInputGlow(wxCommandEvent& event);
30 | void OnInputBlur(wxCommandEvent& event);
31 | void OnDefaultScanlines(wxCommandEvent& event);
32 | void OnDefaultGamma(wxCommandEvent& event);
33 | void OnDefaultNoise(wxCommandEvent& event);
34 | void OnDefaultGlow(wxCommandEvent& event);
35 | void OnDefaultBlur(wxCommandEvent& event);
36 | void OnChangeScanlines(wxScrollEvent& event);
37 | void OnChangeGamma(wxScrollEvent& event);
38 | void OnChangeNoise(wxScrollEvent& event);
39 | void OnChangeGlow(wxScrollEvent& event);
40 | void OnChangeBlur(wxScrollEvent& event);
41 | void OnLimitSprites(wxCommandEvent& event);
42 | void OnDisableSprites(wxCommandEvent& event);
43 | void OnFullScreen(wxCommandEvent& event);
44 | void OnDeInterlace(wxCommandEvent& event);
45 | void OnVSync(wxCommandEvent& event);
46 | void OnChangeVideoSource(wxCommandEvent& event);
47 | void OnChangeScalerAlgo(wxCommandEvent& event);
48 | void OnChangeScalerFactor(wxCommandEvent& event);
49 | void OnChangeRenderer(wxCommandEvent& event);
50 | void OnBrowseScreenShot(wxCommandEvent& event);
51 | void OnTakeScreenShot(wxCommandEvent& event);
52 | void OnChangeScreenshotFilename(wxCommandEvent& event);
53 | void setNewRenderersAndScalers();
54 |
55 | openMSXController& m_controller;
56 |
57 | wxComboBox* m_videoSourceList;
58 | wxComboBox* m_rendererList;
59 | wxComboBox* m_scalerAlgoList;
60 | wxComboBox* m_scalerFactorList;
61 |
62 | wxButton* m_defaultGammaButton;
63 | wxButton* m_defaultNoiseButton;
64 | wxButton* m_defaultBlurButton;
65 | wxButton* m_defaultGlowButton;
66 | wxButton* m_defaultScanlineButton;
67 | wxButton* m_screenShotButton;
68 |
69 | wxStaticText* m_rendererLabel;
70 | wxStaticText* m_scalerLabel;
71 | wxStaticText* m_videoSourceLabel;
72 | wxStaticText* m_vSyncLabel;
73 | wxStaticText* m_deinterlaceLabel;
74 | wxStaticText* m_limitSpritesLabel;
75 | wxStaticText* m_disableSpritesLabel;
76 | wxStaticText* m_fullScreenLabel;
77 | wxStaticText* m_scanLineLabel;
78 | wxStaticText* m_blurLabel;
79 | wxStaticText* m_glowLabel;
80 | wxStaticText* m_gammaLabel;
81 | wxStaticText* m_noiseLabel;
82 | wxStaticText* m_timesLabel;
83 |
84 | wxToggleButton* m_vSyncButton;
85 | wxToggleButton* m_limitSpritesButton;
86 | wxToggleButton* m_disableSpritesButton;
87 | wxToggleButton* m_deinterlaceButton;
88 | wxToggleButton* m_fullscreenButton;
89 |
90 | wxSlider* m_blurSlider;
91 | wxSlider* m_glowSlider;
92 | wxSlider* m_gammaSlider;
93 | wxSlider* m_noiseSlider;
94 | wxSlider* m_scanlineSlider;
95 |
96 | wxTextCtrl* m_blurIndicator;
97 | wxTextCtrl* m_glowIndicator;
98 | wxTextCtrl* m_gammaIndicator;
99 | wxTextCtrl* m_noiseIndicator;
100 | wxTextCtrl* m_scanlineIndicator;
101 | wxTextCtrl* m_screenShotFile;
102 | wxTextCtrl* m_screenShotCounter;
103 |
104 | wxString m_defaultBlur;
105 | wxString m_defaultGlow;
106 | wxString m_defaultGamma;
107 | wxString m_defaultNoise;
108 | wxString m_defaultScanline;
109 |
110 | DECLARE_CLASS(VideoControlPage)
111 | DECLARE_EVENT_TABLE()
112 | };
113 |
114 | #endif
115 |
--------------------------------------------------------------------------------
/src/catapult.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openMSX/wxcatapult/c2231edf3da6d223f06be4341c336c4f93241d04/src/catapult.ico
--------------------------------------------------------------------------------
/src/catapult.rc:
--------------------------------------------------------------------------------
1 | // Originally a Microsoft Developer Studio generated resource script,
2 | // but now maintained manually because we want to build with MinGW32+MSYS.
3 | //
4 | #include "resource.h"
5 |
6 | // Include resource info from the Catapult build process.
7 | #include "resource-info.h"
8 |
9 | #define APSTUDIO_READONLY_SYMBOLS
10 | /////////////////////////////////////////////////////////////////////////////
11 | //
12 | // Generated from the TEXTINCLUDE 2 resource.
13 | //
14 | #include
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | #undef APSTUDIO_READONLY_SYMBOLS
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | // English (U.S.) resources
21 |
22 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
23 | #ifdef _WIN32
24 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
25 | #pragma code_page(1252)
26 | #endif //_WIN32
27 |
28 | /////////////////////////////////////////////////////////////////////////////
29 | //
30 | // Icon
31 | //
32 |
33 | // Icon with lowest ID value placed first to ensure application icon
34 | // remains consistent on all systems.
35 | CATAPULT ICON DISCARDABLE "catapult.ico"
36 |
37 | #ifndef _MAC
38 | /////////////////////////////////////////////////////////////////////////////
39 | //
40 | // Version
41 | //
42 |
43 | VS_VERSION_INFO VERSIONINFO
44 | FILEVERSION CATAPULT_VERSION_INT
45 | PRODUCTVERSION CATAPULT_VERSION_INT
46 | FILEFLAGSMASK 0x3fL
47 | #ifdef _DEBUG
48 | FILEFLAGS 0x1L
49 | #else
50 | FILEFLAGS 0x0L
51 | #endif
52 | FILEOS 0x40004L
53 | FILETYPE 0x1L
54 | FILESUBTYPE 0x0L
55 | BEGIN
56 | BLOCK "StringFileInfo"
57 | BEGIN
58 | BLOCK "080004b0"
59 | BEGIN
60 | VALUE "Comments", "\0"
61 | VALUE "CompanyName", " \0"
62 | VALUE "FileDescription", "openMSX Catapult\0"
63 | VALUE "FileVersion", CATAPULT_VERSION_STR
64 | VALUE "InternalName", "catapult\0"
65 | VALUE "LegalCopyright", "Copyright 2003-2023\0"
66 | VALUE "LegalTrademarks", "\0"
67 | VALUE "OriginalFilename", "catapult.exe\0"
68 | VALUE "PrivateBuild", "\0"
69 | VALUE "ProductName", "openMSX Catapult\0"
70 | VALUE "ProductVersion", CATAPULT_VERSION_STR
71 | VALUE "SpecialBuild", "\0"
72 | END
73 | END
74 | BLOCK "VarFileInfo"
75 | BEGIN
76 | VALUE "Translation", 0x800, 1200
77 | END
78 | END
79 |
80 | #endif // !_MAC
81 |
82 | #endif // English (U.S.) resources
83 | /////////////////////////////////////////////////////////////////////////////
84 |
85 |
86 | /////////////////////////////////////////////////////////////////////////////
87 | // English (U.S.) (unknown sub-lang: 0xC) resources
88 |
89 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENW)
90 | #ifdef _WIN32
91 | LANGUAGE LANG_ENGLISH, 0xC
92 | #pragma code_page(1252)
93 | #endif //_WIN32
94 |
95 | #ifdef APSTUDIO_INVOKED
96 | /////////////////////////////////////////////////////////////////////////////
97 | //
98 | // TEXTINCLUDE
99 | //
100 |
101 | 1 TEXTINCLUDE DISCARDABLE
102 | BEGIN
103 | "resource.h\0"
104 | END
105 |
106 | 2 TEXTINCLUDE DISCARDABLE
107 | BEGIN
108 | "#include ""afxres.h""\r\n"
109 | "\0"
110 | END
111 |
112 | 3 TEXTINCLUDE DISCARDABLE
113 | BEGIN
114 | "\r\n"
115 | "\0"
116 | END
117 |
118 | #endif // APSTUDIO_INVOKED
119 |
120 | #endif // English (U.S.) (unknown sub-lang: 0xC) resources
121 | /////////////////////////////////////////////////////////////////////////////
122 |
123 |
124 |
125 | #ifndef APSTUDIO_INVOKED
126 | /////////////////////////////////////////////////////////////////////////////
127 | //
128 | // Generated from the TEXTINCLUDE 3 resource.
129 | //
130 |
131 |
132 | /////////////////////////////////////////////////////////////////////////////
133 | #endif // not APSTUDIO_INVOKED
134 |
135 |
--------------------------------------------------------------------------------
/src/catapult.xpm:
--------------------------------------------------------------------------------
1 | /* XPM */
2 | static const char* catapult_xpm[] = {
3 | "32 32 362 2",
4 | " c None",
5 | ". c #02027F",
6 | "+ c #00007B",
7 | "@ c #020276",
8 | "# c #02028B",
9 | "$ c #4D4DAE",
10 | "% c #9898CE",
11 | "& c #4A4AA6",
12 | "* c #5858AA",
13 | "= c #9393C6",
14 | "- c #363790",
15 | "; c #02028E",
16 | "> c #3232A8",
17 | ", c #FBFBFD",
18 | "' c #FFFFFF",
19 | ") c #FEFEFE",
20 | "! c #EEEEF5",
21 | "~ c #242582",
22 | "{ c #000099",
23 | "] c #8080CC",
24 | "^ c #E5E5E5",
25 | "/ c #F7F7F7",
26 | "( c #7D7DB5",
27 | "_ c #02028F",
28 | ": c #00009A",
29 | "< c #8888CF",
30 | "[ c #A0A0A0",
31 | "} c #808080",
32 | "| c #EEEEEE",
33 | "1 c #565655",
34 | "2 c #373737",
35 | "3 c #48485B",
36 | "4 c #100655",
37 | "5 c #BE435A",
38 | "6 c #BF445A",
39 | "7 c #7D3326",
40 | "8 c #4B2505",
41 | "9 c #000091",
42 | "0 c #000095",
43 | "a c #5656B8",
44 | "b c #7E7E7E",
45 | "c c #2F2D26",
46 | "d c #9F8729",
47 | "e c #BF4956",
48 | "f c #C0475D",
49 | "g c #BE445B",
50 | "h c #CB4861",
51 | "i c #AA3D4B",
52 | "j c #B7444F",
53 | "k c #A83F44",
54 | "l c #3C1D05",
55 | "m c #00008A",
56 | "n c #000077",
57 | "o c #2E146E",
58 | "p c #C04A60",
59 | "q c #BF465D",
60 | "r c #CB4860",
61 | "s c #CD4B62",
62 | "t c #C5645F",
63 | "u c #C87350",
64 | "v c #9F5962",
65 | "w c #24172C",
66 | "x c #743706",
67 | "y c #973C36",
68 | "z c #A33D44",
69 | "A c #000074",
70 | "B c #000064",
71 | "C c #541E2D",
72 | "D c #BA415A",
73 | "E c #C94760",
74 | "F c #C94761",
75 | "G c #C84761",
76 | "H c #A54E6B",
77 | "I c #C07273",
78 | "J c #D5C904",
79 | "K c #FAF5AE",
80 | "L c #D2CD8D",
81 | "M c #E9DB05",
82 | "N c #998B03",
83 | "O c #713606",
84 | "P c #512705",
85 | "Q c #000067",
86 | "R c #000092",
87 | "S c #000090",
88 | "T c #000086",
89 | "U c #00007A",
90 | "V c #883050",
91 | "W c #8D3266",
92 | "X c #06027D",
93 | "Y c #00007F",
94 | "Z c #767017",
95 | "` c #C0B608",
96 | " . c #DED109",
97 | ".. c #EFE105",
98 | "+. c #F0E20F",
99 | "@. c #EEE563",
100 | "#. c #A49903",
101 | "$. c #703604",
102 | "%. c #723606",
103 | "&. c #562A06",
104 | "*. c #381B03",
105 | "=. c #000068",
106 | "-. c #00008D",
107 | ";. c #000094",
108 | ">. c #00008F",
109 | ",. c #00007C",
110 | "'. c #000041",
111 | "). c #00007D",
112 | "!. c #000070",
113 | "~. c #BDB205",
114 | "{. c #5F5A01",
115 | "]. c #0D0C00",
116 | "^. c #272501",
117 | "/. c #4E4902",
118 | "(. c #847B02",
119 | "_. c #6F3404",
120 | ":. c #582B06",
121 | "<. c #29141F",
122 | "[. c #000088",
123 | "}. c #000081",
124 | "|. c #000078",
125 | "1. c #00006D",
126 | "2. c #000050",
127 | "3. c #000076",
128 | "4. c #6E6727",
129 | "5. c #E6D905",
130 | "6. c #615B02",
131 | "7. c #3A0701",
132 | "8. c #931202",
133 | "9. c #652F04",
134 | "0. c #753706",
135 | "a. c #673106",
136 | "b. c #3C1C0F",
137 | "c. c #00005F",
138 | "d. c #000075",
139 | "e. c #00006C",
140 | "f. c #00006E",
141 | "g. c #000079",
142 | "h. c #000072",
143 | "i. c #00006A",
144 | "j. c #00005A",
145 | "k. c #060675",
146 | "l. c #4C4C9B",
147 | "m. c #878698",
148 | "n. c #AEAB7D",
149 | "o. c #AB8913",
150 | "p. c #663005",
151 | "q. c #6E3406",
152 | "r. c #4E2706",
153 | "s. c #060346",
154 | "t. c #000066",
155 | "u. c #8A3050",
156 | "v. c #AF3E56",
157 | "w. c #000001",
158 | "x. c #000015",
159 | "y. c #00005E",
160 | "z. c #000063",
161 | "A. c #000051",
162 | "B. c #4E4E94",
163 | "C. c #DDDDEB",
164 | "D. c #68350B",
165 | "E. c #552A06",
166 | "F. c #655D69",
167 | "G. c #0B0B59",
168 | "H. c #00004C",
169 | "I. c #000028",
170 | "J. c #CD4961",
171 | "K. c #000000",
172 | "L. c #00000B",
173 | "M. c #000039",
174 | "N. c #02023C",
175 | "O. c #8181A5",
176 | "P. c #FEFEFF",
177 | "Q. c #70380A",
178 | "R. c #713505",
179 | "S. c #766353",
180 | "T. c #CCCCD8",
181 | "U. c #262665",
182 | "V. c #000048",
183 | "W. c #00003C",
184 | "X. c #00002D",
185 | "Y. c #59251B",
186 | "Z. c #C1445B",
187 | "`. c #A63E48",
188 | " + c #803A0F",
189 | ".+ c #813A0F",
190 | "++ c #783908",
191 | "@+ c #773807",
192 | "#+ c #763908",
193 | "$+ c #773A08",
194 | "%+ c #793B09",
195 | "&+ c #5F2D08",
196 | "*+ c #412824",
197 | "=+ c #515185",
198 | "-+ c #04045E",
199 | ";+ c #000055",
200 | ">+ c #000049",
201 | ",+ c #00003D",
202 | "'+ c #000031",
203 | ")+ c #000020",
204 | "!+ c #CC4961",
205 | "~+ c #C04754",
206 | "{+ c #783906",
207 | "]+ c #773906",
208 | "^+ c #703506",
209 | "/+ c #1F0E4A",
210 | "(+ c #0B0567",
211 | "_+ c #02016E",
212 | ":+ c #000060",
213 | "<+ c #000054",
214 | "[+ c #000030",
215 | "}+ c #000024",
216 | "|+ c #3F1F04",
217 | "1+ c #A93E4B",
218 | "2+ c #A73F47",
219 | "3+ c #4F2705",
220 | "4+ c #512805",
221 | "5+ c #522806",
222 | "6+ c #552906",
223 | "7+ c #572A06",
224 | "8+ c #331839",
225 | "9+ c #000083",
226 | "0+ c #00005D",
227 | "a+ c #000046",
228 | "b+ c #00003A",
229 | "c+ c #00002E",
230 | "d+ c #000023",
231 | "e+ c #DBDBE5",
232 | "f+ c #948980",
233 | "g+ c #100955",
234 | "h+ c #000069",
235 | "i+ c #000061",
236 | "j+ c #000057",
237 | "k+ c #00004D",
238 | "l+ c #000042",
239 | "m+ c #000037",
240 | "n+ c #00002B",
241 | "o+ c #00001F",
242 | "p+ c #FCFCFD",
243 | "q+ c #21216E",
244 | "r+ c #0F0750",
245 | "s+ c #502510",
246 | "t+ c #592A08",
247 | "u+ c #3C375A",
248 | "v+ c #000047",
249 | "w+ c #000032",
250 | "x+ c #000027",
251 | "y+ c #000019",
252 | "z+ c #BDBDCC",
253 | "A+ c #505082",
254 | "B+ c #000062",
255 | "C+ c #482214",
256 | "D+ c #5F300A",
257 | "E+ c #3D3C61",
258 | "F+ c #01013E",
259 | "G+ c #000036",
260 | "H+ c #00002C",
261 | "I+ c #080826",
262 | "J+ c #020221",
263 | "K+ c #C4C4D0",
264 | "L+ c #C7C7CE",
265 | "M+ c #060652",
266 | "N+ c #4B3B47",
267 | "O+ c #754822",
268 | "P+ c #D0D0D5",
269 | "Q+ c #9B9BA5",
270 | "R+ c #9898A1",
271 | "S+ c #DEDEDF",
272 | "T+ c #282845",
273 | "U+ c #DFDFE5",
274 | "V+ c #D8D8DB",
275 | "W+ c #B2B0B7",
276 | "X+ c #5A3211",
277 | "Y+ c #A39487",
278 | "Z+ c #4B4B60",
279 | "`+ c #00001B",
280 | " @ c #F6F6F7",
281 | ".@ c #A7998D",
282 | "+@ c #673309",
283 | "@@ c #D2CDC9",
284 | "#@ c #60606F",
285 | "$@ c #000016",
286 | "%@ c #F5F5F6",
287 | "&@ c #FAFAFA",
288 | "*@ c #6E5037",
289 | "=@ c #6C3C15",
290 | "-@ c #EEEDEC",
291 | ";@ c #5E5E6A",
292 | ">@ c #000011",
293 | ",@ c #CDCDD2",
294 | "'@ c #CBC6C2",
295 | ")@ c #572B08",
296 | "!@ c #7E644F",
297 | "~@ c #FCFCFC",
298 | "{@ c #3D3D48",
299 | "]@ c #00000D",
300 | "^@ c #94949E",
301 | "/@ c #988779",
302 | "(@ c #8B8886",
303 | "_@ c #06060E",
304 | ":@ c #000002",
305 | "<@ c #E3E3E5",
306 | "[@ c #4E4E4E",
307 | "}@ c #FDFDFD",
308 | "|@ c #FBFBFB",
309 | "1@ c #7F654F",
310 | "2@ c #572E0C",
311 | "3@ c #3F2611",
312 | "4@ c #39220F",
313 | "5@ c #41362E",
314 | "6@ c #000003",
315 | "7@ c #626157",
316 | "8@ c #C9C9CA",
317 | "9@ c #F5F5F5",
318 | "0@ c #EBEBEB",
319 | "a@ c #4C3B2C",
320 | "b@ c #38210F",
321 | "c@ c #312317",
322 | "d@ c #0E0D0D",
323 | "e@ c #7D7602",
324 | "f@ c #D0C304",
325 | "g@ c #ECDF05",
326 | "h@ c #DBCE05",
327 | "i@ c #989014",
328 | "j@ c #9A9882",
329 | "k@ c #E4E4E4",
330 | "l@ c #98968F",
331 | "m@ c #666357",
332 | "n@ c #20201B",
333 | "o@ c #888103",
334 | "p@ c #C5BA04",
335 | "q@ c #E4D705",
336 | "r@ c #ABA76F",
337 | "s@ c #DADADA",
338 | "t@ c #F4F4F4",
339 | "u@ c #E8E8E3",
340 | "v@ c #AFA950",
341 | "w@ c #C2B608",
342 | "x@ c #E4D706",
343 | "y@ c #EEE005",
344 | "z@ c #DCCF04",
345 | "A@ c #ACA303",
346 | "B@ c #4B4601",
347 | "C@ c #B5AB04",
348 | "D@ c #EDDF05",
349 | "E@ c #E9DC11",
350 | "F@ c #949275",
351 | "G@ c #BEBEBE",
352 | "H@ c #B9B35B",
353 | "I@ c #D6CA04",
354 | "J@ c #BFB404",
355 | "K@ c #807803",
356 | "L@ c #A39903",
357 | "M@ c #A99F03",
358 | "N@ c #918803",
359 | "O@ c #8B8202",
360 | "P@ c #A19703",
361 | "Q@ c #A59B03",
362 | "R@ c #A69C03",
363 | "S@ c #8A8203",
364 | "T@ c #898103",
365 | "U@ c #908803",
366 | " . + @ ",
367 | " # $ % & * = - ",
368 | " ; > , ' ) ' ' ! ~ ",
369 | " { ] ' ^ ^ ' ' / ( ",
370 | " _ : < ' [ } | 1 2 3 4 5 6 7 8 ",
371 | " 9 0 a ' b c d e f g h i j k l ",
372 | " m n o p q r s t u v w x y z ",
373 | " A n B C D E F G H I J K L M N O x P ",
374 | " Q R S T U V W X Y Z ` ...+.@.#.$.%.&.*. ",
375 | " =.-.;.>.T ,.'.=.).!.~.{.].^./.(._.%.:.<. ",
376 | " U T m [.}.|.1.2.3.n 4.5.6.7.8.9.0.a.b.c. ",
377 | " d.e.f.,.g.h.i.j.=.k.l.m.n.o.p.%.q.r.s.t. ",
378 | " u.v.w.x.y.i.z.A.B.C.' ' ) D.O q.E.F.G.H.I. ",
379 | " J. K.L.M.N.O.P.' ' ' Q.R.q.:.S.T.U.V.W.X. ",
380 | " Y.Z.`. +.+++@+0.#+$+$+%+%+%+x q.&+*+=+-+;+>+,+'+)+ ",
381 | " P !+~+{+{+{+]+]+]+]+]+]+]+]+^+/+(+_+3.e.:+<+V.W.[+}+ ",
382 | " |+1+2+3+4+5+6+7+:.:.:.:.:.:.8+T 9++ h.=.0+A.a+b+c+d+ ",
383 | " e+' ' ' ' ' f+g+U |.h.h+i+j+k+l+m+n+o+ ",
384 | " p+' ' ' ' ' ' q+f.r+s+t+u+2.v+W.w+x+y+ ",
385 | " z+' ' ' ' ' ' ' A+B+C+q.q.D+E+F+G+H+I+J+ ",
386 | " K+' ' ' ' ' ' ' L+M+N+q.q.q.O+P+Q+R+S+T+)+ ",
387 | " U+' ' ' ' ' ' ' ' V+W+X+q.%.q.Y+' ' ' Z+`+ ",
388 | " @' ' ' ' ' ' ' ' ' ' .@:.q.x +@@@' ' #@$@ ",
389 | " %@' ' ' ' ' ' ' ' ' ' &@*@q.q.q.=@-@' ;@>@ ",
390 | " ,@' ' ' ' ' ' ' ' ' ' ' '@)@q.x q.!@~@{@]@ ",
391 | " ^@' ' ' ' ' ' ' ' ' ' ' ) /@:.q.]+^+(@_@:@K.K. ",
392 | " <@' ' ' ' [@}@' ' ' ' ' |@1@2@3@4@5@6@K.K.K. ",
393 | " 7@8@9@' ' ' ' ' ' ' ' ' ' 0@a@b@c@d@K.K.K. ",
394 | " e@f@g@h@i@j@~@' ' ' ' ' ' ' ' k@l@m@n@K.K.K. ",
395 | " o@p@h@......q@r@s@t@' ' ' ' u@v@w@x@y@z@A@B@ ",
396 | " C@D@........E@F@G@| ~@' s@H@......q@I@J@D@ ",
397 | " K@L@M@N@ O@P@Q@R@S@T@U@ "};
398 |
--------------------------------------------------------------------------------
/src/openMSXController.h:
--------------------------------------------------------------------------------
1 | #ifndef OPENMSXCONTROLLER_H
2 | #define OPENMSXCONTROLLER_H
3 |
4 | #ifdef __WXMSW__
5 | #ifdef _MSC_VER // we don't want gcc to warn about pragma's
6 | #pragma warning( disable : 4786) // we don't want 39 warnings about browse info names getting too long
7 | #endif
8 | #endif
9 |
10 | #include "CatapultXMLParser.h"
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #ifdef __WXMSW__
17 | // See: http://wiki.wxwidgets.org/WxMSW_Issues#The_windows.h_Header_File.2C_Macros_and_Compiling_Errors
18 | #include
19 | #include
20 | #else
21 | #include
22 | #endif
23 |
24 | class wxCatapultFrame;
25 | class wxCommandEvent;
26 | class CatapultXMLParser;
27 | class PipeConnectThread;
28 | class PipeReadThread;
29 |
30 | class openMSXController
31 | {
32 | public:
33 | openMSXController(wxWindow* target);
34 | ~openMSXController();
35 |
36 | void RaiseOpenMSX();
37 | void RestoreOpenMSX();
38 |
39 | void UpdateMixer();
40 | bool IsRelaunching() const { return m_isRelaunching; }
41 | wxString GetConnectorClass(const wxString& name) const;
42 | wxString GetConnectorPlugged(const wxString& name) const;
43 | const wxArrayString& GetConnectors() const { return m_connectors; }
44 | const wxArrayString& GetPluggables() const { return m_pluggables; }
45 | const wxArrayString& GetPluggableDescriptions() const { return m_pluggabledescriptions; }
46 | const wxArrayString& GetPluggableClasses() const { return m_pluggableclasses; }
47 | bool CheckVersion(const wxString& cmd);
48 | void StartOpenMSX(const wxString& cmd);
49 | void WriteCommand(
50 | const wxString& command,
51 | std::function okCallback = nullptr,
52 | std::function errorCallback = nullptr);
53 | void HandleEndProcess(wxCommandEvent& event);
54 | bool HandleMessage(wxCommandEvent& event);
55 |
56 | bool IsOpenMSXRunning() const { return m_openMsxRunning; }
57 |
58 | private:
59 | struct LaunchInstruction {
60 | wxString command;
61 | std::function callback;
62 | };
63 |
64 | void WriteMessage(const xmlChar* msg, size_t length);
65 | void commandError(const wxString& cmd, const wxString& result);
66 | bool Launch(wxString cmdline);
67 |
68 | void PostLaunch();
69 | void InitLaunchScript();
70 | void AddCommand(
71 | const wxString& cmd,
72 | std::function callback = nullptr);
73 |
74 | void HandleParsedOutput(wxCommandEvent& event);
75 | void HandleStdErr(wxCommandEvent& event);
76 | void HandleStdOut(wxCommandEvent& event);
77 | void ExecuteStart(int startLine = 0);
78 | void HandleLaunch(const wxString& command, const wxString& result, bool ok);
79 | void ExecuteNext();
80 | void UpdateSetting2 (const wxString& name, const wxString& result);
81 | void UpdateSetting (const wxString& cmd, const wxString& result);
82 | void EnableFirmware (const wxString& cmd, const wxString& result);
83 | void FillComboBox (const wxString& control, const wxString& result);
84 | void FillRangeComboBox(const wxString& control, const wxString& result);
85 | void HandlePluggables (const wxString& result);
86 | void HandleConnectors (const wxString& result);
87 | void HandleSoundDevices(const wxString& result);
88 |
89 | void AddSetting(
90 | const wxString& settings,
91 | std::function callback);
92 | void UpdateToggle (const wxString& v, const wxString& c, int f = 0);
93 | void UpdateCombo (const wxString& v, const wxString& c, int f = 0);
94 | void UpdateIndicator(const wxString& v, const wxString& c, int f = 0);
95 | void UpdateSlider (const wxString& v, const wxString& c);
96 | void UpdatePluggable(const wxString& v, const wxString& c);
97 |
98 | struct SettingElement {
99 | wxString setting;
100 | std::function callback;
101 | };
102 | std::vector m_settingTable;
103 |
104 | std::vector m_launchScript;
105 | std::deque> m_launchCallback;
106 | int sendStep;
107 | int m_relaunch;
108 |
109 | unsigned m_openMSXID;
110 | wxArrayString m_connectors;
111 | wxArrayString m_connectorclasses;
112 | wxArrayString m_connectorpluggeds;
113 | wxArrayString m_pluggables;
114 | wxArrayString m_pluggabledescriptions;
115 | wxArrayString m_pluggableclasses;
116 |
117 | struct CommandEntry {
118 | wxString command;
119 | std::function okCallback;
120 | std::function errorCallback;
121 | };
122 | std::deque m_commands;
123 |
124 | wxCatapultFrame* m_appWindow;
125 | bool m_openMsxRunning;
126 | std::unique_ptr m_parser;
127 | bool m_isRelaunching;
128 |
129 | // windows or linux specific stuff
130 | #ifdef __WXMSW__
131 | struct FindOpenmsxInfo {
132 | LPPROCESS_INFORMATION ProcessInfo;
133 | HWND hWndFound;
134 | };
135 |
136 | void HandlePipeCreated();
137 |
138 | HWND FindOpenMSXWindow();
139 | static BOOL CALLBACK EnumWindowCallBack(HWND hwnd, LPARAM lParam);
140 | void CloseHandles(
141 | HANDLE hThread, HANDLE hInputRead,
142 | HANDLE hOutputWrite, HANDLE hErrorWrite);
143 | void ShowError(const wxString& msg);
144 | bool CreatePipes(
145 | HANDLE* input, HANDLE* output, HANDLE* error,
146 | HANDLE* outputWrite, HANDLE* errorWrite);
147 | wxString CreateControlParameter();
148 |
149 | HANDLE m_outputHandle;
150 | HANDLE m_namedPipeHandle;
151 | HWND m_catapultWindow;
152 | PROCESS_INFORMATION m_openmsxProcInfo;
153 | unsigned long m_launchCounter;
154 | wxString m_pipeName;
155 | #else
156 | bool execute(const std::string& command, int& fdIn, int& fdOut, int& fdErr);
157 |
158 | int m_openMSXstdin;
159 | int m_openMSXstdout;
160 | int m_openMSXstderr;
161 | std::unique_ptr m_stdErrThread;
162 | std::unique_ptr m_stdOutThread;
163 | #endif
164 | };
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/src/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by catapult.rc
4 | //
5 |
6 | // Next default values for new objects
7 | //
8 | #ifdef APSTUDIO_INVOKED
9 | #ifndef APSTUDIO_READONLY_SYMBOLS
10 | #define _APS_NEXT_RESOURCE_VALUE 103
11 | #define _APS_NEXT_COMMAND_VALUE 40001
12 | #define _APS_NEXT_CONTROL_VALUE 1000
13 | #define _APS_NEXT_SYMED_VALUE 101
14 | #endif
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | using namespace std;
8 |
9 | namespace utils {
10 |
11 | wxString ConvertPathForCommand(wxString path)
12 | {
13 | path.Prepend(wxT("{"));
14 | path.Append(wxT("}"));
15 | path.Replace(wxT("\\"), wxT("/"));
16 | return path;
17 | }
18 |
19 | wxString ConvertPathNoSlash(wxString path)
20 | {
21 | path.Prepend(wxT("\""));
22 | path.Append(wxT("\""));
23 | return path;
24 | }
25 |
26 | wxString ConvertPathBack(wxString path)
27 | {
28 | path.Replace(wxT("\""), wxT(""));
29 | path.Replace(wxT("/"), wxT("\\"));
30 | return path;
31 | }
32 |
33 |
34 | static vector parseTclList(const string& str)
35 | {
36 | vector result;
37 | for (auto it = str.begin(); it != str.end(); /**/) {
38 | auto ch1 = *it++;
39 | if (ch1 == ' ') continue; // skip space between items
40 |
41 | string item;
42 | switch (ch1) {
43 | case '"':
44 | while (true) {
45 | if (it == str.end()) {
46 | throw runtime_error("unterminated open-quote");
47 | }
48 | char ch = *it++;
49 | if (ch == '"') {
50 | break;
51 | } else if (ch == '\\') {
52 | if (it == str.end()) {
53 | throw runtime_error("backslash at end of string");
54 | }
55 | ch = *it++;
56 | }
57 | item += ch;
58 | }
59 | if ((it != str.end()) && (*it != ' ')) {
60 | throw runtime_error("extra characters after close-quote");
61 | }
62 | break;
63 | case '{': {
64 | int braceLevel = 1;
65 | while (true) {
66 | if (it == str.end()) {
67 | throw runtime_error("unterminated open-brace");
68 | }
69 | char ch = *it++;
70 | if (ch == '}') {
71 | if (--braceLevel == 0) break;
72 | } else if (ch == '{') {
73 | ++braceLevel;
74 | } else if (ch == '\\') {
75 | item += ch; // keep backslash
76 | if (it == str.end()) {
77 | throw runtime_error("backslash at end of string");
78 | }
79 | ch = *it++;
80 | }
81 | item += ch;
82 | }
83 | if ((it != str.end()) && (*it != ' ')) {
84 | throw runtime_error("extra characters after close-brace");
85 | }
86 | break;
87 | }
88 | default:
89 | --it; // also add first char (this might be \)
90 | while (it != str.end()) {
91 | char ch = *it++;
92 | if (ch == ' ') {
93 | break;
94 | } else if (ch == '\\') {
95 | if (it == str.end()) {
96 | throw runtime_error("backslash at end of string");
97 | }
98 | ch = *it++;
99 | }
100 | item += ch;
101 | }
102 | break;
103 | }
104 | result.push_back(item);
105 | }
106 | return result;
107 | }
108 |
109 | wxArrayString parseTclList(const wxString& str)
110 | {
111 | // TODO the input was likely already converted from utf8->wxString
112 | // and here we convert it back to utf8
113 | wxArrayString result;
114 | try {
115 | string str2 = static_cast(str.mb_str(wxConvUTF8));
116 | for (auto& item : parseTclList(str2)) {
117 | result.Add(wxString(item.data(), wxConvUTF8, item.size()));
118 | }
119 | } catch (std::exception&) {
120 | assert(false);
121 | }
122 | return result;
123 | }
124 |
125 | wxString tclEscapeWord(wxString str)
126 | {
127 | str.Replace(wxT("\\"), wxT("\\\\"));
128 | str.Replace(wxT("\n"), wxT("\\r"));
129 | str.Replace(wxT("$"), wxT("\\$"));
130 | str.Replace(wxT("\""), wxT("\\\""));
131 | str.Replace(wxT("["), wxT("\\["));
132 | str.Replace(wxT("]"), wxT("\\]"));
133 | str.Replace(wxT("}"), wxT("\\}"));
134 | str.Replace(wxT("{"), wxT("\\{"));
135 | str.Replace(wxT(" "), wxT("\\ "));
136 | str.Replace(wxT(";"), wxT("\\;"));
137 | return str;
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #ifdef __WXMSW__
9 |
10 | #define VLA(TYPE, NAME, LENGTH) \
11 | auto NAME = static_cast(_alloca(sizeof(TYPE) * (LENGTH)))
12 |
13 | #else
14 |
15 | #define VLA(TYPE, NAME, LENGTH) \
16 | TYPE NAME[(LENGTH)]
17 |
18 | #endif
19 |
20 | namespace utils {
21 |
22 | wxString ConvertPathForCommand(wxString path);
23 | wxString ConvertPathNoSlash (wxString path);
24 | wxString ConvertPathBack (wxString path);
25 |
26 | wxArrayString parseTclList(const wxString& str);
27 | wxString tclEscapeWord(wxString str);
28 |
29 | }
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/wxCatapultApp.cpp:
--------------------------------------------------------------------------------
1 | #define SETUP_EXTERNALS
2 | #include "wxCatapultApp.h"
3 | #undef SETUP_EXTERNALS
4 | #include "wxCatapultFrm.h"
5 | #include "ConfigurationData.h"
6 | #include "CatapultConfigDlg.h"
7 | #include "Version.h"
8 | #include "config.h"
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | // Create a new application object: this macro will allow wxWindows to create
16 | // the application object during program execution (it's better than using a
17 | // static object for many reasons) and also declares the accessor function
18 | // wxGetApp() which will return the reference of the right type (i.e. wxCatapultApp and
19 | // not wxApp)
20 | IMPLEMENT_APP(wxCatapultApp)
21 |
22 | wxCatapultApp::~wxCatapultApp()
23 | {
24 | // clean up the handlers
25 | wxXmlResource::Get()->ClearHandlers();
26 | }
27 |
28 | // 'Main program' equivalent: the program execution "starts" here
29 | // this one is called on application startup and is a good place for the app
30 | // initialization (doing it here and not in the ctor allows to have an error
31 | // return: if OnInit() returns false, the application terminates)
32 | bool wxCatapultApp::OnInit()
33 | {
34 | if (!wxApp::OnInit()) return false;
35 | wxImage::AddHandler(new wxPNGHandler());
36 | wxXmlResource::Get()->InitAllHandlers();
37 |
38 | EVT_CONTROLLER = wxNewEventType();
39 | EVT_TESTCONFIG = wxNewEventType();
40 | bool succes = true;
41 | succes &= LoadXRC(wxT("about.xrc"));
42 | succes &= LoadXRC(wxT("config.xrc"));
43 | succes &= LoadXRC(wxT("fullscreen.xrc"));
44 | succes &= LoadXRC(wxT("screenshot.xrc"));
45 | succes &= LoadXRC(wxT("catapult.xrc"));
46 | succes &= LoadXRC(wxT("session.xrc"));
47 | succes &= LoadXRC(wxT("status.xrc"));
48 | succes &= LoadXRC(wxT("misccontrols.xrc"));
49 | succes &= LoadXRC(wxT("videocontrols.xrc"));
50 | succes &= LoadXRC(wxT("audiocontrols.xrc"));
51 | succes &= LoadXRC(wxT("input.xrc"));
52 | succes &= LoadXRC(wxT("romtype.xrc"));
53 | succes &= LoadXRC(wxT("ipsselect.xrc"));
54 | succes &= LoadXRC(wxT("checkconfigs.xrc"));
55 |
56 | if (succes) {
57 | // We'll set the application and vendorname before the first call to 'Get'
58 | SetVendorName(wxT("openMSX team"));
59 | SetAppName(wxT("Catapult"));
60 |
61 | try {
62 | // create our custom frame with the all the event handlers
63 | wxCatapultFrame *frame = new wxCatapultFrame();
64 |
65 | // Show the frame.
66 | frame->Show(true);
67 | } catch (...) {
68 | return false;
69 | }
70 | } else {
71 | wxMessageBox(wxT("Unable to load resources!\nThere is something wrong with your installation.\n"),
72 | wxT("error"));
73 | return false;
74 | }
75 | return true;
76 | }
77 |
78 | static wxString ver (wxT("V"));
79 | static wxString ver_lng(wxT("version"));
80 | static wxString ver_dsc(wxT("show version information"));
81 |
82 | void wxCatapultApp::OnInitCmdLine(wxCmdLineParser& parser)
83 | {
84 | wxApp::OnInitCmdLine(parser);
85 | parser.AddSwitch(ver, ver_lng, ver_dsc);
86 | }
87 |
88 | bool wxCatapultApp::OnCmdLineHelp(wxCmdLineParser& parser)
89 | {
90 | parser.Usage();
91 | puts("\nopenMSX Catapult is the GUI for openMSX ");
92 | puts("openMSX is the MSX emulator that aims for perfection");
93 | return false;
94 | }
95 |
96 | bool wxCatapultApp::OnCmdLineParsed(wxCmdLineParser& parser)
97 | {
98 | bool res = true;
99 | if (parser.Found(ver_lng)) {
100 | if (res) ShowVersion();
101 | res = false;
102 | }
103 | return wxApp::OnCmdLineParsed(parser) && res;
104 | }
105 |
106 | void wxCatapultApp::ShowVersion()
107 | {
108 | std::cout << Version::FULL_VERSION << std::endl;
109 | }
110 |
111 | bool wxCatapultApp::LoadXRC(wxString XrcFile)
112 | {
113 | wxString resourceDir = GetResourceDir();
114 | if (::wxFileExists(resourceDir + wxT("/dialogs/") + XrcFile)) {
115 | wxXmlResource::Get()->Load(resourceDir + wxT("/dialogs/") + XrcFile);
116 | return true;
117 | } else {
118 | return false;
119 | }
120 | }
121 |
122 | wxString wxCatapultApp::GetResourceDir()
123 | {
124 | #ifdef __WXMSW__
125 | wxString temp = ::wxPathOnly(argv[0]);
126 | temp.Replace(wxT("/"), wxT("\\"));
127 | while (temp.Last() == '\\') {
128 | temp = temp.Left(temp.Len() - 1);
129 | }
130 | int pos = temp.Find('\\', true);
131 | if (pos != wxNOT_FOUND) {
132 | temp = temp.Left(pos + 1) + wxT("resources");
133 | }
134 | return temp;
135 | #else
136 | return RESOURCEDIR;
137 | #endif
138 | }
139 |
--------------------------------------------------------------------------------
/src/wxCatapultApp.h:
--------------------------------------------------------------------------------
1 | #ifndef WXCATAPULTAPP_H
2 | #define WXCATAPULTAPP_H
3 |
4 | #define wxUSE_CMDLINE_PARSER 1
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #ifdef SETUP_EXTERNALS
11 | #define SCOPE
12 | #else
13 | #define SCOPE extern
14 | #endif
15 |
16 | // Globals
17 |
18 | SCOPE int EVT_CONTROLLER;
19 | SCOPE int EVT_TESTCONFIG;
20 |
21 | #define MSGID_STDIN 0
22 | #define MSGID_STDOUT 1
23 | #define MSGID_STDERR 2
24 | #define MSGID_PARSED 3
25 | #define MSGID_PIPECREATED 4
26 | #define MSGID_ENDPROCESS 5
27 | #define HISTORY_SIZE 25
28 |
29 | // Define a new application type, each program should derive a class from wxApp
30 | class wxCatapultApp : public wxApp
31 | {
32 | public:
33 | virtual ~wxCatapultApp();
34 |
35 | wxString GetResourceDir();
36 |
37 | private:
38 | virtual bool OnInit();
39 | virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
40 | virtual void OnInitCmdLine(wxCmdLineParser& parser);
41 | virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
42 | void ShowVersion();
43 | bool LoadXRC(wxString XrcFile);
44 | };
45 |
46 | DECLARE_APP(wxCatapultApp)
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/wxCatapultFrm.h:
--------------------------------------------------------------------------------
1 | #ifndef WXCATAPULTFRAME_H
2 | #define WXCATAPULTFRAME_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include // forward declaration doesn't work on wx 3.0 for some reason
9 | #include
10 |
11 | class CatapultXMLParser;
12 | class SessionPage;
13 | class StatusPage;
14 | class InputPage;
15 | class VideoControlPage;
16 | class AudioControlPage;
17 | class MiscControlPage;
18 | class openMSXController;
19 | class wxButton;
20 | class wxNotebookEvent;
21 | class wxStaticBitmap;
22 |
23 | // Define a new frame type: this is going to be our main frame
24 | class wxCatapultFrame : public wxFrame
25 | {
26 | public:
27 | wxCatapultFrame(wxWindow* parent = nullptr);
28 |
29 | void OpenMSXStarted();
30 | void OpenMSXStopped();
31 | void EnableMainWindow();
32 | void UpdateLed(const wxString& ledname, const wxString& ledstate);
33 | void UpdateState(const wxString& statename, const wxString& state);
34 | void CheckConfigs();
35 |
36 | SessionPage* m_sessionPage;
37 | StatusPage* m_statusPage;
38 | VideoControlPage* m_videoControlPage;
39 | MiscControlPage* m_miscControlPage;
40 | AudioControlPage* m_audioControlPage;
41 | InputPage* m_inputPage;
42 |
43 | wxNotebook* m_tabControl;
44 |
45 | private:
46 | void StartTimers();
47 | void StopTimers();
48 | void SetControlsOnLaunch();
49 | void SetControlsOnEnd();
50 | void EnableSaveSettings(bool enabled);
51 |
52 | // event handlers (these functions should _not_ be virtual)
53 | void OnControllerEvent(wxCommandEvent& event);
54 | void OnMenuQuit(wxCommandEvent& event);
55 | void OnMenuCheckConfigs(wxCommandEvent& event);
56 | void OnMenuAbout(wxCommandEvent& event);
57 | void OnMenuEditConfig(wxCommandEvent& event);
58 | void OnMenuLoadSettings(wxCommandEvent& event);
59 | void OnMenuSaveSettings(wxCommandEvent& event);
60 | void OnMenuSaveSettingsAs(wxCommandEvent& event);
61 | void OnMenuSaveOnExit(wxCommandEvent& event);
62 | void OnMenuDisplayBroken (wxCommandEvent& event);
63 | void OnMenuClose (wxMenuEvent& event);
64 | void OnMenuOpen (wxMenuEvent& event);
65 | void OnMenuHighlight(wxMenuEvent& event);
66 | void OnLaunch(wxCommandEvent& event);
67 | void OnUpdateFPS(wxTimerEvent& event);
68 | void OnEnableMainWindow(wxTimerEvent& event);
69 | void OnCheckFocus(wxTimerEvent& event);
70 | void OnChangePage(wxNotebookEvent& event);
71 | void OnDeselectCatapult(wxActivateEvent& event);
72 | bool EditConfig(bool fatalIfFailed = false);
73 |
74 | std::unique_ptr m_controller;
75 |
76 | wxButton* m_launch_AbortButton;
77 |
78 | wxStaticBitmap* m_powerLed;
79 | wxStaticBitmap* m_capsLed;
80 | wxStaticBitmap* m_kanaLed;
81 | wxStaticBitmap* m_pauseLed;
82 | wxStaticBitmap* m_turboLed;
83 | wxStaticBitmap* m_fddLed;
84 | wxMenu* settingsMenu;
85 | wxMenu* viewMenu;
86 |
87 | wxTimer m_fpsTimer;
88 | wxTimer m_focusTimer;
89 | wxTimer m_safetyTimer;
90 | wxWindow* m_currentFocus;
91 | wxString m_tempStatus;
92 | wxString m_settingsfile;
93 |
94 | DECLARE_CLASS(wxCatapultFrame)
95 | DECLARE_EVENT_TABLE()
96 | };
97 |
98 | #endif
99 |
--------------------------------------------------------------------------------