GithubHelp home page GithubHelp logo

vossstef / tang_nano_20k_c64 Goto Github PK

View Code? Open in Web Editor NEW
58.0 13.0 9.0 18.4 MB

Commodore C64 core for the Tang Nano 20K, Primer 25K and Mega 138K FPGA

License: GNU General Public License v3.0

VHDL 63.55% Verilog 27.44% C 0.07% Batchfile 0.01% SystemVerilog 8.58% Shell 0.01% Tcl 0.35%
fpga tang-nano c64 mist commodore gowin

tang_nano_20k_c64's Introduction

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 (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:


image


HID interfaces aligned in pinmap and control to match MiSTeryNano project's bl616 misterynano_fw respectively FPGA-Companion
Basically BL616 µ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

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

  • S2 keep pressed during power-up for FLASH programming of FPGA bitstream

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 + memory scrubbing
  • Audio Volume + / -
  • Scanlines effect %
  • Widescreen activation
  • HID device selection for Joystick Port 1 and Port 2
  • REU activation
  • c1541 Drive disk image selection
  • c1541 Disk write protetcion
  • c1541 Reset
  • c1541 DOS ROM selection
  • MIDI configuration
  • PAL / NTSC Video mode
  • VIC-II revision, 6526 / 8521 and SID 6561/8580 selection
  • SID Filter selection
  • geoRAM activation
  • Loader (CRT/PRG/BIN/TAP/FLT) 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 again and set OSD: DualShock

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      -

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.
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 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.
or Sipeed Tang Mega 138k
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 - 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

tang_nano_20k_c64's People

Contributors

vossstef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tang_nano_20k_c64's Issues

Unloading .CRT doesn't work

CRT files work perfectly well with the core, but once loaded, they can't be unloaded unless the system is physically power-cycled.
Unloading a CRT and then resetting doesn't work either.

Support PAL / NTSC Video mode

including also HDMI catch-up
affected Modules video, video-analyzer, hdmi, top, core pll selectable
NTSC
-- 720 480 60 Hz 31.4685 kHz
-- ModeLine "720x480" 27.00 720 736 798 858 480 489 495 525 -HSync -VSync

Image not centered in PAL mode

Hi there again, @vossstef

This is a relatively small problem, but it's there and it would be nice to have image properly displayed.

On all my HDMI monitors, the core image is not centered: it's too low, as seen in this picture:

c64_image_low

So, maybe it has something to do with timings? Could it be centered?

Thanks!

black screen

Since the HDMI fixes made yesterday, I can no longer display an image.
I tested on different monitor.

Cooperation on retro core infrastructure

I'd like to suggest that we cooperate a little bit on the infrastructure side. With infrastructure, I relate to everything but the (retro) core itself. IMHO a unified nice framework using the hardware present on the Tang Nano 20k to provide various generic services to the core would be nice.

My suggestion would be to add common services like USB mouse, keyboard, the various joystick interfaces, HDMI, the SDRAM, the flash ROM etc etc and to make sure that the next core developer can also simply re-use these. Somewhat like the MiST and MiSTer frameworks do, but for now more Tang Nano specific.

The difference to MiSTer is, that there is not full Linux in the background and the difference to the MiST is that the MCU on the TN20k is way more powerful. The minor differences are that the e.g. the SD card is connected to the FPGA and not to the MCU which makes interaction between SD card, MCU and core a little different.

refactor keyboard interface

use a core specific keyboard matrix in the bl616 firmware
note: latest bl616 with c64 core support and menu will be needed

Broken audio output

Commit 63c4e59 (audio volume fix) breaks sound output.
Hissing over-amplified sound. And the output is only the left channel for some reason.

GPIO normalization

Good morning

Would it be possible to standardize the GPIO port?
For the joystick port of this core, is it possible to replace it to use the same location and controller as the NESTANG, PACMAN, GALAGA, ... cores?
And for the keyboard, would it be possible to standardize it with the core developer Atari ST?
If all cores are standardized at the GPIO level, it will be simpler for users.

Thanks to all the developers

DB9 joystick directions swaped

I have a MisteryNano 20k board with DB9 joystick connector.
The DB9 joystick works fine with MiSTery core on several games.

With this C64 core flashed, the directions of the joystick are swaped:
Left is right and reverse.
Up is down and reverse.
Fire button works.

I searched the files and modified the file "tang_nano_20k_c64_top.cst" after the command "// generic IO pins to use for e.g. db9 joystick"
pin 28 <> pin 25
pin 26 <> pin 29

The file looks now this way:
..
// generic IO pins to use for e.g. db9 joystick
IO_LOC "io[0]" 27;
IO_PORT "io[0]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "io[1]" 25;
IO_PORT "io[1]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "io[2]" 28;
IO_PORT "io[2]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "io[3]" 29;
IO_PORT "io[3]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "io[4]" 26;
IO_PORT "io[4]" PULL_MODE=UP IO_TYPE=LVCMOS33;
..
After flashing the modified version, the DB9 joystick works as expected.

Feature suggestion: serial over spare I/O

The RS-232 over USB works well, but I have found that its usefulness is limited because it requires a host device on the other end, which means it is only good for a null modem link with a PC.

If it is possible to put this out on spare I/O pins instead, we could connect it through a MAX3232 for a standard serial port, wire up an FTDI adapter module for USB connection or wire a header for an ESP-01 wifi module for onboard wireless telnet using the zimodem firmware.

CRT not loaded at first powerup

On first boot, c64crt.crt shows as loaded in the Storage menu but it isn't loaded in the core. The Reset option doesn't fix it but using the Cold Boot option then successfully loads the default cartridge.

I am testing using the CBM kernal and the Epyx fastload cartridge (FASTLOAD should show after the READY prompt).

USB Joystick behaving strangely

Hi,

I figure this is probably an upstream issue with the BL616 code, or potentially a strange USB hub interaction. If I connect up an 8 pin D joystick via a D to USB adapter then game input when the joystick is at rest has down and right continually selected. Any actual input overrides this. I also have a HUB in this equation so it may also be introducing an issue but the combination works fine with other projects.

This joystick/adapter combination works fine on linux/windows/rpi but I'm unable to test it with the HUB circuit with the tang.

The adapter I'm using is homebrew -> https://github.com/BennehBoy/ZipstickUSB

VID/PID : 040b:6533

I've not encountered issues with it previously.

A generic USB SNES gamepad works without issue.

VID/PID : 0810:e501

Trying to flash BL616 on Linux

Hi,

I have started to try this C64 on my tang nano 20k + dock, which has M0S Dock onboard:

mONFd3t

I have no problem with flashing the core with this command:
openFPGALoader -f tang_nano_20k_c64.fs
It boots!

However, I am missing many options on the OSD, like CRT loading etc.

Looking at the documentation here: https://github.com/vossstef/tang_nano_20k_c64/blob/main/INSTALLATION_WINDOWS.md
I can see the BL616 on the M0S Dock has to be updated too.
For that, you point to a program called BuffaloLabDevCube which seems to be Windows software. I don't have a Windows machine, and will never use that OS.
Is there a way to do that on GNU/Linux?

Thanks!

Video and audio problems

Hi @vossstef!

I could finally test the latest core version on the Tang Nano 20k after flashing the BL616 with the latest firmware, I'm having A LOT of fun with it!

However, I've noticed some video & audio problems:

-If Settings->Screen is set to Wide, there is no HDMI audio. Wide is needed for correct aspect ratio on modern 16:9 monitors.

-If Settings->Screen is set to Wide, screen is not centered: it's displaced towards the left side of the screen.

-SID audio doesn't match the real C64 or the MiSTer core.
For example, try Tim Follin's Ghouls'N Ghosts tittle screen music: in both 6581 and 8580 modes, with or without DIGIFIX, it doesn't sound correct (it sounds correct on the MiSTer core).
This is how it sounds on real hardware and on the C64 MiSTer core: https://www.youtube.com/watch?v=wz36JWHTk-A
Note this music is perhaps the definitive C64 audio test: only the C64 MiSTer core and real C64 passes this hard test :)
Are filters supposed to be implemented? Maybe it's simply filters being missing at this point?

