Two's Complement - Never Twice the Same Color
Episode Date: July 10, 2026Matt 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....
Transcript
Discussion (0)
I'm Matt Godbolt.
And I'm Ben Radie.
And this is Toos Compliment, a programming podcast.
Been a bit.
I mean, not for our listener, obviously.
Our listener is just been a month.
But for us, 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,
but nevertheless, adult things happen and you end up in a different landmass.
So that's me.
So apologies for the sound, and I still haven't actually changed it.
Let me just do that now.
Okay.
Now I'm going to start clipping, and I let's see what that does.
that looks better or 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 yeah yeah i met a number of people claiming to be
our single listener um at a conference recently which was lovely so shout out to the many single
listeners that we had uh there that was 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.
Yeah.
Apparently, people listen to this.
It's amazing.
Which is on them, in fairness.
I don't have to.
We're not making them.
So here we are.
Yeah, we have no idea, as is normal, as is usual.
Right.
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.
but again, due to 4,000 miles.
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.
First time.
So due to the aforementioned time dilation created by you going across the Atlantic Ocean that is stretched out.
Yes.
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.
So we should tell them about this new technology.
Oh, they will not let me back in the country.
Yeah, so one of the things that I got really excited about,
you know I love emulators.
That's my thing.
When I'm not forcing compilers to do things that 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.
Yep.
I 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.
Yeah.
You know, full CRT, bulbous screen.
Right.
Like, 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?
And then behind that was a tiny little thing you would tune to get into the right channel.
And then your, so your computer that you plugged in had to pretend to be.
a TV station, it would generate radio frequency of PAL or NTSC at some frequency.
You tune it into Channel 36 in the UK or Channel...
It was like three or three or four, something like that.
Yeah, in the US, right?
And the TV didn't know that it wasn't actually plugged into an aerial listening to something off the...
Right.
But 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 1940s, 1950s era analog components when color TV was invented.
It's like the worst of all was, but it's really, really nostalgic to see the terrible picture quality that came from it.
And people would use this, right?
There were tricks you could do to make colours 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.
So I thought, right, sod it.
I'm going to learn how all 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 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 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? I 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
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 plugably make a TV
and say, I want a 1990s era Trinitron type display. Or I want, no, I want the actual
1984
Thorne TV that I had in my bedroom,
which I have a photograph of,
and I found that 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, it's been a journey, my friend.
What do you want to know?
Well, 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 it's two layers of emulation.
I've 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.
One is the RGB that is actually being generated by the computer.
Right, there is obviously RGB at some point, with the exception of NES, which is a whole other story.
And we don't have time for that.
But there is RGB, and then it goes through encoding.
And then the BBC Micro's output encoding circuit.
would differ from the ZX spectrums 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's in there as well.
And then they would send it off to the TV.
So 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? Is it a modern one? Is it a cheap and nasty colour 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 hope programming, the screen would start
getting worse and worse and start shimmering and we realised that, oh, you'd have to retune the TV
as everything had gotten hot. And so all these analog components had got out of lock effectively.
And there was no, so it's, it's honestly, 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?
Yeah, yeah, yeah.
But 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
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.
And how musical are you been?
You 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.
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?
I can't tell it's an A, right?
I haven't got perfect pitch.
And then I also, if someone played a 441 hertz sound, I wouldn't be able to hear the difference.
But if you played the two together, there's that horrible wobbling,
whoa, wow, wow kind of thing that happens when they grate against each other.
It's a crunchy, horrible thing when something is nearly in tune, but it isn't in tune, right?
That, the frequency of the wow, wow, wow, 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.
Right. So the trick, trick, 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. This is like just how it's done. But like the trick to me is what you do is you play the two, when you want to tune to say 200 megahertz, you generate a local 200 megahertz signal using just your own oscillator. And you play that again at the same time. You, you're, you're, you're.
multiply them, you mix them together, you multiply them in this instance, but like, go with me and
this my, my music analogy, right? And the result is, yes, you hear both of those chews, but they're
so high pitch and high frequency that they 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. And 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,
I can then sample that at, say, 32 mega samples a second.
And what I've got is essentially a plus or minus sort of Nyquist limit is half of that,
16 megahertz around a 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, they 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 is.
Okay.
And 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 without getting all the sort of like pointless noise of like lower frequency things that you don't care.
Okay.
And then there's some other tricks that you have to do because,
Because, you know, again, you can't discriminate between something that's one hertz higher from
it's one hertz lower.
And there's a trick.
Maybe if we talk about every trick here, we're going to be here for three hours.
And then the thing that's melting my brain here is that it's like, you know, you're talking
about this with audio and I can kind of like think about it.
But it's like, this is television.
Correct.
Right.
Yes.
So 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 bend this, you know, electron ray, whatever.
Electron beam that's flashing back and forth.
Exactly.
Right.
And again, it all had to be done in analog.
So, 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 or 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 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 R.S.
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 and then the yellow lead which would be the video well that will be what kind of video
oh uh I don't know RF video I mean I always think of it is like you've got component and composite
Composite is the word I was looking for there.
Yes.
I would say composite.
I don't know if it's just a thing that I say.
So, you know, unless you connect the thing.
But yeah, so effectively, there are like several layers of encoding.
The first thing is we're going to make something RF so we could transmit it over 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.
And 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 range, you would kind of fiddle it around and say, okay, the FM lives in this part of it.
And 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, you and me, these are packets.
These are like binary encoding and you go like about to start frame, you know, whatever.
But like this is, it can't be the case because we're talking analog era.
electronics. And 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 in 200 megahertz signal. And we just turn the volume of that up and down, like old AM radio,
forget 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 if you were to put it through
a spectrum analyzer. You see that you get this band. Okay. 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? Correct. You're going to slice off
some of that for the audio. You're going to slice off some of that for both channels 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.
Correct.
Have I got that right?
Modulating the up and down of that.
Yeah.
Yeah.
Okay.
And 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,
uh, uh, full,
amplitude sound, sound, right, the RF signal.
Um, and this is also.
true incidentally.
Yeah, no, sorry, I'm confusing myself here.
Right. Forget it. Go ahead.
Is that true for the audio too?
That seems counterintuitive.
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.
It goes into audio circuitry, and I haven't looked at that too much.
Okay, okay.
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. And the way that we do that as 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 on to. But it's
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 nobody
you've picked a black picture.
Right.
So from now, but 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?
Yeah.
Are you with me so far?
Yeah, it gets, the first thing is we inverted.
Is this why television static is mostly white?
It is, we'll get to that, actually.
That's a good, hold that thought, my friend, because this is the cool bit, right?
All right.
So, yes, we've got this, let's just say it goes between zero and one volt, right, where white is, one in volt, one vault is bright white and zero would be black.
Except what we're going to do is we're going to 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. And we want to make sure that everything's synchronized. Otherwise,
the picture rolls, or it's diagonally skewed because the rows aren't aligned, right?
Yeah. But 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
going to be 0.3 volts. And anything below 0.3 volts.
is like blacker than black and it's actually a signal.
It's like it's a thing is happening.
It's our sort of out of band signal.
Because we know also that while we're,
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 being 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.
Okay. Good so far. You're...
So you said blacker than black, like the amplitude, as the amplitude decreases, that is our range of signal, right?
Yes. So we've got, effectively, between like 0.3 and 1 volt is the normal black to white.
Oh, okay. So we've already talked about it being flipped.
We're already talking, yeah, sorry. I've already inverted it so that it makes sane. Yeah, yeah, yeah, yeah, yeah.
That makes sense. I'm back with you again.
Okay, yeah. I did do a bait and switch, but I changed my sort of safe way there, because it's just,
easier to think of it the right way up, right? The way you want to see it, right? The way that
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 signals to just a signal between
zero or one volts and turned it the right way up so that it makes sense, we now, that's what you
would get out of your composite cable. Okay. Got it. So no audio, no weird wiggling, just pure,
something you could put into an acinoscope directly and go, oh, I can.
can see what that's doing as opposed to just a mass of wiggly lines right and i forget so um tvs used
to be black and white you probably remember this i don't know actually that's not true you're you're
you're younger than me i never i think we had one black and white tv but it's in my nan's house yeah we had a
cheap one that was black and white but yeah there so the the 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 whenever it was
with colour was, had to be backwards compatible in the worst possible way.
Like they couldn't squeeze three copies.
They couldn't go, well, 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.
So there was a trick here.
Oh, but I missed over.
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.
So there are like two independent circuits
that are always running inside the TV,
one of which is just a square,
both of which are sore tooth.
Sore tooth.
Excuse me, sore tooth.
And 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.
But the pulse going that low for a while is a signal to say,
it 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 screen.
So that also gives you a certain amount of slop, where if you're not AI slop for a change,
slop where if, for example, your TV's crystal oscillators, or they weren't even crystals,
but the little oscillators that were doing these sawtooth
were slightly out of spec,
then you just keep rewind, 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.
And so the whole picture would spin over and over again.
And I realize I'm gesturing wildly with my hands,
which doesn't help by listener at all.
Yeah.
So without getting into too many 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 sore tooth from top to bottom is always running.
You know, you and I think that it's 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 always a slightly diagonal line from left to right,
and then it's a much less diagonal line going from right to left,
because it's much quicker going back than it is going across.
And so you'd think that the whole picture would be slightly wonky,
because it's, and it is.
And 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.
And I had to model that because I'm like, why is everything slightly off?
Right.
Oh, yeah.
Oh, 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 telling. You are done. Hooray, high fives all round.
But now we want colour.
And so, you know, as a computer programmer, we would say, oh, V2.
Or you sort of come up with something, well, we've got the red, the green, the 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 colour into the signal.
So the trick, and this is the great thing, the trick is we take.
the colour 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 cromanence signals.
And, you know, if you've ever pulled up a colour picker in any of your art packages,
you've probably seen the ones where you've got YSV and, you know, you've got brightness and then two different other sliders.
And you can pick any colour 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, whatever 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?
And you could imagine just a, you know, just a genuine honest 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? Right.
doesn't see them without using more bandwidth
because we can't add,
we call all these TV channels packed into the RF spectrum.
And although 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.
because 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
worse just makes the white areas look a little stippled in places where it's just varying
quite quickly.
Okay, but now we've got a wiggle.
What do we do with this wiggle?
Well, this wiggle, we can somehow, we can encode two pieces of information with that wiggle.
the amplitude of that wiggle could be one of the other dimensions.
Oh, okay.
So now we've got one of them, but how can we get the third one?
Yeah.
Is it the frequency of the wiggle?
What's that, sorry?
Is it the frequency of the wiggle?
It's not the frequency of the wiggle.
That would make sense at some level.
And I think a CCAM, the French thing, used something akin to that.
But that would be too easy.
Also, 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 like 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.
Because there are artifacts, which is partly why we're talking about this because those 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.
Oh, okay.
Yeah.
So 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.
And so the phase, as you'll recall, can be measured as between zero and 360 degrees,
if you want to think about it, right, as a sine wave.
You can slide a 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.
And 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.
You look hard.
So 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?
Right.
Maybe you need a PTP timestamp synchronization, and now everyone's on the same page.
You'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.
Can I take a guess?
Yeah, please.
Because I've been just jabbering.
So tell me, what do you think?
Can I guess?
So there's two checkpoints that you have.
One is the screen reset and one is the line reset.
Yes, go on.
So it could be either of those or maybe even both.
You 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 are.
I am not.
I am not.
So.
At the beginning of each line, after we've had the little dip below the point three volts
that says, hey, this is the beginning of the line.
And so we know that the electron beam has been dragged back and is currently now way off the left-hand side of the screen.
We then come up to like a black level because we're in the sort of border on the left-hand side.
And just before then, and there's something like there's the front porch and the back porch,
there's some stupid names of these things, which is, you know,
It's hilarious, hilariously funny.
Yeah.
We 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.
It's a color TV signal because I've seen the color burst.
Two, synchronize my very short-lived.
one lines worth local 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 as a pain, but you mentioned something about the black, you know, static.
So do you think you can answer your own question now?
Why is it black and white?
Well, because it's not going to have that burst right at the right time to tell it that it's a color TV.
So a color TV set will not, we'll assume it's a black and white picture because it can't synchronize to it and it can't find the color burst.
And so it will suppress all of its own color decoding circuitry.
And so the noise only comes out in black and white.
Congratulations.
Sir, you have won today's podcast.
Well, I just want to thank everyone involved.
You know, my friends, my family here to support me.
I'm just really proud of this accomplishment today.
So thank you.
Really appreciate it.
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 are like period appropriate.
I learned, for example, that there are delay lines for something we're hopefully talk about
in a second, which required a piece of glass that's exactly the right size so that like essentially
it puts, there's like a Piazbo-Elics crystal on both.
size of a spit of glass and it knows it takes 64 microseconds for the, 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 mics. You're like, what? There are other things that use shaped piezo crystals that
then can filter out frequencies. It's just so clever. But while we're here, and as we've just
just been talking about the color burst in particular.
Yeah. Yeah.
What is the name of the European or most of the European TV standard?
Pal.
Do you know what PALS stands for?
Oh, I do not.
It stands for phase alternating lines.
And I think that probably tells you something about what happens on each line.
Maybe about the color part because this is where
NTSC, which is something like the North American Television Standards Committee or something like that.
Yeah, yeah.
Which was developed first, incidentally.
So NTS PRAPAL by about a decade or so.
And so Powell learned from NTSC and went, we like everything about this, but there's this one thing.
And they fix something.
Phase alternating line.
So that would make, so if we're using phase to control color, the hue, right,
then my guess here is that we shift the phase every other line.
I'm trying to think of why that helps, though.
I don't know why that helps.
Well, why does that help?
Let's talk briefly, because I've looked where at 35 minutes, gosh,
let'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,
take 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?
If 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.
You know, I don't remember.
It's been a while.
It's been a bit.
So my understanding is that earlier
American sets would have a tint as well.
Oh, yeah.
Yes.
And so you would fiddle with the tint
because people's skin color
would look like orangey or greeny or whatever sometimes because now you're probably going to
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. Oh, yeah. And 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.
But there's sort of, there's 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 colours would morph.
And it would depend on where the TV set is
and it depends on how warm things are.
And you so fiddle around with this tint.
So this is the thing the Germans, who came up with Powell,
was like, how can we fix this?
And they made the observation,
which to this day lives on in things like JPEG.
And that is humans care about the brightness
far more than they care about the colour.
Okay.
Right.
So, you know, in a JPEG, we store the brightness information
at a more higher resolution than we store the color information
because then you tend not to notice.
This trick comes from this area.
So they said, well, what if it didn't really matter
if we were storing
colour on every line,
unique colour in every line.
And so it's not actually with that.
It's not that they changed it.
But what they said was like,
if we flip the phase every other line
and we delay the previous lines colour
and add it to the current line's colour,
we cancel out any phase error
between the two of them
because they've been affected by 180 degrees
different in each white direction.
And every time
I say that out loud, I go, that 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 colour information to kind of get one blurrier line of
colour information. Of course it was the Germans.
So that is the, and again, probably without a picture, even again, without me being very confident
about it, but that phase alternation and knowing that the T-Eaternation and knowing that the T-
V is going to do this, 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, you know, if you're bouncing off a building, it's adding
three degrees of error.
You add in three degrees of errors on the first line.
You subtract three degrees of error on the second line.
You assume that the other part is the same.
And so those two cancel out.
You divide by two and you get just the right phase out of it.
Okay.
And so pha, pal, pha, phase alternating lines.
and NTSC, which was never twice the same color for that reason.
It was the bad background in for it.
So, 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've already at 40 minutes here is that having done this decode,
now do a physical-based electron beam simulation where I actually use virtual magnets to drag a
virtual stream of electrons onto virtual phosphor, which then bloom. And as the overvolting of like
a two-struct, two-white signal happens, the pixels bloom, the current starts going high in
the electron guns. You get more wide a spew of electrons that hit more area of the screen. What else?
then 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.
And 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 white big thing.
And 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 kind of gone,
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.
I cannot wait to see this working in person.
I really am looking forward to this.
The fun thing 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.
it fast enough like some crap mjpeg stuff to get to my here and i got the satisfaction of watching
the little character play the attract mode in full color with you know all all of warts and all it's
it's been a journey it's been it's been fun but did it did that survive the power outage up in evansson a
couple of weeks ago no uh no i had to ask the dog sitter who is uh in the house to go can you
just go and press this button i had to send a picture 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.
And yeah, they were able to turn it back on for me.
And yeah, I didn't get them to go to the basement and turn the NAS on, which has also died.
But my son has now done that.
But yeah, hilarious stuff, man.
Thank you for listening, my friend.
This has been fun for me.
I don't know what else to do now other than that.
I'm spent.
I've been talking at the screen for this time.
But yeah, good shout on working out where the puzzles were.
That was impressive thinking on your feet.
I mean, you know, whatever.
We're all just nerds.
That's how that works.
So 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 tooth compliment go out within.
Oh, yeah.
the time that we recorded it, which then unfortunately means we have none left in the bank.
So, dear listener, the next one in August will be another seat of the pants, Joe.
Hopefully it's released on time, but no promises at this point.
Correct.
Yeah.
Events may overtake us at this stage.
Yeah.
That's true.
All right.
Well, until then?
Until then.
Yeah.
Have yourself a great time.
Cool.
See you later.
Bye.
You've been listening to Tooth Complement, a programming podcast.
by Ben Radie and Matt Godbold.
Find the show transcript and notes at www.2.2.2's complement.org.
Contact us on Mastodon.
We are at twoscomplement at hackyderm.io.
Our theme music is by Inverse Phase.
Find out more at inversephase.com.
