#oneaday Day 906: Programming club

I spent an hour or so this evening doing my own personal little "programming club", by which I mean I sat down in front of the MiSTer, fired up the Atari800 core and just spent some pleasant time tapping things into Atari BASIC, guided by the book Atari Sound and Graphics: A Self-Teaching Guide by Herb Moore, Judy Lower and Bob Albrecht. I am deliberately doing things as I would have back in the day; that means no modern tools (aside from a Kindle Scribe I have the book on), no IDEs and definitely no fucking generative AI.

I picked this book primarily because I recognised Bob Albrecht's name from a book simply called Atari BASIC which I had used back in the day, and because the main things I want to play with at the moment — or the things I want to know more about over the long term — are the graphics and sound capabilities of the Atari 8-bit. I need to revisit some concepts, such as things like redefining character sets and perhaps some of the mathematical functions, but I've been pleasantly surprised quite how much of that knowledge from back in the early to mid '80s I have apparently retained.

I mean, I have retained knowledge and experience to such a degree that I can still remember where certain symbols are on the Atari keyboard when they don't match a modern layout. Almost immediately, I was hitting some sort of long-dormant muscle memory, and it was a nice feeling; like stepping back into a familiar place after being away for a long time.

I genuinely learned something, too. I've always thought I understood the random number command in Atari BASIC, but it turns out I had misunderstood it quite significantly. To be fair, I had only ever seen it used in one particular way, and thus I had naturally come to assume that is how it worked, but today I feel I actually got a proper handle on how it really does work.

What's that I don't hear you saying? You want to know specifics? Well, all right, since you insist. Here's the simplest use of the Atari BASIC random number keyword:

A=RND(1)

This sets the variable A to a value between 0 and 1, including decimal places. The number in the brackets is irrelevant; most people use either 1 or 0. It doesn't matter.

Getting a number with lots of decimal places isn't always convenient, though, so in that case you use the INT keyword to round it off and get an integer or whole number. Thus the following:

A=INT(RND(1))

…sets the variable A to an integer value between 0 and 1, which means it excludes any fractions. In other words, you will get 0 or 1. But what if you want a bigger number? Well then, you just add a multiplication factor (represented as * in BASIC, as in most other programming languages and spreadsheets), but there's a small caveat to this:

A=INT(20*RND(1))

This sets the variable A to one of 20 different possible integer values. However, they are not between 1 and 20; they are between 0 and 19. To get between 1 and 20, you tweak it to this:

A=INT(20*RND(1)+1)

In other words, you're taking a random integer between 0 and 19 — one of those 20 possible values — then adding 1 to it, which results in a random integer between 1 and 20, which is still one of 20 possible values. So far so good, right? When I came across this as a child, I naturally assumed that the "20*" in this example represented the maximum you wanted the random number to be, and the "+1" was the minimum you wanted it to be. But it does not work like that. I mean, it does if you want a random number between 1 and 20, but what if you want a random number from a range that doesn't begin with 1? What if, say, you wanted a random number between 50 and 60?

Using my mistaken and misunderstood theory from childhood, this, then, doesn't work:

A=INT(60*RND(1)+50)

What happens here is you get a random integer between 0 and 59, then you add 50 to it. As you can probably tell, this causes problems at various points in the range. If the initial random number generated was 59, for example, adding 50 to that will give you 109, which is not between the 50-60 range we are after.

Instead what you have to do is set the multiplication factor to the number of possible different results you want, not the maximum value. Then you set the number added to the minimum value. Then it works. Between 50 and 60 we have 11 values, because we count 50 as the first one. So this does work:

A=INT(11*RND(1)+50)

What happens in this instance is you get a random integer between 0 and 10 (one of 11 possible values), then add 50 to it. This results in a random integer between 50 and 60.

What if you want a number between 0 and 50 that is a multiple of 5? Well, we use what we've just learned. The different possible values are 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 — that's 11 of them in total. So we use 11 as our multiplication factor to get one of 11 different possible values. We then multiply the entire equation again by the "step" we want our random numbers to go in as such:

A=INT(11*RND(1))*5

What happens here is that we pick one of 11 different possible random numbers between 0 and 10, then multiply that result by 5. So if the original number was 0, we get 0; if it was 1, we get 5; if it was 2, we get 10… and so on. The end result is 11 different possible results, each of which is a multiple of 5.

This is relatively rudimentary stuff, I know, but plopping my thoughts down on paper like this is really helping me cement the knowledge in my head — plus I'm just pretty chuffed at finally having figured this out, having discovered I had been misunderstanding this function ever since I was a kid. It never really got me into trouble, mind, because most of the time I was just wanting to generate a random number between 1 and x (to simulate a die roll, say) but it feels pretty damned good to have figured it out properly today!

