summaryrefslogtreecommitdiff
path: root/chip8.c
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-08-30 16:17:45 +0930
committerDaniel Jones <admin@danieljon.es>2020-08-30 16:17:45 +0930
commitc2c45b45f981e557838943c6f24329c51b1adb4b (patch)
tree11d162c4a65865c3e4810515d9a1b17115211ccc /chip8.c
parent72a80b66f979cce2318e0b4c1df1fae7175b4d2c (diff)
downloadchip8-c2c45b45f981e557838943c6f24329c51b1adb4b.tar.gz
chip8-c2c45b45f981e557838943c6f24329c51b1adb4b.zip
move timers to a function
Diffstat (limited to 'chip8.c')
-rw-r--r--chip8.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/chip8.c b/chip8.c
index 1e7a857..f181494 100644
--- a/chip8.c
+++ b/chip8.c
@@ -129,7 +129,8 @@ void
chip8_beep()
{
// TODO: holy shit this is terrible, do something better
- puts("\a");
+ printf("\a");
+ fflush(stdout);
}
void
@@ -157,7 +158,7 @@ chip8_cycle()
uint8_t x = (opcode >> 8) & 0x000F; // lower 4 bits of the high byte, we discard the low byte by right shifting it out
uint8_t y = (opcode >> 4) & 0x000F; // upper 4 bits of the low byte, so we need to discard the lower 4 bits
uint8_t kk = opcode & 0x00FF; // lowest 8 bits
- printf("parsing at 0x%03X opcode = 0x%04X\n", PC, opcode);
+ //printf("parsing at 0x%03X opcode = 0x%04X\n", PC, opcode);
PC += 2; // TODO: remove
switch (opcode & 0xF000)
{
@@ -170,7 +171,6 @@ chip8_cycle()
switch (kk)
{
case 0x00E0: /* cls (clear screen) */
- puts("clear");
memset(video, 0, (WIDTH*HEIGHT) * sizeof(uint32_t));
draw_flag = 1;
break;
@@ -351,7 +351,7 @@ chip8_cycle()
// TODO: not tested
for(int i = 0; i <= x; ++i)
{
- memory[I + i] = V[i];
+ memory[I + i] = V[i];
}
break;
}
@@ -360,7 +360,7 @@ chip8_cycle()
// TODO: not tested
for(int i = 0; i <= x; ++i)
{
- V[i] = memory[I + i];
+ V[i] = memory[I + i];
}
break;
}
@@ -372,7 +372,10 @@ chip8_cycle()
}
default: unknown_opcode(opcode);
}
+}
+void chip8_timer_cycle()
+{
/* timers */
if (delay_timer > 0)
delay_timer--;