Skip to content

Commit c7e461d

Browse files
committed
init Ty3 GBA module
1 parent 158eec8 commit c7e461d

2 files changed

Lines changed: 215 additions & 0 deletions

File tree

ScriptHawk.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ local supportedGames = {
626626
-- Ty the Tasmanian Tiger 2: Bush Rescue(GBA)
627627
["84267CE3D86100688048A8D4F166FA1B2D50E6D5"] = {moduleName="games.GBA_Ty2", friendlyName="Ty the Tasmanian Tiger 2 - Bush Rescue (USA,Europe) (En,Fr,De)"},
628628

629+
-- Ty the Tasmanian Tiger 3: Night of the Quinkan(GBA)
630+
["07FAFA1C96CC039A1788D6526D52F7D3EC0BA3C3"] = {moduleName="games.GBA_Ty3", friendlyName="Ty the Tasmanian Tiger 3 - Night of the Quinkan (USA)"},
631+
629632
-- Tyrants - Fight Through Time (Mega Lo Mania)
630633
["B090D74241CD56820B568C319799412B"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [!]"},
631634
["1F7DD4DCB076E7AF7E43F01795504C4A"] = {moduleName="games.tftt", friendlyName="Tyrants - Fight Through Time (U) [!]"}, -- Bad dump?

games/GBA_Ty3.lua

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
if type(ScriptHawk) ~= "table" then
2+
print("This script is not designed to run by itself");
3+
print("Please run ScriptHawk.lua from the parent directory instead");
4+
print("Thanks for using ScriptHawk :)");
5+
return;
6+
end
7+
8+
local Game = {
9+
Memory = {
10+
player_ptr = {Domain="IWRAM", Address=0x17A4},
11+
--object_array_size = {Domain="IWRAM", Address=0x16F8},
12+
--object_list_ptr = {Domain="IWRAM", Address=0x14A0},
13+
--rangCount = {Domain="IWRAM", Address=0xB06},
14+
--player_ptr = {Domain="EWRAM", Address={0x5B08}}, -- May be better?
15+
},
16+
};
17+
18+
local script_modes = {
19+
"Disabled",
20+
-- "List",
21+
-- "Examine",
22+
};
23+
24+
local script_mode_index = 1;
25+
local script_mode = script_modes[script_mode_index];
26+
27+
--------------------
28+
-- Region/Version --
29+
--------------------
30+
31+
local player_struct = {
32+
[0xC] = {type="s32_le", name="XPosition"},
33+
[0x10] = {type="s32_le", name="YPosition"},
34+
[0x20] = {type="s32_le", name="XVelocity"},
35+
[0x24] = {type="s32_le", name="YVelocity"},
36+
[0x71] = {type="u8_le", name="State"},
37+
--[0x74] = {type="u32_le", name="1st Glide"},
38+
};
39+
40+
function Game.detectVersion(romName, romHash)
41+
ScriptHawk.dpad.joypad.enabled = false;
42+
ScriptHawk.dpad.key.enabled = false;
43+
return true;
44+
end
45+
46+
-------------------
47+
-- Physics/Scale --
48+
-------------------
49+
50+
function Game.getPlayer()
51+
return dereferencePointer(Game.Memory.player_ptr);
52+
end
53+
54+
local movementStates = {
55+
[0x00] = "Idle",
56+
[0x01] = "Run",
57+
[0x02] = "Jump",
58+
[0x03] = "Fall",
59+
[0x04] = "Glide",
60+
[0x05] = "Rang Throw",
61+
[0x06] = "Damaged",
62+
[0x07] = "Run Skid",
63+
[0x08] = "Run Start",
64+
[0x09] = "Run Accel",
65+
[0x0A] = "Landing",
66+
[0x0C] = "Bite",
67+
[0x0D] = "Interacting",
68+
[0x10] = "Fast Falling",
69+
[0x11] = "Fall Damage",
70+
[0x15] = "Platform Drop Through",
71+
[0x17] = "Looking",
72+
[0X19] = "Arial Bite",
73+
};
74+
75+
function Game.getState()
76+
local player = Game.getPlayer();
77+
if player ~= nil then
78+
local currentMovementState = memory.read_u8(player.Address + 0x71, player.Domain);
79+
-- --local direction = memory.read_u8_le(player.Address + 0x16, player.Domain);
80+
return movementStates[currentMovementState] or "Unknown ("..currentMovementState..")";
81+
end
82+
end
83+
84+
function Game.getRangCount()
85+
local player = Game.getPlayer();
86+
if player ~= nil then
87+
local rang_bit = memory.read_u16_le(player.Address + 0x122, player.Domain);
88+
local rang_cnt = bit.band(rang_bit, 0x0001) + bit.band(bit.rshift(rang_bit,1), 0x0001);
89+
return rang_cnt;
90+
end
91+
return 0;
92+
end
93+
94+
function Game.colorRangCount()
95+
local rangs = Game.getRangCount();
96+
if rangs == 0 then
97+
return colors.red;
98+
elseif rangs == 2 then
99+
return colors.green;
100+
end
101+
end
102+
103+
function Game.getGlideFlag()
104+
local player = Game.getPlayer();
105+
if player ~= nil then
106+
local glideFlag = memory.read_u8(player.Address + 0x157, player.Domain);
107+
return glideFlag ~= 0;
108+
end
109+
end
110+
111+
function Game.colorGlideFlag()
112+
local glideFlag = Game.getGlideFlag();
113+
if glideFlag == true and Game.getRangCount() == 2 then
114+
return colors.green;
115+
end
116+
end
117+
118+
--------------
119+
-- Position --
120+
--------------
121+
122+
function Game.getXPosition()
123+
local player = Game.getPlayer();
124+
if player ~= nil then
125+
return memory.read_s32_le(player.Address + 0x0C, player.Domain);
126+
end
127+
return 0
128+
end
129+
130+
function Game.getYPosition()
131+
local player = Game.getPlayer();
132+
if player ~= nil then
133+
return -memory.read_s32_le(player.Address + 0x10, player.Domain);
134+
end
135+
return 0;
136+
end
137+
138+
139+
function Game.setXPosition(value)
140+
local player = Game.getPlayer();
141+
if player ~= nil then
142+
memory.write_s32_le(player.Address + 0x0C, value, player.Domain);
143+
end
144+
end
145+
146+
function Game.setYPosition(value)
147+
local player = Game.getPlayer();
148+
if player ~= nil then
149+
memory.write_s32_le(player.Address + 0x10, value, player.Domain);
150+
end
151+
end
152+
153+
--------------
154+
-- Velocity --
155+
--------------
156+
157+
function Game.getXVelocity()
158+
local player = Game.getPlayer();
159+
if player ~= nil then
160+
return memory.read_s32_le(player.Address + 0x20, player.Domain);
161+
end
162+
return 0;
163+
end
164+
165+
function Game.getYVelocity()
166+
local player = Game.getPlayer();
167+
if player ~= nil then
168+
return memory.read_s32_le(player.Address + 0x24, player.Domain);
169+
end
170+
return 0;
171+
end
172+
173+
function Game.colorYVelocity()
174+
local yVelocity = Game.getYVelocity();
175+
if yVelocity < 0 then
176+
return colors.red;
177+
end
178+
end
179+
180+
------------
181+
-- Events --
182+
------------
183+
184+
local function toggleObjectAnalysisToolsMode()
185+
script_mode_index = script_mode_index + 1;
186+
if script_mode_index > #script_modes then
187+
script_mode_index = 1;
188+
end
189+
script_mode = script_modes[script_mode_index];
190+
end
191+
192+
193+
Game.OSD = {
194+
{"State", Game.getState, category="state"},
195+
{"Rang #", Game.getRangCount, Game.colorRangCount, category="boomerang"},
196+
{"SuperJump", Game.getGlideFlag, Game.colorGlideFlag, category="superjump"},
197+
{"X", category="position"},
198+
{"Y", category="position"},
199+
{"Separator"},
200+
{"X Vel", Game.getXVelocity, category="speed"},
201+
{"Y Vel", Game.getYVelocity, Game.colorYVelocity, category="speed"},
202+
{"dY", category="positionStats"},
203+
{"dXZ", category="positionStats"},
204+
{"Separator"},
205+
{"Max dY", category="positionStatsMore"},
206+
{"Max dXZ", category="positionStatsMore"},
207+
{"Odometer", category="positionStatsMore"},
208+
{"Separator"},
209+
};
210+
211+
212+
return Game;

0 commit comments

Comments
 (0)