PHP Classes
elePHPant
Icontem

PHP Gameboy Emulator: Emulate Gameboy console in a terminal in pure PHP

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (17)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-09-10 (10 days ago) RSS 2.0 feedStarStarStarStar 69%Total: 315 This week: 2All time: 6,988 This week: 342Up
Version License PHP version Categories
php-terminal-gameboy 1.0.3MIT/X Consortium ...5.6PHP 5, Emulators, Games, Console
Collaborate with this project Author
Description

This package can emulate Gameboy console in a terminal in pure PHP.

It can run a Gameboy virtual machine by emulating its hardware and executing games Z80 CPU assembly code with PHP code.

The Gameboy screen is outputted to the terminal console using braille characters. Keyboard inputs are mapped to Gameboy key controls.

Innovation Award
PHP Programming Innovation award winner
March 2016
Winner


Prize: One big elePHPant Plush Mascott
Gameboy is a popular 8 bit console created in the 1980 decade.

This package can emulate a Gameboy in pure PHP code. It outputs the Gameboy screen to your console terminal using Braille characters.

Manuel Lemos
  Performance   Level  
Name: Gabriel Couto <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 29
All time rank: 3594290 in Brazil Brazil
Week rank: 335 Up18 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Details

<p align="center"><img src="https://cloud.githubusercontent.com/assets/2197005/13260438/2f6e96ac-da3a-11e5-86cf-bbfa15083f74.gif" width="560" alt="PHP Terminal GameBoy Emulator" /></p>

Build Status Software License Packagist

Want to play Dr Mario or Pokémon on your server terminal? That's for you!

Table of Contents

Why

Some people will ask me: _"Why you did that?"_

Well, a friend asked me _"What PHP can do?"_. I thought about that awhile and the idea came up. With PHP7's performance improvement now it's possible to emulate some systems :smile: and, come on, that's funny! :dancers:

It's based on the GameBoy JS Emulator.

Requirements

The following PHP versions are supported:

  • PHP 5.6
  • PHP 7
  • HHVM

You will need a good terminal! I've tested only on MacOSX and Linux. I'm sorry about that Windows guys :disappointed:

Installation

Using composer:

$ composer g require gabrielrcouto/php-terminal-gameboy-emulator:dev-master

Using PHAR:

$ wget https://raw.githubusercontent.com/gabrielrcouto/php-terminal-gameboy-emulator/master/bin/php-gameboy.phar
$ chmod +x php-gameboy.phar
$ mv php-gameboy.phar /usr/local/bin/php-gameboy

Running

Your roms are loaded from the directory you are running the php-gameboy command.

$ php-gameboy drmario.gb
$ php-gameboy pokemon.gbc

If you like to run this emulator locally, simple clone the repository:

$ git clone https://github.com/gabrielrcouto/php-terminal-gameboy-emulator.git
$ cd php-terminal-gameboy-emulator
$ composer install -o

For running roms, pass the full path to your rom or put then in the php-terminal-gameboy-emulator folder:

$ bin/php-gameboy pokemon.gbc
$ bin/php-gameboy /full/path/to/your/rom/drmario.gb

Controls

_n_________________
|_|_______________|_|
|  ,-------------.  |
| |  .---------.  | |
| |  |         |  | |
| |  |         |  | |
| |  |         |  | |
| |  |         |  | |
| |  `---------'  | |
| `---------------' |
|   _               |
| _|W|_         ,-. |
||A   D|   ,-. "._,"|
|  |S|    "._," Dot |
|    _  _ Comma     |
|   // //           |
|  // //    \\\\\\  |
|  N  M      \\\\\\ ,
|________...______,"

  • Left = A
  • Up = W
  • Down = S
  • Right = D
  • A = Comma (,)
  • B = Dot (.)
  • Select = N
  • Start = M

Tests

You can use the following command to run the most common checks, such as php -l, phpcs:

$ ant check

TO-DO

Converting from the JS paradigm was a lot of work, and I still need to adapt somethings like:

  • [x] Code standard - PSRs, please!
  • [x] Array of functions - Maybe in PHP it's not the best approach
  • [x] Pixel auxiliary array - Very CPU intensive to convert RGBA every time
  • [ ] Classes - Core is too big!
  • [ ] Profiling and otimizing - XHProf to find the most intensive functions
  • [ ] Save/Restore - I need to save my Pokémon, please!

Credits

@gabrielrcouto

Legal

The purpose of this project was to study all the capabilities of PHP.

It does not have any commercial or profitable intentions.

The user is responsible to use this code and its content in the terms of the law.

The author is completely against piracy and respects all the copyrights, trademarks and patents of Nintendo.

<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/bvezX9B9cTJTidmcB4iikNff/gabrielrcouto/php-terminal-gameboy-emulator'> <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/bvezX9B9cTJTidmcB4iikNff/gabrielrcouto/php-terminal-gameboy-emulator.svg' /></a>

Screenshots  
  • dr-mario.png
  Files folder image Files  
File Role Description
Files folder imagebin (2 files)
Files folder imagesrc (8 files, 1 directory)
Accessible without login Plain text file boot.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-php-7 Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Accessible without login Plain text file build Aux. Auxiliary script
  Accessible without login Plain text file php-gameboy Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
Files folder imageCanvas (2 files)
  Plain text file Cbopcode.php Class Class source
  Plain text file Core.php Class Class source
  Plain text file Data.php Class Class source
  Plain text file Keyboard.php Class Class source
  Plain text file LcdController.php Class Class source
  Plain text file Opcode.php Class Class source
  Plain text file Settings.php Class Class source
  Plain text file TICKTables.php Class Class source

  Files folder image Files  /  src  /  Canvas  
File Role Description
  Plain text file DrawContextInterface.php Class Class source
  Plain text file TerminalCanvas.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 94%
Total:315
This week:2
All time:6,988
This week:342Up
User Ratings User Comments (5)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:95%StarStarStarStarStar
Documentation:-
Examples:95%StarStarStarStarStar
Tests:-
Videos:-
Overall:69%StarStarStarStar
Rank:443
 
Haha, I liked to play with this
1 year ago (Joubert RedRat)
70%StarStarStarStar
Excellent php class package, great idea, this Mister Gabriel ...
1 year ago (marcosptf)
70%StarStarStarStar
Congratulations, this is a superb class ;-)
1 year ago (José Filipe Lopes Santos)
70%StarStarStarStar
Congratulations, this is a superb class ;-)
1 year ago (José Filipe Lopes Santos)
70%StarStarStarStar
Congratulations, this is a superb class ;-)
1 year ago (José Filipe Lopes Santos)
70%StarStarStarStar