Differences

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

Link to this comparison view

x68000:cpsfdev [2017/10/04 03:48]
neko68k added link to joystick register reference.
x68000:cpsfdev [2019/08/27 20:45]
Line 1: Line 1:
-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> 
-$ human68k-gcc joytest.c -liocs 
-$ human68k-objcopy -O xfile a.out joytest.x 
-</file> 
- 
- 
-Code: 
-<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 <stdio.h> 
-#include <iocslib.h> 
- 
-volatile uint8_t *joyport_a = (uint8_t*)0xE9A001; 
-volatile uint8_t *joyport_b = (uint8_t*)0xE9A003; 
-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 joyport_c_old=0; 
- 
-int main(int argc, char *argv[]) 
-{ 
- uint16_t port1 = 0; 
- uint32_t usp = 0; 
-  
- // clear screen 
- printf("\e[2J"); 
- 
- // 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 
- // preserves ADPCM settings 
- joyport_c_old = *joyport_c; 
-  
- *joyport_c = 16|joyport_c_old; 
- while(1) 
- { 
- port1=0; 
- // move cursor to origin 
- printf("\e[;0H"); 
- printf("CPSF Controller Tester\n"); 
- printf("Press ESC to quit.\n\n"); 
-  
- // unset PC4, this is the controller clock/button group select pin 
- *joycontrolword = 8; 
- // read joyport a bits 
- port1 |= (~*joyport_a)<<8; 
-  
- // set PC4 
- *joycontrolword = 9; 
- // read joyport a bits 
- port1 |= (uint8_t)(~*joyport_a); 
-  
- printf("0x%04X\n", port1); 
-  
- // quit on ESC 
- if(_iocs_bitsns(0) == 2){ 
- *joycontrolword = 8; 
- *joyport_c = joyport_c_old; 
- _iocs_b_super(usp); 
- return 0; 
- } 
- } 
-} 
-</file> 
 
 x68000/cpsfdev.txt ยท Last modified: 2019/08/27 20:45 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Driven by DokuWiki