Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 64

Thread: C64 Emulation with Teensy 3.6

  1. #1
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765

    C64 Emulation with Teensy 3.6



    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..
    Last edited by Frank B; 03-20-2017 at 09:27 PM.

  2. #2
    Senior Member defragster's Avatar
    Join Date
    Feb 2015
    Posts
    4,166
    Great work Frank!

  3. #3
    Nice that's looking cool WOW.
    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 by Chris O.; 03-20-2017 at 04:48 AM.

  4. #4
    Junior Member
    Join Date
    Mar 2017
    Posts
    7
    wow... is that all in a "single upload" to the teensy? Or did you structure it somehow?

  5. #5
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    Quote Originally Posted by awef View Post
    wow... is that all in a "single upload" to the teensy? Or did you structure it somehow?
    No, i've cut the parts for loading. The games are different PRG files.

    Amiga: no i dont think that it is possible!

  6. #6
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,397
    Hey Frank, Congratulations and it's amazing what you could do with the 3.6.

  7. #7
    Senior Member Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    707
    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 ?

  8. #8
    Junior Member
    Join Date
    Mar 2017
    Posts
    16
    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?

  9. #9
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    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 by Frank B; 03-20-2017 at 05:26 PM.

  10. #10
    Senior Member KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    2,212
    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!

  11. #11
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    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 by Frank B; 03-20-2017 at 06:33 PM.

  12. #12
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    @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"

    -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..
    Attached Files Attached Files
    Last edited by Frank B; 03-20-2017 at 11:01 PM.

  13. #13
    Senior Member KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    2,212
    Quote Originally Posted by Frank B View Post
    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

  14. #14
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    Quote Originally Posted by KurtE View Post
    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)
    Attached Files Attached Files
    Last edited by Frank B; 03-20-2017 at 09:55 PM.

  15. #15
    Junior Member
    Join Date
    Jul 2013
    Posts
    9
    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

  16. #16
    Check this out you can actually still buy the floppy disk drive on Amazon . com

    Click image for larger version. 

Name:	C64 DISK DRIVE 1541.JPG 
Views:	19 
Size:	112.7 KB 
ID:	10050

  17. #17
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    @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 ?
    Attached Files Attached Files

  18. #18
    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

  19. #19
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    Do you want one of my "Flexiboard3" ? :-) I can add a connector for your keyboard..

  20. #20
    Junior Member
    Join Date
    Jul 2013
    Posts
    9
    Quote Originally Posted by Frank B View Post
    @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/C...re/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

  21. #21

  22. #22
    Junior Member
    Join Date
    Jul 2013
    Posts
    9
    Quote Originally Posted by defragster View Post
    Yeah. I don't think of the PJRC store first. I probably should start, though.

    Thanks!
    David

  23. #23
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    529
    Frank this is utterly mental

    I love it

  24. #24
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,765
    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 by Frank B; 04-09-2017 at 09:05 AM.

  25. #25
    Junior Member
    Join Date
    Aug 2016
    Posts
    18
    Quote Originally Posted by Frank B View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •