From 2aace3fc7302e8e09dfc2a7f54576c340d054a1c Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 24 Sep 2019 15:25:22 -0400 Subject: add more instructions --- chip8.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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; } } -- cgit v1.2.3-101-g0448