1 ; Convert characters to screen codes
3 ; Helper macro that converts and outputs one character
5 .if (char >= 0) .and (char <= 31)
7 .elseif (char >= 32) .and (char <= 95)
9 .elseif (char >= 96) .and (char <= 127)
11 .elseif (char >= 128) .and (char <= 159)
13 .elseif (char >= 160) .and (char <= 223)
15 .elseif (char >= 224) .and (char <= 255)
18 .error "scrcode: Character constant out of range"
22 .macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
24 ; Bail out if next argument is empty
30 .if .match ({arg1}, "")
32 ; Walk over all string chars
33 .repeat .strlen (arg1), i
34 _scrcode {.strat (arg1, i)}
38 .elseif .match (.left (1, {arg1}), 0)
40 ; Just output the number
43 ; Check for a character
44 .elseif .match (.left (1, {arg1}), 'a')
46 ; Just output the character
49 ; Anything else is an error
52 .error "scrcode: invalid argument type"
56 ; Call the macro recursively with the remaining args
57 scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9