Skip to content

Commit

Permalink
setup testing pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
r41k0u committed Jan 21, 2023
1 parent 3fca00c commit ea18927
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ int CPU::NOP()
int CPU::LD_BC_u16()
{
// Load the next 2 bytes into BC

// Left shift the first byte by 8 bits
// OR the second byte
reg_BC.dat = ((*mMap)[reg_PC.dat + 1] << 8) | (*mMap)[reg_PC.dat + 2];
reg_PC.dat += 3;
printf("LD BC, u16");
return 12;
Expand All @@ -45,6 +47,6 @@ int CPU::LD_BC_u16()
int CPU::executeNextInstruction()
{
// Get the opcode
Byte opcode = *mMap[reg_PC.dat];
Byte opcode = (*mMap)[reg_PC.dat];
return (this->*method_pointer[opcode])();
}
7 changes: 6 additions & 1 deletion src/gameBoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ GBE::GBE()
// Unify the CPU and MemoryMap
gbe_cpu->setMemory(gbe_mMap);

gbe_mMap->debugWriteMemory(0x0100, 0x00);
gbe_mMap->debugWriteMemory(0x0101, 0x01);
gbe_mMap->debugWriteMemory(0x0102, 0x02);
gbe_mMap->debugWriteMemory(0x0103, 0x03);

update();
}

Expand All @@ -26,7 +31,7 @@ void GBE::update()
while (cycles < gbe_cpu->clockSpeedPerFrame)
{
// Execute the next instruction
cycles += gbe_cpu->executeNextInstruction(0);
cycles += gbe_cpu->executeNextInstruction();
// updateTimers()
// updateGraphics()
// Do Interrupts()
Expand Down
2 changes: 1 addition & 1 deletion src/gameBoy.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "types.h"
#include "cpu.h"
#include "memoryMap.h"
#include "mmap.h"

// GBE stands for GameBoyEmulator

Expand Down
4 changes: 4 additions & 0 deletions src/mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ bool MemoryMap::writeMemory(Word address, Byte value)
return true;
}

void MemoryMap::debugWriteMemory(Word address, Byte value) {
romBank0[address] = value;
}

Byte MemoryMap::readMemory(Word address)
{
if (address < 0x4000)
Expand Down
1 change: 1 addition & 0 deletions src/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class MemoryMap
Byte* getInterruptEnableRegister() { return interruptEnableRegister; }

bool writeMemory(Word address, Byte value);
void debugWriteMemory(Word address, Byte value);
Byte readMemory(Word address);

Byte operator[](Word address);
Expand Down

0 comments on commit ea18927

Please sign in to comment.