prozap/source/MONITOR.UTILITY

154 lines
7.2 KiB
Plaintext
Raw Normal View History

2020-11-09 13:58:46 +00:00
10 REM
MONITOR UTILITY BY VAL J GOLDING
WITH GREG KIELIAN AND
DAVID SPARKS
* A.P.P.L.E. : FEB 14, 1984 *
100 REM
INITIALIZE
110 B1 = PEEK (49002):B2 = PEEK (49003):D$ = CHR$ (4)
120 ASFLAG = 39084:BUF = 39086:HEXDUMP = 38656:DISASSEMBLY = 38794:FIND = 38957:SAFEGUARD = 39050: TEXT : HOME : GOSUB 4000
130 TEXT : HOME : INVERSE : FOR I = 1 TO 41: PRINT " ";: NEXT : HTAB 40 : PRINT " ";: HTAB 10: NORMAL
132 PRINT "MONITOR DUMP UTILITY";
134 INVERSE : HTAB 40: PRINT " ";: HTAB 40: FOR I = 1 TO 41: PRINT " ";: NEXT : NORMAL : PRINT : POKE 34,5
140 REM &INSTALLATION MODULE
200 REM
MENUS
210 HF$ = "": HOME : PRINT : HTAB 5: PRINT "OPTIONS [A] ASCII/HEX DUMP" : HTAB 14: PRINT "[H] HEX DUMP ONLY": HTAB 14: PRINT "[D] DISASSEMBLY": HTAB 14: PRINT "[E] ENTER MONITOR"
220 HTAB 14: PRINT "[F] FIND 2 HEX BYTES": HTAB 14: PRINT "[C] CHARACTER SEARCH": HTAB 14: PRINT "[Q] QUIT": HTAB 18: INVERSE : PRINT " SELECT ": NORMAL
230 VTAB PEEK (37): HTAB 15: GET IN$: PRINT IN$: IF IN$ = "D" THEN D = 1
240 IF IN$ = "F" THEN D = - 1
250 POKE ASFLAG,0: IF IN$ = "H" THEN IN$ = "A": POKE ASFLAG,1
260 ON IN$ = "E" GOTO 1500: ON IN$ = "Q" GOTO 2050: ON IN$ = CHR$ (13) GOTO 210
270 PRINT : HTAB 5: PRINT " OUTPUT [D] DISK": HTAB 14: PRINT "[P] PRINTER": HTAB 14: PRINT "[V] VIDEO": HTAB 18: INVERSE : PRINT " SELECT": NORMAL
280 VTAB PEEK (37): HTAB 15: GET OUT$: IF OUT$ = CHR$ (13) THEN OUT$ = "V": REM
285 PRINT OUT$:VT = PEEK (37): TEXT : VTAB VT + 1
400 REM
GET HEX ADDRESSES
410 PRINT : INPUT "HEX START ADDRESS? : ";H$
420 H$ = RIGHT$ ("0000" + H$,4)
430 H$ = "1A:" + RIGHT$ (H$,2) + " " + LEFT$ (H$,2) + " "
440 INPUT "HEX END ADDRESS? : ";HX$
450 HX$ = RIGHT$ ("0000" + HX$,4)
460 IF IN$ = "C" THEN PRINT "ASCII/NEG ASCII (A/N) : ";: GET AS$: PRINT AS$: INPUT "ENTER 2 ASCII CHRS : ";AF$: ON LEN (AF$) < > 2 GOTO 130:AS(2) = ASC ( LEFT$ (AF$,1)):AS(1) = ASC ( RIGHT$ (AF$,1)): IF AS$ = "N" THEN AS(2) = AS(2) + 128:AS(1) = AS(1) + 128: GOTO 1110
470 IF AS$ = "A" THEN 1110
480 IF D = - 1 THEN INPUT "SEARCH BYTES, HOB 1ST : ";HF$
490 IF D = - 1 THEN IF LEN (HF$) < 4 THEN HF$ = "0" + HF$: GOTO 490
500 AS$ = "":H$ = H$ + RIGHT$ (HX$,2) + " " + LEFT$ (HX$,2)
510 IF D = - 1 THEN H$ = H$ + " N 98AE:" + RIGHT$ (HF$,2) + " " + LEFT$ (HF$,2)
520 H$ = H$ + " N D9C6G": GOSUB 1000: REM
600 REM
INITIALIZE OUTPUT ROUTINES
610 ON OUT$ = "D" GOSUB 3000: ON OUT$ = "P" GOSUB 2500
620 IF LEN (AF$) THEN PRINT "HEX= ";
630 REM
SELECT OUTPUT MODULE
640 IF D < 0 THEN 900: REM ADDRESS FIND FLAG
650 IF D > 0 THEN 1200: REM DISASSEMBLY FLAG
660 REM
FALL THROUGH TO HEX/ASCII
700 REM
HEX/ASCII
710 CALL HEXDUMP: PRINT
720 IF OUT$ < > "D" THEN PRINT : GOTO 2000
730 REM
HAVE TO SET UP AGAIN
TO WRITE TO DISK
740 GOSUB 1000: REM TO RESTORE ADDRESSES
750 PRINT D$;"WRITE";F2$: REM ACTIVATE DISK
760 IF PEEK (ASFLAG) THEN PRINT "CALL-151";: REM TO EXEC THE FILE LATER
770 CALL HEXDUMP: REM A SECOND TIME
780 IF PEEK (ASFLAG) THEN PRINT : PRINT "3D0G": REM TO EXEC THE FILE LATER
790 PRINT D$: PRINT : GOTO 2000: REM &EXITROUTINE
900 REM
ADDRESS FIND
910 POKE FIND + 1,174 * (IN$ = "C") + 175 * (IN$ = "F"): POKE FIND + 4, 175 * (IN$ = "C") + 174 * (IN$ = "F")
920 CALL FIND: PRINT
930 IF OUT$ < > "D" THEN 2000
940 GOSUB 1000
950 PRINT D$;"WRITE";F2$
960 CALL FIND
970 PRINT : GOTO 2000: REM
1000 REM
STUFF HEX ADDRESSES INTO MEMORY
1010 FOR I = 1 TO LEN (H$): POKE 511 + I, ASC ( MID$ (H$,I,1)) + 128: NEXT : POKE 72,0: CALL - 144: RETURN : REM
1100 REM
CONVERT ASCII CHRS INTO HEX BYTES
1110 HEX$ = "0123456789ABCDEF": FOR I = 1 TO 2:ZZ$(I) = MID$ (HEX$, INT(AS(I) / 16) + 1,1) + MID$ (HEX$,AS(I) - INT (AS(I) / 16) * 16 + 1,1):HF$ = HF$ + ZZ$(I): NEXT :D = - 1: GOTO 500: REM
1200 REM
DISASSEMBLER MODULE
1210 CALL DISASSEMBLY STR$ A$: PRINT A$: ON PEEK (26) + PEEK (27) * 256 < = PEEK (28) + PEEK (29) * 256 GOTO 1210
1220 PRINT : IF OUT$ < > "D" THEN 2000
1230 GOSUB 1000
1240 CALL DISASSEMBLY STR$ A$: PRINT D$;"WRITE";F2$: PRINT A$: PRINT D$ : ON PEEK (26) + PEEK (27) * 256 < = PEEK (28) + PEEK (29) * 256 GOTO 1240
1250 PRINT : GOTO 2000: REM
1500 REM
ENTER MONITOR COMMANDS
1510 H$ = "": TEXT : HOME : PRINT "*";: CALL 64879: FOR I = 1 TO 239:CHR = PEEK (511 + I): IF CHR = 141 THEN 1530
1520 H$ = H$ + CHR$ (CHR - 128): NEXT
1530 H$ = H$ + " ND9C6G": GOSUB 1000: PRINT : PRINT :H$ = "": GOTO 2030: REM
2000 REM
EXIT ROUTINES
2010 IF PR THEN PRINT D$"PR#0"
2020 IF OUT$ = "D" THEN PRINT D$"CLOSE"
2030 PRINT "RETURN TO MENU (Y/N) ? ";: GET A$: PRINT A$: PRINT : ON A$ = "N" GOTO 2050: POKE ASFLAG,0:D = 0
2040 GOTO 130
2050 GOTO 5000: REM
2500 REM
PRINTER ROUTINES
2510 IF NOT PR THEN PRINT : PRINT "ENTER PRINTER SLOT": PRINT "OR DRIVER ADDRESS (DECIMAL):";: INPUT " ";PR$:PR = VAL (PR$): IF NOT PR THEN RETURN
2520 ON PR < 8 GOTO 2530: PRINT D$;"PR#,A";PR: RETURN : REM NEW PRODOS WAY TO ATTACH SPECIAL PRINTER DRIVERS
2530 PRINT D$"PR#"PR: RETURN : REM &REGULAR SLOT
3000 REM
OPEN DISK FILE
3010 PRINT : INPUT "PATHNAME FOR OUTPUT FILE: ";F2$: IF F2$ = "" THEN OUT$ = "V": RETURN : REM GIVE USER A CHANCE TO GET OUT
3020 PRINT D$;"OPEN";F2$: REM &&EACH OUTPUT MODULE SETS THE FILE&TO WRITE AT THE RIGHT TIME.&
3030 RETURN : REM
4000 REM
INSTALL MACHINE CODE IN MEMORY
4020 VTAB 7: PRINT : HTAB 10: INVERSE : PRINT " STAND BY... ": HTAB 10: PRINT " INSTALLING MACHINE ": HTAB 10: PRINT " CODE AT $9700": NORMAL
4030 FOR X = 0 TO 421: READ X1: POKE HEXDUMP + X,X1: NEXT
4040 CALL SAFEGUARD
4050 RETURN : REM
5000 REM
DISCONNECT MACHINE CODE AND
RETURN ALL MEMORY TO SYSTEM
5010 POKE 49002,B1: POKE 49003,B2: CALL 48888
5020 PRINT D$;"CLOSE"
5040 TEXT : VTAB 22: CALL - 958: PRINT D$"RUNSTARTUP": REM
6000 REM
DATA STATEMENTS CONTAIN
MACHINE CODE AT $9700
6010 DATA 164,27,166,26,169,141,32,237,253,32,64,249,160,0,140,171,152,162,7,169,186,32,237,253,169,160,32,237,253,177,26,157,174,152,202,32,218,253,165,26
6020 DATA 197,28,165,27,229,29,144,5,238,171,152,208,12,230,26,208,2,230,27,165,26,41,7,208,215,138,48,17,169,160,32,237,253,32,237,253,32,237,253,157
6030 DATA 174,152,202,16,241,169,160,32,237,253,162,7,173,172,152,208,32,189,174,152,9,128,201,160,176,17,201,128,240,11,41,127,44,30,192,16,6,9,64,208
6040 DATA 2,169,174,32,237,253,202,16,224,173,171,152,208,3,76,0,151,96,169,228,32,192,222,32,227,223,32,108,221,141,163,152,140,164,152,165,54,141,165,152
6050 DATA 165,55,141,166,152,173,48,190,141,167,152,173,49,190,141,168,152,169,16,141,48,190,169,152,141,49,190,165,26,133,58,165,27,133,59,169,0,141,173,152
6060 DATA 32,208,248,32,83,249,133,26,132,27,169,141,76,237,253,173,163,152,133,131,173,164,152,133,132,173,165,152,133,54,173,166,152,133,55,173,167,152,141,48
6070 DATA 190,173,168,152,141,49,190,104,104,160,0,173,173,152,145,131,200,169,174,145,131,200,169,152,145,131,174,169,152,169,141,96,142,169,152,41,127,201,13,208
6080 DATA 7,173,173,152,208,185,240,9,174,173,152,157,174,152,238,173,152,174,169,152,96,172,175,152,174,174,152,32,64,249,169,186,32,237,253,169,141,32,237,253
6090 DATA 169,0,141,170,152,160,0,177,26,205,174,152,208,23,200,177,26,205,175,152,208,15,164,27,166,26,169,160,32,237,253,32,64,249,238,170,152,165,26,197
6100 DATA 28,165,27,229,29,144,6,169,141,32,237,253,96,230,26,208,2,230,27,173,170,152,201,15,144,195,169,141,32,237,253,56,176,182,169,3,32,245,190,144
6110 DATA 1,0,169,1,13,106,191,141,106,191,169,192,13,107,191,141,107,191,96,0,0,0,0,0,0,0,0,0,0,0,27,166,26,169,160,32,237,253,32,64