But that's the whole bloody point, is it not? The fact that your users can play games is a side-effect of your crusade to perfect the emulation and hardware synch. Admit itCongrats, now next logical strep would be to try something more serious like Saturn or the joyful fun of Megadrive+MegaCD+32X combo. 5+ CPUs, bunch of custom chips with incomplete documentation all running at the same time, all for your synchronization enjoyment. Try to make it perfect, and you won't be bored for the rest of your life!I think Chip8 was a pretty good suggestion to get some quick satisfaction, learn a few 'obvious' things, and get prepared for something a bit more interesting. So thanks for the suggestion and I certainly would recommend anyone interested who hasn't written an emulator before to dive in and have a go. Maybe if a bunch of people did this, in a bunch of months/years (or perhaps decades in my case) we might have a bunch more people on the boards working on cool emulators (that people actually want to use)!
Hmmmm must not read too much into this...Congrats, now next logical strep would be to try something more serious like Saturn or the joyful fun of Megadrive+MegaCD+32X combo. 5+ CPUs, bunch of custom chips with incomplete documentation all running at the same time, all for your synchronization enjoyment. Try to make it perfect, and you won't be bored for the rest of your life!I think Chip8 was a pretty good suggestion to get some quick satisfaction, learn a few 'obvious' things, and get prepared for something a bit more interesting. So thanks for the suggestion and I certainly would recommend anyone interested who hasn't written an emulator before to dive in and have a go. Maybe if a bunch of people did this, in a bunch of months/years (or perhaps decades in my case) we might have a bunch more people on the boards working on cool emulators (that people actually want to use)!
http://linux.die.net/man/2/nanosleepI thought I could just process one instruction then sleep, but obviously that doesn't work if SDL_GetTicks has accuracy in milliseconds (as does SDL_Delay probably).
Each instruction takes a set time to run. Emulate the correct number of instructions for a frame. I use 15. At the end of the frame, signal a display update. I use a timer that triggers every 20ms (50Hz in the UK), it emulates the required instructions and then if the display requires an update you go for it.I thought that if the Chip8 runs at 0.6 MHz (600,000Hz), then I could emulate 1/60th of this, so emulate 10000 instructions and then wait draw/sync to 60hz. But I'm not sure this is working. Something obvious I am missing?
Take it steady - pick something with a CPU clocked at 1MHz - 4MHz that you enjoyed as a kid. Then aim to get the boot-up sequence done, then the user interface (if there was one) working. After that, you can move onto something more complex, or start to optimise and add more esoteric behaviours.Can't remember if there was anything else I wanted to add/fix, or whether that is Chip8 finished for now, ready to move onto something more exciting!
I would love to be writing a GameBoy/NES/MasterSystem emulator (GameBoy and MasterSystem in particular, as both have games I would play through in my own emulator), but feel they are quite a stretch after the simple Chip8 experiment, so 8080 next and then see where I can go from there...If you think CHIP8 is too easy, or GameBoy/NES/MasterSystem is too hard, writing a Space Invaders emulator is not
__builtin_parity(value)