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

Data Structures

struct  zone
struct  zonetable
struct  zdata

Macros

#define ZD_ZONETABLE   2
#define ZD_ZONES020   70
#define ASLW(d, n)
#define INCW(d)
#define S_(x)
#define ZONEINFO(f, member)
#define CIAA_PRA   (*(volatile UBYTE *)0xbfe001) /* /FIR1 bit 7, /FIR0 bit 6 */
 GetZoneX1(zone): the start x of a zone (see ZONEINFO).
#define CIAA_PRB   (*(volatile UBYTE *)0xbfe101) /* parallel port data */
#define CIAA_DDRA   (*(volatile UBYTE *)0xbfe201)
#define CIAB_PRA   (*(volatile UBYTE *)0xbfd000) /* BUSY bit 0, SEL bit 2 */
#define POTGO   (*(volatile UWORD *)0xdff034)
#define POTINP   (*(volatile UWORD *)0xdff016)
#define POTINP_HI   (*(volatile UBYTE *)0xdff016) /* BTST #n,$dff016 */
#define JOY0DAT   (*(volatile UWORD *)0xdff00a)
#define JOY1DAT   (*(volatile UWORD *)0xdff00c)

Functions

void _ZoneInit1 (void)
void _ZoneInit2 (void)
void _ZoneInit (void)
void _SetZone2 (void)
void _SetZone (void)
void _ZoneTest (void)
void _TestZoneRange2 (void)
void _TestZoneRange (void)
void _ZoneTable (void)
void _jfire (void)
void _jvert (void)
void _jhoriz (void)
void _allfire (void)
void _allfire2 (void)
void _ZoneTableSize (void)
void _NewZoneTable (void)
void _UseZoneTable (void)
void _FreeZoneTable (void)
void _zonetablenumber (void)
void _zonemode (void)
void _setzonemode (void)
void _fouradaptor (void)
void _zoneinfox1 (void)
void _zoneinfoy1 (void)
void _zoneinfox2 (void)
void _zoneinfoy2 (void)
void _readjoypad (void)
void rizonejoylib_libfinit (void)
void _Initmem (void)
static struct zonetable ** entry (ULONG n)
static struct zone * zone (struct zonetable *zt, ULONG off)
static void free_mem (struct zonetable *table)
static void initmem_c (void)
 init: the 68020 mode and zone table 0 with 256 zones.
static void libfinit_c (void)
 finit: frees every zone table of the list.
static ULONG zoneinit_c (ULONG zonenum, ULONG lastnum)
 ZoneInit start_num,end_num: clears the zones start..end of the current table.
static ULONG zoneinit1_c (void)
 ZoneInit: clears all zones of the current table.
static ULONG zoneinit2_c (ULONG zonenum)
 ZoneInit zone_num: clears one zone of the current table.
static BB_BOOL doset (ULONG n, UWORD x1, UWORD y1, UWORD x2, UWORD y2)
static BB_BOOL setzone_c (ULONG n, UWORD x1, UWORD y1, UWORD x2, UWORD y2)
 SetZone(num,x1,y1,x2,y2): sets a rectangular zone of the current table.
static BB_BOOL setzone2_c (ULONG n, UWORD x, UWORD y, UWORD r)
 SetZone(num,x,y,radius): sets a circular zone of the current table.
void zonetests (void)
static ULONG zonetable_c (void)
 ZoneTable: the address of the current zone table.
static ULONG zonetablesize_c (void)
 ZoneTableSize: the number of zones of the current table.
static void clearzones (struct zonetable *zt)
static BB_BOOL newzonetable_c (ULONG n, ULONG num)
 NewZoneTable table#,num_zones: allocates zone table n.
static BB_BOOL usezonetable_c (ULONG n)
 UseZoneTable table#: makes table n the current one.
static BB_BOOL freezonetable_c (ULONG n)
 FreeZoneTable table#: frees zone table n (1..15).
static ULONG zonetablenumber_c (void)
 ZoneTableNumber: the number of the current zone table.
static ULONG zonemode_c (void)
 ZoneMode: -1 for the 68020 mode, 0 for the 68000 mode.
