// FControl.c - James Rutherford // Version 1:5 - 4th January 1998 #include "fcont1_5.h" /* Sets up the low-level port buffers */ void FSetPortBuffers(void) { GetPadBuf(&X_fcontportbuf[0], &X_fcontportbuf[1]); } /* Checks the specified port for the connection of a controller Logical FALSE is returned (0) if no controller is connected, Logical TRUE is returned (1) if a controller is connected. */ u_char FControllerConnected(u_char port) { u_char connected_val = *(X_fcontportbuf[port]); switch(connected_val){ case 0: return TRUE; default: return FALSE; } } /* Returns the upper 4 bits of [buffer_address+1 byte], which indicates the controller type. The returned result should match one of CONTYPE_xxx */ u_char FControllerType(u_char port) { return (*(X_fcontportbuf[port]+1)>>4); } /* Returns the input data from a STANDARD PAD attached to the specified port */ u_short FSPadRead (u_char port) { return ~(*(X_fcontportbuf[port]+2)<<8|*(X_fcontportbuf[port]+3)); } /* Returns the input data from a ANALOGUE PAD attached to the specified port */ u_short FAPadRead (u_char port) { return ~(*(X_fcontportbuf[port]+2)<<8|*(X_fcontportbuf[port]+3)); } /* Returns the input data from a ANALOGUE JOYSTICK attached to the specified port */ u_short FAJoyRead (u_char port) { return ~(*(X_fcontportbuf[port]+2)<<8|*(X_fcontportbuf[port]+3)); } /* Returns an integer between 0 and 255 for an analogue pad stick motion on the specified port with byte as offset */ u_char FAPadStick255 (u_char port, u_char byte) { return (*(X_fcontportbuf[port]+byte)); } /* Returns an integer between 0 and 255 for an analogue joystick stick motion on the specified port with byte as offset */ u_char FAJoyStick255 (u_char port, u_char byte) { return (*(X_fcontportbuf[port]+byte)); }