MJoergen / C64MEGA65

Commodore 64 core for the MEGA65 based on the MiSTer FPGA C64 core
GNU General Public License v3.0
30 stars 4 forks source link
c64 commodore64 fpga mega65 retro retro-gaming verilog vhdl

Commodore 64 for MEGA65

Experience the Commodore 64 with great accuracy and sublime compatibility on your MEGA65! To get a glimpse of what the C64 core can do for you, watch this trailer on YouTube. Go to the MEGA65 Filehost to download the most recent version 5.1 of the C64 core. If you are in a hurry or have issues, read the FAQ - Frequently Asked Questions. If you are a developer and want to build the C64 core by yourself then head to our developer documentation. You can also learn more what's new in Version 5.1. Otherwise, scroll down and enjoy the user's manual.

Commodore64

This core is based on the MiSTer Commodore 64 core which itself is based on the work of many others.

MJoergen and sy2002 ported the core to the MEGA65 in 2022 and 2023.

The core uses the MiSTer2MEGA65 framework and QNICE-FPGA for FAT32 support (loading ROMs, mounting disks) and for the on-screen-menu.

Brand new and very comprehensive user's guide

Head over to c64.mega65.org to read the brand new and very comprehensive user's guide for the C64 core.

Features

With our Release 5.1, we are striving for a retro C64 PAL experience: The core turns your MEGA65 into a Commodore 64 with a C1541 drive (you can mount *.d64) images. It supports the following hardware ports of the MEGA65:

Additionally, the C64 for MEGA65 core can simulate a 1750 REU with 512KB of RAM, it can simulate cartridges (by loading *.crt files) and it offers a Dual SID / Stereo SID experience.

The C64 runs the original Commodore KERNAL and the C1541 runs the original Commodore DOS, which leads to authentic loading speeds. You will be surprised, how slowly the C64/C1541 were loading... :-) You can optionally install JiffyDOS or use fast loader cartridges to speed up loading.

And you will be amazed by the 99.9% compatibility that this core has when it comes to games, demos and other demanding C64 software. Some demos are even recognizing this core as genuine C64 hardware. And even things like using a fast loader cartridge while connecting a genuine 1541 via IEC are working flawlessly.

Video and Audio

Our philosophy on the MEGA65's outputs is that VGA is the "pure" retro-output (and you can also switch it to 15 kHz and composite sync for a true retro feeling) while HDMI is the "processed" modern output. So there is no "processing" such as CRT emulation and other things on the VGA output, while on the HDMI output several algorithms are working for a very nice looking authentic image.

Important: If you use VGA displays or analog retro monitors, please switch off "HDMI: Flicker-free" as described here.

Convenience

Constraints and Roadmap

Our Release 5.1 is a mature release. Thanks to all the folks who contributed to the core, it is incredibly compatible to an original Commodore 64. With our Release 5.1 you can play nearly all the available games and watch almost all demos ever written for the C64. You can plug nearly every hardware cartridge ever made for the C64 into the MEGA65's expansion port and enjoy working/playing with it and you can work with any IEC device (retro devices such as original 1541 or 1581 drives, printers, plotters and modern devices such as the SD2IEC and the Ultimate-II+). It happens more often than not, that the core is recognized as real hardware by software.

Yet, at this moment, our MEGA65 version of the MiSTer core is still lacking some nice features such as:

And there is much more. Have a look at our Roadmap to learn what we plan to do in future.

Since we do this as a hobby, it might take a year or longer until these things are supported. So please bear with us or help us.

Some demo pictures

c64-1 c64-2 c64-3
Core Menu Disk mounting / file browser Giana Sisters
c64-4 c64-5 c64-6
Censor Design & Oxyron: Comaland Robot Jet Action A Pig Quest

Clarification: These screenshots are just for illustration purposes. This repository does not contain any copyrighted material.

