mirror of
https://wiilab.wiimart.org/wiimart/SWF-Checker
synced 2025-09-04 04:21:12 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
86ea421f38 | ||
![]() |
14150a570b | ||
![]() |
a5bfbdb521 | ||
![]() |
440f6c633d | ||
![]() |
3ffd182238 | ||
![]() |
dd1f369a9d | ||
![]() |
bd35b1e0a4 | ||
![]() |
11040a5bc8 |
@ -9,4 +9,7 @@ It checks for:
|
||||
|
||||
### 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.
|
||||
On your terminal, run `python3 SWFChecker.py` to start.
|
||||
Make sure that your SWF file is in the same folder as the checker.
|
||||
|
||||
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's stage resolution (in pixels) is larger than 700x500 pixels, it will warn about possible overlapping/clipping on the Wii.
|
139
SWFChecker.py
139
SWFChecker.py
@ -1,46 +1,101 @@
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import zlib
|
||||
import sys
|
||||
from sys import version, exit
|
||||
import platform
|
||||
|
||||
platf = platform.system()
|
||||
if platf == "Windows":
|
||||
os.system("title SWF Checker v3.0")
|
||||
os.system("cls")
|
||||
else:
|
||||
os.system("clear")
|
||||
|
||||
print(f"SWF Version Checker v3.0\nPython {version}")
|
||||
print(f"made by idkwh")
|
||||
|
||||
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()
|
||||
def parsetags(data):
|
||||
pos = 8 # start after signature & header
|
||||
rect_bits = (data[pos] >> 3) & 0x1F
|
||||
pos += int((5 + rect_bits * 4 + 7) / 8) # skip RECT
|
||||
pos += 4 # skip frame rate/count
|
||||
|
||||
# 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:])
|
||||
tags = []
|
||||
|
||||
flashver = obj[3]
|
||||
while pos + 2 <= len(data):
|
||||
tag_header = int.from_bytes(data[pos:pos + 2], 'little')
|
||||
pos += 2
|
||||
|
||||
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!)"
|
||||
tag_code = tag_header >> 6
|
||||
tag_length = tag_header & 0x3F
|
||||
|
||||
if tag_length == 0x3F:
|
||||
if pos + 4 > len(data):
|
||||
break
|
||||
tag_length = int.from_bytes(data[pos:pos + 4], 'little')
|
||||
pos += 4
|
||||
|
||||
if pos + tag_length > len(data):
|
||||
break
|
||||
|
||||
tag_data = data[pos:pos + tag_length]
|
||||
tags.append((tag_code, tag_data))
|
||||
pos += tag_length
|
||||
|
||||
return tags
|
||||
|
||||
|
||||
def CheckSWF(swf_path):
|
||||
if not os.path.exists(swf_path):
|
||||
print("File not found. Please check the filename and try again.")
|
||||
if platf == "Windows":
|
||||
os.system("pause")
|
||||
exit()
|
||||
else:
|
||||
asver = "Unable to detect ActionScript version, please try again"
|
||||
os.system("/bin/bash -c 'read -s -n 1 -p \"Press any key to exit.\"'")
|
||||
exit()
|
||||
return None, None, None
|
||||
|
||||
return flashver, asver, obj
|
||||
except KeyboardInterrupt:
|
||||
print("Exiting...")
|
||||
exit()
|
||||
except Exception as e:
|
||||
print(f"Exception occurred!\n{e}")
|
||||
exit()
|
||||
with open(swf_path, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
if data[:3] == b"CWS":
|
||||
print("SWF is compressed. Decompressing...")
|
||||
data = b"FWS" + data[3:8] + zlib.decompress(data[8:])
|
||||
|
||||
flashver = data[3]
|
||||
tags = parsetags(data)
|
||||
|
||||
has_as3 = False
|
||||
has_doabc = False
|
||||
has_doaction = False
|
||||
|
||||
for tag_code, tag_data in tags:
|
||||
if tag_code == 69: # fileattributes
|
||||
if len(tag_data) >= 1:
|
||||
flags = tag_data[0]
|
||||
if flags & 0x08:
|
||||
has_as3 = True
|
||||
elif tag_code == 82: # doabc (AS3.0 Only)
|
||||
has_doabc = True
|
||||
elif tag_code == 12: # doaction (AS1/2.0)
|
||||
has_doaction = True
|
||||
|
||||
if has_as3 or has_doabc:
|
||||
is_as3 = True
|
||||
elif has_doaction:
|
||||
is_as3 = False
|
||||
else:
|
||||
is_as3 = False
|
||||
|
||||
asver = "ActionScript 3.0 (incompatible)" if is_as3 else "ActionScript 1.0/2.0 (compatible)"
|
||||
return flashver, asver, data
|
||||
|
||||
def GetStageWH(obj):
|
||||
rectS = 8
|
||||
@ -58,25 +113,31 @@ def GetStageWH(obj):
|
||||
YMin = ReadBit(bOffset + 2 * nbits, nbits)
|
||||
YMax = ReadBit(bOffset + 3 * nbits, nbits)
|
||||
|
||||
w = round((XMax - XMin) / 20, 2)
|
||||
w = round((XMax - XMin) / 20, 2)
|
||||
h = round((YMax - YMin) / 20, 2)
|
||||
|
||||
return w, h
|
||||
return w, h # w=width, h=height, px
|
||||
|
||||
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: # compatible
|
||||
print(f"Flash version: {flashver}, this SWF is compatible with the Wii.")
|
||||
elif flashver == 9: # kirby tv notice
|
||||
print(f"Flash version: {flashver}, this SWF may be compatible if injected inside the Kirby TV Channel")
|
||||
else: # too new
|
||||
print(f"Flash version: {flashver}, this SWF is not compatible with the Wii.")
|
||||
|
||||
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.")
|
||||
print("The SWF shouldn't overlap and/or clip on the Wii.")
|
||||
|
||||
if platf == "Windows":
|
||||
os.system("pause")
|
||||
exit()
|
||||
else:
|
||||
os.system("/bin/bash -c 'read -s -n 1 -p \"Press any key to exit.\"'")
|
||||
exit()
|
15
requirements.txt
Normal file
15
requirements.txt
Normal file
@ -0,0 +1,15 @@
|
||||
blinker==1.9.0
|
||||
certifi==2025.8.3
|
||||
charset-normalizer==3.4.3
|
||||
click==8.2.1
|
||||
colorama==0.4.6
|
||||
dotenv==0.9.9
|
||||
Flask==3.1.1
|
||||
idna==3.10
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.2
|
||||
python-dotenv==1.1.1
|
||||
requests==2.32.4
|
||||
urllib3==2.5.0
|
||||
Werkzeug==3.1.3
|
Loading…
x
Reference in New Issue
Block a user