[posted] Commodore C64 Emulation on a Teensy 3.6 Microcontroller

If there are some free I/Os I think is better adding some buttons for using only some shortcuts to be used in "handheld" mode.
I think are needed only 7 buttons: LOAD,",RUN,ENTER,cursors,Joystick Swap and Spacebar. This would make a portable console with no need to attach an USB keyboard, so can be made a fork without USB keyboard.
If there are no IOs free (I don't have taken a look to code yet) maybe is possible to use the UART and attach a little device (like a PIC12F) that uses UART and take care of reading additional buttons
 
Looks like there are 10 or 12 unused IOs in the LCD version. The serial debug which pin uses?
If I want to hook some buttons on those IOs and then use the sendString feature on the button press, where is the better place where to put some code to read buttons?
 
Frank's note on a T_LC on the USB port could handle more buttons and provide input through the normal codepath.

Could perhaps be a challenge to introduce code to monitor 'onboard' pin changes and respond once the processor has jumped to emulation execution - even if you found a place to hook the USB code to trigger the input?

<edit> or stick a wireless keyboard radio plug in the USB port and use the keyboard as needed - that is what I was doing.
 
Last edited:
Yesterday the parts arrived. Frank´s board kit and the TFT screen and Teensy 3.6 (ordered from Poland) :) Just the fun part left - to solder it all together and try out the software...

20180410_200718.jpg
 
Guys, I need some help with the setup - something must be wrong with the Arduino IDE environment, as I get compiler errors about "println" declarations. It should be included from stdio.h or similar (there´s a print.h somewhere). Compiling the BLINK test program works and I have gone through all the advice about moving libraries to proper directories etc. Compiler error and a warning, included for reference:

Code:
Arduino:1.8.5 (Windows 7), TD: 1.42-beta3, Kort:"Teensy 3.6, Serial, 240 MHz (overclock), Faster, Swedish"

...
"C:\Program Files (x86)\Arduino\hardware\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=142 -DARDUINO=10805 -DF_CPU=240000000 -DUSB_SERIAL -DLAYOUT_SWEDISH "@C:\Users\user1\AppData\Local\Temp\arduino_build_589447/sketch/defs.h" "-IC:\Users\user1\AppData\Local\Temp\arduino_build_589447/pch" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3" "-IC:\Program Files (x86)\Arduino\libraries\Teensy64" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\USBHost_t36" "-IC:\Program Files (x86)\Arduino\libraries\SdFat-master\src" "-IC:\Program Files (x86)\Arduino\libraries\Teensy-reSID-master" "C:\Program Files (x86)\Arduino\libraries\Teensy64\cpu.cpp" -o "C:\Users\user1\AppData\Local\Temp\arduino_build_589447\libraries\Teensy64\cpu.cpp.o"
C:\Program Files (x86)\Arduino\libraries\Teensy64\cpu.cpp: In function 'void cpu_clock(int)':

C:\Program Files (x86)\Arduino\libraries\Teensy64\cpu.cpp:2652:12: warning: variable 'writeCycles' set but not used [-Wunused-but-set-variable]

 static int writeCycles = 0;

            ^

...
"C:\Program Files (x86)\Arduino\hardware\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=142 -DARDUINO=10805 -DF_CPU=240000000 -DUSB_SERIAL -DLAYOUT_SWEDISH "@C:\Users\user1\AppData\Local\Temp\arduino_build_589447/sketch/defs.h" "-IC:\Users\user1\AppData\Local\Temp\arduino_build_589447/pch" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3" "-IC:\Program Files (x86)\Arduino\libraries\Teensy64" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI" "-IC:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\USBHost_t36" "-IC:\Program Files (x86)\Arduino\libraries\SdFat-master\src" "-IC:\Program Files (x86)\Arduino\libraries\Teensy-reSID-master" "C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp" -o "C:\Users\user1\AppData\Local\Temp\arduino_build_589447\libraries\Teensy64\keyboard_usb.cpp.o"
C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp: In member function 'virtual bool c64USBKeyboard::claim(Device_t*, int, const uint8_t*, uint32_t)':

C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp:48:60: error: 'println' was not declared in this scope

   println("c64USBKeyboard claim this=", (uint32_t)this, HEX);

                                                            ^

C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp: In member function 'void c64USBKeyboard::LEDS(uint8_t)':

C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp:148:41: error: 'println' was not declared in this scope

   println("Keyboard setLEDS ", leds, HEX);

                                         ^

C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp: In member function 'void c64USBKeyboard::updateLEDS()':

C:\Program Files (x86)\Arduino\libraries\Teensy64\keyboard_usb.cpp:154:46: error: 'println' was not declared in this scope

   println("KBD: Update LEDS", leds_.byte, HEX);

                                              ^

Using library Teensy64 in folder: C:\Program Files (x86)\Arduino\libraries\Teensy64 (legacy)
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI 
Using library USBHost_t36 at version 0.1 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\USBHost_t36 
Using library SdFat-master at version 1.0.5 in folder: C:\Program Files (x86)\Arduino\libraries\SdFat-master 
Using library Teensy-reSID-master in folder: C:\Program Files (x86)\Arduino\libraries\Teensy-reSID-master (legacy)
Error compiling for board Teensy 3.6.
 
Might be a typo in the source code of keyboard_usb.cpp since println() can never be used alone, it needs an object inherited from the Stream class, as for example in Serial.println().
 