Installation

  1. Download the ZIP file that contains the bitstream and the core file and unpack it.
  2. Choose the correct .cor file for your MEGA65 model: Please be aware that there are multiple MEGA65 models out there and that each .cor file only works with the model that it was built for. So in case you are not sure, what R3/R3A, R4 and R5 means and which model you have, head over to the model documentation to learn more.
  3. Copy the .cor file on an SD card that has been formatted using the MEGA65's built-in formatting tool. If you want to be on the safe side, just use the internal SD card (bottom tray), which is formatted like this by default.
  4. Read the section "How do I install an alternative MEGA65 core?" on the alternative MEGA65 cores website or read the section "Bitstream Utility" in the MEGA65 Starter Guide.
  5. The core supports FAT32 formatted SD cards to mount .D64 disk images for the C1541 at drive 8.
  6. If you put your disk images into a folder called /c64, then the core will display this folder on startup. Otherwise the root folder will be shown. If you want the core to remember the settings, make sure you read the section Config file below.
  7. Optional: Install JiffyDOS and install the Real-Time-Clock (RTC) driver for GEOS.
  8. Press the Help key on your MEGA65 keyboard as soon as the core is running to mount disks and to configure the core.

Config file

If you want the core to remember the settings you made in the on-screen-menu, then make sure that you copy the config file into a folder called /c64. This /c64 folder needs to be located in the root folder of the SD card that is active when you boot the core. The config file is called c64mega65 and is located in the ZIP file that you downloaded from the MEGA 65 filehost.

The very first time you start the core after you copied the c64mega65 config file into the /c64 folder, it will detect the new config file and present you with factory default settings when you press Help to open the on-screen-menu. After that, the core will always save the settings when you close the on-screen-menu and remember them when you restart the core at a later time.

Important: If you change the SD card, for example by using F1 or F3 in the file browser or by physically changing or removing the card that contains your /c64/c64mega65 config file, then the core will not remember your newest on-screen-menu settings upon next start.

Important advice for users of analog VGA and retro 15 kHz RGB over VGA

It is highly recommended to switch off "HDMI: Flicker-free" when using analog VGA monitors or monitors that work with the "retro 15 kHZ RGB over VGA" signal.

Otherwise you might encounter strange visual effects that range from a blurry image over "underwater" blurry movement of your screen to sporadic flickers and sometimes to a complete loss of VGA sync every few seconds or minutes.

Learn more about "HDMI: Flicker-free" to understand why this is happens.

Using .bit files instead of .cor files

If you are a developer and/or have a JTAG adaptor connected to your MEGA65, then you can use the .bit file from the ZIP instead of the .cor file: Run the M65 tool using this syntax m65 -q yourbitstream.bit and the core will be immediately loaded into the FPGA of the MEGA65 and automatically started.

Using .bit files is very useful, in case you want to try out multiple cores or core versions quickly without going through the lengthy process of flashing .cor files.

HDMI compatibility

Right now, the C64 core is not compatible with all HDMI displays. If your display works with the MEGA65 core but stays black when you load the C64 core, then try this (while the display is black):

  1. Boot the C64 core and wait a few seconds.
  2. Press the Help key.
  3. Press seven times (7x) the Up cursor key.
  4. Press Return.
  5. Press five times (5x) the Down cursor key.
  6. Press Return.
  7. Wait a few seconds.
  8. If this does not solve the issue, continue:
  9. Press four more times (4x) the Up cursor key.
  10. Press Return.
  11. Wait a few seconds.
  12. If this does not solve the issue, continue:
  13. Press one time (1x) the Down cursor key.
  14. Press Return.

Explanation: DVI mode, 60 Hz mode, 576p

The recipe above first activates the "DVI mode" as you are choosing the menu item "HDMI: DVI (no sound)" in the on-screen-menu when you press the Return key for the first time.

In DVI mode, the HDMI data stream sent by the core to your display has a slightly different format and it does not contain any sound. You need to use the 3.5mm audio-out in this case.

