Skip to content

Commit

Permalink
Merge pull request #34 from EremusOne/develop
Browse files Browse the repository at this point in the history
Version 1.0 ready!
  • Loading branch information
EremusOne authored Dec 29, 2023
2 parents 90da6ad + eb0f686 commit 9914e40
Show file tree
Hide file tree
Showing 53 changed files with 6,646 additions and 3,225 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.pio
.vscode
.vscode/**
.VSCodeCounter
.VSCodeCounter/**
data/s/**
!data/s/sppong.sna
!data/s/fantasy.sna
Expand All @@ -16,3 +18,4 @@ downloaded_fs*.bin
/doc/**
/releases
/releases/**

9 changes: 5 additions & 4 deletions ESPecpart2.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
# nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
48k, app, ota_0, 0x10000, 0x80000,
128k, app, ota_1, 0x90000, 0x80000,
spiffs, data, spiffs, 0x110000,0x2F0000,
48k, app, ota_0, 0x10000, 0xC0000,
128k, app, ota_1, 0xD0000, 0xC0000,
nvs, data, nvs, 0x190000, 0xC000,
spiffs, data, spiffs, 0x19C000,0x264000,
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This project is based on David Crespo excellent work on [ZX-ESPectrum-Wiimote](h

## Features

- ZX Spectrum 48K, 128K and Pentagon 128K emulation (no PSRAM needed).
- Accurate Z80 emulation (Authored by [José Luis Sánchez](https://github.com/jsanchezv/z80cpp))
- ZX Spectrum 48K, 128K and Pentagon 128K 100% cycle accurate emulation (no PSRAM needed).
- Perfect Z80 emulation (Authored by [José Luis Sánchez](https://github.com/jsanchezv/z80cpp))
- 6 bpp VGA output in three modes: Standard VGA (60 and 70hz), VGA 50hz and CRT 15khz 50hz.
- Support for two aspect ratios: 16:9 or 4:3 monitors (using 360x200 or 320x240 modes)
- Multicolor attribute effects emulated (Bifrost*2, Nirvana and Nirvana+ engines).
Expand All @@ -21,19 +21,19 @@ This project is based on David Crespo excellent work on [ZX-ESPectrum-Wiimote](h
- AY-3-8912 sound emulation.
- Beeper & Mic emulation (Cobra’s Arc).
- Dual PS/2 keyboard support: you can connect two devices using PS/2 protocol at the same time.
- Kempston and Cursor type Joystick emulation.
- PS/2 Joystick emulation (Cursor, Sinclair, Kempston and Fuller).
- Two real joysticks support (Up to 8 button joysticks) using [ESPjoy adapter](https://antoniovillena.es/store/product/espjoy-for-espectrum/) or DIY DB9 to PS/2 converter.
- Emulation of Betadisk interface with four drives and TRD (read and write) and SCL (read only) support.
- Realtime and fast TAP file loading.
- TAP file saving to SD card.
- SNA and Z80 snapshot loading.
- Snapshot saving and loading.
- Complete file navigation system with autoindexing, folder support and search functions.
- Complete OSD menu in two languages: English & Spanish.
- BMP screen capture to SD Card (thanks David Crespo 😉).

## Work in progress

- Folder support.
- Customizable joystick maps.
- On screen keyboard.
- TZX support.

Expand Down Expand Up @@ -67,13 +67,8 @@ Run these tasks (`Upload` also does a `Build`) whenever you make any change in t

The SD card should be formatted in FAT16 / FAT32 and you must create the following folders in root directory:

- "p" folder -> Will be used for persist snapshots.
- "s" folder -> Put .SNA and .Z80 files here.
- "d" folder -> Put .TRD and .SCL files here.
- "t" folder -> Put .TAP files here.
- "c" folder -> For SCR (not yet!) and BMP screen captures.

First time the emulator access sna, tape or disk directories, it will create and index for sorting the files in it. It may take some time if you put many archives (15-20 seconds in my tests for about 1000 files, about 3 minutes for about 6000 files). Once created, file dialogs will open fast but if you extract the card and add files, you must later use "Options/Storage/Refresh directories" to be able to view new files on the files dialogs.
- ".p" folder -> Will be used for persist snapshots.
- ".c" folder -> For BMP screen captures.

## PS/2 Keyboard functions

Expand All @@ -91,6 +86,8 @@ First time the emulator access sna, tape or disk directories, it will create and
- F12 Reset ESP32
- Pause Pause
- PrntScr BMP screen capture (Folder /c at SDCard)
- CTRL + F1 Hardware info
- CTRL + F5..F8 Screen centering in CRT 15K/50hz mode

## ZX Keyboard functions

Expand All @@ -109,7 +106,10 @@ Press CAPS SHIFT + SYMBOL SHIFT and:
- Q Hard reset
- W Reset ESP32
- P Pause
- C BMP screen capture (Folder /c at SDCard)
- S BMP screen capture (Folder /c at SDCard)
- I Hardware info
- Z, X, C and V Screen centering in CRT 15K/50hz mode


## Hardware configuration and pinout

Expand Down
29 changes: 29 additions & 0 deletions components/fabgl/src/devdrivers/kbdlayouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,35 @@ const KeyboardLayout USLayout {
// deadkeys translation
{
},

// extended joy scancodes (0xE2..)
{
{ 0x40, VK_JOY1LEFT },
{ 0x41, VK_JOY1RIGHT },
{ 0x42, VK_JOY1UP },
{ 0x43, VK_JOY1DOWN },
{ 0x44, VK_JOY1START },
{ 0x45, VK_JOY1MODE },
{ 0x46, VK_JOY1A },
{ 0x47, VK_JOY1B },
{ 0x48, VK_JOY1C },
{ 0x49, VK_JOY1X },
{ 0x4A, VK_JOY1Y },
{ 0x4B, VK_JOY1Z },
{ 0x4C, VK_JOY2LEFT },
{ 0x4D, VK_JOY2RIGHT },
{ 0x4E, VK_JOY2UP },
{ 0x4F, VK_JOY2DOWN },
{ 0x50, VK_JOY2START },
{ 0x51, VK_JOY2MODE },
{ 0x52, VK_JOY2A },
{ 0x53, VK_JOY2B },
{ 0x54, VK_JOY2C },
{ 0x55, VK_JOY2X },
{ 0x56, VK_JOY2Y },
{ 0x57, VK_JOY2Z },
},

};


Expand Down
1 change: 1 addition & 0 deletions components/fabgl/src/devdrivers/kbdlayouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct KeyboardLayout {

VirtualKey deadKeysVK[8]; /**< Dead keys identifiers. */
DeadKeyVirtualKeyDef deadkeysToVK[60]; /**< Translation dead key + virtual key = replaced virtual key */
VirtualKeyDef exJoyScancodeToVK[24]; /**< Direct extended-joy-scancode->virtualkey associations. Extended joy scancodes begin with 0xE1. */
};


