x68000:cpsfdev
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
x68000:cpsfdev [2017/10/02 12:07] – created neko68k | x68000:cpsfdev [2019/08/27 20:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | This is a simple program demonstrating how to interface with a CPSF or CPSF-MD joystick. Using a second CPSF should follow the same technique but with joyport_b, | + | This is a simple program demonstrating how to interface with a CPSF or CPSF-MD joystick. Refer to the following page for joystick register [[joystick_regs|reference]]. Using a second CPSF should follow the same technique but with joyport_b, |
< | < | ||
Line 9: | Line 9: | ||
Code: | Code: | ||
< | < | ||
+ | // This is a simple program demonstrating how to interface with a CPSF or CPSF-MD joystick | ||
+ | // Using a second CPSF should follow the same technique but with joyport_b, IOC4 and PC5 | ||
+ | |||
#include < | #include < | ||
#include < | #include < | ||
Line 17: | Line 20: | ||
volatile uint8_t *joyport_c = (uint8_t*)0xE9A005; | volatile uint8_t *joyport_c = (uint8_t*)0xE9A005; | ||
uint8_t *joycontrolword = (uint8_t*)0xE9A007; | uint8_t *joycontrolword = (uint8_t*)0xE9A007; | ||
+ | uint8_t joyport_c_old=0; | ||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
{ | { | ||
- | uint16_t port1; | + | uint16_t port1 = 0; |
+ | uint32_t usp = 0; | ||
// clear screen | // clear screen | ||
Line 27: | Line 32: | ||
// this is working for all buttons with a CPSF or CPSF-MD | // this is working for all buttons with a CPSF or CPSF-MD | ||
+ | usp = _iocs_b_super(0); | ||
// set IOC4 to 1, disables joystick 1 processing | // set IOC4 to 1, disables joystick 1 processing | ||
// preserves ADPCM settings | // preserves ADPCM settings | ||
- | *joyport_c = 16|(*joyport_c& | + | joyport_c_old = *joyport_c; |
+ | |||
+ | *joyport_c = 16|joyport_c_old; | ||
while(1) | while(1) | ||
{ | { | ||
Line 52: | Line 59: | ||
// quit on ESC | // quit on ESC | ||
- | if(_iocs_bitsns(0) == 2) | + | if(_dos_inpout(0xFF)==0x1B){ |
+ | *joycontrolword = 8; | ||
+ | *joyport_c = joyport_c_old; | ||
+ | _iocs_b_super(usp); | ||
return 0; | return 0; | ||
+ | } | ||
} | } | ||
- | |||
- | |||
- | return 0; | ||
} | } | ||
</ | </ |
x68000/cpsfdev.1506910062.txt.gz · Last modified: 2019/08/27 20:44 (external edit)