When you press Return for the second time, the 60 Hz mode is activated, independent of the C64's output, which is still 50 Hz in PAL mode. This works fine in general, but leads to some flickering and jerky scrolling here and there.

The third press of Return switches from 720p to 576p.

Working with the file browser

Thanks to long filename support and alphabetically sorted file- and directory listings, using the file browser is straightforward. Press MEGA65's Help key to open the on-screen-menu while the C64 is running and either select 8:<Mount Drive>, PRG:<Load> or CRT:<Load> using the cursor keys and Return. Here is how the browser works:

Working with disk images

Mounting disk images

Currently, we support D64 disk images with 35 or 40 tracks (standard format, no error bytes). This covers 99% of all use cases. We do have support for additional D64 disk image variants and G64 disk images on our Roadmap.

Select 8:<Mount Drive> and use the file browser as described above to mount a disk image. Enter LOAD "$",8 and then LIST to list the contents of the disk image or enter LOAD "*",8,1 and then RUN to load and start most games.

Switching diskettes while a program is running

Sometimes a game, demo or application asks you to turn the disk (disks often had two sides back in the days) or to insert another disk.

To do this, open the menu using the Help key and select 8:<name-of-your-disk-image> using the Return key. Now browse and select the new diskimage and confirm again with Return. This will change this disk image while leaving the drive itself on and active and for the C64 core this looks like switching a diskette.

Unmounting disk images

An already mounted drive can be unmounted (i.e. "switch the drive off"): Select it in the Help menu using the Space bar. Do not unmount your disk image, if a program asks you to turn the disk or to insert another disk.

Writing to disk images

