-
Notifications
You must be signed in to change notification settings - Fork 3
Controller Emulation
The way that AI
controls a character is through emulated controller inputs. If you only use the AI
then understanding the controller in not important, however, if ai.h
does not suit your needs you can use controller.h to send your input directly.
In order to use a controller you will need a "spoofed controller" plugged in to whatever port you want to use. In the config file:
; spoof controllers
80376bd4 = 38000000
80376bdc = 38000000
80376bf0 = 380000d8
80376c04 = 38000001
It is also important to choose a proper branch point for your code. The controller must be written to the game after it reads the "spoof" controller and before it sends the input to the game. The "spoof" controller has all inputs set to 0, so if you write too late or too early a blank controller will be used in the game. Here is the proper setup in the config file:
FIXED_SYMBOLS =
_main 80377998 7ee3bb78
Now that we have the setup, there are two functions used to emulate a controller: setController
and writeController
. The controller itself is a struct declared somewhere in the global scope. Every frame the you must call writeController
in order to write this controller's state to the proper memory addresses. Any time you want to change the state of the controller, call setController
and pass in a 16-bit controller state.