[posted] Commodore C64 Emulation on a Teensy 3.6 Microcontroller

I ordered 3.2'' SPI ILI9341 display in China, I am very curious if it works.

Two months of waiting for shipment then? ;)

With the same type of connection or flat cable? (the latter one, I've seen on AliExpress etc)
Would be fun with a slightly larger screen than the current 2.4" (yes, I went for 2.4 instead of 2.8 - didn't want to wait too long :) )
 
-
might be your display, or a connection problem.
The display-spi ist very fast, pls connect it directly to the board - no cables!

I've connected directly to board. Maybe a display issue. I'll order some others displays.
In the meanwhile I've tried connecting to IEC port some drives I have that works on a Commodore 64. A 1541 and a 1541-II. Don't works. After loading sometimes gives an out of data error, or garbage on the screen or nothing. The SD2IEC works even if a lot of games are not loaded.
 
I've made a 3d printed case for the Teensy64 and added a battery, usb charger, amplifier and speaker. It's basically a mobile c64 now, which explains the SX64-II on the case.

I'm happy to add the STL / Fusion 360 files to the repo if wanted.

IMG_20180503_183906.jpg
IMG_20180503_184019.jpg
 
that looks great, would be nice to have a smaller one for portable handheld gaming (sorta like gameboy) hehe
 
@Frank B: I was wondering if you were doing any d64 work?. I have d64 image loading on my Teensy64 and the framework for a menu loader working. I haven't had time to do the writes yet. If your not tackling this, I will spend the time to finish it. The menu is native asm app that uses an invalid opcode (copied you) to call back to the teensy which then writes directly to video ram. Looks 100% native, but the heavy lifting is done in a higher level language on the teensy side.
 
@Frank B: I was wondering if you were doing any d64 work?. I have d64 image loading on my Teensy64 and the framework for a menu loader working. I haven't had time to do the writes yet. If your not tackling this, I will spend the time to finish it. The menu is native asm app that uses an invalid opcode (copied you) to call back to the teensy which then writes directly to video ram. Looks 100% native, but the heavy lifting is done in a higher level language on the teensy side.

Oh, I kinda missed this post.
No, I'm not working on D64. Would be good if you could contribute something for D64:)
The invalid opcode-thing is not as good as it sounds, because it's not very compatible. But it's a start!
 
Hi Frank,

Congratulations for this fantastic MCU project. A nice example of collaboration between enthusiastic people!

I would like to contribute as well if you don't have any objection.

I have done few adaptations to the code to support new features:
- A TFT On Screen Keyboard (touch screen interaction) with limited keys supported but also a PRG loader menu!
- VGA output and TFT display simultaneously, using the TFT display as keyboard (the same image can boot in TFT mode only or in dual screen by pressing one of the custom keys)

For the second feature I had to reshuffle the pins of the TFT display so, at same time, I added support for an analog joystick (replacing your JOY2), JOY1 remaining as is (VGA pinout) and I also added 5 custom keys.
I have not tested but IEC, PS2 and USB should be working.

I shared a small video:

https://youtu.be/-psXHOKJ6W0

About the code modifications, the dual screen mode is built as a diversity of the VGA variant.
In settings :
#define VGA 1
#define VGATFT 1
As indicated, this needs the pinout adaptation (see teensy64.h and the small txt file I added in the code)

The on screen keyboard feature also work with your original TFT variant pinout.
(VGA and VGATFT undefined in settings.h)
It is a variant of the PS2 option (I reuse the key matrix of USB in keyboard.cpp, sorry for the confusion)
#define PS2KEYBOARD 1
#define OSDKEYBOARD 1

Please tell me how to share the code!

The biggest changes are in vic.cpp now split into vic8.cpp and vic16.cpp (VGA and TFT variants both present in same build) and of course teensy64.cpp. I also adapted the ILI9341 driver to support the touch screen and add some non DMA functions to draw.
The rest is a new file for the OSD keyboard.

I also added few functions to pause and resume the CPU core else non DMA functions for the TFT were too slow (non DMA access is required to handle the keyboard display, as the touch screen shares the same SPI bus.

J-M
 
Last edited:
That is a very impressive addition Jean-Marc!

If you put your code on Github then Frank and others can look at it. If you start the repository with the Base code then update with your changes the 'diff' of the files will be easy to see.
 
Hi,

Frank has to grant me access to the GIT project first.
I prepared everything already.

my username "Jean-MarcHarvengt"

J-M
 
J-M doesn't show up a repository on github? … you can make your own fork/clone - or post the link if you have. Indeed making changes directly to Frank's repository would take permission - though you can make a PULL request with a clone.
 
I cloned the project, created a new branch "vgatft_dual_screen_and_on_screen_keyboard_support", added the files and commit them but when I "git push origin vgatft_dual_screen_and_on_screen_keyboard_support", It tells "Permission to FrankBoesing/Teensy64.git denied to Jean-MarcHarvengt"
 
Right - that is where Frank would have to allow you write access to the project. I see it as 'cloned' but can't see your repositories under Jean-MarcHarvengt.

You could set up a PULL request with your changes though.
 
Hi,

I forked the project, now you can see the changes.
(I hope it is ok for Frank)

https://github.com/Jean-MarcHarvengt/Teensy64/tree/master/Teensy64

You might have some compilations error in the keyboard_usb.cpp. I have not touched the file but I get an error in few println. Just comment them out...

So if you compile as is, it should be compatible with the TFT pinout of Frank and you only have the On Screen Keyboard.
If you edit settings.h, you can uncomment the "#define VGA" (still compatible with the VGA board but not add on) and "#define VGATFT" but then you need my pinout (dual screen with VGA and TFT)

I forgot to mention that to have the VGA+TFT sharing the same buffer and working at same time, I had to reduce the DMA TFT buffer of few lines but not too much visible I think.
Even if there is still RAM available, the UVGA driver seems to allocate extra memory even if the buffer is static.
No idea why...
I also hope the calibration of the touch screen is ok for you. Else you will have to adapt the function.

Have fun, I hope you will appreciate that first version.

J-M
 
Cant believe what was posted in #210! Incredible! A C64 in a box. What a design. From my early years in 1982, I b uilt about 50 video games for the C64 including sound and graphics and all. What a great time that was. And It is so pretty to see that this Computer still is alive. I need more time to recover my games an port the to such a device.
 
I got time last night to assemble one of the two kits from @Defragster. And it's working great! Thanks @Frank B and @Defragster!

I compiled with Arduino 1.8.5 and Teensyduino 1.42. I had to comment out the println statements that were noted above. I could not find what was supposed to signal RETURN in the serial monitor keyboard, so I added a line to treat ^ as RETURN. This is the change near the end of Teensy64.cpp in the yield() function:

Code:
  //Input via terminal to keyboardbuffer (for BASIC only)
  if ( Serial.available() ) {
    uint8_t r = Serial.read();

   // added next line to change ^ to RETURN
    if (r == '^') r = 0x0d;

    sendKey(r);
    Serial.write(r);
  }

Other than that, the emulator appears to be working well.

Full sized USB keyboards work as long as there is enough power. :) I used a USB charger with 2.0A output but you can probably get away with less depending on the keyboard. Plugging the keyboard into a powered hub does not work. And I'm not surprised as many of the embedded USB controllers do not support hubs. Or if Teensy 3.5/3.6's hardware does, its possible hub support has not yet been written for it.

And it works with a PI1541:
IMG_20180707_111903_smaller.jpg

Now I'm tempted to try to port the PI1541 over to a Teensy 3.5 too...
 
Good to hear the kits went together well!

AFAIK - the USB Host code was ported when it had the needed features and customized to remove some conflicts. Not sure what they were, but on VGA alone from T_3.6 there were artifacts from USB operation.

Current USB Host does support (many) Hubs on T_3.6 based on posts from KurtE/Paul.

Very cool the 1541 'drive' works!
 
Back
Top