From e2419ece0b596d137b6a9b98f4eb2844c8c29578 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 27 Mar 2016 18:26:46 +0200 Subject: [PATCH] Added scrcode macro for the Apple II. Although the Apple II generally works with plain ASCII (i.e. in the ProDOS 8 MLI) the actual screen codes differ. This fixes #260. --- asminc/apple2.mac | 48 +++++++++++++++++++++++++++++++++++++++++++++++ doc/ca65.sgml | 6 ++++++ 2 files changed, 54 insertions(+) create mode 100644 asminc/apple2.mac diff --git a/asminc/apple2.mac b/asminc/apple2.mac new file mode 100644 index 000000000..b9860c092 --- /dev/null +++ b/asminc/apple2.mac @@ -0,0 +1,48 @@ +; Convert characters to screen codes + +; Helper macro that converts and outputs one character +.macro _scrcode char + .if (char < 256) + .byte (char + 128) + .else + .error "scrcode: Character constant out of range" + .endif +.endmacro + +.macro scrcode 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 + _scrcode {.strat (arg1, i)} + .endrepeat + + ; Check for a number + .elseif .match (.left (1, {arg1}), 0) + + ; Just output the number + _scrcode arg1 + + ; Check for a character + .elseif .match (.left (1, {arg1}), 'a') + + ; Just output the character + _scrcode arg1 + + ; 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 diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 14fe8714f..6ea17d335 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4450,6 +4450,12 @@ The package defines the following macros: +.MACPACK apple2

+ +This macro package defines a macro named .MACPACK atari

This macro package defines a macro named