summaryrefslogtreecommitdiff
path: root/tools/make_shim.c
diff options
context:
space:
mode:
authorehw <Knuckles500@gmail.com>2018-06-05 11:03:34 -0400
committerGitHub <noreply@github.com>2018-06-05 11:03:34 -0400
commita62cf40b29a814188c545e47d7534b6ea3aebcc1 (patch)
tree3db618e96e50af65d6831e4ce2540fb0435a954e /tools/make_shim.c
parent771d125c7564a0ff1e511733114d53ad0521c3f8 (diff)
parentc4c2b3cc6ede5259a1246c195a8c1d58e6d3a35d (diff)
Merge pull request #4 from pret/master
Merge master
Diffstat (limited to 'tools/make_shim.c')
-rw-r--r--tools/make_shim.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/make_shim.c b/tools/make_shim.c
index b5a7517..a025905 100644
--- a/tools/make_shim.c
+++ b/tools/make_shim.c
@@ -95,6 +95,8 @@ int main(int argc, char * argv[]) {
}
for (int arg_idx = optind; arg_idx < argc; arg_idx++) {
+ int last = -1;
+ int curr;
eline[0] = 0;
lineno = 0;
fname = argv[arg_idx];
@@ -102,6 +104,7 @@ int main(int argc, char * argv[]) {
if (file == NULL)
RIP("Unable to open file");
while ((lineptr = fgets(line, sizeof(line), file)) != NULL) {
+ // Assume it's already sorted
lineno++;
unsigned short bank = 0;
unsigned short pointer = 0;
@@ -135,6 +138,7 @@ int main(int argc, char * argv[]) {
bank = strtoul(lineptr, &end, 16);
if (bank == 0 && end == lineptr)
RIP("Unable to parse bank number");
+ curr = (bank << 14) | (pointer & 0x3fff);
// Main loop
const char * section = NULL;
@@ -157,10 +161,16 @@ int main(int argc, char * argv[]) {
// Found section, but cannot shim it
continue;
- printf("SECTION \"Shim for %s\", %s[$%04X]", symbol, section, pointer);
- if (bank)
- printf(", BANK[$%04X]", bank);
- printf("\n%s::\n\n", symbol);
+ if (curr != last) {
+ if (last != -1)
+ fputc('\n', stdout);
+ printf("SECTION \"Shim for %s\", %s[$%04X]", symbol, section, pointer);
+ if (bank)
+ printf(", BANK[$%04X]", bank);
+ printf("\n%s::\n", symbol);
+ last = curr;
+ } else
+ printf("%s::\n", symbol);
fflush(stdout);
}
fclose(file);