Well Documented Code Helps Revive Decades-Old Commodore Project

In the 1980s, [Mike] was working on his own RPG for the Commodore 64, inspired by dungeon crawlers of the era like Ultima IV and Telengard, both some of his favorites. The mechanics and gameplay were fairly revolutionary for the time, and [Mike] wanted to develop some of these ideas, especially the idea of line-of-sight, even further with his own game. But an illness, a stint in the military, and the rest of life since the 80s got in the way of finishing this project. This always nagged at him, so he finally dug out his decades-old project, dusted out his old Commodore and other antique equipment, and is hoping to finish it by 2024.

Luckily [Mike’s] younger self went to some extremes documenting the project, starting with a map he created which was inspired by Dungeons and Dragons. There are printed notes from a Commodore 64 printer, including all of the assembly instructions, augmented with his handwritten notes to explain how everything worked. He also has handwritten notes, including character set plans, disk sector use plans, menus, player commands, character stats, and equipment, all saved on paper. The early code was written using a machine language monitor since [Mike] didn’t know about the existence of assemblers at the time. Eventually, he discovered them and attempted to rebuild the code on a Commodore 128 and then an Amiga, but never got everything working together. There is some working code still on a floppy disk, but a lot of it doesn’t work together either.

While not quite finished yet, [Mike] has a well-thought-out plan for completing the build, involving aggregating all of the commented source code and doing quarterly sprints from here on out to attempt to get the project finished. We’re all excited to see how this project fares in the future. Beyond the huge scope of this pet project, we’d also suggest that this is an excellent example of thoroughly commenting one’s code to avoid having to solve mysteries or reinvent wheels when revisiting projects months (or decades) later. After all, self-documenting code doesn’t exist.

Continue reading “Well Documented Code Helps Revive Decades-Old Commodore Project”

Modernizing C Arrays For Greater Memory Safety

Lately, there has been a push for people to stop using programming languages that don’t promote memory safety. But as we still haven’t seen the death of some languages that were born in the early 1960s, we don’t think there will be much success in replacing the tremendous amount of software that uses said “unsafe” languages.

That doesn’t mean it’s a hopeless cause, though. [Kees Cook] recently posted how modern C99 compilers offer features to help create safer arrays, and he outlines how you can take advantage of these features. Turns out, it is generally easy to do, and if you get errors, they probably point out unexpected behavior in your original code, so that’s a plus.

We don’t think there’s anything wrong with C and C++ if you use them as you should. Electrical outlets are useful until you stick a fork in one. So don’t stick a fork in one. We really liked the recent headline we saw from [Sarah Butcher]: “If you can’t write safe C++ code, it’s because you can’t write C++.” [Cook’s] post makes a similar argument.  C has advanced quite a bit and the fact that 30-year-old code doesn’t use these new features isn’t a good excuse to give up on C.

Continue reading “Modernizing C Arrays For Greater Memory Safety”

Pocket Radio Powered By Tiny Microcontroller

Before the days of MP3 players and smartphones, and even before portable CD players, those of us of a certain age remember that our cassette players were about the only way to take music on-the-go. If we were lucky, they also had a built-in radio for when the single tape exhausted both of its sides. Compared to then, it’s much easier to build a portable radio even though cassettes are largely forgotten, as [wagiminator] shows us with this radio design based on an ATtiny.

The build is about as compact as possible, with the aforementioned ATtiny 402/412 as its core, it also makes use of an integrated circuit FM tuner,  an integrated audio amplifier with its own single speaker, and a small OLED display. The unit also boasts its own lithium-polymer battery charger and its user interface consists of only three buttons, plenty for browsing radio stations and controlling volume.

The entire build fits easily in the palm of a hand and is quite capable for a mobile radio, plus all of the schematics and code is available on the project page. While it doesn’t include AM capability, just the fact that FM is this accessible nowadays when a few decades ago it was cutting-edge technology is quite remarkable. If you’re looking for an even smaller FM receiver without some of the bells and whistles of this one, take a look at this project too.

A Programming Language To Express Programming Frustration

Programming can be a frustrating endeavor. Certainly we’ve all had moments, such as forgetting punctuation in C or messing up whitespace in Python. Even worse, an altogether familiar experience is making a single change to a program that should have resulted in a small improvement but instead breaks the program. Now, though, there’s a programming language that can put these frustrations directly into the code itself into a cathartic, frustration-relieving syntax. The language is called AHHH and it’s quite a scream.

