#ifndef CHIP8_INSTRUCTION_HANDLER_H #define CHIP8_INSTRUCTION_HANDLER_H #include #include "chip8.h" #include "instruction.h" /** * The InstructionHandler class holds the Chip8 instruction set and all handlers */ class InstructionHandler { private: /** * The typedef for the handler functions */ typedef void (*Handler)(Chip8&, Instruction); /** * Map which stores all instructions with their handler */ std::map 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); /** * Handles Chip8 instruction 0x2000 */ static void handle2000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x3000 */ static void handle3000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x4000 */ static void handle4000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x5000 */ static void handle5000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x6000 */ static void handle6000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x7000 */ static void handle7000(Chip8&, Instruction); /** * Handles Chip8 instruction 0x8000 */ static void handle8000(Chip8&, Instruction); 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); }; #endif //CHIP8_INSTRUCTION_HANDLER_H