There is a problem when listing this Atari BASIC program on the screen...

You have access to the listing of a commercially released program written in Atari BASIC.

However, there's a problem. This program looks strange when listed: the variable names having funny, unusual names.

What kind of variables are these?

What kind of variables are these?

The reason is simple: the program has been protected using an obfuscation method.

What is this obfuscation protection?

This technique was used to prevent modification or understanding of an Atari BASIC program by deliberately making the code difficult to read or modify. This method was often used by developers to protect commercial software from being easily altered or pirated.

For example, one of these obfuscation methods or a combination of both was often used:

All these methods prevent you from modifying an Atari BASIC program protected in this way: Any program line containing only a single variable will be impossible for you to modify.

The example listed above is a commercial Atari BASIC program, APX 10001 PERITEL "Limonade", French version.
Pay close attention to the obfuscated variable names.
Line 230, among others.

Atari BASIC obfuscated program

Atari BASIC obfuscated program

How to fix this?

Fortunately, there is a fairly simple method to automatically rename all the variables with simple names compatible with the Atari BASIC editor, allowing you to modify the program again.

Software needed

My very favourite emulator. Simply the best: Altirra Atari 8-Bit Emulator

Step 1 — Move file to your main Windows computer

Transfer the program — let's call it BADPRG.BAS for now — to your Windows computer running the Altirra emulator.

You have plenty of options: FujiNet, SIDE3, or any "SIO-to-Something" device.

Create a virtual .ATR disk, format it in DOS 2.5, make it bootable, and copy your obfuscated Atari BASIC program onto this virtual .ATR disk. Then, transfer the .ATR file to your computer running the Altirra emulator.

Step 2 — Load the program into memory

Start Altirra with "Atari BASIC enabled" and boot on your bootable .ATR disk — the one created during Step 1 with BADPRG.BAS on it.

In Atari BASIC, type:

NEW
LOAD "D1:BADPRG.BAS"

 

Do not run the program.

Step 3 — In the debbuger

Launch the Altirra debugger by pressing the [F8] key

Type this command:

.basic_rebuildvnt

of course, press [RETURN] to execute the command.

 

In the Altirra debugger

In the Altirra debugger

Step 4 — Save the "clean" program

Exit the debugger by de-selecting the "Debug > Enable Debugger" option in Altirra.

Save the Atari BASIC program with a new name, for example:

SAVE "D1:GOODPRG.BAS"

 

There you go! All variables are now renamed with names compatible with the Atari BASIC editor. You can now edit and modify the program as you wish.
Check like 230 again.

Atari BASIC UN-obfuscated program

Atari BASIC UN-obfuscated program

A word of warning: this will rename all variables currently in RAM memory. If the program was designed to auto-edit itself, or if it loads other segments with ENTER commands for instance, this will not rename the new variables used in these new program lines.

Bonus 1 — Give the variables new friendly names

Use the "APX 20177 Extended Atari BASIC" program to rename the variables with friendlier names, easy-to-understand-their-usage names.

The "APX 20177 Extended Atari BASIC" program allows you to easily rename the variables in your Atari BASIC program. It directly modifies the variable names in the table that stores all variable names (VNT – Variable Names Table). In practice, this renames your variables immediately and EVERYWHERE in the listing.

Obviously, save your program again afterwards.

Bonus 2 — Get help and inspiration for the new variables names

Submit the listing obtained in Step 4 to an AI engine and ask it to suggest clear and meaningful variable names.

For example, using a prompt like this:

"You are an expert in Atari BASIC programming, the BASIC language of Atari 8-bit computers such as the Atari 400/800/600XL/800XL/65XE/130XE.
Here is the listing of a program written in Atari BASIC.
I would like you to carefully examine all variables used throughout the program and determine their function.
After this analysis, I would like you to suggest new, explicit, and meaningful names for each variable in the program. Each new variable name you propose must follow the standard constraints of a valid Atari BASIC variable name: the name must start with a letter (A-Z).
Ensure that each new name is unique – Atari BASIC does not allow two variables to have the same name.
If a variable is used only once, please highlight this to me.

<your listing goes here>"

Knowledge base article: kb-software-0007-atari-basic-remove-obfuscation-protection
REV. 002.

Back to the Knowledge base index Knowledge base