The remainder of my time today was spent noodling around with various uses of the random number facility to generate graphics and sound. A lot of this I already knew, but it was nice to make the knowledge feel a little more secure, and realising quite how much stuff I do remember has already done wonders for my confidence. It's once we start getting into things that I never really understood, or which are much more complicated, that I suspect it's going to get a lot more challenging. But I'm determined to finally conquer the display list and player/missile graphics if it kills me!

It just might take a few sessions and lots of reference material on hand to get there. But I think this is going to be fun journey. (If you want to follow along, I've set up a new category on this blog called Programming Club, where I'll be putting all the updates from these self-study sessions.)


Want to read my thoughts on various video games, visual novels and other popular culture things? Stop by MoeGamer.net, my site for all things fun where I am generally a lot more cheerful. And if you fancy watching some vids on classic games, drop by my YouTube channel.

If you want this nonsense in your inbox every day, please feel free to subscribe via email. Your email address won't be used for anything else.

#oneaday Day 863: Where to even begin

One of the things that I've wanted to do for many years is get to grips with really being able to program the Atari 8-bit. This will be a completely useless and unmarketable skill for me to learn, but with the Atari 8-bit in particular having always been so important to me, it feels like a natural step in my enjoyment of the hobby. Only trouble is: I don't really know where to begin!

I still have a vague knowledge of Atari BASIC from my days typing in listings as a kid and inventing my own programs way back when, but I suspect a lot of the intricacies may have fallen out of my head at some point, as I haven't really done anything substantial in Atari BASIC since… well, since it was current and relevant. Beyond that, though, there are a wide variety of things that are a complete mystery to me. And I think the sheer wealth of things it's possible to learn, even on an old computer like an Atari 8-bit, is what makes it so daunting.

Do you get in-depth about how to handle variables and strings? Do you figure out the mathematical functions? Do you learn what all the different default graphics modes do, and what they are best used for? Do you tinker with the sound capabilities of the POKEY sound chip? Do you learn how to display, move and otherwise use player/missile graphics, aka hardware sprites? Do you learn about the display list, and how a display list interrupt is a different thing from manipulating the display list? Do you learn what a vertical blank interrupt is, and how to use it? And at what point in all of this do you "graduate" from BASIC to machine code?

This constant string of questions, which I could have extended to at least five times that length, is probably the big thing that holds me back from actually dipping into "learning how to program the Atari 8-bit" as a serious hobby. I'm sure there isn't really a "bad" place to start — and having an idea of what I would like to be able to program is probably a good way of determining what things I should focus on looking at first — but it's that old Analysis Paralysis thing again; when confronted with seemingly infinite options, you end up choosing none of them.

So I think the answer is probably just to pick a book — of which there are many available on the subject of Atari 8-bit programming, coming at it from myriad angles — and work my way through it. All of it. Then, from there, I can learn where I might want to head next, or figure out where the gaps in my knowledge are. Ultimately, then, I can develop a solid understanding of all the things I might "need" to know in order to be able to program the system effectively.

