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 .depend
ca65 ca65
.kdbgrc.ca65 .kdbgrc.ca65
atari.inc
cbm.inc cbm.inc
cpu.inc cpu.inc
generic.inc generic.inc

View File

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

View File

@@ -46,6 +46,7 @@
/* Constants for the predefined packages */ /* Constants for the predefined packages */
enum { enum {
MAC_ATARI,
MAC_CBM, MAC_CBM,
MAC_CPU, MAC_CPU,
MAC_GENERIC, 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 ; Convert characters to screen codes
.macro scrcode str
.repeat .strlen(str), i ; Helper macro that converts and outputs one character
.if (.strat(str, i) >= '@' .and .strat(str, i) <= 'z') .macro _scrcode char
.byte .strat(str, i) - '@' .if (char >= '@' .and char <= 'z')
.elseif (.strat(str, i) >= 'A' .and .strat(str, i) <= 'Z') .byte (char - '@')
.byte .strat(str, i) - 'A' + 65 .elseif (char >= 'A' .and char <= 'Z')
.elseif (.strat(str, i) = '[') .byte (char - 'A' + 65)
.byte 27 .elseif (char = '[')
.elseif (.strat(str, i) = ']') .byte 27
.byte 29 .elseif (char = ']')
.elseif (.strat(str, i) = '^') .byte 29
.byte 30 .elseif (char = '^')
.elseif (.strat(str, i) = '_') .byte 30
.byte 31 .elseif (char = '_')
.else .byte 31
.byte .strat(str, i) .elseif (char < 256)
.endif .byte char
.endrepeat .else
.error "scrcode: Character constant out of range"
.endif
.endmacro .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 # List of all macro files
INCS = cbm.inc \ INCS = atari.inc \
cbm.inc \
cpu.inc \ cpu.inc \
generic.inc \ generic.inc \
longbranch.inc longbranch.inc
@@ -102,6 +103,9 @@ depend dep: $(OBJS:.o=.c)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Rules to make config includes # Rules to make config includes
atari.inc: macpack/atari.mac
@$(CVT) $< $@ MacAtari
cbm.inc: macpack/cbm.mac cbm.inc: macpack/cbm.mac
@$(CVT) $< $@ MacCBM @$(CVT) $< $@ MacCBM