Skip to content

Commit 2c396f7

Browse files
committed
Started Brother Bear Module
Started Module for "Brother Bear" (GBA)
1 parent 1cecbdc commit 2c396f7

2 files changed

Lines changed: 188 additions & 0 deletions

File tree

ScriptHawk.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ local supportedGames = {
388388
["93BF2FAC1387320AD07251CB4B64FD36BAC1D7A6"] = {moduleName="games.bt", friendlyName="Banjo-Tooie (Europe) (En,Fr,De,Es)", version=2},
389389
["AF1A89E12B638B8D82CC4C085C8E01D4CBA03FB3"] = {moduleName="games.bt", friendlyName="Banjo-Tooie (USA)", version=4},
390390

391+
-- Brother Bear (GBA)
392+
["89E6903500F62E11483402B76C1454AF788646C0"] = {moduleName="games.GBA_brother_bear", friendlyName="Brother Bear (USA)", version=1},
393+
394+
391395
-- Conker's Bad Fur Day
392396
["EE7BC6656FD1E1D9FFB3D19ADD759F28B88DF710"] = {moduleName="games.cbfd", friendlyName="Conker's Bad Fur Day (Europe)", version=1},
393397
["4CBADD3C4E0729DEC46AF64AD018050EADA4F47A"] = {moduleName="games.cbfd", friendlyName="Conker's Bad Fur Day (USA)", version=2},

games/GBA_brother_bear.lua

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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+
pos_ptr = {Domain = "IWRAM", Address = 0x7A40},
11+
--pos_ptr = {Domain = "IWRAM", Address = 0x7A44},
12+
--player_ptr = {Domain="EWRAM", Address=0x47EC},
13+
--object_array_size = {Domain="IWRAM", Address=0x16F8},
14+
--object_list_ptr = {Domain="IWRAM", Address=0x14A0},
15+
--rangCount = {Domain="IWRAM", Address=0xB06},
16+
--player_ptr = {Domain="EWRAM", Address={0x5B08}}, -- May be better?
17+
},
18+
};
19+
20+
local script_modes = {
21+
"Disabled",
22+
--"List",
23+
--"Examine",
24+
};
25+
26+
local script_mode_index = 1;
27+
local script_mode = script_modes[script_mode_index];
28+
29+
--------------------
30+
-- Region/Version --
31+
--------------------
32+
33+
--local player_struct = {
34+
-- [0xC] = {type="s32_le", name="XPosition"},
35+
-- [0x10] = {type="s32_le", name="YPosition"},
36+
-- [0x18] = {type="s32_le", name="XVelocity"},
37+
-- [0x1C] = {type="s32_le", name="YVelocity"},
38+
-- [0x74] = {type="u32_le", name="1st Glide"},
39+
--};
40+
41+
function Game.detectVersion(romName, romHash)
42+
ScriptHawk.dpad.joypad.enabled = false;
43+
ScriptHawk.dpad.key.enabled = false;
44+
return true;
45+
end
46+
47+
local function parsePointer(inPtr)
48+
if (inPtr >= 0x02000000) and (inPtr < 0x02040000) then
49+
return {
50+
Domain = "EWRAM",
51+
Address = inPtr - 0x02000000,
52+
};
53+
elseif (inPtr>= 0x03000000) and (inPtr < 0x03008000) then
54+
return {
55+
Domain = "IWRAM",
56+
Address = inPtr - 0x03000000,
57+
};
58+
end
59+
end
60+
61+
function dereferencePointer(inPtr)
62+
return parsePointer(memory.read_u32_le(inPtr.Address, inPtr.Domain));
63+
end
64+
65+
-------------------
66+
-- Physics/Scale --
67+
-------------------
68+
69+
--function Game.getPlayer()
70+
-- return dereferencePointer(Game.Memory.player_ptr);
71+
--end
72+
73+
-- local movementStates = {
74+
-- [0x00] = "Idle",
75+
-- [0x01] = "Run",
76+
-- [0x02] = "Jump",
77+
-- [0x03] = "Fall",
78+
-- [0x04] = "Glide",
79+
-- [0x05] = "Rang Throw",
80+
-- [0x06] = "Damaged",
81+
-- [0x07] = "Run Skid",
82+
-- [0x09] = "Run Start",
83+
-- [0x0A] = "Landing",
84+
-- [0x0C] = "Bite",
85+
-- [0x0D] = "Interacting",
86+
-- [0x10] = "Fast Falling",
87+
-- [0x11] = "Fall Damage",
88+
-- [0x15] = "Platform Drop Through",
89+
-- [0x17] = "Looking",
90+
-- [0X19] = "Arial Bite",
91+
--};
92+
93+
-- function Game.getState()
94+
-- local player = Game.getPlayer();
95+
-- if player ~= nil then
96+
-- local currentMovementState = memory.read_u8(player.Address + 0x5D, player.Domain);
97+
-- --local direction = memory.read_u8_le(player.Address + 0x16, player.Domain);
98+
-- return movementStates[currentMovementState] or "Unknown ("..currentMovementState..")";
99+
-- end
100+
-- end
101+
102+
--------------
103+
-- Position --
104+
--------------
105+
106+
function Game.getXPosition()
107+
local posInfo = dereferencePointer(Game.Memory.pos_ptr)
108+
if posInfo ~= nil then
109+
return memory.read_s32_le(posInfo.Address + 0x04, posInfo.Domain);
110+
end
111+
return 0
112+
end
113+
114+
function Game.getYPosition()
115+
local posInfo = dereferencePointer(Game.Memory.pos_ptr)
116+
if posInfo ~= nil then
117+
return memory.read_s32_le(posInfo.Address + 0x08, posInfo.Domain);
118+
end
119+
return 0
120+
end
121+
122+
--function Game.colorYVelocity()
123+
--local yVelocity = Game.getYVelocity();
124+
--if yVelocity < 0 then
125+
-- return colors.red;
126+
--end
127+
--end
128+
129+
function Game.setXPosition(value)
130+
local posInfo = dereferencePointer(Game.Memory.pos_ptr)
131+
if posInfo ~= nil then
132+
return memory.write_s32_le(posInfo.Address + 0x04, value, posInfo.Domain);
133+
end
134+
end
135+
136+
function Game.setYPosition(value)
137+
local posInfo = dereferencePointer(Game.Memory.pos_ptr)
138+
if posInfo ~= nil then
139+
return memory.write_s32_le(posInfo.Address + 0x10, value, posInfo.Domain);
140+
end
141+
end
142+
143+
--------------
144+
-- Velocity --
145+
--------------
146+
147+
--function Game.getXVelocity()
148+
--local player = Game.getPlayer();
149+
--if player ~= nil then
150+
-- return memory.read_s32_le(player.Address + 0x18, player.Domain);
151+
--end
152+
-- return 0;
153+
--end
154+
155+
--function Game.getYVelocity()
156+
--local player = Game.getPlayer();
157+
--if player ~= nil then
158+
-- return memory.read_s32_le(player.Address + 0x1C, player.Domain);
159+
--end
160+
-- return 0;
161+
--end
162+
163+
------------
164+
-- Events --
165+
------------
166+
167+
168+
Game.OSD = {
169+
--{"State", Game.getState, category="state"},
170+
{"X", category="position"},
171+
{"Y", category="position"},
172+
{"Separator"},
173+
--{"X Vel", Game.getXVelocity, category="speed"},
174+
--{"Y Vel", Game.getYVelocity, Game.colorYVelocity, category="speed"},
175+
{"dY", category="positionStats"},
176+
{"dXZ", category="positionStats"},
177+
{"Separator"},
178+
{"Max dY", category="positionStatsMore"},
179+
{"Max dXZ", category="positionStatsMore"},
180+
{"Odometer", category="positionStatsMore"},
181+
{"Separator"},
182+
};
183+
184+
return Game;

0 commit comments

Comments
 (0)