Create BLOCK.CONVERT

Initial Commit
This commit is contained in:
Apple Pugetsound Program Library Exchange (A.P.P.L.E.) 2020-11-09 22:05:22 +09:00 committed by GitHub
parent 91bfb7a438
commit e53297a624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

79
source/BLOCK.CONVERT Normal file
View File

@ -0,0 +1,79 @@
10 REM
BLOCK.CONVERT
BY VAL J. GOLDING
A.P.P.L.E. 2/14/84
100 REM
SELECT MODES
110 ONERR GOTO 0640
120 TEXT : HOME : CLEAR : FOR I = 0 TO 7: READ STBL%(I): NEXT : DIM BLK TBL%(15): FOR I = 0 TO 15: READ BLKTBL%(I): NEXT : DIM HALF%(15): FOR I = 0 TO 15: READ HALF%(I): NEXT :HALF$(1) = "FIRST":HALF$(2) = "LAST"
130 INVERSE : FOR I = 1 TO 41: PRINT " ";: NEXT : HTAB 40: PRINT " ";: HTAB 4: NORMAL
140 PRINT "BLOCK AND TRACK/SECTOR CONVERSION";
150 INVERSE : HTAB 40: PRINT " ";: HTAB 40: FOR I = 1 TO 41: PRINT " ";: NEXT : NORMAL : PRINT
160 VTAB 7: HTAB 1: CALL - 958
170 PRINT "CONVERSION MODE: [B] = BLOCK -> T/S": HTAB 18: PRINT "[T] =T/S -> BLOCK": HTAB 9: INVERSE : PRINT " SELECT: ";: NORMAL : PRINT" ";: GET IN$: PRINT IN$: PRINT :TS = (IN$ = "T")
180 IF IN$ = CHR$ (13) THEN PRINT "GOODBYE.": END
190 IF IN$ < > "B" AND IN$ < > "T" THEN 160
200 VTAB 11: HTAB 6: CALL - 958: PRINT "INPUT MODE: [H] = HEX": HTAB 18: PRINT "[D] = DECIMAL": HTAB 9: INVERSE : PRINT " SELECT: ";: NORMAL: PRINT " ";: GET IN$: PRINT IN$: PRINT :HEX = (IN$ = "H")
210 IF IN$ < > "H" AND IN$ < > "D" THEN 200
220 REM
GET TRACK/SECTOR INPUTS
230 VTAB 15: CALL - 958: ON NOT TS GOTO 360: PRINT " TRACK: ";: IF HEX THEN PRINT "$";
240 INPUT "";TRACK$:NBR$ = TRACK$:NBR = VAL (TRACK$): ON HEX GOSUB 0590: ON NOT HEX GOSUB 0550: VTAB PEEK (37): HTAB 22: PRINT "[";: IF NOT HEX THEN PRINT "$"NBR$"]"
250 IF HEX THEN PRINT NBR"]"
260 PRINT "SECTOR: ";: IF HEX THEN PRINT "$0";
270 INPUT "";SEC$:NBR$ = SEC$:NBR = VAL (SEC$): ON HEX GOSUB 0590: ON NOT HEX GOSUB 0550: VTAB PEEK (37): HTAB 22: PRINT "[";: IF NOT HEX THEN PRINT "$0"NBR$"]"
280 IF HEX THEN PRINT NBR"]": GOTO 300
290 TRACK = VAL (TRACK$):SEC = VAL (SEC$): GOTO 320: REM
300 REM
CONVERT HEX INPUT
310 NBR$ = TRACK$: GOSUB 0590:TRACK = NBR:NBR$ = SEC$: GOSUB 0590:SEC = NBR
320 REM
TRK/SEC TO BLOCK
330 BLOCK = TRACK * 8 + BLKTBL%(SEC):HALF = HALF%(SEC):NBR$ = STR$ (BLOCK):NBR = BLOCK: ON HEX GOSUB 0550:BLOCK$ = NBR$: PRINT "BLOCK = ";:IF HEX THEN PRINT "$"BLOCK$;: HTAB 22: PRINT "["BLOCK"]";: GOTO 350
340 PRINT BLOCK;: HTAB 22: PRINT "[$";: GOSUB 0550: PRINT NBR$"]";
350 PRINT " ";HALF$(HALF);" HALF": GOTO 0480: REM
360 REM
GET BLOCK INPUT
370 PRINT " BLOCK: ";: IF HEX THEN PRINT "$";
380 INPUT "";BLOCK$: ON NOT HEX GOTO 400
390 NBR$ = BLOCK$: GOSUB 0590:BLOCK = NBR: VTAB PEEK (37): HTAB 22: PRINT"["BLOCK"]": GOTO 420: REM
400 REM
BLOCK TO TRACK/SEC
410 IF NOT HEX THEN BLOCK = VAL (BLOCK$):NBR = BLOCK: GOSUB 0550: VTAB PEEK (37): HTAB 22: PRINT "[$"NBR$"]"
420 TRACK = INT (BLOCK / 8):SEC = STBL%(BLOCK - (TRACK * 8)):S2 = SEC - 1: IF SEC = 0 THEN S2 = 14
430 IF SEC = 1 THEN S2 = 15
440 NBR = TRACK: GOSUB 0550:TRACK$ = NBR$:NBR = SEC: GOSUB 0550:SEC$ = NBR$:NBR = S2: GOSUB 0550:S2$ = NBR$
450 PRINT " TRACK = $";: IF LEN (TRACK$) = 1 THEN PRINT "0";
460 PRINT TRACK$;: HTAB 22: PRINT "["TRACK"]": PRINT "SECTOR = $0"SEC$" AND $0"S2$;
470 PRINT " ["SEC" AND "S2"]"
480 REM
RERUN OR QUIT
490 PRINT : HTAB 10: PRINT "[S] SAME CONVERSION PARAMETERS": HTAB 10: PRINT "[N] NEW CONVERSION PARAMETERS": HTAB 10: PRINT "[Q] QUIT PROGRAM": PRINT " ";: INVERSE : PRINT " SELECT ";: NORMAL : PRINT " ";: GET IN$: PRINT IN$
500 PRINT : ON IN$ = "N" GOTO 160: ON IN$ = "S" GOTO 220: PRINT "GOODBYE.": PRINT CHR$ (4)"RUNSTARTUP": REM
510 REM
DATA FOR CONVERSION TABLES
520 DATA 0,13,11,9,7,5,3,1
530 DATA 0,7,6,6,5,5,4,4,3,3,2,2,1,1,0,7
540 DATA 1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,2: REM
550 REM
DEC TO HEX
560 HXSTRG$ = "0123456789ABCDEF":LN = 0:NBR$ = ""
570 LN = LN + 1:A = INT (NBR / 16):TEMP$(LN) = MID$ (HXSTRG$,NBR - 16 * A + 1,1):NBR = A: ON NBR > 0 GOTO 0570: FOR I = LN TO 1 STEP - 1:NBR$ = NBR$ + TEMP$(I): NEXT
580 RETURN : REM
590 REM HEX TO DEC
600 IF NBR$ = "" THEN NBR$ = "0"
610 NBR = 0: FOR I = 1 TO LEN (NBR$):A = ASC ( MID$ (NBR$,I,1)) - 48: IF A > 9 THEN A = A - 7
620 NBR = 16 * NBR + A: NEXT
630 RETURN : REM
640 POKE 216,0: TEXT : HOME : VTAB 8: PRINT "ERROR "; PEEK (222);" ENCOUNTERED IN LINE "; PEEK (218) + PEEK (219) * 256: PRINT : PRINT "PRESS ANY KEY TO PROCEED ";: GET IN$: GOTO 100