2005-08-22 17:05:03 +00:00
|
|
|
; Convert characters to screen codes
|
2005-08-28 21:42:03 +00:00
|
|
|
|
|
|
|
; Helper macro that converts and outputs one character
|
|
|
|
.macro _scrcode char
|
2013-04-25 16:32:49 +00:00
|
|
|
.if (char < 256)
|
|
|
|
.byte <(.strat ("h@dbdlhh", char >> 5) << 4) ^ char
|
2005-08-28 21:42:03 +00:00
|
|
|
.else
|
|
|
|
.error "scrcode: Character constant out of range"
|
|
|
|
.endif
|
2005-08-22 17:05:03 +00:00
|
|
|
.endmacro
|
|
|
|
|
2005-08-28 21:42:03 +00:00
|
|
|
.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
|
|
|
|
|
|
|
; Bail out if next argument is empty
|
2013-04-25 16:32:49 +00:00
|
|
|
.if .blank ({arg1})
|
2005-08-28 21:42:03 +00:00
|
|
|
.exitmacro
|
|
|
|
.endif
|
|
|
|
|
|
|
|
; Check for a string
|
|
|
|
.if .match ({arg1}, "")
|
|
|
|
|
|
|
|
; Walk over all string chars
|
|
|
|
.repeat .strlen (arg1), i
|
|
|
|
_scrcode {.strat (arg1, i)}
|
|
|
|
.endrepeat
|
|
|
|
|
|
|
|
; Check for a number
|
|
|
|
.elseif .match (.left (1, {arg1}), 0)
|
|
|
|
|
|
|
|
; Just output the number
|
|
|
|
_scrcode arg1
|
|
|
|
|
|
|
|
; Check for a character
|
|
|
|
.elseif .match (.left (1, {arg1}), 'a')
|
|
|
|
|
|
|
|
; Just output the character
|
|
|
|
_scrcode arg1
|
|
|
|
|
|
|
|
; Anything else is an error
|
|
|
|
.else
|
|
|
|
|
|
|
|
.error "scrcode: invalid argument type"
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
; Call the macro recursively with the remaining args
|
2013-01-22 21:28:26 +00:00
|
|
|
scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
2005-08-28 21:42:03 +00:00
|
|
|
.endmacro
|
2005-08-22 17:05:03 +00:00
|
|
|
|
2013-01-22 21:28:26 +00:00
|
|
|
|