Browse Source

Emulator: Add LCDC register to PPU

master
Riyyi 2 years ago
parent
commit
2b7d4dee3d
  1. 3
      src/emu.cpp
  2. 13
      src/ppu.cpp
  3. 17
      src/ppu.h

3
src/emu.cpp

@ -69,7 +69,8 @@ void Emu::writeMemory(uint32_t address, uint32_t value)
if (address == 0xff50) {
Loader::the().disableBootrom();
}
else if (address >= memory.start_address && address <= memory.end_address) {
if (address >= memory.start_address && address <= memory.end_address) {
// Note: ECHO RAM hack
if (address >= 0xc000 && address <= 0xddff) {
writeMemory(address + (0xe000 - 0xc000), value);

13
src/ppu.cpp

@ -5,11 +5,13 @@
* SPDX-License-Identifier: MIT
*/
#include <cstdint> // uint32_t
#include "emu.h"
#include "ppu.h"
#include "ruc/format/print.h"
#include <iostream>
PPU ::PPU(unsigned int frequency)
PPU ::PPU(uint32_t frequency)
: ProcessingUnit(frequency)
{
}
@ -20,5 +22,10 @@ PPU ::~PPU()
void PPU::update()
{
// print("ppu update\n");
LCDC lcd_control = static_cast<LCDC>(Emu::the().readMemory(0xff40));
if (!(lcd_control & LCDC::LCDandPPUEnable)) {
return;
}
print("PPU update\n");
}

17
src/ppu.h

@ -7,11 +7,26 @@
#pragma once
#include <cstdint> // uint8_t, uint32_t
#include "processing-unit.h"
#include "ruc/meta/core.h"
enum LCDC : uint8_t {
None = 0,
BGandWindowEnable = BIT(0),
OBJEnable = BIT(1),
OBJSize = BIT(2), // 0 = 8x8, 1 = 8x16
BGTileMapArea = BIT(3), // 0 = 9800-9bff, 1 = 9c00-9fff
BGandWindowTileDataArea = BIT(4), // 0 = 8800-97ff, 1 = 8000-8fff
WindowEnable = BIT(5), //
WindowTileMapArea = BIT(6), // 0 = 9800-9bff, 1 = 9c00-9fff
LCDandPPUEnable = BIT(7),
};
class PPU final : public ProcessingUnit {
public:
PPU(unsigned int frequency);
PPU(uint32_t frequency);
virtual ~PPU();
virtual void update() override;

Loading…
Cancel
Save