Feature request: Datel MIDI cart

I have a carrier board for the Tang Nano with MIDI IN and OUT. Unfortunately this collides with the Dual shock connector of the C64 core.

I still would like to see an option to use the MIDI ports in the C64 core. This has been done for the MiST C64 core as it seems:

mist-devel/c64#1

The use case? I think it would be quite funny to couple two Tang Nano via MIDI, run Atari ST + Cubase on one of them and C64 + Cynthcart on the other one. The C64 with it's SID would then be used by the Atari ST as a MIDI synthesizer.

Admittedly a rather odd setup and probably not the most common use case ... but nevertheless tempting ...

I might give that a try myself. But maybe you actually derive your code from the MiST core.

Tape loading does not work with ExBasic Level II cartridge

Tape loading seems not to work when using the ExBasic Level II cartridge from Markt & Technik AG.

When not using the cartridge image, tape files are found normally, however the loading screen remains blank if the cartridge is mounted.

Use flash ROM for ROM and cartridges

The Tang Nano 20k comes with a 64MBit/8Mbytes SPI flash. The first 700+ kBytes are used to store the FPGA bitstream. But the remaining 7MB are unused and can be accessed by the FPGA at runtime.

This can either be used directly and with DSPI mode at 100MHz a random read speed of <250ns can be achieved. This should be sufficient for the C64. Especially multiple ROM carts could be stored there. The flash may also be used to initialize some of the SDRAM at startup such that the SDRAM can also be used to store Rom data but with a shorter access time.

[Feature Request] Joystick on keyboard cursors + left Crtl

Hi there again,

This is a small request, which I believe shouldn't be hard to do and would make the core more enjoyable with joystick simulation on the keyboard.
Currently, we have NumPad for joystick simulation on the keyboard, which is a fantastic idea. But would it be possible to have joystick on keyboard cursors + left Ctrl, please? It's much more ergonomic for playing sessions, and MAME uses that combination too.

[Question] SID and VICII from MiSTer?

Hi there, @vossstef

I just discovered my Tang Nano 20k can do C64 thanks to this!
Now, are the SID, VIC and CPU directly from the MiSTer project? Both are pretty much " perfect" on the MiSTer by now, and I would like to know what to expect with this :)

Thanks!

MISS keys triggering delete

I'm not sure if this is an issue with FPGA companion or the core, so apologies if I am posting in the wrong place.

In my testing, any key marked as MISS in the C64 keymap table seems to be interpreted as MATRIX(0,0) by the core, which is the delete key.

However, this is not the case with the modifier keys, which just (correctly) do nothing if they are marked MISS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.