I’ve always been fascinated by very efficiently
programmed games or demos. The Atari 2600 is an interesting example on
its own since the early games like Pac-Man had to fit in 4K of ROM. While later cartridges ended up using bank
switching to get 8K or even more, the early games really had to be coded very efficiently,
and often meant sacrificing complex features of the game. But if you think 4K would be tough to code
for, how about 2K? My friend Robin Harbron coded this little
game called Minima, which is a play on words for the Ultima games. It’s a little role playing game that fits
in 2K of code. Very impressive. But can you go even smaller? Well, yeah. Here’s another one. This is called “SPlatform” and fits in
a meager 1K of RAM. So, to put things into perspective, how much
is 1K exactly? Well, each of these dots represents a single
byte. And here’s 1,024 of them. Now, you’re typical assembly language instruction
takes up anywhere from 1 to 3 bytes. So, you could probably have a total of around
400 actual instructions. But that wouldn’t leave any room for data,
graphics, sound, or even text. So, it would be a very delicate balance between
instructions and data. But what about even smaller than this? Indeed, could games be written in just 512
bytes of RAM? It turns out, yes they can. In fact, 512 bytes is a magic number because
that means it can fit into a boot sector! So, just a refresher here from my floppy disk
documentary from a couple of years ago. Your typical 360K floppy disk for an IBM or
compatible has 40 tracks starting from the outer rim to the inner core. And then the disk is divided up into 9 sectors
like this. The boot sector is the first sector of track
zero. And as you can see, it’s a very small portion
of the disk surface. Of course, that’s a 360K disk. What about the more common 1.44 MB floppy
disk that most people are familiar with? That format has twice as many tracks, and
twice as many sectors. But a single sector is still just 512 bytes,
so that means it is an even smaller portion of the disk surface. So, what does this boot sector do? Well, the BIOS is in a ROM chip on the motherboard,
but that’s not really an operating system. So, the BIOS has just enough code to read
the boot sector into RAM and then execute it. But the boot sector isn’t big enough to
contain a whole operating system, so it’s purpose is to load the real operating system
into RAM, such as DOS, Windows, or Linux. You might be surprised to find that, at least
on the IBM PC and compatible computers, every floppy disk and hard disk has a boot sector. And, there’s a program installed on every
boot sector, even if the disk is blank. Have you ever accidentally left a floppy disk
in the drive during boot and see the message that says “Invalid System Disk. Replace the disk, then press any key.” Now, you might think this message is coming
from the BIOS ROM. And that would be a good guess. But if that were the case, then how would
you explain this. When I put a different blank disk in, the
message changes. Now it says “non system disk or disk error.” What’s the difference? Well, the first disk was formatted with Windows
95, the second disk was formatted with MS-DOS. And that message you seen the screen is actually
a small program in the boot sector of an otherwise blank disk, which displays this message. Using a sector editor, you could actually
change this message to anything. For example, I changed the message on the
Planet X3 disk so that it says a custom message, and then continues to boot to your hard drive
if you have one. Boot sectors were also historically targeted
by viruses. The viruses were just small programs that
lived in the boot sector and then they would load the operating system afterwords. And then, they would copy themselves to either
the boot sector on your hard drive or other floppy disks and because the virus loaded
in the boot sector, that means it loaded before the operating system, giving it a higher level
of control. Now that you definitely know what a boot sector
is, can you imagine how hard it would be to write an actual game that fits in just 512
bytes? Well, what I have here is a space invaders
game written by Oscar Toledo. And the whole thing is on the boot sector. And I want you to watch how quickly this boots
up. Keep in mind it hasn’t even finished the
power on self test yet. And there it is. I want to illustrate this from a different
angle. See there, that’s the floppy disk light
during the test cycle. The next time you see that light, that means
it’s trying to boot, so watch how quickly the game starts after you see the light. Its super fast, not only because there is
no operating system to load first, but because the drive’s head doesn’t even have to
seek. Literally, all it takes is a single revolution
of the disk to get the boot sector read into system RAM. Of course, this isn’t the best version of
space invaders ever. Its very clear that many concessions were
made. For example, there is no score board, no UFO
across the top, and all of the aliens look exactly the same. Oh, and there are no sound effects or music
either. But still, you can’t deny the skill involved
to make this fit in a boot sector. So, besides space invaders, what other games
are out there? This is another one. It’s called F-Bird, and if it isn’t obvious
it’s a knock-off of flappy bird. Only, this version runs in text mode, using
only ASCII characters for the graphics. One interesting thing about this game is that
I think it’s the only one I have to show you today that actually has sound effects
of any sort. Here’s another one, this is called Pillman. I guess because he eats so many little pills. With all of those ghosts chasing him, I hope
they are Xanax. Anyway, this one also runs in VGA graphics
mode, but there’s something I find very interesting about it. If you look down in the bottom-left corner
you’ll see some weird flashing pixels. It looks like about 20 of them. I suspect what is happening here is that the
author of this game is using the extra screen RAM as variable space for the game. You can actually see specific changes, for
example, when Pillman changes direction. Which means, this game may only need a couple
of dozen bytes of RAM for variables. It’s really blurry trying to zoom into these
from a screen capture, but here’s a still-shot from DOSBOX. This is reminiscent of the Atari 2600, since
it only had 128 bytes of RAM. Speaking of DOSBOX. Many people may be wondering how I’m booting
a raw disk image like this from DOSBOX. Well, it’s actually quite easy. So, once you have DOSBOX open, you just type
the command BOOT, following by the path to the disk image you want to use, in this case
TetrOS. I assume that is an amalgamation of the words
Tetris and Operating System, since the game is its own operating system. So yeah, this is a very playable version of
Tetris, that fits completely in a boot sector. There are other things besides games. For example, this is a functional version
off BASIC that runs from a boot sector. This is one of the example programs you can
type in, which creates a pascal triangle. This version of BASIC is very limited, however. It has a very limited command set, and each
line can only be 19 characters long. So you aren’t going to be able to make anything
super exciting. Plus, I don’t think there is any way to
load and save your work. OK, now being realistic for a moment, none
of these games are that great in that you’re not going to want to sit down and play them
for hours on end. I suspect the people who wrote the games probably
had more fun writing them than they did playing them. And of course, that’s the whole point of
these games is to challenge one’s self to see, you know, how much you can fit into a
very confined space. And so, I just, I have a great admiration
for anyone who can fit a game into 512 bytes of RAM, but anyway that’s actually all I’ve
got for this episode, so stick around for the next one and thanks for watching!