AddRoom Code Breakdown for AOL

In a previous post, I teased that I would explain exactly what is happening in what I believe was the most copied function of the AOL Proggie era. Adding the list of people in a chatroom to a list in your program. This is that post. Fire up your BASIC editor and open up your Win32 API manual and follow along.

Let us start with the include from the Win32 API. Visual Basic (VB) is somewhat of an interpreted language, but it has the ability to include function calls to Dynamically Linked Libraries (DLLs) written in C or another system language.

Key Win32 APIs that are imported and used in dos32.bas from various .DLLs

VB “compiles” to P-CODE and then is interpreted by the runtime or virtual machine of sorts. Similar to Java’s JVM and its bytecode. In VB5 there was a native compiler for x86 machine code, but before VB5, and maybe after, you could “decompile” the P-CODE and get actual source of any program. People got upset at this and there was an entire obfuscation scene dedicated to preventing decompiling of VB programs…

Image result for fate x aol
A good programming team

Interacting with AOL by reading dialogs, clicking buttons and other automations was fairly straight forward. The general flow would be: identify the window, studying its hierarchy, find the control, and send it messages.

To do this, even today in 2021, I like to use Patorjk’s Tool for Window Spying, but you could always use spy++.exe included in the tools from Microsoft. Automation of this style is similar to scraping websites now. You are reverse engineering and poking into stuff you normally shouldn’t. With most scriptable apps you have an official API. For progs, you needed to invent your own API or SDK… by essentially inspecting the window “DOM”..

Image result for spy++

Most controls could be read and written too. But there was one control that alluded us. The list of people in the chat room was some type of special control. There was some formatting that would happen and other things that prevented a standard LB_GETTEXT from working.

Image result for aol chat room
TOXIC GAMER BROS – AOL 4.0? Running on Windows 98?

In the earlier Sk8er.bas there was a call to a “311.dll” which took care of the AOL16 bit. But when 3.0 came out, which was 32bit we had to reinvent the wheel. Not sure who wrote the 311.dll, maybe we could decompile it. It probably was reverse engineered… But I know it held something that is similar to the code in question. Food for thought: Why was it in a .dll?

Don’t make globals, always use Option Explicit 🙂

Ok onto the 32 bit version of this code. There are 2 main variants, but they all do the same thing. Tap into the process, read some memory and do some magic.

dos32.bas’s AddRoom Implementation

This dos32.bas was claimed to be completely written from scratch, it was… except for the above bit. Still searching for the original author. There is actually another variant that I saw in alpha32.bas, it is shorter and simpler, but I will focus on the tear down of dos’s copy pasta.

Code Review

1122-1132

  • Turn off error handling with On Error Resume Next (think of it as a blind try/catch on all exceptions and keep on trucking… not great, but hey)
  • Find Chat Room Window, Get Thread and follow to Process ID (seems roundabout way, was there multiple threads in Aol32.exe?)
  • You can see there are old-school postfix variable identifiers, I think this kept code smaller w/ Option Explicit.
  • VB4 straddled both 16bit and 32bit so I am guessing that is why the integers are defined as “long” here at 32 bit. Long to me is 64bit, but 1995…
Some Copy Pasta’d Knowledge. Thanks David!

1133-1137

  • Biggest mistake I think in this entire snippet, Iterating over a list of items while the list can change.
  • It cannot be atomic I guess, we cannot lock it, but it seems very strange to call LB_GETCOUNT every loop iteration.
  • Send message and get the LB_GETITEMDATA, then pad by 24… No idea perhaps that was formatting data? This listbox had embolden and italic modes for enter/leaving.
  • ReadMemory from ScreenName string which is only 4 characters, must be an address/pointer
  • psnHold now holds the value stored at the address stored in ScreenName
Source is Pointer to Address in ScreenName String of 4 Chars so 32bit Addy

1138-1142

  • psnHold now holds an address. Pad Address by 6… again no idea why.
  • Resize ScreenName to 16 characters (largest screen name possible on AOL)
  • Read Memory into ScreenName
  • Last Step: Trim to null character, remember we use c-strings in VB!

Epilog

Wow, we got through it. Still a lot of unanswered questions, but I think we solved most of the important bits. When I originally read this code in the 90s, it blew my mind. I just chalked it up to magic and copy and pasta’d it. It always stuck in the back of my mind though, and after I learned about memory and pointers in college it seemed to make more sense.

I promised myself I would eventually write this post to shed some light on one of the most important years of my life. What lessons are learned while you are having fun and sharing your code with friends. Thank you for reading and remember… If you don’t understand it, you don’t always need to! Copy Pasta!

The War Room

It keeps going…

Cosmic Rays – Extragalactic Objects

Determinism is an important part of computing.

2 + 2 = 4

Knowing that the computation of the above never changes gives the programmer the ability to reason about there machine in a scientific way. Two plus two is always equal to four!

Or is it?

With our molten iron core spinning within the earth, it creates a giant electromagnetic (EM) field that shields the planet. Very high up there, there is a cloud of stuff that is rejected and deflected from entering our atmosphere and ultimately us and our devices.

Mostly sunburn is the only problem coming from the heavens toward us, but there are other things to “look” for as well. Cosmic Rays are really charged particles believed to come from the stars exploding…

 In 1929, Bothe and Kolhörster discovered charged cosmic-ray particles that could penetrate 4.1 cm of gold.

Wikipedia 2020 🙂

So what happens when one of these particles hits a semi-conductor like your RAM, CPU, SWITCH?

Bad stuff. It could flip a bit.

2 + 2 = 5

This could be a problem. Flip the right bit, you have a blue screen of death. Not a big deal to an entertainment device or non-mission critical systems. Very big deal for a self-driving car, or a power plant control and monitoring system.

Shielding can help, but shielding is expensive. I wonder how well those NeXT cubes with the magnesium cases do for shielding.

Lockstep Computing…

Copy Pasta Style

Typing in codes character by character, while reading it off of a glossy magazine page, was how most of the “learning” to program was done in the 1980s and 90s. Taking code you don’t understand and trying to type it in exactly and watching it work first time was a treat!

Most of time this old method of coding is same method as you should be doing now in 2021 when you type create-react-app, but ya know… deadlines.

I still like to type character by character and not copy pasta. But sometimes you just gotta git r done. It takes a considerable amount of time to become a competent programmer on any particular platform.

A world without Stack Overflow is hard to imagine, but it was what it was. I remember saving up 70 bucks for a C Compiler. Software used to cost money… I begged people to teach me C++. I bought a book that claimed to teach me C++ in 24 Hours!

Anyways, copy pasta style is all about getting something working, so you can study it. Hold it in your hand, mutate the characters and see the results. This person seemed to have done it before at X date. I will try and see if I can replicate results right now.

Is this science?

Perfectly normal. Don’t feel bad. Use libraries, import dependencies you don’t understand. Feel the pain, and then learn what it is these black boxes or preferably opaque boxes provide you. Iterate on the depth you are willing to go down the rabbit hole of “devops”. There is a benefit to writing everything from scratch and doing it all yourself, but most of the time the risk outweighs the benefit. It is a great way to learn, to “reinvent the wheel” but my advise is make your App, not a Library.

So that isn’t to say you shouldn’t be refactoring your App to extract useful features to into a library. But they should exist in the “client” first. And then later be extracted and generalized if seems needed.

The idea when building libraries is to write client code first against some pretend API that you wish existed and then to implement that API.

Chris Sells

Mr. Sells advise is true for UI design as much as it is for API design which is a kind of “UI”. I always like to do a “puppet show” version of anything and work out all the kinks and discover the problem before we ever write any “real code”. It works well with a group of 3-4 people who are stakeholders in the feature/flow.

Ok, back to the history lesson of copy pasta in the 90s and many peoples origin stories in tech… Visual Studio was not really a thing yet, compilers cost money, Windows 95 just came out. Visual Basic 3 (VB3) was the “python of the 90s”, I would say or the “PHP of the 2000s” 🙂

BASIC was my first language, and the idea of making “real GUI apps” was appealing with Visual Basic’s drag and drop editor and easily hooking up to the Windows C APIs if you needed it. The only other thing that ever came close to this for traditional “native” developers was the MFC… in Visual C++ 4.0 had a Drag and Drop editor that really tried to capitalize on this “Rapid Application Development” (RAD) was the acronym of the times.

People often ask what language should you learn? I always say pick what other people are using to make the kind of product you want. If you wanted to make an AOL “addon” as I liked to call them, you would choose Visual Basic.

I think the last version of America Online (AOL) that you could program with VB3 was AOL 2.5. AOL2 .5 was a very, very important part of the “zerver” scene. It was the only version of AOL until like 6.0 you could run reliably for days/hours while automating. Using VB3 and AOL2.5 you could write long running programs that would not leak, and “run forever”.

The way to interact and make “proggies” was shared with others. Through “.bas” (base) I remember using Macro Recorder to do some “scrolling” of ascii art until I discovered there was a whole community and huge codebases to reference.

http://lenshellprogarchive.com/vb.html

The first library that I had access to was the terribly named genozide.bas, which copied sk8r.bas and a few others. Most of the libraries that followed would just copy pasta and put their branding on it. Shout out to Insane Clown Posse for the juggalo32.bas 🤡

I would say most people did this. You combine multiple bas’s into a single file and just keep dumping more functions and constants in it. It was the way. Many, many libraries were copied verbatim from others and with no real functional changes, they were essentially plagiarized. Others took pride in a “no copying” ideology. I was one of them, because I was writing my apps in MFC C++ (like a fool), I studied these libraries to port into C++ so I could use them.

The best library I could find to port was DOS32.BAS. Line 4 is my jam. You should never write VB without this statement. It is similar to the “use strict” in javascript which I am also a big, big, fan. Don’t do the compiler’s job!

DOS32.bas was released and met critical acclaim. It was claimed no copying was done to make DOS32.bas and it is excellently documented. But there was one little bit of code that had to be copied always. This was true even in the old days of sk8r.bas with the 311.dll. AddRoomToList is the function that was beyond all of us in the prog scene. Not sure who wrote it, but here is the most copied function of all time in proggie scene:

Stay tuned for Part II, when I finally break down and try to understand why this piece of code was copied and what it really does. Hope you enjoyed the trip down memory lane.

-cryptide

Further Reading

Frog Jumper – A JS13K Retrospective

I participated in the Javascript 13 Kilobyte game challenge this year along with 227 other game programmers. It is a month long contest that has been done since 2012. 2020 is the first year I’ve even heard about it, and I think it is an excellent contest. Check it out, and consider participating next year: https://js13kgames.com

So why is this contest special? It celebrates “open web technologies” and adds the artificial size constraint to your final package size. This guides the programmer to seriously embrace the fundamentals of computer software engineering. You have no real chance to import a giant library of code, you must tap into the browser, and really focus on being creative with the constraints of code, assets, and browser quirks.

30 Days is not a lot of time if you are just getting started into web programming. But it is enough to make a basic “demo” of a game and submit, and get a t-shirt. I suggest brushing up before the contest begins on some basic html, css, javascript. Luckily I did a TypeScript project early in the year and am somewhat familiar with the web.

Here is the journey of Frog Jumper…

First Week

Read the recommended tips and tricks, and get the lay-of-the-land.

Do some calculations.

Choose some art from opengameart.org

See if I can get some pixel art that looks good and practice scaling it with css to make look nostalgic for me. I want to make an 80s arcade style game.

Learn about scaling modes for all three browsers… (sad)

Think to myself, I have plenty of time.

Second Week

Find a TypeScript project on GitHub to fork

Link up Kontra.js a micro game framework by Stephen Lambert.

Make some animations and think I’m really doing good.

Very little work done, mostly readying Kontra.js docs and checking into sound libraries.

Third Week

Kontra.js linked up and tested the packaging to see if i’m under size with basic animation screen.

Zipped it is 11kb so I’m ok. Then, I add the chicken.

I have no room for game!?

Only thing in it so far is WASD movement and 2 sprites.

Asking for help on twitter I switch to Parcel.js and enable some “tree-shaking” which removes dead code not used from library.

Keep shrinking and trying everything eventually i get down to 10kb!

Time to actually make game.

Fourth Week

Crunch time.

Add some sounds with Frank Forces Zynth library.

Can’t sleep, keep trying to figure out what to do for game play.

Decide to start adding emojis for inspiration.

Then make them scroll…. ok.

Lets Jump.

Ok now I understand what my games is… it is just a side scroller with a jump.

I refactor for the ability to do levels.

It is 3 days left to turn in game.

I’ll leave the rest to the GitHub commits: https://github.com/robmurrer/frogjumper/commits/master

Play the “final” version here: https://games.cryptide.com/js13k/frogjumper/

Works on Mobile and Desktop.

Double tap to jump higher when frog is under you.

Will add more levels and fix bugs soon.

Will add more technical details fo the challenge later 🙂

Thanks to https://enclavegames.com for hosting even for the 8th year. Look forward to next year.

Also thank you to all of you that helped me actually ship game. Lots of play testers from my family and work. And cheers to my wife Jessica for putting up with me and my silly chicken games ❤

Make Yourself

Owning your whole tool chain is important part of becoming a seasoned developer of quality software.

Building the software is the first step. We all love to use Integrated Development Environments (IDE) but what happens if you lose license to that suite of tools?

Your developer ergonomics are important and it is why we use those heavy weight tools like Visual Studio, the best IDE ever invented.

How would you even start rolling your own development toolchain with “free as in beer” tools?

Little Black Books

When you are cook aspiring to become a chef, you are expected to write down notes.

These are your notes, they go home with you.

When you quit or get fired. You keep the book.

In tech, it is not like that 😦

We have one way to exfiltrate some of the sauce. “Open Source”

The post that inspired this post: https://web.archive.org/web/20091121122743/http://www.onehungrychef.com/2009/11/on-hand-me-downs.html#more

I miss that blog.

I ❤ @internetarchive

The Speed of Thought

There are two types of software.

Those that you choose to use, and those that your boss chooses for you.

hmm

The “only way to do it” is sometimes painful. But if there are dollars to be made between those button clicks and some frustration, I will happily click them. Hopefully in the right order.

If I have a choice though, I will choose the program that keeps me in the “zone” for as long as possible. Every second I feel like I am waiting on the machine; is one more second I’m likely to change tasks or get distracted from what I’m actually in your program for.

There is some number… of millisecond lag tolerance. This is the most important metric and a balancing act with the value you are creating. How much of the program’s feature plays in your cash generating mechanisms? How long am I willing to wait? Remember I’m not just a user of a novel feature in your app. It is part of an entire flow that you will never see.

In the craft of turning dirt to dollars, I focus mostly on Electronic Design Automation (EDA). The vast amount of tooling surrounding modern Semi-Conductors and PCBs are staggering (and expensive). Unifying these tools for the usage of mere mortals has been my task for the past 5 years.

To me the task of the next 10 years is to optimize this flow to take seconds or minutes… Rather than years. Who will be a blackbox and who will be sherlocked?

The Mind Compiler

Reading code is the most important activity of a computer programmer. Ideally the code is then interpreted and ran as a thought experiment inside the programmer’s brain. This sounds hard, but as you learn an environment, the mind will eventually reach this level of tooling.

The ability to reason about code without running it, is the key to failing fast and often. Which you always want to do. Failing slow is painful. Just as Intellisense is a huge help for catching syntax errors early, not having to actually build & run your program, you can iterate much quicker.

Of course what happens if your internal transpiling mechanism and logic simulation units fail as you bite off more than your meat computer can handle?

Just press F5.

I recommend picking your favorite open source project and start reading. If you get stuck, just start dropping some breakpoints and calibrating your internal toolkit.

Big Idea Fridays

There are few speeches that cause me to read them multiple times. Dr. Hamming’s “You and Your Research” resonates deeply with me and is one of my favorites. Hamming, defines a work ethic and sprinkles the talk with antedotes that are both kind and relatable.

However you define great things

Dick Hamming

He gave this speech many times and prefer this written version: https://www.cs.virginia.edu/~robins/YouAndYourResearch.html

I like the idea of reserving Friday’s for thinking about deep problems.

Have a good weekend.