summaryrefslogtreecommitdiff
path: root/src/satmkboot.c
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2015-07-08 23:20:18 -0500
committerBobby Bingham <koorogi@koorogi.info>2015-09-15 22:43:32 -0500
commitd9a15195a48be307abea623d883144dbd7f3a51d (patch)
tree041a412a9ead3310a42bb5ec566073c4fa38a301 /src/satmkboot.c
parent882c09f53c0966336537450f0d771c8d30518343 (diff)
always output 8 region code blocks, simplify
By always outputting a fixed number of region codes, we make it predictable at which address the initial program will be loaded. This may make it easier to develop alternate initial program implementations.
Diffstat (limited to 'src/satmkboot.c')
-rw-r--r--src/satmkboot.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/satmkboot.c b/src/satmkboot.c
index a3e4d7e..b86a769 100644
--- a/src/satmkboot.c
+++ b/src/satmkboot.c
@@ -28,14 +28,12 @@ static char *ipfile, *outfile;
static void serialize_region_code(char *out, const struct symbolname *region)
{
- size_t namelen = strlen(region->name);
- char *tmp = out;
- char *end = out+32;
-
- memcpy(tmp, "\xa0\x0e\x00\x09" "For ", 8); tmp += 8;
- memcpy(tmp, region->name, namelen); tmp += namelen;
- *tmp++ = '.';
- memset(tmp, ' ', end - tmp);
+ static const char defcode[32] = "\xa0\x0e\x00\x09" "For ";
+ size_t namelen = region ? strlen(region->name) : 0;
+
+ memcpy(out, defcode, sizeof defcode);
+ if (namelen) memcpy(out+8, region->name, namelen);
+ out[8+namelen] = '.';
}
#define WRITE(f,p,s) fwrite(p,s,1,f)
@@ -304,13 +302,10 @@ int main(int argc, char **argv)
if (sysid.regions[0] == ' ') strcpy(sysid.regions, "JTUBKAEL");
if (sysid.peripherals[0] == ' ') sysid.peripherals[0] = 'J';
- for (int i = 0; i < 10 && sysid.regions[i] != ' '; i++) {
- const struct symbolname *region = find_symbol(regiondefs, sysid.regions[i]);
- if (region) {
- serialize_region_code(ipout, region);
- ipout += 32;
- sysid.bootsize += 32;
- }
+ for (int i = 0; i < 8; i++) {
+ serialize_region_code(ipout, find_symbol(regiondefs, sysid.regions[i]));
+ ipout += 32;
+ sysid.bootsize += 32;
}
ipsize = ipfile