@@ -6,34 +6,38 @@ local game = {
6
6
memorymap = {}
7
7
}
8
8
9
- local controllers = {
10
- [1 ] = 0x807A55A4 + 0xC * 0 ,
11
- [2 ] = 0x807A55A4 + 0xC * 1 ,
12
- [3 ] = 0x807A55A4 + 0xC * 2 ,
13
- [4 ] = 0x807A55A4 + 0xC * 3 ,
14
- }
9
+ -- Pointer to where some struct is stored that contains the controller data..
10
+ local game_data_loc = 0x804576FC
15
11
16
12
local 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" },
13
+ [0x0 ] = { type = " short" , name = " %d.buttons.pressed" },
14
+ [0x2 ] = { type = " sbyte" , name = " %d.joystick.x" },
15
+ [0x3 ] = { type = " sbyte" , name = " %d.joystick.y" },
16
+ [0x4 ] = { type = " sbyte" , name = " %d.cstick.x" },
17
+ [0x5 ] = { type = " sbyte" , name = " %d.cstick.y" },
18
+ [0x6 ] = { type = " byte" , name = " %d.analog.l" },
19
+ [0x7 ] = { type = " byte" , name = " %d.analog.r" },
20
+ [0xA ] = { type = " byte" , name = " %d.plugged" },
21
+ }
22
+
23
+ local controller_ptr = {
24
+ type = " pointer" ,
25
+ name = " controller" ,
26
+ struct = {}
25
27
}
26
28
27
- for port , address in ipairs ( controllers ) do
29
+ for i = 1 , 4 do
28
30
for offset , info in pairs (controller_struct ) do
29
- game . memorymap [ address + offset ] = {
31
+ controller_ptr . struct [ 0x04 + ( 0xC * ( i - 1 )) + offset ] = {
30
32
type = info .type ,
31
33
debug = info .debug ,
32
- name = info .name :format (port ),
34
+ name = info .name :format (i ),
33
35
}
34
36
end
35
37
end
36
38
39
+ game .memorymap [game_data_loc ] = controller_ptr
40
+
37
41
game .translateAxis = core .translateAxis
38
42
game .translateTriggers = core .translateTriggers
39
43
0 commit comments