Matt records from the wrong continent and explains how he taught his computer to be a 1950s television. Ben guesses his way to the secret of the colo(u?)r burst and wins today's podcast.
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Matt GodboltHey Ben.
Ben RadyHey Matt.
Matt GodboltIt has been a while, hasn't it?
Ben RadyBeen a bit.
Matt GodboltI mean, not for our listener, obviously. Our listener, it's just been a month. But for us, things... life has overtaken us. A lot of things are going on. We are, in fact, on different continents right now. And I'm looking at my sound levels, in fact, and I'm wondering how awful this is going to sound. So I'm going to just tweak something. But, yeah, I apologize in advance to the poor editor who has to edit this because I am recording... on my laptop from my wife's childhood home in her bedroom where she grew up in Birmingham in the UK, which is not where I was planning on being around this time.
Ben RadyMm-hmm.
Matt GodboltBut nevertheless, adult things happen and you end up in a different landmass. So that's me.
Ben RadyRight.
Matt GodboltSo apologies for the sound. And I still haven't actually changed it. Let me just do that now. OK. Now I'm going to start clipping and... let's see what that does. That looks... that looks better. No, maybe I am clipping now. I got excited. All right. This, my... this, dear listener, is going to be a heavily not edited at all podcast because Ben and I just need to record something so that you've got something to listen to.
Ben RadyYeah.
Matt GodboltYeah. I met a number of people claiming to be our single listener at a conference recently, which was lovely. So shout out to the many single listeners that we had there. That was good to hear. It's always nice to get feedback. I mean, like, it's a funny thing that we do, right? We just chat, talk to each other. Apparently people listen to this, which is on them, in fairness. They don't have to. We're not making them.
Ben RadyOkay. Yeah. Yeah. It's amazing. I don't understand it.
Matt GodboltSo here we are. Yeah, we have no idea, as is normal, as is usual. But I've been doing some cool things that I would have just talked to you about because normally we would do this down the pub.
Ben RadyRight. Yeah.
Matt GodboltBut again, due to 4,000 miles between us, this is...
Ben RadyYeah. I haven't actually heard about any of this stuff, so it's not going to be... Yeah, I'm genuinely interested because I have not talked to you in a long time.
Matt Godboltthe first time. So you know that I...
Ben RadyDue to the aforementioned time dilation created by you going across the Atlantic Ocean that is stretched out.
Matt GodboltIs that what it is?
Ben RadyYes.
Matt GodboltThat... it does make me wonder, because it does feel like we're in like the 1950s here in the UK, because they haven't got air conditioning and it is very, very, very hot.
Ben RadyUh-huh. Right. Right. That's...
Matt GodboltSomeone should tell them about this new technology.
Ben RadyYeah.
Matt GodboltOh, and they will not let me back in the country. Yeah. So one of the things that I got really excited about, well, you know, I love emulators. That's my thing. When I'm not forcing compilers to do things they shouldn't do, I am... emulating my childhood. And the thing that has really annoyed me all the time is that monitors are too crisp.
Ben RadyYep. Yep.
Matt GodboltI mean, we've talked about this before in a podcast, but like, you know, my very first computer, the first computer I programmed on was plugged into a portable color television, you know, full CRT bulbous screen,
Ben RadyYeah. Yeah. Right. Right.
Matt Godboltlike analog push buttons, like when radio buttons were actual, the buttons you had on radios with a physical mechanism, you press one and the others pop out, you know, right.
Ben RadyRight, right, right. Yeah.
Matt GodboltAnd then behind that was a tiny little thing you would tune to get it to the right channel. And then your, so your computer that you plugged in had to pretend to be a TV station, right?
Ben RadyRight.
Matt GodboltIt would generate radio frequency of PAL or NTSC at some frequency. You tune it into channel 36 in the UK or channel...
Ben RadyYeah, it was like three or four, I think. Yeah, three or four, something like that.
Matt GodboltYeah. In the US, right.
Ben RadyRight.
Matt GodboltAnd the TV didn't know that it wasn't actually plugged into an aerial listening to something off the...
Ben RadyRight.
Matt GodboltBut what that meant was, you know, not only was the CRT... not a perfect device. It's a very, very analog device that involves phosphors and things that... don't instantly light up and instantly fade away, which is part of their charm. But the picture quality was rubbish because you had to squirt color information down a single line. And it wasn't even like you could use a digital encoding, because this stuff had to work on like 1950s
Matt Godboltanalog components when color TV was invented.
Ben RadyRight.
Matt GodboltIt's like the worst of all worlds. But it's really, really nostalgic to see the terrible picture quality that came from it.
Ben RadyRight.
Matt GodboltAnd people would use this, right? There were tricks you could do to make colors look more blended and in some cases to achieve extra effects on a real TV that you won't get on an emulator. Anyway, this was annoying me.
Ben RadyMm-hmm.
Matt GodboltSo I thought, right, sod it. I'm going to learn how this stuff works and I'm going to make my emulator faithfully reproduce all of the things, warts and all. And so I did one pass of this and it's a... it's kind of a fudge. It's like, yeah, we need to blur it a little bit. We need to do some of these effects. But it was like, no, this is not a first principles simulation of what's going on. So I thought I'm going to go deep rather than start by like just synthesizing the picture quality and that kind of stuff. Why don't I learn how to do it? How do I learn to be a TV person?
Matt GodboltI want to take a real BBC Micro or Sega Master System. I'm going to plug it into my computer. I'm going to use a software defined radio, which lets me decode radio frequency signals into essentially a stream of ones and zeros that I can read fast. And then I'm going to software decode that thing back into a color picture. And that's going to teach me everything I know about how the heck this works. And then I'm going to look at each bit of the code and kind of go, which things are available... What parts of that could I have done using analog electronics back in the day? Which things are like DSP tricks that you would only have had in high-end televisions and stuff like that? And now I can actually pluggably make a TV and say, I want a 1990s era
Matt Godbolttype display, or I want... no, I want the actual 1984 Thorn TV that I had in my bedroom, which I have a photograph of, and I found... and I've got the manuals for, and I'm going to try and find an actual real one so I can do some real sampling. But you know, that's... it's been a journey, my friend. What do you want to know?
Ben RadyWow. Wow. Well, so, okay. So just to clarify exactly what you're saying here is you didn't have enough emulator in your emulator. So you added another layer of emulation on top of your emulator. So you have two layers of emulation.
Matt GodboltIn fairness, I haven't put this into the emulator yet. There's a version in the emulator, but this is purely learning about the decoding. What I hadn't registered really is there's kind of two parts to the whole thing.
Ben RadyYeah.
Matt GodboltOne is the RGB that is actually being generated by the computer, right? There is obviously RGB at some point.
Ben RadyMm-hmm.
Matt GodboltWith the exception of NESes, which is a whole other story, and we don't have time for that, but like there is RGB, and then it goes through encoding.
Ben RadyYeah.
Matt GodboltAnd then the BBC Micro's output encoding circuitry would differ from the ZX Spectrum's one, from the Sega Master System. I'm sure all of the systems would come up with their own compromises about what's cheap to do or appropriate to do, to generate the signal. Then they would go through RF modulation, which adds a whole other thing in. They may or may not mix in the audio, because the audio is in there as well. And then they would send it off to the TV, right? So there's stage one is how does the output stage generate the RF signal that's coming out. And then stage two is which type of TV have you plugged it into?
Matt GodboltIs it a modern one? Is it a cheap and nasty color TV? Is it one of those ones where, you know, effectively over time, the heat of your... this is what I had with my friend Richard, we would go around his house. And after a lot of programming, the screen would start getting worse and worse and start shimmering. And we realized that, oh, you'd have to retune the TV as everything had gotten hot. And so all these analog components had gone out of lock effectively. And there was no... so it's...
Ben RadyYeah.
Matt GodboltHonestly, it's an amazing thing. And yeah, there's just so many layers. I've learned so much about how SDRs work, about how fast you have to sample stuff. Essentially, it's like an ADC. So it's like a sampler, an audio sampler, right?
Ben RadyRight. Yeah, yeah, yeah.
Matt GodboltBut not running at 44 kilohertz or 64 kilohertz. It's running at 32 megahertz. So it's 32 million samples a second, which is not totally unreasonable. It's fine. But the RF that we're looking at is a signal that varies and wiggles around a frequency that's like 400 megahertz or 300, 200 megahertz or something like that. So there's a kind of an analog trick for bringing down the signal from that really high domain down to a lower domain that you could then sample.
Ben RadyRight.
Matt GodboltAnd how musical are you, Ben?
Ben RadyYou know, not particularly. And it's also possible that our listener is also not. So, you know, over-explaining is probably a good thing here.
Matt GodboltRight, that's fair. But right, so have you ever, you know when something is slightly out of tune, if you heard two notes that were slightly out of tune, they were both trying to be the same pitch. And so like, an A is 440 hertz, right? And now... yeah, I can't tell it's an A, right?
Ben RadyOkay, yeah.
Matt GodboltI haven't got perfect pitch. But if it's... and then I also... someone played a 441 hertz sound,
Ben RadyRight.
Matt GodboltI wouldn't be able to hear the difference. But if you played the two together, there's that horrible wobbling, whoa, whoa, whoa, whoa kind of thing that happens when they grate against each other.
Ben RadyYeah. Yeah.
Matt GodboltIt's a crunchy, horrible thing when something is nearly in tune, but it isn't in tune, right?
Ben RadyMm-hmm. Mm-hmm.
Matt GodboltThat, the frequency of the whoa, whoa, whoa of the two, beating and grating against each other, is the difference of the two frequencies. So 440 and 441 would give you a once a second wobbling sound.
Ben RadyOkay, yeah, that makes sense. Right, right.
Matt GodboltSo the trick, and anyone who knows about this for real, who's like done electronic engineering or whatever, is like screaming at their speakers right now, this is not a trick.
Ben RadyMm-hmm. I know.
Matt GodboltThis is like just how it's done. But like the trick to me is, what you do is you play the two frequencies... when you want to tune to, say, 200 megahertz, you generate a local 200 megahertz signal using just your own oscillator.
Ben RadyOkay.
Matt GodboltAnd you play that again at the same time. You multiply them. You mix them together. You multiply them in this instance. But like, go with me in this, my music analogy, right? And the result is, yes, you hear both of those tunes, but they're so high-pitched and high-frequency that they're then beyond what you can sample with your sampler. But the difference between them, the wobbling around, is much lower frequency. It's the difference of their frequencies.
Ben RadyOkay.
Matt GodboltAnd so now you get a signal that is around about plus or minus, you know, however wide the various frequencies might be. And so by playing a 200 megahertz tone and multiplying that with whatever noise is happening off the radio,
Ben RadyOkay.
Matt GodboltI can then sample that at, say, 32 megasamples a second. And what I've got is essentially a plus or minus, sort of, Nyquist limit is half of that, 16 megahertz around the 200 megahertz window. So I can get from minus, because it's the same, you can't tell if it's one hertz above or one hertz below.
Ben RadyOkay.
Matt GodboltThey both beat at once a second. So you get both the signals that are from like 200 to 216 and down to 184, whatever that... Right.
Ben RadyOkay.
Matt GodboltBut, and that's the band.
Ben RadyAnd this is all to like bring these frequencies down into a range where you can sample them at the rate that you're able to sample them with the hardware that you have?
Matt GodboltExactly. Without getting all those sort of like pointless noise of like lower frequency things that you don't care about.
Ben RadyOkay.
Matt GodboltAnd then there's some other tricks that you have to do because, you know, again, you can't discriminate between something that's one hertz higher from what's only one hertz lower. And there's a trick. Maybe we want... if we talk about every trick here, we're going to be here for three hours. So I'm...
Ben RadyAnd then the thing that's melting my brain here is that it's like, you know, you talk about this with audio and I can kind of like think about it, but it's like, this is television, right?
Matt GodboltCorrect. Yes.
Ben RadySo it's like, you know, it's not just audio. In fact, it's not even primarily audio. It's the signal that you're using to, you know, bend this, you know, electron ray, whatever the heck it is.
Matt GodboltElectron beam that's flashing back and forth.
Ben RadyThat's... yeah.
Matt GodboltExactly.
Ben RadyRight.
Matt GodboltAnd again, and it all had to be done in analog.
Ben RadyRight.
Matt GodboltSo you know this first stage I just described, you could imagine some kind of magical thing that oscillates. You get it tuning. When you're tuning the television, what you're really doing is tuning that oscillator to a frequency... that there's more... There's a middle stage. There's an intermediate frequency and stuff like that. But like for the purposes of this conversation, you're tuning an oscillator. And then the difference between the oscillator you tuned and the signal that's just got, of course, every TV station mixed into it will... will give you, will center it around the thing that you care about. And then if you filter the stuff that's higher and lower frequency, now you've just got your TV tune. But yeah, now you've got like another layer of encoding. So think about it as encoding. Now you've probably talked about, and I'm going to say a word that you're going to say a different way to me. And I don't know if it's a me thing or a UK thing, US thing. So the not-RF signal that you would plug in, the yellow lead on your old consoles where you didn't have the audio in, you would have like three leads, you'd have left and right audio, which would be red and white.
Ben RadyYeah. Yeah.
Matt GodboltAnd then the yellow lead, which would be the video.
Ben RadyYeah.
Matt GodboltWell, that will be what kind of video?
Ben RadyOh, I don't know. RF video. I mean, but yeah, I always think of it as like, you've got component and comPOSite and... okay.
Matt GodboltCOMposite is the word I was looking for there. Yes. So yes, I would say COMposite.
Ben RadyYeah. Oh, okay.
Matt GodboltI don't know if it's just a thing that I say. So, you know, our listener can have a think. But yes, so effectively there are like several layers of encoding.
Ben RadyYeah.
Matt GodboltThe first thing is we're going to make something RF so we could transmit it over the... what, the waves, the airwaves, right? The composite is too low frequency and everyone would pick the same one. So obviously every channel has its own. But in there are two things, right? One is the composite video, which is itself composed of more things, which we'll get to.
Ben RadyMm-hmm.
Matt GodboltAnd then there's essentially like an FM radio signal that is the audio that is just on the edge of the video signal, either side of it, the way that it works out. And I'm a bit vague on this bit because I haven't got to that yet. But you can imagine, yeah, given the amount of spectrum that you're allowed to use, the bandwidth of radio range, you would kind of fiddle it around and say, okay, the FM lives in this part of it.
Ben RadyMm-hmm.
Matt GodboltAnd then the middle part is all this. And the much wider part, for what it's worth, is the TV signal, which is itself composed of several things, right? Red, green, blue, synchronization pulses, like this is the top of the screen. This is a new line, right? Now in our... you and me, these are packets. These are like binary encoding and you go like, how about the start frame, you know, whatever. But like, this is... it can't be the case, because we're talking analog era electronics.
Matt GodboltAnd so first of all, the first trick is that it's amplitude modulated onto the carrier. So there is the carrier, you know, the 200 megahertz that I mentioned before, is just a wiggling 200 megahertz signal.
Ben RadyYeah. Yeah.
Matt GodboltAnd we just turn the volume of that up and down like old AM radio, right?
Ben RadyYeah. Right.
Matt GodboltForget frequency modulation. We're not modulating the frequency. But by flapping the amplitude up and down fast enough, we are actually using frequencies around it.
Ben RadyRight.
Matt GodboltIf you were to put it through a spectrum analyzer, you see that you get this bandwidth just because of the way it...
Ben RadyOK, so just to reiterate some of this back to make sure I understand what's going on here. You've got, because it's television, you have this limited frequency in which you're allowed to use for your signal, right?
Matt GodboltYeah. Yeah. Correct.
Ben RadyYou're going to slice off some of that for the audio. You're going to slice off some of that for, you know, both channels of the audio. You're going to slice off some of that for the video. And then within that frequency, you're actually encoding the signal in the amplitude of the waves in that frequency.
Matt GodboltCorrect, by modulating the up and down of that.
Ben RadyHave I got that right?
Matt GodboltYeah, yeah.
Ben RadyYeah. OK.
Matt GodboltAnd so the way that it's done is that a black picture is the brightest. So it's inverted, right? So a totally black screen would be just the normal
Ben RadyOK.
Matt Godboltfull amplitude... the RF signal.
Ben RadyYeah. Right.
Matt GodboltAnd this is also true, incidentally... Yeah, no, sorry, I'm confusing myself here. Right, forget... Go ahead.
Ben RadyIs that true for the audio, too? This seems counterintuitive.
Matt GodboltI don't... I don't think so. The audio is separate from this. At this point, we've left the audio behind. It's been filtered off.
Ben RadyOK.
Matt GodboltIt goes into audio circuitry, and I haven't looked at that too much. But yeah, we've got this amplitude modulated thing where we want to extract from that essentially a single continuous analog signal from this wiggling thing.
Ben RadyOkay. Okay. Okay.
Matt GodboltAnd the way that we do that is we treat the... Actually, I'm not sure what the circuitry does at this point, but we're looking for the amplitude. So let's just ignore the fact that it's wiggling anymore and just say it's the amplitude of this. We've got a thing that comes out. And now the amplitude is inverted such that the darkest picture is bright, the loudest, and the brightest picture would be almost no signal. It never goes completely zero, because then you don't have anything to lock onto.
Ben RadyYeah. Yeah.
Matt GodboltBut it's there. So we've got a range now. We've got a range of, say, voltages. And... It's unimportant that it's inverted, other than like the very dark signal is always there. So even if the picture's black, you can tune into the stupid thing and actually know that you've picked up a black picture, right? So from now on... quickly, early on, you invert it the other way around. So it looks sane to humans where, you know, bright is high and dark is low. Let's go with that, right?
Ben RadyYeah.
Matt GodboltYou with me so far? Because, yeah... the first thing is we invert it.
Ben RadyYeah. Is this why television static is mostly white?
Matt GodboltIt is... we'll get to that actually. That's good, hold that thought, my friend, because this is the cool bit, right?
Ben RadyOkay. All right. All right.
Matt GodboltSo yes, we've got this, let's just say goes between zero and one volt, right? Where white is... one volt is bright white and zero would be black, except what we're gonna do is we're gonna say, no, no, no. We need a way of signaling the synchronization pulses. We need to say, this is the beginning of the screen. And we need to say, this is the beginning of a line, because what's happening behind the scenes is that there is... we want to synchronize the electromagnets in the TV with this picture so that they start at the top of the screen, they slowly go down and more quickly, they flip from left to right.
Ben RadyMm-hmm. Mm-hmm.
Matt GodboltAnd we wanna make sure that everything's synchronized. Otherwise the picture rolls or it's diagonally skewed because the rows aren't aligned, right?
Ben RadyYeah.
Matt GodboltBut we need a way of saying, this is a big... this is like, we sort of out of band. And so the out of band is lower than black. It's like we go... we say, right, black is actually gonna be 0.3 volts. And anything below 0.3 volts is like blacker than black, and it's actually a signal. It's like, a thing is happening. It's our sort of out-of-band signal, because we know also that while we're between lines and while we're pulling the beam from the bottom to the top, we actually don't want to paint anything to the screen. Otherwise, you'd start seeing splurge as the light... as the beam retraces its steps, right? And you get pictures being overwritten with crap. So we want it to be low and we might as well just say, well, when it goes really low, that's a signal to you.
Ben RadyOkay.
Matt GodboltGood so far?
Ben RadySo you said blacker than black, like the amplitude... as the amplitude decreases, that is our range of signal, right?
Matt GodboltYes. So we've got effectively between like 0.3 and one volt is the normal black to white.
Ben RadyOkay.
Matt GodboltAnd then below, we're already talking... yeah, sorry, I've already inverted it so that it makes sane.
Ben RadySo you've... we've already talked about it being flipped at this point. Got it.
Matt GodboltYeah, yeah, yeah, yeah.
Ben RadyYeah, yeah, yeah, yeah.
Matt GodboltI'm sorry about that, yeah.
Ben RadyNo, that makes sense. I'm back with you again.
Matt GodboltOkay, yeah, I did do a bait-and-switch, changed my sort of... there, because it's just easier to think of it the right way up, right, the way you would want to see it, right, the way that it actually gets transmitted when you're using a composite cable. Because effectively by the time we have taken it away from being this amplitude modulated signal to just a signal between zero and one volts and turned it the right way up so that it makes sense, where now that's what you would get out of your composite cable.
Ben RadyRight, yes. Right, right. Yeah. Yeah. OK, got it.
Matt GodboltRight. So no audio, no weird wiggling, just pure something you could put into an oscilloscope directly and go, oh, I can see what that's doing, as opposed to just a mass of wiggly lines.
Ben RadyRight. Yeah. Yeah.
Matt GodboltRight. And I forget...
Ben RadyRight.
Matt GodboltSo TVs used to be black and white. You probably remember this.
Ben RadyI don't know. Actually, that's not true. I did actually own a black and white TV.
Matt GodboltYou're younger than me. I never... I think we had one black and white TV, but it was in my nan's house.
Ben RadyYeah. We had a cheap one that was black and white. That was like an extra one.
Matt GodboltBut yeah, so the trick is that whatever we do to get color into our signal had to be, back in the 40s and 50s, whenever it was color was, had to be backwards compatible in the worst possible way.
Ben RadyYeah. Mm-hmm.
Matt GodboltLike they couldn't squeeze three copies. They couldn't go, oh, this is now red and this is now green and this is blue, because your black and white TV would be like, well, it's just... I only show what red is, or something like that.
Ben RadyRight, right. Yeah, yeah.
Matt GodboltSo there was a trick here. Yeah. Oh, but I missed over the... Going below 0.3 volts is a signal to either pull the signal up to the top of the screen if it's a long period of time, or if it's a short burst below 0.3 volts, it pulls it back to the left.
Ben RadyMm-hmm.
Matt GodboltSo there are like two independent circuits that are always running inside the TV, one of which is just a square, both of which are sawtoothed.
Ben RadyYeah.
Matt GodboltSawtooths, excuse me, sawtooths.
Ben RadyMm-hmm. Yeah.
Matt GodboltAnd they're set to be, you know, just slightly longer than a frame and just slightly longer than a line, so that they will naturally just kind of go zero to left to right, left to right continuously, and top to bottom slower, but continuously.
Ben RadyMm-hmm. Mm-hmm.
Matt GodboltBut the pulse going that low for a while is a signal to say, doesn't matter where you think you are, start dragging yourself to the top of the screen if you're the top to bottom, or left of the screen. So that also gives you a certain amount of slop, where... not AI slop for a change, slop where if, for example, your TV's
Ben RadyYeah.
Matt Godboltcrystal oscillators, or they weren't even crystals, but the little oscillators that were doing these sawtooths, was slightly out of spec, then, you know, you just keep rewiring, pulling them back onto the right sort of thing. And if there was no signal at all, then they would sort of free run. And that's when you would see the picture rolling, for example. If there was enough to see where the picture was, but you didn't... the TV couldn't pick up that synchronization pulse anymore, then it would just free run.
Ben RadyYeah. Yeah.
Matt GodboltAnd so the whole picture would spin over and over again. And I realize I'm gesturing wildly with my hands, which doesn't help our listener at all.
Ben RadyYeah. Yeah.
Matt GodboltSo without getting into too many of the specifics, both of those things cause the TV to reset the top bit and the left to right bit. The interesting thing for me for the first time about this was like realizing that that sawtooth from top to bottom is always running. You know, you and I think that the beam scans from left to right, then it goes down a bit and comes back again sort of diagonally, and then it scans the next row left to right. But it doesn't. It's doing... it's always a slightly diagonal line from left to right.
Ben RadyYeah.
Matt GodboltAnd then it's a much less diagonal angle from right to left, because it's much quicker going back than it is going across.
Ben RadyMm-hmm.
Matt GodboltAnd so you'd think that the whole picture would be slightly wonky because it's... and it is.
Ben RadyYeah.
Matt GodboltAnd so they just adjust the damn magnets to turn them by half a degree backwards so that it's all the right way around again. It's just, you know, beautiful.
Ben RadyOh...
Matt GodboltAnd I had to model that because I'm like, why is everything slightly off?
Ben RadyRight.
Matt GodboltOh, yeah. Yeah. Okay, so that's the retrace. So we were talking about black and white. So you could imagine now it's really, really easy. We have these two electromagnets that are being dragged... dragging the electron beam up and down, left and right. They're synchronized with the signal. And then the rest of it is just the brightness. And that's just how many electrons we squirt at the screen in the direction the beam is currently pointing. And there you go. You've got a black and white telly. You are done. Hooray, high fives all round.
Matt GodboltBut now we want color. And so, you know, as a computer programmer, we would say, oh, V2, you know, or you sort of come up with something.
Ben RadyRight.
Matt GodboltWell, we've got the red, the green, and blue, and three channels. And then somehow, oh, there's also a black and white version. But no, they had to come up with a really clever way of getting color into the signal. So the trick, and this is the great thing, the trick is take... we take the color information and we break it down into three components. Rather than red, green and blue, we pick brightness, which we already have, because that's what the black and white signal was. And then we have two chrominance signals.
Ben RadyMm-hmm.
Matt GodboltAnd you know if you've ever pulled up a color picker in any of your art packages, you've probably seen the ones where you've got HSV and you know you've got brightness and then two different other sliders.
Ben RadyMm-hmm. Mm-hmm.
Matt GodboltAnd you can pick any color with three things. That's the beauty of like any space is that if it's a 3D space, you can have any coordinate system and you can get to all the points of the coordinate system as long as you've got three of them. And that's what it is. So like we have essentially a brightness, which is overall how bright something is. We have how saturated a color is, between totally that color or white, white, however white the brightness would let us go. And then we have a kind of color wheel for the third axis, which says, well, which color, if we're not white, which color are we tending towards?
Matt GodboltAnd you could imagine you're just, you know, just a genuine, honest kind of color wheel and like, well, it's a direction on there. And so now we've got three signals again. So that's cool. And one of them is one we're already transmitting. So can we hide the other two signals somewhere that a black and white telly that hasn't even... doesn't even know the color exists
Ben RadyRight.
Matt Godboltdoesn't see them, without using more bandwidth, because we can't add... you know, we've got all these TV channels packed into the RF spectrum.
Ben RadyYeah.
Matt GodboltAnd although we're talking... I'm talking about the composite part now, the width of that signal has to somehow be squished into the radio spectrum. So what we do is we observe that if we wiggle the brightness really fast and not that much, maybe the black and white TV won't notice it.
Ben RadyMm-hmm.
Matt GodboltBecause it's a crap old piece of analog electronics, it's old anyway, a higher frequency wiggle in the brightness would probably go unnoticed, or at worst just makes the white areas look a little stippled in places where it's just varying quite quickly.
Ben RadyMm-hmm.
Matt GodboltOkay, but now we've got a wiggle. What do we do with this wiggle? Well, this wiggle, we can somehow encode two pieces of information with that wiggle. The amplitude of that wiggle could be one of the other dimensions.
Ben RadyOh, OK. Yeah, and the frequency is the other one?
Matt GodboltSo now we've got one of them, but how do we get the third one?
Ben RadyYeah. Is it the frequency of the wiggle?
Matt GodboltWhat else... what's that, sorry?
Ben RadyIs it the frequency of the wiggle?
Matt GodboltIt's not the frequency... that would make sense at some level. And I think SECAM, the French thing, used something akin to that. But that would be too easy.
Ben RadyOK.
Matt GodboltAlso, there are limitations on what frequencies we can use for a variety of reasons, to do with the fact it has to not be a frequency that's going to interfere with this signaling itself, because all these other components are going. And also the RF... sorry, the audio is in there as well. So there was some careful picking of these numbers so they all don't divide into each other and you end up with like stripes or things like that.
Ben RadyOkay.
Matt GodboltBecause there are artifacts, which is partly why we're talking about this, because it... those are artifacts I'm trying to capture in the emulator. So the other thing that we can fiddle around that isn't the frequency is the phase.
Ben RadyOh, okay. Yeah.
Matt GodboltSo you can slide that back and forth and have the peak at this point in time or push it back a little bit, and now we've got another dimension.
Ben RadyRight.
Matt GodboltAnd so the phase, as you'll recall, can be measured as between 0 and 360 degrees, if you want to think about it, right, as a sine wave. You can like slide the sine wave back and forth. And that maps nicely into our 360 degree color wheel that we had. So that's how we pick the color. The color is just the phase of that wiggle.
Ben RadyOkay.
Matt GodboltAnd then how saturated it is, is how wiggly... the brightness of that wiggle. So heavily saturated colors on a black and white television do have a grainy texture over the top of them now, because you can see the wiggle in it if you look hard.
Ben RadyMm-hmm.
Matt GodboltSo that's cool. We have smuggled two pieces of extra information into our channel. Black and white TV people don't really notice it. But we've now got a new problem, which is that analog electronics is not very good at measuring things like phase differences. Because how accurate do you have to be with your signal to know if it's in or out of phase? And in and out of phase with what?
Ben RadyRight.
Matt GodboltMaybe you need a PTP timestamp synchronization and now everyone's on the same page.
Ben RadyMaybe.
Matt GodboltYou're down to the... No, no, we haven't got any of that. It's got to work with crap electronics in a 1960s box.
Ben RadyYeah. Can I... can I take a guess?
Matt GodboltSo we need... Yeah, please. This would be great, because I've been just jabbering.
Ben RadyCan I... can I guess?
Matt GodboltSo tell me, what do you think?
Ben RadySo there's two checkpoints that you have. One is the screen reset and one is the line reset.
Matt GodboltYes, go on.
Ben RadySo it could be either of those, or maybe even both.
Matt GodboltYou are bang on the money, my friend. And it almost makes me think you're cheating and Googling, but I can see your hands, so I know you aren't. Yeah.
Ben RadyI am not. I am not.
Matt GodboltSo at the beginning of each line, after we've had the little dip below the 0.3 volts that says, hey, this is the beginning of the line.
Ben RadyMm-hmm.
Matt GodboltAnd so we know that the electron beam has been dragged back and is currently now way off the left-hand side of the screen.
Ben RadyMm-hmm.
Matt GodboltWe then come up to like a black level, because we're in the sort of border on the left-hand side.
Ben RadyRight.
Matt GodboltAnd just before then, and there's something like... there's the front porch and the back porch.
Ben RadyRight.
Matt GodboltThere's some stupid names for these things, which is, you know, stupid, hilariously funny.
Ben RadyInteresting. Yeah.
Matt GodboltWe just do a quick burst of that color signal, just a little of it, that's short enough that, again, it's not going to be visible. It's off the side of the screen. But anything that's looking for it will see it and go, ah, two things. One, this is a color TV signal. It's not a black and white TV signal.
Ben RadyRight.
Matt GodboltIt's a color TV signal, because I've seen the color burst. Two, synchronize my very short-lived one-line's worth signal
Ben RadyRight.
Matt Godboltlocal oscillator of this color frequency, so that I've now got a reference that I can compare everything else to, and I can compare it to see if it's in or out of phase and by how much. And so that is the trick of getting color. Now decoding that is a pain, but you mentioned something about the black, you know, static. So do you think you can answer your own question now?
Ben RadyYeah.
Matt GodboltWhy is it black and white?
Ben RadyWell, because it's not going to have that burst right at the right time to tell it that it's a color TV.
Matt GodboltBingo. Bingo. So the color TV set will... will assume it's a black and white picture, because it can't synchronize to it and it can't find the color burst.
Ben RadyYeah. Yeah.
Matt GodboltAnd so it will suppress all of its own color decoding circuitry. And so the noise only comes out in black and white. Congratulations, sir.
Ben RadyWow.
Matt GodboltYou've won today's podcast.
Ben RadyWell, I just want to thank everyone involved, you know, my friends, my family here to support me.
Matt GodboltYeah.
Ben RadyAnd I'm just really proud of this accomplishment today. So thank you. Thank you all. Really appreciate it.
Matt GodboltBut so I guess, you know, and so emulating and simulating this has been an absolute blast, and learning all of the various things that they do to the TVs that do that, like, period appropriate. And I learned, for example, that there are delay lines for something we'll hopefully talk about in a second, which required a piece of glass that's exactly the right size so that like essentially it puts...
Ben RadyWow.
Matt GodboltThere's like a piezoelectric crystal on both sides of this bit of glass, and it knows it takes 64 microseconds for the vibrations to make it through to the other side. And that's how you get a delay line, an analog delay line, for 64 micros. You're like, what?
Ben RadyWow.
Matt GodboltThere are other things that use specially shaped piezo crystals that then can filter out frequencies. It's just so clever. But while we're here, and as we've just been talking about the color burst in particular,
Ben RadyThis sounds like an amazing project. Yeah. Yeah.
Matt GodboltWhat is the name of the European, or most of the European, TV standard?
Ben RadyPAL.
Matt GodboltDo you know what PAL stands for?
Ben RadyOh, I do not.
Matt GodboltIt stands for phase alternating lines. And I think that probably tells you something about what happens on each line. And maybe about the color part, because this is where NTSC, which is something like the North American Television Standards Committee or something like that, which was developed first, incidentally.
Ben RadyPhase alternating lines. Yeah, yeah. Uh-huh.
Matt GodboltSo NTSC predates PAL by about a decade or so. And so PAL learned from NTSC and went, we like everything about this, but... there's this one thing, and they fixed something.
Ben RadyYeah. And one thing, so phase alternating lines.
Matt GodboltUh-huh.
Ben RadySo if we're using phase to control color, the hue, right, then my guess here is that we shift the phase every other line.
Matt GodboltOkay.
Ben RadyI'm trying to think of why that helps, though. I don't know why that helps.
Matt GodboltExactly. Yeah. Well, let's talk briefly, because I've looked... we're at 35 minutes, gosh.
Ben RadyWhy does that help? Right.
Matt GodboltLet's talk briefly about one of the problems that NTSC had. And actually, this would be interesting, because I didn't grow up with an NTSC set. I grew up cursing them in the 90s, because we had to like try and make our graphics look good on NTSC TVs for like games. But they wouldn't have suffered from the problem I'm about to describe. So... The problem with the phase being the color information is that tiny, tiny errors start moving you around on that color wheel, right?
Ben RadyMm-hmm. Mm-hmm.
Matt GodboltIf you're just out by one degree, you're moving around this color wheel. And so you had a... you may have had an extra control on your early analog TVs that I would not have had. I had color, brightness, contrast. Those were the three things. Do you remember another one? I'm really... you're younger than me, so you probably don't.
Ben RadyYou know, I don't remember.
Matt GodboltIt's been a while.
Ben RadyIt's been a bit.
Matt GodboltSo my understanding is that earlier American sets would have a tint as well.
Ben RadyOh, yeah. Yes. 100%. Mm-hmm.
Matt GodboltAnd so you would fiddle with the tint, because people's skin color would look like orangey or greeny or whatever sometimes, because... now you probably know where I'm going with this... because of small errors in the phase. Those errors commonly come from the signal being reflected off a building near you. And if you take two signals that are identical and add them together with just a tiny delay in one of them, it's similar to shifting the phase of everything.
Ben RadyOh, yeah.
Matt GodboltAnd I'm going to wave my hands a lot here, because I've read the math a few times and it hasn't really gone in.
Ben RadyOK.
Matt GodboltBut there's sort of an unfortunate thing, either if the TV is just not good at locking onto that signal and the parts aren't great, or if there's a systematic error because everything's being slightly delayed and you're getting a mirror copy coming in, then the colors would morph, and it would depend on where the TV set is.
Ben RadyRight.
Matt GodboltAnd it depends on like how warm things are. And you... so fiddle around with this tint. So this is the thing the Germans who came up with PAL was like, how can we fix this? And they made the observation, which to this day lives on in things like JPEG. So, and that is, humans care about the brightness far more than they care about the color.
Ben RadyOkay.
Matt GodboltRight. So, you know, in, say, a JPEG, we store the... the brightness information at a higher resolution than we store the color information, because then you tend not to notice.
Ben RadyOkay. Yeah. Yeah. Yeah.
Matt GodboltThis trick comes from this area.
Ben RadyRight.
Matt GodboltSo they said, well, what if it didn't really matter if we were storing color on every line, unique color in every line? And so it's not... it's not actually that they changed it. But what they said was like, if we flip the phase every other line and we delay the previous line's color and add it to the current line's color, we cancel out any phase error between the two of them, because they've been affected by 180 degrees different in each direction.
Matt GodboltAnd every time I say that out loud, I go, there seems like there's something wrong with that. But I sit down, I do the maths, and the phase error cancels out. But at the loss of like the fact that you are mixing together two lines' worth of color information to kind of get one blurrier line of color information.
Ben RadyOf course it was the Germans.
Matt GodboltSo that is the... and again, probably without a picture or even, again, without me being very confident about it, but that phase alternation and knowing that the TV is going to do obviously the reverse, any error, any fixed error that you've added in cancels out, because when you reverse it the second time, you're adding minus... if you're bouncing off a building, it's adding three degrees of error.
Ben RadyYeah.
Matt GodboltYou add in three degrees of error on the first line. You subtract three degrees of error on the second line. You assume that the other part is the same.
Ben RadyYeah.
Matt GodboltAnd so those two cancel out. You divide by two and you get just the right phase out of it.
Ben RadyYeah. Okay.
Matt GodboltAnd so PAL, phase alternating lines, and NTSC, which was "never twice the same color" for that reason.
Ben RadyPAL.
Matt GodboltThat was the bad acronym for it.
Ben RadyThat's funny.
Matt GodboltSo, yeah, this has been... an odyssey of discovery, as I said. I can now just about real time in software decode... without using GPU trickery, I can decode this all in software, and I can point at each bit of the code and I can say, yeah, I know what that bit's doing. And whatever... things I didn't cover, because we're already 40 minutes here, is that having done this decode, I now do a physically based electron beam simulation where I actually use a lot of
Ben RadyWow.
Matt Godboltvirtual magnets to drag a virtual stream of electrons onto virtual phosphor, which then bloom.
Ben RadyOh, wow. Wow.
Matt GodboltAnd as the overvolting of like a too-strong, too-white signal happens, the pixels bloom. The current starts going high in the electron guns and you get more, wider spew of like electrons that hit more area of the screen. What else? Then you can... I can simulate the fact that like they often... the flyback, which is this hilariously named but complicated thing that builds up enough charge to have this really high voltage that's needed, you can deplete it by having too much white for too long.
Matt GodboltAnd then essentially the picture starts sagging after that, which is, you know, on... again, on cheap sets where there wasn't much capacitance, or, you know, you would put a pretty big white thing.
Ben RadyWow.
Matt GodboltAnd but I remember having one, my dad nicked a monitor from work. And it had this problem where if you had like a bright white title bar of like a game, everything else underneath it was kinked, because that bright white area had kind of gone and dragged all the power out of it. And it's like, had to recharge it up to be able to like pull the electron beam properly. It's just amazing. It's so fun. And you have been a fantastic foil listening to me. I think I needed this more than I knew, actually. I did say to people at ACCU, I said, this is therapy for us... well, for me.
Ben RadyI will... I cannot... I cannot wait to see this working in person. I just... I really am looking forward to this.
Matt GodboltSo the fun thing is is that I've left my desktop computer plugged in with the SDR in Chicago, 4,000 miles from where I'm sitting here, and I've left my Sega... foolishly left my Sega Master System plugged into it and turned on, with a Wonder Boy 3 cartridge in it. And I'm still able... I could just about stream the picture live that's being decoded, everything could just about keep up, and I could just about transmit fast enough, like some crap MJPEG stuff, to get to me here. And I've got the satisfaction of watching the little character play the attract mode in full color with, you know, all of... warts and all. It's been a journey. It's been fun. But yeah.
Ben RadyDid it... did that survive the power outage up in Evanston a couple of weeks ago? Okay.
Matt GodboltNo, no, I had to ask the dog sitter who was in the house to go, can you just go and press this button?
Ben RadyOh, my God.
Matt GodboltI had to send a pic... Luckily, I had a picture from one of the many times I was doing the Advent of Compiler Optimization for like the thumbnails. I said, the computer is here, like a big drawn-on arrow, press this button.
Ben RadyOkay.
Matt GodboltAnd yeah, they were able to turn it back on for me.
Ben RadyMy god.
Matt GodboltAnd yeah, I didn't get them to go in the basement and turn the NAS on, which has also died, but... my son has now done that. But yeah, hilarious stuff, man.
Ben RadyAll right. Excellent.
Matt GodboltThank you for listening, my friend. This has been fun for me. I don't know what else to do now other than go on... I'm spent. I've been talking at the screen for this time. But yeah, good... good shout on working out where the puzzles were.
Ben RadyThis is... this is an amazing project.
Matt GodboltThat was... that was impressive thinking on your feet.
Ben RadyI mean, you know, whatever. We're all just nerds here. That's how that works.
Matt GodboltSo I'm probably going to edit this and put it out like in a couple of days' time, which I think will probably be the first time ever that we've had a Two's Complement go out within the time that we recorded it, which then unfortunately means we have none left in the bank.
Ben RadyOh, yeah. Within a few... Right.
Matt GodboltSo dear listener, you will... the next one in August will be another seat-of-the-pants job. But...
Ben RadyHopefully it's released on time, but no promises at this point.
Matt GodboltCorrect.
Ben RadyRight. Yeah.
Matt GodboltCorrect. Events may overtake us at this stage.
Ben RadyYeah.
Matt GodboltYeah, that's true.
Ben RadyYeah. All right. Well, until then.
Matt GodboltUntil then, yeah, have yourself a great time.
Ben brings a 1976 letter from Bill Gates, and Matt brings the after-effects of last night's pub. The hat gets out of the rabbit, a squirrel is briefly involved, and nobody downloads a computer.
Ben's friend is locked out of their AWS account and Matt's AI has decided he's a hacker. The escape route runs through a cheap computer, a mesh network, and Neal Stephenson.