- [FIX] Ara cada renderer te la seua textura de font - [CHG] Continuar l'execució ja no tanca el debugger - [NEW] En la memòria no tocada actual o en avanç, se "adivina" quina es la instrucció - [FIX] Resetejar el spectrum borrava la ROM - [NEW] Anar avant o arrere en el temps mou el cursor del desensamblador
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
#include "z80analyze.h"
|
|
#include "z80.h"
|
|
#include <SDL2/SDL.h>
|
|
#include "ui_window.h"
|
|
#include "ui.h"
|
|
|
|
namespace z80analyze
|
|
{
|
|
SDL_Window *win = nullptr;
|
|
SDL_Renderer *ren = nullptr;
|
|
SDL_Texture *tex = nullptr;
|
|
SDL_Texture *uitex = 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);
|
|
uitex = ui::createtexture(ren);
|
|
|
|
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;
|
|
ui::setrenderer(ren, uitex);
|
|
|
|
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(uitex); uitex = nullptr;
|
|
SDL_DestroyTexture(tex); tex = nullptr;
|
|
SDL_DestroyRenderer(ren); ren = nullptr;
|
|
SDL_DestroyWindow(win); win = nullptr;
|
|
}
|
|
}
|