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