OSDN Git Service

debug tool update.
authorastoria-d <astoria-d@mail.goo.ne.jp>
Sat, 23 Mar 2013 14:42:37 +0000 (23:42 +0900)
committerastoria-d <astoria-d@mail.goo.ne.jp>
Sat, 23 Mar 2013 14:42:37 +0000 (23:42 +0900)
emulator/cpu.c
emulator/debug.c
emulator/ppucore/dummy-driver2.c

index 8410e39..ab58b44 100644 (file)
@@ -25,6 +25,7 @@ void pc_set(unsigned short addr);
 unsigned short pc_get(void);
 void pc_move(int offset);
 void report_exec_err(void);
+void d1_set(int on_off);
 void d2_set(int on_off);
 void d3_set(int on_off);
 
@@ -34,7 +35,6 @@ int disas_inst(unsigned short addr);
 void dump_6502(int full);
 extern int debug_mode;
 extern unsigned short break_point;
-extern int dbg_log_msg;
 extern int critical_error;
 
 
@@ -44,6 +44,7 @@ static unsigned short cpu_addr_buffer;
 static void (*dump_6502_level2)(int);
 static void (*dump_6502_level3_load)(unsigned short, unsigned char);
 static void (*dump_6502_level3_store)(unsigned short, unsigned char);
+static int (*d1_disas)(unsigned short);
 
 /*
  * clock execution function array.
@@ -196,12 +197,8 @@ static int fetch_and_decode_inst(void) {
         break_hit();
     }
 
-    if (dbg_log_msg) {
-        disas_inst(pc);
-    }
+    d1_disas(pc);
     if (debug_mode) {
-        if (!dbg_log_msg)
-            disas_inst(pc);
         ret = emu_debug();
         if (!ret)
             return FALSE;
@@ -273,6 +270,7 @@ unsigned char get_cpu_data_buf(void) {
 /*null func*/
 static void null_dump_6502 (int param) {}
 static void null_load_store (unsigned short addr, unsigned char data) {}
+static int null_disas(unsigned short addr) {return 0;}
 
 static void dump_load (unsigned short addr, unsigned char data) {
     dprint("                                  ");
@@ -301,6 +299,7 @@ int init_cpu(void) {
     cpu_data_buffer = 0;
     cpu_addr_buffer = 0;
 
+    d1_set(debug_mode);
     d2_set(debug_mode);
     d3_set(debug_mode);
 
@@ -308,6 +307,15 @@ int init_cpu(void) {
 }
 
 /*------for debug.c-----*/
+void d1_set(int on_off) {
+    if (on_off) {
+        d1_disas = disas_inst;
+    }
+    else {
+        d1_disas = null_disas;
+    }
+}
+
 void d2_set(int on_off) {
     if (on_off) {
         dump_6502_level2 = dump_6502;
index 54a2d66..edb7b52 100644 (file)
@@ -15,6 +15,7 @@ unsigned char vram_data_get(unsigned short addr);
 unsigned char dbg_get_byte(unsigned short addr);
 unsigned short dbg_get_short(unsigned short addr);
 void dump_ppu_reg(void);
+void d1_set(int on_off);
 void d2_set(int on_off);
 void d3_set(int on_off);
 void d4_set(int on_off);
@@ -28,7 +29,6 @@ struct cmd_list {
 
 static struct cmd_list* debug_history;
 //global variable.
-int dbg_log_msg;
 unsigned short break_point;
 
 static void print_debug(void) {
@@ -43,7 +43,7 @@ static void print_debug(void) {
     printf("        pshow: show ppu registers\n");
     printf("  v addr size: vram dump\n");
     printf("  da addr size: disassemble\n");
-    printf("   log on/off: set log msg on/off\n");
+    printf("   d1 on/off: debug log level 1 (dump instruction on execution)\n");
     printf("   d2 on/off: debug log level 2 (dump reg status for each instruction)\n");
     printf("   d3 on/off: debug log level 3 (dump load/store data value)\n");
     printf("   d4 on/off: debug log level 4 (dump vram data write)\n");
@@ -106,13 +106,13 @@ int emu_debug(void) {
         else if (!strcmp(buf, "show")){
             dump_6502(TRUE);
         }
-        else if (!strcmp(buf, "log")){
+        else if (!strcmp(buf, "d1")){
             scanf("%s", buf);
             if (!strcmp(buf, "on")){
-                dbg_log_msg = TRUE;
+                d1_set(TRUE);
             }
             else if (!strcmp(buf, "off")){
-                dbg_log_msg = FALSE;
+                d1_set(FALSE);
             }
             else {
                 printf("log parameter must be either [on] or [off].\n");
@@ -337,7 +337,6 @@ void break_hit(void) {
 int init_debug(void) {
     dprint("init debug..\n");
     debug_history = NULL;
-    dbg_log_msg = debug_mode;
     break_point = 0;
     //initscr();          /* Start curses mode          */
 
index b0d30d3..713fd72 100644 (file)
@@ -58,6 +58,7 @@ unsigned char dbg_get_byte(unsigned short addr) { return 0; }
 unsigned short dbg_get_short(unsigned short addr) { return 0; }
 int disas_inst(unsigned short addr) { return 0; }
 void set_nmi_pin(int val) { }
+void d1_set(int on_off) {}
 void d2_set(int on_off) {}
 void d3_set(int on_off) {}