Expand the color list a bit, muck with the Linux color console code, and change a few ifs to a case statement.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2192 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-11-12 14:52:29 +00:00
parent 137f0da055
commit 4f6fab781b
5 changed files with 200 additions and 184 deletions

View File

@ -36,12 +36,19 @@ enum ConsoleColors
// Strong text *may* result in mis-aligned text in the console, depending on the
// font and the platform, so use these with caution.
Color_StrongBlack,
Color_StrongRed, // intended for errors
Color_StrongGreen, // intended for infrequent state information
Color_StrongBlue, // intended for block headings
Color_StrongMagenta,
Color_StrongOrange, // intended for warnings
Color_StrongGray,
Color_StrongCyan,
Color_StrongYellow,
Color_StrongWhite,
Color_Default,
ConsoleColors_Count
};

View File

@ -76,26 +76,45 @@ const IConsoleWriter ConsoleWriter_Null =
// --------------------------------------------------------------------------------------
#ifdef __LINUX__
static const wxChar* tbl_color_codes[] =
static __forceinline const wxChar* GetLinuxConsoleColor(ConsoleColors color)
{
L"\033[30m" // black
, L"\033[31m" // red
, L"\033[32m" // green
, L"\033[33m" // yellow
, L"\033[34m" // blue
, L"\033[35m" // magenta
, L"\033[36m" // cyan
, L"\033[37m" // white!
, L"\033[30m\033[1m" // strong black
, L"\033[31m\033[1m" // strong red
, L"\033[32m\033[1m" // strong green
, L"\033[33m\033[1m" // strong yellow
, L"\033[34m\033[1m" // strong blue
, L"\033[35m\033[1m" // strong magenta
, L"\033[36m\033[1m" // strong cyan
, L"\033[37m\033[1m" // strong white!
, L"\033[0m" // Back to default.
};
switch(color)
{
case Color_Black: return L"\033[30m";
case Color_StrongBlack: return L"\033[30m\033[1m";
case Color_Red: return L"\033[31m";
case Color_StrongRed: return L"\033[31m\033[1m";
case Color_Green: return L"\033[32m";
case Color_StrongGreen: return L"\033[32m\033[1m";
case Color_Yellow: return L"\033[33m";
case Color_StrongYellow: return L"\033[33m\033[1m";
case Color_Blue: return L"\033[34m";
case Color_StrongBlue: return L"\033[34m\033[1m";
// No orange, so use magenta.
case Color_Orange:
case Color_Magenta: return L"\033[35m";
case Color_StrongOrange:
case Color_StrongMagenta: return L"\033[35m\033[1m";
case Color_Cyan: return L"\033[36m";
case Color_StrongCyan: return L"\033[36m\033[1m";
// Use 'white' instead of grey.
case Color_Gray:
case Color_White: return L"\033[37m";
case Color_StrongGray:
case Color_StrongWhite: return L"\033[37m\033[1m";
// On some other value being passed, clear any formatting.
case Color_Default:
default: return L"\033[0m";
}
}
#endif
// One possible default write action at startup and shutdown is to use the stdout.
@ -115,32 +134,20 @@ static void __concall ConsoleStdio_Newline()
wxPrintf( L"\n" );
}
static void __concall ConsoleStdio_SetColor( ConsoleColors color )
static void __concall ConsoleStdio_ClearColor()
{
#ifdef __LINUX__
wxPrintf(tbl_color_codes[16]);
switch (color)
{
case Color_Black: wxPrintf(tbl_color_codes[0]); break;
case Color_Green: wxPrintf(tbl_color_codes[2]); break;
case Color_Red: wxPrintf(tbl_color_codes[1]); break;
case Color_Blue: wxPrintf(tbl_color_codes[4]); break;
case Color_Magenta: wxPrintf(tbl_color_codes[5]); break;
case Color_Orange: wxPrintf(tbl_color_codes[5]); break; // No orange, so use magenta.
case Color_Gray: wxPrintf(tbl_color_codes[7]); break; // Use white instead of grey.
case Color_Cyan: wxPrintf(tbl_color_codes[6]); break;
case Color_Yellow: wxPrintf(tbl_color_codes[3]); break;
case Color_White: wxPrintf(tbl_color_codes[7]); break;
case Color_StrongBlack: wxPrintf(tbl_color_codes[8]); break;
case Color_StrongRed: wxPrintf(tbl_color_codes[9]); break;
case Color_StrongGreen: wxPrintf(tbl_color_codes[10]); break;
case Color_StrongBlue: wxPrintf(tbl_color_codes[12]); break;
case Color_StrongOrange: wxPrintf(tbl_color_codes[13]); break; // strong magenta.
default: wxPrintf(tbl_color_codes[16]); break;
}
wxPrintf(L"\033[0m");
#endif
}
static void __concall ConsoleStdio_SetColor( ConsoleColors color )
{
#ifdef __LINUX__
ConsoleStdio_ClearColor();
wxPrintf(GetLinuxConsoleColor(color));
#endif
}
static void __concall ConsoleStdio_SetTitle( const wxString& title )
{
@ -149,13 +156,6 @@ static void __concall ConsoleStdio_SetTitle( const wxString& title )
#endif
}
static void __concall ConsoleStdio_ClearColor()
{
#ifdef __LINUX__
wxPrintf(tbl_color_codes[16]);
#endif
}
const IConsoleWriter ConsoleWriter_Stdio =
{
ConsoleStdio_DoWrite, // Writes without newlines go to buffer to avoid error log spam.

View File

@ -117,10 +117,10 @@ void ConsoleTestThread::ExecuteTaskInThread()
}
// ----------------------------------------------------------------------------
// pass an uninitialized file object, the function will ask the user for the
// filename and try to open it, returns true on success (file was opened),
// Pass an uninitialized file object. The function will ask the user for the
// filename and try to open it. It returns true on success (file was opened),
// false if file couldn't be opened/created and -1 if the file selection
// dialog was canceled
// dialog was canceled.
//
static bool OpenLogFile(wxFile& file, wxString& filename, wxWindow *parent)
{
@ -180,6 +180,7 @@ void ConsoleLogFrame::ColorArray::Create( int fontsize )
const wxFont fixedB( fontsize, wxMODERN, wxNORMAL, wxBOLD );
// Standard R, G, B format:
new (&m_table[Color_Default]) wxTextAttr( wxColor( 0, 0, 0 ), wxNullColour, fixed );
new (&m_table[Color_Black]) wxTextAttr( wxColor( 0, 0, 0 ), wxNullColour, fixed );
new (&m_table[Color_Red]) wxTextAttr( wxColor( 128, 0, 0 ), wxNullColour, fixed );
new (&m_table[Color_Green]) wxTextAttr( wxColor( 0, 128, 0 ), wxNullColour, fixed );
@ -196,7 +197,13 @@ void ConsoleLogFrame::ColorArray::Create( int fontsize )
new (&m_table[Color_StrongRed]) wxTextAttr( wxColor( 128, 0, 0 ), wxNullColour, fixedB );
new (&m_table[Color_StrongGreen]) wxTextAttr( wxColor( 0, 128, 0 ), wxNullColour, fixedB );
new (&m_table[Color_StrongBlue]) wxTextAttr( wxColor( 0, 0, 128 ), wxNullColour, fixedB );
new (&m_table[Color_StrongMagenta]) wxTextAttr( wxColor( 160, 0, 160 ), wxNullColour, fixedB );
new (&m_table[Color_StrongOrange]) wxTextAttr( wxColor( 160, 120, 0 ), wxNullColour, fixedB );
new (&m_table[Color_StrongGray]) wxTextAttr( wxColor( 108, 108, 108 ), wxNullColour, fixedB );
new (&m_table[Color_StrongCyan]) wxTextAttr( wxColor( 128, 180, 180 ), wxNullColour, fixedB );
new (&m_table[Color_StrongYellow]) wxTextAttr( wxColor( 180, 180, 128 ), wxNullColour, fixedB );
new (&m_table[Color_StrongWhite]) wxTextAttr( wxColor( 160, 160, 160 ), wxNullColour, fixedB );
}
void ConsoleLogFrame::ColorArray::Cleanup()

