-
Notifications
You must be signed in to change notification settings - Fork 0
/
GRAPH.BAS
125 lines (100 loc) · 1.71 KB
/
GRAPH.BAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
DECLARE SUB setPalette (pal() AS ANY)
DECLARE SUB grpPalette ()
DECLARE SUB getPalette (pal() AS ANY)
'intpixel type
TYPE IntPixel
r AS INTEGER
g AS INTEGER
b AS INTEGER
END TYPE
'function declarations
DECLARE FUNCTION crc (a AS INTEGER)
DECLARE FUNCTION nospc$ (s$)
'config
OPTION BASE 0
DIM SHARED pal(256) AS IntPixel
'start
CLS
COLOR 15
PRINT "File Graph"
COLOR 7
PRINT "----------"
PRINT
'details
COLOR 14
INPUT "File name"; fsrc$
INPUT "Point gap [10]"; xGap%
IF xGap% < 1 THEN xGap% = 1
IF xGap% > 319 THEN xGap% = 319
INPUT "Time gap [.5]"; tGap!
IF tGap! < 0 THEN tGap! = 0
'show
SCREEN 13
getPalette pal()
grpPalette
OPEN "B", #1, fsrc$
length& = LOF(1)
SEEK #1, 1
'prepare
x% = 0
LINE (0, 0)-(0, 0), 1
FOR i& = 1 TO length&
'input
k$ = INKEY$
IF k$ = CHR$(27) THEN EXIT FOR
IF k$ <> "" THEN
CLS
x% = 0
LINE (0, 0)-(0, 0), 1
END IF
'display
byte% = ASC(INPUT$(1, #1))
y% = 5 + INT(.7 * (255 - byte%))
LINE -(x%, y%), byte%
SOUND 21000, tGap!
x% = x% + xGap%
'edge case
IF (x% > 319) THEN
x% = 0
LINE (0, 0)-(0, 0), 1
END IF
NEXT
'end
setPalette pal()
CLOSE #1
SCREEN 1
SYSTEM
FUNCTION crc (a AS INTEGER)
IF (a < 0) THEN crc = 0 ELSE crc = a
END FUNCTION
SUB getPalette (pal() AS IntPixel)
OUT &H3C7, 0
FOR i% = 0 TO 255
pal(i%).r = INP(&H3C9)
pal(i%).g = INP(&H3C9)
pal(i%).b = INP(&H3C9)
NEXT
END SUB
SUB grpPalette
OUT &H3C8, 0
FOR i% = 0 TO 255
OUT &H3C9, (i% \ 64) * 16
OUT &H3C9, ((i% \ 8) AND 7) * 8
OUT &H3C9, (i% AND 7) * 8
NEXT
END SUB
FUNCTION nospc$ (s$)
FOR i = 1 TO LEN(s$)
a$ = MID$(s$, i, 1)
IF (a$ <> " ") THEN b$ = b$ + a$
NEXT
nospc$ = b$
END FUNCTION
SUB setPalette (pal() AS IntPixel)
OUT &H3C8, 0
FOR i% = 0 TO 255
OUT &H3C9, pal(i%).r
OUT &H3C9, pal(i%).g
OUT &H3C9, pal(i%).b
NEXT
END SUB