]> Shamusworld >> Repos - wozmaker/commitdiff
Add "settings" dialog, fixes to work with MXE cross-compilation.
authorShamus Hammons <jlhamm@acm.org>
Sun, 6 Jan 2019 03:23:00 +0000 (21:23 -0600)
committerShamus Hammons <jlhamm@acm.org>
Sun, 6 Jan 2019 03:23:00 +0000 (21:23 -0600)
.gitignore
src/fileio.cpp
src/fileio.h
src/global.cpp
src/global.h
src/mainwin.cpp
src/mainwin.h
src/settingsdialog.cpp [new file with mode: 0644]
src/settingsdialog.h [new file with mode: 0644]
wozmaker.pro

index ad3055e6d161328c7add04456a6f87285be45244..e37d149af17f5a614b900aeef24f19c5200d87cf 100644 (file)
@@ -4,6 +4,8 @@ mandelbrot/
 gmon.out
 analysis1.ods
 wozmaker
-Makefile
+Makefile*
 res/*.xcf
 .qmake.stash
+release/
+win64/
index 3261c2c95d58c38902d49529fae1ee7e3e2e53e1..d8ff4653da539e4456628739dd74596d857c43e0 100644 (file)
@@ -171,11 +171,13 @@ Really, this crap should go into fileio.cpp.  !!! FIX !!!
 
        if (Global::a2rSize > (60 + Uint32LE(Global::a2r->strmSize)))
        {
-               Global::metadata = (A2RMetadata *)((uint8_t *)Global::a2r + (60 + Uint32LE(Global::a2r->strmSize)));
+               Global::metadata = (Metadata *)((uint8_t *)Global::a2r + (60 + Uint32LE(Global::a2r->strmSize)));
 
                // Make sure it's plausible metadata
                if (memcmp(Global::metadata->metaTag, "META", 4) != 0)
                        Global::metadata = NULL;
+               else
+                       UnpackMetadata(Global::metadata);
        }
 
        // Unpack TMNG & XTMG streams to simplify analysis
@@ -289,3 +291,130 @@ bool WriteWOZFile(const char * filename)
        return true;
 }
 
+
+void UnpackMetadata(Metadata * data)
+{
+       uint32_t start = 0;
+       uint32_t end = Uint32LE(data->metaSize);
+       uint32_t i = 0;
+       Global::metaCount = 0;
+
+       while (start < end)
+       {
+               if (i < 255)
+                       Global::meta[Global::metaCount][i++] = data->data[start];
+
+               start++;
+
+               if (data->data[start] == '\x0A')
+               {
+                       Global::meta[Global::metaCount][i] = 0;
+                       Global::metaCount++;
+                       i = 0;
+                       start++;
+               }
+       }
+}
+
+
+uint8_t * GetMetadata(const char * keyword)
+{
+       uint32_t kwLen = strlen(keyword);
+
+       for(uint8_t i=0; i<Global::metaCount; i++)
+       {
+               if ((strlen((char *)Global::meta[i]) >= kwLen)
+                       && (memcmp(Global::meta[i], keyword, kwLen) == 0))
+               {
+                       return &Global::meta[i][kwLen];
+               }
+       }
+
+       return NULL;
+}
+
+
+uint16_t GetRequiredMachineBits(void)
+{
+       uint8_t * kw = GetMetadata("requires_machine\x09");
+       uint32_t kwLen = strlen((char *)kw);
+       uint16_t bits = 0;
+       char type[8];
+       uint8_t typeLen = 0;
+
+       for(uint32_t i=0; i<kwLen; i++)
+       {
+               type[typeLen++] = kw[i];
+
+               if ((kw[i + 1] == '|') || (kw[i + 1] == '\0'))
+               {
+                       type[typeLen] = 0;
+
+                       if (strcmp(type, "2") == 0)
+                               bits |= 0x001;
+                       else if (strcmp(type, "2+") == 0)
+                               bits |= 0x002;
+                       else if (strcmp(type, "2e") == 0)
+                               bits |= 0x004;
+                       else if (strcmp(type, "2c") == 0)
+                               bits |= 0x008;
+                       else if (strcmp(type, "2e+") == 0)
+                               bits |= 0x010;
+                       else if (strcmp(type, "2gs") == 0)
+                               bits |= 0x020;
+                       else if (strcmp(type, "2c+") == 0)
+                               bits |= 0x040;
+                       else if (strcmp(type, "3") == 0)
+                               bits |= 0x080;
+                       else if (strcmp(type, "3+") == 0)
+                               bits |= 0x100;
+
+                       typeLen = 0;
+                       i++;
+               }
+       }
+
+       return bits;
+}
+
+
+uint16_t GetRequiredRAMInK(void)
+{
+       char * kw = (char *)GetMetadata("requires_ram\x09");
+
+       if (strcmp(kw, "16K") == 0)
+               return 16;
+       else if (strcmp(kw, "24K") == 0)
+               return 24;
+       else if (strcmp(kw, "32K") == 0)
+               return 32;
+       else if (strcmp(kw, "48K") == 0)
+               return 48;
+       else if (strcmp(kw, "64K") == 0)
+               return 64;
+       else if (strcmp(kw, "128K") == 0)
+               return 128;
+       else if (strcmp(kw, "256K") == 0)
+               return 256;
+       else if (strcmp(kw, "512K") == 0)
+               return 512;
+       else if (strcmp(kw, "768K") == 0)
+               return 768;
+       else if (strcmp(kw, "1M") == 0)
+               return 1024;
+       else if (strcmp(kw, "1.25M") == 0)
+               return 1280;
+       else if (strcmp(kw, "1.5M+") == 0)
+               return 1536;
+
+       return 0;
+}
+/*
+METADATA Keywords (standard)
+----------------------------
+title, subtitle, publisher, developer, copyright, version, language, requires_ram, requires_machine, notes, side, side_name, contributor, image_date
+
+ram: 16K|24K|32K|48K|64K|128K|256K|512K|768K|1M|1.25M|1.5M+|Unknown
+mch: 2|2+|2e|2c|2e+|2gs|2c+|3|3+
+*/
+
index 3b42dbf02cf7cf3b5b0d8a74675834983ae4a156..62bdd046153d42a6af1e620cc1b5993d9b08b378 100644 (file)
@@ -8,6 +8,13 @@
 //       may not be compiled on an architecture that supports little endian
 //       natively.
 
