version.4th revision 280933
1280924Sdteske\ Copyright (c) 2006-2015 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 280933 2015-04-01 01:14:19Z 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
52280924Sdteske		\ Use above default if no logo is requested
53254942Sdteske		s" loader_logo" getenv dup -1 = if
54254942Sdteske			drop str_loader_version
55254942Sdteske		else
56280933Sdteske			\ For tributes, do nothing (defer to logo-*.4th)
57254942Sdteske			2dup s" tribute" compare-insensitive 0= if
58254942Sdteske				2drop
59280933Sdteske				s" logo" sfind if
60280933Sdteske					drop exit \ see logo-tribute.4th
61254942Sdteske				else
62254942Sdteske					drop str_loader_version
63254942Sdteske				then
64254942Sdteske			else 2dup s" tributebw" compare-insensitive 0= if
65254942Sdteske				2drop
66280933Sdteske				s" logo" sfind if
67280933Sdteske					drop exit \ see logo-tributebw.4th
68254942Sdteske				else
69254942Sdteske					drop str_loader_version
70254942Sdteske				then
71254942Sdteske			else
72254942Sdteske				2drop str_loader_version
73254942Sdteske			then then
74254942Sdteske		then
75254942Sdteske	then dup -1 = if
76254942Sdteske		drop exit \ default version (above) is disabled
77222417Sjulian	then
78222417Sjulian
79222417Sjulian	\ Right justify the text
80222417Sjulian	dup versionX @ swap - versionY @ at-xy
81222417Sjulian
82222417Sjulian	\ Print the version (optionally in cyan)
83222417Sjulian	loader_color? if
84222417Sjulian		." [36m" type ." [37m"
85222417Sjulian	else
86222417Sjulian		type
87222417Sjulian	then
88222417Sjulian;
89