- [NEW] Symbols per a etiquetar adreces - [NEW] Mapa de memòria "tocada" - [NEW] En el mapa de memòria al passar el ratolí mostra l'adreça - [NEW] En el mapa de memòria es mostra en roig la posició del contador de programa - [NEW] Reemplaç en els opcodes de adreces conegudes per la seua etiqueta
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
#include "z80analyze.h"
|
|
#include "z80.h"
|
|
#include <SDL2/SDL.h>
|
|
#include "ui_window.h"
|
|
|
|
namespace z80analyze
|
|
{
|
|
SDL_Window *win = nullptr;
|
|
SDL_Renderer *ren = nullptr;
|
|
SDL_Texture *tex = nullptr;
|
|
|
|
void refreshTitle();
|
|
|
|
bool handleEvent(SDL_Event *e)
|
|
{
|
|
if (e->type == SDL_MOUSEBUTTONUP)
|
|
{
|
|
z80::clearMemTouched();
|
|
refresh();
|
|
}
|
|
if (e->type == SDL_MOUSEMOTION)
|
|
{
|
|
refreshTitle();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void show()
|
|
{
|
|
if (!win)
|
|
{
|
|
win = SDL_CreateWindow("Z80 Analyzer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 512, 512, SDL_WINDOW_SHOWN);
|
|
ren = SDL_CreateRenderer(win, -1, 0);
|
|
tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 256, 256);
|
|
ui::window::registerWindow(SDL_GetWindowID(win), handleEvent);
|
|
}
|
|
refresh();
|
|
}
|
|
|
|
char tmp[10];
|
|
void refreshTitle()
|
|
{
|
|
int mx, my;
|
|
SDL_GetMouseState(&mx, &my);
|
|
mx/=2; my/=2;
|
|
SDL_SetWindowTitle(win, SDL_itoa(mx+my*256, tmp, 16));
|
|
}
|
|
void refresh()
|
|
{
|
|
if (!win) return;
|
|
|
|
Uint32 *pixels;
|
|
int pitch;
|
|
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
|
for (int i=0; i<65536; ++i)
|
|
{
|
|
uint8_t tag = z80::getMemTouched(i);
|
|
pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : 0x00FF00;
|
|
}
|
|
pixels[z80::getPC()] = 0xFF0000;
|
|
SDL_UnlockTexture(tex);
|
|
SDL_RenderCopy(ren, tex, NULL, NULL);
|
|
SDL_RenderPresent(ren);
|
|
refreshTitle();
|
|
}
|
|
|
|
void hide()
|
|
{
|
|
ui::window::unregisterWindow(SDL_GetWindowID(win));
|
|
SDL_DestroyTexture(tex);
|
|
SDL_DestroyRenderer(ren);
|
|
SDL_DestroyWindow(win);
|
|
}
|
|
}
|