]> git.sur5r.net Git - cc65/blobdiff - asminc/cbm.mac
Fixed _textcolor definition.
[cc65] / asminc / cbm.mac
index a6ec9f8dbacd18dfa13ae1627a0bfb45904a6bea..6d7ac7e8ddb00bc6d793ceed98571d42e08a7c29 100644 (file)
@@ -1,21 +1,13 @@
 ; Convert characters to screen codes
 
-; Helper macro that converts and outputs one character
+; Macro that converts one character.
+; scrbyte() can be used as an instruction operand
+.define scrbyte(code)   (<(.strat ("h@dbdlhh", code >> 5) << 4) ^ code)
+
+; Helper macro that stores one character
 .macro _scrcode char
-        .if (char >= '@' .and char <= 'z')
-                .byte   (char - '@')
-        .elseif (char >= 'A' .and char <= 'Z')
-                .byte   (char - 'A' + 65)
-        .elseif (char = '[')
-                .byte   27
-        .elseif (char = ']')
-                .byte   29
-        .elseif (char = '^')
-                .byte   30
-        .elseif (char = '_')
-                .byte   31
-        .elseif (char < 256)
-                .byte   char
+        .if (char < 256)
+                .byte   scrbyte {char}
         .else
                 .error  "scrcode: Character constant out of range"
         .endif
@@ -24,7 +16,7 @@
 .macro  scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
 
         ; Bail out if next argument is empty
-        .if     .blank (arg1)
+        .if     .blank ({arg1})
                 .exitmacro
         .endif
 
 
         ; Anything else is an error
         .else
-
                 .error  "scrcode: invalid argument type"
-
         .endif
 
         ; Call the macro recursively with the remaining args
         scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
 .endmacro
-
-