|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#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" |
| #define __NOLIBBASE__ |
| #define IESIZE 22 /* ief-ie */ |
|
static |
| BLITZ_ALIAS | ( | doabsmouse | , |
| doabsmouse_c | ) |
| BLITZ_ALIAS | ( | doclickbutton | , |
| doclickbutton_c | ) |
| BLITZ_ALIAS | ( | dofreemacrokey | , |
| dofreemacrokey_c | ) |
| BLITZ_ALIAS | ( | doloadtape | , |
| doloadtape_c | ) |
| BLITZ_ALIAS | ( | domacrokey | , |
| domacrokey_c | ) |
| BLITZ_ALIAS | ( | domousebutton | , |
| domousebutton_c | ) |
| BLITZ_ALIAS | ( | doplayback | , |
| doplayback_c | ) |
| BLITZ_ALIAS | ( | doplayback2 | , |
| doplayback2_c | ) |
| BLITZ_ALIAS | ( | doplaywait | , |
| doplaywait_c | ) |
| BLITZ_ALIAS | ( | doplaywait2 | , |
| doplaywait2_c | ) |
| BLITZ_ALIAS | ( | dorecord | , |
| dorecord_c | ) |
| BLITZ_ALIAS | ( | dorecord2 | , |
| dorecord2_c | ) |
| BLITZ_ALIAS | ( | dorelmouse | , |
| dorelmouse_c | ) |
| BLITZ_ALIAS | ( | dosavetape | , |
| dosavetape_c | ) |
| BLITZ_ALIAS | ( | dotapeadd | , |
| dotapeadd_c | ) |
| BLITZ_ALIAS | ( | dotapeadd2 | , |
| dotapeadd2_c | ) |
| BLITZ_ALIAS | ( | dotapemode | , |
| dotapemode_c | ) |
| BLITZ_ALIAS | ( | doxstatus | , |
| doxstatus_c | ) |
| void brexxlib_codefinit | ( | void | ) |
| void brexxlib_codeinit | ( | void | ) |
|
static |
|
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).
|
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.
|
static |
| void doabsmouse | ( | void | ) |
|
static |
| void doclickbutton | ( | void | ) |
|
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".
| b | d0.w: the button, 0 = left, otherwise right |
| void dofreemacrokey | ( | void | ) |
|
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.
| key | d0: the raw key code (low byte) |
| qual | d1: the qualifier (low byte) |
| void doloadtape | ( | void | ) |
|
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).
| name | d1: the file name |
| dos | a6: dos.library |
| void domacrokey | ( | void | ) |
|
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).
| key | d1: the raw key code (low byte) |
| qual | d2: the qualifier (low byte) |
| void domousebutton | ( | void | ) |
|
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.
| b | d0.w: the button, 0 = left, otherwise right |
| on | d1.w: 0 = released, otherwise pressed |
|
static |
| void doplayback | ( | void | ) |
| void doplayback2 | ( | 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).
|
static |
PlayBack: stop a playback.
Restores the link the handler hijacked (if mode is 2).
| void doplaywait | ( | void | ) |
| void doplaywait2 | ( | 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).
|
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").
| void doqplay | ( | void | ) |
|
static |
QuickPlay On|Off: play tapes without their timing.
On: the handler plays all events of the tape at once.
| v | d0.w: 0 = Off, otherwise On |
| void dorecord | ( | void | ) |
| void dorecord2 | ( | 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).
|
static |
Record: stop recording.
The start time goes into the tape being recorded (if mode is 1).
| void dorelmouse | ( | void | ) |
|
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).
| void dosavetape | ( | void | ) |
|
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).
| name | d1: the file name |
| dos | a6: dos.library |
| void dotapeadd | ( | void | ) |
| void dotapeadd2 | ( | 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).
|
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.
| void dotapemode | ( | void | ) |
|
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.
| v | d0.w: 0 = Off, otherwise On |
| void dotype | ( | void | ) |
|
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).
| s | d0: the string |
| lens | a2: the argument stack, -4(a2) = the string's length |
| void doxstatus | ( | 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).
|
static |
|
static |
| void freetape | ( | void | ) |
|
static |
|
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.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| struct IOStdReq io |
| struct { ... } io_request |
|
static |
|
static |
| const char mess1[] = "Can't Open File" |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void port |
|
static |
|
static |
|
static |
|
static |