BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
edstub.c File Reference
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/tasks.h>
#include <exec/io.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "edstub.h"

Data Structures

struct  comdata_s

Macros

#define STUB(n)
#define PROGMARK   0x54454470UL /* 'TEDp' */
#define CDOFF(m)
#define WIN_WIDTH   640
#define BMAPMUL   80 /* bytes per row of a 640 pixel plane */
#define BITMAP_ROWS   16 /* stripe uses rows 0..9 */
#define LOG_BEGIN   struct sb L = { lbuf, 0, sizeof lbuf }; lbuf[0] = 0
#define LOG_END   edstub_log(lbuf)
#define MAXREQ   8
#define GUARD_BYTE   0xA5
#define PROGCOLS   256 /* columns counted and pictured */

Functions

void edstub_tomain (void)
 STUB (screenclose)
 STUB (screenopen2)
 STUB (openreq)
 STUB (closereq)
 STUB (getinput)
 STUB (error)
 STUB (detokallz)
 STUB (tokall)
 STUB (ezfreq)
 STUB (refgads)
 STUB (getinput2)
 STUB (tokone)
 STUB (openio)
 STUB (closeio)
 STUB (actgad)
 STUB (pointeron)
 STUB (sleepon)
 STUB (extalloc)
 STUB (progress)
static void stripe_check (void)
void * memset (void *d, int c, size_t n)
void * memcpy (void *d, const void *s, size_t n)
ULONG edstub_strlen (const char *s)
 The length of the string s.
int edstub_prefix (const char *s, const char *pre)
 1 if s starts with pre, else 0.
int edstub_streq (const char *a, const char *b)
 1 if the strings are equal, else 0.
void edstub_strcpy (char *d, const char *s, ULONG max)
 Copy s to d, at most max - 1 characters and the 0 (nothing if max is 0).
void edstub_strcat (char *d, const char *s, ULONG max)
 Append s to d; max is the size of all of d (as edstub_strcpy).
ULONG edstub_udiv10 (ULONG u, ULONG *rem)
 u / 10 without libgcc (no __udivsi3 in a -nostdlib build); the remainder to *rem.
void sbc (struct sb *b, char c)
 Append the character c.
void sbs (struct sb *b, const char *s)
 Append the string s ("(null)" for NULL).
void sbn (struct sb *b, LONG v)
 Append v in decimal.
void sbx (struct sb *b, ULONG v, int digits)
 Append the low digits hex digits of v, upper case.
void sbq (struct sb *b, const char *s)
 Append s quoted, controls (< 32 and 127) as \xNN.
void edstub_log (const char *s)
 Log a line: to Output() and appended to the log file.
int edstub_set_log (const char *path)
 Set the log file: create it (a new file) and write the lines kept so far.
static void closeall (void)
static void abort_job (const char *why)
void edstub_reset_requests (void)
 A new job: the counters of the requester answers start again.
static const char * reqtext (struct Requester *r)
static const char * gadtext (struct Gadget *g)
static void popreq (void)
void screenclose_c (struct regs *r)
void screenopen2_c (struct regs *r)
void detokallz_c (struct regs *r)
void tokall_c (struct regs *r)
void refgads_c (struct regs *r)
void openio_c (struct regs *r)
void closeio_c (struct regs *r)
void pointeron_c (struct regs *r)
void sleepon_c (struct regs *r)
void actgad_c (struct regs *r)
void tokone_c (struct regs *r)
void openreq_c (struct regs *r)
void closereq_c (struct regs *r)
void getinput2_c (struct regs *r)
int edstub_open_requests (void)
 The number of requesters open now (openreq not yet closed).
struct MsgPort * edstub_req_port (void)
 The UserPort of the requester window.
void getinput_c (struct regs *r)
void ezfreq_c (struct regs *r)
void extalloc_c (struct regs *r)
void error_c (struct regs *r)
static ULONG rowoff (UWORD row)
static void stripe_reset (void)
int edstub_set_bitmap (UWORD bmapmul, ULONG guard)
 Give the compiler a bitmap of bmapmul bytes per row (comdata+92) with guard bytes before and after it, and record the stripe from now on (edstub_stripe_log).
