BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
brexxlib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"
#include <exec/io.h>
#include <exec/interrupts.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <proto/dos.h>

Data Structures

struct  tape
struct  mkey

Macros

#define __NOLIBBASE__
#define TAPEOBJ   LIB_brexxlib, BL_IA3|BL_PD0 /* a3 = tape object */
#define IESIZE   22 /* ief-ie */
#define NHIJACK   8 /* more links of one handler call */
#define DOSBase   dosbase /* for proto/dos.h */

Functions

void dorecord (void)
void dorecord2 (void)
void doplayback (void)
void doplayback2 (void)
void dosavetape (void)
void doloadtape (void)
void doabsmouse (void)
void dorelmouse (void)
void domousebutton (void)
void doclickbutton (void)
void domacrokey (void)
void dotapeadd (void)
void dotapeadd2 (void)
void dotapemode (void)
void dotype (void)
void doqplay (void)
void doxstatus (void)
void doplaywait (void)
void doplaywait2 (void)
void dofreemacrokey (void)
void brexxlib_codeinit (void)
void brexxlib_codefinit (void)
void freetape (void)
static struct InputEvent * my_handler (struct InputEvent *ev)
static void * globalloc (ULONG size)
static void globfree (void *mem, ULONG size)
static void copyw (UWORD *d, const UWORD *s, UWORD n)
static void waitlast (void)
static void clearie (void)
static void inject (void)
static void addtape (void)
static ULONG doxstatus_c (void)
 XStatus: what BREXX is doing.
 BLITZ_ALIAS (doxstatus, doxstatus_c)
static void doqplay_c (ULONG v)
 QuickPlay On|Off: play tapes without their timing.
 BLITZ_ALIAS (doqplay, doqplay_c)
static void dotapeadd_c (void)
 TapeTrap: end the redirection of the simple events to a tape.
 BLITZ_ALIAS (dotapeadd, dotapeadd_c)
static void dotapeadd2_c (void)
 TapeTrap Tape#: append the simple events to a tape.
 BLITZ_ALIAS (dotapeadd2, dotapeadd2_c)
static void dotapemode_c (ULONG v)
 QuietTrap On|Off: whether trapped events are only appended.
 BLITZ_ALIAS (dotapemode, dotapemode_c)
static void freemacrokey (UBYTE key, UBYTE qual)
static void dofreemacrokey_c (ULONG key, ULONG qual)
 FreeMacroKey Rawkey,Qualifier: remove a macro key.
 BLITZ_ALIAS (dofreemacrokey, dofreemacrokey_c)
static void domacrokey_c (ULONG key, ULONG qual)
 MacroKey Tape#,Rawkey,Qualifier: a key that plays a tape.
 BLITZ_ALIAS (domacrokey, domacrokey_c)
static void movemouse (ULONG x, ULONG y, UBYTE class, UWORD qual)
static void doabsmouse_c (ULONG x, ULONG y)
 AbsMouse X,Y: a POINTERPOS event to X,Y.
 BLITZ_ALIAS (doabsmouse, doabsmouse_c)
static void dorelmouse_c (ULONG x, ULONG y)
 RelMouse X Offset,Y Offset: a relative mouse move.
 BLITZ_ALIAS (dorelmouse, dorelmouse_c)
static void mousebutton (ULONG b, ULONG on)
static void domousebutton_c (ULONG b, ULONG on)
 MouseButton Button,On|Off: a mouse button event.
 BLITZ_ALIAS (domousebutton, domousebutton_c)
static void doclickbutton_c (ULONG b)
 ClickButton Button: a mouse button press and release.
 BLITZ_ALIAS (doclickbutton, doclickbutton_c)
static void dotype_c (const UBYTE *s, const ULONG *lens)
 Type String$: the characters of a string as key events.
 BLITZ_ALIAS (dotype, dotype_c)
static void recordoff (void)
static void restorelinks (void)
static void playbackoff (void)
static void playback3 (struct tape *tape)
static void freetape_ (struct tape *tape)
static void freetape_c (void)
 The object's free routine: free the events of a tape.
static void dorecord_c (void)
 Record: stop recording.
 BLITZ_ALIAS (dorecord, dorecord_c)
static void dorecord2_c (void)
 Record Tape#: record the input events into a tape.
 BLITZ_ALIAS (dorecord2, dorecord2_c)
static void doplayback_c (void)
 PlayBack: stop a playback.
 BLITZ_ALIAS (doplayback, doplayback_c)
