From 72efecbb1a59e5f9ed879b65f5dbd241a23a93d3 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 6 Mar 2018 17:00:39 +0000 Subject: [PATCH] Support different preludes for different archs (c64 and vic20 now.) --- README.md | 4 ---- bin/sixtypical | 17 ++++++++++++----- loadngo.sh => loadngo-c64.sh | 4 ++-- tests/SixtyPical Compilation.md | 2 +- tests/appliances/bin/dcc6502-adapter | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) rename loadngo.sh => loadngo-c64.sh (65%) diff --git a/README.md b/README.md index f55f6ef..788616f 100644 --- a/README.md +++ b/README.md @@ -79,10 +79,6 @@ are trashed inside the block. Not because it saves 3 bytes, but because it's a neat trick. Doing it optimally is probably NP-complete. But doing it adequately is probably not that hard. -### Different preludes for different architectures - -`--prelude=c64-basic` - ### And at some point... * `low` and `high` address operators - to turn `word` type into `byte`. diff --git a/bin/sixtypical b/bin/sixtypical index e084d13..72aabef 100755 --- a/bin/sixtypical +++ b/bin/sixtypical @@ -37,10 +37,11 @@ if __name__ == '__main__': help="Only parse and analyze the program; do not compile it." ) argparser.add_argument( - "--basic-prelude", - action="store_true", - help="Insert a Commodore BASIC 2.0 snippet before the program " - "so that it can be LOADed and RUN on Commodore platforms." + "--prelude", type=str, + help="Insert a snippet before the compiled program " + "so that it can be LOADed and RUN on a certain platforms. " + "Also sets the origin. " + "Options are: c64 or vic20." ) argparser.add_argument( "--debug", @@ -93,10 +94,16 @@ if __name__ == '__main__': fh = sys.stdout start_addr = 0xc000 prelude = [] - if options.basic_prelude: + if options.prelude == 'c64': start_addr = 0x0801 prelude = [0x10, 0x08, 0xc9, 0x07, 0x9e, 0x32, 0x30, 0x36, 0x31, 0x00, 0x00, 0x00] + elif options.prelude == 'vic20': + start_addr = 0x1001 + prelude = [0x0b, 0x10, 0xc9, 0x07, 0x9e, 0x34, + 0x31, 0x30, 0x39, 0x00, 0x00, 0x00] + else: + raise NotImplementedError # we are outputting a .PRG, so we output the load address first # we don't use the Emitter for this b/c not part of addr space diff --git a/loadngo.sh b/loadngo-c64.sh similarity index 65% rename from loadngo.sh rename to loadngo-c64.sh index 0a3401e..b28509e 100755 --- a/loadngo.sh +++ b/loadngo-c64.sh @@ -5,11 +5,11 @@ if [ "X$X64" = "X" ]; then fi SRC=$1 if [ "X$1" = "X" ]; then - echo "Usage: ./loadngo.sh " + echo "Usage: ./loadngo-c64.sh " exit 1 fi OUT=/tmp/a-out.prg -bin/sixtypical --traceback --basic-prelude $SRC > $OUT || exit 1 +bin/sixtypical --traceback --prelude=c64 $SRC > $OUT || exit 1 ls -la $OUT if [ -e vicerc ]; then $X64 -config vicerc $OUT diff --git a/tests/SixtyPical Compilation.md b/tests/SixtyPical Compilation.md index 831b94e..2ead442 100644 --- a/tests/SixtyPical Compilation.md +++ b/tests/SixtyPical Compilation.md @@ -7,7 +7,7 @@ SixtyPical to 6502 machine code. [Falderal]: http://catseye.tc/node/Falderal -> Functionality "Compile SixtyPical program" is implemented by - -> shell command "bin/sixtypical --basic-prelude --traceback %(test-body-file) >/tmp/foo && tests/appliances/bin/dcc6502-adapter shell command "bin/sixtypical --prelude=c64 --traceback %(test-body-file) >/tmp/foo && tests/appliances/bin/dcc6502-adapter Tests for functionality "Compile SixtyPical program" diff --git a/tests/appliances/bin/dcc6502-adapter b/tests/appliances/bin/dcc6502-adapter index d92339b..e11b6aa 100755 --- a/tests/appliances/bin/dcc6502-adapter +++ b/tests/appliances/bin/dcc6502-adapter @@ -1,6 +1,6 @@ #!/usr/bin/env python -# script that allows the binary output of sixtypical --basic-prelude --compile to be +# script that allows the binary output of sixtypical --prelude=c64 --compile to be # disassembled by https://github.com/tcarmelveilleux/dcc6502 import sys