This video demonstrates how to create a Haiku poetry generator program on the Commodore VIC-20 using Commodore BASIC, showcasing memory-constrained programming techniques. The program uses arrays to store categorized words (5-syllable, 7-syllable, and 5-syllable words) and random selection to generate poems that follow the traditional 5-7-5 syllable structure. The program is designed to run on unexpanded VIC-20 systems with only 3.5 KB available to BASIC, requiring careful memory management. The speaker explains how the DIMENSION statement creates arrays, how DATA statements populate them, and how RANDOMIZE and RANDOM functions enable random word selection. The program demonstrates cross-platform compatibility across Commodore 8-bit computers (VIC-20, PET 4032, Plus/4, C64, C128) by avoiding hardware-specific commands like POKE and PEEK.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
VIC20 Haiku Creator - Poetry in 3.5 KilobytesAdded:
[music] [music] >> Hi, I'm Doug from Dynamic Computing and welcome to another episode of the Chicken Head Chronicles. My uh occasional series all about the Commodore 8-bit computers.
So, this week we're going back in time to my Vic-20, which of course, as many of you know, first computer, 1981 or so, picked it up, fell in love, and it started my entire love of computers and Commodore machines in general.
One thing I always used to do as a kid is program in BASIC on it.
And I was a year or two before I got any kind of expansion cartridge. I think I got the uh the uh graphics cartridge, the one that adds 3 KB of RAM and adds all those graphics commands. Um then it seems like maybe maybe I got an 8K cartridge at one point in time, but I don't really have solid memories of that. But I think I was limited to to just a total of 8 KB, five on board and then 3K on the uh super expander cartridge.
But we could do some really cool things with our basic Vic-20s. 5 KB of SRAM memory, 3.5 KB available to BASIC. I was creating custom characters where you take, you know, the the alphanumeric characters and you have this little 8x8 grid and you plot out the little uh poke commands on the grid to reprogram individual 8x8 characters, making custom characters, making custom games. I mean, how many little dudes with two legs, two arms, and a head holding a little sword did I create back in the day? I have no idea, but I created a ton of them. And some cool little fun games based on that, too.
But, when I got back into retrocomputing back in about 2018 or so, um one of the things I wanted to do was get back in and and cut my teeth maybe doing a little bit of basic programming again. So, I pulled out the old Vic-20 and I decided, probably, I'm thinking 2019 or so, that I was going to write a note a new basic program just on the Vic-20. Once you've learned basic programming and you start, you know, looking at a book maybe that that talks about it, it's the stuff just pops back into your head. You know, I hadn't done a poke command in 35 years. I start looking at the manuals and like, oh yeah, I remember these poke locations. I remember these numbers to change the screen colors and access the audio chip and everything like that.
But, what I wanted to do was practice some of the more complicated things in basic, like uh arrays, which are actually pretty powerful in Commodore Basic. And a lot of simpler basics back in the day didn't have the ability to handle arrays.
So, I decided to create a program that generates haikus. And of course, haikus are the Japanese style of poetry where you have five syllable line, a seven syllable line, and then another five syllable line. I thought that'd be pretty fun to just create something that would put strings of characters together and try to create some actual fun poetry out of it. So, that's what I did. So, let's pop on over to the Vic-20 and take a look at what I created a couple of years ago.
Come on by. And here, of course, is my beautiful Vic-20. This is not my original. My original, I took a Sharpie marker sometime in the '80s and colored the entire thing black in Sharpie marker and then lost track of it. I have no idea where it is. I don't remember throwing it out, but I've never been able to find my original. This is one of my four or five VIC-20s that I own, but it's beautiful. It's got an absolutely gorgeous keyboard, perfectly responsive, everything works great. And we of course have from my friends at The Future Was 8-Bit a Penultimate cartridge in here, which is something you absolutely have to have, and something I don't recall ever doing an official review on even though I've meant to for like 6 years now. And instead of a floppy drive, which I I do own uh a couple of actual 1540 I've got a 1540 drive for the VIC-20, and then I have a 1541 that is in the white 1540 case, which is actually a pretty cool. But instead I'm using an SD to IEC, which uh works kind of like a little uh uh hard drive. It's actually kind of cool. Let's open the VIC-20 up and see what she looks like on screen. Here we are on the lovely VIC-20 screen, and as you can see, I don't have any of the extra memory expansion uh set up right now. We're literally dealing with the 5K that's on board here. The only purpose I have for this uh uh Penultimate cartridge in here is cuz I use it sometimes to uh access the files.
But really we're going to be relying solely on the SD to IEC to pull it up.
Let's see what we've got here.
And it's very, very fast. And there's our Haiku program. So, let's load Haiku 11. And the reason it's called Haiku 11 is it is the eighth generation of the Haiku program.
One of the cool things, and one of the things I decided to do when I created the Haiku generation program was I wanted to make sure that it was fully compatible just right out of the box with all of the 8-bit Commodore computers. I run this on a Vic 20, I run it on my PET 4032, I run it on my Plus/4, it'll run on my Commodore uh uh 64, Commodore 128 in both 64, 128, and VDC mode. Everything it runs because I kept it simple. I didn't use any pokes or peeks. Let's see what it does. Haiku generator by Douglas Compton. What is your name? Well, considering everybody still calls me Mark for some reason, I know why. Mark, what's your favorite number? Oh, come on. This is an easy one.
69. Hello Mark, 69's a good number. I will use that number to create a haiku for you. Haiku? Yes or no?
And just simple, yes.
One haiku coming up. The snowy ocean, happy silly desert bird, dark ladies running. And you can see that it follows the the uh guidelines for an actual haiku. Five syllables for the first line, seven syllables for the second, five syllables for the third line. And often there's something very nature oriented, which is why I did this.
It totally created this from random, from a list of of words that I created that we're going to talk about in a minute.
Some of them are better than others.
Happy silly desert bird, dark ladies running. Okay, let's do another one.
Totally random.
Warm windy rainstorm, sunny single singing bird, fine old men singing.
Again, totally random.
Another one?
Warm melting ocean, muddy tiny darker sky, the stranger singing. See, it reuses some words, obviously, cuz I can't have an 11 million words in here in 3 and 1/2 kilobytes, but it absolutely does grab words randomly from the list I've created and creates a haiku every single time.
Bright cloudy ocean, muddy silly singing bird. Lots of birds actually. Sad songbird swimming.
One rainbow autumn, gentle autumn singing bird. Wow, there are a lot of singing birds. Two stray dogs singing.
Oh, singing dogs, nice.
Warm melting snowstorm, shady tiny calming lake. Old fishes playing.
Cool. Now, let's take a look at how this program works. We could do this all day.
And uh but let's take a look at how it works.
Thanks for the poetry.
First of all, we're going to list the program.
And you can see it's not particularly long.
I mean, it's a 22 character display.
It's not particularly long. But let's list through line 60. We'll go through this a line at a time and see what makes this little guy tick.
Starting off up at the top, of course, we're going to clear the screen, which is simple to do.
Just the little shift clear home.
And then I change the character color to black. Now, on a PET computer, it does not care about this because it's just going to be a green screen.
Uh but on every other Commodore 8-bit, it's going to change the character color to black. If it can't change it to black, it just keeps it its normal color.
And then uh line 15, haiku generator. I just use some again print characters to space over a little bit and space down. Uh input your name. And I changed the I believe I changed the color there. And it the input is N dollar sign. I literally only use that to keep track of the name. It doesn't do anything else.
And put your favorite number. I did this just for fun, just to kind of make the numbers a little bit more random. The random number generator on Commodore 8-bits is not entirely random. It's it it does have a pattern, but if you throw in an additional number into it, it does help randomize it a little more. And then I greet myself, "Hello N dollar sign." And then it says, "N is a good number." Great. We I will use that number to create the haiku. And then it asks me if I want to create the haiku, yes or no. And it puts that a wire N in another string. Let's list a little bit more here.
All right. So, if the answer, that's what AN stands for is answer, is yes, then go to 91. If it's no, then go to 500, which breaks us out of the program. It just says, "Thanks for the poetry." and breaks us out.
If it's neither of those, if it is neither yes or no, I sarcastically say, "You have a hard time following directions."
and it goes back and asks you again. So, it literally only accepts yes or no, and if you choose any other character, it just makes fun of you. I put a few remarks in here. Although it does consume some memory, which we are going to be talking about, uh it does consume some memory, uh but I want to be able to remark in the program so I know and other people who use this know what each of the lines does. So, uh remark, uh dim statements pull 30 words into an array to be selected randomly. Each line grabs 10 words and moves into the array and then moves on. Let's see what I'm talking about with the array.
Here's our actual array.
Line 91. Dimension that that stands for a basically dimension array. Dimension F1, which is my first variable here. F1 dollar sign means it's a character.
When you have an array, you tell it how big the array is. This array is nine dimensions. So, basically, we're going to have F1 dollar sign one, F1 dollar sign two, F1 dollar sign three, all the way up to F1 dollar sign nine.
Then, for F1 equals zero to nine, it counts up to nine. This now tells it read from the data statements that we're going to be looking at in a bit, F1, and then F1, which is so So, the first time it goes through, F1 dollar sign one, it pulls in data. F1 dollar sign two, it pulls in data. F1 dollar sign three, it pulls in data. And it does uh goes through there for an iteration of nine times. Pulls in the first 10 characters. Sorry, it does it 10 times.
Pulls in the Pulls in the first 10 uh data arrays. Second line, same thing.
Pulls in the second set of words.
F2 dollar sign, zero through nine. So, 10 different uh words.
Then, F3, that is basically pulling in the first line of the haiku, literally the first five syllables of the first line of the haiku. It pulls those in.
Here's the second.
And here's the third down here.
And it just dimensions the same number of uh uh arrays there. Pulls them right in. Now, what is in these arrays?
We can actually look at those, even though we're in base back to basic, it still has all that information that's read into the arrays. So, if I do print F1 dollar sign one, it pulls in the first thing in the array. Fantastic.
It was The first word is glad. If I do two.
The second word is the. Of course, it uh has the the D there.
If I do three, that's the word one.
If I do four, see how it stores different variables in the same variable called F1 dollar sign, but it gives it 10 different options. Here's the eighth one.
cold Here's the ninth one.
warm Okay. There is no 10 and 11 and 12 cuz I have not defined those arrays. So, if I do dimension of the array 15, nothing because I've never created that length of of uh dimensioned array. If I go on to my third one here, so uh T2 T2 And we're going to look at the fourth dimension.
old men T2 six stray dogs See how it's pulling those in?
Let's look a little bit deeper on how it does this.
There's our our last dimension where it reads in the third set of of words from the third line of the array and stores those in the variable T3. So, we've got F 1 F2 and F3. We have nine different arrays. S1 S2 S3 T1 T through 2 T3 for third.
Each one of them has 10 different uh dimensions to the array. Think of it like a spreadsheet, okay? So, you've got A B C D E F G, okay? And then you've got 1 2 3 4 5 6 7. So, T3 would be over here, T3, and it would be the ninth one down. If you think of it like a spreadsheet, it makes it make a little more sense. Now, print. Cool. It It clears the screen. Cool. One haiku coming up. Now, I reversed haiku here.
Reversing works on all of the Commodore computers, not not just the color ones.
So, that'll come out in reverse text.
And then I change it the color back.
Okay. Pick randomly from the dimensioned array for the first line of the poem.
This is repeated below for each line of the haiku and is printed to screen. So, I've got this variable called variable called F4 equals integer rounded N. That is the number that you typed in, which can be just about any number. It can handle just mostly any number that a Commodore 8-bit can handle. You can have that 65,000, you can have it 69, you can have it 42, whatever.
Takes that. It bases the random number on that number.
Nine times plus one, okay? So, that's 10.
All right. And then F5, it it grabs another random character or random number for that array.
And here, it grabs yet another random number, okay? So, it's now randomly picked one or zero through nine, okay?
That's what that does, and it assigns the number zero 1 2 3 4 5 6 7 8 9 to that particular variable, F4 F5 F6.
Let's keep looking.
And it prints that first line out. Print F1.
Okay. First line first character or first set of words for the haiku. And it puts the random one in there. Pops it in there, puts in a space.
Pops the second word in there based on that random number, puts in a space.
Third word random number zero through nine, puts in a space. It's just created the first line uh from my my uh dimensioned array and prints it to the screen.
Line two, same thing.
Well, we put a space there.
Second line F S4 S5 S6, it grabs random numbers zero through nine again kind of based on the number you put in. I really don't need that. It wouldn't change it much if I didn't put it in there, but I was having fun.
Prints that on the screen.
Creates the third line, set of random numbers pops those on the screen, prints those out.
That's it. That's what it does.
So, it prints out the haiku just like we showed earlier. And then it asks, "Do you like my haiku?" Yes or no.
If you say yes, it goes to this uh line 450.
"Great, let's do another one." And it'll just keep repeating that. It pauses for 1 second, and then it goes back and it just generates another haiku based on your random number. If you say no, then it goes to 500. "Thanks for the poetry."
And then the next line is just a break.
It just breaks out of a basic programming.
And also, if you do anything besides yes or no, you have a hard time following directions, and it goes back and it just asks you again. It just makes it a loop.
Basically, so it doesn't error out if you put in the wrong character. It just tells you you put in the wrong character. Now, let's look at how I pulled this data together.
Our second set for our second line, again, we've got two syllable word here because the second line of a haiku needs to be seven syllables. Flooded, tender, muddy, gentle, shady, happy, forlorn, misty, sunny, foggy, summer, winter, autumn, springtime, etc. Two syllables.
Now, here we're going three syllables. So, two syllables, two syllables, three syllables. There's our seven syllables.
So, I picked words in the for this last set of characters in the second line that were three syllables. Dragonfly, butterfly, calming lake. See how you can have two words together with a space? It doesn't care.
Calm ocean.
Darker sky. Oh my goodness.
Calm ocean is one is only two syllables. That's a bug in my program. I need to fix that.
Darker sky.
Next data statements, mountain stream, two syllables. Desert bird, two syllables.
Three syllables.
Mountain path, warming fire, singing bird. All of those are three syllable words for the the second set of data.
Lastly, we're going to grab the third line.
This is also going to be five syllables.
Let's see if I screwed this up at all. I can't believe after all these years I found a bug.
This is one syllable for the last line.
Young, the, three, two, fine, sad, glad, bright, dark, old.
Next line, or the next word, is going to be two syllables. Crickets, fishes, songbirds, strangers, old men, crayfish, stray dogs.
Last one is also going to be two syllables. Children, old cats, ladies, eating, sleeping, running, swimming.
Lie down, go slow, go fast, singing, dreaming, playing. Okay, those are the words that all of my dimensioned arrays pull in.
So, that would make sense that my last array would say uh playing. So, let's take a look.
Print P3 nine Whoops. I forgot the dollar sign.
Playing, see? And then eight would be dreaming.
Does that make sense? How it pulls in the array, 10 words, pops them into this dimensioned array.
Uh next would be singing.
Yep, singing.
I'm still bugged by that one bug that I found in there.
Name Doug E. Fresh Favorite number 6767 I will create a haiku. Let's Let's put something else in so you can see the error message. J You have a hard time directions. Haiku, yes or no? Yes.
Sad snowy ocean, sunny gentle desert bird.
Three fishes swimming. Hey, see that's that's pretty cool. That's pretty cool.
We're going to do another haiku.
Warm chilly daybreak, foggy tiny singing bird, dark old cats sleeping.
You like my haiku? No.
Thanks for the poetry. Okay, now how much memory does this really consume? First of all, let's clear things out completely.
So now we should be able to we should be at a completely free slate here. Let's see how much basic memory we have.
3581 bytes, okay?
No problem. Let's go ahead and load haiku 11.
This is just loading the program into memory now, okay?
We have one byte free. 1139 uh bytes. We have 1 kilobyte free.
But here But watch this. This is before the program is executed. Now we're going to execute it. We're going to be putting things into the array. So let's do uh Philbert Schlong.
Look at that. I tried to use capital letters.
How funny. 654321.
Hello Philbert Schlong. Let's see if we can actually Yeah, it works fine in lower case. We'll do them lower case there.
654321 is a good number. Use that number to create a haiku. Yes.
Dark green below winter, muddy mountain path, glad stray dogs go fast. Cool.
We don't like the haiku. Let's go back to capitals.
But look what happens to our memory here.
Can anyone in the class tell me why we only have 635 bytes free instead of the 1139 we had before we ran the program?
That's right, little Billy. It's because after we run it, it takes that data that I keyed in in those data statements and it throws it into those arrays and all of those arrays are still absolutely full. So, if we do print, I think it's N dollar sign, Filbert Schlong.
Hey, Filbert. And you know that the number print N, that number's still in there. All of those take up data. Print F2 (5) Duggie, why are you forgetting the dollar sign?
Filbert Schlong would never forget the dollar sign. Call me. That takes up data right there. That's why this takes up more data. This is also why, in order to keep this being able to be run on an unexpanded Vic 20, which was my goal, I can only have a certain number of arrays. Could I make it a little bigger?
Absolutely. I think if I do the math, I could probably get it up to about um 11 words instead of 10, maybe 12 words if I'm careful, and I would still have a couple bytes of memory free, but I'd be kind of pushing it right there. And then you get to the point where if you have uh like a really long name here, you know, Filbert Schlong Bartholomew uh Spoogenheimer the Fourth, suddenly that takes up more memory and we run out of memory. So, I want there to be just a little bit of a buffer for longer names, things like that. So, I I could probably expand it to 11 words it pulls from instead of 10 and still get away with it, but if I went much beyond that, well, we'd have some issues.
Now, bonus points for anyone who can tell me why this word is up here. Put it in the comments below. I'm going to have this program available. I'm going to put it up on my Facebook group, the Commodore Technology Facebook group. I'll put a link in the description. I'll see if I can put like a Dropbox link for it. I'll see if I can put the actual text for it on my website. So, you if you go to www.10marc.com.
Hey, why don't we just type it in?
10marc.com Let's see if we can go there on the Vic 20.
Huh? Syntax error. If you go to www.10marc.com, I will have a link there that has the actual code that you can just put right into your computer, your Vic 20, your Commodore 64, whatever. I'll also have a download link there for the actual program.
All that I ask, if you add or change or do anything, just go ahead and throw me some credit. Leave my Leave my credits in there and don't try and like, you know, take this on as your own creation cuz this is something fun I'm really quite proud of.
I want to say thank you to all of my absolutely fantastic patrons on Patreon.
And this is how I want to thank you today.
You guys are absolutely fantastic. If you want to join in the fun and become part of my my group of Patreons who helps support me, pop over to patreon.com/10marc.
For as little as two bucks a month, you can sign up. There's even a free tier if you just want to be a, you know, show your support without dropping any money into the the till.
That's fine. Thank you all so much.
>> [music] >> So, thanks for joining me today. I really do appreciate it as I'm sitting here playing some Ms. Pac-Man and hopefully not going to get slaughtered.
Uh please follow me on all of the socials, the Blue Skies, the uh Instagrams, the Facebooks.
And I just got killed. Uh, follow me on all the socials. Please comment below. I'd love to hear your opinions about the haiku program. I'd love to hear how you could, you know, I could maybe enhance the hi- haiku program.
Um, make sure you download it from my website. Feel free to play around with it. Feel free to enhance it, but it can just give me a little bit of credit for it.
But, until next time, this is Doug from the Chicken Head Chronicles and 10-Minute Amiga Retrocast literally signing out.
Bye-bye.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











