fixed up controller

This commit is contained in:
Lauchmelder 2022-03-08 21:21:28 +01:00
parent 024e439c24
commit 3e6619a730
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
6 changed files with 19 additions and 19 deletions

View file

@ -16,7 +16,7 @@ Bus::Bus(Screen* screen) :
palettes = std::vector<Byte>(0x20, 0); palettes = std::vector<Byte>(0x20, 0);
LOG_CORE_INFO("Inserting cartridge"); LOG_CORE_INFO("Inserting cartridge");
cartridge.Load("roms/donkeykong.nes"); cartridge.Load("roms/mario.nes");
LOG_CORE_INFO("Powering up CPU"); LOG_CORE_INFO("Powering up CPU");
cpu.Powerup(); cpu.Powerup();

View file

@ -27,7 +27,7 @@ Byte ControllerPort::Write(Word addr, Byte val)
Byte ControllerPort::Read(Word addr) Byte ControllerPort::Read(Word addr)
{ {
if (connectedDevices[addr & 1] == nullptr) if (connectedDevices[addr & 1] == nullptr)
return 0xFF; return 0x00;
return connectedDevices[addr & 1]->CLK(); return connectedDevices[addr & 1]->CLK();
} }

View file

@ -518,7 +518,7 @@ void PPU::EvaluateSprites()
secondaryOAM[freeSecondaryOAMSlot + 2] = ReadOAM(oamaddr + 4 * n + 2); secondaryOAM[freeSecondaryOAMSlot + 2] = ReadOAM(oamaddr + 4 * n + 2);
secondaryOAM[freeSecondaryOAMSlot + 3] = ReadOAM(oamaddr + 4 * n + 3); secondaryOAM[freeSecondaryOAMSlot + 3] = ReadOAM(oamaddr + 4 * n + 3);
sprites[freeSecondaryOAMSlot >> 2].OAMPosition = n >> 4; sprites[freeSecondaryOAMSlot >> 2].OAMPosition = n >> 2;
freeSecondaryOAMSlot += 4; freeSecondaryOAMSlot += 4;
} }

View file

@ -25,10 +25,10 @@ public:
inline Byte CLK() inline Byte CLK()
{ {
Byte output = outRegister & 1; Byte output = (outRegister & 0x80) >> 7;
outRegister >>= 1; outRegister <<= 1;
return (output << outPin); return 0x40 | (output << outPin);
} }
protected: protected:

View file

@ -14,14 +14,14 @@ void StandardController::OUT(PortLatch latch)
StandardButtons pressed; StandardButtons pressed;
pressed.Buttons.A = Input::IsKeyDown(GLFW_KEY_S); pressed.Buttons.A = Input::IsKeyDown(GLFW_KEY_L);
pressed.Buttons.B = Input::IsKeyDown(GLFW_KEY_A); pressed.Buttons.B = Input::IsKeyDown(GLFW_KEY_K);
pressed.Buttons.Select = Input::IsKeyDown(GLFW_KEY_RIGHT_SHIFT); pressed.Buttons.Select = Input::IsKeyDown(GLFW_KEY_RIGHT_SHIFT);
pressed.Buttons.Start = Input::IsKeyDown(GLFW_KEY_ENTER); pressed.Buttons.Start = Input::IsKeyDown(GLFW_KEY_ENTER);
pressed.Buttons.Up = Input::IsKeyDown(GLFW_KEY_UP); pressed.Buttons.Up = Input::IsKeyDown(GLFW_KEY_W);
pressed.Buttons.Down = Input::IsKeyDown(GLFW_KEY_DOWN); pressed.Buttons.Down = Input::IsKeyDown(GLFW_KEY_S);
pressed.Buttons.Left = Input::IsKeyDown(GLFW_KEY_LEFT); pressed.Buttons.Left = Input::IsKeyDown(GLFW_KEY_A);
pressed.Buttons.Right = Input::IsKeyDown(GLFW_KEY_RIGHT); pressed.Buttons.Right = Input::IsKeyDown(GLFW_KEY_D);
if (pressed.Raw == 0xFF) if (pressed.Raw == 0xFF)
volatile int dkjf = 3; volatile int dkjf = 3;

View file

@ -6,14 +6,14 @@ union StandardButtons
{ {
struct 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 Right : 1;
Byte Left : 1;
Byte Down : 1;
Byte Up : 1;
Byte Start : 1;
Byte Select : 1;
Byte B : 1;
Byte A : 1;
} Buttons; } Buttons;
Byte Raw; Byte Raw;