static void setzonemode_c (ULONG mode)
 SetZoneMode mode: sets the zone test mode, only on a 68020 or better.
static ULONG zoneinfo (ULONG zonenum, UWORD off)
static ULONG jfire_c (UWORD port)
 JFire(port): the fire buttons of a joystick port.
static ULONG vert (UWORD d)
static ULONG adaptor (UBYTE first, UBYTE second)
static ULONG jvert_c (UWORD port)
 JVert(port): the vertical direction of a joystick port.
static ULONG jhoriz_c (ULONG port)
 JHoriz(port): the horizontal direction of a joystick port.
static ULONG allfire2_c (UWORD bits)
 AllFire(joybits): the fire buttons of the ports asked for.
static ULONG allfire_c (void)
 AllFire: the fire buttons of all four ports (joybits %1111).
static ULONG fouradaptor_c (ULONG status)
 JAdaptorStatus On/Off: switches the reading of the four player adaptor.
static ULONG readpad (UBYTE fire, UWORD go, UWORD data)
static ULONG readjoypad_c (UWORD port)
 ReadJoyPad(port#): the buttons of a CD32 pad.

Variables

static struct zdata zd = { 1, 0, { 0 }, 0, 0 }
static UBYTE fourplayer = 0xff

Macro Definition Documentation

◆ ASLW

#define ASLW ( d,
n )
Value:
(((ULONG)(d) & 0xffff0000UL) | (UWORD)((ULONG)(d) << (n)))
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498
static struct @065163037313156332013005143365272036211065172003 d

◆ CIAA_DDRA

#define CIAA_DDRA   (*(volatile UBYTE *)0xbfe201)

◆ CIAA_PRA

#define CIAA_PRA   (*(volatile UBYTE *)0xbfe001) /* /FIR1 bit 7, /FIR0 bit 6 */

GetZoneX1(zone): the start x of a zone (see ZONEINFO).

GetZoneX2(zone): the end x (circle: radius^2) of a zone.

GetZoneY1(zone): the start y of a zone.

GetZoneY2(zone): the end y of a zone (circle: -1).

◆ CIAA_PRB

#define CIAA_PRB   (*(volatile UBYTE *)0xbfe101) /* parallel port data */

◆ CIAB_PRA

#define CIAB_PRA   (*(volatile UBYTE *)0xbfd000) /* BUSY bit 0, SEL bit 2 */

◆ INCW

#define INCW ( d)
Value:
(((ULONG)(d) & 0xffff0000UL) | (UWORD)((ULONG)(d) + 1))

◆ JOY0DAT

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

◆ JOY1DAT

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

◆ POTGO

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

◆ POTINP

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

◆ POTINP_HI

#define POTINP_HI   (*(volatile UBYTE *)0xdff016) /* BTST #n,$dff016 */

◆ S_

#define S_ ( x)
Value:
ULONG x
Definition 2dlib.c:2491
#define BL_STR(x)
Definition blitzlib.h:533

◆ ZD_ZONES020

#define ZD_ZONES020   70

◆ ZD_ZONETABLE

#define ZD_ZONETABLE   2

◆ ZONEINFO

#define ZONEINFO ( f,
member )
Value:
static ULONG BLITZ_ROUTINE f(ULONG zonenum BL_REG(d0)) \
{ \
return zoneinfo(zonenum, offsetof(struct zone, member)); \
}
#define BL_REG(r)
Definition blitzlib.h:280
#define BLITZ_ROUTINE
Definition blitzlib.h:313
static ULONG zoneinfo(ULONG zonenum, UWORD off)
Definition rizonejoylib.c:898
Definition rimapshapeslib.c:182
Definition rizonejoylib.c:308

Function Documentation

◆ _allfire()

void _allfire ( void )

◆ _allfire2()

void _allfire2 ( void )

◆ _fouradaptor()

void _fouradaptor ( void )

◆ _FreeZoneTable()

void _FreeZoneTable ( void )

◆ _Initmem()

void _Initmem ( void )

◆ _jfire()

void _jfire ( void )

◆ _jhoriz()

void _jhoriz ( void )

◆ _jvert()

void _jvert ( void )

