Skip to content

vossstef/VIC20Nano

Repository files navigation

VIC20Nano

The VIC20Nano is a port of some MiST and MiSTer components of the VIC20 FPGA core to 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) too (no Dualshock 2, no Paddles and no Retro DB9 Joystick support).

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:


image


HID interfaces aligned in pinmap and control to match MiSTeryNano project's bl616 misterynano_fw.
Basically BL616 µC on the Sipeed M0S Dock 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 VIC20 Nano on the Tang Nano 20k board can be done using a Linux PC or a Windows PC Instruction.

VIC20Nano on Tang Primer 25K

See Tang Primer 25K

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 slot. Power Cycle TN. LED 0 acts as Drive activity indicator.
Disk directory listing:
LOAD"$",8
LIST
Load first program from Disk:
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
Block 0 1 2 3
3k x - - -
8k - x - -
16k - x x -
24k - x x x
32k 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.
Detach Cartrige by OSD CRT selection 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.

Tape Image Loader (*.TAP)

A Tape *.TAP file can be loaded via OSD file selection.
In order to start a tape download select normal VIC20 Kernal (mandatory) and type: LOAD
The file is loaded automatically as soon as file selected via OSD (no need to press PLAY TAPE button).
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 boot tape.
Prevent TAP load at boot or for Tape unload OSD TAP selection No Disk , Save settings and Reset.

Kernal Loader (.BIN)

The CBM factory PAL type is the power-up default Kernal.
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.

Push Button utilization

  • S2 keep pressed during power-up for programming Flash
  • 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) file selection

Gamecontrol support

legacy single D9 Digital Joystick. OSD: Retro D9
or
USB Joystick(s). OSD: USB #1 or USB #2
or
Gamepad. OSD: DualShock
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 Paddle. OSD: 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 agin. OSD: DS2

Keyboard

Layout Tape Play not implemented.

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

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

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 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
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.
microSD or microSDHC card FAT/exFAT formatted
TFT Monitor with HDMI Input and Speaker

HID and Gamecontrol Hardware option needs alternative option Primer 25K Mega 138K
USB Keyboard USB-C to USB-A adapter 4 port mini USB hub x x
USB Joystick(s) 4 port mini USB hub - x x
USB Mouse 4 port mini USB hub - 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) breadboard to wire everything up and some jumper wires - x