static void dopb (struct tape *tape, UWORD sig)
static void doplayback2_c (void)
 PlayBack Tape#: play a tape.
 BLITZ_ALIAS (doplayback2, doplayback2_c)
static void doplaywait_c (void)
 PlayWait: wait until the running playback has finished.
 BLITZ_ALIAS (doplaywait, doplaywait_c)
static void doplaywait2_c (void)
 PlayWait Tape#: play a tape again and wait for its end.
 BLITZ_ALIAS (doplaywait2, doplaywait2_c)
static void dosavetape_c (const char *name, struct DosLibrary *dos)
 SaveTape Tape#,Filename$: save a tape to a file.
 BLITZ_ALIAS (dosavetape, dosavetape_c)
static void doloadtape_c (const char *name, struct DosLibrary *dos)
 LoadTape Tape#,filename$: load a tape from a file.
 BLITZ_ALIAS (doloadtape, doloadtape_c)
static LONG openinput (void)
static void handlercmd (UWORD cmd)
static void codeinit_c (void)
 The init routine: open input.device and add the input handler.
static void codefinit_c (void)
 The finit routine: stop a playback, remove the handler.
static int timebefore (ULONG s1, ULONG m1, ULONG s0, ULONG m0)
static int due (const struct InputEvent *ev, const struct InputEvent *in)

Variables

static volatile UWORD mode
static volatile UWORD newstart
static struct InputEvent * lastrec
static struct InputEvent * lastlink
static struct InputEvent * hjnode [NHIJACK]
static struct InputEvent * hjlink [NHIJACK]
static UWORD nhijack
static struct timeval firstval
static struct tape * firsta3
static struct timeval playval
static struct tape * tapeadd
static UWORD trap_mode = 1
static UWORD qplay
static ULONG mysig
static struct Task * mytask
static UWORD mybit
static UWORD sigit
static struct InputEvent dumevent = { .ie_Class = IECLASS_POINTERPOS }
static struct mkey * mkeys
static struct Interrupt my_interrupt
static const char devname [] = "input.device"
struct { 
   struct IOStdReq   io 
   struct MsgPort   port 
} io_request
static UWORD dumtape [9]
static struct DosLibrary * dosbase
const char mess1 [] = "Can't Open File"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ DOSBase

#define DOSBase   dosbase /* for proto/dos.h */

◆ IESIZE

#define IESIZE   22 /* ief-ie */

◆ NHIJACK

#define NHIJACK   8 /* more links of one handler call */

◆ TAPEOBJ

#define TAPEOBJ   LIB_brexxlib, BL_IA3|BL_PD0 /* a3 = tape object */

Function Documentation

◆ addtape()

void addtape ( void )
static

◆ BLITZ_ALIAS() [1/20]

BLITZ_ALIAS ( doabsmouse ,
doabsmouse_c  )

◆ BLITZ_ALIAS() [2/20]

BLITZ_ALIAS ( doclickbutton ,
doclickbutton_c  )

◆ BLITZ_ALIAS() [3/20]

BLITZ_ALIAS ( dofreemacrokey ,
dofreemacrokey_c  )

◆ BLITZ_ALIAS() [4/20]

BLITZ_ALIAS ( doloadtape ,
doloadtape_c  )

◆ BLITZ_ALIAS() [5/20]

BLITZ_ALIAS ( domacrokey ,
domacrokey_c  )

◆ BLITZ_ALIAS() [6/20]

BLITZ_ALIAS ( domousebutton ,
domousebutton_c  )

◆ BLITZ_ALIAS() [7/20]

BLITZ_ALIAS ( doplayback ,
doplayback_c  )

◆ BLITZ_ALIAS() [8/20]

BLITZ_ALIAS ( doplayback2 ,
doplayback2_c  )

◆ BLITZ_ALIAS() [9/20]

BLITZ_ALIAS ( doplaywait ,
doplaywait_c  )

◆ BLITZ_ALIAS() [10/20]

BLITZ_ALIAS ( doplaywait2 ,
doplaywait2_c  )

◆ BLITZ_ALIAS() [11/20]

BLITZ_ALIAS ( doqplay ,
doqplay_c  )

◆ BLITZ_ALIAS() [12/20]

BLITZ_ALIAS ( dorecord ,
dorecord_c  )

◆ BLITZ_ALIAS() [13/20]

BLITZ_ALIAS ( dorecord2 ,
dorecord2_c  )

◆ BLITZ_ALIAS() [14/20]

BLITZ_ALIAS ( dorelmouse ,
dorelmouse_c  )

◆ BLITZ_ALIAS() [15/20]