◆ _NewZoneTable()

void _NewZoneTable ( void )

◆ _readjoypad()

void _readjoypad ( void )

◆ _SetZone()

void _SetZone ( void )

◆ _SetZone2()

void _SetZone2 ( void )

◆ _setzonemode()

void _setzonemode ( void )

◆ _TestZoneRange()

void _TestZoneRange ( void )

◆ _TestZoneRange2()

void _TestZoneRange2 ( void )

◆ _UseZoneTable()

void _UseZoneTable ( void )

◆ _zoneinfox1()

void _zoneinfox1 ( void )

◆ _zoneinfox2()

void _zoneinfox2 ( void )

◆ _zoneinfoy1()

void _zoneinfoy1 ( void )

◆ _zoneinfoy2()

void _zoneinfoy2 ( void )

◆ _ZoneInit()

void _ZoneInit ( void )

◆ _ZoneInit1()

void _ZoneInit1 ( void )

◆ _ZoneInit2()

void _ZoneInit2 ( void )

◆ _zonemode()

void _zonemode ( void )

◆ _ZoneTable()

void _ZoneTable ( void )

◆ _zonetablenumber()

void _zonetablenumber ( void )

◆ _ZoneTableSize()

void _ZoneTableSize ( void )

◆ _ZoneTest()

void _ZoneTest ( void )

◆ adaptor()

ULONG adaptor ( UBYTE first,
UBYTE second )
static

◆ allfire2_c()

ULONG allfire2_c ( UWORD bits)
static

AllFire(joybits): the fire buttons of the ports asked for.

Bit n-1 of joybits asks for port n (1..4; 3 and 4 only with the four player adaptor switched on).

Parameters
bitsd0.b: the ports
Returns
d0: a bit per pressed fire button (bit n-1 = port n)

◆ allfire_c()

ULONG allfire_c ( void )
static

AllFire: the fire buttons of all four ports (joybits %1111).

Returns
d0: a bit per pressed fire button

◆ clearzones()

void clearzones ( struct zonetable * zt)
static

◆ doset()

BB_BOOL doset ( ULONG n,
UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2 )
static

◆ entry()

struct zonetable ** entry ( ULONG n)
static

◆ fouradaptor_c()

ULONG fouradaptor_c ( ULONG status)
static

JAdaptorStatus On/Off: switches the reading of the four player adaptor.

On by default ($FF); with 0, ports 3 and 4 read as nothing.

Parameters
statusd0.b: the new status
Returns
d0: the old status in the low byte, d0's upper bytes kept

◆ free_mem()

void free_mem ( struct zonetable * table)
static

◆ freezonetable_c()

BB_BOOL freezonetable_c ( ULONG n)
static

FreeZoneTable table#: frees zone table n (1..15).

