This commit is contained in:
Gemdation 2025-04-19 13:26:09 -05:00 committed by GitHub
commit 35ae3714e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 94 additions and 0 deletions

12
README.md Normal file
View File

@ -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.

82
SWFChecker.py Normal file
View File

@ -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.")