fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
62b54b1
settings-overhaul
1-- Super Monkey Ball 2 (NTSC v1.0) 2 3local core =require ( "games.core" ) 4 5local game ={ 6memorymap ={} 7} 8 9local controllers ={ 10[ 1 ] =0x80145210 + 0x3C * 0 , 11[ 2 ] =0x80145210 + 0x3C * 1 , 12[ 3 ] =0x80145210 + 0x3C * 2 , 13[ 4 ] =0x80145210 + 0x3C * 3 , 14} 15 16local controller_struct ={ 17[ 0x0 ] ={ type ="short" , name ="controller.%d.buttons.pressed" } , 18[ 0x2 ] ={ type ="sbyte" , name ="controller.%d.joystick.x" } , 19[ 0x3 ] ={ type ="sbyte" , name ="controller.%d.joystick.y" } , 20[ 0x4 ] ={ type ="sbyte" , name ="controller.%d.cstick.x" } , 21[ 0x5 ] ={ type ="sbyte" , name ="controller.%d.cstick.y" } , 22[ 0x6 ] ={ type ="byte" , name ="controller.%d.analog.l" } , 23[ 0x7 ] ={ type ="byte" , name ="controller.%d.analog.r" } , 24[ 0xA ] ={ type ="byte" , name ="controller.%d.plugged" } , 25} 26 27for port , address in ipairs ( controllers ) do 28for offset , info in pairs ( controller_struct ) do 29game . memorymap [ address + offset ] ={ 30type =info . type , 31debug =info . debug , 32name =info . name : format ( port ), 33} 34end 35end 36 37local abs =math . abs 38 39-- These functions seem to apply to many games 40 41function game . translateAxis ( x , y ) 42x =x / 100 43y =y / 100 44 45local near =1 - ( abs ( abs ( x ) - abs ( y ))) * 0.100 46 47local angle =math . atan2 ( x , y ) 48local mag =math . sqrt ( x * x + y * y ) 49 50-- Reduce the magnitute when x,y values are headed towards a diagonal 51return x + math . sin ( angle ) * mag * near * 0.25 , y + math . cos ( angle ) * mag * near * 0.25 52end 53 54local min =math . min 55 56function game . translateTriggers ( l , r ) 57return min ( 1 , l / 125 ), min ( 1 , r / 125 ) 58end 59 60return game