vossstef / tang_nano_20k_c64

Commodore C64 core for the Tang Nano 20K Primer 25K and Mega 138K Pro FPGA
GNU General Public License v3.0
64 stars 11 forks source link
c64 commodore fpga gowin mist tang-nano

C64Nano

The C64Nano is a port of some MiST and MiSTer components of the C64 FPGA core for the Tang Nano 20k FPGA board with a new VHDL top level and HDMI Video and Audio Output.
It has also been ported to the Tang Primer 25K (Gowin GW5A-25) and Tang Mega 138k Pro (Gowin GW5AST-138) too.
Be aware that the VIC20 FPGA core had been ported too in similar manner (link).

Original C64 core by Peter Wendrich
All HID components and BL616 MCU µC firmware by Till Harbaum
c1541 by https://github.com/darfpga

Features:

HID interfaces aligned in pinmap and control to match MiSTeryNano project's bl616 misterynano_fw respectively FPGA-Companion
Basically a µC acts as USB host for USB devices and as an OSD controller using a SPI communication protocol.

Note PROJECT IS STILL WORK IN PROGRESS

Installation

The installation of C64 Nano on the Tang Nano 20k board can be done using a Linux PC or a Windows PC (Instruction).

c64 Nano on Tang Primer 25K

See Tang Primer 25K

c64 Nano on Tang Mega 138k Pro

See Tang Mega 138K

emulated Diskdrive c1541

Emulated 1541 on a regular FAT/exFAT formatted microSD card including parallel bus Speedloader Dolphin DOS 2.0.
Copy a D64 Disk image to your sdcard and rename it to disk8.d64 as default boot image.
Add further D64 or G64 images as you like and insert card in TN slot. LED 0 acts as Drive activity indicator.

[!TIP] Disk directory listing: (or F7 keypress)
command:
LOAD"$",8
LIST
Load first program from Disk: (or just LOAD if Dolphin Kernal active)
LOAD"*",8
RUN

c1541 DOS ROM can be selected from OSD (default Dolphin DOS 2.0, CBM DOS, SpeedDos Plus or JiffyDOS)
In case a program don't load correctly select via OSD the factory default CBM DOS an give it a try.

Cartridge ROM Loader (.CRT)

Cartridge ROM can be loaded via OSD file selection.
Copy a *.CRT to your sdcard and rename it to c64crt.crt as default boot cartridge ROM.
Prevent the cartridge load at boot by OSD CRT selection No Disk , Save settings and System Cold Boot.

[!TIP] Detach Cartridge by OSD CRT selection No Disk and System Cold Boot.

BASIC Program Loader (.PRG)

A BASIC Program .PRG file can be loaded via OSD file selection.
Copy a
.PRG to your sdcard and rename it to c64prg.prg as default boot basic program. Prevent the PRG load at boot by OSD PRG selection No Disk , Save settings and Reset or System Cold Boot.

[!TIP] Check loaded file by command: LIST

[!IMPORTANT] command: RUN

Tape Image Loader (*.TAP)

