			Routines in UTILS.ASM 20021208
			------------------------------

GetSwitch: Will fill an ASCIIZ buffer with the string after the "=" sign of
a predetermined command-line switch of the form /SWITCH=VALUE. The switch
name is *NOT* case sensitive.

	On entry:
	  (SP+6) -> Address of ASCIIZ buffer to fill with the switch's value
	  (SP+4) -> Address of ASCIIZ buffer with switch name
	  (SP+2) -> Address of command-line (with leading lenght byte)
	  (SP+0) -> Normal return address

	On return:
	  Carry flag reset: Buffer filled
	    A : Zero
	    BC: Amount of chars remaining in command line
	    DE: Points to the terminating NULL of the buffer to fill
	    HL: Points to one after the last byte copied from the cmdline
	  Carry flag set: Error (switch not found, no chars in cmdline, etc)


ExpandMacros: Will replace occurrences of "%1" to "%9" in an ASCIIZ buffer
for the Nth ASCIIZ string from a parameter buffer, delivering an ASCII
(not ASCIIZ) string in a supplied address. The parameter string block MUST
start with a NULL char (ASCII 0). Example:

	Src:	DB	"Marcelo %1 %2."
	Param:	DB	00,"made",00,"me.",00
	Desti:	DB	00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

After executing the routine, DESTI will hold the following string (note that
the destination string is not ASCIIZ):

	Desti:	DB	"Marcelo made me."

	On entry:
	  (SP+6) -> Source buffer start address (Src in the example)
	  (SP+4) -> Param buffer start address (Param in the example)
	  (SP+2) -> Destination buffer start address (Desti in the example)
	  (SP+0) -> Normal return address

	On return:
	  A : Zero
	  B : Zero (if strings replaced), Hi byte of param buff addr if not
	  C : Low byte of parameter buffer address
	  DE: Pointer to the last byte in the output buffer + 1
	  HL: Pointer to the last byte in the source buffer + 1


Ascii2Word: Converts an ASCIIZ number to a 2-byte value. The number can have
a prefix character to preset the number base. In case of hex numbers, the
letter case does NOT matter. This routine DOES NOT deal with negative or
fractional numbers. All returned values are positive. The routine will work
with values in the range 0 - 65,535 (dec), 0 - FFFF (hex), 0 - 177777 (oct),
or 0 - 1111 1111 1111 1111 (bin).

	Prefix:
	  "@": Means OCTAL number follows (ex: @345; bad ex: @87)
	  "#": Means HEXADECIMAL number follows (ex: #F00f; bad ex: #G0)
	  "%": Means BINARY number follows (ex: %1010; bad ex: %5)
	  <no prefix>: Default, for DECIMAL numbers (ex: 987; bad ex: 3A57)

	On entry:
	  (SP+2) -> ASCIIZ string starting address
	  (SP+0) -> Normal return address

	On return:
	  Carry flag reset: Operation successful.
	    A : Low byte of converted number (copy of register L)
	    HL: Converted number
	  Carry flag set: Error while converting (overflow or invalid char)


Word2Hex: Converts a 2-byte value to four hexadecimal characters. All values
are considered positive. Uses UTILS.ASM:Byte2Hex routine twice...

	On entry:
	  (SP+4) -> Number to convert
	  (SP+2) -> Four-byte ASCII buffer start address
	  (SP+0) -> Normal return address

	On return:
	  ASCII buffer is filled with the converted number
	  A : Ascii code of lowest nibble of converted number
	  DE: Number to convert
	  HL: Pointer to last char in buffer


Byte2Hex: Converts a 1-byte number to two hexadecimal characters. All values
are considered positive.

	On entry:
	  (SP+4) -> Number to convert (in LSB, MSB is ignored)
	  (SP+2) -> Two-byte ASCII buffer start address
	  (SP+0) -> Normal return address

	On return:
	  ASCII buffer is filled with the converted number
	  A : Ascii code of lower nibble of converted number
	  D : Ignored MSB of number to convert
	  E : Number to convert
	  HL: Pointer to last char in buffer


Byte2Ascii: Converts a 1-byte number to ASCII characters. Leading zeroes are
replaced by spaces. All values are considered positive.

	On entry:
	  (SP+4) -> Number to convert (in LSB, MSB is ignored)
	  (SP+2) -> Three-byte ASCII buffer start address
	  (SP+0) -> Normal return address

	On return:
	  ASCII buffer is filled with converted number
	  A : Ascii code of LSB
	  C : Ascii code of mid-significant digit (or space, if it was zero)
	  HL: Pointer to last char in buffer


Word2Ascii: Converts a 2-byte number to ASCII characters. All values are
considered positive.

	On entry:
	  (SP+4) -> Number to convert
	  (SP+2) -> Five-byte ASCII buffer start address
	  (SP+0) -> Normal return address

	On return:
	  ASCII buffer is filled with converted number
	  A : Ascii code of LSB
	  BC: 000Ah
	  DE: Buffer start address
	  HL: Least significant digit of number to convert


