This video brilliantly showcases how elegant mathematical logic can overcome hardware limitations to create realistic simulations. It serves as a reminder that true programming ingenuity lies in simplicity rather than raw computational power.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
This 1984 C64 BASIC Game Has Better Physics Than You'd Expect!Added:
Welcome to 8bit Basic. Okay, check this out. Right here is Stuntman. It's a parachute game from 1984. Type from scratch in basic. And the reason I want to show you this one specifically, oh, let me time my jump. Let's see if I can make it. So, the reason I want to show you this specifically is one, it's fun, but two, the code underneath, it's really doing something quite clever. Is this one going to make it?
is using actual parabolic maths to calculate where the stunt man lands based on the wind speed.
Oh, am I going to make it? Oh, nice landing.
It uses real physics. It's done in basic. It's on a Commodore 64 and it's from 1984. And then just to keep things interesting, if you're electrocuted, well, the screen loses its mind. I'm going to show you some of the coding tricks. And of course, let me time this jump.
Yeah. Come on. Come on. Come on. Ah, I've lost a life. We'd better try that again.
As I said, I'm going to show you some of the codic tricks. And of course, I've done an 8bit basic upgrade. So, we will definitely look at that perfect landing.
We'll definitely be getting into it.
What I love about this game is I absolutely love the simple use of the PK ski graphics. It's really Oh my goodness. I don't think I've ever done two in a row. Sorry, I'm distracting myself with the gameplay. Um, as I was saying, I really love the PKY graphics.
Very simple. We've got a really simple monocolored sprite. Wow. I just cannot believe how well I am playing and talking at the same time. Maybe that's why I've been doing so badly at other games. I need to play and talk. Ah, all right. I have to concentrate. So, I really enjoy the simple plain sprite, the simple player sprite, and just the really, really effective use of PKY characters to create uh to create the rest of the game field.
You'll notice at the bottom we have our wind speed, and I do need to take notice of that. So, it's going six that away.
So, if I go about here, and because I'm quite high up as well, I've got time to drift back. So, what I plan on showing you is the Oh, I just missed is I want to show you the specific maths that does the stunt man movement because I think it's really quite clever. And then I'm going to show you what happens when you land on the fence and get yourself electrocuted.
Let's see if I can That's basically what happens.
And then I've also done a little 8bit basic sprite upgrade just to make the game a little bit more prettier. So, I'm going to be showing you that. So, without further ado, let's jump into my code. As you can see, I'm on my original hardware today, my beautiful Commodore 64C with original SID chip and all. I've also brought a new digitizer upscaler, which is the RetroTink 4X. It's the light version. It's not the full version, but it's doing a really great job. I think what I'll do is I will switch the screen to black and the text to white, and hopefully that is nice and readable. Here's our pokes.
And I'm going to make the text nice and white. So, I've done a little demonstration of the code for the electrocution. So, let's take a look at that. Load demo.
And as usual, I also will be putting this image file on my GitHub. So, if you want to download it and look at the original Stuntman, Stuntman 8 bit basic upgraded version or any of my demos, they will be there. First of all, I'm going to run it just to remind you of the beautiful screen flash and sounds.
Electric shock flash demo. Press any key to zap the screen. This flashes the border and background and plays a descending SID sound.
So, the first part of the little code, list 85 to 100. Here we go. It starts off by setting some variables that we need. So, VL is the volume. So down the bottom here, that's the memory location or volume. W is waveform and gate. So that's the memory location where we need to poke information for the waveform and the gate. The gate basically start stops the sound.
A 54277 here, that's the attack and decay. So that's where we poke information about how the sound starts and how it trails off.
H is the high and low frequency bite. So H here is for high frequency, L is for low frequency. So every sound created by the SID chip needs a low bite and a high bite. So it needs two bits of information. So those numbers are just set there so that we can poke them a lot easier. REM here in case you not come across before is just a remark. So it's just a little comment that gets ignored.
So this is what sets to make sure that the screen is its normal colors and normal border colors. So 53280a 6 5281 comma 6. So that's setting them both to gray.
This next part is just part of our code that just waits for a key press. That's not in the original game, so I'm not going to worry too much about that. 500 to 550. Here is where some of our magic begins. So, it starts our flash loop.
So, it starts the number 15 and goes down to zero, which is 16 numbers in total, which very coincidentally, Commodore 64 has 16 colors. So, we start at 15, work our way down.
So, for I, so that sets up a loop. So this is going to happen 15 to 0. So it's going to start at 15 and go down to zero, which is essentially 16 times step minus one. So that means it's going to start at 15 and then the next loop will be 14, 13, 12, 11. And so that's how we cycle through our colors. So it changes the background color. So I on the first loop is 15 as it says above. So poke 53281 I and poke 53280. So that's our background and our border. So that's going to set it to color 16. So I can show you now exactly what that'll do.
Poke 53281. 53281, 15 is the first number. So we start with that light gray and 15. So if you poke memory address 14, blue. So this is how that flicker happens. But it just happens so fast. It looks like an electrocution or it looks like a lightning. Oh, that's very very bright.
12.
So, it's a classic classic piece of coding. No, I can't go backwards. That would be 11. And then it goes down through there. So, I'm just going to set it back to zero. So, I have my nice black.
So, each time the loop works through that deals with the watercolor and the background color. So, there is more to the code. So, every time the loop starts, it'll change a color quickly.
And then there is a bunch of code that deals with the sound. I'm just going to show you that cuz it's quite clever.
List 560 to 720.
So, we set the SID volume. SID is the sound chip to the current loop value.
So, quite handily, 15 is actually the maximum volume of the SID chip. So the 15 of the color that we're using and the 15 of the volume works really well. So that means each time our sound plays it actually decrescendos. Fancy music there. It actually gets gradually softer.
So poke VL1. So that will set the volume to 15 on the first loop which is loud.
Rem turn on voice one triangular waveform plus the gate. So poke W, which is the memory location we set earlier, 129. that stays the same every time because we're going to use the triangle waveform which is a particular type of sound and we always need to make sure that the gate is turned on. It uses the same attack and decay. So when it pokes a which is just the memory location of the attack which is how the sound starts and decay which is how it finishes that stays to 15. So this doesn't change it just needs to be set every single time the loop goes through. So the next one is the high bite of the frequency.
So as I said before it takes two things to make sound on the SID chip in terms of frequency. You need a high bite and a low bite and they get put together and that decides the frequency. So this is how it uses I. So it pokes the memory location H which is set earlier and the information it puts there. It adds in 2 + 5 * I. So that'll be 2 + 5 * 15 the first time the loop goes through and then it'll be 2 + 5 * 14 13 as it goes down. So then the sound will actually make that descending wind sound. So that's really quite clever as well. The low frequency doesn't change. So that's quite easy. It's just that changing high frequency getting smaller and smaller.
That's what creates the descending noise sound as well. REM next flash sound step.
So the next So what that will do is it'll go back to the top of the loop that we started and then it's going to change I from 15 down to 14. Go through the next flash. make it's going to change the sound. So then it will so it gets gradually lower as well when that has fully finished. We have poke W. So that was set before at the top. And that's just the little register to just make sure that we are turning the sound off of the SID chip so the sound doesn't continue. And it clears the attack and decay register. So it puts that back to zero as well so that when you use any other sounds everything's ready to start again. So that is the clever little code. Let me just run that again to show you. Here we go.
Really great little programming trick.
Let me show you what that looked like in the actual game because my version there I spread it across the different lines and I added the REM statements just to make it easier to see. This is what it looks like in the game code. So here is the code as it appears in the game. It is 1200 to 1230. a really nice little loop that would be perfect for including in your own games if you're going to be doing any basic coding. So, it starts off with our loop just we saw for 1 to 15 minus one. It does its background and border pokes.
Here is all of our volume SID chip stuff that we saw earlier.
Remember these VL these W's, these variables have all been set previously in the code. Importantly, does the next there. So that's all it takes to do that loop 16 times from 15 down to zero. Then once it's done that final one, it knows no more next. So we just go down to the next line and then it will poke those few things and just make sure all the sound is off and return. So this is a go sub. So the return means okay once we finish this little code at 1200, it jumps back to the next line and continues from where we were. The next code I wanted to show you is the movement of the stunt man. Let me just wait for the plane to be a little bit higher. So, we've got a wind speed of five. So, I want to show you what happens to the wind speed of five. Oh, that was a good one. I should have done that one. So, I need to go past because with a wind speed of five, it's going to curl back. If you watch it, I think I'm going to miss.
Oh, wind speed of eight. This will be a nice one. So, we're going to have quite a big arc here. So, if I start over there, you can see it's going to drag me on quite Oh, I was just a little too late.
Wind speed of seven. So that's going to have a nice arc as well. And you'll notice it it's gradual. So it is like a parabola. It doesn't happen straight away. It's not linear. It's slow. And then I'm going to gradually speed up and it's going to pull me further and further. Aha. There we go. So let me now break down as best as I can this real mass that uses the parabola to get our physics going. So here is the magic code there. I'm going to do my best to explain that line. Keeping in mind I'm not the world's best mathematician. So here I go. X and Y, they are the values of your character. Oh, I've got my little cat visitor again. Thank you, Chai. All right, you need to move off so I can do the rest of my video.
There we go. So X and Y are your screen positions. So the Commodore 64, the very top left is 0 0. So as the numbers increase, you're actually going down the screen. So that's important to keep in mind. So I'm just going to type out in words what it actually is. So X equals WS stands for the wind speed. So whatever your wind speed is, wind speed, it could be five, it could be eight, it could be six. So this is where the wind speed comes into play. So it's the wind speed times t. Now what t is that is the fall timer cuz there is a little timer that's running. So basically t is set to uh it's either one or zero every time we jump and it gets increased every frame.
So this code happens many many many many many times as we are falling. So at the start it's full timer. So t * t which is essentially t ^ 2. So I'm just going to put t to the power of two.
I'm just going to do that to show to the power of two. So t * t So let's say the wind speed was six. So to be doing six * and the timer well at the start it's just going to be 1. So it's 1 to the^ of two divided by or over m. Now m was a variable that was set up and it's just basically um a scaling value. So m is set to 50.
So we divide by 50. So then that way the numbers are not too big and it gives us something we can work with. So m is always 50 minus xv. xv was a variable that was set up and that is three. So that's the initial movement.
So even if the wind speed is zero, three is going to be dragging you across the screen gradually. So when wind speed is zero, you will still go like that. So you need to compensate for that. So initial movement is three. So that's what that is times the full timer again plus XI. Now X I is read earlier. So there is a little peak. So peak is opposite of poke. When you poke, you put something into a memory location. When you peak, you see what's there. So that actually looks at where your current position is or your initial X position.
So, have you got all of that? So, this is what updates your x position.
Then the next part of the formula, it upgrades or updates your y position.
Now, the y- position is a little easier.
So, I'll just start that on a new line.
So, y = 4.9 4.9 * t * t. Remember t is just the timer.
So how many times um or how many frames you have been falling for. So I'm going to do t to the power of two just to show that it is I know it's the full timer.
Full timer to the power of two. I really hope you're enjoying this math. So it took me a little while to get my head around it. So the full timer to the power of two divided by m. m again is just 50 which is our scaling number. So that way our numbers are too are not too big. So that is the scaling value plus y i just like x i where's plus that is the initial of y. So that's where you are. So those two things. So that's why you have the really nice curve from your parabola based on your speed. But then also you do start gradually falling faster as well. all to do with this formula here.
So your y is your fall and then because it is using the fall timer as more loops go it then has more impact. So I've written a little program that hopefully is going to make this just a little bit clearer and show you just with in terms of numbers an example of what happens in the code. So I've slowed it right down. So if you look at the x values 74 72 70 it's sort of going down by twos 69 68 67 for a while 68 68 71 now it's going to start ramping up 87 92 96 101 106 so you can see we're starting to get bigger by fives then by 10 123 so that we're going up to 7s. So that's what gives us that growth. So it starts small and then it gets much much bigger. I'll just run it again so we can have a look at the Y column as well.
Rub. That's not going to do anything.
Let's run it. So 50 50 51.
So this essentially is our falling speed. It's quite gradual, but it is speeding up and the numbers are getting slightly further apart as we go down. So it's quite a clever little formula.
There it is ticking away. And it always stops at the same line. So, I'm not sure if you noticed when we were playing the game, whenever you hit the same point as the pink X in the middle of the screen, that was the checkpoint. So, wherever you land there, that's when it does the checks to see whether or not you've landed on the pad or if you've landed on the forest or in the swamp or on the electric wires. So, now that your brains are all full and hurting from that code explanation, let's look at my game upgrade. As always, here is our code.
For those of you that like to see the code, I've put in my little intro screen as well, just to say which book it comes from, and that I've done some little tweaks to. Here it all comes. We have quite a few more data statements compared to the previous one because I've done some work with sprites. So, I hope you enjoy my upgraded version.
Stop man upgraded by 8bit basic YouTube channel. Judge the wind speed before you jump by pressing space. Land on the target. Avoid electricity, fences, and the swamp. Press any key to start.
Oh, wind speed zero. So, here's a good example. I'm going to show you that the inertia is maintained. So, you still go.
It's dragging me across three. And I jumped too early. Oh. Oh, I just made it. All right. Wind speed eight. So, I'm going to get that nice parabola dragging me back.
And I should talk about my sprite. So, there's my pretty cloud in the background. I'm not the best 8 bit artist, but I wasn't ah I missed it.
Wasn't too unhappy with that. And for the plane, I actually used two sprites and essentially stuck them together because I wanted a long plane. And when you use color sprites, they're actually sort of taller and narrower. So, my plane is just a little bit slower.
I did also move the cloud movement and the plane movement into machine language using the data statements just so it would be a bit more effective. Okay, let me concentrate and see if I can get a good jump. Wind speed eight.
Plus, this is also a short fall. So, do I have time to curve back?
Ah, yes, I do. I also added a man counter down the bottom so you know how many lives you have left. You didn't have that before. Jump speed three.
It's only going to pull me back just a little.
Ah, yeah. So when you actually understand the maths and again you can figure out how to do the jumping even without looking at the maths it does make a lot of sense. So yeah this game really really clever. It uses simplicity really well but it's got great maths behind it and it's a perfect example of what our wonderful games were like back in 1984.
Come on. Come on. Come on with Commodore 64 Basic. Let me see if I can get you a decent jump where I land on the electricity.
There we go. Perfect landing on the electricity. Thank you so much for watching. Please leave me a like, a thumbs up, or a little comment. And I'll see you all again soon for some more 8bit basic.
Related Videos
Is dark matter real? - Why can't we find it? - physicist explains | Don Lincoln and Lex Fridman
LexClips
1K views•2026-05-30
Saptarshi Basu - Spectacular Voyage of Droplets: A Multiscale Journey to Extreme Flow Conditions
DAlembert-SU-CNRS
152 views•2026-06-02
A 6.0 Just Hit Hawaii — And It Came From The Wrong Place
TerraWatchHQ
115 views•2026-06-03
The Split-Second Mistake That Made Bouncing Bettys So Deadly
NoMansLandChannel
253 views•2026-06-02
Nobody Expected This Lava Reaction 🤯 #faits #facts
TendzDora
28K views•2026-05-30
The Difference In Charged And Neutral Particles
heavybrainspace
959 views•2026-05-29
The Silent Memory of Glass
UnchartedScienceworld
146 views•2026-05-30
A380 vs Every Vehicles Crash Test Challenge | Which One Win?
BeamLap
163 views•2026-05-29











