- [FIX] El cursor es mostra sempre damunt de les finestres zx_screen i z80debug

- [FIX] el dibuixat del crosshair en la finestra z80analyze causaba potencialment una escritura fora de rang
- [NEW] Refresc de la finestra z80analyze millorat
This commit is contained in:
2024-12-17 12:03:04 +01:00
parent 620cd8d88c
commit dfcc0a26fe
5 changed files with 32 additions and 20 deletions

View File

@@ -236,6 +236,7 @@ int main(int argc, char *argv[])
time = SDL_GetTicks(); time = SDL_GetTicks();
z80analyze::refresh(); z80analyze::refresh();
} }
z80analyze::refresh(true);
} else if (!z80debug::debugging() && z80debug::paused()) { } else if (!z80debug::debugging() && z80debug::paused()) {

View File

@@ -12,6 +12,8 @@ namespace z80analyze
SDL_Texture *tex = nullptr; SDL_Texture *tex = nullptr;
SDL_Texture *uitex = nullptr; SDL_Texture *uitex = nullptr;
uint16_t address = 0; uint16_t address = 0;
int mx, my;
bool needs_refresh = true;
void refreshTitle(); void refreshTitle();
@@ -34,8 +36,11 @@ namespace z80analyze
{ {
if (e->motion.windowID == SDL_GetWindowID(win)) { if (e->motion.windowID == SDL_GetWindowID(win)) {
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
mx = e->motion.x/2;
my = e->motion.y/2;
refreshTitle(); refreshTitle();
refresh(); needs_refresh=true;
focus(); focus();
} }
} }
@@ -70,15 +75,17 @@ namespace z80analyze
char tmp[10]; char tmp[10];
void refreshTitle() void refreshTitle()
{ {
int mx, my; if (mx>=0 && my>=0 && mx<256 && my<256) {
SDL_GetMouseState(&mx, &my); address = mx+my*256;
mx/=2; my/=2; SDL_SetWindowTitle(win, SDL_itoa(address, tmp, 16));
address = mx+my*256; }
SDL_SetWindowTitle(win, SDL_itoa(address, tmp, 16));
} }
void refresh() void refresh(const bool conditional)
{ {
if (!win) return; if (!win) return;
if (conditional && !needs_refresh) return;
needs_refresh = false;
ui::setrenderer(ren, uitex); ui::setrenderer(ren, uitex);
Uint32 *pixels; Uint32 *pixels;
@@ -94,17 +101,16 @@ namespace z80analyze
} }
pixels[z80::getPC()] = 0xFFFFFF; pixels[z80::getPC()] = 0xFFFFFF;
int mx, my; if (mx>=0 && my>=0 && mx<256 && my<256) {
SDL_GetMouseState(&mx, &my); if (mx>2) pixels[(mx-2)+(my)*256] = 0x000000;
mx/=2; my/=2; if (mx>1) pixels[(mx-1)+(my)*256] = 0x000000;
pixels[(mx-2)+(my)*256] = 0x000000; if (mx<255) pixels[(mx+1)+(my)*256] = 0x000000;
pixels[(mx-1)+(my)*256] = 0x000000; if (mx<254) pixels[(mx+2)+(my)*256] = 0x000000;
pixels[(mx+1)+(my)*256] = 0x000000; if (my>1) pixels[(mx)+(my-1)*256] = 0x000000;
pixels[(mx+2)+(my)*256] = 0x000000; if (my>2) pixels[(mx)+(my-2)*256] = 0x000000;
pixels[(mx)+(my-1)*256] = 0x000000; if (my<255) pixels[(mx)+(my+1)*256] = 0x000000;
pixels[(mx)+(my-2)*256] = 0x000000; if (my<254) pixels[(mx)+(my+2)*256] = 0x000000;
pixels[(mx)+(my+1)*256] = 0x000000; }
pixels[(mx)+(my+2)*256] = 0x000000;
SDL_UnlockTexture(tex); SDL_UnlockTexture(tex);
SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderCopy(ren, tex, NULL, NULL);

View File

@@ -3,7 +3,7 @@
namespace z80analyze namespace z80analyze
{ {
void show(); void show();
void refresh(); void refresh(const bool conditional=false);
void hide(); void hide();
void focus(); void focus();
} }

View File

@@ -93,6 +93,9 @@ namespace z80debug
bool eventHandler(SDL_Event *e) bool eventHandler(SDL_Event *e)
{ {
if (e->type == SDL_MOUSEMOTION) {
SDL_ShowCursor(SDL_ENABLE);
}
if (z80debug::debugging()) { if (z80debug::debugging()) {
if (e->type==SDL_WINDOWEVENT) { if (e->type==SDL_WINDOWEVENT) {
if ((e->window.event==SDL_WINDOWEVENT_SHOWN) || (e->window.event==SDL_WINDOWEVENT_EXPOSED)) { if ((e->window.event==SDL_WINDOWEVENT_SHOWN) || (e->window.event==SDL_WINDOWEVENT_EXPOSED)) {
@@ -164,7 +167,6 @@ namespace z80debug
} }
} }
if (e->type == SDL_MOUSEMOTION) { if (e->type == SDL_MOUSEMOTION) {
SDL_ShowCursor(SDL_ENABLE);
if (!resizing) { if (!resizing) {
if ( (e->motion.y > (mem_y*CHR_H)-8) && (e->motion.y < (mem_y*CHR_H)+8) && ( e->motion.x < midx*CHR_W ) ) { if ( (e->motion.y > (mem_y*CHR_H)-8) && (e->motion.y < (mem_y*CHR_H)+8) && ( e->motion.x < midx*CHR_W ) ) {
if (resizing_type != RESIZING_MEMORY) SDL_SetCursor(cur_ns); if (resizing_type != RESIZING_MEMORY) SDL_SetCursor(cur_ns);

View File

@@ -128,6 +128,9 @@ namespace zxscreen
} }
} }
} }
if (e->type == SDL_MOUSEMOTION) {
SDL_ShowCursor(true);
}
return true; return true;
} }