mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 19:22:05 +00:00
Now that we replace missing libc functions, switch back to err().
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/main.h"
|
||||
#include "link/symbol.h"
|
||||
@@ -77,9 +78,7 @@ area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
|
||||
|
||||
return (org);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,9 +309,7 @@ AssignVRAMSections(void)
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXVBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to place VRAM section anywhere\n");
|
||||
exit(1);
|
||||
errx(1, "Unable to place VRAM section anywhere");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,9 +328,7 @@ AssignSRAMSections(void)
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXSBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to place SRAM section anywhere\n");
|
||||
exit(1);
|
||||
errx(1, "Unable to place SRAM section anywhere");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,9 +347,7 @@ AssignWRAMSections(void)
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXWBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to place WRAMX section anywhere\n");
|
||||
exit(1);
|
||||
errx(1, "Unable to place WRAMX section anywhere");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,9 +366,7 @@ AssignCodeSections(void)
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to place ROMX section anywhere\n");
|
||||
exit(1);
|
||||
errx(1, "Unable to place ROMX section anywhere");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,8 +388,7 @@ AssignSections(void)
|
||||
BankFree[i] = malloc(sizeof *BankFree[i]);
|
||||
|
||||
if (!BankFree[i]) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
@@ -472,10 +462,9 @@ AssignSections(void)
|
||||
if (area_AllocAbs
|
||||
(&BankFree[BANK_WRAM0], pSection->nOrg,
|
||||
pSection->nByteSize) != pSection->nOrg) {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed WRAM0 section "
|
||||
"at $%lX\n", pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed WRAM0 "
|
||||
"section at $%lX", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
pSection->nBank = BANK_WRAM0;
|
||||
@@ -484,10 +473,8 @@ AssignSections(void)
|
||||
if (area_AllocAbs
|
||||
(&BankFree[BANK_HRAM], pSection->nOrg,
|
||||
pSection->nByteSize) != pSection->nOrg) {
|
||||
fprintf(stderr, "Unable to load fixed "
|
||||
"HRAM section at $%lX\n",
|
||||
pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed HRAM "
|
||||
"section at $%lX", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
pSection->nBank = BANK_HRAM;
|
||||
@@ -530,17 +517,15 @@ AssignSections(void)
|
||||
pSection->nOrg,
|
||||
pSection->nByteSize)
|
||||
!= pSection->nOrg) {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed SRAM section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed SRAM section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
DOMAXVBANK(pSection->
|
||||
nBank);
|
||||
pSection->oAssigned = 1;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed SRAM section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed SRAM section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,17 +568,15 @@ AssignSections(void)
|
||||
pSection->nOrg,
|
||||
pSection->nByteSize)
|
||||
!= pSection->nOrg) {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed WRAMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed WRAMX section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
DOMAXWBANK(pSection->
|
||||
nBank);
|
||||
pSection->oAssigned = 1;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed WRAMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed WRAMX section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -636,17 +619,15 @@ AssignSections(void)
|
||||
pSection->nOrg,
|
||||
pSection->nByteSize)
|
||||
!= pSection->nOrg) {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed VRAM section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed VRAM section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
DOMAXVBANK(pSection->
|
||||
nBank);
|
||||
pSection->oAssigned = 1;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed VRAM section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed VRAM section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -655,10 +636,8 @@ AssignSections(void)
|
||||
if (area_AllocAbs
|
||||
(&BankFree[BANK_ROM0], pSection->nOrg,
|
||||
pSection->nByteSize) != pSection->nOrg) {
|
||||
fprintf(stderr, "Unable to load fixed "
|
||||
"ROM0 section at $%lX\n",
|
||||
pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed ROM0 "
|
||||
"section at $%lX", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
pSection->nBank = BANK_ROM0;
|
||||
@@ -703,15 +682,15 @@ AssignSections(void)
|
||||
pSection->
|
||||
nByteSize) !=
|
||||
pSection->nOrg) {
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed ROMX section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
DOMAXBANK(pSection->
|
||||
nBank);
|
||||
pSection->oAssigned = 1;
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed ROMX section at $%lX in bank $%02lX", pSection->nOrg, pSection->nBank);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,14 +716,13 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[pSection->nBank],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "Unable to load fixed ROMX section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1,
|
||||
"Unable to load fixed ROMX section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed ROMX section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed ROMX section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
} else if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_SRAM
|
||||
@@ -755,14 +733,12 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[pSection->nBank],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "Unable to load fixed SRAM section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed SRAM section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXSBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed VRAM section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed VRAM section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
} else if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_VRAM
|
||||
@@ -773,14 +749,12 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[pSection->nBank],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "Unable to load fixed VRAM section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed VRAM section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXVBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed VRAM section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed VRAM section into bank $%02lX", pSection->nBank);
|
||||
}
|
||||
} else if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_WRAMX
|
||||
@@ -791,14 +765,12 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[pSection->nBank],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "Unable to load fixed WRAMX section into bank $%02lX\n", pSection->nBank - BANK_WRAMX);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed WRAMX section into bank $%02lX", pSection->nBank - BANK_WRAMX);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXWBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed WRAMX section into bank $%02lX\n", pSection->nBank - BANK_WRAMX);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed WRAMX section into bank $%02lX", pSection->nBank - BANK_WRAMX);
|
||||
}
|
||||
}
|
||||
pSection = pSection->pNext;
|
||||
@@ -820,8 +792,7 @@ AssignSections(void)
|
||||
area_AllocAbsROMXAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
-1) {
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX into any bank\n", pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed ROMX section at $%lX into any bank", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXBANK(pSection->nBank);
|
||||
@@ -834,8 +805,7 @@ AssignSections(void)
|
||||
area_AllocAbsVRAMAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
-1) {
|
||||
fprintf(stderr, "Unable to load fixed VRAM section at $%lX into any bank\n", pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed VRAM section at $%lX into any bank", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXVBANK(pSection->nBank);
|
||||
@@ -848,8 +818,7 @@ AssignSections(void)
|
||||
area_AllocAbsSRAMAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
-1) {
|
||||
fprintf(stderr, "Unable to load fixed SRAM section at $%lX into any bank\n", pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed SRAM section at $%lX into any bank", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXSBANK(pSection->nBank);
|
||||
@@ -862,8 +831,7 @@ AssignSections(void)
|
||||
area_AllocAbsWRAMAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
-1) {
|
||||
fprintf(stderr, "Unable to load fixed WRAMX section at $%lX into any bank\n", pSection->nOrg);
|
||||
exit(1);
|
||||
errx(1, "Unable to load fixed WRAMX section at $%lX into any bank", pSection->nOrg);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXWBANK(pSection->nBank);
|
||||
@@ -885,8 +853,7 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[BANK_WRAM0],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "WRAM0 section too large\n");
|
||||
exit(1);
|
||||
errx(1, "WRAM0 section too large");
|
||||
}
|
||||
pSection->nBank = BANK_WRAM0;
|
||||
pSection->oAssigned = 1;
|
||||
@@ -895,8 +862,7 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[BANK_HRAM],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "HRAM section too large\n");
|
||||
exit(1);
|
||||
errx(1, "HRAM section too large");
|
||||
}
|
||||
pSection->nBank = BANK_HRAM;
|
||||
pSection->oAssigned = 1;
|
||||
@@ -911,8 +877,7 @@ AssignSections(void)
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[BANK_ROM0],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "ROM0 section too large\n");
|
||||
exit(1);
|
||||
errx(1, "ROM0 section too large");
|
||||
}
|
||||
pSection->nBank = BANK_ROM0;
|
||||
pSection->oAssigned = 1;
|
||||
@@ -920,8 +885,7 @@ AssignSections(void)
|
||||
case SECT_ROMX:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "(INTERNAL) Unknown section type!\n");
|
||||
exit(1);
|
||||
errx(1, "(INTERNAL) Unknown section type!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/types.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/main.h"
|
||||
@@ -91,9 +92,8 @@ AddNeededModules(void)
|
||||
}
|
||||
if (options & OPT_SMART_C_LINK) {
|
||||
if (!addmodulecontaining(smartlinkstartsymbol)) {
|
||||
fprintf(stderr, "Can't find start symbol '%s'\n",
|
||||
errx(1, "Can't find start symbol '%s'",
|
||||
smartlinkstartsymbol);
|
||||
exit(1);
|
||||
} else
|
||||
printf("Smart linking with symbol '%s'\n",
|
||||
smartlinkstartsymbol);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "asmotor.h"
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/object.h"
|
||||
#include "link/output.h"
|
||||
#include "link/assign.h"
|
||||
@@ -73,8 +74,7 @@ main(int argc, char *argv[])
|
||||
case 'p':
|
||||
fillchar = strtoul(optarg, &ep, 0);
|
||||
if (optarg[0] == '\0' || *ep != '\0') {
|
||||
fprintf(stderr, "Invalid argument for option 'p'\n");
|
||||
exit(1);
|
||||
errx(1, "Invalid argument for option 'p'");
|
||||
}
|
||||
if (fillchar < 0 || fillchar > 0xFF) {
|
||||
fprintf(stderr, "Argument for option 'p' must be between 0 and 0xFF");
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "asmotor.h"
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/main.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/assign.h"
|
||||
@@ -20,9 +21,7 @@ SetMapfileName(char *name)
|
||||
mf = fopen(name, "w");
|
||||
|
||||
if (mf == NULL) {
|
||||
fprintf(stderr, "Cannot open mapfile '%s': ", name);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
err(1, "Cannot open mapfile '%s'", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +31,7 @@ SetSymfileName(char *name)
|
||||
sf = fopen(name, "w");
|
||||
|
||||
if (sf == NULL) {
|
||||
fprintf(stderr, "Cannot open symfile '%s'\n", name);
|
||||
exit(1);
|
||||
err(1, "Cannot open symfile '%s'", name);
|
||||
}
|
||||
|
||||
fprintf(sf, ";File generated by xLink v" LINK_VERSION "\n\n");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/main.h"
|
||||
|
||||
@@ -80,8 +81,7 @@ AllocSection(void)
|
||||
|
||||
*ppSections = malloc(sizeof **ppSections);
|
||||
if (!*ppSections) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
(*ppSections)->tSymbols = tSymbols;
|
||||
(*ppSections)->pNext = NULL;
|
||||
@@ -102,15 +102,13 @@ obj_ReadSymbol(FILE * f)
|
||||
|
||||
pSym = malloc(sizeof *pSym);
|
||||
if (!pSym) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
readasciiz(s, f);
|
||||
pSym->pzName = malloc(strlen(s) + 1);
|
||||
if (!pSym->pzName) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
strcpy(pSym->pzName, s);
|
||||
@@ -150,7 +148,7 @@ obj_ReadRGB0Section(FILE * f)
|
||||
if (pSection->nByteSize) {
|
||||
pSection->pData = malloc(pSection->nByteSize);
|
||||
if (!pSection->pData) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
SLONG nNumberOfPatches;
|
||||
@@ -169,7 +167,7 @@ obj_ReadRGB0Section(FILE * f)
|
||||
while (nNumberOfPatches--) {
|
||||
pPatch = malloc(sizeof *pPatch);
|
||||
if (!pPatch) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
*ppPatch = pPatch;
|
||||
@@ -177,7 +175,7 @@ obj_ReadRGB0Section(FILE * f)
|
||||
|
||||
pPatch->pzFilename = malloc(strlen(s) + 1);
|
||||
if (!pPatch->pzFilename) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
strcpy(pPatch->pzFilename, s);
|
||||
@@ -193,8 +191,7 @@ obj_ReadRGB0Section(FILE * f)
|
||||
if ((pPatch->nRPNSize = readlong(f)) > 0) {
|
||||
pPatch->pRPN = malloc(pPatch->nRPNSize);
|
||||
if (!pPatch->pRPN) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
fread(pPatch->pRPN, sizeof(UBYTE),
|
||||
@@ -228,8 +225,7 @@ obj_ReadRGB0(FILE * pObjfile)
|
||||
if (nNumberOfSymbols) {
|
||||
tSymbols = malloc(nNumberOfSymbols * sizeof(struct sSymbol *));
|
||||
if (!tSymbols) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < nNumberOfSymbols; i += 1)
|
||||
@@ -305,8 +301,7 @@ obj_ReadRGB1Section(FILE * f)
|
||||
if (pSection->nByteSize) {
|
||||
pSection->pData = malloc(pSection->nByteSize);
|
||||
if (!pSection->pData) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
SLONG nNumberOfPatches;
|
||||
@@ -325,14 +320,14 @@ obj_ReadRGB1Section(FILE * f)
|
||||
while (nNumberOfPatches--) {
|
||||
pPatch = malloc(sizeof *pPatch);
|
||||
if (!pPatch) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
*ppPatch = pPatch;
|
||||
readasciiz(s, f);
|
||||
pPatch->pzFilename = malloc(strlen(s) + 1);
|
||||
if (!pPatch->pzFilename) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
strcpy(pPatch->pzFilename, s);
|
||||
@@ -342,7 +337,7 @@ obj_ReadRGB1Section(FILE * f)
|
||||
if ((pPatch->nRPNSize = readlong(f)) > 0) {
|
||||
pPatch->pRPN = malloc(pPatch->nRPNSize);
|
||||
if (!pPatch->pRPN) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
fread(pPatch->pRPN, sizeof(UBYTE),
|
||||
@@ -376,7 +371,7 @@ obj_ReadRGB1(FILE * pObjfile)
|
||||
if (nNumberOfSymbols) {
|
||||
tSymbols = malloc(nNumberOfSymbols * sizeof *tSymbols);
|
||||
if (!tSymbols) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < nNumberOfSymbols; i += 1)
|
||||
@@ -440,14 +435,10 @@ obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
|
||||
obj_ReadRGB1(pObjfile);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "'%s' is an unsupported version",
|
||||
tzObjectfile);
|
||||
exit(1);
|
||||
break;
|
||||
errx(1, "'%s' is an unsupported version", tzObjectfile);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "'%s' is not a valid object\n", tzObjectfile);
|
||||
exit(1);
|
||||
errx(1, "'%s' is not a valid object", tzObjectfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,10 +454,7 @@ obj_Readfile(char *tzObjectfile)
|
||||
|
||||
pObjfile = fopen(tzObjectfile, "rb");
|
||||
if (pObjfile == NULL) {
|
||||
fprintf(stderr, "Unable to open object '%s': ",
|
||||
tzObjectfile);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
err(1, "Unable to open object '%s'", tzObjectfile);
|
||||
}
|
||||
obj_ReadOpenFile(pObjfile, tzObjectfile);
|
||||
fclose(pObjfile);
|
||||
@@ -516,13 +504,7 @@ lib_Readfile(char *tzLibfile)
|
||||
|
||||
pObjfile = fopen(tzLibfile, "rb");
|
||||
if (pObjfile == NULL) {
|
||||
fprintf(stderr, "Unable to open object '%s': ", tzLibfile);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
}
|
||||
if (!pObjfile) {
|
||||
fprintf(stderr, "Unable to open '%s'\n", tzLibfile);
|
||||
exit(1);
|
||||
err(1, "Unable to open object '%s'", tzLibfile);
|
||||
}
|
||||
char tzHeader[5];
|
||||
|
||||
@@ -531,9 +513,7 @@ lib_Readfile(char *tzLibfile)
|
||||
if (strcmp(tzHeader, "XLB0") == 0)
|
||||
lib_ReadXLB0(pObjfile);
|
||||
else {
|
||||
fprintf(stderr, "'%s' is an invalid library\n",
|
||||
tzLibfile);
|
||||
exit(1);
|
||||
errx(1, "'%s' is an invalid library", tzLibfile);
|
||||
}
|
||||
fclose(pObjfile);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/mylink.h"
|
||||
#include "link/symbol.h"
|
||||
#include "link/main.h"
|
||||
@@ -46,8 +47,7 @@ getsymvalue(SLONG symid)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "*INTERNAL* UNKNOWN SYMBOL TYPE\n");
|
||||
exit(1);
|
||||
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
|
||||
}
|
||||
|
||||
SLONG
|
||||
@@ -64,8 +64,7 @@ getsymbank(SLONG symid)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "*INTERNAL* UNKNOWN SYMBOL TYPE\n");
|
||||
exit(1);
|
||||
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
|
||||
}
|
||||
|
||||
SLONG
|
||||
@@ -159,20 +158,18 @@ calcrpn(struct sPatch * pPatch)
|
||||
t = rpnpop();
|
||||
rpnpush(t & 0xFF);
|
||||
if (t < 0 || (t > 0xFF && t < 0xFF00) || t > 0xFFFF) {
|
||||
fprintf(stderr,
|
||||
"%s(%ld) : Value must be in the HRAM area\n",
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be in the HRAM area",
|
||||
pPatch->pzFilename, pPatch->nLineNo);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case RPN_PCEZP:
|
||||
t = rpnpop();
|
||||
rpnpush(t & 0xFF);
|
||||
if (t < 0x2000 || t > 0x20FF) {
|
||||
fprintf(stderr,
|
||||
"%s(%ld) : Value must be in the ZP area\n",
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be in the ZP area",
|
||||
pPatch->pzFilename, pPatch->nLineNo);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case RPN_CONST:
|
||||
@@ -217,11 +214,10 @@ calcrpn(struct sPatch * pPatch)
|
||||
high |= (*rpn++) << 24;
|
||||
t = rpnpop();
|
||||
if (t < low || t > high) {
|
||||
fprintf(stderr,
|
||||
"%s(%ld) : Value must be in the range [%ld;%ld]\n",
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be in the range [%ld;%ld]",
|
||||
pPatch->pzFilename,
|
||||
pPatch->nLineNo, low, high);
|
||||
exit(1);
|
||||
}
|
||||
rpnpush(t);
|
||||
size -= 8;
|
||||
@@ -255,11 +251,10 @@ Patch(void)
|
||||
pSect->pData[pPatch->nOffset] =
|
||||
(UBYTE) t;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s(%ld) : Value must be 8-bit\n",
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be 8-bit",
|
||||
pPatch->pzFilename,
|
||||
pPatch->nLineNo);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case PATCH_WORD_L:
|
||||
@@ -280,11 +275,10 @@ Patch(void)
|
||||
1] = t & 0xFF;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s(%ld) : Value must be 16-bit\n",
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be 16-bit",
|
||||
pPatch->pzFilename,
|
||||
pPatch->nLineNo);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case PATCH_LONG_L:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extern/err.h"
|
||||
#include "link/main.h"
|
||||
#include "link/patch.h"
|
||||
#include "link/types.h"
|
||||
@@ -53,8 +54,7 @@ sym_GetValue(char *tzName)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Unknown symbol '%s'\n", tzName);
|
||||
exit(1);
|
||||
errx(1, "Unknown symbol '%s'", tzName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,7 @@ sym_GetBank(char *tzName)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Unknown symbol '%s'\n", tzName);
|
||||
exit(1);
|
||||
errx(1, "Unknown symbol '%s'", tzName);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -93,10 +92,7 @@ sym_CreateSymbol(char *tzName, SLONG nValue, SBYTE nBank)
|
||||
if (nBank == -1)
|
||||
return;
|
||||
|
||||
fprintf(stderr,
|
||||
"Symbol '%s' defined more than once\n",
|
||||
tzName);
|
||||
exit(1);
|
||||
errx(1, "Symbol '%s' defined more than once", tzName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user