Browse Source

Fix bug with improperly initialized fn ptr table

master
Austin Morlan 1 week ago
parent
commit
2b4bd4158f
Signed by: austin
GPG Key ID: FD6B27654AF5E348
  1. 12
      Source/Chip8.cpp
  2. 10
      Source/Chip8.hpp

12
Source/Chip8.cpp

@ -65,6 +65,13 @@ Chip8::Chip8()
table[0xE] = &Chip8::TableE;
table[0xF] = &Chip8::TableF;
for (size_t i = 0; i <= 0xE; i++)
{
table0[i] = &Chip8::OP_NULL;
table8[i] = &Chip8::OP_NULL;
tableE[i] = &Chip8::OP_NULL;
}
table0[0x0] = &Chip8::OP_00E0;
table0[0xE] = &Chip8::OP_00EE;
@ -81,6 +88,11 @@ Chip8::Chip8()
tableE[0x1] = &Chip8::OP_ExA1;
tableE[0xE] = &Chip8::OP_Ex9E;
for (size_t i = 0; i <= 0x65; i++)
{
tableF[i] = &Chip8::OP_NULL;
}
tableF[0x07] = &Chip8::OP_Fx07;
tableF[0x0A] = &Chip8::OP_Fx0A;
tableF[0x15] = &Chip8::OP_Fx15;

10
Source/Chip8.hpp

@ -147,9 +147,9 @@ private:
std::uniform_int_distribution<uint8_t> randByte;
typedef void (Chip8::*Chip8Func)();
Chip8Func table[0xF + 1]{&Chip8::OP_NULL};
Chip8Func table0[0xE + 1]{&Chip8::OP_NULL};
Chip8Func table8[0xE + 1]{&Chip8::OP_NULL};
Chip8Func tableE[0xE + 1]{&Chip8::OP_NULL};
Chip8Func tableF[0x65 + 1]{&Chip8::OP_NULL};
Chip8Func table[0xF + 1];
Chip8Func table0[0xE + 1];
Chip8Func table8[0xE + 1];
Chip8Func tableE[0xE + 1];
Chip8Func tableF[0x65 + 1];
};

Loading…
Cancel
Save