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