- [FIX] Solventats els bugs de la memòria modular amb classes

This commit is contained in:
2024-12-19 20:57:28 +01:00
parent dbd80694aa
commit 68843ab6b3
6 changed files with 31 additions and 23 deletions

View File

@@ -1153,8 +1153,9 @@ namespace z80
const uint8_t opcode = READ_M1();
uint8_t tag = z80mem::get()->getTag(current_opcode_address);
if ( !(tag & MEMTAG_IGNORE) ) tag = tag | MEMTAG_INST;
z80mem::get()->setTag(current_opcode_address, tag | !(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST);
if ( !(tag & MEMTAG_IGNORE) )
tag = tag | MEMTAG_INST;
z80mem::get()->setTag(current_opcode_address, tag | (!(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST) );
uint16_t tmp;

View File

@@ -1041,6 +1041,7 @@ namespace z80debug
void setcursor(const uint16_t address)
{
//if (!debugging()) return;
if ( !(z80mem::get()->getTag(address) & MEMTAG_INST) )
cursor = find_previous_opcode(address);
else

3
z80mem.cpp Normal file
View File

@@ -0,0 +1,3 @@
#include "z80mem.h"
z80mem* z80mem::singleton= nullptr;

View File

@@ -21,19 +21,19 @@ class z80mem
public:
static z80mem *get() { return singleton; };
virtual uint8_t readMem(uint16_t address);
virtual void writeMem(uint16_t address, uint8_t value);
virtual uint8_t readMem(uint16_t address) = 0;
virtual void writeMem(uint16_t address, uint8_t value) = 0;
virtual void loadMem(uint16_t address, uint16_t len, uint8_t *buffer);
virtual void loadMem(uint16_t address, uint16_t len, uint8_t *buffer) = 0;
virtual uint8_t getTag(uint16_t address);
virtual void setTag(uint16_t address, uint8_t value);
virtual void reset();
virtual uint8_t getTag(uint16_t address) = 0;
virtual void setTag(uint16_t address, uint8_t value) = 0;
virtual void reset() = 0;
virtual void saveState(FILE* f);
virtual void loadState(FILE* f);
virtual void saveState(FILE* f) = 0;
virtual void loadState(FILE* f) = 0;
virtual uint32_t getSize();
virtual uint32_t getSize() = 0;
protected:

View File

@@ -23,7 +23,7 @@ class zx_48mem : public z80mem
protected:
static uint8_t memory[65536];
static uint8_t tags[65536];
uint8_t memory[65536];
uint8_t tags[65536];
};

View File

@@ -38,6 +38,9 @@ namespace zxscreen
uint8_t zx_pixels[352*296];
uint8_t *ptr_pixel = zx_pixels;
#define SCREEN_SYNC 0xFFFF
#define SCREEN_BORDER 0xFFFE
void create_tables()
{
uint32_t count = 0;
@@ -46,24 +49,24 @@ namespace zxscreen
uint16_t *ptr_color = color_addr;
// vsync
for (int i=0; i<224*16;++i) { *(ptr_pixel++) = 0; *(ptr_color++) = 0; }
for (int i=0; i<224*16;++i) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_SYNC; }
// Upper border
for (int i=0; i<48;++i) {
// hsync
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 0; }
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_SYNC; }
//border
for (int j=0;j<176;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 1; count+=2; }
for (int j=0;j<176;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_BORDER; count+=2; }
}
// scanlines
for (uint8_t y=0; y<192; ++y)
{
// hsync
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 0; }
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_SYNC; }
// Left border
for (int j=0;j<24;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 1; count+=2; }
for (int j=0;j<24;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_BORDER; count+=2; }
// Actual screen
for (uint8_t x=0;x<32;++x)
@@ -79,15 +82,15 @@ namespace zxscreen
}
// Right border
for (int j=0;j<24;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 1; count+=2; }
for (int j=0;j<24;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_BORDER; count+=2; }
}
// Lower border
for (int i=0; i<56;++i) {
// hsync
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 0; }
for (int j=0;j<48;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_SYNC; }
//border
for (int j=0;j<176;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = 1; count+=2; }
for (int j=0;j<176;++j) { *(ptr_pixel++) = 0; *(ptr_color++) = SCREEN_BORDER; count+=2; }
}
//printf("COUNT: %i\n", count);
}
@@ -194,9 +197,9 @@ namespace zxscreen
for (int i=0;i<dt;++i)
{
if (color_addr[t_screen] != 0)
if (color_addr[t_screen] != SCREEN_SYNC)
{
if (color_addr[t_screen] == 1) {
if (color_addr[t_screen] == SCREEN_BORDER) {
*(ptr_pixel++) = border_color;
*(ptr_pixel++) = border_color;
} else {