fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
1f39dd3
master
1--Shadow The Hedgehog (NTSC-U) 2 3local core =require ( "games.core" ) 4 5local game =core . newGame ( 0x805A5810 ) 6 7local controllers ={ 8[ 1 ] =0x805A5810 , 9} 10 11local controller_struct ={ 12[ 0x0 ] ={ type ="u16" , name ="controller.%d.buttons.pressed" } , 13[ 0x2 ] ={ type ="sbyte" , name ="controller.%d.joystick.x" } , 14[ 0x3 ] ={ type ="sbyte" , name ="controller.%d.joystick.y" } , 15[ 0x4 ] ={ type ="sbyte" , name ="controller.%d.cstick.x" } , 16[ 0x5 ] ={ type ="sbyte" , name ="controller.%d.cstick.y" } , 17[ 0x6 ] ={ type ="byte" , name ="controller.%d.analog.l" } , 18[ 0x7 ] ={ type ="byte" , name ="controller.%d.analog.r" } , 19} 20 21function game . translateJoyStick ( x , y ) 22--Left = 25 <- 127 23--Neutral = -128 24--Right = -127 -> -25 25if x > 0 26then 27x =( math . abs ( x ) - 127 ) / 102 28x =math . min ( x , 1 ) 29else 30x =- ( math . abs ( x ) - 127 ) / 102 31x =math . max ( x , - 1 ) 32end 33if y > 0 34then 35y =( math . abs ( y ) - 127 ) / 102 36y =math . min ( y , 1 ) 37else 38y =- ( math . abs ( y ) - 127 ) / 102 39y =math . max ( y , - 1 ) 40end 41return x , y 42end 43 44game . translateCStick =game . translateJoyStick 45 46for port , address in ipairs ( controllers ) do 47for offset , info in pairs ( controller_struct ) do 48game . memorymap [ address + offset ] ={ 49type =info . type , 50debug =info . debug , 51name =info . name : format ( port ), 52} 53end 54end 55 56return game