summaryrefslogtreecommitdiff
path: root/themes/openSUSE/src/bsplash.inc
blob: 62c0f7555cc0f864b3c5f7072819bfc8d45f4c19 (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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Boot loader splash code.
%
% config.welcome: type of welcome animation
%   0: no splash
%   1: 'welcome' texts fade-in
%   2: rolling cd
%   3: light bulb fade-in
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


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

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

/burn time 16 shl 1193180 div 60 div 60 mod { false } { true } ifelse def

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Init splash.
%
% ( ) ==> ( )
%
/bsplash.init {
  /bsplash.list [
    config.welcome 2 le {
      config.welcome 2 eq { [ /b1.init /b1.done /b1.run ] } if
      [ /b2.init /b2.done /b2.run ]
    } if
    config.welcome 3 eq {
      [ /b3.init /b3.done /b3.run ]
      burn { [ /b4.init /b4.done /b4.run ] } if
    } if
  ] 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

  config.welcome 3 eq { "off.jpg" } { "welcome.jpg" } ifelse 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 {
    config.welcome 2 le { 1500000 usleep } if
  } 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_text .undef eq { return } if

  /b2_text_tmp b2_text 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

  % blend b2_text_tmp over b2_buf, store result in b2_buf
  0 0 moveto
  b2_text_tmp b2_idx b2_start sub 20 mul 255 min b2_buf blend

  560 120 moveto b2_buf restorescreen

  false

} def


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

  /b3_ok false def

  /b3_on "on.jpg"
    findfile dup .undef ne {
      dup setimage 200 0 400 600 unpackimage exch free
    } if
  def

  /b3_off "off.jpg"
    findfile dup .undef ne {
      dup setimage 200 0 400 600 unpackimage exch free
    } if
  def

  b3_on .undef eq { return } if
  b3_off .undef eq { return } if

  /b3_tmp b3_on imgsize 0 0 moveto savescreen def

  /b3_idx 0 def
  /b3_start 0 def
  /b3_steps 30 def

  /b3_ok true def
} def


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

  b3_ok not { return } if

  /b3_on xfree
  /b3_off xfree
  /b3_tmp xfree

  /b3_ok false def
} def


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

  b3_ok not { true return } if

  /b3_idx inc

  b3_idx b3_start b3_steps add gt { true return } if

  b3_idx b3_start lt { false return } if

  b3_tmp b3_off over length memcpy
  0 0 moveto
  b3_on b3_idx b3_start sub 15 mul 255 min b3_tmp blend

  200 0 moveto b3_tmp restorescreen

  false

} def


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

  /b4_ok false def

  /b4_glow "glow.jpg"
    findfile dup .undef ne {
      dup setimage 200 0 400 600 unpackimage exch free
    } if
  def

  b4_glow .undef eq { return } if

  /b4_tmp b4_glow imgsize 0 0 moveto savescreen def

  /b4_idx 0 def
  /b4_start 40 def
  /b4_steps 30 def

  /b4_ok true def
} def


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

  b4_ok not { return } if

  /b4_glow xfree
  /b4_tmp xfree

  /b4_ok false def
} def


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

  b4_ok not { true return } if

  /b4_idx inc

  b4_idx b4_start b4_steps add gt { true return } if

  b4_idx b4_start lt { false return } if

  /b4_val b4_idx b4_start sub 20 mul 255 min def

  b4_val 255 lt {
    b4_tmp b3_on over length memcpy
    0 0 moveto
    b4_glow b4_val b4_tmp blend
  } {
    b4_tmp b3_off over length memcpy
  } ifelse

  200 0 moveto b4_tmp restorescreen

  false

} def