]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/boot/forth/beastie.4th
MFS9 SVN r254331:
[FreeBSD/releng/9.2.git] / sys / boot / forth / beastie.4th
1 \ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
2 \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3 \ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
4 \ All rights reserved.
5
6 \ Redistribution and use in source and binary forms, with or without
7 \ modification, are permitted provided that the following conditions
8 \ are met:
9 \ 1. Redistributions of source code must retain the above copyright
10 \    notice, this list of conditions and the following disclaimer.
11 \ 2. Redistributions in binary form must reproduce the above copyright
12 \    notice, this list of conditions and the following disclaimer in the
13 \    documentation and/or other materials provided with the distribution.
14
15 \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 \ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 \ SUCH DAMAGE.
26
27 \ $FreeBSD$
28
29 marker task-beastie.4th
30
31 include /boot/delay.4th
32
33 variable logoX
34 variable logoY
35
36 \ Initialize logo placement to defaults
37 46 logoX !
38 4  logoY !
39
40 : beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns)
41
42 2dup at-xy ."               \e[31m,        ," 1+
43 2dup at-xy ."              /(        )`" 1+
44 2dup at-xy ."              \ \___   / |" 1+
45 2dup at-xy ."              /- \e[37m_\e[31m  `-/  '" 1+
46 2dup at-xy ."             (\e[37m/\/ \\e[31m \   /\" 1+
47 2dup at-xy ."             \e[37m/ /   |\e[31m `    \" 1+
48 2dup at-xy ."             \e[34mO O   \e[37m) \e[31m/    |" 1+
49 2dup at-xy ."             \e[37m`-^--'\e[31m`<     '" 1+
50 2dup at-xy ."            (_.)  _  )   /" 1+
51 2dup at-xy ."             `.___/`    /" 1+
52 2dup at-xy ."               `-----' /" 1+
53 2dup at-xy ."  \e[33m<----.\e[31m     __ / __   \" 1+
54 2dup at-xy ."  \e[33m<----|====\e[31mO)))\e[33m==\e[31m) \) /\e[33m====|" 1+
55 2dup at-xy ."  \e[33m<----'\e[31m    `--' `.__,' \" 1+
56 2dup at-xy ."               |        |" 1+
57 2dup at-xy ."                \       /       /\" 1+
58 2dup at-xy ."           \e[36m______\e[31m( (_  / \______/" 1+
59 2dup at-xy ."         \e[36m,'  ,-----'   |" 1+
60      at-xy ."         `--{__________)\e[37m"
61
62         \ Put the cursor back at the bottom
63         0 25 at-xy
64 ;
65
66 : beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns)
67
68         2dup at-xy ."               ,        ," 1+
69         2dup at-xy ."              /(        )`" 1+
70         2dup at-xy ."              \ \___   / |" 1+
71         2dup at-xy ."              /- _  `-/  '" 1+
72         2dup at-xy ."             (/\/ \ \   /\" 1+
73         2dup at-xy ."             / /   | `    \" 1+
74         2dup at-xy ."             O O   ) /    |" 1+
75         2dup at-xy ."             `-^--'`<     '" 1+
76         2dup at-xy ."            (_.)  _  )   /" 1+
77         2dup at-xy ."             `.___/`    /" 1+
78         2dup at-xy ."               `-----' /" 1+
79         2dup at-xy ."  <----.     __ / __   \" 1+
80         2dup at-xy ."  <----|====O)))==) \) /====|" 1+
81         2dup at-xy ."  <----'    `--' `.__,' \" 1+
82         2dup at-xy ."               |        |" 1+
83         2dup at-xy ."                \       /       /\" 1+
84         2dup at-xy ."           ______( (_  / \______/" 1+
85         2dup at-xy ."         ,'  ,-----'   |" 1+
86              at-xy ."         `--{__________)"
87
88         \ Put the cursor back at the bottom
89         0 25 at-xy
90 ;
91
92 : fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (13 rows x 21 columns)
93
94         \ We used to use the beastie himself as our default... until the
95         \ eventual complaint derided his reign of the advanced boot-menu.
96         \ 
97         \ This is the replacement of beastie to satiate the haters of our
98         \ beloved helper-daemon (ready to track down and spear bugs with
99         \ his trident and sporty sneakers; see above).
100         \ 
101         \ Since we merely just changed the default and not the default-
102         \ location, below is an adjustment to the passed-in coordinates,
103         \ forever influenced by the proper location of beastie himself
104         \ kept as the default loader_logo_x/loader_logo_y values.
105         \ 
106         5 + swap 6 + swap
107
108         2dup at-xy ."  ______" 1+
109         2dup at-xy ." |  ____| __ ___  ___ " 1+
110         2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+
111         2dup at-xy ." |  __|| | |  __/  __/" 1+
112         2dup at-xy ." | |   | | |    |    |" 1+
113         2dup at-xy ." |_|   |_|  \___|\___|" 1+
114         2dup at-xy ."  ____   _____ _____" 1+
115         2dup at-xy ." |  _ \ / ____|  __ \" 1+
116         2dup at-xy ." | |_) | (___ | |  | |" 1+
117         2dup at-xy ." |  _ < \___ \| |  | |" 1+
118         2dup at-xy ." | |_) |____) | |__| |" 1+
119         2dup at-xy ." |     |      |      |" 1+
120              at-xy ." |____/|_____/|_____/"
121
122         \ Put the cursor back at the bottom
123         0 25 at-xy
124 ;
125
126 : tribute-art ( x y -- ) \ see tribute[bw]-logo
127
128         \ Disable the brand art (we're going to use that space)
129         s" set loader_brand=none" evaluate
130
131         \ Blank out the frame of the menu and move the title to left
132         s" set loader_menu_title=" evaluate
133         s" set loader_menu_frame=none" evaluate
134
135         \ Move the menu to the center of the screen
136         s" set loader_menu_x=26" evaluate
137         s" set loader_menu_y=13" evaluate
138         s" set loader_menu_timeout_x=21" evaluate
139         s" set loader_menu_timeout_y=24" evaluate
140
141         2 - swap 39 - swap \ top-left (see `fbsdbw-logo' comments above)
142
143         2dup at-xy 11 spaces ." ,d      b." 1+
144         2dup at-xy ."         ,d88]      [88b." 1+
145         2dup at-xy ."      ,d888P" 34 emit ."  ,d88b. " 34 emit ." Y888b." 1+
146         2dup at-xy ."  , <888P" 34 emit ."  ,dP" 34 emit ." ,db." 34 emit
147                    ." Yb. " 34 emit ." Y888> ," 1+
148         2dup at-xy ." <88b.~ ,d888  " 34 emit ." YP" 34 emit
149                    ."   888b. ~,d88>" 1+
150         2dup at-xy ."  ," 34 emit ." Y888888P" 34 emit ." ,db.,db." 34 emit
151                    ." Y888888P" 34 emit ." ," 1+
152         2dup at-xy ." <88b." 34 emit ." YP" 34 emit ."  _ " 34 emit
153                    ." YP" 34 emit 34 emit ." YP" 34 emit ."  _ " 34 emit
154                    ." YP" 34 emit ." ,d88>" 1+
155         2dup at-xy ."   " 34 emit ." Y88b.,dP          Yb.,d88P" 34 emit 1+
156              at-xy ."      " 34 emit ." YP" 34 emit ."               " 34 emit
157                    ." YP" 34 emit ." "
158 ;
159
160 : tribute-text ( x y -- ) \ see tribute[bw]-logo
161
162         swap 2 - swap \ beastie adjustment (see `fbsdbw-logo' comments above)
163
164         2dup at-xy ." CEO Workstation" 1+
165         1+
166         2dup at-xy ." Nakatomi Socrates FreeBSD 9.2" 1+
167         2dup at-xy ." Z-Level Central Core" 1+
168         1+
169              at-xy ." Preliminary Clearance Approved."
170 ;
171
172 : tribute-logo ( x y -- ) \ color Socrates tribute (16 rows x 32 columns)
173
174         \ Produce the tribute art in bright green
175         2dup at-xy ." \e[32;1m" 2dup tribute-art ." \e[37m"
176
177         \ Produce the tribute text in regular green
178         2dup at-xy ." \e[32m" 2dup tribute-text ." \e[37m"
179
180         \ Distinguish the ``Free'' in tribute-text
181         2 + swap 16 + swap at-xy ." Free"
182
183         \ Put the cursor back at the bottom
184         0 25 at-xy
185 ;
186
187 : tributebw-logo ( x y -- ) \ Socrates tribute (16 rows x 32 columns)
188
189         \ Produce the tribute art and text
190         2dup tribute-art tribute-text
191
192         \ Put the cursor back at the bottom
193         0 25 at-xy
194 ;
195
196 : orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns)
197
198         3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
199
200         2dup at-xy ."  \e[31m```                        \e[31;1m`\e[31m" 1+
201         2dup at-xy ." s` `.....---...\e[31;1m....--.```   -/\e[31m" 1+
202         2dup at-xy ." +o   .--`         \e[31;1m/y:`      +.\e[31m" 1+
203         2dup at-xy ."  yo`:.            \e[31;1m:o      `+-\e[31m" 1+
204         2dup at-xy ."   y/               \e[31;1m-/`   -o/\e[31m" 1+
205         2dup at-xy ."  .-                  \e[31;1m::/sy+:.\e[31m" 1+
206         2dup at-xy ."  /                     \e[31;1m`--  /\e[31m" 1+
207         2dup at-xy ." `:                          \e[31;1m:`\e[31m" 1+
208         2dup at-xy ." `:                          \e[31;1m:`\e[31m" 1+
209         2dup at-xy ."  /                          \e[31;1m/\e[31m" 1+
210         2dup at-xy ."  .-                        \e[31;1m-.\e[31m" 1+
211         2dup at-xy ."   --                      \e[31;1m-.\e[31m" 1+
212         2dup at-xy ."    `:`                  \e[31;1m`:`" 1+
213         2dup at-xy ."      \e[31;1m.--             `--." 1+
214              at-xy ."         .---.....----.\e[37m"
215
216         \ Put the cursor back at the bottom
217         0 25 at-xy
218 ;
219
220 : orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns)
221
222         3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
223
224         2dup at-xy ."  ```                        `" 1+
225         2dup at-xy ." s` `.....---.......--.```   -/" 1+
226         2dup at-xy ." +o   .--`         /y:`      +." 1+
227         2dup at-xy ."  yo`:.            :o      `+-" 1+
228         2dup at-xy ."   y/               -/`   -o/" 1+
229         2dup at-xy ."  .-                  ::/sy+:." 1+
230         2dup at-xy ."  /                     `--  /" 1+
231         2dup at-xy ." `:                          :`" 1+
232         2dup at-xy ." `:                          :`" 1+
233         2dup at-xy ."  /                          /" 1+
234         2dup at-xy ."  .-                        -." 1+
235         2dup at-xy ."   --                      -." 1+
236         2dup at-xy ."    `:`                  `:`" 1+
237         2dup at-xy ."      .--             `--." 1+
238              at-xy ."         .---.....----."
239
240         \ Put the cursor back at the bottom
241         0 25 at-xy
242 ;
243
244 \ This function draws any number of beastie logos at (loader_logo_x,
245 \ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
246 \ your beastie, set the variable `loader_logo' to the respective logo name.
247
248 \ Currently available:
249
250 \       NAME        DESCRIPTION
251 \       beastie     Color ``Helper Daemon'' mascot (19 rows x 34 columns)
252 \       beastiebw   B/W ``Helper Daemon'' mascot (19 rows x 34 columns)
253 \       fbsdbw      "FreeBSD" logo in B/W (13 rows x 21 columns)
254 \       orb         Color ``Orb'' mascot (15 rows x 30 columns) (2nd default)
255 \       orbbw       B/W ``Orb'' mascot (15 rows x 32 columns)
256 \       tribute     Color ``Tribute'' (must fit 19 rows x 34 columns) (default)
257 \       tributebw   B/W ``Tribute'' (must fit 19 rows x 34 columns)
258
259 \ NOTE: Setting `loader_logo' to an undefined value (such as "none") will
260 \       prevent beastie from being drawn.
261
262 : draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
263
264         s" loader_logo_x" getenv dup -1 <> if
265                 ?number 1 = if logoX ! then
266         else
267                 drop
268         then
269         s" loader_logo_y" getenv dup -1 <> if
270                 ?number 1 = if logoY ! then
271         else
272                 drop
273         then
274
275         s" loader_logo" getenv dup -1 = if
276                 logoX @ logoY @
277                 loader_color? if
278                         s" tribute-logo"
279                         sfind if
280                                 execute
281                         else
282                                 drop
283                                 orb-logo
284                         then
285                 else
286                         s" tributebw-logo"
287                         sfind if
288                                 execute
289                         else
290                                 drop
291                                 orbbw-logo
292                         then
293                 then
294                 drop exit
295         then
296
297         2dup s" beastie" compare-insensitive 0= if
298                 logoX @ logoY @ beastie-logo
299                 2drop exit
300         then
301         2dup s" beastiebw" compare-insensitive 0= if
302                 logoX @ logoY @ beastiebw-logo
303                 2drop exit
304         then
305         2dup s" fbsdbw" compare-insensitive 0= if
306                 logoX @ logoY @ fbsdbw-logo
307                 2drop exit
308         then
309         2dup s" orb" compare-insensitive 0= if
310                 logoX @ logoY @ orb-logo
311                 2drop exit
312         then
313         2dup s" orbbw" compare-insensitive 0= if
314                 logoX @ logoY @ orbbw-logo
315                 2drop exit
316         then
317         2dup s" tribute" compare-insensitive 0= if
318                 logoX @ logoY @
319                 s" tribute-logo" sfind if
320                         execute
321                 else
322                         orb-logo
323                 then
324                 2drop exit
325         then
326         2dup s" tributebw" compare-insensitive 0= if
327                 logoX @ logoY @
328                 s" tributebw-logo" sfind if
329                         execute
330                 else
331                         orbbw-logo
332                 then
333                 2drop exit
334         then
335
336         2drop
337 ;
338
339 : clear-beastie ( -- ) \ clears beastie from the screen
340         logoX @ logoY @
341         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
342         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
343         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
344         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
345         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
346         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
347         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
348         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
349         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
350         2dup at-xy 34 spaces            2drop
351
352         \ Put the cursor back at the bottom
353         0 25 at-xy
354 ;
355
356 : beastie-start ( -- ) \ starts the menu
357         s" beastie_disable" getenv
358         dup -1 <> if
359                 s" YES" compare-insensitive 0= if
360                         exit
361                 then
362         else
363                 drop
364         then
365
366         s" loader_delay" getenv
367         -1 = if
368                 s" include /boot/menu.rc" evaluate
369         else
370                 drop
371                 ." Loading Menu (Ctrl-C to Abort)" cr
372                 s" set delay_command='include /boot/menu.rc'" evaluate
373                 s" set delay_showdots" evaluate
374                 delay_execute
375         then
376 ;