Chip8-CPP/include/instruction_handler.h

44 lines
1.1 KiB
C
Raw Normal View History

2023-09-09 17:57:57 +00:00
#ifndef CHIP8_INSTRUCTION_HANDLER_H
#define CHIP8_INSTRUCTION_HANDLER_H
#include <map>
#include "chip8.h"
#include "instruction.h"
/**
* The InstructionHandler class holds the Chip8 instruction set and all handlers
*/
2023-09-09 17:57:57 +00:00
class InstructionHandler {
private:
/**
* The typedef for the handler functions
*/
typedef void (*Handler)(Chip8&, Instruction);
/**
* Map which stores all instructions with their handler
*/
2023-09-09 17:57:57 +00:00
std::map<unsigned short, Handler> handlers = {};
/**
* Handles Chip8 instruction 0x0000, as well as 0x00E0 and 0x00EE
*/
static void handle0000(Chip8&, Instruction);
/**
* Handles Chip8 instruction 0x1000
*/
static void handle1000(Chip8&, Instruction);
2023-09-09 17:57:57 +00:00
public:
InstructionHandler();
/**
* Attempts to handle a chip8 instruction
* @param instructionNumber the 16-bit value to determine the instruction
* @param chip8 the Chip8 instance
* @param instruction the Instruction instance
*/
void handleInstruction(unsigned short instructionNumber, Chip8& chip8, Instruction instruction);
2023-09-09 17:57:57 +00:00
};
#endif //CHIP8_INSTRUCTION_HANDLER_H