Cleaner debug/non-debug separation, don't CLS when debugging.
This commit is contained in:
parent
4aed1bb03e
commit
7193297f0c
|
@ -62,12 +62,15 @@ typedef enum
|
|||
} reader_state_t;
|
||||
|
||||
/* Debug global which can be set via command line flag --debug */
|
||||
unsigned int debug = 0;
|
||||
bool debug = false;
|
||||
|
||||
/* Debug macros that are enabled via the --debug flag */
|
||||
#define DEBUG_PRINTF(...) do { if(debug) { printf(__VA_ARGS__); } } while(0)
|
||||
#define DEBUG_PRINT_HEX(data, length) do { if(debug) { printHex(data, length); } } while(0)
|
||||
|
||||
/* Macros that are enabled when debug is not enabled */
|
||||
#define NON_DEBUG_PRINTF(...) do { if(!debug) { printf(__VA_ARGS__); } } while(0)
|
||||
|
||||
void printHex(const unsigned char * const data, int length )
|
||||
{
|
||||
printf( "Length: %d bytes\n", length );
|
||||
|
@ -413,14 +416,8 @@ HANDLE InitReaders(unsigned int &readerCount)
|
|||
unsigned int pno = 0;
|
||||
|
||||
/* Put a space into location where we will be backspacing, for laziness */
|
||||
if (!debug)
|
||||
{
|
||||
printf( " " );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "...\n" );
|
||||
}
|
||||
NON_DEBUG_PRINTF( " " );
|
||||
DEBUG_PRINTF( "...\n" );
|
||||
|
||||
/* Try to open the reader indefinitely */
|
||||
while( 1 )
|
||||
|
@ -430,11 +427,7 @@ HANDLE InitReaders(unsigned int &readerCount)
|
|||
|
||||
for (unsigned int baud = 0; baud < 2; baud++)
|
||||
{
|
||||
if (!debug)
|
||||
{
|
||||
printf( "%s", pattern[(pno++) % 4] );
|
||||
}
|
||||
|
||||
NON_DEBUG_PRINTF( "%s", pattern[(pno++) % 4] );
|
||||
DEBUG_PRINTF("Attempting to probe readers on %ls,%d\n", comport[which], baudrate[baud]);
|
||||
serial = OpenSerial( comport[which], baudrate[baud] );
|
||||
|
||||
|
@ -464,10 +457,7 @@ HANDLE InitReaders(unsigned int &readerCount)
|
|||
}
|
||||
}
|
||||
|
||||
if (!debug)
|
||||
{
|
||||
printf( "%s", pattern[(pno++) % 4] );
|
||||
}
|
||||
NON_DEBUG_PRINTF( "%s", pattern[(pno++) % 4] );
|
||||
}
|
||||
|
||||
/* Failed, close */
|
||||
|
@ -507,12 +497,12 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
if (wcscmp(argv[2], L"--debug") == 0)
|
||||
{
|
||||
inifile = argv[1];
|
||||
debug = 1;
|
||||
debug = true;
|
||||
}
|
||||
else if (wcscmp(argv[1], L"--debug") == 0)
|
||||
{
|
||||
inifile = argv[2];
|
||||
debug = 1;
|
||||
debug = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -526,13 +516,10 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
}
|
||||
|
||||
/* Display if we're debugging */
|
||||
if( debug )
|
||||
{
|
||||
printf( "Enabling debug mode!\n" );
|
||||
}
|
||||
|
||||
DEBUG_PRINTF( "Enabling debug mode!\n" );
|
||||
|
||||
/* Initialize menu */
|
||||
Menu menu = Menu(inifile);
|
||||
Menu menu = Menu(inifile, debug);
|
||||
|
||||
if( menu.NumberOfEntries() < 1 )
|
||||
{
|
||||
|
|
7
Menu.cpp
7
Menu.cpp
|
@ -3,8 +3,11 @@
|
|||
|
||||
#include "Menu.h"
|
||||
|
||||
Menu::Menu(_TCHAR *inifile)
|
||||
Menu::Menu(_TCHAR *inifile, bool isDebugEnabled)
|
||||
{
|
||||
/* Set up debug */
|
||||
debug = isDebugEnabled;
|
||||
|
||||
/* Read settings */
|
||||
settings = LoadSettings( inifile, &num_programs );
|
||||
|
||||
|
@ -38,7 +41,7 @@ Menu::~Menu(void)
|
|||
void Menu::DisplayPrompt()
|
||||
{
|
||||
/* Prompt the user */
|
||||
system("cls");
|
||||
if (!debug) { system("cls"); }
|
||||
printf( "Make a selection on the reader to boot a game.\n" );
|
||||
printf( "%s will boot in %d seconds.\n\n", settings[0].name, TIMEOUT_SECONDS );
|
||||
}
|
||||
|
|
3
Menu.h
3
Menu.h
|
@ -22,7 +22,7 @@ typedef struct
|
|||
class Menu
|
||||
{
|
||||
public:
|
||||
Menu(_TCHAR *inifile);
|
||||
Menu(_TCHAR *inifile, bool isDebugEnabled);
|
||||
~Menu(void);
|
||||
|
||||
unsigned int NumberOfEntries() { return num_programs; }
|
||||
|
@ -38,6 +38,7 @@ class Menu
|
|||
void ResetTimeout();
|
||||
bool ShouldBootDefault();
|
||||
private:
|
||||
bool debug;
|
||||
unsigned int num_programs;
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
|
|
Loading…
Reference in New Issue