Now that the Worm program is finished, I’m starting two new projects to work on in parallel. The other one will be a game, once I work out some details. This one should be easier. It’s a 6502 implementation of a SHA-256 hash calculator. I thought it’d be interesting to see how well an 8-bit system could handle calculations that were designed for 32-bit (or more) processors, and how difficult it would be to implement.
Memory management (banking) in the C128 is unlike the C64 or other 8-bit Commodores, since it uses the MMU to switch blocks of ROM and RAM in and out of service. This can seem kind of complicated at first, but it’s essential to taking full advantage of the resources that the C128 provides, so I thought I’d do a whiteboard tutorial on how banking works and how to do it in assembly.
The Worm game is finished! It works pretty much how the BSD version does, which was the goal. It could be prettied up further than that with multiple colors and sounds or other new features, so if anyone wants to fork the source from the repository and do that, or use it in any other way, feel free. I’m ready to move on to something else, probably a more complex game with bitmap graphics, sprites, and sound.
[Setting: A Hollywood conference room.] Suit #1: “Gentlemen, we have a problem. Our new movie is setting up to be a disaster. Test audiences hate it. They’re saying it makes no sense and that the lead actress has two modes, boring and bitchface. The editors say there isn’t enough good there to salvage. We’ve been promoting it hard, and now word is leaking out that it’s bad. How can we save our asses?
So I learned Python the other day. Actually, that’s a joke. You can’t learn a programming language in a day. But if you already know several others, you can learn the basics: the syntax, looping constructs, how variables work, things like that. Enough to write simple scripts while checking the documentation for specifics on particular functions. Python has become ubiquitous enough that I figured I need to be familiar with it, if not expert, so I plowed through a tutorial.
In this session, we change the color scheme and show how to fill color RAM to set the foreground color for text characters. We add a delay between moves and change the keyboard routine so a key can be held down without repeating too fast, and also to put a time limit on moves. Next time we’ll be adding a final score display and a “play again” question, as well as a graceful exit back to BASIC.
There may be some stack pointer manipulation coming up in the next Worm video, so I thought I’d do a mid-week video explaining the 6502 stack in detail. This one goes over how to use it and demonstrates what happens under the hood, instruction by instruction, then how to manipulate the pointer manually if you need to. It also touches on the pitfalls in using the stack and what to watch out for.
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.
After today, I’m about ready for an old-man rant about the evils of modern technology. Instead I’ll write up the problem and solution I had today in case others come looking for it. I happened to brush against my computer today and the static caused it to freeze up. Okay, that’s annoying, but not the end of the world. Reboot and start things back up. But monitor #2 came back up in a weird resolution.
I covered these addressing modes in video #14 on the addressing modes in general, but I’ve had a couple of questions about the indirect modes specifically. I thought it might help to draw out examples on the whiteboard, since they are more complicated than the other modes. Hopefully watching this along with the examples in #14 will make it clearer. Indirect addressing, especially the Y-indirect (indirect indexed), is a powerful mode that lets you setup pointers into memory that can be adjusted on the fly, as we do with HEADP and TAILP in the worm program.