The C64 core supports not only reading from D64 disk images but also writing to them (and to the MEGA65's SD cards) so that you can save your gaming high-scores and play games that are able to save and restore the game's state. And you can now work productively with the C64 core on the MEGA65 for example by saving documents in GEOS or by saving your BASIC programs.

Important things to know about how writing to disk images works:

Directly loading *.prg files

A lot of games, demos and also SID tunes are available as "one-file" releases in the *.prg file format. You do not need to create a *.d64 disk image and add the programs to the disk image. Instead, you can directly copy them on your SD card and run them using the PRG:<Load> menu item.

IMPORTANT: Make sure that either one of the three following things is true:

The reason for this is: Before the core attempts to load a program into the C64's memory, it resets the core. This is for your convenience so that you can load multiple programs in a row. But since cartridges are also started via a reset of the core, the three options above make sure that no cartridge is active.

SID configuration / Dual SID / Stereo SID

6581 vs. 8580

The original Commodore 64 "only" had one SID. Older versions had a SID called 6581 and newer versions had a SID called 8580. Both were mono, there was no stereo capability available. This is why by default, the C64 for MEGA65 core starts with only one SID enabled, the 6581.

If you are an audiophile when it comes to SID music, then you always might want to choose the right SID for the game or demo or music release that you are running. The C64 core lets you select different SID versions and configurations in real-time while the program is running. As a rule of thumb you can assume that most games and demos since the year 2000 optimized their music and sound effects for the 8580 and most older games and demos were optimized for the 6581. Beware that this is a rule of thumb and many exceptions exist.

Pseudo stereo using a mixed dual SID setup

A dual SID setup utilizing a 6581 on the left stereo channel and an 8580 on the right channel (or vice-versa) creates a pleasant pseudo stereo effect for the C64 because each SID chip has its own unique tonal characteristics, producing a richer and more dynamic audio experience. This combination allows for a wider soundstage, resulting in an immersive listening experience that enhances the enjoyment of the classic C64 gaming and music content.

To setup this mixed dual SID configuration - which is still mono - go to the SID menu and select either L: 6581 R: 8580 or L: 8580 R: 6581 while in parallel selecting Same as left SID port in the Right SID Port section.

Stereo SID

True stereo SID is not widely supported on the C64. A few modern games (such as Super Mario Bros 64 by ZeroPaige), some demos and some music disks and specialized releases (such as the awesome Game of Thrones by Genesis Project) support true stereo using two SIDs. You can also browse the High Voltage SID collection for stereo SID releases.

IMPORTANT: Always configure one of the options under Stereo SID and additionally the correct Right SID Port in the SID menu to enjoy stereo SID music. What the "correct" port is depends on the software that you are running. If you are not sure, try D420 first.

512 KB RAM Expansion Unit (1750 REU)

Select Simulate 1750 REU 512KB in the Expansion Port menu. The 1750 512KB REU is as close to cycle accurate as it can go on a MEGA65. Remember, we are pretty constrained by the quirky HyperRAM. This means our REU is not perfect, but 99.9% perfect: It even runs the very picky TreuLove_ForReal1750Reu.d64 version of Booze Design's Treu Love demo (see CSDB page) that is supposed to only run on real hardware and also the absolutely awesome game Sonic the Hedgehog runs like a charme on the MEGA65.

Please feel free to browse CSDB's REU Releases and enjoy them on your MEGA65.

The REU also works perfectly with GEOS: Configure a RAM drive, copy the programs, fonts and file you want to work with on the RAM drive and enjoy a 10x acceleration of your GEOS workflows. Don't forget to copy the results of your work on a "real disk" (D64 data disk that you have mounted) before ending your GEOS session so that all your data is persistently saved to the MEGA65's SD card (see also the section "Writing to disk images" above).

The REU is switched off by default. You can switch it on using the options menu.

Compatibility advise: Only turn on the REU for software that is explicitly supporting the REU. Otherwise you might experience random crashes of otherwise very stable software. Explanation: The REU itself is 99.9% compatible so you can count on it. But the majority of C64 software does not support the REU. Some of the software even gets unstable, if you have the REU activated. The reason for this effect is, that when the REU is activated, certain addresses in the C64 memory space that are normally free to be used for the software are not usable any more. If it happens that this software needs to work with these addresses and a REU is installed/activated, then the software crashes.

Hardware cartridges

The MEGA65 sports an Expansion Port so that you can run most of your original retro C64 cartridges (games, freezers and other utility cartridges) as well as modern cartridges and flash cartridges.

Working with original retro cartridges and most modern cartridges is simple: Make sure that your MEGA65 is configured to use the hardware port by selecting Use hardware slot in the Expansion Port menu. Switch-off your MEGA65, insert the cartridge and then switch-on the MEGA65 and the cartridge starts.

Use the soft-reset to reset and/or start hardware cartridges. Do not use the hard-reset for hardware cartridges.

CORE #0 update (pre-2024 MEGA65s only)

If your MEGA65 was built before 2024, then you very likely need to update your so-called "CORE #0". This is the MEGA65 core that decides, which core is supposed to run when a cartridge is inserted. The original CORE #0 crashed when so-called "Ultimax mode" cartridges were inserted and therefore a lot of the games, utility cartridges and flash cartridges cannot be started when this old CORE #0 is installed.

You have two options when you own such a MEGA65:

  1. Update CORE #0 as described here

  2. Manually boot the C64 for MEGA65 core using the No Scroll mechanism and then insert your cartridge while the MEGA65 is switched on and while the C64 core is running and then press the reset button. While we cannot officially endorse this option - do it at your own risk - the MEGA65's hardware is way more robust than the original C64's hardware was, particularly when it comes to the Expansion Port. There are certain mechanisms in place that shield the inner guts of the MEGA65 from the Expansion Port. A lot of MEGA65 users have used this option for a while and until now, no damaged MEGA65 due to this workaround are known.

And if you are interested in the technical details about how your MEGA65 handles the whole multi core functionality during startup, then head to this MEGA65 Wiki article.

Flash cartridges, freezers and homebrew cartridges

IMPORTANT: Never insert a "naked PCB" into the MEGA65's Expansion Port!

As the name suggests: Flash cartridges allow you to flash certain *.crt cartridge files onto a hardware cartridge and then use them as if they would be "a real" cartridge. The C64 core supports a number of flash cartridges. You can flash some of them directly on your MEGA65. For your convenience, we recommend to use a large capacity IEC hardware device such as an FD-2000 or an SD2IEC so that you do not need to split your cartridges into multiple *.d64 disk images.

The C64 core also supports a number of freezers and some homebrew cartridges.

Please read the dedicated documentation for flash cartridges, freezers and homebrew cartridges to learn more.

Simulated cartridges

Cartridges can be simulated by loading *.crt files from your SD card. Use the menu item CRT:<Load> to do so and it will automatically switch the core from Use hardware slot to Simulate cartridge. The core will automatically reset and the cartridge is started. If you are simulating certain utility cartridges, you can now go ahead and mount disk images or load programs.

Simulated cartridges work great on the MEGA65. We successfully tested them with a lot of games and made sure that we also tested different cartridge types.

But since they are only "simulated", they can never be as glitch-free and accurate as hardware cartridges. We use the MEGA65's HyperRAM to store the data from the *.crt files when we simulate the cartridge. While this works very well in more than 99% of the cases, the constraints of the HyperRAM (for example its latency) can lead to undesired artefacts when playing simulated cartridges: We actually need to halt the CPU for a short period of time, each time the cartridge does a bank switch. Most of the time you won't notice due to smart caching mechanisms, but sometimes you might.

IEC devices

The C64 for MEGA65 core supports the MEGA65's hardware IEC port so that you can attach real 1541 & 1581 drives as well as printers, plotters or modern devices such as the SD2IEC and the Ultimate-II+. You can copy from virtual disks (*.d64) to real disks and the other way around.

IMPORTANT: The built-in simulated 1541 disk drive that works with *.d64 disk images is always drive #8. You need to make sure that any other disk- or hard-drive or SD2IEC that you are connecting to the hardware IEC port has the device number #9, #10 or #11 - but NEVER use #8. Learn more about the C64's device numbers here.

You need to activate the IEC hardware port by selecting the menu item IEC: Use hardware port. Only activate it if there is no clash of drive numbers. As soon as it is activated, it works nicely together with the built-in drive #8.

Also be aware, that when using a real C1541 drive, for some games you need to switch-off "HDMI: Flicker-free.

Commodore Kernals and JiffyDOS

Select the Kernal: Standard menu item to enter a sub-menu that lets you choose from multiple operating system versions that Commodore shipped back in the days: Besides the well-known Standard Kernal you can also choose the Kernal for the Commodore 64 Games System and the Kernal for the Japanese Revision. Please note that the core is being reset each time you switch the Kernal version.

JiffyDOS is a third-party disk drive operating system upgrade for the C64. It significantly improves the speed and efficiency of disk-based operations, allowing for faster file access and loading times. Additionally, it offers an array of convenient commands and features for enhanced disk management, without sacrificing compatibility with most existing software. Our core supports JiffyDOS for the built-in simulated "Drive #8" as well as for real devices that you attach via the IEC port as long as you have JiffyDOS installed on those devices.

Please note that JiffyDOS is commercial software and that you need to own an appropriate amount of licenses before you can use it on your MEGA65. Learn where to buy and how to install by reading our dedicated JiffyDOS documentation.

Flicker-free HDMI

When you use an emulator on your computer, you very probably will experience jerky movements on the screen and tearing effects because a lot of computer monitors are running at 60 Hz or higher while the Commodore 64 had a pretty odd frequency. Even if it would have been exactly 50 Hz, you would experience this on a modern computer using emulation, and imagine that: The C64 is closer to 50.125 Hz than to 50 Hz, so it gets even worse... As a reference, just start the legendary game The Great Giana Sisters on your favorite emulator on your computer and then watch the title scroller / intro. You will see a pretty stuttering scroller.

Not so when using an FPGA based recreation on the MEGA65 using the right display and settings. We have your back! :-)

