Skip to content

Latest commit

 

History

History
140 lines (123 loc) · 6.96 KB

readmeEnglish.md

File metadata and controls

140 lines (123 loc) · 6.96 KB

ESP32 Gameboy

Gameboy emulator (fork lualiliu) for the TTGO VGA32 v1.2 board with ESP32 chip.
  • Use of vga and keyboard
  • Up to 8 cache banks
  • PSRAM is not used, it works in ESP32 with 520 KB of RAM (TTGO VGA32 v1.2)
  • Use of a single core
  • Low-income OSD
  • Created project compatible with Arduino IDE and Platform IO
  • Sound with the fabgl library
  • Support for 8 and 64 color mode
  • VGA 200x150 and 320x175
  • Emulation of the classic Game Boy

Requirements

Required:
  • TTGO VGA32 v1.2
  • Visual Studio 1.48.1 PLATFORM 2.2.0
  • Arduino IDE 1.8.11
  • Arduino fabgl 0.9.0 library (included in PLATFORM project)
  • Arduino bitluni library 0.3.3 (included in the project)


PlatformIO

PLATFORM 2.2.0 must be installed from the Visual Studio extensions.

Then the working directory gameboy will be selected. We must modify the file platformio.ini the option upload_port to select the COM port where we have our TTGO VGA32 board.

Then we will proceed to compile and upload to the board. No partitions are used, so we must upload all the compiled binary. Everything is prepared so we don't have to install the bitluni libraries. However, if we need the sound options, we will need to install the libraries of fabgl, only for the Arduino IDE, since for PLATFORM I have left the libraries in the project.

Arduino IDE

The whole project is compatible with the structure of Arduino 1.8.11. We only have to open the gameboy.ino in the gameboy directory.

We must install the spressif extensions in the additional card url manager https://dl.espressif.com/dl/package_esp32_index.json

For the normal mode, the project is already prepared, so that no bitluni library is needed. However, if we need the sound support, it is required to install the libraries fabgl 0.9.0. We can do it from the library manager. We must deactivate the PSRAM option, and in case of exceeding 1 MB of binary, select 4 MB of partition at the time of uploading. Although the code does not use PSRAM, if the option is active and our ESP32 does not have it, an exception will be generated and restart it in loop mode.

Usability

The following actions are allowed from the menu (F1 key):
  • Select ROM allows to choose the disk.
  • Change the milliseconds of keyboard polling
  • CPU speed
  • Turn the sound on and off
  • Emulator and chip restart
The keys to play are:
  ESP32 Joystick GB Keyboard
  -----------------------------------
   Cursor up - up
   Cursor down - down
   Left - left slider
   Right-handed cursor - right
   a - A
   z - B
   Space bar - Start
   ENTER - SELECT              
 

There is a basic OSD of low resources, that is to say, very simple, that is visualized by pressing the key F1. To move through the OSD, we use the arrow keys, the ENTER to accept and the ESC to cancel.

Files must be converted to .h in hexadecimal. You can use the online tool:
http://tomeko.net/online_tools/file_to_hex.php?lang=en For the roms you must use the tool rom2h to generate the necessary .h.

Options

The file gbConfig.h options are selected:
  • use_lib_200x150: 200x150 video mode is used.
  • use_lib_320x175: 320x175 video mode is used.
  • use_lib_vga8colors: Force to use RGB 8 color mode (3 pins). It consumes little ram and is very fast, but only takes 8 colors, compared to 64 in normal mode (6 pins RRGGBB).
  • use_lib_vga64colors: Force to use RRGGBB 64 colors mode (6 pins). It consumes more ram and is slower, but gets 64 colors (grayscale).
  • use_lib_vga_low_memory: Experimental mode with low video RAM consumption, but slower.
  • use_lib_fast_vga: Ultra fast experimental mode, which achieves almost double the video access speed. In 8-color mode, it brings out a classic CGA style palette, and in 64-color mode, grayscale.
  • use_lib_fast_vgaBLUE8colors: Ultra fast experimental mode for 8-color mode, using blue palette.
  • use_lib_fast_vgaRED8colors: Ultra fast experimental mode for 8-color mode, using red palette.
  • use_lib_fabgl_sound: A 3 channel mixer is used in dirty mode. It consumes quite a lot of ram. The fabgl library 0.9.0 is required
  • use_lib_log_serial: Logs are sent by serial port usb
  • usb_lib_optimice_checkchange_bankswitch: Only switches banks when they are different, gaining speed.
  • gb_ms_joy: You must specify the number of milliseconds of polling for the keyboard.
  • gb_frame_crt_skip: If it is 1 it skips a frame.
  • use_lib_vga_thread: Experimental multithreading mode, for now it is very slow.
  • use_min_ram: Does not use any cache bank, saving memory, but being slower.
  • use_half_ram:Use 4 cache banks, gaining speed, sacrificing memory.
  • use_max_ram:Use 8 cache banks, gaining speed, sacrificing memory.
  • use_lib_tinyFont: Uses own routines to draw 6x8 font without using bitluni ones, saving RAM and Flash memory

Test applications

We can choose the following games:
  • Long Crownr
  • Retroid

Generate .h

I have created a tool to generate the structure of the roms in .h:

https://github.com/rpsubc8/esp32gameboy/tree/master/arduino/tools

The roms .gb files must be entered in the directory:

 input
  roms  

And you must launch the executable rom2h
It will be generated in the directory:

 output
  dataFlash
   gbrom.h
   roms

All the .h that are generated, must be released to the project, overwriting the current ones from the dataFlash directory.