What's new

Chip8 debugger: how to handle timers

jesper

New member
I just wrote a chip8 emulator in JavaScript. Now I would like to write some kind of disassembler and debugger. The debugger should be able to run loaded program step by step and in any moment should show state of memeory and registers.

I've stumbled upon one problem which I'm not sure how to solve. My emulator performs cycles at 60Hz and in each cycles it executes 10 instructions. It's easy to execute instructions step by step but I don't know how to handle delay and sound timers which, as we all know, count down at 60Hz. Should they be updated at 60Hz interval regardless of whether emulator runs step by step or at normal speed? Or maybe when emulator runs step by step, timers should be updated after certain number of steps?
 

GamerCat

New member
Do you execute 1 instruction per step, or 1 cycle per step?
If you execute 1 inst/step, you should decrement your timers each 600 steps.
If you execute 1 cycle/step, you should decrement your timers each 60 steps.

Hope that makes sence!
 
OP
J

jesper

New member
Uhm... what's the difference between step and cycle?
I think in my emulator it is: 1 step = 1 cycle = 10 instructions.
 

GamerCat

New member
Well, as I understand it 1 cycle = 10 insts. And by step I mean one main loop cycle. Kinda hard to explain xD
 

Top