You can switch "HDMI: Flicker-free" mode on/off at any time with no interference of your C64 experience. We recommend the following small test-case for you to experience the difference by yourself:

  1. Switch OFF "HDMI: Flicker-free" and load The Great Giana Sisters and watch the title scroller: Every approximately 8 seconds, you will see a jerky movement and tearing.

  2. Now while you experience this, switch ON the "HDMI: Flicker-free" mode and continue watching the title scroller: It will be buttery smooth.

  3. The same will happen when you play the game. And this effect is not only there at Giana Sisters but at everything that scrolls and/or moves a lot of things on the screen.

Summary: Modern HDMI displays can only display signals with screen refresh rates of 50 Hz, 60 Hz and other "even" frequencies. The C64 on the other hand outputs a very "odd" screen refresh rate that is closer to 50.125 Hz. This will lead to undesired jerky screen movements every approximately 8 seconds.

Compatibility

We are slowing down the whole system (not only the C64, but also the SID, VIC, C1541, ...), so that it runs at only 99.75% of the original clock speed of the C64. This does not decrease the compatibility of the core in most cases and you probably will never notice.

But the advantage of this 0.25% slowdown is a clean 50 Hz signal for your HDMI display. We believe that this is the most compatible way of providing a flicker-free experience on HDMI.

