mirror of
https://wiilab.wiimart.org/wiimart/SWF-Checker
synced 2025-09-05 21:11:03 +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
|
### 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.
|
135
SWFChecker.py
135
SWFChecker.py
@ -1,46 +1,101 @@
|
|||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import zlib
|
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:
|
try:
|
||||||
swf = input("SWF Filename: ").strip()
|
swf = input("SWF Filename: ").strip()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nExiting...")
|
print("\nExiting...")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
def CheckSWF(swf):
|
def parsetags(data):
|
||||||
try:
|
pos = 8 # start after signature & header
|
||||||
if not os.path.exists(swf):
|
rect_bits = (data[pos] >> 3) & 0x1F
|
||||||
print("Error: File not found. Please check the filename and try again.")
|
pos += int((5 + rect_bits * 4 + 7) / 8) # skip RECT
|
||||||
return None, None, None
|
pos += 4 # skip frame rate/count
|
||||||
|
|
||||||
with open(swf, "rb") as f:
|
tags = []
|
||||||
obj = f.read()
|
|
||||||
|
|
||||||
# decompress (CWS, zlib)
|
while pos + 2 <= len(data):
|
||||||
if obj[:3] == b"CWS":
|
tag_header = int.from_bytes(data[pos:pos + 2], 'little')
|
||||||
print("SWF is compressed (zlib, CWS head), uncompressing...")
|
pos += 2
|
||||||
obj = b"FWS" + obj[3:8] + zlib.decompress(obj[8:])
|
|
||||||
|
|
||||||
flashver = obj[3]
|
tag_code = tag_header >> 6
|
||||||
|
tag_length = tag_header & 0x3F
|
||||||
|
|
||||||
file_attributes_index = obj.find(b'\x45')
|
if tag_length == 0x3F:
|
||||||
if file_attributes_index != -1:
|
if pos + 4 > len(data):
|
||||||
flag = obj[file_attributes_index + 2]
|
break
|
||||||
isas3 = bool(flag & 0x08)
|
tag_length = int.from_bytes(data[pos:pos + 4], 'little')
|
||||||
asver = "3 (this game WILL NOT work on the Wii)" if isas3 else "1/2 (this version is compatible with the Wii!)"
|
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:
|
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
|
with open(swf_path, "rb") as f:
|
||||||
except KeyboardInterrupt:
|
data = f.read()
|
||||||
print("Exiting...")
|
|
||||||
exit()
|
if data[:3] == b"CWS":
|
||||||
except Exception as e:
|
print("SWF is compressed. Decompressing...")
|
||||||
print(f"Exception occurred!\n{e}")
|
data = b"FWS" + data[3:8] + zlib.decompress(data[8:])
|
||||||
exit()
|
|
||||||
|
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):
|
def GetStageWH(obj):
|
||||||
rectS = 8
|
rectS = 8
|
||||||
@ -60,23 +115,29 @@ def GetStageWH(obj):
|
|||||||
|
|
||||||
w = round((XMax - XMin) / 20, 2)
|
w = round((XMax - XMin) / 20, 2)
|
||||||
h = round((YMax - YMin) / 20, 2)
|
h = round((YMax - YMin) / 20, 2)
|
||||||
|
return w, h # w=width, h=height, px
|
||||||
return w, h
|
|
||||||
|
|
||||||
flashver, asver, SWFDAT = CheckSWF(swf)
|
flashver, asver, SWFDAT = CheckSWF(swf)
|
||||||
|
|
||||||
if flashver is not None:
|
if flashver is not None:
|
||||||
w, h = GetStageWH(SWFDAT)
|
w, h = GetStageWH(SWFDAT)
|
||||||
print(f"SWF Dimensions: {w}x{h} pixels")
|
print(f"SWF Dimensions: {w}x{h} pixels")
|
||||||
|
if flashver <= 8: # compatible
|
||||||
if flashver > 8:
|
print(f"Flash version: {flashver}, this SWF is compatible with the Wii.")
|
||||||
print(f"Flash version: {flashver}, this version may NOT be compatible with the Wii.")
|
elif flashver == 9: # kirby tv notice
|
||||||
else:
|
print(f"Flash version: {flashver}, this SWF may be compatible if injected inside the Kirby TV Channel")
|
||||||
print(f"Flash version: {flashver}, this version is compatible with the Wii.")
|
else: # too new
|
||||||
|
print(f"Flash version: {flashver}, this SWF is not compatible with the Wii.")
|
||||||
|
|
||||||
print(f"ActionScript version: {asver}")
|
print(f"ActionScript version: {asver}")
|
||||||
|
|
||||||
if w > 700 and h > 500:
|
if w > 700 and h > 500:
|
||||||
print("WARNING: The given SWF might overlap/clip on the Wii.")
|
print("WARNING: The given SWF might overlap/clip on the Wii.")
|
||||||
else:
|
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