From 393cc190e76ac806c2565d57426ddc894a29d58b Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Thu, 27 Jul 2023 15:09:05 +0100 Subject: [PATCH] Arduino build (#19) * changes for Arduino build * update --- README.md | 48 +++++++++++++++++---- hw/esp32-espi-dac.h | 5 --- hw/esp32-espi-spiffs.h | 5 --- hw/esp32-espi.h | 4 -- hw/esp32-utft-dac.h | 4 -- hw/esp32/dac.h | 3 -- hw/esp32/espi.h | 13 ------ hw/esp32/kbd.h | 5 --- hw/esp32/spiffs.h | 5 --- hw/esp32/utft.h | 9 ---- hw/esp8266-pwm-fs-23k256.h | 7 --- hw/esp8266-pwm-fs.h | 6 --- hw/esp8266-pwm-sd.h | 6 --- hw/esp8266-pwm.h | 6 --- hw/esp8266/espi.h | 12 ------ hw/esp8266/fs.h | 5 --- hw/esp8266/kbd.h | 4 -- hw/esp8266/pwm.h | 3 -- hw/esp8266/sd.h | 6 --- hw/esp8266/spiram.h | 6 --- hw/esp8bit.h | 40 +++++++++++++++++ hw/lm4f-utft-sd.h | 8 ---- hw/lm4f-utft.h | 6 --- hw/lm4f/kbd.h | 4 -- hw/lm4f/sd.h | 5 --- hw/lm4f/spiram.h | 8 ---- hw/lm4f/utft.h | 11 ----- hw/node32s-example.h | 38 ++++++++++++++++ hw/stellarpad-example.h | 34 +++++++++++++++ hw/{lilygo-vga32.h => ttgo-t7-v14-mini32.h} | 6 ++- hw/user.h | 18 +------- library.properties | 10 +++++ 32 files changed, 169 insertions(+), 181 deletions(-) delete mode 100644 hw/esp32-espi-dac.h delete mode 100644 hw/esp32-espi-spiffs.h delete mode 100644 hw/esp32-espi.h delete mode 100644 hw/esp32-utft-dac.h delete mode 100644 hw/esp32/dac.h delete mode 100644 hw/esp32/espi.h delete mode 100644 hw/esp32/kbd.h delete mode 100644 hw/esp32/spiffs.h delete mode 100644 hw/esp32/utft.h delete mode 100644 hw/esp8266-pwm-fs-23k256.h delete mode 100644 hw/esp8266-pwm-fs.h delete mode 100644 hw/esp8266-pwm-sd.h delete mode 100644 hw/esp8266-pwm.h delete mode 100644 hw/esp8266/espi.h delete mode 100644 hw/esp8266/fs.h delete mode 100644 hw/esp8266/kbd.h delete mode 100644 hw/esp8266/pwm.h delete mode 100644 hw/esp8266/sd.h delete mode 100644 hw/esp8266/spiram.h create mode 100644 hw/esp8bit.h delete mode 100644 hw/lm4f-utft-sd.h delete mode 100644 hw/lm4f-utft.h delete mode 100644 hw/lm4f/kbd.h delete mode 100644 hw/lm4f/sd.h delete mode 100644 hw/lm4f/spiram.h delete mode 100644 hw/lm4f/utft.h create mode 100644 hw/node32s-example.h create mode 100644 hw/stellarpad-example.h rename hw/{lilygo-vga32.h => ttgo-t7-v14-mini32.h} (56%) create mode 100644 library.properties diff --git a/README.md b/README.md index d8c3985..fa9d4aa 100644 --- a/README.md +++ b/README.md @@ -3,21 +3,53 @@ r65emu Arduino emulation library for 8-bit microcomputers based on 6502, i8080 and z80. +Sample Applications: +-------------------- +- [Apple1](https://github.com/jscrane/Apple1) +- [CPM80](https://github.com/jscrane/cpm80) +- [Space Invaders](https://github.com/jscrane/invaders) +- [Pacman](https://github.com/jscrane/pacman) +- [Commodore PET](https://github.com/jscrane/PET) +- [Compukit UK101](https://github.com/jscrane/UK101) + +Configuration: +-------------- +If building using the Arduino IDE, `r65emu/hw/user.h` must be configured correctly. + +Currently the only mass-produced board which is supported is the +[LilyGO TTGO](https://www.tinytronics.nl/shop/en/development-boards/microcontroller-boards/with-wi-fi/lilygo-ttgo-vga32-esp32). + +Examples are also given for a generic `node32s` board and a homebrew `esp8bit` board. + +Copy your configuration file to `user.h`. If the board is also mass-produced, please open a PR to add the new file to the library. + Libraries: --------- -- [My port](https://github.com/jscrane/UTFT-Energia) -of Henning Karlsen's [UTFT library](http://henningkarlsen.com/electronics/library.php?id=52), -- [Rei Vilo's port](https://github.com/rei-vilo/SD_TM4C) of -Adafruit/Sparkfun's [SD library](https://github.com/adafruit/SD), -- [My port](https://github.com/jscrane/SpiRAM) -of Phil Stewart's [SpiRAM library](http://playground.arduino.cc/Main/SpiRAM) + +Display: +-------- +Depending on target board, one of: +- [My port](https://github.com/jscrane/UTFT-Energia) of Henning Karlsen's [UTFT library](http://www.rinkydinkelectronics.com/library.php?id=51) +- [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) +- [FabGL](https://github.com/fdivitto/FabGL) + +Storage: +-------- +These are optional if the target board supports it (e.g., esp8266 or esp32 boards): +- [Rei Vilo's port](https://github.com/rei-vilo/SD_TM4C) of Adafruit/Sparkfun's [SD library](https://github.com/adafruit/SD), +- [My port](https://github.com/jscrane/SpiRAM) of Phil Stewart's [SpiRAM library](http://playground.arduino.cc/Main/SpiRAM) + +Input: +------ +- [PS2Keyboard](https://github.com/jscrane/PS2Keyboard) Hardware: --------- -- A [Stellaris Launchpad](http://www.energia.nu/Guide_StellarisLaunchPad.html) _or_ ESP8266 board, e.g., [WeMOS](https://www.wemos.cc/en/latest/d1/d1_mini.html), _or_ ESP32-based board, e.g., [Node32s](https://www.esp32.com/viewtopic.php?t=459), +- A [Stellaris Launchpad](http://www.energia.nu/Guide_StellarisLaunchPad.html) _or_ +ESP8266 board, e.g., [WeMOS](https://www.wemos.cc/en/latest/d1/d1_mini.html), _or_ +ESP32-based board, e.g., [Node32s](https://www.esp32.com/viewtopic.php?t=459), - An SD drive to store programs (for Stellarpad), - A 23k256 SPI RAM chip (for Stellarpad, optional), - A supported TFT screen, such as [this one](http://forum.stellarisiti.com/topic/626-ssd1289-32-320x240-tft-16bit-parallel-interface-touch-libraries/), - A PS/2 keyboard. -See _hardware.h_ for wiring details and other options. diff --git a/hw/esp32-espi-dac.h b/hw/esp32-espi-dac.h deleted file mode 100644 index c6a9e27..0000000 --- a/hw/esp32-espi-dac.h +++ /dev/null @@ -1,5 +0,0 @@ -#define RAM_SIZE 0x10000u - -#include -#include -#include diff --git a/hw/esp32-espi-spiffs.h b/hw/esp32-espi-spiffs.h deleted file mode 100644 index 9181d2c..0000000 --- a/hw/esp32-espi-spiffs.h +++ /dev/null @@ -1,5 +0,0 @@ -#define RAM_SIZE 0x10000u - -#include -#include -#include diff --git a/hw/esp32-espi.h b/hw/esp32-espi.h deleted file mode 100644 index 6f6ca6c..0000000 --- a/hw/esp32-espi.h +++ /dev/null @@ -1,4 +0,0 @@ -#define RAM_SIZE 0x10000u - -#include -#include diff --git a/hw/esp32-utft-dac.h b/hw/esp32-utft-dac.h deleted file mode 100644 index ece0ef5..0000000 --- a/hw/esp32-utft-dac.h +++ /dev/null @@ -1,4 +0,0 @@ -#define RAM_SIZE 0x10000u - -#include -#include diff --git a/hw/esp32/dac.h b/hw/esp32/dac.h deleted file mode 100644 index a980e52..0000000 --- a/hw/esp32/dac.h +++ /dev/null @@ -1,3 +0,0 @@ -// sound: dac and pwm -#define DAC_SOUND 25 -#define PWM_SOUND 25 diff --git a/hw/esp32/espi.h b/hw/esp32/espi.h deleted file mode 100644 index 71c33b0..0000000 --- a/hw/esp32/espi.h +++ /dev/null @@ -1,13 +0,0 @@ -// TFT display... -#define USE_ESPI -//#define USER_SETUP_LOADED -//#define ILI9341_DRIVER -//#define TFT_CS 5 -//#define TFT_DC 2 -//#define TFT_MOSI 23 -//#define TFT_MISO -1 -//#define TFT_SCLK 18 -//#define TFT_RST -1 -//#define SPI_FREQUENCY 40000000 -//#define LOAD_GLCD - diff --git a/hw/esp32/kbd.h b/hw/esp32/kbd.h deleted file mode 100644 index 6bfcf78..0000000 --- a/hw/esp32/kbd.h +++ /dev/null @@ -1,5 +0,0 @@ -// PS/2 keyboard -#define USE_KBD -#define KBD_DATA 34 -#define KBD_IRQ 35 - diff --git a/hw/esp32/spiffs.h b/hw/esp32/spiffs.h deleted file mode 100644 index 4a6c13d..0000000 --- a/hw/esp32/spiffs.h +++ /dev/null @@ -1,5 +0,0 @@ -// "tape" storage... -#undef USE_SD -#undef USE_FS -#define USE_SPIFFS - diff --git a/hw/esp32/utft.h b/hw/esp32/utft.h deleted file mode 100644 index de39b1f..0000000 --- a/hw/esp32/utft.h +++ /dev/null @@ -1,9 +0,0 @@ -// TFT display... -#define USE_UTFT -#undef TFT_BACKLIGHT -#define TFT_MODEL ILI9325C -#define TFT_RS 32 -#define TFT_WR 33 -#define TFT_CS 27 -#define TFT_RST 26 - diff --git a/hw/esp8266-pwm-fs-23k256.h b/hw/esp8266-pwm-fs-23k256.h deleted file mode 100644 index cb1729c..0000000 --- a/hw/esp8266-pwm-fs-23k256.h +++ /dev/null @@ -1,7 +0,0 @@ -#define RAM_SIZE 0x8000u - -#include -#include -#include -#include -#include diff --git a/hw/esp8266-pwm-fs.h b/hw/esp8266-pwm-fs.h deleted file mode 100644 index beba42a..0000000 --- a/hw/esp8266-pwm-fs.h +++ /dev/null @@ -1,6 +0,0 @@ -#define RAM_SIZE 0x8000u - -#include -#include -#include -#include diff --git a/hw/esp8266-pwm-sd.h b/hw/esp8266-pwm-sd.h deleted file mode 100644 index d200727..0000000 --- a/hw/esp8266-pwm-sd.h +++ /dev/null @@ -1,6 +0,0 @@ -#define RAM_SIZE 0x8000u - -#include -#include -#include -#include diff --git a/hw/esp8266-pwm.h b/hw/esp8266-pwm.h deleted file mode 100644 index 5be732a..0000000 --- a/hw/esp8266-pwm.h +++ /dev/null @@ -1,6 +0,0 @@ -#define NO_CHECKPOINT 1 -#define RAM_SIZE 0x8000u - -#include -#include -#include diff --git a/hw/esp8266/espi.h b/hw/esp8266/espi.h deleted file mode 100644 index a548200..0000000 --- a/hw/esp8266/espi.h +++ /dev/null @@ -1,12 +0,0 @@ -// TFT display... -#define USE_ESPI -//must define these in Makefile (or platformio) -//#define USER_SETUP_LOADED -//#define ILI9341_DRIVER -//#define TFT_CS PIN_D8 -//#define TFT_DC PIN_D1 -//#define TFT_WIDTH 240 -//#define TFT_HEIGHT 320 -//#define TFT_RST -1 -//#define SPI_FREQUENCY 40000000 -//#define LOAD_GLCD diff --git a/hw/esp8266/fs.h b/hw/esp8266/fs.h deleted file mode 100644 index 847f794..0000000 --- a/hw/esp8266/fs.h +++ /dev/null @@ -1,5 +0,0 @@ -// "tape" storage... -#undef USE_SD -#undef USE_SPIFFS -#define USE_FS - diff --git a/hw/esp8266/kbd.h b/hw/esp8266/kbd.h deleted file mode 100644 index 5e9f943..0000000 --- a/hw/esp8266/kbd.h +++ /dev/null @@ -1,4 +0,0 @@ -// PS/2 keyboard -#define USE_KBD -#define KBD_IRQ D3 -#define KBD_DATA D4 diff --git a/hw/esp8266/pwm.h b/hw/esp8266/pwm.h deleted file mode 100644 index c29a942..0000000 --- a/hw/esp8266/pwm.h +++ /dev/null @@ -1,3 +0,0 @@ -// sound -#define PWM_SOUND D2 -#define PWM_TOP 1024 diff --git a/hw/esp8266/sd.h b/hw/esp8266/sd.h deleted file mode 100644 index 3ebeaa0..0000000 --- a/hw/esp8266/sd.h +++ /dev/null @@ -1,6 +0,0 @@ -// "tape" storage... -#define USE_SD -#define SD_CS D0 -#undef USE_SPIFFS -#undef USE_FS - diff --git a/hw/esp8266/spiram.h b/hw/esp8266/spiram.h deleted file mode 100644 index 5766029..0000000 --- a/hw/esp8266/spiram.h +++ /dev/null @@ -1,6 +0,0 @@ -// SPI-RAM -#define USE_SPIRAM -#define SPIRAM_DEV SPI -#define SPIRAM_CS D0 -#define SPIRAM_SIZE 0x8000u - diff --git a/hw/esp8bit.h b/hw/esp8bit.h new file mode 100644 index 0000000..ef40306 --- /dev/null +++ b/hw/esp8bit.h @@ -0,0 +1,40 @@ +// Homebrew esp8bit board based on WeMOS D1-Mini +// https://github.com/jscrane/esp8bit + +#define RAM_SIZE 0x8000u + +// TFT display... +#define USE_ESPI +//must define these in Makefile (or platformio) +//#define USER_SETUP_LOADED +//#define ILI9341_DRIVER +//#define TFT_CS PIN_D8 +//#define TFT_DC PIN_D1 +//#define TFT_WIDTH 240 +//#define TFT_HEIGHT 320 +//#define TFT_RST -1 +//#define SPI_FREQUENCY 40000000 +//#define LOAD_GLCD + +// PS/2 keyboard +#define USE_KBD +#define KBD_IRQ D3 +#define KBD_DATA D4 + +// SPI-RAM +#define USE_SPIRAM +#define SPIRAM_DEV SPI +#define SPIRAM_CS D0 +#define SPIRAM_SIZE 0x8000u + +// "tape" storage... +#undef USE_SD +//#define SD_CS D0 +#undef USE_SPIFFS +#undef USE_FS + +#undef USE_SPIFFS +#define USE_FS + +// sound +#define PWM_SOUND D2 diff --git a/hw/lm4f-utft-sd.h b/hw/lm4f-utft-sd.h deleted file mode 100644 index 4c31ced..0000000 --- a/hw/lm4f-utft-sd.h +++ /dev/null @@ -1,8 +0,0 @@ -#define RAM_SIZE 0x3000u - -#define SPI_CS PF_3 - -#include -#include -#include -#include diff --git a/hw/lm4f-utft.h b/hw/lm4f-utft.h deleted file mode 100644 index 973b982..0000000 --- a/hw/lm4f-utft.h +++ /dev/null @@ -1,6 +0,0 @@ -#define RAM_SIZE 0x3000u - -#define SPI_CS PF_3 - -#include -#include diff --git a/hw/lm4f/kbd.h b/hw/lm4f/kbd.h deleted file mode 100644 index 9b364ec..0000000 --- a/hw/lm4f/kbd.h +++ /dev/null @@ -1,4 +0,0 @@ -// PS/2 keyboard -#define USE_KBD -#define KBD_DATA PE_4 -#define KBD_IRQ PE_5 diff --git a/hw/lm4f/sd.h b/hw/lm4f/sd.h deleted file mode 100644 index 295f037..0000000 --- a/hw/lm4f/sd.h +++ /dev/null @@ -1,5 +0,0 @@ -// "tape" storage... -#define USE_SD -#define SD_CS PF_3 -#define SD_SPI 1 - diff --git a/hw/lm4f/spiram.h b/hw/lm4f/spiram.h deleted file mode 100644 index b255f8b..0000000 --- a/hw/lm4f/spiram.h +++ /dev/null @@ -1,8 +0,0 @@ -// SPI-RAM -#define USE_SPIRAM -#define SPIRAM_CS PE_0 -#define SPIRAM_DEV SPI_for_SD -#define SPIRAM_MODULE 1 -#define SPIRAM_CLKDIV 1 -#define SPIRAM_SIZE 65536u - diff --git a/hw/lm4f/utft.h b/hw/lm4f/utft.h deleted file mode 100644 index b82d12d..0000000 --- a/hw/lm4f/utft.h +++ /dev/null @@ -1,11 +0,0 @@ -// TFT display... -// NOTE: edit memorysaver.h to select the correct chip for your display! -// Daniel Rebollo's boosterpack -#define USE_UTFT -#define TFT_BACKLIGHT PD_6 -#define TFT_MODEL SSD1289 -#define TFT_RS PC_6 -#define TFT_WR PC_5 -#define TFT_CS PC_7 -#define TFT_RST PC_4 - diff --git a/hw/node32s-example.h b/hw/node32s-example.h new file mode 100644 index 0000000..69cf719 --- /dev/null +++ b/hw/node32s-example.h @@ -0,0 +1,38 @@ +#define RAM_SIZE 0x10000u + +// TFT display... +#define USE_ESPI +// must be configured in uC-Makefile, or platformio, or TFT_eSPI's User_Setup.h +//#define USER_SETUP_LOADED +//#define ILI9341_DRIVER +//#define TFT_CS 5 +//#define TFT_DC 2 +//#define TFT_MOSI 23 +//#define TFT_MISO -1 +//#define TFT_SCLK 18 +//#define TFT_RST -1 +//#define SPI_FREQUENCY 40000000 +//#define LOAD_GLCD + +// use alternative TFT display library... +//#define USE_UTFT +//#undef TFT_BACKLIGHT +//#define TFT_MODEL ILI9325C +//#define TFT_RS 32 +//#define TFT_WR 33 +//#define TFT_CS 27 +//#define TFT_RST 26 + +// PS/2 keyboard +#define USE_KBD +#define KBD_DATA 34 +#define KBD_IRQ 35 + +// "tape" storage... +#undef USE_SD +#undef USE_FS +#define USE_SPIFFS + +// sound: dac and pwm +#define DAC_SOUND 25 +#define PWM_SOUND 25 diff --git a/hw/stellarpad-example.h b/hw/stellarpad-example.h new file mode 100644 index 0000000..57a2c0e --- /dev/null +++ b/hw/stellarpad-example.h @@ -0,0 +1,34 @@ +// Stellaris Launchpad example + +#define RAM_SIZE 0x3000u + +// PS/2 keyboard +#define USE_KBD +#define KBD_DATA PE_4 +#define KBD_IRQ PE_5 + +// "tape" storage... +#define USE_SD +#define SD_CS PF_3 +#define SD_SPI 1 + +// 23k256 SPI-RAM +#define USE_SPIRAM +#define SPI_CS PF_3 +#define SPIRAM_CS PE_0 +#define SPIRAM_DEV SPI_for_SD +#define SPIRAM_MODULE 1 +#define SPIRAM_CLKDIV 1 +#define SPIRAM_SIZE 0x8000u + +// TFT display... +// NOTE: edit memorysaver.h to select the correct chip for your display! +// Daniel Rebollo's boosterpack +#define USE_UTFT +#define TFT_BACKLIGHT PD_6 +#define TFT_MODEL SSD1289 +#define TFT_RS PC_6 +#define TFT_WR PC_5 +#define TFT_CS PC_7 +#define TFT_RST PC_4 + diff --git a/hw/lilygo-vga32.h b/hw/ttgo-t7-v14-mini32.h similarity index 56% rename from hw/lilygo-vga32.h rename to hw/ttgo-t7-v14-mini32.h index 0c510d4..0a63c36 100644 --- a/hw/lilygo-vga32.h +++ b/hw/ttgo-t7-v14-mini32.h @@ -1,14 +1,18 @@ // LilyGO TTGO VGA32 +// https://www.tinytronics.nl/shop/en/development-boards/microcontroller-boards/with-wi-fi/lilygo-ttgo-vga32-esp32 +// Display #define USE_VGA +// PS/2 Keyboard #define USE_KBD #define KBD_DATA 32 #define KBD_IRQ 33 +// 64kB RAM #define RAM_SIZE 0x10000u -// sound: dac and pwm +// Sound: dac and pwm #define DAC_SOUND 25 #define PWM_SOUND 25 diff --git a/hw/user.h b/hw/user.h index f3fdf74..5431d0d 100644 --- a/hw/user.h +++ b/hw/user.h @@ -1,17 +1,3 @@ +// user-configured hardware description -#if defined(ESP32) -// #include -// #include -// #include - -#elif defined(ESP8266) -// #include -// #include -#include -// #include - -#elif defined(LM4F) -// #include -// #include - -#endif +#error "hw/user.h not configured!" diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..04f0433 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=r65emu +version=1.0.0 +author=Stephen Crane +maintainer=Stephen Crane +sentence=8-bit Microcomputer Emulation Library +paragraph=Supports 6502, 8080 and Z80 processors +category=Other +url=https://github.com/jscrane/r65emu +architectures=esp32, esp8266, tivac +includes=r65emu.h