Skip to content

Commit

Permalink
Implement Noise Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Demigod345 committed Dec 22, 2023
1 parent ec29cb8 commit a558b13
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 110 deletions.
13 changes: 8 additions & 5 deletions src/gameBoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "cpu.h"
#include "gameBoy.h"

#include <chrono>

int GBE::s_Cycles;

GBE::GBE()
Expand Down Expand Up @@ -36,14 +38,13 @@ GBE::GBE()
gbe_graphics->init();

gbe_sound->init();
gbe_sound->test();

// Open the Boot ROM
if ((bootROM = fopen("../src/dmg_boot.gb", "rb")) == NULL)
printf("boot rom file not opened");

// Open the Game ROM
if ((gameROM = fopen("../tests/tetris.gb", "rb")) == NULL)
if ((gameROM = fopen("../tests/drmario.gb", "rb")) == NULL)
printf("game rom file not opened");

// Set the Boot ROM
Expand Down Expand Up @@ -122,18 +123,20 @@ void GBE::update()
{
// Execute the next instruction
s_Cycles += gbe_cpu->executeNextInstruction();

// update the DIV and TIMA timers
gbe_cpu->updateTimers(s_Cycles);
gbe_graphics->executePPU(s_Cycles);
// this runs at a freq of around 27 * freq(DIV) = 442368 Hz
// this is probably enough to implement APU
gbe_sound->executeAPU();
gbe_sound->test();
gbe_sound->stepAPU(s_Cycles);
// gbe_sound->test(s_Cycles);
s_Cycles = 0;
s_Cycles += gbe_cpu->performInterrupt();
// printf("s_Cycles after: %d\n\n", s_Cycles);
gbe_graphics->pollEvents();
}

// printf("a: %lld\n", a);
}

void GBE::executeBootROM()
Expand Down
Loading

0 comments on commit a558b13

Please sign in to comment.