summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-12-25 21:29:52 +0100
committerLoic Guegan <loic.guegan@mailbox.org>2023-12-25 21:29:52 +0100
commit4ad64d82c3007f4dffd973c8f8a22653312357c5 (patch)
tree27fc1126d000aa321eaa93657b16e7d05c905b47
parentc50ed6ba7358f49b61ef32558630f37f257cb365 (diff)
Minor changes
-rw-r--r--src/keypad.c11
-rw-r--r--src/keypad.h1
-rw-r--r--src/vcpu.c8
3 files changed, 19 insertions, 1 deletions
diff --git a/src/keypad.c b/src/keypad.c
index 30b4479..d106642 100644
--- a/src/keypad.c
+++ b/src/keypad.c
@@ -26,3 +26,14 @@ int KeypadIsPressed(unsigned char c){
}
return 0;
}
+
+int KeypadGetPressed(){
+ int keycode=GetKeyPressed();
+ if(keycode){
+ for(int i=0;i<16;i++){
+ if(map[i]==keycode)
+ return 1;
+ }
+ }
+ return -1;
+}
diff --git a/src/keypad.h b/src/keypad.h
index d762be4..9339280 100644
--- a/src/keypad.h
+++ b/src/keypad.h
@@ -3,4 +3,5 @@
#include "raylib.h"
int KeypadIsPressed(unsigned char c);
+int KeypadGetPressed();
diff --git a/src/vcpu.c b/src/vcpu.c
index 504aa7a..67dea13 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -220,7 +220,13 @@ void VCPUExecute(){
break;
case 0x0A:
- // TODO
+ int key=KeypadGetPressed();
+ if(key >= 0){
+ State.V[State.X]=key&0x0F;
+ }
+ else
+ State.PC-=2; // Go back to last instruction (loop until key is pressed)
+
break;
case 0x15: // Set timer