summaryrefslogtreecommitdiff
path: root/themes/openSUSE/src/bsplash.inc
blob: bdf9abda1fcfd962a897520309b77cece7a7e92a (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Boot loader splash code.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Some global vars.

/.b_init	 0 def
/.b_done	 1 def
/.b_run		 2 def

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Init splash.
%
% ( ) ==> ( )
%
/bsplash.init {
  /bsplash.list [
    config.welcome 2 eq { [ /b1.init /b1.done /b1.run ] } if
    [ /b2.init /b2.done /b2.run ]
  ] def

  bsplash.list { dup .b_init get exec } forall
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Free splash memory.
%
% ( ) ==> ( )
%
/bsplash.free {
  bsplash.list { dup .b_done get exec } forall
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Show boot loader splash.
%
% ( ) ==> ( )
%
/bsplash.show {
  currentimage

  % "/boot/i386/loader/xxx" chdir

  "welcome.jpg" findfile /splash.file over def setimage

  0 0 moveto 0 0 image.size image

  % "/boot/i386/loader" chdir

  bsplash.init

  bsplash.skip not { 100000 usleep } if

  bsplash.skip not {
    {
      0 usleep
      bsplash.skip { exit } if
      bsplash.run { exit } if
    } loop
  } if

  bsplash.free

  setimage

  /splash.file xfree

} def


% Run splash animations. Return 'true' when done.
%
% ( ) ==> ( true|false )
%
/bsplash.run {
  true

  bsplash.list { dup .b_run get exec and } forall
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Just wait.
%
% ( ) ==> ( )
%
/bsplash.done {
  bsplash.skip not {
    1500000 usleep
  } if
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Check if we should skip the intro.
%
% ( ) ==> ( true|false )
%
/bsplash.skip {
  % any key pressed?
  getkey 0xffff and {
    /bsplash.skip true def
    true
  } {
    false
  } ifelse
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Init.
%
% ( array ) ==> ( )
%
/b1.init {
  pop

  /b1_ok false def

  /b1_cd "cd.jpg" readimage def
  /b1_cd_mask "cd_a.jpg" readimage def

  b1_cd .undef eq b1_cd_mask .undef eq or { return } if

  /b1_cd_tmp b1_cd imgsize 0 0 moveto savescreen def

  20 350 moveto
  /b1_orig 300 150 savescreen def
  /b1_buf 300 150 savescreen def

  /b1_idx 0 def
  /b1_steps 20 def

  /b1_ok true def
} def


/b1_x [ 0  2  6 15 25 37 51 67 83 98 113 125 136 144 148 150 ] def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Cleanup.
%
% ( array ) ==> ( )
%
/b1.done {
  pop

  b1_ok not { return } if

  /b1_cd xfree
  /b1_cd_mask xfree
  /b1_cd_tmp xfree

  /b1_orig xfree
  /b1_buf xfree

  /b1_ok false def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Run animation.
%
% Return true when finished.
%
% ( array ) ==> ( true|false )
%
/b1.run {
  pop

  b1_ok not { true return } if

  /b1_idx inc

  b1_idx b1_steps gt { true return } if

  b1_buf b1_orig over length memcpy

  b1_cd_tmp b1_cd_mask over length memcpy
  0 255 b1_idx 20 mul sub 0 max b1_cd_tmp blend

  /b1_dx_cur b1_x b1_idx aget dup .undef eq { pop 150 } if def

  150 0 moveto
  b1_cd b1_cd_tmp b1_buf blend

  150 b1_dx_cur 2 div sub 0 moveto
  b1_cd b1_cd_tmp b1_buf blend

  150 b1_dx_cur sub 0 moveto
  b1_cd b1_cd_tmp b1_buf blend


  20 350 moveto b1_buf restorescreen

  false

} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Init.
%
% ( array ) ==> ( )
%
/b2.init {
  pop

  /b2_ok false def

  /b2_text "text.jpg" readimage def
  % /b2_spot "spotlite.jpg" readimage def

  b2_text .undef eq { return } if

  /b2_text_tmp b2_text imgsize 0 0 moveto savescreen def
  % /b2_spot_tmp b2_spot imgsize 0 0 moveto savescreen def

  560 120 moveto
  /b2_orig b2_text imgsize savescreen def
  /b2_buf b2_text imgsize savescreen def

  /b2_idx 0 def
  /b2_start 10 def
  /b2_steps 20 def

  /b2_ok true def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Cleanup.
%
% ( array ) ==> ( )
%
/b2.done {
  pop

  b2_ok not { return } if

  /b2_text xfree
  /b2_text_tmp xfree

  /b2_orig xfree
  /b2_buf xfree

  /b2_ok false def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Run animation.
%
% Return true when finished.
%
% ( array ) ==> ( true|false )
%
/b2.run {
  pop

  b2_ok not { true return } if

  /b2_idx inc

  b2_idx b2_start b2_steps add gt { true return } if

  b2_idx b2_start lt { false return } if

  b2_buf b2_orig over length memcpy

  b2_text_tmp b2_text over length memcpy
  0 255 b2_idx b2_start sub 20 mul sub 0 max b2_text_tmp blend

  % b2_spot_tmp b2_spot over length memcpy
  % 0 255 b2_idx b2_start sub 20 mul sub 0 max b2_spot_tmp blend

  % 0 0 moveto
  % 0x80ff80 b2_spot_tmp b2_buf blend
  0 0 moveto
  0xffffff b2_text_tmp b2_buf blend

  560 120 moveto b2_buf restorescreen

  false

} def