version.4th revision 254942
1238431Sdteske\ Copyright (c) 2006-2011 Devin Teske <dteske@FreeBSD.org>
2222417Sjulian\ All rights reserved.
3222417Sjulian\ 
4222417Sjulian\ Redistribution and use in source and binary forms, with or without
5222417Sjulian\ modification, are permitted provided that the following conditions
6222417Sjulian\ are met:
7222417Sjulian\ 1. Redistributions of source code must retain the above copyright
8222417Sjulian\    notice, this list of conditions and the following disclaimer.
9222417Sjulian\ 2. Redistributions in binary form must reproduce the above copyright
10222417Sjulian\    notice, this list of conditions and the following disclaimer in the
11222417Sjulian\    documentation and/or other materials provided with the distribution.
12222417Sjulian\ 
13222417Sjulian\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14222417Sjulian\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15222417Sjulian\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16222417Sjulian\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17222417Sjulian\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18222417Sjulian\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19222417Sjulian\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20222417Sjulian\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21222417Sjulian\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22222417Sjulian\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23222417Sjulian\ SUCH DAMAGE.
24222417Sjulian\ 
25222417Sjulian\ $FreeBSD: head/sys/boot/forth/version.4th 254942 2013-08-26 23:37:11Z dteske $
26222417Sjulian
27222417Sjulianmarker task-version.4th
28222417Sjulian
29222417Sjulianvariable versionX
30222417Sjulianvariable versionY
31222417Sjulian
32254942Sdteske\ Default $loader_version value if not overridden or using tribute screen
33254942Sdteske: str_loader_version ( -- C-ADDR/U|-1 ) -1 ;
34254942Sdteske
35222417Sjulian\ Initialize text placement to defaults
36222417Sjulian80 versionX !	\ NOTE: this is the ending column (text is right-justified)
37222417Sjulian24 versionY !
38222417Sjulian
39222417Sjulian: print_version ( -- )
40222417Sjulian
41222417Sjulian	\ Get the text placement position (if set)
42222417Sjulian	s" loader_version_x" getenv dup -1 <> if
43222417Sjulian		?number drop versionX ! -1
44222417Sjulian	then drop
45222417Sjulian	s" loader_version_y" getenv dup -1 <> if
46222417Sjulian		?number drop versionY ! -1
47222417Sjulian	then drop
48222417Sjulian
49254942Sdteske	\ Default version if none was set
50222417Sjulian	s" loader_version" getenv dup -1 = if
51254942Sdteske		drop
52254942Sdteske		\ Default version if no logo is requested
53254942Sdteske		s" loader_logo" getenv dup -1 = if
54254942Sdteske			drop str_loader_version
55254942Sdteske		else
56254942Sdteske			2dup s" tribute" compare-insensitive 0= if
57254942Sdteske				2drop
58254942Sdteske				s" tribute-logo" sfind if
59254942Sdteske					drop exit \ see beastie tribute-text
60254942Sdteske				else
61254942Sdteske					drop str_loader_version
62254942Sdteske				then
63254942Sdteske			else 2dup s" tributebw" compare-insensitive 0= if
64254942Sdteske				2drop
65254942Sdteske				s" tributebw-logo" sfind if
66254942Sdteske					drop exit \ see beastie tribute-text
67254942Sdteske				else
68254942Sdteske					drop str_loader_version
69254942Sdteske				then
70254942Sdteske			else
71254942Sdteske				2drop str_loader_version
72254942Sdteske			then then
73254942Sdteske		then
74254942Sdteske	then dup -1 = if
75254942Sdteske		drop exit \ default version (above) is disabled
76222417Sjulian	then
77222417Sjulian
78222417Sjulian	\ Right justify the text
79222417Sjulian	dup versionX @ swap - versionY @ at-xy
80222417Sjulian
81222417Sjulian	\ Print the version (optionally in cyan)
82222417Sjulian	loader_color? if
83222417Sjulian		." [36m" type ." [37m"
84222417Sjulian	else
85222417Sjulian		type
86222417Sjulian	then
87222417Sjulian;
88