Copyright (c) Hyperion Entertainment and contributors.
Potgo Resource
The potgo resource is used to get control of the hardware POTGO register connected to the proportional I/O pins on the game controller ports. There are two registers, POTGO (write-only) and POTINP (read-only). These pins could also be used for digital I/O.
The potgo resource provides three functions for working with the POTGO hardware.
Potgo Resource Functions
| AllocPotBits() | Allocate bits in the POTGO register. |
| FreePotBits() | Free previously allocated bits in the POTGO register. |
| WritePotgo() | Set and clear bits in the POTGO register. The bits must have been allocated before calling this function. |
The example program shown below demonstrates how to use the ptogo resource to track mouse button presses on port 1.
/*
* Read_Potinp.c
*
* An example of using the potgo.resource to read pins 9 and 5 of
* port 1 (the non-mouse port). This bypasses the gameport.device.
* When the right or middle button on a mouse plugged into port 1 is pressed,
* the read value will change.
*
* Use of port 0 (mouse) is unaffected.
*
* Compile with SAS C 5.10 lc -b1 -cfistq -v -y -L
*
* Run from CLI only
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <resources/potgo.h>
#include <hardware/custom.h>
#include <clib/exec_protos.h>
#include <clib/potgo_protos.h>
#include <stdio.h>
#ifdef LATTICE
int CXBRK(void) {return(0);} /* Disable SAS Ctrl-C checking */
int chkabort(void) { return(0); } /* really */
#endif
struct PotgoBase *PotgoBase;
ULONG potbits;
UWORD value;
#define UNLESS(x) if(!(x))
#define UNTIL(x) while(!(x))
#define OUTRY 1L<<15
#define DATRY 1L<<14
#define OUTRX 1L<<13
#define DATRX 1L<<12
extern struct Custom far custom;
void main(int argc,char **argv)
{
UNLESS (PotgoBase=(struct PotgoBase *)OpenResource("potgo.resource"))
return;
potbits=AllocPotBits(OUTRY|DATRY|OUTRX|DATRX);
/* Get the bits for the right and middle mouse buttons on the alternate mouse port. */
if (potbits != (OUTRY|DATRY|OUTRX|DATRX))
{
printf("Pot bits are already allocated! %lx\n",potbits);
FreePotBits(potbits);
return;
}
/* Set all ones in the register (masked by potbits) */
WritePotgo(0xFFFFFFFFL,potbits);
printf("\nPlug a mouse into the second port. This program will indicate when\n");
printf("the right or middle button (if the mouse is so equipped) is pressed.\n");
printf("Stop the program with Control-C. Press return now to begin.\n");
getchar();
UNTIL (SIGBREAKF_CTRL_C & SetSignal(0L,0L))
/* until CTRL-C is pressed */
{
/* Read word at $DFF016 */
value = custom.potinp;
/* Show what was read (restricted to our allocated bits) */
printf("POTINP = $%lx\n",value & potbits);
}
FreePotBits(potbits);
}
Additional programming information on the potgo resource can be found in the include files and the Autodocs for the potgo resource.
Potgo Resource Information
Includes & resources/potgo.h
& resources/potgo.i
& utility/hooks.h
& utility/hooks.i
AutoDocs & potgo.doc