rilesdebuglib
This library was written for REDDebugger, a debugger program of Red When Excited; the program itself is not part of the release. Its commands are plain helpers that do not talk to the runtime debugger (that is the job of the RI Debug Lib). Most of them are useful only in a program like a debugger or a monitor:
- Memory and registers as text:
D_HexWord,D_CheckNMove,D_CheckNMoveA,D_CheckNMoveWord,D_GetSR,GetHex$,GetHexAdr$,PeekMax$andGetDataItem. Some of them (D_HexWord,D_CheckNMoveA,D_CheckNMoveWord) show bytes at addresses below $420 as*instead of reading them. - A font printer:
FLocate,FPrint,FNPrint,FInverseandFYOffsetprint with the library’s own 8x8 font into the first bitplane of the used bitmap, which must be 640 pixels (80 bytes) wide.FPrintDetokeprints a tokenised Blitz source line with the names of its tokens, from the token list given toSetupLESDebug. - The copper and the custom chips:
GetCopIns$shows a copper instruction as text,GetCustomRegandGetCustomRegAdrturn register offsets into names and back. - Text on a rastport:
OutTextandOutTextPen. - Parsing:
D_InitParseandD_NextArg$split a string at its commas;ProcessString,AddProcessPtrandClearProcessPtrsreplace%codes in it. - Searching:
SearchMemandSearchMemFoundsearch memory for a value;D_FindStringPtr,FindLineToken,ExtractLabelandD_FindVolumelook up other things.
Many commands take addresses rather than strings and check nothing, so
a wrong address reads or overwrites memory. With runtime error
checking, the font printer checks the used bitmap and AddProcessPtr
refuses a 21st code. The library opens graphics.library itself, and
every run of a program starts it with its defaults. All commands work
in Amiga and Blitz mode except D_FindVolume, which is Amiga mode
only.
Register names and hexadecimal text:
NPrint GetCustomReg($096)
NPrint GetHex$(255,1)
NPrint GetHex$(GetCustomRegAdr("COLOR00"),2)The fixed bugs of the library are listed in Fixes in rilesdebuglib.
Library number 49.
Commands
AddProcessPtr
Adds a % code for ProcessString; character is a string whose first character is the code, string the address of the 0-terminated text to put for it.
Statement. Help text: character,string
Arguments: $, .l
There is room for 20 codes besides %p and %c; further codes are
ignored. With runtime error checking, a 21st code is the error
“AddProcessPtr table holds at most 20 entries”. Every run of a
program starts with no codes.
ClearProcessPtrs
Removes all codes added with AddProcessPtr; %p and %c stay.
Statement. Help text: -- reset process string pointers
No arguments.
D_CheckNMove
Copies count longs (1 without count) from source_address to dest_address as four characters each, leaving one byte free behind each long.
Statement. Help text: source_address,dest_address[,count]
2 forms:
.l, .l.l, .l, .w
The bytes are copied as they are, 0 bytes included. A count of 0
copies nothing.
D_CheckNMoveA
Like D_CheckNMove, but a 0 byte becomes the character 1, and bytes at addresses below $420 become *.
Statement. Help text: source_address,dest_address[,count]
2 forms:
.l, .l.l, .l, .w
A count of 0 copies nothing.
D_CheckNMoveWord
Copies count words (1 without count) from source_address to dest_address as two characters each, without a gap. A 0 byte becomes the character 1, and bytes at addresses below $420 become *.
Statement. Help text: source_address,dest_address[,count]
2 forms:
.l, .l.l, .l, .w
A count of 0 copies nothing.
D_FindStringPtr
Searches the 32768 bytes below areg5, in steps of 2 bytes, for the long lookfor and returns the address of the first match, or -1 if there is none.
Function, result .l. Help text: areg5,lookfor
Arguments: .l, .l
The search covers the addresses from areg5-32768 to areg5-2; the
long at areg5 itself is not compared.
D_FindVolume
Looks up a device, volume or assign by name and returns -1 if it is there, or 0 if there is none. volumename is the address of the name, without the colon.
Function, result .l. Help text: (volumename)
Arguments: .l
Amiga mode only. The name is compared without regard to case. It works on Kickstart 1.x too.
D_GetSR
Writes the condition codes of the status register SR as text into buffer, for example X-Z--; a flag that is not set shows as -.
Statement. Help text: buffer,SR
Arguments: .l, .w
The text is the five letters XNZVC and a 0 byte, six bytes in all.
D_HexWord
Writes num words of memory from source as hexadecimal text to address, five characters per word (four digits and a space). No 0 byte is written at the end.
Statement. Help text: source,address,num
Arguments: .l, .l, .w
Bytes at addresses below $420 show as **. A num of 0 writes
nothing.
At an odd source, each five characters are a byte, a space and the
next byte, so that the words at the even addresses stay together:
the bytes 12 34 56 78 show as 12 3456 78.
D_InitParse
Starts splitting the 0-terminated string at the address string into arguments separated by commas; D_NextArg$ then gives them one by one.
Statement. Help text: string
Arguments: .l
The string is copied into the parser’s buffer of 256 bytes; a longer string is cut after 255 characters.
D_NextArg$
The next argument of the string given to D_InitParse, up to the next comma; an empty string after the last one.
Function, result $. Help text: - get next parameter
No arguments.
Spaces are kept as they are.
ExtractLabel
The name of a label in a line of text at the address label_string. From the tenth character on, the first . is searched; the name runs from behind it to a space, a : or the end of the line.
Function, result $. Help text: label_string
Arguments: .l
A line without a . behind its first nine characters gives an empty
string.
FindLineToken
The first token of a tokenised Blitz source line at Start_Address, as a word without its top bit, or 0 if the line holds no token.
Function, result .w. Help text: Start_Address
Arguments: .l
FInverse
Switches inverse printing of the font printer on (any value but 0) or off (0), for FPrint, FNPrint and FPrintDetoke.
Statement. Help text: inversemode
Arguments: .w
FLocate
Sets the cursor of the font printer to column x and row y, both counted in characters of 8 pixels.
Statement. Help text: x,y
Arguments: .w, .w
FNPrint
Like FPrint, then the cursor goes to the start of the next row.
Statement. Help text: a$
Arguments: $
FPrint
Prints a string with the library’s 8x8 font at the cursor into the first bitplane of the used bitmap; the cursor moves on.
Statement. Help text: a$
Arguments: $
The bitmap must be 80 bytes (640 pixels) wide; its other bitplanes
are not touched. With FInverse on, the characters are inverted.
Printing stops at column 80, so a cursor in column 80 or beyond
prints nothing.
With runtime error checking, a bitmap narrower than 640 pixels is the error “Font printer needs a bitmap of 640 pixels”, and a cursor row that does not lie inside the bitmap the error “Font printer row outside the bitmap”. Without it, nothing checks the size of the bitmap.
FPrintDetoke
Prints a tokenised Blitz source line with the font printer, its tokens as their names. A marker goes before the character at cio, lineoffset characters are skipped from the left, and the cursor moves on.
Statement. Help text: tokenised_string,cio,typ,lineoffset
Arguments: .l, .w, .w, .w
tokenised_string is the address of the line, ended by a 0 byte.
The names come from the token list given to SetupLESDebug; a token
not in it prints as ?????. With SetupLESDebug’s tokenise set,
the names are drawn into the second bitplane too, so they show in
another colour. The marker is > for a typ of 0, otherwise an
inverse space; it leaves the FInverse setting as it is.
With FInverse on, the line is inverted, the token names in the
second bitplane too. Printing stops at column 80, the character
behind the marker included, and with runtime error checking the
bitmap is checked as for FPrint.
FYOffset
Sets a number of pixel lines that the font printer adds to the row of the cursor, to print between the rows of 8 pixels.
Statement. Help text: pixel_offset - offset from vertical y cursor to print at
Arguments: .w
GetCopIns$
The copper instruction (two words) at the address copdata as text, for example MOVE 0FFF to COLOR00 or WAIT (xx,yy) MASK (xx,yy).
Function, result $. Help text: copdata
Arguments: .l
A MOVE shows the value and the register’s name, padded to 8
characters. A WAIT or SKIP shows the position and the mask, each as
two hexadecimal numbers, and [BFD] if the blitter finish disable
bit is set. The lowest bit of the horizontal position and mask
belongs to the instruction and always shows as 0: $2C31,$FFFE is
WAIT (30,2C) MASK (FE,FF) [BFD].
GetCustomReg
The name of the custom chip register at offset address ($000 to $1FE), for example DMACON for $096; an empty string for an offset out of range.
Function, result $. Help text: address
Arguments: .w
Only the low word of address counts. GetCustomReg($1FE) is
NOOP.
GetCustomRegAdr
The offset of the custom chip register named name$, for example $180 for COLOR00, or -1 if the name is not known. The names are in upper case.
Function, result .l. Help text: name$
Arguments: $
The whole name must match: DMACONXYZ gives -1, DENISEID gives
$07C and NOOP $1FE.
GetDataItem
The byte (size 1), word (2) or long (any other size) at address, read byte by byte, so odd addresses work too; 0 for an address below $420.
Function, result .l. Help text: address,size -- size=1 byte, size=2 word, otherwise long
Arguments: .l, .w
GetHex$
The value as hexadecimal text with upper case digits; mode 1 gives 2 digits (a byte), 2 gives 4 (a word) and any other mode 8 (a long).
Function, result $. Help text: value,mode (1=byte, 2=word, 3=longword)
Arguments: .l, .w
GetHexAdr$
Like GetHex$, for the byte, word or long at the address value.
Function, result $. Help text: *value,mode (1=byte, 2=word, 3=longword)
Arguments: .l, .w
Low addresses are not checked. The word or long is read byte by byte, so odd addresses work on a 68000 too.
GetProgMode
Writes the name of a program mode as six characters into buffer, without a 0 byte; BLITZ for a negative mode, AMIGA for 0 and QAMIGA for a positive one.
Statement. Help text: mode,buffer
Arguments: .w, .l
OutText
Prints a 0-terminated string (or the string at an address) on a rastport, with its top-left corner at x,y.
Statement. Help text: x,y,rastport,address/string
Arguments: .w, .w, .l, any
The text is placed by the baseline of the rastport’s font, so y is
the top of the text, and drawn in the rastport’s pen (see
OutTextPen).
OutTextPen
Sets the pen that OutText draws with on a rastport.
Statement. Help text: rastport,pen
Arguments: .l, .w
PeekMax$
The 0-terminated string at address, but at most max_chars characters of it.
Function, result $. Help text: (address,max_chars)
Arguments: .l, .w
Low addresses are not checked. A max_chars below 1 gives an empty
string.
ProcessString
The rest of the parser’s string (from D_InitParse) with its % codes replaced. %p becomes REDDebugger, %c the address of the token list in hexadecimal, %% a %, and the codes added with AddProcessPtr their strings.
Function, result $. Help text: - the text of D_InitParse with %x replaced
No arguments.
It takes no argument: it works on the parser’s text from its
current place, so after a D_NextArg$ only the rest is processed. A
% code without an entry is dropped, and a % at the end of the
text ends it. Before D_InitParse, and after the last argument, the
result is an empty string.
SearchMem
Searches memory from start_ad up to end_ad (excluded) for a value and returns -1 if found, 0 if not, and 1 if the search was stopped with the space bar.
Function, result .l. Help text: type,value,start_ad,end_ad
Arguments: .b, any, .l, .l
type is 1 for a byte, 2 for a word, 3, 5 or 6 for a long and 4 for
a string, which value then is (or its address); any other type
finds nothing. Every byte address is tried, odd ones too. The
address found is given by SearchMemFound. Holding down the space
bar stops a long search; SearchMemFound then keeps its value.
A word or long is found only if it lies wholly in front of end_ad.
An empty search string finds nothing.
SearchMemFound
The address the last SearchMem found, or 0 if it found nothing.
Function, result .l. No help text.
No arguments.
SetupLESDebug
Gives the library the token list that FPrintDetoke takes the token names from; with tokenise not 0, FPrintDetoke draws the names into the second bitplane too.
Statement. Help text: token_addr,tokenise
Arguments: .l, .b
token_addr is the address of the first entry of a chain: each
entry holds the address of the next (a long), the token number (a
word) and the name. Its address in hexadecimal is also what
ProcessString puts for %c.