- [FIX] RLCA(), RLA(), RRCA() i RRA() calculaven mal el carry i m'estaven tornant loco
This commit is contained in:
14
z80.cpp
14
z80.cpp
@@ -166,6 +166,8 @@ namespace z80
|
|||||||
t+=3;
|
t+=3;
|
||||||
if (addr>=0x4000) memory[addr] = value;
|
if (addr>=0x4000) memory[addr] = value;
|
||||||
if (z80debug::isbreak(addr, 4)) z80debug::stop();
|
if (z80debug::isbreak(addr, 4)) z80debug::stop();
|
||||||
|
//if (z80debug::debugging())
|
||||||
|
z80debug::setmemmodified(addr);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,30 +429,38 @@ namespace z80
|
|||||||
|
|
||||||
void RLCA()
|
void RLCA()
|
||||||
{
|
{
|
||||||
|
const bool should_carry = rA & 0x80;
|
||||||
rA = (rA>>7) | (rA<<1);
|
rA = (rA>>7) | (rA<<1);
|
||||||
KEEP_FLAGS(fS | fZ | fP);
|
KEEP_FLAGS(fS | fZ | fP);
|
||||||
SET_FLAGS(rA & (fX | fY | fC));
|
SET_FLAGS(rA & (fX | fY | fC));
|
||||||
|
if (should_carry) SET_FLAGS(fC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RRCA()
|
void RRCA()
|
||||||
{
|
{
|
||||||
|
const bool should_carry = rA & 0x01;
|
||||||
rA = (rA<<7) | (rA>>1);
|
rA = (rA<<7) | (rA>>1);
|
||||||
KEEP_FLAGS(fS | fZ | fP);
|
KEEP_FLAGS(fS | fZ | fP);
|
||||||
SET_FLAGS(rA & (fX | fY | fC));
|
SET_FLAGS(rA & (fX | fY | fC));
|
||||||
|
if (should_carry) SET_FLAGS(fC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RLA()
|
void RLA()
|
||||||
{
|
{
|
||||||
|
const bool should_carry = rA & 0x80;
|
||||||
rA = (rA<<1) | (rF&fC);
|
rA = (rA<<1) | (rF&fC);
|
||||||
KEEP_FLAGS(fS | fZ | fP);
|
KEEP_FLAGS(fS | fZ | fP);
|
||||||
SET_FLAGS(rA & (fX | fY | fC));
|
SET_FLAGS(rA & (fX | fY));
|
||||||
|
if (should_carry) SET_FLAGS(fC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RRA()
|
void RRA()
|
||||||
{
|
{
|
||||||
|
const bool should_carry = rA & 0x01;
|
||||||
rA = ((rF&fC)<<7) | (rA>>1);
|
rA = ((rF&fC)<<7) | (rA>>1);
|
||||||
KEEP_FLAGS(fS | fZ | fP);
|
KEEP_FLAGS(fS | fZ | fP);
|
||||||
SET_FLAGS(rA & (fX | fY | fC));
|
SET_FLAGS(rA & (fX | fY));
|
||||||
|
if (should_carry) SET_FLAGS(fC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RRD()
|
void RRD()
|
||||||
|
|||||||
61
z80debug.cpp
61
z80debug.cpp
@@ -44,6 +44,10 @@ namespace z80debug
|
|||||||
{255,255,255},
|
{255,255,255},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint16_t oAF, oBC, oDE, oHL, oAF2, oBC2, oDE2, oHL2, oIX, oIY, oSP, oPC;
|
||||||
|
|
||||||
|
bool mem_modified[65536];
|
||||||
|
|
||||||
uint8_t offset_x = 0;
|
uint8_t offset_x = 0;
|
||||||
uint8_t offset_y = 0;
|
uint8_t offset_y = 0;
|
||||||
|
|
||||||
@@ -195,32 +199,33 @@ namespace z80debug
|
|||||||
printtxt(0,3, "HL HL' PC ", COLOR_WHITE);
|
printtxt(0,3, "HL HL' PC ", COLOR_WHITE);
|
||||||
printtxt(0,4, "(BC) (DE) (HL) ", COLOR_WHITE);
|
printtxt(0,4, "(BC) (DE) (HL) ", COLOR_WHITE);
|
||||||
|
|
||||||
printtxt(3,0, tohex(z80::getAF(), 4), COLOR_GRAY);
|
printtxt(3,0, tohex(z80::getAF(), 4), oAF != z80::getAF() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(11,0, tohex(z80::getAF(true), 4), COLOR_GRAY);
|
printtxt(11,0, tohex(z80::getAF(true), 4), oAF2 != z80::getAF(true) ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(19,0, tohex(z80::getIX(), 4), COLOR_GRAY);
|
printtxt(19,0, tohex(z80::getIX(), 4), oIX != z80::getIX() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(3,1, tohex(z80::getBC(), 4), COLOR_GRAY);
|
printtxt(3,1, tohex(z80::getBC(), 4), oBC != z80::getBC() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(11,1, tohex(z80::getBC(true), 4), COLOR_GRAY);
|
printtxt(11,1, tohex(z80::getBC(true), 4), oBC2 != z80::getBC(true) ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(19,1, tohex(z80::getIY(), 4), COLOR_GRAY);
|
printtxt(19,1, tohex(z80::getIY(), 4), oIY != z80::getIY() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(3,2, tohex(z80::getDE(), 4), COLOR_GRAY);
|
printtxt(3,2, tohex(z80::getDE(), 4), oDE != z80::getDE() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(11,2, tohex(z80::getDE(true), 4), COLOR_GRAY);
|
printtxt(11,2, tohex(z80::getDE(true), 4), oDE2 != z80::getDE(true) ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(19,2, tohex(z80::getSP(), 4), COLOR_GRAY);
|
printtxt(19,2, tohex(z80::getSP(), 4), oSP != z80::getSP() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(3,3, tohex(z80::getHL(), 4), COLOR_GRAY);
|
printtxt(3,3, tohex(z80::getHL(), 4), oHL != z80::getHL() ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(11,3, tohex(z80::getHL(true), 4), COLOR_GRAY);
|
printtxt(11,3, tohex(z80::getHL(true), 4), oHL2 != z80::getHL(true) ? COLOR_RED : COLOR_GRAY);
|
||||||
printtxt(19,3, tohex(z80::getPC(), 4), COLOR_GRAY);
|
printtxt(19,3, tohex(z80::getPC(), 4), oPC != z80::getPC() ? COLOR_RED : COLOR_GRAY);
|
||||||
|
|
||||||
printtxt(5,4, tohex(memory[z80::getBC()], 2), COLOR_GRAY);
|
printtxt(5,4, tohex(memory[z80::getBC()], 2), COLOR_GRAY);
|
||||||
printtxt(13,4, tohex(memory[z80::getDE()], 2), COLOR_GRAY);
|
printtxt(13,4, tohex(memory[z80::getDE()], 2), COLOR_GRAY);
|
||||||
printtxt(21,4, tohex(memory[z80::getHL()], 2), COLOR_GRAY);
|
printtxt(21,4, tohex(memory[z80::getHL()], 2), COLOR_GRAY);
|
||||||
|
|
||||||
const uint8_t flags = (z80::getAF() & 0xFF);
|
const uint8_t flags = (z80::getAF() & 0xFF);
|
||||||
printtxt(0,5,"S", flags&0x80?COLOR_WHITE:COLOR_GRAY);
|
const uint8_t mod_flags = flags ^ (oAF & 0xFF);
|
||||||
printtxt(1,5,"Z", flags&0x40?COLOR_WHITE:COLOR_GRAY);
|
printtxt(0,5,"S", flags&0x80 ? (mod_flags&0x80 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x80 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(2,5,"X", flags&0x20?COLOR_WHITE:COLOR_GRAY);
|
printtxt(1,5,"Z", flags&0x40 ? (mod_flags&0x40 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x40 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(3,5,"H", flags&0x10?COLOR_WHITE:COLOR_GRAY);
|
printtxt(2,5,"X", flags&0x20 ? (mod_flags&0x20 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x20 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(4,5,"Y", flags&0x08?COLOR_WHITE:COLOR_GRAY);
|
printtxt(3,5,"H", flags&0x10 ? (mod_flags&0x10 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x10 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(5,5,"P", flags&0x04?COLOR_WHITE:COLOR_GRAY);
|
printtxt(4,5,"Y", flags&0x08 ? (mod_flags&0x08 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x08 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(6,5,"N", flags&0x02?COLOR_WHITE:COLOR_GRAY);
|
printtxt(5,5,"P", flags&0x04 ? (mod_flags&0x04 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x04 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
printtxt(7,5,"C", flags&0x01?COLOR_WHITE:COLOR_GRAY);
|
printtxt(6,5,"N", flags&0x02 ? (mod_flags&0x02 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x02 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
|
printtxt(7,5,"C", flags&0x01 ? (mod_flags&0x01 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x01 ? COLOR_BROWN : COLOR_GRAY) );
|
||||||
|
|
||||||
offset_x = offset_y = 0;
|
offset_x = offset_y = 0;
|
||||||
box(46,8,11,12,COLOR_WHITE);
|
box(46,8,11,12,COLOR_WHITE);
|
||||||
@@ -268,8 +273,9 @@ namespace z80debug
|
|||||||
for (int i=0; i<6; ++i) {
|
for (int i=0; i<6; ++i) {
|
||||||
printtxt(0,i, tohex(mem_viewer_cursor, 4), COLOR_CYAN);
|
printtxt(0,i, tohex(mem_viewer_cursor, 4), COLOR_CYAN);
|
||||||
for (int j=0; j<16; ++j) {
|
for (int j=0; j<16; ++j) {
|
||||||
printtxt(5+j*3, i, tohex(memory[mem_viewer_cursor++],2), COLOR_WHITE);
|
printtxt(5+j*3, i, tohex(memory[mem_viewer_cursor],2), mem_modified[mem_viewer_cursor] ? COLOR_RED : COLOR_WHITE);
|
||||||
printchar(53+j, i, memory[mem_viewer_cursor], COLOR_GRAY);
|
printchar(53+j, i, memory[mem_viewer_cursor], mem_modified[mem_viewer_cursor] ? COLOR_BROWN : COLOR_GRAY);
|
||||||
|
mem_viewer_cursor++;
|
||||||
}
|
}
|
||||||
//printtxt(5,0, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", COLOR_WHITE);
|
//printtxt(5,0, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", COLOR_WHITE);
|
||||||
//printtxt(53,0, "0123456789AB\tDEF", COLOR_GRAY);
|
//printtxt(53,0, "0123456789AB\tDEF", COLOR_GRAY);
|
||||||
@@ -287,6 +293,12 @@ namespace z80debug
|
|||||||
printtxt(1,1, console_error, COLOR_RED);
|
printtxt(1,1, console_error, COLOR_RED);
|
||||||
|
|
||||||
SDL_RenderPresent(ren);
|
SDL_RenderPresent(ren);
|
||||||
|
|
||||||
|
for (int i=0; i<65536; ++i) mem_modified[i] = false;
|
||||||
|
|
||||||
|
oAF = z80::getAF(); oBC = z80::getBC(); oDE = z80::getDE(); oHL = z80::getHL();
|
||||||
|
oAF2 = z80::getAF(true); oBC2 = z80::getBC(true); oDE2 = z80::getDE(true); oHL2 = z80::getHL(true);
|
||||||
|
oIX = z80::getIX(); oIY = z80::getIY(); oSP = z80::getSP(); oPC = z80::getPC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendToConsole(const char* text)
|
void sendToConsole(const char* text)
|
||||||
@@ -424,4 +436,9 @@ namespace z80debug
|
|||||||
cont();
|
cont();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setmemmodified(const uint16_t addr)
|
||||||
|
{
|
||||||
|
mem_modified[addr] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace z80debug
|
|||||||
void stop();
|
void stop();
|
||||||
void cont();
|
void cont();
|
||||||
const bool debugging();
|
const bool debugging();
|
||||||
|
void setmemmodified(const uint16_t addr);
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
void sendToConsole(const char* text);
|
void sendToConsole(const char* text);
|
||||||
|
|||||||
Reference in New Issue
Block a user