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