void Output(void) { SLONG i; FILE *f; if ((f = fopen(tzOutname, "wb"))) { writehome(f); for (i = 1; i <= MaxBankUsed; i += 1) writebank(f, i); fclose(f); } for (i = BANK_WRAM0; i < MAXBANKS; i++) { struct sSection *pSect; MapfileInitBank(i); pSect = pSections; while (pSect) { if (pSect->nBank == i) { MapfileWriteSection(pSect); } pSect = pSect->pNext; } MapfileCloseBank(area_Avail(i)); } }
void Output(void) { SLONG i; FILE *f; FILE *f_overlay = NULL; if ((f = fopen(tzOutname, "wb"))) { if (tzOverlayname) { f_overlay = fopen(tzOverlayname, "rb"); if (!f_overlay) { fprintf(stderr, "Failed to open overlay file %s\n", tzOverlayname); exit(1); } fseek(f_overlay, 0, SEEK_END); if (ftell(f_overlay) % 0x4000 != 0) { fprintf(stderr, "Overlay file must be aligned to 0x4000 bytes\n"); exit(1); } MaxOverlayBank = (ftell(f_overlay) / 0x4000) - 1; if (MaxOverlayBank < 1) { fprintf(stderr, "Overlay file be at least 0x8000 bytes\n"); exit(1); } if (MaxOverlayBank > MaxBankUsed) { MaxBankUsed = MaxOverlayBank; } } writehome(f, f_overlay); for (i = 1; i <= MaxBankUsed; i += 1) writebank(f, f_overlay, i); fclose(f); if (tzOverlayname) { fclose(f_overlay); } } for (i = BANK_WRAM0; i < MAXBANKS; i++) { struct sSection *pSect; MapfileInitBank(i); pSect = pSections; while (pSect) { if (pSect->nBank == i) { MapfileWriteSection(pSect); } pSect = pSect->pNext; } MapfileCloseBank(area_Avail(i)); } }