RidersPyTools 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- RidersPyTools_KC/Archetypes.py +24 -0
- RidersPyTools_KC/Characters.py +55 -0
- RidersPyTools_KC/DolphinProc.py +61 -0
- RidersPyTools_KC/GameState.py +98 -0
- RidersPyTools_KC/Gears.py +129 -0
- RidersPyTools_KC/MapParser.py +143 -0
- RidersPyTools_KC/Player.py +354 -0
- RidersPyTools_KC/RidersObject.py +125 -0
- RidersPyTools_KC/Stages.py +38 -0
- RidersPyTools_KC/__init__.py +1 -0
- RidersPyTools_KC/config.py +35 -0
- RidersPyTools_KC/include/Constants.py +105 -0
- RidersPyTools_KC/include/Controller.py +75 -0
- RidersPyTools_KC/include/GearStats.py +72 -0
- RidersPyTools_KC/include/GenericData.py +176 -0
- RidersPyTools_KC/include/OffsetAttr.py +26 -0
- RidersPyTools_KC/include/Structs.py +0 -0
- RidersPyTools_KC/include/__init__.py +0 -0
- riderspytools-0.0.1.dist-info/METADATA +76 -0
- riderspytools-0.0.1.dist-info/RECORD +22 -0
- riderspytools-0.0.1.dist-info/WHEEL +4 -0
- riderspytools-0.0.1.dist-info/licenses/LICENSE +19 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
ARCH_ALLROUNDER = 0
|
|
2
|
+
ARCH_LATEBOOSTER = 1
|
|
3
|
+
ARCH_TOPSPEED = 2
|
|
4
|
+
ARCH_COMBAT = 3
|
|
5
|
+
ARCH_DRIFT = 4
|
|
6
|
+
ARCH_OMNIROUNDER = 5
|
|
7
|
+
ARCH_SUPERSONIC = 6
|
|
8
|
+
ARCH_BOOST = 7
|
|
9
|
+
ARCH_TRICKSTER = 8
|
|
10
|
+
ARCH_NONE = 9
|
|
11
|
+
|
|
12
|
+
ARCH_ID_TO_NAME = {
|
|
13
|
+
ARCH_ALLROUNDER: "All-Rounder",
|
|
14
|
+
ARCH_LATEBOOSTER: "Late Booster",
|
|
15
|
+
ARCH_TOPSPEED: "Top Speed",
|
|
16
|
+
ARCH_COMBAT: "Combat",
|
|
17
|
+
ARCH_DRIFT: "Drift",
|
|
18
|
+
ARCH_OMNIROUNDER: "Omnirounder",
|
|
19
|
+
ARCH_SUPERSONIC: "Super Sonic",
|
|
20
|
+
ARCH_BOOST: "Boost",
|
|
21
|
+
ARCH_TRICKSTER: "Trickster",
|
|
22
|
+
ARCH_NONE: "None",
|
|
23
|
+
}
|
|
24
|
+
ALL_TE_ARCHS = list(ARCH_ID_TO_NAME.keys())
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
CHR_SONIC = 0
|
|
2
|
+
CHR_TAILS = 1
|
|
3
|
+
CHR_KNUCKLES = 2
|
|
4
|
+
CHR_AMY = 3
|
|
5
|
+
CHR_JET = 4
|
|
6
|
+
CHR_STORM = 5
|
|
7
|
+
CHR_WAVE = 6
|
|
8
|
+
CHR_EGGMAN = 7
|
|
9
|
+
CHR_CREAM = 8
|
|
10
|
+
CHR_ROUGE = 9
|
|
11
|
+
CHR_SHADOW = 10
|
|
12
|
+
CHR_SUPER_SONIC = 11
|
|
13
|
+
CHR_NIGHTS = 12
|
|
14
|
+
CHR_AIAI = 13
|
|
15
|
+
CHR_ULALA = 14
|
|
16
|
+
CHR_E10G = 15
|
|
17
|
+
CHR_E10R = 16
|
|
18
|
+
|
|
19
|
+
CHR_ID_TO_NAME = {
|
|
20
|
+
CHR_SONIC: "Sonic",
|
|
21
|
+
CHR_TAILS: "Tails",
|
|
22
|
+
CHR_KNUCKLES: "Knuckles",
|
|
23
|
+
CHR_AMY: "Amy",
|
|
24
|
+
CHR_JET: "Jet",
|
|
25
|
+
CHR_STORM: "Storm",
|
|
26
|
+
CHR_WAVE: "Wave",
|
|
27
|
+
CHR_EGGMAN: "Dr. Eggman",
|
|
28
|
+
CHR_CREAM: "Cream",
|
|
29
|
+
CHR_ROUGE: "Rouge",
|
|
30
|
+
CHR_SHADOW: "Shadow",
|
|
31
|
+
CHR_SUPER_SONIC: "Super Sonic",
|
|
32
|
+
CHR_NIGHTS: "NiGHTS",
|
|
33
|
+
CHR_AIAI: "AiAi",
|
|
34
|
+
CHR_ULALA: "Ulala",
|
|
35
|
+
CHR_E10G: "E-10000G",
|
|
36
|
+
CHR_E10R: "E-10000R"
|
|
37
|
+
}
|
|
38
|
+
ALL_CHRS = list(CHR_ID_TO_NAME.keys())
|
|
39
|
+
|
|
40
|
+
CHR_ID_TO_DEFAULT_GEAR_NAME = {
|
|
41
|
+
CHR_SONIC: "Blue Star",
|
|
42
|
+
CHR_TAILS: "Yellow Tail",
|
|
43
|
+
CHR_KNUCKLES: "Red Rock",
|
|
44
|
+
CHR_AMY: "Pink Rose",
|
|
45
|
+
CHR_JET: "Type-J",
|
|
46
|
+
CHR_STORM: "Type-S",
|
|
47
|
+
CHR_WAVE: "Type-W",
|
|
48
|
+
CHR_CREAM: "Smile",
|
|
49
|
+
CHR_ROUGE: "Temptation",
|
|
50
|
+
CHR_NIGHTS: "Night Sky",
|
|
51
|
+
CHR_AIAI: "BANANA",
|
|
52
|
+
CHR_ULALA: "Channel-5",
|
|
53
|
+
CHR_E10G: "E-gearG",
|
|
54
|
+
CHR_E10R: "E-gearR"
|
|
55
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import dolphin_memory_engine
|
|
2
|
+
import time
|
|
3
|
+
from src.RidersPyTools_KC.include.Constants import GameIDs
|
|
4
|
+
import GameState
|
|
5
|
+
|
|
6
|
+
# def dolphin_connection_proc():
|
|
7
|
+
print("Attempting to connect to Dolphin...")
|
|
8
|
+
print("If Dolphin is not open, open it now, or close this program.")
|
|
9
|
+
dolphin_memory_engine.hook()
|
|
10
|
+
if dolphin_memory_engine.is_hooked():
|
|
11
|
+
# Hook and check the game (convert to async def later)
|
|
12
|
+
game_id_bytes = dolphin_memory_engine.read_bytes(0x80000000, 6)
|
|
13
|
+
print("Checking game version...")
|
|
14
|
+
# Match case did not let me convert to bytes here so, lmao I don't using an if-statement but sure man whatever.
|
|
15
|
+
match game_id_bytes:
|
|
16
|
+
case GameIDs.SONIC_RIDERS_ID:
|
|
17
|
+
GameState.GAME_VERSION = GameIDs.SONIC_RIDERS_ID
|
|
18
|
+
print("Game loaded: Sonic Riders (Vanilla/Vanilla based mod)")
|
|
19
|
+
|
|
20
|
+
case GameIDs.SONIC_RIDERS_TE_ID:
|
|
21
|
+
GameState.GAME_VERSION = GameIDs.SONIC_RIDERS_TE_ID
|
|
22
|
+
print("Game loaded: Sonic Riders: Tournament Edition")
|
|
23
|
+
|
|
24
|
+
case GameIDs.SONIC_RIDERS_DX_ID:
|
|
25
|
+
GameState.GAME_VERSION = GameIDs.SONIC_RIDERS_DX_ID
|
|
26
|
+
print("Game loaded: Sonic Riders: DX")
|
|
27
|
+
|
|
28
|
+
case GameIDs.SONIC_RIDERS_ZG_ID:
|
|
29
|
+
GameState.GAME_VERSION = GameIDs.SONIC_RIDERS_ZG_ID
|
|
30
|
+
print("Game loaded: Sonic Riders: Zero Gravity")
|
|
31
|
+
|
|
32
|
+
case GameIDs.SONIC_RIDERS_FT_ID:
|
|
33
|
+
GameState.GAME_VERSION = GameIDs.SONIC_RIDERS_FT_ID
|
|
34
|
+
print("Game loaded: Sonic Riders: Future")
|
|
35
|
+
|
|
36
|
+
case _:
|
|
37
|
+
print("No valid Sonic Riders game loaded in this dolphin instance, please load a supported Sonic Riders version.")
|
|
38
|
+
dolphin_memory_engine.un_hook()
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
# if game_id_bytes == bytes(SONIC_RIDERS_ID, "utf-8"):
|
|
42
|
+
# GameState.GAME_VERSION = GameVersion.Vanilla
|
|
43
|
+
# print("Game loaded: Sonic Riders (Vanilla/Vanilla based mod)")
|
|
44
|
+
# elif bytes(SONIC_RIDERS_TE_ID, "utf-8"):
|
|
45
|
+
# GameState.GAME_VERSION = GameVersion.TE
|
|
46
|
+
# print("Game loaded: Sonic Riders: Tournament Edition")
|
|
47
|
+
# elif bytes(SONIC_RIDERS_DX_ID, "utf-8"):
|
|
48
|
+
# GameState.GAME_VERSION = GameVersion.DX
|
|
49
|
+
# print("Game loaded: Sonic Riders: DX")
|
|
50
|
+
# elif bytes(SONIC_RIDERS_ZG_ID, "utf-8"):
|
|
51
|
+
# GameState.GAME_VERSION = GameVersion.ZG
|
|
52
|
+
# print("Game loaded: Sonic Riders: Zero Gravity")
|
|
53
|
+
# else:
|
|
54
|
+
# print("No valid Sonic Riders game loaded, please load a valid Sonic Riders ROM.")
|
|
55
|
+
# dolphin_memory_engine.un_hook()
|
|
56
|
+
|
|
57
|
+
else:
|
|
58
|
+
print("Connection to Dolphin failed, attempting again in 5 seconds...")
|
|
59
|
+
time.sleep(5)
|
|
60
|
+
# dolphin_connection_proc()
|
|
61
|
+
pass
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
|
|
3
|
+
from .include.Constants import GameIDs
|
|
4
|
+
from enum import Enum, IntEnum
|
|
5
|
+
# from src.RidersPyTools_KC.Constants import GameVersion
|
|
6
|
+
|
|
7
|
+
# Starts as vanilla unless written otherwise
|
|
8
|
+
GAME_VERSION = GameIDs.SONIC_RIDERS_TE_ID
|
|
9
|
+
|
|
10
|
+
# Main game mode ID, see GameModes.
|
|
11
|
+
CURRENT_GAME_MODE = None
|
|
12
|
+
|
|
13
|
+
# Internal ID used by the game to determine certain states about certain modes
|
|
14
|
+
GAME_DETAIL = None
|
|
15
|
+
|
|
16
|
+
# AKA ExitMethod
|
|
17
|
+
END_OF_GAME_FLAG = None
|
|
18
|
+
|
|
19
|
+
class GameModes(IntEnum):
|
|
20
|
+
STAGE_SELECT = 0x1, # Game initializes to this value on start rather than main menu on start. Odd.
|
|
21
|
+
STORY_MODE = 100,
|
|
22
|
+
MISSION_MODE = 200,
|
|
23
|
+
TAG_MODE = 300,
|
|
24
|
+
EMERALD_CHASE = 400,
|
|
25
|
+
BATTLE_MODE = 500,
|
|
26
|
+
TIME_TRIAL = 600,
|
|
27
|
+
FREE_RACE = 700,
|
|
28
|
+
WORLD_GRAND_PRIX = 800,
|
|
29
|
+
UNK_MODE = 900, # Complete mystery to this day...
|
|
30
|
+
CUTSCENE_MODE = 1000
|
|
31
|
+
MAIN_MENU_MODE = 2000
|
|
32
|
+
|
|
33
|
+
MODE_ID_TO_NAME = {
|
|
34
|
+
GameModes.STAGE_SELECT: "Stage Select",
|
|
35
|
+
GameModes.STORY_MODE: "Story Mode",
|
|
36
|
+
GameModes.MISSION_MODE: "Mission Mode",
|
|
37
|
+
GameModes.TAG_MODE: "Tag Mode",
|
|
38
|
+
GameModes.EMERALD_CHASE: "Emerald Chase",
|
|
39
|
+
GameModes.BATTLE_MODE: "Battle Mode",
|
|
40
|
+
GameModes.TIME_TRIAL: "Time Trial",
|
|
41
|
+
GameModes.FREE_RACE: "Free Race",
|
|
42
|
+
GameModes.WORLD_GRAND_PRIX: "World Grand Prix",
|
|
43
|
+
GameModes.UNK_MODE: "Unknown Mode",
|
|
44
|
+
GameModes.CUTSCENE_MODE: "In a Cutscene",
|
|
45
|
+
GameModes.MAIN_MENU_MODE: "Main Menu"
|
|
46
|
+
}
|
|
47
|
+
ALL_MODES = list(MODE_ID_TO_NAME.keys())
|
|
48
|
+
|
|
49
|
+
class ExitMethod(IntEnum):
|
|
50
|
+
Quit = 1,
|
|
51
|
+
Retry = 2
|
|
52
|
+
|
|
53
|
+
class RaceState(IntEnum):
|
|
54
|
+
Init = 0,
|
|
55
|
+
OpeningCutscene = 1,
|
|
56
|
+
Countdown = 2,
|
|
57
|
+
Active = 3,
|
|
58
|
+
End = 4
|
|
59
|
+
|
|
60
|
+
RACESTATE_ID_TO_NAME = {
|
|
61
|
+
RaceState.Init: "Initializing race",
|
|
62
|
+
RaceState.OpeningCutscene: "Starting race",
|
|
63
|
+
RaceState.Countdown: "Race Countdown",
|
|
64
|
+
RaceState.Active: "In an active race",
|
|
65
|
+
RaceState.End: "Race finished"
|
|
66
|
+
}
|
|
67
|
+
ALL_RACESTATES = list(RACESTATE_ID_TO_NAME.keys())
|
|
68
|
+
|
|
69
|
+
# TODO: Map this to data addresses properly so that modifying an instance of the rules will modify the game memory
|
|
70
|
+
@dataclasses.dataclass
|
|
71
|
+
class RuleSettings:
|
|
72
|
+
unk31: bool
|
|
73
|
+
unk30: bool
|
|
74
|
+
unk29: bool
|
|
75
|
+
unk28: bool
|
|
76
|
+
unk27: bool
|
|
77
|
+
announcer: bool
|
|
78
|
+
unk25: bool
|
|
79
|
+
unk24: bool
|
|
80
|
+
unk23: bool
|
|
81
|
+
unk22: bool
|
|
82
|
+
cpu_racers: bool
|
|
83
|
+
unk20: bool
|
|
84
|
+
disable_retire: bool
|
|
85
|
+
unk18: bool
|
|
86
|
+
unk17: bool
|
|
87
|
+
unk16: bool
|
|
88
|
+
unk15: bool
|
|
89
|
+
unk14: bool
|
|
90
|
+
unk13: bool
|
|
91
|
+
unk12: bool
|
|
92
|
+
unk11: bool
|
|
93
|
+
air_pits: bool
|
|
94
|
+
items: bool
|
|
95
|
+
japanese_voices: bool
|
|
96
|
+
unk7: bool
|
|
97
|
+
max_lap: int
|
|
98
|
+
pass
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from enum import IntFlag
|
|
2
|
+
|
|
3
|
+
GEAR_INVALID = 255
|
|
4
|
+
GEAR_DEFAULT = 0
|
|
5
|
+
GEAR_HIGH_BOOSTER = 1
|
|
6
|
+
GEAR_AUTO_SLIDER = 2
|
|
7
|
+
GEAR_POWERFUL = 3
|
|
8
|
+
GEAR_FASTEST = 4
|
|
9
|
+
GEAR_TURBO_STAR = 5
|
|
10
|
+
GEAR_SPEED_BALANCER = 6
|
|
11
|
+
GEAR_BLUE_STAR_II = 7
|
|
12
|
+
GEAR_ACCESS = 8
|
|
13
|
+
GEAR_BEGINNER = 9
|
|
14
|
+
GEAR_ACCELERATOR = 10
|
|
15
|
+
GEAR_TRAP = 11
|
|
16
|
+
GEAR_LIGHT_BOARD = 12
|
|
17
|
+
GEAR_SLIDE_BOOSTER = 13
|
|
18
|
+
GEAR_LEGEND = 14
|
|
19
|
+
GEAR_MAGIC_CARPET = 15
|
|
20
|
+
GEAR_AIR_BROOM = 16
|
|
21
|
+
GEAR_HOVERCRAFT = 17
|
|
22
|
+
GEAR_CHAOS_EMERALD = 18
|
|
23
|
+
GEAR_FASTER = 19
|
|
24
|
+
GEAR_GAMBLER = 20
|
|
25
|
+
GEAR_POWER = 21
|
|
26
|
+
GEAR_OPA_OPA = 22
|
|
27
|
+
GEAR_CRAZY = 23
|
|
28
|
+
GEAR_BERSERKER = 24
|
|
29
|
+
GEAR_E_RIDER = 25 # Eggman Default Gear (vanilla)
|
|
30
|
+
GEAR_AIR_TANK = 26
|
|
31
|
+
GEAR_HEAVY_BIKE = 27
|
|
32
|
+
GEAR_DESTROYER = 28
|
|
33
|
+
GEAR_OMNIPOTENCE = 29
|
|
34
|
+
GEAR_COVER_S = 30
|
|
35
|
+
GEAR_COVER_F = 31
|
|
36
|
+
GEAR_COVER_P = 32
|
|
37
|
+
GEAR_HANG_ON = 33
|
|
38
|
+
GEAR_SUPER_HANG_ON = 34
|
|
39
|
+
GEAR_DARKNESS = 35 # Shadow Default Gear (vanilla)
|
|
40
|
+
GEAR_GRINDER = 36
|
|
41
|
+
GEAR_ADVANTAGE_S = 37
|
|
42
|
+
GEAR_ADVANTAGE_F = 38
|
|
43
|
+
GEAR_ADVANTAGE_P = 39
|
|
44
|
+
GEAR_CANNONBALL = 40
|
|
45
|
+
GEAR_GUN_GEAR = 41 # TE Original No. 1
|
|
46
|
+
GEAR_BOARD_70 = 42 # TE Original No. 2
|
|
47
|
+
GEAR_BITO = 43 # TE Original No. 3
|
|
48
|
+
|
|
49
|
+
GEAR_ID_TO_NAME = {
|
|
50
|
+
GEAR_INVALID: "", # This should show nothing
|
|
51
|
+
GEAR_DEFAULT: "Default Gear",
|
|
52
|
+
GEAR_HIGH_BOOSTER: "High Booster",
|
|
53
|
+
GEAR_AUTO_SLIDER: "Auto Slider",
|
|
54
|
+
GEAR_POWERFUL: "Powerful Gear",
|
|
55
|
+
GEAR_FASTEST: "Fastest",
|
|
56
|
+
GEAR_TURBO_STAR: "Turbo Star",
|
|
57
|
+
GEAR_SPEED_BALANCER: "Speed Balancer",
|
|
58
|
+
GEAR_BLUE_STAR_II: "Blue Star II",
|
|
59
|
+
GEAR_ACCESS: "Access",
|
|
60
|
+
GEAR_BEGINNER: "Beginner",
|
|
61
|
+
GEAR_ACCELERATOR: "Accelerator",
|
|
62
|
+
GEAR_TRAP: "Trap Gear",
|
|
63
|
+
GEAR_LIGHT_BOARD: "Light Board",
|
|
64
|
+
GEAR_SLIDE_BOOSTER: "Slide Booster",
|
|
65
|
+
GEAR_LEGEND: "Legend",
|
|
66
|
+
GEAR_MAGIC_CARPET: "Magic Carpet",
|
|
67
|
+
GEAR_AIR_BROOM: "Air Broom",
|
|
68
|
+
GEAR_HOVERCRAFT: "Hovercraft",
|
|
69
|
+
GEAR_CHAOS_EMERALD: "Chaos Emeralds",
|
|
70
|
+
GEAR_FASTER: "Faster",
|
|
71
|
+
GEAR_GAMBLER: "Gambler",
|
|
72
|
+
GEAR_POWER: "Power Gear",
|
|
73
|
+
GEAR_OPA_OPA: "Opa Opa",
|
|
74
|
+
GEAR_CRAZY: "The Crazy",
|
|
75
|
+
GEAR_BERSERKER: "Berserker",
|
|
76
|
+
GEAR_E_RIDER: "E-Rider",
|
|
77
|
+
GEAR_AIR_TANK: "Air Tank",
|
|
78
|
+
GEAR_HEAVY_BIKE: "Heavy Bike",
|
|
79
|
+
GEAR_DESTROYER: "Destroyer",
|
|
80
|
+
GEAR_OMNIPOTENCE: "Omnipotence",
|
|
81
|
+
GEAR_COVER_S: "Cover-S",
|
|
82
|
+
GEAR_COVER_F: "Cover-F",
|
|
83
|
+
GEAR_COVER_P: "Cover-P",
|
|
84
|
+
GEAR_HANG_ON: "Hang-On",
|
|
85
|
+
GEAR_SUPER_HANG_ON: "Super Hang-On",
|
|
86
|
+
GEAR_DARKNESS: "Darkness",
|
|
87
|
+
GEAR_GRINDER: "Grinder",
|
|
88
|
+
GEAR_ADVANTAGE_S: "Advantage-S",
|
|
89
|
+
GEAR_ADVANTAGE_F: "Advantage-F",
|
|
90
|
+
GEAR_ADVANTAGE_P: "Advantage-P",
|
|
91
|
+
GEAR_CANNONBALL: "Cannonball",
|
|
92
|
+
GEAR_GUN_GEAR: "Gun Gear",
|
|
93
|
+
GEAR_BOARD_70: "Board '70",
|
|
94
|
+
GEAR_BITO: "Bito"
|
|
95
|
+
}
|
|
96
|
+
ALL_GEARS = list(GEAR_ID_TO_NAME.keys())
|
|
97
|
+
|
|
98
|
+
# Based off TE's version.
|
|
99
|
+
# DX unfortunately has reworked some of them, so their behavior may be unknown. Sorry.
|
|
100
|
+
class SpecialFlags(IntFlag):
|
|
101
|
+
noSpecialFlags = 0,
|
|
102
|
+
alwaysIgnoreTurbulence = 1 << 0,
|
|
103
|
+
legendEffect = 1 << 1,
|
|
104
|
+
alwaysOnIce = 1 << 2,
|
|
105
|
+
unk = 1 << 3,
|
|
106
|
+
noBoosting = 1 << 4,
|
|
107
|
+
autoDrift = 1 << 5,
|
|
108
|
+
noSpeedLossUphill = 1 << 6,
|
|
109
|
+
tornadoBoost = 1 << 7,
|
|
110
|
+
noSpeedLossChargingJump = 1 << 8,
|
|
111
|
+
firstPlaceDoubleRings = 1 << 9,
|
|
112
|
+
ringGear = 1 << 10,
|
|
113
|
+
disableAttacks = 1 << 11,
|
|
114
|
+
berserkerEffect = 1 << 12,
|
|
115
|
+
noTypeShortcuts = 1 << 13,
|
|
116
|
+
noPits = 1 << 14,
|
|
117
|
+
thirtyPercentAir = 1 << 15,
|
|
118
|
+
fiftyPercentAir = 1 << 16,
|
|
119
|
+
iceImmunity = 1 << 17,
|
|
120
|
+
lightBoardEffect = 1 << 18,
|
|
121
|
+
stickyFingers = 1 << 19,
|
|
122
|
+
# custom
|
|
123
|
+
lowBoost = 1 << 20,
|
|
124
|
+
lowerDecel = 1 << 21,
|
|
125
|
+
noBoostChain = 1 << 22,
|
|
126
|
+
noSpeedLossTurning = 1 << 23,
|
|
127
|
+
ignoreOffroad = 1 << 24,
|
|
128
|
+
moneyCrisis = 1 << 25,
|
|
129
|
+
noBoostSpeedBoostChain = 1 << 26
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Created by Exortile for SRTE's recompilation workflow
|
|
2
|
+
# Repurposed to read in symbols and add it to the object database of an instantiated object in this package
|
|
3
|
+
|
|
4
|
+
import io, sys, os
|
|
5
|
+
|
|
6
|
+
# parse_map allow these to be fully read in the symbol entry section
|
|
7
|
+
allowed_sections = {
|
|
8
|
+
".init": True,
|
|
9
|
+
".text": True,
|
|
10
|
+
".fini": True,
|
|
11
|
+
".rodata": True,
|
|
12
|
+
".data": True,
|
|
13
|
+
".sdata": True,
|
|
14
|
+
".sdata2": True,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# .bss must be allowed to find the player list.
|
|
18
|
+
# condition: if '*(.bss)' in linelist[0] or line
|
|
19
|
+
|
|
20
|
+
# add known symbols we want to be able to modify with our py package
|
|
21
|
+
# or, just all symbols honestly
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def parse_map(mapfile: io.TextIOWrapper, dolphinmapfile: io.TextIOWrapper, start_address: int):
|
|
25
|
+
is_section_allowed = False
|
|
26
|
+
memory_map_found = False
|
|
27
|
+
|
|
28
|
+
line = mapfile.readline()
|
|
29
|
+
|
|
30
|
+
while line:
|
|
31
|
+
line = line.strip()
|
|
32
|
+
if line == "Linker script and memory map":
|
|
33
|
+
memory_map_found = True
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
line = mapfile.readline()
|
|
37
|
+
|
|
38
|
+
if not memory_map_found:
|
|
39
|
+
raise Exception("No memory map found.")
|
|
40
|
+
|
|
41
|
+
line = mapfile.readline()
|
|
42
|
+
|
|
43
|
+
while line:
|
|
44
|
+
linelist = line.split()
|
|
45
|
+
|
|
46
|
+
# change to new section
|
|
47
|
+
if line[:1] == ".":
|
|
48
|
+
is_section_allowed = allowed_sections.get(linelist[0], False)
|
|
49
|
+
|
|
50
|
+
if is_section_allowed:
|
|
51
|
+
# write out new section header
|
|
52
|
+
section_header = "{} section layout\n".format(linelist[0])
|
|
53
|
+
dolphinmapfile.write(section_header)
|
|
54
|
+
|
|
55
|
+
elif is_section_allowed:
|
|
56
|
+
if len(linelist) == 2:
|
|
57
|
+
|
|
58
|
+
# symbol entry
|
|
59
|
+
if linelist[0][:2] == "0x" and linelist[1][:2] != "0x":
|
|
60
|
+
address = int(linelist[0], 16)
|
|
61
|
+
address += start_address
|
|
62
|
+
address = hex(address)[2:]
|
|
63
|
+
symbol_entry = "{} {}\n".format(address, linelist[1])
|
|
64
|
+
dolphinmapfile.write(symbol_entry)
|
|
65
|
+
# print(symbol_entry)
|
|
66
|
+
# Here, it writes the symbols needed for the map file. We can intercept here and compare for known symbols.
|
|
67
|
+
# Text.s enters this, so we know this is an allowed section.
|
|
68
|
+
# Goes up to 0x80434af0
|
|
69
|
+
|
|
70
|
+
# Here, we gather what symbols are.
|
|
71
|
+
# in *(.bss) exists players. Get it from linelist[1]
|
|
72
|
+
if len(linelist) > 1 and linelist[1] == "players":
|
|
73
|
+
# Store address and name it in our config/constants for TE
|
|
74
|
+
print("Found TE player ptr list:\n" + linelist[0] + " " + linelist[1])
|
|
75
|
+
pass
|
|
76
|
+
line = mapfile.readline()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def parse_for_dol(parentdir, dolphinmapfile: io.TextIOWrapper):
|
|
80
|
+
mapfile = open(parentdir + "/main.map")
|
|
81
|
+
|
|
82
|
+
parse_map(mapfile, dolphinmapfile, 0)
|
|
83
|
+
|
|
84
|
+
mapfile.close()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def parse_for_rel(parentdir, dolphinmapfile: io.TextIOWrapper):
|
|
88
|
+
dolfile = open(parentdir + "/main.dol", "rb")
|
|
89
|
+
relfile = open(parentdir + "/_Main.rel", "rb")
|
|
90
|
+
mapfile = open(parentdir + "/_Main.map")
|
|
91
|
+
|
|
92
|
+
dolfile.seek(0xD8)
|
|
93
|
+
start_address = int.from_bytes(dolfile.read(4), 'big')
|
|
94
|
+
bss_size = int.from_bytes(dolfile.read(4), 'big')
|
|
95
|
+
|
|
96
|
+
relfile.seek(0x54)
|
|
97
|
+
code_section_start = int.from_bytes(relfile.read(4), 'big')
|
|
98
|
+
code_section_start &= ~1 # remove executable bit flag
|
|
99
|
+
start_address += (bss_size + 0x1EED40 + code_section_start)
|
|
100
|
+
|
|
101
|
+
relfile.close()
|
|
102
|
+
dolfile.close()
|
|
103
|
+
|
|
104
|
+
parse_map(mapfile, dolphinmapfile, start_address)
|
|
105
|
+
|
|
106
|
+
mapfile.close()
|
|
107
|
+
|
|
108
|
+
# This is where parsing starts. Thing is, we have to set a directory for the map here
|
|
109
|
+
# I don't know how we'd do that for ALL instances when we make this a package.
|
|
110
|
+
# So, figure that out in the future, future me.
|
|
111
|
+
|
|
112
|
+
buildDir = "../build"
|
|
113
|
+
if len(sys.argv) > 1:
|
|
114
|
+
buildDir = sys.argv[1]
|
|
115
|
+
buildDir = os.path.normpath(buildDir)
|
|
116
|
+
|
|
117
|
+
dolphinMapFile = open("GXSRTE.map", "w")
|
|
118
|
+
|
|
119
|
+
dolphinMapFile.write("-- main.dol memory map --\n\n")
|
|
120
|
+
parse_for_dol(buildDir, dolphinMapFile)
|
|
121
|
+
|
|
122
|
+
# dolphinMapFile.write("\n-- _Main.rel memory map --\n\n")
|
|
123
|
+
# parse_for_rel(buildDir, dolphinMapFile)
|
|
124
|
+
|
|
125
|
+
dolphinMapFile.close()
|
|
126
|
+
|
|
127
|
+
def read_for_files(pathToMap):
|
|
128
|
+
# buildDir = "../build" # not needed anymore
|
|
129
|
+
# if len(sys.argv) > 1:
|
|
130
|
+
buildDir = pathToMap # User MUST send in a path to their map file. This might cause a problem with distribution... ugh.
|
|
131
|
+
buildDir = os.path.normpath(buildDir)
|
|
132
|
+
|
|
133
|
+
dolphinMapFile = open("GXSRTE.map", "w")
|
|
134
|
+
|
|
135
|
+
dolphinMapFile.write("-- main.dol memory map --\n\n")
|
|
136
|
+
parse_for_dol(buildDir, dolphinMapFile)
|
|
137
|
+
|
|
138
|
+
# dolphinMapFile.write("\n-- _Main.rel memory map --\n\n")
|
|
139
|
+
# parse_for_rel(buildDir, dolphinMapFile)
|
|
140
|
+
|
|
141
|
+
dolphinMapFile.close()
|
|
142
|
+
pass
|
|
143
|
+
|