2021-11-30 23:29:09 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "spec.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
struct Segment* g_segments;
|
|
|
|
int g_segmentsCount;
|
|
|
|
|
|
|
|
static void write_dmadata_table(FILE *fout)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < g_segmentsCount; i++)
|
2022-06-06 19:51:03 +00:00
|
|
|
fprintf(fout, "DEFINE_DMA_ENTRY(%s, \"%s\")\n", g_segments[i].name, g_segments[i].name);
|
2021-11-30 23:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void usage(const char *execname)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "zelda64 dmadata generation tool v0.01\n"
|
|
|
|
"usage: %s SPEC_FILE DMADATA_TABLE\n"
|
|
|
|
"SPEC_FILE file describing the organization of object files into segments\n"
|
|
|
|
"DMADATA_TABLE filename of output dmadata table header\n",
|
|
|
|
execname);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
FILE *dmaout;
|
|
|
|
void *spec;
|
|
|
|
size_t size;
|
2022-01-23 23:09:02 +00:00
|
|
|
|
2021-11-30 23:29:09 +00:00
|
|
|
if (argc != 3)
|
|
|
|
{
|
|
|
|
usage(argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
spec = util_read_whole_file(argv[1], &size);
|
|
|
|
parse_rom_spec(spec, &g_segments, &g_segmentsCount);
|
|
|
|
|
|
|
|
dmaout = fopen(argv[2], "w");
|
|
|
|
if (dmaout == NULL)
|
|
|
|
util_fatal_error("failed to open file '%s' for writing", argv[2]);
|
|
|
|
write_dmadata_table(dmaout);
|
|
|
|
fclose(dmaout);
|
2022-02-06 19:40:26 +00:00
|
|
|
free_rom_spec(g_segments, g_segmentsCount);
|
2021-11-30 23:29:09 +00:00
|
|
|
free(spec);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|