- [NEW] [ui] incoffset() i panel()
- [NEW] mòdul ay_viewer - [NEW] [ay-3-8912] afegits mètodes de debug - [FIX] [ay-3-8912]Arreglats uns quants tipus de dades - [FIX] [ay-3-8912]Arreglat el càlcul de la frequència (en realitat amplitud) dels tonos - [FIX] [ay-3-8912] Arreglat el algoritme de càlcul del roido
This commit is contained in:
88
ay_viewer.cpp
Normal file
88
ay_viewer.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "ay_viewer.h"
|
||||
#include "ui.h"
|
||||
#include "ay-3-8912.h"
|
||||
|
||||
void ay_viewer::show()
|
||||
{
|
||||
if (!win)
|
||||
{
|
||||
win = SDL_CreateWindow("AY-3-8912 Viewer", 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, 512, 512);
|
||||
uitex = ui::createtexture(ren);
|
||||
|
||||
//ui::window::registerWindow(SDL_GetWindowID(win), handleEvent);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
void ay_viewer::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::getMemTag(i);
|
||||
//pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_MIXED ? 0xFF00FF : 0x00FF00;
|
||||
uint32_t none_color = i<0x4000 ? 0x101010 : i<0x5800 ? 0x202020 : i<0x5b00 ? 0x404040 : 0x808080;
|
||||
uint8_t tag = mem::getTag(i);
|
||||
pixels[i] = !(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_SetRenderDrawColor(ren, 30, 30, 30, 255);
|
||||
SDL_RenderClear(ren);
|
||||
|
||||
char temp[256];
|
||||
|
||||
ui::panel(0,0,9,18,"REG:");
|
||||
|
||||
for (int i=0; i<16; ++i) {
|
||||
sprintf(temp, "%2u: %3u", i, audio::debug::get_register(i));
|
||||
ui::printtxt(0,i,temp, COLOR_WHITE);
|
||||
}
|
||||
|
||||
ui::panel(9,0,18,18,"CHANNEL A:");
|
||||
sprintf(temp, "TONE FREQ: %4u", audio::debug::get_channel_a_tone_freq());
|
||||
ui::printtxt(0,0,temp, COLOR_WHITE);
|
||||
sprintf(temp, "COUNTER: %4u", audio::debug::get_channel_a_tone_freq_counter());
|
||||
ui::printtxt(0,1,temp, COLOR_WHITE);
|
||||
sprintf(temp, "TONE LEVL: %1u", audio::debug::get_channel_a_tone_level());
|
||||
ui::printtxt(0,2,temp, COLOR_WHITE);
|
||||
sprintf(temp, "LEVEL: %1u", audio::debug::get_channel_a_level());
|
||||
ui::printtxt(0,3,temp, COLOR_WHITE);
|
||||
|
||||
|
||||
SDL_RenderPresent(ren);
|
||||
}
|
||||
|
||||
void ay_viewer::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;
|
||||
}
|
||||
|
||||
void ay_viewer::focus()
|
||||
{
|
||||
if (win) {
|
||||
SDL_RaiseWindow(win);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
bool ay_viewer::handleEvent(SDL_Event *e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user