45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#include <coco.h>
|
|
#include <stdarg.h>
|
|
#include <vcc/printer.h>
|
|
|
|
static int sendArgs(const char *format, ...)
|
|
{
|
|
va_list args;
|
|
va_start(args, format);
|
|
int count = vcc_printer_vprintf(format, args);
|
|
va_end(args);
|
|
return count;
|
|
}
|
|
|
|
/* A custom console hook receives A and must preserve B, X, Y and U. */
|
|
static asm void ignoreConsoleCharacter(void)
|
|
{
|
|
asm { rts }
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
const byte *device = (const byte *)0x006F; /* BASIC DEVNUM */
|
|
ConsoleOutHook savedHook;
|
|
int count, invalid, nullFormat, empty, previousDevicePreserved;
|
|
cls(1);
|
|
setOutputDevice(DEV_CASSETTE);
|
|
savedHook = setConsoleOutHook(ignoreConsoleCharacter);
|
|
count = sendArgs("%04u %-4s %c %%\n", 9U, "IO", 'X');
|
|
invalid = vcc_printer_printf("PREFIX%f");
|
|
nullFormat = vcc_printer_printf(NULL);
|
|
empty = vcc_printer_printf("");
|
|
previousDevicePreserved = *device == (byte)DEV_CASSETTE;
|
|
ConsoleOutHook active = setConsoleOutHook(savedHook);
|
|
setOutputDevice(DEV_SCREEN);
|
|
if (count != 14 || invalid >= 0 || nullFormat >= 0 || empty != 0 || !previousDevicePreserved ||
|
|
active != ignoreConsoleCharacter)
|
|
{
|
|
printf("FAIL LINE %u COUNT %d\n", (unsigned)__LINE__, count);
|
|
return 1;
|
|
}
|
|
printf("PRINTER CHECKS PASSED\n");
|
|
return 0;
|
|
}
|