rem ascii.bas

grmode= 0

if programarg$ (1) = "g" then grmode= not 0

if peek16 (sysvarptr) = 0 then if grmode then mode 10 else else grmode= not 0

print

if not grmode then goto no_control

for i= 0 to 31
	if i mod 8 = 0 then print
	print hex$(i, 2); "="; chr$ (1); chr$ (i);
	if i mod 8 <> 7 then print " ";
next

label no_control

FOR i= 32 TO 255
	if not grmode and i = &80 then i= &A0
	if i mod 8 = 0 then print: if i= 128 and grmode then get a$
	print hex$(i); "="; chr$ (i);
	if i mod 8 <> 7 then print " ";
next

print
if grmode then get a$
print

if not grmode then goto no_control2

for i= 0 to 31
	print chr$ (1); chr$ (i);
next

label no_control2

for i= 32 to 255
	if not grmode and i = &80 then i= &A0
	' Force cursor legal position, so that the following
	' pos test can work.
	' The finality of this is to keep the lines without
	' spacing in a 32 char width window (spectrum mode,
	' for example).
	if grmode then print chr$ (16);
	if i mod 32 = 0 then if pos (#0) > 1 then print
	print chr$ (i);
next

print: print

if grmode then get a$

end
