§ Код программы

1SCREEN 13
2
3DrawGrid
4DrawText
5
6cx% = 0: cy% = 0
7dx% = 0: dy% = 0
8
9LOCATE 2, 19: PRINT "S-Save font.bin"
10LOCATE 3, 19: PRINT "L-Load font.bin"
11
12mode = 1
13
14DO
15
16  UpdateGrid cx%, cy%, 1
17  IF mode = 0 THEN SetGrid dx%, dy%, 15
18
19  DO: i$ = INKEY$: LOOP WHILE i$ = ""
20
21  lf = 0: rt = 0: up = 0: dn = 0
22  IF i$ = CHR$(0) + "K" THEN lf = 1
23  IF i$ = CHR$(0) + "M" THEN rt = 1
24  IF i$ = CHR$(0) + "H" THEN up = 1
25  IF i$ = CHR$(0) + "P" THEN dn = 1
26  IF i$ = "s" OR i$ = "S" THEN SaveFont
27  ' MODE = 0: Draw 8x8 Block
28  IF mode = 0 THEN
29
30    SetGrid dx%, dy%, 8
31
32    IF lf AND dx% > 0 THEN dx% = dx% - 1
33    IF rt AND dx% < 7 THEN dx% = dx% + 1
34    IF up AND dy% > 0 THEN dy% = dy% - 1
35    IF dn AND dy% < 7 THEN dy% = dy% + 1
36
37    IF i$ = CHR$(27) THEN mode = 1: i$ = ""
38
39    ' Swap color
40    IF i$ = " " THEN
41
42      ax = 8 + 8 * cx% + dx%
43      ay = 80 + 8 * cy% + dy%
44      n = POINT(ax, ay)
45      k = n <> 8 AND n <> 0
46      IF k THEN c = 8 ELSE c = 15
47      PSET (ax, ay), c
48
49    END IF
50
51  ELSE
52
53    UpdateGrid cx%, cy%, 0
54
55    IF lf AND cx% > 0 THEN cx% = cx% - 1
56    IF rt AND cx% < 31 THEN cx% = cx% + 1
57    IF up AND cy% > 0 THEN cy% = cy% - 1
58    IF dn AND cy% < 7 THEN cy% = cy% + 1
59
60    IF i$ = CHR$(13) THEN mode = 0: i$ = ""
61
62  END IF
63
64LOOP UNTIL i$ = CHR$(27) AND mode = 1
65
66SUB DrawGrid
67
68  ox = 8
69  oy = 8
70
71  FOR y = 0 TO 7
72  FOR x = 0 TO 7
73    LINE (ox + 8 * x, oy + 8 * y)-(ox + 8 * x + 8, oy + 8 * y + 8), 8, B
74  NEXT
75  NEXT
76
77END SUB
78
79SUB DrawText
80
81  COLOR 7
82  FOR y = 1 TO 7
83  FOR x = 0 TO 31
84    LOCATE 10 + y, x + 2: PRINT CHR$(x + 32 * y);
85  NEXT
86  NEXT
87
88END SUB
89
90SUB SaveFont
91
92OPEN "font.bin" FOR OUTPUT AS #1
93FOR i = 0 TO 255: PRINT #1, CHR$(0); : NEXT
94FOR y = 0 TO 6
95FOR x = 0 TO 31
96FOR i = 0 TO 7
97t = 0
98FOR j = 0 TO 7
99
100  n = POINT(8 + x * 8 + j, 80 + y * 8 + i)
101  k = n <> 8 AND n <> 0
102  t = t * 2
103  IF k THEN t = t + 1
104
105NEXT
106PRINT #1, CHR$(t);
107NEXT
108NEXT
109NEXT
110CLOSE #1
111END SUB
112
113SUB SetGrid (x%, y%, c)
114  LINE (8 + x% * 8, 8 + y% * 8)-(8 + x% * 8 + 8, 8 + y% * 8 + 8), c, B
115END SUB
116
117SUB UpdateGrid (x%, y%, t%)
118
119  ox = 8
120  oy = 80
121
122  FOR i = 0 TO 7
123  FOR j = 0 TO 7
124
125    ax = ox + j + x% * 8
126    ay = oy + i + y% * 8
127    a = POINT(ax, ay)
128    k = (a <> 8) AND (a <> 0)
129
130    IF k THEN c = 7 ELSE c = 0
131
132    IF t% > 0 THEN
133      IF k THEN B = 15 ELSE B = 8
134    ELSE
135      IF k THEN B = 7 ELSE B = 0
136    END IF
137
138    PSET (ax, ay), B
139
140    LINE (8 + 8 * j + 1, 8 + 8 * i + 1)-(8 + 8 * j + 7, 8 + 8 * i + 7), c, BF
141
142  NEXT
143  NEXT
144
145END SUB