- [FIX] Corregit el acces als port amb OUT

- [NEW] Nou model de gestió de memòria
This commit is contained in:
2025-07-23 13:51:51 +02:00
parent 3fd28136f6
commit 6e3e8e9b69
16 changed files with 315 additions and 94 deletions
+14 -13
View File
@@ -1,6 +1,6 @@
#include "z80.h"
#include "z80debug.h"
#include "z80mem.h"
#include "zx_mem.h"
//#include "zx_tape.h"
#include <stdio.h>
@@ -153,14 +153,14 @@ namespace z80
{
if (z80debug::isbreak(addr, 2)) z80debug::stop();
t+=3;
const uint8_t tag = z80mem::get()->getTag(addr);
const uint8_t tag = mem::getTag(addr);
if ( !(tag&MEMTAG_IGNORE) ) {
if (!code) {
if ( tag & MEMTAG_INST ) {
//printf("WARNING! READING DATA FROM CODE!!! $%4X\n", addr);
//z80debug::stop();
} else {
z80mem::get()->setTag(addr, tag | MEMTAG_DATA);
mem::setTag(addr, tag | MEMTAG_DATA);
}
} else {
if ( (reading_m1) && ( tag & MEMTAG_DATA ) ) {
@@ -170,14 +170,14 @@ namespace z80
}
}
reading_m1 = false;
return z80mem::get()->readMem(addr);
return mem::readMem(addr);
}
uint8_t READ_MEM_8()
{
const uint8_t data = READ_MEM_8(rPC, true);
const uint8_t tag = z80mem::get()->getTag(rPC);
if ( !(tag & MEMTAG_IGNORE) ) z80mem::get()->setTag(rPC, tag | MEMTAG_CODE);
const uint8_t tag = mem::getTag(rPC);
if ( !(tag & MEMTAG_IGNORE) ) mem::setTag(rPC, tag | MEMTAG_CODE);
rPC++;
return data;
}
@@ -208,18 +208,18 @@ namespace z80
const uint8_t WRITE_MEM_8(const uint16_t addr, const uint8_t value)
{
t+=3;
if (addr>=0x4000) z80mem::get()->writeMem(addr, value);
if (addr>=0x4000) mem::writeMem(addr, value);
if (z80debug::isbreak(addr, 4)) z80debug::stop();
//if (z80debug::debugging())
z80debug::setmemmodified(addr);
const uint8_t tag = z80mem::get()->getTag(addr);
const uint8_t tag = mem::getTag(addr);
if ( !(tag & MEMTAG_IGNORE) ) {
if ( tag & MEMTAG_INST ) {
//printf("WARNING! WRITING DATA OVER CODE!!! $%4X\n", addr);
//z80debug::stop();
} else {
z80mem::get()->setTag(addr, tag | MEMTAG_DATA | MEMTAG_TDATA);
mem::setTag(addr, tag | MEMTAG_DATA | MEMTAG_TDATA);
}
}
@@ -1008,7 +1008,8 @@ namespace z80
t+=4;
if (port == 0x10000) {
port = rBC;
if (rC==0xfe) port = 0xfe;
} else {
port = (rA<<8) | port;
}
if (out_ports[port&0xff]) out_ports[port&0xff](port, val);
}
@@ -1125,7 +1126,7 @@ namespace z80
out_ports[i] = nullptr;
}
z80mem::get()->reset();
mem::reset();
rPC = iff1 = iff2 = im = 0;
rAF = rAF2 = rBC = rBC2 = rDE = rDE2 = rHL = rHL2 = rIX = rIY = rSP = 0xffff;
@@ -1164,10 +1165,10 @@ namespace z80
t = 0;
const uint8_t opcode = READ_M1();
uint8_t tag = z80mem::get()->getTag(current_opcode_address);
uint8_t tag = mem::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) );
mem::setTag(current_opcode_address, tag | (!(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST) );
uint16_t tmp;