Skip to content

Commodore VIC20 core for the Tang Nano 9k Nano 20k Primer 20k Primer 25k Mega 60k Mega138k Pro FPGA

License

Notifications You must be signed in to change notification settings

vossstef/VIC20Nano

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VIC20Nano

The VIC20Nano is a port of some MiST and MiSTer components of the VIC20 for the :

Board FPGA support Note
Tang Nano 9k GW1NR X no C1541, Tape, Mega-Cart
8k or 16k memory expansion
micro SD card HW modification needed
Tang Nano 20k GW2AR X -
Tang Primer 20K Dock ext Board GW2A X -
Tang Primer 25K GW5A-25 X no Dualshock, no Retro D9 Joystick
Tang Mega 60k NEO GW5AT-60 X two Dualshock, selectable
Tang Mega 138k Pro GW5AST-138 X two Dualshock, selectable

Be aware that the C64 had been ported too in similar manner (C64Nano).
Also the Atari 2600 VCS had been ported (A2600Nano).

Original VIC-20 core by MikeJ (Mike Johnson) and WoS (Wolfgang Scherr)
All HID, SDcard and BL616 MCU µC firmware by Till Harbaum
c1541 by darfpga

Features:

  • PAL 832x576p@50Hz or NTSC 800x480p@60Hz HDMI Video and Audio Output
  • USB Keyboard via µC (Sipeed M0S Dock BL616 / Raspberry Pi Pico RP2040 / ESP32 S2/S3)
  • USB Joystick via µC
  • USB Mouse via µC as c1351 Mouse emulation
  • USB Gamepad Stick via µC as Paddle Emulation
  • legacy D9 Joystick (Atari / Commodore digital type) MiSTeryNano shield
  • Joystick emulation on Keyboard Numpad
  • Dualshock 2 Controller Gamepad Keys & Stick as Joystick
  • Dualshock 2 Controller Gamepad Sticks as Paddle Emulation (analog mode)
  • emulated 1541 Diskdrive on FAT/extFAT microSD card
  • C1541 DOS ROM selection
  • Cartridge ROM (*.PRG) loader
  • Direct BASIC program file (*.PRG) injection loader
  • Tape (*.TAP) image loader C1530 Datasette
  • Loadable 8K Kernal ROM (*.BIN)
  • Mega-Cart (*.ROM) loader
  • On Screen Display (OSD) for configuration and D64 image selection
  • 3K, 8K, 16K, 24K, 32K RAM Expansion (35k with cardtridge RAM)
  • 8K RAM at $A000 as loadable Cartridge Slot
  • RS232 Serial Interface VIC-1011 to Tang onboard USB-C serial port or external hw pin.

image


HID interfaces aligned in pinmap and control to match MiSTeryNano project's misterynano_fw respectively FPGA-Companion.
Basically a µC M0S/BL616 / Raspberry Pi Pico RP2040 / ESP32-S2/S3 acts as USB host for USB devices and as an OSD controller using a SPI communication protocol.

Installation

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

VIC20Nano on Tang Nano 9K

See Tang Primer 9K

VIC20Nano on Tang Primer 20K (Dock ext board)

See Tang Primer 20K
The DDR3 memory controller is a slight modified copy of nestang. It had been tested on a board eqipped with a SKHynix DDR3 memory and is used as a buffer for the TAP Tape loading.

VIC20Nano on Tang Primer 25K

See Tang Primer 25K. PMOD TF-CARD V2 is required !

VIC20Nano on Tang Mega 60k NEO

See Tang Mega 60K NEO

VIC20Nano on Tang Mega 138K Pro

See Tang Mega 138K Pro

emulated Diskdrive c1541

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

Tip

Disk directory listing: [or F1 keypress in JiffyDOS]
command:
LOAD"$",8
LIST
Load first program from Disk: (or just LOAD if Dolphin Kernal active)
LOAD"*",8
RUN
JiffyDOS can be used as well known Speedloader. Change in OSD the c1541 DOS to Jiffy too.

RAM Expansion

Size and Region can be activated in several steps. A change takes effect immediately.
Take care to activate the correct size of needed expansion before you load *.PRG and *.TAP !

Expansion $0400 3k $2000 8k $4000 8k $6000 8k $A000 8k
Block 0 1 2 3 Cartridge
3k x - - -
8k - x - -
16k - x x -
24k - x x x
35k x x x x x

Cartridge ROM Loader (.PRG/.CRT)

Cartrige ROM can be loaded via OSD file selection.
Be aware that the core doesn't support the VICE EMU file format.
Typical VIC20 Cartridge ROMS with ending .PRG have a two byte header indicating the loading location.
8k Cartridges to be loadeded directly as such. 16k or larger Cartridges have to be loaded in several steps and the file with ending xyz-a000.prg have to be loaded last. First load xyz-2000.prg, xyz-4000.prg or xyz-6000.prg and then xyz-a000.prg at last. The Cartridge will start after that last step automatically.
Copy a 8K xyz-a000.prg ROM to your sdcard and rename it to vic20crt.crt as default boot cartridge.

Tip