Expand Down
39 changes: 39 additions & 0 deletions components/fabgl/src/devdrivers/kbjoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@ VirtualKey KeybJoystick::scancodeToVK(uint8_t scancode, bool isExtended, Keyboar
return vk;
}

VirtualKey KeybJoystick::scancodeTojoyVK(uint8_t scancode, KeyboardLayout const * layout)
{
VirtualKey vk = VK_NONE;

if (layout == nullptr)
layout = m_layout;

VirtualKeyDef const * def = layout->exJoyScancodeToVK;
for (; def->scancode; ++def)
if (def->scancode == scancode) {
vk = def->virtualKey;
break;
}

if (vk == VK_NONE && layout->inherited)
vk = scancodeTojoyVK(scancode, layout->inherited);

// printf("VK: %d\n",vk);

return vk;

}

VirtualKey KeybJoystick::manageCAPSLOCK(VirtualKey vk)
{
Expand Down Expand Up @@ -410,7 +432,9 @@ bool KeybJoystick::blockingGetVirtualKey(VirtualKeyItem * item)
uint8_t * scode = item->scancode;

*scode = getNextScancode();
// printf("Scode: %x\n",*scode);
if (*scode == 0xE0) {
// printf(" E0 Scode: %x\n",*scode);
// two bytes scancode
*(++scode) = getNextScancode(100, true);
if (*scode == 0xF0) {
Expand All @@ -432,6 +456,21 @@ bool KeybJoystick::blockingGetVirtualKey(VirtualKeyItem * item)
else if (i == sizeof(PAUSECODES) - 1)
item->vk = VK_PAUSE;
}
} else if (*scode == 0xE2) {
// printf(" E2 Scode: %x\n",*scode);
// two bytes joy scancode
*(++scode) = getNextScancode(100, true);
// printf(" E2 Scode: %x\n",*scode);
if (*scode == 0xF0) {
// two bytes scancode key up
*(++scode) = getNextScancode(100, true);
// printf(" E2 Scode: %x\n",*scode);
item->vk = scancodeTojoyVK(*scode);
item->down = false;
} else {
// two bytes scancode key down
item->vk = scancodeTojoyVK(*scode);
}
} else if (*scode == 0xF0) {
// one byte scancode, key up
*(++scode) = getNextScancode(100, true);
Expand Down
1 change: 1 addition & 0 deletions components/fabgl/src/devdrivers/kbjoystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ class KeybJoystick : public PS2Device {
private:

VirtualKey scancodeToVK(uint8_t scancode, bool isExtended, KeyboardLayout const * layout = nullptr);
VirtualKey scancodeTojoyVK(uint8_t scancode, KeyboardLayout const * layout = nullptr);
VirtualKey VKtoAlternateVK(VirtualKey in_vk, bool down, KeyboardLayout const * layout = nullptr);
VirtualKey manageCAPSLOCK(VirtualKey vk);
void updateLEDs();
Expand Down
36 changes: 36 additions & 0 deletions components/fabgl/src/devdrivers/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ VirtualKey Keyboard::scancodeToVK(uint8_t scancode, bool isExtended, KeyboardLay
}


VirtualKey Keyboard::scancodeTojoyVK(uint8_t scancode, KeyboardLayout const * layout)
{
VirtualKey vk = VK_NONE;

if (layout == nullptr)
layout = m_layout;

VirtualKeyDef const * def = layout->exJoyScancodeToVK;
for (; def->scancode; ++def)
if (def->scancode == scancode) {
vk = def->virtualKey;
break;
}

if (vk == VK_NONE && layout->inherited)
vk = scancodeTojoyVK(scancode, layout->inherited);

return vk;

}

VirtualKey Keyboard::manageCAPSLOCK(VirtualKey vk)
{
if (m_CAPSLOCK) {
Expand Down Expand Up @@ -415,8 +436,10 @@ bool Keyboard::blockingGetVirtualKey(VirtualKeyItem * item)
uint8_t * scode = item->scancode;

*scode = getNextScancode();
// printf("Scode: %x\n",*scode);
if (*scode == 0xE0) {
// two bytes scancode
// printf(" E0 Scode: %x\n",*scode);
*(++scode) = getNextScancode(100, true);
if (*scode == 0xF0) {
// two bytes scancode key up
Expand All @@ -437,6 +460,19 @@ bool Keyboard::blockingGetVirtualKey(VirtualKeyItem * item)
else if (i == sizeof(PAUSECODES) - 1)
item->vk = VK_PAUSE;
}
} else if (*scode == 0xE2) {
// printf(" E2 Scode: %x\n",*scode);
// two bytes joy scancode
*(++scode) = getNextScancode(100, true);
if (*scode == 0xF0) {
// two bytes scancode key up
*(++scode) = getNextScancode(100, true);
item->vk = scancodeTojoyVK(*scode);
item->down = false;
} else {
// two bytes scancode key down
item->vk = scancodeTojoyVK(*scode);
}
} else if (*scode == 0xF0) {
// one byte scancode, key up
*(++scode) = getNextScancode(100, true);
Expand Down
1 change: 1 addition & 0 deletions components/fabgl/src/devdrivers/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ class Keyboard : public PS2Device {
private:

VirtualKey scancodeToVK(uint8_t scancode, bool isExtended, KeyboardLayout const * layout = nullptr);
VirtualKey scancodeTojoyVK(uint8_t scancode, KeyboardLayout const * layout = nullptr);
VirtualKey VKtoAlternateVK(VirtualKey in_vk, bool down, KeyboardLayout const * layout = nullptr);
VirtualKey manageCAPSLOCK(VirtualKey vk);
void updateLEDs();
Expand Down
38 changes: 38 additions & 0 deletions components/fabgl/src/fabutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,44 @@ enum VirtualKey {
VK_HANKAKU_ZENKAKU_KANJI,
VK_SHIFT_0,

VK_JOY1LEFT,
VK_JOY1RIGHT,
VK_JOY1UP,
VK_JOY1DOWN,
VK_JOY1START,
VK_JOY1MODE,
VK_JOY1A,
VK_JOY1B,
VK_JOY1C,
VK_JOY1X,
VK_JOY1Y,
VK_JOY1Z,
VK_JOY2LEFT,
VK_JOY2RIGHT,
VK_JOY2UP,
VK_JOY2DOWN,
VK_JOY2START,
VK_JOY2MODE,
VK_JOY2A,
VK_JOY2B,
VK_JOY2C,
VK_JOY2X,
VK_JOY2Y,
VK_JOY2Z,

VK_KEMPSTON_RIGHT,
VK_KEMPSTON_LEFT,
VK_KEMPSTON_DOWN,
VK_KEMPSTON_UP,
VK_KEMPSTON_FIRE,
VK_KEMPSTON_ALTFIRE,

VK_FULLER_RIGHT,
VK_FULLER_LEFT,
VK_FULLER_DOWN,
VK_FULLER_UP,
VK_FULLER_FIRE,

VK_ASCII, /**< Specifies an ASCII code - used when virtual key is embedded in VirtualKeyItem structure and VirtualKeyItem.ASCII is valid */
VK_LAST, // marks the last virtual key

Expand Down
2 changes: 2 additions & 0 deletions components/pwm_audio/include/pwm_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ esp_err_t pwm_audio_get_status(pwm_audio_status_t *status);

uint32_t pwm_audio_rbstats(void);

uint32_t pwm_audio_pwmcount(void);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 9914e40

Please sign in to comment.