Code Monkey home page Code Monkey logo

gameboy.live's Introduction

Gameboy.Live

🕹️ Gameboy.Live is a Gameboy emulator written in go for learning purposes. You can simply play Gameboy games on your desktop:

https://github.com/HFO4/gameboy.live/raw/master/doc/screenshot.png

Or, "Cloud Game" in your terminal with a single command (The demo server is down now, you have to deploy on you own server):

telnet gameboy.live 1989

https://github.com/HFO4/gameboy.live/raw/master/doc/cloud-gaming.gif

Even play with other visitors together on someone's GitHub profile:

https://user-images.githubusercontent.com/16058869/97843755-cff68580-1d24-11eb-85ef-ca9ae3f2f195.gif

Installation

You can directly download the executable file from the Release page, or build it from the source. Go Version 1.11 or higher is required. Run go version to check what the version currently installed is. On Debian based systems, the packages libasound2-dev and libgl1-mesa-dev must be installed.

git clone https://github.com/HFO4/gameboy.live.git
cd gameboy.live
go build -o gbdotlive main.go

Usage

Usage of gbdotlive:
  -G    Play specific game in Fyne GUI mode
  -S    Start a static image cloud-gaming server
  -c config
        Set the game option list config file path
  -d    Use Debugger in GUI mode
  -f FPS
        Set the FPS in GUI mode (default 60)
  -g    Play specific game in GUI mode (default true)
  -h    This help
  -m    Turn on sound in GUI mode (default true)
  -p port
        Set the port for the cloud-gaming server (default 1989)
  -r ROM
        Set ROM file path to be played in GUI mode
  -s    Start a cloud-gaming server

GUI mode

Play a specified ROM file in GUI mode:

gbdotlive -G -r "Tetris.gb" 

Set up a telnet Cloud Gaming server

You can use Gameboy.Live as a "Cloud Gaming" server, where players use telnet to play Gameboy games in terminal without additional software installation required. (Except telnet itself xD)

A gamelist.json config file is required to specify game options. This is a typical example:

[{
	"Title": "Tetris",
	"Path": "test.gb"
}, {
	"Title": "Dr. Mario",
	"Path": "Dr. Mario (JU) (V1.1).gb"
}, {
	"Title": "Legend of Zelda - Link's Awakening",
	"Path": "Legend of Zelda, The - Link's Awakening (U) (V1.2) [!].gb"
}]

It is recommended to test every ROM before putting them in the config file.

Next, start a Gameboy.Live server with the config file from the previous step:

gbdotlive -s -c "gamelist.json"

You will see an output like this, which means your server has started successfully:

2019/04/30 21:27:56 Listen port: 1989 

Now, you can play games anywhere you want! The simulation and rendering process is done entirely on the server.

telnet <ip of your server>:<port>

"Cloud Gaming" is only supported in terminals which support standard ANSI and the UTF-8 charset. You can use WSL instead of CMD on Windows.

Set up a static Cloud Gaming server

You can also set up a static cloud gaming server, where one specific game is emulated, everone can play it cooperatively by clicking hyperlinks. Start such a server with folowing command:

gbdotlive -S -r "Pokemon - Red Version (USA, Europe) (SGB Enhanced).gb" 

A HTTP server will start up on default port 1989, these HTTP routes is avaliable to use:

Routes Method Description
/image GET Show the latest game screenshot.
/svg?callback=[Redirect URL] GET Show the latest game screenshot with Gameboy style border and clickable gamepad. An SVG template gb.svg is required.
/control?button=[Button ID]&callback=[Redirect URL] GET Send new gamepad input.

WebSockets streaming

Thanks to szymonWojdat, you can use websockets interface for sending static images so that you don't need to reload the website after each button press.