The reason why this is all on my mind right now is, of course, because of the increasing number of AI slop projects I've been seeing in retro gaming. Over on the website Atarimania today, two out of the four new additions to the database have "developed using AI" disclaimers on them. And one might ask: why don't I just "get the AI to do it for me"? Surely it is easier than ever to shit out a program-shaped object using Claude (they had to pick the cuntiest name possible for it, didn't they?) and then convince everyone that "I made this"?

Well, no. If you've spent any time reading this blog over the last few years, you'll know that this would provide me with absolutely no satisfaction whatsoever. Just because "an easy option" exists now doesn't mean I want or need to take it. In fact, I feel like with how likely it is that the AI bubble is going to burst and all of this crap is just going to go away one day — and God, I long for that day — it is all the more valuable to learn how to do something like this properly.

What I'd love to be able to do is create a game for the Atari 8-bit. That feels like a very far-off goal right now — but one way of looking at it is that back in the '80s, people had a fraction of the reference resources we have today (and no, I don't count AI in that) and were still able to learn how to do these things in their own time relatively quickly. So with a bit of determination, dedication and actually setting a bit of time aside to do this, I feel like I might be able to learn something.

As I say, it'll be something that is mostly useless and not really marketable, but who cares? Remember a time when hobbies were just things you did because they were fun, and you didn't feel the need to monetise them or even share them with others? I'm thinking that's what this has to be. Something that is just for me; something that I want to learn for myself. Not because I want to make and sell a game, but just because it's something I've always wanted to learn, and to be able to make something for my own satisfaction.

So I think maybe for the rest of this evening I might go spend some time tinkering in Atari BASIC on the ol' MiSTer…


Want to read my thoughts on various video games, visual novels and other popular culture things? Stop by MoeGamer.net, my site for all things fun where I am generally a lot more cheerful. And if you fancy watching some vids on classic games, drop by my YouTube channel.

If you want this nonsense in your inbox every day, please feel free to subscribe via email. Your email address won't be used for anything else.

#oneaday Day 641: Learning something new and pointless

Every so often, I get kind of a hunger to learn something new, but a little gremlin in my mind almost always stops me from pursuing that thought with a simple phrase: "there's no point".

His thinking is that learning how to do something new absolutely must be something useful that you can use in your day-to-day life, and preferably make money from. And the reason I listen to him is because I understand where he's coming from; we live in a mercenary world with a cost of living that continues to escalate, and thus it would seem eminently sensible to learn something that would, at the very least, have some value in the job market.

But at the same time, there are things I want to learn about that, while arguably "pointless", I think would just be fun and interesting. One that I keep coming back to is the concept of programming — but specifically programming on the Atari 8-bit home computers.

I used to dabble quite a bit in programming in BASIC when I was a kid. I had several floppy disks' worth of BASIC listings that represented a combination of things I had typed in from magazines, things I had adapted from things I had typed in, and completely original creations. I never got particularly good at programming in Atari BASIC, but I did enjoy doing it. And for the longest time I've found myself wondering "what if I actually applied myself and tried to rediscover and expand on those skills?"

That's about where the gremlin enters the picture, you see. There is no rational reason why I should spend time learning how to program a long-defunct computer that you can't buy any more and which, in the grand scheme of Home Computers People Have Heard Of, ranks far behind the Commodore 64 and Spectrum, despite having capabilities at the very least on a par with, and often superior to, both of them.

"It's a waste of time," he says. "There's no point. You won't make any money from it. No-one will want to hire you based on that."

Well, frankly, who gives a shit? I'm not getting any younger, and I feel like learning new things is a good way to keep the brain active. So I think what I might actually do is put some serious time into this. Maybe devote an evening or two a week to it and see what happens.

It might not go anywhere. But at least I'll have been trying something new. And that's quite an exciting thing.

Another thing that has been holding me back is not really knowing where to start, but a blog I stumbled across by chance earlier today gave me some good recommendations of books to take a look at. And if people back in the '80s could learn how to program using just these books and no Internet to look things up on, I'm sure I can do something similar.

Maybe. We'll see.


Want to read my thoughts on various video games, visual novels and other popular culture things? Stop by MoeGamer.net, my site for all things fun where I am generally a lot more cheerful. And if you fancy watching some vids on classic games, drop by my YouTube channel.

If you want this nonsense in your inbox every day, please feel free to subscribe via email. Your email address won't be used for anything else.

#oneaday Day 508: Pondering a new video idea

I play a lot of classic games on my YouTube channel, and that's not going to be changing any time soon. But I'm always pondering interesting new things I might be able to do with the channel, and something popped into my head earlier.

What if I do some videos specifically about programming in Atari BASIC, with an aim to showcasing what an interesting, flexible language it is — particularly compared to some other micros' BASICs — and basing the videos on the numerous tutorials published in magazines like Page 6 and Atari User? (Crediting the original writers, obviously.)

My thinking behind it comes from several perspectives: one, there is a niche interest "market" in videos about programming for classic computers, as evidenced by the thoroughly lovely Yawning Angel Retro channel, who specialises in programming the Amiga with the AMOS language.

Two, I just think it would be an interesting twist on what I do on the channel.

Three, I will probably learn something from it — albeit something that may not necessarily be especially "useful" in the modern world.

Four, it's something to do with the magazines I've been acquiring besides just doing flipthroughs of them (which I also intend to keep doing on an occasional basis).

And five, it's something a bit different to do with the computer stuff. I'm not exactly bored of doing the games — there are still myriad titles I haven't covered on both Atari 8-bit and ST! — but I have reached a point where I want to do something a little different. This is part of the reason I've done so much console stuff on the channel recently — that and the MiSTer Multisystem 2 making it so easy to capture from all manner of different platforms — but I'm always conscious that the backbone of my channel was built on Atari home computer stuff.

I think I will try an experiment in the coming weeks and months. I will start with the absolute basics (no pun intended) for the sake of those who have never programmed in '70s/'80s computer BASIC, and gradually move on to the Atari specialisms: graphics, sound, manipulating the Display List, Player/Missile Graphics and all manner of other things. Some of these things I've never understood, so I feel like taking the time to make a video version of some of these tutorials may well allow me to improve and advance my own knowledge — something I've always kind of wanted to do, but never really made the time for.

In time, maybe I'll even be able to Snorkify some Atari BASIC games. But let's not get ahead of ourselves, shall we…?


Want to read my thoughts on various video games, visual novels and other popular culture things? Stop by MoeGamer.net, my site for all things fun where I am generally a lot more cheerful. And if you fancy watching some vids on classic games, drop by my YouTube channel.

If you want this nonsense in your inbox every day, please feel free to subscribe via email. Your email address won't be used for anything else.