From 35ae3714e441824b88788de5d93aa72afb6731ed Mon Sep 17 00:00:00 2001 From: Gemdation Date: Sat, 19 Apr 2025 13:26:09 -0500 Subject: [PATCH] when the --- README.md | 12 ++++++++ SWFChecker.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 README.md create mode 100644 SWFChecker.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..59b8813 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# SWF Checker + +This was written by @idkwhereisthisname, it is a tool that can detect whether a SWF file is compatible with Wii injects using FriishProduce. + +It checks for: +* ActionScript verson +* the Flash version +* Size issues + +### Usage + +If a SWF was made with ActionScript 2 (or 1) and Flash version 8 (or older), it will say it can work with the Wii. If the 'game stage' is larger than 700x500 pixels, it will warn about possible overlapping/clipping on the Wii. diff --git a/SWFChecker.py b/SWFChecker.py new file mode 100644 index 0000000..9377f7e --- /dev/null +++ b/SWFChecker.py @@ -0,0 +1,82 @@ +import os +import zlib +import sys + +print(f"SWF Version Checker v1.0\nPython {sys.version}") +os.system("title SWF Version Checker v1.0") +try: + swf = input("SWF Filename: ").strip() +except KeyboardInterrupt: + print("\nExiting...") + exit() + +def CheckSWF(swf): + try: + if not os.path.exists(swf): + print("Error: File not found. Please check the filename and try again.") + return None, None, None + + with open(swf, "rb") as f: + obj = f.read() + + # decompress (CWS, zlib) + if obj[:3] == b"CWS": + print("SWF is compressed (zlib, CWS head), uncompressing...") + obj = b"FWS" + obj[3:8] + zlib.decompress(obj[8:]) + + flashver = obj[3] + + file_attributes_index = obj.find(b'\x45') + if file_attributes_index != -1: + flag = obj[file_attributes_index + 2] + isas3 = bool(flag & 0x08) + asver = "3 (this game WILL NOT work on the Wii)" if isas3 else "1/2 (this version is compatible with the Wii!)" + else: + asver = "Unable to detect ActionScript version, please try again" + + return flashver, asver, obj + except KeyboardInterrupt: + print("Exiting...") + exit() + except Exception as e: + print(f"Exception occurred!\n{e}") + exit() + +def GetStageWH(obj): + rectS = 8 + nbits = (obj[rectS] >> 3) & 0x1F + bOffset = rectS * 8 + 5 + + def ReadBit(offset, bits_Num): + ByteOffs = offset // 8 + BShift = offset % 8 + val = int.from_bytes(obj[ByteOffs:ByteOffs + 4], "big") + return (val >> (32 - bits_Num - BShift)) & ((1 << bits_Num) - 1) + + XMin = ReadBit(bOffset, nbits) + XMax = ReadBit(bOffset + nbits, nbits) + YMin = ReadBit(bOffset + 2 * nbits, nbits) + YMax = ReadBit(bOffset + 3 * nbits, nbits) + + w = round((XMax - XMin) / 20, 2) + h = round((YMax - YMin) / 20, 2) + + return w, h + +flashver, asver, SWFDAT = CheckSWF(swf) + +if flashver is not None: + w, h = GetStageWH(SWFDAT) + print(f"SWF Dimensions: {w}x{h} pixels") + + if flashver > 8: + print(f"Flash version: {flashver}, this version may NOT be compatible with the Wii.") + else: + print(f"Flash version: {flashver}, this version is compatible with the Wii.") + + print(f"ActionScript version: {asver}") + + if w > 700 and h > 500: + print("WARNING: The given SWF might overlap/clip on the Wii.") + else: + print("The SWF should NOT overlap and/or clip on the Wii.")