§ Экран

Просто для интереса. Было интересно и увлекательно сделать на Quick Basic 4.5 такой экран.

А также скачать пример экрана SCREEN.SCR.

§ Код

1SCREEN 13
2
3DIM scr AS STRING * 6912
4DIM dc(192) AS INTEGER
5
6' Colormap
7DATA 0,0,0
8DATA 0,0,1
9DATA 1,0,0
10DATA 1,0,1
11DATA 0,1,0
12DATA 0,1,1
13DATA 1,1,0
14DATA 1,1,1
15
16' Make palette
17FOR i = 0 TO 7
18
19  READ r, g, b
20
21  ' 0-7
22  OUT 968, i
23  OUT 969, r * 48: OUT 969, g * 48: OUT 969, b * 48
24
25  ' 8-15
26  OUT 968, i + 8
27  OUT 969, r * 63: OUT 969, g * 63: OUT 969, b * 63
28
29NEXT
30
31' Make Y-coord
32FOR y = 0 TO 191
33
34  ' Read char data
35  ' 2048 | 256 |  32 | X=1
36  '  7:6 | 2:0 | 5:3 | 4:0
37
38  a = (y \ 8) AND 7
39  b = y AND 7
40  c = y \ 64
41  dc(y) = 32 * a + 256 * b + 2048 * c
42
43NEXT
44
45' Read binary screen data to memory
46OPEN "SCREEN.SCR" FOR BINARY AS #1: GET #1, , scr: CLOSE #1
47
48' Render
49FOR y = 0 TO 191
50FOR x = 0 TO 255 STEP 8
51
52  a = x \ 8
53  b = y \ 8
54  ch = ASC(MID$(scr, 1 + a + dc(y), 1))
55
56  ' Read attr data
57  attr = ASC(MID$(scr, 1 + 6144 + a + b * 32))
58
59  fr = attr AND 7        ' Fore
60  bg = (attr \ 8) AND 7  ' Back
61  br = (attr AND 64) \ 8 ' Bright
62  bl = attr AND 128      ' Blink
63
64  FOR i = 0 TO 7
65
66    IF ch AND 128 THEN cl = fr ELSE cl = bg
67    PSET (32 + x + i, y), cl + br
68    ch = ch * 2
69
70  NEXT
71
72NEXT
73NEXT