PDA

View Full Version : [posted] Commodore C64 Emulation on a Teensy 3.6 Microcontroller



Pages : [1] 2

Frank B
09-02-2017, 10:05 PM
https://github.com/FrankBoesing/Teensy64/blob/master/extras/logo201707.png?raw=true

https://github.com/FrankBoesing/Teensy64

Features



Supports Commodore Serial IEC Bus
For ILI9341 SPI Display
USB-Keyboards (wireless too)
31kHz reSID Audio emulation
Audio Line-Out
Compatible to 1541 and other drives + SD2IEC
Simple drive emulation included (load "whatever.prg" or load "$" )
Supports original joysticks
very small
Hotkeys (e.g. "LOAD "$":LIST)


About


10 PRINT "HELLO WORLD";
20 GOTO 10

Some time ago, 2015, someone in the PJRC forum asked me if it was possible to emulate the C64's SID chip on the Teensy 3.2. Since I had already had experience with the porting of audio codecs (mp3/aac/flac), I came up with the idea to search for a "finished" emulator and found the very good reSID. This is also used by VICE. The porting (https://github.com/FrankBoesing/Teensy-reSID) wasn't that difficult, but I've optimized some parts of it to better match the Teensy and its audio library. It is even possible to emulate a second reSID for stereo operation. Unfortunately, current reSID versions require a lot of RAM, so I had to switch to an older version - which is not necessarily worse. Soon the wish for a SID-Player came up and a little later the Teensy 3.6 was announced. With 256KB RAM, more than enough flash, SD slot and 180 MHz it seemed possible to emulate a complete C64. But before that, other hurdles had to be overcome. There was no way to control a display fast enough. However, the T3.6 has a fast SPI interface, which can be supplied via a DMA channel. The first display that crossed my mind was the well-known ILI9341, which had already done a good job for the T3.2. Some time before, a user in the forum had noticed that you can overclock its SPi interface drastically. After some attempts I had a working video player (https://www.youtube.com/watch?v=lBLKsSEvWHM) - even before the official release of Teensy 3.6. Paul Stoffregen thankfully provided me with an early pre-release version. After many preliminary considerations and deviations I came to the conclusion that the T3.6 should be capable of a C64 emulation. Unfortunately I forgot almost everything about the C64, and I had to and still have to learn everything anew and read a lot of technical details. I must admit that I have underestimated the VIC (the video chip of the C64) enormously. But that was a good thing, otherwise I would never have started this project. In the meantime I have rewritten the code for the VIC four times.

In the beginning my goal was to make emulation good enough for "Boulder Dash" (https://www.youtube.com/watch?v=CjijgL0VC6k) and other of my old favorite games. This goal has been achieved and I have the ambition to make some demos executable. "Teensy64" is compatible enough to play many games and other programs like the original. For the serial floppy interface the SID sound emulation has to be switched off during the accesses, because reSID requires a lot of computing time. Since the C64 operates this interface "in software" with the CPU and the signal lines have to be controlled more or less exactly in time, I couldn't find a way to keep the sound active even after many ideas and attempts. However, a 1541 floppy disk drive that had been bought extra second-hand was damaged after a short time. It was just too old. After some searching I found the "SD2IEC" project. It seems to be a good replacement and emulates the floppy drive wonderfully. SD2IEC can be connected to the interface of the board and works great. My plan is to port the SD2IEC software to Teensy 3.6 and integrate it into "Teensy64". I'm not sure if that's possible yet. There is also a way to work with the Teensy64 without an external drive. I patched the emulated ROM a little bit and misused the device ID 1. The following commands are available:



Load "$" - loads the directory (display as known with the command "LIST")
Load "whatever. prg" - Loads the program from the Teensy SD card.
Save "whatever. prg" - Saves the program.


Other commands such as "open" are currently NOT supported for Device 1. Disk-Containers like "D64" are not supported by this simple patch.
Access is ALWAYS made to a subdirectory "/C64/", which must be present on the SD card.

Thanks to Bill Greiman for his SdFat library with long file names. The C64 was able to support file names of 16 characters length in the 80's when Microsoft only supported 8+3 characters.
There are many more TODOs I would like to tackle little by little. The emulated VIC does not yet support the BA signal, and the emulated 6150 processor does not yet know it; -) Therefore there are some inaccuracies in the processor cycles. For example, the VIC can pause the processor or allow write access only. The latter has not yet been implemented. There's still work to be done on the internal timing of the sprites - so "Democoder"tricks like sprite stretching don't work. Also "xFLI" and "DMA Delay" is not yet possible. All things that the developers of the C64 didn't foresee at that time but were discovered by "hackers". Furthermore, only the PAL mode works satisfactorily - but this is only because I haven't found an NTSC program yet!

Working "Demo VIC Tricks":

- Open Borders (top/bottom)
- FLD-Flexible Line Distance



This project is "Open Source" and everyone is invited to work on it.


https://www.youtube.com/watch?v=CjijgL0VC6k
11457
(Old Version of board with only one joystick port soldered)
The board is exactly the size of the display.

Defragster, thank you very much for your help.

IEC Levelshifter:
This boards uses one transitor and three resistors as bi-directional levelshifter - per line. It is not very fast (about 1.2uS on falling edge) , but fast enough for the C64. It needs a bit more power (mA) than the single 1k-resistors which Commodore used in ther devices. I read somewhere, that, normally, you can attach 8 devices to the bus. With this board, I wouldn't use more than 5-6.


How to compile:
Teensy64 needs some special settings:

- F_CPU = 240MHz
- F_BUS = 120MHz
- AUDIO_BLOCK_SAMPLES=32

Included is a file named "defs.h" that will do all the hard work you - if you replace the platform.txt of Arduino (latest 1.39) with the one which is attached to this post. It will not influence your other sketches.
If you don't want to use this solution, please ask the forum for help ;)

The following additional libraries are needed (copy them to your personal libraries folder)

- Teensy-reSid (https://github.com/FrankBoesing/Teensy-reSID)
- SdFat
(https://github.com/greiman/SdFat)
Done.


Known issues:
-

use platform.txt from this thead: https://forum.pjrc.com/threads/38533-HOWTO-Store-Projects-settings-(like-F_CPU-USB-Keyboard-layout)?p=187712#post187712
(copy to Arduino/hardware/teensy/avr/)

Frank B
09-02-2017, 10:25 PM
Please help me with this list !

Tested:
Working alternative Roms:



JiffyDos

Working Apps:



SEABrowse


Working Games:



Boulder Dash
Bruce Lee
Choplifter
Commando
Commando 95
Fort Apocalypse
Frogs
GORF
Galaga (b&w version)
Galaxian
Dig Dug
Donkey Kong
GhostBusters (problems with "Ghostbusters hahahaah" sample at the beginning)
Last Ninja, The
Loderunner
Madness (from IEC only)
Maniac Mansion (from IEC only)
Mario Bro
PAC-MAN
Paperboy
Paradroid
Parallax
Pole Position
Zaxxon

[..]

Not Working games:


Bubble Bobble (does not start - why ? Can a 64er expert help?)

[..]

Working Demos:

Delirious 9
Radwar Party 2017 Invitation

[..]

Not Working Demos:
(List will be too long)



Others are not tested so far.

Frank B
09-03-2017, 08:41 PM
Tips & Tricks

- The emulation runs inside a interrupt, and you can interact with it. For example, you can access the emulated RAM and all registers of the virtual c64 machine in your loop():



Serial.print(cpu.RAM[0xBA]); //Displays last used device

In the "extras" folder (https://github.com/FrankBoesing/Teensy64/tree/master/extras/docs) is a C64 Memorymap.


- There is a command to send keystrokes to the C64. Example:


sendString("POKE 53280,3\r");

Just add this as last line to your setup() and see what happens..
Or "autoload" and run a program from the SD-Card:


sendString("LOAD\"DIGDUG.PRG\"\r:RUN\r");


- there is a freeware C-Compiler (http://cc65.github.io/cc65/) for the C64. (I did'nt have time to test it..)

- See https://www.c64-wiki.com for detailed information about the 64

- want real retro-feeling ? In vic-palette.h you can select a black&white palette, or settings for a green-display. You can choose other palettes, too, or create your own.

- You can use the Arduino serial console to send commands to the virtual C64

- you can RESET with CTRL+ALT+DEL

- 2017/10/30: Added Joystickport-swap with NUMLOCK
- 2017/10/31: Added volume adjustment with CTRL-Right and Cursor UP/DOWN

[..] to be continued

Frank B
09-04-2017, 08:52 PM
11469
(click to enlarge)

How to build:
Use a good, clean soldering iron with not too much Watt (power) - 30 Watt are ok. Don't solder longer than a few seconds per soldering joint - if you need too, let it cool down and try again.
Solder the lowest/smallest parts first. First, the backlight-resistor, then the other 15 resistors. After that, the audio-connector and USB - then the pinheaders (Don't forget the USB-Host pins for the Teensy), transitors and the capacitor.
You'll need a small side cutter to shorten the female pinheaders - make sure not to cut too much by mistake! Don't worry if you loose one pin - that's normal.
Last step: solder the big Joystick-connectors and the IEC connector.

Double/tripple check if everything is ok, remove tin solder rests and clean the board. If you have a magnifying glass, please check that there are no unintended shorts or cold joints.

Don't forget to solder the USB Pins to your Teensy 3.6

Also, please take a look here: https://www.pjrc.com/soldering-pins-on-to-your-teensy/

KurtE
09-04-2017, 09:15 PM
Board looks nice!

defragster
09-04-2017, 09:43 PM
Board looks nice!

And you can soon get one Kurt, work with Frank ;) PCB's and most parts to build 10 of them on there way to me - and I'll place a DigiKey order tomorrow to complete the kits for US addresses.

Easy to assemble and it works!

Frank - Re post #1 - also need F_CPU=240 MHz since the IDE defaults to 180 and that fails the F_BUS at 120 MHz.

How to compile:
Teensy64 needs two Settings:

- F_BUS = 120MHz
- AUDIO_BLOCK_SAMPLES=32
- F_CPU = 240MHz

Frank B
09-05-2017, 08:31 PM
Thanks :) I've added this, and a short "How to compile".
Does it make sense to add compiled hex-files to the repro (would mean some additional work for me with every update) ? Or is it easy enough to compile ?

defragster
09-05-2017, 09:21 PM
It compiled easily enough for me with your DEFS installer. But if you made a Version_HEX for each update you would be able to try prior versions if an anomaly came up? And if somebody can't get it to build & Run they would have a known good hex if the hardware is built and soldered right.

defragster
09-05-2017, 11:01 PM
Your solder directions look good. I saw a video recently where masking tape was used to keep the part in place. I got a bottle of 90% Isopropyl Alcohol and had good results with that. A clean old toothbrush to wet and wipe the area - rather than pouring on too much. Then I SAFELY get the board somewhat warm (from a distance at first) with a hair dryer to make sure there are no trapped pockets of liquid and quickly evaporate off any excess. Look for it to be clean and inspect. Of course I had one bad joint on USB - a nice shiny blob that was only on the pin and not mated to the PCB - DOH - worse was it worked on some devices so I assumed it was a software issue when it wasn't.

Frank B
09-06-2017, 07:57 PM
Yeah, it happens a lot. I have also searched many times in the wrong place for an error;)

Frank B
09-11-2017, 09:32 PM
Added improved keyboard-scan. This fixes some problems with games that scan the keyboard-matrix with swapped in/outputs (i.e. "PAC-MAN").
"Bruce Lee" starts now - shows the "demo" perfectly- but crashes when start... hm - there must be an other reason :confused: I guess I need help with this game - any c64 specialists here ?

Frank B
09-12-2017, 08:14 PM
Ok.. let's start a little challenge ;)

EDIT: SOLVED. Challenge finished.

The first one, who can tell me what _exactly_ the problem with "Bruce Lee" is, gets an FREE Teensy64 kit (Board v.03 + parts - except display and T3.6)
(or get money back if you purchased one)
You'll need a 6502 disassembler and some knowlage.. Your description must include enough information for me to fix the problem. It's a compatibility problem - might be easy to identify ;)

I hope someone finds it, and this way I have the time for other higher priority things...

Frank B
09-17-2017, 08:34 PM
VGA-Output (https://forum.pjrc.com/threads/45916-Teensy-3-6-VGA-driver?p=153615&viewfull=1#post153615) (still experimental)

ralphw
09-19-2017, 01:22 AM
This looks great! Is there a link I can click on to order the kit?

defragster
09-19-2017, 01:27 AM
RalphW - Send a PM to Frank for details. I just got a set of PCB's in the US - going to assemble one tonight with the parts kits complete to mail to those interested in the working ILI9341 version. Will take pics of the parts and as I have it assembled to upload soon.

defragster
09-20-2017, 12:18 AM
I got parts to make a kit - it worked - here is what it looks like - more available - just PM FrankB:
11567 11568
11569 11570
11571 11572

linuxgeek
09-20-2017, 05:20 AM
That's pretty remarkable stuff!

Frank B
09-27-2017, 07:02 PM
Thank you, linuxgeek.

I have a working VGA version on a breadboard - not with USB-HOST (flicker problems), but PS2 Keyboard connector.
Looks great on a big screen. VGA-Refresh is 60Hz, emulated PAL is 50Hz - so, due to these different frequencies, in some situations may be a bit flickering visible (have not seen this so far).
Still some work to do - the small TFT has no visible left/right borders, so they are not yet implemented for VGA. Then, new boards are needed - will take some time. I'll make a special price for those who ordered the TFT Version so far.
The board will be useful for other VGA-Projects (or as T3.6 board with some 5V leveshifts), too.

Some time ago I posted a video of a experimental version: https://forum.pjrc.com/threads/45916-Teensy-3-6-VGA-driver?p=153615&viewfull=1#post153615

GitHub update for PS/2 & VGA follows in the next days.

Good news: A user reported that loading programs from a original disk drive works.

ron2way
09-28-2017, 02:46 AM
I am slowly making progress in compiling C64 but I am now stuck. using 1.8.4 and 1.39 I getting error "getname" no member in patches.cpp.

commenting out the offending lines to compile further gives me a "not static member error" . I have attached the ide verbose output

Frank B
09-28-2017, 04:20 PM
I am slowly making progress in compiling C64 but I am now stuck. using 1.8.4 and 1.39 I getting error "getname" no member in patches.cpp.

commenting out the offending lines to compile further gives me a "not static member error" . I have attached the ide verbose output

Hi, looks like Bill Greimans` SdFat is not installed (?)
https://github.com/greiman/SdFat

ron2way
09-28-2017, 11:21 PM
the library manager shows 1.03 installed and I am able to compile the sdinfo in the examples folder with ide configured for teensy 3.6 without issues

Frank B
09-29-2017, 06:51 PM
Hm. You're right, I havn't seen it in your logs. Can you try to remove the std SD-lib ?
Well, this shouldn't be needed as it works for me, but the problem is definately a confusion with these libs.
Unfortunately, the audio-lib wants SD.h and it is not easy to override this wihout editing the audio-lib or writing an own - I don't want this..
This is the reason, i add a "SD.h" file to the teensy64 library - this seems not to work for you.

@Defragster: You compiled it - did you have the same problem ?

defragster
09-29-2017, 07:07 PM
I'll have to check again - but I had no such problem when I updated the readme with my steps on Win 10

Frank B
10-01-2017, 01:50 PM
I've decided to lower the price for the kit. The new price is 29 USD or 25 EUR.

ron2way
10-04-2017, 05:15 AM
I am now down to "ctags pattern are missing" issue. I have the same error now on windows 7 and ubuntu 15.10 64 bit machine.

Frank B
10-04-2017, 06:27 PM
Hi,
I don't know.. it really should work without problems. Have you tried to remove the normal SD library ? At least this should work.

For comparison, my output is:


Bibliothek Teensy64_new im Ordner: C:\Users\Frank\Documents\Arduino\libraries\Teensy6 4_new (legacy) wird verwendet
Bibliothek SdFat-master in Version 1.0.3 im Ordner: C:\Users\Frank\Documents\Arduino\libraries\SdFat-master wird verwendet
Bibliothek SPI in Version 1.0 im Ordner: C:\Arduino\hardware\teensy\avr\libraries\SPI wird verwendet
Bibliothek Audio in Version 1.3 im Ordner: C:\Arduino\hardware\teensy\avr\libraries\Audio wird verwendet
Bibliothek SerialFlash in Version 0.5 im Ordner: C:\Arduino\hardware\teensy\avr\libraries\SerialFla sh wird verwendet
Bibliothek reSID im Ordner: C:\Users\Frank\Documents\Arduino\libraries\reSID (legacy) wird verwendet

No mention of SD

Seems that I have to fork the Audio-lib and add it to the emu-code to get rid of the includes of sd.h

Frank B
10-04-2017, 07:39 PM
ron2way: I've decided to make my own audio-library for the emu. It will only have a copy of the needed audio-dac, without references to SerialFlash, Wire, or SD.
Please wait a few days - I want to add some other things before I start with that. I hope that I can do it next weekend.
I addition, it will completely remove other teensyduino-core things that slow down the emu unnecessarily.

Then, i've noticed that fastloaders do not work with IEC. That's the next important thing on my list.. I hope I can solve that...

Frank B
10-07-2017, 01:21 PM
Latest update to version 08 is on GitHub now:

+ VGA (work in progress)
+ PS/2 Keyboards (optional)
+ Remove teensy Audio-Library - just copied the output_dac.* files from the official lib
- removed "SD.h" from lib, there shouldn't be any conflicts anymore.
+ minor impovements

Please take a look at settings.h to configure.

Frank B
10-07-2017, 10:11 PM
I have a fastloader (jiffydos-like) partially working - that means the timing must be close to OK.


LOL... is anybody interested in this and this project ? I'm talking with myself...
Maybe it's better to stop and spend time more meaningfully?

ron2way
10-08-2017, 12:14 AM
At last a successful compile after downloading your changes. Compiled on a linux64 but had to use a win7 machine to load the hex file to the teensy.

Frank B
10-08-2017, 11:46 AM
Update:

- "Bruce Lee" works now. Challenge finished. Sorry guys :)
- Fastloader "Jiffydos" works

I want to make it a bit nicer, update follows today. My workaround to make fastloaders work - which need a very exact timing was to disable the screenrendering during loading.

@ron2way: great !

Frank B
10-11-2017, 10:24 PM
Anybody interested in a VGA Version ?
My preliminary board looks like this:


11745
Because the demand is very small, I ask before continuing and will only finalize the final board if there is demand for the VGA version.

ron2way
10-12-2017, 01:20 AM
I will purchase one.

Fox1974
10-12-2017, 10:58 AM
I am also interested, any options to pre-order at this time? Please let me know if I can pre-order.

firehopper
10-12-2017, 02:40 PM
I'm interested in a vga version too..

Frank B
10-12-2017, 09:13 PM
Ok..:-)

I'm almost through with testing the preliminary board - so far, everything works (with additional diode (https://forum.pjrc.com/threads/46886-Sn74cbtd3861?p=156092&viewfull=1#post156092) as protection). 20x Fastloading with Jiffydos + SD2IEC seems to work, too (but a bit more testing is required).
( I don't know any other emulator that can do this with real hardware.. are there any ? I'd like to know..)
Screen-refresh + Sound is disabled during IEC access (would be a little too much work for teensy..)

Just played one of my old fav games, "Bruce Lee" on this board + 22'' display.

TBD:
- fix board, order... takes some time :-(
- add code for correct right- and left borders on VGA

I'm going to order a cheap VGA->TV converter too, for testing.

Frank B
10-12-2017, 09:23 PM
For Jiffydos: You need the Jiffydos kernal eprom-file for the C64. Convert it with a tool like "bin2h.exe" to a c-header file, take the output and insert into "roms.cpp" as "const unsigned char rom_kernal[8192]="
You might want to leave the original as is and use "#ifdef" to switch between both versions.

Later, I'll add a menusystem to the emulator which can select the desired ROMs and other things.

KurtE
10-17-2017, 10:35 PM
Thought I would mention I assembled one over the last couple of days.

1180611807

As I am the Tinkering type, I made a few minor mods to the assembly. In particular I used long breakout pins on the Teensy, such that it makes it easier to jumper pins on the Teensy to other stuff like breadboard as well as nice place to hook up Logic Analyzer. In the past I purchased some from Adafruit and some from sparkfun (https://www.sparkfun.com/products/12693)

I also used some standoffs, such that it can sit on ground without having the Teensy hit...

So far the only thing I have tested out is the USB Host code and verified i could talk to a Keyboard...

Next up figure out how to install the Commodore 64 code to try it out. It is unfortunate that we got rid of my Wife's C64 and all of the games a long long long time ago. Likewise I no longer have my Amiga.

I should mention that the board is easy to assemble. With my boards I have to constantly look at the schematic and board layout to find which parts go where...
As you maybe can see the differences in this picture:
11808

Also maybe try out some of my other ili9341_t3n library code to see if it works OK on this board... Should once I track down which PINS connect.

defragster
10-18-2017, 01:45 AM
Kurt: Check this out for pin connects :: github.com/FrankBoesing/Teensy64 /T64_PinMapUse.txt (https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/T64_PinMapUse.txt)
{ Frank - it doesn't look like I found a #define or anything for the DAC pin used }

On assembly - Yes Frank has done some good work! The Version like this with ILI9341 is currently available and AFAIK will still be supported - but it is a good general purpose display and USB board. The VGA board may be coming along and offer the same setup - with VGA video option ( and other minor interface part changes ).

KurtE
10-18-2017, 09:40 PM
Thanks Defragster - I verified my display test program works :D Next up try to install the C64 stuff... But might be awhile - power out, running on generator

defragster
10-18-2017, 09:49 PM
Thanks Defragster - I verified my display test program works :D Next up try to install the C64 stuff... But might be awhile - power out, running on generator

Awesome you got Display working - now you can post USB_HOST status/debug on local screen as you work. I went through Frank's code and pulled those pins out to that file knowing without them the board would seem 'single use'. Frank went over it and made some edits so it should be right and helpful for all pins wired.

Yes Kurt, we are having a windy day aren't we :) - our lights have only flickered so far. Dropped once yesterday and I swapped my UPS that had about 0% reserve just hibernated on any dip ( or when my laser printer fired up the fuser ) - as I type new UPS kept machine up across a dip that dropped 2nd display and other stuff.

C64 stuff was good an easy when I did it. Just need a lib or two and I got it working. Have not recompiled recently with newest IDE/TD but there are README notes on Github that should get you there - post any issues.

misc
10-22-2017, 08:59 PM
Anybody interested in a VGA Version ?
My preliminary board looks like this:


11745
Because the demand is very small, I ask before continuing and will only finalize the final board if there is demand for the VGA version.
Edit: It has a easy to solder SMD IC ("SOIC") for 3V<->5V conversion on the backside. The board can be used for other projects, too. Perhaps the 5V bidirectional pins are useful ?

I would definitely buy one as well :)

Wayne
10-23-2017, 04:44 PM
I might have some of the games already in a file format, I can check for the C-64 if you like.

Frank B
10-23-2017, 08:05 PM
I might have some of the games already in a file format, I can check for the C-64 if you like.

Easiest, and fasted to use is single-file software - PRG files. They load in less than a second from the Teensy-SD slot.
They are available on the internet. Some time ago I saw a big archive with hundrets of them..

I think, most PAL 80's and 90's games should work. The younger the games are are the more likely they use "dirty tricks" which may not be emulated at the moment..
NTSC is totally untested.

Frank B
10-24-2017, 02:53 PM
I have a rock-stable VGA now, at least on my display. I think, I was right with this post (https://forum.pjrc.com/threads/45916-Teensy-3-6-VGA-driver?p=154921&viewfull=1#post154921). However, for this test, I had to disable some important things
Reasons for pixel-flickering are: - GPIO-Access, DAC, USB. I am hoping that I can solve this with synchronizing the GPIO and DAC accesses with the VGA hsync-signal.
USB (Host) is not that easy - It helps a lot to disable the async transfers completely (after enumeration) - but there is still a little flickering. I tried to sync this is with VGA-vsync, and to enable the periodic transfers "outside" the screen only - but this resulted in too slow reaction to key-presses. Maybe hsync is better...

Anyway, the flickering is not too annoying, and I can't see it from 1.5 Meter distance.

KurtE
10-26-2017, 10:49 PM
I am hoping to try out a few C64 games, but I don't have any C64 joysticks... I found a few up on Ebay for about $200 8)

So thought I might build my own for now... Looked at some sites and it look like the connections to the 9 pin connector looks pretty straight forward, so I thought I would buy some simple joystick parts.

I saw Defragster purchased some stuff from Sparkfun... Should have purchased some of the same stuff. Actually Amazon has the joystick a bit cheaper. But I purchased a different one that also came with some buttons (8)... I probably should have looked a little more carefully as I think the size of it is a little out of scale :lol:

11902

May need to build a pretty big heavy box for it!

prickle
10-27-2017, 09:18 AM
The stick I got for my Aiie box is not bad. About the right size for me, seems pretty solid but feels a bit cheap.

11904

I bought it here: http://www.ebay.com.au/itm/AC-240V-5A-4NO-4NC-Momentary-2-5mm-Fixing-Thread-Joystick-Switch-HY-/191877862651?hash=item2caccfd4fb

Frank B
10-27-2017, 08:33 PM
@Kurt: I bought an old digital ATARI Joystick for 5€ in the bay.. One of the next things I'll add is a "swap joystickports" function via keyboard.
All the c64 software uses the ports more or less randomly. It's a bit annoying to always plug the joystick into another socket. That's why I had two then.

@prickle: Nice !!


Last updates:
- Please update the reSID library - there was a little change to make it more exact.
- VGA: GPIO and DAC is now sychronized to VGA - flicker almost completely gone.
- VIC: Added a better emulation for graphic modes 1 and 3 in "idle" state - all other modes in "idle" are still ""TODO". Only very few programs use it, so not a big issue.

Please report issues on Github! Thank you!

misc
10-29-2017, 07:33 AM
I am hoping to try out a few C64 games, but I don't have any C64 joysticks... I found a few up on Ebay for about $200 8)

So thought I might build my own for now... Looked at some sites and it look like the connections to the 9 pin connector looks pretty straight forward, so I thought I would buy some simple joystick parts.

I saw Defragster purchased some stuff from Sparkfun... Should have purchased some of the same stuff. Actually Amazon has the joystick a bit cheaper. But I purchased a different one that also came with some buttons (8)... I probably should have looked a little more carefully as I think the size of it is a little out of scale :lol:

11902

May need to build a pretty big heavy box for it!
You can buy them online, i am not sure whether they sell outside eu, but you can ask Thomas :
https://shop.pixelwizard.eu/commodore-c64/34/competition-pro-retro?c=6

Frank B
10-30-2017, 09:50 PM
I've managed to record some music - I hope this gives you an impression of the SID emulation. Not 100% perfect, but not too bad, I think :)
https://github.com/FrankBoesing/Teensy64/blob/master/examples/SDCARD/C64/Monty%20On%20The%20Run.mp3

There are several C64 programs to create such music.

menno
10-30-2017, 09:54 PM
I got the parts this weekend and now have a. teensy64 as well!

I had some trouble early on with USB input but all is working now, I have to fix my joysticks though or create a smaller one.

So far I've been able to play a few games. For anyone having trouble finding PRG you can also try getting the .d64 images and extract the PRG with a tool called c1541 from the VICE emulator.

I'll try to make a list of games I've tried and the results of which work and which don't.

I also have a 1541 that I'll try and see if it works

I wasn't able to upload a picture for whatever reason, I'll try to link it https://imgur.com/a/2AfsX

Frank B
10-31-2017, 06:31 PM
Hi menno, the picture was too large. I shrinked it a bit:

11951

Please add 330Ohm resistor if you add speakers directly, without amplifier. The Teensy does not like it, without it, you're shorting the DAC-pin.

I've added two features :

- 2017/10/30: Added Joystickport-swap with NUMLOCK
- 2017/10/31: Added volume adjustment with CTRL-Right and Cursor UP/DOWN

menno
10-31-2017, 07:44 PM
Hi menno, the picture was too large. I shrinked it a bit:

Please add 330Ohm resistor if you add speakers directly, without amplifier. The Teensy does not like it, without it, you're shorting the DAC-pin.

I've added two features :

- 2017/10/30: Added Joystickport-swap with NUMLOCK
- 2017/10/31: Added volume adjustment with CTRL-Right and Cursor UP/DOWN

Thanks! I've added the resistors, they are in the plug, but sound is very silent now, I'm looking into a tiny amplifier to fix it, I've already updated to the latest version but my keyboard doesn't have a numlock key but I'll figure something out for that

Frank B
10-31-2017, 07:54 PM
Do you have an amplifier on stock ? Mail me, if not..
NumLock: Should this be configurable ? Which key would be better for such keyboards ?

menno
10-31-2017, 08:00 PM
I don't have anything on stock, I might have some parts to make one (though it's probably easier just order one from China)

The keyboard I'm using is a rii rt-mwk01, with the teensy usbhost test I should be able to figure out a key that I can use for it, I'll let you know once I figured it out!

eightbitswide
11-02-2017, 03:27 AM
Question: (and maybe this is too far outside the scope of this project)

Might it be possible for this project to be *retrofitted* to accept the VIC chip data from an actual C64 motherboard and output in VGA? None of the IEC, ReSID, ps/2 keyboard stuff would be required, which would (I hope) open up enough I/O for such a task. I'm picturing something that would plug into the socket, then output VGA.

Edit: You probably have also implemented the Character ROM internally, simplifying things even further, also it also looks like the entire project could be hung on the Expansion port if U6 (Color RAM) is also emulated in the Teensy.

Edit: I see the Teensy 3.5 is 5v tolerant, which would be idea for this. Will your VIC/VGA code run on the Teensy 3.5?

I can think of at least a hundred die-hard C64 guys (perhaps a few more) who would really go for something like this.
-8b

Frank B
11-02-2017, 09:10 PM
Hm, might be possible.. But it would -still- be an emulation. I wonder, if a FPGA wouldn't be better.
The crystal input might be a bit problematic - on the other hand, it can be ignored, maybe ? The would mean, the c64-clock would be drivenby the teensy. We should take a look at the shematic - I'm not sure.
Maybe open an other thread for this ?

eightbitswide
11-02-2017, 09:56 PM
Maybe open an other thread for this ?

Great idea.. New thread opened.
https://forum.pjrc.com/threads/47434-Commodore-64-VIC-Emulation-on-the-Teensy

KurtE
11-05-2017, 04:39 PM
Thought I would mention, that I picked up a couple of cheap controllers on ebay: https://www.ebay.com/itm/371085473534
They are a pretty low quality product, that have laud clicks and the like but I have been able to try one of them out on Boulder dash and it worked :D
Great job.

Couple of quick comments:
1) Might be nice to know a preferred way to install your code and software. That is with the github project: https://github.com/FrankBoesing/Teensy64
You probably want some of this in your Arduino sketch folder: C64 directory and you need part of it in your Sketch/libraries folder: Teensy64
I just copied this directory to the appropriate place, but will need to remember when I do a sync and see you made changes.

2) it took me a bit of time to get the program to compile and run for me. I am using my private copy of the usb host code. Slight superset of current official one.
There was an issue with the keyboard_usb.cpp code in the project. There are lines in there that have: println("Title", val, HEX);
which no longer compile. That is because internal to usb host library Paul renamed the print/println functions to print_ and println_ and then for those files that need to use these. I first added the macros to your file. Still did not compile as you had other Serial.print lines... So I made those also not use Serial....

3) After that I was able to get it to run :D Took me a bit to figure out how to use the keyboard. That is if I try to type the line: 10 print "hello world", when I pressed the " key on the keyboard I got something like a ; instead. Finally found " as a SHIFT+2 key.

Again great stuff... Soon now assemble other board.

Frank B
11-05-2017, 08:24 PM
Thought I would mention, that I picked up a couple of cheap controllers on ebay: https://www.ebay.com/itm/371085473534
They are a pretty low quality product, that have laud clicks and the like but I have been able to try one of them out on Boulder dash and it worked :D
Great job.

Couple of quick comments:
1) Might be nice to know a preferred way to install your code and software. That is with the github project: https://github.com/FrankBoesing/Teensy64
You probably want some of this in your Arduino sketch folder: C64 directory and you need part of it in your Sketch/libraries folder: Teensy64
I just copied this directory to the appropriate place, but will need to remember when I do a sync and see you made changes.

2) it took me a bit of time to get the program to compile and run for me. I am using my private copy of the usb host code. Slight superset of current official one.
There was an issue with the keyboard_usb.cpp code in the project. There are lines in there that have: println("Title", val, HEX);
which no longer compile. That is because internal to usb host library Paul renamed the print/println functions to print_ and println_ and then for those files that need to use these. I first added the macros to your file. Still did not compile as you had other Serial.print lines... So I made those also not use Serial....

3) After that I was able to get it to run :D Took me a bit to figure out how to use the keyboard. That is if I try to type the line: 10 print "hello world", when I pressed the " key on the keyboard I got something like a ; instead. Finally found " as a SHIFT+2 key.

Again great stuff... Soon now assemble other board.

Thank you very much for your comments. Very helpful ! The Keymapping is close to the original keymapping- It's possible to change that, but other emulators use the C64 keymap, too.
I really don't know why they did the " on shift-2: But, luck for German users, the " is shift-2 on the normal German keyboard too :)
(Edit: But "Z" and "Y" are swapped for Germans :-( )

Have you tried to do something with the Keboard-LED's in my code ? I had no luck so far (?)


@All : Currently, I'm working on a really big update. I was hoping to get it done today, but no chance.. turned out to be much more complicated than I thought. My brain is fried and I need a pause. The Videochip (VIC) and a little part of the CPU will work complete different. Reason for this is, that some games show flickering sprites or other parts. I'm hoping to prevent this with a even "more close to the original" emulation. Keeping the same speed while doing more work is complicated...)
This will take a week more. Minimum.

A betatester tried the (old)VGA Version. It's working for him. Maybe he writes something here..

Frank.

edit: @Kurt: For VGA, please use the "raw HID" setting, and run the "Auto adjust" on your display.
edit: I've udated the list in Post #2 (https://forum.pjrc.com/threads/46168-Commodore-C64-Emulation-on-a-Teensy-3-6-Microcontroller?p=152500&viewfull=1#post152500)

KurtE
11-06-2017, 12:18 AM
Frank, I will take a look at the LED stuff hopefully tomorrow. Was busy most of day still playing with serial stuff. Did some testing on can I do different formats: 8n1, 8n2, 7e1, 7e2 on the different types of serial adapters that are supported (FTDI, CDCACM, PL2303, CH341). Then for the fun of I add CP210x support as well. Not sure if they all work to their fullest extent but hopefully be fully complete.

I was using wireless keyboard with no LEDS when I was testing earlier today. so will swap out to a simple one that has the leds.

KurtE
11-06-2017, 02:37 PM
I have taken a quick look at the LED stuff and there are some issues.

For example I know from the main keyboard code I had to defer updating the LEDS when you were processing the keyboard input message... I see you brought in some but not all of this. I added this and sometimes this can work...

I am now finding that allocating of transfer buffers is failing. I added 2 to the contribute number of transfers part of your class and this now makes it work on Caps lock (if I enable that in your code) for a few on or offs, but then still fails with failing to allocate... So I need to trace when these buffers are begin allocated and freed. Also need to see if issue as well in main test program. May not show up there as have many USB devices as part of the test so lots of transfer structures... So maybe masked.

Still looking.

menno
11-06-2017, 05:35 PM
A betatester tried the (old)VGA Version. It's working for him. Maybe he writes something here..



I've not had much time to test it all, but VGA output seems to be working fine for me, do I understand it correctly that it doesn't work for others?

I'd attach an image but I don't seem to be able to upload it to this forum.

KurtE
11-07-2017, 02:17 PM
Hi Frank, I think I have the LEDS working, a lot cleaner now... It worked in test program earlier by luck...

My whole update leds function is now just:

void KeyboardController::updateLEDS() {
// Now lets tell keyboard new state.
mk_setup(setup, 0x21, 9, 0x200, 0, sizeof(leds_.byte)); // hopefully this sets leds
queue_Control_Transfer(device, &setup, &leds_.byte, this);
}

Same code appears to work in yours (different class name).

Frank B
11-07-2017, 10:10 PM
Hi Frank, I think I have the LEDS working, a lot cleaner now... It worked in test program earlier by luck...

My whole update leds function is now just:

void KeyboardController::updateLEDS() {
// Now lets tell keyboard new state.
mk_setup(setup, 0x21, 9, 0x200, 0, sizeof(leds_.byte)); // hopefully this sets leds
queue_Control_Transfer(device, &setup, &leds_.byte, this);
}

Same code appears to work in yours (different class name).

That's all ? Cool :-) I'll try that tomorrow. Thank you very much !
I'm very busy (with other things too) at the moment - sorry have not much time for the forum and other things. The new aproach for VIC looks good, at the moment.. most problems are solved, but still much work.

@menno: No, you're the first one how tried VGA - as far as I know.

Frank B
11-07-2017, 10:21 PM
Kurt,
i could not resist... it' bedtime, but i wanted to see it :)


USBHS_ASYNC_ON;
keyboard.LEDS(0x02);
keyboard.updateLEDS();
delay(100);
USBHS_ASYNC_OFF;

Great. Works. Thanks again ;)

KurtE
11-08-2017, 02:17 PM
You are welcome,

Hi Frank,

One other comment, Currently being setup to build your app, I appear to have the issue, that either I have to setup and remove your platform.txt or I have to add empty defs.h to each of the other apps that I am testing. Or did I miss adding something to the file... (I had merged in your stuff) as to leave TYQT installed. .. Probably should just copy your file in and then let tyqt modify it again..

JimDrew
11-08-2017, 11:59 PM
Is there a walk-through on how to use the Arduino IDE to build this? I got the files, and installed the SDFat library, but I am not sure how to load/compile the project! I have a board sitting here built and ready to go! :)

defragster
11-09-2017, 12:25 AM
With the IDE installed and then TeensyDuino you should be able to build and program a new BLINK to the T_3.6.

Then in the IDE's Sketchbook Folder you need the source from a downloaded zip or local fork of: https://github.com/FrankBoesing/Teensy64

That page shows two libraries that should also go into the Library folders:

External libraries required to be in sketchbook/libraries:
Teensy-reSid
SdFat

With that in place it should compile with the Teensy at 240 MHz - there may be updated notes here: https://forum.pjrc.com/threads/46168-Commodore-C64-Emulation-on-a-Teensy-3-6-Microcontroller?p=152499&viewfull=1#post152499

Post any feedback.

JimDrew
11-09-2017, 01:01 AM
I have no issues using any of the Teensy 3.6 examples (like BLINK). The teensy-resid and sdFat are there. I downloaded the source and put it into my projects directory, but there is only C64.ino as a project file that will load and that generates an error about missing the .h file.

defragster
11-09-2017, 01:07 AM
A copy of the Teensy64 directory from github is needed there - many more files than just the INO.

You can close and open the IDE after that is copied to make sure it is found.

JimDrew
11-09-2017, 01:28 AM
OK.. I don't understand. I have been using the Arduino IDE for many years. I have zero issues using it. I installed the Teensy 3.6 installer and I can select the BLINK example and it blinks the LED. The Re-sid and sdFat examples are also present. I took the Teensy64-master.zip and tried to install it as a library - doesn't work. I then tried putting the unzipped contents into my projects directory. The only project file that exists in the entire zip file is C64.ino. What is suppose to be loaded? What is the story with the platform.txt file? I have no idea where that file is suppose to reside. It seems that it is suppose to replace something in the Arduino system (based on the description in the first post), but that is not clear.

JimDrew
11-09-2017, 01:54 AM
I was able to test the board by loading the Adafruit ILI9341 example and changing the display pins to match what is used for the Teensy64 board. So, at least that works. :)

defragster
11-09-2017, 03:12 AM
AdaFruit and BLINK are good feed back knowing it works and the IDE is working and ready to go.

I haven't worked with this in too long - will see if I can get it going on a new computer ...

defragster
11-09-2017, 04:32 AM
In libraries needed as noted: reSID and SdFat

Teensy64 also goes in libraries directory.

For the main project file I opened as extracted: C:\tCode\lib_zip\Teensy64-master\Teensy64-master\C64\c64.ino

Ignoring the other files works with these HACKS to the Teensy CORE code

About line 52 make this change: C:\arduino-1.8.5\hardware\teensy\avr\cores\teensy3\AudioStrea m.h:

#ifndef AUDIO_BLOCK_SAMPLES
#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
#define AUDIO_BLOCK_SAMPLES 32 // teensy64 was :: 128


About lines 768 and 770 add and remove comments on these lines in : C:\arduino-1.8.5\hardware\teensy\avr\cores\teensy3\kinetis.h:


#if (F_CPU == 240000000)
#define F_PLL 240000000
#ifndef F_BUS
// #define F_BUS 60000000
//#define F_BUS 80000000 // uncomment these to try peripheral overclocking
#define F_BUS 120000000 // all the usual overclocking caveats apply...


I think I saw one warning and got:



Using library Teensy64 in folder: C:\tCode\libraries\Teensy64 (legacy)
Using library SPI at version 1.0 in folder: C:\arduino-1.8.5\hardware\teensy\avr\libraries\SPI
Using library USBHost_t36 at version 0.1 in folder: C:\arduino-1.8.5\hardware\teensy\avr\libraries\USBHost_t36
Using library SdFat at version 1.0.3 in folder: C:\tCode\libraries\SdFat
Using library reSID in folder: C:\tCode\libraries\reSID (legacy)
Sketch uses 377904 bytes (36%) of program storage space. Maximum is 1048576 bytes.
Global variables use 234812 bytes (89%) of dynamic memory, leaving 27332 bytes for local variables. Maximum is 262144 bytes.

JimDrew
11-09-2017, 04:35 AM
Thanks. I have never had an issue with any sketch before, and I have a few commercial products that use the IDE to generate code so I am really familiar with how it all works. The Teensy64-master.zip contains a directory called C64 that only has two files in it (C64.ino and defs.h). There is also a directory called Teensy64 which has all of the .cpp and .h files for the emulator, but no project file (which is a file that has a .ino extension). I tried combining various files and such and could not get anything to compile successfully. Since the display works, I am assuming that the joystick ports, audio port, USB port, and IEC all work as well.

The error message I get is:

:\Users\Jim\Documents\Arduino\Teensy64-master\C64\C64.ino:36:22: fatal error: Teensy64.h: No such file or directory

The compile is failing immediately because it's not finding the Teensy64.h file. I thought this was because there are only two files in the C64 directory so I copied all of the .cpp and .h files to the C64 directory with the same result.

I am using v1.8.2 of the Arduino IDE. Is that compatible?

JimDrew
11-09-2017, 04:47 AM
OK, figured out the main issue. There needs to be some explaining about what is in the archive (teensy64-master.zip).

I saw above in your post: Using library Teensy64 in folder: C:\tCode\libraries\Teensy64 (legacy)

So, you need to copy JUST the Teensy64 directory to your libraries directory. The C64 directory then goes into your projects directory. The extras and examples directories can be copied anywhere.

Now I get the compile errors that deal with the changes you have stated need to be made. I will make those changes and see what happens!

defragster
11-09-2017, 04:54 AM
Updated #75 - indeed I left Teensy64 in libraries as the pasted IDE output indicates

JimDrew
11-09-2017, 05:07 AM
Success! :)

For anyone pulling their hair out, follow this guide:

Make the changes to the Teensy system files as described above in post #75 (https://forum.pjrc.com/threads/46168-Commodore-C64-Emulation-on-a-Teensy-3-6-Microcontroller?p=158848&viewfull=1#post158848)
Download the teensy64-master.zip from the github link and unzip the archive to a temp directory.
Copy the Teensy64 directory to your arduino libraries directory.
Copy the C64 directory to your projects directory.
Open the C64.ino project from the C64 directory (in your projects directory).
Start the compile. When finished, upload the data (if you have the auto update off).
Remove the power to the board and plug the power back in (reset does not work if you had another sketch already running on the Teensy board).

The confusion here is that normally you do not ever put files in the libraries directory unless they are in fact a library. The Teensy64 directory needs to be in the libraries directory because some files are replacing library files.

defragster
11-09-2017, 05:13 AM
When compiled on this i7 laptop::
> IDE 1.8.5 built in ~90 seconds - clean first build on Battery and 47 seconds on AC.
> Modified beta IDE 1.9.0 built in ~60 seconds on Battery and 30 seconds on AC.

To compare resultant build results - some minor bytes of difference:



// IDE 1.8.5 build with td 1.40 released
Sketch uses 377904 bytes (36%) of program storage space. Maximum is 1048576 bytes.
Global variables use 234812 bytes (89%) of dynamic memory, leaving 27332 bytes for local variables. Maximum is 262144 bytes.



// the BETA 1.9.0 build engine with td 1.40 beta 3
Sketch uses 377904 bytes (36%) of program storage space. Maximum is 1048576 bytes.
Global variables use 234084 bytes (89%) of dynamic memory, leaving 28060 bytes for local variables. Maximum is 262144 bytes.

Both binaries still untested - but they built. I rebuilt the beta 1.9.0 version because the JAVA app had a Win 10 access popup displayed - I didn't address the first build.

defragster
11-09-2017, 05:20 AM
The Teensy button is not RESET - but puts the Teensy into PROGRAM mode and it should allow Teensy Loader to push the code if it does not do it AUTO.

Obviously the Subset of files in TEENSY64 is a library of code. It contains custom versions of standard TeensyDuino Library code with needed modifications so the resulting build to work in the fashion needed to emulate the C64 as Frank built it.

JimDrew
11-09-2017, 05:36 AM
I use v1.8.2 and it takes 52 seconds to compile on my desktop.


Sketch uses 377904 bytes (36%) of program storage space. Maximum is 1048576 bytes.
Global variables use 234812 bytes (89%) of dynamic memory, leaving 27332 bytes for local variables. Maximum is 262144 bytes.

defragster
11-09-2017, 06:16 AM
Your time made me wonder - those times were on battery. When running on AC they drop by HALF. 47 seconds for stock 1.8.5 and 30 seconds for 1.8.5 with the 1.9.0 parallel build engine.
That is here : Arduino-1-9-has-multi-cpu-parallel-build (https://forum.pjrc.com/threads/47213-Arduino-1-9-has-multi-cpu-parallel-build)

JimDrew
11-09-2017, 02:29 PM
I should try v1.8.5. After v1.6.4 the compile time more than doubled for any project. Maybe they have fixed that with v1.8.5? Parallel processing should really help. I am using a 4930K CPU @3.9GHz with all SSD drives.

JimDrew
11-09-2017, 04:09 PM
I spent quote a bit of time this morning attempting to make a real 1541 drive work with the Teensy64. Unfortunately, it doesn't work - at least not with my board. Here is what happens:

I power up the Teensy64 with the 1541 plugged in and the screen shows the Teensy64 logo and then IEC ACCESS. The 1541 resets and C64 is up. Using the USB keyboard, I type LOAD"$",8 and press RETURN. IEC ACCESS is displayed, the drive comes on, track 18 is found and then the whole system hangs. One in about 50 attempts actually will show LOADING and then load the directory. If I power off the drive while the system is hung, I see IEC ACCESS and then the C64 shows FILE NOT FOUND and the cursor comes back. I tried several 1541's and cables, all which confirmed to work with a real C64 (sitting next to the Teensy64).

So... do you have a schematic of your board? I am assuming that the 1K pull-up resistors are partially for the IEC bus? I suppose that one of the level shifters could be bad. I have not tried a SD2IEC type device. I know the disk drive inside and out, having spent 2 decades making copying hardware and software for it, and I am about to release a true 1541 emulator called ÁDrive (micro-Drive) that is about 1" square in size, based on a 64MIPs dsPIC33 emulating a 6502, dual 6522s, data separator, etc. all cycle exact and supporting .g64,.nib,.d64, and .scp image files.

I have thousands of original C64 game disks that I can test once I can get the drive working in Teensy64.

Frank B
11-09-2017, 05:10 PM
I spent quote a bit of time this morning attempting to make a real 1541 drive work with the Teensy64. Unfortunately, it doesn't work - at least not with my board. Here is what happens:

I power up the Teensy64 with the 1541 plugged in and the screen shows the Teensy64 logo and then IEC ACCESS. The 1541 resets and C64 is up. Using the USB keyboard, I type LOAD"$",8 and press RETURN. IEC ACCESS is displayed, the drive comes on, track 18 is found and then the whole system hangs. One in about 50 attempts actually will show LOADING and then load the directory. If I power off the drive while the system is hung, I see IEC ACCESS and then the C64 shows FILE NOT FOUND and the cursor comes back. I tried several 1541's and cables, all which confirmed to work with a real C64 (sitting next to the Teensy64).

So... do you have a schematic of your board? I am assuming that the 1K pull-up resistors are partially for the IEC bus? I suppose that one of the level shifters could be bad. I have not tried a SD2IEC type device. I know the disk drive inside and out, having spent 2 decades making copying hardware and software for it, and I am about to release a true 1541 emulator called ÁDrive (micro-Drive) that is about 1" square in size, based on a 64MIPs dsPIC33 emulating a 6502, dual 6522s, data separator, etc. all cycle exact and supporting .g64,.nib,.d64, and .scp image files.

I have thousands of original C64 game disks that I can test once I can get the drive working in Teensy64.

Would be great to have a such a tester ;)
Ok, first, please make sure, everything compiled correctly: That means: F_CPU 240MHz, F_BUS 120MHz, AUDIO_BLOCK_SAMPLES=32, -O2 (no LTO or other options)
If you're unsure, please try the latest HEX-File (from GitHub)

I have a schematic - but, at the moment, the hardware is not "open" - maybe this changes one day. At the moment its not.
Testing it is easy, without schematic: There is a pinmapping (https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/T64_PinMapUse.txt) on Github, and you can write a short sketch that toggles the IEC Pins (would be great if you could add that to the reprository, with a pull-request!). A voltmeter can give you the answer for Outputs. Inputs/Bidirectional lines can be tested with pinMode(x, OUTPUT_OPENDRAIN)

Since the bus works for other users (personally, I could test with a SD2IEC only), I assume no basic design problem. But ok, it is possible.

The VGA board will have different levelshifters (BSS138) and is a mixed through-hole / SMT design.
You mentioned, the board is large ? I'd be surprised if you can make it much smaller without removing connectors. And it's exactly the size of the display, so, usually, there is no point in making it smaller.

Edit: The VGA board will be a bit larger.
Edit: VIC-Code: I have some progress, some things are working better now. I can't update github at this point, because I have to complete it and want to do some tests before I can do that.

JimDrew
11-09-2017, 05:25 PM
Yes, it compiles just fine and appears to work. I can make a simple test program that toggles the IEC lines high/low.

I don't see where anyone else has actually tried a real 1541. Has this been confirmed to work?

BSS138 is what I have used on everything for years!

I meant the board was large because of the connectors and their positions. I would like to make a new design that splits it into a couple of boards (all SMT) so the LCD can be mounted inside of a 1/6th scale 1701 monitor case, with the joysticks and IEC connector facing out the back of it. I doubt the LCD will handle a cable due to the SPI bus speed.

Speaking of SPI bus speed. I looked at your code for handling the display, and I notice that you use digitalread() and digitalwrite(). Are you aware that under Arduino these commands can take tens to hundreds of microseconds to complete (depending on the CPU)? It's such a problem for Arduino boards and ESP8266 modules that we have switched to getting/setting the pin by accessing the CPU directly. This eliminates the latency. I don't know how critical it is for you when changing the CS and DC pins, but every little bit of extra time helps!

Frank B
11-09-2017, 05:28 PM
I have two users (one in Germany) who confirmed working drives.
digitalWrite: That's used during initialization only where this does not matter. After that, there is DMA only.

Edit: the reason for the transitors was that i wanted th whole board to be through-hole and easy to solder for beginners.

JimDrew
11-09-2017, 05:50 PM
OK, I wrote a quick test sketch. I don't know how to do anything on Github because I don't use it myself. Here is the sketch:


/* Teensy64 IEC pin test
*
* November 9, 2017
* By Jim Drew
*
* Run this test and measure the voltage on each of the IEC pins.
* You should see each pin toggle between 0v and +5v.
*
*/

#define PIN_RESET 25 //PTA5
#define PIN_SERIAL_ATN 4 //PTA13
#define PIN_SERIAL_CLK 26 //PTA14
#define PIN_SERIAL_DATA 27 //PTA15
#define PIN_SERIAL_SRQ 36 //PTC9

void setup() {

pinMode(PIN_RESET, OUTPUT_OPENDRAIN);
pinMode(PIN_SERIAL_ATN, OUTPUT_OPENDRAIN);
pinMode(PIN_SERIAL_CLK, OUTPUT_OPENDRAIN);
pinMode(PIN_SERIAL_DATA, OUTPUT_OPENDRAIN);
pinMode(PIN_SERIAL_SRQ, OUTPUT_OPENDRAIN);
}

void loop() {

// make all lines low
digitalWrite(PIN_RESET, LOW);
digitalWrite(PIN_SERIAL_ATN, LOW);
digitalWrite(PIN_SERIAL_CLK, LOW);
digitalWrite(PIN_SERIAL_DATA, LOW);
digitalWrite(PIN_SERIAL_SRQ, LOW);

delay(3000); // delay 3 seconds to give even crappy VOMs time to respond

//make all lines high again
digitalWrite(PIN_RESET, HIGH);
digitalWrite(PIN_SERIAL_ATN, HIGH);
digitalWrite(PIN_SERIAL_CLK, HIGH);
digitalWrite(PIN_SERIAL_DATA, HIGH);
digitalWrite(PIN_SERIAL_SRQ, HIGH);

delay(3000); // delay 3 seconds again and repeat!

}

This test works perfectly on my board. I can't imagine it being a NTSC vs. PAL issue since the disk drives run at the same frequency no matter what the input voltage is.

On the off chance that there was a compiling issue, I used the Teensy loader and uploaded the Teensy64_171024_PAL.hex file from Github. I got the same results. I am going to try a SD2IEC to see if that works.

Ok... SD2IEC works perfectly every single time! My 1541, 1541-II, 1571, and 1581 all have the exact same problem so I think there must be a slight timing issue with the IEC bus when using real hardware. I am using completely stock disk drives (no JiffyDOS). Let me know if I can help debug something. I have Saleae's Logic Pro 16, DSO's, etc.

Frank B
11-09-2017, 05:55 PM
Yes, that's indeed no PAL/NTSC problem. Can you please open the Aduino-Monitor and post the output?
Your sketch tests output only, but I think that's not a issue...

Frank B
11-09-2017, 06:18 PM
Ok... SD2IEC works perfectly every single time! My 1541, 1541-II, 1571, and 1581 all have the exact same problem so I think there must be a slight timing issue with the IEC bus. I am using completely stock disk drives (no JiffyDOS).

Hm :-( Bad news. I think I have to buy a new old drive... On the other hand, it's good enough to work with jiffydos (jiffy rom on C64-side, SD2IEC on the other), which is 25 times faster.
Is the shielding on the IEC conn. soldered (the two pins on the edge)?

JimDrew
11-09-2017, 06:27 PM
The sketch was to determine if the level shifter is working. If the 0v/5v toggle occurs then it will also work correctly for an input. Yes, the shielding is good. I design and prototype hardware for a living, so I think my board looks pretty good. :)

I don't have the PC next to my C64 and disk drives. I will have to move some stuff around in order to be able to see results from the Arduino-Monitor.

The biggest difference between the SD2IEC and a real disk drive is the drive portion itself. It's slow, which has long delays between IEC transfers due to having to decode GCR and find the sector it is looking for. The S2DIEC doesn't have to wait up to 200ms to find a sector.

Frank B
11-09-2017, 06:31 PM
Output: Not needed anymore. If you say it works with Sd2IEC i'd not assume a compilation problem.
Hm, do short commands work - like the command channel?

OPEN 1,8,15:INPUT#1,E,E$,T,S:PRINT E,E$,T,S:CLOSE 1

JimDrew
11-09-2017, 06:35 PM
I already did that earlier. It hangs (most of the time) with a 1541, and shows the error channel properly on the SD2IEC every time. I actually had it work twice in a row with a 1541 and then 10 times in a row where it hung the bus.

Frank B
11-09-2017, 06:38 PM
OK. Have to buy a 1541 or something similar.. :-( I want that working.

JimDrew
11-09-2017, 06:51 PM
I am going to convert my JiffyDOS kernal ROM and put in place of the stock ROM (ROMS.cpp) and try that with a stock drive and a drive that has JiffyDOS in it. I am sure there is just some little timing thing going on here. JiffyDOS has a little bit different timing.

This is a pretty impressive emulator! I am interested in your VGA board too. I have a couple of extra C64C cases I got from the Kickstarter project that would be great for this along with Keyriah.

Let me know if you would like something tested. I have lots of equipment at my disposal and the disk drive internals are second nature for me. :)

Frank B
11-09-2017, 07:00 PM
Yes, roms.cpp is the right location. You can ignore the "patch" lines.

I've used the tool "BIN2H" (I don't remember where I downloaded it)

It is planned to support different ROMS, with easy switching between them - when I have my other - more urgent - changes working.
Hm. Would it be possible to connect a computer to the teensy ? I guess this changes the timing a tiny little bit... might explain why it worked for others ?

JimDrew
11-09-2017, 07:16 PM
Computer? As in a PC to emulate a disk drive? Yeah, that's possible. Having more than 1 disk drive also changes the timing a little bit because of the extra pull-up resistor. I don't know how fast the transistors you are using really are. BSS138 is not available in TO-92 package, so I can't easily change the transistors to something I know works perfectly and is super fast.

Frank B
11-09-2017, 07:28 PM
They are quite slow. As the IEC isn't that fast, that should be OK (well, I hope).
I'd like to send you a mail, and don't have your address... can you send me a short mail to :
f (dot) boesing at gmx (dot) de
please ? Thanks..

JimDrew
11-09-2017, 09:33 PM
Responded to your PM!

JimDrew
11-09-2017, 10:32 PM
OK, some info for you...

Compiled with the JiffyDOS ROM (and turned off the ROM patches). Now, when I boot up if I type @$ <RETURN> to get a directory the drive comes on, steps to track 18, and then the bus hangs. When I turn off the drive and turn it back on, the C64 cursor comes back but the keyboard never recognizes the RETURN and some other keys anymore! I have to reboot (CTRL-ALT-DEL) the Teensy64.

Now... what is interesting is that if I type @I <RETURN> to initialize the drive, and then type @$<RETURN>, I get the directory perfectly! If I immediately type @$<RETURN> again, the bus hangs and I have to reboot. But.. if I always enter @I<RETURN> before I attempt to get the directory, then I can get the directory every single time! It's like after a directory read the CIA DDR is not correct, or CLK/DAT/ATN is not set correctly.

::edit::

Ok, the above works fine (@I followed by @$), but ONLY if I don't let the 1541 motor stop running between the @I and @$ commands! If the motor stops between commands, then the bus hangs when trying to get the directory. This is 100% repeatable.

By the way, this is using JiffyDOS only the C64 side. I have not tried testing with a drive that also has JiffyDOS.

Frank B
11-10-2017, 11:07 AM
Thanks ! I try to find the reason. And I will order a floppydrive this weekend. I hope it will work better than the last one..
But the bug must be something simple. Maybe I can find it without having a 15x1

Frank B
11-11-2017, 04:37 PM
Ordered ;-) I hope I have it end of next week. With a bit luck, I'll get a second drive and a original C64, too.

JimDrew
11-11-2017, 07:36 PM
That's great. I would have offered to send you a 1541, but the shipping cost would have been ridiculous from the U.S. to Germany, and it would have never made it there without the drive alignment being knocked out wack! :)

KurtE
11-12-2017, 05:57 PM
Hi Frank,

Was wondering with the VGA board, do we need to add the Diode you showed on the picture in the post: https://forum.pjrc.com/threads/46886-Sn74cbtd3861?p=156092&viewfull=1#post156092

If so did you need to cut the trace going to the pin? Which diode did you use? I have a package of through hole diodes (a pack from Amazon with 10 different ones)... So hopefully one of them will work.

P.S - Other than that I think I have the board assembled. Won't be able to test for a few days... Did not find any VGA cables... I most of tossed them awhile ago :( ordered one from Amazon.

Frank B
11-12-2017, 09:49 PM
Hi Frank,

Was wondering with the VGA board, do we need to add the Diode you showed on the picture in the post: https://forum.pjrc.com/threads/46886-Sn74cbtd3861?p=156092&viewfull=1#post156092

If so did you need to cut the trace going to the pin? Which diode did you use? I have a package of through hole diodes (a pack from Amazon with 10 different ones)... So hopefully one of them will work.

P.S - Other than that I think I have the board assembled. Won't be able to test for a few days... Did not find any VGA cables... I most of tossed them awhile ago :( ordered one from Amazon.

Hi, the diode is not a good solution.. if you really want to mess with it, any (500mA minimum) will work. Cut the VCC trace between the ic- pin1 pad and the via nearby, and insert the diode between 5v+ and pin1. I have no idea which part-# the diode on the picture is, I bought 100 of them years ago and there is no marking. It's just to lower the voltage a little bit. The IC is for levelshifting only. You don't need it, if you don't have a diskdrive and nothing attached to the IEC bus. But, if you soldered it, I'd add the diode, yes.. and please measure the voltage on the outputs.

I made new boards.. will take a short time.

itec
11-12-2017, 10:59 PM
How can I get a board? I've managed to compile no problem, would like to make something more permanent and play around making launcher / menu for prg's.

defragster
11-13-2017, 12:49 AM
@itec: PM "Frank B" - which board you are interested in and your destination country - the original ILI9341's are on hand - newer boards are evolving for using VGA.

Frank B
11-13-2017, 04:57 AM
Hi. The VGA boards are not for sale. The are for tests only!
I made new but they are still in production/test.

itec
11-13-2017, 05:43 AM
@itec: PM "Frank B"
@defragster: Thanks. I have pm'd Frank. I am chasing down a TFT version luckily.

defragster
11-14-2017, 02:32 AM
JimDrew - glad you got up and running. I can confirm my test builds just uploaded to my ILI9341 Teensy64 from that new machine and work with one of my newly pinned T_3.6's.

JimDrew
11-14-2017, 03:15 PM
Yeah, I have the code so I can compile it. I have tried different ROMs and such already.

KurtE
11-14-2017, 07:23 PM
Hi, the diode is not a good solution.. if you really want to mess with it, any (500mA minimum) will work. Cut the VCC trace between the ic- pin1 pad and the via nearby, and insert the diode between 5v+ and pin1. I have no idea which part-# the diode on the picture is, I bought 100 of them years ago and there is no marking. It's just to lower the voltage a little bit. The IC is for levelshifting only. You don't need it, if you don't have a diskdrive and nothing attached to the IEC bus. But, if you soldered it, I'd add the diode, yes.. and please measure the voltage on the outputs.

I made new boards.. will take a short time.

Hi Frank, I put on the Diode. My VGA cable arrived so I plugged it into an old unused monitor. Took a few minutes figuring out how to compile for VGA mode.
I added -DVGA=1
in the defs.h file

The compiler was having issues finding uVGA.h, which I had downloaded into my <sketch folder>/libraries directory and restarted the Arduino IDE, plus cleared out all stuff out of my %temp% folder associated with Arduino.
So added the #include to the top level sketch and it built and installed.

The vga screen come up :D BUT the USB Mouse is not working. I tried running the USBHOst test program (mouse) and it is now showing anything either...

Was wondering if I need to do something with the Solder jumpers on the bottom SJ1/SJ2?
12055

12056

Will take out volt meter and see what is happening.

defragster
11-14-2017, 08:34 PM
Kurt: Thanks for the pics and details. I was on the verge of building mine up and your details will save me some work :)

Looks like I need to reset my system to use the DEFS.h file - I took a shortcut to build for Jim the other day hacking the TD sources - but that won't give the -DVGA=1 switch. I'll see if that works with the beta 1.9.0 build engine that does a full compile in 2/3'rds the time.

> I noted that closing the IDE deletes the %temp% folder in use - so it should start fresh when re-opened.

AFAIK from schematic those two jumpers cut USB connect over to use PS/2 style connection. I'll forward that PDF.

Frank B
11-14-2017, 08:45 PM
Hm, seems that a mail got lost.. I was sure that I sent you all Info, Kurt. You have to close the jumpers accordingly. (Remove the Teensy before soldering, and use a multimeter to check the connections between teensy-USB and the USB socket)
Yes, when changing the options in defs.h, it's needed to restart Arduino, because the builder does not recongnize the changes.
That's needed too, if you edit settings.h - sometimes the builder-caching bug will do (not -) funny things..

defragster
11-14-2017, 08:49 PM
Thanks Frank - I looked at the schematic you sent and wrongly assumed there were default lines connecting the USB by default even though I couldn't see that in the drawing.

Frank B
11-14-2017, 08:52 PM
No, no default - To be honest, I didn't find any way to close a Jumper in EAGLE. I wonder if there is a "legal" way without tricks..

Frank B
11-14-2017, 09:20 PM
Ok..
Got the drive this evening (wow - that was fast) , and I have it working - need to backport the workaround to the old version on github and do some tests with sd2iec AND the floppydrive.
@Jim, don't know if that works at the moment - it's too late here - but if you want to try it:
Comment out line 1950: https://github.com/FrankBoesing/Teensy64/blob/master/Teensy64/vic.cpp#L1950
I have a similar line in the new VIC-Code, and that helped.
I really want to get the new VIC done.. If I only had some more free time...

Edit: or, better, try: cpu.vic.badline = 0;

Edit: Or, best, wait a bit.. i'll update github tomorrow.. maybe, more changes are needed for that version.

KurtE
11-14-2017, 09:57 PM
Thanks guys,

After I posted, I unplugged Teensy and then used multimeter to verify that the USB pins of the Teensy go to the pin of the jumpers with the center pads go to the USB connector. So pulled soldering iron back out and closed the
jumpers.

Now USB is working :D

Sorry I don't know Eagle well enough.. I use Diptrace and have the same issues with how to close the jumper.

I know that the Sparkfun Eagle libraries has components for jumpers, some with the jumpers closed and some without... However when ever I use them (I import them into a Diptrace library). The verification code complains about shorts...
Might be able to ignore them. Or maybe there is some trick like put the etch between them on some different layer and then have the gerber some how merge them...

I was able to download the program. to the board. I noticed during the build that it wanted me to set USB type to RAWHID so I did so... Was able to run a few of the programs. Sometimes when I boot, the screen image breaks up. Other times works pretty well.

When you build for VGA Do you still want the program to run at 240 and the like?

Frank B
11-14-2017, 10:04 PM
Hi Kurt, yes, 240MHz are needed. 120MHz FBUS, hm, maybe not :)
RAWHID, or even better NOUSB causes less glitches and an very good picture - with other USB-Modes, you may get heavy pixel-flicker.

defragster
11-14-2017, 10:51 PM
Quick Look at : https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/T64_PinMapUse.txt

Shows Serial2 pins 9/10 are free for debug - also 18/19 for SDA0/SCL0?

KurtE
11-14-2017, 11:12 PM
Quick Look at : https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/T64_PinMapUse.txt

Shows Serial2 pins 9/10 are free for debug - also 18/19 for SDA0/SCL0?

I also have several USB to serial adapters I can use to talk to Serial2 ;)

defragster
11-14-2017, 11:32 PM
I also have several USB to serial adapters I can use to talk to Serial2 ;)

The best one is a TEENSY! ... but yes , I heard you have a FEW :) . . . yeah that was my idea when I made the reverse table to find the free pins - drop interference from PC USB and still have a reliable SerMon.

Uploaded the XLS file for used pins - the ILI9341 : ReversePinMap.xlsx (https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/ReversePinMap.xlsx)

JimDrew
11-15-2017, 03:28 PM
Ok..
Got the drive this evening (wow - that was fast) , and I have it working - need to backport the workaround to the old version on github and do some tests with sd2iec AND the floppydrive.
@Jim, don't know if that works at the moment - it's too late here - but if you want to try it:
Comment out line 1950: https://github.com/FrankBoesing/Teensy64/blob/master/Teensy64/vic.cpp#L1950
I have a similar line in the new VIC-Code, and that helped.
I really want to get the new VIC done.. If I only had some more free time...

Edit: or, better, try: cpu.vic.badline = 0;

Edit: Or, best, wait a bit.. i'll update github tomorrow.. maybe, more changes are needed for that version.


I will try commenting out line 1950. So this is a badlines issue stealing CPU cycles? I am glad you found your 1541 drive didn't work too!

EDIT: OK, that did not change anything. :( In fact, it might actually be worse because I can't do the @I and @$ back to back and always get the directory. Also, when the bus hangs if I turn off the disk drive, the RETURN key and other keys no longer work. I have to reboot the Teensy. This tells me that the CIA is in some odd ball state where the keyboard doesn't work. However, I think the CIA that is connected to the keyboard is not the same one connected to the disk drive. Is it possible that you have the control registers swapped or are using the wrong one in the IEC stuff?

Frank B
11-15-2017, 06:25 PM
I will try commenting out line 1950. So this is a badlines issue stealing CPU cycles? I am glad you found your 1541 drive didn't work too!

EDIT: OK, that did not change anything. :( However, I think the CIA that is connected to the keyboard is not the same one connected to the disk drive. Is it possible that you have the control registers swapped or are using the wrong one in the IEC stuff?

No.
I found the real reason for the not working drives: They are much slower than SD2IEC, and there is a long pause on the IEC Bus - the emu thought "ah, ok, IEC ready" and switched to the normal mode.
The badline-hack from yesterday was enough to make it a little bit faster, with my new version.
I hope, it works now, - at least a bit better - would you please give it a try ? I've tested with a 1541 and some short programs from disk and played a little with sd2iec.
I did NOT test with jiffy- will do that later...

Edit: Oops... I should mention, that I updated Github and added a new HEX-File..

JimDrew
11-15-2017, 08:27 PM
I am unable to get even a disk directory reliably with 1950 commented out. If I put it back in it works the same as it did before, so in my case it makes it worse.

From an emulation standpoint the CIA needs to be cycle exact to the CPU, and typically with sub-cycle accuracy. So certain things like the fact that CIA timers actually start 1us after they are told to start have to be duplicated correctly. The delay in the IEC can be up to several seconds long, depending on what operation the disk drive is doing. How a IEC device works should have absolutely no affect on how the IEC bus on the C64 works. I have not looked at the relationship between the CIA emulation and the CPU emulation in the Teensy64 source code. These have to be "locked" by a common cycle clock. It's the only way to emulate this correctly.

With my 1541 emulator (uDrive) I run the CPU instruction clock as an interrupt. When an instruction is fetched, a large lookup table jumps to the proper code to handle the instruction. The first thing that the code to handle the instruction does is to poke in a new value for the instruction clock. This would be 2us for a NOP, 4us for STA $xxxx, etc. Instructions where a page boundary is crossed will increment the clock by 1us. When done, the interrupt exits to the main loop. The CPU instruction interrupt will re-trigger when the clock time set by the last instruction look up expires. I also have the VIAs in emulations also trigger interrupts when necessary (based on the control reg). This method keeps everything synchronized. Otherwise, polling in the main loop would be required and that gets messy.

Frank B
11-15-2017, 08:28 PM
Try the new version from Github please. It's updated. No need for a manual code-change, no need for commenting-out that line.
It works with the 1541 and SD2IEC. It's not tested with jiffy, at the moment. Maybe there are new problems with jiffy - we'll see...

I guess, my English is worse than I thought. Excuse me.

JimDrew
11-15-2017, 08:45 PM
Ok, I will try it and get back to you! :)

Good news! The change you made to CIA2 now allows me to load directories just fine. I started testing some commercial disks. Rapidlok protected disks do not work (4th and Inches, Law of the West, etc.) Likewise, Vorpal protected disks (Championship Wrestling, California Games, etc.) do not work. I tried Predator (Activision) and it goes past the protection check and the fast loader kicks in and the game works up to title screen and then hangs loading the back side of the disk. So, it seems for the most part you have the IEC working pretty well. It could be that if you are truly emulating a PAL C64, that these games don't work because they are NTSC only. Is there a chance for a NTSC version of this emulator?

Frank B
11-15-2017, 09:10 PM
Hi,
NTSC is planned - at the moment the timing is PAL ! NTSC will be one of the next things, I'll do.
Thanks for the info re: protection ! Very useful. Maybe, one day, these things will work better, too.. :)

JimDrew
11-15-2017, 09:18 PM
I am sure that the problem I am having is related to the NTSC requirement. I only have a few disks that work with both NTSC and PAL (auto-detect). I will focus on those.

Edit: yes, definitely issues with NTSC vs. PAL Also, now that you have added the exact timing fix, no IRQ loader actually works. The disk data loads but the VIC is not updated. So, games that load in the background are not changing the display data ever. This could be a NTSC/PAL thing, but I don't think so. It's like no free VIC time is available.

Frank B
11-16-2017, 07:21 PM
I am sure that the problem I am having is related to the NTSC requirement. I only have a few disks that work with both NTSC and PAL (auto-detect). I will focus on those.

Edit: yes, definitely issues with NTSC vs. PAL Also, now that you have added the exact timing fix, no IRQ loader actually works. The disk data loads but the VIC is not updated. So, games that load in the background are not changing the display data ever. This could be a NTSC/PAL thing, but I don't think so. It's like no free VIC time is available.

Yes, the VIC is paused now. Can you send me such a game, please ? Or tell me the title ?
And, having having NTSC-only game would be great.

JimDrew
11-16-2017, 08:22 PM
If you had a SuperCard Pro board and 5.25" PC floppy drive you could write .scp image files to a real disk. You could also use the Zoom Floppy with your real 1541 and a PC to write .g64 image files to disk. .g64 images contain raw data including copy-protection. 720 from Mindscape, Predator from Activision, and just about everything else I tried all use a loader where the disk loads but the screen is never updated between files. There are literally thousands of NTSC games in .scp and .g64 format.

Frank B
11-18-2017, 06:31 PM
Small update regarding IEC:

In the meantime I was able to test some hardware and got some feedback.

Current status is:

Teensy64 <-> 1541: no problems
Teensy64 <-> 1541 + 1541-II: no problems
Teensy64 <-> SD2IEC: no problems
Teensy64 with Jiffy <-> SD2IEC: no problems
Teensy64 with Jiffy <-> 1541 + 1541-II: no problems
Teensy64 with Jiffy <-> 1541 + 1541-II with Jiffy: no problems

IRQ loader: Loading works, but no audio + no image updates: This is "by design" like this, and currently intended. Maybe we can make this better, at a later stage...

Feedback from users:

Teensy64 <-> Ulitmate (perhaps connected to a Cevi, cable to the emulator) Transmission errors
Teensy64 <-> 1541 Miscellaneous copy-protected disks (WARNING ONLY NTSC programs tested - can this be due to NTSC?) Does not work.

Question: How is the timing of the Ultimate different? What exactly doesn't fit there? Which signal is slower/faster?
Edit: Could it be a ground-loop?

JimDrew
11-18-2017, 08:33 PM
The IEC timing of the 1541U2 (and U2+) is exactly the same as a real 1541. It passes all of VICE's IEC timing tests that measure sub-microsecond latency. This could be just a cabling issue.

Frank B
11-18-2017, 09:28 PM
I'll concentrate now on making my other update ready before I look at IEC again.
Diskdrives with normal speed, and SD2IEC work good, and I think, as a first step, I should be satisfied with that for now.
The main goal is to make as much games as possible working (- and there's work to do...). Not maximum IEC compatibility (although that would be good, too)

JimDrew
11-19-2017, 12:49 AM
I think I will wait on you adding NTSC support before continuing testing. I can not find a single original NTSC game that will load. Every one of them crashes at some point, which also happens when I use the .g64 image in VICE with it set for PAL mode.

gothmag
11-21-2017, 05:48 PM
I tried jumpman, space taxi, and M.U.L.E. but none worked suspect it's an ntsc issue as well. All the supplied .prgs work fine.

defragster
11-21-2017, 06:07 PM
I tried jumpman, space taxi, and M.U.L.E. but none worked suspect it's an ntsc issue as well. All the supplied .prgs work fine.

You got your boards! And parts kit(s) assembled to working - Great!

gothmag
11-21-2017, 06:13 PM
Yea, no problems, and assembly was really easy. I'm working on getting it to compile now because like another user I'm getting the ctags error. That was using Arduino 1.8.5 and teensyduino 1.40 I think so going to try versions listed. Really a cool project though and I look forward to VGA version if it works out.

defragster
11-21-2017, 06:22 PM
Yea, no problems, and assembly was really easy. I'm working on getting it to compile now because like another user I'm getting the ctags error. That was using Arduino 1.8.5 and teensyduino 1.40 I think so going to try versions listed. Really a cool project though and I look forward to VGA version if it works out.

My last build worked using IDE 1.8.5 and TD 1.40 (beta 3). I didn't catch the ctags error.

gothmag
11-21-2017, 06:25 PM
My last build worked using IDE 1.8.5 and TD 1.40 (beta 3). I didn't catch the ctags error.

Interesting. OS? I was using Win10 using platform.txt, and without. I wasn't using the Arduino installer, just the zipped package. Luckily the .hex are included, even if only occasional versions I think that's a smart idea and hope Frank tries to continue those.

defragster
11-21-2017, 07:04 PM
Interesting. OS? I was using Win10 using platform.txt, and without. I wasn't using the Arduino installer, just the zipped package. Luckily the .hex are included, even if only occasional versions I think that's a smart idea and hope Frank tries to continue those.

Also Win 10. I have been doing UnZip of IDE last years - multiple installs work without conflict and got rid of odd issues I saw with IDE. Yes - I agree, working HEX is important for a baseline where the hardware/software is DYI.

My current build didn't adjust platform.txt. Notes back a week with JimDrew show what I ( and he ) did to get a working build.

gothmag
11-21-2017, 07:29 PM
Also Win 10. I have been doing UnZip of IDE last years - multiple installs work without conflict and got rid of odd issues I saw with IDE. Yes - I agree, working HEX is important for a baseline where the hardware/software is DYI.

My current build didn't adjust platform.txt. Notes back a week with JimDrew show what I ( and he ) did to get a working build.

I'll look into it more tonight if nothing else I'll give it a try on my dev pc. It was 11 by time I had a chance to solder, 12:30am after cleaning, and had to give up around 2:30am since I wake up at 6am. I had tried to re define those in the defs header commenting out rest of stuff with no change. At least I was able to program and try the demos/couple other games.

Frank B
11-21-2017, 09:58 PM
@all - can you post issues with not working software on github, please ? I want to make a list.

I need the following information:
- What exactly does not work ? (for example "sprite flicker", "sound problem" or "does not start" (how did you load it ? IEC/IEC+Fastloader or SD-Card)
- NTSC / PAL ? (currently, NTSC-only games will most likely not work - for almost all are PAL-fixes available on the web)

Please don't add demos.


Thanks !

gothmag
11-21-2017, 11:31 PM
I am running from sd card. I got mule to work(but no joystick atm to test gameplay), space taxi says error 290 and jump man said load error, check disk.

gothmag
11-29-2017, 01:18 AM
I wanted to ask what it might take and if you think it's possible to use d64 images directly from sd card. From what I've found the majority of programs I've tried that don't use a single prg fail sooner than later, but most that are a single prg work ok, although running from sd card choplifter failed to start. I don't know the commodore well enough right now to do any work on this, although after Christmas I'd like to see what I can do to help. Would sd2iec work better for multi .prg games?

itec
12-02-2017, 05:43 AM
@gothmag
I just received my Teensy64 board and have been having a play. I've started doing a basic implementation of the D64 image format. There is a good library available called diskimage.c, though it appears to load the entire disk image into memory. I don't think this is good on a microcontroller.

As a result I have been writing my own by taking some parts of diskimage.c and following the documentation at http://unusedino.de/ec64/technical/formats/d64.html. I've done a rough implementation of loading a directory, following the directory entries from track 18/1 on. I've used the existing method in pacthes.cpp for hooking the load. In my current builds LOAD "$" returns the sdcard contents and LOAD "$IMAGE.D64" loads the directory from the image file. I've followed the existing code from Frank for the SDCard patch basically. In the image you can see the title, blocks free, file type are incorrect. I'm currently doing the BAM stuff for this.

@all: If anyone else is already doing this work, please let me know.

12132

gothmag
12-02-2017, 02:29 PM
Ok, so it's definitely possible. I was essentially thinking to load the image the same way but from there appear to just be a disk drive since most, but not all, of the incompatibility I've had seems to stem from multi track programs. I think mule is a good example since it runs ok up until it tries to switch from the menu to the game. I'm working on a couple hardware projects for other people right now but as soon as the prototypes are done I can start spending some time working on this. Just so you know I'm not uninterested, I just have other things I need to do right now. Are you going to put this code on github at some point?

itec
12-02-2017, 11:20 PM
@gothmag
I am happy to submit any changes to github and have Frank decide if it's clean enough. His code is pretty darn nice.

JimDrew
12-03-2017, 10:05 AM
I don't think you are going to be able to use .d64 image files with games/demos that have custom track loaders (fast loaders). That would require low-level drive support.

menno
12-03-2017, 06:56 PM
@gothmag
I just received my Teensy64 board and have been having a play. I've started doing a basic implementation of the D64 image format. There is a good library available called diskimage.c, though it appears to load the entire disk image into memory. I don't think this is good on a microcontroller.

As a result I have been writing my own by taking some parts of diskimage.c and following the documentation at http://unusedino.de/ec64/technical/formats/d64.html. I've done a rough implementation of loading a directory, following the directory entries from track 18/1 on. I've used the existing method in pacthes.cpp for hooking the load. In my current builds LOAD "$" returns the sdcard contents and LOAD "$IMAGE.D64" loads the directory from the image file. I've followed the existing code from Frank for the SDCard patch basically. In the image you can see the title, blocks free, file type are incorrect. I'm currently doing the BAM stuff for this.

@all: If anyone else is already doing this work, please let me know.

12132

I'd be very interested in this as well, even if not all disk images would be possible due to fastloaders and/or copy protection it might still be very useful.

defragster
12-03-2017, 07:07 PM
I'd be very interested in this as well, even if not all disk images would be possible due to fastloaders and/or copy protection it might still be very useful.

Stay tuned - great to have interest. The board kits with ILI9341 and T_3.6 connectivity are available. Frank may be 'offline' a short time - though the more interested folks the better. PM me if I can help get you a kit.

I don't have history with C64, but I know enough to understand the complexity and proficiency of what FrankB has done here and am excited to see it move forward.

gothmag
12-04-2017, 07:09 AM
I just thought I'd add. I had my dad mail me my sd2iec. I've only tested 1 thing, which is all I've got time for now, and M.U.L.E. works. It's one of my favorite games from when I was a kid so that's great. This is essentially the way forward I think. "Native" loading and directory traversal like itec has started on followed by sd2iec emulation/porting. Not everything since the channels are an abomination, but it's close. Again I won't have time for a little while but it seems like it'll be the quickest way to make it work properly. https://sd2iec.de/

JimDrew
12-05-2017, 12:57 AM
Yeah, something like the SD2IEC would work for a lot of cracked programs, but that's all. Demos, and a lot of programs use custom loader routines.

gothmag
12-05-2017, 01:41 AM
Demos on the Amiga were cool, the commodore I could pass on. M.U.L.E. Is an actual disk image, do you have an example of something that you don't think would work? I've got everything on sd2iec. No disks at my house though.

JimDrew
12-05-2017, 06:14 AM
M.U.L.E was copy-protected and used with EA's custom sector loader. The disk image you have of it is a crack. Anything that works on the SD2IEC has to use the standard loading routines (no block reads or custom disk format), which means they are all cracks if they work.

itec
12-05-2017, 06:58 AM
I think I will end up with a less compatible implementation than the sd2iec that loads incredibly quickly. I won't do all the extra copy protection sectors in the d64 format or other image formats with additional tracks/BAM, GEOS etc

Directory listing is now complete and I am just starting to test loading of prg files from the D64. I haven't looked at SEQ files yet.

I am also looking at the new internal sd2iec with the teensy64 as an option. I am not sure if I could power it from the 5v on Frank's board though.

defragster
12-05-2017, 08:13 AM
Are you looking at this one - or one like it? : https://www.ebay.com/itm/Internal-fit-SD2IEC-Commodore-1541-Disk-Drive-Emulator-SD-Card-Reader-C64-Vic20-/232564602479?hash=item3625ee366f

I was there yesterday [ebay reminded me today] and the sd2iec I got is no longer available so I can't link the page - it was $25 not $45 - and shipped for $5 less to US. What Frank tested against in pic below. I didn't wire mine up yet. I assume that runs from PCB's 5V. That was the goal in that jumper block (drawing linked below).

That one above doesn't show power used - Fed from USB, the PCB should get most of 500 mA. With ~190 used for the base unit - maybe more depending on USB_Host. From a USB passing more, the T_3.6 may have enough? I just clocked the ILI9341 at 187mA with display at BASIC screen with wireless USB connected - did not catch a change doing a DIR load "$" of onboard SD.

Linked board isn't labeled - but I assume it wants 5V - if taken off a 5V VIN pin (https://forum.pjrc.com/threads/46168-Commodore-C64-Emulation-on-a-Teensy-3-6-Microcontroller?p=152626&viewfull=1#post152626) that will bypass the regulator and pull 5V from there for whatever it is worth.

12140

itec
12-06-2017, 05:16 AM
Some more progress on the D64 disk images. I need to take in to account a few things like wildcards, secondaryAddress, SEQ files and then do the write code.

Looks like it is going to work with the same restrictions as SD2IEC but much faster and less compatible.


https://www.youtube.com/watch?v=ulIOVZd5xvk

itec
12-06-2017, 05:26 AM
@defragster
I have this one on the way: https://www.thefuturewas8bit.com/sd2iec-classic.html

It looks like I could squeeze that in pretty easily and have a slower but more compatible drive as an option. It will be handy for testing if I end up finishing the code.

I asked the manufacturer about the power requirements for the sd2iec and they pointed me to a page for hooking vias on the c64 motherboard for power.

I'll measure it when it arrives and hope that there is headroom on the teensy64. If not it will require a separate usb for the sd2iec drive or a change to a 5v plugpack I guess.

Robin
03-25-2018, 04:19 PM
This project went up on the blog today. :)
https://www.pjrc.com/commodore-c64-emulator/

PaulStoffregen
03-25-2018, 11:19 PM
Gave it a shout-out just now on social networking.

https://twitter.com/PaulStoffregen/status/978046812538904576

https://www.facebook.com/paulstoffregen/posts/1628873627201534

https://plus.google.com/113416559182515729363/posts/LbVtDYbV2u6

Frank B
03-26-2018, 08:50 PM
Robin, Paul, thank you.


@all: I took a break for some time.
I have received private messages and emails which I will probably answer next weekend.


The development continues (of course).

PaulStoffregen
03-29-2018, 12:43 PM
Hackaday covered it today. :)

https://hackaday.com/2018/03/28/emulating-a-complete-commodore-64/

gothmag
03-29-2018, 07:43 PM
Cool some hackaday coverage! I'm in for 2 VGA boards when they're ready. Unfortunately I've had another hw/sw project hat is taking much longer than expected so haven't had a chance to do much other than put jiffydos on mine. Glad to see you're back Frank.

defragster
03-30-2018, 03:09 AM
Check with Frank if the 'v0.3 Teensy VGA' boards are good to go. I've got kit parts.

Cyb3rn0id
03-30-2018, 12:46 PM
Hi, I'm interested in this project. I work with microcontrollers from years and I'm a Commodore64 lover. How can I obtain a complete kit?

zonkt
04-01-2018, 08:36 AM
Hi, I'm interested in this project. I work with microcontrollers from years and I'm a Commodore64 lover. How can I obtain a complete kit?

Same here :) The Teensy board I know where to get and with a component list, the rest is easy to buy locally. Except for the base board (Frank's design right?). I would love to put something like this together. The version with a small LED-display is an awesome way to get a small portable game play device for the car :D

defragster
04-01-2018, 08:56 AM
gothmag already got the LED board and now is interested in the VGA board.

I have part kits for both to US ship with PCB's - PM Frank if interested - he was shipping outside US.

Cyb3rn0id
04-01-2018, 10:21 AM
Yes, I've sent an email to Frank. Hope I'll get an answer soon

Frank B
04-01-2018, 07:18 PM
Yes, I've sent an email to Frank. Hope I'll get an answer soon

Yes, Tim and I will contact all of you.

defragster
04-01-2018, 08:08 PM
I sent out three PM's - if in the US and interested send me one.

To answer question I got about what is needed having the kit ...

All the parts and connectors needed to populate the PCB to install your T_3.6 are included.

For the LED version it needs an ILI9341 - like from PJRC.com. For the C64 VGA it takes a compatible VGA display to work with.

From Frank's notes - Additional Parts needed:
SD Card
Screws
USB Keyboard
C64-Compatible Joystick(s)
Active Speakers (PC Speakers) – DO NOT CONNECT HEADPHONES

zonkt
04-02-2018, 08:33 AM
I'll send you a PM Frank... :)

Cyb3rn0id
04-05-2018, 08:50 AM
The stick I got for my Aiie box is not bad. About the right size for me, seems pretty solid but feels a bit cheap.

11904

Hi, this setup looks like I thought to make: add some buttons for simple Load/run/reset/directions without attach a real usb keyboard in order to make an all-in-one portable device. Can I have more info about keyboard you've implemented? You've used GPIOs?

Frank B
04-05-2018, 08:15 PM
If you want an own keyboard, perhaps the easiest way, without modifiying the T64 sourcode involves using a Teensy LC in keyboard mode connected via USB to the T36. But I've not tried that so far.

Cyb3rn0id
04-06-2018, 06:16 AM
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

Frank B
04-06-2018, 06:50 AM
See https://github.com/FrankBoesing/Teensy64/blob/master/extras/docs/T64_PinMapUse.txt for used pins. Others are unused. For VGA, please have a look at the sources, or wait for an update of this file in the next days..

Cyb3rn0id
04-06-2018, 07:33 AM
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?

defragster
04-06-2018, 07:44 AM
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.

zonkt
04-11-2018, 07:09 AM
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...

13560

zonkt
04-13-2018, 09:25 AM
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:


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_5 89447/sketch/defs.h" "-IC:\Users\user1\AppData\Local\Temp\arduino_build_5 89447/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\USBHos t_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_58 9447\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_5 89447/sketch/defs.h" "-IC:\Users\user1\AppData\Local\Temp\arduino_build_5 89447/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\USBHos t_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_58 9447\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\USBHos t_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.

Theremingenieur
04-13-2018, 11:34 AM
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().

zonkt
04-13-2018, 03:20 PM
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.

zonkt
04-13-2018, 06:38 PM
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:


https://www.youtube.com/watch?v=EtQGdxxXEfE

https://www.youtube.com/watch?v=Mu0sFQLgedc

zonkt
04-14-2018, 10:30 AM
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)

Cyb3rn0id
04-15-2018, 09:43 AM
Hi,
I'm trying to compile but I've error about "Ctags pattern" is missing

Cyb3rn0id
04-15-2018, 10:02 AM
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?

Cyb3rn0id
04-15-2018, 10:14 AM
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\Teensy 64\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\Teensy 64\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\Teensy 64\Teensy64.cpp:238:2: error: #error Teensy64: Set AUDIO_BLOCK_SAMPLES to 32

#error Teensy64: Set AUDIO_BLOCK_SAMPLES to 32

^

Cyb3rn0id
04-15-2018, 10:24 AM
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\Teensy 64\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\Teensy 64\keyboard_usb.cpp: In member function 'void c64USBKeyboard::LEDS(uint8_t)':

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

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

^

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

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

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

^

Cyb3rn0id
04-15-2018, 12:14 PM
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

zonkt
04-15-2018, 02:20 PM
Sorry my mistake, I've copied platform.txt in the wrong path.

Yes, the new platform.txt should be placed here (after installing the teensyduino package https://www.pjrc.com/teensy/td_download.html ):

C:\Program Files (x86)\Arduino\hardware\teensy\avr\platform.txt

zonkt
04-15-2018, 02:24 PM
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.

Theremingenieur
04-15-2018, 05:09 PM
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.

Frank B
04-15-2018, 06:30 PM
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:


https://www.youtube.com/watch?v=EtQGdxxXEfE

https://www.youtube.com/watch?v=Mu0sFQLgedc
I'm still working on an update :)

p.s. and yes, just remove the prints, fow now..

Cyb3rn0id
04-17-2018, 11:21 AM
All working. Display arrived. I've a defect: two vertical white lines on the right. Is it normal or my display is defective?

zonkt
04-17-2018, 12:18 PM
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:


https://www.youtube.com/watch?v=r-uBWE8QSrY

Cyb3rn0id
04-17-2018, 02:09 PM
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

Cyb3rn0id
04-17-2018, 02:22 PM
@Zonkt you've mounted the female strip wrong side. I've made same error, then I've desoldered and soldered to back side

Cyb3rn0id
04-18-2018, 07:09 AM
Dragon's Lair II - Escape from Singe's Castle - from IEC - stucks at second stage (ye olde whirlpools)

zonkt
04-18-2018, 09:35 AM
@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.
13618 13619

Frank B
04-18-2018, 07:55 PM
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
@others do you have this problem, too?


Sometimes screen initialization fails: screen is shifted
might be your display, or a connection problem.
The display-spi ist very fast, pls connect it directly to the board - no cables!

Frank B
04-18-2018, 07:59 PM
I ordered 3.2'' SPI ILI9341 display in China, I am very curious if it works.

zonkt
04-19-2018, 08:21 AM
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 :) )

Cyb3rn0id
04-19-2018, 09:39 AM
-
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.

Cyb3rn0id
04-20-2018, 12:46 PM
I ordered 3.2'' SPI ILI9341 display in China, I am very curious if it works.

Are the ones with the 40-pin connector?

ron2way
04-21-2018, 01:46 AM
can someone post a hex file for the vga version. I have assemble the board and would like to test it. TIA

ron2way
04-21-2018, 03:00 AM
can someone post a hex file for the vga version. I have assemble the board and would like to test it. TIA

Disregard the request for the hex file. I was able to get the board working.

defragster
04-21-2018, 06:25 AM
Disregard the request for the hex file. I was able to get the board working.

Good work!

Frank B
04-22-2018, 07:28 PM
Are the ones with the 40-pin connector?

This one:
https://www.aliexpress.com/item/3-2-inch-TFT-LCD-Module-without-Touch-Panel-ILI9341-Drive-IC-240-RGB-320-SPI/32859744548.html

itec
05-03-2018, 08:49 AM
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.

13729
13730

tonton81
05-03-2018, 08:59 AM
that looks great, would be nice to have a smaller one for portable handheld gaming (sorta like gameboy) hehe

Frank B
05-03-2018, 05:48 PM
@itec: Great ! Can you do a pullrequest?

itec
05-09-2018, 02:06 PM
@Frank B: Pullrequest completed.

itec
05-09-2018, 02:18 PM
@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
05-13-2018, 08:22 PM
@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!

Jean-Marc
06-04-2018, 06:19 PM
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

defragster
06-04-2018, 07:26 PM
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.

Jean-Marc
06-04-2018, 08:07 PM
Hi,

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

my username "Jean-MarcHarvengt"

J-M

defragster
06-04-2018, 08:11 PM
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.

Jean-Marc
06-04-2018, 09:27 PM
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"

defragster
06-04-2018, 10:11 PM
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.

Jean-Marc
06-05-2018, 07:14 PM
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

audioengineer
07-06-2018, 12:24 AM
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.

alan242
07-07-2018, 09:27 PM
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:



//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:
14152

Now I'm tempted to try to port the PI1541 over to a Teensy 3.5 too...

defragster
07-08-2018, 03:24 AM
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!

Mike Chambers
07-13-2018, 03:31 PM
Impressive work! This really shows off what the Teensy is capable of.

I also noticed when I look at the code, that your CPU core is based on the 6502 emu I wrote some years back. Nice to see it making the rounds.

kuumn
07-14-2018, 04:01 PM
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 (https://bestmultimeterreviews.org/fluke-87v-review/) this SX64-II on the case.

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

13729
13730

I am also thinking to made one. Just gathering basic stuff now.

defragster
07-26-2018, 05:23 AM
Here is a zipped set of build notes from Frank_B as DOC files : 14279

JimDrew
08-09-2018, 06:23 AM
Hi gang! I am going to do a presentation on the Teensy64 at the Commodore Retro eXpo (CRX) event in a couple of weeks. See: www.crxevent.com

Has there been any progress made on making this NTSC compatible? That is a huge issue for us in the U.S. as basically none of the U.S. games work in PAL mode.

Also, I see that J-M made a neat addition with the virtual keyboard, but his github reports as being 3 commits ahead. Is there an executable of the latest build?

Thanks!


Jim

Jean-Marc
08-20-2018, 06:38 PM
Did someone test the touch screen support code on the real Teensy64 hardware?
https://github.com/Jean-MarcHarvengt/Teensy64

In the meanwhile, I ported few other game console emulators (on my modified pinout!) but it should not be too difficult to have them running on the Teensy64 hardware board
https://github.com/Jean-MarcHarvengt/TeensyCEC

Retro_Peter
09-17-2018, 02:35 PM
Hi, has anybody a leftover Teesy64 (LCD) Version for sale ? I tried to retrieve one from Frank, but he didn't answer for months ...

Frank B
09-17-2018, 03:09 PM
Hello, everybody,
I (really) needed a long, relaxing break.


I still have some circuit boards, but I think that due to the customs duties only the shipping within Europe makes sense.


With time I will surely finish long announced c64-updates (esp. VIC)


Please excuse my long, unannounced absence.

@Retro_Peter, bitte sende mir eine Mail.

Frank B
09-17-2018, 03:14 PM
If there are open questions about this other of my projects or libraries, please don't hesitate to ask again.

Edit: I've disabled the PMs, so please use eMail (there's a link in my profile)

Frank B
09-19-2018, 06:19 PM
Hm trying to compile with Arduino 1.8.7 and Teensyduino 1.44 shows this Error(?) (or warning?) :
Error while detecting libraries included by C:\Users\Frank\Documents\Arduino\libraries\Teensy6 4_new\Teensy64.cpp

...trying to find the reason (Is anyone familiar with this message?)

itec
09-20-2018, 06:48 AM
>Error while detecting libraries included by C:\Users\Frank\Documents\Arduino\libraries\Teensy6 4_new\Teensy64.cpp

Is it just a typo? "\Teensy6 4_new\" has an extra space in it.

defragster
09-20-2018, 06:54 AM
>Error while detecting libraries included by C:\Users\Frank\Documents\Arduino\libraries\Teensy6 4_new\Teensy64.cpp

Is it just a typo? "\Teensy6 4_new\" has an extra space in it.

That 'space insertion' shows regularly on Forum posted paths for some reason

@FrankB - there was some change in Library parsing or limiting of old libraries that resulted in some errors. It was one of the fixes just put in the IDE - it may be catching something in the C64 build? Paul pointed to the 'arduino_debug.exe' versus starting 'arduino.exe' that might shows some added feedback?

Frank B
09-20-2018, 05:49 PM
That 'space insertion' shows regularly on Forum posted paths for some reason

@FrankB - there was some change in Library parsing or limiting of old libraries that resulted in some errors. It was one of the fixes just put in the IDE - it may be catching something in the C64 build? Paul pointed to the 'arduino_debug.exe' versus starting 'arduino.exe' that might shows some added feedback?

Indeed, the additional space was inserted by vBulletin.
arduino_debug.exe shows no additional output.
Well, it seems to work, so it might be a warning - but, funny is, I'm the only one who gets this message. Google knows nothing, and shows this thread only...

defragster
09-20-2018, 07:17 PM
At least it builds and works.
Would have been nice to see added info from _debug. Here is the recent thread where that was noted (https://forum.pjrc.com/threads/53574-Teensyduino-1-43-Beta-2?p=186138&viewfull=1#post186138) with regard to the library issue that came up.

zonkt
10-30-2018, 08:43 AM
I'm yet to finish the little box for my Teensy64 (with LCD), but the other day I got this thing from a fellow C64 nerd :) Just as an inspiration of what can be done. An original casing and with Raspberry Pi as a central unit, Arduino (for the built in emulator menu and operating system) and a keyboard/joystick interface board etc. I guess the same thing could be done with the VGA version of Teensy64 - even though the small size really should be taken in consideration and be used as an advantage (not put inside a big and bulky C64 case :D ).
1505615057

Jeff Pearson
11-20-2018, 04:33 AM
Awesome. My second computer was a C-64. First was a Vic-20. Miss the old thing at times this is something I am interested in ..

Frank B
11-21-2018, 07:14 PM
@zonkt: wow this is awesome. can you post more pictures?

@all: The T3.36 has not headroom for significant improvements regarding the VIC and other low-level things. I tried, but wasn't successful. There is a slight chance when we overclock to 256MHz- but we will soon reach new limits.
Currently, my plan is a transition to the comming T4 which will be _much_faster and has more ram. Maybe we can use a better display, too.
My plan is a board that supports other emulators, too, or maybe has small joysticks on board, and a small speaker and allow headphones.

tonton81
11-21-2018, 07:19 PM
pocket sized N64 with Super Smash Bros! :)

zonkt
02-01-2019, 08:34 AM
@Frank B: Haven't been logged in for quite some time :)

Yes, sure. I can take a few pictures close up and post here. It's a very neat installation that allows for original joytsticks, a separate USB keypad for easier access in menues etc and an HDMI port to connect to a tv set or computer screen. I think the IEC interface works as well, but haven't tried it yet.

Tom Eilers
02-01-2019, 11:54 AM
for zonkt some pictures 15796

zonkt
02-05-2019, 04:43 PM
1583015831158321583315834
1583515836158371583815839

From top left to bottom right:
1. Overview of the internals inside an old Commodore 64 box with original keyboard.
2. The RPi menu button, to access disk images, settings, network etc. The network connector (this RPi is older and without wifi) and the serial interface.
3. HDMI port and a setup of USB connectors.
4. Joystick ports and power connector.
5. Closer overview of Arduino and power board.
6. Joystick and keyboard interface.
7. Backside of ports.
8. Arduino to facilitate the menu system.
9. Main board RPi with Pi64 emulator.
10. Power distribution board.

Loaded on the SD memory is a complete Linux system with the emulator software and disk images with games and software for the C64...

Frank B
02-05-2019, 05:18 PM
This raspberry is wrong there... ;) It should be a teensy..

zonkt
02-05-2019, 06:48 PM
This raspberry is wrong there... ;) It should be a teensy..

I know... but that┤s easy to fix right? :D Or perhaps even both - there┤s plenty of space in that box.

Jean-Marc
02-13-2019, 06:22 PM
Hi Frank,

I was so inspired by your great work that I decided to port part of your code to my latest project.
I hope you have no objection.
https://github.com/Jean-MarcHarvengt/espMCUME
Via this new project I would like to port the emulators in TeensyCEC to more MCU platforms in future (I hope the Teensy3.6 followers too!)
I posted a video today, have a look at the project.

J-M

Unilein
09-11-2020, 08:48 AM
Hi Frank,

is it still possible to get such a Teensy64 Kit?

Frank B
09-11-2020, 09:12 AM
Hi Frank,

is it still possible to get such a Teensy64 Kit?


I have to look there.
I've moved, and all the stuff is still in boxes.


I'll probably have time on Sunday.