mirror of
https://codeberg.org/cryu/micro-sci-a2-controller
synced 2024-11-24 14:31:34 +00:00
Add custom screencode macro.
This commit is contained in:
parent
8f415a7306
commit
4f204c718f
53
firmware/screencode.h
Normal file
53
firmware/screencode.h
Normal file
@ -0,0 +1,53 @@
|
||||
; Convert characters to screen codes
|
||||
; Modified to pass through codes below 12
|
||||
|
||||
; Helper macro that converts and outputs one character
|
||||
.macro _screencode char
|
||||
.if (char < 256)
|
||||
.if (char > 11)
|
||||
.byte (char | $80)
|
||||
.else
|
||||
.byte (char)
|
||||
.endif
|
||||
.else
|
||||
.error "screencode: Character constant out of range"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro screencode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
||||
|
||||
; Bail out if next argument is empty
|
||||
.if .blank (arg1)
|
||||
.exitmacro
|
||||
.endif
|
||||
|
||||
; Check for a string
|
||||
.if .match ({arg1}, "")
|
||||
|
||||
; Walk over all string chars
|
||||
.repeat .strlen (arg1), i
|
||||
_screencode {.strat (arg1, i)}
|
||||
.endrepeat
|
||||
|
||||
; Check for a number
|
||||
.elseif .match (.left (1, {arg1}), 0)
|
||||
|
||||
; Just output the number
|
||||
_screencode arg1
|
||||
|
||||
; Check for a character
|
||||
.elseif .match (.left (1, {arg1}), 'a')
|
||||
|
||||
; Just output the character
|
||||
_screencode arg1
|
||||
|
||||
; Anything else is an error
|
||||
.else
|
||||
|
||||
.error "screencode: invalid argument type"
|
||||
|
||||
.endif
|
||||
|
||||
; Call the macro recursively with the remaining args
|
||||
screencode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
||||
.endmacro
|
Loading…
Reference in New Issue
Block a user