C64 Emulation with Teensy 3.6

Status
Not open for further replies.

Frank B

Senior Member

The Teensy 3.6 is amazing !
It has no problems with the emulation of a 6510 CPU, C64 SID (@44Khz), VIC (with 99.9% of it's features), two CIAs, PLA.... transfers the screencontent with 60MHz SPI to the display (16-BIT ILI9341) (44Hz refresh-rate), uses the USB-HOST feature for a USB-Keyboard, and has still enough cpu-power left..

I'll publish this project in a few weeks.

FLASH: 360KB
RAM: 230KB

Edit: More info in post#12

Edit:
Note: The green PCB is not needed. It's just my dev-board ("Flexiboard3"). Required are ILI9341 and USB-HOST only.

Edit: Yes, the video could be better. Need better equipment..

Edit: Board available!
Edit: Full Project description here: https://forum.pjrc.com/threads/46168-Commodore-C64-Emulation-on-a-Teensy-3-6-Microcontroller
VGA-Output (still experimental)
 
Last edited:
Nice that's looking cool WOW.:D
Frank you think it could be possible to emulate Commodore Amiga?
I think I even play the commando game but on Atari 800 back in the day ):
 
Last edited:
Looks impressive !!! I don't think you load the program files from the compact cassette or a 5.25" floppy, so I wonder if you use the Teensy 3.6's integrated SD card reader for that ?
 
Brilliant work! I might be showing my age here, but I still actually still have all over those games, bar Mario, in original cassette form for the ZX Spectrum. I remember my older brother being slightly better than me at G'N'G but could never figure out why.

I can hear a joystick, or something or other in the background. How is this handled and/or implemented?
 
At the moment, i use a pretty simple method and a fixed #define in the main sketch that loads the PRG file and "injects" it into the virtual c64-RAM (after reset)
My plan is to support T64 (=tape) files at least (for the first release). It seems to me that this is the simplest file-format ?
Later, if ever, i want to add (virtual) floppy support. And i think it's exact enough to speak with a real 1541.. (i don't have one, unfortunately)

Michael, no, at the moment no joystick. I have a pretty basic joystick emulation on the keyboard, but it's almost impossible to play with it. Maybe i should use some pins and a real joystick ?
I've never had a spectrum, but a ZX81. That time, i could not effort a Spectrum. And later i got a C64 (with tape drive only).

If someone wants to test it: I could upload a hex-file with an included "C64 DEMO" ("Delirious 9")
As you might think,"demos" use pretty advanced techniques and tricks to squeeze the last drop out of the poor 1 MHz C64 (even the 3.6 gets a little warm..) The emulation handles it pretty good (some little problems and artifacts, but i'm sure i can fix them sometime in the future..)
You'll need USB-HOSt (only a connector) and a ILI9341 Display. Sound-Output is via DAC.
 
Last edited:
Looks like great stuff!

It has been a long time since I played with a C64 (30+ years ago). Then I moved from a Franklin Act to an Amiga...

Could be fun... May have to take you up on it sometime soon and try it with my Well monitor board (T3.6, Touch screen, sound hooked up to DAC...)

Again great stuff!
 
Yup, ~30Years ago was my time, too.. :)
It's so much fun to hear the old C64 SID-tunes and watch the graphics..

Which pins do you use for the display ? I make a special version for you :) But you still need a usb-keyboard. Do you have one of Paul`s T3.6 BETA Boards ?
 
Last edited:
@all
OK, here's a "preview" - Please report bugs, and not working PRG-Files!
(And it would be great if you report _working_ files too)

It is set to emulate a PAL C-64 (NTSC (="Never The Same Color" ;-) files will have problems if they are timing-sensitive)

Pin-Numbers are:
Code:
#define SCK  14
#define MISO 12
#define MOSI 28

#define TFT_BACKLIGHT   4
#define TFT_TOUCH_CS    24
#define TFT_TOUCH_INT   3
#define TFT_DC          21
#define TFT_CS          15
#define TFT_RST         255  // 255 = unused, connected to 3.3V
#define TFT_SCLK        SCK
#define TFT_MOSI        MOSI
#define TFT_MISO        MISO
Use short and reliable connections: The SPI-Clock is 60MHz!

Touch is not used.
Sound-Output is on DAC0 and DAC1 (but, of course, mono). Use a good speaker ! It would by a shame to use a tiny cheap one..
Don't connect other pins.

Special Keys:
"NUM" switches the Joystick-emulation (watch the serial monitor)
Joystick is on the keys 1-9 on the numerical keypad, "fire" is on "alt gr" right
"RUN/STOP" is esc
"Commodore" is the left windows-key
"Restore" is "print"
_wsb_684x343_Drean_Commodore_64_Retroport_22+$28Large$29.jpg



-Files-
I added a quick&dirty "hack" that allows to use the command
Code:
LOAD "FILENAME",8,1
(8 characters+extension)
The C64 supports way more than 8 characters (yes, it was in the 80's!), but the sd.h lib supports only 8... :-(
then,
Code:
RUN
Create a directory "C64" on the SD-Card, and copy the PRG into the new directory.
Type LOAD "DELIRI.PRG",8,1 on the keyboard or into the serial monitor.
(loading is very fast. DELIRI.PRG is included in the download)
"DELIRI" wants some keystrokes, so please connect an USB-keyboard.

Please keep in mind, that this is a very early version, and bugs are possible :)
Some files will _not_work.
(especially all which want to access the floppydisk)

Or try some programs in BASIC.

10 PRINT "HELLO WORLD ";
20 GOTO 10

:)

Perhaps you can find some useful things if you ask google for "planet emu" or something like that..
 

Attachments

  • c64.ino.zip
    331.1 KB · Views: 384
Last edited:
Yup, ~30Years ago was my time, too.. :)
It's so much fun to hear the old C64 SID-tunes and watch the graphics..

Which pins do you use for the display ? I make a special version for you :) But you still need a usb-keyboard. Do you have one of Paul`s T3.6 BETA Boards ?
It may take me a little bit of time as trying out new board, but my BOard has the pins set as:
Code:
#define TFT_DC 22
#define TFT_CS 15
#define TFT_RST -1
#define TFT_SCK 14
#define TFT_MISO 12
#define TFT_MOSI 7
#define DEBUG_PIN 13
#define TOUCH_CS  8

