xref: /illumos-gate/usr/src/boot/forth/version.4th (revision 22028508)
1199767f8SToomas Soome\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
21ea94c75SAndy Fiddaman\ Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
3199767f8SToomas Soome\ All rights reserved.
41ea94c75SAndy Fiddaman\
5199767f8SToomas Soome\ Redistribution and use in source and binary forms, with or without
6199767f8SToomas Soome\ modification, are permitted provided that the following conditions
7199767f8SToomas Soome\ are met:
8199767f8SToomas Soome\ 1. Redistributions of source code must retain the above copyright
9199767f8SToomas Soome\    notice, this list of conditions and the following disclaimer.
10199767f8SToomas Soome\ 2. Redistributions in binary form must reproduce the above copyright
11199767f8SToomas Soome\    notice, this list of conditions and the following disclaimer in the
12199767f8SToomas Soome\    documentation and/or other materials provided with the distribution.
131ea94c75SAndy Fiddaman\
14199767f8SToomas Soome\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15199767f8SToomas Soome\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16199767f8SToomas Soome\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17199767f8SToomas Soome\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18199767f8SToomas Soome\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19199767f8SToomas Soome\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20199767f8SToomas Soome\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21199767f8SToomas Soome\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22199767f8SToomas Soome\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23199767f8SToomas Soome\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24199767f8SToomas Soome\ SUCH DAMAGE.
25199767f8SToomas Soome
26199767f8SToomas Soomemarker task-version.4th
27199767f8SToomas Soome
28199767f8SToomas Soomevocabulary version-processing
29199767f8SToomas Soomeonly forth also version-processing definitions
30199767f8SToomas Soome
31199767f8SToomas Soomevariable versionX
32199767f8SToomas Soomevariable versionY
33199767f8SToomas Soome
34199767f8SToomas Soome\ Default $loader_version value if not overridden or using tribute screen
35199767f8SToomas Soome: str_loader_version ( -- C-ADDR/U|-1 ) -1 ;
36199767f8SToomas Soome
37199767f8SToomas Soome\ Initialize text placement to defaults
38199767f8SToomas Soome80 versionX !	\ NOTE: this is the ending column (text is right-justified)
39199767f8SToomas Soome24 versionY !
40199767f8SToomas Soome
41199767f8SToomas Soomeonly forth definitions also version-processing
42199767f8SToomas Soome
43199767f8SToomas Soome: print_version ( -- )
44199767f8SToomas Soome
45199767f8SToomas Soome	\ Get the text placement position (if set)
46199767f8SToomas Soome	s" loader_version_x" getenv dup -1 <> if
47199767f8SToomas Soome		?number drop versionX ! -1
48199767f8SToomas Soome	then drop
49199767f8SToomas Soome	s" loader_version_y" getenv dup -1 <> if
50199767f8SToomas Soome		?number drop versionY ! -1
51199767f8SToomas Soome	then drop
52199767f8SToomas Soome
53199767f8SToomas Soome	\ Default version if none was set
54199767f8SToomas Soome	s" loader_version" getenv dup -1 = if
55199767f8SToomas Soome		drop
56199767f8SToomas Soome		\ Use above default if no logo is requested
57199767f8SToomas Soome		s" loader_logo" getenv dup -1 = if
58199767f8SToomas Soome			drop str_loader_version
59199767f8SToomas Soome		else
60199767f8SToomas Soome			\ For tributes, do nothing (defer to logo-*.4th)
61199767f8SToomas Soome			2dup s" tribute" compare-insensitive 0= if
62199767f8SToomas Soome				2drop
63199767f8SToomas Soome				s" logo" sfind if
64199767f8SToomas Soome					drop exit \ see logo-tribute.4th
65199767f8SToomas Soome				else
66199767f8SToomas Soome					drop str_loader_version
67199767f8SToomas Soome				then
68199767f8SToomas Soome			else 2dup s" tributebw" compare-insensitive 0= if
69199767f8SToomas Soome				2drop
70199767f8SToomas Soome				s" logo" sfind if
71199767f8SToomas Soome					drop exit \ see logo-tributebw.4th
72199767f8SToomas Soome				else
73199767f8SToomas Soome					drop str_loader_version
74199767f8SToomas Soome				then
75199767f8SToomas Soome			else
76199767f8SToomas Soome				2drop str_loader_version
77199767f8SToomas Soome			then then
78199767f8SToomas Soome		then
79199767f8SToomas Soome	then dup -1 = if
80199767f8SToomas Soome		drop exit \ default version (above) is disabled
81199767f8SToomas Soome	then
82199767f8SToomas Soome
83199767f8SToomas Soome	\ Right justify the text
84199767f8SToomas Soome	dup versionX @ swap - versionY @ at-xy
85199767f8SToomas Soome
86199767f8SToomas Soome	\ Print the version (optionally in cyan)
87199767f8SToomas Soome	loader_color? dup ( c-addr/u -- c-addr/u bool bool )
88199767f8SToomas Soome	if 6 fg then
89199767f8SToomas Soome	-rot type
90199767f8SToomas Soome	if me then
91199767f8SToomas Soome
921ea94c75SAndy Fiddaman	at-bl
93199767f8SToomas Soome;
94199767f8SToomas Soome
95199767f8SToomas Soomeonly forth definitions
96