Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hex Reader for Telehack
10 REM HEXREAD.BAS BY TECHMAGE@TELEHACK.COM
20 PRINT "STARTING ADDRESS (DEC)";
21 INPUT A: REM STARTING ADDRESS (DECIMAL)
25 PRINT "DATA PER LINE";
26 INPUT L: REM LINE LENGTH
30 PRINT "LINES PER PAGE";
31 INPUT P: REM PAGE LENGTH
35 DIM D(L): REM DATA ARRAY
40 AC=A: REM CURRENT ADDRESS (INCREMENTS)
50 REM *** BEGIN PAGE LOOP ***
55 FOR IA=1 TO P
60 GOSUB 100
65 GOSUB 200
70 GOSUB 300
75 GOSUB 400
80 AC=AC+L
83 PRINT: REM NEW LINE
85 NEXT
90 GOSUB 500
95 GOTO 600
100 REM *** GET DATA ARRAY ***
105 FOR IB=1 TO L
110 D(IB)=PEEK(AC+(IB-1))
115 NEXT
120 RETURN
125 D=PEEK(AC)
130 PRINT HEX$(D);" ";
200 REM *** PRINT ADDRESS ***
205 FOR J=1 TO 8-LEN(HEX$(AC))
210 PRINT "0";
215 NEXT
220 PRINT HEX$(AC);" ";
225 RETURN
300 REM *** PRINT HEX DATA ***
305 FOR IC=1 TO L
310 H$=HEX$(D(IC))
315 IF LEN(H$)=1 THEN PRINT "0"+H$+" ";
320 IF LEN(H$)>1 THEN PRINT H$+" ";
325 NEXT
330 RETURN
400 REM *** PRINT ASCII DATA ***
405 FOR ID=1 TO L
410 IF D(ID)>=32 AND D(ID)<=126 THEN PRINT CHR$(D(ID));
415 IF D(ID)<32 OR D(ID)>126 THEN PRINT ".";
420 NEXT
425 RETURN
500 REM *** PRINT PAGE FOOTER ***
505 PRINT "---0x";HEX$(AC-(L*P));"/0x";HEX$(AC-1);"---------"
600 PRINT "CONTINUE";
605 INPUT C$: REM CONTINUE? RESPONSE
610 IF C$="Y" OR C$="y" THEN GOTO 55
615 END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment