Retro Game Coders

This is a pretty nifty website that covers a variety of retro-coding topics. Here I link to three recent posts.

#1: CP/M working in a browser

I’ve mentioned before my fondness for CP/M, the first widely-used microcomputer OS, the DOS-before-DOS. My attempts to try to emulate machines using it, however, have mostly gotten snagged on one thing or another. Well they have a post about getting in-browser CP/M working, with information on some of its commands. Here you can run it yourself,

People familiar with MS-DOS should be right at home, although some commands are different. (That’s because MS-DOS changed them; it was originally made as a CP/M clone.) One major difference is the absence, in this version, of disk directories. Instead there were up to 16 numbered “user areas,” each its own individual region on the disk, kept separate from the others. CP/M was an amazingly compact system, a single floppy disk could host a half-dozen compilers and have room to spare.

#2: Speeding Up PETSCII

Commodore BASIC was notoriously slow, but also feature-poor. A version of the same Microsoft BASIC that was co-written by Bill Gates himself, and was later ported to MS-DOS as QuickBasic. This page is a collection of different ways to speed up printing PETSCII characters, covering several optimization techniques, one of them, avoiding IF statements, being non-obvious.

#3 Online Retro IDE

The linked page is actually about a recent update for it that adds support for DOSBox and BBC BASIC. It supports loading your code directly into a Javascript emulator. It supports many other computers and consoles. The IDE itself is here. The update page claims that FreeDOS is available as a platform, and with it another runnable version of Rogue, but I couldn’t figure out how to get into it before posting.

Kaze Emanuar’s Adventures in Mario 64 Optimization: Calculating Sine

I’ve mentioned Kaze Emanuar’s efforts to make the best Mario 64 there can possibly be on its native hardware. He’s compiled it with optimization flags turned on, made its platforming engine much more efficient, and worked hard to minimize cache misses, which was a major source of slowdowns in the game’s code. Under his efforts, he’s gotten the engine running at 60fps (although not yet in a playable version of the original). While these optimizations are not the kind of thing that can keep being found indefinitely, he’s bound to run out of ways to tune up the code, currently he’s still finding new ways to speed it up.

I hope you’re ready for some F-U-N (approximation FUNctions)

He made a Youtube video detailing his most recent optimization find: getting the game’s trigonometric functions executing at their speediest. What is interesting is that the Mario 64 code already uses a couple of tricks to get sine and cosine results in a rapid manner: the game only uses 4096 discrete angles of movement direction, and contains a lookup table that covers each of those angles. But it turns out that this optimization is actually a mis-optimization, because the RAM bus hits incurred to read the values into the cache are actually more expensive than just figuring out the values in code on the N64’s hardware!

The video starts out decently comprehensible, but eventually descends into the process of figuring out sine and cosine on the fly, and the virtues of the various ways this can be done, so you can’t be faulted for bailing before the end, possibly at the moment the dreaded words “Taylor series” are mentioned. But it’s a fairly interesting watch until then!

Romhack Thursday: Super Mario 64 Reduced Lag

It’s not so much a hack as a recompilation, but it’s distributed in patch form so I’m accepting it. A person identified as “Nintendo 64 Wizard” took the source code created by decompiling Super Mario 64, and, simply, did something that Nintendo didn’t do: compile the game with -O2 optimization turned on. The result is a much more consistent frame rate.

From the romhacking.net article, a scene from the star with Bowser’s Sub in it, which is notorious for causing the game to lag.

If optimizing Super Mario 64 is an appealing concept to you, you might be interested in some of the videos made by Youtuber Kaze Emanuar, that goes into why the game has lag, and his own efforts into improving it.

Super Mario 64 Reduced Lag hack (romhacking.net)