Nice job. The sound effects are a bit too advanced because early IBM computers shipped with pretty simple, magnetically driven dynamic speakers.

On a related note, I’ve actually spent the last four months working on a 100% faithful adaptation of both QBasic and QuickBasic 4.5 that runs entirely in the browser on a virtual CPU and hardware abstraction layer. It’s a love letter to everyone who learned to program on Microsoft’s BASIC interpreters in the ’80s and early ’90s.

The best compliment I’ve received so far is from friends who grew up in the same era I did: when I fullscreen the browser, a few of them assumed it was a virtual machine running the real thing.

A QBasic port of the original BASIC-based DONKEY.BAS was one of the first programs I got running in it:

https://mordenstar.com/share/qbasic-core-demos

You used to be able to do surprising things with those old speakers using a timer interrupt: on an IBM XT it was possible to get 8kHz quality out of it, enough to make 4-channel MOD playback sound about as good as hearing it over a phone.

But your more typical use case was to play a single tone for some significant fraction of a second.

Nice, there’s also a great in-depth article about an album driven entirely using the primitive PC speaker. The whole COM file comes in at around 40 KB, so you can copy it onto an old machine and run it. Some of it you'd swear you're listening to a SID chip~

https://habr.com/en/articles/439192

https://www.youtube.com/watch?v=tUy1MEpqbvk

Note for the audience that COM files were limited to 64 KB, thus not much left and naturally it was all done in Assembly.

Mach 3 by Loriciels (France) from 1987 is impressive in this regard:

https://www.youtube.com/watch?v=chJrd9Kxbdw

It somehow sounds even better on an actual 80s PC, with the bass sound being amplified by the massive steel enclosure.

Loved that game back in the day. Thanks.

I remember an old company called "Access software" that had something called "Realsound" with which they played really high quality audio on the PC speaker. Their games were things like Countdown, Martian Memorandum etc.

The 8088 MPH demo, for example, pushed the PC Speaker pretty far: https://www.youtube.com/watch?v=yHXx3orN35Y

Using a sound card (read the comments)

Yes, a friend of mine had a Turbo Pascal library (aka unit) that he used as alternative when no sound card was available, for his games.

This was on a 386, not an XT, but I had a shareware driver for Windows 3.1 that provided that for the regular Windows sound APIs.

[dead]

At my first job, our entire order-entry and inventory management system was written in QBASIC. I wish I had the source to try it out with this.

I know someone who might, if we could figure out how to get it off a DOS 5.25" floppy!

That’s awesome. If you ever end up getting a copy of it, I’d love to stress-test QBasic-Core against it since I built in a virtual hard drive to allow File I/O (PUT for random access, PRINT to file number, etc.)

I’ve got a fairly large collection of several hundred programs from the early to late ’90s that I’ve been carefully testing A/B testing against period accurate hardware and my simulator but actual professionally used QBASIC-based applications from back with the source intact are hard to come by.

The good news is that 5.25" floppies have tended to be more resilient to time than the 3.5" discs. Turns out just having less data spread over a larger space helped them in this regard.

Hardest part is usually trying to find working drives and a means of getting the data off the system.

The best (and most flexible) way to get data of old floppies is https://github.com/keirf/greaseweazle which reads the data at a raw magnetic level using a standard floppy drive and a custom open source circuit board which replaces the host controller.

However, if you are specifically dealing with PC floppies, it is potentially overkill (but it might still be the easiest way to hook up a 5.25" floppy drive to a modern computer).

5.25" drives may also need a separate power supply in addition to the greaseweazle, for 3.5" drives the GW has enough power to power the drive directly though.

And for the slightly younger folks who have more memories of Visual Basic than QBasic, check out GAMBAS: https://gambaswiki.org/website/en/main.html

Loved Visual Basic! VB3 was probably my first experience as a kid to the idea of “threading” and UI-blocking operations.

Remember this?

  DoEvents

I do remember DoEvents! Sadly it's not present in GAMBAS, but there's WAIT, which is kinda the same: https://gambaswiki.org/wiki/lang/wait

> early IBM computers shipped with pretty simple, magnetically driven dynamic speakers

Yes the PC & donkey.bas were monophonic design, but the PCjr shipped with 3-channel polyphonic sound plus a noise generator. It might have been capable of doing the sounds in this port of donkey that took “some liberties”. ;)

I remember some sound demos on the PC that emulated polyphonic sound by fast/audible switching between notes in a chord. Hey it seemed cool at the time. :P I just looked and couldn’t find any quickly enough but bumped into examples of even better true polyphony on the PC achieved by assembly hacking.

> ... fast/audible switching between notes in a chord ...

https://en.wikipedia.org/wiki/Arpeggio

Many of my favorite chiptunes use this technique.

> I remember some sound demos on the PC that emulated polyphonic sound by fast/audible switching between notes in a chord

Didn't know that about the PCjr! I'll have to see if I can find some examples of the generator online. Polyphony by rapidly switching between notes in a chord was also one of the common tricks on the SID chip for the C64.

Even though it has separate channels, you could use get away with a single channel to play triads by arpeggiating extremely fast between the three notes.

Do non-magnetically driven speakers exist?

Yes, electrostatic speakers are a good example. Also a lot of PC motherboards I've had over the years have had the little piezoelectric speaker. And while still magnetic, there are planar magnetic speakers which are much more like electrostatic speakers (just using a magnetic field instead of electric field) than the typical moving coil / dynamic speaker drivers that you think of.

This guy knows speakers.

I have a pair of Magneplanar speakers. They always impress people.

This is fantastic! As one of those kids who spent the early 90s in QBasic, thank you!

Amazing. This is nostalgia heroin for me.

