forked from ruedigergad/emumaster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenable-gba.patch
More file actions
232 lines (211 loc) · 6.64 KB
/
Copy pathenable-gba.patch
File metadata and controls
232 lines (211 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
diff --git a/src/emumaster.pro b/src/emumaster.pro
index 6c04123..45ac882 100644
--- a/src/emumaster.pro
+++ b/src/emumaster.pro
@@ -2,10 +2,9 @@ TEMPLATE = subdirs
SUBDIRS += \
base \
- snes \
+ snes gba \
diskgallery
-# gba snes pico \
# nes gba snes psx amiga pico \
OTHER_FILES += \
diff --git a/src/gba/gba.cpp b/src/gba/gba.cpp
index d13e71a..efdb285 100644
--- a/src/gba/gba.cpp
+++ b/src/gba/gba.cpp
@@ -25,12 +25,14 @@
#include <base/emuview.h>
#include <base/pathmanager.h>
#include <QFile>
-#include <QApplication>
+#include <QGuiApplication>
+#include <QQuickView>
//#include <qdeclarative.h>
#include <QSemaphore>
#include <QQuickView>
#include <QtQml>
+#include <QDebug>
timer_type timer[4];
@@ -53,13 +55,14 @@ static GbaThread gbaThread;
GbaEmu gbaEmu;
-GbaEmu::GbaEmu() :
- Emu("gba")
+GbaEmu::GbaEmu(QObject *parent) :
+ Emu("gba", parent)
{
}
bool GbaEmu::init(const QString &diskPath, QString *error)
{
+ qDebug("Initializing GbaEmu.");
gpuFrame = QImage(240, 160, QImage::Format_RGB16);
setVideoSrcRect(gpuFrame.rect());
setFrameRate(60);
@@ -68,8 +71,14 @@ bool GbaEmu::init(const QString &diskPath, QString *error)
requestQuit = false;
*error = loadBios();
- if (error->isEmpty())
+ if (error->isEmpty()) {
+ qDebug() << "Calling setDisk: " << diskPath;
*error = setDisk(diskPath);
+ }
+
+ if (!error->isEmpty()) {
+ qDebug() << "Got error: " << *error;
+ }
return error->isEmpty();
}
@@ -144,14 +153,23 @@ QString GbaEmu::loadBios()
QString GbaEmu::setDisk(const QString &path)
{
+ qDebug("GbaEmu::setDisk");
init_gamepak_buffer();
- if (!gbaMemLoadGamePack(path))
+ qDebug() << "Loading game pack: " << path;
+ if (!gbaMemLoadGamePack(path)) {
+ qDebug("Loading game pack failed.");
return tr("Could not load disk");
+ }
+
+ qDebug("Resetting...");
reset();
skip_next_frame = 1;
+ qDebug("Starting gbaThread...");
gbaThread.start();
consumerSem.acquire();
+
+ qDebug("Leaving GbaEmu::setDisk.");
return QString();
}
@@ -341,9 +359,12 @@ int main(int argc, char *argv[])
qmlRegisterType<GbaCheats>();
qmlRegisterType<GbaGameSharkValidator>("EmuMaster", 1, 0,
"GbaGameSharkValidator");
- QApplication app(argc, argv);
- EmuView view(&gbaEmu, argv[1]);
- return app.exec();
+
+ QGuiApplication *app = new QGuiApplication(argc, argv);
+ QQuickView *view = new QQuickView();
+
+ EmuView emuView(&gbaEmu, argv[1], view);
+ return app->exec();
}
void GbaEmu::sl()
diff --git a/src/gba/gba.h b/src/gba/gba.h
index 697cc2a..b77866a 100644
--- a/src/gba/gba.h
+++ b/src/gba/gba.h
@@ -18,6 +18,7 @@
#define GBAEMU_H
#if defined(__cplusplus)
+#include <base/emu.h>
#include "common.h"
#include <QThread>
@@ -38,7 +39,7 @@ class GbaEmu : public Emu
Q_PROPERTY(QString gamePackMaker READ gamePackMaker CONSTANT)
Q_PROPERTY(GbaCheats *cheats READ cheats CONSTANT)
public:
- GbaEmu();
+ explicit GbaEmu(QObject *parent = 0);
bool init(const QString &diskPath, QString *error);
void shutdown();
diff --git a/src/gba/mem.cpp b/src/gba/mem.cpp
index daae727..4705e2a 100644
--- a/src/gba/mem.cpp
+++ b/src/gba/mem.cpp
@@ -24,6 +24,7 @@
#include <base/pathmanager.h>
#include <base/configuration.h>
#include <QFile>
+#include <QDebug>
// This table is configured for sequential access on system defaults
@@ -2708,6 +2709,8 @@ static QPair<QString, QString> parseLine(QString line, int count)
static void loadConfig()
{
+ qDebug() << "Trying to load game config for (GamePack- Title,Code,Maker): " << gbaGamePackTitle << "," << gbaGamePackCode << "," << gbaGamePackMaker;
+
idle_loop_target_pc = 0xFFFFFFFF;
iwram_stack_optimize = 1;
bios_rom[0x39] = 0x00;
@@ -2722,45 +2725,71 @@ static void loadConfig()
printf("could not load gba_game_config.txt");
return;
}
+
while (!f.atEnd()) {
QString line = f.readLine();
count++;
QPair<QString, QString> vars = parseLine(line, count);
- if (vars.first != "game_name" || vars.second != gbaGamePackTitle)
+ if (vars.first != "game_name" || vars.second != gbaGamePackTitle) {
continue;
+ }
+ qDebug("Found matching title at %i.", count);
line = f.readLine();
count++;
vars = parseLine(line, count);
- if (vars.first != "game_code" || vars.second != gbaGamePackCode)
+ if (vars.first != "game_code" || vars.second != gbaGamePackCode) {
continue;
+ }
+ qDebug("Found matching code at %i.", count);
line = f.readLine();
count++;
vars = parseLine(line, count);
- if (vars.first == "vender_code" && vars.second == gbaGamePackMaker)
+ if (vars.first == "vender_code" && vars.second == gbaGamePackMaker) {
+ qDebug("Found matching maker at %i.", count);
break;
+ }
}
+
+ if (!f.atEnd()) {
+ qDebug("Trying to load config.");
+ }
+
while (!f.atEnd()) {
QString line = f.readLine();
count++;
QPair<QString, QString> vars = parseLine(line, count);
- if (vars.first == "game_name")
+ if (vars.first == "game_name") {
+ qDebug("Found game_name at %i, returning.", count);
return;
- if (vars.first == "idle_loop_eliminate_target")
+ }
+ if (vars.first == "idle_loop_eliminate_target") {
idle_loop_target_pc = vars.second.toInt(0, 16);
+ qDebug() << "Set idle_loop_eliminate_target: " << idle_loop_target_pc;
+ }
if (vars.first == "translation_gate_target") {
+ qDebug("Got a translation_gate_target.");
if(translation_gate_targets < MAX_TRANSLATION_GATES) {
+ qDebug() << "Setting translation_gate_target_pc[" << translation_gate_targets << "] = " << vars.second.toInt(0, 16);
translation_gate_target_pc[translation_gate_targets] = vars.second.toInt(0, 16);
translation_gate_targets++;
}
}
- if (vars.first == "iwram_stack_optimize" && vars.second == "no")
+ if (vars.first == "iwram_stack_optimize" && vars.second == "no") {
+ qDebug("Set iwram_stack_optimize = 0");
iwram_stack_optimize = 0;
- if (vars.first == "flash_rom_type" && vars.second == "128KB")
+ }
+ if (vars.first == "flash_rom_type" && vars.second == "128KB") {
flash_device_id = FLASH_DEVICE_MACRONIX_128KB;
- if (vars.first == "bios_rom_hack_39" && vars.second == "yes")
+ qDebug() << "Set flash_device_id: " << flash_device_id;
+ }
+ if (vars.first == "bios_rom_hack_39" && vars.second == "yes") {
+ qDebug("Applying bios_rom_hack_39.");
bios_rom[0x39] = 0xC0;
- if (vars.first == "bios_rom_hack_2C" && vars.second == "yes")
+ }
+ if (vars.first == "bios_rom_hack_2C" && vars.second == "yes") {
+ qDebug("Applying bios_rom_hack_2C.");
bios_rom[0x2C] = 0x02;
+ }
}
}