c128 Archive

Commodore 128 Assembly Programming #19: Worm part 4

It’s customary when making videos about 1980’s technology to wear a funny or ironic retro t-shirt. I have only one of those, so instead, enjoy one of my collection of local farmer hats.

In this one we add code to keep the tail pointer-to-pointer (TAILP) updated, to handle collisions with digits on the screen, and to keep the worm at the proper length, growing it when it “eats” digits. All the worm functionality is finished now, so next time we’ll work on the end-game score display, and a better keyboard-entry routine.

Commodore 128 Assembly Programming #16: Worm part 3

Continuing with the Worm game. I thought I had worked out how to make the tail end of the worm go away, and then once I started to describe it I realized it wouldn’t be that simple. We have to keep track of each “body part” of the worm in order from front to back, so we always know which one is the next to drop off as the worm “moves.” That means we will have a list of pointers to those body parts, and pointers into that list.

Double pointers are challenging, so that will be a fun task I wasn’t expecting. I may do a whiteboard video to draw it out better than I explained it here. The pointer list will be in a 2K area of memory, wrapping around to the beginning if necessary, with two pointers into that list for the head and tail of the worm. Got the head pointer done in this video, and will add the tail pointer and the code to move the tail along in the next one.

6502 Assembly #15: Worm on the Commodore 128 Part 2

In this video we continue working on the Worm game started in #13, adding collision detection and the random placement of a digit on the screen for the player to guide the worm to. Next time, we’ll start by debugging why the digit is always 5 instead of randomly 1-8 and always appears in the third quadrant of the screen.

This series is undergoing a slight re-branding. When I started it, I was focused only on the 6502 microprocessor, which is found in many different computers and products from the 1980s (Commodore computers, Nintendo Entertainment System, Atari consoles, etc.) and is still in wide use today. But when it comes to writing programs that actually run on something, you have to program for a particular platform. While the 6502 itself doesn’t change, the methods of input/output, printing things on the display, memory management, and so on vary greatly from one 6502-based system to another.

In other words, if you write a 6502 routine to multiple two values in memory, you can use that unchanged on any 6502 system. If you want to print those values on the screen, send them to a printer, or save them to a disk file, then it matters what system you’re on.

So I will be (and have been) writing these programs for the Commodore 128, for three reasons. First, it’s the system I’m familiar with, having owned a few back in the day, and I always wanted to do more with it. Second, it’s the most powerful system that the VICE emulator does. Since I’m using an emulator anyway, I might as well use the emulated machine that has the most power and features. Third, there seem to be very few people out there programming for the C128. There’s a lot of activity around the C64, with new games and products popping up regularly, but very little for the C128. A new YouTube channel just appeared called Nybbles and Bytes, where she plans to convert a Javascript game she wrote to the C128, and her video and some comments on it made me realize this isn’t well-traveled territory.

Fourth (insert Monty Python bit), if I ever buy a real Commodore again, it will be a C128, and then my programs will run on it.

That means I’ll be expanding into some of the C128’s more unique features, like the 80-column screen and banked RAM. The programming will still all be 6502, but we will get deeper into the C128’s hardware and some cool stuff you can do with it.

Same Deal Every Time

I was telling someone the other day that every computer I’ve bought has cost about $700-800, even though they keep getting more powerful. You can spend a lot more than that, of course. But it seems like each time I put together a system with current proven hardware that’s plenty powerful for my needs, the price ends up in that range, going back to my first computer in 1988.

Then I got to wondering whether that’s really true. That’s a pretty old memory, so is it accurate, or something I dreamed up over the years because it sounded good? I went hunting online and found the Sears Catalog page from 1998 below, which matches up with what I remember. I bought a 128D and monitor from Sears just like the ones in the picture. According to that, the computer was $499 and the monitor was $299, but there’s the combo price in the lower right: $749.98. I don’t remember what accessories I bought, if any. I know I didn’t get a printer, but I probably got a joystick and some blank floppy discs.

That was a fun little nostalgia trip, since that was my computer until some point in the late 90s. Even after I got into the Internet business, I would connect to the Unix systems at work using a terminal on the 128 at home, so I used it for nearly ten years.

Aside from nostalgia, I’ve been thinking about that system because, since I got back into assembly programming a little, I was surprised to find out how much is still being done with the 6502 family of CPUs used by so many of the top 1980s systems. They’re apparently pretty popular in embedded systems and some of those hobby mini-computer boards, so I’d say there’s more interest in them now than there was 10-15 years ago.

That looks like another reason to do some assembly language tutorials or other videos like I mentioned in my recent C programming series. More to come on that soon.

Should Have Been a Hoarder

I get an automated eBay notification for Commodore C128s, because sometimes I think it’d be nice to have a real one again, and I’m curious about what people are doing with them. But the prices on them keep going up, and an emulator is a pretty good substitute, so I haven’t bought any yet. The picture below is an example of what they’re going for these days: two completely untested systems, which may not work at all, and have missing keys, have a bid of $116 (including shipping). Tested ones without anything missing can bring $300.

And 15 years or so ago, I gave three of them, plus some peripherals, away to a metal scrap guy. They weren’t worth anything then, but now they’re making a comeback as collector’s items. Oh well. Would be nice to still have them, but you can’t save everything just in case.