I have some USB keyboards sitting around that I use for different things like testing out RPI3...

And yes I still have Pauls V1 beta board sitting on my Desk
 
It may take me a little bit of time as trying out new board, but my BOard has the pins set as:
Code:
#define TFT_DC 22
#define TFT_CS 15
#define TFT_RST -1
#define TFT_SCK 14
#define TFT_MISO 12
#define TFT_MOSI 7
#define DEBUG_PIN 13
#define TOUCH_CS  8

I have some USB keyboards sitting around that I use for different things like testing out RPI3...

And yes I still have Pauls V1 beta board sitting on my Desk

Ok, it might the easiest to use Pauls board and connect the display to it( since it has the USB )
But i'll upload your version tomorrow, as promised :)

Edit: Added Radwar Party 2017 Invitation Demo (in Heinsberg, Germany)
 

Attachments

  • Radwar.zip
    15.6 KB · Views: 329
Last edited:
This looks like lots of fun! I will be ordering a display ASAP.

One question/suggestion... Would it be possible to address a real SID instead of emulating one? I just got a SID player working the other day with some of the chips I had saved all these years and think that would be cool to just plug one in to the emulator.

David
 
@Dave, i think yes - the timing might be a bit difficult ? don't know. Is your sourccode available ? And do you have a schematic ? And do you have a spare SID that i can buy....?
@Chris, yes, but too expensive.
@Kurt, i've attached a HEX with your display-connections.

Did anyone try it ?
 

Attachments

  • c64.settings_kurt.zip
    290.2 KB · Views: 293
Did anyone try it ?
Hey Frank
I wish I could but currently my T3.6 is tied up in a project with the screen already setup as this:
Code:
#define SCK  13
#define MISO 12
#define MOSI 11

#define TFT_BACKLIGHT   8
#define TFT_TOUCH_CS    30
#define TFT_TOUCH_INT   29 // TIRQ_PIN  29
#define TFT_DC          15
#define TFT_CS          10
#define TFT_RST         255  // 255 = unused, my setup------>connected to 3.3V
#define TFT_SCLK        SCK
#define TFT_MOSI        MOSI
#define TFT_MISO        MISO

On top of this you mention this:
Don't connect other pins.
And I already have some other PINS connected.
Code:
void setup()   {

  pinMode(25, OUTPUT);
  digitalWriteFast(25, HIGH);  // ensure SS (PIN 25) stays high for now, disable Slave Select.
  // SN74LVC1T45 ( MISO 3-state logic )
  pinMode(7, OUTPUT); // Teensy 3.6 IDLE Interrupt disconnect
  digitalWriteFast(7, HIGH);  //
  pinMode(28, OUTPUT); // ( MISO 3-state logic )
  digitalWriteFast(28, LOW); // SN74LVC1T45-Q1
  
  // TFT BackLight
  pinMode(TFT_BACKLIGHT, OUTPUT); // pin 8
  analogWrite(TFT_BACKLIGHT, 255);

  // initialize the debug led on Pin 6
  pinMode(Debug_led, OUTPUT); // debug led on pin 6, need pin 13 for spi SCK
  digitalWriteFast(Debug_led, LOW);
}
Then I have to find the pin header connector for the USB keyboard :(
 
@Dave, i think yes - the timing might be a bit difficult ? don't know. Is your sourccode available ? And do you have a schematic ? And do you have a spare SID that i can buy....?


Frank,

The schematic I used is pretty much what is in the original datasheet located here:

http://www.classiccmp.org/cini/pdf/Commodore/ds_6581.pdf

The timing diagram is pretty good for writes, too. I didn't try the reads, but you could get the original ADCs to work for paddles if the rest works out. I know readback almost works since I had the RW and CS signals swapped and could see the bus trying to write for a few nanoseconds before switching back to read.

I have posted the teensy code in this thread... I also have some minor timing problems, but it still sounds really good.

Unfortunately, I only have two chips and the second is going to be utilized for the stereo SID option when I get some time to do some soldering. I've been looking around for some more, but haven't been lucky yet.

Did anyone try it ?

I also need to buy a screen. Any suggestions on a US supplier that you think will work?

David
 
Hm, I just found a horrible bug in the CIAx emulation, and I have to rewrite the whole CIAx code.
It seems, only very few programms use the CIA timers + interrupts. Surprising.
Hopefully the new will be fast enough. Would be great if the whole thing still can run without overclocking(180MHz)
 
Last edited:
Hm, I just found a horrible bug in the CIAx emulation, and I have to rewrite the whole CIAx code.
It seems, only very few programms use the CIA timers + interrupts. Surprising.
Hopefully the new will be fast enough. Would be great if the whole thing still can run without overclocking(180MHz)

cant wait to be able to see the source to this, you sir, are awesome :) and crazy. I blame you for making me dig out my ili9341 display I had bought a while ago but never tried :) that display works, now to find a usb port and try this soon.. dont have one lyin around so I'd have to buy one I think.. also want some zif sockets.
 
Status
Not open for further replies.
Back
Top