Skip to content

Mega65 emulation how to start

LGB edited this page Sep 6, 2019 · 1 revision

Download/install/compile Xemu

You probably want to visit this link: http://xemu-dist.lgb.hu/ It has got pre-built binaries for Ubuntu Linux (in the form of a DEB package for 18.04 LTS 64 bit, may work on later versions too), Windows (either 32 bit or 64 bit, but unless you have a 32 bit Windows, you really want the 64 bit).

If you want to compile Xemu yourself, you can read the README file of Xemu itself: https://github.com/lgblgblgb/xemu and scroll a bit downwards. Note, compiling Xemu for Windows still needs Linux (only to compile, not later for use it!) though WSL (Windows Subsystem for Linux) can be enough for this purpose (available for free in the Windows Store, I believe). Technically, Xemu should be fine with MacOS too, however that is not so much tested. On MacOS you must compile yourself, since there is no easy way to provide pre-compiled version, since Apple would force me to buy a Mac to do it, why I can use only free software to do a cross-platform build for Windows at least.

The goal here, that you have the executable for Xemu Mega65 emulation which can be started, even if it does not work at this point, complaining about missing SD-card image.

Executable names for Xemu/mega65:

  • xemu-xmega65 on Linux, if you use the DEB package
  • build/bin/xmega65.native on Linux (relative to the project root) if you compiled Xemu yourself
  • build/bin/xmega65.win32 (or .win64) if you build for Windows but on Linux (relative to the project root). In this case you can rename that file to .exe file, and move it to the Windows filesystem, altogether with the SDL2.dll file, which is needed

Learn where your preference directory is

On windows, start xemu/mega65 with syscon enabled to remain open, so you must use the -syscon command line switch. So you probably need to run xemu from console. On Linux, open a terminal, and start xemu/mega65. On Linux, you already have a terminal functioning as console too, so you don't need the -syscon parameter. You can see a line something like this:

SDL preferences directory: /home/lgb/.local/share/xemu-lgb/mega65/

The exact path given is heavily system/OS/version dependent (created by the SDL2 library), that's why you should find yourself, for your system.

This directory holds/will hold various files needed for the emulation, that's why it's important to know where it is. Generally speaking, you may not need this in the future if all the preparation works are done already.

Create the SD-card image

If you try to start Xemu/mega65 emulation at the first time, you'll get an error window about the missing SD-card image file. Mega65 is designed "around" an SD-card, even the ROM is loaded from there, so you can't live without that. In case of an emulator, it means an image file of an SD-card, not an actual SD-card though.

Xemu should automatically provide you to create an SD-card image file, thus you don't need to deal with this step too much at least. You must pick a size, though.

Format the "SD-card" (... image file)

At this point, you must rely on the Mega65 built-in software already! After creation of the SD-card image file. Starting Xemu/Mega65, you should see a kind of selection menu, providing at least two options: configure system, and format the SD-card. Surely choose the SD-card thing by pressing the right number key for that function. Now you are in the FDISK utility of the Mega65, which is the identical version you would see on a real Mega65, as it's already its own software running, it's not done by Xemu itself.

What you should see is a bunch of messages, then a warning, that everything will be deleted. You must confirm this, by typing exactly DELETE EVERYTHING (at this point, there can be a little bug, if you mistype it ...). FDISK will partition and format the "SD-card" then.

After FDISK confirms it's done, you can even exit Xemu/Mega65 and re-start it. What you should see, that system is not ready yet, complaining (even maybe continaully) about the missing ROM. It's natural, and it's the way a real Mega65 would behave as well.

Put the needed files onto the "SD-card" (... image file)

This part is a really bit scratchy. The main problem is about the ROM, which is a copyrighted material, not so much easy to be distributed by Xemu automatically, neither by a real Mega65 for the very same reason. On a real Mega65 at this point, you should remove the SD-card from it, put it into a PC, and copy the needed files onto it. However, since there is no real SD-card in case of Xemu/Mega65, in our case you must deal with the SD-card image itself. Now, it's important to know where is your image file, so the reason it was important to learn where your preferences directory is. The SD-card image file will be in that directory, with the name mega65.img. Basically you must find and use a tool capable of handling an image of a partitioned block device (as you can imagine, that file is corresponding to a dump of an SD-card).

First, download the needed files. BEWARE: this can be a legal issue, to download a copyrighted material, so do it at your own risk. Visit Mega65 github site https://github.com/MEGA65/mega65-core and scroll down. Follow the instructions there to have your MEGA65.ROM and CHARROM.ROM files.

IMPORTANT: capitalize file names at this point! It may be irrelevant on Windows for most users, but there can be problems on the SD-card file if you don't do that in case of very OSes, thus Linux/etc is involved too.

You also need a D81 image. Grab something you like. You should have one though, whatever it is, since Xemu/Mega65's feature to "mount" and D81 later would require to have something on your SD-card, since it can be overridden then (no, the D81 on the SD-card won't change because of that), if there is no MEGA65.D81 file on your card image, it won't work. So, it's important to name that file as MEGA65.D81, again, all capitalized letters only! Also, MEGA65.D81 on your SD-card is automatically put into use as your disk in Mega65, unless you override that with an external source in case of Xemu/Mega65.

The basic goal now, to put these files MEGA65.ROM CHARROM.ROM and MEGA65.D81 onto your card image file. This is somewhat problematic, since I can't mention any Windows tool (I'm not a Windows user at all), some may suggest something for me, to include into this HOWTO file :)

On Linux, you can probably just mount that via the loop mount device. However, since it's a partitioned media, it's not that easy. Fortunately there is an easy way, with using the losetup command line utility.

Future

This is really an impractical start for many users, being to complicated. In the future, I plan to use a more automatic method to do all the preparation works, except that the needed copyrighted ROM still depends on a manual user interaction, but Xemu will help to place that on the SD-card image as well, though.