A ZX Spectrum Emulator written in Go

Build Status

GoSpeccy - An evolving ZX Spectrum 48k Emulator

GoSpeccy is a free ZX Spectrum (Speccy for friends) emulator written in Go.

Quick start

Installing and starting GoSpeccy with Go1 is simple:

go get -v github.com/remogatto/gospeccy/src/gospeccy
gospeccy
gospeccy -wos="interlace demo"

Description

GoSpeccy is based on a concurrent architecture. We think the concurrency is a strong peculiarity of GoSpeccy as it opens new interesting scenarios when developing and using the emulator.

Go has interesting features that help in emulators development:

  • it has "low-level" similarities with C while allowing more productivity than C in certain cases

  • it is strongly typed and type safe so you are aware about certain errors at compile-time

  • it is garbage collected so there is small chance of memory leaks

  • it has an uint16 built-in type that helps dealing with 8/16 bit emulation

  • it has goroutines to enable concurrency in the emulator design and implementation

The Zilog Z80 CPU emulation is the core of GoSpeccy. The CPU emulation code is generated using a modified version of the z80.pl script shipped with FUSE (one of the best ZX Spectrum emulators around). The script has been hacked to generate Go code rather than C code.

Another source of inspiration was JSSpeccy, a neat Javascript Speccy emulator.

The Z80 emulation is tested against the excellent test-suite shipped with FUSE.

If you like this software, please watch it on github! Seeing a growing number of watchers is an excellent motivation for the GoSpeccy team to keep up this work :) Bug reports and testing are also appreciated! And don't forget to fork and send patches, of course ;)

Features

  • Complete (almost) Zilog Z80 emulation
  • Concurrent architecture
  • Beeper support
  • Initial support for Kempston joysticks
  • An interactive on-screen console interface based on clingon
  • Snapshot support: SNA, Z80 formats (48k versions)
  • Tape support (TAP format, read-only)
  • Accelerated tape loading
  • ZIP files support
  • SDL backend
  • 2x scaler and fullscreen

Using GoSpeccy

To make the screen bigger try the "-2x" command line option, or type "scale(2)" in the interactive console.

To try the classic Hello World try to press the following keys:

p
CTRL+p
hello world
CTRL+p
RETURN

For a nice picture of the speccy keyboard layout visit this page.

To load a program run:

gospeccy file.tap

To enable tape loading acceleration use the accelerated-load option. For a complete list of the command-line options run:

gospeccy -help

If you can't wait to see what this machine can do, try the nice Fire104b intro by Andrew Gerrand included in the gospeccy distribution! In the gospeccy folder, run:

gospeccy -2x snapshots/Syntax09nF.z80

To automatically download a program from World of spectrum, and start it:

gospeccy -wos="horace*tower"

For more, try searching the Internet for ZX Spectrum 48k games and demos in Z80 and TAP format. For example:

Key bindings

Host computer   ZX Spectrum
---------------------------
CTRL            SYMBOL SHIFT
LEFT SHIFT      CAPS SHIFT
[a-z0-9]        [A-Z0-9]
SPACE           SPACE

For more info about key bindings see file spectrum/keyboard.go

Proprietary games and system ROM

Generally, games/programs are protected by copyright so none of them is included in GoSpeccy. However, it is possible to find tons of games for the ZX Spectrum on the Internet. The system ROM for Spectrum 48k can be freely distributed and so it's included in the GoSpeccy distribution.

Convention over Configuration

Loading files in the emulator relies on a Convention over Configuration approach. To enjoy it, you should create the following folder structure:

mkdir -p $HOME/.config/gospeccy/roms			# System roms folder
mkdir -p $HOME/.config/gospeccy/programs		# Scripts folder
mkdir -p $HOME/.config/gospeccy/scripts			# Scripts folder

If you like to add your custom search path, In the scripts folder, create file config_local.go with the following contents:

// Search path for programs, scripts, etc
addSearchPath("/home/user/gospeccy")

After this, to load /home/user/gospeccy/programs/somegame.z80 simply execute:

gospeccy somegame.z80

Screenshots

Manic Miner running on GoSpeccy.

Manic Miner running on GoSpeccy

