New atari builtin macro package that features a scrcode macro.

Changed the scrcode macro from the cbm builtin macro package to accept
multiple arguments of different types.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3598 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2005-08-28 21:42:03 +00:00
parent 71ac7eb22d
commit f21605a972
6 changed files with 126 additions and 19 deletions

View file

@ -1,6 +1,7 @@
.depend
ca65
.kdbgrc.ca65
atari.inc
cbm.inc
cpu.inc
generic.inc

View file

@ -52,6 +52,7 @@
/* Predefined macro packages converted into C strings by a perl script */
#include "atari.inc"
#include "cbm.inc"
#include "cpu.inc"
#include "generic.inc"
@ -63,6 +64,7 @@ static struct {
char* Package;
} MacPackages[MAC_COUNT] = {
/* Packages sorted by id */
{ "atari", MacAtari },
{ "cbm", MacCBM },
{ "cpu", MacCPU },
{ "generic", MacGeneric },

View file

@ -46,6 +46,7 @@
/* Constants for the predefined packages */
enum {
MAC_ATARI,
MAC_CBM,
MAC_CPU,
MAC_GENERIC,

View file

@ -0,0 +1,59 @@
; Convert characters to screen codes
; Helper macro that converts and outputs one character
.macro _scrcode char
.if (char >= 0) .and (char <= 31)
.byte (char + 64)
.elseif (char >= 32) .and (char <= 95)
.byte (char - 32)
.elseif (char >= 96) .and (char <= 127)
.byte char
.elseif (char >= 128) .and (char <= 159)
.byte (char + 64)
.elseif (char >= 160) .and (char <= 223)
.byte (char - 32)
.elseif (char >= 224) .and (char <= 255)
.byte char
.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
.endmacro

View file

@ -1,22 +1,62 @@
; Convert characters to screen codes
.macro scrcode str
.repeat .strlen(str), i
.if (.strat(str, i) >= '@' .and .strat(str, i) <= 'z')
.byte .strat(str, i) - '@'
.elseif (.strat(str, i) >= 'A' .and .strat(str, i) <= 'Z')
.byte .strat(str, i) - 'A' + 65
.elseif (.strat(str, i) = '[')
.byte 27
.elseif (.strat(str, i) = ']')
.byte 29
.elseif (.strat(str, i) = '^')
.byte 30
.elseif (.strat(str, i) = '_')
.byte 31
.else
.byte .strat(str, i)
.endif
.endrepeat
; Helper macro that converts and outputs 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
.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
.endmacro

View file

@ -59,7 +59,8 @@ OBJS = anonname.o \
# -----------------------------------------------------------------------------
# List of all macro files
INCS = cbm.inc \
INCS = atari.inc \
cbm.inc \
cpu.inc \
generic.inc \
longbranch.inc
@ -102,6 +103,9 @@ depend dep: $(OBJS:.o=.c)
# -----------------------------------------------------------------------------
# Rules to make config includes
atari.inc: macpack/atari.mac
@$(CVT) $< $@ MacAtari
cbm.inc: macpack/cbm.mac
@$(CVT) $< $@ MacCBM