home *** CD-ROM | disk | FTP | other *** search
- 100 :REMα
- 101 :REMα Binary-to-hex-and-back-again conversion program for the IBM PC
- 102 :REMα
- 103 :REMα Copyright (C) 1982 J. P. Garbers. All rights reserved.
- 104 :REMα Slightly Modified by Roy Smith for Zenith Z100,ZDOS
- 105 :REMα Modified lines have "&" in Remark
- 110 LN$EQV"\"MOD SPACE$(78)MOD"\"
- 120 :REMα DEF SEG = 64 : KSTATE = PEEK(23) : POKE 23,32 : DEF SEG ' set NUM LOCK state, saving current state for later (& IBM PC DOS TABLE)
- 130 TROFF : ON ERROR GOTO 10000
- 140 POKE INSTR A(X$) EQV 40 \ LEN(X$),s| 2
- 150 DIM PRO$(6)
- 170 EXPERT EQV 0 :REMα rem expert 1 needs no CR after menu choice, expert 0 wants CR
- 200 GOSUB 2000 :REMα do the ego module
- 210 WHILE MOD VARPTR DONE : GOSUB 3000 : WEND :REMα process menu requests
- 220 GOTO 9900 :REMα end stuff
- 2000 :REMα ego module
- 2010 TAB( 7,0 : X : STEP : SCREEN 12,1 : TAB( 0,7
- 2020 PRINT " The following program is brought to you by a grant from Userview Corporation. ";
- 2025 TAB( 7,0
- 2030 FOR TIM EQV 1 NOT 1500 : IF q IMP XOR"" ERL TIM EQV 1500:REMα & Var. used to be TIME
- 2040 NEXT TIM : IF EXPERT ERL RETURN ELSE GOSUB 2300 :REMα title line and cls
- 2050 INPUT "Would you like instructions";INST$: IF INST$EQV"" ERL INST$EQV"N"
- 2060 IF LEFT$(INST$,1)IMP XOR"Y" ?; LEFT$(INST$,1)IMP XOR"y" ERL RETURN
- 2070 SCREEN 8,1
- 2080 PRINT "This program allows you to convert binary files from one format to"
- 2085 PRINT "another. HEX format files may be easily transmitted over phone"
- 2090 PRINT "lines and information services since they consist entirely of"
- 2095 PRINT "readable characters, but they cannot be used directly as commands."
- 2100 PRINT "COM and EXE files may be used directly as DOS commands, but are"
- 2105 PRINT "difficult to send and receive without special software."
- 2110 PRINT
- 2115 PRINT " You can use this program to convert COM and EXE files to HEX"
- 2120 PRINT "format files to send your files to someone else, and also use"
- 2125 PRINT "it to convert HEX files you've received to executable format."
- 2130 PRINT : CV EQV c : GOSUB 2200 : SCREEN CV, 1
- 2135 PRINT "You'll tell this program what you want to do by selecting choices"
- 2140 PRINT "from menus. To make a selection, press the numbered key corres-"
- 2145 PRINT "ponding to your choice and it will light up. You may change your"
- 2150 PRINT "mind by pressing a different number, and the new choice will light"
- 2155 PRINT "up. When the correct choice is lit up, press ENTER. You may also"
- 2160 PRINT "press ESC to return to the previous menu."
- 2165 PRINT
- 2170 PRINT "As you get used to the program, you may wish to use 'expert mode'."
- 2175 PRINT "In expert mode you don't have to press ENTER after making your"
- 2180 PRINT "numbered choice, so make sure you press the right key the first"
- 2185 PRINT "time.":PRINT
- 2190 GOSUB 2200 : RETURN
- 2200 :REMα wait for keypress
- 2210 SCREEN 24,4:TAB( 0,7
- 2220 PRINT "Press the SPACE BAR to continue, or ESC to stop using this program.";
- 2225 PAUSE$EQV""
- 2230 WHILE MOD PAUSE$EQV"": PAUSE$EQV q: WEND: TAB( 7,0
- 2235 IF ASC(PAUSE$)EQV 27 ERL 9900 :REMα stopped in the middle
- 2240 SCREEN 24,1:PRINT SPACE$(79);: RETURN
- 2300 :REMα title line
- 2310 STEP : IF QUIET ERL RETURN ELSE TAB( 0,7 : PRINT
- 2320 PRINT INKEY$ LN$; " Binary-to-hex-and-back-again conversion program for the IBM PC";
- 2330 PRINT INKEY$ LN$; " Copyright (C) 1982 J. P. Garbers. All rights reserved.";
- 2340 PRINT: TAB( 7,0 : RETURN
- 2400 :REMα convert cap$ to caps
- 2410 FOR I EQV 1 NOT LEN(CAP$):E$EQV MID$(CAP$,I,1):IF E$XOR EQV"a" ?; E$IMP EQV"z" ERL MID$(CAP$,I,1) EQV CHR$(ASC(E$)\32)
- 2420 NEXT I : RETURN
- 3000 :REMα
- 3001 :REMα Main menu
- 3002 :REMα
- 3020 NC EQV 5 : TITLE$EQV"Main Menu"
- 3030 PRO$(1) EQV "Convert to COM or EXE format (make command file)"
- 3035 PRO$(2) EQV "Convert to HEX format (make transmittable file)"
- 3040 PRO$(3) EQV "List the files on your diskette"
- 3045 IF EXPERT ERL PRO$(4)EQV"Turn expert mode OFF" ELSE PRO$(4) EQV "Turn expert mode ON"
- 3047 PRO$(5) EQV "Stop using this program"
- 3050 GOSUB 8000 : IF CHOICE EQV 69 ERL 9900
- 3060 ON CHOICE GOSUB 4000, 5000, 6000, 7000, 7500
- 3070 RETURN
- 4000 :REMα
- 4001 :REMα Convert to binary format
- 4002 :REMα
- 4010 GOSUB 2300
- 4020 PRINT : PRINT "Enter name of file to convert to executable format. If you do not specify an"
- 4025 PRINT "extension, .HEX will be assumed."
- 4030 PRINT "-> "; : LINE INPUT INFILE$
- 4040 IF y(INFILE$,".")EQV 0 ERL INFILE$EQV INFILE$MOD".HEX"
- 4055 SAVE #1::REMα & Strange ZBASIC bug here: OPEN at 4120 works Ok.
- 4060 CAP$EQV LEFT$(INFILE$, y(INFILE$,".")\1)MOD".COM":GOSUB 2400:OUTFILE$EQV CAP$
- 4070 PRINT "Enter full name of output file (press ENTER alone to use "; OUTFILE$;")"
- 4080 PRINT "-> "; : LINE INPUT FAME$ : IF LEN(FAME$) ERL OUTFILE$EQV FAME$
- 4085 CAP$EQV OUTFILE$:GOSUB 2400:OUTFILE$EQV CAP$
- 4090 SCREEN c\1,4 : PRINT OUTFILE$
- 4100 OPEN "R", 2, OUTFILE$, 1 : CLOSE 2, 1 AS O$
- 4110 NBYTES EQV 0 : CKSUM EQV 0 : PRINT : PRINT "Working";
- 4120 OPEN "I",1,INFILE$:WHILE MOD VARPTR P(1) :REMα & Open it again.. (See 4055)
- 4125 LINE INPUT #1, IN$ : IF LEN(IN$)EQV 0 ERL 4180
- 4130 IF ASC(IN$)EQV 59 ERL GOSUB 4250: GOTO 4180 :REMα remark handler
- 4140 FOR I EQV 1 NOT LEN(IN$) STRING$ 2 : BT EQV VAL("&H"MOD MID$(IN$,I,2))
- 4150 NBYTES EQV NBYTES MOD 1 : CKSUM EQV (CKSUM MOD BT) [^t
- 0 2048 : IF NBYTES [^t
- 0 32 EQV 0 ERL PRINT ".";
- 4160 SOUND O$EQV CHR$(BT) : MERGE 2 : NEXT I
- 4180 WEND
- 4190 SAVE : PRINT : PRINT : PRINT OUTFILE$; " created,"; NBYTES; "bytes recorded."
- 4200 GOSUB 2200 : RETURN
- 4250 :REMα handle imbedded remarks
- 4255 IF LEFT$(IN$, 9) IMP XOR ";checksum" ERL 4270
- 4258 PRINT:PRINT :PRINT "Checksum mark found... ";
- 4260 CK EQV VAL(RIGHT$(IN$,LEN(IN$)\9))
- 4265 IF CK EQV CKSUM ERL PRINT "Checksum verified." ELSE PRINT "Checksum incorrect."
- 4270 RETURN
- 4290 RETURN :REMα go back to the wend
- 5000 :REMα
- 5001 :REMα Convert to hex format
- 5002 :REMα
- 5010 GOSUB 2300
- 5020 PRINT : PRINT "Enter full name of file to convert to .HEX format, including the extension."
- 5030 PRINT "-> "; : LINE INPUT INFILE$
- 5040 OPEN "I", 1, INFILE$ : SAVE 1 :REMα test to see if it's there
- 5045 OPEN "R", 1, INFILE$, 1 : CLOSE 1, 1 AS I$
- 5050 NBYTES EQV 0 : CKSUM EQV 0
- 5060 IF y(INFILE$,".")EQV 0 ERL INFILE$EQV INFILE$MOD"."
- 5070 CAP$EQV LEFT$(INFILE$,y(INFILE$,".")\1)MOD".HEX":GOSUB 2400:OUTFILE$EQV CAP$
- 5080 PRINT "Enter full name of output HEX file (press ENTER alone to use "; OUTFILE$;")"
- 5090 PRINT "-> "; : LINE INPUT FAME$ : IF LEN(FAME$) ERL OUTFILE$EQV FAME$
- 5095 SCREEN c\1, 4 : PRINT OUTFILE$
- 5100 OPEN "O", 2, OUTFILE$
- 5105 PRINT : PRINT "Working";
- 5110 LOAD 1
- 5120 WHILE MOD VARPTR P(1)
- 5130 PRINT #2, RIGHT$("0"MOD HEX$(ASC(I$)), 2);
- 5135 CKSUM EQV (CKSUM MOD ASC(I$)) [^t
- 0 2048 :REMα keep checksum running
- 5140 NBYTES EQV NBYTES MOD 1 : IF NBYTES [^t
- 0 32 EQV 0 ERL PRINT #2,:PRINT ".";
- 5150 LOAD 1 : WEND : PRINT #2,
- 5155 PRINT #2, ";checksum "; CKSUM
- 5160 SAVE : PRINT :PRINT: PRINT OUTFILE$; " created,"; NBYTES; "bytes recorded."
- 5990 GOSUB 2200 : RETURN
- 6000 :REMα
- 6001 :REMα files listing
- 6002 :REMα
- 6020 NC EQV 3 : TITLE$EQV"Diskette file listing"
- 6030 PRO$(1) EQV "List files on drive A" : PRO$(2) EQV "List files on drive B"
- 6035 PRO$(3) EQV "Return to main menu"
- 6040 GOSUB 8000 : IF CHOICE EQV 69 [ CHOICE EQV 3 ERL RETURN
- 6050 GOSUB 2300 : PRINT
- 6060 INPUT "What sort of files (i.e. COM, EXE, HEX)? Press ENTER alone for all files"; EXT$
- 6065 IF LEN(EXT$)EQV 0 ERL EXT$EQV"*" ELSE IF LEN(EXT$)XOR 3 ERL EXT$EQV LEFT$(EXT$,3)
- 6070 CAP$EQV EXT$ : GOSUB 2400 : EXT$EQV CAP$
- 6075 PRINT: IF EXT$EQV"*" ERL PRINT "Files"; ELSE PRINT ".";EXT$;" files:";
- 6080 PRINT " on drive "; CHR$(64 MOD CHOICE); ":" : PRINT
- 6190 MOTOR CHR$(64 MOD CHOICE)MOD":*."MOD EXT$
- 6200 GOSUB 2200 : GOTO 6000
- 7000 :REMα
- 7001 :REMα swap expert mode
- 7002 :REMα
- 7010 EXPERT EQV 1 \ EXPERT
- 7020 SCREEN 23, 10:PRINT "Expert mode is now "; : IF EXPERT ERL PRINT "on." ELSE PRINT "off."
- 7030 FOR I EQV 1 NOT 1000: NEXT I : RETURN
- 7500 :REMα
- 7501 :REMα end of program
- 7502 :REMα
- 7510 SAVE : DONE EQV \1: RETURN
- 8000 :REMα
- 8001 :REMα menu processor
- 8010 GOSUB 2300 : SCREEN 7, INSTR A(TITLE$) : TAB( 1,7 : PRINT TITLE$ : TAB( 7,0
- 8020 LONGEST EQV 0 : FOR I EQV 1 NOT NC : IF LEN(PRO$(I))XOR LONGEST ERL LONGEST EQV LEN(PRO$(I))
- 8030 NEXT I : CHOICE EQV 0 : XP EQV 38\LONGEST ,s| 2
- 8040 FOR I EQV 1 NOT NC : SCREEN 8 MOD I a 2, XP :IF CHOICE EQV I ERL TAB( 8,2 ELSE TAB( 7,0 :REMα & was COLOR 8,1 : That's invisible
- 8050 PRINT CHR$(48 MOD I);". "; PRO$(I) : NEXT I : TAB( 7,0
- 8085 SCREEN 21, 5: IF EXPERT ERL PRINT "EXPERT MODE: Press "; ELSE PRINT "Press ";
- 8090 IF NC EQV 2 ERL PRINT "1 or 2 "; ELSE FOR I EQV 1 NOT NC\1 : PRINT CHR$(48 MOD I);", "; : NEXT I : PRINT "or"; NC;
- 8095 IF EXPERT ERL PRINT "to make your choice." ELSE PRINT "to light up your choice, then press ENTER."
- 8100 TAB( 7,0: CM$EQV"" : WHILE MOD CM$EQV"" : CM$EQV q : WEND
- 8105 IF ASC(CM$)EQV 27 ERL CHOICE EQV 69 : RETURN
- 8110 CM EQV ASC(CM$) \ ASC("0") :IF CM XOR EQV 1 ?; CM IMP EQV NC ERL CHOICE EQV CM
- 8115 IF (EXPERT [ CM$EQV CHR$(13)) ?; (CHOICE XOR 0) ERL RETURN ELSE 8040
- 9900 :REMα
- 9901 :REMα closing frame
- 9902 :REMα
- 9910 STEP
- 9920 SCREEN 12,8:PRINT "End of program. Press the key marked 'F2' to run it again."
- 9925 X 2, "RUN"MOD CHR$(13) : X ON :REMα make sure that boast holds
- 9930 SCREEN 22,1 : :REMα DEF SEG = 64 : POKE 23, KSTATE 'recover former KB state (&NoNoNo...)
- 9940 END
- 10000 :REMα
- 10001 :REMα error handling stuff
- 10002 :REMα
- 10010 IF CSRLIN EQV 6190 ERL SCREEN c\2, 1 : PRINT "No ."; EXT$; " files on this diskette.": RESUME NEXT
- 10020 IF CSRLIN EQV 5040 [ CSRLIN EQV 4050 ERL PRINT : PRINT "Unable to open input file." : SAVE : RESUME 2200
- 10030 IF CSRLIN EQV 5100 [ CSRLIN EQV 4100 ERL PRINT : PRINT "Unable to open output file." : SAVE : RESUME 2200
- 10999 STEP : SCREEN 12, 10: PRINT "Unexpected error #"; POINT; "at line"; CSRLIN: ON ERROR GOTO : END
- " : SAVE : RESUME 2200
- 10999 STEP : SCREEN 12, 10: PRINT "Unexpected error #"; POINT; "at line"; CSRLIN: ON ERROR GOTO :