Skip to content

Commit

Permalink
Working on Mapper 4 again.
Browse files Browse the repository at this point in the history
  • Loading branch information
mplamann committed Feb 15, 2013
1 parent c720e3d commit dfc4f3b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 27 deletions.
Binary file modified log/Log.odt
Binary file not shown.
Binary file added log/Screen Shot 2013-02-15 at 10.34.14 AM.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 10 additions & 11 deletions src/CpuV2.cpp
Expand Up @@ -112,7 +112,7 @@ void STY(CpuV2* cpu, int argument)

void CLC(CpuV2* cpu, int) { cpu->C = false; }
void SEC(CpuV2* cpu, int) { cpu->C = true; }
void CLI(CpuV2* cpu, int) { cpu->oldI = false; }
void CLI(CpuV2* cpu, int) { cpu->CLIdelay = 1; } //cpu->I = false; }
void SEI(CpuV2* cpu, int) { cpu->I = true; }
void CLV(CpuV2* cpu, int) { cpu->V = false; }
void CLD(CpuV2* cpu, int) { cpu->D = false; }
Expand Down Expand Up @@ -459,7 +459,7 @@ void processInterrupt(CpuV2* cpu, int vector)
pushToStack(cpu, (cpu->PC >> 8) & 0xFF);
pushToStack(cpu, cpu->PC & 0xFF);
pushToStack(cpu, cpu->getP());
cpu->I = true;
//cpu->I = true;
cpu->PC = vector;
}

Expand Down Expand Up @@ -741,7 +741,6 @@ void CpuV2::setP(int P)
C = ((P & 0x01) != 0);
Z = ((P & 0x02) != 0);
I = ((P & 0x04) != 0);
oldI = I;
D = ((P & 0x08) != 0);
V = ((P & 0x40) != 0);
N = ((P & 0x80) != 0);
Expand Down Expand Up @@ -769,19 +768,20 @@ int CpuV2::getP()

void CpuV2::RunInstruction(int scanline)
{
if (CLIdelay >= 0 && CLIdelay-- == 0)
I = false;
int opcode = memory->readByteFrom(PC);
int arg1 = memory->readByteFrom(PC+1);
int arg2 = memory->readByteFrom(PC+2);
oldI = I;

// cout << setw(4) << PC << " " << setw(2) << opcode << " " << setw(2) << arg1 << " " << setw(2) << arg2 << " " << opcodeStrings[opcode] << " ";
// cout << "A:" << setw(2) << A << " X:" << setw(2) << X << " Y:" << setw(2) << Y << " P:" << setw(2) << getP() << " SP:" << setw(2) << S << " SL: " << dec << scanline << hex;
cout << setw(4) << PC << " " << setw(2) << opcode << " " << setw(2) << arg1 << " " << setw(2) << arg2 << " " << opcodeStrings[opcode] << " ";
cout << "A:" << setw(2) << A << " X:" << setw(2) << X << " Y:" << setw(2) << Y << " P:" << setw(2) << getP() << " SP:" << setw(2) << S << " SL: " << dec << scanline << hex << " PPUSTATUS: " << (int)memory->PPUSTATUS << " cycle: " << dec << cycles << hex;

int argument = addressingModes[opcode](this, opcode, arg1, arg2);
cycles += cycleMap[opcode];
opcodes[opcode](this, argument);

//cout << "\n";
cout << "\n";
}

void CpuV2::RunForCycles(float cycle_count, int scanline)
Expand Down Expand Up @@ -813,7 +813,6 @@ void CpuV2::doRESET()
{
cycles += 6;
I = true;
oldI = true;
PC = memory->readByteFrom(VECTOR_RESET) + (memory->readByteFrom(VECTOR_RESET+1) << 8);
}

Expand Down Expand Up @@ -856,7 +855,7 @@ char* CpuV2::stateData(size_t* size)
int bufferIndex = 0;

int regs[5] = {A,X,Y,S,PC};
int flags[7] = {N,C,Z,oldI,D,V,B};
int flags[7] = {N,C,Z,I,D,V,B};
memcpy(buffer+bufferIndex, regs, sizeOfRegs);
bufferIndex += sizeOfRegs;
memcpy(buffer+bufferIndex, flags, sizeOfFlags);
Expand Down Expand Up @@ -894,7 +893,7 @@ void CpuV2::loadState(char* buffer, size_t size)
N = flags[0];
C = flags[1];
Z = flags[2];
oldI = flags[3];
I = flags[3];
D = flags[4];
V = flags[5];
B = flags[6];
Expand All @@ -919,7 +918,7 @@ CpuV2::CpuV2(void)
C = false;
Z = false;
I = true;
oldI = true;
CLIdelay = -1;
D = false;
B = false;
V = false;
Expand Down
3 changes: 2 additions & 1 deletion src/CpuV2.h
Expand Up @@ -13,7 +13,8 @@ class CpuV2
int S;
int PC;

bool N,Z,C,I,D,V,B,oldI; // Processor status flags
bool N,Z,C,I,D,V,B; // Processor status flags
int CLIdelay;
int getP();
void setP(int P);

Expand Down
13 changes: 0 additions & 13 deletions src/Mapper4.cpp
Expand Up @@ -158,16 +158,3 @@ void Mapper4::scanlineCounter()
counter_latched = false;
}
}

void Mapper4::updatePpuAddr(int address)
{
/*if (lastPpuAddr != -1)
{
if (!(lastPpuAddr & 0x0100) && (address & 0x0100))
{
// Rising edge of A12
scanlineCounter();
}
}
lastPpuAddr = address;*/
}
1 change: 0 additions & 1 deletion src/Mapper4.h
Expand Up @@ -13,7 +13,6 @@ class Mapper4 : public Mapper
int ppuReadByteFrom(int address);
void writeByteTo(int address, int value);
void ppuWriteByteTo(int address, int value);
void updatePpuAddr(int address);
void scanlineCounter();

CpuV2* cpu;
Expand Down
1 change: 0 additions & 1 deletion src/NESEmulator.cpp
Expand Up @@ -201,7 +201,6 @@ void renderFrame()
{
game_time = al_get_time();

// Render one frame
for (; scanline < 262; scanline++)
{
//if (usingArduino)
Expand Down

0 comments on commit dfc4f3b

Please sign in to comment.