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:
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.
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.
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.
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.
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 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.
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.
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~
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.
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?
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.
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.
> 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.
> 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.
For those who don't know why GORILLA.BAS is so cool... Back in the day, computers were expensive and games weren't readily available. Sometimes a parent would buy a computer for word processing or spreadsheets or take kids to the office which also had business computers. Children were curious about the computers but there wasn't really anything fun to do with them besides banging on the keyboard...
...Until you found the BASIC dialect that came with MS-DOS, that is! GORILLA.BAS was bundled with DOS and was a fun little game you could play in those computers. It's not like you could access web games on the Internet - there was no Internet!
It was also a very educational experience to start messing with the code until you broke it - forcing you to figure out how to fix it, to get your game back.
this reminded me I gave myself infinite lives in a GNU version of Nibbles (not really the same game but a drastically expanded one) so I could see all the levels.
> Back in the day, computers were expensive and games weren't readily available.
You could get a PC for a thousand bucks back then, and shareware was a thing in 1990-91. Crystal Caves, Commander Keen, Duke Nukem were huge hits and there were tons of less popular games...not to mention copying commercial games from friends.
And that would get you a system that was fairly anemic even for then. There were still some 286 systems being sold then which was 2 full architecture leaps behind at a time when it was starting to become very important.
> You could get a PC for a thousand bucks back then
In the United States... In a lot of countries, computers cost a lot more than that in the local currency which, together with lower salaries, made computers inaccessible to most people.
I remember seeing people playing GORILLA.BAS in computer stores...
Just as importantly - it was an all‑in‑one. I think a lot of people tend to forget that there were already plenty of earlier BASIC dialects (GW‑BASIC, Apple II BASIC, C64 BASIC, etc).
However QBASIC was likely the first freely available, all‑in‑one "batteries included" environment that came bundled with MS‑DOS 5 with a relatively friendly IDE that had built‑in help for every single command. GORILLA.BAS and NIBBLES.BAS were the gateway drugs for many future programmers.
Basic and Qbasic represent a part of computer culture that has been lost a little bit. It was the idea of making computers programmable to almost anyone without having to have a deep knowledge of how the system works.
I'm not saying we should go back to BASIC but that spirit of easy to build has been lost a little. Nowadays you need to pull in like 40 dependencies before things can get really moving. Yeah it is OK after that but the barrier to entry can be a little tough at times. This is the same complaint I have about multimedia on the web, Flash solved the issue in a terrible fashion but the core idea was great.
100%. I actually loved Flash for what it was. I get that it could definitely become convoluted especially when you were jumping between various keyframes, some of the control flows could get really messy.
But just like QBASIC, it was a “batteries included.” environment. That’s what made it so compelling.
QBASIC was the same way. It's a literal siren song for inquisitive kids to just experiment, because everything is right there. Like you said, there’s no importing libraries. It’s a completely self-contained sandbox of possibilities.
If you have a question, you just slap that F1 on your buckler-spring mechanical keyboard and boom there’s documentation/examples.
Definitely. I've used a few of them (Commodore BASIC, Applesoft BASIC) as a kid.
I could have worded that a bit better. What i meant was that as far as I'm aware, QBASIC was the first free OS-bundled fully featured BASIC IDE which even by today’s standards still kind of holds up:
• find and replace
• split panes
• an immediate mode
• debugging
• breakpoints
• built‑in help for every basic keyword and command.
• editing any lines (no need for line number at multiples of 10 to insert and modify at a later time)
Even as someone that grew up with GW-BASIC and had moved on to Turbo Pascal by the time qbasic came out, I must say you have a point. I think however that the more traditional BASIC "IDE" with line numbers etc, used in GW-BASIC, has its charm and is still fun to play with. It's quite unlike any modern IDE, but there is some logic to it and with some practice it isn't bad for what it needed to do.
Oh definitely! Some of my earliest memories were my dad helping me type in basic programs that were listed in the popular COMPUTE! magazine back in the day.
10 PRINT "YOU'RE DEFINITELY GOING TO GET FATIGUED"
20 PRINT "AFTER A FEW HUNDRED LINES OF TYPING THIS"
30 PRINT "IN AND MAKE A MISTAKE. HAVE FUN!"
40 PRINT CHR$(7)
It sounds kind of crazy now but we genuinely used to buy computer magazines that had basic code printed in them, to try the game you would type the basic into a file, save and then run it.
Before that we had the BASIC dialect that came with ROM on power up. :)
And this is how we got many of our games from the local library, or bookstore, Atari as example, but similar existed for the other 8 bit home computers,
Yeah it's very iconic. It’s actually the same melodic motif that’s played in the intro of GORILLA.BAS and NIBBLES.BAS - it’s a short snippet from Tchaikovsky’s 1812 Overture.
Kind of reminds me of how most people don’t know “Korobeiniki” (Коробейники) by name, they just call it the Tetris song.
Everyone loves it for being a song with cannons in it. Must be a lame way to be remembered though. People like Beethoven and Mozart for, you know, their actual music. But Tchaikovsky? CANNONS!
I remember hacking GORILLA.BAS code, which was on our office computers, to randomize gravity for my opponent, the result being they could not accurately predict where their bananas would go. I was an unbeatable legend for a while.
For anyone unfamiliar with DONKEY.BAS: it’s notable for having been co-written by Bill Gates. More info on its history bere: https://en.wikipedia.org/wiki/DONKEY.BAS
Inspired by the 45th anniversary of the IBM PC, I got my slopmachine cracking on a port of DONKEY.BAS to work in a browser. Pretty happy with the result. As a young person I remember being fascinated that you could make a game like this with so little code.
The game theory is all wrong, this is a cooperative game, either they both win or both lose. I don't see how the Donkey getting hit by a car should be classified as "Donkey wins"
That has all the hall marks of urban legend, but why let the truth get in the way of a great story.
I have said it for a very long time, Gates wasn't innovative in technology but he absolutely innovated in bringing the most ruthless business practices into software.
Someone gave my grandfather a Games BASICA floppy that had this and other games on it. But this copy had a few games that had been "modified". I remember in DONKEY.BAS, it would curse at you if you hit the donkey. "YOU STUPID SONOFABITCH". We thought it was hilarious. My grandfather was less pleased. He took it away from us when he found out.
Modifying those games were the first times I ever touched code! There was one that existed somewhere between DOS 2.0 and 3.2 that simply asked your name, then asked how the hell you got that name. It was maybe half a dozen lines, but easy enough to modify output and learn a bit about variables.
As a kid I modified DONKEY.BAS for my younger brother who wanted to play as a donkey avoiding cars. It was a clumsy modification, I didn't account for the differing size of the pseudo-sprites, but it made him happy.
I haven’t looked at the code but the collision detection was buggy even back in the day. You have to switch lanes while there is nothing or a donkey in front of you. If the donkey is in the other lane it registers a hit even if it looks like you passed it
Edit: line 1750 is where it does a simple collision check and yep looks like it registers a collision without checking you’re past the donkey or not
It says something about what a thoughtful development environment these early BASICs were, that you could make a full simple little game like this in only 131 lines even though they're ostensibly far less powerful than modern languages. I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
Never mind how compact, beginner-friendly, and just plain fun they were to use. It's been said countless times but I'll say it again - we've lost something over the years.
raylib might do it in less lines. SDL is designed as a cross platform base layer to wrap in another framework not as something you should be using directly.
SDL has a lot of issues, and falls into the "only if you must" category. Still better than .NET or Java in many ways, as spacial audio is easy in the mixer. =3
Python is the modern Basic replacement, and also has similar fundamental design trade-offs. VB6 was the peak of the OLE/Multimedia paradigm, and was functionally replaced by the web browser script sandbox.
> we've lost something over the years.
Indeed, Information Appliances were never general-purpose computers. Some people used to care about that sort of thing, and left civilization the GNU compilers as one of the most important intellectual artifacts of our generation. =3
It was really cool! The ease of getting started was definitely one of the selling points for the “home computers” of that era (GW-BASIC ran on IBM compatible PCs instead, but the appeal of BASIC was the same). Brevity was an important feature since a lot of people obtained programs by typing them over from a magazine or recording them from the radio. And of course, there was no such thing as auto-complete (let alone AI generation).
That being said, SDL isn't actually that bad either. A minimal example is about 40 lines of code [1], not counting comments and blank lines, but including lines with just a curly brace which you could easily remove if you were concerned about size. A slightly more serious implementation of Snake runs about 345 lines of code [2].
And to be fair, DONKEY.BAS is also cheating slightly on the line metric by stuffing lines full of statements, like for example:
A$=INKEY$:IF A$=CHR$(27) THEN 1298 ELSE POKE 106,0:IF LEN(A$)>0 THEN LINE (CX,CY)-(CX+28,CY+44),0,BF:CX=252-CX:PUT (CX,CY),CAR%,PRESET:SOUND 200,1
>I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
The basics (window, events, renderer) can be done in about 30 lines:
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
static SDL_Window* window;
static SDL_Renderer* renderer;
int main(int argc, char* argv) {
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_GAMEPAD);
SDL_CreateWindowAndRenderer("test", 640, 480, SDL_WINDOW_RESIZABLE, &window, &renderer);
SDL_Event event;
while(true) {
while(SDL_PollEvent(&event) != 0) {
if (event.type == SDL_EVENT_QUIT) {
goto ENDGAME;
}
//events go here
}
// update here
SDL_SetRenderDrawColor(renderer,0,0,0,255);
SDL_RenderClear(renderer);
// render here
SDL_RenderPresent(renderer);
}
ENDGAME:
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}
I don't think you could get all of donkey.bas done in 131 lines, though. SDL3 does ship with an embedded debug font but that seems like cheating. You probably couldn't replicate the drawing code easily, it would probably need to be faked with images, and you'd need a font atlas for the text.
I learned to program with BASIC. It was awful. I didn’t know how awful it was until many years later. So I don’t miss the language. But something I miss is how easy it was to learn what your machine was doing.
The DOS boot and config involved only two files: CONFIG.SYS and AUTOEXEC.BAT, that was it. Most programs were self-contained, so you could copy the directory to a floppy disk and run them on another machine. If you broke something, copy the files again and restart; that was it… I “broke” config and programs many times, and it was a good way to learn.
Other than that, either you would have machine code via DATA statement, be lucky that there was support for entering Assembly like on the BBC, or have the opportunity to actually get a proper assembler.
Back in the days you would buy printed magazines that contained full basic source code of programs and games and type them on your own text editor. I was a bit too young to do that but I remember watching my older brother just do that and then play games (after finding the typing errors for a while).
Also, on reflection, I think the firefox window size is half of what I reported - I'm not sure what OSX does to its screenshots, but using SHIFT-CTRL-CMD-3, it's reporting about half that size. Not sure if that makes a difference to your changes (likely not).
tangential: I still remember how disappointed I was in PCs being used to a C64 (which was released in 1982) The quality of the games & sound effects was just not on the same level (C64 being much more advanced)
PC was a clear winner for RPGs, adventure games, and wargames/strategy, even in the early days of PC/XT. Anything that could make use of more RAM and disk, while also not demanding too much of graphics or audio, was great on PC.
This is what got me into programming. When I was a kid, I had a shitty 386 because my father got a computer second hand from a friend (we were poor). I was playing the game and then pressed a key and it took me to the basic editor. I was confused with what I saw and started changing things. I changed a number and the size of the explosion on the banana got bigger. My best friend at the time went to computer camp and explained to me that it was code. 30 years later I'm still programming.
WTF 386 was for me a sci-fi like device I wouldnt dare think about having when I was a kid. I had a very nice 8086 I cherished, with VGA video no less ! (Yes driving a vga card with a 8086 was slow..
Ahhh I never saw donkey.bas, and only saw the Microsoft one. You know, when that company cared about being part of the industry, as opposed to being the entire industry, and really want to be 5 other industries to, as they do now.
Gorillas.bas (it's more or less like worms, except with only 1 gorilla per team)
Nice. First DOS I actually installed was Dos 6.22 and first one I worked on was DOS 5.0. Never actually used gwbasic, I was stuck on Commodore 64 until DOS 5.0.
DOS 5 is when edit and qbasic were introduced, after the DOS 4.0 failure.
Similar experience I was stuck with Timex 2068 until the 386SX kind of became affordable enough for leasing, however our school had computer labs, thus I did my typography lessons on MS-DOS 3.3, on nice 5.25" inch floppies.
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
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.
This is fantastic! As one of those kids who spent the early 90s in QBasic, thank you!
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.
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.
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
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.
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?
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
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.
Nibbles!
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.
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)
Are you sure? https://www.reenigne.org/blog/8088-pc-speaker-mod-player-how...
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.
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.
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.
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.
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.
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!
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?
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.
I once heard a digitized version of "Daisy Bell" (DAISY.COM) which sings through IBM PC speaker although of poor bitrate.
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.
> 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.
> 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.
Brings back memories of GORILLA.BAS! https://en.wikipedia.org/wiki/Gorillas_(video_game)
For those who don't know why GORILLA.BAS is so cool... Back in the day, computers were expensive and games weren't readily available. Sometimes a parent would buy a computer for word processing or spreadsheets or take kids to the office which also had business computers. Children were curious about the computers but there wasn't really anything fun to do with them besides banging on the keyboard...
...Until you found the BASIC dialect that came with MS-DOS, that is! GORILLA.BAS was bundled with DOS and was a fun little game you could play in those computers. It's not like you could access web games on the Internet - there was no Internet!
It was also a very educational experience to start messing with the code until you broke it - forcing you to figure out how to fix it, to get your game back.
At my age, getting my game back sounds fabulous
Yes, when did we start messing with the code? We need to fix it?
My earliest coding memory is messing with the gorilla code to get an advantage playing this against my brother…
My first ever hack was turning off collision detection in nibbles.bas so I could worm right through walls.
this reminded me I gave myself infinite lives in a GNU version of Nibbles (not really the same game but a drastically expanded one) so I could see all the levels.
> Back in the day, computers were expensive and games weren't readily available.
You could get a PC for a thousand bucks back then, and shareware was a thing in 1990-91. Crystal Caves, Commander Keen, Duke Nukem were huge hits and there were tons of less popular games...not to mention copying commercial games from friends.
Crystal Caves! I've been trying to remember the name of that game for ages! I never bought the full version but played the shareware endlessly...
There's a (presumably) excellent modern port of it a available on Steam: https://store.steampowered.com/app/1330890/Crystal_Caves_HD/
I say presumably because I played their excellent Secret Agent HD port but haven't played Crystal Caves yet.
There are also infinite clones of it. But I'm not aware of any open source one yet
$1k in 1990 ~= $2.5k today.
And that would get you a system that was fairly anemic even for then. There were still some 286 systems being sold then which was 2 full architecture leaps behind at a time when it was starting to become very important.
> You could get a PC for a thousand bucks back then
In the United States... In a lot of countries, computers cost a lot more than that in the local currency which, together with lower salaries, made computers inaccessible to most people.
I remember seeing people playing GORILLA.BAS in computer stores...
Which is why in many countries we stayed on the Speccy and C64, until 386SX were already widespread.
Just as importantly - it was an all‑in‑one. I think a lot of people tend to forget that there were already plenty of earlier BASIC dialects (GW‑BASIC, Apple II BASIC, C64 BASIC, etc).
However QBASIC was likely the first freely available, all‑in‑one "batteries included" environment that came bundled with MS‑DOS 5 with a relatively friendly IDE that had built‑in help for every single command. GORILLA.BAS and NIBBLES.BAS were the gateway drugs for many future programmers.
Basic and Qbasic represent a part of computer culture that has been lost a little bit. It was the idea of making computers programmable to almost anyone without having to have a deep knowledge of how the system works.
I'm not saying we should go back to BASIC but that spirit of easy to build has been lost a little. Nowadays you need to pull in like 40 dependencies before things can get really moving. Yeah it is OK after that but the barrier to entry can be a little tough at times. This is the same complaint I have about multimedia on the web, Flash solved the issue in a terrible fashion but the core idea was great.
100%. I actually loved Flash for what it was. I get that it could definitely become convoluted especially when you were jumping between various keyframes, some of the control flows could get really messy.
But just like QBASIC, it was a “batteries included.” environment. That’s what made it so compelling.
QBASIC was the same way. It's a literal siren song for inquisitive kids to just experiment, because everything is right there. Like you said, there’s no importing libraries. It’s a completely self-contained sandbox of possibilities.
If you have a question, you just slap that F1 on your buckler-spring mechanical keyboard and boom there’s documentation/examples.
Only if you ignore the 8 bit home computers, we got all BASIC interpreters and machine code for free with each one.
And there were "IDEs" that sometimes were offered in cover tapes, at the expense of even lesser RAM, I got one for the Spectrum.
And the 8 bit computers with at least 128 KB, already could run CP/M, which opened the door for better BASICs, including compilers.
Definitely. I've used a few of them (Commodore BASIC, Applesoft BASIC) as a kid.
I could have worded that a bit better. What i meant was that as far as I'm aware, QBASIC was the first free OS-bundled fully featured BASIC IDE which even by today’s standards still kind of holds up:
• find and replace
• split panes
• an immediate mode
• debugging
• breakpoints
• built‑in help for every basic keyword and command.
• editing any lines (no need for line number at multiples of 10 to insert and modify at a later time)
Even as someone that grew up with GW-BASIC and had moved on to Turbo Pascal by the time qbasic came out, I must say you have a point. I think however that the more traditional BASIC "IDE" with line numbers etc, used in GW-BASIC, has its charm and is still fun to play with. It's quite unlike any modern IDE, but there is some logic to it and with some practice it isn't bad for what it needed to do.
You already had Turbo BASIC by then, what the OP is right about is QBASIC being freely available.
In terms of commercial products, there were already a few to chose from, including the big brother Quick BASIC, which introduced its IDE in 1986.
QBASIC was a subset from QuickBASIC 4.5.
Oh definitely! Some of my earliest memories were my dad helping me type in basic programs that were listed in the popular COMPUTE! magazine back in the day.
It sounds kind of crazy now but we genuinely used to buy computer magazines that had basic code printed in them, to try the game you would type the basic into a file, save and then run it.
Before that we had the BASIC dialect that came with ROM on power up. :)
And this is how we got many of our games from the local library, or bookstore, Atari as example, but similar existed for the other 8 bit home computers,
https://www.atariarchives.org
GORILLA and NIBBLES!
I was more of a Nibbles[0] person. I played it with other people on my XT-class laptop in high school.
[0] https://en.wikipedia.org/wiki/Nibbles_(video_game)
I’ve got the music in my head just from seeing it written down. And the sound effect from gorrilla.
Yeah it's very iconic. It’s actually the same melodic motif that’s played in the intro of GORILLA.BAS and NIBBLES.BAS - it’s a short snippet from Tchaikovsky’s 1812 Overture.
Kind of reminds me of how most people don’t know “Korobeiniki” (Коробейники) by name, they just call it the Tetris song.
I love the 1812 Overture, in part, because it has artillery.
"Oh, yes-- I play in the orchestra. I am in the auxiliary percussion and artillery sections."
Haha, symphonies with accompanying armaments really make you appreciate where you’re going to be seated as an audience member.
Everyone loves it for being a song with cannons in it. Must be a lame way to be remembered though. People like Beethoven and Mozart for, you know, their actual music. But Tchaikovsky? CANNONS!
My favorite is MONEY.BAS
We used to do quick tests of PC builds with GORILLA.BAS. It was later replaced by the 'Doom test'.
GORILLA.BAS got me into programming decades ago. I made an (admittedly partially vibe coded) homage this year: https://gameswithtony.com/gorillas/
First code I ever edited.
First time I played it was 8th grade, in Randy Seaman's Algebra class. He also had wolf3d on that machine.
speaking of GORILLA.BAS I made a multiplayer browser room: https://franz101.github.io/gorilla
I remember hacking GORILLA.BAS code, which was on our office computers, to randomize gravity for my opponent, the result being they could not accurately predict where their bananas would go. I was an unbeatable legend for a while.
For anyone unfamiliar with DONKEY.BAS: it’s notable for having been co-written by Bill Gates. More info on its history bere: https://en.wikipedia.org/wiki/DONKEY.BAS
2nd, the wikipedia article has some fun stuff in it
Inspired by the 45th anniversary of the IBM PC, I got my slopmachine cracking on a port of DONKEY.BAS to work in a browser. Pretty happy with the result. As a young person I remember being fascinated that you could make a game like this with so little code.
nothing novel? just a generated port?
- https://gorillas.zone
- https://codepen.io/manz/pen/RmEQgv
- https://github.com/rizwan-virani/gorillas
- https://github.com/theraccoonbear/BrowserGORILLAS.BAS
you can play as the donkey cheat mode sexy bill
> I got my slopmachine cracking on a port
For 131 lines?
The game theory is all wrong, this is a cooperative game, either they both win or both lose. I don't see how the Donkey getting hit by a car should be classified as "Donkey wins"
Donkey is also a collective noun for the donkeys and so the army that is the donkey wins.
¡Viva Donkey!
I once heard the rumor that DONKEY.BAS was the last piece of code Bill Gates wrote himself at Microsoft. I wonder if it's true.
That has all the hall marks of urban legend, but why let the truth get in the way of a great story.
I have said it for a very long time, Gates wasn't innovative in technology but he absolutely innovated in bringing the most ruthless business practices into software.
Feel free to correct the Wikipedia entry (which does not say anything about it being his last contribution though): https://en.wikipedia.org/wiki/DONKEY.BAS
And you may also want to correct this one about the Pancake Sorting algorithm he invented as a student that was not improved for another 30 years: https://en.wikipedia.org/wiki/Pancake_sorting#The_original_p...
Someone gave my grandfather a Games BASICA floppy that had this and other games on it. But this copy had a few games that had been "modified". I remember in DONKEY.BAS, it would curse at you if you hit the donkey. "YOU STUPID SONOFABITCH". We thought it was hilarious. My grandfather was less pleased. He took it away from us when he found out.
I learned most of the best cursing I've ever done from my grandfather. He took pride in teaching his grandkids to curse.
He was involved in setting up the radar systems at Pearl Harbor, much good that did.
Modifying those games were the first times I ever touched code! There was one that existed somewhere between DOS 2.0 and 3.2 that simply asked your name, then asked how the hell you got that name. It was maybe half a dozen lines, but easy enough to modify output and learn a bit about variables.
As a kid I modified DONKEY.BAS for my younger brother who wanted to play as a donkey avoiding cars. It was a clumsy modification, I didn't account for the differing size of the pseudo-sprites, but it made him happy.
Donkey running on a PC 5150:
https://youtu.be/kmCMkD1vv0E?si=RqGhqIC-EHVhXnDI&t=145
That video should totally have this as the soundtrack beneath it:
https://m.youtube.com/watch?v=Z3qRXDGApNU
> 1296 PRINT "THIS PROGRAM REQUIRES ADVANCED BASIC -- USE COMMAND 'BASICA'":COLOR 15,0,0:FOR I=1 TO 9000:NEXT: RESUME 1298
TIL there is an “Advanced Basic”. I hope the naming was tongue in cheek.
Is it an easter egg that I can move the donkey with A/D rather than move the car with Space?
yep. gamer
my car keeps hitting the donkey when switching lanes even though I'm already well past it..
have you had anything to drink recently?
Officer, I'm not going to discuss my day with you.
I haven’t looked at the code but the collision detection was buggy even back in the day. You have to switch lanes while there is nothing or a donkey in front of you. If the donkey is in the other lane it registers a hit even if it looks like you passed it
Edit: line 1750 is where it does a simple collision check and yep looks like it registers a collision without checking you’re past the donkey or not
It says something about what a thoughtful development environment these early BASICs were, that you could make a full simple little game like this in only 131 lines even though they're ostensibly far less powerful than modern languages. I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
Never mind how compact, beginner-friendly, and just plain fun they were to use. It's been said countless times but I'll say it again - we've lost something over the years.
raylib might do it in less lines. SDL is designed as a cross platform base layer to wrap in another framework not as something you should be using directly.
I usually recommend the inexperienced do at least 1 project in godot:
https://godotengine.org/
Then port it to UE if they are interested in skill reuse for future projects:
https://www.unrealengine.com/
SDL has a lot of issues, and falls into the "only if you must" category. Still better than .NET or Java in many ways, as spacial audio is easy in the mixer. =3
Python is the modern Basic replacement, and also has similar fundamental design trade-offs. VB6 was the peak of the OLE/Multimedia paradigm, and was functionally replaced by the web browser script sandbox.
> we've lost something over the years.
Indeed, Information Appliances were never general-purpose computers. Some people used to care about that sort of thing, and left civilization the GNU compilers as one of the most important intellectual artifacts of our generation. =3
It was really cool! The ease of getting started was definitely one of the selling points for the “home computers” of that era (GW-BASIC ran on IBM compatible PCs instead, but the appeal of BASIC was the same). Brevity was an important feature since a lot of people obtained programs by typing them over from a magazine or recording them from the radio. And of course, there was no such thing as auto-complete (let alone AI generation).
That being said, SDL isn't actually that bad either. A minimal example is about 40 lines of code [1], not counting comments and blank lines, but including lines with just a curly brace which you could easily remove if you were concerned about size. A slightly more serious implementation of Snake runs about 345 lines of code [2].
And to be fair, DONKEY.BAS is also cheating slightly on the line metric by stuffing lines full of statements, like for example:
1. https://examples.libsdl.org/SDL3/renderer/01-clear/ 2. https://examples.libsdl.org/SDL3/demo/01-snake/
>I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
The basics (window, events, renderer) can be done in about 30 lines:
I don't think you could get all of donkey.bas done in 131 lines, though. SDL3 does ship with an embedded debug font but that seems like cheating. You probably couldn't replicate the drawing code easily, it would probably need to be faked with images, and you'd need a font atlas for the text.
131 lines and about 10% of them are the title/copyright banner. Genuinely impressive in it's terseness
Nearly a quarter of it is checking for necessary prerequisites, too.
What we lost is simplicity across the stack.
I learned to program with BASIC. It was awful. I didn’t know how awful it was until many years later. So I don’t miss the language. But something I miss is how easy it was to learn what your machine was doing.
The DOS boot and config involved only two files: CONFIG.SYS and AUTOEXEC.BAT, that was it. Most programs were self-contained, so you could copy the directory to a floppy disk and run them on another machine. If you broke something, copy the files again and restart; that was it… I “broke” config and programs many times, and it was a good way to learn.
BASIC was higher level (or anyway, more batteries-included) than C. You could probably do this game in 131 lines of javascript straightforwardly.
BASIC was the whole OS in 8 bit home computers.
Other than that, either you would have machine code via DATA statement, be lucky that there was support for entering Assembly like on the BBC, or have the opportunity to actually get a proper assembler.
Back in the days you would buy printed magazines that contained full basic source code of programs and games and type them on your own text editor. I was a bit too young to do that but I remember watching my older brother just do that and then play games (after finding the typing errors for a while).
On my machine, it is flickering like _crazy_, as if it's trying to shift back and forth between two resolutions.
OSX, Firefox, browser size 3326×2830 pixels. Only happens at or around that particular size - resizing the window fixes the issue.
maybe fixed. https://github.com/jkrauska/DONKEY.BAS/pull/4
Also, on reflection, I think the firefox window size is half of what I reported - I'm not sure what OSX does to its screenshots, but using SHIFT-CTRL-CMD-3, it's reporting about half that size. Not sure if that makes a difference to your changes (likely not).
So simple, so cool, so much fun :-)
My perceptron can play this game, I think
https://github.com/victorqribeiro/carGamePerceptron
Related:
Happy 45th Birthday to the IBM PC and Model F/XT
https://news.ycombinator.com/item?id=49280103
Clearly this needs to be replicated as GTA minigame.
I’m partial to Gorrila.bas
It turned out that Dino run has deep roots
Surprisingly fun!
A greyscale photo of a donkey appears if you lose badly enough. Surely that wasn't possible in basic with 16 colors??
EDIT: That must be the easter egg mentioned in the repo.
A dithered, meme-y photo of Bill Gates appears if you win 10 times. That probably wasn't in the original, I'm guessing?
tangential: I still remember how disappointed I was in PCs being used to a C64 (which was released in 1982) The quality of the games & sound effects was just not on the same level (C64 being much more advanced)
PC was a clear winner for RPGs, adventure games, and wargames/strategy, even in the early days of PC/XT. Anything that could make use of more RAM and disk, while also not demanding too much of graphics or audio, was great on PC.
This is what got me into programming. When I was a kid, I had a shitty 386 because my father got a computer second hand from a friend (we were poor). I was playing the game and then pressed a key and it took me to the basic editor. I was confused with what I saw and started changing things. I changed a number and the size of the explosion on the banana got bigger. My best friend at the time went to computer camp and explained to me that it was code. 30 years later I'm still programming.
WTF 386 was for me a sci-fi like device I wouldnt dare think about having when I was a kid. I had a very nice 8086 I cherished, with VGA video no less ! (Yes driving a vga card with a 8086 was slow..
Ha yes, PC XT clone here! And then eventually, a 486SX around 1993, which was my first foray into Linux.
Ahhh I never saw donkey.bas, and only saw the Microsoft one. You know, when that company cared about being part of the industry, as opposed to being the entire industry, and really want to be 5 other industries to, as they do now.
Gorillas.bas (it's more or less like worms, except with only 1 gorilla per team)
On the plus side: it was much prettier.
Donkey was for basica/gwbasic. Gorillas was for qbasic, like a decade later.
Nice. First DOS I actually installed was Dos 6.22 and first one I worked on was DOS 5.0. Never actually used gwbasic, I was stuck on Commodore 64 until DOS 5.0.
DOS 5 is when edit and qbasic were introduced, after the DOS 4.0 failure.
Similar experience I was stuck with Timex 2068 until the 386SX kind of became affordable enough for leasing, however our school had computer labs, thus I did my typography lessons on MS-DOS 3.3, on nice 5.25" inch floppies.