Okay, then we'll start. Well, everyone's now seen all of the slides, so we can just go
down the pub. So, as this part of the slide says, my name is Steve, and as that part of
the slide says, I'm a bit of a geek. Now, if we've all turned up to the right room,
this is a talk about old computers and emulation and things that I've learned about old computers
through emulation. Over the course of the next 20 minutes or so, I'm going to look at
why emulation is really quite fun. I want to mention these seven things that I've learned
over the last year or so, and then the honoree mentions there's some other stuff that I found
that was too good to go to waste. So, before all of that, who am I? What have I done to
earn a place on this stage? Or is this slide should really be called? It's the ego slide.
Well, the speaker brags about themselves for 10 minutes while everyone else gets bored.
My slide has that on it. That's not a computer. That's Lego. Yeah. So, who am I? Well, I'm
a game developer. I've been a developer for quite a few years. I've written console games.
I've written mobile games. I've written a book, 20 Go To 10, which was crowdfunded last
year. And it's a very good book on old computers, because that's essentially all I do. I've
spoken at this conference a few times before, and I still haven't got it right. So, everything
that's on that slide is not really that useful. It's about what's not on that slide. I'm not
a professional retro developer. I haven't built, you know, the Vega. I have not built
the new Commodore 64 machine. Everything that I have done with retro has been just me having
a fiddle around with electronics. Essentially, that's a long-winded way of saying, if I can
do this, anyone can. So, why is emulation useful? Well, it just is. And it isn't necessarily
about games. It's about being able to see the machine. How does it boot up? How does
it start? What goes on behind the hood? And you can do it safely. You can't break anything
when you're running this stuff through an emulator. So, where should we start? The
Jupiter race. Each of these, I'm going to mention a couple of emulators that I've used
and experimented with. Obviously, Mamers probably got all of these anyway, but Mamers is too
big for me to compile. I like the smaller emulators because I can compile them easier
and I can actually see. That way, I've got the development environment of the emulator
and I can then run it through GCC as well. So, what did I know about the Jupiter race
before all of this? Well, it uses FORTH. The first thing anyone will say about the Jupiter
race, well, it programs in FORTH. And it's just like a ZX81 because the guys, Vickers
and Al Vassa, worked on the ZX81. They also worked on the beginning of the Spectrum. And
they said, why is Clive Sinclair making all this money on our computer? We could build
a computer of ourselves and we could make all the money. And they did. Unfortunately,
they didn't sell any machines. So, they made all the money of about 4,000 quid. But it's
a very nice machine and the prices of the army bear just stupid. It is why I don't have
one. And when I said it's like the ZX81, it's very like the ZX81. This is the code
from two different emulators that reads the keyboard. Can you spot the difference? No,
there isn't. Well, there is. There is one difference. Jupiter 8th added an extra shift
button in the bottom right. And that's the only change between the two machines' keyboard
code. One thing. What else do we know? Oh, it's got a font which is stored in memory.
And this was really interesting. Because the font is stored in memory. But this is the
font, but it's not stored like that. Well, if you have a look, look at some of the...
It's stored here. That's not a very big memory location for the code. So, what's it actually
doing? Well, if you look at letters, you know, some of these, they can go below the line.
But most don't. So, and you've got some things which go to the top and some that don't. So,
if you've got a capital letter that doesn't go above a line and go below the line, why
do you need all eight bytes to store that letter? You don't. You just hot chop the top off.
And then you write a piece of code that puts that byte back in before you render it. So,
they managed to save a whole chunk of code. The graphic symbols you see at the top, they're
not stored in memory. They're generated by code. Again, you've saved another 200-something
bytes by doing that. In fact, the only symbol in the whole font which is copied in its entirety
is the copyright symbol. It's the only one that uses all eight bytes. And everything
else is just modified some way. And it took only 64 bytes of code to do all of this munging.
So that's quite a big saving over every single top and every single bottom of each letter.
Next machine. Oh, there's a couple of murmurs for that one. Good. It's one of my favourites.
Obviously, when anyone mentions the Welsh computer industry, they have to mention the
dragon because it's pretty much the only one that existed. But it's a great machine.
The 699 processor is a phenomenal piece of work. Wonderful machine. It's also told it's
a bit of a rip-off of the Tandy Coco. It isn't. Both the dragon and the Tandy Coco were based
on the same reference design that Motorola put out to basically sell their chips. So
they both used exactly the same setup. The other thing that people know about the dragon
other than the fact it uses Microsoft Basic is green. The video chip defaults to green.
Which colour green? That's colour green. Seriously, dudes. Why you thought that was a good thing
to boot up to in the morning? It means your games look like this. Now, luckily, someone
had the bright idea that you could actually just not use the colour. Build all your games
in black and white because then they look a bit better. And they look like this. Which
is fairly respectable for a machine from 1982. This one is Jet Set Willy. Very well known
that the 48K Spectrum had Jet Set Willy but the much smaller Dragon 32 had Jet Set Willy
with more rooms in it. Because they did all the graphics in black and white so there was
less colour needed so they got more data space and of course the processor was a lot better
than the Z80. What else do we know about the dragon? Yeah, that's its font. It's not very
pretty I'm afraid. But this is the bit that I found interesting. This sets up the graphics
mode. At no point are you actually sending data across the bus. If you write to a memory
address ffc6 for example, it will set a bit. It doesn't matter what data is on the data
bus, it's just not read. If you write to c6 it writes a 0 bit, if you write to c7 it
writes a 1 bit. You can send data by just writing anything to an address. That I thought
was a really interesting approach. Turns out it's not the only machine to do it. Turns
out ARM did it as well. The Archimedes, they just said right we're not going to connect
the data bus to this chip. It'll be cheaper and then we'll write data to it just by toggling
addresses. Nice clever way. So what computer's coming next everybody? It's the Game Boy. Pretty
sure most people have had one of these. They're a bit like the Nokia phones of their era. You
drop it on the pavement and the pavement cracks. That sort of thing. So what did I know about
the Game Boy? Well there are so many emulators out there that emulate this and some variation
of it. Four shades of green and had a version of DRM. Now I know where we are so I'm pretty
safe in saying DRM is a bad thing. But this is what they did. Now that's currently obviously
too small for you to be able to see but that's not important. What's important is that it's
all on the screen. That is the first 256 bytes of the Nintendo Game Boy ROM. And in this lot
it has to set up the graphics system, the sound system, it has to do its copy protection
on the cartridge you put in to make sure it's an official cartridge. And it does that in
that 256 bytes of code and then this is the bit that does the check. You put two pointers
into memory, one into the cartridge that's been inserted and one into the 256 bytes of
ROM and it says okay if all of these bytes in the cartridge match all of these bytes
in the ROM then it's a legitimate cartridge. You're allowed to play and the game game continues.
But what bytes are these? Well there's not many of them, you can see it goes around the
loop and if it doesn't match the machine just locks up, that's fine. Well these are the
bytes that it checks. Can anyone spot the pattern in those bytes? Let me show you in
a graphical form. Anyone spot the pattern in those bytes? The logo that comes up when
you switch on the Game Boy is that? It's in code. So it checks for the Game Boy Nintendo
logo at the start. This means if you're doing a dodgy cartridge you have to copy the Nintendo
logo into your cartridge. This means you are committing a copyright law infringement and
because it's a logo it's a trademark law as well. As much as I hit the other thing whoever
came up with that idea, that was a smart idea. I just disagree with it. Pac-Man. Originally
called Pac-Man I can't think why they would change the name. It's a lovely little machine
and it's incredible when you consider how much memory it has. 3K of memory for a full
screen of color graphics. Now the way that it does this is through tiling and through
a lot of clever hardware. But the bit that's interesting is how it's laid out. Again you
don't really need to look at this but if you come up close the memory goes in this direction
then in that direction then in that direction then down the other side. It's a weird way
of mapping. But it means that when you get to level 256 this happens. I don't expect
anyone to have got there but thanks to emulation I can write one byte and I can actually play
level 256. Now it looks like the screen is all corrupt because some kind of graph, it's
not. You know when you're playing the game and you get oranges and strawberry and fruit
in the middle of it here? That's what it's trying to draw. They never thought anyone
would get to level 256 so they never had a piece of code that checked the number of pieces
of fruit that it should draw. And this is just running over all memory drawing all the
fruit that it can find and then the rest of memory that it can find. That bit there, brilliant.
So Pac-Man done. ZX81. Any fans of the ZX81? I was expecting a bigger cheer to be honest.
We've got two fans over there. First machine I ever had. Don't worry that's not one of
my security questions. 1k of memory. 1 kilobyte. No colour, no sound, it's complete moot.
But we had a chess program that ran in 1k. There was a 3D monster mice, not 1k but still
3D games on a piece of plastic, basically a black plastic cheese wedge. You could get
a 16k RAM pack. Wow, think of all that extra memory. What can you do with that? A very
interesting fact that I found out completely by accident. I was taking a photograph of
this for the book and there's a big story about the ZX81 RAM pack wobble. And because
this RAM pack is set on the back of the machine it does this and then it crashes. Well people
solve this problem by blue tack and with glue. Some people solve the problem by just buying
a better machine. I solved the problem by actually sticking the two together with screws
and really folding it in nice and tight. I thought I'm going to get a picture of this
and this famous RAM pack wobble thing. So I measured the angle between the ZX81 case
and the 16k RAM pack. It's 16 degrees. So what did I find out about the ZX81? Well
how does it know there's a 16k RAM pack in there or not? Well it just tries everything.
It just writes to every memory address it can find and when it's on it says oh hang on
I've got no memory addresses over here it says well that's where your memory stops. Just
writes data into it and then reads it back again. Very simple but effective. The grown
up version of the ZX81 was the spectrum. This one did have colour of sorts. It had sound
of sorts. It went beep. But what a machine. There are so many emulators for this machine
it's not even funny. Even I've written one. But what can we say about the machine or the
keyboard other than being rubbery dead flesh thing? It's how the keyboard's read that's
kind of interesting. And it works this way. A Z80 machine has an input output system using
memory and an input output system using ports. So you can communicate with systems that aren't
based on a memory bus. So what does it do to read the keyboard? It does an out request
onto a port and if there is a zero in any one of these bit positions it means the key
is down. Well a traditional thing in a lot of these machines of the early 80s it would
always be negative logic. So if you have zero zero zero zero for example in that it means
all of those keys are down. Which funnily enough means it's quicker to check for five
keys being down than it is to check for one key. Because if you want to check for a very
specific key you've got to check the individual bit. Whereas if you just don't care about
it you just say right well if it's not if it isn't one one one if it's you know it
will just trigger as one of these keys is down. That's all it needs to worry about.
And finally of our seven the Commodore 64 which I'm kind of contractually obliged to
sort of put in since I put in Sinclair as well before. Commodore 64 what can we say?
Well it's a bread bin and there are far too many emulators as well to mention. It was
originally called the Vic 40 because the one before this was the Vic 20 and by a nice coincidence
40 in hex is also 64. A lot of memory 64 kilobytes of memory. 64k of memory hang on
wait a minute how does that work? How can you have a machine with 64k of memory in?
The address range is always 64k. So you've got 64k of memory and that's all you could
ever get. Where's everything stored? Where's your basic interpreter? Where's the system?
If you've got 64k of memory there's not enough room to store the system. Well this
is what it did. It gave you all the memory and they said actually no I need this bit
for my ROM. I need this bit for the SID chip to do the sound. I need this bit for my kernel.
So essentially you don't have 64k of memory. It's all hidden by the ROMs. But there was
an instruction you could call which was that and it would basically say yeah I know there's
a basic ROM over there but really I know machine code. So just ignore the ROM and it just switches
the whole ROM off. If you don't want to use the kernel or the system ROMs there to do
the rendering to the screen you can just say well I know where the screen data is I'll
just write to it directly so you can turn that one off as well. And essentially if you're
prepared to go the whole machine code route you can just turn it all off so you've got
64k of memory. That's the only way you could have done it. So what are the other mentions
that we should do? Well I should probably mention the X81 again because it is just an
amazing machine. I also have to mention the Game Boy again obviously not so close as the
brilliant emulator but one of the talks later on is about the Game Boy emulator and they're
in the room and I don't want to offend them. Isn't that right? The Spectrum, the Jetpack
game, there's a couple of things I'm using about this game. One, very good game. The
people who wrote it later became rare that did Goldeneye. This drew the screen backwards.
Most people think when you draw a screen you start at the top and you go down to the bottom
right? That's how you do it. Well they couldn't do that because their code was a bit slow
so what they realised is if I'm drawing the screen this way if you don't get to the bottom
of the screen before the TV gets to the bottom of the screen you only ever get half a screen.
So what they did is they drew it backwards. You start at the bottom and go up to the top.
That way it doesn't matter if your game is too slow you're only ever going to get the
crossover once per frame worst case scenario. So as the screen is refreshing this way you're
rendering that way and if you ever see a little black line when you play Jetpack that's what
it is. It couldn't render the screen quick enough and it's just missed the flyback code.
The other thing is it's also 16K game which means you can fit it onto a cartridge and
this cartridge can take the place of the Spectrum ROM and this was a very unpopular thing. I
mean you'd think you know games laid, who remembers cassette tapes? I've suddenly realised
we might have an audience that have no idea what a cassette tape is. These games were
loaded off cassette and they would make a screechy noise. That sort of thing. That's a good rendition
let's play. I'm sure somewhere, somewhere can actually sing the sound tunes from the Spectrum
and actually load them into a machine. That's probably possible. I don't have pitch perfect
but I'm sure it's possible. So they think why would I want to listen to seven minutes
of screechy noises? Surely I just want to put a cartridge in. So Sinclair made a cartridge
system. It had 10 games on it and that was it. Flop. But because it fitted in 16K it
could be done as a cartridge and because it fits in the same memory as the ROM means you
can't use any other Spectrum ROM capabilities in your code. The Acorn BBC Micro. Popular
for anyone who was in the UK during the 80s because this was the computer we had at school.
It was deemed educational enough to be allowed in the classroom. What's nice about this one
is that they have a little credits page in the ROM. Now it's very difficult to see that
on an actual real world machine because when I showed you the Commodore 64 and the ROM
was overlapping the RAM, the same thing is true of the BBC, its ROM was overlapped by
something else. So you can't read the thanks to page. But because of emulation you can
and you can see all the people they thank. Pretty much everyone and their wife and they
thank the city of Cambridge. Knop. Knop. No operation or no operation. It doesn't do
anything. It's an assembler instruction that pretty much every machine has. Just does nothing.
So why would you ever code that? Well, when you're poor like what I is, you don't have
an assembler. Most people, you know, you'd have an assembler, you'd type in some reasonably
English type things into the assembler. It would convert it into machine code and then
the machine code would run on the machine. I didn't have an assembler. So I had to hand
assemble everything by looking up in a reference book and saying I want to do this instruction,
this is the number I need to do and I type that number in manually to my machine. Now
when you do a jump that goes backwards, you have to write it in two's complement and a
jump like that say F0 is back about what is it, about 16 instructions about. But I can
never remember if it includes the instruction itself or not. So this instruction is two
bytes. So is this going back 16 or 14? No idea. So all I would do is I'd put a big stack
of knobs. So wherever it jumped to, it's going to be a safe instruction and it's not going
to mess up the machine. Turns out I wasn't the only person to have ever done that. Microsoft
Basic. If you type weight 6502 comma 1, it prints Microsoft on the screen because these
bytes are hidden in the computation for the sign function. But that's not ASCII. If you
mask off those bits, shift them around a bit, subtract something else, then it's Microsoft
but backwards and it's there. Microsoft and Apple put a lot of these sort of things. Steve
Jobs was very scared. And quite rightly so, loads of people were trying to copy the Apple
2. Very, very popular computer, particularly in America. So Steve Jobs put a thing in there
where if you went up and you pressed a special combination of keys, it would put up a big
icon saying stolen from Apple. I was going to put that on the slide. Unfortunately, copyright
means I can't put it on the slide. But I can show you Microsoft, one of Microsoft's many
little things they put in there. So with that, I shall end. My beer is getting seriously
low. I will update my FOSDEM scorecard. There we go. If you think after 23, I'd be good
at this by now, right? So with that in mind, I'll open the floor to questions or even if
you've got nice stories about old computers, this is a talk where it's acceptable to use
the phrase, this is more of a comment than a question. So with that in mind, I'll say
thank you very much and over to you. How are we doing? We've got eight minutes for questions.
Orgin, we'll chit chat, whatever we have. There is one over here. Can I tell you on
there what's the way? So what about Amstrad? Amstrad as a company, if you loved Amstrad
on I think the 5th of June 1984, you hated them the day after because they bought Sinclair.
In America, there's a show called The Apprentice. In the UK, we have a version where Alan Sugar
who created Amstrad, he had his own range of machines, CPC6664s and things like that. They
are surprisingly good machines. For a machine that sold a couple of million copies, it doesn't
sound like a lot nowadays, but back then it was a really good, well-made machine, surprisingly
enough. Unfortunately, I don't have one. Their chips are called Roland and Dave, I think,
named after the designers. It's another Z80 machine. The spectrum and what it spawned
really did say, well, we already know Z80, so we're going to go and set up our own computer
company and use the Z80 again. It's not that it was the best machine or the best processor,
but the Z80 did get used in so many things. So it's kind of disproportional to its value
as a chip. Good to hear some Amstrad here.
Yes, it was. So the question is about the, I didn't realize I was doing funnies. Yes,
so the Commodore 64 was called Vic 40 in pre-production and prototyping. ZX Spectrum
was called ZX2 during its prototyping stage. Not unsurprisingly, it came after the ZX80
and ZX81. The bit, which I'm so glad you brought it up because it's something I forgot to mention
earlier, the ZX80 that Sinclair produced was named because of the Z80 chip. It was Z80
chip with the extra special ingredient, ZX, for extra. ZX81 was called 81 because it came
out the year after and therefore was related to the year, not the ZX80. The spectrum was
called the Spectrum because it had color. Therefore, ZX81 is probably the only computer
ever named for its year of release. I've never found another one, except probably a Gateway
2000, but that's a PC and they're boring.
Yes, so the question is, do I know anything about non-Western machines, Russian, Chinese
machines, and the answer is no. Because I'm of that sort of age, I remember when there
was an Iron Curtain and it was called an Iron Curtain, whether that's politically correct
or not, I don't know. But we couldn't get those machines into the West and they couldn't
get our machines across. So they would essentially either smuggle some in or they would find
circuit diagrams and then rebuild their own. There is a massive scenario of clones and
copies and variations from what used to be the whole Eastern block. They are all impressive.
They look like they're homemade, and they just look amazing. It's just the physicality
of the machine. They are carbon copies of other spectrums and things of their ilk, but
they are lovely.
So repeating the question for the crowd, something, something, something, Japanese stuff.
Tell me electromechanical computer. How do we do? Okay. I think you're about to kick
me off, aren't you? Almost.
Just a comment. I don't know if you are aware, but reading the keyboard on the spectrum, the
last eight bits actually select each of each row of the keyboard, so you can do a very
simple routine to read. Is any key pressed by just doing a single read?
Yes.
Press any key. If it's quick, think.
The youngest machine I've made an emulator for. Tricky. It probably is a spectrum or
something like that. One of the first ones I did was a chip 8 emulator, which is an
interesting one. If you want to write an emulator, write chip 8 emulator, because the machine
never existed. It was things like the Cosmic that was it back in the 1970s. This machine
would actually run a sort of a simulator or an emulator inside itself to run the chip
8 code. Chip 8 didn't exist in the machine. It was an interpreted language that was being
run on a 70s processor. If you see any of the old TV games where you'd sort of play
a version of Pong, the chip inside that is probably an RCA 1802, which would run the
simulator chip 8 language.
It was an Apple One story I wanted to get in, but I didn't think I could get that in
the time frame. It's about the Apple One ROM. It doesn't do much. It's just basically
write data into memory, read data from memory, and execute a program. Use a jump if carry
flag, because the carry flag is always going to be set in one particular way, so it acts
like a different type of jump, because that different type of jump didn't exist. I didn't
have quite the room to include everything, because my time is up. Get lost. Go home.