Skip to content

Commit 8b9e6f3

Browse files
committed
Duck Dodgers Module
1 parent 9e9e8f6 commit 8b9e6f3

3 files changed

Lines changed: 115 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ A collection of Lua scripts and RAM watches for [BizHawk](https://github.com/TAS
129129
- Wonder Boy in Monster World (SMS)
130130

131131
## Partially Supported Games
132+
- Duck Dodgers Starring Daffy Duck
132133
- Elmo's Number Journey (N64 only)
133134
- Elmo's Letter Adventure (N64 only)
134135
- Legend of Galahad (Genesis)

ScriptHawk.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ local supportedGames = {
440440
["C1058CC2482B91204100CC8515DA99AEB06773F5"] = {moduleName="games.GBA_DrillDozer", friendlyName="Drill Dozer (USA)", version=1},
441441
["84AFA7108E4D604E7B1A6D105DF5760869A247FA"] = {moduleName="games.GBA_DrillDozer", friendlyName="Screw Breaker Goushin Dorirurero (Japan)", version=2},
442442

443+
-- Duck Dodgers
444+
["2C840E2991D6A2AF63C4EFE830240FC49D93FC9A"] = {moduleName="games.duck_dodgers", friendlyName="Duck Dodgers Starring Daffy Duck (USA) (En,Fr,Es)"},
445+
443446
-- Earthworm Jim 3D
444447
["EAB14F23640CD6148D4888902CDCC00DD6111BF9"] = {moduleName="games.ej3d", friendlyName="Earthworm Jim 3D (USA)", version=1},
445448
["F02C1AFD18C1CBE309472CBE5B3B3F04B22DB7EE"] = {moduleName="games.ej3d", friendlyName="Earthworm Jim 3D (Europe) (En,Fr,De,Es,It)", version=2},

games/duck_dodgers.lua

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
speedy_speeds = { .001, .01, .1, .2, .3, .5, .75, 1, 5 },
10+
speedy_index = 5,
11+
speedy_invert_xz = true,
12+
max_rot_units = 360,
13+
Memory = {
14+
x_position = 0x1CFF64, -- Float
15+
y_position = 0x1CFF6C, -- Float
16+
z_position = 0x1CFF68, -- Float
17+
x_velocity = 0x1CFED4, -- Float
18+
y_velocity = 0x1CFEDC, -- Float
19+
z_velocity = 0x1CFED8, -- Float
20+
rot_sine = 0x1CFF34, -- TODO: This rotation stuff is kinda borked still, just copy pasted from the Rayman 2 module, figure it out properly
21+
--rot_sine_mirror = 0x1CFF38,
22+
rot_cosine = 0x1CFF44,
23+
--rot_cosine_inverse = 0x1CFF48,
24+
},
25+
};
26+
27+
function Game.getXPosition()
28+
return mainmemory.readfloat(Game.Memory.x_position, true);
29+
end
30+
31+
function Game.setXPosition(value)
32+
mainmemory.writefloat(Game.Memory.x_position, value, true);
33+
end
34+
35+
function Game.getYPosition()
36+
return mainmemory.readfloat(Game.Memory.y_position, true);
37+
end
38+
39+
function Game.setYPosition(value)
40+
mainmemory.writefloat(Game.Memory.y_position, value, true);
41+
end
42+
43+
function Game.getZPosition()
44+
return mainmemory.readfloat(Game.Memory.z_position, true);
45+
end
46+
47+
function Game.setZPosition(value)
48+
mainmemory.writefloat(Game.Memory.z_position, value, true);
49+
end
50+
51+
function Game.getXVelocity()
52+
return mainmemory.readfloat(Game.Memory.x_velocity, true);
53+
end
54+
55+
function Game.getYVelocity()
56+
return mainmemory.readfloat(Game.Memory.y_velocity, true);
57+
end
58+
59+
function Game.getZVelocity()
60+
return mainmemory.readfloat(Game.Memory.z_velocity, true);
61+
end
62+
63+
function Game.getVelocity() -- Calculated VXZ
64+
local vX = Game.getXVelocity();
65+
local vZ = Game.getZVelocity();
66+
return math.sqrt(vX*vX + vZ*vZ);
67+
end
68+
69+
--------------
70+
-- Rotation --
71+
--------------
72+
73+
function Game.getYRotation()
74+
local currentSine = mainmemory.readfloat(Game.Memory.rot_sine, true);
75+
local currentCosine = mainmemory.readfloat(Game.Memory.rot_cosine, true);
76+
if currentSine > 0 then
77+
return math.deg(math.acos(currentCosine));
78+
end
79+
return 360 - math.deg(math.acos(currentCosine));
80+
end
81+
82+
function Game.setYRotation(value)
83+
local sineValue = math.sin(math.rad(value));
84+
local cosineValue = math.cos(math.rad(value));
85+
86+
-- Set the sine values
87+
mainmemory.writefloat(Game.Memory.rot_sine, sineValue, true);
88+
--mainmemory.writefloat(Game.Memory.rot_sine_mirror, sineValue, true);
89+
90+
-- Set the cosine values
91+
mainmemory.writefloat(Game.Memory.rot_cosine, cosineValue, true);
92+
--mainmemory.writefloat(Game.Memory.rot_cosine_inverse, cosineValue * -1, true);
93+
end
94+
95+
Game.OSD = {
96+
{"X"},
97+
{"Y"},
98+
{"Z"},
99+
{"Separator"},
100+
--{"X Velocity", Game.getXVelocity},
101+
{"Y Velocity", Game.getYVelocity},
102+
--{"Z Velocity", Game.getZVelocity},
103+
{"Velocity", Game.getVelocity},
104+
{"Separator"},
105+
{"dY"},
106+
{"dXZ"},
107+
{"Separator"},
108+
{"Facing", Game.getYRotation},
109+
};
110+
111+
return Game;

0 commit comments

Comments
 (0)