Make sure the static server above is already started up on default port 1989.

  • Use ws://localhost:1989/stream route in order to start a websocket communication channel.
  • Images will be streamed to the client in PNG encoding.
  • The client can send their input commands in text format using one of these codes:
    • Right Arrow: 0
    • Left Arrow: 1
    • Up Arrow: 2
    • Down Arrow: 3
    • A: 4
    • B: 5
    • Select: 6
    • Start: 7
  • check out client_demo.html for a simple demo and don't forget to run the server before by using the command above 🌝

Debug

Gameboy.Live has a simple built-in debugger. To turn on debug mode, set the d flag to true:

gbdotlive -r "test.gb" -d=true

The emulator will firstly break at the ROM entry point 0x0100 in debug mode, which is the entry point of the game program. You can type the address of next breakpoint. The emulator will continue to run until the next breakpoint is reached. At each breakpoint, the emulator will print the register's contents like above and dump the main memory into memory.dump (ROM and RAM bank not included)

[OP:NOP]
AF:01B0  BC:0013  DE:00D8  HL:014D  SP:FFFE   
PC:0100  LCDC:91  IF:E1    IE:00    IME:false 
LCD:100 

Keyboard instruction

Keyboard Gameboy
Enter Start
Backspace Select
Up
Down
Left
Right
X A
Z B

Features & TODOs

  • CPU instruction emulation
  • Timer and interrupt
  • Support for ROM-only, MBC1, MBC2, MBC3 cartridge
  • Sound emulation
  • Graphics emulation
  • Cloud gaming
  • ROM debugger
  • Game saving & restore in cartridge level

There are still many TODOs:

  • Support Gameboy Color emulation
  • Support for MBC4, MBC5, HuC1 cartridge
  • Sound simulation is incomplete, still got differences compared to the Gameboy real machine
  • Sprite priority issue (see Wario Land II and Metroid II: Return of Samus)
  • Failed to pass Blargg's instruction timing test
  • Game saving & restore in emulator level
  • Multiplayer support in cloud gaming mode

Testing

Testing result

Contribution

This emulator is just for learning and entertainment purposes. There are still many places to be perfected. Any suggestions or contributions is welcomed!

Credits

Thanks:

Reference

gameboy.live's People

Contributors

andydotxyz avatar hfo4 avatar lvskng avatar maxolasersquad avatar spellarbot avatar szymonwojdat avatar tilkinsc 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  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

gameboy.live's Issues

help

how to fix this:
[dorker@leo10 gameboy.live]$ gbdotlive -G -r "Tetris.gb"
bash: gbdotlive: command not found
[dorker@leo10 gameboy.live]$ sudo gbdotlive -G -r "Tetris.gb"
sudo: gbdotlive: command not found
[dorker@leo10 gameboy.live]$ go gbdotlive -G -r "Tetris.gb"
go gbdotlive: unknown command
Run 'go help' for usage.
[dorker@leo10 gameboy.live]$

Where can I find the gb files?

Thanks for this repo. But when I run this project, it shew me "open Dr. Mario (JU) (V1.1).gb: no such file or directory".

➜ gameboy.live git:(master) ✗ ./gbdotlive -s -c "gamelist.json"
2021/03/06 21:59:26 Listen port: 1989
2021/03/06 22:00:26 New Player: 1c4e580b-dee2-4a56-b800-bd34c225eb29
2021/03/06 22:01:39 [Core] Loading rom file...
2021/03/06 22:01:39 open Dr. Mario (JU) (V1.1).gb: no such file or directory

Can't build on PI

I wanto to build it on Raspberry Pi, but encountered the following erros:

main.go:7:2: cannot find package "github.com/HFO4/gbc-in-cloud/driver" in any of:
	/usr/lib/go-1.7/src/github.com/HFO4/gbc-in-cloud/driver (from $GOROOT)
	($GOPATH not set)
main.go:8:2: cannot find package "github.com/HFO4/gbc-in-cloud/fyne" in any of:
	/usr/lib/go-1.7/src/github.com/HFO4/gbc-in-cloud/fyne (from $GOROOT)
	($GOPATH not set)
