#include "zx_128pageviewer.h" #include "z80.h" #include "z80mem.h" void zx_128pageviewer::show() { if (!win) { win = SDL_CreateWindow("ZX128 Page Viewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 128, SDL_WINDOW_SHOWN); ren = SDL_CreateRenderer(win, -1, 0); tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 1024, 128); //ui::window::registerWindow(SDL_GetWindowID(win), handleEvent); } refresh(); } void zx_128pageviewer::refresh() { if (!win) return; Uint32 *pixels; int pitch; const uint8_t *tags = z80mem::get()->rawTagPtr(0); SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch); for (int i=0; i<131072; ++i) { const int x = (i&0x7f) + (((i>>14)&0x07)*128); const int y = (i>>7)&0x7f; uint32_t none_color = 0x808080; //i<0x4000 ? 0x101010 : i<0x5800 ? 0x202020 : i<0x5b00 ? 0x404040 : 0x808080; uint8_t tag = tags[i]; pixels[x+y*1024] = !(tag & MEMTAG_TOUCHED) ? none_color : (tag & MEMTAG_TINST) ? 0x00FF00 : (tag & MEMTAG_TREPEAT) ? 0xFF0000 : 0x0000FF; } //pixels[z80::getPC()] = 0xFFFFFF; SDL_UnlockTexture(tex); SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderPresent(ren); } void zx_128pageviewer::hide() { //ui::window::unregisterWindow(SDL_GetWindowID(win)); SDL_DestroyTexture(tex); tex = nullptr; SDL_DestroyRenderer(ren); ren = nullptr; SDL_DestroyWindow(win); win = nullptr; } void zx_128pageviewer::focus() { if (win) { SDL_RaiseWindow(win); refresh(); } } bool zx_128pageviewer::handleEvent(SDL_Event *e) { return true; }