36 | 36 |
help="Only parse and analyze the program; do not compile it."
|
37 | 37 |
)
|
38 | 38 |
argparser.add_argument(
|
|
39 |
"--origin", type=str, default='0xc000',
|
|
40 |
help="Location in memory where the `main` routine will be "
|
|
41 |
"located. Default: 0xc000."
|
|
42 |
)
|
|
43 |
argparser.add_argument(
|
|
44 |
"--output-format", type=str, default='prg',
|
|
45 |
help="Executable format to produce. Options are: prg (.PRG file "
|
|
46 |
"for Commodore 8-bit). Default: prg."
|
|
47 |
)
|
|
48 |
argparser.add_argument(
|
39 | 49 |
"--prelude", type=str,
|
40 | 50 |
help="Insert a snippet before the compiled program "
|
41 | 51 |
"so that it can be LOADed and RUN on a certain platforms. "
|
42 | |
"Also sets the origin. "
|
|
52 |
"Also sets the origin and format. "
|
43 | 53 |
"Options are: c64 or vic20."
|
44 | 54 |
)
|
45 | 55 |
argparser.add_argument(
|
|
91 | 101 |
sys.exit(0)
|
92 | 102 |
|
93 | 103 |
fh = sys.stdout
|
94 | |
start_addr = 0xc000
|
|
104 |
|
|
105 |
if options.origin.startswith('0x'):
|
|
106 |
start_addr = int(options.origin, 16)
|
|
107 |
else:
|
|
108 |
start_addr = int(options.origin, 10)
|
|
109 |
|
|
110 |
output_format = options.output_format
|
|
111 |
|
95 | 112 |
prelude = []
|
96 | 113 |
if options.prelude == 'c64':
|
|
114 |
output_format = 'prg'
|
97 | 115 |
start_addr = 0x0801
|
98 | 116 |
prelude = [0x10, 0x08, 0xc9, 0x07, 0x9e, 0x32,
|
99 | 117 |
0x30, 0x36, 0x31, 0x00, 0x00, 0x00]
|
100 | 118 |
elif options.prelude == 'vic20':
|
|
119 |
output_format = 'prg'
|
101 | 120 |
start_addr = 0x1001
|
102 | 121 |
prelude = [0x0b, 0x10, 0xc9, 0x07, 0x9e, 0x34,
|
103 | 122 |
0x31, 0x30, 0x39, 0x00, 0x00, 0x00]
|
104 | |
else:
|
105 | |
raise NotImplementedError
|
|
123 |
elif options.prelude:
|
|
124 |
raise NotImplementedError("Unknown prelude: {}".format(options.prelude))
|
106 | 125 |
|
107 | |
# we are outputting a .PRG, so we output the load address first
|
108 | |
# we don't use the Emitter for this b/c not part of addr space
|
109 | |
if not options.debug:
|
|
126 |
# If we are outputting a .PRG, we output the load address first.
|
|
127 |
# We don't use the Emitter for this b/c not part of addr space.
|
|
128 |
if output_format == 'prg':
|
110 | 129 |
fh.write(Word(start_addr).serialize(0))
|
111 | 130 |
|
112 | 131 |
emitter = Emitter(start_addr)
|