Git Product home page Git Product logo

gospeccy's Introduction

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.

gospeccy's People

Contributors

atomsymbol-notifications avatar ivorget avatar mjgarton avatar remogatto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gospeccy's Issues

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!

Resolve public/private ambiguities in method names

We should decide which of the public methods in the current API should really be public. Here below a list of candidate methods to be eventually privatized. Please, add others if it is the case.

  • NewMemory
  • NewUla
  • NewPorts

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

Slow emulation of some applications

In some applications an artificial slowdown has been observed. The host CPU is well below 100% utilization, but the Z80 emulation is noticeably slower than it should be. I guess this is due to the sdl.Delay(20) call in gospeccy.go main loop that constantly slows down the execution. On slower machines or when emulating cpu-intensive applications, we need a way to dynamic adjust that delay.

Problem with sdl shared library

When executing a gospeccy binary linked against http://github.com/remogatto/Go-SDL package I get

$ ./gospeccy
./gospeccy: error while loading shared libraries: cgo_sdl.so: cannot open 
shared object file: No such file or directory

It seems it's a problem of remogatto/Go-SDL binding. BTW, I open the issue here for better readability.

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

GoSpeccy running as a service

Since at the moment the Go language doesn't provide cgo support for ARM devices, these devices can't run the emulator. In fact, cgo is needed in order to support the SDL backend. A solution could be running the emulator as a service that sends video/audio informations to a browser through websockets.

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

Copy/Paste support

It would be nice to add a copy/paste mechanism through the console. It would be useful for sending BASIC snippets to the emulator.

Fix tests

Tests need to be fixed now that the design seems to be a bit more stable and the main gospeccy master branch was merged with 0xe2-0x9a-0x9b branch.

Fullscreen mode hack

What about slightly modify the vertical size of the border to 24 in order get a perfect 640x480 fit when in fullscreen mode?

License

Think about changing license from MIT to GPLv3.

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).

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.

Convention over configuration for snapshots/roms load

Add a bit of convention of configuration spice when loading sna/roms.

The search should be performed following the order:

  1. ./
  2. $HOME/.gospeccy/sna

For example, given the following situation:

$ ls
game1.sna
$ gospeccy game1.sna

GoSpeccy will simply load ./game1.sna adhering to the principle of least surprise.

However, trying to load a snapshot that doesn't exist in the current directory:

$ gospeccy game2.sna

GoSpeccy will load $HOME/.gospeccy/sna/game2.sna if it exists. Otherwise, an error will be raised.
The same will apply when support for z80 format will be added: in this case GoSpeccy will search for files in $HOME/.gospeccy/z80/.

gospeccy wont compile on OS X

gospeccy has a dependency on Go-PerfEvents, which looks to be linux only.
As a result, I can't compile (and thus can't execute) gospeccy on my Mac :-(

RANDOMIZE USR 0

Executing "RANDOMIZE USR 0" in Basic fails to reset the machine.

BASIC snippets

It would be nice to add a BASIC snippets section to the wiki. The section would contain short piece of BASIC code illustrating some funny things of the speccy and/or of the emulator (border scrolling, beeper effects, etc).

For example:

10 BORDER 0
20 BORDER 1
30 BORDER 2
40 GOTO 10

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.

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

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

Keyboard device on a separate goroutine?

Emulating the keyboard device on a separate goroutine could help in programmatically sending key events through channels. The main advantage would be about keydown/keyup timing. In fact, to simulate a keypress event (key pressed and released in a short time) it's necessary to send a keydown/keyup events pair. However, a keydown event can not be immediately followed by a keyup event because the system ROM would not be aware of the two events if they occured in a short interval of time (<20 ms). So, after pressing down a key it's necessary to wait a certain amount of time before releasing it. BTW, a call to time.Sleep would be blocking for the emulation goroutine. With a channel based approach such non-blocking synchronization should be easier to implement.

Simulating keypress, keydown/keyup events could be useful in a couple of use cases:

  • when loading tapes through the system ROM in order to trigger system ROM loading routine by sending LOAD ""
  • in tests
  • for simulating key pressing in games

Performance issue with current master

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

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 e7ce336

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.

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.

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()

...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.