[fa.info-mac] MS-BASIC program to get Fromhex on a Macintosh

info-mac@uw-beaver (info-mac) (08/03/84)

From: Dale Carstensen C-3 <dlc@lanl>
The following program converts a "fromhex.dl" file to a "resource".  I can
also provide "fromhex.dl" and/or "fromhex.rc" if that is necessary for you.

60 REM This Microsoft BASIC program converts "fromhex.dl" into a "resource".
70 REM Change the name of the fromhex download file to "C", run this program,
80 REM and a file named "C prog" will appear (with no icon!).  Change the
90 REM name of the "C prog" file to "fromhex", and you're ready to convert
100 REM qprint, macmelody, etc. in a similar fashion.  (from "C" to "C prog").
110 OPEN "C" AS #1 LEN=67
120 FIELD #1, 1 AS DUM$, 66 AS L$
130 GET #1,  1
140 L1$=L$
150 BSTR=1:ESTR=8:GOSUB 1000:OFFDATA=A
160 BSTR=9:ESTR=16:GOSUB 1000:OFFMAP=A
170 B=(OFFMAP + 24)*2:GOSUB 1100
180 GOSUB 1200:TYPLST=A
190 B=(OFFMAP+TYPLST)*2:GOSUB 1100
200 GOSUB 1200:NUMTYP=A+1
210 C=C+4
220 IF NUMTYP<>0 THEN GOTO 240
230 PRINT"No CODE resource":CLOSE #1: END
240 IF MID$(L1$,C,8) = "DCDODDDE" THEN GOTO 260
250 NUMTYP=NUMTYP - 1:C=C+16:GOTO 220
260 C=C+8:GOSUB 1200:NUMRES=A+1
270 C=C+4:GOSUB 1200
280 B=(OFFMAP+TYPLST+A)*2:GOSUB 1100
290 IF NUMRES <> 0 THEN  GOTO 310
300 PRINT"No purgeable, locked, preload CODE": CLOSE #1:END
310 GOSUB 1200
330 IF A=1 THEN GOTO 350
340 C=C+24:NUMRES=NUMRES-1:GOTO 290
350 C=C+12:GOSUB 1200:SCODE=A+8
360 B=(OFFDATA+A)*2:GOSUB 1100
370 C=C+4:GOSUB 1200:LCODE=A
380 C=C+8:GOSUB 1200:NLONGR=A+1
390 C=C+4:GOSUB 1200
400 IF A = &H602C THEN GOTO 420
410 PRINT "Bad crtmac.s": CLOSE #1: END
420 I=0:L1$=""
430 B=(OFFDATA + SCODE) * 2: C=(B MOD 66) + 1: B = INT(B/66) + 1
450 GET #1,B
455 H%=0:L%=0:J=0:N=0:W=0:  REM reference all future variables!
457 DIM CODE%(LCODE/2)
460 CODE%(0)=0:CP=VARPTR(CODE%(0))
470 H%=(ASC(MID$(L$,C,1))-64)*16
480 C=C+1
490 IF C = 67 THEN GET #1: C=1
500 L%=ASC(MID$(L$,C,1))-64
510 POKE CP+I,H%+L%
520 I=I+1:C=C+1
530 IF I=LCODE THEN GOTO 560
540 IF C = 67 THEN GET #1: C=1
550 GOTO 470
560 CALL CP: REM From 565 to 680 is a vestige -- crtmac does relocation!
565 CLOSE #1:I=4
570 J=PEEK(CP+I)*256 + PEEK(CP+I+1)
580 N=PEEK(CP+J)
590 POKE CP+J,0
600 W=PEEK(CP+J+2)*256 + PEEK(CP+J+3) + CP
610 POKE CP+J+1, INT(W/65536!): W=W - 65536!*INT(W/65536!)
620 POKE CP+J+2, INT(W/256): W=W - 256*INT(W/256)
630 POKE CP+J+3, W
640 IF (N > 0) AND (N < 255)  THEN J=J+2*N: GOTO 580
650 IF N = 255 THEN GOTO 680
660 I = I+4:  NLONGR = NLONGR - 1
670 IF NLONGR > 0 THEN GOTO 570
680 CALL CP:END
1000 A = 0
1010 A = A * 16 + ASC(MID$(L1$,BSTR,1)) - 64
1020 BSTR=BSTR + 1
1030 IF BSTR <= ESTR THEN GOTO 1010
1040 RETURN
1100 C = (B MOD 66) + 1
1110 B = INT(B/66) + 1
1120 GET #1, B
1130 L1$=L$
1140 GET #1
1150 L1$ = L1$ + L$
1160 RETURN
1200 BSTR = C
1210 ESTR = C + 3
1220 GOSUB 1000
1230 RETURN