If you experience issues, then you can switch the core back to 100% system speed. The menu item for doing so is called "HDMI: Flicker-free". You can switch this ON and OFF in real-time without the need to re-load the program that you are currently running.

Our tests have shown, that the vast majority of software works like a charm and the value of having a completely smooth and flicker free experience on HDMI seems therefore larger than slight compatibility issues. This is why this feature is activated by default.

Switch-off when using retro analog display devices

While this works great on digital HDMI displays, there is a disadvantage on some analog VGA monitors: The 0.25% slowdown leads to a slightly off VGA signal timing which might lead to strange effects. This is why you should disable "HDMI: Flicker-free" when working with an analog monitor such as VGA or such as Retro 15 kHz RGB.

Switch-off when loading certain games via real 1541 hardware

The 0.25% slowdown is not a problem when you use the core with emulated 1541 hardware (i.e. using *.d64 disk images) because in this case the C64's CPU and the 1541's CPU are slowed down in parallel.

In contrast to that: If you use a real 1541 or other drive, then in some rare situations (for example games from Rainbow Arts which use a picky own fastloader) you will run into compatibility problems such as crashing games.

If you encounter incompatibilities when you load via real devices connected to the IEC port, then switch-off "HDMI: Flicker-free" mode.

But in this case we would advise you heavily to also use an analog retro monitor, because with "HDMI: Flicker-free" OFF, the output on HDMI will be slightly jerky due to the misalignment of the C64's retro output frequency and the frequencies that modern HDMI monitors are actually able to display.

Hard-reset vs soft-reset

If you press the reset button of your MEGA65 briefly, i.e. less than 1.5 seconds, you will do a soft-reset. A long press does a hard-reset. Here is the difference between the two:

There is another difference between the hard-reset and the soft-reset that is more related to your convenience while using the file browser and the options menu:

Tips for watching demos

The core has been tested rigorously with a lot of very demanding demos and the result is that it almost always "just works". So there are not a lot of tips for you when it comes to watching demos but two:

  1. Demos newer than the year 2000 tend to use the 8580 SID: You might want to switch to 8580 by default when watching these kind of demos.

  2. Some demos rely on the 8521 CIA instead of the 6526 CIA which is active by default. Currently we know for sure of one demo where this is the case: "XXX" by Lethargy.

    All other demos that we tested work fine with the 6526 CIA.