void edstub_set_progress (int on)
 Announce the progress call (comdata+98 = 'TEDp') or not (0).
void progress_c (struct regs *r)
void edstub_stripe_log (const char *id)
 After a compile: log the stripe, then clear the bitmap, refill the guards and the counters.
struct MsgPort * edstub_create_port (void)
 A message port with a signal of its own, with Kickstart 1.x calls (CreateMsgPort of V36).
void edstub_delete_port (struct MsgPort *port)
 Free a port of edstub_create_port() and its signal.
struct IORequest * edstub_create_ioreq (struct MsgPort *port, ULONG size)
 An IO request for a port, with Kickstart 1.x calls (CreateIORequest of V36).
void edstub_delete_ioreq (struct IORequest *io)
 Free a request of edstub_create_ioreq() (as DeleteIORequest: the node's successor and io_Device set to -1 first).
void edstub_init_c (struct regs *r)
void edstub_main_c (struct regs *r)

Variables

struct ExecBase * SysBase
struct DosLibrary * DOSBase
struct IntuitionBase * IntuitionBase
struct edstruct * edstub_ed
 The edstruct blitz2 passed to outside (a1).
const char *(* edstub_ezfreq_hook )(const char *title)
 ezfreq: the file name for the requester with this title, or NULL (default: cancelled).
void(* edstub_error_hook )(const char *msg)
 The compiler's error message (default: logged).
void(* edstub_tokone_hook )(UBYTE *line)
 tokone: tokenise the line (default: logged, line left as is).
void(* edstub_abort_hook )(const char *why)
 Before the frame aborts inside main (compiler waits for input forever, extalloc of the original compiler failed): the program can log its result and free its data.
void(* edstub_openio_hook )(void)
 openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.
void(* edstub_closeio_hook )(void)
 openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.
UWORD(* edstub_getinput2_hook )(void)
 getinput2 (the compiler polls the stop requester, chkrealstop): the id of the gadget hit, 0 = nothing (default: nothing).
char edstub_logname [EDSTUB_PATHLEN]
 The log file's name; empty while there is none.
int edstub_quiet
 Non-zero: edstub_log does not write to Output() (a program with a console output of its own; the log file still gets the lines).
ULONG edstub_abort_sp
static struct comdata_s cd
static UWORD colors [32]
static UWORD halfcolors [32]
static UBYTE flag84
static struct Window fakewin
static struct MsgPort * winport
static UBYTE * bitmap
static UBYTE * bitmap_mem
static ULONG bitmap_size
static ULONG guard_size
static APTR old_winptr
static int in_main
static char early [2048]
static struct sb earlyb = { early, 0, sizeof early }
static char lbuf [600]
static int reqdepth
static struct Requester * reqstack [MAXREQ]
static int nomem_answers
static int unexpected
int edstub_busy
 The busy pointer: sleepon sets it (1), pointeron clears it (ted.s: the window pointer); the frame shows nothing, it only keeps the state.
static int stripe_on
static UBYTE progcount [4][PROGCOLS]
static ULONG progcalls
static ULONG progbad
static UBYTE snap [BITMAP_ROWS][PROGCOLS]
static ULONG snap_set
static ULONG guard_before
static ULONG guard_after

Macro Definition Documentation

◆ BITMAP_ROWS

#define BITMAP_ROWS   16 /* stripe uses rows 0..9 */

◆ BMAPMUL

#define BMAPMUL   80 /* bytes per row of a 640 pixel plane */

◆ CDOFF

#define CDOFF ( m)
Value:
(offsetof(struct comdata_s, m) - 8)
Definition edstub.c:48

◆ GUARD_BYTE

#define GUARD_BYTE   0xA5

◆ LOG_BEGIN

#define LOG_BEGIN   struct sb L = { lbuf, 0, sizeof lbuf }; lbuf[0] = 0

◆ LOG_END

#define LOG_END   edstub_log(lbuf)

◆ MAXREQ

#define MAXREQ   8

◆ PROGCOLS

#define PROGCOLS   256 /* columns counted and pictured */

◆ PROGMARK

#define PROGMARK   0x54454470UL /* 'TEDp' */

◆ STUB

#define STUB ( n)
Value:
extern void n##_stub(void)
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498

◆ WIN_WIDTH

#define WIN_WIDTH   640

Function Documentation

◆ abort_job()

void abort_job ( const char * why)
static

◆ actgad_c()

void actgad_c ( struct regs * r)

◆ closeall()

void closeall ( void )
static

◆ closeio_c()

void closeio_c ( struct regs * r)

◆ closereq_c()

void closereq_c ( struct regs * r)

◆ detokallz_c()

void detokallz_c ( struct regs * r)

◆ edstub_create_ioreq()

struct IORequest * edstub_create_ioreq ( struct MsgPort * port,
ULONG size )

An IO request for a port, with Kickstart 1.x calls (CreateIORequest of V36).

Parameters
portthe reply port (NULL: fails)
sizethe size of the request in bytes (cleared)
Returns
the request, or NULL if port is NULL or out of memory

◆ edstub_create_port()

struct MsgPort * edstub_create_port ( void )

A message port with a signal of its own, with Kickstart 1.x calls (CreateMsgPort of V36).

Returns
the port, or NULL if out of memory or signals

◆ edstub_delete_ioreq()

void edstub_delete_ioreq ( struct IORequest * io)

Free a request of edstub_create_ioreq() (as DeleteIORequest: the node's successor and io_Device set to -1 first).

Parameters
iothe request (NULL: nothing)

◆ edstub_delete_port()

void edstub_delete_port ( struct MsgPort * port)

Free a port of edstub_create_port() and its signal.

Parameters
portthe port (NULL: nothing)

◆ edstub_init_c()

void edstub_init_c ( struct regs * r)

◆ edstub_log()

void edstub_log ( const char * s)

Log a line: to Output() and appended to the log file.

Before there is a log file, the lines are kept and edstub_set_log() writes them first. The file is opened and closed for every line, so the log survives a crash of the compiler.

Parameters
sthe line, without its line feed

◆ edstub_main_c()

void edstub_main_c ( struct regs * r)

◆ edstub_open_requests()

int edstub_open_requests ( void )

The number of requesters open now (openreq not yet closed).

Returns
the depth of the requester stack

◆ edstub_prefix()

int edstub_prefix ( const char * s,
const char * pre )

1 if s starts with pre, else 0.

◆ edstub_req_port()

struct MsgPort * edstub_req_port ( void )

The UserPort of the requester window.

Its signal is the stop requester's exception (blitz2 openstopreq), a message there is "a gadget was hit".

Returns
the port

◆ edstub_reset_requests()

void edstub_reset_requests ( void )

A new job: the counters of the requester answers start again.

◆ edstub_set_bitmap()

int edstub_set_bitmap ( UWORD bmapmul,
ULONG guard )

Give the compiler a bitmap of bmapmul bytes per row (comdata+92) with guard bytes before and after it, and record the stripe from now on (edstub_stripe_log).

Parameters
bmapmulbytes per row (at least 80)
guardguard bytes before and after the bitmap
Returns
1, or 0 if out of memory (the bitmap stays as it was)

◆ edstub_set_log()

int edstub_set_log ( const char * path)

Set the log file: create it (a new file) and write the lines kept so far.

Parameters
paththe file name (cut to EDSTUB_PATHLEN - 1 characters)
Returns
1, or 0 if the file cannot be created (no log file then)

◆ edstub_set_progress()

void edstub_set_progress ( int on)

Announce the progress call (comdata+98 = 'TEDp') or not (0).

A call toggles the cell as the original compiler XORs it (the byte column of rows bar and 9 - bar of the bitmap) and is counted.

◆ edstub_strcat()

void edstub_strcat ( char * d,
const char * s,
ULONG max )

Append s to d; max is the size of all of d (as edstub_strcpy).

◆ edstub_strcpy()

void edstub_strcpy ( char * d,
const char * s,
ULONG max )

Copy s to d, at most max - 1 characters and the 0 (nothing if max is 0).

◆ edstub_streq()

int edstub_streq ( const char * a,
const char * b )

1 if the strings are equal, else 0.

◆ edstub_stripe_log()

void edstub_stripe_log ( const char * id)

After a compile: log the stripe, then clear the bitmap, refill the guards and the counters.

Lines (tab separated, with the job's id): PROGRESS ID none (no call) or per bar with calls PROGRESS ID bar N COUNTS (the calls per column from column 0, a digit each, '+' above 9, up to the last column called), plus PROGRESS ID bad N for calls with a bar above 3 or a column outside the row; STRIPE ID none (bitmap empty) or per row with set bytes STRIPE ID row R PICTURE ('#' $FF, '.' 0, 'x' else, up to the last byte not 0, columns 0 to 255); GUARD ID ok or GUARD ID before N after M (bytes of the guards changed). The picture and the guards are those of the checkpoints openreq, closereq and the end of the job: the fullest picture, the most changed guard bytes (with two passes the XORs of the second undo those of the first; the requester of the second pass opens between them). Nothing without edstub_set_bitmap.

Parameters
idthe job's id

◆ edstub_strlen()

ULONG edstub_strlen ( const char * s)

The length of the string s.

◆ edstub_tomain()

void edstub_tomain ( void )

◆ edstub_udiv10()

ULONG edstub_udiv10 ( ULONG u,
ULONG * rem )

u / 10 without libgcc (no __udivsi3 in a -nostdlib build); the remainder to *rem.

◆ error_c()

void error_c ( struct regs * r)

◆ extalloc_c()

void extalloc_c ( struct regs * r)

◆ ezfreq_c()

void ezfreq_c ( struct regs * r)

◆ gadtext()

const char * gadtext ( struct Gadget * g)
static

◆ getinput2_c()

void getinput2_c ( struct regs * r)

◆ getinput_c()

void getinput_c ( struct regs * r)

◆ memcpy()

void * memcpy ( void * d,
const void * s,
size_t n )

◆ memset()

void * memset ( void * d,
int c,
size_t n )

◆ openio_c()

void openio_c ( struct regs * r)

◆ openreq_c()

void openreq_c ( struct regs * r)

◆ pointeron_c()

void pointeron_c ( struct regs * r)

◆ popreq()

void popreq ( void )
static

◆ progress_c()

void progress_c ( struct regs * r)

◆ refgads_c()

void refgads_c ( struct regs * r)

◆ reqtext()

const char * reqtext ( struct Requester * r)
static

◆ rowoff()

ULONG rowoff ( UWORD row)
static

◆ sbc()

void sbc ( struct sb * b,
char c )

Append the character c.

◆ sbn()

void sbn ( struct sb * b,
LONG v )

Append v in decimal.

◆ sbq()

void sbq ( struct sb * b,
const char * s )

Append s quoted, controls (< 32 and 127) as \xNN.

◆ sbs()

void sbs ( struct sb * b,
const char * s )

Append the string s ("(null)" for NULL).

◆ sbx()

void sbx ( struct sb * b,
ULONG v,
int digits )

Append the low digits hex digits of v, upper case.

◆ screenclose_c()

void screenclose_c ( struct regs * r)

◆ screenopen2_c()

void screenopen2_c ( struct regs * r)

◆ sleepon_c()

void sleepon_c ( struct regs * r)

◆ stripe_check()

void stripe_check ( void )
static

◆ stripe_reset()

void stripe_reset ( void )
static

◆ STUB() [1/19]

STUB ( actgad )

◆ STUB() [2/19]

STUB ( closeio )

◆ STUB() [3/19]

STUB ( closereq )

◆ STUB() [4/19]

STUB ( detokallz )

◆ STUB() [5/19]

STUB ( error )

◆ STUB() [6/19]

STUB ( extalloc )

◆ STUB() [7/19]

STUB ( ezfreq )

◆ STUB() [8/19]

STUB ( getinput )

◆ STUB() [9/19]

STUB ( getinput2 )

◆ STUB() [10/19]

STUB ( openio )

◆ STUB() [11/19]

STUB ( openreq )

◆ STUB() [12/19]

STUB ( pointeron )

◆ STUB() [13/19]

STUB ( progress )

◆ STUB() [14/19]

STUB ( refgads )

◆ STUB() [15/19]

STUB ( screenclose )

◆ STUB() [16/19]

STUB ( screenopen2 )

◆ STUB() [17/19]

STUB ( sleepon )

◆ STUB() [18/19]

STUB ( tokall )

◆ STUB() [19/19]

STUB ( tokone )

◆ tokall_c()

void tokall_c ( struct regs * r)

◆ tokone_c()

void tokone_c ( struct regs * r)

Variable Documentation

◆ bitmap

UBYTE* bitmap
static

◆ bitmap_mem

UBYTE* bitmap_mem
static

◆ bitmap_size

ULONG bitmap_size
static

◆ cd

struct comdata_s cd
static
Initial value:
= {
screenclose_stub, screenopen2_stub,
openreq_stub, closereq_stub, getinput_stub, error_stub,
detokallz_stub, tokall_stub, ezfreq_stub, refgads_stub, getinput2_stub,
0, 0, 0, 0, 0,
tokone_stub, openio_stub, closeio_stub, actgad_stub,
pointeron_stub, sleepon_stub,
0, 0, extalloc_stub, 0, 0,
0, progress_stub,
0
}

◆ colors

UWORD colors[32]
static

◆ DOSBase

struct DosLibrary* DOSBase

◆ early

char early[2048]
static

◆ earlyb

struct sb earlyb = { early, 0, sizeof early }
static

◆ edstub_abort_hook

void(* edstub_abort_hook) (const char *why) ( const char * why)

Before the frame aborts inside main (compiler waits for input forever, extalloc of the original compiler failed): the program can log its result and free its data.

◆ edstub_abort_sp

ULONG edstub_abort_sp

◆ edstub_busy

int edstub_busy

The busy pointer: sleepon sets it (1), pointeron clears it (ted.s: the window pointer); the frame shows nothing, it only keeps the state.

◆ edstub_closeio_hook

void(* edstub_closeio_hook) (void) ( void )

openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.

◆ edstub_ed

struct edstruct* edstub_ed

The edstruct blitz2 passed to outside (a1).

◆ edstub_error_hook

void(* edstub_error_hook) (const char *msg) ( const char * msg)

The compiler's error message (default: logged).

◆ edstub_ezfreq_hook

const char *(* edstub_ezfreq_hook) (const char *title) ( const char * title)

ezfreq: the file name for the requester with this title, or NULL (default: cancelled).

◆ edstub_getinput2_hook

UWORD(* edstub_getinput2_hook) (void) ( void )

getinput2 (the compiler polls the stop requester, chkrealstop): the id of the gadget hit, 0 = nothing (default: nothing).

◆ edstub_logname

char edstub_logname[EDSTUB_PATHLEN]

The log file's name; empty while there is none.

◆ edstub_openio_hook

void(* edstub_openio_hook) (void) ( void )

openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.

◆ edstub_quiet

int edstub_quiet

Non-zero: edstub_log does not write to Output() (a program with a console output of its own; the log file still gets the lines).

◆ edstub_tokone_hook

void(* edstub_tokone_hook) (UBYTE *line) ( UBYTE * line)

tokone: tokenise the line (default: logged, line left as is).

◆ fakewin

struct Window fakewin
static

◆ flag84

UBYTE flag84
static

◆ guard_after

ULONG guard_after
static

◆ guard_before

ULONG guard_before
static

◆ guard_size

ULONG guard_size
static

◆ halfcolors

UWORD halfcolors[32]
static

◆ in_main

int in_main
static

◆ IntuitionBase

struct IntuitionBase* IntuitionBase

◆ lbuf

char lbuf[600]
static

◆ nomem_answers

int nomem_answers
static

◆ old_winptr

APTR old_winptr
static

◆ progbad

ULONG progbad
static

◆ progcalls

ULONG progcalls
static

◆ progcount

UBYTE progcount[4][PROGCOLS]
static

◆ reqdepth

int reqdepth
static

◆ reqstack

struct Requester* reqstack[MAXREQ]
static

◆ snap

UBYTE snap[BITMAP_ROWS][PROGCOLS]
static

◆ snap_set

ULONG snap_set
static

◆ stripe_on

int stripe_on
static

◆ SysBase

struct ExecBase* SysBase

◆ unexpected

int unexpected
static

◆ winport

struct MsgPort* winport
static