fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
ffa28d1
main
1-- Super Smash Bros. Brawl (NTSC v1.01) 2 3local core =require ( "games.core" ) 4 5local game =core . newGame () 6 7--[[ 8Brawl seems to have 4 addresses dedicated to controller input values, each address polling around 15fps. 9If you poll all four addresses for the controller values, you get 60fps input! 10 11Structure: 12Polling Address 1 [0x805BA480] 13Port 1 [0x805BA480 + 0x40 * 0] 14Port 2 [0x805BA480 + 0x40 * 1] 15Port 3 [0x805BA480 + 0x40 * 2] 16Port 4 [0x805BA480 + 0x40 * 3] 17Polling Address 2 [0x805BA680] 18Port 1 [0x805BA680 + 0x40 * 0] 19Port 2 [0x805BA680 + 0x40 * 1] 20Port 3 [0x805BA680 + 0x40 * 2] 21Port 4 [0x805BA680 + 0x40 * 3] 22Polling Address 3 [0x805BA880] 23Port 1 [0x805BA880 + 0x40 * 0] 24Port 2 [0x805BA880 + 0x40 * 1] 25Port 3 [0x805BA880 + 0x40 * 2] 26Port 4 [0x805BA880 + 0x40 * 3] 27Polling Address 4 [0x805BAA80] 28Port 1 [0x805BAA80 + 0x40 * 0] 29Port 2 [0x805BAA80 + 0x40 * 1] 30Port 3 [0x805BAA80 + 0x40 * 2] 31Port 4 [0x805BAA80 + 0x40 * 3] 32]] 33 34local polling_addresses ={ 350x805BA480 , 360x805BA680 , 370x805BA880 , 380x805BAA80 , 39} 40 41local controllers ={ 42[ 1 ] =0x40 * 0 , 43[ 2 ] =0x40 * 1 , 44[ 3 ] =0x40 * 2 , 45[ 4 ] =0x40 * 3 , 46} 47 48local controller_struct ={ 49[ 0x04 ] ={ type ="int" , name ="controller.%d.buttons.pressed" } , 50[ 0x34 ] ={ type ="sbyte" , name ="controller.%d.joystick.x" } , 51[ 0x35 ] ={ type ="sbyte" , name ="controller.%d.joystick.y" } , 52[ 0x36 ] ={ type ="sbyte" , name ="controller.%d.cstick.x" } , 53[ 0x37 ] ={ type ="sbyte" , name ="controller.%d.cstick.y" } , 54[ 0x38 ] ={ type ="byte" , name ="controller.%d.analog.l" } , 55[ 0x39 ] ={ type ="byte" , name ="controller.%d.analog.r" } , 56[ 0x3C ] ={ type ="byte" , name ="controller.%d.plugged" } , 57} 58 59for _ , polling_addr in ipairs ( polling_addresses ) do 60-- For every polling address.. 61for port , controller_addr in ipairs ( controllers ) do 62-- For every controller 63for offset , info in pairs ( controller_struct ) do 64game . memorymap [ polling_addr + controller_addr + offset ] ={ 65type =info . type , 66debug =info . debug , 67name =info . name : format ( port ), 68} 69end 70end 71end 72 73function game . translateJoyStick ( x , y ) 74return x / 100 , y / 100 75end 76 77local min =math . min 78 79function game . translateTriggers ( l , r ) 80return min ( 1 , l / 128 ), min ( 1 , r / 128 ) 81end 82 83return game