Mega65 a modern retromachine: first contact through the emulator

Some years ago I found by accident the Mega651, a new 8-bit computer, the succesor of the never released Commodore C65. In fact this machine is based on Commodore C65 prototypes and its ROM was based on that of the original C65, which logically contained many bugs yet to be fixed, as it was only a prototype still in development.
This computer uses an FPGA and, besides being an enhanced Commodore C65, it offers C64 compatibility both through the Mega65's own core, which replicates the compatibility layer the Commodore engineers originally planned to include in the C65, and through a dedicated core that fully emulates the C64. Currently there are other cores too like one of a ZX Spectrum and another of a Gameboy.
A few days ago, I remebred this project and I wanted to take another look at it to see how it had evolved. I found out that besides BASIC and Assembler, now it could be programmed with C and there is also a PASCAL environment available. I also noticed there was an emulator called Xemu2 so I decided to install it and check out the Mega65.
Installing and setting up Xemu
You can find the source code of Xemu on GitHub3, but the developer provides several packages4, including one for Ubuntu that works perfectly on my Devuan GNU+Linux system. I downloaded and installed it.
As usual, the emulator requires the system ROM. I followed Xemu's official docs5 and everything worked flawlessly. The process is not difficult but it does require some work on our part. First I obtained the Commodore C65 ROM searching for 910828.bin on the internet. Then I downloaded the Mega65's ROM changes from the official files site6 (search for BDF).
Once I had all the files I patched the C65 ROM with Mega65's changes. I installed bsdiff and then I used the command bspatch which is part of bsdiff.
sudo apt install bsdiff
bspatch 910828.bin new-920364.bin 920413/920413.bdf
910828
is the C65's original ROMnew-920364.bin
is the name of the patched ROM920413/920413.bdf
are the Mega65's changes
With the ROM and the emulator installed I launched the emulator and said YES when the program asked if it should generate the initial virtual SD Card, etc. You can launch it from your DE menu or from your cli with the command:
xemu-xmega65
To load the ROM I right clicked on Xemu's screen and then I chose "Disks" -> "SD-card" -> "Update files on SD image". Then right clicked again on Xemu's window and I chose "Reset/ROM Switching" -> "Reset". After that I got the emulator working.

Checking out and enjoying the Mega65
Next thing I did was to get the offical docs in order to see how to do basic tasks on the system. I also did a few BASIC, basic tests ;), and I downloaded and played the game "Meteor Defense" to check out if the emulator was working. You can get the official docs, games and more from the official Mega65 files site (check out the footnotes).

After playing with the game I decided to write a bigger program in BASIC, so I typed the program "Monster Chase" from the book Stimulating Simulations by C. William Engel7. I run the program, saved it to a virtual disk image, reload it from the virtual disk and run it again.
The game worked flawlessly and I must confess I really enjoyed the experience of typing a game in BASIC from a book to play with it. Although this might seem like a joke nowadays, back when I started with computers in the 80s it was very common, and I doubt anyone who hasn't gone through this ritual can truly understand or appreciate it.

After checking everything out with BASIC, I installed the llv-mos8 compiler on my system to cross-compile a C program for the Mega65. llvm-mos has a target for the C64, mos-c64-clang, but it also has a specific target for the Mega65, mos-mega65-clang. Sadly things didn't work out as expected.
Compiling the program for the C64 and runnig it on the emulator using the Mega65's compatibility layer for the C64 worked like a charm, but compiling the program for the Mega65 and running it under the Mega65 regular mode it crashed. I didn't know if it was something related to the compiler or the emulator.


Final thoughts
I have mixed feelings about this machine since the price isn't exactly low, and the fact that such a simple program written in C didn't work discouraged me quite a bit. However, I'll keep an eye on the project's progress. In the meantime, I will continue enjoying it through the emulator.
Who knows what surprises this machine might hold in the future!