; 20221210 bkw: ; Convert characters to inverse video (set bit 7). Actually, toggles ; bit 7 (passing it inverse video characters turn them into normal ones). ; Based on scrcode macro from cc65's atari.mac. Probably this should ; ship with cc65... ; Helper macro that converts and outputs one character .macro _inv char .if char > $ff .error "inverse: Character constant out of range" .else .byte char .bitxor $80 .endif .endmacro .macro inverse 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 _inv {.strat (arg1, i)} .endrepeat ; Check for a number .elseif .match (.left (1, {arg1}), 0) ; Just output the number _inv arg1 ; Check for a character .elseif .match (.left (1, {arg1}), 'a') ; Just output the character _inv arg1 ; Anything else is an error .else .error "inv: invalid argument type" .endif ; Call the macro recursively with the remaining args inverse arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 .endmacro