From 3e6619a73070c7cfcbfb7b09bb663eee736b3555 Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Tue, 8 Mar 2022 21:21:28 +0100 Subject: [PATCH] fixed up controller --- src/Bus.cpp | 2 +- src/ControllerPort.cpp | 2 +- src/PPU.cpp | 2 +- src/controllers/Controller.hpp | 6 +++--- src/controllers/StandardController.cpp | 12 ++++++------ src/controllers/StandardController.hpp | 14 +++++++------- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Bus.cpp b/src/Bus.cpp index 0e8bda9..f398852 100644 --- a/src/Bus.cpp +++ b/src/Bus.cpp @@ -16,7 +16,7 @@ Bus::Bus(Screen* screen) : palettes = std::vector(0x20, 0); LOG_CORE_INFO("Inserting cartridge"); - cartridge.Load("roms/donkeykong.nes"); + cartridge.Load("roms/mario.nes"); LOG_CORE_INFO("Powering up CPU"); cpu.Powerup(); diff --git a/src/ControllerPort.cpp b/src/ControllerPort.cpp index c3ca70b..ab24829 100644 --- a/src/ControllerPort.cpp +++ b/src/ControllerPort.cpp @@ -27,7 +27,7 @@ Byte ControllerPort::Write(Word addr, Byte val) Byte ControllerPort::Read(Word addr) { if (connectedDevices[addr & 1] == nullptr) - return 0xFF; + return 0x00; return connectedDevices[addr & 1]->CLK(); } diff --git a/src/PPU.cpp b/src/PPU.cpp index 183a397..4a40856 100644 --- a/src/PPU.cpp +++ b/src/PPU.cpp @@ -518,7 +518,7 @@ void PPU::EvaluateSprites() secondaryOAM[freeSecondaryOAMSlot + 2] = ReadOAM(oamaddr + 4 * n + 2); secondaryOAM[freeSecondaryOAMSlot + 3] = ReadOAM(oamaddr + 4 * n + 3); - sprites[freeSecondaryOAMSlot >> 2].OAMPosition = n >> 4; + sprites[freeSecondaryOAMSlot >> 2].OAMPosition = n >> 2; freeSecondaryOAMSlot += 4; } diff --git a/src/controllers/Controller.hpp b/src/controllers/Controller.hpp index aa3b78a..1d23d11 100644 --- a/src/controllers/Controller.hpp +++ b/src/controllers/Controller.hpp @@ -25,10 +25,10 @@ public: inline Byte CLK() { - Byte output = outRegister & 1; - outRegister >>= 1; + Byte output = (outRegister & 0x80) >> 7; + outRegister <<= 1; - return (output << outPin); + return 0x40 | (output << outPin); } protected: diff --git a/src/controllers/StandardController.cpp b/src/controllers/StandardController.cpp index 2735aaf..c06766d 100644 --- a/src/controllers/StandardController.cpp +++ b/src/controllers/StandardController.cpp @@ -14,14 +14,14 @@ void StandardController::OUT(PortLatch latch) StandardButtons pressed; - pressed.Buttons.A = Input::IsKeyDown(GLFW_KEY_S); - pressed.Buttons.B = Input::IsKeyDown(GLFW_KEY_A); + pressed.Buttons.A = Input::IsKeyDown(GLFW_KEY_L); + pressed.Buttons.B = Input::IsKeyDown(GLFW_KEY_K); pressed.Buttons.Select = Input::IsKeyDown(GLFW_KEY_RIGHT_SHIFT); pressed.Buttons.Start = Input::IsKeyDown(GLFW_KEY_ENTER); - pressed.Buttons.Up = Input::IsKeyDown(GLFW_KEY_UP); - pressed.Buttons.Down = Input::IsKeyDown(GLFW_KEY_DOWN); - pressed.Buttons.Left = Input::IsKeyDown(GLFW_KEY_LEFT); - pressed.Buttons.Right = Input::IsKeyDown(GLFW_KEY_RIGHT); + pressed.Buttons.Up = Input::IsKeyDown(GLFW_KEY_W); + pressed.Buttons.Down = Input::IsKeyDown(GLFW_KEY_S); + pressed.Buttons.Left = Input::IsKeyDown(GLFW_KEY_A); + pressed.Buttons.Right = Input::IsKeyDown(GLFW_KEY_D); if (pressed.Raw == 0xFF) volatile int dkjf = 3; diff --git a/src/controllers/StandardController.hpp b/src/controllers/StandardController.hpp index e017dc3..5177b05 100644 --- a/src/controllers/StandardController.hpp +++ b/src/controllers/StandardController.hpp @@ -6,14 +6,14 @@ union StandardButtons { struct { - Byte A : 1; - Byte B : 1; - Byte Select : 1; - Byte Start : 1; - Byte Up : 1; - Byte Down : 1; - Byte Left : 1; Byte Right : 1; + Byte Left : 1; + Byte Down : 1; + Byte Up : 1; + Byte Start : 1; + Byte Select : 1; + Byte B : 1; + Byte A : 1; } Buttons; Byte Raw;