mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-04 08:21:40 -04:00
a9ce423bdc
CLOSES #1275, CLOSES #1295, CLOSES #1384, CLOSES #1628, CLOSES #1677, CLOSES #1682, CLOSES #1691, CLOSES #1813, CLOSES #1822, CLOSES #1861, CLOSES #1867, CLOSES #1868, CLOSES #1869, CLOSES #1870, CLOSES #1871, CLOSES #1872, CLOSES #1874, CLOSES #1876, CLOSES #1878, CLOSES #1880, CLOSES #1881, CLOSES #1882, CLOSES #1884, CLOSES #1885, CLOSES #1886, CLOSES #1887, CLOSES #1888, CLOSES #1889, CLOSES #1890, CLOSES #1891, CLOSES #1892, CLOSES #1893, CLOSES #1894, CLOSES #1895, CLOSES #1896, CLOSES #1899, CLOSES #1900, CLOSES #1901
44 lines
1.2 KiB
Lua
44 lines
1.2 KiB
Lua
-- home/joypad2.asm:16-53 JoypadLowSensitivity (hJoy7 = 1, 30 then 5)
|
|
-- pokegold home/joypad.asm:313-340 JoyTextDelay (hInMenu, 15 then 5)
|
|
|
|
local MenuRepeat = {}
|
|
|
|
MenuRepeat.GEN1_DELAY, MenuRepeat.GEN1_RATE = 30, 5
|
|
MenuRepeat.GEN2_DELAY, MenuRepeat.GEN2_RATE = 15, 5
|
|
|
|
local ALL_DIRS = { "up", "down", "left", "right" }
|
|
|
|
function MenuRepeat.new(delay, rate, enabled)
|
|
return {
|
|
delay = tonumber(delay) or MenuRepeat.GEN1_DELAY,
|
|
rate = math.max(1, tonumber(rate) or MenuRepeat.GEN1_RATE),
|
|
enabled = enabled ~= false,
|
|
dir = nil,
|
|
frames = 0,
|
|
}
|
|
end
|
|
|
|
function MenuRepeat.reset(state)
|
|
state.dir, state.frames = nil, 0
|
|
end
|
|
|
|
function MenuRepeat.direction(state, input, dirs)
|
|
for _, dir in ipairs(dirs or ALL_DIRS) do
|
|
if input:wasPressed(dir) then
|
|
state.dir, state.frames = dir, 0
|
|
return dir, true
|
|
end
|
|
end
|
|
local dir = state.dir
|
|
if not (dir and state.enabled and input.isDown and input:isDown(dir)) then
|
|
MenuRepeat.reset(state)
|
|
return nil, false
|
|
end
|
|
state.frames = state.frames + 1
|
|
local afterDelay = state.frames - state.delay
|
|
if afterDelay >= 0 and afterDelay % state.rate == 0 then return dir, false end
|
|
return nil, false
|
|
end
|
|
|
|
return MenuRepeat
|