Skip to content

Commit

Permalink
Instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Greening committed Dec 8, 2024
1 parent 1456f8f commit 3dcba1b
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 28 deletions.
58 changes: 52 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@

[![Build Firmware](https://github.com/atomic14/esp32-zxspectrum/actions/workflows/build_firmware.yml/badge.svg)](https://github.com/atomic14/esp32-zxspectrum/actions/workflows/build_firmware.yml)

# Overview
# ESP32 Rainbow

This is heavily inspired b the [OpenVegaPlus](https://github.com/alvaroalea/OpenVegaPlus) project. But I've hacked around the code quite substantially.
This repository contains the software for the [ESP32 Rainbow project](https://www.crowdsupply.com/atomic14/esp32-rainbow).

Currently it should support a variety of different boards - have a look in `platform.io` for inspiration.
![ESP32 Rainbow](docs/images/esp32-rainbow.jpg)

# Warning
The code is designed for my board, but will run on pretty much any ESP32 board.

This is just me messing around - I'm not going to provide any support for this project in its current state. It's purely for my own amusement.
This is currently a work in progress and is under active development. So, I can't guarantee that the code will be stable.

You are free to use it. The OpenVegaPlus project was released under the GNU GPL - so this project is too.
You will need to install [Visual Studio Code](https://code.visualstudio.com/download) and [PlatformIO](https://platformio.org/install) to build the code.

# Supported boards

Check the `platformio.ini` file for the complete list of suppoted boards.

To add a new board make a copy of an existing board section in the file and modify the pins to match your board.

- ESP32 Rainbow
- Cheap Yellow Display (CYD)
- LilyGo T-Deck

Pretty much any ESP32 board should work, you just need a 320x240 TFT display and either I2S amplifier or speaker driven with a transistor.

# Input

My board (the [ESP32 Rainbow](https://www.crowdsupply.com/atomic14/esp32-rainbow) has a built in keyboard and has 2xQWIIC connectors which can be used to connect a wide range of controllers (e.g. Wii Nunchucks).

The LilyGo T-Deck has a keyboard, but the firmware for the keyboard is pretty terrible making it very hard to use.

The CYD has no keyboard, but you should be able to hook up I2C devices to it.

Alternatively, you can use some python code in the `keyboard-server` directory to use your desktop keyboard to type. This has only been tested on a Mac - I've no idea if it will work on Windows.

```sh
cd keyboard-server
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python serial_keyboard.py
```

# SDCard/Flash Storage

The CYD and my board have an SD card slot that is independent of the SPI bus used by the TFT display. This means you can use the SD card slot to store games.

The LilyGo T-Deck has as SD card but it uses the same SPI bus as the TFT display. I have not managed to get both of them to work simultaneously. If someone wants to dig into this and fix it then please let me know.

If you can't use the SD card then drop any games (z80 or tzx/tap) into the `data` folder. You will then need to use the platformio menu to upload the filesystem to the device.

For anyone using an SD card, make sure it is formatted with the FAT32 filesystem and drop any games (z80 or tzx/tap) into the root of the card.

# Help Support Development

If you find this project useful and want to help support further development then please consider buying a board from my [Crowd Supply](https://www.crowdsupply.com/atomic14) page.

Or you can back me on [Patreon](https://www.patreon.com/atomic14).
4 changes: 2 additions & 2 deletions desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sdl_app
sdl_app.*
zx_emulator
zx_emulator.*
emsdk
2 changes: 1 addition & 1 deletion desktop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CXXFLAGS = \
LDFLAGS = -L/usr/local/lib -framework Cocoa

# Target executable name
TARGET = sdl_app
TARGET = zx_emulator

SRCS = \
../firmware/src/Emulator/128k_rom.cpp \
Expand Down
5 changes: 3 additions & 2 deletions desktop/Makefile.ems
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CXXFLAGS = \
LDFLAGS = -L/usr/local/lib

# Target executable name
TARGET = sdl_app.html
TARGET = zx_emulator.html

SRCS = \
../firmware/src/Emulator/128k_rom.cpp \
Expand All @@ -32,7 +32,8 @@ SRCS = \
../firmware/src/Emulator/snaps.cpp \
../firmware/src/AySound/AySound.cpp \
../firmware/src/Serial.cpp \
../firmware/src/TZX/tzx_cas.cpp
../firmware/src/TZX/tzx_cas.cpp \
src/loadgame.cpp

OBJC_SRCS = \
src/main.mm
Expand Down
27 changes: 21 additions & 6 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@

This uses the same code as the ESP32 version, but makes it a bit easier to develop and test as we can run it on the desktop.

# Building for the desktop

# Setup Emscripten
The code is designed to run on a Mac, but it shold be pretty easy to get runningon windows.

```
make clean
make
./zx_emulator
```

On lauch you will be prompted to select a game to load. Select a z80 or tzx/tap file.

# Using Emscripten

This allows you to run the emulator in your browser.

https://emscripten.org/docs/getting_started/downloads.html

Expand All @@ -14,16 +27,16 @@ git clone https://github.com/emscripten-core/emsdk.git
```
cd emsdk
# Fetch the latest version of the emsdk (not needed the first time you clone)
## Fetch the latest version of the emsdk (not needed the first time you clone)
git pull
# Download and install the latest SDK tools.
## Download and install the latest SDK tools.
./emsdk install latest
# Make the "latest" SDK "active" for the current user. (writes .emscripten file)
## Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate latest
# Activate PATH and other environment variables in the current terminal
## Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh
```

Expand All @@ -37,4 +50,6 @@ make -f Makefile.ems

```
python3 -m http.server
```
```

Now go to http://localhost:8000/zx_emulator.html
Binary file added desktop/filesystem/manic.z80
Binary file not shown.
10 changes: 5 additions & 5 deletions desktop/src/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ void handleEvents(bool &isRunning)
auto it = sdl_to_spec.find(e.key.keysym.sym);
if (it != sdl_to_spec.end())
{
machine->updatekey(it->second, 1);
machine->updateKey(it->second, 1);
}
}
if (e.type == SDL_KEYUP)
{
auto it = sdl_to_spec.find(e.key.keysym.sym);
if (it != sdl_to_spec.end())
{
machine->updatekey(it->second, 0);
machine->updateKey(it->second, 0);
}
}
}
Expand Down Expand Up @@ -256,7 +256,7 @@ void main_loop()
handleEvents(isRunning);
count++;
// fill out the framebuffer
fillFrameBuffer(frameBuffer, machine->mem.currentScreen, machine->hwopt.BorderColor);
fillFrameBuffer(frameBuffer, machine->mem.currentScreen->data, machine->hwopt.BorderColor);
updateAndRender(renderer, texture, frameBuffer);
#ifndef __EMSCRIPTEN__
std::this_thread::sleep_for(std::chrono::milliseconds(20));
Expand Down Expand Up @@ -293,11 +293,11 @@ int main()
machine->runForFrame(nullptr, nullptr);
}
// press the enter key to trigger tape loading
machine->updatekey(SPECKEY_ENTER, 1);
machine->updateKey(SPECKEY_ENTER, 1);
for(int i = 0; i < 10; i++) {
machine->runForFrame(nullptr, nullptr);
}
machine->updatekey(SPECKEY_ENTER, 0);
machine->updateKey(SPECKEY_ENTER, 0);
for(int i = 0; i < 10; i++) {
machine->runForFrame(nullptr, nullptr);
}
Expand Down
Binary file added docs/images/esp32-rainbow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion firmware/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ build_flags =
-DSD_CARD_CS=GPIO_NUM_5


[env:lilygo-t-keyboard]
[env:lilygo-t-deck]
extends = esp32_common
board = esp32-s3-devkitc-1
board_build.arduino.memory_type = qio_opi
Expand Down
10 changes: 5 additions & 5 deletions firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void setup(void)
digitalWrite(BOARD_POWERON, HIGH);
#endif
Serial.begin(115200);
for(int i = 0; i < 5; i++) {
BusyLight bl;
vTaskDelay(pdMS_TO_TICKS(1000));
Serial.println("Booting...");
}
// for(int i = 0; i < 5; i++) {
// BusyLight bl;
// vTaskDelay(pdMS_TO_TICKS(1000));
// Serial.println("Booting...");
// }
// print out avialable ram
Serial.printf("Free heap: %d\n", ESP.getFreeHeap());
Serial.printf("Free PSRAM: %d\n", ESP.getFreePsram());
Expand Down

0 comments on commit 3dcba1b

Please sign in to comment.