xref: /illumos-gate/usr/src/boot/forth/beastie.4th (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
1\ Copyright (c) 2003 Scott Long <scottl@FreeBSD.org>
2\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3\ Copyright (c) 2006-2015 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
27marker task-beastie.4th
28
29only forth definitions
30
31variable logoX
32variable logoY
33
34\ Initialize logo placement to defaults
3546 logoX !
364  logoY !
37
38\ This function draws any number of beastie logos at (loader_logo_x,
39\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
40\ your beastie, set the variable `loader_logo' to the respective logo name.
41\
42\ NOTE: Each is defined as a logo function in /boot/logo-${loader_logo}.4th
43\ NOTE: If `/boot/logo-${loader_logo}.4th' does not exist or does not define
44\       a `logo' function, no beastie is drawn.
45\
46: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
47
48	s" loader_logo_x" getenv dup -1 <> if
49		?number 1 = if logoX ! then
50	else drop then
51	s" loader_logo_y" getenv dup -1 <> if
52		?number 1 = if logoY ! then
53	else drop then
54
55
56	\ If `logo' is defined, execute it
57	s" logo" sfind ( -- xt|0 bool ) if
58		logoX @ logoY @ rot execute
59	else
60		\ Not defined; try-include desired logo file
61		drop ( xt = 0 ) \ cruft
62		s" loader_logo" getenv dup -1 = over 0= or if
63			dup 0= if 2drop else drop then \ getenv result unused
64			loader_color? if
65				s" try-include /boot/forth/logo-orb.4th"
66			else
67				s" try-include /boot/forth/logo-orbbw.4th"
68			then
69		else
70			2drop ( c-addr/u -- ) \ getenv result unused
71			s" try-include /boot/forth/logo-${loader_logo}.4th"
72		then
73		evaluate
74		1 spaces
75
76		\ Execute `logo' if defined now
77		s" logo" sfind if
78			logoX @ logoY @ rot execute
79		else drop then
80	then
81;
82
83: draw-beastie
84	['] draw-beastie console-iterate
85;
86
87also support-functions
88
89: beastie-start ( -- ) \ starts the menu
90	s" beastie_disable" getenv dup -1 <> if
91		s" YES" compare-insensitive 0= if
92			any_conf_read? if
93				load_xen_throw
94				load_kernel
95				load_modules
96			then
97			exit \ to autoboot (default)
98		then
99	else drop then
100
101	s" loader_delay" getenv -1 = if
102		s" include /boot/forth/menu.rc" evaluate
103	else
104		drop
105		." Loading Menu (Ctrl-C to Abort)" cr
106		s" set delay_command='include /boot/forth/menu.rc'" evaluate
107		s" set delay_showdots" evaluate
108		delay_execute
109	then
110;
111
112only forth definitions
113