Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
May, 1982, Issue 24 COMPUTEI 135<br />
May. 1982, Issue 24 COMPUTE! 135<br />
Did you ev,,' t)'pe NEW and "egret it? In theory, your<br />
Did you ever type NEW and regret it? In theory, your<br />
program in -memmy memory is i.s wil)ed wiped out by Iry the wm'd word NEW. On<br />
the Atari, mem01) memory is, i.s, in, [acl" fact, washed clea.n dean with zeros,<br />
zeros.<br />
But the Apple AI)I)le a.nd and PETICBM com/mten computers just reset some<br />
pointers (the program pmgralll is still in there). Here'sH how you<br />
un-new,<br />
un-new.<br />
Recovering<br />
Recovering<br />
From NEW On<br />
Apple And CBM<br />
Apple And CBM<br />
Jimmy Stephens<br />
AthenS,GA<br />
Jimmy Stephens<br />
Athens, GA<br />
If you are like me, at least once in your li fe you<br />
If you are like me, at least once in your life you<br />
have had that sickening feeling that comes with the<br />
realization that you have just typed NEW, or maybe<br />
realization that you have just typed NEW, or maybe<br />
turned your computer off, without saving your<br />
program. The next thing g you probably did was to<br />
look for the nearest window tojump out. Unfortunately,<br />
if you havejustlllrned turned off the computer, I<br />
can't give you any alternative to jumping out the<br />
can't give you any alternative to jumping out the<br />
window. (Hopefully it's a text window.) What I can<br />
do is to show you how to combat an accidental NEW.<br />
When the NEW command is processed by<br />
Apple and CBM computers, the program in memory<br />
is not erased. All that happens is that several<br />
pointers are reset so that, when the next program<br />
pointers are reset so that, wh en the next program<br />
is entered, it will write over the old one. If you<br />
have entered NEW and have not written any lines<br />
to a new program or loaded another program,<br />
to a new program or loaded another program,<br />
then your old program is still in memory and can<br />
be recovered with a little work.<br />
be recovered with a li llie work.<br />
On both Apple and CBM, NEW destroys only<br />
twO bytes of the actual program. Fortunately, these<br />
two bytes of the actual program. Fortunately, these<br />
two bytes deal with the length of the first line e of<br />
the program and cann be recovered. The first POKE<br />
to be made is POKE 2050,8 on the Apple or POKE<br />
to be made is POK E 2050,8 o n the Apple or POK E<br />
1026,4 on CBM. Now, try LiSTing the program.<br />
1026,4 on CBM. Now, try LISTing the program.<br />
Surprise! You shouldd see sec the first line of the program<br />
on the screen.<br />
Your next POKE will be determined by the<br />
Your next POKE will be determined by the<br />
number of bytes in this first line. Count the number<br />
of characters in the line, remembering that reserved<br />
BASIC commands are tokenized and take up onlyy<br />
one byte. Therefore, count all BASICC commands<br />
as one character. Add six to your total and POKE<br />
as one character. Add six to your total and POKE<br />
this value into location 2049 on the Apple or location<br />
1025 on CBM.<br />
There is a good chance, because of spaces in<br />
the line and such, that this POKE will not be correct<br />
the first time. LIST the program again. If it LISTs<br />
the first time. LIST the program again. Ifit LISTs<br />
O.K. then the POKE was right and you can skip to<br />
the next paragraph. Otherwise, you will need to try<br />
the next paragraph. Otherwise, you will need to try<br />
a new value and redo the POKE. Keep trying values<br />
around your original total until the program LISTs<br />
around your original total until the program LISTs<br />
correctl y.<br />
correctly.<br />
At this point, although it looks alright, do not<br />
mn run the program. If you do, the variables will overwrite<br />
the program and all your work will have been<br />
for r nothing. Youu will have to make POKEs in a<br />
pair of locations to reset the pointer for the be<br />
pair of locations to reset the pointer fo r the beginning<br />
of the variables. For CBM computers, these<br />
locations depend on which ROM revision your<br />
system has. For Original ROMs, these locations are<br />
system has. For Original ROMs, these locations are<br />
124 and 125, and, for both Upgrade and 4.0, ROMs<br />
the locations are 42 and43. The Apple has a pointer<br />
to the start of variable space as well as a pointer to<br />
the end of the program. This means that if you<br />
have an Apple, you will have to make all remaining<br />
POKEs K in both of these locations. The first pointer<br />
is at 105 and 106 and the second one resides at 175<br />
and 176.<br />
The next POKEs are designed to give your<br />
program some room to breathe and are determined<br />
by the amount of RAM you have. T hese POKEs<br />
are onl y te mporary and will be changed later. Use<br />
program some room to breathe and are determined<br />
by the amount of RAM you have. These POKEs<br />
are only temporary and will be changed later. Use<br />
the formula below to determine the value of the<br />
first POKE.<br />
first POKE.<br />
((Number of Kilobytes of RAM) * 4) -2<br />
This POKE is made in the high byte of the<br />
variabl e poin ter(s). Next, POKE 0 into the low byte<br />
variable pointer(s). Next, POKE 0 into the low byte<br />
of the pointer(s). For example: On a 16KK Apple,<br />
the operation would look like this<br />
the operation would look like this<br />
POKE 105,0: : POKE 106,62: : POKE 175,0:<br />
:<br />
POKE 176,62<br />
POKE 176,62<br />
Your program will now run, but, if it uses<br />
lots of variables, you will soon get an OUT OF<br />
lots of variables, you will soon get an OUT OF<br />
MEMORY message. Too fix this, add the following<br />
lines to your program:<br />
o 0I=XXXX<br />
1I 1=1+ I = I+1:IFPEEK(I)81THEN1<br />
I:IFPEEK(I) 8ITHENI<br />
2 IFPEEK(I+1)81THEN1<br />
+ 8ITHENI<br />
3 1= I = I 1 + 6:A = INT(I/256):B = 1-256*A<br />
I-256*A<br />
4 POKEYY,B:POKEZZ,A:END<br />
63999 QQ<br />
XXXX = 1024 for CBM or 2048 for Apple.<br />
XXXX = 1024 for CBM or 2048 for Apple.<br />
YY::::: = low byte of variable pointer(s).<br />
ZZ::::: = high byte of variable pointer(s). (Two more POKEs<br />
for the second pointer will be necessary on the Apple.<br />
for the second pointer will be necessary on the Apple.<br />
When the program is run, it will change the<br />
POKEs to the correct value. Obviously, if your<br />
program's first line number is less than five orr if it<br />
has a line numbered 63999, you wi ll have to make<br />
has a line numbered 63999, you will have to make<br />
some adjustments. Also, you will need to make<br />
sure that "QQ" does not appear anywhere else in<br />
the program. IfI f it does, you will have to useu ~e another<br />
two-letter sequence in line 63999 and you will \yill need<br />
to adjust the ASCIII codes in lines one and two<br />
accordingly. ©<br />
accord in gly. ©