Skip to content

Commit

Permalink
Add Multicore
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGoldsteinNz authored and EricGoldsteinNz committed Nov 6, 2023
1 parent e8fc12e commit b729f45
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set ver=1.0.1
set ver=1.1.0
rem build script for the distributable versions of tadpole
if not exist "venv\" (
python -m venv venv
Expand Down
40 changes: 39 additions & 1 deletion tadpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ def loadMenus(self):
action_battery_fix = QAction(QIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton)), "Battery Fix - Built by the community (Improves battery life and shows low power warning)", self, triggered=self.Battery_fix)
self.menu_os.menu_update.addAction(action_battery_fix)
action_bootloader_patch = QAction(QIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton)), "Bootloader Fix - Built by the community (Prevents device from not booting and corrupting SD card when changing files on SD card)", self, triggered=self.bootloaderPatch)
self.menu_os.menu_update.addAction(action_bootloader_patch)
self.menu_os.menu_update.addAction(action_bootloader_patch)
self.menu_os.menu_update.addSeparator()
self.menu_os.menu_update_multicore = self.menu_os.menu_update.addMenu("Multicore")
action_updateMulticore006 = QAction(QIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton)), "Manually change to Multicore 0.06", self, triggered=self.UpdateMulticore006)
self.menu_os.menu_update_multicore.addAction(action_updateMulticore006)
self.menu_os.menu_update_multicore.addSeparator()
action_makeMulticoreROMList = QAction(QIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton)), "Build Multicore ROM List", self, triggered=self.makeMulticoreROMList)
self.menu_os.menu_update_multicore.addAction(action_makeMulticoreROMList)
#Sub-menu for updating themes
self.menu_os.menu_change_theme = self.menu_os.addMenu("Theme")
try:
Expand Down Expand Up @@ -686,6 +693,22 @@ def UpdatetoV1_71(self):
url = "https://api.github.com/repos/EricGoldsteinNz/SF2000_Resources/contents/OS/V1.71"
self.UpdateDevice(url)

def UpdateMulticore006(self):
logging.info("Tadpole~UpdateMulticore006")
url = "https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/OS/multicore_alpha_0.06.zip"
self.UpdateDeviceFromZip(url)

def makeMulticoreROMList(self):
logging.info("Tadpole~makeMulticoreROMList")
drive = self.combobox_drive.currentText()
msgBox = DownloadProgressDialog()
msgBox.setText("Rebuilding Multicore ROM list.")
msgBox.show()
msgBox.showProgress(0, True)
romcount = tadpole_functions.makeMulticoreROMList(drive)
msgBox.close()
QMessageBox.about(self, "Finished Rebuilding Multicore ROMs",f"Found {romcount} ROMs in multicore folders")

def Battery_fix(self):
logging.info("Tadpole~Battery_fix")
qm = QMessageBox()
Expand Down Expand Up @@ -970,6 +993,21 @@ def UpdateDevice(self, url):
msgBox.close()
QMessageBox.about(self, "Failure","ERROR: Something went wrong while trying to download the update")

def UpdateDeviceFromZip(self, url):
drive = self.combobox_drive.currentText()
msgBox = DownloadProgressDialog()
msgBox.setText("Downloading Firmware Update.")
msgBox.show()
msgBox.showProgress(0, True)
if tadpole_functions.downloadAndExtractZIP(drive, url, msgBox.progress):
msgBox.close()
QMessageBox.about(self, "Success","Update successfully downloaded")
else:
msgBox.close()
QMessageBox.about(self, "Failure","ERROR: Something went wrong while trying to download the update")



def change_theme(self, url):
qm = QMessageBox()
ret = qm.question(self,'Heads up', "Changing themes will ovewrite your game shortcut icons. You can change them again after the theme is applied. Are you sure you want to change your theme?" , qm.Yes | qm.No)
Expand Down
34 changes: 34 additions & 0 deletions tadpole_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import hashlib
import zipfile
from io import BytesIO
#feature imports
import struct
import frogtool
Expand Down Expand Up @@ -700,6 +701,7 @@ def changeTheme(drive_path: str, url: str = "", file: str = "", progressBar: QPr
Raises:
ValueError: When both url and file params are provided.
"""
# TODO do this in memory instead
if url and not file:
zip_file = "theme.zip"
downloadFileFromGithub(zip_file, url)
Expand Down Expand Up @@ -817,6 +819,22 @@ def downloadFileFromGithub(outFile, url):
return False


def downloadAndExtractZIP(root, url, progress):
try:
response = requests.get(url)
if response.status_code == 200:

zip = zipfile.ZipFile(BytesIO(response.content))
zip.extractall(path=root)

return True
else:
print("Error when trying to download a file from Github. Response was not code 200")
raise InvalidURLError
except Exception as e:
print(str(e))
return False

def DownloadOSFiles(correct_drive, progress):
downloadDirectoryFromGithub(correct_drive,"https://api.github.com/repos/EricGoldsteinNz/SF2000_Resources/contents/OS/V1.6", progress)
#Make the ROM directories
Expand Down Expand Up @@ -847,6 +865,22 @@ def DownloadOSFiles(correct_drive, progress):
downloadFileFromGithub(os.path.join(correct_drive,"bios","bisrv.asd"), "https://raw.githubusercontent.com/EricGoldsteinNz/SF2000_Resources/main/OS/V1.6/bios/bisrv.asd")
return True

def makeMulticoreROMList(drive):
logging.info("tadpole_functions~makeMulticoreROMList")
romcount = 0
for d in os.listdir(os.path.join(drive,"cores")):
if os.path.isdir(os.path.join(drive,"cores",d)):
logging.info(f"Build Multicore ROMs for {d}")
romfolder = os.path.join(drive,"ROMS",d)
if os.path.exists(romfolder):
for rom in os.listdir(romfolder):
romcount += 1
# Creates a new file
with open(os.path.join(drive,"ROMS",f"{d};{rom}.gba"), 'w'):
pass
return romcount


def emptyFavourites(drive) -> bool:
return emptyFile(os.path.join(drive, "Resources", "Favorites.bin"))

Expand Down
8 changes: 4 additions & 4 deletions versioninfo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(1, 0, 1, 0),
prodvers=(1, 0, 1, 0),
filevers=(1, 1, 0, 0),
prodvers=(1, 1, 0, 0),
mask=0x3f,
flags=0x0,
OS=0x4,
Expand All @@ -15,12 +15,12 @@ VSVersionInfo(
u'080904B0',
[StringStruct(u'CompanyName', u'EricGoldstein'),
StringStruct(u'FileDescription', u'tadpole'),
StringStruct(u'FileVersion', u'1.0.1'),
StringStruct(u'FileVersion', u'1.1.0'),
StringStruct(u'InternalName', u'tadpole'),
StringStruct(u'LegalCopyright', u'by EricGoldstein 2023'),
StringStruct(u'OriginalFilename', u'tadpole.exe'),
StringStruct(u'ProductName', u'tadpole'),
StringStruct(u'ProductVersion', u'1.0.1')])
StringStruct(u'ProductVersion', u'1.1.0')])
]),
VarFileInfo([VarStruct(u'Translation', [2057, 1200])])
]
Expand Down

0 comments on commit b729f45

Please sign in to comment.