Michael Darby - 314Reactor
Published © GPL3+

Battlegrounds on Game Boy Color

The reason: I’ve seen quite a few cool projects with Gameboy and Raspberry Pi.

IntermediateFull instructions provided8 hours6,161
Battlegrounds on Game Boy Color

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Gameboy Color Shell
×1
3.7 V LiPo Battery
×1
SD card
×1
Adafruit Powerboost 500c
×1
Adafruit Pi TFT 2.2
×1
Gameboy blank cart shell
×1
buttons
×1
Adafruit Speaker
×1
GBC Buttons
×1
I2S DAC
×1
Slide Switch
Slide Switch
×1
Sugru
×1
Veroboard
×1

Software apps and online services

Pi Bakery
Moonlight stream

Hand tools and fabrication machines

Dremel
Snips
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Code snippet #1

Plain text
Section "Device"  
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb0"
EndSection

Code snippet #2

Plain text
Section "Device"  
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb0"
EndSection

Main code

Python
This is the code that lets the buttons do things on the system.
import RPi.GPIO as GPIO
import time
import uinput

GPIO.setmode(GPIO.BCM)

GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)


device = uinput.Device([
        uinput.BTN_LEFT,
        uinput.BTN_RIGHT,
        uinput.REL_X,
        uinput.REL_Y,
		uinput.KEY_W,
		uinput.KEY_S,
		uinput.KEY_EQUAL,
		uinput.KEY_F,
        ])

try:
	while True:
		input_down = GPIO.input(27)
		input_a = GPIO.input(22)
		input_b = GPIO.input(23)
		input_right = GPIO.input(24)
		input_left = GPIO.input(17)
		input_start = GPIO.input(5)
		input_up = GPIO.input(6)
		input_select = GPIO.input(12)

		if input_up == False:
			device.emit(uinput.REL_Y, -60)
			time.sleep(0.1)
			
		if input_down == False:
			device.emit(uinput.REL_Y, 60)
			time.sleep(0.1)
			
		if input_left == False:
			device.emit(uinput.REL_X, -60)
			time.sleep(0.1)
			
		if input_right == False:
			device.emit(uinput.REL_X, 60)
			time.sleep(0.1)
			
		if input_start == False:
			device.emit_click(uinput.KEY_EQUAL)
			time.sleep(0.2)
			
		if input_select == False:
			device.emit_click(uinput.KEY_F)
			time.sleep(0.2)
			
		if input_a == False:
			device.emit_click(uinput.BTN_RIGHT)
			time.sleep(0.2)
			
		if input_b == False:
			device.emit_click(uinput.BTN_LEFT)
			time.sleep(0.2)

finally:  
    GPIO.cleanup()

Shell command for running moonlight

SH
This is the shell command for running moonlight that was put into a .sh file on the desktop, it is configured to load steam at the resolution of the Pi TFT
moonlight stream -width 320 -height 240 -fps 30 -localaudio -app steam --unsupported

Config.txt

INI
Config file required for getting the proper resolution on the Pi TFT with fbcp
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
framebuffer_width=320
framebuffer_height=240

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=87
hdmi_cvt=320 240 60 1 0 0 0

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtoverlay=hifiberry-dac
dtoverlay=i2s-mmap

# --- added by adafruit-pitft-helper Mon 11 Sep 07:15:48 UTC 2017 ---
[pi1]
device_tree=bcm2708-rpi-b-plus.dtb
[pi2]
device_tree=bcm2709-rpi-2-b.dtb
[all]
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft22,rotate=90,speed=32000000,fps=60
# --- end adafruit-pitft-helper Mon 11 Sep 07:15:48 UTC 2017 ---

Github file

https://github.com/notro/fbtft/wiki/Framebuffer-use

Credits

Michael Darby - 314Reactor

Michael Darby - 314Reactor

55 projects • 143 followers
I like to keep fit, explore and of course make projects.

Comments