main.go:9:2: cannot find package "github.com/HFO4/gbc-in-cloud/gb" in any of:
	/usr/lib/go-1.7/src/github.com/HFO4/gbc-in-cloud/gb (from $GOROOT)
	($GOPATH not set)
main.go:10:2: cannot find package "github.com/HFO4/gbc-in-cloud/server" in any of:
	/usr/lib/go-1.7/src/github.com/HFO4/gbc-in-cloud/server (from $GOROOT)
	($GOPATH not set)

I have installed the libasound2-dev and libgl1-mesa-dev.

build error

my go version 1.11.11

go build -o gbdotlive main.go

github.com/go-gl/glfw/v3.2/glfw

In file included from ../github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:24:0:
../github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
../github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
^~~~~~~
In file included from /usr/include/stdio.h:862:0,
from /usr/include/X11/Xcursor/Xcursor.h:26,
from ../github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_platform.h:39,
from ../github.com/go-gl/glfw/v3.2/glfw/glfw/src/internal.h:169,
from ../github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_init.c:28,
from ../github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw

In file included from ../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:24:0:
../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
^~~~~~~
In file included from /usr/include/stdio.h:862:0,
from /usr/include/X11/Xcursor/Xcursor.h:26,
from ../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_platform.h:39,
from ../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/internal.h:169,
from ../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_init.c:28,
from ../fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

github.com/HFO4/gbc-in-cloud/server

../github.com/HFO4/gbc-in-cloud/server/player.go:51:4: cannot use Driver (type *"github.com/HFO4/gbc-in-cloud/driver".ASCII) as type "github.com/HFO4/gbc-in-cloud/driver".DisplayDriver in field value:
*"github.com/HFO4/gbc-in-cloud/driver".ASCII does not implement "github.com/HFO4/gbc-in-cloud/driver".DisplayDriver (wrong type for Run method)
have Run(chan bool)
want Run(chan bool, func())
../github.com/HFO4/gbc-in-cloud/server/player.go:289:38: not enough arguments in call to player.Emulator.DisplayDriver.Run
have (chan bool)
want (chan bool, func())

why telnet?

why not playable via browser? nobody knows/uses telnet?!

No such file or directory

I run gameboy on docker. docker run --name gbdotlive -v /[REDACTED]/gameboy:/data -p 1989:1989 shokinn/docker-gameboy.live

After selecting a game and press enter at the 'here is the controls' page, container crashes w/
open 'Pokemon - Red Version (USA, Europe).gb': no such file or directory in container log

drwxrwxr-x  2 eric eric 4.0K May 14 23:43  .
drwxrwxr-x 14 eric eric 4.0K May 14 23:30  ..
-rwxr-xr-x  1 eric eric 512K May 14 23:30 'Donkey Kong (JU) (V1.1) [S][!].gb'
-rwxr-xr-x  1 eric eric 512K May 14 23:30 'Legend of Zelda, The - Link'\''s Awakening (U) (V1.2) [!].gb'
-rwxr-xr-x  1 eric eric 1.0M May 14 23:30 'Pokemon - Red Version (USA, Europe).gb'
-rwxr-xr-x  1 eric eric  32K May 14 23:30 'Tetris (World).gb'
-rw-rw-r--  1 eric eric  348 May 14 23:40  gamelist.json

gamelist.json

[{
        "Title": "Tetris",
        "Path": "Tetris (World).gb"
}, {
        "Title": "Donkey Kong",
        "Path": "Donkey Kong (JU) (V1.1) [S][!].gb"
}, {
        "Title": "Legend of Zelda - Link's Awakening",
        "Path": "Legend of Zelda, The - Link's Awakening (U) (V1.2) [!].gb"
}, {
        "Title": "Pokemon - Red",
        "Path": "Pokemon - Red Version (USA, Europe).gb"
}]

BUILD ERROR

  • OS: Ubuntu 18.04 bionic
  • go version go1.14.3 linux/amd64
