summaryrefslogtreecommitdiffstats
path: root/bsplash.inc
blob: ed5396f8b48be45bcef401f3f282d784388f31d8 (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
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Boot loader splash code.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


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

/.b_x		 0 def
/.b_y		 1 def
/.b_dx		 2 def
/.b_dy		 3 def
/.b_steps	 4 def
/.b_mask	 5 def
/.b_count	 6 def
/.b_w		 7 def
/.b_h		 8 def
/.b_back	 9 def
/.b_tmp1	10 def
/.b_tmp2	11 def

/bsplash.list [
  [ 194 75 0   0 20 "mandriva.pcx" 0 0 0 .undef .undef .undef  ]
] def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Init splash.
%
% ( ) ==> ( )
%
/bsplash.init {
  bsplash.list {
    dup .b_mask get readimage over .b_mask rot put
    dup .b_mask get dup .undef ne {
      imgsize
      2 index .b_h rot put
      over .b_w rot put

      dup .b_x get over .b_y get moveto
      dup .b_w get over .b_steps get 2 index .b_dx get abs mul add
      over .b_h get 2 index .b_steps get 3 index .b_dy get abs mul add
      savescreen over .b_back rot put

      dup .b_w get 1 sub over .b_h get 1 sub savescreen over .b_tmp1 rot put
      dup .b_w get 1 sub over .b_h get 1 sub savescreen over .b_tmp2 rot put
    } {
      pop
    } ifelse
    pop
  } forall
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Free splash memory.
%
% ( ) ==> ( )
%
/bsplash.free {
  bsplash.list {
    dup .b_mask get free dup .b_mask .undef put
    dup .b_back get free
    dup .b_tmp1 get free
    dup .b_tmp2 get free
    pop
  } forall
} def


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

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

  0 0 moveto 0 0 image.size image

  bsplash.init

  400000 usleep

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

  bsplash.free

  setimage

  splash.file free /splash.file .undef def

} def


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

  bsplash.list {
    dup .b_mask get .undef ne over .b_count get .undef ne and {
      exch pop false exch

      dup .b_count get 1 add over .b_count rot put

      % count runs from  0 ... steps inclusive

      dup .b_count get 0 ge {

        % copy background
        dup .b_dx get over .b_count get mul 10 div
          over .b_dx get 2 index .b_steps get mul 10 div neg 0 max add
        over .b_dy get 2 index .b_count get mul 10 div
          2 index .b_dy get 3 index .b_steps get mul 10 div neg 0 max add
        moveto
        dup .b_back get 0xff 2 index .b_tmp1 get blend

        % we need 2 copies
        dup .b_tmp2 get over .b_tmp1 get over length memcpy

        % draw text
        0 0 moveto 0x333333 over .b_mask get 2 index .b_tmp1 get blend
        1 1 moveto white over .b_mask get 2 index .b_tmp1 get blend

        % blend result with background
        0 0 moveto dup .b_tmp1 get over .b_count get 255 mul 2 index .b_steps get div 2 index .b_tmp2 get blend

        % show result
        dup .b_x get over .b_dx get 2 index .b_count get mul 10 div add
          over .b_dx get 2 index .b_steps get mul 10 div neg 0 max add
        over .b_y get 2 index .b_dy get 3 index .b_count get mul 10 div add
          2 index .b_dy get 3 index .b_steps get mul 10 div neg 0 max add
        moveto
        dup .b_tmp2 get restorescreen

      } if

      dup .b_count get over .b_steps get eq { dup .b_count .undef put } if
    } if
    pop
  } forall

} def


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