Might be a typo in the source code of keyboard_usb.cpp since println() can never be used alone, it needs an object inherited from the Stream class, as for example in Serial.println().

Thanks! In this case, I just went the easy way for now... commented out those failing "println" and it all compiled nicely :) A familiar blue screen appeared.
 
Running a few games. Some works, other don´t. A few will start, but hangs after a while. I made a film clip on some of them, just for fun:

 
Running a few games. Some works, other don´t. A few will start, but hangs after a while. I made a film clip on some of them, just for fun:

Depending on if the game has been cracked or not, or perhaps in what way. The result of loading and running it, may be different. I found a few sources with plenty of games and demos etc. Results so far:

Works
Donkey Kong
Dig Dug
Blue Max
Super Lem
Stunt Car Racer (you can actually save and load game progress, if using "tape" as media)
Paper Boy
Necromancer
Commando
Uridium

Great fun! Now I have to arrange with a proper box and perhaps a small cooling heat sink for the Teensy chip (it gets warm after a while, but not critically hot)
 
I've put the original platform.txt and compile. Can anyone helpme? How can I use the platform.txt of Frank without having "Ctags pattern" error?
 
The original platform.txt has those rows in:

# ctags
# ------------------------------
tools.ctags.path={runtime.tools.ctags.path}
tools.ctags.cmd.path={path}/ctags
tools.ctags.pattern="{cmd.path}" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "{source_file}"

so I added those rows in the modified platform.txt by frank but now I've those errors:

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\Teensy64.cpp:226:2: error: #error Teensy64: Please select F_CPU=240MHz

#error Teensy64: Please select F_CPU=240MHz

^

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\Teensy64.cpp:230:2: error: #error Teensy64: Please select F_BUS=120MHz

#error Teensy64: Please select F_BUS=120MHz

^

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\Teensy64.cpp:238:2: error: #error Teensy64: Set AUDIO_BLOCK_SAMPLES to 32

#error Teensy64: Set AUDIO_BLOCK_SAMPLES to 32

^
 
Sorry my mistake, I've copied platform.txt in the wrong path.

Now I've some errors due to "println" not declared:

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\keyboard_usb.cpp:48:60: error: 'println' was not declared in this scope

println("c64USBKeyboard claim this=", (uint32_t)this, HEX);

^

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\keyboard_usb.cpp: In member function 'void c64USBKeyboard::LEDS(uint8_t)':

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\keyboard_usb.cpp:148:41: error: 'println' was not declared in this scope

println("Keyboard setLEDS ", leds, HEX);

^

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\keyboard_usb.cpp: In member function 'void c64USBKeyboard::updateLEDS()':

C:\Users\Gianni\Documents\Arduino\libraries\Teensy64\keyboard_usb.cpp:154:46: error: 'println' was not declared in this scope

println("KBD: Update LEDS", leds_.byte, HEX);

^
 
Problem is on keyboard_usb.cpp at rows 48, 148, 154
there are statements as:

println("KBD: Update LEDS", leds_.byte, HEX);

cannot put Serial.println instead of println because there are 3 arguments. For now those lines can be commented out
 
Problem is on keyboard_usb.cpp at rows 48, 148, 154
there are statements as:

println("KBD: Update LEDS", leds_.byte, HEX);

cannot put Serial.println instead of println because there are 3 arguments. For now those lines can be commented out

Same thing that I described in post #181 :) I didn't put time on fixing the code, so comment it out was an easy solution... and it works so far.
I´m planning to write a Howto-document on how to download and install stuff from scratch - just to make it easier for beginners to get started. The soldering of hardware took just over an hour, but fiddling with the software, Arduino IDE etc, way more.
 
It looks like FrankB defined somewhere a println function Macro which is intended to work without a preceding Stream object for debugging purposes. But that „somewhere“ seems not to be included.
Commenting out these println commands is fine.
 
All working. Display arrived. I've a defect: two vertical white lines on the right. Is it normal or my display is defective?
 
All working. Display arrived. I've a defect: two vertical white lines on the right. Is it normal or my display is defective?

Check out the videos posted here - no white lines visible. Not very likely a soldering problem or other hardware, but something to do with the internal screen connections or memory mapping (?). Here´s how mine looks:

 
I think is a display problem. I'll buy another.
In the meanwhile I've tested some games (converted from D64 to PRG using dirmaster)

A Journey to the center of the earth (ozisoft) -> works
B.C.'s quest for tires -> partially works. I've played a little and arrived on the mountain (where the rocks falls down), the player hits something invisible, maybe a defective sprite collision?
Doctor Who and the mines of terror -> don't work. IEC access screen remains stuck above the intro image
Cybernoid -> don't work, random white/yellow patterns

NumLock feature doesn't work. When I hit num/lock for the joystick swap, board stucks, neither CRT ALT CANC reset, I must disconnet power

Sometimes screen initialization fails: screen is shifted
 
@Zonkt you've mounted the female strip wrong side. I've made same error, then I've desoldered and soldered to back side
 
@Zonkt you've mounted the female strip wrong side. I've made same error, then I've desoldered and soldered to back side

I was in a hurry :) Have put it in its right place and will put it inside a small box for better protection. The connectors are soldered and makes the mount slightly lower. Added a small heat sink to the chip.
30740150_1952011758204389_3655116004683415552_n.jpg 30738439_1952011668204398_9061892364720668672_n.jpg
 
Back
Top