diff --git a/main.cpp b/main.cpp index 4c7f29f..c39d9e9 100644 --- a/main.cpp +++ b/main.cpp @@ -236,6 +236,7 @@ int main(int argc, char *argv[]) time = SDL_GetTicks(); z80analyze::refresh(); } + z80analyze::refresh(true); } else if (!z80debug::debugging() && z80debug::paused()) { diff --git a/z80analyze.cpp b/z80analyze.cpp index 2121f8a..dde37f9 100644 --- a/z80analyze.cpp +++ b/z80analyze.cpp @@ -12,6 +12,8 @@ namespace z80analyze SDL_Texture *tex = nullptr; SDL_Texture *uitex = nullptr; uint16_t address = 0; + int mx, my; + bool needs_refresh = true; void refreshTitle(); @@ -34,8 +36,11 @@ namespace z80analyze { if (e->motion.windowID == SDL_GetWindowID(win)) { SDL_ShowCursor(SDL_DISABLE); + mx = e->motion.x/2; + my = e->motion.y/2; + refreshTitle(); - refresh(); + needs_refresh=true; focus(); } } @@ -70,15 +75,17 @@ namespace z80analyze char tmp[10]; void refreshTitle() { - int mx, my; - SDL_GetMouseState(&mx, &my); - mx/=2; my/=2; - address = mx+my*256; - SDL_SetWindowTitle(win, SDL_itoa(address, tmp, 16)); + if (mx>=0 && my>=0 && mx<256 && my<256) { + address = mx+my*256; + SDL_SetWindowTitle(win, SDL_itoa(address, tmp, 16)); + } } - void refresh() + void refresh(const bool conditional) { if (!win) return; + if (conditional && !needs_refresh) return; + needs_refresh = false; + ui::setrenderer(ren, uitex); Uint32 *pixels; @@ -94,17 +101,16 @@ namespace z80analyze } pixels[z80::getPC()] = 0xFFFFFF; - int mx, my; - SDL_GetMouseState(&mx, &my); - mx/=2; my/=2; - pixels[(mx-2)+(my)*256] = 0x000000; - pixels[(mx-1)+(my)*256] = 0x000000; - pixels[(mx+1)+(my)*256] = 0x000000; - pixels[(mx+2)+(my)*256] = 0x000000; - pixels[(mx)+(my-1)*256] = 0x000000; - pixels[(mx)+(my-2)*256] = 0x000000; - pixels[(mx)+(my+1)*256] = 0x000000; - pixels[(mx)+(my+2)*256] = 0x000000; + if (mx>=0 && my>=0 && mx<256 && my<256) { + if (mx>2) pixels[(mx-2)+(my)*256] = 0x000000; + if (mx>1) pixels[(mx-1)+(my)*256] = 0x000000; + if (mx<255) pixels[(mx+1)+(my)*256] = 0x000000; + if (mx<254) pixels[(mx+2)+(my)*256] = 0x000000; + if (my>1) pixels[(mx)+(my-1)*256] = 0x000000; + if (my>2) pixels[(mx)+(my-2)*256] = 0x000000; + if (my<255) pixels[(mx)+(my+1)*256] = 0x000000; + if (my<254) pixels[(mx)+(my+2)*256] = 0x000000; + } SDL_UnlockTexture(tex); SDL_RenderCopy(ren, tex, NULL, NULL); diff --git a/z80analyze.h b/z80analyze.h index 301798f..d29424b 100644 --- a/z80analyze.h +++ b/z80analyze.h @@ -3,7 +3,7 @@ namespace z80analyze { void show(); - void refresh(); + void refresh(const bool conditional=false); void hide(); void focus(); } diff --git a/z80debug.cpp b/z80debug.cpp index 700a86e..b5de5a6 100644 --- a/z80debug.cpp +++ b/z80debug.cpp @@ -93,6 +93,9 @@ namespace z80debug bool eventHandler(SDL_Event *e) { + if (e->type == SDL_MOUSEMOTION) { + SDL_ShowCursor(SDL_ENABLE); + } if (z80debug::debugging()) { if (e->type==SDL_WINDOWEVENT) { if ((e->window.event==SDL_WINDOWEVENT_SHOWN) || (e->window.event==SDL_WINDOWEVENT_EXPOSED)) { @@ -164,7 +167,6 @@ namespace z80debug } } if (e->type == SDL_MOUSEMOTION) { - SDL_ShowCursor(SDL_ENABLE); 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 (resizing_type != RESIZING_MEMORY) SDL_SetCursor(cur_ns); diff --git a/zx_screen.cpp b/zx_screen.cpp index 57a5df1..a73e547 100644 --- a/zx_screen.cpp +++ b/zx_screen.cpp @@ -128,6 +128,9 @@ namespace zxscreen } } } + if (e->type == SDL_MOUSEMOTION) { + SDL_ShowCursor(true); + } return true; }