- [NEW] La posició del cursor se marca amb un requadre blau (no relleno) en el desensamblador
- [NEW] setcursor corregeix l'adreça si no coincideix amb una instrucció - [FIX] Corregits els opcodes FD34 i FD35 - [NEW] Ara en el analitzador es borra o es fixa la memòria amb DELETE i RETURN - [NEW] Fent click en un pixel del analitzador du a la posició de memòria que toca en el desensamblador - [NEW] ui::printvoidrect() - [NEW] la finestra del analitzador pilla el foco nomes amb pasar per damunt - [NEW] Fent click en una linea del desensamblador fica o lleva un breakpoint en eixa adreça - [FIX] les accions en el analitzador actualitzen la finestra del debugger - [FIX] El cursor del analitzador nomes es deu moure al estar damunt de al finestra del analitzador - [FIX] El desensamblador, quan el tag de memoria era MIXED no reconixia part de la instrucció - [FIX] El desensamblador usava el color incorrecte per a codi amb el tag REPEAT
This commit is contained in:
7
ui.cpp
7
ui.cpp
@@ -65,6 +65,13 @@ namespace ui
|
||||
SDL_RenderFillRect(ren, &rect);
|
||||
}
|
||||
|
||||
void printvoidrect(int x, int y, int w, int h, uint8_t color)
|
||||
{
|
||||
SDL_Rect rect {(offset_x+x)*CHR_W, (offset_y+y)*CHR_H, w*CHR_W, h*CHR_H};
|
||||
SDL_SetRenderDrawColor(ren, colors[color][0], colors[color][1], colors[color][2], 255);
|
||||
SDL_RenderDrawRect(ren, &rect);
|
||||
}
|
||||
|
||||
void printchar(int x, int y, char chr, uint8_t color)
|
||||
{
|
||||
if (color != 255) SDL_SetRenderDrawColor(ren, colors[color][0], colors[color][1], colors[color][2], 255);
|
||||
|
||||
1
ui.h
1
ui.h
@@ -29,6 +29,7 @@ namespace ui
|
||||
|
||||
void box(int x, int y, int w, int h, uint8_t color);
|
||||
void printrect(int x, int y, int w, int h, uint8_t color);
|
||||
void printvoidrect(int x, int y, int w, int h, uint8_t color);
|
||||
void printchar(int x, int y, char chr, uint8_t color=255);
|
||||
void printtxt(int x, int y, const char *text, uint8_t color);
|
||||
|
||||
|
||||
16
z80.cpp
16
z80.cpp
@@ -153,15 +153,15 @@ namespace z80
|
||||
if (memtag[addr] != MEMTAG_IGNORE) {
|
||||
if (!code) {
|
||||
if ( memtag[addr] == MEMTAG_INST ) {
|
||||
printf("WARNING! READING DATA FROM CODE!!! $%4X\n", addr);
|
||||
z80debug::stop();
|
||||
//printf("WARNING! READING DATA FROM CODE!!! $%4X\n", addr);
|
||||
//z80debug::stop();
|
||||
} else {
|
||||
memtag[addr] = MEMTAG_DATA;
|
||||
}
|
||||
} else {
|
||||
if ( (reading_m1) && (memtag[addr] == MEMTAG_DATA) ) {
|
||||
printf("WARNING! EXECUTING DATA AS CODE!!! $%4X\n", addr);
|
||||
z80debug::stop();
|
||||
//printf("WARNING! EXECUTING DATA AS CODE!!! $%4X\n", addr);
|
||||
//z80debug::stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,8 +210,8 @@ namespace z80
|
||||
z80debug::setmemmodified(addr);
|
||||
if ( (memtag[addr] != MEMTAG_IGNORE) && (memtag[addr] != MEMTAG_MIXED) ) {
|
||||
if (memtag[addr]==MEMTAG_INST) {
|
||||
printf("WARNING! WRITING DATA OVER CODE!!! $%4X\n", addr);
|
||||
z80debug::stop();
|
||||
//printf("WARNING! WRITING DATA OVER CODE!!! $%4X\n", addr);
|
||||
//z80debug::stop();
|
||||
} else if (memtag[addr] == MEMTAG_CODE) {
|
||||
memtag[addr] = MEMTAG_MIXED;
|
||||
} else {
|
||||
@@ -2339,8 +2339,8 @@ namespace z80
|
||||
case 0x31: INVALID(opcode); break;
|
||||
case 0x32: INVALID(opcode); break;
|
||||
case 0x33: INVALID(opcode); break;
|
||||
case 0x34: INCMEM8(rIY+READ_MEM_8());t+=2; break;
|
||||
case 0x35: DECMEM8(rIY+READ_MEM_8());t+=2; break;
|
||||
case 0x34: d=READ_MEM_8(); INCMEM8(rIY+d);t+=2; break;
|
||||
case 0x35: d=READ_MEM_8(); DECMEM8(rIY+d);t+=2; break;
|
||||
case 0x36: d=READ_MEM_8(); WRITE_MEM_8(rIY+d, READ_MEM_8()); t+=2; break;
|
||||
case 0x37: INVALID(opcode); break;
|
||||
case 0x38: INVALID(opcode); break;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "z80analyze.h"
|
||||
#include "z80.h"
|
||||
#include "z80debug.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include "ui_window.h"
|
||||
#include "ui.h"
|
||||
@@ -10,6 +11,7 @@ namespace z80analyze
|
||||
SDL_Renderer *ren = nullptr;
|
||||
SDL_Texture *tex = nullptr;
|
||||
SDL_Texture *uitex = nullptr;
|
||||
uint16_t address = 0;
|
||||
|
||||
void refreshTitle();
|
||||
|
||||
@@ -17,18 +19,36 @@ namespace z80analyze
|
||||
{
|
||||
if (e->type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
if (e->button.button == 1)
|
||||
//z80::clearMemTouched();
|
||||
z80::clearMemTag();
|
||||
//if (z80::getMemTag(address)!=MEMTAG_INST) address = find_previous_opcode(address);
|
||||
z80debug::setcursor(address);
|
||||
z80debug::refresh();
|
||||
|
||||
/*if (e->button.button == 1)
|
||||
z80::clearMemTouched();
|
||||
//z80::clearMemTag();
|
||||
else
|
||||
z80::fixMemTouched();
|
||||
z80::fixMemTouched();*/
|
||||
refresh();
|
||||
}
|
||||
if (e->type == SDL_MOUSEMOTION)
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
refreshTitle();
|
||||
refresh();
|
||||
if (e->motion.windowID == SDL_GetWindowID(win)) {
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
refreshTitle();
|
||||
refresh();
|
||||
focus();
|
||||
}
|
||||
}
|
||||
if (e->type == SDL_KEYDOWN) {
|
||||
if (e->key.keysym.scancode == SDL_SCANCODE_RETURN) {
|
||||
z80::fixMemTouched();
|
||||
refresh();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode == SDL_SCANCODE_BACKSPACE) {
|
||||
z80::clearMemTouched();
|
||||
refresh();
|
||||
z80debug::refresh();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -53,7 +73,8 @@ namespace z80analyze
|
||||
int mx, my;
|
||||
SDL_GetMouseState(&mx, &my);
|
||||
mx/=2; my/=2;
|
||||
SDL_SetWindowTitle(win, SDL_itoa(mx+my*256, tmp, 16));
|
||||
address = mx+my*256;
|
||||
SDL_SetWindowTitle(win, SDL_itoa(address, tmp, 16));
|
||||
}
|
||||
void refresh()
|
||||
{
|
||||
@@ -65,11 +86,11 @@ namespace z80analyze
|
||||
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
||||
for (int i=0; i<65536; ++i)
|
||||
{
|
||||
uint8_t tag = z80::getMemTag(i);
|
||||
pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_MIXED ? 0xFF00FF : 0x00FF00;
|
||||
//uint8_t tag = z80::getMemTag(i);
|
||||
//pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_MIXED ? 0xFF00FF : 0x00FF00;
|
||||
|
||||
//uint8_t tag = z80::getMemTouched(i);
|
||||
//pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_REPEAT ? 0xFF0000 : 0x00FF00;
|
||||
uint8_t tag = z80::getMemTouched(i);
|
||||
pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_REPEAT ? 0xFF0000 : 0x00FF00;
|
||||
}
|
||||
pixels[z80::getPC()] = 0xFFFFFF;
|
||||
|
||||
@@ -99,4 +120,13 @@ namespace z80analyze
|
||||
SDL_DestroyRenderer(ren); ren = nullptr;
|
||||
SDL_DestroyWindow(win); win = nullptr;
|
||||
}
|
||||
|
||||
void focus()
|
||||
{
|
||||
if (win) {
|
||||
SDL_RaiseWindow(win);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ namespace z80analyze
|
||||
void show();
|
||||
void refresh();
|
||||
void hide();
|
||||
void focus();
|
||||
}
|
||||
|
||||
29
z80debug.cpp
29
z80debug.cpp
@@ -64,6 +64,8 @@ namespace z80debug
|
||||
|
||||
uint8_t use[7][256];
|
||||
|
||||
uint16_t line_address[256];
|
||||
|
||||
char temp[256];
|
||||
const char *tohex(int value, int numdigits)
|
||||
{
|
||||
@@ -183,6 +185,15 @@ namespace z80debug
|
||||
}
|
||||
}
|
||||
if (e->type == SDL_MOUSEBUTTONDOWN) {
|
||||
if ( (e->button.x<midx*CHR_W) && (e->button.y<(mem_y-1)*CHR_H) && (e->button.y>CHR_H) ) {
|
||||
const uint16_t address = ((e->button.y)/CHR_H)-1;
|
||||
if (breakpoints[line_address[address]]==0)
|
||||
breakpoints[line_address[address]]=1;
|
||||
else
|
||||
breakpoints[line_address[address]]=0;
|
||||
refresh();
|
||||
}
|
||||
|
||||
if (!resizing && resizing_type != RESIZING_NONE) {
|
||||
resizing = true;
|
||||
}
|
||||
@@ -278,7 +289,7 @@ namespace z80debug
|
||||
uint16_t find_previous_opcode(uint16_t pc)
|
||||
{
|
||||
pc--;
|
||||
if (z80::getMemTag(pc)!=MEMTAG_CODE && z80::getMemTag(pc)!=MEMTAG_INST) return pc;
|
||||
if (z80::getMemTag(pc)!=MEMTAG_CODE && z80::getMemTag(pc)!=MEMTAG_MIXED && z80::getMemTag(pc)!=MEMTAG_INST) return pc;
|
||||
|
||||
while (z80::getMemTag(pc)!=MEMTAG_INST) pc--;
|
||||
|
||||
@@ -299,8 +310,8 @@ namespace z80debug
|
||||
|
||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||
{
|
||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_GRAY, COLOR_WHITE};
|
||||
if (z80::getMemTouched(address)!=MEMTAG_INST) colors[3]=COLOR_GRAY;
|
||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_WHITE, COLOR_WHITE};
|
||||
if (z80::getMemTouched(address)!=MEMTAG_INST && z80::getMemTouched(address)!=MEMTAG_REPEAT) colors[3]=COLOR_GRAY;
|
||||
if (z80::getMemTouched(address)==MEMTAG_NONE) colors[1]=COLOR_GRAY;
|
||||
|
||||
if (is_debugging && (address == z80::getPC())) {
|
||||
@@ -325,7 +336,8 @@ namespace z80debug
|
||||
ui::printtxt(19,line, z80dis::getOpcode(address), colors[2]);
|
||||
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]);
|
||||
} else {
|
||||
ui::printtxt(19,line, tohex(z80::getMem()[address],2), COLOR_GRAY);
|
||||
ui::printrect(19,line,2,1,COLOR_GRAY);
|
||||
ui::printtxt(19,line, tohex(z80::getMem()[address],2), COLOR_WHITE);
|
||||
ui::printtxt(31,line, "?????????", COLOR_GRAY);
|
||||
}
|
||||
}
|
||||
@@ -351,16 +363,20 @@ namespace z80debug
|
||||
uint16_t pc = cursor; //z80::getPC();
|
||||
uint16_t pos = pc;
|
||||
int num_lines = mem_y-2;
|
||||
line_address[(num_lines/2)-1] = pos;
|
||||
ui::printvoidrect(0,(num_lines/2)-1, midx-2,1, COLOR_BLUE);
|
||||
printDissasemblerLine(pc, (num_lines/2)-1, true);
|
||||
|
||||
for (int i=num_lines/2;i<num_lines;++i) {
|
||||
pos += z80dis::getOpcodeSize(pos);
|
||||
line_address[i] = pos;
|
||||
printDissasemblerLine(pos, i, true);
|
||||
}
|
||||
|
||||
pos = pc;
|
||||
for (int i=(num_lines/2)-2;i>=0;--i) {
|
||||
pos = find_previous_opcode(pos);
|
||||
line_address[i] = pos;
|
||||
printDissasemblerLine(pos, i);
|
||||
}
|
||||
|
||||
@@ -852,7 +868,10 @@ namespace z80debug
|
||||
|
||||
void setcursor(const uint16_t address)
|
||||
{
|
||||
cursor = address;
|
||||
if (z80::getMemTag(address)!=MEMTAG_INST)
|
||||
cursor = find_previous_opcode(address);
|
||||
else
|
||||
cursor = address;
|
||||
}
|
||||
|
||||
void cursorfwd()
|
||||
|
||||
Reference in New Issue
Block a user