xref: /freebsd/stand/forth/brand.4th (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1*ca987d46SWarner Losh\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
2*ca987d46SWarner Losh\ All rights reserved.
3*ca987d46SWarner Losh\
4*ca987d46SWarner Losh\ Redistribution and use in source and binary forms, with or without
5*ca987d46SWarner Losh\ modification, are permitted provided that the following conditions
6*ca987d46SWarner Losh\ are met:
7*ca987d46SWarner Losh\ 1. Redistributions of source code must retain the above copyright
8*ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer.
9*ca987d46SWarner Losh\ 2. Redistributions in binary form must reproduce the above copyright
10*ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer in the
11*ca987d46SWarner Losh\    documentation and/or other materials provided with the distribution.
12*ca987d46SWarner Losh\
13*ca987d46SWarner Losh\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*ca987d46SWarner Losh\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*ca987d46SWarner Losh\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*ca987d46SWarner Losh\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*ca987d46SWarner Losh\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*ca987d46SWarner Losh\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*ca987d46SWarner Losh\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*ca987d46SWarner Losh\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*ca987d46SWarner Losh\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*ca987d46SWarner Losh\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*ca987d46SWarner Losh\ SUCH DAMAGE.
24*ca987d46SWarner Losh\
25*ca987d46SWarner Losh\ $FreeBSD$
26*ca987d46SWarner Losh
27*ca987d46SWarner Loshmarker task-brand.4th
28*ca987d46SWarner Losh
29*ca987d46SWarner Loshvariable brandX
30*ca987d46SWarner Loshvariable brandY
31*ca987d46SWarner Losh
32*ca987d46SWarner Losh\ Initialize brand placement to defaults
33*ca987d46SWarner Losh2 brandX !
34*ca987d46SWarner Losh1 brandY !
35*ca987d46SWarner Losh
36*ca987d46SWarner Losh\ This function draws any number of company brands at (loader_brand_x,
37*ca987d46SWarner Losh\ loader_brand_y) if defined, or (2,1) (top-left). To choose your brand, set
38*ca987d46SWarner Losh\ the variable `loader_brand' to the respective brand name.
39*ca987d46SWarner Losh\
40*ca987d46SWarner Losh\ NOTE: Each is defined as a brand function in /boot/brand-${loader_brand}.4th
41*ca987d46SWarner Losh\ NOTE: If `/boot/brand-${loader_brand}.4th' does not exist or does not define
42*ca987d46SWarner Losh\       a `brand' function, no brand is drawn.
43*ca987d46SWarner Losh\
44*ca987d46SWarner Losh: draw-brand ( -- ) \ at (loader_brand_x,loader_brand_y), else (2,1)
45*ca987d46SWarner Losh
46*ca987d46SWarner Losh	s" loader_brand_x" getenv dup -1 <> if
47*ca987d46SWarner Losh		?number 1 = if brandX ! then
48*ca987d46SWarner Losh	else drop then
49*ca987d46SWarner Losh 	s" loader_brand_y" getenv dup -1 <> if
50*ca987d46SWarner Losh 		?number 1 = if brandY ! then
51*ca987d46SWarner Losh 	else drop then
52*ca987d46SWarner Losh
53*ca987d46SWarner Losh	\ If `brand' is defined, execute it
54*ca987d46SWarner Losh	s" brand" sfind ( -- xt|0 bool ) if
55*ca987d46SWarner Losh		brandX @ brandY @ rot execute
56*ca987d46SWarner Losh	else
57*ca987d46SWarner Losh		\ Not defined; try-include desired brand file
58*ca987d46SWarner Losh		drop ( xt = 0 ) \ cruft
59*ca987d46SWarner Losh		s" loader_brand" getenv dup -1 = over 0= or if
60*ca987d46SWarner Losh			dup 0= if 2drop else drop then \ getenv result unused
61*ca987d46SWarner Losh			s" try-include /boot/brand-fbsd.4th"
62*ca987d46SWarner Losh		else
63*ca987d46SWarner Losh			2drop ( c-addr/u -- ) \ getenv result unused
64*ca987d46SWarner Losh			s" try-include /boot/brand-${loader_brand}.4th"
65*ca987d46SWarner Losh		then
66*ca987d46SWarner Losh		evaluate
67*ca987d46SWarner Losh		1 spaces
68*ca987d46SWarner Losh
69*ca987d46SWarner Losh		\ Execute `brand' if defined now
70*ca987d46SWarner Losh		s" brand" sfind if
71*ca987d46SWarner Losh			brandX @ brandY @ rot execute
72*ca987d46SWarner Losh		else drop then
73*ca987d46SWarner Losh	then
74*ca987d46SWarner Losh;
75