Support different preludes for different archs (c64 and vic20 now.)
Chris Pressey
5 years ago
78 | 78 | Not because it saves 3 bytes, but because it's a neat trick. Doing it optimally |
79 | 79 | is probably NP-complete. But doing it adequately is probably not that hard. |
80 | 80 | |
81 | ### Different preludes for different architectures | |
82 | ||
83 | `--prelude=c64-basic` | |
84 | ||
85 | 81 | ### And at some point... |
86 | 82 | |
87 | 83 | * `low` and `high` address operators - to turn `word` type into `byte`. |
36 | 36 | help="Only parse and analyze the program; do not compile it." |
37 | 37 | ) |
38 | 38 | argparser.add_argument( |
39 | "--basic-prelude", | |
40 | action="store_true", | |
41 | help="Insert a Commodore BASIC 2.0 snippet before the program " | |
42 | "so that it can be LOADed and RUN on Commodore platforms." | |
39 | "--prelude", type=str, | |
40 | help="Insert a snippet before the compiled program " | |
41 | "so that it can be LOADed and RUN on a certain platforms. " | |
42 | "Also sets the origin. " | |
43 | "Options are: c64 or vic20." | |
43 | 44 | ) |
44 | 45 | argparser.add_argument( |
45 | 46 | "--debug", |
92 | 93 | fh = sys.stdout |
93 | 94 | start_addr = 0xc000 |
94 | 95 | prelude = [] |
95 | if options.basic_prelude: | |
96 | if options.prelude == 'c64': | |
96 | 97 | start_addr = 0x0801 |
97 | 98 | prelude = [0x10, 0x08, 0xc9, 0x07, 0x9e, 0x32, |
98 | 99 | 0x30, 0x36, 0x31, 0x00, 0x00, 0x00] |
100 | elif options.prelude == 'vic20': | |
101 | start_addr = 0x1001 | |
102 | prelude = [0x0b, 0x10, 0xc9, 0x07, 0x9e, 0x34, | |
103 | 0x31, 0x30, 0x39, 0x00, 0x00, 0x00] | |
104 | else: | |
105 | raise NotImplementedError | |
99 | 106 | |
100 | 107 | # we are outputting a .PRG, so we output the load address first |
101 | 108 | # we don't use the Emitter for this b/c not part of addr space |
0 | #!/bin/sh | |
1 | ||
2 | if [ "X$X64" = "X" ]; then | |
3 | X64=x64 | |
4 | fi | |
5 | SRC=$1 | |
6 | if [ "X$1" = "X" ]; then | |
7 | echo "Usage: ./loadngo-c64.sh <source.60p>" | |
8 | exit 1 | |
9 | fi | |
10 | OUT=/tmp/a-out.prg | |
11 | bin/sixtypical --traceback --prelude=c64 $SRC > $OUT || exit 1 | |
12 | ls -la $OUT | |
13 | if [ -e vicerc ]; then | |
14 | $X64 -config vicerc $OUT | |
15 | else | |
16 | $X64 $OUT | |
17 | fi | |
18 | rm -f $OUT |
0 | #!/bin/sh | |
1 | ||
2 | if [ "X$X64" = "X" ]; then | |
3 | X64=x64 | |
4 | fi | |
5 | SRC=$1 | |
6 | if [ "X$1" = "X" ]; then | |
7 | echo "Usage: ./loadngo.sh <source.60p>" | |
8 | exit 1 | |
9 | fi | |
10 | OUT=/tmp/a-out.prg | |
11 | bin/sixtypical --traceback --basic-prelude $SRC > $OUT || exit 1 | |
12 | ls -la $OUT | |
13 | if [ -e vicerc ]; then | |
14 | $X64 -config vicerc $OUT | |
15 | else | |
16 | $X64 $OUT | |
17 | fi | |
18 | rm -f $OUT |
6 | 6 | [Falderal]: http://catseye.tc/node/Falderal |
7 | 7 | |
8 | 8 | -> Functionality "Compile SixtyPical program" is implemented by |
9 | -> shell command "bin/sixtypical --basic-prelude --traceback %(test-body-file) >/tmp/foo && tests/appliances/bin/dcc6502-adapter </tmp/foo" | |
9 | -> shell command "bin/sixtypical --prelude=c64 --traceback %(test-body-file) >/tmp/foo && tests/appliances/bin/dcc6502-adapter </tmp/foo" | |
10 | 10 | |
11 | 11 | -> Tests for functionality "Compile SixtyPical program" |
12 | 12 |