BLITZ_ALIAS ( dosavetape ,
dosavetape_c  )

◆ BLITZ_ALIAS() [16/20]

BLITZ_ALIAS ( dotapeadd ,
dotapeadd_c  )

◆ BLITZ_ALIAS() [17/20]

BLITZ_ALIAS ( dotapeadd2 ,
dotapeadd2_c  )

◆ BLITZ_ALIAS() [18/20]

BLITZ_ALIAS ( dotapemode ,
dotapemode_c  )

◆ BLITZ_ALIAS() [19/20]

BLITZ_ALIAS ( dotype ,
dotype_c  )

◆ BLITZ_ALIAS() [20/20]

BLITZ_ALIAS ( doxstatus ,
doxstatus_c  )

◆ brexxlib_codefinit()

void brexxlib_codefinit ( void )

◆ brexxlib_codeinit()

void brexxlib_codeinit ( void )

◆ clearie()

void clearie ( void )
static

◆ codefinit_c()

void codefinit_c ( void )
static

The finit routine: stop a playback, remove the handler.

Removes the input handler, closes input.device and frees both signals. Fixed (#104): only the signals AllocSignal gave (the original freed 255 and 65535 after a failed one).

◆ codeinit_c()

void codeinit_c ( void )
static

The init routine: open input.device and add the input handler.

Own IOStdReq + MsgPort (the result of OpenDevice is not checked), the handler with priority 51 ("one more than intuition"); clears the macro keys, QuietTrap On, QuickPlay Off; allocates the "playback finished" signal and remembers the task. Fixed (#104): without a free signal mysig stays 0 (PlayWait then returns at once) and mybit -1 (not freed); the original took the -1 as the bit.

◆ copyw()

void copyw ( UWORD * d,
const UWORD * s,
UWORD n )
static

◆ doabsmouse()

void doabsmouse ( void )

◆ doabsmouse_c()

void doabsmouse_c ( ULONG x,
ULONG y )
static

AbsMouse X,Y: a POINTERPOS event to X,Y.

Built in dumevent and executed, or appended to the TapeTrap tape.

Parameters
xd0.w: x
yd1.w: y

◆ doclickbutton()

void doclickbutton ( void )

◆ doclickbutton_c()

void doclickbutton_c ( ULONG b)
static

ClickButton Button: a mouse button press and release.

Two MouseButton events of the button: down, then up. Fixed (#97): in the original the up event got the d0 the first call left: 0 (the left button) for an executed event, the QuietTrap value when the event went to a tape - ClickButton 0 under TapeTrap with QuietTrap On recorded "left down, RIGHT up".

Parameters
bd0.w: the button, 0 = left, otherwise right

◆ dofreemacrokey()

void dofreemacrokey ( void )

◆ dofreemacrokey_c()

void dofreemacrokey_c ( ULONG key,
ULONG qual )
static

FreeMacroKey Rawkey,Qualifier: remove a macro key.

Frees the first macro key with this raw key and qualifier (bytes); nothing if there is none.

Parameters
keyd0: the raw key code (low byte)
quald1: the qualifier (low byte)

◆ doloadtape()

void doloadtape ( void )

◆ doloadtape_c()

void doloadtape_c ( const char * name,
struct DosLibrary * dos )
static

LoadTape Tape#,filename$: load a tape from a file.

Frees the tape's events, then reads the format of SaveTape. Errors: "Can't Open File" (in the normal code; DIFF as SaveTape). A file whose start time cannot be read whole (shorter than 8 bytes) leaves the tape empty, with the start time 0 (Fixed (#101): the original took the read unchecked); the load ends at the first short event record.

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

Parameters
named1: the file name
dosa6: dos.library

◆ domacrokey()

void domacrokey ( void )

◆ domacrokey_c()

void domacrokey_c ( ULONG key,
ULONG qual )
static

MacroKey Tape#,Rawkey,Qualifier: a key that plays a tape.

Replaces a macro key with the same key and qualifier and puts the new one first in the list (10 bytes, memlib globalloc). The input handler checks RAWKEY events against the list while nothing is recorded or played and starts the tape.

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

Parameters
keyd1: the raw key code (low byte)
quald2: the qualifier (low byte)

◆ domousebutton()

void domousebutton ( void )

◆ domousebutton_c()

void domousebutton_c ( ULONG b,
ULONG on )
static

MouseButton Button,On|Off: a mouse button event.

A RAWMOUSE event (LBUTTON, or RBUTTON for Button <> 0; UP_PREFIX for Off), executed or appended to the TapeTrap tape.

Parameters
bd0.w: the button, 0 = left, otherwise right
ond1.w: 0 = released, otherwise pressed

◆ dopb()

void dopb ( struct tape * tape,
UWORD sig )
static

◆ doplayback()

void doplayback ( void )

◆ doplayback2()

void doplayback2 ( void )

◆ doplayback2_c()

void doplayback2_c ( void )
static

PlayBack Tape#: play a tape.

Nothing for an empty tape; otherwise stops a playback and starts this one (no signal at the end). The handler links the tape's events in front of the first incoming event later than them (Fixed (#100)).

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

◆ doplayback_c()

void doplayback_c ( void )
static

PlayBack: stop a playback.

Restores the link the handler hijacked (if mode is 2).

◆ doplaywait()

void doplaywait ( void )

◆ doplaywait2()

void doplaywait2 ( void )

◆ doplaywait2_c()

void doplaywait2_c ( void )
static

PlayWait Tape#: play a tape again and wait for its end.

Only while a playback runs (low byte of mode = 2): it stops it, plays the given tape (with the end signal) and waits for it (Wait(mysig)); otherwise it returns at once, as the original. Fixed (#99): with an empty tape it returns at once (the original started nothing and waited for ever); an old signal is cleared before the start.

Reads a3: the tape object (!libs{brexxlib,$1380} from the word argument in d0).

◆ doplaywait_c()

void doplaywait_c ( void )
static

PlayWait: wait until the running playback has finished.

Returns at once if no tape plays (or without a signal, Fixed (#104)); otherwise the playback gets the end signal and PlayWait waits for it. Under Forbid, so that the handler cannot end the playback between the test and the wait; an old signal (a playback of a macro key after an earlier PlayWait) is cleared first. Fixed (#99): a form of its own; the original's PlayWait needed a Tape# (its help reads "PlayWait").

◆ doqplay()

void doqplay ( void )

◆ doqplay_c()

void doqplay_c ( ULONG v)
static

QuickPlay On|Off: play tapes without their timing.

On: the handler plays all events of the tape at once.

Parameters
vd0.w: 0 = Off, otherwise On

◆ dorecord()

void dorecord ( void )

◆ dorecord2()

void dorecord2 ( void )

◆ dorecord2_c()

void dorecord2_c ( void )
static

Record Tape#: record the input events into a tape.

Stops any other recording, frees the tape's events and lets the input handler record RAWKEY, RAWMOUSE and POINTERPOS events (mode $8001: the handler first takes the time of the first event, firstval).

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

◆ dorecord_c()

void dorecord_c ( void )
static

Record: stop recording.

The start time goes into the tape being recorded (if mode is 1).

◆ dorelmouse()

void dorelmouse ( void )

◆ dorelmouse_c()

void dorelmouse_c ( ULONG x,
ULONG y )
static

RelMouse X Offset,Y Offset: a relative mouse move.

A RAWMOUSE event with the qualifier RELATIVEMOUSE and the offsets, executed or appended to the TapeTrap tape. Fixed (#98): the original made a POINTERPOS event like AbsMouse (the class 2 it passes in d2 was not used).

Parameters
xd0.w: the x offset
yd1.w: the y offset

◆ dosavetape()

void dosavetape ( void )

◆ dosavetape_c()

void dosavetape_c ( const char * name,
struct DosLibrary * dos )
static

SaveTape Tape#,Filename$: save a tape to a file.

Nothing for an empty tape; otherwise the 8 byte start time, then 18 bytes per event (the event without its link). Write errors are not checked. Errors: "Can't Open File" (in the normal code; DIFF: BEQ err1 into the error check area in the original).

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

Parameters
named1: the file name
dosa6: dos.library

◆ dotapeadd()

void dotapeadd ( void )

◆ dotapeadd2()

void dotapeadd2 ( void )

◆ dotapeadd2_c()

void dotapeadd2_c ( void )
static

TapeTrap Tape#: append the simple events to a tape.

Type, AbsMouse, RelMouse, MouseButton and ClickButton then append their events to this tape (with QuietTrap On only appended, otherwise also executed). Fixed (#96): appending an event no longer clears mode.

Reads a3: the tape object (!libs{brexxlib,$1380} from Tape# in d0).

◆ dotapeadd_c()

void dotapeadd_c ( void )
static

TapeTrap: end the redirection of the simple events to a tape.

Type, AbsMouse, RelMouse, MouseButton and ClickButton are executed again. Fixed (#95): the original falls through into TapeTrap Tape# (no RTS behind CLR.l tapeadd), so tapeadd became the caller's a3.

◆ dotapemode()

void dotapemode ( void )

◆ dotapemode_c()

void dotapemode_c ( ULONG v)
static

QuietTrap On|Off: whether trapped events are only appended.

On (the default, 1 after init): an event under TapeTrap goes to the tape only; Off: it is also executed.

Parameters
vd0.w: 0 = Off, otherwise On

◆ dotype()

void dotype ( void )

◆ dotype_c()

void dotype_c ( const UBYTE * s,
const ULONG * lens )
static

Type String$: the characters of a string as key events.

Every character as RAWKEY event (rawkeylib unconvert: d0 = raw key, d1 = qualifier), executed or appended to the TapeTrap tape. A character without a raw key (unconvert's d0 -1) is skipped (Fixed (#102): the original made it the event code $FFFF with qualifier 1).

Parameters
sd0: the string
lensa2: the argument stack, -4(a2) = the string's length

◆ doxstatus()

void doxstatus ( void )

◆ doxstatus_c()

ULONG doxstatus_c ( void )
static

XStatus: what BREXX is doing.

Fixed (#103): without bit 15, the handler's flag (the original returned $8001, $8002 or $8000 until the handler had run).

Returns
d0: mode - 0 nothing, 1 record, 2 playback (MOVEQ #0:MOVE)

◆ due()

int due ( const struct InputEvent * ev,
const struct InputEvent * in )
static

◆ freemacrokey()

void freemacrokey ( UBYTE key,
UBYTE qual )
static

◆ freetape()

void freetape ( void )

◆ freetape_()

void freetape_ ( struct tape * tape)
static

◆ freetape_c()

void freetape_c ( void )
static

The object's free routine: free the events of a tape.

Stops a playback and a recording first (just in case), then frees the tape's events.

Reads a3: the tape object.

◆ globalloc()

void * globalloc ( ULONG size)
static

◆ globfree()

void globfree ( void * mem,
ULONG size )
static

◆ handlercmd()

void handlercmd ( UWORD cmd)
static

◆ inject()

void inject ( void )
static

◆ mousebutton()

void mousebutton ( ULONG b,
ULONG on )
static

◆ movemouse()

void movemouse ( ULONG x,
ULONG y,
UBYTE class,
UWORD qual )
static

◆ my_handler()

struct InputEvent * my_handler ( struct InputEvent * ev)
static

◆ openinput()

LONG openinput ( void )
static

◆ playback3()

void playback3 ( struct tape * tape)
static

◆ playbackoff()

void playbackoff ( void )
static

◆ recordoff()

void recordoff ( void )
static

◆ restorelinks()

void restorelinks ( void )
static

◆ timebefore()

int timebefore ( ULONG s1,
ULONG m1,
ULONG s0,
ULONG m0 )
static

◆ waitlast()

void waitlast ( void )
static

Variable Documentation

◆ devname

const char devname[] = "input.device"
static

◆ dosbase

struct DosLibrary* dosbase
static

◆ dumevent

struct InputEvent dumevent = { .ie_Class = IECLASS_POINTERPOS }
static

◆ dumtape

UWORD dumtape[9]
static

◆ firsta3

struct tape* firsta3
static

◆ firstval

struct timeval firstval
static

◆ hjlink

struct InputEvent * hjlink[NHIJACK]
static

◆ hjnode

struct InputEvent* hjnode[NHIJACK]
static

◆ io

struct IOStdReq io

◆ [struct]

struct { ... } io_request

◆ lastlink

struct InputEvent* lastlink
static

◆ lastrec

struct InputEvent* lastrec
static

◆ mess1

const char mess1[] = "Can't Open File"

◆ mkeys

struct mkey* mkeys
static

◆ mode

volatile UWORD mode
static

◆ my_interrupt

struct Interrupt my_interrupt
static
Initial value:
= {
.is_Node = { .ln_Pri = 51 },
.is_Data = 0,
.is_Code = (void (*)(void))my_handler,
}
static struct InputEvent * my_handler(struct InputEvent *ev)
Definition brexxlib.c:1021

◆ mybit

UWORD mybit
static

◆ mysig

ULONG mysig
static

◆ mytask

struct Task* mytask
static

◆ newstart

volatile UWORD newstart
static

◆ nhijack

UWORD nhijack
static

◆ playval

struct timeval playval
static

◆ port

void port

◆ qplay

UWORD qplay
static

◆ sigit

UWORD sigit
static

◆ tapeadd

struct tape* tapeadd
static

◆ trap_mode

UWORD trap_mode = 1
static