Code: Select all
#define GFX
const CHAR_HEIGHT = 8 ' 8|14|16
data "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "tab", "lf"
data "vt", "np", "cr", "so", "si", "dle", "dc1", "dc2", "dc3", "dc4", "nak"
data "syn", "etb", "can", "em", "eof" ,"esc", "fs", "gs", "rs", "us"
sub putstring(x as integer, y as integer, s as string, c as integer)
#ifdef GFX
dim as integer h: screeninfo , h
dim as integer rows = hiword(width())
draw string (x*8, y*(h\rows)), s, c
#else
for i as integer = 1 to len(s)
if asc(s, i) < 32 then
select case asc(s, i)
case 7, 8
c = 12
mid(s, i, 1) = " "
case 0, 9, 10, 13', 26
c = 9
mid(s, i, 1) = " "
end select
end if
next i
color c
locate y+1, x+1
print s;
#endif
end sub
dim as string altname(0 to 31)
for i as integer = 0 to 31
read altname(i)
next i
#ifdef GFX
screenres 80*8, 35*CHAR_HEIGHT
windowtitle "8*" & CHAR_HEIGHT & " ASCII codes"
#endif
width 80, 35
for c as integer = 0 to 255
dim as string s = right("00" & c, 3) & " "
dim as integer x, y
dim as integer i = c
select case i
case 0 to 31
y = i mod 16
x = (i \ 16) * 14
select case altname(c)
'case "nul", "tab", "lf", "cr", "eof"
' s &= " (" & altname(c) & ")"
'case "bel", "bs"
' s &= " (" & altname(c) & ")"
case else
s &= chr(c) & " (" & altname(c) & ")"
end select
case 32 to 47
i -= 32
y = i mod 16
x = 28 '14*2 + (i \ 16) * 9
if c = 32 then
s &= "sp"
else
s &= chr(c)
end if
case 48 to 127
i -= 48
y = i mod 16
x = 14*2 + 1*9 + (i \ 16) * 8
s &= chr(c)
case 128 to 157 '128+15*2-1
i -= 128
y = i mod 15: y += 16 + 2
x = 2 + (i \ 15) * 8
s &= chr(c)
case 158 to 255
i -= 158
y = i mod 14: y += 16 + 2
x = 2 + 8*2 + (i \ 14) * 8
s &= chr(c)
end select
putstring(x+3, y+1, s, 7)
next c
putstring(17, 0, "Regular ASCII Chart (character codes 0 - 127)", 15)
putstring(16, 1+16+1, "Extended ASCII Chart (character codes 128 - 255)", 15)
putstring(0, 1 + 16 + 2 + 15, "", 7)
sleep
- The text mode can't print chr(7) or chr(8) (bell and backspace), instead either beeping or deleting. So instead of printing the char I change it to a space instead, and mark those entries as red.
- QB replaces some characters (0, 9, 10, 13, 26 - nul, tab, lf, cr, eof) with a space. I do the same in text mode (except for eof, which prints fine in FB) and mark them as blue.
- In gfx mode, I just "Draw String" all the characters, knowing it's not going to beep or do anything funny with the cursor. The result is pretty much the same as QB, except some characters have different glyphs (and eof is printed).