The entry is cleared: fixed (#868), the original left the freed block there. Table 0 always becomes the current one, as the manual documents ("change the currently used zonetable to table number 0"; no defect, #869). Fixed (#872): n is compared unsigned, a negative n is refused (the original freed the current table).

Parameters
nd0: the table number
Returns
d0: BB_TRUE done, BB_FALSE bad number or no such table

◆ initmem_c()

void initmem_c ( void )
static

init: the 68020 mode and zone table 0 with 256 zones.

is020 and the 68020 mode from AttnFlags (AFB_68020); table 0 (2052 bytes, MEMF_PUBLIC) is the current one, all zones cleared; without memory there is no table. All 16 entries of the list are cleared: fixed (#871), the original cleared only entry 0, so the next run of a program with the library still loaded found the tables of the run before, freed by its finit. The four player adaptor's status is set to on, the manual's default: fixed (#1132), the original kept the status of the run before (after JAdaptorStatus Off the next run started with the adaptor off).

◆ jfire_c()

ULONG jfire_c ( UWORD port)
static

JFire(port): the fire buttons of a joystick port.

Ports 1, 2: CIAA PRA /FIR1 resp. /FIR0, the second button through POTGO/POTINP; ports 3, 4: the four player adaptor (CIAB PRA SEL/BUSY), 0 if it is switched off (JAdaptorStatus).

Parameters
portd0.b: the port 1..4
Returns
d0: 1 = fire, + 2 = the second button (ports 1, 2); 0 for other ports

◆ jhoriz_c()

ULONG jhoriz_c ( ULONG port)
static

JHoriz(port): the horizontal direction of a joystick port.

As JVert; port 1 "right" returns d0 unchanged (the port number 1, which is also the result for "right": no defect).

Parameters
portd0.b: the port 1..4
Returns
d0: -1 left, 1 right, 0 none (or another port)

◆ jvert_c()

ULONG jvert_c ( UWORD port)
static

JVert(port): the vertical direction of a joystick port.

Ports 1, 2: JOY1DAT resp. JOY0DAT; ports 3, 4: the four player adaptor in CIAA PRB (0 if switched off).

Parameters
portd0.b: the port 1..4
Returns
d0: -1 up, 1 down, 0 none (or another port)

◆ libfinit_c()

void libfinit_c ( void )
static

finit: frees every zone table of the list.

Then the entries and the current table are cleared: fixed (#871), the original left them set for the next run of a program with the library still loaded (from the editor), whose finit freed them again.

◆ newzonetable_c()

BB_BOOL newzonetable_c ( ULONG n,
ULONG num )
static

NewZoneTable table#,num_zones: allocates zone table n.

n 1..15, num_zones 1..65535 (1: fixed, #1136, the original refused a table of one zone, which the manual allows; the manual's 65536 is refused, the zone loops count in words, #1137); an old table of that number is freed first. All zones of the new table are cleared and the current table stays as it is; a replaced current table stays current under its new block: fixed (#875), the original ran ZoneInit on the current table and left AllocMem's garbage in the new one. If the AllocMem fails after the free, the table no longer exists (its entry cleared, 0 returned) and, if it was the current one, table 0 becomes current: fixed (#874, D-018), the original left the freed block in the entry and in _zonetable. Fixed (#872): n is compared unsigned, a negative n is refused (the original passed it: entry -1 is _zonetable).

Parameters
nd0: the table number
numd1: the number of zones
Returns
d0: BB_TRUE done, BB_FALSE bad arguments or no memory

◆ readjoypad_c()

ULONG readjoypad_c ( UWORD port)
static

ReadJoyPad(port#): the buttons of a CD32 pad.

Clocks the pad's shift register through the fire line (see readpad). Every port number but 2 reads the joystick port: documented, no defect (#877; the manual names 1 for the joystick port and 2 for the mouse port, and its example reads the joystick port with ReadJoyPad(0)).

Parameters
portd0.w: the port (2 = the mouse port, any other number the joystick port)
Returns
d0: bits 7..0 = B, R, Y, G, FF, RW, PL, 0 (as the help text)

◆ readpad()

ULONG readpad ( UBYTE fire,
UWORD go,
UWORD data )
static

◆ rizonejoylib_libfinit()

void rizonejoylib_libfinit ( void )

◆ setzone2_c()

BB_BOOL setzone2_c ( ULONG n,
UWORD x,
UWORD y,
UWORD r )
static

SetZone(num,x,y,radius): sets a circular zone of the current table.

x1, y1 = the centre, x2 = radius^2 (a word), y2 = -1. The radius is a word, like the coordinates (the original's MULS.w); one outside 0-255 is refused (BB_FALSE, nothing stored): fixed (#867, W7 decision Q1 (a)), the original stored the radius squared's low word, so radius 256 and more wrapped (256: 0, 300: 24464). Results otherwise as the rectangle form.

Parameters
nd0: the zone number
xd1: the centre x
yd2: the centre y
rd3: the radius (a word, 0-255)
Returns
d0: BB_TRUE done, BB_FALSE no table, out of range or a radius outside 0-255

◆ setzone_c()

BB_BOOL setzone_c ( ULONG n,
UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2 )
static

SetZone(num,x1,y1,x2,y2): sets a rectangular zone of the current table.

The corners are ordered (EXG) so that x1 < x2 and y1 < y2 (the manual's "x2,y2 should be the bottom left" means the bottom right; either order works, #1137). Without a table the result is 0: fixed (#876, the original returned -1, "done"). num is compared unsigned: fixed (#873), the original wrote a negative num before the table. A rectangle whose bottom edge (the larger y) is -1 is refused: fixed (#866), y2 = -1 marks a circle, the original stored it and the zone tests took it for a circle.

Parameters
nd0: the zone number
x1d1: a corner x
y1d2: a corner y
x2d3: the other corner x
y2d4: the other corner y
Returns
d0: BB_TRUE done, BB_FALSE no table, out of range or a bottom edge of -1

◆ setzonemode_c()

void setzonemode_c ( ULONG mode)
static

SetZoneMode mode: sets the zone test mode, only on a 68020 or better.

Both modes give the same results for every zone SetZone makes (#866, #879, #880 fixed); the mode only chooses the instructions of Zone and ZoneTest (CMP2 in the 68020 mode).

Parameters
moded0.b: the mode byte (non-zero: 68020 mode)

◆ usezonetable_c()

BB_BOOL usezonetable_c ( ULONG n)
static

UseZoneTable table#: makes table n the current one.

Fixed (#872): n is compared unsigned, a negative n is refused (the original passed it and selected entry -1, _zonetable itself).

Parameters
nd0: the table number (< 16)
Returns
d0: BB_TRUE done, BB_FALSE n too large or no such table

◆ vert()

ULONG vert ( UWORD d)
static

◆ zone()

struct zone * zone ( struct zonetable * zt,
ULONG off )
static

◆ zoneinfo()

ULONG zoneinfo ( ULONG zonenum,
UWORD off )
static

◆ zoneinit1_c()

ULONG zoneinit1_c ( void )
static

ZoneInit: clears all zones of the current table.

Without a table the original reads the count from address 0 - not observable, left out.

Returns
d0: as ZoneInit start,end; -1 without a table

◆ zoneinit2_c()

ULONG zoneinit2_c ( ULONG zonenum)
static

ZoneInit zone_num: clears one zone of the current table.

The number is compared unsigned: fixed (#873), the original checked only the upper bound (CMP.l : BMI), a negative number wrote before the table.

Parameters
zonenumd0: the zone
Returns
d0: the zone's byte offset, -1 without a table or out of range

◆ zoneinit_c()

ULONG zoneinit_c ( ULONG zonenum,
ULONG lastnum )
static

ZoneInit start_num,end_num: clears the zones start..end of the current table.

x1..y2 = -1 (not set). The numbers are compared unsigned: fixed (#873), the original passed a negative start (CMP.l : BMI).

Parameters
zonenumd0: the first zone
lastnumd1: the last zone
Returns
d0: end + 1 (the low word), -1 without a table or for a bad range

◆ zonemode_c()

ULONG zonemode_c ( void )
static

ZoneMode: -1 for the 68020 mode, 0 for the 68000 mode.

MOVE.b zones020,d0: the thunk replaces the low byte of d0 only.

Returns
d0.b: the mode byte ($FF or 0, or what SetZoneMode stored)

◆ zonetable_c()

ULONG zonetable_c ( void )
static

ZoneTable: the address of the current zone table.

The table: the zone count (a long), then per zone x1, x2, y1, y2 (words, 8 bytes); a circle has the radius squared in x2 and -1 in y2; table 0 is 2052 bytes. The manual differs ("+0: x1, +2: y1, +4: x2, +6: y2", "+4: radius of zone", "8 words (16 bytes)", "2048 bytes"); the library's layout is the one programs use (#1137).

Returns
d0: the table, 0 if none (fixed, #876: the original returned -1)

◆ zonetablenumber_c()

ULONG zonetablenumber_c ( void )
static

ZoneTableNumber: the number of the current zone table.

Returns
d0: its index in the list, -1 without a table (or not listed)

◆ zonetablesize_c()

ULONG zonetablesize_c ( void )
static

ZoneTableSize: the number of zones of the current table.

Returns
d0: the count, 0 without a table

◆ zonetests()

void zonetests ( void )

Variable Documentation

◆ fourplayer

UBYTE fourplayer = 0xff
static

◆ zd

struct zdata zd = { 1, 0, { 0 }, 0, 0 }
static