A heap of dung
I’ve been working hard behind the scenes to release a new version of the QL-SD ROM driver. The starting point was that Urs König asked me about a mysterious heap corruption with QL-SD when using his QL/E distribution under Minerva. And mysterious it was, after stripping down QL/E’s monster boot file to a few lines a simple WSTAT command turned out to be the culprit. How can that be?
Long(!) story short, this turned out to be an incompatibility between a compatibility hack contained in SMSQ/E’s DV3 driver (on which the QL-SD driver is based on) and Minerva’s heap manager: when the first empty space in the heap was exactly(!) 384 bytes long the QL-SD driver corrupted the heap chain! This is difficult to debug because once you load a debugger the heap is too different to trigger the bug! Generally the bug is very difficult to trigger which is why it went unnoticed for so long, but fortunately with QL/E it was reproducible.
One network to rule them all
While working on the code I found a few more places where I could save a few more bytes, all in all a whole kilobyte even! So, what to do with so much space? It’s not enough space to include more card management functions (more on that later), but enough to do something I’ve been thinking about for a long time:
In one of my other 1000 QL projects I created new versions of the very famous TK2 basic toolkit and in doing so I also created the QLNET hardware proxy: this means that the highly timing critical low level QL network driver functions can be split off from the rest of TK2 so that they can be burned into a ROM while the much bigger rest of the network code is loaded from another device into potentially slower RAM.
And now with all this free space available the time has come for QL-SD to host the QLNET low level functions. Yaaay! The remainder of TK2 can then be loaded from SD without losing network support. Mind you this is only useful for original black box QLs, GoldCard and SuperGoldCard come with their own TK2, in this case the new functions are simply ignored.
SMSQ/E for Q68 comes with several CARD_xxx basic functions for working with the FAT32 host file system. As these are somewhat useful I adapted them for QL-SD and released it as an external BASIC extension. There are three new basic functions:
- CARD_CREATE card,size_in_mb,filename$
Create a new empty file on the card with the desired size. The great thing about this command is that unlike files created by the PC the file is guaranteed to be contiguous, which is a necessity for usage with QL-SD.
“card” is 1 for the first slot and 2 for the 2nd slot.
- CARD_RENF card,”old-name”,”new-name”
Rename a file on the card. Note that the QL-SD driver can not handle long filenames, so the filenames must comply with the old DOS 8.3 filename scheme.
- dir$ = CARD_DIR$(card)
Return the first 16 root directory entries in a string. QL-SD can only “see” the first 16 entries in the root directory, so this is a good way to check what’s actually seen by the driver.
You can head over to the updated QL-SD product page and get the new driver and toolkits. All QL-SDs produced by me shipped with an EEPROM that can be updated within seconds using an appropriate EEPROM programmer. I know not everybody possesses one of those, but unfortunately I cannot provide an update service at this time. I’m hoping that this can be somewhat crowd sourced so people with the hardware can help other people out, maybe even for a fee.
Speaking of fees, I do this all for free. And it’s taken up so much time that I need to scale back eventually. But in the meantime, if you still want to support my work, check out my cookie jar. In any case, thanks for reading and enjoy.