34 points · by remogatto · 15y ago · 8 comments
From the "Architecture" page[5]: In consequence, the whole emulation core is basically just one goroutine
[4]: Like, ridiculously more efficient, making it possible to sync millions of times per second. The system bsnes uses is called "libco", and although it doesn't have its own web-site, you can browse the code here: http://gitorious.org/bsnes/bsnes/blobs/master/bsnes/libco/
[5]: https://github.com/remogatto/gospeccy/wiki/Architecture
I think you are wrong. OK, it is true that the "emulation core" in GoSpeccy is not using any parallelism (the emulation core is fast enough, so what would be the reason for a parallel implementation there?), but it has a more concurrent design than (all?) other Spectrum emulators.
The part where you are wrong is that all video and audio postprocessing in GoSpeccy is designed to run in parallel to the hardware emulation (Z80 CPU, ULA chip). As I explained in [https://github.com/remogatto/gospeccy/wiki/Architecture], there are not many things which actually run in parallel, because the emulator is fast enough (50 frames per second).
But you can try the following: load some Spectrum game or demo that is painting to the screen a lot. Set scale to 2. Then increase FPS from 50 to 150 (or more, if you have a faster computer) and observe that the GoSpeccy Linux process will be automatically using more than 1 x86 CPU core. And it will manage to play sound without any hiccups. (But, of course, if you increase the FPS even more, you will reach a point where sound buffer underruns start to happen.)
Quoting from Effective Go[1]:
A goroutine has a simple model: it is a function executing in parallel with other goroutines in the same address space. It is lightweight, costing little more than the allocation of stack space. And the stacks start small, so they are cheap, and grow by allocating (and freeing) heap storage as required.
Goroutines are multiplexed onto multiple OS threads so if one should block, such as while waiting for I/O, others continue to run. Their design hides many of the complexities of thread creation and management.
Pixel timing accurate emulators exist -- in fact, C64 games written after ~1990 are useless without it.
GoSpeccy does not support any 384 line mode. As far as I know, the horizontal resolution is 256 pixels, so doubling that would yield 512 horizontal pixels.