mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-15 20:35:13 +00:00
Rework handling of dmadata (#1036)
* Generate dmadata * Remove tab indentations in mkdmadata.c and mkldscript.c * Fix * Review suggestions * Hopefully fix * Fix index Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
783ef3a117
commit
04a9d51e90
13 changed files with 2034 additions and 3438 deletions
55
tools/mkdmadata.c
Normal file
55
tools/mkdmadata.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#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++)
|
||||
fprintf(fout, "DEFINE_DMA_ENTRY(%s)\n", g_segments[i].name);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
free(spec);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue