+
Skip to content

IF2 ROM Cartridge replacement using a Raspberry Pico. Inspired by Paul Farrow's ZXC cartridges.

License

Notifications You must be signed in to change notification settings

Thor10/ZXPicoZXCx

 
 

Repository files navigation

ZXPicoZXCx

IF2 ROM Cartridge replacement using a Raspberry Pico with ability to emulate Paul Farrow's ZXC Cartridges. Currently supports ZXC1 & ZXC2 cartridges only. Tested with Spectrum ROM Tester, Spectrum 128k Emulator (with & without IF1) and Spanish 128k Emulator

Based on the original design by Derek Fountain https://github.com/derekfountain/zx-spectrum-pico-rom.

image

Includes a simple DB9 joystick connector, wired to Atari pinout and mapped to Sinclair 1 (67890). Note this is a simple hardware implementation inspired by the Shadow of the Unicorn Interface using diodes rather than the Pico (not enough GPIOs) or an inverter chip which most other interfaces use. As a result 5V is not sent to the adapter and autofire functions of some joysticks do not work. This is most likely due to the lack of a constant ground signal, normal fire and directions work fine.

The joystick circuit is pretty basic, it uses the 4075 OR chip to pull the GND pin of the joystick low when RD, A0, A12 & IORQ are low, high when any of them isn't low. This is basically simulating when the Spectrum is reading 67890 on the keyboard. If the output from the OR chip is low then if you move the joystick or press fire it grounds one of the data lines, either D0, D1, D2, D3 or D4. This creates the correct bit pattern for a IN 0xfe read on the Spectrum. Diodes protect the data line so it literally only zeros the bits when they are needed. I beleive it is the fact that the ground pin of the joystick isn't constant that autofire circuits don't work.

Version Control

  • v0.2 changes to improve ZXC compatibility, added zxcOn true/false ** Latest Version
  • v0.1 initial release taken form PicoIF2ROM but with interrupt driven user button

Usage

Usage is very simple. On every cold boot the Spectrum will default to the normal Spectrum, basically the interface will be disabled. To change ROMs press and hold the user button for >1second and the Spectrum will boot into the ROM Explorer. If you want to reset the Spectrum just press the user button and do not hold down. The ROM Explorer is very easy to use and is in the style of a standard File Explorer. User the cursor/arrow keys to navigate the ROMs and enter to select one. ROMs with icons to the RHS indicate they will launch with ZXC compatibiltiy. More details of the ROM Explorer cna be found below.

Building an Interface

I've provided everything you need to build your own Interface below, includng the Gerbers for getting the PCBs made. I've also provided all the code so you can add your own ROMs and compile the necessary files to load onto the Pico. For details on how to set-up a build enviroment please refer to the Raspberry Pico SDK documentation

Once built, load the UF2 file onto the Pico and boot the Spectrum. Hopefully all works fine.

The Schematic

image

The PCB

image

All the files needed to make your own PCB are in the Gerbers folder, zipped.

Bill of Materials (BoM)

The ROMs

For demonstration purposes I have included the following ROMs:

Adding your own ROMs

To add your own ROMs you need to first create a binary dump of the ROM (or just download it) and convert that into a uint8_t array to put in the roms_lite.h header file. I've written a little utility to do this called compressROM. This utiltiy uses a very simple compression alogrithm to reduce the size of the ROMs which helps if you want to add a loads of them (max 126). After compressing the utility creates the approprite header file structure to paste into roms_lite.h.

Once you've added the ROM to roms_lite.h you then need to add details about the ROM to the picozxcx_lite.h header file. This is in four parts.

  1. name of the arrary
  2. whether you need to enable ZXC compatibility
  3. the desciption to show in the ROM selector (max 32chars)
  4. Set the MAXROMS number to match the number of ROMs

Use the examples in the header file already as a guide.

ZXC Compatibiltiy

As of v0.2 this is compatible with ZXC2 allowing banking, turning off of the ROM and locking the paging. Full details of how ZXC2 works can be found on Paul Farrow's website but a summary of how I've implemented it is below:

When in ZXC compatibility mode, the Pico will scan each ROM address memory request. If the memory request is in the top 64bytes (0x3fc0-0x3fff) the Pico will do one of the following:

  • If address bit 5 is on (1) the Pico will prevent further paging, basically locking the interface. This lock cannot be reversed via software and needs the user (reset) button pressing. Note you can still get into the ROM swap menu by pressing and holding the user button, this simply stops the software paging from working.
  • If addressbit 4 is on (1) the Pico will page out the interface ROM paging in the Spectrum ROM
  • If addressbit 4 is off (0) the Pico will page in the interface ROM, paging out the Spectrum ROM
  • Address bits 0-3 are used to determine which ROM to page in, 0 is ROM 0, 5 is ROM 5 etc... I've set-up the Pico to mimic a 128k EPROM which allows for 8 banks/pages.
    • To use this you need to create a single ROM binary with all the ROMs you want to swap in/out using the ZXC commands.
    • The Spectrum 128k emulator ROM on Paul's website is a 32kB or 48kB ROM as an example. You don't need to split this into 2 or 3 16kB ROMs, just load the whole thing.

The ROM Selector

In order to swap between all the different ROMs the interface needs a simple ROM Selector utility which runs on the Spectrum. Once this has launched the Pico will constantly monitor the top of ROM memory, so to pick a ROM all the Spectrum code needs to do is loop over a memory read at the correct location between 0x3f80 and 0x3fff. For example 0x3f80 is ROM 0, 0x3f96 is ROM 22. If a ROM is selected which doesn't exist the code will just pick the last ROM.

I've provided a fully working ROM Explorer program, in the style of File Explorer, which does exactly this. You can easily replace this with your own if you wish and I've highlighted the relavent sections in the code which need replacing.

image

You can also use the selector to turn the device off, which pages in the Spectrum ROM, especailly useful on 128k machines or if you want to use external devices with shadow ROMs i.e. Interface 1.

image

The Case

I've created a 3D Printed Case for the interface. This makes it a lot easier to attach and remove from the Spectrum. You can download the STLs on Thingiverse

image

image

About

IF2 ROM Cartridge replacement using a Raspberry Pico. Inspired by Paul Farrow's ZXC cartridges.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.7%
  • CMake 0.3%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载