Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amstrad CPC (and possibly other 8bits computers) emulation #177

Open
8Gilles8 opened this issue Jan 15, 2025 · 2 comments
Open

Amstrad CPC (and possibly other 8bits computers) emulation #177

8Gilles8 opened this issue Jan 15, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@8Gilles8
Copy link

Hi,

I've been really enjoying retro-go for quite a while now.
Since an msx emulator was added, I wondered if it would be possible to also add Amstrad CPC (and maybe the + and gx4000 variants).

A good but not very well known emulator is CPCEC.
I also stumbled upon CPCESP which is designed for ESP32. At this time, source code has not been published, but there are links to other projects it is based on.

What's interesting with CPCEC is that this project is not just an Amstrad CPC emulator, but there are also other Z80 based systems: ZX Spectrum, C64 and MSX. If you can port this to retro-go, you could have 4 emulators in 1.

As a side note, I have an odroid go with the qwerty keyboard addon. It would be great to see it work with computers in retro-go. If you want, I can test builds for keyboard compatibility.

I hope those ideas will lead to something.

Thanks again for all your work. I can't wait to see what's coming next.

Gilles

@8Gilles8 8Gilles8 added the enhancement New feature or request label Jan 15, 2025
@ducalex
Copy link
Owner

ducalex commented Jan 26, 2025

What's interesting with CPCEC is that this project is not just an Amstrad CPC emulator, but there are also other Z80 based systems: ZX Spectrum, C64 and MSX. If you can port this to retro-go, you could have 4 emulators in 1.

I have no objection replacing fMSX with CPCEC. Do you know if anyone tried porting it to esp32 before? Or pi pico or any mcu really? But I think the license could be a problem. For all intents and purposes retro-go can be considered a GPLv2-only project and:

  1. I don't think you can use GPLv3 code in a GPLv2 project but since CPCEC would be a standalone app inside retro-go, does it apply to us? I don't know.
  2. Most allocations are static (eg BYTE mem_ram[129<<14],mem_rom[9<<14]; will definitely not build for esp32) so that has to change. Which means I'd be creating derivative work and we're pack at point 1 regarding license confusion...

If the license is a no-go then I'd probably still be open to adding individual emulators for sinclair or cpc or commodore machines, but flash size is going to be a concern.

As a side note, I have an odroid go with the qwerty keyboard addon. It would be great to see it work with computers in retro-go. If you want, I can test builds for keyboard compatibility.

Adding keyboard support is a good idea and probably not very difficult! I remember seeing the project on the hardkernel forum but I've never looked to how it worked. Can you give me a few links to the schematics and maybe to an odroid-go project that supports it?

@8Gilles8
Copy link
Author

Hi Ducalex,

it's good to see that you are interested in my suggestions.

I have no objection replacing fMSX with CPCEC. Do you know if anyone tried porting it to esp32 before? Or pi pico or any mcu really?

To my knowledge, there has only been windows versions.
The author of CPCEC says that: "The default build of CPCEC requires a Microsoft Windows 2000 operating system or later, while the SDL2 build requires any operating system supported by the SDL2 library. The minimal hardware requirements are those fitting the operating system, and it's advised that the main microprocessor runs at 400 MHz at least. Screen resolution in pixels must be 800x600 at least. A sound card is optional. Using a joystick is optional, too."

A portage of CPCEC to esp32 would require to keep the core emulation and replace SDL2 code. I think you did something similar with the other emulators.
I understand it's still a lot of work, but if it can lead to 4 new systems, it might be worth the effort.
I'd gladly help, but I'm not as good as you. I think it would take more time for you to explain to me what I can do to help than doing it yourself.

As for the specs, the 800x600 screen resolution could be a problem, but if you've never heard of the CPC before, I can tell you that it uses 3 modes: mode 0 is 160x200 pixels with 16 colors (each pixel is like 2 pixels wide in a 320x200 resolution); mode 1 is 320x200 pixels with 4 colors and mode 2 is 640x200 pixels with 2 colors. Around the screen is a border in a unique color (independant from colors used inside the screen).
Some games uses the CRTC (the video signal chip) to create a custom screen size to change aspect ratio, sometimes by expanding into the border vertically and reducing screen space horizontally or vice-versa.
Anyway, I think the emulator core will provide a bitmap buffer of the screen that you could render in the 320x240 screen of the host system.

