Michael J. Barkan
Using less than 1K of memory, this utility program for cassette can save you a lot of time and frustration.
I had recently made a CSAVE and a LIST"C:" (after about five hours of typing) and neither of them had saved the program. This sort of thing is more than distressing. My solution is neither elaborate nor entirely original, but it works.
Ed Stewart's article in COMPUTE!'s Second Book of Atari on backing up machine language tapes served as the inspiration for my program. Stewart's program reads a block of data from the cassette tape, puts it in a string, reads another block, adds it to the string, and so on. The string eventually contains the entire program. Of course, the string needs to be as big as the computer's memory, so I couldn't use the method directly.
I know absolutely nothing about machine language except that when I try to change something, the system crashes — so I didn't change anything. The trick was to fool the machine language program. Locations 203 and 204 (decimal) contain the starting address of string A$. All I had to do (sounds easy, now) was reset these locations so that the machine language subroutine would "forget" that it had already put something into A$. This means that A$ needs to hold a maximum of only 128 bytes, the size of one cassette data block. Therefore, this program, once running, takes up less than 1K of memory; A$ just keeps reusing the same 128 bytes.
To use this utility, type it in and save it with LIST"C:". Load the program you want to save, or start typing in a new program. Make sure your program starts at line 10 or higher. CSAVE it. Now ENTER"G" this utility and run it. It will ask you to start loading the tape with your new'program. If the tape runs all the way through and ends with an end-of-file flag, you'll get a "GOOD TAPE" message. If the tape is not readable, you'll get an error message (my favorite is 143), but your program is still in the computer, so you can try again. Delete lines 0 through 9 first, though.
If your tape is of the ENTER"C:" variety, just change the 255 in line 4 to 0, and the program will verify it, too.
That's all there is to it. Not quite like having a disk drive, but at least now tape storage will be far less likely to cause you distress.
1 CLR : DIM A$ (128) : POKE 203, ADR(A$) - (INT (ADR (A$) / 256) * 256) : POKE 204, INT (ADR(A$) / 256) : REM POKE START LOCATION OF A$ 2 FOR I = 1536 TO 1565 : READ A : POKE I, A : NEXT I : TRAP 7 : REM POKE IN M. L. ROUTINE AND SET TRAP FOR END OF FILE FLAG 3 ? CHR $ (125) ; "INSERT TAPE TO TEST" : ? "PRESS ANY KEY TO BEGIN" 4 CLOSE #1 : OPEN # 1, 4, 255, "C :" : REM CHANGE 255 TO 0 FOR TAPES WITH LONG INTER-RECORD GAPS 5 FOR I = 1 TO 100000 : GET #1, B : X = USR (1536) : REM LOOP THROUGH THIS MORE TIMES THAN ANYONE WILL EVER NEED 6 POKE 203, ADR (A$) - (INT (ADR (A$) / 256) * 256) : POKE 204, INT (ADR (A$) / 256) : NEXT I : REM EUREKA! RESET POINTER TO START OF A$ 7 IF PEEK (195) = 136 THEN CLOSE #1 : ? CHR$ (125) ; "GOOD TAPE" : END : REM LOOK FOR END OF FILE FLAG 8 ? "ERROR - " ; PEEK (195) : END : REM TAPE IS NOT READABLE 9 DATA 104, 174, 138, 2, 134, 61, 160, 0, 162, 0, 185, 0, 4, 129, 203, 200, 230, 203, 208, 2, 230, 204, 196, 61, 240, 3, 76, 10, 6, 56