Q-emuLator for macOS version 2.2 has been released, now allowing the creation of subdirectories in QXL.WIN containers and on floppy disks. The included Toolkit 2 has been updated to a recent version that includes the SuperBASIC MAKE_DIR command.
Q-emuLator blog
Sunday, January 8, 2023
Sunday, September 25, 2022
Q-emuLator 3.5 for Windows
Friday, December 24, 2021
Q-emuLator updates
Q-emuLator versions 2.1 for OS X and 3.4 for Windows are now available for download.
SMSQ/e support has been improved when using the emulator-specific build of SMSQ/e (available here).
Both formats of microdrive images (mdump_task and QLay) are now supported by the unregistered version of the emulator, since supporting only one of them was confusing.
The version for Intel Macs also catches up with the TCP/IP driver improvements recently added to the PC version, and audio emulation has been made compatible with OS X 11 Big Sur.
Monday, September 7, 2020
Q-emuLator 2.0 for macOS
Sunday, May 10, 2020
Dumping Intel 8049 ROMs
The second processor is an Intel 8049 microcontroller that runs independently of the main processor and handles the keyboard, sound and serial port inputs.
The 8049 sits on the right side of the QL motherboard, squeezed between the microdrives and the keyboard connectors |
This can cause a significant slowdown of QL software and the exact timing depends on the code that runs on the IPC.
The code is stored in an internal 2 KB ROM. Sinclair wrote the code, but it got programmed in the chip by the manufacturer, and there is no way to reprogram it.
This also means that if you need to replace an IPC chip, you cannot just buy any available 8049: It needs to come from a QL, or it will contain a different, incompatible ROM.
There are a few copies of the QL IPC code on the internet and they are all the same, apart for a single unused byte toward the end of the ROM.
In order to improve the 'QL Speed' accuracy of Q-emuLator, I plan to better account for the 8049 timings (simulating the interaction between the 68008 andthe ZX8301 ULA will also be necessary, but that's a topic for another day). To compare the speed measured on a real QL to the emulation speed, I need to be sure about what code is running on the IPC, so I decided to dump the contents of the chip and compare them to the version from the internet.
EPROM programmers have the circuitry necessary to read the 8049 ROM, but I don't know of any programmers that support this chip, probably because it cannot be written to.
Reading the ROM can be accomplished by using the "ROM Verification Algorithm" described in the MCS-48 datasheet (MCS-48 is the family of microcontrollers that includes the 8049).
I bought an Arduino UNO board to connect it to the 8049 and read the ROM.
I also got a second QL 8049 to use in my initial experiments and avoid the risk of ruining the chip in my QL.
My two IPC chips look quite different... Will they contain the same or different code? |
There is a web page called 8049 Spy that explains how to connect the 8049 for reading the ROM.
I used the same method, with two differences:
- The 8049 is connected to an Arduino instead of the 6802 Nano Computer.
- I added a resistor for protection on each of the 8 data lines since these are bidirectional and both the Arduino and 8049 could end up trying to write to them at the same time if the timings are not perfect.
The IPC (on the right) connected to the Arduino board (left) |
View from above |
- Apply 12 Volt to pin 7 to set the "ROM Verification" mode. In my circuit, I used a boost converter to convert the +5V used by the 8049 and Arduino to +12V.
- Set the 11-bit address of the ROM location to read, using DB0-DB7 for the low 8 bits and P20-P22 for the high 3 bits.
- Set the RESET pin to high to signal that the address is valid.
- After a few cycles, read the content of the ROM location from DB0-DB7.
- Set RESET to low and repeat from step 2 using the next address, until we've read all the 2048 ROM locations.
8049 connections for ROM Verification |
#define RESET_PIN A0
void SetReset(uint8_t b) {
digitalWrite(RESET_PIN, b);
}
void SetDigitalPinDir(bool bOut) {
if (bOut) {
DDRD = B11111100 | DDRD;
DDRB = B00011111;
} else {
DDRD = B00000011 & DDRD;
DDRB = 0;
}
}
void SetAddress(int addr) {
PORTD = ((uint8_t)addr << 2) | (PORTD & 3);
PORTB = (uint8_t)(addr >> 6);
}
uint8_t ReadDataBus() {
return (PIND >> 2) | (PINB << 6);
}
void Output(uint8_t b) {
if (b < 16)
Serial.print("0");
Serial.print(b, HEX);
}
void OutputNewLine() {
Serial.println();
}
int addr;
// Diagnostics
uint8_t diff;
void setup() {
SetDigitalPinDir(false);
pinMode(RESET_PIN, OUTPUT);
SetReset(LOW);
addr = 0;
diff = 0;
Serial.begin(9600);
while (!Serial); // Wait until serial console is opened
}
void loop() {
if (addr < 2048) {
SetDigitalPinDir(true);
SetAddress(addr);
delayMicroseconds(100);
SetReset(HIGH);
delayMicroseconds(5);
SetDigitalPinDir(false);
SetAddress(255); // Input pullups
delayMicroseconds(2);
uint8_t data = ReadDataBus();
SetReset(LOW);
delayMicroseconds(10);
Output(data);
diff |= (data ^ addr);
addr++;
if ((addr & 31) == 0) {
OutputNewLine();
if (addr == 2048) {
pinMode(RESET_PIN, INPUT);
diff ^= 255;
if (diff) {
Serial.print("Some data lines appear disconnected: 0x");
Output(diff);
OutputNewLine();
}
}
}
}
}
Sunday, November 5, 2017
Q-emuLator 3.2 for Windows
An update of Q-emuLator for Windows is now available at http://www.terdina.net/ql/winql.html.
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:
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):
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.