How far does the HAL go? Screen 12 and 13, and writing directly to VRAM? WAIT for vsync? Call absolute for mouse usage?

Thanks! I went so far with it that I was honestly questioning my own sanity.

The HAL has a virtualized CPU, and I spent more time than I’d care to admit precisely timing instructions on various period-accurate hardware (386SX, 486DX). I even tuned it to the point where programs that take advantage of it actually run faster on the 486 because of the built‑in math coprocessor.

> Writing directly to VRAM? WAIT for vsync?

All screen modes are supported including the ability to draw to hidden pages. It’s got a fully emulated VGA hardware layer and even a synthetic VGA beam clock, so you can do tricks like `WAIT &H3DA, 8, 8` for vertical retrace to minimize flicker.

> Call absolute for mouse usage?

Yup! Int 33h is fully supported, we basically use a virtual TSR driver which is pointed to by the interrupt vector table. I actually tested it with an old pixel art editor I made in the 90s!

PEEK/POKE and much of the BIOS are fully simulated, so you can use more advanced QuickBasic 4.5 features like calling interrupts (including silly stuff like rebooting the computer via int 19h).

There's a ton more (including a Hayes compatible modem plugged into COM1) as well.

I basically dug out a stack of my old PC books from the late ’80s and early ’90s, and they’ve been my bibles for the past several months (Undocumented DOS, The Programmer’s PC Sourcebook, etc.).

It’s about 99% done at this point. I’m hoping to do a Show HN in the next couple of weeks.

Wow, I didn’t expect this kind of reply at all. What a labor of love. Can’t wait to try it out! What made you decide to emulate things at this level instead of using a more off the shelf hardware stack?

So I wanted to build more than just a simple online QuickBasic simulator - I've seen a few of them but they all kind of fall apart at the last mile.

You really can't create a QuickBasic interpreter with any expectation of accuracy unless you also flesh out the corresponding hardware that would have accompanied it back in the day.

What I’m really aiming for is to recreate the world we grew up with as kids in the late ’80s and ’90s. I want to tap into that feeling of discovering QuickBASIC on a computer for the first time and realizing you could bring your own creations to life.

For me, and I bet a lot of kids back then, QuickBASIC was the closest thing to sorcery: you could conjure whatever was in your imagination and watch it traced out pixel by pixel on your 14-inch VGA monitor.

This comment is peak HN!

In depth, thoughtful comments about someone deeply passionate about technology were the reason why HN became the place on the web for hackers.

Thanks for keeping the spirit alive!

I once heard a digitized version of "Daisy Bell" (DAISY.COM) which sings through IBM PC speaker although of poor bitrate.

aw neat I'd love to try doing this for its predecessor GWBASIC (my first programming language on the Tandy 1000EX)

You absolutely should!

I’ve already sunk hundreds of hours into building out the fidelity of QuickBASIC (everything down to emulating memory access so you can simulate realistic PEEKing and POKEing), so I don’t have the sanity points left to tackle any other variants myself, but I’d love to see a GW-BASIC version.

Sounds like pcbasic, that implements GW-BASIC in python, both with a SDL GUI and a TUI, and it contains a partial PC emulator to make it possible to peek and poke some addresses and such. Impressive project, well documented and seems stable and nothing obvious is missing.

https://robhagemans.github.io/pcbasic/download.html

Got grounded for “breaking” the computer by POKE’ing random numbers to 0 to 65535. In my defense, I was 11.

Haha same. I definitely crashed our family's PC quite a few times as a kid by forgetting to set the segment address to &HA000 and then poking, mistakenly assuming I was hitting mode 13h VGA memory.

What's weird is that they did an open-source release of GWBASIC, but it seemed to be in a worse state than the DOS 1/2/4 releases. I don't think there's a turnkey distribution out there outside of digging up your old DOS 4.01 floppies.

There is this fork that is easy to build:

https://codeberg.org/tkchia/GW-BASIC

There are some binary releases there from 2022, but I did not try those. The binary I built from source has worked very well.

Never tried to build the DOS source, but I really enjoyed playing with the toolchain they included with the MS-DOS 4 source code release. It's pretty much a complete, MIT-licensed (but binary only) Microsoft toolchain (msc, masm, make, link, etc) from ~1988. For some of my recent hobby projects I put that toolchain in my git repos, to have everything self-contained, with DOSBox as a virtual machine both for building and running, and no other dependencies. So I am happy Microsoft released the DOS code, even if I did not look much at the code itself.

It runs fairly well in dosbox in a browser though right? Why port directly?

Great question! So DOSBox, which I absolutely love, has some limitations. For example, you don’t really get a lot of period-accurate virtual devices out of the box, whereas Qbasic-Core tries to recreate the experience of actually having a 386SX/33 MHz computer along with the accompanying peripherals - everything from a LPT-connected dot-matrix printer to a 14.4 kbps Hayes-compatible modem, all of which you can directly interface with.

For me, this project is really a love letter. It’s about recreating that nostalgic experience and also making it something others can just drop in and enjoy. You don't have to install DosBox, track down a copy of QBASIC and configure it with sane defaults for speed since many BAS programs which are CPU dependent are probably going to run way too fast.

You can run it anywhere you have a browser, because it runs entirely client-side. You can even share programs in other sites, since it ships with a small virtual interpreter. That means you can iframe BAS examples if you want to demonstrate how QuickBasic worked.

How comes the modem panel is not “shader-ized” (scanlines + distortion)?

Keen eye! That's an old demo video. The modem panel now (and other panels such as the printer) are now run through the same post-processing shader pipeline as the rest of the editor when you've entered into CRT immersive mode.

Nibbles!