- [CHG] Mòdul zxscreen renombrat a zx_screen
- [NEW] Les coses de la ULA ara estàn en el modul zx_ula - [NEW] zx_screen ja agafa el color del borde de la ULA
This commit is contained in:
15
main.cpp
15
main.cpp
@@ -3,23 +3,14 @@
|
|||||||
#include "z80.h"
|
#include "z80.h"
|
||||||
#include "z80dis.h"
|
#include "z80dis.h"
|
||||||
#include "z80debug.h"
|
#include "z80debug.h"
|
||||||
#include "zxscreen.h"
|
#include "zx_ula.h"
|
||||||
|
#include "zx_screen.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
uint8_t memory[65536];
|
uint8_t memory[65536];
|
||||||
uint32_t t = 0;
|
uint32_t t = 0;
|
||||||
|
|
||||||
int ula_in()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ula_out(int val)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE* f = fopen("48.rom", "rb");
|
FILE* f = fopen("48.rom", "rb");
|
||||||
@@ -27,7 +18,7 @@ int main(int argc, char *argv[])
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
z80::reset(memory);
|
z80::reset(memory);
|
||||||
z80::connect_port(0xfe, ula_in, ula_out);
|
z80::connect_port(0xfe, zx_ula::port_in, zx_ula::port_out);
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_EVERYTHING);
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
z80debug::show();
|
z80debug::show();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "zxscreen.h"
|
#include "zx_screen.h"
|
||||||
#include "z80.h"
|
#include "z80.h"
|
||||||
|
#include "zx_ula.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
namespace zxscreen
|
namespace zxscreen
|
||||||
@@ -24,6 +25,7 @@ namespace zxscreen
|
|||||||
void refresh()
|
void refresh()
|
||||||
{
|
{
|
||||||
const uint8_t* memory = z80::getMem();
|
const uint8_t* memory = z80::getMem();
|
||||||
|
const uint8_t border_color = zx_ula::get_border_color();
|
||||||
//memory+=0x4000;
|
//memory+=0x4000;
|
||||||
|
|
||||||
Uint32* pixels;
|
Uint32* pixels;
|
||||||
@@ -31,13 +33,13 @@ namespace zxscreen
|
|||||||
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
||||||
|
|
||||||
// Upper border
|
// Upper border
|
||||||
for (int i=0; i<352*48;++i) *(pixels++) = palette[7];
|
for (int i=0; i<352*48;++i) *(pixels++) = palette[border_color];
|
||||||
|
|
||||||
// scanlines
|
// scanlines
|
||||||
for (uint8_t y=0; y<192; ++y)
|
for (uint8_t y=0; y<192; ++y)
|
||||||
{
|
{
|
||||||
// Left border
|
// Left border
|
||||||
for (int j=0;j<48;++j) *(pixels++) = palette[7];
|
for (int j=0;j<48;++j) *(pixels++) = palette[border_color];
|
||||||
|
|
||||||
// Actual screen
|
// Actual screen
|
||||||
for (uint8_t x=0;x<32;++x)
|
for (uint8_t x=0;x<32;++x)
|
||||||
@@ -54,11 +56,11 @@ namespace zxscreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Right border
|
// Right border
|
||||||
for (int j=0;j<48;++j) *(pixels++) = palette[7];
|
for (int j=0;j<48;++j) *(pixels++) = palette[border_color];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lower border
|
// Lower border
|
||||||
for (int i=0; i<352*48;++i) *(pixels++)=palette[7];
|
for (int i=0; i<352*48;++i) *(pixels++)=palette[border_color];
|
||||||
|
|
||||||
SDL_UnlockTexture(tex);
|
SDL_UnlockTexture(tex);
|
||||||
SDL_RenderCopy(ren, tex, NULL, NULL);
|
SDL_RenderCopy(ren, tex, NULL, NULL);
|
||||||
22
zx_ula.cpp
Normal file
22
zx_ula.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "zx_ula.h"
|
||||||
|
|
||||||
|
namespace zx_ula
|
||||||
|
{
|
||||||
|
static uint8_t border_color = 0;
|
||||||
|
static uint8_t ear = 0;
|
||||||
|
static uint8_t mic = 0;
|
||||||
|
|
||||||
|
int port_in()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void port_out(int val)
|
||||||
|
{
|
||||||
|
border_color = val & 0x7;
|
||||||
|
mic = (val>>3)&0x1;
|
||||||
|
ear = (val>>4)&0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t get_border_color() { return border_color; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user