-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstereo.exw
86 lines (70 loc) · 2.02 KB
/
stereo.exw
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
-- Random Dot Stereo Pictures
-- Like the ones you've seen in all the shopping malls!
-- Relax your eyes so that you are focusing a few inches
-- behind the screen - maybe on your reflection if you have
-- a lot of glare. You should see 2 letters of the alphabet,
-- one upper case, one lower case.
-- usage: ex stereo [filename]
-- (will read PICTURE file by default)
-- picture can contain digits from 1 to 9 to indicate "depth"
without type_check
-- include graphics.e
include dos_rescue.e as dos_rescue
constant DEPTH = 13
sequence vc
integer xpixels_per_char, ypixels_per_char, in_file
procedure gstereo()
object input
sequence image, row, line
integer index, height, w
image = {}
while 1 do
input = gets(in_file)
if atom(input) then
exit
end if
image = append(image, repeat(' ', DEPTH) & input)
end while
w = DEPTH * xpixels_per_char
for y = 0 to (length(image)-1)*ypixels_per_char do
line = image[floor(y/ypixels_per_char+1)]
row = repeat(0, (length(image[1])-1)*xpixels_per_char)
row[1..w] = rand(repeat(vc[VC_NCOLORS], w))-1
for x = w + 1 to length(row) do
height = line[x/xpixels_per_char+1]
index = x - w
if height >= '0' then
if height <= '9' then
index += (height - '0') * xpixels_per_char
end if
end if
row[x] = row[index]
end for
pixel(row, {0, y})
end for
end procedure
if dos_rescue:graphics_mode(18) then
puts(2, "need VGA graphics\n")
abort(1)
end if
sequence cmd, file_name
cmd = command_line()
if length(cmd) >= 3 then
file_name = cmd[3]
else
file_name = "picture"
end if
in_file = open(file_name, "r")
if in_file = -1 then
printf(1, "Can't open %s\n", {file_name})
abort(1)
end if
dos_rescue:clear_screen()
vc = dos_rescue:video_config()
xpixels_per_char = floor(vc[VC_XPIXELS]/80)
ypixels_per_char = floor(vc[VC_YPIXELS]/25)
gstereo()
while dos_rescue:get_key() = -1 do
end while
if dos_rescue:graphics_mode(-1) then
end if