From b729f450516242fd7aa29855551cd1c1c0d277d6 Mon Sep 17 00:00:00 2001 From: EricGoldsteinNz Date: Mon, 6 Nov 2023 22:20:31 +1300 Subject: [PATCH] Add Multicore --- build.bat | 2 +- tadpole.py | 40 +++++++++++++++++++++++++++++++++++++++- tadpole_functions.py | 34 ++++++++++++++++++++++++++++++++++ versioninfo | 8 ++++---- 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/build.bat b/build.bat index 657eafb..6498010 100644 --- a/build.bat +++ b/build.bat @@ -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 diff --git a/tadpole.py b/tadpole.py index bd9cb6d..cd8f35f 100644 --- a/tadpole.py +++ b/tadpole.py @@ -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: @@ -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() @@ -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) diff --git a/tadpole_functions.py b/tadpole_functions.py index 262ee65..87617bb 100644 --- a/tadpole_functions.py +++ b/tadpole_functions.py @@ -7,6 +7,7 @@ import shutil import hashlib import zipfile +from io import BytesIO #feature imports import struct import frogtool @@ -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) @@ -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 @@ -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")) diff --git a/versioninfo b/versioninfo index 9a924cb..a8fa1c1 100644 --- a/versioninfo +++ b/versioninfo @@ -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, @@ -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])]) ]