示例#1
0
void iprintfColored(int palette, const char *format, ...) {
    va_list args;
    va_start(args, format);

    PrintConsole* console = getPrintConsole();
    int x = console->cursorX;
    int y = console->cursorY;

    char s[100];
    vsiprintf(s, format, args);

    u16* dest = BG_MAP_RAM_SUB(22)+y*32+x;
    for (uint i=0; i<strlen(s); i++) {
        if (s[i] == '\n') {
            x = 0;
            y++;
        }
        else {
            *(dest++) = s[i] | TILE_PALETTE(palette);
            x++;
            if (x == 32) {
                x = 0;
                y++;
            }
        }
    }
    console->cursorX = x;
    console->cursorY = y;
    //iprintf(s);
}
示例#2
0
文件: main.c 项目: smealum/ctrrpc
static void
print(console_t  *console,
      const char *fmt, ...)
{
    static char buffer[256];
    va_list ap;
    va_start(ap, fmt);
    vsiprintf(buffer, fmt, ap);
    va_end(ap);

    size_t num_lines = 0;
    const char *p = buffer;
    while((p = strchr(p, '\n')) != NULL)
    {
        ++num_lines;
        ++p;
    }

    if(console->lines + num_lines > MAX_LINES)
    {
        p = console->console;
        while(console->lines + num_lines > MAX_LINES)
        {
            p = strchr(p, '\n');
            ++p;
            --console->lines;
        }

        memmove(console->console, p, strlen(p)+1);
    }

    strcat(console->console, buffer);
    console->lines = console->lines + num_lines;
}
示例#3
0
 int sprintf(char* pDst, const char* fmt, ...)
 {
     int len = 0;
     va_list args;
     va_start(args, fmt);
     len = vsiprintf(pDst, fmt, args);
     va_end(args);
     return len;
 }
示例#4
0
int u0_dbg_printf(const char *format, ...)
{
    int len = 0;
    char buff[128] = { 0 };

    va_list args;
    va_start(args, format);
    #if USE_REDUCED_PRINTF == 0
    len = vsprintf(buff, format, args);
    #else
    len = vsiprintf(buff, format, args);
    #endif
    va_end(args);

    char *c = &buff[0];
    while(*c) {
        uart0_putchar(*c);
        c++;
    }

    return len;
}