Close

Characters and "Typing" in "MacWrite"

A project log for Macintosh SAO

It's the 40th anniversary of the original Macintosh. Why not recapture the magic in an SAO?

aaronAaron 09/29/2024 at 03:060 Comments

I've ordered the final boards for the Mac SAO and (provided I haven't made any catastrophic mistakes) I'm waiting for them to be manufactured and shipped. In the mean time, I'm tackling more firmware, and todays exploits were "typing out" characters in "MacWrite"

The display on the MacSAO is only 64x48 pixels. The character font that is included with the CH32V003fun library are 8x8 pixels. Putting nothing but these on the screen will get you 8 characters per line, and only 6 rows top-to-bottom (with no spacing). 

I started poking around for a font that would be sufficient. There are a few 4x3 fonts out there, but I didn't want to worry about licensing, and I did want to be able to distribute the source eventually. I found a great font in Romeo Van Snick's Creep, which is a 4px wide font.

I couldn't find any way to simply extract the bits from the font file, so I ended up reconstructing them in Emutyworks' Bitmap editor. While I was doing this, I ended up altering some of the characters more to my liking.

As you can see from the bitmap, I tried a few different approaches. There is a world out there where I managed to get the combo Capital/Lowercase-in-a-single-byte to work, but in the name of getting things done, I just put each character in its own byte. If I start running into flash issues, I may try to solve this. As an aside, working on a project at this resolution and this size really emphasizes how much you can rely on the human brain to fill in the gaps of an experience. Some of these characters are only recognizable because you know what their much bigger, much better-defined representations are. The lower-case "m" and "w" are particularly suspect.

One of the frustrating problems I had was getting the characters to display in the way I wanted them to. There is the way that you store the data, and the way that you read the data. I was frequently getting mirrored characters, or characters rotated 90 degrees. The right way to handle this would be to have a good understanding of how the bitmap interpreter moves through the data and build according to that. Instead, I just leaned heavily into Jasper Van Loenen's image2cpp and trial-and-error'd my way to success. 

With the characters taken care of, I started working on displaying the characters. I wrote an ASCII map to transform character codes into actual characters on the screen, and a method of animating them.

I probably need to figure out a scrolling feature, but maybe I'll leave that up to individual users. 

Glancing at my the statistics on the build, I am creeping up on the limits of the CH32V003. I have just 4k of flash left, and 196 bytes of ram to work with. I'm sure there are opportunities for creative efficiencies.

I'm pleased with the result. I can fit 3 lines of text in the MacWrite window. There are 10 characters of space per line with a single pixel between characters. Some characters being narrower than others, you might be able to fit 11 or 12.

At any rate, I'm having fun and I'm very pleased with how it's looking.

Discussions