You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Add experimental retro-go launcher
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "Doom",
|
||||
"publisher": "MicroPythonOS",
|
||||
"short_description": "Legendary 3D shooter",
|
||||
"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.",
|
||||
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.doom/icons/com.micropythonos.doom_0.0.1_64x64.png",
|
||||
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.doom/mpks/com.micropythonos.doom_0.0.1.mpk",
|
||||
"fullname": "com.micropythonos.doom",
|
||||
"version": "0.0.1",
|
||||
"category": "games",
|
||||
"activities": [
|
||||
{
|
||||
"entrypoint": "assets/doom.py",
|
||||
"classname": "Doom",
|
||||
"intent_filters": [
|
||||
{
|
||||
"action": "main",
|
||||
"category": "launcher"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
from mpos.apps import Activity
|
||||
|
||||
class Doom(Activity):
|
||||
|
||||
romdir = "/roms"
|
||||
doomdir = romdir + "/doom"
|
||||
retrogodir = "/retro-go"
|
||||
configdir = retrogodir + "/config"
|
||||
bootfile = configdir + "/boot.json"
|
||||
#partition_label = "prboom-go"
|
||||
partition_label = "retro-core"
|
||||
# Widgets:
|
||||
status_label = None
|
||||
|
||||
def onCreate(self):
|
||||
screen = lv.obj()
|
||||
self.status_label = lv.label(screen)
|
||||
self.status_label.set_width(lv.pct(90))
|
||||
self.status_label.set_text(f'Looking for .wad or .zip files in {self.doomdir} on internal storage and SD card...')
|
||||
self.status_label.set_long_mode(lv.label.LONG_MODE.WRAP)
|
||||
self.status_label.center()
|
||||
self.setContentView(screen)
|
||||
|
||||
def onResume(self, screen):
|
||||
self.start_wad(self.doomdir + '/Doom v1.9 Free Shareware.zip')
|
||||
|
||||
def mkdir(self, dirname):
|
||||
# Would be better to only create it if it doesn't exist
|
||||
try:
|
||||
import os
|
||||
os.mkdir(dirname)
|
||||
except Exception as e:
|
||||
self.status_label.set_text(f"Info: could not create directory {dirname} because: {e}")
|
||||
|
||||
def start_wad(self, wadfile):
|
||||
self.mkdir(self.romdir)
|
||||
self.mkdir(self.doomdir)
|
||||
self.mkdir(self.retrogodir)
|
||||
self.mkdir(self.configdir)
|
||||
try:
|
||||
import os
|
||||
import json
|
||||
# Would be better to only write this if it differs from what's already there:
|
||||
fd = open(self.bootfile, 'w')
|
||||
'''
|
||||
bootconfig = {
|
||||
"BootName": "doom",
|
||||
"BootArgs": f"/sd{wadfile}",
|
||||
"BootSlot": -1,
|
||||
"BootFlags": 0
|
||||
}
|
||||
'''
|
||||
bootconfig = {
|
||||
"BootName": "nes",
|
||||
"BootArgs": "/sd/roms/nes/homebrew/Yun.zip",
|
||||
"BootSlot": -1,
|
||||
"BootFlags": 0
|
||||
}
|
||||
json.dump(bootconfig, fd)
|
||||
fd.close()
|
||||
except Exception as e:
|
||||
self.status_label.set_text(f"ERROR: could not write config file: {e}")
|
||||
return
|
||||
results = []
|
||||
try:
|
||||
from esp32 import Partition
|
||||
results = Partition.find(label=self.partition_label)
|
||||
except Exception as e:
|
||||
self.status_label.set_text(f"ERROR: could not search for internal partition with label {self.partition_label}, unable to start: {e}")
|
||||
return
|
||||
if len(results) < 1:
|
||||
self.status_label.set_text(f"ERROR: could not find internal partition with label {self.partition_label}, unable to start")
|
||||
return
|
||||
partition = results[0]
|
||||
try:
|
||||
partition.set_boot()
|
||||
except Exception as e:
|
||||
print(f"ERROR: could not set partition {partition} as boot, it probably doesn't contain a valid program: {e}")
|
||||
try:
|
||||
import vfs
|
||||
vfs.umount('/')
|
||||
except Exception as e:
|
||||
print(f"Warning: could not unmount internal filesystem from /: {e}")
|
||||
try:
|
||||
import machine
|
||||
machine.reset()
|
||||
except Exception as e:
|
||||
print(f"Warning: could not restart machine: {e}")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
@@ -9,5 +9,5 @@ ls -al $fwfile
|
||||
echo "Add --erase-all if needed"
|
||||
sleep 5
|
||||
# This needs python and the esptool
|
||||
~/.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
|
||||
~/.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 $@
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
mydir=$(readlink -f "$0")
|
||||
mydir=$(dirname "$mydir")
|
||||
|
||||
size=0x200000 # 2MB
|
||||
~/sources/mklittlefs/mklittlefs -c "$mydir"/../internal_filesystem/ -s "$size" internal_filesystem.bin
|
||||
#size=0x200000 # 2MB
|
||||
#~/sources/mklittlefs/mklittlefs -c "$mydir"/../internal_filesystem/ -s "$size" internal_filesystem.bin
|
||||
|
||||
size=0x520000
|
||||
~/sources/mklittlefs/mklittlefs -c "$mydir"/../../../internalsd_zips_removed_gb_romart -s "$size" internalsd_zips_removed_gb_romart.bin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user