/*
 * cprintf — printf for the conio output set.  Formats into a static
 * buffer with vsprintf (from SDCC's stdlib), then emits via cputs which
 * applies the current text attribute per character.
 *
 * No '\n' to CR LF translation — Turbo-C convention: callers write
 * "\r\n" explicitly in the format string for line breaks.
 *
 * Not reentrant (single static buffer) but Z80 single-threaded is fine.
 */

#include <conio.h>
#include <stdarg.h>
#include <stdio.h>

#define CPRINTF_BUF_SIZE 256

static char cp_buf[CPRINTF_BUF_SIZE];

int cprintf(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    int n = vsprintf(cp_buf, fmt, ap);
    va_end(ap);
    cputs(cp_buf);
    return n;
}
