- [NEW] zxscreen
- [NEW] F8 para execució - [NEW] F5 continua execució - [NEW] ULA synch interrupt - [NEW] Break on read/write - [FIX] INC8 and DEC8 did wrong flags calculations - [FIX] INCMEM8 and DECMEM8 did no flags calculation at all - [NEW] Flags visualization - [DEL] run command replaced by cont command - [NEW] reset command - [NEW] Breakpoint delete command
This commit is contained in:
65
zxscreen.cpp
Normal file
65
zxscreen.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "zxscreen.h"
|
||||
#include "z80.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
namespace zxscreen
|
||||
{
|
||||
uint32_t palette[16] = {
|
||||
0x000000, 0x000080, 0x800000, 0x800080, 0x008000, 0x008080, 0x808000, 0x808080,
|
||||
0x000000, 0x0000FF, 0xFF0000, 0xFF00FF, 0x00FF00, 0x00FFFF, 0xFFFF00, 0xFFFFFF
|
||||
};
|
||||
SDL_Window *win = nullptr;
|
||||
SDL_Renderer *ren = nullptr;
|
||||
SDL_Texture *tex = nullptr;
|
||||
|
||||
void show()
|
||||
{
|
||||
if (win) return;
|
||||
win = SDL_CreateWindow("ZX Spectrum Screen", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 352, 288, SDL_WINDOW_RESIZABLE);
|
||||
ren = SDL_CreateRenderer(win, -1, 0);
|
||||
tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 352, 288);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh()
|
||||
{
|
||||
const uint8_t* memory = z80::getMem();
|
||||
//memory+=0x4000;
|
||||
|
||||
Uint32* pixels;
|
||||
int pitch;
|
||||
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
||||
|
||||
// Upper border
|
||||
for (int i=0; i<352*48;++i) *(pixels++) = palette[7];
|
||||
|
||||
// scanlines
|
||||
for (uint8_t y=0; y<192; ++y)
|
||||
{
|
||||
// Left border
|
||||
for (int j=0;j<48;++j) *(pixels++) = palette[7];
|
||||
|
||||
// Actual screen
|
||||
for (uint8_t x=0;x<32;++x)
|
||||
{
|
||||
uint16_t address = 0x4000 | (x&0x1f) | ((y&0x7)<<8) | ((y&0x38)<<2) | ((y&0xc0)<<5);
|
||||
uint8_t block = memory[address];
|
||||
for (int i=0;i<8;++i)
|
||||
{
|
||||
*(pixels++)=(block&0x80) ? palette[7] : palette[0];
|
||||
block = block<<1;
|
||||
}
|
||||
}
|
||||
|
||||
// Right border
|
||||
for (int j=0;j<48;++j) *(pixels++) = palette[7];
|
||||
}
|
||||
|
||||
// Lower border
|
||||
for (int i=0; i<352*48;++i) *(pixels++)=palette[7];
|
||||
|
||||
SDL_UnlockTexture(tex);
|
||||
SDL_RenderCopy(ren, tex, NULL, NULL);
|
||||
SDL_RenderPresent(ren);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user