- [FIX] ui module should only update renderer when it actually changes
- [NEW] Disassembly window now can scroll with cursors or mouse wheel - [NEW] Added valgrind script and supporting file
This commit is contained in:
23
main.cpp
23
main.cpp
@@ -107,15 +107,28 @@ int main(int argc, char *argv[])
|
|||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
zxscreen::redraw();
|
zxscreen::redraw();
|
||||||
}
|
}
|
||||||
|
if (e.type == SDL_MOUSEWHEEL) {
|
||||||
|
if (e.wheel.mouseX<46 && e.wheel.mouseY<20) {
|
||||||
|
if (e.wheel.y>0) {
|
||||||
|
z80debug::cursorback();
|
||||||
|
z80debug::refresh();
|
||||||
|
} else if (e.wheel.y<0) {
|
||||||
|
z80debug::cursorfwd();
|
||||||
|
z80debug::refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (e.type == SDL_KEYDOWN) {
|
if (e.type == SDL_KEYDOWN) {
|
||||||
if (e.key.keysym.scancode==SDL_SCANCODE_ESCAPE) {
|
if (e.key.keysym.scancode==SDL_SCANCODE_ESCAPE) {
|
||||||
should_exit=true; break;
|
should_exit=true; break;
|
||||||
} else if (e.key.keysym.scancode==SDL_SCANCODE_F10) {
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_F10) {
|
||||||
|
z80debug::history::gototop();
|
||||||
const uint8_t dt = z80::step();
|
const uint8_t dt = z80::step();
|
||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
zxscreen::refresh(dt);
|
zxscreen::refresh(dt);
|
||||||
zxscreen::redraw();
|
zxscreen::redraw();
|
||||||
} else if (e.key.keysym.scancode==SDL_SCANCODE_F11) {
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_F11) {
|
||||||
|
z80debug::history::gototop();
|
||||||
const uint8_t dt = z80debug::next();
|
const uint8_t dt = z80debug::next();
|
||||||
zxscreen::refresh(dt);
|
zxscreen::refresh(dt);
|
||||||
zxscreen::redraw();
|
zxscreen::redraw();
|
||||||
@@ -133,11 +146,17 @@ int main(int argc, char *argv[])
|
|||||||
const uint8_t dt = z80::step();
|
const uint8_t dt = z80::step();
|
||||||
z80debug::cont();
|
z80debug::cont();
|
||||||
zxscreen::refresh(dt);
|
zxscreen::refresh(dt);
|
||||||
} else if (e.key.keysym.scancode==SDL_SCANCODE_F6) {
|
/*} else if (e.key.keysym.scancode==SDL_SCANCODE_F6) {
|
||||||
z80debug::history::gototop();
|
z80debug::history::gototop();
|
||||||
const uint8_t dt = z80::step();
|
const uint8_t dt = z80::step();
|
||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
zxscreen::refresh(dt);
|
zxscreen::refresh(dt);*/
|
||||||
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_UP) {
|
||||||
|
z80debug::cursorback();
|
||||||
|
z80debug::refresh();
|
||||||
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_DOWN) {
|
||||||
|
z80debug::cursorfwd();
|
||||||
|
z80debug::refresh();
|
||||||
} else if (e.key.keysym.scancode==SDL_SCANCODE_RETURN) {
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_RETURN) {
|
||||||
z80debug::executeConsole();
|
z80debug::executeConsole();
|
||||||
} else if (e.key.keysym.scancode==SDL_SCANCODE_BACKSPACE) {
|
} else if (e.key.keysym.scancode==SDL_SCANCODE_BACKSPACE) {
|
||||||
|
|||||||
1
ui.cpp
1
ui.cpp
@@ -39,6 +39,7 @@ namespace ui
|
|||||||
void setrenderer(SDL_Renderer *renderer)
|
void setrenderer(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
if (!surf) init();
|
if (!surf) init();
|
||||||
|
if (ren==renderer) return;
|
||||||
ren = renderer;
|
ren = renderer;
|
||||||
if (tex) SDL_DestroyTexture(tex);
|
if (tex) SDL_DestroyTexture(tex);
|
||||||
tex = SDL_CreateTextureFromSurface(ren, surf);
|
tex = SDL_CreateTextureFromSurface(ren, surf);
|
||||||
|
|||||||
12
valgrind-sup.txt
Normal file
12
valgrind-sup.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
ignore_unversioned_libs
|
||||||
|
Memcheck:Leak
|
||||||
|
...
|
||||||
|
obj:*/lib*/lib*.so
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ignore_versioned_libs
|
||||||
|
Memcheck:Leak
|
||||||
|
...
|
||||||
|
obj:*/lib*/lib*.so.*
|
||||||
|
}
|
||||||
2
valgrind.sh
Executable file
2
valgrind.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --suppressions=valgrind-sup.txt ./z80
|
||||||
1
z80.cpp
1
z80.cpp
@@ -1066,6 +1066,7 @@ namespace z80
|
|||||||
|
|
||||||
uint32_t step()
|
uint32_t step()
|
||||||
{
|
{
|
||||||
|
z80debug::setcursor(rPC);
|
||||||
current_opcode_address = rPC;
|
current_opcode_address = rPC;
|
||||||
t = 0;
|
t = 0;
|
||||||
const uint8_t opcode = READ_M1();
|
const uint8_t opcode = READ_M1();
|
||||||
|
|||||||
75
z80debug.cpp
75
z80debug.cpp
@@ -30,6 +30,8 @@ namespace z80debug
|
|||||||
|
|
||||||
uint8_t breakpoints[65536];
|
uint8_t breakpoints[65536];
|
||||||
|
|
||||||
|
uint16_t cursor = 0;
|
||||||
|
|
||||||
char temp[256];
|
char temp[256];
|
||||||
const char *tohex(int value, int numdigits)
|
const char *tohex(int value, int numdigits)
|
||||||
{
|
{
|
||||||
@@ -112,6 +114,26 @@ namespace z80debug
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printDissasemblerLine(const uint16_t address, const int line)
|
||||||
|
{
|
||||||
|
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_GRAY, COLOR_WHITE};
|
||||||
|
if (is_debugging && (address == z80::getPC())) {
|
||||||
|
for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW;
|
||||||
|
ui::printrect(0,line, 44,1, COLOR_BLUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakpoints[address]&9) ui::printtxt(0,line,"*", colors[0]);
|
||||||
|
ui::printtxt(1,line,tohex(address,4), colors[1]);
|
||||||
|
|
||||||
|
if (z80::getMemTag(address)==MEMTAG_INST) {
|
||||||
|
ui::printtxt(7,line, z80dis::getOpcode(address), colors[2]);
|
||||||
|
ui::printtxt(19,line, z80dis::getAsm(address), colors[3]);
|
||||||
|
} else {
|
||||||
|
ui::printtxt(7,line, tohex(z80::getMem()[address],2), COLOR_GRAY);
|
||||||
|
ui::printtxt(19,line, "?????????", COLOR_GRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void refresh()
|
void refresh()
|
||||||
{
|
{
|
||||||
ui::setrenderer(ren);
|
ui::setrenderer(ren);
|
||||||
@@ -125,49 +147,24 @@ namespace z80debug
|
|||||||
ui::printtxt(3,0, "ASSEMBLER:", COLOR_WHITE);
|
ui::printtxt(3,0, "ASSEMBLER:", COLOR_WHITE);
|
||||||
|
|
||||||
ui::setoffset(1, 1);
|
ui::setoffset(1, 1);
|
||||||
/*printtxt(1,0, "19C4:", COLOR_CYAN);
|
|
||||||
printtxt(7,0, "10 EE", COLOR_GRAY);
|
|
||||||
printtxt(19,0, "DJNZ 0x19B4", COLOR_WHITE);
|
|
||||||
printrect(0,1, 44,1, COLOR_BLUE);
|
|
||||||
printtxt(1,1, "19C6:", COLOR_YELLOW);
|
|
||||||
printtxt(7,1, "01 3C 00", COLOR_YELLOW);
|
|
||||||
printtxt(19,1, "LD BC,0x003C", COLOR_YELLOW);*/
|
|
||||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_GRAY, COLOR_WHITE};
|
|
||||||
|
|
||||||
uint16_t pc = z80::getPC();
|
|
||||||
uint8_t *memory = z80::getMem();
|
uint8_t *memory = z80::getMem();
|
||||||
if (is_debugging) {
|
|
||||||
for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW;
|
|
||||||
ui::printrect(0,8, 44,1, COLOR_BLUE);
|
|
||||||
}
|
|
||||||
if (breakpoints[pc]&9) ui::printtxt(0,8,"*", colors[0]);
|
|
||||||
ui::printtxt(1,8,tohex(pc,4), colors[1]);
|
|
||||||
ui::printtxt(7,8, z80dis::getOpcode(pc), colors[2]);
|
|
||||||
ui::printtxt(19,8, z80dis::getAsm(pc), colors[3]);
|
|
||||||
|
|
||||||
|
uint16_t pc = cursor; //z80::getPC();
|
||||||
uint16_t pos = pc;
|
uint16_t pos = pc;
|
||||||
|
|
||||||
|
printDissasemblerLine(pc, 8);
|
||||||
|
|
||||||
for (int i=9;i<18;++i) {
|
for (int i=9;i<18;++i) {
|
||||||
pos += z80dis::getOpcodeSize(pos);
|
pos += z80dis::getOpcodeSize(pos);
|
||||||
if (breakpoints[pos]&9) ui::printtxt(0,i,"*", COLOR_RED);
|
printDissasemblerLine(pos, i);
|
||||||
ui::printtxt(1,i,tohex(pos,4), COLOR_CYAN);
|
|
||||||
ui::printtxt(7,i, z80dis::getOpcode(pos), COLOR_GRAY);
|
|
||||||
ui::printtxt(19,i, z80dis::getAsm(pos), COLOR_WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = pc;
|
pos = pc;
|
||||||
for (int i=7;i>=0;--i) {
|
for (int i=7;i>=0;--i) {
|
||||||
pos = find_previous_opcode(pos);
|
pos = find_previous_opcode(pos);
|
||||||
if (breakpoints[pos]&9) ui::printtxt(0,i,"*", COLOR_RED);
|
printDissasemblerLine(pos, i);
|
||||||
ui::printtxt(1,i,tohex(pos,4), COLOR_CYAN);
|
|
||||||
if (z80::getMemTag(pos)==MEMTAG_INST) {
|
|
||||||
ui::printtxt(7,i, z80dis::getOpcode(pos), COLOR_GRAY);
|
|
||||||
ui::printtxt(19,i, z80dis::getAsm(pos), COLOR_WHITE);
|
|
||||||
} else {
|
|
||||||
ui::printtxt(7,i, tohex(z80::getMem()[pos],2), COLOR_GRAY);
|
|
||||||
ui::printtxt(19,i, "?????????", COLOR_GRAY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//for (int i=0;i<20;++i) printtxt(1,i,tohex(pc,4), COLOR_CYAN);
|
|
||||||
|
|
||||||
ui::setoffset(0, 0);
|
ui::setoffset(0, 0);
|
||||||
ui::box(46,0,25,8,COLOR_WHITE);
|
ui::box(46,0,25,8,COLOR_WHITE);
|
||||||
@@ -513,6 +510,22 @@ namespace z80debug
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setcursor(const uint16_t address)
|
||||||
|
{
|
||||||
|
cursor = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cursorfwd()
|
||||||
|
{
|
||||||
|
cursor += z80dis::getOpcodeSize(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cursorback()
|
||||||
|
{
|
||||||
|
cursor = find_previous_opcode(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace history
|
namespace history
|
||||||
{
|
{
|
||||||
void store()
|
void store()
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ namespace z80debug
|
|||||||
|
|
||||||
void loadngo(const char* filename, const char* addr);
|
void loadngo(const char* filename, const char* addr);
|
||||||
|
|
||||||
|
void setcursor(const uint16_t address);
|
||||||
|
void cursorfwd();
|
||||||
|
void cursorback();
|
||||||
|
|
||||||
namespace history
|
namespace history
|
||||||
{
|
{
|
||||||
void store();
|
void store();
|
||||||
|
|||||||
Reference in New Issue
Block a user