1115410Sscottl\ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
2120031Sscottl\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3254105Sdteske\ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
4115410Sscottl\ All rights reserved.
5222417Sjulian\ 
6115410Sscottl\ Redistribution and use in source and binary forms, with or without
7115410Sscottl\ modification, are permitted provided that the following conditions
8115410Sscottl\ are met:
9115410Sscottl\ 1. Redistributions of source code must retain the above copyright
10115410Sscottl\    notice, this list of conditions and the following disclaimer.
11115410Sscottl\ 2. Redistributions in binary form must reproduce the above copyright
12115410Sscottl\    notice, this list of conditions and the following disclaimer in the
13115410Sscottl\    documentation and/or other materials provided with the distribution.
14222417Sjulian\ 
15115410Sscottl\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16115410Sscottl\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17115410Sscottl\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18115410Sscottl\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19115410Sscottl\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20115410Sscottl\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21115410Sscottl\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22115410Sscottl\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23115410Sscottl\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24115410Sscottl\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25115410Sscottl\ SUCH DAMAGE.
26222417Sjulian\ 
27115410Sscottl\ $FreeBSD$
28115410Sscottl
29115410Sscottlmarker task-beastie.4th
30115410Sscottl
31262701Sdteskeonly forth definitions also support-functions
32262701Sdteske
33222417Sjulianvariable logoX
34222417Sjulianvariable logoY
35115410Sscottl
36222417Sjulian\ Initialize logo placement to defaults
37222417Sjulian46 logoX !
38222417Sjulian4  logoY !
39115410Sscottl
40222417Sjulian: beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns)
41115410Sscottl
42222417Sjulian2dup at-xy ."               [31m,        ," 1+
43120031Sscottl2dup at-xy ."              /(        )`" 1+
44120031Sscottl2dup at-xy ."              \ \___   / |" 1+
45120031Sscottl2dup at-xy ."              /- [37m_[31m  `-/  '" 1+
46120031Sscottl2dup at-xy ."             ([37m/\/ \[31m \   /\" 1+
47120031Sscottl2dup at-xy ."             [37m/ /   |[31m `    \" 1+
48120031Sscottl2dup at-xy ."             [34mO O   [37m) [31m/    |" 1+
49120031Sscottl2dup at-xy ."             [37m`-^--'[31m`<     '" 1+
50120031Sscottl2dup at-xy ."            (_.)  _  )   /" 1+
51222417Sjulian2dup at-xy ."             `.___/`    /" 1+
52120031Sscottl2dup at-xy ."               `-----' /" 1+
53120031Sscottl2dup at-xy ."  [33m<----.[31m     __ / __   \" 1+
54120031Sscottl2dup at-xy ."  [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+
55120031Sscottl2dup at-xy ."  [33m<----'[31m    `--' `.__,' \" 1+
56120031Sscottl2dup at-xy ."               |        |" 1+
57120031Sscottl2dup at-xy ."                \       /       /\" 1+
58120031Sscottl2dup at-xy ."           [36m______[31m( (_  / \______/" 1+
59120031Sscottl2dup at-xy ."         [36m,'  ,-----'   |" 1+
60222417Sjulian     at-xy ."         `--{__________)[37m"
61222417Sjulian
62222417Sjulian	\ Put the cursor back at the bottom
63222417Sjulian	0 25 at-xy
64120031Sscottl;
65120031Sscottl
66222417Sjulian: beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns)
67222417Sjulian
68222417Sjulian	2dup at-xy ."               ,        ," 1+
69222417Sjulian	2dup at-xy ."              /(        )`" 1+
70222417Sjulian	2dup at-xy ."              \ \___   / |" 1+
71222417Sjulian	2dup at-xy ."              /- _  `-/  '" 1+
72222417Sjulian	2dup at-xy ."             (/\/ \ \   /\" 1+
73222417Sjulian	2dup at-xy ."             / /   | `    \" 1+
74222417Sjulian	2dup at-xy ."             O O   ) /    |" 1+
75222417Sjulian	2dup at-xy ."             `-^--'`<     '" 1+
76222417Sjulian	2dup at-xy ."            (_.)  _  )   /" 1+
77222417Sjulian	2dup at-xy ."             `.___/`    /" 1+
78222417Sjulian	2dup at-xy ."               `-----' /" 1+
79222417Sjulian	2dup at-xy ."  <----.     __ / __   \" 1+
80222417Sjulian	2dup at-xy ."  <----|====O)))==) \) /====|" 1+
81222417Sjulian	2dup at-xy ."  <----'    `--' `.__,' \" 1+
82222417Sjulian	2dup at-xy ."               |        |" 1+
83222417Sjulian	2dup at-xy ."                \       /       /\" 1+
84222417Sjulian	2dup at-xy ."           ______( (_  / \______/" 1+
85222417Sjulian	2dup at-xy ."         ,'  ,-----'   |" 1+
86222417Sjulian	     at-xy ."         `--{__________)"
87222417Sjulian
88222417Sjulian	\ Put the cursor back at the bottom
89222417Sjulian	0 25 at-xy
90115410Sscottl;
91115410Sscottl
92222417Sjulian: fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (13 rows x 21 columns)
93222417Sjulian
94222417Sjulian	\ We used to use the beastie himself as our default... until the
95222417Sjulian	\ eventual complaint derided his reign of the advanced boot-menu.
96222417Sjulian	\ 
97222417Sjulian	\ This is the replacement of beastie to satiate the haters of our
98222417Sjulian	\ beloved helper-daemon (ready to track down and spear bugs with
99222417Sjulian	\ his trident and sporty sneakers; see above).
100222417Sjulian	\ 
101222417Sjulian	\ Since we merely just changed the default and not the default-
102222417Sjulian	\ location, below is an adjustment to the passed-in coordinates,
103222417Sjulian	\ forever influenced by the proper location of beastie himself
104222417Sjulian	\ kept as the default loader_logo_x/loader_logo_y values.
105222417Sjulian	\ 
106222417Sjulian	5 + swap 6 + swap
107222417Sjulian
108222417Sjulian	2dup at-xy ."  ______" 1+
109222417Sjulian	2dup at-xy ." |  ____| __ ___  ___ " 1+
110222417Sjulian	2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+
111222417Sjulian	2dup at-xy ." |  __|| | |  __/  __/" 1+
112222417Sjulian	2dup at-xy ." | |   | | |    |    |" 1+
113222417Sjulian	2dup at-xy ." |_|   |_|  \___|\___|" 1+
114222417Sjulian	2dup at-xy ."  ____   _____ _____" 1+
115222417Sjulian	2dup at-xy ." |  _ \ / ____|  __ \" 1+
116222417Sjulian	2dup at-xy ." | |_) | (___ | |  | |" 1+
117222417Sjulian	2dup at-xy ." |  _ < \___ \| |  | |" 1+
118222417Sjulian	2dup at-xy ." | |_) |____) | |__| |" 1+
119222417Sjulian	2dup at-xy ." |     |      |      |" 1+
120222417Sjulian	     at-xy ." |____/|_____/|_____/"
121222417Sjulian
122222417Sjulian	\ Put the cursor back at the bottom
123222417Sjulian	0 25 at-xy
124151873Sscottl;
125151873Sscottl
126222417Sjulian: orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns)
127222417Sjulian
128222417Sjulian	3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
129222417Sjulian
130222417Sjulian	2dup at-xy ."  [31m```                        [31;1m`[31m" 1+
131222417Sjulian	2dup at-xy ." s` `.....---...[31;1m....--.```   -/[31m" 1+
132222417Sjulian	2dup at-xy ." +o   .--`         [31;1m/y:`      +.[31m" 1+
133222417Sjulian	2dup at-xy ."  yo`:.            [31;1m:o      `+-[31m" 1+
134222417Sjulian	2dup at-xy ."   y/               [31;1m-/`   -o/[31m" 1+
135222417Sjulian	2dup at-xy ."  .-                  [31;1m::/sy+:.[31m" 1+
136222417Sjulian	2dup at-xy ."  /                     [31;1m`--  /[31m" 1+
137222417Sjulian	2dup at-xy ." `:                          [31;1m:`[31m" 1+
138222417Sjulian	2dup at-xy ." `:                          [31;1m:`[31m" 1+
139222417Sjulian	2dup at-xy ."  /                          [31;1m/[31m" 1+
140222417Sjulian	2dup at-xy ."  .-                        [31;1m-.[31m" 1+
141222417Sjulian	2dup at-xy ."   --                      [31;1m-.[31m" 1+
142222417Sjulian	2dup at-xy ."    `:`                  [31;1m`:`" 1+
143222417Sjulian	2dup at-xy ."      [31;1m.--             `--." 1+
144222417Sjulian	     at-xy ."         .---.....----.[37m"
145222417Sjulian
146222417Sjulian 	\ Put the cursor back at the bottom
147222417Sjulian 	0 25 at-xy
148120031Sscottl;
149120031Sscottl
150222417Sjulian: orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns)
151222417Sjulian
152222417Sjulian	3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
153222417Sjulian
154222417Sjulian	2dup at-xy ."  ```                        `" 1+
155222417Sjulian	2dup at-xy ." s` `.....---.......--.```   -/" 1+
156222417Sjulian	2dup at-xy ." +o   .--`         /y:`      +." 1+
157222417Sjulian	2dup at-xy ."  yo`:.            :o      `+-" 1+
158222417Sjulian	2dup at-xy ."   y/               -/`   -o/" 1+
159222417Sjulian	2dup at-xy ."  .-                  ::/sy+:." 1+
160222417Sjulian	2dup at-xy ."  /                     `--  /" 1+
161222417Sjulian	2dup at-xy ." `:                          :`" 1+
162222417Sjulian	2dup at-xy ." `:                          :`" 1+
163222417Sjulian	2dup at-xy ."  /                          /" 1+
164222417Sjulian	2dup at-xy ."  .-                        -." 1+
165222417Sjulian	2dup at-xy ."   --                      -." 1+
166222417Sjulian	2dup at-xy ."    `:`                  `:`" 1+
167222417Sjulian	2dup at-xy ."      .--             `--." 1+
168222417Sjulian	     at-xy ."         .---.....----."
169222417Sjulian
170222417Sjulian 	\ Put the cursor back at the bottom
171222417Sjulian 	0 25 at-xy
172215345Sjhb;
173215345Sjhb
174222417Sjulian\ This function draws any number of beastie logos at (loader_logo_x,
175222417Sjulian\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
176222417Sjulian\ your beastie, set the variable `loader_logo' to the respective logo name.
177222417Sjulian\ 
178222417Sjulian\ Currently available:
179222417Sjulian\ 
180222417Sjulian\ 	NAME        DESCRIPTION
181222417Sjulian\ 	beastie     Color ``Helper Daemon'' mascot (19 rows x 34 columns)
182222417Sjulian\ 	beastiebw   B/W ``Helper Daemon'' mascot (19 rows x 34 columns)
183222417Sjulian\ 	fbsdbw      "FreeBSD" logo in B/W (13 rows x 21 columns)
184254237Sdteske\ 	orb         Color ``Orb'' mascot (15 rows x 30 columns) (2nd default)
185254105Sdteske\ 	orbbw       B/W ``Orb'' mascot (15 rows x 32 columns)
186254237Sdteske\ 	tribute     Color ``Tribute'' (must fit 19 rows x 34 columns) (default)
187254237Sdteske\ 	tributebw   B/W ``Tribute'' (must fit 19 rows x 34 columns)
188222417Sjulian\ 
189222417Sjulian\ NOTE: Setting `loader_logo' to an undefined value (such as "none") will
190222417Sjulian\       prevent beastie from being drawn.
191222417Sjulian\ 
192222417Sjulian: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
193222417Sjulian
194222417Sjulian	s" loader_logo_x" getenv dup -1 <> if
195222417Sjulian		?number 1 = if logoX ! then
196138258Sscottl	else
197138258Sscottl		drop
198115410Sscottl	then
199222417Sjulian	s" loader_logo_y" getenv dup -1 <> if
200222417Sjulian		?number 1 = if logoY ! then
201222417Sjulian	else
202222417Sjulian		drop
203222417Sjulian	then
204115410Sscottl
205262703Sdteske	s" loader_logo" getenv dup -1 <> if
206262703Sdteske		dup 5 + allocate if ENOMEM throw then
207262703Sdteske		0 2swap strcat s" -logo" strcat
208262703Sdteske		over -rot ( a-addr/u -- a-addr a-addr/u )
209262703Sdteske		sfind     ( a-addr a-addr/u -- a-addr xt bool )
210262703Sdteske		rot       ( a-addr xt bool -- xt bool a-addr )
211262703Sdteske		free      ( xt bool a-addr -- xt bool ior )
212262703Sdteske		if EFREE throw then
213262703Sdteske	else
214262703Sdteske		0 ( cruft -- cruft bool ) \ load the default below
215262703Sdteske	then
216262703Sdteske	0= if
217262703Sdteske		drop ( cruft -- )
218222417Sjulian		loader_color? if
219262703Sdteske			['] orb-logo
220115410Sscottl		else
221262703Sdteske			['] orbbw-logo
222115410Sscottl		then
223115410Sscottl	then
224262703Sdteske	logoX @ logoY @ rot execute
225115410Sscottl;
226115410Sscottl
227222417Sjulian: clear-beastie ( -- ) \ clears beastie from the screen
228222417Sjulian	logoX @ logoY @
229222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
230222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
231222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
232222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
233222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
234222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
235222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
236222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
237222417Sjulian	2dup at-xy 34 spaces 1+		2dup at-xy 34 spaces 1+
238222417Sjulian	2dup at-xy 34 spaces		2drop
239222417Sjulian
240222417Sjulian	\ Put the cursor back at the bottom
241222417Sjulian	0 25 at-xy
242115410Sscottl;
243115410Sscottl
244222417Sjulian: beastie-start ( -- ) \ starts the menu
245271135Semaste	s" console" getenv dup -1 <> if
246271135Semaste		s" efi" 2swap contains? if
247271135Semaste			s" set beastie_disable=YES" evaluate
248271135Semaste		then
249271135Semaste	else drop then
250116175Sscottl	s" beastie_disable" getenv
251116175Sscottl	dup -1 <> if
252116175Sscottl		s" YES" compare-insensitive 0= if
253262701Sdteske			any_conf_read? if
254262701Sdteske				load_kernel
255262701Sdteske				load_modules
256262701Sdteske			then
257262701Sdteske			exit \ to autoboot (default)
258116175Sscottl		then
259138258Sscottl	else
260138258Sscottl		drop
261116175Sscottl	then
262222417Sjulian
263222417Sjulian	s" loader_delay" getenv
264222417Sjulian	-1 = if
265222417Sjulian		s" include /boot/menu.rc" evaluate
266222417Sjulian	else
267115410Sscottl		drop
268222417Sjulian		." Loading Menu (Ctrl-C to Abort)" cr
269222417Sjulian		s" set delay_command='include /boot/menu.rc'" evaluate
270222417Sjulian		s" set delay_showdots" evaluate
271222417Sjulian		delay_execute
272115410Sscottl	then
273115410Sscottl;
274262701Sdteske
275262701Sdteskeonly forth also
276