Diff for /np2/debugsub.c between versions 1.8 and 1.14

version 1.8, 2004/02/06 17:10:32 version 1.14, 2005/03/20 06:09:16
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "strres.h"  #include        "strres.h"
   #include        "textfile.h"
 #include        "dosio.h"  #include        "dosio.h"
 #include        "cpucore.h"  #include        "cpucore.h"
 #include        "pccore.h"  #include        "pccore.h"
Line 19 Line 20
 #endif  #endif
   
   
 static const char s_nv[] = "NV";  static const OEMCHAR s_nv[] = OEMTEXT("NV");
 static const char s_ov[] = "OV";  static const OEMCHAR s_ov[] = OEMTEXT("OV");
 static const char s_dn[] = "DN";  static const OEMCHAR s_dn[] = OEMTEXT("DN");
 static const char s_up[] = "UP";  static const OEMCHAR s_up[] = OEMTEXT("UP");
 static const char s_di[] = "DI";  static const OEMCHAR s_di[] = OEMTEXT("DI");
 static const char s_ei[] = "EI";  static const OEMCHAR s_ei[] = OEMTEXT("EI");
 static const char s_pl[] = "PL";  static const OEMCHAR s_pl[] = OEMTEXT("PL");
 static const char s_ng[] = "NG";  static const OEMCHAR s_ng[] = OEMTEXT("NG");
 static const char s_nz[] = "NZ";  static const OEMCHAR s_nz[] = OEMTEXT("NZ");
 static const char s_zr[] = "ZR";  static const OEMCHAR s_zr[] = OEMTEXT("ZR");
 static const char s_na[] = "NA";  static const OEMCHAR s_na[] = OEMTEXT("NA");
 static const char s_ac[] = "AC";  static const OEMCHAR s_ac[] = OEMTEXT("AC");
 static const char s_po[] = "PO";  static const OEMCHAR s_po[] = OEMTEXT("PO");
 static const char s_pe[] = "PE";  static const OEMCHAR s_pe[] = OEMTEXT("PE");
 static const char s_nc[] = "NC";  static const OEMCHAR s_nc[] = OEMTEXT("NC");
 static const char s_cy[] = "CY";  static const OEMCHAR s_cy[] = OEMTEXT("CY");
   
 static const char *flagstr[16][2] = {  static const OEMCHAR *flagstr[16][2] = {
                                 {NULL, NULL},           // 0x8000                                  {NULL, NULL},           // 0x8000
                                 {NULL, NULL},           // 0x4000                                  {NULL, NULL},           // 0x4000
                                 {NULL, NULL},           // 0x2000                                  {NULL, NULL},           // 0x2000
Line 54  static const char *flagstr[16][2] = { Line 55  static const char *flagstr[16][2] = {
                                 {NULL, NULL},           // 0x0002                                  {NULL, NULL},           // 0x0002
                                 {s_nc, s_cy}};          // 0x0001                                  {s_nc, s_cy}};          // 0x0001
   
 static const char file_i286reg[] = "i286reg.%.3u";  static const OEMCHAR file_i286reg[] = OEMTEXT("i286reg.%.3u");
 static const char file_i286cs[] = "i286_cs.%.3u";  static const OEMCHAR file_i286cs[] = OEMTEXT("i286_cs.%.3u");
 static const char file_i286ds[] = "i286_ds.%.3u";  static const OEMCHAR file_i286ds[] = OEMTEXT("i286_ds.%.3u");
 static const char file_i286es[] = "i286_es.%.3u";  static const OEMCHAR file_i286es[] = OEMTEXT("i286_es.%.3u");
 static const char file_i286ss[] = "i286_ss.%.3u";  static const OEMCHAR file_i286ss[] = OEMTEXT("i286_ss.%.3u");
 static const char file_i286txt[] = "i286txt.%.3u";  static const OEMCHAR file_memorybin[] = OEMTEXT("memory.bin");
 static const char file_memorybin[] = "memory.bin";  
   static const OEMCHAR str_register[] =                                                           \
 static const char str_register[] =                                                                              \                                  OEMTEXT("AX=%.4x  BX=%.4x  CX=%.4x  DX=%.4x  ")         \
                                         "AX=%.4x  BX=%.4x  CX=%.4x  DX=%.4x  "                          \                                  OEMTEXT("SP=%.4x  BP=%.4x  SI=%.4x  DI=%.4x")           \
                                         "SP=%.4x  BP=%.4x  SI=%.4x  DI=%.4x" CRLITERAL          \                                  OEMTEXT(CRLITERAL)                                                                      \
                                         "DS=%.4x  ES=%.4x  SS=%.4x  CS=%.4x  "                          \                                  OEMTEXT("DS=%.4x  ES=%.4x  SS=%.4x  CS=%.4x  ")         \
                                         "IP=%.4x   ";                                  OEMTEXT("IP=%.4x   ");
 static const char str_picstat[] =                                                                               \  static const OEMCHAR str_picstat[] =                                                            \
                                         CRLITERAL "PIC0=%.2x:%.2x:%.2x"                                         \                                  OEMTEXT(CRLITERAL)                                                                      \
                                         CRLITERAL "PIC1=%.2x:%.2x:%.2x"                                         \                                  OEMTEXT("PIC0=%.2x:%.2x:%.2x")                                          \
                                         CRLITERAL "8255PORTC = %.2x / system-port = %.2x";                                  OEMTEXT(CRLITERAL)                                                                      \
                                   OEMTEXT("PIC1=%.2x:%.2x:%.2x")                                          \
                                   OEMTEXT(CRLITERAL)                                                                      \
 const char *debugsub_flags(UINT16 flag) {                                  OEMTEXT("8255PORTC = %.2x / system-port = %.2x");
   
 static char     work[128];  
         int             i;  const OEMCHAR *debugsub_flags(UINT16 flag) {
         UINT16  bit;  
   static OEMCHAR  work[128];
           int                     i;
           UINT16          bit;
   
         work[0] = 0;          work[0] = 0;
         for (i=0, bit=0x8000; bit; i++, bit>>=1) {          for (i=0, bit=0x8000; bit; i++, bit>>=1) {
                 if (flagstr[i][0]) {                  if (flagstr[i][0]) {
                         if (flag & bit) {                          if (flag & bit) {
                                 milstr_ncat(work, flagstr[i][1], sizeof(work));                                  milstr_ncat(work, flagstr[i][1], NELEMENTS(work));
                         }                          }
                         else {                          else {
                                 milstr_ncat(work, flagstr[i][0], sizeof(work));                                  milstr_ncat(work, flagstr[i][0], NELEMENTS(work));
                         }                          }
                         if (bit != 1) {                          if (bit != 1) {
                                 milstr_ncat(work, str_space, sizeof(work));                                  milstr_ncat(work, str_space, NELEMENTS(work));
                         }                          }
                 }                  }
         }          }
         return(work);          return(work);
 }  }
   
 const char *debugsub_regs(void) {  const OEMCHAR *debugsub_regs(void) {
   
 static char work[256];  static OEMCHAR  work[256];
   
         SPRINTF(work, str_register, CPU_AX, CPU_BX, CPU_CX, CPU_DX,          OEMSPRINTF(work, str_register,  CPU_AX, CPU_BX, CPU_CX, CPU_DX,
                                                                 CPU_SP, CPU_BP, CPU_SI, CPU_DI,                                                                          CPU_SP, CPU_BP, CPU_SI, CPU_DI,
                                                                 CPU_DS, CPU_ES, CPU_SS, CPU_CS, CPU_IP);                                                                          CPU_DS, CPU_ES, CPU_SS, CPU_CS, CPU_IP);
         milstr_ncat(work, debugsub_flags(CPU_FLAG), sizeof(work));          milstr_ncat(work, debugsub_flags(CPU_FLAG), NELEMENTS(work));
         milstr_ncat(work, CRCONST, sizeof(work));          milstr_ncat(work, CRCONST, NELEMENTS(work));
         return(work);          return(work);
 }  }
   
 void debugsub_status(void) {  static void writeseg(const OEMCHAR *fname, UINT32 addr, UINT limit) {
   
 static int      filenum = 0;  
         FILEH   fh;          FILEH   fh;
         char    work[512];          UINT    size;
 const char      *p;          UINT8   buf[0x400];                                                             // Stack 0x1000 -> 0x400
   
         SPRINTF(work, file_i286reg, filenum);          fh = file_create_c(fname);
         fh = file_create_c(work);          if (fh == FILEH_INVALID) {
         if (fh != FILEH_INVALID) {                  return;
           }
           limit = min(limit, 0xffff);
           limit++;
           while(limit) {
                   size = min(limit, sizeof(buf));
                   MEML_READ(addr, buf, size);
                   file_write(fh, buf, size);
                   addr += size;
                   limit -= size;
           }
           file_close(fh);
   }
   
   void debugsub_status(void) {
   
   static int              filenum = 0;
           TEXTFILEH       tfh;
           OEMCHAR         work[512];
   const OEMCHAR   *p;
   
           OEMSPRINTF(work, file_i286reg, filenum);
           tfh = textfile_create(file_getcd(work), 0);
           if (tfh != NULL) {
                 p = debugsub_regs();                  p = debugsub_regs();
                 file_write(fh, p, strlen(p));                  textfile_write(tfh, p);
                 SPRINTF(work, str_picstat,                  OEMSPRINTF(work, str_picstat,
                                                                 pic.pi[0].imr, pic.pi[0].irr, pic.pi[0].isr,                                                                  pic.pi[0].imr, pic.pi[0].irr, pic.pi[0].isr,
                                                                 pic.pi[1].imr, pic.pi[1].irr, pic.pi[1].isr,                                                                  pic.pi[1].imr, pic.pi[1].irr, pic.pi[1].isr,
                                                                 mouseif.portc, sysport.c);                                                                  mouseif.upd8255.portc, sysport.c);
                 file_write(fh, work, strlen(work));                  textfile_write(tfh, work);
                 file_close(fh);                  textfile_close(tfh);
         }          }
   
         SPRINTF(work, file_i286cs, filenum);          OEMSPRINTF(work, file_i286cs, filenum);
         fh = file_create_c(work);          writeseg(work, CS_BASE, 0xffff);
         if (fh != FILEH_INVALID) {          OEMSPRINTF(work, file_i286ds, filenum);
                 file_write(fh, &mem[CS_BASE], 0x10000);          writeseg(work, DS_BASE, 0xffff);
                 file_close(fh);          OEMSPRINTF(work, file_i286es, filenum);
         }          writeseg(work, ES_BASE, 0xffff);
         SPRINTF(work, file_i286ds, filenum);          OEMSPRINTF(work, file_i286ss, filenum);
         fh = file_create_c(work);          writeseg(work, SS_BASE, 0xffff);
         if (fh != FILEH_INVALID) {  
                 file_write(fh, &mem[DS_BASE], 0x10000);  
                 file_close(fh);  
         }  
         SPRINTF(work, file_i286es, filenum);  
         fh = file_create_c(work);  
         if (fh != FILEH_INVALID) {  
                 file_write(fh, &mem[ES_BASE], 0x10000);  
                 file_close(fh);  
         }  
         SPRINTF(work, file_i286ss, filenum);  
         fh = file_create_c(work);  
         if (fh != FILEH_INVALID) {  
                 file_write(fh, &mem[SS_BASE], 0x10000);  
                 file_close(fh);  
         }  
         SPRINTF(work, file_i286txt, filenum);  
         fh = file_create_c(work);  
         if (fh != FILEH_INVALID) {  
                 file_write(fh, &mem[0xa0000], 0x4000);  
                 file_close(fh);  
         }  
         filenum++;          filenum++;
 }  }
   

Removed from v.1.8  
changed lines
  Added in v.1.14


RetroPC.NET-CVS <cvs@retropc.net>