Skip to content

Commit 126b2cf

Browse files
Clean up and increase safety with multiple device and ROM versions
1 parent 0c8e6fd commit 126b2cf

File tree

8 files changed

+71
-43
lines changed

8 files changed

+71
-43
lines changed

qtBuildSystem/Mu/Mu.pro

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ windows{
3838
QMAKE_LFLAGS += -fopenmp
3939
DEFINES += EMU_MULTITHREADED EMU_MANAGE_HOST_CPU_PIPELINE
4040
}
41-
CONFIG += cpu_x86_32 # this should be auto detected in the future
41+
CONFIG += cpu_x86_32 # TODO:this should be auto detected in the future
4242
}
4343

4444
macx{
@@ -54,25 +54,21 @@ linux-g++{
5454
QMAKE_CXXFLAGS += -fopenmp
5555
QMAKE_LFLAGS += -fopenmp
5656
DEFINES += EMU_MULTITHREADED EMU_MANAGE_HOST_CPU_PIPELINE
57-
CONFIG += cpu_x86_64 # this should be auto detected in the future
57+
CONFIG += cpu_x86_64 # TODO:this should be auto detected in the future
5858
}
5959

6060
android{
6161
QMAKE_CFLAGS += -fopenmp
6262
QMAKE_CXXFLAGS += -fopenmp
6363
QMAKE_LFLAGS += -fopenmp
6464
DEFINES += EMU_MULTITHREADED EMU_MANAGE_HOST_CPU_PIPELINE
65-
CONFIG += cpu_armv7 # this should be auto detected in the future
65+
CONFIG += cpu_armv7 # TODO:this should be auto detected in the future
6666
}
6767

6868

6969
CONFIG(debug, debug|release){
7070
# debug build, be accurate, fail hard, and add logging
71-
DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_SANDBOX
72-
# DEFINES += EMU_SANDBOX_LOG_MEMORY_ACCESSES # checks all reads and writes to memory and logs certain events
73-
# DEFINES += EMU_SANDBOX_OPCODE_LEVEL_DEBUG # for breakpoints
74-
# DEFINES += EMU_SANDBOX_LOG_JUMPS # log large jumps
75-
# DEFINES += EMU_SANDBOX_LOG_APIS # for printing sysTrap* calls, EMU_SANDBOX_OPCODE_LEVEL_DEBUG must be on too
71+
DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER
7672
CONFIG += no_dynarec # easier to debug with
7773
macx|linux-g++{
7874
# also check for any buffer overflows and memory leaks

qtBuildSystem/Mu/emuwrapper.cpp

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,45 @@ void EmuWrapper::writeOutSaves(){
165165
}
166166
}
167167

168-
uint32_t EmuWrapper::init(const QString& assetPath, uint8_t osVersion, bool syncRtc, bool allowInvalidBehavior, bool fastBoot){
168+
uint32_t EmuWrapper::init(const QString& assetPath, const QString& osVersion, bool syncRtc, bool allowInvalidBehavior, bool fastBoot){
169169
if(!emuRunning && !emuInited){
170170
//start emu
171171
uint32_t error;
172-
QString osVersionId = osVersion == 4 ? "41" : osVersion == 5 ? "52" : QString::number((int)osVersion) + "0";
173-
QString model = osVersion > 4 ? "en-t3" : "en-m515";
174-
QFile romFile(assetPath + "/palmos" + osVersionId + "-" + model + ".rom");
175-
QFile bootloaderFile(assetPath + "/bootloader-" + model + ".rom");
176-
QFile ramFile(assetPath + "/userdata-" + model + ".ram");
177-
QFile sdCardFile(assetPath + "/sd-" + model + ".img");
172+
uint8_t deviceModel;
178173
bool hasBootloader = true;
179174

180-
//used to mark saves with there OS version and prevent corruption
181-
emuOsName = "os" + QString::number((int)osVersion);
175+
if(osVersion == "Palm m500/Palm OS 4.0")
176+
emuOsName = "palmos40-en-m500";
177+
else if(osVersion == "Palm m515/Palm OS 4.1")
178+
emuOsName = "palmos41-en-m515";
179+
else if(osVersion == "Tungsten T3/Palm OS 5.2.1")
180+
emuOsName = "palmos52-en-t3";
181+
else if(osVersion == "Tungsten T3/Palm OS 5.2.1")
182+
emuOsName = "palmos60-en-t3";
183+
else
184+
return EMU_ERROR_INVALID_PARAMETER;
185+
186+
if(osVersion.contains("Palm m500"))
187+
deviceModel = EMU_DEVICE_PALM_M500;
188+
else if(osVersion.contains("Palm m515"))
189+
deviceModel = EMU_DEVICE_PALM_M515;
190+
else if(osVersion.contains("Tungsten T3"))
191+
deviceModel = EMU_DEVICE_TUNGSTEN_T3;
192+
else
193+
return EMU_ERROR_INVALID_PARAMETER;
194+
195+
QFile romFile(assetPath + "/" + emuOsName + ".rom");
196+
QFile bootloaderFile(assetPath + "/bootloader-dbvz.rom");
197+
QFile ramFile(assetPath + "/userdata-" + emuOsName + ".ram");
198+
QFile sdCardFile(assetPath + "/sd-" + emuOsName + ".img");
182199

183200
if(!romFile.open(QFile::ReadOnly | QFile::ExistingOnly))
184201
return EMU_ERROR_INVALID_PARAMETER;
185202

186-
if(!bootloaderFile.open(QFile::ReadOnly | QFile::ExistingOnly))
203+
if(deviceModel == EMU_DEVICE_TUNGSTEN_T3 || !bootloaderFile.open(QFile::ReadOnly | QFile::ExistingOnly))
187204
hasBootloader = false;
188205

189-
error = emulatorInit(osVersion == 4 ? EMU_DEVICE_PALM_M500 : EMU_DEVICE_TUNGSTEN_T3, (uint8_t*)romFile.readAll().data(), romFile.size(), hasBootloader ? (uint8_t*)bootloaderFile.readAll().data() : NULL, hasBootloader ? bootloaderFile.size() : 0, syncRtc, allowInvalidBehavior);
206+
error = emulatorInit(deviceModel, (uint8_t*)romFile.readAll().data(), romFile.size(), hasBootloader ? (uint8_t*)bootloaderFile.readAll().data() : NULL, hasBootloader ? bootloaderFile.size() : 0, syncRtc, allowInvalidBehavior);
190207
if(error == EMU_ERROR_NONE){
191208
QTime now = QTime::currentTime();
192209

@@ -204,9 +221,9 @@ uint32_t EmuWrapper::init(const QString& assetPath, uint8_t osVersion, bool sync
204221
}
205222

206223
emuInput = palmInput;
207-
emuRamFilePath = assetPath + "/userdata-" + model + ".ram";
208-
emuSdCardFilePath = assetPath + "/sd-" + model + ".img";
209-
emuSaveStatePath = assetPath + "/states-" + model + ".states";
224+
emuRamFilePath = assetPath + "/userdata-" + emuOsName + ".ram";
225+
emuSdCardFilePath = assetPath + "/sd-" + emuOsName + ".img";
226+
emuSaveStatePath = assetPath + "/states-" + emuOsName + ".states";
210227

211228
//make the place to store the saves
212229
QDir(emuSaveStatePath).mkdir(".");

qtBuildSystem/Mu/emuwrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class EmuWrapper{
5050
EmuWrapper();
5151
~EmuWrapper();
5252

53-
uint32_t init(const QString& assetPath, uint8_t osVersion, bool syncRtc = false, bool allowInvalidBehavior = false, bool fastBoot = false);
53+
uint32_t init(const QString& assetPath, const QString& osVersion, bool syncRtc = false, bool allowInvalidBehavior = false, bool fastBoot = false);
5454
void exit();
5555
void pause();
5656
void resume();
@@ -64,6 +64,7 @@ class EmuWrapper{
6464
bool isInited() const{return emuInited;}
6565
bool isRunning() const{return emuRunning;}
6666
bool isPaused() const{return emuPaused;}
67+
bool isTungstenT3() const{return palmEmulatingTungstenT3;}
6768
void setPenValue(float x, float y, bool touched);
6869
void setKeyValue(uint8_t key, bool pressed);
6970

qtBuildSystem/Mu/mainwindow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,15 @@ void MainWindow::on_center_released(){
329329
void MainWindow::on_ctrlBtn_clicked(){
330330
if(!emu.isInited()){
331331
QString sysDir = settings->value("resourceDirectory", "").toString();
332-
uint32_t error = emu.init(sysDir, settings->value("palmOsVersion", false).toInt(), settings->value("featureSyncedRtc", false).toBool(), settings->value("featureDurable", false).toBool(), settings->value("fastBoot", false).toBool());
332+
uint32_t error = emu.init(sysDir, settings->value("palmOsVersionString", "Palm m515/Palm OS 4.1").toString(), settings->value("featureSyncedRtc", false).toBool(), settings->value("featureDurable", false).toBool(), settings->value("fastBoot", false).toBool());
333333

334334
if(error == EMU_ERROR_NONE){
335335
emu.setCpuSpeed(settings->value("cpuSpeed", 1.00).toDouble());
336336

337337
ui->up->setEnabled(true);
338338
ui->down->setEnabled(true);
339339

340-
if(settings->value("palmOsVersion", false).toInt() > 4){
340+
if(emu.isTungstenT3()){
341341
ui->left->setEnabled(true);
342342
ui->right->setEnabled(true);
343343
ui->center->setEnabled(true);
@@ -348,7 +348,7 @@ void MainWindow::on_ctrlBtn_clicked(){
348348
ui->todo->setEnabled(true);
349349
ui->notes->setEnabled(true);
350350

351-
if(settings->value("palmOsVersion", false).toInt() > 4)
351+
if(emu.isTungstenT3())
352352
ui->voiceMemo->setEnabled(true);
353353

354354
ui->power->setEnabled(true);

qtBuildSystem/Mu/settingsmanager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SettingsManager::SettingsManager(QWidget* parent) :
2525
ui->showOnscreenKeys->setChecked(!settings->value("hideOnscreenKeys", false).toBool());
2626

2727
ui->fastBoot->setChecked(settings->value("fastBoot", false).toBool());
28-
ui->palmOsVersion->setValue(settings->value("palmOsVersion", false).toInt());
28+
ui->palmOsVersion->setCurrentIndex(settings->value("palmOsVersionIndex", 0).toInt());
2929

3030
ui->featureSyncedRtc->setChecked(settings->value("featureSyncedRtc", false).toBool());
3131
ui->featureDurable->setChecked(settings->value("featureDurable", false).toBool());
@@ -161,6 +161,7 @@ void SettingsManager::on_cpuSpeed_valueChanged(double arg1){
161161
emu.setCpuSpeed(arg1);
162162
}
163163

164-
void SettingsManager::on_palmOsVersion_valueChanged(int arg1){
165-
settings->setValue("palmOsVersion", arg1);
164+
void SettingsManager::on_palmOsVersion_currentIndexChanged(int index){
165+
settings->setValue("palmOsVersionIndex", index);
166+
settings->setValue("palmOsVersionString", ui->palmOsVersion->itemText(index));
166167
}

qtBuildSystem/Mu/settingsmanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private slots:
4949

5050
void on_fastBoot_toggled(bool checked);
5151
void on_cpuSpeed_valueChanged(double arg1);
52-
void on_palmOsVersion_valueChanged(int arg1);
52+
void on_palmOsVersion_currentIndexChanged(int index);
5353

5454
private:
5555
Ui::SettingsManager* ui;

qtBuildSystem/Mu/settingsmanager.ui

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,30 @@
338338
</widget>
339339
</item>
340340
<item>
341-
<widget class="QSpinBox" name="palmOsVersion">
342-
<property name="minimum">
343-
<number>4</number>
344-
</property>
345-
<property name="maximum">
346-
<number>6</number>
341+
<widget class="QComboBox" name="palmOsVersion">
342+
<property name="currentIndex">
343+
<number>1</number>
347344
</property>
345+
<item>
346+
<property name="text">
347+
<string>Palm m500/Palm OS 4.0</string>
348+
</property>
349+
</item>
350+
<item>
351+
<property name="text">
352+
<string>Palm m515/Palm OS 4.1</string>
353+
</property>
354+
</item>
355+
<item>
356+
<property name="text">
357+
<string>Tungsten T3/Palm OS 5.2.1</string>
358+
</property>
359+
</item>
360+
<item>
361+
<property name="text">
362+
<string>Tungsten T3/Palm OS 6.0</string>
363+
</property>
364+
</item>
348365
</widget>
349366
</item>
350367
<item>

readme.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,10 @@ Install prc-tools from the below link(self compiled or prepackaged VM)
6363

6464
## Running
6565
#### Files
66-
palmos41-en-m515.rom(all euro languages, from Palm dev program): 412557a221933a8be12622de7a21320a (MD5)
67-
palmos41-en-m515.rom(English only, verified authentic from device): 83cb1d1c76e568b916dc2e7c0bf669f6 (MD5)
66+
palmos40-en-m500.rom: f50e4d5e4d98dc831f2c34a9107651eb (MD5)
67+
palmos41-en-m515.rom: 83cb1d1c76e568b916dc2e7c0bf669f6 (MD5)
6868
palmos52-en-t3.rom: de46ec84d9aabf655eabdf9b00a3845d (MD5)
69-
bootloader-en-m515.rom(v1): 9da101cd2317830649a31f8fa46debec (MD5)
70-
bootloader-en-m515.rom(v2): e64c755205bc3e79d1bc5b70128f688d (MD5)
71-
72-
If you can read English or intend to install your own language pack use the verified version:
73-
I understand not everyone speaks English so I list both ROMs, I do all my testing on the English only build because I have verified it with an actual device, but will do my best to support the Palm dev version as well(it runs on the same hardware anyway).
69+
bootloader-dbvz.rom: 9da101cd2317830649a31f8fa46debec (MD5)
7470

7571
#### For Qt
7672
1. Run once to create the directory tree

0 commit comments

Comments
 (0)