BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
gameiolib.c File Reference
#include "blitzlib.h"

Macros

#define JOY0DAT   (*(volatile UWORD *)0xdff00a)
#define JOY1DAT   (*(volatile UWORD *)0xdff00c)
#define POTGOR   (*(volatile UWORD *)0xdff016)
#define POTGORH   (*(volatile UBYTE *)0xdff016) /* BTST #n,$DFF016: high byte */
#define POTGO   (*(volatile UWORD *)0xdff034)
#define CIAAPRA   ((volatile UBYTE *)0xbfe001) /* +$200 = DDRA */

Functions

void _joyx (void)
 Joyx(Port): the horizontal direction of the joystick.
void _joyy (void)
 Joyy(Port): the vertical direction of the joystick.
void _joyr (void)
 Joyr(Port): the direction of the joystick as 0..8.
void _joyb (void)
 Joyb(Port): the joystick/mouse buttons.
void _joychk (void)
ULONG _gameb (UWORD port)
 Gameb(Port): the buttons of a CD32 pad.
static void _joychk_c (UWORD port)

Macro Definition Documentation

◆ CIAAPRA

#define CIAAPRA   ((volatile UBYTE *)0xbfe001) /* +$200 = DDRA */

◆ JOY0DAT

#define JOY0DAT   (*(volatile UWORD *)0xdff00a)

◆ JOY1DAT

#define JOY1DAT   (*(volatile UWORD *)0xdff00c)

◆ POTGO

#define POTGO   (*(volatile UWORD *)0xdff034)

◆ POTGOR

#define POTGOR   (*(volatile UWORD *)0xdff016)

◆ POTGORH

#define POTGORH   (*(volatile UBYTE *)0xdff016) /* BTST #n,$DFF016: high byte */

Function Documentation

◆ _gameb()

ULONG _gameb ( UWORD port)

Gameb(Port): the buttons of a CD32 pad.

The fire line is switched to output (CIAA DDRA), POTGO set, then 7 bits are clocked out with the fire line (each after 8 CIA reads as delay) and read from POTGOR. At the end POTGO drives pin 5 of the port high again: $3000 for port 1, $0300 for port 0. Fixed (#415): the original wrote $3000 also for port 0 (the DBF of the port 0 loop jumps into the loop of port 1). Errors (debugger): Port must be 0 or 1.

Parameters
portd0: the port (0 or anything else = 1)
Returns
d0: 1 play/pause, 2 reverse, 4 forward, 8 green, 16 yellow, 32 red, 64 blue (a bit is set when the line is low)

◆ _joyb()

void _joyb ( void )

Joyb(Port): the joystick/mouse buttons.

Left button: CIAA PRA bit 6 (port 0) / 7 (port 1); right button: bit 2 / 6 of the byte $DFF016 (POTGOR bits 10/14; port 1 first writes POTGO = $C000). The original's code. Errors (debugger): Port must be 0 or 1.

In: d0.w the port (0 or anything else = 1) Out: d0 bit 0 = left, bit 1 = right button; only d0 changed

◆ _joychk()

void _joychk ( void )

◆ _joychk_c()

void _joychk_c ( UWORD port)
static

◆ _joyr()

void _joyr ( void )

Joyr(Port): the direction of the joystick as 0..8.

0..7 clockwise from up, 8 = centre/invalid. The original looks the value up in the table rots (8,2,8,6, 4,3,8,5, 8,8,8,8, 0,1,8,7) at (Joyx & 3) * 2 + (Joyy & 3) * 8, through BSR _joyx and BSR _joyy2; Joyx and Joyy depend only on the bits 9, 8, 1 and 0 of the counter word, so here one table of 16 longs indexed by those bits holds the original's results, d0 as a whole (checked for every counter word): not a bug (word function), the upper word of d0 is the one of Joyy's MOVEQ, $FFFF for up. Changes d0 and d1 (the original d0-d3). Errors (debugger): Port must be 0 or 1.

In: d0.w the port Out: d0.w the direction

◆ _joyx()

void _joyx ( void )

Joyx(Port): the horizontal direction of the joystick.

From JOY0DAT (port 0) or JOY1DAT (any other port): bit 9 = left, bit 1 = right (the original's MOVEQ/BTST chain). Changes d0 and d1. Errors (debugger): Port must be 0 or 1.

In: d0.w the port Out: d0 -1 left, 1 right, 0 neither (a long, MOVEQ)

◆ _joyy()

void _joyy ( void )

Joyy(Port): the vertical direction of the joystick.

From JOY0DAT/JOY1DAT: bit 8 ^ bit 9 = up, bit 0 ^ bit 1 = down (the original's MOVE d1,d2:LSR #1,d2:EOR d2,d1, here with d0 as the scratch register instead of d2). Changes d0 and d1. Errors (debugger): Port must be 0 or 1.

In: d0.w the port Out: d0 -1 up, 1 down, 0 neither (a long, MOVEQ)