While it may not look like it on the surface, the language is Turing complete and can be used just like any other programming language. The only difference is that there are only 16 commands in this language which are all variants of strings of four capital- or lower-case-H characters. The character “A” in the command “AHHH” starts the program, and from there virtually anything can be coded as a long, seemingly unending scream. The programming language is loosely related to COW which uses various “moos” to create programs instead of screams, and of course is also distantly related to brainfuck which was an esoteric programming language created in order to have the smallest possible compiler.

We can’t really recommend that beginner programmers start to learn this language instead of something more practical like Python, esoteric languages like these can teach us a lot about the way that computers work. This language, for example, lets you code in pixels instead of characters. Others are more for fun such as this language which turns your code into an ’80s rock ballad.

Thanks to [Kyle F] for the tip!

Honey, I Shrunk The Arduino Core

High-level programming languages do a great job of making a programmer’s job easier, but these languages often leave a lot of efficiency on the table as a compromise. While a common thought is to move into a lower-level language like assembly to improve on a program’s speed or memory use, there’s often a lot that can be done at the high level before resorting to such extremes. This, of course, is true of the Arduino platform as well, as [NerdRalph] demonstrates by shrinking the size of the Arduino core itself.

[NerdRalph] had noticed that the “blink” example program actually includes over 1 kB of extraneous code, and that more complicated programs include even more cruft. To combat this issue, he created ArduinoShrink, which seeks to make included libraries more modular and self-contained. It modifies some of the default registers and counters to use less memory and improve speed, and is also designed to improve interrupt latency as well by changing when the Arduino would otherwise disable interrupts.

While there are some limits to ArduinoShrink, such as needing to know specifics about the pins at compile time, for anyone writing programs for Arduinos that are memory-intensive or need improvements in timing, this could be a powerful new tool. If you’d prefer to go in the opposite direction to avoid ever having to learn C or assembly, though, you can always stick with running Python on your embedded devices.

Coding A Dynamic Menu For Character LCDs On Arduino

These days, there’s a huge variety of screens on the market for use with microcontrollers. OLEDs and graphic LCDs abound, while e-ink devices tempt the user with their clean look and low energy consumption. However, for many purposes, the humble HD44780 character LCD does the job just fine. If you’re using such a device, you might want to implement a simple menu system, and in that case, [MyHomeThings] has you covered.

The menu code is simple to modify and implement. It allows the user to define a certain number of menu items, along with button labels and functions to be executed with button presses. By default, it’s set up to work with  left and right function buttons, with up and down buttons to toggle through the menu’s various entries. This suits the commonly available Arduino shields which combine a 16×2 character LCD with a set of four tactile buttons in a cross formation. However, modifying the code to use an alternate button scheme would be simple for those eager to tweak things to their liking.

For the absolute beginner to programming, it’s a great way to put together a simple interface for your microcontroller projects. It’s the sort of thing you might use if you’d built a do-everything Arduino handheld device, as we’ve seen built before. If you find text menus too archaic for your purposes, though, be sure to sound off with your favourite solutions in the comments.

DIY 8-Bit Computer Knows All The Tricks

Some projects are a rite of passage within their respected fields. For computer science, building one’s own computer from scratch is certainly among those projects. Of course, we’re not talking about buying components online and snapping together a modern x86 machine. We mean building something closer to a fully-programmable 8-bit computer from the ground up, like this one from [Federico] based on 74LS logic chips.

The computer was designed and built from scratch which is impressive enough, but [Federico] completed this project in about a month as well. It can be programmed manually through DIP switches or via a USB connection to another computer, and also includes an adjustable clock which can perform steps anywhere from 1 Hz to 32 kHz. Complete with a 1024 byte memory, a capable ALU, four seven-segment LEDs and (in the second version of the computer) a 2×16 LCD disply, this 8-bit computer has it all.

Not only is this a capable machine designed by someone who clearly knows his way around a logic chip, but [Federico] has also made the code and schematics available on his GitHub page. It’s worth a read even without building your own, but if you want to go that route without printing an enormous PCB you can always follow the breadboard route.

Thanks to [killergeek] for the tip!

Continue reading “DIY 8-Bit Computer Knows All The Tricks”