1
0
Fork 0

Fix bug with improperly initialized fn ptr table

This commit is contained in:
Austin Morlan 2022-08-01 11:08:46 -07:00
parent 084f2e9a9c
commit 2b4bd4158f
Signed by: austin
GPG Key ID: FD6B27654AF5E348
2 changed files with 17 additions and 5 deletions

View File

@ -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;

View File

@ -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];
};