Changed keyboard register to mem map

This commit is contained in:
0xmac 2024-12-02 10:37:30 +01:00
parent 59c3b0d640
commit a5e914de4b

View File

@ -2,10 +2,10 @@
#include <SFML/Window.h>
extern uint8_t systemRegister;
extern uint8_t keyboardResult;
extern sfKeyCode currentKey;
static uint8_t keyboardResult;
static sfKeyCode scanMatrix[48] = {
const static sfKeyCode scanMatrix[48] = {
sfKeyNum1, sfKeyNum2, sfKeyNum3, sfKeyNum4, sfKeyNum5, sfKeyNum6, sfKeyNum7, sfKeyNum8,
sfKeyQ, sfKeyW, sfKeyE, sfKeyR, sfKeyT, sfKeyY, sfKeyU, sfKeyI,
sfKeyA, sfKeyS, sfKeyD, sfKeyF, sfKeyG, sfKeyH, sfKeyJ, sfKeyK,
@ -15,11 +15,11 @@ static sfKeyCode scanMatrix[48] = {
};
void scanKeyboard(const sfKeyCode key){
void scanKeyboard(){
keyboardResult = 0;
for (int i = 0; i < 8; i++) {
if (key == scanMatrix[i + (((systemRegister & 0x07) % 6) * 8)]){
if (currentKey == scanMatrix[i + (((systemRegister & 0x07) % 6) * 8)]){
keyboardResult |= (0x80 >> i);
}
}