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

Macros

#define ED_PARS4   ((const UBYTE *)&ed.type) /* pars+4: a2 for len */
#define ED_PARSF   ((const UBYTE *)(&ed + 1)) /* parsf: a2 for type */

Functions

ULONG doeditstr2 (ULONG n)
 Edit$(Characters): reads a line of up to n characters, without a default.
ULONG doeditstr (UBYTE *def, ULONG n, const UBYTE *args)
 Edit$(DefaultString$,Characters): reads a line of up to n characters over a default string.
void doinkey (void)
 Inkey$: one character from the current input, "" if none came.
ULONG doinkey2 (ULONG n)
 Inkey$(Characters): n attempts to read a character, the characters that came.
ULONG doedit2 (ULONG n, const void *caller_a6)
 Edit(Characters): reads a number of up to n characters, without a default.
ULONG doedit (ULONG def, ULONG n, const void *caller_a6)
 Edit(DefaultValue,Characters): reads a number of up to n characters over a default value.
void editchk1 (void)
void editchk2 (void)
void editchkz (void)
void editchk (void)
void inkeychk (void)
void editctrlc (void)
static ULONG getsingle (void)
static ULONG editstr (UBYTE *def, ULONG max, ULONG deflen)
static ULONG doeditz (ULONG n, const void *caller_a6, UBYTE *saved_string)
static void editchk1_c (ULONG n)
static void editchk2_c (ULONG n)
static void editchk_c (ULONG n)
static void inkeychk_c (ULONG n)
static void editchkz_c (ULONG n)
 BLITZ_ERRCHK_ASM (editctrlc, " .globl _editctrlc\n" "_editctrlc:\n" " jmp _blitz_tok+" BL_ASMTOK(LIB_inputoutputlib, 13))

Variables

struct { 
   UBYTE   buff [80] 
   ULONG   len 
   UWORD   type 
} ed = { .type = 5 }

Macro Definition Documentation

◆ ED_PARS4

#define ED_PARS4   ((const UBYTE *)&ed.type) /* pars+4: a2 for len */

◆ ED_PARSF

#define ED_PARSF   ((const UBYTE *)(&ed + 1)) /* parsf: a2 for type */

Function Documentation

◆ BLITZ_ERRCHK_ASM()

BLITZ_ERRCHK_ASM ( editctrlc ,
" .globl _editctrlc\n" "_editctrlc:\n" " jmp _blitz_tok+" BL_ASMTOKLIB_inputoutputlib, 13 )

◆ doedit()

ULONG doedit ( ULONG def,
ULONG n,
const void * caller_a6 )

Edit(DefaultValue,Characters): reads a number of up to n characters over a default value.

