Classic Computer Magazine Archive COMPUTE! ISSUE 8 / JANUARY 1981 / PAGE 120

The 32K Bug

Earl H. Wuchter

There is something about the 32K PET that makes it different from any other size PET, and if you are not aware of this difference, the graphic program you have developed and debugged on a smaller machine may not run correctly in the big one.

The difference is subtle, but quite important. With 32K of RAM, the upper end of memory available to BASIC (where it stores string variables) is immediately followed by the lower end of the screen RAM (top of the screen). Any lesser amount of RAM provides a dead area adjacent to the screen.

If your program is to run correctly in 32K you must pay strict attention to the screen boundary and not allow any characters to spill over into the strings.

Consider, for example, a program that is going to create an explosion effect with characters radiating upward from a computed position (variable M). Characters are to be poked to locations M-40, M-39, M-41, M-80, M-78, M-82, etc. You would certainly make tests to ensure that location M is on the screen, but you might not want to slow the graphic effect by testing all of the other locations. When location M is near the top of the screen, some of the characters will go out of bounds, and will not be displayed. In the 32K PET, they may show up later as part of other strings.

If this condition is troubling an existing program, cure it by lowering the top of available memory. Begin the program with IF PEEK(53) = 128 THEN POKE 53, 127 : CLR