Skip to content

Commit

Permalink
Laying groundwork to get music working in single player games.. Might…
Browse files Browse the repository at this point in the history
… be too big of a task.

Small code cleanups.
  • Loading branch information
bkacjios committed Aug 3, 2020
1 parent 689087f commit bc85277
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 29 deletions.
13 changes: 4 additions & 9 deletions source/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ function love.load(args, unfilteredArg)
end
end

local MENU_CSS = 0
local MENU_STAGE_SELECT = 1
local MENU_INGAME = 2
local MENU_POSTGAME_SCORES = 4

memory.hook("slippi.local_player.index", "Slippi auto port switcher", function(port)
if PANEL_SETTINGS:IsSlippiNetplay() and PANEL_SETTINGS:IsSlippiAutoPortEnabled() then
port = port % 4
Expand All @@ -121,13 +116,13 @@ memory.hook("slippi.local_player.index", "Slippi auto port switcher", function(p
end
end)

memory.hook("menu", "Slippi Auto Port Switcher", function(menu)
memory.hook("menu_minor", "Slippi Auto Port Switcher", function(menu)
if PANEL_SETTINGS:IsSlippiNetplay() and PANEL_SETTINGS:IsSlippiAutoPortEnabled() then
if menu == MENU_CSS or menu == MENU_STAGE_SELECT then
if menu == MENU_VS_CSS or menu == MENU_VS_STAGE_SELECT then
-- Switch back to port 1 when not in a match
PORT = 0
log.debug("[AUTOPORT] Forcing port %d in menus", PORT)
if menu ~= MENU_STAGE_SELECT then
if menu ~= MENU_VS_STAGE_SELECT then
CONTROLLER_PORT_DISPLAY = love.timer.getTime() + 1.5 -- Show the port display number for 1.5 seconds
end
else
Expand All @@ -140,7 +135,7 @@ memory.hook("menu", "Slippi Auto Port Switcher", function(menu)
end)

memory.hook("player.*.character", "Show port on character select", function(port, character)
if memory.menu == MENU_CSS and port-1 == PORT then
if memory.menu_minor == MENU_VS_CSS and port-1 == PORT then
CONTROLLER_PORT_DISPLAY = love.timer.getTime() + 1.5 -- Show the port display number for 1.5 seconds
end
end)
Expand Down
60 changes: 59 additions & 1 deletion source/melee.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,65 @@
local memory = require("memory")
local color = require("util.color")

MENU_VS_CSS = 0x0
MENU_VS_STAGE_SELECT = 0x1
MENU_VS_INGAME = 0x2
MENU_VS_POSTGAME_SCORES = 0x4

MATCH_GAME = 0x02
MATCH_STAGE_CLEAR = 0x03
MATCH_STAGE_CLEAR2 = 0x05
MATCH_NEW_RECORD = 0x06
MATCH_NO_CONTEST = 0x07
MATCH_GAME_CLEAR = 0x09

MENU_TITLE_SCREEN = 0x00
MENU_LANGUAGE_CHANGE = 0x01
MENU_VS_MODE = 0x02
MENU_CLASSIC_MODE = 0x03
MENU_ADVENTURE_MODE = 0x04
MENU_ALL_STAR_MODE = 0x05
MENU_DEBUG = 0x06
MENU_SOUND_TEST = 0x07
MENU_VS_UNKNOWN = 0x08
MENU_UNKOWN_1 = 0x09
MENU_CAMERA_MODE = 0x0A
MENU_TROPHY_GALLERY = 0x0B
MENU_TROPHY_LOTTERY = 0x0C
MENU_TROPHY_COLLECTION = 0x0D
MENU_START_MATCH = 0x0E
MENU_TARGET_TEST = 0x0F
MENU_SUPER_SUDDEN_DEATH = 0x10
MENU_INVISIBLE_MELEE= 0x11
MENU_SLOW_MO_MELEE = 0x12
MENU_LIGHTNING_MELEE = 0x13
MENU_CHARACTER_APPROACHING = 0x14
MENU_CLASSIC_MODE_CREDITS = 0x15
MENU_ADVENTURE_MODE_CREDITS = 0x16
MENU_ALL_STAR_CREDITS = 0x17
MENU_INTRO_VIDEO = 0x18
MENU_ADVENTURE_MODE_CINEMEATIC = 0x19
MENU_CHARACTER_UNLOCKED = 0x1A
MENU_TOURNAMENT = 0x1B
MENU_TRAINING_MODE = 0x1C
MENU_TINY_MELEE = 0x1D
MENU_GIANT_MELEE = 0x1E
MENU_STAMINA_MODE = 0x1F
MENU_HOME_RUN_CONTEST = 0x20
MENU_10_MAN_MELEE = 0x21
MENU_100_MAN_MELEE = 0x22
MENU_3_MINUTE_MELEE = 0x23
MENU_15_MINUTE_MELEE = 0x24
MENU_ENDLESS_MELEE = 0x25
MENU_CRUEL_MELEE = 0x26
MENU_PROGRESSIVE_SCAN = 0x27
MENU_PLAY_INTRO_VIDEO = 0x28
MENU_MEMORY_CARD_OVERWRITE = 0x29
MENU_FIXED_CAMERA_MODE = 0x2A
MENU_EVENT_MATCH = 0x2B
MENU_SINGLE_BUTTON_MODE = 0x2C


local character_selections = {
[0x00] = {
name = "captain",
Expand Down Expand Up @@ -204,7 +263,6 @@ function melee.loadtextures()
end
end


function melee.getCharacterID(port)
if not memory.player then return end
local player = memory.player[port]
Expand Down
5 changes: 3 additions & 2 deletions source/modules/games/GALE01-2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ local game = {

game.memorymap[0x80479D60] = { type = "int", name = "frame" }
game.memorymap[0x8049E753] = { type = "byte", name = "stage", debug = true }
game.memorymap[0x80479D33] = { type = "byte", name = "menu", init = -1, debug = true }
game.memorymap[0x80479D30] = { type = "byte", name = "menu_major", init = -1, debug = true }
game.memorymap[0x80479D33] = { type = "byte", name = "menu_minor", init = -1, debug = true }
game.memorymap[0x804807C8] = { type = "bool", name = "teams" }

local controllers = {
[1] = 0x804C1FAC + 0x44 * 0,
[2] = 0x804C1FAC + 0x44 * 1,
Expand Down
25 changes: 8 additions & 17 deletions source/music.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ local melee = require("melee")
local memory = require("memory")
local notification = require("notification")

local MENU_CSS = 0
local MENU_STAGE_SELECT = 1
local MENU_INGAME = 2
local MENU_POSTGAME_SCORES = 4

local STAGE_TRACKS_LOADED = {}
local STAGE_TRACKS = {}
local TRACK_NUMBER = {}
Expand Down Expand Up @@ -49,11 +44,11 @@ function music.init()
end

function music.isInGame()
return memory.menu == MENU_INGAME
return memory.menu_minor == MENU_VS_INGAME
end

function music.isInMenus()
return memory.menu == MENU_CSS or memory.menu == MENU_STAGE_SELECT
return memory.menu_minor == MENU_VS_CSS or memory.menu_minor == MENU_VS_STAGE_SELECT
end

function music.kill()
Expand Down Expand Up @@ -140,9 +135,9 @@ function music.playNextTrack()
end

function music.onStateChange()
if memory.menu == MENU_INGAME then
if memory.menu_minor == MENU_VS_INGAME then
music.loadForStage(memory.stage)
elseif memory.menu == MENU_CSS or memory.menu == MENU_STAGE_SELECT then
elseif memory.menu_minor == MENU_VS_CSS or memory.menu_minor == MENU_VS_STAGE_SELECT then
music.loadForStage(0)
end
end
Expand All @@ -151,10 +146,10 @@ memory.hook("OnGameClosed", "Dolphin - Game closed", function()
music.kill()
end)

memory.hook("menu", "Melee - Menu state", function(menu)
if menu == MENU_CSS or menu == MENU_STAGE_SELECT then
memory.hook("menu_minor", "Melee - Menu state", function(menu)
if menu == MENU_VS_CSS or menu == MENU_VS_STAGE_SELECT then
music.loadForStage(0)
elseif menu == MENU_INGAME then
elseif menu == MENU_VS_INGAME then
MATCH_SOFT_END = false
music.loadForStage(memory.stage)
else
Expand All @@ -163,7 +158,7 @@ memory.hook("menu", "Melee - Menu state", function(menu)
end)

memory.hook("stage", "Melee - Stage loaded", function(stage)
if memory.menu == MENU_INGAME then
if memory.menu_minor == MENU_VS_INGAME then
music.loadForStage(stage)
end
end)
Expand All @@ -172,10 +167,6 @@ memory.hook("match.paused", "Melee - Pause volume", function(paused)
music.setVolume(music.getVolume())
end)

local MATCH_GAME = 0x02
local MATCH_NO_CONTEST = 0x07
local MATCH_TRAINING_EXIT = 0x09

memory.hook("match.result", "Melee - GAME kill music", function(result)
if result == MATCH_GAME then
MATCH_SOFT_END = true
Expand Down

0 comments on commit bc85277

Please sign in to comment.