|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzexec.h"#include <intuition/intuition.h>#include <proto/intuition.h>Macros | |
| #define | __NOLIBBASE__ |
| #define | IntuitionBase myint |
Functions | |
| static void | codeinit (void) |
| Library init: open intuition, remember a5 and install the trap handler. | |
| static void | codefinit (void) |
| Library finit: close intuition. | |
| void | printerr (ULONG msg) |
| printerr - show a runtime error and end the program ("user
mode...OK to generate error"). | |
| void | tasktrap (void) |
| void | traps (void) |
Variables | |
| static const char | intname [] = "intuition.library" |
| APTR | oldtc |
| UBYTE * | olda5 |
| struct IntuitionBase * | myint |
| UWORD | errpend |
| ULONG | errmsg |
| ULONG | intstack [2 *8] |
| ULONG * | intsp |
| static UBYTE | maxerrtext [] = "No currently used object!" |
| static UBYTE | braerrtext [] = "Offset out of range" |
| static UBYTE | eoptext [] = "End of Program" |
| static UBYTE | text2 [] = "OKAY!" |
| static UBYTE | text3 [] = "OKAY!" |
| static struct IntuiText | bodytext = { 1, 0, 0, 0, 8, NULL, NULL, NULL } |
| static struct IntuiText | postext = { 1, 0, 0, 0, 0, NULL, text2, NULL } |
| static struct IntuiText | negtext = { 1, 0, 0, 0, 0, NULL, text3, NULL } |
| #define __NOLIBBASE__ |
| #define IntuitionBase myint |
|
static |
Library finit: close intuition.
The trap handler stays the task's: a SetInt routine can still run until intlib's finit, which comes later (finits go from the low library numbers up), and runerrlib's gosuper hands its traps to the task's handler. runerrlib's finit, the last of them, puts back the handler the program started with. (The original put its saved CPU vectors back here, #1069.)
|
static |
Library init: open intuition, remember a5 and install the trap handler.
Fixed (#1069): tasktrap becomes the task's trap handler (tc_TrapCode; the old one is kept in oldtc), the CPU's vector table is not touched. The original saved the vectors of TRAP #0..#5 (VBR from runerrlib's getvbr, $C31D) and put mytrap0..mytrap5 there. errpend (the original's ctrlc) is cleared. OldOpenLibrary is not checked.
| void printerr | ( | ULONG | msg | ) |
printerr - show a runtime error and end the program ("user mode...OK to generate error").
The TRAP #0 handler continues here in user mode (the TRAP #1 handler too, with the message of a SetInt routine's runtime error, #1073). a5 is set back to the globals of the init, the message is shown in an AutoRequest (64,64,640,64, both gadgets "OKAY!") and the program ends through exitslib's endjmp ($C800). Never returns.
Fixed (intended deviation, #6): the numeric codes 1-3 that blitz2's code raises get the texts of debuglib (1 "No currently used object!": the used object test; 2 "Offset out of range": the bounds check of an array field of a NewType; 3 "End of Program": blitz2 appends moveq #3,d0:trap #0 (eopcode) to a program compiled with runtime errors on, End jumps behind it). The original took d0 as the message pointer as it is: the requester of these codes had an empty text.
| msg | d0: the message (C string) of the runtime error, or one of the codes 1-3 |
| void tasktrap | ( | void | ) |
| void traps | ( | void | ) |
|
static |
|
static |
|
static |
| ULONG errmsg |
| UWORD errpend |
|
static |
| ULONG* intsp |
| ULONG intstack[2 *8] |
|
static |
| void myint |
|
static |
| UBYTE* olda5 |
| APTR oldtc |
|
static |
|
static |
|
static |