misc: Update NO_COLOR define switch
authorStephan Veigl <veigl@gmx.net>
Fri, 9 Nov 2012 08:32:10 +0000 (09:32 +0100)
committerStephan Veigl <veigl@gmx.net>
Thu, 29 Nov 2012 10:05:33 +0000 (11:05 +0100)
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 <veigl@gmx.net>
simavr/sim/sim_core.c
simavr/sim/sim_core.h

index e62938f..5e7e2c8 100644 (file)
 // 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
index 6466b80..cc5da7b 100644 (file)
 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));\