- [NEW] Treballant en modularitzar la memòria, per a començar a implementar soport per als demes Spectrums

This commit is contained in:
2024-12-19 17:36:22 +01:00
parent da4c692283
commit dbd80694aa
10 changed files with 263 additions and 135 deletions

View File

@@ -1,5 +1,6 @@
#include "zx_screen.h"
#include "z80.h"
#include "z80mem.h"
#include "zx_ula.h"
#include <SDL2/SDL.h>
#include "zx_tape.h"
@@ -67,8 +68,8 @@ namespace zxscreen
// Actual screen
for (uint8_t x=0;x<32;++x)
{
uint16_t color = 0x5800 + x + (y>>3)*32;
uint16_t address = 0x4000 | (x&0x1f) | ((y&0x7)<<8) | ((y&0x38)<<2) | ((y&0xc0)<<5);
uint16_t color = /*0x5800 +*/ x + (y>>3)*32;
uint16_t address = /*0x4000 |*/ (x&0x1f) | ((y&0x7)<<8) | ((y&0x38)<<2) | ((y&0xc0)<<5);
for (int i=7;i>0;i-=2)
{
*(ptr_pixel++) = (address & 0x1FFF) | (i << 13);
@@ -188,7 +189,7 @@ namespace zxscreen
void refresh(const uint32_t dt, const bool full)
{
const uint8_t* memory = z80::getMem();
//const uint8_t* memory = z80mem::getRawPointer(0x4000);
const uint8_t border_color = zx_ula::get_border_color();
for (int i=0;i<dt;++i)
@@ -199,13 +200,13 @@ namespace zxscreen
*(ptr_pixel++) = border_color;
*(ptr_pixel++) = border_color;
} else {
uint8_t color = memory[color_addr[t_screen]];
uint8_t color = z80mem::get()->readMem(0x5800+color_addr[t_screen]);
uint8_t c1 = color&0x7, c2 = (color>>3)&0x7;
if ((color&0x80) && flash) { c1=c2; c2=color&0x7; }
if ((color&0x40)) { c1 |= 0x8; c2 |= 0x8; }
uint16_t address = (0x4000) | (pixel_addr[t_screen]&0x1FFF);
uint16_t address = /*(0x4000) |*/ (pixel_addr[t_screen]&0x1FFF);
uint8_t mask = 1 << (pixel_addr[t_screen]>>13);
uint8_t block = memory[address];
uint8_t block = z80mem::get()->readMem(0x4000 + address);
*(ptr_pixel++)=(block&mask) ? c1 : c2;
mask>>=1;
*(ptr_pixel++)=(block&mask) ? c1 : c2;