summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip8.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/chip8.c b/chip8.c
index 25e94a7..c21b1bc 100644
--- a/chip8.c
+++ b/chip8.c
@@ -122,6 +122,38 @@ void vm_thread(void* v) {
vm.Vx[15] = 0;
}
break;
+ case '5':
+ if (vm.Vx[hex_char(str[1])] > vm.Vx[hex_char(str[2])]) {
+ vm.Vx[15] = 1;
+ } else {
+ vm.Vx[15] = 0;
+ }
+ vm.Vx[hex_char(str[1])] -= vm.Vx[hex_char(str[2])];
+ break;
+ case '6':
+ if ((vm.Vx[hex_char(str[1])] & 1) == 1) {
+ vm.Vx[15] = 1;
+ } else {
+ vm.Vx[15] = 0;
+ }
+ vm.Vx[hex_char(str[1])] /= 2;
+ break;
+ case '7':
+ if (vm.Vx[hex_char(str[1])] < vm.Vx[hex_char(str[2])]) {
+ vm.Vx[15] = 1;
+ } else {
+ vm.Vx[15] = 0;
+ }
+ vm.Vx[hex_char(str[1])] = vm.Vx[hex_char(str[2])] - vm.Vx[hex_char(str[1])];
+ break;
+ case 'e':
+ if ((vm.Vx[hex_char(str[1])] & 1) == 1) {
+ vm.Vx[15] = 1;
+ } else {
+ vm.Vx[15] = 0;
+ }
+ vm.Vx[hex_char(str[1])] *= 2;
+ break;
}
}