Skip to content

Files

Latest commit

 

History

History
132 lines (117 loc) · 7.81 KB

readmeEnglish.md

File metadata and controls

132 lines (117 loc) · 7.81 KB

Tiny ESP32

Port of Jens Nyberg's NES Master PC emulator to TTGO VGA32 v1.x (1.0, 1.1, 1.2, 1.4) board with ESP32.

I have made several modifications:
  • Ported from x86 PC to ESP32
  • No PSRAM is used, running on ESP32 with 520 KB RAM (TTGO VGA32 v1.x).
  • Use of a single core
  • Low resource OSD
  • Created project compatible with Arduino IDE and Platform IO
  • Web Editor and ArduinoDroid (6.3.1) compatible project with tool makeandroid.bat
  • Emulation of ricoh2A03 (fabgl library) reduced version of dcrespo3d(David Crespo Tascón)
  • Screen adjustment X
  • Emulation CPU speed menu (AUTO), sound, keyboard
  • Support for 8 and 64 color mode (reduced version by Ricardo Massaro).
  • VGA 320x240
  • It is recommended to use only single cartridges without bank switching.
  • A 3-channel DIRTY Sound is used which is not faithful to the real emulation.
  • Up, down, left, right cursors
  • X key (button A), Z key (button B)
  • C key (SELECT button), V key (START button)

Requirements

Required:
  • TTGO VGA32 v1.x (1.0, 1.1, 1.2, 1.4)
  • Visual Studio 1.48.1 PLATFORMIO 2.2.1 Espressif32 v3.3.2
  • Arduino IDE 1.8.11 Espressif System 1.0.6
  • ArduinoDroid (6.3.1)
  • Arduino fabgl 0.9.0 reduced library (included in PLATFORMIO project)
  • Arduino bitluni 0.3.3 reduced library (included in project)



ArduinoDroid

You must run, just once, the script makeandroid.bat, which leaves the entire data structure of the dataFlash directory in the root directory, as well as replacing the main files with .h calls without using the dataFlash data directory.
At the end, the script itself ends up deleting the dataFlash directory.
The script uses fart.exe (find and replace text).
Once, it has been successfully executed, it can be used with the ArduinoDroid.



Arduino Web Editor

The makeandroid.bat script must be run once only. Once finished, it is uploaded to the cloud as any other project, either compressed in zip or by files.



PlatformIO

PLATFORMIO 2.2.1 must be installed from the Visual Studio extensions. Espressif32 v3.3.2 is also required.

Then the working directory TinyNesMasterttgovga32 will be selected. We must modify the platformio.ini file the upload_port option 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 the whole compiled binary. It's all set up so you don't have to install the bitluni and fabgl libraries.



Arduino IDE

The whole project is compatible with the Arduino 1.8.11 framework. We only have to open the nes.ino in the nes directory.

We must install the spressif extensions in the additional card url manager https://dl.espressif.com/dl/package_esp32_index.json.
The project is already prepared, so no bitluni or fabgl libraries are needed. We must deactivate the PSRAM option, and in case of exceeding 1 MB of binary, select 4 MB of partition when 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 it will restart in loop mode.



Usability

The following actions are allowed from the menu (F1 key):
  • Select ROM allows you to choose game ROMs.
  • Offset X of the screen.
  • Change polling milliseconds for video, keyboard, mouse and sound.
  • Sound Volume (100%, 75,%, 50%, 25%, 5%)
  • Sound active or muted.
  • Cpu wait in AUTO mode (set 20 ms per real frame) or wait in ms as desired.
A basic low-resource OSD is available, i.e. very simple, which is displayed by pressing the F1 key.

The files must be converted to .h in hexadecimal. The online tool can be used:
http://tomeko.net/online_tools/file_to_hex.php?lang=en



Options

The gbConfig.h file options are selected:
  • use_lib_vga8colors: Forces to use RGB 8-color mode (3 pins). Outputs 8 colors, as opposed to 64 in normal mode (6 RRGGBB pins).
  • use_lib_sound_ricoh2A03: A 3-channel mixer is used in dirty mode, emulating the ricoh2A03. Consume un poco de RAM. It requires the reduced fabgl 0.9.0 library, already included in the project.
  • use_lib_log_serial: Logs are sent via usb serial port.
  • gb_ms_keyboard: The number of polling milliseconds for the keyboard must be specified.
  • gb_ms_sound: The number of polling milliseconds for the sound must be specified.
  • gb_delay_emulate_ms: Milliseconds to wait for each completed frame.
  • use_lib_fix_double_precision: No usar FPU para el cálculo del PLL.
  • use_lib_debug_i2s: Detailed information on the initialisation of the video mode.
  • use_lib_measure_time: Displays CPU consumption and fps statistics.
  • use_lib_vga320x240x60hz_bitluni: Use bitluni's 320x240 video mode.
  • use_lib_vga320x240x60hz_fabgl: Use 320x240 video mode with fabgl settings.
  • use_lib_vga320x240x60hz_bitluni_apll_fix: Use bitluni's 320x240 video mode with PLL bug fix.



Tool rom2h

I have created a very basic tool(win32), to convert .nes files to .h in ready mode to be processed by the emulator. We just have to leave the .nes files in the input/roms folder and run the rom2h.exe file, so that an output will be generated in the output/dataFlash directory. For testing purposes, a file has been left in the input/roms directory, which it is recommended to delete in case of making a new custom list. It is also recommended to delete the files in the nes/dataFlash/gbrom.h and nes/dataFlash/rom directory to have a clean project.


Tool rom2h

 input/
  roms/
   AlfonzoMeleeHB.nes
   ChaseHB.nes
 output/
  dataFlash/
   rom/
Subsequently we must copy the dataFlash directory into the ESP32TinyNesMaster\nes project overwriting the previous dataFlash folder. It is recommended that you clean up the project and recompile.
This tool is very simple, and does not check for errors, so it is recommended to leave the files with very simple names and as simple as possible. The project in PLATFORM.IO is prepared for 1MB of Flash. If we need the 4MB of flash, we will have to modify the entry in the platformio.ini file.
board_build.partitions = huge_app.csv
In the Arduino IDE, we must choose the option Partition Scheme (Huge APP).



DIY circuit

If we don't want to use a TTGO VGA32 v1.x board, we can build it following the fabgl schematic: