From 68b352d1dfcfc7aa34377d74495bc29f575b9a2e Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Mon, 12 Nov 2018 00:38:03 +0000 Subject: [PATCH] Wire the GameBoy board like a piece of powered hardware. Signed-off-by: Adrian Conlon --- LR35902/inc/GameBoyBus.h | 3 +++ LR35902/src/GameBoyBus.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/LR35902/inc/GameBoyBus.h b/LR35902/inc/GameBoyBus.h index 1a48ca0..b783750 100644 --- a/LR35902/inc/GameBoyBus.h +++ b/LR35902/inc/GameBoyBus.h @@ -36,6 +36,9 @@ namespace EightBit { Bus() noexcept; + virtual void powerOn() override; + virtual void powerOff() override; + auto& CPU() { return m_cpu; } auto& VRAM() { return m_videoRam; } auto& OAMRAM() { return m_oamRam; } diff --git a/LR35902/src/GameBoyBus.cpp b/LR35902/src/GameBoyBus.cpp index abdfc61..be4fb94 100644 --- a/LR35902/src/GameBoyBus.cpp +++ b/LR35902/src/GameBoyBus.cpp @@ -8,6 +8,17 @@ EightBit::GameBoy::Bus::Bus() noexcept WrittenByte.connect(std::bind(&GameBoy::Bus::Bus_WrittenByte, this, std::placeholders::_1)); } +void EightBit::GameBoy::Bus::powerOn() { + EightBit::Bus::powerOn(); + CPU().powerOn(); + reset(); +} + +void EightBit::GameBoy::Bus::powerOff() { + CPU().powerOff(); + EightBit::Bus::powerOff(); +} + void EightBit::GameBoy::Bus::reset() { IO().reset(); LR35902::lower(CPU().RESET());