Classic Computer Magazine Archive Article from Atari Classics magazine

Got a problem? Some folks have a
lot of software utilities on disk and
some folks just roll their own....




BASIC
OFF!
by Joseph R. Chiko

    It began many years  ago in a different time, in a different place, and for a different reason. It began as a quest to make executing BASIC programs easier for my spouse. The program started out launching simple BASIC programs I had typed in on my then 1200XL.

    Over time, the expectations of the program became more grandiose. First, one page of documentation was to be displayed, then an unlimited number of pages. Soon, the program was capable of allowing the viewer to go backwards up to 100 pages of documentation.

    Then, the program was pressed upon to launch machine language programs. And, it eventually did this, too. But the magazines that printed the type-in software I loved died off all too soon. I grew tired of trying to write complex BASIC programs and too intimidated and discouraged to tackle machine language.

    At that point, I discovered CLSN Pascal and became a coding fool again. I spewed forth solitaire games and utility programs like a volcano does lava and ash. As I attempted my 20th version of solitaire, Spiderette, I discovered that CLSN Pascal did not disable BASIC.

    So the quest mutated again, and resumed. Donning my well-worn programmer's helmet (used to protect my cranium from the sudden stops it encounters with sold objects such as desk tops and doors and the like), I set out on the quest to unearth the secret of disabling BASIC from within software. It turns out to have been a prudent decision to wear my programmer's helmet for many a late night was spent thumping my head off of the desk in attempt to make what I had read sink into my all too thick skull.

    I scoured old issues of Analog and Antic looking for clues to the secret of turning off BASIC. I dog-eared pages and scribbled cryptic notes in the margins of Mapping the Atari, De Re Atari, and Atari's listing of the 800 OS. I now own a 130XE and, while on a local bulletin board, discovered a listing for the 130XE OS. I even asked for advice from other Atarians on the BBS only to be pointed in directions that I had already explored.

    All attempts at disabling BASIC had ended in failure. My goal was to append two programs together. The first would be BASICOFF, the name of the eventual program. It would disable BASIC when executed from either Atari DOS 2.5 or SpartaDOS 3.2d. The appended program would be the Pascal object file. By turning off BASIC the Pascal program could be 8K larger. That would be 8K of additional features. There could be high scores and counters for games won and played and maybe more. But everything I tried either locked up my system or required that RESET be pressed, which would simply return me to DOS.

    I was getting desperate and frustrated. The forehead of my helmet was wearing thin and I was in danger of damaging my skull and possibly my brain. I even considered abandoning the quest altogether. But at a club meeting, a friend mentioned that SpartaDOS 3.2d was weird. So, I began to test the fledgling program under DOS 2.5. The program would now turn off BASIC only if I pressed RESET after its execution, but it was not crashing. I returned to the books to see if I had overlooked anything. I went over the recommended list of procedures to disable BASIC that are as follows:

    1. Ensure that bit 2 at PORTB is set to a 1
    2. Ensure that BASICF is greater than 0
    3. Turn the screen off and on to recoup the 8K that BASIC had used

    I started to disassemble code only to discover, to my chagrin, that my ALDS disassembler went into a print loop after 10 pages. I was able to learn that some BASIC off programs forced RAMTOP to be 192, so I added this to my code. I also put in a snippet of code to change the color of the screen if the program were successful in disabling BASIC. And, to ease testing requirements, I had the program return to DOS instead of doing the second phase of the load.

    Late one night, with the sound of my helmet bouncing off the desk thudding dully throughout the house, I managed to read something between the chapters in Mapping the Atari. It mentioned that cartridge A had to be turned off in order for BASIC to be disabled. With this new code added to the program, BASICOFF worked. I had succeeded! I fired off a short Pascal program to test BASICOFF. The Pascal program simply entered a high resolution graphics mode and displayed the addresses of screen memory to ensure that they were what they were supposed to be.

    I was elated! BASICOFF was working. But, my elation was short-lived. The program would not work with SpartaDOS 3.2d so I started dumping SpartaDOS. I was able to deduce that the reason for my scrambled screen was that the program was in the RAM under the ROM chip when the screen display list was setup, resulting in a scrambled screen. SpartaDOS calls a common routine to set and reset PORTB, keeping a copy of the original contents of PORTB in an 8 byte array. I stared at the code for days, going cross-eyed in the process, trying to figure out which of the 8 copies was being used to reset PORTB. Just as I was losing consciousness in a last and perhaps futile attempt to jar an idea loose, I realized that I did not need to know which of the memory addresses to change. All that had to be done was simply to change all 8 values, so that no matter which value SparataDOS used to restore PORTB, it would indicate that BASIC was indeed off.

    I had finally and definitely succeeded in wrenching the secret of disabling BASIC from its hiding place. It took me months to figure this out and I now can see daylight though the small hole in the forehead of my programmer's helmet. Perhaps I will remember why I do not like machine language for a long time to come, but I can take solace in the fact that the assembler listing that follows this article may keep some fellow 8-bitter from damaging his brain or ego.

    To use this program, type in the code and use your favorite assembler to compile it. Let's assume the compiled object file is BASICOFF.OBJ. I would typically use the following SpartaDOS commands to combine two object programs together:

COPY BASICOFF.OBJ GAME.OBJ
COPY PASCAL.OBJ GAME.OBJ/A

    A similar operation can be done using Atari DOS 2.5. GAME.OBJ will now do a multi-phased load. In phase one, the code of BASICOFF is executed. If BASIC is already off, the screen will not change colors. If BASIC is disabled by BASICOFF, the screen colors will change. In phase 2, the code for GAME.OBJ is loaded with the additional 8k freed up by disabling BASIC available for its use. Now, my large Pascal programs can be launched by the BASIC utility responsible for this task without having to worry about how to handle the exception of programs that require that BASIC be turned off.

;% BASICOFF.ASM