====== MEGA65 Prerelease Starter’s Manual ====== * Version 0.1 by Ralph Egas * Version 0.2-0.3 by Deft? Others? (via google docs) * Additional edits by wiki contributors (see edit history for authors) ===== - Prerequisites ===== ==== - Nexys(tm)4 DDR board ==== The MEGA65 is based on the Nexys(tm)4 DDR FPGA board from Digilent and carries an Artix-7(tm) Field Programmable Gate Array (FPGA) from Xilinx. This component is used to host MEGA65’s circuits like the GS4510 CPU, VIC-IV Video Controller and other circuits. Apart from the FPGA, the board sports various IO ports like VGA, USB, Ethernet, Mono audio and other connectors that will be used in the final MEGA65 design in an appropriate form factor. The board can be ordered at various online shops like http://shop.trenz-electronic.de in Europe for around EUR 300 and http://www.digilentinc.com themselves in the US for around USD 320 at the time of writing. The board comes with a USB to micro USB cable to power it using a computer or a USB wall socket. ==== - USB Keyboard ==== In order to type on the MEGA65 (and do anything, really) you need to attach a USB keyboard to the USB socket that sits between the power connector and the Ethernet port. It’s important to use a simple / old PC (Windows) keyboard without an internal USB hub due to the USB controller on the Nexys(tm)4 DDR board lacking support for detecting more than one device, e.g. a keyboard and a hub, at the same time. ==== - VGA Monitor ===== Although the final design will probably (also) generate a more mainstream 1080p HD signal, at least for now it’s important to either use a monitor that supports 1920 x 1200 or alternatively a 1080p capable TV / monitor and a separate VGA to HDMI converter (like the Atlona AT-HD500 for example) that converts the signal into the 1080p signal your HD TV / monitor supports. Some TVs / monitors that output 1080p are capable of handling the higher vertical scan frequency necessary for 1920 x 1200 but most will not. Optionally a Mono audio cable can be used to connect to the line-in of your monitor if it has audio support. Make sure one end of you cable fits the monitor line-in and the other end is a male Mono mini jack plug. ==== - SD Micro card ==== Plain SD Micro cards up to 4GB are currently officially supported. Some 4GB cards are known not to play nice though, so right now the safest bet is an (old) SD Micro up to 2GB. Cards like that may be hard to get by in your local store but there’s a ton of opportunity to get them from eBay. Most importantly, the card should not be of the newer SDHC or SDXC kind that support higher capacities, at least not for the time being. ==== - A Windows PC and SD Micro card reader ==== At the time of writing a Windows PC / laptop with an internal or external SD Micro card reader is needed to populate an SD Micro card with data in order for it to be successfully read by the MEGA65 due to the current SD card driver in the MEGA65 being sensitive to a specific partition and layout. This means that an Apple Mac will not be capable of formatting an SD Micro card the right way for the MEGA65 to read its contents currently. ==== - DirMaster software ==== This Windows software can be acquired from Style’s website here: http://style64.org/dirmaster. With DirMaster it’s possible to populate a D81 image with C64 / C65 files like games and pictures or whatever contents you’d like to access on the MEGA65. Although mounting D81 disks is optional, there’s not a lot one can do on a MEGA65 without loading software and / or saving work to disk. The D81 file format stems from the old 1581 disk drive that was a much sought after (expensive) item back in the day whereas most people with drives had 1541’s supporting 5.25” floppy disks. The 1581 chewed on the then more modern 3.5” instead. ==== - The MEGA65 FPGA bitstream ==== Last, but not least, a prebuilt bitstream file can be acquired by getting registered at http://mega65.org after donating at least EUR 5. By contributing to the project you’ll help ongoing development and to provide this service. After registration you’ll be kept updated with the latest core files and necessary information. The bitstream is basically the footprint for programming the FPGA on the Nexys4 DDR board, the single-most important component on the board and where the MEGA65 computer circuitry is hosted. ===== - Configuring the Nexys(tm)4 DDR board ===== ==== - Jumper settings ==== Please locate the following jumpers on the Nexys4 DDR board and adjust them where necessary: JP1 - Located near the VGA port. In order to boot the MEGA65 FPGA bitstream and configure the FPGA to host the MEGA65 circuitry, this jumper will need to cover the 2 pins labeled ‘USD/SD’. By default this jumper is set to ‘QSPI’ instead so it’s necessary to make this change to boot from SD where the bitstream shall reside. This will be explained in Chapter 3 later. JP2 - Located closest to the ‘XILINX’ and ‘ANALOG DEVICES’ logo on the Nexys4 DDR board. Set this jumper to ‘SD’ in order for the bitstream to be loaded and configured from SD card rather than from a USB stick. At the time of writing the core files only support booting from SD. You’ll need to hook up a keyboard to the USB port anyway. JP3 - Located near the +5V DC power connector. Set this jumper to ‘USB’ in order to power the Nexys4 DDR board over a USB cable, for instance by connecting the packaged cable to a PC or laptop. In this case you should hook up your USB power cable to the USB micro connector close to the +5V DC power connector just around the closest corner on your board. Alternatively, by setting the jumper to ‘WALL’ the board gets powered by the +5V DC power connecter instead. For the latter please acquire and connect a power adaptor capable of providing +5V DC on the core pin and GND on the shield. Please refer to Digilent’s website for more specs on power consumption specifics and resulting adaptor needs. ==== - Hooking up power and peripherals ==== Please hook up a USB keyboard without bells and whistles to the USB port that sits between the power connector and the Ethernet port. Please hook up a VGA cable to the VGA port located on the other side of the Ethernet port. Optionally hook up a Mono mini jack plug to the mini jack port that sits next to the VGA port on the other side of the Ethernet port. Hook up the other end to an audio receiver like a line-in on your monitor. After populating your 2GB - 4GB SD Micro card with the necessary files, please insert it into the SD Micro card slot that is located on the bottom of the Nexys4 DDR board. Please hook up a power supply according to the JP3 jumper setting as described above. You are now ready to turn the power switch that sits next to the +5V DC power connector and the MEGA65 should be ready to go! ===== - Preparing a SD Micro card ===== ==== - SD Micro card types ==== As stated in Chapter 1, the SD Micro card needs to be 4GB tops and should be plain SD rather than SDHC or SDXC as the latter are not supported by the SD drivers and software. Support for different SD Micro card brands is a work in progress. ==== - Partitioning and formatting ==== On Windows in Windows Explorer, locate the volume / drive letter that corresponds to your SD Micro card and issue a formatting command by right clicking on the volume / drive letter and selecting ‘Format...'. In the Format dialog that gets brought up, leave ‘Capacity’ unchanged, set ‘File system’ to ‘FAT32’ (by default it selects FAT instead), set ‘Allocation unit size’ to ‘Default allocation size’ and type your ‘Volume Label’ of choice (for instance, ‘MEGA65’), uncheck ‘Quick Format’ and click the ’Start’ button. Click the ‘OK’ button to dismiss the warning dialog and the formatting process will kick off. ==== - Mandatory and optional files ==== Once properly formatted, please copy the below files to your SD Micro card in the following order: - The bitstream file, e.g. ‘20150716ddr.bit’ - A C65 ROM that got extracted from a 1991 prototype C65, e.g. ‘910111.bin’ that can be obtained here for instance: ftp://www.zimmers.net/pub/cbm/firmware/computers/c65/index.html. Please rename this file to ‘C65GS.ROM’ (or ‘MEGA65.ROM’ for bitstreams from September 2015 onwards) after downloading first and put it under that name on the SD. - [OPTIONAL] A C64 character rom file of 4KB that got extracted from a C64 or emulator or got custom made, e.g. ‘c64.bin’ that can be obtained here: ftp://www.zimmers.net/pub/cbm/firmware/characters/index.html. Please rename this file to ‘CHARROM.G65’ (or ‘CHARROM.M65’ for bitstreams from September 2015 onwards) after downloading first and put it under that name on the SD. The bitstream has an alternative C64-like character set embedded so this file is entirely optional and will mostly be used to provide custom character sets for personalising your MEGA65. - [OPTIONAL] A boot logo file if you have one available. In the future a tool will be provided to create custom logos. Bitstream updates however are occasionally packed with a boot logo you can use freely. If you have such file available please make sure it is named ‘BOOTLOGO.G65’ (or ‘BOOTLOGO65.M65’ for bitstreams from September 2015 onwards) before uploading it to your SD. - [OPTIONAL] A D81 disk file that can be mounted on the MEGA65. To automatically have the system mount your favourite D81 disk file, please make sure it is named ‘C65GS.D81’ (or ‘MEGA65.D81’ for bitstreams from September 2015 onwards) before uploading it to your SD. A yellow border in C65 mode indicates the presence of an automount disk image. ** After putting the files on SD don’t forget to eject it safely first especially since the SD drivers are sensitive to any kind of anomalies which is also why it’s important to stick to the order of files as presented above. ** At the time of writing there’s a known issue with regards to auto-mounting where you still have to manually mount the ‘C65GS.D81’ (or ‘MEGA65.D81’ for bitstreams from September 2015 onwards) image by using ‘SYS49152’ in C64 mode. Without this operation the disk is presumed to be mounted however its directory contents will be garbled. When successfully re-mounted, the disk image will be available after a reset / warm boot. Interestingly, in the presence of a ‘C65GS.D81’ file, any other disk image mounted with ‘SYS49152’ will be auto-mounted after a reset. ==== - Obtaining a D81 virtual disk file ==== Many D81 disk files can be found on the internet. Simply Google-ing ‘d81 disk files’ will surely get you plentiful. An alternative way to obtain a D81 file is create one of your own using DirMaster. It features a simple drag-and-drop interface that allows you to copy C64 / C65 specific file to your virtual disk. It’s entirely possible to download C64 games or applications that are in the public domain or that were commercially abandoned and run them on your MEGA65 in C64 mode. At the time of writing probably not all software is working 100% yet but we’re getting close. ===== - Booting ===== ==== - Power ==== After all peripherals are hooked up and you’ve got your SD Micro card properly populated with mandatory and maybe some optional files it is time to turn that power switch! If all goes well the Nexys4 DDR board will get the bitstream from SD, configure the FPGA, fire up the custom circuits in it, effectively booting the MEGA65 computer and run its initial Kickstart software (the OS, basically). When Kickstart is booting the initial OS bootstrap code it will display the Kickstart version at the top, e.g. ‘C65GS KICKSTART V00.03’. If this doesn’t happen chances are there’s something wrong with the bitstream file, the SD card isn’t inserted or any or all jumpers are in the wrong positions. Once it succeeds Kickstart will dynamically show what it’s up to until it successfully loads and switches to the code in the mandatory ’C65GS.ROM’ (or ‘MEGA65.ROM’) file that in turn shows a familiar C64-like start screen. In the process it will have optionally loaded the ‘BOOTLOGO.G65’ (or ‘BOOTLOGO.M65’) and displayed it to the left of the Kickstart version text, mounted the C65GS.D81 (or ‘MEGA65.D81’) file if present and overwritten its internal character rom with ‘CHARROM.G65’ (or ‘CHARROM.M65’) if such file is present. In case Kickstart doesn’t make it to the C65 start screen then either a proper ‘C65GS.ROM’ is missing or the SD Micro card wasn’t properly formatted as discussed in Chapter 3. The partitioning and formatting has to be carried out *exactly* as described earlier due to the sensitive nature of the SD handling in the system while the MEGA65 is a work in progress. ==== - Program ==== There are two buttons located on the Nexys4 DDR board right above the ‘DIGILENT’ logo. The right-most button has a label underneath it called ‘PROG’. When you hold down and release this button the whole board will be reset and the whole bootstrap procedure will start over as if the power was just turned on. ==== - Reset ==== The button next to the program button has a label underneath it called ‘CPU RESET’. This button actually resets the MEGA65 that is hosted already on the FPGA. The FPGA will not be reprogrammed in this case, it’s just Kickstart that will carry out it’s initial bootstrap procedure. Basically this comes close to resetting an original C64 or C65 back in the day and the FPGA instead can be seen as a ‘host’ a virtual C64-like computer lives in. Alternatively a CPU reset will also be carried out after holding the ‘RESTORE’ key, which is mapped to ‘Page Up’ on a USB PC keyboard, for 2 seconds before letting it go. ===== - Using the MEGA65 ===== ==== - C65 mode ==== From the C65 startup screen you can now issue BASIC commands. Please check Chapter 3.1 of the unofficial C65 manual for a BASIC 10 reference. At the time of writing a copy is located here: http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt. In order to load files from a mounted D81 it’s necessary to first switch to C64 mode by typing ‘GO64’ followed by ‘RETURN’ / ‘ENTER’. An alternative to invoking the C64 mode is by resetting the CPU while holding the ‘C=‘ key, currently mapped to the left ’CTRL’ on the USB PC keyboard. Resetting can be done by pressing the hardware button on the Nexys4 DDR board or holding the ‘RESTORE’ key as described in Chapter 4. ==== - C64 mode ==== In this mode you can play some of the greatest games of all time! Before that happens you’ll have to mount a D81 disk file to become available as a disk in the C64 environment. Type SYS49152 to invoke the Disk Chooser routine that stays resident in the C64 RAM by default and until it is overwritten. If you’ve provided a .D81 file on the SD it will show some lines of text on the screen followed by ‘MOUNT [NAME OF DISKFILE] ?’. Press ‘Y’ on your keyboard and the text ‘DISK MOUNTED’ should appear underneath. At this point you can keep working in the C64 mode or reset the machine (without holding the ‘C=‘ key) and go back to C65 mode. In either mode you can now show the disk’s contents by typing ‘LOAD”$”’ and ‘RETURN’ / ‘ENTER’, followed by ‘LIST’ and ‘RETURN’ / ‘ENTER. As the C65 no longer supports loading from tape there is no more need to type ‘LOAD”$”,8’. HINT: It is even possible to skip the trailing quotation mark. If you have a loader menu as first program in your disk image and after a cold boot you have loaded it once with ‘LOAD”:*’, after a reset (warm boot) you can just press ‘SHIFT’ followed by ‘RUN/STOP’, currently mapped to ’ESC’ on the USB PC keyboard, (which results in ‘LOAD”*’) to reload it! To load a specific file on your disk type ‘LOAD””’ and ‘RETURN’ / ‘ENTER’, where is replaced with the actual name of the file you’d like to load. The specific file name will be enclosed by “” and in order to load a file it needs to be of the ‘PRG’ type. Once loaded you can type ‘LIST’ followed by ‘RETURN’ / ‘ENTER’ to see the BASIC code of the program. In case you loaded a game the BASIC program will typically consist of just one line containing a ‘SYS’ keyword followed by an address. Type ‘RUN’ followed by ‘RETURN’ / ‘ENTER’ to execute the BASIC program and presto! The above is just a typical example of a first encounter with the system. The internet however is flooded with ideas and concepts behind the C65 and even more so C64 in case you’re not familiar with the systems. The C64 community is actually pretty alive and there are still people inventing new tricks that people never thought possible on the C64. This is also where a big part of the fun of working with 8-bit machines comes from. Constantly pushing the boundaries of hardware that in itself does not, only this time with amazing speed thanks to the MEGA65. Happy adventuring!