A Tape *.TAP file can be loaded via OSD file selection
In order to start a tape download choose C64 CBM Kernal (mandatory as Dolphin DOS doesn't support Tape). Best to save Kernal OSD selection via Save settings.

[!IMPORTANT] command: LOAD
___ Only if you have Exbasic Level II .CRT Basic loaded then use command: **LOAD***
Screen will blank!

The file is loaded automatically as soon as TAP file selected via OSD (no need to press PLAY TAPE button) in case no TAP had been previously selected.
As mentioned screen will blank for several seconds and then display briefly the filename of the to be loaded file. It will blank shortly afterwards again till load completed and take a lot of time...
Copy a *.TAP to your sdcard and rename it to c64tap.tap as default tape mountpoint.
For Tape unload use OSD TAP selection No Disk and Reset or System Cold Boot.

[!WARNING] After board power-up or coldboot a TAP file will not autoloaded even if TAP file selection had been saved or c64tap.tap mountpoint available !
Unblock loader by OSD TAP selection No Disk or simply select again the desired TAP file to be loaded after you typed LOAD

[!TIP] Check loaded file by command: LIST

[!IMPORTANT] command: RUN

[!NOTE] The available (muffled) Tape Sound audio can be disabled from OSD.

Kernal Loader (.BIN)

The build-in Dolphin Kernal is the power-up default C64 Kernal with an excellent C1541 speedloader.

[!TIP] If you are fine with that then there is no need to load another Kernal via OSD and just select OSD Kernal BIN selection No Disk and Save settings!

In general Kernal ROM files .BIN can be loaded via OSD selection.
Copy a 8K C64 Kernal ROM
.BIN to your sdcard and rename it to c64kernal.bin as default boot Kernal.
Prevent Kernal load by OSD Kernal BIN selection No Disk and Save settings and do a power-cyle of the board. In this case the build-in Dolphin Kernal will by default be used after next power cycle.

SID Filter Curve (.FLT)

Custom Filters curves can optionally be loaded via OSD.

[!TIP] This is in most cases not needed and build-in filters curves are already an optimum.

[!NOTE] Remember to select the 6581 chip, not the 8580. Select 'Custom 1' as the filter to activate it.
When a custom filter is loaded, there's no difference between custom options Custom 1, 2, and 3. Selecting 'Default' switches back to the built-in filter curve.

Prevent Filter curve load by OSD Kernal FLT selection No Disk and Save settings and power-cyle of the board.

Core Loader Sequencing

The core will after power cycle/ cold-boot start downloading the images on the sdcard in the following order:

[!NOTE] (1) BIN Kernal, (2) CRT ROM, (3) PRG Basic and finally (4) FLT.

emulated RAM Expansion Unit REU 1750

For those programs the require a RAM Expansion Unit (REU) it can be activated by OSD on demand.

Playing Sonic the Hedgehog V1.2
Enable REU, and load the PRG.
Playing around with GEOS
Enable REU, select c1541 CBM DOS ROM and load the PRG.

Push Button utilization

OSD

invoke by F12 keypress

Gamecontrol support

legacy single D9 Digital Joystick. OSD: Retro D9
Atari ST type of Joystick 2nd button supported using a MiSTeryNano shield.

or
USB Joystick(s). OSD: USB #1 Joy or USB #2 Joy
or
Gamepad Stick as Joystick. OSD: DualShock 2


left stick digital for Move and square , cross and circle Button for 3 Trigger buttons
or following Pad controls:
Buttons - -
square
Trigger
Up cross
Trigger 2
Left - Right
- Down circle
Trigger 3

or Keyboard Numpad. OSD: Numpad
0
Trigger
8
Up
.
Trigger 2
4
Left
- 6
Right
- 2
Down
-

or Mouse. OSD: Mouse
USB Mouse as c1351 Mouse emulation.

or Dualshock2 Gamepad as Paddle. OSD: DS2 Paddle
Dualshock 2 Sticks in analog mode as VC-1312 Paddle emulation.
square , cross, circle and triangle used as 4 Trigger buttons
You have first to set the DS2 Sticks into analog mode by pressing the DS2 ANALOG button. Mode indicated by red light indicator.
Configure DIGITAL mode (press ANALOG button again) when using the Joystick mode again and set OSD: DualShock

or USB Paddle. OSD: USB #1 Padd or USB #2 Padd
Left Stick in X / Y analog mode as VC-1312 Paddle emulation.
Button 1 / 2 as Trigger

Keyboard

Layout PAGE UP (Tape Play) Key or the Tang S1 Button swap the Joystick Ports if OSD Swap Joys is set to Off mode.

LED UI

LED function TN20K TP25K TM138K
0 c1541 activity x x x
1 D64 selected x - x
2 CRT seleced x - x
3 PRG selected x - x
4 Kernal selected x - x
5 TAP selected x - x

Solid red of the c1541 led after power-up indicates a missing DOS in Flash

Multicolor RGB LED

MIDI-IN and OUT

Type of MIDI interface can be selected from OSD.
There is support for Sequential Inc., Passport/Sentech, DATEL/SIEL/JMS/C-LAB and Namesoft
You can use a MiSTeryNano MIDI shield to interface to a Keyboard.

RS232 Serial Interface

The Tang onboard USB-C serial port can be used for communication with the C64 Userport Serial port in VIC-1011 or UP9600 mode.
Terminal programs need the Kernal serial routines therefore select via OSD the CBM Kernal rather than default DolphinDOS.
For a first start use UP9600 mode and a Terminal program like ccgms and on the PC side Putty with 2400 Baud.

OSD selection allows to change in between TANG USB-C port or external HW pin interface.

Board RX (I) FPGA TX (O) FPGA Note
TN20k 31 77 pinmap, misterynano io(6) / io(7)
TP25k K5 L5 J4-6 J4-5, share M0S Dock PMOD
TM138k Pro H15 H14 J24-6 J24-5, share M0S Dock PMOD

Remember that in + out to be crossed to connect to external device. Level are 3V3 tolerant.

A future release will add Swiftlink 6551 UART support @ $DE00, $DF00 and $D700, NMI.

Powering

Prototype circuit with Keyboard can be powered by Tang USB-C connector from PC or a Power Supply Adapter.

Synthesis

Source code can be synthesized, fitted and programmed with GOWIN IDE Windows or Linux.
Alternatively use the command line build script gw_sh.exe build_tn20k.tcl, build_tp25k.tcl or build_tm138k.tcl

Pin mapping

see pin configuration in .cst configuration file

HW circuit considerations

Pinmap TN20k Interfaces
Sipeed M0S Dock, digital Joystick D9 and DualShock Gamepad connection.
wiring

Pinmap D-SUB 9 Joystick Interface

Joystick pin IO Tang Nano pin FPGA pin Joystick Function
1 2 J6 10 25 UP
2 1 J6 9 28 DOWN
3 4 J6 12 29 LEFT
4 3 J5 11 26 RIGHT
5 - - - POT Y/ TRIGGER 3 -
6 0 J5 8 27 TRIGGER
7 - n.c n.c 5V -
8 - J5 20 - GND -
9 - - MiSTeryNano shield only POT X/ TRIGGER 2

Pinmap Dualshock 2 Controller Interface

image
DS pin Tang Nano pin FPGA pin DS Function
1 J5 18 71 MISO JOYDAT
2 J5 19 53 MOSI JOYCMD
3 n.c. - 7V5
4 J5 15 - GND
5 J5 16 - 3V3
6 J5 17 72 CS JOYATN
7 J5 20 52 MCLK JOYCLK
8 n.c. - JOYIRQ
9 n.c. - JOYACK

Getting started

In order to use this Design the following things are needed:

Sipeed M0S Dock or Raspberry Pi Pico RP2040 or ESP32-S2/S3
Sipeed Tang Nano 20k
or Sipeed Tang Primer 25k
and PMOD DVI
and PMOD TF-CARD
and PMOD SDRAM
and M0S PMOD adapter or ad hoc wiring + soldering.
or Sipeed Tang Mega 138k Pro
and PMOD SDRAM
and PMOD DS2x2
and M0S PMOD adapter
microSD or microSDHC card FAT32 formatted
TFT Monitor with HDMI Input and Speaker

HID and Gamecontrol Hardware option TN20k needs alternative option Primer 25K Mega 138K
USB Keyboard USB-C to USB-A adapter 4 port mini USB hub HS8836A x x
USB Joystick(s) 4 port mini USB hub HS8836A - x x
USB Mouse 4 port mini USB hub HS8836A - x x
USB Gamepad 4 port mini USB hub HS8836A - x x
Commodore/Atari compatible retro D9 Joystick MiSTeryNano shield D-SUB 9 M connector, breadboard to wire everything up, some jumper wires - -
Dualshock 2 Controller Gamepad Gamepad Adapter Board (Sipeed Joystick to DIP) respectively
PMOD DS2x2
breadboard to wire everything up and some jumper wires - x