]> git.sur5r.net Git - cc65/blob - asminc/apple2.mac
cfg/atari-xex.cfg: fix typo in comment
[cc65] / asminc / apple2.mac
1 ; Convert characters to screen codes
2
3 ; Helper macro that converts and outputs one character
4 .macro _scrcode char
5         .if (char < 256)
6                 .byte   (char + 128)
7         .else
8                 .error  "scrcode: Character constant out of range"
9         .endif
10 .endmacro
11
12 .macro  scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
13
14         ; Bail out if next argument is empty
15         .if     .blank (arg1)
16                 .exitmacro
17         .endif
18
19         ; Check for a string
20         .if     .match ({arg1}, "")
21
22                 ; Walk over all string chars
23                 .repeat .strlen (arg1), i
24                         _scrcode        {.strat (arg1, i)}
25                 .endrepeat
26
27         ; Check for a number
28         .elseif .match (.left (1, {arg1}), 0)
29
30                 ; Just output the number
31                 _scrcode        arg1
32
33         ; Check for a character
34         .elseif .match (.left (1, {arg1}), 'a')
35
36                 ; Just output the character
37                 _scrcode        arg1
38
39         ; Anything else is an error
40         .else
41
42                 .error  "scrcode: invalid argument type"
43
44         .endif
45
46         ; Call the macro recursively with the remaining args
47         scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
48 .endmacro