There has been a portage of Caprice32 to the odroid go by millim:
https://forum.odroid.com/viewtopic.php?f=159&t=40921
The first post of the thread has a link to a github.
Here is the latest fw for odroid go.
You should see the github for instructions on how to prep the folders on the SD card.
This emulator has not evolved for 4 years.
Menu is called via menu+B. There are 3 panes and you navigate with menu+direction between them: on the top left, you choose one disk image, then on the top right you can select which file to autostart. When the menu says "Ready to go", you have to press menu+B again to start emulation. Bottom pane is for preferences.
I think this emulator doesn't display the border. It only draws what's inside. It's not really a problem except for games that draw things in the border space via a CRTC tweak.

As I don't know if you're familier with CPCs, I try to explain what could be relevant to emulation on the odroid.

Also there are only 27 colors in to choose from in the original series (464, 664 and 6128).
On the + series (464+, 6128+ and gx4000), there are a lot more (4096) and you can display 32 on screen.
The model identifier tells you if it has a k7 drive (begins with 4) of floppy drive (begins with 6). After that you have the RAM size (64 or 128kB).
The + series have a cartridge port. The gx4000 is a console (no keyboard, no drive). I think it's more or less a 464+.
Caprice32 only emulates the original series.
CPCEC can deal with the + series.
It's also the only emulator that I know of that can emulate a dandanator: a recent device the can support big rom cartridges.

But I think the license could be a problem. For all intents and purposes retro-go can be considered a GPLv2-only project and:

1. I don't think you can use GPLv3 code in a GPLv2 project but since CPCEC would be a standalone app inside retro-go, does it apply to us? I don't know.

I don't know much about licenses. I looked at the gwenesis github and I saw that it is an AGPLv3.0 project. And LCD-Game-Emulator is GPL-3.0.
So it seems you do already have GPLv3 components in retro-go.

Would it be a problem to turn retro-go into a GPLv3 license?
I don't mean to offend you. I'm just asking. You may have good reasons to keep a GPLv2 license.

2. Most allocations are static (eg `BYTE mem_ram[129<<14],mem_rom[9<<14];` will definitely not build for esp32) so that has to change. Which means I'd be creating derivative work and we're pack at point 1 regarding license confusion...

As explained before, RAM size is either 64kB or 128kB (using bank switching). Most softwares uses only 64kB. A reasonnable amount uses the 128 kB from 6128.
Back in the days, you could expand RAM to 576 kB. I recently bought a Z-Mem, which is 1MB. Only a few softwares make use of it and I don't think any (legacy) games need that much. So, targetting more than 128kB of RAM would benefit only to a handfull of utilities. There might be no point in using those on a small handheld without keyboard. And even with the keyboard addon, it shouldn't be very usefull.
CPCEC seems to emulate a 2MB RAM. I only know FutureOS which uses that amount.

If the license is a no-go then I'd probably still be open to adding individual emulators for sinclair or cpc or commodore machines, but flash size is going to be a concern.

I know there are a lot of different supported devices nowadays.
I only have an odroid go and Caprice32 is using 1.3MB of flash. I think a CPC emulator in retro-go would take a lot less than that.
That being said, hardware variants with only 4MB flash might not be able to accomodate too much new emulators.

Adding keyboard support is a good idea and probably not very difficult! I remember seeing the project on the hardkernel forum but I've never looked to how it worked. Can you give me a few links to the schematics and maybe to an odroid-go project that supports it?

Here is the odroid wiki about the keyboard.
The source code is available in the Arduino IDE. I can find you the file if you want (I think it's legal to post it here).

After a quick search, I found this project. If I'm correct, it's a bluetooth keyboard utility which makes use of the QWERTY keyboard.

There was also a C64 emulator with QWERTY keyboard.
I never went very far with it. I don't know enough about C64 to launch anything and I don't know enough games to motivate me to learn.

By the way, there is also a RTC module with the keyboard. This could be interesting, although I don't see myself connecting the keyboard just for it's RTC functionnalities.

I hope this could help you.
I don't think I can be of much help coding, but I can try to test the CPC emulation (I don't know C64, Sinclair nor MSX enough to test those properly, but I'm sure there are others out there who'd be willing to).
I would need odroid fw files to test new builds.

By the way, I'm french, so it might be more convenient to speak french if we both have to discuss about this between ourselves.
Of course, we'll stick to english as much as possible so that non french speakers could follow the discussion.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants