FreeCalypso > hg > freecalypso-reveng
view dspanal/coffout.c @ 367:6dd0fc53bcba
pirelli/battery: battery icon experiments
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 21 Oct 2020 22:40:28 +0000 |
parents | 493f73198267 |
children |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include "coffout.h" static FILE *outF; static void write16(val) unsigned val; { putc(val, outF); putc(val >> 8, outF); } static void write32(val) unsigned val; { putc(val, outF); putc(val >> 8, outF); putc(val >> 16, outF); putc(val >> 24, outF); } emit_coff_output(filename, sections, nsect) char *filename; struct coff_section *sections; unsigned nsect; { uint32_t dataptr; unsigned n; char section_name[32]; outF = fopen(filename, "w"); if (!outF) { perror(filename); exit(1); } write16(0x00C1); write16(nsect); write32(0); write32(0); write32(0); write16(0); write16(0x0117); write16(0x0098); dataptr = 0x16 + 0x28 * nsect; for (n = 0; n < nsect; n++) { sprintf(section_name, "chunk%03u", n); fwrite(section_name, 1, 8, outF); write32(sections[n].addr); write32(sections[n].addr); write32(sections[n].size); write32(dataptr); dataptr += sections[n].size << 1; write32(0); write32(0); write32(0); write16(sections[n].flags); putc(0, outF); putc(sections[n].mempage, outF); } for (n = 0; n < nsect; n++) fwrite(sections[n].data, 2, sections[n].size, outF); fclose(outF); return(0); }