beastie.4th revision 262701
133965Sjdp\ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
233965Sjdp\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3218822Sdim\ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
4130561Sobrien\ All rights reserved.
533965Sjdp\ 
633965Sjdp\ Redistribution and use in source and binary forms, with or without
733965Sjdp\ modification, are permitted provided that the following conditions
833965Sjdp\ are met:
933965Sjdp\ 1. Redistributions of source code must retain the above copyright
1033965Sjdp\    notice, this list of conditions and the following disclaimer.
1133965Sjdp\ 2. Redistributions in binary form must reproduce the above copyright
1233965Sjdp\    notice, this list of conditions and the following disclaimer in the
1333965Sjdp\    documentation and/or other materials provided with the distribution.
1433965Sjdp\ 
1533965Sjdp\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1633965Sjdp\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1733965Sjdp\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1838889Sjdp\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1938889Sjdp\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20218822Sdim\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2133965Sjdp\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2233965Sjdp\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2333965Sjdp\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2433965Sjdp\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25218822Sdim\ SUCH DAMAGE.
26218822Sdim\ 
2760484Sobrien\ $FreeBSD: stable/10/sys/boot/forth/beastie.4th 262701 2014-03-03 07:16:39Z dteske $
2860484Sobrien
2960484Sobrienmarker task-beastie.4th
3060484Sobrien
3160484Sobrieninclude /boot/delay.4th
32130561Sobrien
3360484Sobrienonly forth definitions also support-functions
3460484Sobrien
3560484Sobrienvariable logoX
3660484Sobrienvariable logoY
3760484Sobrien
3860484Sobrien\ Initialize logo placement to defaults
3960484Sobrien46 logoX !
4060484Sobrien4  logoY !
4133965Sjdp
4260484Sobrien: beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns)
4360484Sobrien
4433965Sjdp2dup at-xy ."               [31m,        ," 1+
4533965Sjdp2dup at-xy ."              /(        )`" 1+
4633965Sjdp2dup at-xy ."              \ \___   / |" 1+
4738889Sjdp2dup at-xy ."              /- [37m_[31m  `-/  '" 1+
4833965Sjdp2dup at-xy ."             ([37m/\/ \[31m \   /\" 1+
4933965Sjdp2dup at-xy ."             [37m/ /   |[31m `    \" 1+
5033965Sjdp2dup at-xy ."             [34mO O   [37m) [31m/    |" 1+
5133965Sjdp2dup at-xy ."             [37m`-^--'[31m`<     '" 1+
5233965Sjdp2dup at-xy ."            (_.)  _  )   /" 1+
5333965Sjdp2dup at-xy ."             `.___/`    /" 1+
5433965Sjdp2dup at-xy ."               `-----' /" 1+
5533965Sjdp2dup at-xy ."  [33m<----.[31m     __ / __   \" 1+
5633965Sjdp2dup at-xy ."  [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+
5760484Sobrien2dup at-xy ."  [33m<----'[31m    `--' `.__,' \" 1+
5860484Sobrien2dup at-xy ."               |        |" 1+
5960484Sobrien2dup at-xy ."                \       /       /\" 1+
6033965Sjdp2dup at-xy ."           [36m______[31m( (_  / \______/" 1+
6133965Sjdp2dup at-xy ."         [36m,'  ,-----'   |" 1+
6233965Sjdp     at-xy ."         `--{__________)[37m"
6333965Sjdp
6460484Sobrien	\ Put the cursor back at the bottom
6560484Sobrien	0 25 at-xy
6633965Sjdp;
6760484Sobrien
6860484Sobrien: beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns)
6960484Sobrien
7060484Sobrien	2dup at-xy ."               ,        ," 1+
7133965Sjdp	2dup at-xy ."              /(        )`" 1+
7260484Sobrien	2dup at-xy ."              \ \___   / |" 1+
7360484Sobrien	2dup at-xy ."              /- _  `-/  '" 1+
7433965Sjdp	2dup at-xy ."             (/\/ \ \   /\" 1+
7533965Sjdp	2dup at-xy ."             / /   | `    \" 1+
7633965Sjdp	2dup at-xy ."             O O   ) /    |" 1+
7760484Sobrien	2dup at-xy ."             `-^--'`<     '" 1+
7833965Sjdp	2dup at-xy ."            (_.)  _  )   /" 1+
7933965Sjdp	2dup at-xy ."             `.___/`    /" 1+
8033965Sjdp	2dup at-xy ."               `-----' /" 1+
8133965Sjdp	2dup at-xy ."  <----.     __ / __   \" 1+
8238889Sjdp	2dup at-xy ."  <----|====O)))==) \) /====|" 1+
8338889Sjdp	2dup at-xy ."  <----'    `--' `.__,' \" 1+
8433965Sjdp	2dup at-xy ."               |        |" 1+
8533965Sjdp	2dup at-xy ."                \       /       /\" 1+
8633965Sjdp	2dup at-xy ."           ______( (_  / \______/" 1+
8733965Sjdp	2dup at-xy ."         ,'  ,-----'   |" 1+
8860484Sobrien	     at-xy ."         `--{__________)"
8960484Sobrien
9060484Sobrien	\ Put the cursor back at the bottom
9160484Sobrien	0 25 at-xy
9260484Sobrien;
9360484Sobrien
9460484Sobrien: fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (13 rows x 21 columns)
9560484Sobrien
9633965Sjdp	\ We used to use the beastie himself as our default... until the
9733965Sjdp	\ eventual complaint derided his reign of the advanced boot-menu.
9860484Sobrien	\ 
9960484Sobrien	\ This is the replacement of beastie to satiate the haters of our
10060484Sobrien	\ beloved helper-daemon (ready to track down and spear bugs with
10160484Sobrien	\ his trident and sporty sneakers; see above).
10260484Sobrien	\ 
10360484Sobrien	\ Since we merely just changed the default and not the default-
10460484Sobrien	\ location, below is an adjustment to the passed-in coordinates,
10560484Sobrien	\ forever influenced by the proper location of beastie himself
10660484Sobrien	\ kept as the default loader_logo_x/loader_logo_y values.
10760484Sobrien	\ 
10860484Sobrien	5 + swap 6 + swap
10933965Sjdp
11060484Sobrien	2dup at-xy ."  ______" 1+
11160484Sobrien	2dup at-xy ." |  ____| __ ___  ___ " 1+
112218822Sdim	2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+
113218822Sdim	2dup at-xy ." |  __|| | |  __/  __/" 1+
114218822Sdim	2dup at-xy ." | |   | | |    |    |" 1+
115218822Sdim	2dup at-xy ." |_|   |_|  \___|\___|" 1+
116218822Sdim	2dup at-xy ."  ____   _____ _____" 1+
117218822Sdim	2dup at-xy ." |  _ \ / ____|  __ \" 1+
118218822Sdim	2dup at-xy ." | |_) | (___ | |  | |" 1+
11960484Sobrien	2dup at-xy ." |  _ < \___ \| |  | |" 1+
12033965Sjdp	2dup at-xy ." | |_) |____) | |__| |" 1+
12160484Sobrien	2dup at-xy ." |     |      |      |" 1+
12238889Sjdp	     at-xy ." |____/|_____/|_____/"
12338889Sjdp
12460484Sobrien	\ Put the cursor back at the bottom
12533965Sjdp	0 25 at-xy
12660484Sobrien;
12760484Sobrien
12833965Sjdp: orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns)
12933965Sjdp
13033965Sjdp	3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
13160484Sobrien
13260484Sobrien	2dup at-xy ."  [31m```                        [31;1m`[31m" 1+
13360484Sobrien	2dup at-xy ." s` `.....---...[31;1m....--.```   -/[31m" 1+
13460484Sobrien	2dup at-xy ." +o   .--`         [31;1m/y:`      +.[31m" 1+
13533965Sjdp	2dup at-xy ."  yo`:.            [31;1m:o      `+-[31m" 1+
13660484Sobrien	2dup at-xy ."   y/               [31;1m-/`   -o/[31m" 1+
13760484Sobrien	2dup at-xy ."  .-                  [31;1m::/sy+:.[31m" 1+
13833965Sjdp	2dup at-xy ."  /                     [31;1m`--  /[31m" 1+
13960484Sobrien	2dup at-xy ." `:                          [31;1m:`[31m" 1+
14060484Sobrien	2dup at-xy ." `:                          [31;1m:`[31m" 1+
14160484Sobrien	2dup at-xy ."  /                          [31;1m/[31m" 1+
14260484Sobrien	2dup at-xy ."  .-                        [31;1m-.[31m" 1+
14360484Sobrien	2dup at-xy ."   --                      [31;1m-.[31m" 1+
14460484Sobrien	2dup at-xy ."    `:`                  [31;1m`:`" 1+
14560484Sobrien	2dup at-xy ."      [31;1m.--             `--." 1+
14660484Sobrien	     at-xy ."         .---.....----.[37m"
14760484Sobrien
14860484Sobrien 	\ Put the cursor back at the bottom
14933965Sjdp 	0 25 at-xy
15033965Sjdp;
15138889Sjdp
15238889Sjdp: orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns)
15360484Sobrien
15460484Sobrien	3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
15533965Sjdp
15660484Sobrien	2dup at-xy ."  ```                        `" 1+
15760484Sobrien	2dup at-xy ." s` `.....---.......--.```   -/" 1+
15860484Sobrien	2dup at-xy ." +o   .--`         /y:`      +." 1+
15960484Sobrien	2dup at-xy ."  yo`:.            :o      `+-" 1+
16060484Sobrien	2dup at-xy ."   y/               -/`   -o/" 1+
16133965Sjdp	2dup at-xy ."  .-                  ::/sy+:." 1+
16260484Sobrien	2dup at-xy ."  /                     `--  /" 1+
16360484Sobrien	2dup at-xy ." `:                          :`" 1+
164218822Sdim	2dup at-xy ." `:                          :`" 1+
165218822Sdim	2dup at-xy ."  /                          /" 1+
166218822Sdim	2dup at-xy ."  .-                        -." 1+
16738889Sjdp	2dup at-xy ."   --                      -." 1+
16838889Sjdp	2dup at-xy ."    `:`                  `:`" 1+
16960484Sobrien	2dup at-xy ."      .--             `--." 1+
17038889Sjdp	     at-xy ."         .---.....----."
17138889Sjdp
17238889Sjdp 	\ Put the cursor back at the bottom
17338889Sjdp 	0 25 at-xy
174218822Sdim;
17538889Sjdp
17638889Sjdp\ This function draws any number of beastie logos at (loader_logo_x,
17760484Sobrien\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
17838889Sjdp\ your beastie, set the variable `loader_logo' to the respective logo name.
17938889Sjdp\ 
18038889Sjdp\ Currently available:
18160484Sobrien\ 
18260484Sobrien\ 	NAME        DESCRIPTION
18338889Sjdp\ 	beastie     Color ``Helper Daemon'' mascot (19 rows x 34 columns)
18438889Sjdp\ 	beastiebw   B/W ``Helper Daemon'' mascot (19 rows x 34 columns)
18533965Sjdp\ 	fbsdbw      "FreeBSD" logo in B/W (13 rows x 21 columns)
18660484Sobrien\ 	orb         Color ``Orb'' mascot (15 rows x 30 columns) (2nd default)
18760484Sobrien\ 	orbbw       B/W ``Orb'' mascot (15 rows x 32 columns)
18860484Sobrien\ 	tribute     Color ``Tribute'' (must fit 19 rows x 34 columns) (default)
18960484Sobrien\ 	tributebw   B/W ``Tribute'' (must fit 19 rows x 34 columns)
19060484Sobrien\ 
19160484Sobrien\ NOTE: Setting `loader_logo' to an undefined value (such as "none") will
19260484Sobrien\       prevent beastie from being drawn.
19360484Sobrien\ 
19460484Sobrien: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
19560484Sobrien
19660484Sobrien	s" loader_logo_x" getenv dup -1 <> if
19760484Sobrien		?number 1 = if logoX ! then
19860484Sobrien	else
19960484Sobrien		drop
20060484Sobrien	then
20160484Sobrien	s" loader_logo_y" getenv dup -1 <> if
20260484Sobrien		?number 1 = if logoY ! then
20360484Sobrien	else
20460484Sobrien		drop
20560484Sobrien	then
20660484Sobrien
20760484Sobrien	s" loader_logo" getenv dup -1 = if
20860484Sobrien		logoX @ logoY @
20960484Sobrien		loader_color? if
21060484Sobrien			orb-logo
21160484Sobrien		else
21260484Sobrien			orbbw-logo
21389857Sobrien		then
21489857Sobrien		drop exit
21560484Sobrien	then
21660484Sobrien
21733965Sjdp	2dup s" beastie" compare-insensitive 0= if
21833965Sjdp		logoX @ logoY @ beastie-logo
21933965Sjdp		2drop exit
22033965Sjdp	then
22133965Sjdp	2dup s" beastiebw" compare-insensitive 0= if
22233965Sjdp		logoX @ logoY @ beastiebw-logo
22333965Sjdp		2drop exit
22433965Sjdp	then
22533965Sjdp	2dup s" fbsdbw" compare-insensitive 0= if
22633965Sjdp		logoX @ logoY @ fbsdbw-logo
22733965Sjdp		2drop exit
22833965Sjdp	then
22933965Sjdp	2dup s" orb" compare-insensitive 0= if
23033965Sjdp		logoX @ logoY @ orb-logo
23133965Sjdp		2drop exit
23233965Sjdp	then
23338889Sjdp	2dup s" orbbw" compare-insensitive 0= if
23433965Sjdp		logoX @ logoY @ orbbw-logo
23533965Sjdp		2drop exit
23633965Sjdp	then
23733965Sjdp	2dup s" tribute" compare-insensitive 0= if
23833965Sjdp		logoX @ logoY @
23933965Sjdp		s" tribute-logo" sfind if
24060484Sobrien			execute
24133965Sjdp		else
24233965Sjdp			drop orb-logo
24360484Sobrien		then
24460484Sobrien		2drop exit
24560484Sobrien	then
24660484Sobrien	2dup s" tributebw" compare-insensitive 0= if
24760484Sobrien		logoX @ logoY @
24860484Sobrien		s" tributebw-logo" sfind if
24960484Sobrien			execute
25060484Sobrien		else
25160484Sobrien			drop orbbw-logo
25260484Sobrien		then
25360484Sobrien		2drop exit
25460484Sobrien	then
255130561Sobrien
25660484Sobrien	2drop
257130561Sobrien;
25860484Sobrien
25960484Sobrien: clear-beastie ( -- ) \ clears beastie from the screen
26060484Sobrien	logoX @ logoY @
26160484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26260484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26360484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26433965Sjdp	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26560484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26660484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26760484Sobrien	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26833965Sjdp	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
26933965Sjdp	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
27060484Sobrien	2dup at-xy 34 spaces		2drop
27160484Sobrien
27260484Sobrien	\ Put the cursor back at the bottom
27360484Sobrien	0 25 at-xy
27460484Sobrien;
27560484Sobrien
27633965Sjdp: beastie-start ( -- ) \ starts the menu
27760484Sobrien	s" beastie_disable" getenv
278130561Sobrien	dup -1 <> if
279130561Sobrien		s" YES" compare-insensitive 0= if
28033965Sjdp			any_conf_read? if
28160484Sobrien				load_kernel
28260484Sobrien				load_modules
28360484Sobrien			then
28460484Sobrien			exit \ to autoboot (default)
28560484Sobrien		then
28660484Sobrien	else
28760484Sobrien		drop
28860484Sobrien	then
28960484Sobrien
290130561Sobrien	s" loader_delay" getenv
29160484Sobrien	-1 = if
292130561Sobrien		s" include /boot/menu.rc" evaluate
293130561Sobrien	else
294130561Sobrien		drop
29533965Sjdp		." Loading Menu (Ctrl-C to Abort)" cr
29660484Sobrien		s" set delay_command='include /boot/menu.rc'" evaluate
29733965Sjdp		s" set delay_showdots" evaluate
29833965Sjdp		delay_execute
29933965Sjdp	then
30060484Sobrien;
30160484Sobrien
30233965Sjdponly forth also
30333965Sjdp