The purpose of this software is to convert Sinclair ZX-81/TS-1000 programs to ASCII files. The ZX-81 stores all of it’s Basic files as TOKENIZED files and are unreadable by most other computers. Once the programs are converted to ASCII files, you can port the programs to any system that uses ASCII program files.
Please note that this program will NOT translate Sinclair BASIC to any other BASIC language. You will have to do that yourself. It’s not hard but you should use an Editor like QUED/M to do global replace, search etc.
Assumptions:
1. It is assumed that you have an RS-232 adaptor for your ZX-81. The Memotech RS-232 is the one I used. The ZX-81 modem software is written for the Memotech device. You may have to modify the software if you are using a different device.
2. It is assumed that you have a communications program for the Macintosh and that you have hard-wired the ZX-81 directly to the Macintosh. I used Smartcom II and a home made cable.
3. It is asumed that your ZX-81 program does NOT containe Z-80 machine code embedded in a statement and that your program does not have a line numbers greater than 8999.
4. If your ZX-81 program has a line number 118, it will be translated as line 0 after line 117. You will have to change the line number after the program has been converted.
Using Sinclair Migration:
1. Connect the ZX-81 to the Mac with a direct cable.
2. You must add the following code to your ZX-81 program. If you are trying to port a program that is un-listable on the ZX-81 try this:
A. Put the ZX-81 in FAST mode.
B. TYPE RAND USR 836
C. Start tape. Tape will load and give an error C
D. Type LIST and there is the program!
Enter the following code to the ZX-81 program:
9000 THIS WILL MOVE PROGRAMS OUT VIA THE RS-232 PORT
9001 LET P$="00011010,00001000"
9002 RAND USR 10900
9003 LET T$=""
9004 FAST
9005 FOR N=16509 TO ( PEEK 16396+256* PEEK 16397)
9006 IF PEEK N=118 THEN GOTO 9910
9007 LET T$=T$+ STR$ PEEK N+","
9008 NEXT N
9009 GOTO 9915
9010 RAND USR 10895
9011 LET T$= CHR$ 118
9012 RAND USR 10895
9013 LET T$=""
9014 NEXT N
9015 SLOW
(NOTE: This is for the Memotech RS-232 Module !!!)
3. Start the file capture on the Mac. This is the INPUT file. Remember what you save it as. I use the following naming convention “program/TOKEN” so that I know it is a tokenized file.
4. Enter RUN 9000 on the ZX-81. The program will read each byte and send it out the RS-232 port. The Mac should receive data that looks something like this:
0,20,2,0,249, 0,30,14,0,233,63,13,16,31,30,126,134,0,0,0,0,17, 0,50,12,0,233,43,16,35,126,131,96,0,0,0,17, 0,55,12,0,233,59,16,35,126,131,96,0,0,0,17, 0,58,13,0,241,40,57,20,33,28,126,134,72,0,0,0, 0,60,17,0,233,38,13,16,40,57,26,29,28,126,132,32,0,0,0,17, 0,65,17,0,233,39,13,16,40,57,26,29,37,126,133,24,0,0,0,17, etc.
(NOTE: Each number is a TOKENIZED value of ZX-81 BASIC.) Sinclair Migration will convert these tokenized files to ASCII. The converted file will look like this:
20 RAND 30 DIM Z$(32) 50 DIM F(7) 55 DIM V(7) 58 LET CT=50 60 DIM A$(CT,10) 65 DIM B$(CT,19) etc.
(Note again that this is pure Sinclair ZX-81 Basic syntax.)
5. Once the ZX-81 program ends, finish saving the input file on the Mac.
6. Run Sinclair Migration on the Mac. Select Open from under the File menu. Select the file you just downloaded from the ZX-81 (Input File/Tokenized). Enter the name you want for the ASCII file. The progam will default to add the extension of “ASCII” to the input file name. Select save and your file will be converted to ASCII. Note that the tokenized file is not changed; a new file is created with the ASCII text.
7. You now have an ASCII file of your ZX-81 Program. It is fairly easy to translate it to ZBasic syntax. This program was written in ZBasic and I reccomend it.
Here’s where to get the software mentioned:
1. ZBasic (Cost approx $89.00)
ZEDCOR, Inc
4500 East Speedway, Suite 22
Tucson, AZ 85712-5305
tel: (800) 482-4567
2. Qued/M (Cost approx $89.00)
Paragon Concepts Inc
4954 Sun Valley Road
Del Mar, CA 92014
tel: (619) 481-1477
I have enclosed the ZBasic source code for those who might want to write a simmilar program for a MS-DOS or CP/M system.
* * PROGRAM SOUCE CODE * *
REM **********************************************
REM * *
REM * COPYRIGHT 1987 BY Anthony Oresteen *
REM * [address omitted] *
REM * tel: [phone number omitted] *
REM * *
REM * A Donation of $5.00 is asked if YOU keep *
REM * this program . Please send your tax de- *
REM * ductiable donation to: *
REM * Holy Cross Parish *
REM * 313 East Wilson ST *
REM * Batavia, IL 60510 *
REM * USA *
REM * *
REM **********************************************
REM THIS PROGRAM IS WRITTEN FOR THE ZBASIC COMPILER 4.0
REM SET OPTIONS AS FOLLOWS:
REM
REM DEFAULT VARIABLE TYPE SINGLE PRECISION
REM DEFAULT DATA TYPE 'TEXT'
REM SPACE REQUIRED AFTER KEYWORD
REM OPTIMIZE EXPRESIONS AS INTERGER
REM ALL OTHER OPTIONS OFF (BOXES NOT SELECTED)
REM =================================================
REM = Last Change: 11 Nov 1987 10:30 PM =
REM =================================================
REM ***************** STANDARD MAC SETUP **************
CLS
FLUSHEVENTS
COORDINATE WINDOW
DEFMOUSE=1 : CALL SHOWPEN : TEXT ,,,0
WINDOW OFF
APPLE MENU "/About Sinclair"
MENU 1, 0, 1, "File"
MENU 1, 1, 1, "/OOpen"
MENU 1, 2, 1, "/QQuit"
MENU 1, 3, 1, "/TTransfer⌐"
MENU 1, 4, 1, "/`Shutdown!"
EDIT MENU 2
REM ------------------ OPENING WINDOW DISPLAY ---------------
WINDOW 1,"",(160,110)-(352,202),-2 : TEXT 0,12,0,0
PRINT% (30,16) "Sinclair Migration"
PRINT% (22,35) "⌐ 1987 A. Oresteen"
PRINT% (27,55) "All Rights Reserved"
PRINT% (45,75) "Release 1.01"
REM -----------------------------------------------------
REM HERE WE LOAD THE SINCLAIR TOKENS
REM -----------------------------------------------------
DIM 10 T0KEN$(256)
FOR N = 0 TO 255
READ T0KEN$(N)
NEXT N
LET T0KEN$(11) = CHR$ (34) : REM PUTS QUOTES IN ARRAY; CAN'T DO IT
WITH A READ STATEMENT!
DELAY 1000
WINDOW CLOSE 1
MENU ON : DIALOG ON : BREAK ON
ON BREAK GOSUB "QUIT"
ON MENU GOSUB "MENUCHOICE"
ON DIALOG GOSUB "GETEVENT"
REM **** HERE WE ARE WAITING FOR SOMETHING TO HAPPEN ********
"GLOBALPAUSE"
REM ********************************************************
REM THIS IS THE MAIN EVENT LOOP. IT TRAPS ALL EVENTS (DIALOG etc. )
REM ********************************************************
GOTO "GLOBALPAUSE"
MENU OFF : BREAK OFF : DIALOG OFF
"GETEVENT"
WHAT = DIALOG (0)
IF WHAT = 1 THEN GOSUB "BUTTON"
RETURN
REM * NOW WE BRANCH TO THE WINDOW WHERE THE EVENT TOOK PLACE *
"BUTTON"
WHERE = WINDOW (0)
IF WHERE = 5 THEN GOSUB "W5BUTTON"
RETURN
REM -------------------------------------------------------
REM ********** END OF EVENT LOOP *********
REM -------------------------------------------------------
REM ********************************************************
REM HERE WE TRAP THE MENU SELECTIONS !
REM ********************************************************
"MENUCHOICE"
MENU
LET LASTWIN = WINDOW (0)
M1=MENU(0): M2=MENU(1)
IF M1=255 THEN GOSUB "ABOUT"
IF M1 = 1 THEN GOSUB "FILE"
RETURN
"FILE"
IF M2= 1 THEN GOSUB "OPEN"
IF M2= 2 THEN GOSUB "QUIT"
IF M2= 3 THEN GOSUB "LAUNCH"
IF M2= 4 THEN GOSUB "CRASH"
RETURN
"OPEN"
REM --------- GET INPUT FILE -----------------
NAMES$ = FILES$ (1,"TEXT",,VOL%) : IF NAMES$ = "" THEN RETURN
OPEN "I",1,NAMES$, 1000, VOL% : Z$ = NAMES$+".ASCII"
REM ---------- GET OUTPUT FILE ----------------
NAME2$ = FILES$(0,"Save ZX-81 Program as⌐",Z$,VOL2%)
IF NAME2$="" THEN CLOSE #1 : RETURN
OPEN "O",2, NAME2$,,VOL2%
REM ------------- HERE WE CONVERT THE INPUT FILE -------
WINDOW 2,"Sinclair Migration",(20,50)-(492,200), 261
TEXT 4,12,0,0 : LINECOUNT=1
PRINT: PRINT "Converting Sinclair ZX-81 Program: ";NAMES$;" TO ASCII"
PRINT : PRINT "Lines Converted: " : CURSOR=4
"GETDATA"
INPUT #1,T,S,U,V : LNUM= T*256+S: LANGTH=U+256*V
IF LNUM = 9000 THEN GOTO "END"
TEMP$=STR$(LNUM)+" " : TEMP$=RIGHT$(TEMP$,LEN(TEMP$)-1 ): REM REMOVES SIGN BYTE
N=1 : NUM = 0 :PRINT #2, TEMP$ ;
FOR N = 1 TO LANGTH-1
INPUT#1,XX :
IF XX = 126 THEN NUM =1
IF NUM = 0 THEN TEMP$=T0KEN$ (XX) : PRINT #2, TEMP$;
IF NUM =1 THEN INPUT#1,A,A,A,A,A : N= N+5 : NUM = 0
NEXT N
PRINT #2, CHR$(13);
PRINT % (120,57); LINECOUNT : LINECOUNT=LINECOUNT+1
INPUT#1,XX
GOTO "GETDATA"
"END"
CLOSE 1 : CLOSE 2 : CURSOR=0 : PRINT : PRINT "DONE!" : BEEP
DELAY 4000 : WINDOW CLOSE #2
RETURN
REM *********** Begin Quit Menu ********************************
"QUIT"
REM ---- HERE WE EXIT. SHOULD CLOSE & POST FILES FIRST! ----
END
REM ------------- End of Quit Menu -----------------------------
REM *********** Begin Transfer Menu **************************
"LAUNCH"
LASTWIN = WINDOW (0)
Current$= FILES$ (1,"APPL",,VOL%)
IF Current$ = "" THEN RETURN
CLOSE
RUN Current$,VOL%
RETURN
REM ----------- End of Transfer Menu ---------------------
REM *********** Begin Shutdown Menu **************************
"CRASH"
REM ------ SHOULD POST DATA TO FILES & CLOSE FIRST !!!!-----
CLOSE
SHUTDOWN
REM ----------- End of Shutdown Menu --------------------
REM ************* The About Menu ***************
"ABOUT"
WINDOW #5, , (60,50)-(450,320),-2 : TEXT 6, 18, 0,
PRINT% (60,20) "Sinclair ZX-81 Migration"
TEXT 0, 12, 0,
PRINT% (100,40) "Version 1.01 (10 Nov 87)"
PRINT% (100,60) "⌐1987 Anthony Oresteen"
PRINT% (100,80) "All Rights Reserved"
PRINT% (10,120) " Shareware fee $5.00"
PRINT% (10,140) " Please send your fee to:
PRINT% (40,165) " Holy Cross Parish"
PRINT% (40,185) " 313 East Wilson St"
PRINT% (40,205) " Batavia, IL 60510"
PRINT% (40,225) " USA"
TEXT 4,9,0, :
PRINT% (297,259) "ZBasic 4.00"
BUTTON #11,1,"Thanks!",(285,200)-(370,220),1
RETURN
"W5BUTTON"
WINDOW CLOSE #5
RETURN
REM --------------- END of About Menu ---------------------
REM ----------------------------------------------------
REM HERE ARE THE SINCLAIR TOKENS
REM ---------------------------------------------------
DATA " ","R","R","R","R","R","R","R","R","R","R","'"
DATA $,$,":","?","(",")",">","<","="
DATA "+","- ","*","/",";",",",".","0","1","2","3","4","5","6","7","8","9"
DATA A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
DATA " RND "," INKEY$ "," PI "," "," "," "," "," "," "," "," "," "," "," ",
DATA " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ",
DATA " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ",
DATA " "," "," "," "," "," "," "," "," "," "," "," "," "," "," ",
DATA " "," "," "," "," "," ","'"," ","$",":","?","(",")",">","<","="
DATA "+","-","*","/",";",",","."
DATA "0","1","2","3","4","5","6","7","8","9",a,b,c,d,e,f,g,h,i,j,k,l,m,n
DATA o,p,q,r,s,t,u,v,w,x,y,z,"~"," AT "," TAB "," "," CODE "," VAL "," LEN "
DATA " SIN "," COS "," TAN "," ASN "," ACS "," ATN "," LN "," EXP "," INT "
DATA " SQR "," SGN "," ABS "," PEEK "," USR "," STR$ "," CHR$ "," NOT "
DATA **," OR "," AND "," <= "," >= "," <> "," THEN "," TO "," STEP "," LPRINT "
DATA " LLIST "," STOP "," SLOW "," FAST "," NEW "," SCROLL "," CONT "," DIM "
DATA " REM "," FOR "," GOTO "," GOSUB "," INPUT "," LOAD "," LIST "," LET "
DATA " PAUSE "," NEXT "," POKE "," PRINT "," PLOT "," RUN "," SAVE "," RAND "
DATA " IF "," CLS "," UNPLOT "," CLEAR "," RETURN "," COPY "
If you have any questions write to me (enclose a SASE):
Anthony J. Oresteen
[address omitted]
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.