1228690Sdes\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
2228690Sdes\ All rights reserved.
3228690Sdes\ 
4228690Sdes\ Redistribution and use in source and binary forms, with or without
5228690Sdes\ modification, are permitted provided that the following conditions
6228690Sdes\ are met:
7228690Sdes\ 1. Redistributions of source code must retain the above copyright
8228690Sdes\    notice, this list of conditions and the following disclaimer.
9228690Sdes\ 2. Redistributions in binary form must reproduce the above copyright
10228690Sdes\    notice, this list of conditions and the following disclaimer in the
11228690Sdes\    documentation and/or other materials provided with the distribution.
12228690Sdes\ 
13228690Sdes\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14228690Sdes\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15228690Sdes\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16228690Sdes\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17228690Sdes\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18228690Sdes\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19228690Sdes\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20228690Sdes\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21228690Sdes\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22228690Sdes\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23228690Sdes\ SUCH DAMAGE.
24228690Sdes\ 
25228690Sdes\ $FreeBSD: releng/10.2/sys/boot/forth/version.4th 281843 2015-04-22 01:08:40Z dteske $
26228690Sdes
27228690Sdesmarker task-version.4th
28228690Sdes
29228690Sdesvocabulary version-processing
30228690Sdesonly forth also version-processing definitions
31228690Sdes
32228690Sdesvariable versionX
33228690Sdesvariable versionY
34228690Sdes
35255376Sdes\ Default $loader_version value if not overridden or using tribute screen
36228690Sdes: str_loader_version ( -- C-ADDR/U|-1 ) -1 ;
37228690Sdes
38236099Sdes\ Initialize text placement to defaults
39236099Sdes80 versionX !	\ NOTE: this is the ending column (text is right-justified)
40228690Sdes24 versionY !
41228690Sdes
42236099Sdesonly forth definitions also version-processing
43228690Sdes
44228690Sdes: print_version ( -- )
45228690Sdes
46236099Sdes	\ Get the text placement position (if set)
47228690Sdes	s" loader_version_x" getenv dup -1 <> if
48236099Sdes		?number drop versionX ! -1
49228690Sdes	then drop
50228690Sdes	s" loader_version_y" getenv dup -1 <> if
51228690Sdes		?number drop versionY ! -1
52236099Sdes	then drop
53228690Sdes
54228690Sdes	\ Default version if none was set
55228690Sdes	s" loader_version" getenv dup -1 = if
56228690Sdes		drop
57236099Sdes		\ Use above default if no logo is requested
58228690Sdes		s" loader_logo" getenv dup -1 = if
59236099Sdes			drop str_loader_version
60228690Sdes		else
61236099Sdes			\ For tributes, do nothing (defer to logo-*.4th)
62236099Sdes			2dup s" tribute" compare-insensitive 0= if
63236099Sdes				2drop
64236099Sdes				s" logo" sfind if
65236099Sdes					drop exit \ see logo-tribute.4th
66236099Sdes				else
67236099Sdes					drop str_loader_version
68236099Sdes				then
69236099Sdes			else 2dup s" tributebw" compare-insensitive 0= if
70228690Sdes				2drop
71228690Sdes				s" logo" sfind if
72228690Sdes					drop exit \ see logo-tributebw.4th
73236099Sdes				else
74228690Sdes					drop str_loader_version
75236099Sdes				then
76228690Sdes			else
77228690Sdes				2drop str_loader_version
78228690Sdes			then then
79228690Sdes		then
80236099Sdes	then dup -1 = if
81228690Sdes		drop exit \ default version (above) is disabled
82228690Sdes	then
83228690Sdes
84236099Sdes	\ Right justify the text
85228690Sdes	dup versionX @ swap - versionY @ at-xy
86236099Sdes
87228690Sdes	\ Print the version (optionally in cyan)
88236099Sdes	loader_color? dup ( c-addr/u -- c-addr/u bool bool )
89228690Sdes	if 6 fg then
90228690Sdes	-rot type
91228690Sdes	if me then
92228690Sdes
93228690Sdes	0 25 at-xy
94236099Sdes;
95228690Sdes
96236099Sdesonly forth definitions
97228690Sdes