--- np2/debugsub.c 2003/11/14 07:37:28 1.2 +++ np2/debugsub.c 2005/02/07 14:46:07 1.12 @@ -1,8 +1,7 @@ #include "compiler.h" #include "strres.h" #include "dosio.h" -#include "i286.h" -#include "memory.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "debugsub.h" @@ -60,7 +59,6 @@ static const char file_i286cs[] = "i286_ static const char file_i286ds[] = "i286_ds.%.3u"; static const char file_i286es[] = "i286_es.%.3u"; static const char file_i286ss[] = "i286_ss.%.3u"; -static const char file_i286txt[] = "i286txt.%.3u"; static const char file_memorybin[] = "memory.bin"; static const char str_register[] = \ @@ -101,14 +99,36 @@ const char *debugsub_regs(void) { static char work[256]; - SPRINTF(work, str_register, I286_AX, I286_BX, I286_CX, I286_DX, - I286_SP, I286_BP, I286_SI, I286_DI, - I286_DS, I286_ES, I286_SS, I286_CS, I286_IP); - milstr_ncat(work, debugsub_flags(I286_FLAG), sizeof(work)); + SPRINTF(work, str_register, CPU_AX, CPU_BX, CPU_CX, CPU_DX, + CPU_SP, CPU_BP, CPU_SI, CPU_DI, + CPU_DS, CPU_ES, CPU_SS, CPU_CS, CPU_IP); + milstr_ncat(work, debugsub_flags(CPU_FLAG), sizeof(work)); milstr_ncat(work, CRCONST, sizeof(work)); return(work); } +static void writeseg(const char *fname, UINT32 addr, UINT limit) { + + FILEH fh; + UINT size; + UINT8 buf[0x400]; // Stack 0x1000 -> 0x400 + + fh = file_create_c(fname); + 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; @@ -124,41 +144,19 @@ const char *p; SPRINTF(work, str_picstat, pic.pi[0].imr, pic.pi[0].irr, pic.pi[0].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)); file_close(fh); } SPRINTF(work, file_i286cs, filenum); - fh = file_create_c(work); - if (fh != FILEH_INVALID) { - file_write(fh, &mem[CS_BASE], 0x10000); - file_close(fh); - } + writeseg(work, CS_BASE, 0xffff); SPRINTF(work, file_i286ds, filenum); - fh = file_create_c(work); - if (fh != FILEH_INVALID) { - file_write(fh, &mem[DS_BASE], 0x10000); - file_close(fh); - } + writeseg(work, DS_BASE, 0xffff); SPRINTF(work, file_i286es, filenum); - fh = file_create_c(work); - if (fh != FILEH_INVALID) { - file_write(fh, &mem[ES_BASE], 0x10000); - file_close(fh); - } + writeseg(work, ES_BASE, 0xffff); 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); - } + writeseg(work, SS_BASE, 0xffff); filenum++; } @@ -169,7 +167,9 @@ void debugsub_memorydump(void) { fh = file_create_c(file_memorybin); if (fh != FILEH_INVALID) { - for (i=0; i<34; i++) { + for (i=0; i<34; i++) +// for (i=0; i<64; i++) + { file_write(fh, mem + i*0x8000, 0x8000); } file_close(fh);