Sunday, November 5, 2017

Q-emuLator 3.2 for Windows

An update of Q-emuLator for Windows is now available at

New features:

  • Support for “mdump version 2” microdrive images
  • Use the original Sinclair device driver to access microdrive images
  • mdump_task now included in the FileUtil directory; Use it on a QL to create images of your microdrive cartridges (also works with any copy-protected software you own) that can be used with the emulator
  • Accurate sound timbre
  • Save QL screen snapshots to the desktop by pressing CTRL+F11

This version also includes many small compatibility improvements.

The payment processing service for registration has changed to Paypal.

Using the Sinclair device driver for microdrive access

Here is the new option to use the QDOS driver to access microdrive images (only works when using Sinclair ROMs):


The option is enabled by default. The tradeoff is that access to microdrive images becomes much slower compared to the Q-emuLator device driver (used when the option is not checked). The simulated tape speed is about twice that of a real QL, so loading programs may take a few seconds.

Note that this option only applies to microdrive images; Other media attached to virtual microdrive slots still use the Q-emuLator device driver, as those types of media are not supported by the original QL ROM.

A few early software titles for the QL used copy protection schemes where they accessed the microdrives through QDOS calls, but then did some extra checks at fixed memory addresses where the Sinclair driver would store some of its internal data or cached sectors. There is even software that reads extra sectors from the tape after turning the motor off, relying on the inertia of the motor.

All of these more exotic protection schemes now work correctly in Q-emuLator when using a microdrive image containing a dump of the original copy-protected cartridge and using Sinclair ROMs with the “QDOS MDV image driver” option enabled.

Monday, September 21, 2015

SuperBASIC Syntax Highlighting in Notepad++

Having always needed to read and edit files from QL, PC, Mac and Unix, I’ve always used programmer’s editors that as a minimum support files with different character encodings and different line endings.

In the past I’ve used software like BBEdit, UltraEdit and jEdit, but my current favorite is Notepad++, a free text editor available for Windows. In addition to the usual features expected from code editors, it has all kinds of plug-ins available for specific tasks like for example pretty-printing XML and of course it has built-in syntax highlighting for the most common programming languages.

Syntax highlighting draws various words and elements of the source code using different colors, based on their function in the language (e.g. keywords vs. strings). It improves the readability of the code.

Notepad++ offers an easy and quick way of adding syntax highlighting for new languages by filling in some pre-defined fields with the lists of different types of keywords and operators and assigning a color to each one of them.
This is a portion of the language definition window:

Notepad++ SuperBASIC definition

It took about 30 minutes to enter all the keywords and operators from the QL and the keywords from the Toolkit II and the Turbo Toolkit.

I assigned different colors to SuperBASIC constructs and operators, QL keywords, Toolkit keywords, numbers, comments and strings. User-defined symbols have no style defined and are shown in black.

Here is how a procedure from the Turbo source code now looks in Notepad++ with the SuperBASIC syntax highlighting (click on the picture to see it full size):

SuperBASIC syntax highlighting

Now I find it easier to read and edit SuperBASIC code! (Q-emuLator runs most of my QL programs from Windows directories, so I can have them open in a Windows editor at the same time.)

The only thing I miss is the RENUM command, but implementing that in Notepad++ would require writing a plug-in.

The SuperBASIC definition for Notepad++ is available for download here.
To install it, unzip the file, then in the Language menu in Notepad++ select ‘Define your  language…’ and click on the ‘Import…’ button to load the definition file.
To try it out, load some SuperBASIC code and select the ‘SuperBASIC’ language from the bottom of the Language menu.

Wednesday, February 26, 2014

OS X Floppy Disk Access


In OS X, it used to be possible for users to get raw access to removable disks, including floppy disks.

In recent versions of the OS, Apple changed the permissions and only root can now access floppy disks at the low level necessary to be able to read non-Mac and non-PC disks.

This change may have closed a potential security hole, but it also means that emulators are no longer able to access floppy disks without the root user authorizing the access at some point.

On OS X Mavericks, for example, Q-emuLator by default will not be able to gain access to QL floppy disks. The easiest solution is for root to grant access to the floppy disk to everyone.

In OS X all disks are visible (“mounted”) as subdirectories of the /dev directory, so to enable Q-emuLator to access a floppy disk you may use the following procedure:

  1. Open a terminal window.
  2. To go to the disk mount directory, type: cd /dev
  3. The raw devices for all disks are visible here as rdisk followed by a number. As for security purposes you don’t want to grant raw access to one of your hard disks by mistake, first take a look at what disks are available on your system by typing: ls rdisk*
  4. Now insert a QL floppy disk. The Finder will complain that it cannot read it and offer to initialize or eject the disk. Click the Ignore button instead to tell the Finder to mind his own business and leave the disk in the drive.
  5. Now take a look at the available disks again: ls rdisk*
    You should notice an additional disk listed (compared to the first time you run the same command). Take a mental note of the disk number for the floppy disk. For example, in my case the floppy appeared as rdisk2.
  6. Grant read/write access to the disk to everyone by typing the following command and entering the password (of course, replace the <n> at the end with the number that you noted at the previous step):  sudo chmod a+rw rdisk<n>

