Skip to content

Commit 7f82b99

Browse files
committed
systemKill now checks for DOSBaase before printing, don't depend on printf
this saves 2k of executable size if rest of game doesn't use printf
1 parent acd78de commit 7f82b99

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/ace/managers/system.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,12 @@ static void systemFlushIo() {
448448
}
449449

450450
void systemKill(const char *szMsg) {
451-
printf("ERR: SYSKILL: '%s'", szMsg);
452-
logWrite("ERR: SYSKILL: '%s'", szMsg);
451+
logWrite("ERR: ACE SYSKILL: '%s'", szMsg);
452+
if(DOSBase) {
453+
BPTR lOut = Output();
454+
Write(lOut, "ERR: ACE SYSKILL: ", sizeof("ERR: ACE SYSKILL: "));
455+
Write(lOut, (char*)szMsg, strlen(szMsg));
456+
}
453457

454458
if(GfxBase) {
455459
CloseLibrary((struct Library *) GfxBase);
@@ -466,26 +470,28 @@ void systemCreate(void) {
466470
SysBase = *((struct ExecBase**)4UL);
467471
#endif
468472

469-
GfxBase = (struct GfxBase *)OpenLibrary((CONST_STRPTR)"graphics.library", 0L);
470-
if (!GfxBase) {
471-
systemKill("Can't open Gfx Library!\n");
472-
return;
473-
}
474-
475473
DOSBase = (struct DosLibrary*)OpenLibrary((CONST_STRPTR)"dos.library", 0);
476474
if (!DOSBase) {
477475
systemKill("Can't open DOS Library!\n");
478476
return;
479477
}
480478

479+
GfxBase = (struct GfxBase *)OpenLibrary((CONST_STRPTR)"graphics.library", 0L);
480+
if (!GfxBase) {
481+
systemKill("Can't open Gfx Library!\n");
482+
return;
483+
}
484+
481485
// Determine original stack size
482486
s_pProcess = (struct Process *)FindTask(NULL);
483487
char *pStackLower = (char *)s_pProcess->pr_Task.tc_SPLower;
488+
#if defined(ACE_DEBUG)
484489
ULONG ulStackSize = (char *)s_pProcess->pr_Task.tc_SPUpper - pStackLower;
485490
if(s_pProcess->pr_CLI) {
486491
ulStackSize = *(ULONG *)s_pProcess->pr_ReturnAddr;
487492
}
488493
logWrite("Stack size: %lu\n", ulStackSize);
494+
#endif
489495
*pStackLower = SYSTEM_STACK_CANARY;
490496

491497
// Reserve all audio channels - apparantly this allows for int flag polling

0 commit comments

Comments
 (0)