fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
60fa5b3
master
1-- Super Smash Bros. Melee (NTSC v1.2) / Dairantou Smash Brothers DX (Japan v1.2) 2 3local core =require ( "games.core" ) 4 5local game =core . newGame () 6 7-- Controls/Saves the volume levels of the game 8game . memorymap [ 0x8045C384 ] ={ type ="s8" , name ="volume.slider" } -- Scale is (-100 to 100) 9 10-- You can change these values in real time to change the volume, but when opening the sound menu, it will readjust to the slider value above 11game . memorymap [ 0x804D3887 ] ={ type ="u8" , name ="volume.music" } -- Scale is (0-127) 12game . memorymap [ 0x804D388F ] ={ type ="u8" , name ="volume.ui" } -- Scale is (0-127) 13 14game . memorymap [ 0x80479D60 ] ={ type ="u32" , name ="frame" } 15 16game . memorymap [ 0x80479D30 ] ={ type ="u8" , name ="scene.major" , debug =true } 17game . memorymap [ 0x80479D31 ] ={ type ="u8" , name ="scene.major2" } 18game . memorymap [ 0x80479D32 ] ={ type ="u8" , name ="scene.major_prev" } 19game . memorymap [ 0x80479D33 ] ={ type ="u8" , name ="scene.minor" , debug =true } 20game . memorymap [ 0x80479D34 ] ={ type ="u8" , name ="scene.minor_prev" } 21 22game . memorymap [ 0x804D6598 ] ={ type ="u8" , name ="menu.player_one_port" } -- What port is currently acting as "Player 1" in single player games 23game . memorymap [ 0x804807C8 ] ={ type ="bool" , name ="menu.teams" } 24 25game . memorymap [ 0x804A04F0 ] ={ type ="u8" , name ="menu.id" } 26game . memorymap [ 0x804A04F1 ] ={ type ="u8" , name ="menu.id_prev" } 27game . memorymap [ 0x804A04F3 ] ={ type ="u8" , name ="menu.selection" } 28game . memorymap [ 0x804A04F4 ] ={ type ="u8" , name ="menu.value" } 29 30game . memorymap [ 0x804D5F90 ] ={ type ="u32" , name ="rng.seed" } 31 32local controllers ={ 33[ 1 ] =0x804C1FAC + 0x44 * 0 , 34[ 2 ] =0x804C1FAC + 0x44 * 1 , 35[ 3 ] =0x804C1FAC + 0x44 * 2 , 36[ 4 ] =0x804C1FAC + 0x44 * 3 , 37} 38 39local controller_struct ={ 40[ 0x00 ] ={ type ="u32" , name ="controller.%d.buttons.pressed" } , 41[ 0x04 ] ={ type ="u32" , name ="controller.%d.buttons.pressed_previous" } , 42[ 0x08 ] ={ type ="u32" , name ="controller.%d.buttons.instant" } , 43[ 0x10 ] ={ type ="u32" , name ="controller.%d.buttons.released" } , 44[ 0x1C ] ={ type ="u8" , name ="controller.%d.analog.byte.l" } , 45[ 0x1D ] ={ type ="u8" , name ="controller.%d.analog.byte.r" } , 46[ 0x20 ] ={ type ="float" , name ="controller.%d.joystick.x" } , 47[ 0x24 ] ={ type ="float" , name ="controller.%d.joystick.y" } , 48[ 0x28 ] ={ type ="float" , name ="controller.%d.cstick.x" } , 49[ 0x2C ] ={ type ="float" , name ="controller.%d.cstick.y" } , 50[ 0x30 ] ={ type ="float" , name ="controller.%d.analog.l" } , 51[ 0x34 ] ={ type ="float" , name ="controller.%d.analog.r" } , 52[ 0x41 ] ={ type ="u8" , name ="controller.%d.plugged" } , 53} 54 55for port , address in ipairs ( controllers ) do 56for offset , info in pairs ( controller_struct ) do 57game . memorymap [ address + offset ] ={ 58type =info . type , 59debug =info . debug , 60name =info . name : format ( port ), 61} 62end 63end 64 65local player_static_addresses ={ 660x80453080 , -- Player 1 670x80453F10 , -- Player 2 680x80454DA0 , -- Player 3 690x80455C30 , -- Player 4 700x80456AC0 , -- Player 5 710x80457950 , -- Player 6 72} 73 74local entity_pointer_offsets ={ 75[ 0xB0 ] ="entity" , 76[ 0xB4 ] ="partner" , -- Partner entity (For sheik/zelda/iceclimbers) 77} 78 79local player_static_struct ={ 80[ 0x004 ] ={ type ="u32" , name ="character" } , 81[ 0x008 ] ={ type ="u32" , name ="mode" } , 82[ 0x00C ] ={ type ="u16" , name ="transformed" } , 83[ 0x044 ] ={ type ="u8" , name ="skin" } , 84--[0x045] = { type = "u8", name = "port" }, 85[ 0x046 ] ={ type ="u8" , name ="color" } , 86[ 0x047 ] ={ type ="u8" , name ="team" } , 87--[0x048] = { type = "u8", name = "index" }, 88[ 0x049 ] ={ type ="u8" , name ="cpu_level" } , 89[ 0x04A ] ={ type ="u8" , name ="cpu_type" } , -- 4 = 20XX, 22 = normalish, 19 = Alt Normal 90} 91 92for id , address in ipairs ( player_static_addresses ) do 93for offset , info in pairs ( player_static_struct ) do 94game . memorymap [ address + offset ] ={ 95type =info . type , 96debug =info . debug , 97name =( "player.%i.%s" ): format ( id , info . name ), 98} 99end 100 101for offset , name in pairs ( entity_pointer_offsets ) do 102game . memorymap [ address + offset ] ={ 103type ="pointer" , 104name =( "player.%i.%s" ): format ( id , name ), 105struct ={ 106[ 0x60 + 0x0004 ] ={ type ="u32" , name ="character" } , 107--[0x60 + 0x000C] = { type = "u8", name = "port" }, 108--[0x60 + 0x0618] = { type = "u8", name = "index" }, 109[ 0x60 + 0x0619 ] ={ type ="u8" , name ="skin" } , 110[ 0x60 + 0x061A ] ={ type ="u8" , name ="color" } , 111[ 0x60 + 0x061B ] ={ type ="u8" , name ="team" } , 112 113[ 0x60 + 0x0620 ] ={ type ="float" , name ="controller.joystick.x" } , 114[ 0x60 + 0x0624 ] ={ type ="float" , name ="controller.joystick.y" } , 115[ 0x60 + 0x0638 ] ={ type ="float" , name ="controller.cstick.x" } , 116[ 0x60 + 0x063C ] ={ type ="float" , name ="controller.cstick.y" } , 117[ 0x60 + 0x0650 ] ={ type ="float" , name ="controller.analog.float" } , 118[ 0x60 + 0x065C ] ={ type ="u32" , name ="controller.buttons.pressed" } , 119[ 0x60 + 0x0660 ] ={ type ="u32" , name ="controller.buttons.pressed_previous" } , 120 121--[[ 122[0x60 + 0x1A94] = { type = "u32", name = "cpu_type" }, 123[0x60 + 0x1A98] = { type = "u32", name = "cpu_level" }, 124]] 125} , 126} 127end 128end 129 130-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L29 131local CSSDT_BUF_ADDR =0x80005614 132 133game . memorymap [ CSSDT_BUF_ADDR ] ={ 134type ="pointer" , 135name ="slippi" , 136debug =true , 137struct ={ 138-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L253 139[ 0x000 ] ={ 140type ="pointer" , 141--name = "slippi_ptr", 142debug =true , 143struct ={ 144[ 0x00 ] ={ type ="u8" , name ="connection_state" } , -- 1 145[ 0x01 ] ={ type ="bool" , name ="local_player.ready" } , -- 1 146[ 0x02 ] ={ type ="bool" , name ="remote_player.ready" } , -- 1 147[ 0x03 ] ={ type ="u8" , name ="local_player.index" , debug =true } , -- 1 148[ 0x04 ] ={ type ="u8" , name ="remote_player.index" } , -- 1 149[ 0x05 ] ={ type ="u32" , name ="rng_offset" } , -- 4 150[ 0x09 ] ={ type ="u8" , name ="delay_frames" } , -- 1 151[ 0x0A ] ={ type ="u8" , name ="local_player.chatmsg_id" } , -- 1 152[ 0x0B ] ={ type ="u8" , name ="opponent.chatmsg_id" } , -- 1 153[ 0x0C ] ={ type ="u8" , name ="chatmsg.index" } , -- 1 154[ 0x0D ] ={ type ="u32" , name ="vs.left_names" } , -- 4 155[ 0x11 ] ={ type ="u32" , name ="vs.right_names" } , -- 4 156-- [0x15] = { type = "string-jis", len = 31, name = "local_player.name", debug = true }, -- 31 157-- [0x34] = { type = "string-jis", len = 31, name = "players.1.name", debug = true }, -- 31 158-- [0x53] = { type = "string-jis", len = 31, name = "players.2.name", debug = true }, -- 31 159-- [0x72] = { type = "string-jis", len = 31, name = "players.3.name" }, -- 31 160-- [0x91] = { type = "string-jis", len = 31, name = "players.4.name" }, -- 31 161-- [0xB0] = { type = "string-jis", len = 31, name = "opponent.name" }, -- 31 162-- [0xCF] = { type = "string-jis", len = 10, name = "players.1.code", debug = true }, -- 10 163-- [0xD9] = { type = "string-jis", len = 10, name = "players.2.code", debug = true }, -- 10 164-- [0xE3] = { type = "string-jis", len = 10, name = "players.3.code" }, -- 10 165-- [0xED] = { type = "string-jis", len = 10, name = "players.4.code" }, -- 10 166-- [0xF7] = { type = "string", len = 29, name = "players.1.uuid", debug = true }, -- 29 167-- [0x114] = { type = "string", len = 29, name = "players.2.uuid", debug = true }, -- 29 168-- [0x131] = { type = "string", len = 29, name = "players.3.uuid", debug = true }, -- 29 169-- [0x14E] = { type = "string", len = 29, name = "players.4.uuid", debug = true }, -- 29 170-- [0x16B] = { type = "string", len = 241, name = "error_msg", debug = true }, -- 241 171-- [0x25C] = { type = "data", len = 241, name = "game_info", debug = true }, -- 241 172-- [0x34D] = { type = "data", len = 51, name = "match_id", debug = true }, -- 51 173} 174} , 175} 176} 177 178-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L10 179local ONLINE_BUF_ADDR =0x804D6CBC 180 181game . memorymap [ ONLINE_BUF_ADDR ] ={ 182type ="pointer" , 183name ="online" , 184debug =true , 185struct ={ 186-- https://github.com/project-slippi/slippi-ssbm-asm/blob/9c36ffc5e4787c6caadfb12727c5fcff07d64642/Online/Online.s#L182-L225 187[ 0x07 ] ={ type ="u32" , name ="rng_offset" } 188} 189} 190 191-- Where character ID's are stored in the CSS menu 192local player_select_external_addresses ={ 1930x8043208B , 1940x80432093 , 1950x8043209B , 1960x804320A3 , 197} 198 199local player_select_external ={ 200[ 0x04 ] ="character" , 201[ 0x05 ] ="skin" , 202} 203 204for id , address in ipairs ( player_select_external_addresses ) do 205for offset , name in pairs ( player_select_external ) do 206game . memorymap [ address + offset ] ={ 207debug =true , 208type ="u8" , 209name =( "player.%i.select.%s" ): format ( id , name ), 210} 211end 212end 213 214local player_card_addresses ={ 2150x803F0E06 , 2160x803F0E2A , 2170x803F0E4E , 2180x803F0E72 , 219} 220 221local player_card ={ 222[ 0x00 ] ="team" , 223[ 0x01 ] ="mode" , 224--[0x02] = "mode2", -- Duplicate? 225[ 0x03 ] ="skin" , 226[ 0x04 ] ="character" , 227[ 0x05 ] ="hovered" , 228} 229 230for id , address in ipairs ( player_card_addresses ) do 231for offset , name in pairs ( player_card ) do 232game . memorymap [ address + offset ] ={ 233type ="byte" , 234name =( "player.%i.card.%s" ): format ( id , name ), 235} 236end 237end 238 239-- 0x80480530 = Only for VS matches? 240-- 0x80480590 = PlayerDATA 241 242-- MATCH = 8046b6a0 243 244local match_info =0x8046B6A0 245local match_info_struct ={ 246[ 0x00 ] ={ type ="u8" , name ="match.info.state" } , 247[ 0x01 ] ={ type ="u8" , name ="match.info.pauser" } , 248[ 0x05 ] ={ type ="bool" , name ="match.info.playing" , debug =true } , 249[ 0x08 ] ={ type ="u8" , name ="match.info.result" , debug =true } , 250[ 0x0E ] ={ type ="bool" , name ="match.info.finished" , debug =true } , 251[ 0x24 ] ={ type ="u32" , name ="match.info.timer.frames" } , 252[ 0x28 ] ={ type ="u32" , name ="match.info.timer.seconds" } , 253[ 0x2C ] ={ type ="u16" , name ="match.info.timer.millis" } , 254} 255 256for offset , info in pairs ( match_info_struct ) do 257game . memorymap [ match_info + offset ] =info 258end 259 260local match_init_addr =0x24C8 261local match_init_struct ={ 262[ 0x00 ] ={ type ="u8" , name ="match.settings.flags.1" } , 263--[[ 264TIMER = bit.band(flags, 3) 265 2660: TIMER_FROZEN 2671: TIMER_HIDDEN 2682: TIMER_COUNT_DOWN 2693: TIMER_COUNT_UP 270 271HUDPOS = bit.band(bit.rshift(flags, 2), 7) 272 2730: MATCH_HUDPOS_NONE 2741: MATCH_HUDPOS_ONE 2752: MATCH_HUDPOS_TWO 2763: MATCH_HUDPOS_THREE 2774: MATCH_HUDPOS_FOUR 2785: MATCH_HUDPOS_SIX 2796: MATCH_HUDPOS_UNK 2807: MATCH_HUDPOS_FOURCOMPACT 281 282MATCH = bit.band(bit.rshift(flags, 5), 7) 283 2840: MODE_TIME 2851: MODE_STOCK 2862: MODE_COIN 2873: MODE_BONUS 288]] 289[ 0x01 ] ={ type ="u8" , name ="match.settings.flags.2" } , 290--[[ 2910x01: UNKNOWN_2 2920x02: TIMER_UNKOWN 2930x04: UNKNOWN_3 2940x08: DISABLE_MUSIC 2950x10: HIDE_GO 2960x20: HIDE_READY 2970x40: UNKNOWN_4 2980x80: TIMER_UNKNOWN 299]] 300[ 0x02 ] ={ type ="u8" , name ="match.settings.flags.3" } , 301--[[ 3020x01: UNKNOWN_5 3030x02: CREATE_HUD 3040x04: UNKNOWN_7 3050x08: DISABLE_PAUSE 3060x10: SINGLE_BUTTON 3070x20: UNKNOWN_8 3080x40: DISABLE_OFFSCREEN_DAMAGE 3090x80: UNKNOWN_9 310]] 311[ 0x03 ] ={ type ="u8" , name ="match.settings.flags.4" } , 312--[[ 3130x01: TIMER_RUN_ON_PAUSE 3140x02: TIMER_HIDE_ON_PAUSE 3150x04: SHOW_LRAS 3160x08: CHECK_LRAS 3170x10: SHOW_RETRY 3180x20: CHECK_RETRY 3190x40: SHOW_ANALOG_STICK 3200x80: SHOW_SCORE 321]] 322[ 0x04 ] ={ type ="u8" , name ="match.settings.flags.5" } , 323--[[ 3240x01 - 0x10: UNKNOWN_10 3250x20: RUN_STOCK_LOGIC 3260x40: CHECK_STOCK_STEAL 3270x80: UNKNOWN_11 328]] 329[ 0x05 ] ={ type ="u8" , name ="match.settings.flags.6" } , 330--[[ 3310x01 - 0x10: UNKNOWN_12 3320x20: NO_HIT 3330x40: SKIP_UKNONWN_STOCK_CHECK 3340x80: NO_CHECK_END 335]] 336[ 0x06 ] ={ type ="bool" , name ="match.settings.bombrain" } , 337[ 0x08 ] ={ type ="bool" , name ="match.settings.teams" } , 338[ 0x0B ] ={ type ="s8" , name ="match.settings.item_frequency" } , 339[ 0x0C ] ={ type ="s8" , name ="match.settings.self_destruct" } , 340[ 0x0E ] ={ type ="short" , name ="match.settings.stage" } , 341[ 0x10 ] ={ type ="u32" , name ="match.settings.timer.seconds" } , 342[ 0x14 ] ={ type ="u8" , name ="match.settings.timer.millis" } , 343 344[ 0x28 ] ={ type ="float" , name ="match.settings.quake_multiplier" } , 345[ 0x2C ] ={ type ="float" , name ="match.settings.damage_ratio" } , 346[ 0x30 ] ={ type ="float" , name ="match.settings.match_speed" } , 347} 348 349for offset , info in pairs ( match_init_struct ) do 350game . memorymap [ match_info + match_init_addr + offset ] =info 351end 352 353game . memorymap [ 0x804D640F ] ={ type ="bool" , name ="match.info.paused" } 354 355local stage_info_addr =0x8049E6C8 356local stage_info_struct ={ 357[ 0x0088 ] ={ type ="int" , name ="stage.id" , debug =true } , 358[ 0x06D4 ] ={ type ="short" , name ="stage.targets" } , 359[ 0x06E0 ] ={ type ="float" , name ="stage.homerun_distance" } , 360} 361for offset , info in pairs ( stage_info_struct ) do 362game . memorymap [ stage_info_addr + offset ] =info 363end 364 365local player_cursors_pointers ={ 3660x804A0BC0 , 3670x804A0BC4 , 3680x804A0BC8 , 3690x804A0BCC , 370} 371 372local player_cursor_struct ={ 373--[0x00] = { type = "u32", name = "unknown_ptr" }, 374[ 0x05 ] ={ type ="u8" , name ="state" } , -- The state of the pointer (0 = in the bottom area, 1 = holding coin, 2 = empty hand) 375[ 0x0B ] ={ type ="u8" , name ="b_frame_counter" } , -- How many frames the player is holding B for (At 32, it will forcibly exit back to the menus) 376[ 0x0C ] ={ type ="float" , name ="position.x" } , 377[ 0x10 ] ={ type ="float" , name ="position.y" } , 378} 379 380for port , addr in pairs ( player_cursors_pointers ) do 381game . memorymap [ addr ] ={ type ="pointer" , name =( "player.%i.cursor" ): format ( port ), struct =player_cursor_struct } 382end 383 384game . translateJoyStick =function ( x , y ) return x , y end 385game . translateCStick =function ( x , y ) return x , y end 386game . translateTriggers =function ( l , r ) return l , r end 387 388return game