Skip to content

Commit 9ba9bf9

Browse files
Add experimental retro-go launcher
1 parent 95dfc1b commit 9ba9bf9

File tree

5 files changed

+118
-3
lines changed

5 files changed

+118
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "Doom",
3+
"publisher": "MicroPythonOS",
4+
"short_description": "Legendary 3D shooter",
5+
"long_description": "Plays Doom 1, 2 and modded .wad files from internal storage or SD card and plays them. Place them in the folder /roms/doom/ . Uses ducalex's retro-go port of PrBoom. Supports zipped wad files too.",
6+
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.doom/icons/com.micropythonos.doom_0.0.1_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.doom/mpks/com.micropythonos.doom_0.0.1.mpk",
8+
"fullname": "com.micropythonos.doom",
9+
"version": "0.0.1",
10+
"category": "games",
11+
"activities": [
12+
{
13+
"entrypoint": "assets/doom.py",
14+
"classname": "Doom",
15+
"intent_filters": [
16+
{
17+
"action": "main",
18+
"category": "launcher"
19+
}
20+
]
21+
}
22+
]
23+
}
24+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from mpos.apps import Activity
2+
3+
class Doom(Activity):
4+
5+
romdir = "/roms"
6+
doomdir = romdir + "/doom"
7+
retrogodir = "/retro-go"
8+
configdir = retrogodir + "/config"
9+
bootfile = configdir + "/boot.json"
10+
#partition_label = "prboom-go"
11+
partition_label = "retro-core"
12+
# Widgets:
13+
status_label = None
14+
15+
def onCreate(self):
16+
screen = lv.obj()
17+
self.status_label = lv.label(screen)
18+
self.status_label.set_width(lv.pct(90))
19+
self.status_label.set_text(f'Looking for .wad or .zip files in {self.doomdir} on internal storage and SD card...')
20+
self.status_label.set_long_mode(lv.label.LONG_MODE.WRAP)
21+
self.status_label.center()
22+
self.setContentView(screen)
23+
24+
def onResume(self, screen):
25+
self.start_wad(self.doomdir + '/Doom v1.9 Free Shareware.zip')
26+
27+
def mkdir(self, dirname):
28+
# Would be better to only create it if it doesn't exist
29+
try:
30+
import os
31+
os.mkdir(dirname)
32+
except Exception as e:
33+
self.status_label.set_text(f"Info: could not create directory {dirname} because: {e}")
34+
35+
def start_wad(self, wadfile):
36+
self.mkdir(self.romdir)
37+
self.mkdir(self.doomdir)
38+
self.mkdir(self.retrogodir)
39+
self.mkdir(self.configdir)
40+
try:
41+
import os
42+
import json
43+
# Would be better to only write this if it differs from what's already there:
44+
fd = open(self.bootfile, 'w')
45+
'''
46+
bootconfig = {
47+
"BootName": "doom",
48+
"BootArgs": f"/sd{wadfile}",
49+
"BootSlot": -1,
50+
"BootFlags": 0
51+
}
52+
'''
53+
bootconfig = {
54+
"BootName": "nes",
55+
"BootArgs": "/sd/roms/nes/homebrew/Yun.zip",
56+
"BootSlot": -1,
57+
"BootFlags": 0
58+
}
59+
json.dump(bootconfig, fd)
60+
fd.close()
61+
except Exception as e:
62+
self.status_label.set_text(f"ERROR: could not write config file: {e}")
63+
return
64+
results = []
65+
try:
66+
from esp32 import Partition
67+
results = Partition.find(label=self.partition_label)
68+
except Exception as e:
69+
self.status_label.set_text(f"ERROR: could not search for internal partition with label {self.partition_label}, unable to start: {e}")
70+
return
71+
if len(results) < 1:
72+
self.status_label.set_text(f"ERROR: could not find internal partition with label {self.partition_label}, unable to start")
73+
return
74+
partition = results[0]
75+
try:
76+
partition.set_boot()
77+
except Exception as e:
78+
print(f"ERROR: could not set partition {partition} as boot, it probably doesn't contain a valid program: {e}")
79+
try:
80+
import vfs
81+
vfs.umount('/')
82+
except Exception as e:
83+
print(f"Warning: could not unmount internal filesystem from /: {e}")
84+
try:
85+
import machine
86+
machine.reset()
87+
except Exception as e:
88+
print(f"Warning: could not restart machine: {e}")
8.48 KB
Loading

scripts/flash_over_usb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ ls -al $fwfile
99
echo "Add --erase-all if needed"
1010
sleep 5
1111
# This needs python and the esptool
12-
~/.espressif/python_env/*/bin/python -m esptool --chip esp32s3 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0 $fwfile $1
12+
~/.espressif/python_env/*/bin/python -m esptool --chip esp32s3 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0 $fwfile $@
1313

scripts/mklittlefs.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
mydir=$(readlink -f "$0")
44
mydir=$(dirname "$mydir")
55

6-
size=0x200000 # 2MB
7-
~/sources/mklittlefs/mklittlefs -c "$mydir"/../internal_filesystem/ -s "$size" internal_filesystem.bin
6+
#size=0x200000 # 2MB
7+
#~/sources/mklittlefs/mklittlefs -c "$mydir"/../internal_filesystem/ -s "$size" internal_filesystem.bin
8+
9+
size=0x520000
10+
~/sources/mklittlefs/mklittlefs -c "$mydir"/../../../internalsd_zips_removed_gb_romart -s "$size" internalsd_zips_removed_gb_romart.bin
811

0 commit comments

Comments
 (0)