+struct Metadata
+{
+       uint8_t metaTag[4];             // "META"
+       uint32_t metaSize;              // Size of the META chunk
+       uint8_t data[];                 // Variable length array of metadata
+};
+
 struct A2RStream
 {
        uint8_t location;               // Quarter track for this stream
@@ -17,13 +24,6 @@ struct A2RStream
        uint8_t data[];                 // Variable length array for stream data
 };
 
-struct A2RMetadata
-{
-       uint8_t metaTag[4];             // "META"
-       uint32_t metaSize;              // Size of the META chunk
-       uint8_t data[];                 // Variable length array of metadata
-};
-
 struct A2R
 {
        // Header
@@ -56,13 +56,6 @@ struct WOZTrack
        uint16_t reserved;
 };
 
-struct WOZMetadata
-{
-       uint8_t metaTag[4];             // "META"
-       uint32_t metaSize;              // Size of the META chunk
-       uint8_t data[];                 // Variable length array of metadata
-};
-
 struct WOZ
 {
        // Header
@@ -141,6 +134,10 @@ uint32_t CRC32(const uint8_t * data, uint32_t length);
 uint8_t * ReadFile(const char * filename, uint32_t * size);
 bool LoadA2R(const char * filename);
 bool WriteWOZFile(const char * filename);
+void UnpackMetadata(Metadata * data);
+uint8_t * GetMetadata(const char * keyword);
+uint16_t GetRequiredMachineBits(void);
+uint16_t GetRequiredRAMInK(void);
 
 
 // Inline functions ("get" functions--need to write "set" functions)
index 44b18fa0cccd74d9e6f4874d9427fbbf394650cc..40d7904cfad4a685e1b5f9c92451bb7146391448 100644 (file)
@@ -17,7 +17,7 @@
 
 A2R * Global::a2r = NULL;
 uint32_t Global::a2rSize = 0;
-A2RMetadata * Global::metadata;
+Metadata * Global::metadata;
 A2RStream * Global::stream[800];
 uint32_t Global::numStreams = 0;
 uint8_t Global::bitStream[80000];
@@ -47,3 +47,6 @@ uint8_t Global::bStream[141][80000] = { 0 };
 uint32_t Global::bStreamLen[141] = { 0 };
 uint32_t Global::bStreamLenBits[141] = { 0 };
 
+uint8_t Global::meta[32][256] = { 0 };
+uint8_t Global::metaCount = 0;
+
index 09215950380eb57721960ee23d0d5854c0290f66..15b038a93f4478a3546142f18ae8251c1c5e400c 100644 (file)
@@ -4,8 +4,8 @@
 #include <stdint.h>
 
 class A2R;
-class A2RMetadata;
 class A2RStream;
+class Metadata;
 
 class Global
 {
@@ -13,7 +13,7 @@ class Global
        public:
                static A2R * a2r;
                static uint32_t a2rSize;
-               static A2RMetadata * metadata;
+               static Metadata * metadata;
                static A2RStream * stream[800];
                static uint32_t numStreams;
                static uint8_t bitStream[80000];
@@ -38,6 +38,8 @@ class Global
                static uint8_t bStream[141][80000];
                static uint32_t bStreamLen[141];
                static uint32_t bStreamLenBits[141];
+               static uint8_t meta[32][256];
+               static uint8_t metaCount;
 };
 
 #endif // __GLOBAL_H__
index e98031dbc0919565b30781f4c70c688ff9b9f25b..4ca0ae1716a2d12e8e8f30638ec3cc42fe6b9633 100644 (file)
@@ -17,6 +17,7 @@
 #include "mainwidget.h"
 #include "navwidget.h"
 #include "nibblewidget.h"
+#include "settingsdialog.h"
 #include "waveformwidget.h"
 
 
@@ -31,8 +32,11 @@ MainWin::MainWin()
        loadFile = CreateAction(tr("&Open"), tr("Open A2R"), tr("Open an A2R file"), QIcon(), QKeySequence(tr("ctrl+o")));
        connect(loadFile, SIGNAL(triggered()), this, SLOT(HandleLoadFile()));
 
-       newGame = CreateAction(tr("&New"), tr("New Game"), tr("Start a new game of Warehouse Man Deluxe"), QIcon(), QKeySequence(tr("ctrl+n")));
-//     connect(newGame, SIGNAL(triggered()), this, SLOT(HandleNewGame()));
+       saveFile = CreateAction(tr("&Save"), tr("Save WOZ"), tr("Save a WOZ file"), QIcon(), QKeySequence(tr("ctrl+s")));
+       connect(saveFile, SIGNAL(triggered()), this, SLOT(HandleSaveFile()));
+
+       settings = CreateAction(tr("&Disk Settings"), tr("Disk Settings"), tr("Settings for the loaded A2R file"), QIcon(), QKeySequence(tr("ctrl+d")));
+       connect(settings, SIGNAL(triggered()), this, SLOT(HandleSettings()));
 
        undoAction = CreateAction(tr("&Undo"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+z")));
 //     connect(undoAction, SIGNAL(triggered()), this, SLOT(HandleUndo()));
@@ -66,6 +70,8 @@ MainWin::MainWin()
 
        QMenu * menu = menuBar()->addMenu(tr("&File"));
        menu->addAction(loadFile);
+       menu->addAction(saveFile);
+       menu->addAction(settings);
        menu->addSeparator();
 //     menu->addAction(undoAction);
 //     menu->addAction(resetLevel);
@@ -197,6 +203,22 @@ void MainWin::HandleLoadFile(void)
 }
 
 
+void MainWin::HandleSaveFile(void)
+{
+}
+
+
+void MainWin::HandleSettings(void)
+{
+       SettingsDialog dlg(this);
+
+       if (dlg.exec() == false)
+               return;
+
+       // Deal with stuff here, since user hit "OK" button
+}
+
+
 void MainWin::AboutWozMaker(void)
 {
        QMessageBox::about(this, tr("About WOZ Maker"), tr("WOZ Maker v1.0.0\n\nWritten by James Hammons\n\nCopyright (C) 2018 Underground Software"));
index b3edaaac8239b7e21a23f750f48e10f058e1913f..a7e9cdc25a1434ab87afe764d934874bf8ec4af2 100644 (file)
@@ -27,22 +27,22 @@ class MainWin: public QMainWindow
        protected slots:
                void closeEvent(QCloseEvent * event);
                void HandleLoadFile(void);
+               void HandleSaveFile(void);
+               void HandleSettings(void);
 
                void AboutWozMaker(void);
-//             bool LoadA2R(const QString);
 
        private:
                MainWidget * mainWidget;
                InfoWidget * infoWidget;
                NavWidget * navWidget;
                QAction * loadFile;
+               QAction * saveFile;
+               QAction * settings;
 
-               QAction * newGame;
                QAction * undoAction;
-
                QAction * gameOptions;
                QAction * gameStats;
-
                QAction * appExit;
                QAction * appAbout;
                QAction * resetLevel;
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
new file mode 100644 (file)
index 0000000..3321f30
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// settingsdialog.cpp: Dialog for changing Architektonas settings
+//
+// Part of the Architektonas Project
+// (C) 2011 Underground Software
+// See the README and GPLv3 files for licensing and warranty information
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// WHO  WHEN        WHAT
+// ---  ----------  ------------------------------------------------------------
+// JLH  06/04/2011  Created this file
+
+#include "settingsdialog.h"
+//#include "baseunittab.h"
+//#include "generaltab.h"
+
+
+SettingsDialog::SettingsDialog(QWidget * parent/*= 0*/): QDialog(parent)
+{
+//     tabWidget = new QTabWidget;
+//     generalTab = new GeneralTab(this);
+//     baseunitTab = new BaseUnitTab(this);
+//     tabWidget->addTab(generalTab, tr("General"));
+//     tabWidget->addTab(baseunitTab, tr("Base Unit"));
+
+       buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+
+       connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+       connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+       QVBoxLayout * mainLayout = new QVBoxLayout;
+//     mainLayout->addWidget(tabWidget);
+       mainLayout->addWidget(buttonBox);
+       setLayout(mainLayout);
+
+       setWindowTitle(tr("WOZ Maker Disk Settings"));
+}
+
+
+SettingsDialog::~SettingsDialog()
+{
+}
+
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
new file mode 100644 (file)
index 0000000..79ff882
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __SETTINGSDIALOG_H__
+#define __SETTINGSDIALOG_H__
+
+#include <QtWidgets>
+
+//class GeneralTab;
+//class BaseUnitTab;
+
+class SettingsDialog: public QDialog
+{
+       Q_OBJECT
+
+       public:
+               SettingsDialog(QWidget * parent = 0);
+               ~SettingsDialog();
+
+       private:
+//             QTabWidget * tabWidget;
+               QDialogButtonBox * buttonBox;
+
+       public:
+//             GeneralTab * generalTab;
+//             BaseUnitTab * baseunitTab;
+};
+
+#endif // __SETTINGSDIALOG_H__
+
index 8c42cb957193418d457b2918ab5b1f5f6a4fc415..f4e68dbea61f04449875fedadfc789573c3b3b08 100644 (file)
@@ -1,6 +1,6 @@
 # Use 'qmake -o Makefile wozmaker.pro'
 
-CONFIG    += qt warn_on release debug
+CONFIG    += qt warn_on release c++11
 RESOURCES += res/resources.qrc
 #LIBS      += -Ldxflib/lib -ldxf
 #LIBS      += -lao
@@ -31,6 +31,7 @@ HEADERS = \
        src/mainwin.h \
        src/navwidget.h \
        src/nibblewidget.h \
+       src/settingsdialog.h \
        src/waveformwidget.h
 
 SOURCES = \
@@ -46,5 +47,6 @@ SOURCES = \
        src/mainwin.cpp \
        src/navwidget.cpp \
        src/nibblewidget.cpp \
+       src/settingsdialog.cpp \
        src/waveformwidget.cpp