Personal Computer News


Commodore 64 Restoration

 
Published in Personal Computer News #044

Commodore 64 Restoration

A feature lacking on the Commodore 64 is the ability to 'RESTORE' to a particular line of DATA. The following subroutine is very short and can easily be included in your program, to achieve a 'RESTORE TO LINE'.

Simply set the variable LINE to the required line number, then call the subroutine with GOSUB 60000.

The routine has an error message for non-existent line numbers.


   10 REM DEMO
   20 DATA 1,2
   30 FSYS 3,4
   40 LINE=30:GOSUB 60000
   50 READ A,B:PRINT A,B:END
   60 REM
60000 REM RESTORE TO LINE
60010 X0 = 2048
60020 X1 = PEEK(X0+3)+256*PEEK(X0+4)
60030 IF X1=LINE THEN POKE 65,X0 AND 255:POKE 66,(X0/256) AND 255:RETURN
60040 X0=PEEK(X0+1)+256*PEEK(X0+2)-1:IF X0>? THEN 60020
60050 PRINT~?NO SUCH LINE:END

David Gristwood
Sunderland, Tyne and Wear

David Gristwood