2014-02-10 11:54:46 -07:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 11:54:46 -07:00
|
|
|
// Refer to the license.txt file included.
|
2009-05-19 15:57:41 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-05-14 04:54:48 -06:00
|
|
|
|
2015-03-01 06:52:09 -07:00
|
|
|
#include <iostream>
|
|
|
|
#include <stdarg.h>
|
2009-05-14 04:54:48 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define CON_BLACK 0
|
|
|
|
#define CON_RED 1
|
|
|
|
#define CON_GREEN 2
|
|
|
|
#define CON_YELLOW 3
|
|
|
|
#define CON_BLUE 4
|
|
|
|
#define CON_MAGENTA 5
|
|
|
|
#define CON_CYAN 6
|
|
|
|
#define CON_WHITE 7
|
|
|
|
#define CON_BRIGHT 8
|
|
|
|
#define CON_BRIGHT_BLACK CON_BLACK | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_RED CON_RED | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_GREEN CON_GREEN | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_YELLOW CON_YELLOW | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_BLUE CON_BLUE | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_MAGENTA CON_MAGENTA | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_CYAN CON_CYAN | CON_BRIGHT
|
|
|
|
#define CON_BRIGHT_WHITE CON_WHITE | CON_BRIGHT
|
|
|
|
|
|
|
|
|
2009-07-18 10:34:11 -06:00
|
|
|
inline void CON_Printf(const int x, const int y, const char* fmt, ...)
|
2009-05-14 04:54:48 -06:00
|
|
|
{
|
|
|
|
char tmpbuf[255];
|
|
|
|
|
|
|
|
va_list marker;
|
|
|
|
va_start(marker,fmt);
|
|
|
|
vsprintf(tmpbuf, fmt, marker);
|
|
|
|
va_end(marker);
|
|
|
|
|
|
|
|
printf("\x1b[%d;%dH%s", y, x, tmpbuf);
|
|
|
|
}
|
|
|
|
|
2009-07-18 10:34:11 -06:00
|
|
|
inline void CON_SetColor(u8 foreground, u8 background = CON_BLACK)
|
2009-05-14 04:54:48 -06:00
|
|
|
{
|
2009-05-14 04:57:35 -06:00
|
|
|
u8 bright = foreground & CON_BRIGHT ? 1 : 0;
|
2009-05-14 04:54:48 -06:00
|
|
|
|
|
|
|
if (bright)
|
|
|
|
foreground &= ~CON_BRIGHT;
|
|
|
|
|
|
|
|
printf("\x1b[%d;%d;%dm", 30+foreground, bright, 40+background);
|
|
|
|
}
|
|
|
|
|
2009-07-18 10:34:11 -06:00
|
|
|
inline void CON_Clear()
|
2009-06-12 23:53:07 -06:00
|
|
|
{
|
|
|
|
// Escape code to clear the whole screen.
|
|
|
|
printf("\x1b[2J");
|
|
|
|
}
|
|
|
|
|
2009-07-18 10:34:11 -06:00
|
|
|
// libogc's clear escape codes are crappy
|
|
|
|
inline void CON_BlankRow(const int y)
|
|
|
|
{
|
|
|
|
int columns = 0, rows = 0;
|
|
|
|
CON_GetMetrics(&columns, &rows);
|
2010-02-03 13:29:49 -07:00
|
|
|
char blank[columns];
|
2009-08-15 18:37:01 -06:00
|
|
|
std::fill(blank, blank + columns, ' ');
|
2009-08-15 18:56:49 -06:00
|
|
|
blank[columns-1] = '\0';
|
2009-07-18 10:34:11 -06:00
|
|
|
CON_Printf(0, y, "%s", blank);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CON_PrintRow(x, y, ...) \
|
|
|
|
{ \
|
|
|
|
CON_BlankRow(y); \
|
|
|
|
CON_Printf(x, y, __VA_ARGS__); \
|
|
|
|
}
|