Mercurial > hg > dmlib
comparison tools/objlink.c @ 2411:829e3080e0ad
Cosmetic cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jan 2020 23:12:21 +0200 |
parents | bc05bcfc4598 |
children | 203b0fbb05d3 |
comparison
equal
deleted
inserted
replaced
2410:bc05bcfc4598 | 2411:829e3080e0ad |
---|---|
1 /* | 1 /* |
2 * objlink - Link files (RAW and PRG) into one PRG object | 2 * objlink - Link files (RAW and PRG) into one PRG object |
3 * Programmed and designed by Matti 'ccr' Hamalainen | 3 * Programmed and designed by Matti 'ccr' Hamalainen |
4 * (C) Copyright 2002-2018 Tecnic Software productions (TNSP) | 4 * (C) Copyright 2002-2020 Tecnic Software productions (TNSP) |
5 * | 5 * |
6 * Please read file 'COPYING' for information on license and distribution. | 6 * Please read file 'COPYING' for information on license and distribution. |
7 */ | 7 */ |
8 #include "dmtool.h" | 8 #include "dmtool.h" |
9 #include "dmlib.h" | 9 #include "dmlib.h" |
10 #include "dmargs.h" | 10 #include "dmargs.h" |
11 #include "dmfile.h" | 11 #include "dmfile.h" |
12 | 12 |
13 | |
13 #define SET_MAX_FILENAMES (128) | 14 #define SET_MAX_FILENAMES (128) |
14 #define SET_MAX_MEMBLOCKS (128) | 15 #define SET_MAX_MEMBLOCKS (128) |
15 | 16 |
16 | 17 |
17 /* Typedefs | 18 /* Typedefs |
21 int start, end; // Start and end address | 22 int start, end; // Start and end address |
22 int type; // Type | 23 int type; // Type |
23 char *name; // Name of the block | 24 char *name; // Name of the block |
24 int placement; | 25 int placement; |
25 } DMMemBlock; | 26 } DMMemBlock; |
27 | |
26 | 28 |
27 typedef struct | 29 typedef struct |
28 { | 30 { |
29 char *name; // Description of memory model | 31 char *name; // Description of memory model |
30 char *desc; | 32 char *desc; |
31 int size; // Total addressable memory size | 33 int size; // Total addressable memory size |
32 int nmemBlocks; // Defined memory areas | 34 int nmemBlocks; // Defined memory areas |
33 DMMemBlock memBlocks[SET_MAX_MEMBLOCKS]; | 35 DMMemBlock memBlocks[SET_MAX_MEMBLOCKS]; |
34 } DMMemModel; | 36 } DMMemModel; |
35 | 37 |
38 | |
36 typedef struct | 39 typedef struct |
37 { | 40 { |
38 char *filename; | 41 char *filename; |
39 int type; | 42 int type; |
40 int placement; | 43 int placement; |
41 int addr; | 44 int addr; |
42 } DMSourceFile; | 45 } DMSourceFile; |
46 | |
43 | 47 |
44 // Source file type | 48 // Source file type |
45 enum | 49 enum |
46 { | 50 { |
47 STYPE_RAW = 1, | 51 STYPE_RAW = 1, |
77 { | 81 { |
78 LA_NONE = -2, | 82 LA_NONE = -2, |
79 LA_AUTO = -1 | 83 LA_AUTO = -1 |
80 }; | 84 }; |
81 | 85 |
86 | |
82 /* Memory models | 87 /* Memory models |
83 */ | 88 */ |
84 const DMMemModel memoryModels[] = { | 89 const DMMemModel memoryModels[] = |
85 { "C64 unrestricted", "$01 = $34", (64*1024), 0, { | 90 { |
86 { 0, 0, 0, NULL, 0 } | 91 { "C64 unrestricted", "$01 = $34", |
87 }}, | 92 64 * 1024, |
88 | 93 0, |
89 { "C64 normal (IO+Basic+Kernal)", "$01 = $37", (64*1024), 3, { | 94 { |
90 { 0xA000, 0xBFFF, MTYPE_ROM_WT, "Basic ROM", PLACE_STATIC }, | 95 { 0x0000, 0x0000, 0 , NULL , 0 } |
91 { 0xD000, 0xDFFF, MTYPE_IO, "I/O", PLACE_STATIC }, | 96 } |
92 { 0xE000, 0xFFFF, MTYPE_ROM_WT, "Kernal ROM", PLACE_STATIC }, | 97 }, |
93 }}, | 98 |
94 | 99 { "C64 normal (IO+Basic+Kernal)", "$01 = $37", |
95 { "C64 modified (IO+Kernal)", "$01 = $36", (64*1024), 2, { | 100 64 * 1024, |
96 { 0xD000, 0xDFFF, MTYPE_IO, "I/O", PLACE_STATIC }, | 101 3, |
97 { 0xE000, 0xFFFF, MTYPE_ROM_WT, "Kernal ROM", PLACE_STATIC }, | 102 { |
98 }}, | 103 { 0xA000, 0xBFFF, MTYPE_ROM_WT , "Basic ROM" , PLACE_STATIC }, |
99 | 104 { 0xD000, 0xDFFF, MTYPE_IO , "I/O" , PLACE_STATIC }, |
100 { "C64 modified (IO only)", "$01 = $35", (64*1024), 1, { | 105 { 0xE000, 0xFFFF, MTYPE_ROM_WT , "Kernal ROM" , PLACE_STATIC }, |
101 { 0xD000, 0xDFFF, MTYPE_IO, "I/O", PLACE_STATIC }, | 106 } |
102 }}, | 107 }, |
103 | 108 |
104 { "C64 modified (Char+Kernal+Basic)", "$01 = $33", (64*1024), 3, { | 109 { "C64 modified (IO+Kernal)", "$01 = $36", |
105 { 0xA000, 0xBFFF, MTYPE_ROM_WT, "Basic ROM", PLACE_STATIC }, | 110 64 * 1024, |
106 { 0xD000, 0xDFFF, MTYPE_ROM, "Char ROM", PLACE_STATIC }, | 111 2, |
107 { 0xE000, 0xFFFF, MTYPE_ROM_WT, "Kernal ROM", PLACE_STATIC }, | 112 { |
108 }}, | 113 { 0xD000, 0xDFFF, MTYPE_IO , "I/O" , PLACE_STATIC }, |
109 | 114 { 0xE000, 0xFFFF, MTYPE_ROM_WT , "Kernal ROM" , PLACE_STATIC }, |
110 /* | 115 } |
111 { "C64 normal", "$01 = $37", (64*1024), 0, { | 116 }, |
112 { 0x0000, 0x0000, MTYPE_RAM, "" }, | 117 |
113 }}, | 118 { "C64 modified (IO only)", "$01 = $35", |
114 */ | 119 64 * 1024, |
120 1, | |
121 { | |
122 { 0xD000, 0xDFFF, MTYPE_IO , "I/O" , PLACE_STATIC }, | |
123 } | |
124 }, | |
125 | |
126 { "C64 modified (Char+Kernal+Basic)", "$01 = $33", | |
127 64 * 1024, | |
128 3, | |
129 { | |
130 { 0xA000, 0xBFFF, MTYPE_ROM_WT , "Basic ROM" , PLACE_STATIC }, | |
131 { 0xD000, 0xDFFF, MTYPE_ROM , "Char ROM" , PLACE_STATIC }, | |
132 { 0xE000, 0xFFFF, MTYPE_ROM_WT , "Kernal ROM" , PLACE_STATIC }, | |
133 } | |
134 }, | |
115 }; | 135 }; |
116 | 136 |
117 static const int nmemoryModels = sizeof(memoryModels) / sizeof(memoryModels[0]); | 137 static const int nmemoryModels = sizeof(memoryModels) / sizeof(memoryModels[0]); |
118 | 138 |
119 | 139 |
123 DMSourceFile srcFiles[SET_MAX_FILENAMES]; // Source file names | 143 DMSourceFile srcFiles[SET_MAX_FILENAMES]; // Source file names |
124 | 144 |
125 int nmemBlocks = 0; | 145 int nmemBlocks = 0; |
126 DMMemBlock memBlocks[SET_MAX_FILENAMES]; | 146 DMMemBlock memBlocks[SET_MAX_FILENAMES]; |
127 | 147 |
148 char *optDestName = NULL; | |
128 char *optLinkFileName = NULL; | 149 char *optLinkFileName = NULL; |
129 int optLinkFileFormat = FMT_GENERIC; | 150 int optLinkFileFormat = FMT_GENERIC; |
130 | |
131 BOOL optDescribe = FALSE, | 151 BOOL optDescribe = FALSE, |
132 optAllowOverlap = FALSE; | 152 optAllowOverlap = FALSE, |
133 | 153 optCropOutput = FALSE; |
134 Uint32 optInitValue = 0; | 154 unsigned int optCropStart, optCropEnd; |
155 unsigned int optInitValue = 0; | |
135 int optInitValueType = 1; | 156 int optInitValueType = 1; |
136 unsigned int optCropStart, optCropEnd; | 157 int optLoadAddress = LA_AUTO; |
137 BOOL optCropOutput = FALSE; | |
138 | |
139 int optLoadAddress = LA_AUTO; | |
140 | |
141 int optMemModel = 0; | 158 int optMemModel = 0; |
142 const DMMemModel *memModel = NULL; | 159 const DMMemModel *memModel = NULL; |
143 Uint8 *memory = NULL; | 160 Uint8 *memory = NULL; |
144 | |
145 char *optDestName = NULL; | |
146 | 161 |
147 | 162 |
148 /* Arguments | 163 /* Arguments |
149 */ | 164 */ |
150 static const DMOptArg optList[] = | 165 static const DMOptArg optList[] = |