PVSnesLib
4.3.0
Documentation to code in C or ASM for the Nintendo SNES
|
input support. More...
Go to the source code of this file.
Macros | |
#define | mouse_L 0x01 /*! \brief SNES Mouse Left button mask.*/ |
Mouse speed setting. 0: slow, 1: normal, 2: fast. | |
#define | padsCurrent(value) (pad_keys[value]) |
Return current value of selected pad. More... | |
#define | REG_JOYxLH(a) (((vuint16 *)0x4218)[(a)]) |
Number of frames elapsed since last shot was fired. More... | |
Typedefs | |
typedef enum KEYPAD_BITS | KEYPAD_BITS |
enum values for the pad buttons. | |
typedef enum SUPERSCOPE_BITS | SUPERSCOPE_BITS |
enum values for the SuperScope buttons and flags. | |
Enumerations | |
enum | KEYPAD_BITS { KEY_A = BIT(7) , KEY_B = BIT(15) , KEY_SELECT = BIT(13) , KEY_START = BIT(12) , KEY_RIGHT = BIT(8) , KEY_LEFT = BIT(9) , KEY_DOWN = BIT(10) , KEY_UP = BIT(11) , KEY_R = BIT(4) , KEY_L = BIT(5) , KEY_X = BIT(6) , KEY_Y = BIT(14) } |
enum values for the pad buttons. More... | |
enum | SUPERSCOPE_BITS { SSC_FIRE = BIT(15) , SSC_CURSOR = BIT(14) , SSC_PAUSE = BIT(12) , SSC_TURBO = BIT(13) , SSC_OFFSCREEN = BIT(9) , SSC_NOISE = BIT(8) } |
enum values for the SuperScope buttons and flags. More... | |
Functions | |
void | detectMouse (void) |
Check if Mouse is connected and populate snes_mouse (0 or 1 for connected) | |
void | detectMPlay5 (void) |
Check if MultiPlayer5 is connected and populate snes_mplay5 (0 or 1 for connected) | |
void | detectSuperScope (void) |
Detects if SuperScope is connected on Port 1 (second controller port on console) and populate snes_sscope (0 or 1 for connected) | |
void | mouseRead (void) |
Wait for mouse ready and read mouse values in. | |
void | mouseSpeedChange (u8 port) |
Set mouse hardware speed (populate mouseSpeed[] first). More... | |
void | padsClear (u16 value) |
Clear internal variables for selected pad. More... | |
unsigned short | padsDown (u16 value) |
Return value of down keys for selected pad. More... | |
unsigned short | padsUp (u16 value) |
Return value of up keys for selected pad. More... | |
void | scanMPlay5 (void) |
Wait for multiplayer5 pads ready and read pad values in. | |
void | scanPads (void) |
Wait for pad ready and read pad values in. | |
void | scanScope (void) |
Nintendo SHVC Scope BIOS version 1.00 Quickly disassembled and commented by Revenant on 31 Jan 2013. More... | |
Variables | |
u8 | mouse_x [2] |
1 if button is pressed, stays until is unpressed (Turbo mode). | |
u8 | mouseButton [2] |
1 if Mouse present | |
u8 | mouseConnect [2] |
1 if SuperScope is connected | |
u8 | mousePressed [2] |
1 if button is pressed, stays for a bit and then it gets released (Click mode). | |
u8 | mouseSpeedSet [2] |
Mouse acceleration. daaaaaaa, d = direction (0: up/left, 1: down/right), a = acceleration. | |
u16 | scope_centerh |
Vertical shot position, adjusted for aim. | |
u16 | scope_centerv |
0x0000 is the center of the screen, positive values go to bottom right. | |
u16 | scope_down |
0x0000 is the center of the screen, positive values go to bottom right. | |
u16 | scope_held |
flags that have become true this frame. | |
u16 | scope_last |
flagsthat have been true for a certain length of time. | |
u16 | scope_now |
flags that are currently true. | |
u16 | scope_repdelay |
Hold delay. | |
u16 | scope_shoth |
Vertical shot position, not adjusted. | |
u16 | scope_shothraw |
Repeat rate. | |
u16 | scope_shotv |
Horizontal shot position, adjusted for aim. | |
u16 | scope_shotvraw |
Horizontal shot position, not adjusted. | |
u16 | scope_sinceshot |
flags that were true on the previous frame. | |
u8 | snes_mouse |
1 if MultiPlay5 is connected | |
u8 | snes_sscope |
1 if Mouse is going to be used | |
input support.
common values for SuperScope input.
common values for pad input.
common values that can be used to test auto pad.
padsCurrent | ( | value | ) | (pad_keys[value]) |
Return current value of selected pad.
value | Address of the pad to use (0 or 1 to 4 if multiplayer 5 connected) |
#define REG_JOYxLH | ( | a | ) | (((vuint16 *)0x4218)[(a)]) |
Number of frames elapsed since last shot was fired.
SNES Controllers I/O Ports - Automatic Reading. 4218h/4219h - JOY1L/JOY1H - Joypad 1 (gameport 1, pin 4) (R) 421Ah/421Bh - JOY2L/JOY2H - Joypad 2 (gameport 2, pin 4) (R) 421Ch/421Dh - JOY3L/JOY3H - Joypad 3 (gameport 1, pin 5) (R) 421Eh/421Fh - JOY4L/JOY4H - Joypad 4 (gameport 2, pin 5) (R)
Register Serial Default Bit Transfer Purpose Number______Order______(Joypads)_____ 15 1st B Button (1=Low=Pressed) 14 2nd Y Button 13 3rd Select Button 12 4th Start Button 11 5th Up 10 6th Down 9 7th Left 8 8th Right 7 9th A Button 6 10th X Button 5 11th L Button 4 12th R Button 3 13th 0 (High) 2 14th 0 (High) 1 15th 0 (High) 0 16th 0 (High)
When enabled, the SNES will read 16 bits from each of the 4 controller port data lines into registers $4218-f. This begins between H=32.5 and H=95.5 of the first V-Blank scanline, and ends 4224 master cycles later. Register $4212 bit 0 is set during this time. Specifically, it begins at H=74.5 on the first frame, and thereafter some multiple of 256 cycles after the start of the previous read that falls within the observed range.
Reading $4218-f during this time will read back incorrect values. The only reliable value is that no buttons pressed will return 0 (however, if buttons are pressed 0 could still be returned incorrectly). Presumably reading $4016/7 or writing $4016 during this time will also screw things up.
enum KEYPAD_BITS |
enum values for the pad buttons.
enum SUPERSCOPE_BITS |
mouseSpeedChange | ( | u8 | port | ) |
Set mouse hardware speed (populate mouseSpeed[] first).
port | Specify wich port to use (0-1) |
padsClear | ( | u16 | value | ) |
Clear internal variables for selected pad.
value | Address of the pad to use (0 or 1 to 4 if multiplayer 5 connected) |
padsDown | ( | u16 | value | ) |
Return value of down keys for selected pad.
value | Address of the pad to use (0 or 1 to 4 if multiplayer 5 connected) |
padsUp | ( | u16 | value | ) |
Return value of up keys for selected pad.
value | Address of the pad to use (0 or 1 to 4 if multiplayer 5 connected) |
scanScope | ( | void | ) |
Nintendo SHVC Scope BIOS version 1.00 Quickly disassembled and commented by Revenant on 31 Jan 2013.
This assembly uses xkas v14 syntax. It probably also assembles with bass, if there's any such thing as good fortune in the universe.
How to use the SHVC Super Scope BIOS: (all variables are two bytes)
1: Set "HoldDelay" and "RepDelay" for the button hold delay and repeat rate
2: "jsr GetScope" or "jsl GetScopeLong" once per frame
3: Read one of the following to get the scope input bits (see definitions below):
3a: If the bits read from ScopeNow indicate a valid shot, or if the Cursor button is being pressed, then read "ShotH"/"ShotV" to adjust for aim, or read "ShotHRaw"/"ShotVRaw" for "pure" coordinates
3c: at some point, set "CenterH"/"CenterV" equal to "ShotHRaw"/"ShotVRaw" so that the aim-adjusted coordinates are "correct"