View File

@ -1559,20 +1559,24 @@ StartRecomp:
//const u32 pgsz = std::min(0x1000 - inpage_offs, inpage_sz);
const u32 pgsz = inpage_sz;
if(PageType!=-1)
{
if (PageType==0) {
switch (PageType)
{
case -1:
break;
case 0:
mmap_MarkCountedRamPage( inpage_ptr );
manual_page[inpage_ptr >> 12] = 0;
}
else
{
break;
default:
xMOV( ecx, inpage_ptr );
xMOV( edx, pgsz / 4 );
//xMOV( eax, startpc ); // uncomment this to access startpc (as eax) in dyna_block_discard
u32 lpc = inpage_ptr;
u32 stg = pgsz;
while(stg>0)
{
xCMP( ptr32[PSM(lpc)], *(u32*)PSM(lpc) );
@ -1590,21 +1594,21 @@ StartRecomp:
// (ideally, perhaps, manual_counter should be reset to 0 every few minutes?)
if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 3) {
if (startpc != 0x81fc0 && manual_counter[inpage_ptr >> 12] <= 3)
{
// Counted blocks add a weighted (by block size) value into manual_page each time they're
// run. If the block gets run a lot, it resets and re-protects itself in the hope
// that whatever forced it to be manually-checked before was a 1-time deal.
// Counted blocks have a secondary threshold check in manual_counter, which forces a block
// to 'uncounted' mode if it's recompiled several time. This protects against excessive
// to 'uncounted' mode if it's recompiled several times. This protects against excessive
// recompilation of blocks that reside on the same codepage as data.
// fixme? Currently this algo is kinda dumb and results in the forced recompilation of a
// lot of blocks before it decides to mark a 'busy' page as uncounted. There might be
// be a more clever approach that could streamline this process, by doing a first-pass
// test using the vtlb memory protection (without recompilation!) to reprotect a counted
// block. But unless a new also is relatively simple in implementation, it's probably
// block. But unless a new algo is relatively simple in implementation, it's probably
// not worth the effort (tests show that we have lots of recompiler memory to spare, and
// that the current amount of recompilation is fairly cheap).
@ -1612,16 +1616,15 @@ StartRecomp:
xJC( dyna_page_reset );
// note: clearcnt is measured per-page, not per-block!
//DbgCon.WriteLn( "Manual block @ %08X : size=%3d page/offs=%05X/%03X inpgsz=%d clearcnt=%d",
//DbgCon.WriteLn( "Manual block @ %08X : size =%3d page/offs = %05X/%03X inpgsz = %d clearcnt = %d",
// startpc, sz, inpage_ptr>>12, inpage_ptr&0xfff, inpage_sz, manual_counter[inpage_ptr >> 12] );
}
else
{
DbgCon.WriteLn( Color_Gray, "Uncounted Manual block @ 0x%08X : size=%3d page/offs=%05X/%03X inpgsz=%d",
DbgCon.WriteLn( Color_Gray, "Uncounted Manual block @ 0x%08X : size =%3d page/offs = %05X/%03X inpgsz = %d",
startpc, sz, inpage_ptr>>12, inpage_ptr&0xfff, pgsz, inpage_sz );
}
}
break;
}
// Finally: Generate x86 recompiled code!
@ -1631,8 +1634,7 @@ StartRecomp:
}
#ifdef PCSX2_DEBUG
if( (dumplog & 1) )
iDumpBlock(startpc, recPtr);
if (dumplog & 1) iDumpBlock(startpc, recPtr);
#endif
pxAssert( (pc-startpc)>>2 <= 0xffff );