We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!
I'm trying to write an emulator for learning experience. It's a chip8 emulator. The emulator also include video memory, which i would like to display.
The thing i haven't figured out yet is how to "loop" my emulation "outside" the draw loop? I want my emulator to process code between every call to draw(). Otherwise if, say i have a framerate at 60 fps, my emulator also processes instructions only 60 times per second, which would make it a pretty slow CPU. :)
To clarify, i still want the draw function to render the videomemory from the emulator at 60fps. But i also want the emulator parsing code at full speed "between" the rendered frames.
I doubt it would be good practice to crank the framerate up to 1000fps? :)
Hope you understand what i mean.
/Mats
Answers
How does your emulator send data to processing? If you have a serial connection for example, the serial event will intercept any data arriving through the connection. You can process it and display it in the next frame in draw. The serialEvent() is not locked to the draw thread.
Kf
@Kaggen --
Are you trying to write the emulator in Processing in the same sketch but in a separate thread from the draw() loop? If so, perhaps try
thread()
Here is an example of a separate thread implementation in a recent previous discussion:
Yes. Sorry if i was unclear, but my goal is to write the whole thing in Processing. The whole emulator, including loading programs, parsing opcodes, executing opcodes and displaying on screen. All in the same sketch as you say.
I have actually written a large part of this already in C on a Linux machine, but became a bit frustrated when i was about to implement the GUI part in GTK. I have almost written as many lines of code for the GUI part as the whole emulating part and still got more to do. Don't get me wrong, this is a very simple emulator (or virtual machine). Nothing like a Nintendo emulator or the like. The graphics have a whooping 64x32 monochrome pixel resolution. :)
I will check out your links Jeremy, thank you. Threading might be what i'm looking for. Didn't even think about that. :)
/Mats
Good luck, @Kaggen.
thread()
is simple and easy to use, but very limited. You can also use full JavaThread
s. There are example discussions of both in the forum: