From 43c83e991c0705b7dc981ca760aa14fd3331604c Mon Sep 17 00:00:00 2001 From: Stephan Veigl Date: Fri, 9 Nov 2012 09:32:10 +0100 Subject: [PATCH] misc: Update NO_COLOR define switch The NO_COLOR define switch is a preparation for the Windows version. Since the standard Windows command prompt is not able to display ANSI color statements correctly. With this define switch it is possible to remove any coloring of the output. This will be set automatically in the MinGW patch. The color definitions are moved from sim_core.c to sim_core.h since they are used in other macros as well. Signed-off-by: Stephan Veigl --- simavr/sim/sim_core.c | 8 -------- simavr/sim/sim_core.h | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/simavr/sim/sim_core.c b/simavr/sim/sim_core.c index e62938f..5e7e2c8 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -32,14 +32,6 @@ // SREG bit names const char * _sreg_bit_name = "cznvshti"; -#ifdef NO_COLOR - #define FONT_RED - #define FONT_DEFAULT -#else - #define FONT_RED "\e[31m" - #define FONT_DEFAULT "\e[0m" -#endif - /* * Handle "touching" registers, marking them changed. * This is used only for debugging purposes to be able to diff --git a/simavr/sim/sim_core.h b/simavr/sim/sim_core.h index 6466b80..cc5da7b 100644 --- a/simavr/sim/sim_core.h +++ b/simavr/sim/sim_core.h @@ -26,6 +26,16 @@ extern "C" { #endif +#ifdef NO_COLOR + #define FONT_GREEN + #define FONT_RED + #define FONT_DEFAULT +#else + #define FONT_GREEN "\e[32m" + #define FONT_RED "\e[31m" + #define FONT_DEFAULT "\e[0m" +#endif + /* * Instruction decoder, run ONE instruction */ @@ -64,7 +74,7 @@ void avr_dump_state(avr_t * avr); #define DUMP_STACK() \ for (int i = avr->trace_data->stack_frame_index; i; i--) {\ int pci = i-1;\ - printf("\e[31m*** %04x: %-25s sp %04x\e[0m\n",\ + printf(FONT_RED "*** %04x: %-25s sp %04x\n" FONT_DEFAULT,\ avr->trace_data->stack_frame[pci].pc, \ avr->trace_data->codeline ? avr->trace_data->codeline[avr->trace_data->stack_frame[pci].pc>>1]->symbol : "unknown", \ avr->trace_data->stack_frame[pci].sp);\ @@ -78,7 +88,7 @@ void avr_dump_state(avr_t * avr); printf("*** CYCLE %" PRI_avr_cycle_count "PC %04x\n", avr->cycle, avr->pc);\ for (int i = OLD_PC_SIZE-1; i > 0; i--) {\ int pci = (avr->trace_data->old_pci + i) & 0xf;\ - printf("\e[31m*** %04x: %-25s RESET -%d; sp %04x\e[0m\n",\ + printf(FONT_RED "*** %04x: %-25s RESET -%d; sp %04x\n" FONT_DEFAULT,\ avr->trace_data->old[pci].pc, avr->trace_data->codeline ? avr->trace_data->codeline[avr->trace_data->old[pci].pc>>1]->symbol : "unknown", OLD_PC_SIZE-i, avr->trace_data->old[pci].sp);\ }\ printf("Stack Ptr %04x/%04x = %d \n", _avr_sp_get(avr), avr->ramend, avr->ramend - _avr_sp_get(avr));\ -- 2.20.1