- [NEW] makefile més util

- [FIX] next (F11) no longer keeps breaking on current line
- [NEW] b alone sets breakpoint on current line
- [NEW] d alone clears breakpoint on current line
- [NEW] d all removes all breakpoints
- [FIX] IX bit & IY bit instruction visualization is fixed
- [FIX] RRD & RLD were swaped
This commit is contained in:
2024-04-18 13:01:51 +02:00
parent e80de06d2c
commit 145a48b86b
6 changed files with 22 additions and 12 deletions

View File

@@ -1,2 +1,8 @@
default: compile:
g++ -g *.cpp -lSDL2 -o z80 g++ -g *.cpp -lSDL2 -o z80
run: compile
./z80
debug: compile
gdb z80

View File

@@ -55,13 +55,12 @@ int main(int argc, char *argv[])
z80debug::refresh(); z80debug::refresh();
zxscreen::refresh(); zxscreen::refresh();
} else if (e.key.keysym.scancode==SDL_SCANCODE_F11) { } else if (e.key.keysym.scancode==SDL_SCANCODE_F11) {
z80debug::next(); t += z80debug::next();
//t += z80::step();
fps=0; fps=0;
fps_time = SDL_GetTicks(); fps_time = SDL_GetTicks();
zxscreen::refresh(); zxscreen::refresh();
} else if (e.key.keysym.scancode==SDL_SCANCODE_F5) { } else if (e.key.keysym.scancode==SDL_SCANCODE_F5) {
z80::step(); t += z80::step();
z80debug::cont(); z80debug::cont();
fps=0; fps=0;
fps_time = SDL_GetTicks(); fps_time = SDL_GetTicks();

10
z80.cpp
View File

@@ -457,8 +457,8 @@ namespace z80
{ {
uint8_t a = rA; uint8_t a = rA;
uint8_t hl = READ_MEM_8(rHL); uint8_t hl = READ_MEM_8(rHL);
rA = (rA & 0xF0) | (hl >> 4); rA = (rA & 0xF0) | (hl & 0x0F);
hl = (hl<<4) | (a & 0X0F); hl = (hl >> 4) | (a << 4);
WRITE_MEM_8(rHL, hl); WRITE_MEM_8(rHL, hl);
KEEP_FLAGS(fC); KEEP_FLAGS(fC);
FLAGS_SZXY(rA); FLAGS_SZXY(rA);
@@ -470,8 +470,8 @@ namespace z80
{ {
uint8_t a = rA; uint8_t a = rA;
uint8_t hl = READ_MEM_8(rHL); uint8_t hl = READ_MEM_8(rHL);
rA = (rA & 0xF0) | (hl & 0x0F); rA = (rA & 0xF0) | (hl >> 4);
hl = (hl >> 4) | (a << 4); hl = (hl << 4) | (a & 0x0F);
WRITE_MEM_8(rHL, hl); WRITE_MEM_8(rHL, hl);
KEEP_FLAGS(fC); KEEP_FLAGS(fC);
FLAGS_SZXY(rA); FLAGS_SZXY(rA);
@@ -710,7 +710,7 @@ namespace z80
static inline const uint8_t SLL(const uint8_t v) static inline const uint8_t SLL(const uint8_t v)
{ {
const uint8_t res = (v<<1) & 1; const uint8_t res = (v<<1) | 1;
rF=0; rF=0;
FLAGS_SZXY(res); FLAGS_SZXY(res);
if (v&0x80) SET_FLAGS(fC); if (v&0x80) SET_FLAGS(fC);

View File

@@ -365,6 +365,7 @@ namespace z80debug
z80debug::refresh(); z80debug::refresh();
} else if (strcmp(cmd, "b")==0 || strcmp(cmd, "break")==0) { } else if (strcmp(cmd, "b")==0 || strcmp(cmd, "break")==0) {
getcmd(); getcmd();
if (cmd[0] == 0) { breakpoints[z80::getPC()]=1; return; }
int address = getnum(cmd); int address = getnum(cmd);
if (address<0 || address>65536) { strcpy(console_error, "Illegal break address"); return; } if (address<0 || address>65536) { strcpy(console_error, "Illegal break address"); return; }
getcmd(); getcmd();
@@ -384,6 +385,8 @@ namespace z80debug
breakpoints[address] |= break_type; breakpoints[address] |= break_type;
} else if (strcmp(cmd, "d")==0 || strcmp(cmd, "delete")==0) { } else if (strcmp(cmd, "d")==0 || strcmp(cmd, "delete")==0) {
getcmd(); getcmd();
if (strcmp(cmd, "all")==0) { for (int i=0;i<65536;++i) breakpoints[i]=0; return; }
if (cmd[0] == 0) { breakpoints[z80::getPC()]=0; return; }
int address = getnum(cmd); int address = getnum(cmd);
if (address<0 || address>65536) { strcpy(console_error, "Illegal address"); return; } if (address<0 || address>65536) { strcpy(console_error, "Illegal address"); return; }
getcmd(); getcmd();
@@ -414,9 +417,11 @@ namespace z80debug
return (breakpoints[address]&type); return (breakpoints[address]&type);
} }
void next() uint32_t next()
{ {
breakpoints[z80::getPC()+z80dis::getOpcodeSize(z80::getPC())] |= 8; breakpoints[z80::getPC()+z80dis::getOpcodeSize(z80::getPC())] |= 8;
const uint32_t t = z80::step();
cont(); cont();
return t;
} }
} }

View File

@@ -15,5 +15,5 @@ namespace z80debug
void executeConsole(); void executeConsole();
const bool isbreak(const uint16_t address, const uint8_t type=1); const bool isbreak(const uint16_t address, const uint8_t type=1);
void next(); uint32_t next();
} }

View File

@@ -118,7 +118,7 @@ namespace z80dis
} }
} }
if (strstr(base, "hhd")) { if (strstr(buffer, "hhd")) {
opcode_size+=1; opcode_size+=1;
strcpy(base, buffer); strcpy(base, buffer);