To Do

  • Fix some memory and I/O contention bugs
  • Add support for more file formats (take a look here)
  • Add support for tape saving
  • Better general performance
  • Add more filters and improve the scaler
  • Add new graphical backends (Go's exp/draw?)

Credits

  • Thanks to for giving a new whole direction to this project.
  • Thanks to the people on golang-nuts for giving feedback and support.
  • Thanks to Andrew Gerrand for the crackling Fire104b demo.

Contacts

License

Copyright (c) 2010 Andrea Fazzi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Owner
Andrea Fazzi
My first program was created on a rubbish black keyboard (ZX Spectrum). I was six years old. and I never stopped programming since.
Andrea Fazzi
Comments
  • Improve documentation

    Improve documentation

    A lot of things changed after the first gospeccy public release. We should improve and rewrite part of the documentation in order to reflect these changes. In particular, we should improve ChangeLog, README and add some pages to the wiki.

    To do on the ChangeLog:

    • Add latest changes cherry picking from git log output

    To do on the README:

    • Remove the "naive" adjective from the title and add something more appealing. Perhaps concurrent?
    • Tweak the introduction speaking about the new concurrent design resulting from 0xe2-0x9a-0x9b contribution
    • Add the new features in the feature list
    • Add a "Design" section?
    • Fix the Go-SDL dependency in "Dependencies" section. It actually depends by 0xe2-0x9a-0x9b/Go-SDL
    • Speak about the new console feature in "Quick start" section
    • Add more images. Perhaps an image of the speccy controlled from the console?
    • Add a "How to contribute" section explaining code conventions and the fork/pull request github cycle
    • Add a "CREDITS" section
    • Tell about Convention over Configuration for loading roms/sna/scripts

    To do on the wiki

    • Add a page with a nice picture showing the current design
  • Write tests for console.go

    Write tests for console.go

    I'd like to write a bunch of test cases for console.go before next release. However, console.go is in package main so it can't be tested with gotest. I'm evaluating to put console functionalities in an external package in order to test it.

  • Performance issue with current master

    Performance issue with current master

    I've got some performance issues running benchmarks against 4d55de27a2847f3599cc4c9355907d6fa9d04be7:

    cd src/spectrum
    make bench
    ...
    spectrum.BenchmarkRender         500       4397058 ns/op
    spectrum.BenchmarkZ80        500       2881148 ns/op
    

    It seems there is a slowdown compared with commit e7ce33673bdba3293abb133c22960bb9ca3af41f

    git checkout e7ce336
    make bench
    spectrum.BenchmarkRender        5000        590439 ns/op
    spectrum.BenchmarkZ80       1000       1907403 ns/op
    

    Perhaps there's something with my tests, I'll see.

  • Add Makefile install task to install bin and resource files

    Add Makefile install task to install bin and resource files

    Currently, the root Makefile lacks of an "install" task. This prevent the user to install the gospeccy executable in $GOBIN. It also prevent to install resources files like the system ROM.

  • Makefile overkill

    Makefile overkill

    The number of Makefile dependencies and their handling is really bad right now. This causes excessively long build times.

    # time make
    real    0m3.900s
    user    0m3.937s
    sys     0m0.522s
    
  • Pull up console from spectrum package

    Pull up console from spectrum package

    Perhaps we need to accomplish a better separation between the emulation core and the frontend pulling up console from spectrum package. Indeed I see the console as a part of the emulator frontend (gospeccy) rather than as a part of the emulator core (package spectrum).

  • Change import statement to use goinstall

    Change import statement to use goinstall

    GoSpeccy depends now for a couple of package hosted on github, namely

    • 0xe2-0x9a-0x9b/Go-SDL
    • 0xe2-0x9a-0x9b/Go-PerfEvents

    We should change import statements to the git path of these projects in order to make installation process painless through goinstall.

  • Exiting from GoSpeccy doesn't work again (issue reopened)

    Exiting from GoSpeccy doesn't work again (issue reopened)

    It seems that exiting from GoSpeccy by pressing ESC key or by issuing exit() command on the console doesn't work properly again. The problem seems to happen randomly.

  • stress1.go test doesn't pass

    stress1.go test doesn't pass

    The stress1.go SEGFAULTs with the following backtrace:

    panic: runtime error: SIGNONE: no trap
    
    runtime.panic+0x9f /home/andrea/src/go/src/pkg/runtime/proc.c:1101
        runtime.panic(0x8192f1c, 0x1926148)
    runtime.panicstring+0x61 /home/andrea/src/go/src/pkg/runtime/runtime.c:88
        runtime.panicstring(0x84368b0, 0xddbe78)
    runtime.sigpanic+0x5c /home/andrea/src/go/src/pkg/runtime/linux/thread.c:304
        runtime.sigpanic()
    
    goroutine 799 [4]:
    runtime.gosched+0x75 /home/andrea/src/go/src/pkg/runtime/proc.c:558
        runtime.gosched()
    runtime.selectgo+0x2c0 /home/andrea/src/go/src/pkg/runtime/chan.c:789
        runtime.selectgo(0x18dd270, 0x18de980)
    clingon.*Animation·animate+0x262 /home/andrea/src/clingon/animation.go:88
        clingon.*Animation·animate(0x18c6d60, 0x8057da6)
    runtime.goexit /home/andrea/src/go/src/pkg/runtime/proc.c:149
        runtime.goexit()
    
    goroutine 794 [4]:
    runtime.gosched+0x75 /home/andrea/src/go/src/pkg/runtime/proc.c:558
        runtime.gosched()
    runtime.selectgo+0x2c0 /home/andrea/src/go/src/pkg/runtime/chan.c:789
        runtime.selectgo(0x956b2b0, 0x18de900)
    clingon.*Animation·animate+0x262 /home/andrea/src/clingon/animation.go:88
        clingon.*Animation·animate(0x18c6620, 0x8057da6)
    runtime.goexit /home/andrea/src/go/src/pkg/runtime/proc.c:149
        runtime.goexit()
    

    ...

  • Cabal menu color-cycle speed

    Cabal menu color-cycle speed

    In the game Cabal (http://www.worldofspectrum.org/infoseekid.cgi?id=0000780), the speed of the main menu color-cycle is different than in other emulators (FUSE, Z80). The reason causing this behavior is unknown. The speed on actual ZX Spectrum hardware is unknown.

  • Sync generators

    Sync generators

    The perl script and the erb files in src/gen that generate opcodes.go and z80.go should be synced with the current status of these files in src/spectrum folder.

  • New to go :D I want to make a small change to generate .sna after loading .tap

    New to go :D I want to make a small change to generate .sna after loading .tap

    Hi, it seems I cannot find a way to convert a tap to sna without launching a emu, loading the tap, pausing it, generating a sna,etc... And I want this to be run in batch (nice because I can just run it with a For %i or whatever)

    I know what a .sna is, but I've thought I could dump to .sna, just right after the tap is loaded, or... put hook in the keyboard/joystick of the spectrum (a port read?), and generate the sna just right in the main title?.

    Well, I am new to ZX dev and learning Go, so excuse me if I am talking nonsense... I've been reading the source, a bit lost because is the first Go program I've studied wich uses channels, threads, etc... So I am a bit lost. If you have a tip, I could make the modification in local and use here, I guess this is of no use to other people (generally)

    thanks!

  • builds and runs on osx

    builds and runs on osx

    no code change - I just enabled the darwin target and added a few notes on how to get a working SDL 1 installed .... took me a few hours of head scratching.

  • can't clone - repository corrupt?

    can't clone - repository corrupt?

    $ go get -v github.com/remogatto/gospeccy/src/gospeccy
    github.com/remogatto/gospeccy (download)
    # cd .; git clone https://github.com/remogatto/gospeccy /Users/pmoore/go/src/github.com/remogatto/gospeccy
    Cloning into '/Users/pmoore/go/src/github.com/remogatto/gospeccy'...
    error: object cec29ea04ebd325e17a9defbd2ec1c027eaf703b: zeroPaddedFilemode: contains zero-padded file modes
    fatal: Error in object
    fatal: index-pack failed
    package github.com/remogatto/gospeccy/src/gospeccy: exit status 128
    
  • can't compile due to missing dependency?

    can't compile due to missing dependency?

    $ go get -x -v github.com/remogatto/gospeccy/src/gospeccy
    github.com/0xe2-0x9a-0x9b/Go-PerfEvents (download)
    cd .
    git clone https://github.com/0xe2-0x9a-0x9b/Go-PerfEvents /home/okmonk/go/src/github.com/0xe2-0x9a-0x9b/Go-PerfEvents
    Username for 'https://github.com': ^C
    

    At first I didn't know why it would ask me for username and password, but apparently there's 404 when trying https://github.com/0xe2-0x9a-0x9b/Go-PerfEvents

    Any thoughts on this? Thanks.

    PS: go version go1.0.2

  • hardware supported

    hardware supported

    is it possible to find out any information on supported hardware please fdd3000? PDS? micro command? im also interested in emulating the uhf cathode ray tube output authentically - i understand there are some serious health hazards - phosphoric delay and crosstalk synchronization - two effects barely touched on in the ula book has anyone access to the FCC ruling on why the zx specturm was not allowed into america? i guess cause we have better software than apple commodore and atari

Mettaur is GBA emulator written in golang.
Mettaur is GBA emulator written in golang.

Mettaur Mettaur is GBA emulator written in golang. Warning: This emulator is WIP, so many ROMs don't work correctly now. Run Please download latest bi

Dec 25, 2022
A GameBoy emulator written in Go

gogoboy A GameBoy emulator written in Go About this project This project is a proof of concept of building emulators with test driven development. I'v

Aug 20, 2022
Magia is GBA emulator written in golang.
Magia is GBA emulator written in golang.

magia is GBA emulator written in golang.

Dec 25, 2022
A toy GameBoy Color emulator written in golang.
A toy GameBoy Color emulator written in golang.

?? worldwide 日本語のドキュメントはこちら GameBoyColor emulator written in golang. This emulator can play a lot of ROMs work without problems and has many features.

Jan 1, 2023
A Chip8 emulator written in Go

A Chip8 Emulator in Go chip8.go is a simple Chip8 emulator, compliant with the technical standard laid out in the Cowgod's Manual. Graphics and sound

Jun 6, 2022
CHIP-8 Emulator written in Go
CHIP-8 Emulator written in Go

dP oo 88 .d8888b. 88d888b. dP 88d888b. 88d888b. dP dP 88' `"" 88' `88 88 88' `88 88' `88 88 88 88. ... 88 88 88 88. .88

Nov 26, 2021
NES emulator written in Go.
NES emulator written in Go.

Summary This is an NES emulator written in Go. Screenshots Title Screens http://www.michaelfogleman.com/static/nes/ Dependencies github.com/go-gl/gl/v

Dec 26, 2022
A simple CHIP-8 emulator written in Go

GoCHIP This is a simple CHIP-8 emulator written in Go. Check out this blogpost to learn more about CHIP-8 emulation: https://tobiasvl.github.io/blog/w

Jan 10, 2022
A CHIP-8 emulator written in Go

chip8 A CHIP-8 emulator written in Go. Usage Usage of chip8: -scaleFactor int Display scale factor (default 10) rom Path to ROM (m

May 25, 2022
Nintendo Entertainment System (NES) and Famicom emulator written in Go
Nintendo Entertainment System (NES) and Famicom emulator written in Go

go6502 Nintendo Entertainment System (NES) and Famicom emulator written in Go Dependencies go get -u github.com/go-gl/gl go get -u github.com/go-gl/gl

Apr 25, 2022
🕹️ A basic gameboy emulator with terminal "Cloud Gaming" support
🕹️ A basic gameboy emulator with terminal

Gameboy.Live ??️ Gameboy.Live is a Gameboy emulator written in go for learning purposes. You can simply play Gameboy games on your desktop: Or, "Cloud

Jan 1, 2023
Gopher2600 is an Atari 2600/VCS Emulator.
Gopher2600 is an Atari 2600/VCS Emulator.

Gopher2600 Gopher2600 is an emulator for the Atari 2600 written in the Go language. The accuracy of the emulation is very high and the 6507, TIA and R

Dec 8, 2022
A chip-8 emulator built with Go

Introduction Chip-8 is an interpretted language designed to create programs/games on the 8bit systems like the COSMAC VIP and Telmac 1800. Chyp8 is an

Oct 3, 2021
Golang RISC-V emulator that can play DOOM
Golang RISC-V emulator that can play DOOM

RISC-V Emulator A toy Golang RISC-V emulator that can play DOOM For now it uses smunaut bootloader and riscv_doom from the ICE40 project. But since th

Dec 12, 2022
Gones - An attempt to program a NES emulator

Gones - An attempt to program a NES emulator The following resources were used for the project: The great work on wiki.nesdev.org R650X and R651X Data

Jan 10, 2022
'mouseable' is keyboard-based mouse emulator for Windows.

Motivation Mouseable is intended to replace a mouse or trackpad. This program was inspired by Ultimate Hacking Keyboard Demo, Windows built-in functio

Dec 12, 2022
Sensor Emulator

Sensor Emulator This is a simple sensor emulator software implemented for IoT experiments. It emulates sensors sending data to an MQTT broker. Feature

Nov 28, 2021
VMAGI - Write an performant emulator in 24 hours!
VMAGI - Write an performant emulator in 24 hours!

VMAGI Welcome! VMAGI is a small emulator/interpreter my friend Matthew and I challenged each other to build in 24 hours. This includes both the implem

Nov 27, 2022
Chip-8 - A simple chip-8 emulator for golang
Chip-8 - A simple chip-8 emulator for golang

?? What the fuck is this A simple chip-8 emulator. Chip-8 is a simple, interpret

Aug 4, 2022