Skip to content

Commit 069fefa

Browse files
authoredNov 12, 2020
Merge pull request #53 from little512/master
add support for Kirby Air Ride, Twilight Princess
2 parents b842730 + fbb812f commit 069fefa

File tree

7 files changed

+140
-2
lines changed

7 files changed

+140
-2
lines changed
 

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Latest downloads can be found in [releases](https://github.com/bkacjios/m-overla
1414
* Need for Speed Underground 1 (NTSC v1.0)
1515
* Need for Speed Underground 2 (NTSC v1.0)
1616
* The Legend of Zelda: The Wind Waker (NTSC v1.0)
17-
* The Legend of Zelda: Twilight Princess (GC NTSC v1.0, Wii NTSC v1.0)
17+
* The Legend of Zelda: Twilight Princess (GC NTSC v1.0, PAL v1.0, Wii NTSC v1.0)
1818
* Luigi's Mansion (NTSC v1.0)
1919
* Metroid Prime (NTSC v1.0, NTSC v1.2)
2020
* Metroid Prime 2 - Echoes (NTSC v1.0, [Randomizer](https://github.com/randovania/randovania))
@@ -27,6 +27,7 @@ Latest downloads can be found in [releases](https://github.com/bkacjios/m-overla
2727
* Super Smash Bros. Melee (NTSC v1.2, PAL, [20XX](https://smashboards.com/threads/the-20xx-melee-training-hack-pack-v4-07-7-04-17.351221/), [UnclePunch Training Mode](https://github.com/UnclePunch/Training-Mode), [Slippi](https://slippi.gg))
2828
* Super Smash Bros. Brawl (NTSC v1.0, NTSC v1.1, NTSC v1.2, [Project M](https://en.wikipedia.org/wiki/Project_M), [P+](https://projectplusgame.com/))
2929
* The SpongeBob SquarePants Movie (NTSC v1.1, PAL v1.0)
30+
* Kirby Air Ride (NTSC-U v1.0, NTSC-J v1.0, [UnclePunch Hack Pack](https://www.kirbyairri.de/hpinfo.html))
3031

3132
*More games can be supported upon request!*
3233

‎source/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function love.drawControllerOverlay()
423423
if controller then
424424
-- Draw Joystick
425425

426-
if controller.plugged and controller.plugged ~= 0x00 then
426+
if controller.plugged and controller.plugged ~= (memory.isKirbyAirRide() and 0x01 or 0x00) then
427427
local sin = 128 + math.sin(love.timer.getTime()*2) * 128
428428
graphics.setColor(255, 0, 0, sin)
429429
graphics.easyDraw(DC_CON, 512-42-16, 256-42-16, 0, 42, 42)

‎source/modules/games/GKYE01-0.lua

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- Kirby Air Ride (NTSC 1.0)
2+
3+
local game = {
4+
memorymap = {}
5+
}
6+
7+
local addr = 0x8058B0E4
8+
local off = 0x44
9+
10+
local controllers = {
11+
[1] = addr + off * 0,
12+
[2] = addr + off * 1,
13+
[3] = addr + off * 2,
14+
[4] = addr + off * 3,
15+
}
16+
17+
-- Notably similar addresses to Melee, which makes sense since both games are made by HAL.
18+
local controller_struct = {
19+
[0x00] = { type = "int", name = "controller.%d.buttons.pressed" },
20+
[0x20] = { type = "float", name = "controller.%d.joystick.x" },
21+
[0x24] = { type = "float", name = "controller.%d.joystick.y" },
22+
[0x28] = { type = "float", name = "controller.%d.cstick.x" },
23+
[0x2C] = { type = "float", name = "controller.%d.cstick.y" },
24+
[0x30] = { type = "float", name = "controller.%d.analog.l" },
25+
[0x34] = { type = "float", name = "controller.%d.analog.r" },
26+
[0x41] = { type = "byte", name = "controller.%d.plugged" },
27+
28+
-- A note about plugged:
29+
-- Byte 0x41 of each controller is set from 0x00 to 0x01 only after the
30+
-- controller has been plugged in or the game was started with the
31+
-- controller plugged in, however, the overlay does not seem to
32+
-- detect this behavior, therefore showing all controllers regardless
33+
-- of memory status as unplugged.
34+
35+
-- Melee has a similar issue, but instead of setting byte 0x41 to 0x01,
36+
-- it starts as 0xFF and gets set to 0x00.
37+
38+
-- I've fixed this issue by detecting whether or not the current game is
39+
-- Kirby Air Ride and changing the number to compare against from 0x00 to
40+
-- 0x01 for Kirby Air Ride only.
41+
}
42+
43+
for port, address in ipairs(controllers) do
44+
for offset, info in pairs(controller_struct) do
45+
game.memorymap[address + offset] = {
46+
type = info.type,
47+
debug = info.debug,
48+
name = info.name:format(port),
49+
}
50+
end
51+
end
52+
53+
game.translateAxis = function(x, y) return x, y end
54+
game.translateTriggers = function(l, r) return l, r end
55+
56+
return game

‎source/modules/games/GKYJ01-0.lua

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- Kirby's Airride (NTSC-J v1.0)
2+
3+
local game = {
4+
memorymap = {}
5+
}
6+
7+
local addr = 0x80585B64
8+
local off = 0x44
9+
10+
local controllers = {
11+
[1] = addr + off * 0,
12+
[2] = addr + off * 1,
13+
[3] = addr + off * 2,
14+
[4] = addr + off * 3,
15+
}
16+
17+
-- Notably similar addresses to Melee, which makes sense since both games are made by HAL.
18+
local controller_struct = {
19+
[0x00] = { type = "int", name = "controller.%d.buttons.pressed" },
20+
[0x20] = { type = "float", name = "controller.%d.joystick.x" },
21+
[0x24] = { type = "float", name = "controller.%d.joystick.y" },
22+
[0x28] = { type = "float", name = "controller.%d.cstick.x" },
23+
[0x2C] = { type = "float", name = "controller.%d.cstick.y" },
24+
[0x30] = { type = "float", name = "controller.%d.analog.l" },
25+
[0x34] = { type = "float", name = "controller.%d.analog.r" },
26+
[0x41] = { type = "byte", name = "controller.%d.plugged" },
27+
28+
-- A note about plugged:
29+
-- Byte 0x41 of each controller is set from 0x00 to 0x01 only after the
30+
-- controller has been plugged in or the game was started with the
31+
-- controller plugged in, however, the overlay does not seem to
32+
-- detect this behavior, therefore showing all controllers regardless
33+
-- of memory status as unplugged.
34+
35+
-- Melee has a similar issue, but instead of setting byte 0x41 to 0x01,
36+
-- it starts as 0xFF and gets set to 0x00.
37+
38+
-- I've fixed this issue by detecting whether or not the current game is
39+
-- Kirby Air Ride and changing the number to compare against from 0x00 to
40+
-- 0x01 for Kirby Air Ride only.
41+
}
42+
43+
for port, address in ipairs(controllers) do
44+
for offset, info in pairs(controller_struct) do
45+
game.memorymap[address + offset] = {
46+
type = info.type,
47+
debug = info.debug,
48+
name = info.name:format(port),
49+
}
50+
end
51+
end
52+
53+
game.translateAxis = function(x, y) return x, y end
54+
game.translateTriggers = function(l, r) return l, r end
55+
56+
return game

‎source/modules/games/GZ2P01-0.lua

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- The Legend of Zelda - Twilight Princess (PAL v1.0)
2+
3+
-- The motivation behind adding PAL version support is that most
4+
-- speedrunners run on the PAL version of the game, since German
5+
-- is the fastest language.
6+
7+
local core = require("games.core")
8+
9+
local game = {
10+
memorymap = {}
11+
}
12+
13+
core.loadGenericControllerMap(0x804363B0, game)
14+
15+
return game

‎source/modules/games/clones.lua

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ return {
88
["SDRE32"] = { id = "GALE01", version = 2 }, -- SSBM SD Remix
99
["RSBE01"] = { id = "RSBE01", version = 2 }, -- Super Smash Bros. Brawl
1010
["G2ME0R"] = { id = "G2ME01", version = 0 }, -- Metroid Prime 2: Echoes Randomizer
11+
["KHPE01"] = { id = "GKYE01", version = 0 }, -- Kirby Air Ride Hack Pack
1112
}

‎source/modules/memory/init.lua

+9
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ function watcher.isMelee()
333333
return gid == "GALE01"
334334
end
335335

336+
function watcher.isKirbyAirRide()
337+
local gid = watcher.gameid
338+
339+
local clone = clones[gid]
340+
if clone then gid = clone.id end
341+
342+
return (gid == "GKYE01" or gid == "GKYJ01")
343+
end
344+
336345
function watcher.runhooks()
337346
local pop
338347
while true do

0 commit comments

Comments
 (0)
Please sign in to comment.