[Python] A memo to operate ROM created by GBDK with PyBoy

It is a memo to operate ROM created by GBDK with PyBoy. This implementation is published in the following repository. https://github.com/Kazuhito00/pyboy-gbdk-examples

What is PyBoy

A Game Boy emulator written in Python. It seems that it is developing not just an emulator but also a platform for reinforcement learning. https://github.com/Baekalfen/PyBoy

What is GBDK

Abbreviation for GameBoy Developers Kit, freeware that allows you to develop Game Boy software in C or assembly language. http://gbdk.sourceforge.net/

Installation GBDK

  1. Download the GBDK main unit from the link below
    https://sourceforge.net/projects/gbdk/files/gbdk/
    In this sample, the Windows version ([gbdk-2.95-win32.zip](https: /) /sourceforge.net/projects/gbdk/files/gbdk-win32/2.95/gbdk-2.95-win32.zip/download)) is used.
  2. Unzip to any folder such as "C: \ gbdk"
  3. Add "C: \ gbdk \ bin" to the system environment variable of Windows
    * If you decompress other than "C: \ gbdk", you need to change the path according to the answer location.

PyBoy

  1. Install SDL2
     Ubuntu: sudo apt install libsdl2-dev
     Fedora: sudo dnf install SDL2-devel
     macOS: brew install sdl2
     Windows: (New-Object Net.WebClient).DownloadFile('https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip', 'SDL2-devel-2.0.10-VC.zip')
      : Expand-Archive -Force 'SDL2-devel-2.0.10-VC.zip' C:\SDL2\
      : setx PYSDL2_DLL_PATH C:\SDL2\SDL2-2.0.10\lib\x64
      : setx PATH "%PATH%;C:\SDL2\SDL2-2.0.10\lib\x64"
  2. Install PyBoy with pip
    python3 -m pip install --upgrade pip
    python3 -m pip install pyboy

Hello World You can create Hello Work with printf ().

hello_world.c


#include <stdio.h>
#include <gb/gb.h>
#include <gb/console.h>

int main(void)
{
    gotoxy(0, 0);  //Specify drawing coordinates
    printf("Hello World\n");
}

Compiled with GBDK's LCC compiler.

c:\gbdk\bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -c -o hello_world.o hello_world.c
c:\gbdk\bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wl-yt2 -Wl-yo4 -Wl-ya4 -o hello_world.gb hello_world.o

Launch with PyBoy

from pyboy import PyBoy

#Start PyBoy
color_palette = [0xd6e895, 0xacc04c, 0x527d3e, 0x264a2e]  #Game Boy-like color palette specification
pyboy = PyBoy('hello_world.gb', color_palette=color_palette)

while not pyboy.tick():
    pass

Success if the following window appears. 2020-06-20 (7).png

that's all.

Recommended Posts

[Python] A memo to operate ROM created by GBDK with PyBoy
A memo connected to HiveServer2 of EMR with python
[Python] A memo to write CSV vertically with Pandas
Operate a receipt printer with python
Try to operate Facebook with Python
How to batch start a python program created with Jupyter notebook
[Python] A memo that I tried to get started with asyncio
Pass a list by reference from Python to C ++ with pybind11
Convert memo at once with Python 2to3
Memo to ask for KPI with python
Created a darts trip with python (news)
I tried to communicate with a remote server by Socket communication with Python.
A memo organized by renaming the file names in the folder with python
A memo that allows you to change Pineapple's Python environment with pyenv
A memo corresponding to Django's runserver moss in Python 2.7.11 entered with Homebrew
How to read a CSV file with Python 2/3
Send a message to LINE with Python (LINE Notify)
I want to make a game with Python
Try to make a "cryptanalysis" cipher with Python
Decide to assign a laboratory with Python (fiction)
A memo when creating a python environment with miniconda
Steps to create a Twitter bot with python
Try to make a dihedral group with Python
A simple to-do list created with Python + Django
A memo for creating a python environment by a beginner
Read line by line from a file with Python
I want to write to a file with Python
A layman wants to get started with Python
[Python] Created a class to play sin waves in the background with pyaudio
[Keras] Personal memo to classify images by folder [Python]
How to convert / restore a string with [] in python
Memo to create your own Box with Pepper's Python
[Python] How to draw a line graph with Matplotlib
Visualization memo by Python
Try to make a command standby tool with python
Python Ver. To introduce WebPay with a little code.
I tried to draw a route map with Python
Try to operate DB with Python and visualize with d3
A story about how Windows 10 users created an environment to use OpenCV3 with Python 3.5
Introduction to Mathematics Starting with Python Study Memo Vol.1
Operate Kinesis with Python
How to publish GitHub Pages with Pelican, a static HTML generator made by Python
I want to work with a robot in python.
From buying a computer to running a program with python
Operate Blender with Python
I tried to automatically generate a password with Python3
A program to write Lattice Hinge with Rhinoceros with Python
How to save a table scraped by python to csv
A memo that I touched the Datastore with python
[Python] Created a method to convert radix in 1 second
A memo about building a Django (Python) application with Docker
A memo of misunderstanding when trying to load the entire self-made module with Python3
[Python] How to create a 2D histogram with Matplotlib
[Python] Delete by specifying a tag with Beautiful Soup
How to operate Discord API with Python (bot registration)
[Automation] Operate GitLab with Python to facilitate inquiry management
Publish / upload a library created in Python to PyPI
Operate Excel with Python (1)
I want to run a quantum computer with Python
[Python] How to draw a scatter plot with Matplotlib
Memo of "Cython-Speeding up Python by fusing with C"