The default is converted with printlib's UStr$ into the library's 80 byte buffer, the line is read over it and converted with Val (see doeditz). Fixed (#129): the padding starts behind the default (the original's first padding space overwrote its last character: UStr$ leaves a3 right behind it, without a 0). UStr$ and Val get their !libs bases from the ALibJsr stubs (#130). By design (#131): n = 80 reads up to 81 characters into the buffer. Errors (debugger only): n = 0 -> "Can't Edit 0 Characters!", n > 80 -> "Can only Edit up to 80 characters".

Parameters
defd0: the default value (FFP float)
nd1: the maximum number of characters
caller_a6a6: the caller's a6, passed on to UStr$ and Val
Returns
d0: the value (FFP float)

◆ doedit2()

ULONG doedit2 ( ULONG n,
const void * caller_a6 )

Edit(Characters): reads a number of up to n characters, without a default.

The line is read in the library's 80 byte buffer and converted with vallib's Val (see doeditz). Fixed (#129): the buffer starts empty (padded with n spaces). The original put a default "0" there, which its padding overwrote for n >= 2 (#129) and showed only for n = 1; an empty line still gives 0. Val gets the ffplib base although Edit has no !libs: the compiler links the ALibJsr call through a stub that loads the callee's !libs (not a bug, #130). By design (#131): n = 80 reads up to 81 characters into the 80 byte buffer. Errors (debugger only): n = 0 -> "Can't Edit 0 Characters!", n > 80 -> "Can only Edit up to 80 characters".

Parameters
nd0: the maximum number of characters
caller_a6a6: the caller's a6, passed on to Val
Returns
d0: the value (FFP float)

◆ doeditstr()

ULONG doeditstr ( UBYTE * def,
ULONG n,
const UBYTE * args )

Edit$(DefaultString$,Characters): reads a line of up to n characters over a default string.

The default is padded with spaces to n characters in the string buffer, then the line is read over it (see editstr). The padding starts one byte before a3 when the default is not at a3 (a3 points behind the string argument's terminating 0). Fixed (#132): at the end of the file the result is empty (the original returned the length -1). Errors (debugger only): n = 0 -> "Can't Edit 0 Characters!". DIFF: a2 is a register parameter here (the length is popped through a local cursor; the original returns with a2 decremented).

Parameters
defd0: the default string
nd1: the maximum number of characters
argsa2: the argument stack, the default's length below it
Returns
d0: the number of characters read (the string length)

◆ doeditstr2()

ULONG doeditstr2 ( ULONG n)

Edit$(Characters): reads a line of up to n characters, without a default.

The buffer at a3 is padded with n spaces (for input handlers that edit the buffer), then the line is read over it with inputoutputlib's dogetstring (see editstr). Fixed (#132): at the end of the file (DefaultInput returns -1 characters) the result is empty (the original moved a3 back by one and returned the length -1). Errors (debugger only): n = 0 -> "Can't Edit 0 Characters!".

Parameters
nd0: the maximum number of characters
Returns
d0: the number of characters read (the string length)

◆ doeditz()

ULONG doeditz ( ULONG n,
const void * caller_a6,
UBYTE * saved_string )
static

◆ doinkey()

void doinkey ( void )

Inkey$: one character from the current input, "" if none came.

Reads one character with inputoutputlib's dogetsingle (d0 negative = none) and appends it to the string at a3. The original's code, an assembler entry: as a C function it saved d2-d7/a2/a6 around the ALibJsr (the handler may change them) and cleared d0/d1/a0/a1 for it, about 160 cycles per call. Like the original it changes what the input handler changes (the handler keeps a3-a6: BlitzKey keeps d1/a0/ a1 too, the C handlers d2-d7/a2/a6).

Out: d0 the string length, 1 or 0; a3 behind the character

◆ doinkey2()

ULONG doinkey2 ( ULONG n)

Inkey$(Characters): n attempts to read a character, the characters that came.

Calls dogetsingle n times and appends every character it returns to the string at a3. n counts as an unsigned long. Fixed (#128): Inkey$(0) is the empty string (the original skipped MOVEQ #0,d6 and returned the caller's d6 as the length). Errors (debugger, inkeychk): "Can't Inkey$ a negative number of Characters!" (fixed, #1031: the original had no check; a negative n makes about 4 billion attempts).

Parameters
nd0: the number of attempts
Returns
d0: the string length (the characters that came)

◆ editchk()

void editchk ( void )

◆ editchk1()

void editchk1 ( void )

◆ editchk1_c()

void editchk1_c ( ULONG n)
static

◆ editchk2()

void editchk2 ( void )

◆ editchk2_c()

void editchk2_c ( ULONG n)
static

◆ editchk_c()

void editchk_c ( ULONG n)
static

◆ editchkz()

void editchkz ( void )

◆ editchkz_c()

void editchkz_c ( ULONG n)
static

◆ editctrlc()

void editctrlc ( void )

◆ editstr()

ULONG editstr ( UBYTE * def,
ULONG max,
ULONG deflen )
static

◆ getsingle()

ULONG getsingle ( void )
static

◆ inkeychk()

void inkeychk ( void )

◆ inkeychk_c()

void inkeychk_c ( ULONG n)
static

Variable Documentation

◆ buff

UBYTE buff[80]

◆ [struct]

struct { ... } ed

◆ len

ULONG len

◆ type

UWORD type