Detach Cartridge by OSD :
temporary Cartridge unload & Reset
permanent No Disk, Save settings 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 vic20prg.prg as default boot basic program.
Prevent PRG load by OSD PRG selection No Disk , Save settings and Reset.

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 VIC20 CBM Kernal (mandatory as JiffyDOS doesn't support Tape). Best to save Kernal OSD selection via Save settings.

Important

command: LOAD

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.
After some seconds the filename of the to be loaded file will be shown and it will take time...
Copy a *.TAP to your sdcard and rename it to vic20tap.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 CBM factory PAL type is the power-up default Kernal.

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!

Kernal ROM files *.BIN can be loaded via OSD selection (e.g. JiffyDOS VIC20).
Copy a 8K VIC20 Kernal ROM *.BIN to your sdcard and rename it to vic20kernal.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.

loadable Cartridge RAM Slot

Some Cartridge based games can be be simply loaded from a VIC20 D64 Disk Image.
Example: 16 k Cartridge Game
Enable RAM Expansion at $2000 (or $6000) and Cartridge region $A000
Leave OSD setting CRT writeable setting as enabled as first approach. Save setting and do a Cold Boot Reset.
LOAD "xyz.200",8,1 (Block 1)
or LOAD "xyz.600",8,1 (Block 3)
LOAD "xyz.A00",8,1 (Block 5)
Start Game by command: SYS40960 (general start Address for Cartridge Slot)
or better perform a Reset via OSD.
There are also some cartridge games on D64 Image with a loader that themselves further reload the needed RAM regions and autostart (you have to activate RAM regions beforhand).
A loaded Cartridge can be exited by disabling memory region $A000 + Cold Reset via OSD. In order to trial another game just activate again (after reset !) the $A000 memory and load another game.

Mega-Cart (.ROM)

The 2MB Mega-Cart *.ROM can be loaded via OSD file selection.
If the Mega-Cart is used, then managing the RAM expansion configuration is done in its menu. NVRAM is not supported.

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.

Push Button / DIP Switch utilization

  • Nano 20k S2 keep pressed during power-up for FLASH programming of FPGA bitstream
  • Primer 20k: There is by default unfortunately no Button/Switch to prevent FPGA bitstream load from FLASH (see rework how to add).
  • Mega 60k NEO SW1 ON SW6 ON + Press & Hold RECONFIG + Power the Board + release RECONFIG and perform programming.

Caution

A FLASH programm attempt without keeping the board in reset may lead to corruption of the C1541 DOS images stored in FLASH requiring re-programming.

  • S1 reserved

OSD

invoke by F12 keypress

  • Reset
  • Cold Reset
  • Audio Volume + / -
  • Scanlines effect %
  • Widescreen activation
  • Screen centering
  • PAL / NTSC Video mode
  • HID device selection for Joystick Port
  • RAM Expansion $A000(8k), $6000(8k), $4000(8k), $2000(8k), $0400(3k)
  • Cartridge Write protection
  • c1541 Drive disk image selection
  • c1541 Disk write protetcion
  • c1541 Reset
  • c1541 DOS ROM selection
  • Loader (CRT/PRG/BIN/TAP/ROM) file selection
  • Cartridge unload

Gamecontrol support

legacy single D9 Digital Joystick. OSD: Retro D9
or
USB Joystick(s). OSD: USB #1 Joy or USB #2 Joy
or
Gamepad Stick as Joystick. OSD: DualShock2
stick digital for Move and Left L1 or Right R1 shoulder Button for Trigger or following Pad controls:

Buttons - -
Left L1/R1
Trigger
triangle button
Up
.
square button
Left
- circle button
Right
- cross button
Down
-

or Keyboard Numpad. OSD: Numpad

0
Trigger
8
Up
-
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.
Left L1 / L2 and Right R1 / R2 shoulder Button as Trigger
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 Tape Play not implemented.

LED UI

LED function TN20K TP20K TP25K TM60k TM138K Pro TN9k
0 c1541 activity x x x x (done) x N/A
1 D64 selected x x x x (ready) x N/A
2 CRT seleced x x - - x x
3 PRG selected x x - - x x
4 Kernal selected x x - - x x
5 TAP selected x x - - x N/A

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

Multicolor RGB LED

  • green      all fine and ready to go
  • red          something wrong with SDcard / default boot image
  • blue        µC firmware detected valid FPGA core
  • yellow      FPGA core can't detect valid firmware
  • white      -

RS232 Serial Interface

The Tang onboard USB-C serial port can be used for communication with the Userport Serial port VIC-1011.
Terminal programs need the Kernal serial routines therefore select via OSD the CBM Kernal.
For a first start use 1200Baud and a Terminal program like VIC term and on the PC side Putty.
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
TM60k NEO AB20 AA19 J24-6 J24-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.

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_tp20k.tcl or build_tp25k.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 interface is 3.3V tolerant. Joystick 5V supply pin has to be left floating !
    pinmap
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
6 0 J5 8 27 TRIGGER
7 - n.c n.c 5V
8 - J5 20 - GND
9 - - - POT X

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 V2
and SDRAM
and M0S PMOD adapter or ad hoc wiring + soldering.
or Tang Primer 20K with Dock ext Board
and M0S PMOD adapter.
and PMOD DS2x2
or Tang Nano 9K
or Sipeed Tang Mega 138k Pro
and SDRAM
and PMOD DS2x2
and M0S PMOD adapter
or Tang Mega 60K NEO
and SDRAM
and PMOD DS2x2
and M0S PMOD adapter

microSD or microSDHC card FAT/exFAT formatted
TFT Monitor with HDMI Input and Speaker

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