My First Paid Game Dev: Code Walkthrough of Frogs And Flies on the Commodore 64
Vložit
- čas přidán 10. 06. 2024
- Today we'll take an in-depth look at the first commercial(ish) game I made, Frogs and Flies for the Commodore 64, published by Loadstar in 1997. I play the game, explain some of the history/story behind it, and then do a full walkthrough of my 24-year-old code!
To support 8-Bit Show And Tell:
Become a patron: / 8bitshowandtell
One-time donation: paypal.me/8BitShowAndTell
2nd channel: / @8-bitshowandtell247
BCD episode: • Commodore 64 Game Prog...
Music playback episode: • IRQ-Driven SID Music: ...
End credits music is "64738" by Bedford Level Experiment: • 64738 - Lyric Video
Index
0:00 Selling my first game
1:47 Assembling the game
2:58 Credits, Loadstar agreement, more game info
6:41 Playing the game
11:01 Looking through the source
12:58 The labels / memory layout
16:49 Game initialization
18:26 Play initialization
24:06 Main loop
26:58 Game over
29:37 Fly logic
40:02 Sprite collision
42:40 Scoring, sprite setup
44:36 Part Two: the Advanced/Beginner options
47:33 Continuing with code: frog1's variables
51:10 Frog timeout
53:30 Frog state machine: idle to start jump
59:30 Splashing, swimming
1:03:02 Jumping, landing
1:08:09 Updating the frog position, wall collision
1:09:54 The tongue!
1:15:54 The 12.4 to 9 bit conversion
1:16:49 Routines: Screen clear, BCD score, Game init
1:20:20 Brain: Frog "AI"
1:23:04 Title screen
1:27:00 Game timer, day/night
1:28:35 Copy + paste time!
1:31:30 Wrap-up and thanks - Věda a technologie
My Daughter and I have been playing this game for 2 years now. Started to play it when she way 4. I had no clue you made this game. I'm still kinda stunned. WOW thank you for the good times with my daughter!!!! * She loves the C64 ;) *
Thanks for letting me know, I'm really glad you and your daughter have enjoyed it!
I found this game a year or more ago on one of the download sites. I was happy that somebody ported the game and surprised that it was actually made better. Now I find out that it was you. This is fantastic.
It has a certain charm, runs very smoothly, music suits the game and some nice touches (like missing your landing and swimming to the next water lily).
all the froggies jumping pretty high for a white fly
Nooooo...😂😂😂
ok I admit I LOLed
Great looking game!! And excellent music (which is somehow familiar to me). Hats off to you. I owned Frog Bog on the Intellivision, I hadn't thought of it until you showed the cartridge, thanks for that!
As a kid, I played so much Frog Bog! The sound effects from that game are forever stuck in my head.
"When you write the AI, either way you win!" ~Robin Harbron
was wondering what that meant, till I got to 8:42.
I love this video. Your explanations are so good. I hope we'll see the day when the sequel to the sprite / joystick video comes. You showed an example of some moving letters (sprites) and it looked very interesting. I'm currently learning 6510 assembly to make my own game, and you have helped me a lot the last few years. Today I finally grasped the concept of raster interrupts. Thank you for making these videos.
Thanks, I'm glad you're enjoying them. I actually did make the sequel to the sprite/joystick video as a Patreon video (like this Frogs & Flies video) and it'll be released for free in 4 or 5 months I think.
Hey, Patreon people! Thank you for supporting him.
I got to watch this for free because of you and him.
I remember you working on that game during our North and the Sea days. Thanks for the shout-out!
My boss left me with the unenviable task of maintaining a Python-based web page when he left the company, which was fun since I didn't know any Python. Mind you, looking at the code, it was like he didn't either--he actually had the following code in a function (pseudocode here, can't remeber exact Python syntax):
switch (checkyear) {
case 2015: year=2015; break;
case 2016: year=2016; break;
case 2017: year=2017; break;
case 2018: year=2018; break;
default:break;
}
OK, it should be pretty obvious that his entire system broke *hard* when we got into 2019 and it took me ages to find this little gem. If you're writing better code than this then you're golden as far as I'm concerned.
This is a fantastic video, Robin. Can't believe I've only just discovered it. Incredibly interesting. You deserve far more subscribers than you have!
Thanks, I'm glad you found it! :)
This is absolutely delightful. Thank you for sharing this piece of your past. Thoroughly enjoyed this.
Robin, this is quite a catchy tune that really sticks in my mind. 😅
Great video, will watch it again later when I have the time to fully digest the assembly part.
When I grew up with my C64 I always wanted to learn assembly programming but failed for whatever reason. This is truly an eye opener for me.
I had my Amiga in 85 and you published a C64 game in 97 ?! I wasn't aware there were still games published for 8 bit machines in that year... You must love your C64 very much 🤔🤙
I've never created a game that I sold, but the process of programming itself is very satisfying even though it can be nerve wracking as you try to track down some tough bug. It's like being an investigator on a crime scene sometimes, looking for the culprit that keeps your code from running properly. Good times. Programming on a machine that gives you full control and access to everything is a very satisfying thing!
You: "Gotcha, byte! Now you are going to stop your corrupt activities! Get out of my RAM!"
Byte: "And I would have gotten away with It too, if it weren't for you meddling programmer!"
@@sophiacristina Ha! BASIC on the C64 required an extra level of awareness because you could get yourself into trouble real fast due to some shortcomings of the BASIC implementation: Only the first two letters of a variable name are used, so "BOTS" and "BONUS" will be treated as the same variable (used to get me all the time) and many others. I can only imagine how challenging it was on something like the Atari 2600 was back in the day with its 128 BYTEs of RAM (yes, bytes!), max 8k of ROM size and no video framebuffer to speak of: All the work is done in software, live, as the video beam is drawing the screen. And back then those guys didn't have the tools we have now. They were literally using calculators and graph paper to make their games fit into the 4k or 8k space.
@@JustWasted3HoursHere I don't know what to answer, but that is pretty interesting info... Since i'm from the 90s and Brazilian, i had never touched a C64 or met someone that did (those computer were basically inaccessible here at the time)...
So i can only see it thought older people... I downloaded an C64 emulator, but i still have to mess with it and see what you guys struggle so much... Anyway, i watch this channel and 8-bit guy, so that gives me a good theoretical POV...
My life was on DOS, hahaha... My first game was Doom...
I heard that understanding Atari is pretty simple, but programming it is a pain, especially because the racing-the-bean issue... However, i'm willing to make a small demo on it just for fun, even if it is the trashiest trash ever, hahahah...
I also want to emulate and invent a 4004 console, so i was doing my research and i was "neat, 512 bytes of RAM, but i can add more. 4096 bytes of ROM, i can program Tetris on it, if i can do it, i think i can do something out of 2600, since it is more modern, right?! RIGHT?!", got on wikipedia, the first thing i saw... 128 bytes... *jaw dropped*...
Wtf?! This text is bigger than 128 bytes!
EDIT: I saw wiki and it is saying 4004 (in fact, 4002) have 40 bytes and the ROM have 256 bytes... :(
I need to do my research...
The code i got for the emulator was using:
"RAM[16][4][16]" (in nibbles)... :s
Now i have to see who is wrong here...
I used to love Frogs and Flies for the Atari 2600 (still own it in fact). Used to play it with the wife as well. I have a similar story where my wife loved the game "Deluxe Pacman" for the Amiga, and when I switched to a PC, I got permission from Edgar Vigdal to recreate it (as best I could) for the PC. I mainly recreated it for my wife who missed playing it. It's still available for download as I updated it for various versions of windows. Unlike you, I never got paid (the odd donation), just made it and put it out there for free. I'm a bit embarrassed by my code looking back at it now. I originally programmed it in C and I was still rather new to the language. I only recently released the source code after some people wanted it.
Vigdal made really nice space battle (Deluxe Galaga?) for Amiga
For history, 2600 game Frogs and Flies was Mattel's port of their Intellivision game Frog Bog.
I saw a quick flash of text and I thought "oh this must be some detail he added a note on but he didn't keep the text up long enough!" so I rewound and paused it. Growing up in Toronto I heard the Black Fly song at school in grade 4 and every few years I pull it up on youtube to listen to it. Such a classic and I got a good chuckle out of seeing it referenced out of the blue!!
I'm glad you caught that! I put little references like that in my videos and so often nobody notices, or if they do, they don't comment :)
This has long been a favorite game of mine, I play it often.
The music is amazing. The game mechanics are truly original and leads to a wide range of emergent situations, especially considering the game design understanding of the era. I literally watched the whole match you had against the AI and I cheered for you. The only thing I would consider "missing" is that something like "you won" at the end. But back then, it was the gameplay that mattered, not the afterpart nor the preamble. I grew up with a C64 and never saw your game but by 97 I was on pc I think.
I know the melody as "Here comes Peter Cotton Tail, hopping down thr bunny trail"
"Five Green and Speckled Frogs" has similarities to "Peter Cottontail", but it's definitely not the same. For example, the verse melody of Frogs goes from the 5th to the 6th note of the scale while Cottontail just sticks with the 5th before going to the 3rd and root. Frogs makes a lot more use of syncopation as well. Sheet music for both songs can be found online fairly easily if you want to compare yourself.
Frog Bog on Intellivision was a family favorite growing up. One of the few games my little sister had an even chance of winning :-)
Great stuff Robin. I would have bought this for sure if I had known about it.
Tomorrow peopele from Poland will know your game and your story Robin:)
another great episode robin, really enjoyed the walk through and has given me inspiration to crack my hardware out again - thank you for sharing and i hope you do much more of this. maybe you could do an example of how something in specific works. THANK YOU
I love your videos, both the technical content, your insights, and even how soothing you sound! I grew up with my C64, if I was a bit older then I can imagine that I would have done the same things you did, but alas I stuck with BASIC. I wish I had gotten more into the machine programming side back then when my brain was absorbing information (and retaining it!).
I recently went through some of the code I wrote for a grade 13 high school course back in 88. I believe the correct term is “spaghetti code” for comparing then to now. Even in my comments area I had “future features coming soon”.
It feels like another person wrote that code since I have been a software developer now for nearly 30 years.
My little boy and I added a few new features to my old programs. So satisfying to watch him learn the love of coding and to finally finish some of those “coming soon” features 3 decades later.
Thanks for the walk down memory lane Robin. I share you sense of nostalgia for your old programs.
That was interesting, thank you! As soon as I saw the title, I knew what it was, as I've had it for the Atari 2600 and the (differently-named) Intellivision for years... errr, decades... Anyway, I've never played your version, but it looks like you did a great job on it, and seeing the code walkthru was fascinating. 🙂
Would be neat to see how small you can remake the game with the experience you have now. A 3rd video on some optimizations would be interesting, to me at least. Maybe even a comparison of the speed the code runs at to a more efficient program. Even though you released this game the year I was born, I find low level coding like assembly interesting.
Magnificent run-through. Very thoughtful. Wish I had the source code for "Sea to Sea," my first sale to Loadstar. (Got a call from Fender Tucker and had a hard time realizing that he usually didn't call for a rejection!). Writing code is the BEST COMPUTER GAME - but a program to a complete stranger who (unlike your family) doesn't have to like it, now that is right up there with getting married, having a child, and getting your first machine!
I had fun programming on my Commodore 64 . The good old days:). Now learning programming in Xcode
Nice Christopher Hinton reference, I didn't catch that the first time I watched this!
Looks good, it’s very playable and it works. Nice work sir. Not many people can say this.
Awesome walk through, thanks for posting!
Thank you so much for explaining your code in depth! It helped me much to understand the way how to program in assembler, especially how to obercome obstacles. Knowing all the commands is one thing… but applying them in the limited 8 bit world another… 😂
I got paid a modicum of cash for writing one of the tunes that was accepted for the PC game _Star Control 2._ The devs of said game, who later made serious bank with _Skylanders,_ really took advantage of the music community on that one. Every tune in the game ran them $50, plus the eventual delivery of the finished game (along with an amusing letter of apology for being about a year late on said delivery). Even though there are a lot of tunes in the game, the final total was certainly less than $1500 for what was ultimately a widely acclaimed game soundtrack, in addition to being the very first example of completely digital music on the PC.
Seeing your modest payout for creative effort reminded me of that particular escapade.
Frog Bog on intellivision was one of the first games I ever played I was like 3 years old and my dad showed me how to play, I’ve been hooked since
Actually I really appreciate as you walk through your quarter century old code 👏. We all learned at some point (and still do). If we can see our mistakes but now know how to do it better it means we learned something in the process and this is good 👍
This is awesome - thank you so much!
Would be funny to see the code optimized with all your experience since then. what the final LOC count would be / performance improvements. Then again, it appears to run just fine.
Trying to learn to code, first time I saw and understood assembly.
Very helpful video, thank you.
isn't it bizarre how simple Assembly is? Yet, so hard to program with it? I mean, how much simpler can you get other than "ADD", "MOV", "JMP", etc? Only once in my life did I truly understand assembly, and that was when I had to create my own instruction set architecture for a graduate course.
This is amazing! I published game for Vita (ps mobile) which took me over a year to develop of everyday work and although i didn’t get huge money from it but the satisfaction of completing the project and a little bit of money made me very happy. Your game is very well done!!! Congratulations!
Yeah, I think he said he only took him 3 weeks? That's kinda amazing.
During the "Frog AI" parts, I kept thinking about Mel Brooks as "the world's leading authority on mind control in frogs".
Yeah, it was 3 weeks and then another session or two to add the white flies and the Quit option that Loadstar requested before publication. Haha re: mind control in frogs.
Yes, it's a fantastic feeling to complete a project. Congrats!
What a cool video! Thanks for sharing.
Ahhhhh I remember wanting to do a game just like this when I was like ten. Satisfying.
Good question at the end. I've done many walk throughs of the code to Supernatural, trying to be as detailed as I can. But there's always more detail to add! It's very hard to strike the optimal balance between entertainment and teaching. I really enjoyed this anyway.
I recognise the pragmatic approach to solving problems. A little too pragmatic in the case of copying large sections of code leading to the obvious problems. But it ain't stupid if it works. Out came a nice little game regardless. Hope you spent your money wisely!
Very cool game, I want to play it!!! Thanks Robin
I felt the same great satisfaction when I had my first C64 game published in a magazine. Got paid pennies for it but great day for me. I didn't follow up with programming though unfortunately.
Commodore made amazing machines. It's sad it didn't survive much past the 16bit era. The last Commodore machine I had was the Colt 8088, and even though it was a very dry, no-frills machine, it did an amazing job as dedicated BBS dumb terminal (28.8k baud, baby!). Commodore allowed me to explore the world one last time before it gave its final breath.
Very great content! Remembering typing in basic codes through the nights. Wrote also my own small simple softwares. Great times. Had the old brown C64 model only with datasette drive. Later as PC's overtook everything my friend gave me his old c64 disk drive. As I was 20 years, I bought a Amiga 4000 and tuned it up......could play Quake, Freespace and so on without problems. This was about the year 2000. So I fulfilled me a kids dream to have an Amiga someday;-). Sadly I sold this monster-machine a few years later:-(. Now Im thinking about to buy a C64 and a Amiga again for programming some classic games. Dont like the emulators...I want the real thing;-) Also to see what the demo scen is getting out of this old machines is unbeleavable! GREAT CHANNEL !!!
I'm really impressed you remember your code that well after so much time. Great video!
Nice cool game !!!!!. Congrats for the job you have done !!!!
Nice video. I am in awe in how you can easily interpret this and talk us through it. For me as a beginner I could have used a schematic of the overall structure and working of the code at the start.
Awesome video as always! Unfortunately, I don’t believe I have that issue of load star. If so, I would be playing frogs & flies all day! Such a fun game that you did a great job porting!
You could use that same background, and write a routine with some ducks flying and landing. Just add 2 crosshairs for 2 person play and you could have a duck hunt game. I would add different birds such as geese,pheasants, quails, and ducks for different point values. Add a eagle or dove, for negative points if you shoot it. The person with the most points in a timed rnd wins.
Some of the birds might attack the frogs :-(
This is gonna be the perfect thing to sit down and veg out to while I recover from my second covid shot tomorrow 😌
Oh, good luck, I'm just starting to feel normal after mine yesterday!
Sheep
25 years since Frogs and Flies was published!
Ahhhh... All that 6502 code just makes my heart melt...! THANX!
The music's pretty catchy.
@Robin - thanks for doing this. I know it's pretty specialised and very time consuming and perhaps won't get you the most view - but it's pure gold and I appreciated it. To others looking to code a 8-bit blockbuster from their bedroom so they can buy a Ferrari I recomemend you also check out: Matt Heffernan on YT.
Frogs & Flies 2021 - when? 🤩
I remember a time when I didn't know how to write loops, so I just unrolled them - before I even knew that unrolling a loop even was a thing, and I certainly wasn't doing it for any kind of performance optimisation. 🙂
Hey Macbeth, I just downloaded this game from the csdb...that's why I love the csdb.
Great my master 👌👌👌
Fun game, enjoyable show! For some years I've toyed with the idea of trying to port GBA "Advance Wars" to C64. Turn-based strategy, so I think it's feasible. The furthest I've gotten is just adapting a bit of BG gfx. Not sure how many features would need dropping, if any. I've gotten so many hours of enjoyment from that series, I recommend it highly. Cheers!
If you ever rewrite your code add a demo mode like the arcade games use to have. Cycle through different levels and high scores.
Hi Robin, great walkthrough. Wondering, are you going to put the source on GitHub at any point ?
Quite an assembly language beast for such a simple game. Surprised there wasn't a free C compiler for 6502 in 1997.
Looks like a very fun and addicting game.
Great and interesting video. Was the source code shared to review alongside?
Even on the C64 C would have an over head which you don’t get with assembler. I get paid to write a whole bunch of higher level languages but I can still bang out 6502 assembler so I wouldn’t bother with C on an 8 bit Micro.
Damn!!!
You left a comment about frogs and flies on my video some years ago as MacbthPSW?
The AI is kicking your butt until the end. I love the graphics! That was on the C64? I would have enjoyed it back in the day.
Can you make a video about what’s involved in cleaning up after yourself when exiting the game?
I think you briefly talked about the digitized drums and music. Was there a music editor that you used? Was there separate code somewhere to merge together all the assets? Did your music program come with its own engine for playing back the music / sfx?
Is the source available as a download? I'd like to have the full listing to took at as I review this video.
1:18:29 to get all the way to zero:
loop dex
sta addr,x
bne loop
STA doesn't affect the 6502 flags.
Aha, good!
So we are the same age :D 1973 for the win :D Nice sprites btw!
Bad code is Okay, as long as you get things done! I agree! In my video yesterday, I made an PoC for an AI that has voice activation and face detection and recognition. I did a quick PoC spend a day on it and the code, of which 60% is from someone else who write a wrapper around the Fisher Haar recognizer, is horrendous. But it proved the concept, it showed what I need to look into more before doing a prototype. And after that prototype you will throw everything away, when all kinks are worked out, and then you write the real thing. That's how electronics- and other product design has worked forever. You never get a good clean viable product the first time.
Thank you for the walkthrough, as a developer and C64-kid, I am uneasy without ctrl +s to save to persistent storage every 5 minutes, version control, and IntelliSense. I understand this code somewhat but how would a dev team work on the same code like this?
On 8-bit systems, it was incredibly rare for more than one person to code a game, with the exception of a musician programmer to write the music routine, which would be added into the codebase by the game programmer--and fairly often that was only played on the title screen. If a game had distinct sections/levels, different programmers could work on each and then integrate them into a single program.
I just ran across this game when going through a bunch of disk files in a "Roms" directory of a sd2iec software card i bougjt!
Hey, Macbeth, looking sharp on your tbaytel site.
very interesting, did you open source the code? Did you ever disassemble the Atari Frogs and Flies?
I copied a chunk of code this week to another part of a program and it made me think of this one.
One of my favourite games… was available on Atari as well 👍👍👍
Frogs and Flies for the VIC-20 please
I had a frogs and flies game for the Odyssey 2 that I never could find any information about.
Thanks for that. :-)
I use to play this game a lot!
I remember this game
clrscr did not need to temporary store its inputs (A and X), if you used LDY #250 instead, and used TXA after color is done char routine now have a correct A preserved.
But as outside of a loop not that important. Counting down to and including zero can be done with BPL if you could start with a value of 128 or less.
Omg, that was one of my favorite games on the 2600. Yeah I’m ancient lol
Fender Tucker?!
Does the contract still prohibits to release game and code on a github ? :)
At 1:18:00 you could just have moved the dex instruction up above the 4 sta, no extra math required but the loop should behave the same. Or am I missing something?
I played (and loved) the Atari 2600 version as a kid. I would have loved this version
could re-write your old C64 games to the Commander X16 - lots of banked memory to make use of and much faster clock-speed for doing game enhancement
What about compressing items and storing them using Base64 encoding then decode them and drop them back into where they are needed.
I was trying to compile a program from one of your video streams and it just not compile with GCC-586 seems like GCC-586 didn't like the rather ropey C++ code
Is this one of the games that were played in the movie _Grandma's Boy_ ? It looks familiar...
(The movie's versions may have been a port)
Cheers,
I've never seen that movie, but apparently they're playing "Frog Bog" which is the Intellivision version of this game!
Maybe you do the inc because it effectively does a read and a write, but maybe takes less bytes than a load and store. I know I did a push 1 and pop reg to set the whole 32 bits of an x86 register: 3 bytes vs 5 or 6 I think haha
Master!!!
Didn't Frogger use that same tune? Your baseline adds a nice touch!
No they just ripped a bunch of Anime songs and a nursery tune, early 80ies had lax copyright in Japan lol.
@@freeculture I didn't ask where it came from or who composed it. I asked whether it was the same tune as in Frogger.
You should turn the song into a ring tone