ultimecia

A ps1 emulator in c
Log | Files | Refs

edea.c (850B)


      1 #include <stdio.h>
      2 
      3 #include "types.h"
      4 
      5 #include "cpu.h"
      6 #include "interconnect.h"
      7 
      8 /* Breakpoint global (internal to this file) */
      9 //static u32 breakpoint_addr = 0;
     10 
     11 extern u32 running;
     12 extern u32 paused;
     13 extern u32 step;
     14 extern CPU* cpu;
     15 extern Interconnect* inter;
     16 
     17 typedef enum { HEX, DEC, OCT, BIN, F_COUNT } EDEA_FORMAT ;
     18 static const char *fmt[F_COUNT] = {
     19     [HEX] = "%08X",
     20     [DEC] = "%u",
     21     [OCT] = "%o",
     22     [BIN] = "%b"
     23 };
     24 
     25 void
     26 edea_peek(u32 v, EDEA_FORMAT mode)
     27 {
     28     if (!v) { puts("usage: peek <address>"); return; }
     29 
     30     printf("0x");
     31     printf(fmt[mode], v); 
     32     puts("");
     33 
     34 }
     35 
     36 void
     37 edea(char* l)
     38 {
     39     char *t1, *t2;
     40 
     41     t1 = strtok(l, " \t\r\n");
     42     t2 = strtok(NULL, " \t\r\n");
     43     //t3 strtok(NULL, " \t\r\n");
     44 
     45     if (!t1) return;
     46 
     47     if (!strcmp(t1, "peek"))
     48         if(t2)
     49             edea_peek(atoi(t2), HEX);
     50 
     51 }