Now Q-emuLator will be able to access the QL floppy disk (as it did by default on previous versions of OS X).

If you insert another disk in the floppy drive, OS X will likely assign to it a different device name, so keep the terminal window open and repeat steps 4-6 for the new disk.

To avoid having to repeat this procedure often, it may be a good idea to use the emulator to copy the contents of your QL disks to folders on your hard disk (I use a different folder for each disk) and from now on use the folders instead of the floppy disks. Your software will load from the folders exactly as if it was still on the floppy disk (you can even continue to use the FLP device name), only much faster.

Tuesday, October 1, 2013

Code size

While looking for a Perl file to modify for another project, I came across a script I wrote ten years ago to count the lines and comments in C/C++ projects and out of curiosity decided to use it on the current Q-emuLator codebase.


The result is that Q-emuLator today has 68000 lines of code (67995 lines in 235 files to be precise, after excluding lines that are entirely blank or comments)…

…mostly written during nights over the last 19 years Confused smileSleeping half-moon.

The count includes some currently inactive code like the binary translator for the QemuFast project and it excludes the Unzip sources.

A few assembly and Perl files are also not counted.

There are then about 5000 lines of code between the M68000 debugger and a tool to generate tables for the disassembler and the timings for each CPU instruction.

Now if I add just a few lines I can get to 68008! Smile

Saturday, August 17, 2013

Q-emuLator 1.2 for OS X: Trial Mode

Q-emuLator 1.2 for Mac OS X has just been released, adding a special mode (similar to the one available for the Windows version) that allows users to try running QL software on it before purchasing a license.


The new “Try” button in the startup/registration window allows emulating a QL with 128 KB or RAM and speed similar to that of the 68008 CPU.

As always, registration unlocks fast CPU emulation and the full set of features:


Download this update from the Q-emuLator for OS X page!

Saturday, April 20, 2013

Minerva and Games

The Minerva ROM brings a number of improvements to QDOS, but some QL games (especially early ones) don’t work correctly on it. What are the technical reasons for these problems?

For last year’s release of the “QL Games Collection” I worked on a special version of
Q-emuLator to use as the runtime for the games and I had the opportunity to investigate and answer this question for many games.

Here is what I found, the main differences between Minerva and Sinclair ROMs that can cause incompatibilities:

  • Minerva expects programs to run in user mode. If a program changes the supervisor stack pointer even just for a short while, Minerva can crash, for example when the interrupt 2 service routine is called.
  • Some games take complete control of the QL, typically to maximize speed and available memory, to use the second hardware display page or to strengthen the copy protection. However, virtually all of these programs still need to call QDOS to communicate with the IPC co-processor to play sounds and to read the keyboard.
    In Sinclair ROMs, the IPC functions are at a lower level than the rest of the OS, but on Minerva IPC access is more similar to any other QDOS calls and it accesses the system variables, which these games normally overwrite. This can cause crashes or funky behavior.
  • The interrupt 2 handler, which some games use to get the correct timing or to run code periodically, accesses some system variables both on Sinclair and Minerva ROMs. However, the Sinclair handler can often continue to work when the variables are overwritten, while the Minerva one can not.
  • Minerva treats unhandled exceptions very differently than the Sinclair ROM.
    It’s actually pretty common for QL software to contain bugs that cause unhandled exceptions as when running on Sinclair ROMs most of these exceptions where simply ignored by QDOS and many software authors didn’t even have a chance of noticing the problem.
    On Minerva, unhandled exceptions cause a call to the OS rather than just being ignored and this in turn can have unexpected side effects, or crash the system when combined with any of the previous issues (for example for games that take over the entire system).

In general, when running early QL games on an emulator, the safer choice is to use a Sinclair ROM and set the amount of RAM to 128 KB to avoid incompatibilities. A number of these games wouldn’t work if the QL had a RAM expansion as they expected everything to be at the same fixed memory addresses as on a 128 KB QL.

Monday, February 11, 2013

3.1.3 update for Windows

Version 3.1.3 for Windows is out with the following changes:

  • Exit and re-enter full screen mode on Alt-Tab.
  • Return cartridge name in "get medium info" trap for microdrive images (*.mdv).
  • Fixed crash when QCF file was passed on the command line.