RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
8bitexe.h
1#ifndef _8BITEXE_H
2#define _8BITEXE_H
3
4#include <algorithm>
5#include "binary.h"
6#include "gsos.h"
7#include "../common.h"
8#include "../dumper/dumper.h"
9#include "../linker/module.h"
10#include "../linker/options.h"
11#include "../linker/reader.h"
12#include "../linker/segment.h"
13#include "../linker/writer.h"
14
15/* a collection of various simple 8-bit formats */
16/* TODO: should this be reorganized? */
17
18namespace Apple
19{
24 {
25 public:
26 bool dos33_header;
27
28 /* TODO: enable setting the base address as a parameter */
29
30 AppleFormat(uint64_t default_base_address = 0x0803, std::string default_extension = "", bool dos33_header = true)
31 : GenericBinaryFormat(default_base_address, default_extension), dos33_header(dos33_header)
32 {
33 }
34
35 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
36
38 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
39 void Dump(Dumper::Dumper& dump) const override;
40 };
41
46 {
47 public:
48 // TODO: untested
49
50 std::shared_ptr<Linker::Contents> optional_header;
51
52 /* TODO: enable setting the base address as a parameter */
53
54 SOSFormat(uint64_t default_base_address = 0x9000, std::string default_extension = "") // TODO: what would be a good default address? this is lifted from the SOS reference manual
55 : GenericBinaryFormat(default_base_address, default_extension)
56 {
57 }
58
59 offset_t ImageSize() const override;
60
61 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
62
64 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
65 void Dump(Dumper::Dumper& dump) const override;
66 };
67
82 {
83 public:
84 std::shared_ptr<Linker::OutputFormat> data_fork;
85
95 header_format_t header;
96
97 file_type_t file_type;
98 /* TODO: enable setting the base address as a parameter */
99
100 AppleDriver(file_type_t file_type = FILE_TYPE_BIN, header_format_t header = HEADER_BIN)
102 header(header),
103 file_type(file_type)
104 {
105 }
106
107 AppleDriver(file_type_t file_type, target_format_t target)
108 : GSOutputDriver(target, 0),
109 header(HEADER_BIN),
110 file_type(file_type)
111 {
112 }
113
114 protected:
115 void OnContainerCreated() override;
116 void OnReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
117 offset_t OnWriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
118 void OnDump(Dumper::Dumper& dump) const override;
119
120 public:
121 void SetAppleSingleDoubleVersion(offset_t version);
122
124 {
125 public:
126 Linker::Option<std::optional<offset_t>> asver{"asver", "Version of the AppleSingle/AppleDouble container (recognized values: 1, 2)"};
127 Linker::Option<std::optional<offset_t>> adver{"adver", "Version of the AppleSingle/AppleDouble container (recognized values: 1, 2)"};
128
130 {
131 InitializeFields(asver, adver);
132 }
133 };
134
135 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
136 void SetOptions(std::map<std::string, std::string>& options) override;
137
138 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
139
140 void CalculateValues() override;
141
142 void GenerateFile(std::string filename, Linker::Module& module) override;
143 void Dump(Dumper::Dumper& dump) const override;
144
145 uint8_t GetFileType() const;
146 uint16_t GetAuxiliaryFileType() const;
147
148 bool UseDOS33Header() const
149 {
150 if(file_type != FILE_TYPE_BIN || target != OutputDriver::TARGET_DATA_FORK)
151 {
152 return false;
153 }
154
155 switch(header)
156 {
157 case HEADER_BIN:
158 // only apply header if there is no NAPS suffix
160 case HEADER_DOS33:
161 return true;
162 default:
163 case HEADER_RAW:
164 return false;
165 }
166 }
167
169 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
170 };
171}
172
173namespace Atari
174{
179 {
180 public:
181 /* exe, obj, com are also used */
182 AtariFormat(uint64_t default_base_address = 0, std::string default_extension = ".xex")
183 : GenericBinaryFormat(default_base_address, default_extension)
184 {
185 }
186
190 struct Segment
191 {
192 public:
196 enum segment_type : uint16_t
197 {
201 SDX_FIXED = 0xFFFA,
203 SDX_SYMREQ = 0xFFFB,
205 SDX_SYMDEF = 0xFFFC,
207 SDX_FIXUPS = 0xFFFD,
209 SDX_RAMALLOC = 0xFFFE,
211 SDX_POSIND = 0xFFFE,
214 };
226 uint16_t address = 0;
230 uint8_t block_number = 0;
231 enum control_byte_type : uint8_t
232 {
243 };
251 uint16_t size = 0;
255 char symbol_name[8] = { };
259 std::shared_ptr<Linker::Contents> image;
263 std::set<uint16_t> relocations; // TODO: multiple blocks?
264
265 Segment(bool header_type_optional = true)
267 {
268 }
269
270 Segment(uint16_t header_type)
272 {
273 }
274
278 offset_t GetSize() const;
279
283 void ReadFile(const std::shared_ptr<Linker::Reader>& rd);
284
288 void WriteFile(const std::shared_ptr<Linker::Writer>& wr) const;
289
293 void ReadRelocations(const std::shared_ptr<Linker::Reader>& rd);
294
298 void WriteRelocations(const std::shared_ptr<Linker::Writer>& wr) const;
299 };
300
304 std::vector<std::unique_ptr<Segment>> segments;
305
307 static const uint16_t LOADER_ADDRESS = 0x02E2;
308
313 static const uint16_t ENTRY_ADDRESS = 0x02E0;
314
316 bool HasEntryPoint() const;
318 void AddEntryPoint(uint16_t entry);
319
320 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
321
322 void ProcessModule(Linker::Module& module) override;
323
324 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
325
327 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
328 void Dump(Dumper::Dumper& dump) const override;
329 };
330}
331
332namespace Commodore
333{
338 {
339 public:
341 {
342 public:
343 uint16_t line_address = 0;
344 uint16_t line_number = 0;
345 uint16_t next_address = 0;
346 std::vector<uint8_t> tokens;
347
348 /* BASIC token */
349 enum Token
350 {
351 // using http://fileformats.archiveteam.org/wiki/Commodore_BASIC_tokenized_file
352 END = 0x80,
353 FOR = 0x81,
354 NEXT = 0x82,
355 DATA = 0x83,
356 INPUT_HASH = 0x84,
357 INPUT = 0x85,
358 DIM = 0x86,
359 READ = 0x87,
360 LET = 0x88,
361 GOTO = 0x89,
362 RUN = 0x8A,
363 IF = 0x8B,
364 RESTORE = 0x8C,
365 GOSUB = 0x8D,
366 RETURN = 0x8E,
367 REM = 0x8F,
368 STOP = 0x90,
369 ON = 0x91,
370 WAIT = 0x92,
371 LOAD = 0x93,
372 SAVE = 0x94,
373 VERIFY = 0x95,
374 DEF = 0x96,
375 POKE = 0x97,
376 PRINT_HASH = 0x98,
377 PRINT = 0x99,
378 CONST = 0x9A,
379 LIST = 0x9B,
380 CLR = 0x9C,
381 CMD = 0x9D,
382 SYS = 0x9E,
383 OPEN = 0x9F,
384 CLOSE = 0xA0,
385 GET = 0xA1,
386 NEW = 0xA2,
387 TAB_PAREN = 0xA3,
388 TO = 0xA4,
389 FN = 0xA5,
390 SPC_PAREN = 0xA6,
391 THEN = 0xA7,
392 NOT = 0xA8,
393 STEP = 0xA9,
394 _PLUS = 0xAA,
395 _MINUS = 0xAB,
396 _MULTIPLY = 0xAC,
397 _DIVIDE = 0xAD,
398 _POWER = 0xAE,
399 AND = 0xAF,
400 OR = 0xB0,
401 _GREATER = 0xB1,
402 _EQUAL = 0xB2,
403 _LESS = 0xB3,
404 SGN = 0xB4,
405 INT = 0xB5,
406 ABS = 0xB6,
407 USR = 0xB7,
408 FRE = 0xB8,
409 POS = 0xB9,
410 SQR = 0xBA,
411 RND = 0xBB,
412 LOG = 0xBC,
413 EXP = 0xBD,
414 COS = 0xBE,
415 SIN = 0xBF,
416 TAN = 0xC0,
417 ATN = 0xC1,
418 PEEK = 0xC2,
419 LEN = 0xC3,
420 STR_DOLLAR = 0xC4,
421 VAL = 0xC5,
422 ASC = 0xC6,
423 CHR_DOLLAR = 0xC7,
424 LEFT_DOLLAR = 0xC8,
425 RIGHT_DOLLAR = 0xC9,
426 MID_DOLLAR = 0xCA,
427 GO = 0xCB,
428 _PI = 0xFF,
429 };
430
431 void AddToken(Token token);
432 void AddString(std::string text);
433 void AddDecimal(int value);
434 offset_t ImageSize() const override; // including header
435
436 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
438 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
439 void CalculateValues();
440 void Dump(Dumper::Dumper& dump) const override;
441 void Dump(Dumper::Dumper& dump, std::optional<uint16_t> line_index, int display_flags) const;
442 };
443
445 {
446 public:
447 uint16_t load_address = 0;
448 std::vector<BASICLine> lines;
449 uint16_t end_address = 0;
450
451 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
453 offset_t ImageSize() const override;
454 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
455 void CalculateValues();
456 void Dump(Dumper::Dumper& dump) const override;
457 void Dump(Dumper::Dumper& dump, int display_flags) const;
458 };
459
461 static const uint16_t PET_BASIC_START = 0x0401;
463 static const uint16_t VIC_BASIC_START = 0x1001;
465 static const uint16_t C64_BASIC_START = 0x0801;
466
468 {
469 public:
471 {
472 public:
474 : Enumeration(
475 "PET", PET_BASIC_START,
476 "VIC20", VIC_BASIC_START,
477 "VIC-20", VIC_BASIC_START,
478 "VIC", VIC_BASIC_START,
479 "C64", C64_BASIC_START)
480 {
481 descriptions = {
482 { PET_BASIC_START, "Commodore PET" },
483 { VIC_BASIC_START, "Commodore VIC-20" },
484 { C64_BASIC_START, "Commodore 64" },
485 };
486 }
487 };
488
489 Linker::Option<Linker::ItemOf<SystemTypeEnumeration>> system{"system", "Target Commodore system type", C64_BASIC_START};
490 Linker::Option<std::optional<offset_t>> load_address{"load_address", "Load address for BASIC code"};
491
492 CommodoreOptionCollector()
493 {
494 InitializeFields(system, load_address);
495 }
496 };
497
498 uint16_t load_address = 0;
499 std::shared_ptr<Linker::Contents> loader;
500
501 uint16_t GetLoadAddress() const;
502
503 void Clear() override;
504
505 ~CommodoreFormat()
506 {
507 Clear();
508 }
509
510 void SetupDefaultLoader();
511 uint16_t GetImagePaddingSize() const;
512
513 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
514 void SetOptions(std::map<std::string, std::string>& options) override;
515
516 void ProcessModule(Linker::Module& module) override;
517
518 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
519 void CalculateValues() override;
520 offset_t ImageSize() const override;
522 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
523 void Dump(Dumper::Dumper& dump) const override;
524
526 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
527 };
528}
529
530namespace DigitalResearch
531{
532 class PRLFormat;
533
538 {
539 public:
541 {
542 public:
543 Linker::Option<std::optional<std::vector<std::string>>> rsx_file_names{"rsx", "List of filenames to append as Resident System Extensions"};
544
546 {
547 InitializeFields(rsx_file_names);
548 }
549 };
550
552 uint8_t preinit_code[10] = { 0xC9 }; /* z80 return instruction */
554 bool loader_active = true;
557 {
559 std::string rsx_file_name;
561 std::string name;
563 uint16_t offset = 0;
565 uint16_t length = 0;
567 bool nonbanked_only = false;
569 std::shared_ptr<PRLFormat> module;
570
572 void OpenAndPrepare();
573 };
575 std::vector<rsx_record> rsx_table;
576
577 void Clear() override;
578
579 CPM3Format()
580 : GenericBinaryFormat(0x0100, ".com")
581 {
582 }
583
585 {
586 Clear();
587 }
588
589 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
590
591 void SetOptions(std::map<std::string, std::string>& options) override;
592
593 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
594
596 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
597 void Dump(Dumper::Dumper& dump) const override;
598
599 void CalculateValues() override;
600 };
601
606 {
607 public:
609 {
610 public:
611 Linker::Option<bool> banked{"banked", "Generated .SPR file for banked CP/M 3"};
612
614 {
615 InitializeFields(banked);
616 }
617 };
618
620 uint16_t zero_fill = 0;
622 uint16_t load_address = 0; // TODO: implement
624 uint16_t cslen = 0; // TODO: implement
625
628
630 bool option_banked_bios = false; // TODO: make flag, implement behavior
631
633 std::set<uint16_t> relocations;
634
662
663 static uint16_t GetDefaultBaseAddress(application_type application);
664 static std::string GetDefaultApplicationExtension(application_type application);
665
667 :
668 GenericBinaryFormat(GetDefaultBaseAddress(application), GetDefaultApplicationExtension(application)),
671 {
672 }
673
674 std::shared_ptr<Linker::OptionCollector> GetOptions() override;
675 void SetOptions(std::map<std::string, std::string>& options) override;
676
677 std::unique_ptr<Script::List> GetScript(Linker::Module& module) override;
678
679 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
680
681 bool ProcessRelocation(Linker::Module& module, Linker::Relocation& rel, Linker::Resolution resolution) override;
682
683 void ProcessModule(Linker::Module& module) override;
684
685 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
686
688 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
689
691 void ReadWithoutHeader(const std::shared_ptr<Linker::Reader>& rd, uint16_t image_size);
692
694 void WriteWithoutHeader(const std::shared_ptr<Linker::Writer>& wr) const;
695
696 void Dump(Dumper::Dumper& dump) const override;
697 };
698}
699
700namespace FLEX
701{
706 {
707 public:
708 /* TODO: enable setting the base address, default should be ??? */
709
710 struct Segment
711 {
712 public:
713 uint16_t address;
714 uint16_t size; /* it is supposed to be at most 255, but we can store larger segments by cutting them into pieces */
715 std::shared_ptr<Linker::Contents> image;
716
717 void WriteFile(const std::shared_ptr<Linker::Writer>& wr) const;
718 };
719
720 std::vector<std::unique_ptr<Segment>> segments;
721
722 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
723
725 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
726 void Dump(Dumper::Dumper& dump) const override;
727
729 std::string GetDefaultExtension(Linker::Module& module, std::string filename) const override;
730 };
731}
732
733namespace UZI
734{
739 {
740 public:
741 /* TODO */
742 bool uzi180_header;
743 uint16_t entry;
744
745 void ProcessModule(Linker::Module& module) override;
746
748 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
749 void Dump(Dumper::Dumper& dump) const override;
750
752 std::string GetDefaultExtension(Linker::Module& module) const override;
753 };
754
759 {
760 public:
761 std::shared_ptr<Linker::Contents> code, data;
762
763 void OnNewSegment(std::shared_ptr<Linker::Segment> segment) override;
764
765 /* TODO: apparently both .code and .data are loaded at 0x0100 */
766
768 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
769 void Dump(Dumper::Dumper& dump) const override;
770
772 std::string GetDefaultExtension(Linker::Module& module) const override;
773 };
774}
775
776#endif /* _8BITEXE_H */
This is not actually a file format, but an interface to permit generating multiple binary outputs for...
Definition 8bitexe.h:82
offset_t OnWriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Called if there is no container allocated.
Definition 8bitexe.cc:262
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition 8bitexe.cc:298
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition 8bitexe.cc:245
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition 8bitexe.cc:141
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:310
void GenerateFile(std::string filename, Linker::Module &module) override
The main function that handles processing, calculating and generating the final image.
Definition 8bitexe.cc:201
void OnReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Called if there is no container allocated.
Definition 8bitexe.cc:250
void OnContainerCreated() override
Called after the container is created.
Definition 8bitexe.cc:238
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:191
void OnDump(Dumper::Dumper &dump) const override
Called if there is no container allocated.
Definition 8bitexe.cc:267
header_format_t
Definition 8bitexe.h:87
@ HEADER_RAW
For a BIN file, there is no DOS 3.3 header (even if no "+naps" is specified)
Definition 8bitexe.h:93
@ HEADER_BIN
For a BIN file, there may or may not be a DOS 3.3 header (if no "+naps" is specified)
Definition 8bitexe.h:89
@ HEADER_DOS33
For a BIN file, the DOS 3.3 header is included (even if "+naps" is specified)
Definition 8bitexe.h:91
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition 8bitexe.cc:136
BIN file for Apple ][.
Definition 8bitexe.h:24
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:18
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:31
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:45
This is not actually a file format, but an interface to permit generating multiple binary outputs for...
Definition gsos.h:783
target_format_t
Represents the file type of the main file.
Definition gsos.h:787
@ TARGET_DATA_FORK
Main file is a data fork, typically empty.
Definition gsos.h:791
@ PRODUCE_NAPS_SUFFIX
NuLib2 attribute preservation string suffix, such as #06xxxx (Apple II, III, IIgs only)
Definition apple.h:741
target_format_t target
Format of "filename".
Definition apple.h:746
@ TARGET_DATA_FORK
Main file is a data fork, typically empty.
Definition apple.h:717
produce_format_t produce
Bitset of other files to produce.
Definition apple.h:749
SOS file for Apple ///.
Definition 8bitexe.h:46
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition 8bitexe.cc:64
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:89
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:108
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:69
EXE file for Atari 400/800.
Definition 8bitexe.h:179
static const uint16_t LOADER_ADDRESS
Address which contains a loader between to execute between loading segments.
Definition 8bitexe.h:307
void AddEntryPoint(uint16_t entry)
Attaches a new segment that contains the entry point.
Definition 8bitexe.cc:332
static const uint16_t ENTRY_ADDRESS
Address which contains the actual entry address after loading.
Definition 8bitexe.h:313
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:482
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition 8bitexe.cc:466
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:509
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:499
std::vector< std::unique_ptr< Segment > > segments
Sequence of segments.
Definition 8bitexe.h:304
bool HasEntryPoint() const
An entry point is present if the memory address at EntryAddress has been filled by a segment.
Definition 8bitexe.cc:322
A template for flat binary formats.
Definition binary.h:21
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition 8bitexe.cc:737
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:747
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:777
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:716
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:560
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:591
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:574
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition 8bitexe.cc:555
PRG file for Commodore PET/VIC-20/64.
Definition 8bitexe.h:338
static const uint16_t C64_BASIC_START
Address at which the BASIC program should start for a Commodore 64.
Definition 8bitexe.h:465
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition 8bitexe.cc:841
void Clear() override
Resets all fields to their default values, deallocate memory.
Definition 8bitexe.cc:796
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition 8bitexe.cc:895
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition 8bitexe.cc:836
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition 8bitexe.cc:854
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition 8bitexe.cc:889
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:910
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:900
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:876
static const uint16_t VIC_BASIC_START
Address at which the BASIC program should start for a Commodore VIC-20.
Definition 8bitexe.h:463
static const uint16_t PET_BASIC_START
Address at which the BASIC program should start for a Commodore PET.
Definition 8bitexe.h:461
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition 8bitexe.cc:937
CP/M Plus .com file format.
Definition 8bitexe.h:538
bool loader_active
Whether loader should be active, even if no RSXs are attached.
Definition 8bitexe.h:554
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition 8bitexe.cc:1095
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:1021
std::vector< rsx_record > rsx_table
The attached RSX records.
Definition 8bitexe.h:575
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:1056
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:1084
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition 8bitexe.cc:988
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition 8bitexe.cc:983
void Clear() override
Resets all fields to their default values, deallocate memory.
Definition 8bitexe.cc:978
uint8_t preinit_code[10]
Pre-initialization code to be executed before fully loading program.
Definition 8bitexe.h:552
MP/M .prl file format.
Definition 8bitexe.h:606
std::set< uint16_t > relocations
Offsets to bytes referencing pages that must be relocated.
Definition 8bitexe.h:633
uint16_t zero_fill
Additional memory to allocate, similar to .bss.
Definition 8bitexe.h:620
void WriteWithoutHeader(const std::shared_ptr< Linker::Writer > &wr) const
Write without header, only needed for RSX files stored inside a CP/M 3 .COM file.
Definition 8bitexe.cc:1346
void OnNewSegment(std::shared_ptr< Linker::Segment > segment) override
Callback function when allocating a new segment When the linker script runs, it creates segments cons...
Definition 8bitexe.cc:1241
bool ProcessRelocation(Linker::Module &module, Linker::Relocation &rel, Linker::Resolution resolution) override
Callback function to process relocations.
Definition 8bitexe.cc:1251
std::shared_ptr< Linker::OptionCollector > GetOptions() override
Returns object containing a sequence of option fields provided with the -S command line flag.
Definition 8bitexe.cc:1159
application_type
The format of the generated binary.
Definition 8bitexe.h:642
@ APPL_OVL
CP/M-80 .ovl overlay (unsupported)
Definition 8bitexe.h:658
@ APPL_RSM
CP/M-80 2 .rsm resident system extension file (unsupported)
Definition 8bitexe.h:650
@ APPL_SPR
MP/M-80 .spr system module file (unsupported)
Definition 8bitexe.h:656
@ APPL_UNKNOWN
Unspecified.
Definition 8bitexe.h:644
@ APPL_BRS
MP/M-80 .brs banked resident system process file (unsupported)
Definition 8bitexe.h:654
@ APPL_RSP
MP/M-80 .rsp resident system process file (unsupported)
Definition 8bitexe.h:652
@ APPL_PRL
MP/M-80 .prl executable file.
Definition 8bitexe.h:646
@ APPL_RSX
CP/M-80 Plus .rsx resident system extension file (unsupported)
Definition 8bitexe.h:648
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:1369
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition 8bitexe.cc:1267
void SetOptions(std::map< std::string, std::string > &options) override
Passes command line parameters as settings over to format object.
Definition 8bitexe.cc:1164
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:1330
bool option_banked_bios
On a banked BIOS, align the data segment of the .SPR on a page boundary and store the length of the c...
Definition 8bitexe.h:630
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition 8bitexe.cc:1284
bool suppress_relocations
Do not include relocations, only used for .OVL files.
Definition 8bitexe.h:627
application_type application
Target application type.
Definition 8bitexe.h:661
void ReadWithoutHeader(const std::shared_ptr< Linker::Reader > &rd, uint16_t image_size)
Read without header, only needed for RSX files stored inside a CP/M 3 .COM file.
Definition 8bitexe.cc:1299
uint16_t load_address
Address to be loaded at, only used for .OVL files.
Definition 8bitexe.h:622
uint16_t cslen
Code segment length, only used for .SPR files in banked systems.
Definition 8bitexe.h:624
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:1009
FLEX .cmd file format from Technical Systems Consultants.
Definition 8bitexe.h:706
std::string GetDefaultExtension(Linker::Module &module, std::string filename) const override
Appends a default extension to the filename.
Definition 8bitexe.cc:1152
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:1141
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:1131
A representation of an enumeration with associated string representations for each value.
Definition options.h:15
std::map< value_type, std::string > descriptions
An empty dictionary that explains the value types in detail.
Definition options.h:20
A class to encode a general file format.
Definition format.h:29
offset_t WriteFile(const std::shared_ptr< Writer > &wr) const override=0
Stores data in memory to file.
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
Helper class that contains the options interpreted by the format.
Definition options.h:499
Documents and handles command line options.
Definition options.h:306
virtual std::string GetDefaultExtension(Module &module, std::string filename) const
Appends a default extension to the filename.
A representation of a value within some binary data that has to be fixed up once the exact position o...
Definition relocation.h:28
Representing a resolved relocation.
Definition resolution.h:17
UZI280 file format.
Definition 8bitexe.h:759
void OnNewSegment(std::shared_ptr< Linker::Segment > segment) override
Callback function when allocating a new segment When the linker script runs, it creates segments cons...
Definition 8bitexe.cc:1442
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:1474
std::string GetDefaultExtension(Linker::Module &module) const override
Provides a default filename for the output file.
Definition 8bitexe.cc:1485
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:1460
UZI/UZI280 file formats.
Definition 8bitexe.h:739
std::string GetDefaultExtension(Linker::Module &module) const override
Provides a default filename for the output file.
Definition 8bitexe.cc:1435
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition 8bitexe.cc:1424
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition 8bitexe.cc:1411
void ProcessModule(Linker::Module &module) override
Processes the module object and initializes format fields.
Definition 8bitexe.cc:1405
Represents a loadable segment in the binary.
Definition 8bitexe.h:191
control_byte_type control_byte
Only used for SDX_RAMALLOC/SDX_POSIND.
Definition 8bitexe.h:247
void WriteRelocations(const std::shared_ptr< Linker::Writer > &wr) const
Writes relocations.
Definition 8bitexe.cc:450
uint8_t block_number
Only used for SDX_RAMALLOC/SDX_POSIND, SDX_SYMREQ.
Definition 8bitexe.h:230
std::shared_ptr< Linker::Contents > image
The binary data in the segment.
Definition 8bitexe.h:259
uint16_t address
Address at which segment must be loaded.
Definition 8bitexe.h:226
offset_t GetSize() const
Retrieves the number of bytes in the segment body.
Definition 8bitexe.cc:317
char symbol_name[8]
Only used for SDX_SYMREQ, SDX_SYMDEF.
Definition 8bitexe.h:255
void WriteFile(const std::shared_ptr< Linker::Writer > &wr) const
Writes the segment into a file.
Definition 8bitexe.cc:394
control_byte_type
Definition 8bitexe.h:232
@ CB_PROGEXTAREA
(SDX 4.47+) allocate in program extended area
Definition 8bitexe.h:238
@ CB_PAGEALIGNED
(SDX 4.43+) page aligned
Definition 8bitexe.h:240
@ CB_SYSEXTAREA
allocate in system extended area
Definition 8bitexe.h:236
@ CB_CONVRAM
allocate in conventional RAM
Definition 8bitexe.h:234
@ CB_RAMALLOC
SDX_RAMALLOC instead of SDX_POSIND.
Definition 8bitexe.h:242
void ReadRelocations(const std::shared_ptr< Linker::Reader > &rd)
Read relocations.
Definition 8bitexe.cc:445
segment_type
Types of segments, represented by their signature values.
Definition 8bitexe.h:197
@ SDX_SYMREQ
SpartaDOS X required symbols (not implemented)
Definition 8bitexe.h:203
@ SDX_FIXUPS
SpartaDOS X fixup information (not implemented)
Definition 8bitexe.h:207
@ SDX_FIXED
SpartaDOS X fixed-address segment (not implemented)
Definition 8bitexe.h:201
@ SDX_SYMDEF
SpartaDOS X symbol definitions (not implemented)
Definition 8bitexe.h:205
@ SDX_POSIND
SpartaDOS X position independent (not implemented)
Definition 8bitexe.h:211
@ SDX_RAMALLOC
SpartaDOS X RAM allocation block (not implemented)
Definition 8bitexe.h:209
@ ATARI_SEGMENT
Atari segment type.
Definition 8bitexe.h:213
@ SIGNATURE_LOW
Lowest currently defined signature to check on reading.
Definition 8bitexe.h:199
std::set< uint16_t > relocations
Relocations, only used for SDX_SYMREQ and SDX_FIXUPS.
Definition 8bitexe.h:263
void ReadFile(const std::shared_ptr< Linker::Reader > &rd)
Reads a segment from a file into this object.
Definition 8bitexe.cc:342
uint16_t size
Only used for SDX_RAMALLOC/SDX_POSIND.
Definition 8bitexe.h:251
bool header_type_optional
Set if placing header type is optional, also set when signature is absent in file when reading.
Definition 8bitexe.h:222
segment_type header_type
Header type, Atari DOS uses only 0xFFFF, signature only obligatory for the first segment.
Definition 8bitexe.h:218
A single RSX record.
Definition 8bitexe.h:557
uint16_t length
Length of RSX module, only used for reading.
Definition 8bitexe.h:565
bool nonbanked_only
Whether RSX is only loaded on non-banked systems.
Definition 8bitexe.h:567
std::string name
Name of RSX file, as stored inside RSX.
Definition 8bitexe.h:561
uint16_t offset
Offset to RSX block.
Definition 8bitexe.h:563
std::string rsx_file_name
Name of RSX file to load, only used for writing.
Definition 8bitexe.h:559
std::shared_ptr< PRLFormat > void OpenAndPrepare()
The actual RSX data, stored in PRLFormat (on disk, without the header)
Definition 8bitexe.cc:944
Definition 8bitexe.h:711