➜  Gameboy.Live git:(master) go build -o gbdotlive main.go
# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/c_glfw_linbsd.go:24:0:
../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
             snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
                                          ^~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/X11/Xcursor/Xcursor.h:26,
                 from ../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/glfw/src/x11_platform.h:39,
                 from ../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/glfw/src/internal.h:169,
                 from ../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/glfw/src/x11_init.c:28,
                 from ../../../../pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# pkg-config --cflags  -- gl gl
pkg-config: exec: "pkg-config": executable file not found in $PATH
# pkg-config --cflags  -- gl gl
pkg-config: exec: "pkg-config": executable file not found in $PATH

Conection Refused

I´ve tryed both windows and linux terminal:
"telnet gameboy.live 1989"
and i always get:
"telnet: Unable to connect to remote host: Connection refused"

I´ve also tried from mobile phone using 4G

Telnet server is down?

Hey, great project :)

I was trying to connect to telnet gameboy.live 1989, yet all I'm getting is Trying 47.74.183.161...
Is the server down?

I'm not sure if that's even an actual server 😅 or if we're supposed to host our own server first.

About translation contribute

Hello, we are Korean university students. This project is an area we are interested in, so we would like to contribute.
We want to contribute through the Korean translation of the project. Can you give us permission?

Compile error / no release version yet

encountered this error when trying to compile on my Macbook

main.go:7:2: cannot find package "github.com/HFO4/gbc-in-cloud/driver" in any of:
	/usr/local/Cellar/go/1.10.3/libexec/src/github.com/HFO4/gbc-in-cloud/driver (from $GOROOT)
	/Users/zxybazh/goforest/src/github.com/HFO4/gbc-in-cloud/driver (from $GOPATH)
main.go:8:2: cannot find package "github.com/HFO4/gbc-in-cloud/gb" in any of:
	/usr/local/Cellar/go/1.10.3/libexec/src/github.com/HFO4/gbc-in-cloud/gb (from $GOROOT)
	/Users/zxybazh/goforest/src/github.com/HFO4/gbc-in-cloud/gb (from $GOPATH)
main.go:9:2: cannot find package "github.com/HFO4/gbc-in-cloud/server" in any of:
	/usr/local/Cellar/go/1.10.3/libexec/src/github.com/HFO4/gbc-in-cloud/server (from $GOROOT)
	/Users/zxybazh/goforest/src/github.com/HFO4/gbc-in-cloud/server (from $GOPATH)
main.go:10:2: cannot find package "github.com/faiface/pixel/pixelgl" in any of:
	/usr/local/Cellar/go/1.10.3/libexec/src/github.com/faiface/pixel/pixelgl (from $GOROOT)
	/Users/zxybazh/goforest/src/github.com/faiface/pixel/pixelgl (from $GOPATH)

Issue with High Sierra

Since merging in #10 the app has been working but today I tested on mac OS High Sierra and saw a lot of

2019-05-14 23:30:17.338 main[50763:1244727] pid(50763)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

and the app never started.
It seems like the "core.Run()" is required to be called from the main thread on mac OS that is not required on Linux.

I cannot seem to get to the bottom of this so thought I would log this issue instead.
I suspect that there are some OS input handling baked into the core package that I did not find when extracting the last of the graphics code to the "driver" package.

Greetings!

This is a very well put together project. Could you list more about the project, your motives, etc on the readme?

I am currently creating a gameboy emulator written in C++. I am also writing an assembler (with uniquely named opcodes) which in its core targets specifically the gb.

Here are some easy resources I have found for quick lookup of ops:
http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
http://imrannazar.com/Gameboy-Z80-Opcode-Map

In my assembler, I have switched LD (HL), * to SV (HL), * and some other changes that make sense. Like ADD A, * is just ADD *. I am interested in where you are leading this project and how you are going to implement state saving. For example, are you just going to dump a rom's-worth of memory or just the changes to the memory... are you going to make it modular in the sense you can serialize data structures and just reimport them?

I want my assembler to be able to export standard roms (and mine generated matches that of the standard bin) into source.

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.