mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2025-04-25 21:01:01 -04:00
Added hard-coded table of System Menu versions for conversions
This commit is contained in:
parent
cfd5abac7e
commit
194b65c6d6
@ -47,3 +47,65 @@ def _pad_bytes(data, alignment=64) -> bytes:
|
|||||||
while (len(data) % alignment) != 0:
|
while (len(data) % alignment) != 0:
|
||||||
data += b'\x00'
|
data += b'\x00'
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
_wii_menu_versions = {
|
||||||
|
"Prelaunch": [0, 1, 2],
|
||||||
|
"1.0J": 64,
|
||||||
|
"1.0U": 33,
|
||||||
|
"1.0E": 34,
|
||||||
|
"2.0J": 128,
|
||||||
|
"2.0U": 97,
|
||||||
|
"2.0E": 130,
|
||||||
|
"2.1E": 162,
|
||||||
|
"2.2J": 192,
|
||||||
|
"2.2U": 193,
|
||||||
|
"2.2E": 194,
|
||||||
|
"3.0J": 224,
|
||||||
|
"3.0U": 225,
|
||||||
|
"3.0E": 226,
|
||||||
|
"3.1J": 256,
|
||||||
|
"3.1U": 257,
|
||||||
|
"3.1E": 258,
|
||||||
|
"3.2J": 288,
|
||||||
|
"3.2U": 289,
|
||||||
|
"3.2E": 290,
|
||||||
|
"3.3J": 352,
|
||||||
|
"3.3U": 353,
|
||||||
|
"3.3E": 354,
|
||||||
|
"3.3K": 326,
|
||||||
|
"3.4J": 384,
|
||||||
|
"3.4U": 385,
|
||||||
|
"3.4E": 386,
|
||||||
|
"3.5K": 390,
|
||||||
|
"4.0J": 416,
|
||||||
|
"4.0U": 417,
|
||||||
|
"4.0E": 418,
|
||||||
|
"4.1J": 448,
|
||||||
|
"4.1U": 449,
|
||||||
|
"4.1E": 450,
|
||||||
|
"4.1K": 454,
|
||||||
|
"4.2J": 480,
|
||||||
|
"4.2U": 481,
|
||||||
|
"4.2E": 482,
|
||||||
|
"4.2K": 486,
|
||||||
|
"4.3J": 512,
|
||||||
|
"4.3U": 513,
|
||||||
|
"4.3E": 514,
|
||||||
|
"4.3K": 518,
|
||||||
|
"4.3U-Mini": 4609,
|
||||||
|
"4.3E-Mini": 4610
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_vwii_menu_versions = {
|
||||||
|
"vWii-1.0.0J": 512,
|
||||||
|
"vWii-1.0.0U": 513,
|
||||||
|
"vWii-1.0.0E": 514,
|
||||||
|
"vWii-4.0.0J": 544,
|
||||||
|
"vWii-4.0.0U": 545,
|
||||||
|
"vWii-4.0.0E": 546,
|
||||||
|
"vWii-5.2.0J": 608,
|
||||||
|
"vWii-5.2.0U": 609,
|
||||||
|
"vWii-5.2.0E": 610,
|
||||||
|
}
|
||||||
|
@ -129,17 +129,14 @@ class TMD:
|
|||||||
# "Reserved" data 2.
|
# "Reserved" data 2.
|
||||||
tmd_data.seek(0x1C6)
|
tmd_data.seek(0x1C6)
|
||||||
self.reserved2 = tmd_data.read(18)
|
self.reserved2 = tmd_data.read(18)
|
||||||
# Access rights of the title; DVD-video access and AHBPROT.
|
# Access rights of the title; DVD-video and AHB access.
|
||||||
tmd_data.seek(0x1D8)
|
tmd_data.seek(0x1D8)
|
||||||
self.access_rights = tmd_data.read(4)
|
self.access_rights = tmd_data.read(4)
|
||||||
# Version number straight from the TMD.
|
# Version number straight from the TMD.
|
||||||
tmd_data.seek(0x1DC)
|
tmd_data.seek(0x1DC)
|
||||||
self.title_version = int.from_bytes(tmd_data.read(2))
|
self.title_version = int.from_bytes(tmd_data.read(2))
|
||||||
# Calculate the converted version number via util module.
|
# Calculate the converted version number via util module.
|
||||||
try:
|
self.title_version_converted = title_ver_dec_to_standard(self.title_version, self.title_id, bool(self.vwii))
|
||||||
self.title_version_converted = title_ver_dec_to_standard(self.title_version, self.title_id)
|
|
||||||
except ValueError:
|
|
||||||
self.title_version_converted = ""
|
|
||||||
# The number of contents listed in the TMD.
|
# The number of contents listed in the TMD.
|
||||||
tmd_data.seek(0x1DE)
|
tmd_data.seek(0x1DE)
|
||||||
self.num_contents = int.from_bytes(tmd_data.read(2))
|
self.num_contents = int.from_bytes(tmd_data.read(2))
|
||||||
@ -413,7 +410,7 @@ class TMD:
|
|||||||
if new_version > 65535:
|
if new_version > 65535:
|
||||||
raise ValueError("Title version is not valid! Integer version number cannot exceed v65535.")
|
raise ValueError("Title version is not valid! Integer version number cannot exceed v65535.")
|
||||||
self.title_version = new_version
|
self.title_version = new_version
|
||||||
version_converted = title_ver_dec_to_standard(new_version, self.title_id)
|
version_converted = title_ver_dec_to_standard(new_version, self.title_id, bool(self.vwii))
|
||||||
self.title_version_converted = version_converted
|
self.title_version_converted = version_converted
|
||||||
else:
|
else:
|
||||||
raise TypeError("Title version type is not valid! Type must be either integer or string.")
|
raise TypeError("Title version type is not valid! Type must be either integer or string.")
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
# General title-related utilities that don't fit within a specific module.
|
# General title-related utilities that don't fit within a specific module.
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
from ..shared import _wii_menu_versions, _vwii_menu_versions
|
||||||
|
|
||||||
|
|
||||||
def title_ver_dec_to_standard(version: int, title_id: str) -> str:
|
def title_ver_dec_to_standard(version: int, title_id: str, vwii: bool = False) -> str:
|
||||||
"""
|
"""
|
||||||
Converts a title's version from decimal form (vXXX, the way the version is stored in the TMD/Ticket) to its standard
|
Converts a title's version from decimal form (vXXX, the way the version is stored in the TMD/Ticket) to its standard
|
||||||
and human-readable form (vX.X). The Title ID is required as some titles handle this version differently from others.
|
and human-readable form (vX.X). The Title ID is required as some titles handle this version differently from others.
|
||||||
@ -18,6 +19,8 @@ def title_ver_dec_to_standard(version: int, title_id: str) -> str:
|
|||||||
The version of the title, in decimal form.
|
The version of the title, in decimal form.
|
||||||
title_id : str
|
title_id : str
|
||||||
The Title ID that the version is associated with.
|
The Title ID that the version is associated with.
|
||||||
|
vwii : bool
|
||||||
|
Whether this title is for the vWii or not. Only relevant for the System Menu.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -26,7 +29,16 @@ def title_ver_dec_to_standard(version: int, title_id: str) -> str:
|
|||||||
"""
|
"""
|
||||||
version_out = ""
|
version_out = ""
|
||||||
if title_id == "0000000100000002":
|
if title_id == "0000000100000002":
|
||||||
raise ValueError("The System Menu's version cannot currently be converted.")
|
if vwii:
|
||||||
|
try:
|
||||||
|
version_out = list(_vwii_menu_versions.keys())[list(_vwii_menu_versions.values()).index(version)]
|
||||||
|
except ValueError:
|
||||||
|
version_out = ""
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
version_out = list(_wii_menu_versions.keys())[list(_wii_menu_versions.values()).index(version)]
|
||||||
|
except ValueError:
|
||||||
|
version_out = ""
|
||||||
else:
|
else:
|
||||||
# For most channels, we need to get the floored value of version / 256 for the major version, and the version %
|
# For most channels, we need to get the floored value of version / 256 for the major version, and the version %
|
||||||
# 256 as the minor version. Minor versions > 9 are intended, as Nintendo themselves frequently used them.
|
# 256 as the minor version. Minor versions > 9 are intended, as Nintendo themselves frequently used them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user