notaz.gp2x.de
/
fceu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
asm cpu works, added sync()s
[fceu.git]
/
ncpu_debug.c
diff --git
a/ncpu_debug.c
b/ncpu_debug.c
index
864cae3
..
ebb32fa
100644
(file)
--- a/
ncpu_debug.c
+++ b/
ncpu_debug.c
@@
-8,12
+8,14
@@
// asm core state
extern uint32 nes_registers[0x10];
extern uint32 pc_base;
// asm core state
extern uint32 nes_registers[0x10];
extern uint32 pc_base;
-uint32 PC_prev = 0;
+uint32 PC_prev = 0
, g_cnt = 0
;
+int cpu_repeat;
+int cpu_lastval;
static void leave(void)
{
static void leave(void)
{
- printf("A: %02x, X: %02x, Y: %02x, S: %02x\n", X.A, X.X, X.Y, X.S);
+ printf("
\n
A: %02x, X: %02x, Y: %02x, S: %02x\n", X.A, X.X, X.Y, X.S);
printf("PC = %04lx, OP=%02X\n", PC_prev, (PC_prev < 0x2000) ? RAM[PC_prev&0x7ff] : ARead[PC_prev](PC_prev));
exit(1);
}
printf("PC = %04lx, OP=%02X\n", PC_prev, (PC_prev < 0x2000) ? RAM[PC_prev&0x7ff] : ARead[PC_prev](PC_prev));
exit(1);
}
@@
-21,35
+23,36
@@
static void leave(void)
static void compare_state(void)
{
uint8 nes_flags;
static void compare_state(void)
{
uint8 nes_flags;
+ int fail = 0;
if ((nes_registers[0] >> 24) != X.A) {
printf("A: %02lx vs %02x\n", nes_registers[0] >> 24, X.A);
if ((nes_registers[0] >> 24) != X.A) {
printf("A: %02lx vs %02x\n", nes_registers[0] >> 24, X.A);
-
leave()
;
+
fail = 1
;
}
if ((nes_registers[1] & 0xff) != X.X) {
printf("X: %02lx vs %02x\n", nes_registers[1] & 0xff, X.X);
}
if ((nes_registers[1] & 0xff) != X.X) {
printf("X: %02lx vs %02x\n", nes_registers[1] & 0xff, X.X);
-
leave()
;
+
fail = 1
;
}
if ((nes_registers[2] & 0xff) != X.Y) {
printf("Y: %02lx vs %02x\n", nes_registers[2] & 0xff, X.Y);
}
if ((nes_registers[2] & 0xff) != X.Y) {
printf("Y: %02lx vs %02x\n", nes_registers[2] & 0xff, X.Y);
-
leave()
;
+
fail = 1
;
}
if (nes_registers[3] - pc_base != X.PC) {
printf("PC: %04lx vs %04x\n", nes_registers[3] - pc_base, X.PC);
}
if (nes_registers[3] - pc_base != X.PC) {
printf("PC: %04lx vs %04x\n", nes_registers[3] - pc_base, X.PC);
-
leave()
;
+
fail = 1
;
}
if ((nes_registers[4] >> 24) != X.S) {
printf("S: %02lx vs %02x\n", nes_registers[4] >> 24, X.S);
}
if ((nes_registers[4] >> 24) != X.S) {
printf("S: %02lx vs %02x\n", nes_registers[4] >> 24, X.S);
-
leave()
;
+
fail = 1
;
}
if (((nes_registers[4]>>8)&0xff) != X.IRQlow) {
printf("IRQlow: %02lx vs %02x\n", ((nes_registers[4]>>8)&0xff), X.IRQlow);
}
if (((nes_registers[4]>>8)&0xff) != X.IRQlow) {
printf("IRQlow: %02lx vs %02x\n", ((nes_registers[4]>>8)&0xff), X.IRQlow);
-
leave()
;
+
fail = 1
;
}
// NVUB DIZC
}
// NVUB DIZC
@@
-58,15
+61,17
@@
static void compare_state(void)
if (!(nes_registers[5]&0x000000ff)) nes_flags |= 0x02; // Z
// nes_flags |= 0x20; // U, not set in C core (set only when pushing)
if (!(nes_registers[5]&0x000000ff)) nes_flags |= 0x02; // Z
// nes_flags |= 0x20; // U, not set in C core (set only when pushing)
- if (nes_flags !=
X.P
) {
- printf("flags: %02x vs %02x\n", nes_flags,
X.P
);
-
leave()
;
+ if (nes_flags !=
(X.P&~0x20)
) {
+ printf("flags: %02x vs %02x\n", nes_flags,
(X.P&~0x20)
);
+
fail = 1
;
}
if ((int32)nes_registers[7] != X.count) {
printf("cycles: %li vs %li\n", (int32)nes_registers[7], X.count);
}
if ((int32)nes_registers[7] != X.count) {
printf("cycles: %li vs %li\n", (int32)nes_registers[7], X.count);
-
leave()
;
+
fail = 1
;
}
}
+
+ if (fail) leave();
}
}
@@
-95,18
+100,26
@@
void X6502_Run_d(int32 c)
int32 cycles = c << 4; /* *16 */ \
if (PAL) cycles -= c; /* *15 */ \
int32 cycles = c << 4; /* *16 */ \
if (PAL) cycles -= c; /* *15 */ \
- printf("-- run(%i)\n", (int)c);
+ //printf("-- %06i: run(%i)\n", (int)g_cnt, (int)c);
+ g_cnt += c;
while (cycles > 0)
{
PC_prev = X.PC;
nes_registers[7]=1;
X.count=1;
while (cycles > 0)
{
PC_prev = X.PC;
nes_registers[7]=1;
X.count=1;
+
+ cpu_repeat = 0;
X6502_Run_c();
X6502_Run_c();
+
+ cpu_repeat = 1;
X6502_Run_a();
X6502_Run_a();
+
compare_state();
cycles -= 1 - X.count;
}
compare_state();
cycles -= 1 - X.count;
}
+
+ //printf("-- run_end\n");
}
void X6502_Reset_d(void)
}
void X6502_Reset_d(void)
@@
-129,10
+142,12
@@
void X6502_Power_d(void)
void X6502_AddCycles_d(int x)
{
void X6502_AddCycles_d(int x)
{
- printf("-- AddCycles(%i
)\n", x
);
+ printf("-- AddCycles(%i
|%i)\n", x, x*48
);
- X6502_AddCycles_c(x);
- X6502_AddCycles_a(x);
+ printf("can't use this in debug\n");
+ exit(1);
+ //X6502_AddCycles_c(x);
+ //X6502_AddCycles_a(x);
//compare_state();
}
//compare_state();
}