- [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:
2024-04-13 15:30:07 +02:00
parent eb4f2be4a4
commit 0d78733d06
7 changed files with 173 additions and 21 deletions

39
z80.cpp
View File

@@ -1,4 +1,5 @@
#include "z80.h"
#include "z80debug.h"
#include <stdio.h>
@@ -131,6 +132,7 @@ namespace z80
uint8_t READ_MEM_8(const uint16_t addr)
{
if (z80debug::isbreak(addr, 2)) z80debug::stop();
t+=3;
return memory[addr];
}
@@ -155,13 +157,14 @@ namespace z80
uint16_t READ_MEM_16(const uint16_t addr)
{
return READ_MEM_8(addr) + READ_MEM_8(addr+1) << 8;
return READ_MEM_8(addr) + (READ_MEM_8(addr+1) << 8);
}
const uint8_t WRITE_MEM_8(const uint16_t addr, const uint8_t value)
{
t+=3;
memory[addr] = value;
if (addr>=0x4000) memory[addr] = value;
if (z80debug::isbreak(addr, 4)) z80debug::stop();
return value;
}
@@ -263,9 +266,9 @@ namespace z80
uint8_t value = *reg + 1;
KEEP_FLAGS(fC);
FLAGS_SZXY(*reg);
if (*reg == 0x80) SET_FLAGS(fV);
if ( (*reg & 0x0f) == 0x00 ) SET_FLAGS(fH);
FLAGS_SZXY(value);
if (value == 0x80) SET_FLAGS(fV);
if ( (value & 0x0f) == 0x00 ) SET_FLAGS(fH);
*reg = value;
}
@@ -275,10 +278,10 @@ namespace z80
uint8_t value = *reg - 1;
KEEP_FLAGS(fC);
FLAGS_SZXY(*reg);
FLAGS_SZXY(value);
SET_FLAGS(fN);
if (*reg == 0x7f) SET_FLAGS(fV);
if ( (*reg & 0x0f) == 0x0f ) SET_FLAGS(fH);
if (value == 0x7f) SET_FLAGS(fV);
if ( (value & 0x0f) == 0x0f ) SET_FLAGS(fH);
*reg = value;
}
@@ -288,6 +291,12 @@ namespace z80
t++;
uint8_t value = READ_MEM_8(addr);
value++;
KEEP_FLAGS(fC);
FLAGS_SZXY(value);
if (value == 0x80) SET_FLAGS(fV);
if ( (value & 0x0f) == 0x00 ) SET_FLAGS(fH);
WRITE_MEM_8(addr, value);
}
@@ -296,6 +305,13 @@ namespace z80
t+=1;
uint8_t value = READ_MEM_8(addr);
value--;
KEEP_FLAGS(fC);
FLAGS_SZXY(value);
SET_FLAGS(fN);
if (value == 0x7f) SET_FLAGS(fV);
if ( (value & 0x0f) == 0x0f ) SET_FLAGS(fH);
WRITE_MEM_8(addr, value);
}
@@ -566,6 +582,13 @@ namespace z80
RETN();
}
void interrupt()
{
if (!iff1) return;
PUSH(rPC);
rPC = 0x38;
}
void RST(uint8_t vec)
{
PUSH(rPC);