RETURN(ret)
;
; Description:
; Decimal to binary conversion
;
; Parameters:
; xbin - binary number output
; num - decimal number (input)
;
PROC Dec2Bin(BYTE ARRAY xbin BYTE num)
BYTE b, binx
xbin(0)=8 xbin(1)='0
FOR n=0 TO 7
DO
IF 8-n>1 THEN
binx=Power(2,7-N)
ELSE
binx=1
FI
IF num/binx=1 THEN
xbin(N+1)='1
num=num-binx
ELSE
xbin(n+1)='0
FI
OD
RETURN
;
; Description:
; Inverting the original text
;
; Parameters:
; text - String to be inverted
; newline - Indicates the behaviour of
; text when inverted. If 0 then following
; text will be on the same line otherwise
; new line will formed
;
PROC InvText(BYTE ARRAY text, newline)
BYTE u
FOR u=1 TO text(0)
DO
text(u)==%$80
OD
IF newline = 0 THEN
Print(text)
ELSE
PrintE(text)
FI
RETURN
;
; Description:
; ATASCII to Atari internal code conversion
; Taken from the tutorial by Larry S. for
; SPACE newsletter
;
; Parameters:
; chr - Atari character in decimal
;
BYTE FUNC A2Int(BYTE chr)
BYTE i
i=chr&128
chr==&127
IF chr<32 THEN
RETURN(chr+64+i)
ELSEIF chr<96 THEN
RETURN(chr-32+i)
FI
RETURN(chr+i)
;
; Description:
; Print directly to memory
;
; Parameters:
; str - String to be printed to memory
; mem - Memory address at which to write
; offset - Offset from mem to write at
;
PROC PrintMem(BYTE ARRAY str, mem BYTE offset)
BYTE POINTER pos
BYTE i
FOR i=1 to str(0)
DO
pos=mem+offset+i-1
pos^=A2Int(str(i))
OD
RETURN