There's an 8-bit data direction register (DDR) that controlls the direction of the 8 data lines plus an 8-bit register that you read/write input/output states.
There's also three "control" lines which can also be set in direction and read the input state or change the output state.
All of these 8+3 lines can be individually set as inputs or outputs as you want them.
Example in C:
// Amiga register addresses
#define PARALLEL_DDR 0xBFE301 // System address of parallel port data direction register
#define PARALLEL_DATA 0xBFE101 // System address of paralled port data register
#define PAR_CTRL_DDR 0xBFD200 // System address of parallel port control line data direction register
#define PAR_CTRL_DATA 0xBFD000 // System address of parallel port control line data register
// Amiga register values
#define PARALLEL_DATA_OUTPUT 0xFF // Set parallel data direction to output
#define PARALLEL_DATA_INPUT 0x00 // Set parallel data direction to input
#define PARALLEL_CTRL_OUTPUT 0x07 // Set sel, pout, busy as outputs
/**********************************************************
write_data_latch
Writes single byte of data to programmer data latch
Arguments: unsigned char data_to_write
Return: none
Working:
**********************************************************/
void write_data_latch(unsigned char data_to_write)
{
// Write data to port
*parallel_ddr = PARALLEL_DATA_OUTPUT;
*parallel_data = data_to_write;
// Toggle data latch LE
*par_ctrl_data = *par_ctrl_data & (~DATA_LATCH_ON);
*par_ctrl_data = *par_ctrl_data | LATCH_IDLE;
}
Reading input lines is as simple as reading from system address 0xBFE101
Lines that are set as inputs will have a state of 1 or 0 depending on the 5V or 0V input state. If some lines are set as outputs, their current output state will be read in reads to 0xBFE101
That will work just like that, but to be "system friendly", you should declare to have the hardware resource open, then close it when the program exits.
e.g.
// Allocate the parallel port
if (MiscBase=OpenResource(MISCNAME))
{
pport_bits_owner = AllocMiscResource(MR_PARALLELBITS,"Your program name");
pport_port_owner = AllocMiscResource(MR_PARALLELPORT,"Your program name");
// If parallel port was successfully allocated
if ((pport_bits_owner==NULL) && (pport_port_owner==NULL))
{
// Here's where your program does its thing....
}
// Else the parallel port is busy
else
{
printf(" Can't allocate parallel port resources!\n");
printf(" The port may be in use by another application.\n\n");
}
// Clean up resources - do this when your program exits
if (pport_bits_owner==0){FreeMiscResource(MR_PARALLELBITS);}
if (pport_port_owner==0){FreeMiscResource(MR_PARALLELPORT);}
}
Should be easy enough do to in BASIC as well. Been a few years, but I guess it'd be something like:
REM set data lines as outputs
poke(hBFE301, hFF)
REM set output line states to 10101010
poke(hBFE101, hAA)
I can't remember how you state hex numbers in BASIC.
Look on Aminet as well, Barry Walker wrote some demo stuff that shows how to do the same sort of thing in ARexx.