User Tools

Site Tools


x68000:cpsfdev

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
x68000:cpsfdev [2017/10/02 14:23] neko68kx68000: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, IOC5 and PC5. It can be compiled with the Lydux toolchain with the following commands:+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, IOC5 and PC5. It can be compiled with the Lydux toolchain with the following commands:
  
 <file> <file>
Line 9: Line 9:
 Code: Code:
 <file> <file>
 +// 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 <stdint.h> #include <stdint.h>
 #include <stdio.h> #include <stdio.h>
Line 17: Line 20:
 volatile uint8_t *joyport_c = (uint8_t*)0xE9A005; // joy control volatile uint8_t *joyport_c = (uint8_t*)0xE9A005; // joy control
 uint8_t *joycontrolword = (uint8_t*)0xE9A007; // if bit 7 = 0, bit manipulation. if bit 7 = 1, mode setting uint8_t *joycontrolword = (uint8_t*)0xE9A007; // if bit 7 = 0, bit manipulation. if bit 7 = 1, mode setting
 +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&0xF);+ 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; 
 } }
 </file> </file>
x68000/cpsfdev.1506918189.txt.gz · Last modified: 2019/08/27 20:44 (external edit)