1199767f8SToomas Soome\ Copyright (c) 2003 Scott Long <scottl@FreeBSD.org> 2199767f8SToomas Soome\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> 3199767f8SToomas Soome\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org> 4a1625066SAndy Fiddaman\ Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 5199767f8SToomas Soome\ All rights reserved. 61ea94c75SAndy Fiddaman\ 7199767f8SToomas Soome\ Redistribution and use in source and binary forms, with or without 8199767f8SToomas Soome\ modification, are permitted provided that the following conditions 9199767f8SToomas Soome\ are met: 10199767f8SToomas Soome\ 1. Redistributions of source code must retain the above copyright 11199767f8SToomas Soome\ notice, this list of conditions and the following disclaimer. 12199767f8SToomas Soome\ 2. Redistributions in binary form must reproduce the above copyright 13199767f8SToomas Soome\ notice, this list of conditions and the following disclaimer in the 14199767f8SToomas Soome\ documentation and/or other materials provided with the distribution. 151ea94c75SAndy Fiddaman\ 16199767f8SToomas Soome\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17199767f8SToomas Soome\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18199767f8SToomas Soome\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19199767f8SToomas Soome\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20199767f8SToomas Soome\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21199767f8SToomas Soome\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22199767f8SToomas Soome\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23199767f8SToomas Soome\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24199767f8SToomas Soome\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25199767f8SToomas Soome\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26199767f8SToomas Soome\ SUCH DAMAGE. 27199767f8SToomas Soome 28199767f8SToomas Soomemarker task-menu.4th 29199767f8SToomas Soome 30199767f8SToomas Soome\ Frame drawing 31199767f8SToomas Soomeinclude /boot/forth/frames.4th 32199767f8SToomas Soome 33199767f8SToomas Soomevocabulary menu-infrastructure 34199767f8SToomas Soomevocabulary menu-namespace 35199767f8SToomas Soomevocabulary menu-command-helpers 36199767f8SToomas Soome 37199767f8SToomas Soomeonly forth also menu-infrastructure definitions 38199767f8SToomas Soome 39199767f8SToomas Soomef_double \ Set frames to double (see frames.4th). Replace with 40199767f8SToomas Soome \ f_single if you want single frames. 41199767f8SToomas Soome46 constant dot \ ASCII definition of a period (in decimal) 42199767f8SToomas Soome 43199767f8SToomas Soome 5 constant menu_default_x \ default column position of timeout 44199767f8SToomas Soome10 constant menu_default_y \ default row position of timeout msg 45199767f8SToomas Soome 4 constant menu_timeout_default_x \ default column position of timeout 46199767f8SToomas Soome23 constant menu_timeout_default_y \ default row position of timeout msg 47199767f8SToomas Soome10 constant menu_timeout_default \ default timeout (in seconds) 48199767f8SToomas Soome 49199767f8SToomas Soome\ Customize the following values with care 50199767f8SToomas Soome 51199767f8SToomas Soome 1 constant menu_start \ Numerical prefix of first menu item 52199767f8SToomas Soomedot constant bullet \ Menu bullet (appears after numerical prefix) 53199767f8SToomas Soome 5 constant menu_x \ Row position of the menu (from the top) 54199767f8SToomas Soome 10 constant menu_y \ Column position of the menu (from left side) 55199767f8SToomas Soome 56199767f8SToomas Soome\ Menu Appearance 57199767f8SToomas Soomevariable menuidx \ Menu item stack for number prefixes 58199767f8SToomas Soomevariable menurow \ Menu item stack for positioning 59199767f8SToomas Soomevariable menubllt \ Menu item bullet 60199767f8SToomas Soome 61199767f8SToomas Soome\ Menu Positioning 62199767f8SToomas Soomevariable menuX \ Menu X offset (columns) 63199767f8SToomas Soomevariable menuY \ Menu Y offset (rows) 64199767f8SToomas Soome 65199767f8SToomas Soome\ Menu-item elements 66199767f8SToomas Soomevariable menurebootadded 67199767f8SToomas Soome 68199767f8SToomas Soome\ Menu timer [count-down] variables 69199767f8SToomas Soomevariable menu_timeout_enabled \ timeout state (internal use only) 70199767f8SToomas Soomevariable menu_time \ variable for tracking the passage of time 71199767f8SToomas Soomevariable menu_timeout \ determined configurable delay duration 72199767f8SToomas Soomevariable menu_timeout_x \ column position of timeout message 73199767f8SToomas Soomevariable menu_timeout_y \ row position of timeout message 74199767f8SToomas Soome 75199767f8SToomas Soomeonly forth also menu-namespace definitions 76199767f8SToomas Soome 77199767f8SToomas Soome\ Menu-item key association/detection 78199767f8SToomas Soomevariable menukey1 79199767f8SToomas Soomevariable menukey2 80199767f8SToomas Soomevariable menukey3 81199767f8SToomas Soomevariable menukey4 82199767f8SToomas Soomevariable menukey5 83199767f8SToomas Soomevariable menukey6 84199767f8SToomas Soomevariable menukey7 85199767f8SToomas Soomevariable menukey8 86199767f8SToomas Soomevariable menureboot 87199767f8SToomas Soomevariable menuacpi 88199767f8SToomas Soomevariable menuosconsole 89a1625066SAndy Fiddamanvariable menukmdb 90199767f8SToomas Soomevariable menuoptions 91199767f8SToomas Soome 92199767f8SToomas Soome\ Menu initialization status variables 93199767f8SToomas Soomevariable init_state1 94199767f8SToomas Soomevariable init_state2 95199767f8SToomas Soomevariable init_state3 96199767f8SToomas Soomevariable init_state4 97199767f8SToomas Soomevariable init_state5 98199767f8SToomas Soomevariable init_state6 99199767f8SToomas Soomevariable init_state7 100199767f8SToomas Soomevariable init_state8 101199767f8SToomas Soome 102199767f8SToomas Soome\ Boolean option status variables 103199767f8SToomas Soomevariable toggle_state1 104199767f8SToomas Soomevariable toggle_state2 105199767f8SToomas Soomevariable toggle_state3 106199767f8SToomas Soomevariable toggle_state4 107199767f8SToomas Soomevariable toggle_state5 108199767f8SToomas Soomevariable toggle_state6 109199767f8SToomas Soomevariable toggle_state7 110199767f8SToomas Soomevariable toggle_state8 111199767f8SToomas Soome 112199767f8SToomas Soome\ Array option status variables 113199767f8SToomas Soomevariable cycle_state1 114199767f8SToomas Soomevariable cycle_state2 115199767f8SToomas Soomevariable cycle_state3 116199767f8SToomas Soomevariable cycle_state4 117199767f8SToomas Soomevariable cycle_state5 118199767f8SToomas Soomevariable cycle_state6 119199767f8SToomas Soomevariable cycle_state7 120199767f8SToomas Soomevariable cycle_state8 121199767f8SToomas Soome 122199767f8SToomas Soome\ Containers for storing the initial caption text 123199767f8SToomas Soomecreate init_text1 64 allot 124199767f8SToomas Soomecreate init_text2 64 allot 125199767f8SToomas Soomecreate init_text3 64 allot 126199767f8SToomas Soomecreate init_text4 64 allot 127199767f8SToomas Soomecreate init_text5 64 allot 128199767f8SToomas Soomecreate init_text6 64 allot 129199767f8SToomas Soomecreate init_text7 64 allot 130199767f8SToomas Soomecreate init_text8 64 allot 131199767f8SToomas Soome 132199767f8SToomas Soomeonly forth definitions 133199767f8SToomas Soome 134199767f8SToomas Soome: arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise. 135*dfaefdd8SToomas Soome \ FICL_PLATFORM_ARCHITECTURE is always defined, drop flag 136*dfaefdd8SToomas Soome s" FICL_PLATFORM_ARCHITECTURE" environment? drop 137*dfaefdd8SToomas Soome s" i386" compare 0<> if 138*dfaefdd8SToomas Soome true 139*dfaefdd8SToomas Soome else 140*dfaefdd8SToomas Soome false 141199767f8SToomas Soome then 142199767f8SToomas Soome; 143199767f8SToomas Soome 144199767f8SToomas Soome: acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise 145199767f8SToomas Soome s" hint.acpi.0.rsdp" getenv 146199767f8SToomas Soome dup -1 = if 147199767f8SToomas Soome drop false exit 148199767f8SToomas Soome then 149199767f8SToomas Soome 2drop 150199767f8SToomas Soome true 151199767f8SToomas Soome; 152199767f8SToomas Soome 153199767f8SToomas Soome: acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise 154199767f8SToomas Soome s" hint.acpi.0.disabled" getenv 155199767f8SToomas Soome dup -1 <> if 156199767f8SToomas Soome s" 0" compare 0<> if 157199767f8SToomas Soome false exit 158199767f8SToomas Soome then 159199767f8SToomas Soome else 160199767f8SToomas Soome drop 161199767f8SToomas Soome then 162199767f8SToomas Soome true 163199767f8SToomas Soome; 164199767f8SToomas Soome 165199767f8SToomas Soome: +c! ( N C-ADDR/U K -- C-ADDR/U ) 166199767f8SToomas Soome 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr ) 167199767f8SToomas Soome rot + c! ( n c-addr/u k n c-addr -- n c-addr/u ) 168199767f8SToomas Soome rot drop ( n c-addr/u -- c-addr/u ) 169199767f8SToomas Soome; 170199767f8SToomas Soome 171199767f8SToomas Soomeonly forth also menu-namespace definitions 172199767f8SToomas Soome 173199767f8SToomas Soome\ Forth variables 174199767f8SToomas Soome: namespace ( C-ADDR/U N -- ) also menu-namespace +c! evaluate previous ; 175199767f8SToomas Soome: menukeyN ( N -- ADDR ) s" menukeyN" 7 namespace ; 176199767f8SToomas Soome: init_stateN ( N -- ADDR ) s" init_stateN" 10 namespace ; 177199767f8SToomas Soome: toggle_stateN ( N -- ADDR ) s" toggle_stateN" 12 namespace ; 178199767f8SToomas Soome: cycle_stateN ( N -- ADDR ) s" cycle_stateN" 11 namespace ; 179199767f8SToomas Soome: init_textN ( N -- C-ADDR ) s" init_textN" 9 namespace ; 180199767f8SToomas Soome 181199767f8SToomas Soome\ Environment variables 182199767f8SToomas Soome: menu_init[x] ( N -- C-ADDR/U ) s" menu_init[x]" 10 +c! ; 183199767f8SToomas Soome: menu_command[x] ( N -- C-ADDR/U ) s" menu_command[x]" 13 +c! ; 184199767f8SToomas Soome: menu_caption[x] ( N -- C-ADDR/U ) s" menu_caption[x]" 13 +c! ; 185199767f8SToomas Soome: ansi_caption[x] ( N -- C-ADDR/U ) s" ansi_caption[x]" 13 +c! ; 186199767f8SToomas Soome: menu_keycode[x] ( N -- C-ADDR/U ) s" menu_keycode[x]" 13 +c! ; 187199767f8SToomas Soome: toggled_text[x] ( N -- C-ADDR/U ) s" toggled_text[x]" 13 +c! ; 188199767f8SToomas Soome: toggled_ansi[x] ( N -- C-ADDR/U ) s" toggled_ansi[x]" 13 +c! ; 189199767f8SToomas Soome: menu_caption[x][y] ( N M -- C-ADDR/U ) s" menu_caption[x][y]" 16 +c! 13 +c! ; 190199767f8SToomas Soome: ansi_caption[x][y] ( N M -- C-ADDR/U ) s" ansi_caption[x][y]" 16 +c! 13 +c! ; 191199767f8SToomas Soome 192199767f8SToomas Soomealso menu-infrastructure definitions 193199767f8SToomas Soome 194199767f8SToomas Soome\ This function prints a menu item at menuX (row) and menuY (column), returns 195199767f8SToomas Soome\ the incremental decimal ASCII value associated with the menu item, and 196199767f8SToomas Soome\ increments the cursor position to the next row for the creation of the next 197199767f8SToomas Soome\ menu item. This function is called by the menu-create function. You need not 198199767f8SToomas Soome\ call it directly. 1991ea94c75SAndy Fiddaman\ 200199767f8SToomas Soome: printmenuitem ( menu_item_str -- ascii_keycode ) 201199767f8SToomas Soome 202199767f8SToomas Soome loader_color? if [char] ^ escc! then 203199767f8SToomas Soome 204199767f8SToomas Soome menurow dup @ 1+ swap ! ( increment menurow ) 205199767f8SToomas Soome menuidx dup @ 1+ swap ! ( increment menuidx ) 206199767f8SToomas Soome 207199767f8SToomas Soome \ Calculate the menuitem row position 208199767f8SToomas Soome menurow @ menuY @ + 209199767f8SToomas Soome 210199767f8SToomas Soome \ Position the cursor at the menuitem position 211199767f8SToomas Soome dup menuX @ swap at-xy 212199767f8SToomas Soome 213199767f8SToomas Soome \ Print the value of menuidx 214199767f8SToomas Soome loader_color? dup ( -- bool bool ) 215199767f8SToomas Soome if b then 216199767f8SToomas Soome menuidx @ . 217199767f8SToomas Soome if me then 218199767f8SToomas Soome 219199767f8SToomas Soome \ Move the cursor forward 1 column 220199767f8SToomas Soome dup menuX @ 1+ swap at-xy 221199767f8SToomas Soome 222199767f8SToomas Soome menubllt @ emit \ Print the menu bullet using the emit function 223199767f8SToomas Soome 224199767f8SToomas Soome \ Move the cursor to the 3rd column from the current position 225199767f8SToomas Soome \ to allow for a space between the numerical prefix and the 226199767f8SToomas Soome \ text caption 227199767f8SToomas Soome menuX @ 3 + swap at-xy 228199767f8SToomas Soome 229199767f8SToomas Soome \ Print the menu caption (we expect a string to be on the stack 230199767f8SToomas Soome \ prior to invoking this function) 231199767f8SToomas Soome type 232199767f8SToomas Soome 233199767f8SToomas Soome \ Here we will add the ASCII decimal of the numerical prefix 234199767f8SToomas Soome \ to the stack (decimal ASCII for `1' is 49) as a "return value" 235199767f8SToomas Soome menuidx @ 48 + 236199767f8SToomas Soome; 237199767f8SToomas Soome 238199767f8SToomas Soome: delim? ( C -- BOOL ) 239199767f8SToomas Soome dup 32 = ( c -- c bool ) \ [sp] space 240199767f8SToomas Soome over 9 = or ( c bool -- c bool ) \ [ht] horizontal tab 241199767f8SToomas Soome over 10 = or ( c bool -- c bool ) \ [nl] newline 242199767f8SToomas Soome over 13 = or ( c bool -- c bool ) \ [cr] carriage return 243199767f8SToomas Soome over [char] , = or ( c bool -- c bool ) \ comma 244199767f8SToomas Soome swap drop ( c bool -- bool ) \ return boolean 245199767f8SToomas Soome; 246199767f8SToomas Soome 247a1625066SAndy Fiddaman\ illumos kernel acpi-user-options has following values: 248199767f8SToomas Soome\ default: 0 - system will enable acpi based on bios date 249199767f8SToomas Soome\ on: 1 - acpi is set on 250199767f8SToomas Soome\ off: 2 - acpi is set off 251199767f8SToomas Soome\ madt: 4 - use only MADT 252199767f8SToomas Soome\ legacy: 8 - use legacy mode 253199767f8SToomas Soome 254199767f8SToomas Soome: acpi-captions ( N -- ) 255199767f8SToomas Soome \ first entry 256a1625066SAndy Fiddaman dup s" [A]CPI................ default" rot 48 menu_caption[x][y] setenv 257c3e6a6edSJohn Levon dup s" ^[1mA^[mCPI.............. ^[32;7mdefault^[m" rot 48 ansi_caption[x][y] setenv 258199767f8SToomas Soome 259a1625066SAndy Fiddaman dup s" [A]CPI................ On" rot 49 menu_caption[x][y] setenv 260c3e6a6edSJohn Levon dup s" ^[1mA^[mCPI.............. ^[34;1mOn^[m" rot 49 ansi_caption[x][y] setenv 261199767f8SToomas Soome 262a1625066SAndy Fiddaman dup s" [A]CPI................ Off" rot 50 menu_caption[x][y] setenv 263c3e6a6edSJohn Levon dup s" ^[1mA^[mCPI.............. ^[34;1mOff^[m" rot 50 ansi_caption[x][y] setenv 264199767f8SToomas Soome 265a1625066SAndy Fiddaman dup s" [A]CPI................ MADT" rot 51 menu_caption[x][y] setenv 266c3e6a6edSJohn Levon dup s" ^[1mA^[mCPI.............. ^[34;1mMADT^[m" rot 51 ansi_caption[x][y] setenv 267199767f8SToomas Soome 268a1625066SAndy Fiddaman dup s" [A]CPI................ Legacy" rot 52 menu_caption[x][y] setenv 269c3e6a6edSJohn Levon s" ^[1mA^[mCPI.............. ^[34;1mLegacy^[m" rot 52 ansi_caption[x][y] setenv 270199767f8SToomas Soome; 271199767f8SToomas Soome 272a1625066SAndy Fiddaman\ illumos console has following values: 273199767f8SToomas Soome\ text, ttya, ttyb, ttyc, ttyd 274199767f8SToomas Soome 275199767f8SToomas Soome: osconsole-captions ( N -- ) 276199767f8SToomas Soome \ first entry 277a1625066SAndy Fiddaman dup s" Os[C]onsole........... text" rot 48 menu_caption[x][y] setenv 278c3e6a6edSJohn Levon dup s" Os^[1mC^[monsole............ ^[32;7mtext^[m" rot 48 ansi_caption[x][y] setenv 279199767f8SToomas Soome 280a1625066SAndy Fiddaman dup s" Os[C]onsole........... ttya" rot 49 menu_caption[x][y] setenv 281c3e6a6edSJohn Levon dup s" Os^[1mC^[monsole............ ^[34;1mttya^[m" rot 49 ansi_caption[x][y] setenv 282199767f8SToomas Soome 283a1625066SAndy Fiddaman dup s" Os[C]onsole........... ttyb" rot 50 menu_caption[x][y] setenv 284c3e6a6edSJohn Levon dup s" Os^[1mC^[monsole............ ^[34;1mttyb^[m" rot 50 ansi_caption[x][y] setenv 285199767f8SToomas Soome 286a1625066SAndy Fiddaman dup s" Os[C]onsole........... ttyc" rot 51 menu_caption[x][y] setenv 287c3e6a6edSJohn Levon dup s" Os^[1mC^[monsole............ ^[34;1mttyc^[m" rot 51 ansi_caption[x][y] setenv 288199767f8SToomas Soome 289a1625066SAndy Fiddaman dup s" Os[C]onsole........... ttyd" rot 52 menu_caption[x][y] setenv 290c3e6a6edSJohn Levon s" Os^[1mC^[monsole............ ^[34;1mttyd^[m" rot 52 ansi_caption[x][y] setenv 291199767f8SToomas Soome; 292199767f8SToomas Soome 293a1625066SAndy Fiddaman\ kmdb options are as follows 294a1625066SAndy Fiddaman\ default: 0 - disabled 295a1625066SAndy Fiddaman\ 1 - boot with -k option 296a1625066SAndy Fiddaman\ 2 - as 1 + configure NMI to drop to kmdb 297a1625066SAndy Fiddaman\ 3 - boot with -k and -d options 298a1625066SAndy Fiddaman\ 4 - as 3 + configure NMI to drop to kmdb 299a1625066SAndy Fiddaman 300a1625066SAndy Fiddaman: kmdb-captions ( N -- ) 301a1625066SAndy Fiddaman \ first entry 302a1625066SAndy Fiddaman dup s" [k]mdb Mode........... Off" rot 48 menu_caption[x][y] setenv 303a1625066SAndy Fiddaman dup s" ^[1mk^[mmdb Mode............. ^[34;1mOff^[m" rot 48 ansi_caption[x][y] setenv 304a1625066SAndy Fiddaman 305a1625066SAndy Fiddaman dup s" [k]mdb Mode........... Loaded" rot 49 menu_caption[x][y] setenv 306a1625066SAndy Fiddaman dup s" ^[1mk^[mmdb Mode............. ^[32;7mLoaded^[m" rot 49 ansi_caption[x][y] setenv 307a1625066SAndy Fiddaman 308a1625066SAndy Fiddaman dup s" [k]mdb Mode........... On NMI" rot 50 menu_caption[x][y] setenv 309a1625066SAndy Fiddaman dup s" ^[1mk^[mmdb Mode............. ^[32;7mOn NMI^[m" rot 50 ansi_caption[x][y] setenv 310a1625066SAndy Fiddaman 311a1625066SAndy Fiddaman dup s" [k]mdb Mode........... On Boot" rot 51 menu_caption[x][y] setenv 312a1625066SAndy Fiddaman dup s" ^[1mk^[mmdb Mode............. ^[32;7mOn Boot^[m" rot 51 ansi_caption[x][y] setenv 313a1625066SAndy Fiddaman 314a1625066SAndy Fiddaman dup s" [k]mdb Mode........... On Boot/NMI" rot 52 menu_caption[x][y] setenv 315a1625066SAndy Fiddaman s" ^[1mk^[mmdb Mode............. ^[32;7mOn Boot/NMI^[m" rot 52 ansi_caption[x][y] setenv 316a1625066SAndy Fiddaman; 317a1625066SAndy Fiddaman 318a1625066SAndy Fiddaman: set-captions ( x y - x y ) 319a1625066SAndy Fiddaman \ Set the current non-ANSI caption 320a1625066SAndy Fiddaman 2dup swap dup ( x y -- x y y x x ) 321a1625066SAndy Fiddaman s" set menu_caption[x]=$menu_caption[x][y]" 322a1625066SAndy Fiddaman 17 +c! 34 +c! 37 +c! evaluate 323a1625066SAndy Fiddaman ( x y y x x c-addr/u -- x y ) 324a1625066SAndy Fiddaman 325a1625066SAndy Fiddaman \ Set the current ANSI caption 326a1625066SAndy Fiddaman 2dup swap dup ( x y -- x y y x x ) 327a1625066SAndy Fiddaman s" set ansi_caption[x]=$ansi_caption[x][y]" 328a1625066SAndy Fiddaman 17 +c! 34 +c! 37 +c! evaluate 329a1625066SAndy Fiddaman ( x y y x x c-addr/u -- x y ) 330a1625066SAndy Fiddaman; 331a1625066SAndy Fiddaman 332199767f8SToomas Soome\ This function creates the list of menu items. This function is called by the 333199767f8SToomas Soome\ menu-display function. You need not call it directly. 3341ea94c75SAndy Fiddaman\ 335199767f8SToomas Soome: menu-create ( -- ) 336199767f8SToomas Soome 337199767f8SToomas Soome \ Print the frame caption at (x,y) 338199767f8SToomas Soome s" loader_menu_title" getenv dup -1 = if 339199767f8SToomas Soome drop s" Welcome to illumos" 340199767f8SToomas Soome then 341199767f8SToomas Soome TRUE ( use default alignment ) 342199767f8SToomas Soome s" loader_menu_title_align" getenv dup -1 <> if 343199767f8SToomas Soome 2dup s" left" compare-insensitive 0= if ( 1 ) 344199767f8SToomas Soome 2drop ( c-addr/u ) drop ( bool ) 345199767f8SToomas Soome menuX @ menuY @ 1- 346199767f8SToomas Soome FALSE ( don't use default alignment ) 347199767f8SToomas Soome else ( 1 ) 2dup s" right" compare-insensitive 0= if ( 2 ) 348199767f8SToomas Soome 2drop ( c-addr/u ) drop ( bool ) 349199767f8SToomas Soome menuX @ 42 + 4 - over - menuY @ 1- 350199767f8SToomas Soome FALSE ( don't use default alignment ) 351199767f8SToomas Soome else ( 2 ) 2drop ( c-addr/u ) then ( 1 ) then 352199767f8SToomas Soome else 353199767f8SToomas Soome drop ( getenv cruft ) 354199767f8SToomas Soome then 355199767f8SToomas Soome if ( use default center alignement? ) 356199767f8SToomas Soome menuX @ 19 + over 2 / - menuY @ 1- 357199767f8SToomas Soome then 3581ea94c75SAndy Fiddaman at-xy type 359199767f8SToomas Soome 360199767f8SToomas Soome \ If $menu_init is set, evaluate it (allowing for whole menus to be 361199767f8SToomas Soome \ constructed dynamically -- as this function could conceivably set 362199767f8SToomas Soome \ the remaining environment variables to construct the menu entirely). 3631ea94c75SAndy Fiddaman \ 364199767f8SToomas Soome s" menu_init" getenv dup -1 <> if 365199767f8SToomas Soome evaluate 366199767f8SToomas Soome else 367199767f8SToomas Soome drop 368199767f8SToomas Soome then 369199767f8SToomas Soome 370199767f8SToomas Soome \ Print our menu options with respective key/variable associations. 371199767f8SToomas Soome \ `printmenuitem' ends by adding the decimal ASCII value for the 372199767f8SToomas Soome \ numerical prefix to the stack. We store the value left on the stack 373199767f8SToomas Soome \ to the key binding variable for later testing against a character 374199767f8SToomas Soome \ captured by the `getkey' function. 375199767f8SToomas Soome 376199767f8SToomas Soome \ Note that any menu item beyond 9 will have a numerical prefix on the 377199767f8SToomas Soome \ screen consisting of the first digit (ie. 1 for the tenth menu item) 378199767f8SToomas Soome \ and the key required to activate that menu item will be the decimal 379199767f8SToomas Soome \ ASCII of 48 plus the menu item (ie. 58 for the tenth item, aka. `:') 380199767f8SToomas Soome \ which is misleading and not desirable. 3811ea94c75SAndy Fiddaman \ 382199767f8SToomas Soome \ Thus, we do not allow more than 8 configurable items on the menu 383199767f8SToomas Soome \ (with "Reboot" as the optional ninth and highest numbered item). 384199767f8SToomas Soome 3851ea94c75SAndy Fiddaman \ 386199767f8SToomas Soome \ Initialize the OsConsole option status. 3871ea94c75SAndy Fiddaman \ 388199767f8SToomas Soome 0 menuosconsole ! 389199767f8SToomas Soome s" menu_osconsole" getenv -1 <> if 390199767f8SToomas Soome c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) 391199767f8SToomas Soome dup menuosconsole ! 392199767f8SToomas Soome dup osconsole-captions 393199767f8SToomas Soome 394199767f8SToomas Soome s" init_osconsole" evaluate 395199767f8SToomas Soome 396199767f8SToomas Soome \ Get the current cycle state (entry to use) 397199767f8SToomas Soome s" osconsole_state" evaluate @ 48 + ( n -- n y ) 398199767f8SToomas Soome 399a1625066SAndy Fiddaman set-captions 400199767f8SToomas Soome 401199767f8SToomas Soome \ Initialize cycle state from stored value 402199767f8SToomas Soome 48 - ( n y -- n k ) 403199767f8SToomas Soome s" init_cyclestate" evaluate ( n k -- n ) 404199767f8SToomas Soome 405199767f8SToomas Soome \ Set $os_console 406199767f8SToomas Soome s" activate_osconsole" evaluate ( n -- n ) 407199767f8SToomas Soome then 408199767f8SToomas Soome drop 409199767f8SToomas Soome then 410199767f8SToomas Soome 4111ea94c75SAndy Fiddaman \ 412199767f8SToomas Soome \ Initialize the ACPI option status. 4131ea94c75SAndy Fiddaman \ 414199767f8SToomas Soome 0 menuacpi ! 415199767f8SToomas Soome s" menu_acpi" getenv -1 <> if 416199767f8SToomas Soome c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) 417199767f8SToomas Soome dup menuacpi ! 418199767f8SToomas Soome dup acpi-captions 419199767f8SToomas Soome 420199767f8SToomas Soome s" init_acpi" evaluate 421199767f8SToomas Soome 422199767f8SToomas Soome \ Get the current cycle state (entry to use) 423199767f8SToomas Soome s" acpi_state" evaluate @ 48 + ( n -- n y ) 424199767f8SToomas Soome 425a1625066SAndy Fiddaman set-captions 426199767f8SToomas Soome 427199767f8SToomas Soome \ Initialize cycle state from stored value 428199767f8SToomas Soome 48 - ( n y -- n k ) 429199767f8SToomas Soome s" init_cyclestate" evaluate ( n k -- n ) 430199767f8SToomas Soome 431199767f8SToomas Soome \ Set $acpi-user-options 432199767f8SToomas Soome s" activate_acpi" evaluate ( n -- n ) 433199767f8SToomas Soome then 434199767f8SToomas Soome drop 435199767f8SToomas Soome then 436199767f8SToomas Soome 4371ea94c75SAndy Fiddaman \ 438a1625066SAndy Fiddaman \ Initialize the kmdb option status. 4391ea94c75SAndy Fiddaman \ 440a1625066SAndy Fiddaman 0 menukmdb ! 441a1625066SAndy Fiddaman s" menu_kmdb" getenv -1 <> if 442199767f8SToomas Soome c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) 443a1625066SAndy Fiddaman dup menukmdb ! 444a1625066SAndy Fiddaman dup kmdb-captions 445199767f8SToomas Soome 446a1625066SAndy Fiddaman s" init_kmdb" evaluate 447199767f8SToomas Soome 448a1625066SAndy Fiddaman \ Get the current cycle state (entry to use) 449a1625066SAndy Fiddaman s" kmdb_state" evaluate @ 48 + ( n -- n y ) 450199767f8SToomas Soome 451a1625066SAndy Fiddaman set-captions 452199767f8SToomas Soome 453199767f8SToomas Soome \ Initialize cycle state from stored value 454199767f8SToomas Soome 48 - ( n y -- n k ) 455199767f8SToomas Soome s" init_cyclestate" evaluate ( n k -- n ) 456199767f8SToomas Soome 457a1625066SAndy Fiddaman \ Activate the current option 458a1625066SAndy Fiddaman s" activate_kmdb" evaluate ( n -- n ) 459199767f8SToomas Soome then 460199767f8SToomas Soome drop 461199767f8SToomas Soome then 462199767f8SToomas Soome 4631ea94c75SAndy Fiddaman \ 464199767f8SToomas Soome \ Initialize the menu_options visual separator. 4651ea94c75SAndy Fiddaman \ 466199767f8SToomas Soome 0 menuoptions ! 467199767f8SToomas Soome s" menu_options" getenv -1 <> if 468199767f8SToomas Soome c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) 469199767f8SToomas Soome menuoptions ! 470199767f8SToomas Soome else 471199767f8SToomas Soome drop 472199767f8SToomas Soome then 473199767f8SToomas Soome then 474199767f8SToomas Soome 475199767f8SToomas Soome \ Initialize "Reboot" menu state variable (prevents double-entry) 476199767f8SToomas Soome false menurebootadded ! 477199767f8SToomas Soome 478199767f8SToomas Soome menu_start 479199767f8SToomas Soome 1- menuidx ! \ Initialize the starting index for the menu 480199767f8SToomas Soome 0 menurow ! \ Initialize the starting position for the menu 481199767f8SToomas Soome 482199767f8SToomas Soome 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') 483199767f8SToomas Soome begin 484199767f8SToomas Soome \ If the "Options:" separator, print it. 485199767f8SToomas Soome dup menuoptions @ = if 486199767f8SToomas Soome \ Optionally add a reboot option to the menu 487199767f8SToomas Soome s" menu_reboot" getenv -1 <> if 488199767f8SToomas Soome drop 489199767f8SToomas Soome s" Reboot" printmenuitem menureboot ! 490199767f8SToomas Soome true menurebootadded ! 491199767f8SToomas Soome then 492199767f8SToomas Soome 493199767f8SToomas Soome menuX @ 494199767f8SToomas Soome menurow @ 2 + menurow ! 495199767f8SToomas Soome menurow @ menuY @ + 496199767f8SToomas Soome at-xy 497199767f8SToomas Soome s" menu_optionstext" getenv dup -1 <> if 498199767f8SToomas Soome type 499199767f8SToomas Soome else 500199767f8SToomas Soome drop ." Options:" 501199767f8SToomas Soome then 502199767f8SToomas Soome then 503199767f8SToomas Soome 504199767f8SToomas Soome \ make sure we have not already initialized this item 505199767f8SToomas Soome dup init_stateN dup @ 0= if 506199767f8SToomas Soome 1 swap ! 507199767f8SToomas Soome 508199767f8SToomas Soome \ If this menuitem has an initializer, run it 509199767f8SToomas Soome dup menu_init[x] 510199767f8SToomas Soome getenv dup -1 <> if 511199767f8SToomas Soome evaluate 512199767f8SToomas Soome else 513199767f8SToomas Soome drop 514199767f8SToomas Soome then 515199767f8SToomas Soome else 516199767f8SToomas Soome drop 517199767f8SToomas Soome then 518199767f8SToomas Soome 519199767f8SToomas Soome dup 520199767f8SToomas Soome loader_color? if 521199767f8SToomas Soome ansi_caption[x] 522199767f8SToomas Soome else 523199767f8SToomas Soome menu_caption[x] 524199767f8SToomas Soome then 525199767f8SToomas Soome 526199767f8SToomas Soome dup -1 <> if 527199767f8SToomas Soome \ test for environment variable 528199767f8SToomas Soome getenv dup -1 <> if 529199767f8SToomas Soome printmenuitem ( c-addr/u -- n ) 530199767f8SToomas Soome dup menukeyN ! 531199767f8SToomas Soome else 532199767f8SToomas Soome drop 533199767f8SToomas Soome then 534199767f8SToomas Soome else 535199767f8SToomas Soome drop 536199767f8SToomas Soome then 537199767f8SToomas Soome 538199767f8SToomas Soome 1+ dup 56 > \ add 1 to iterator, continue if less than 57 539199767f8SToomas Soome until 540199767f8SToomas Soome drop \ iterator 541199767f8SToomas Soome 542199767f8SToomas Soome \ Optionally add a reboot option to the menu 543199767f8SToomas Soome menurebootadded @ true <> if 544199767f8SToomas Soome s" menu_reboot" getenv -1 <> if 545199767f8SToomas Soome drop \ no need for the value 546199767f8SToomas Soome s" Reboot" \ menu caption (required by printmenuitem) 547199767f8SToomas Soome 548199767f8SToomas Soome printmenuitem 549199767f8SToomas Soome menureboot ! 550199767f8SToomas Soome else 551199767f8SToomas Soome 0 menureboot ! 552199767f8SToomas Soome then 553199767f8SToomas Soome then 554199767f8SToomas Soome; 555199767f8SToomas Soome 5560c268761SToomas Soome\ Takes an integer on the stack and updates the timeout display. 5571ea94c75SAndy Fiddaman\ 558199767f8SToomas Soome: menu-timeout-update ( N -- ) 559199767f8SToomas Soome 5600c268761SToomas Soome \ Enforce minimum 561199767f8SToomas Soome dup 0 < if drop 0 then 562199767f8SToomas Soome 5630c268761SToomas Soome menu_timeout_x @ menu_timeout_y @ at-xy \ position cursor 564199767f8SToomas Soome 5650c268761SToomas Soome dup 0> if 5660c268761SToomas Soome s" Autoboot in " type 5670c268761SToomas Soome dup . s" second" type 5680c268761SToomas Soome 1 > if [char] s emit then 5690c268761SToomas Soome s" . [Space] to pause " type 570199767f8SToomas Soome else 5710c268761SToomas Soome drop 40 spaces \ erase message 572199767f8SToomas Soome then 573199767f8SToomas Soome 5741ea94c75SAndy Fiddaman at-bl 575199767f8SToomas Soome; 576199767f8SToomas Soome 577199767f8SToomas Soome\ This function blocks program flow (loops forever) until a key is pressed. 578199767f8SToomas Soome\ The key that was pressed is added to the top of the stack in the form of its 579199767f8SToomas Soome\ decimal ASCII representation. This function is called by the menu-display 580199767f8SToomas Soome\ function. You need not call it directly. 581199767f8SToomas Soome\ note, the esc sequences will be dropped, this needs to be changed if 582199767f8SToomas Soome\ menu is built based on arrow keys. 5831ea94c75SAndy Fiddaman\ 584199767f8SToomas Soome: getkey ( -- ascii_keycode ) 585199767f8SToomas Soome 586199767f8SToomas Soome begin \ loop forever 587199767f8SToomas Soome 588199767f8SToomas Soome menu_timeout_enabled @ 1 = if 589199767f8SToomas Soome ( -- ) 590199767f8SToomas Soome seconds ( get current time: -- N ) 591199767f8SToomas Soome dup menu_time @ <> if ( has time elapsed?: N N N -- N ) 592199767f8SToomas Soome 593199767f8SToomas Soome \ At least 1 second has elapsed since last loop 594199767f8SToomas Soome \ so we will decrement our "timeout" (really a 595199767f8SToomas Soome \ counter, insuring that we do not proceed too 596199767f8SToomas Soome \ fast) and update our timeout display. 597199767f8SToomas Soome 598199767f8SToomas Soome menu_time ! ( update time record: N -- ) 599199767f8SToomas Soome menu_timeout @ ( "time" remaining: -- N ) 600199767f8SToomas Soome dup 0> if ( greater than 0?: N N 0 -- N ) 601199767f8SToomas Soome 1- ( decrement counter: N -- N ) 602199767f8SToomas Soome dup menu_timeout ! 603199767f8SToomas Soome ( re-assign: N N Addr -- N ) 604199767f8SToomas Soome then 605199767f8SToomas Soome ( -- N ) 606199767f8SToomas Soome 607199767f8SToomas Soome dup 0= swap 0< or if ( N <= 0?: N N -- ) 608199767f8SToomas Soome \ halt the timer 609199767f8SToomas Soome 0 menu_timeout ! ( 0 Addr -- ) 610199767f8SToomas Soome 0 menu_timeout_enabled ! ( 0 Addr -- ) 611199767f8SToomas Soome then 612199767f8SToomas Soome 613199767f8SToomas Soome \ update the timer display ( N -- ) 614199767f8SToomas Soome menu_timeout @ menu-timeout-update 615199767f8SToomas Soome 616199767f8SToomas Soome menu_timeout @ 0= if 617199767f8SToomas Soome \ We've reached the end of the timeout 618199767f8SToomas Soome \ (user did not cancel by pressing ANY 619199767f8SToomas Soome \ key) 620199767f8SToomas Soome 621199767f8SToomas Soome s" menu_timeout_command" getenv dup 622199767f8SToomas Soome -1 = if 623199767f8SToomas Soome drop \ clean-up 624199767f8SToomas Soome else 625199767f8SToomas Soome evaluate 626199767f8SToomas Soome then 627199767f8SToomas Soome then 628199767f8SToomas Soome 629199767f8SToomas Soome else ( -- N ) 630199767f8SToomas Soome \ No [detectable] time has elapsed (in seconds) 631199767f8SToomas Soome drop ( N -- ) 632199767f8SToomas Soome then 633199767f8SToomas Soome ( -- ) 634199767f8SToomas Soome then 635199767f8SToomas Soome 636199767f8SToomas Soome key? if \ Was a key pressed? (see loader(8)) 637199767f8SToomas Soome 638199767f8SToomas Soome \ An actual key was pressed (if the timeout is running, 639199767f8SToomas Soome \ kill it regardless of which key was pressed) 640199767f8SToomas Soome menu_timeout @ 0<> if 641199767f8SToomas Soome 0 menu_timeout ! 642199767f8SToomas Soome 0 menu_timeout_enabled ! 643199767f8SToomas Soome 644199767f8SToomas Soome \ clear screen of timeout message 645199767f8SToomas Soome 0 menu-timeout-update 646199767f8SToomas Soome then 647199767f8SToomas Soome 648199767f8SToomas Soome \ get the key that was pressed and exit (if we 649199767f8SToomas Soome \ get a non-zero ASCII code) 650199767f8SToomas Soome key dup 0<> if 651199767f8SToomas Soome dup 0x1b = if 652199767f8SToomas Soome key? if ( is it sequence? ) 653199767f8SToomas Soome drop 654199767f8SToomas Soome begin 655199767f8SToomas Soome key? 656199767f8SToomas Soome while 657199767f8SToomas Soome key drop 658199767f8SToomas Soome repeat 659199767f8SToomas Soome else 660199767f8SToomas Soome exit 661199767f8SToomas Soome then 662199767f8SToomas Soome else 663199767f8SToomas Soome exit 664199767f8SToomas Soome then 665199767f8SToomas Soome else 666199767f8SToomas Soome drop 667199767f8SToomas Soome then 668199767f8SToomas Soome then 669199767f8SToomas Soome 50 ms \ sleep for 50 milliseconds (see loader(8)) 670199767f8SToomas Soome 671199767f8SToomas Soome again 672199767f8SToomas Soome; 673199767f8SToomas Soome 674288c4f44SToomas Soome: menu-erase ( -- ) \ Erases menu and resets positioning variable to position 1. 675199767f8SToomas Soome 676199767f8SToomas Soome \ Clear the screen area associated with the interactive menu 677199767f8SToomas Soome menuX @ menuY @ 678199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ 679199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ 680199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ 681199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ 682199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ 683199767f8SToomas Soome 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 684199767f8SToomas Soome 2drop 685199767f8SToomas Soome 686199767f8SToomas Soome \ Reset the starting index and position for the menu 687199767f8SToomas Soome menu_start 1- menuidx ! 688199767f8SToomas Soome 0 menurow ! 689199767f8SToomas Soome; 690199767f8SToomas Soome 691199767f8SToomas Soomeonly forth 692199767f8SToomas Soomealso menu-infrastructure 693199767f8SToomas Soomealso menu-namespace 694199767f8SToomas Soomealso menu-command-helpers definitions 695199767f8SToomas Soome 696199767f8SToomas Soome: toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state 697199767f8SToomas Soome 698199767f8SToomas Soome \ ASCII numeral equal to user-selected menu item must be on the stack. 699199767f8SToomas Soome \ We do not modify the stack, so the ASCII numeral is left on top. 700199767f8SToomas Soome 701199767f8SToomas Soome dup init_textN c@ 0= if 702199767f8SToomas Soome \ NOTE: no need to check toggle_stateN since the first time we 703199767f8SToomas Soome \ are called, we will populate init_textN. Further, we don't 704199767f8SToomas Soome \ need to test whether menu_caption[x] (ansi_caption[x] when 705199767f8SToomas Soome \ loader_color?=1) is available since we would not have been 706199767f8SToomas Soome \ called if the caption was NULL. 707199767f8SToomas Soome 708199767f8SToomas Soome \ base name of environment variable 709199767f8SToomas Soome dup ( n -- n n ) \ key pressed 710199767f8SToomas Soome loader_color? if 711199767f8SToomas Soome ansi_caption[x] 712199767f8SToomas Soome else 713199767f8SToomas Soome menu_caption[x] 7141ea94c75SAndy Fiddaman then 715199767f8SToomas Soome getenv dup -1 <> if 716199767f8SToomas Soome 717199767f8SToomas Soome 2 pick ( n c-addr/u -- n c-addr/u n ) 718199767f8SToomas Soome init_textN ( n c-addr/u n -- n c-addr/u c-addr ) 719199767f8SToomas Soome 720199767f8SToomas Soome \ now we have the buffer c-addr on top 721199767f8SToomas Soome \ ( followed by c-addr/u of current caption ) 722199767f8SToomas Soome 723199767f8SToomas Soome \ Copy the current caption into our buffer 724199767f8SToomas Soome 2dup c! -rot \ store strlen at first byte 725199767f8SToomas Soome begin 726199767f8SToomas Soome rot 1+ \ bring alt addr to top and increment 727199767f8SToomas Soome -rot -rot \ bring buffer addr to top 728199767f8SToomas Soome 2dup c@ swap c! \ copy current character 729199767f8SToomas Soome 1+ \ increment buffer addr 730199767f8SToomas Soome rot 1- \ bring buffer len to top and decrement 731199767f8SToomas Soome dup 0= \ exit loop if buffer len is zero 732199767f8SToomas Soome until 733199767f8SToomas Soome 2drop \ buffer len/addr 734199767f8SToomas Soome drop \ alt addr 735199767f8SToomas Soome 736199767f8SToomas Soome else 737199767f8SToomas Soome drop 738199767f8SToomas Soome then 739199767f8SToomas Soome then 740199767f8SToomas Soome 741199767f8SToomas Soome \ Now we are certain to have init_textN populated with the initial 742199767f8SToomas Soome \ value of menu_caption[x] (ansi_caption[x] with loader_color enabled). 743199767f8SToomas Soome \ We can now use init_textN as the untoggled caption and 744199767f8SToomas Soome \ toggled_text[x] (toggled_ansi[x] with loader_color enabled) as the 745199767f8SToomas Soome \ toggled caption and store the appropriate value into menu_caption[x] 746199767f8SToomas Soome \ (again, ansi_caption[x] with loader_color enabled). Last, we'll 747199767f8SToomas Soome \ negate the toggled state so that we reverse the flow on subsequent 748199767f8SToomas Soome \ calls. 749199767f8SToomas Soome 750199767f8SToomas Soome dup toggle_stateN @ 0= if 751199767f8SToomas Soome \ state is OFF, toggle to ON 752199767f8SToomas Soome 753199767f8SToomas Soome dup ( n -- n n ) \ key pressed 754199767f8SToomas Soome loader_color? if 755199767f8SToomas Soome toggled_ansi[x] 756199767f8SToomas Soome else 757199767f8SToomas Soome toggled_text[x] 758199767f8SToomas Soome then 759199767f8SToomas Soome getenv dup -1 <> if 760199767f8SToomas Soome \ Assign toggled text to menu caption 761199767f8SToomas Soome 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed 762199767f8SToomas Soome loader_color? if 763199767f8SToomas Soome ansi_caption[x] 764199767f8SToomas Soome else 765199767f8SToomas Soome menu_caption[x] 766199767f8SToomas Soome then 767199767f8SToomas Soome setenv 768199767f8SToomas Soome else 769199767f8SToomas Soome \ No toggled text, keep the same caption 770199767f8SToomas Soome drop ( n -1 -- n ) \ getenv cruft 771199767f8SToomas Soome then 772199767f8SToomas Soome 773199767f8SToomas Soome true \ new value of toggle state var (to be stored later) 774199767f8SToomas Soome else 775199767f8SToomas Soome \ state is ON, toggle to OFF 776199767f8SToomas Soome 777199767f8SToomas Soome dup init_textN count ( n -- n c-addr/u ) 778199767f8SToomas Soome 779199767f8SToomas Soome \ Assign init_textN text to menu caption 780199767f8SToomas Soome 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed 781199767f8SToomas Soome loader_color? if 782199767f8SToomas Soome ansi_caption[x] 783199767f8SToomas Soome else 784199767f8SToomas Soome menu_caption[x] 785199767f8SToomas Soome then 786199767f8SToomas Soome setenv 787199767f8SToomas Soome 788199767f8SToomas Soome false \ new value of toggle state var (to be stored below) 789199767f8SToomas Soome then 790199767f8SToomas Soome 791199767f8SToomas Soome \ now we'll store the new toggle state (on top of stack) 792199767f8SToomas Soome over toggle_stateN ! 793199767f8SToomas Soome; 794199767f8SToomas Soome 795199767f8SToomas Soome: cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem 796199767f8SToomas Soome 797199767f8SToomas Soome \ ASCII numeral equal to user-selected menu item must be on the stack. 798199767f8SToomas Soome \ We do not modify the stack, so the ASCII numeral is left on top. 799199767f8SToomas Soome 800199767f8SToomas Soome dup cycle_stateN dup @ 1+ \ get value and increment 801199767f8SToomas Soome 802199767f8SToomas Soome \ Before assigning the (incremented) value back to the pointer, 803199767f8SToomas Soome \ let's test for the existence of this particular array element. 804199767f8SToomas Soome \ If the element exists, we'll store index value and move on. 805199767f8SToomas Soome \ Otherwise, we'll loop around to zero and store that. 806199767f8SToomas Soome 807199767f8SToomas Soome dup 48 + ( n addr k -- n addr k k' ) 808199767f8SToomas Soome \ duplicate array index and convert to ASCII numeral 809199767f8SToomas Soome 810199767f8SToomas Soome 3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y) 811199767f8SToomas Soome loader_color? if 812199767f8SToomas Soome ansi_caption[x][y] 813199767f8SToomas Soome else 814199767f8SToomas Soome menu_caption[x][y] 815199767f8SToomas Soome then 816199767f8SToomas Soome ( n addr k n k' -- n addr k c-addr/u ) 817199767f8SToomas Soome 818199767f8SToomas Soome \ Now test for the existence of our incremented array index in the 819199767f8SToomas Soome \ form of $menu_caption[x][y] ($ansi_caption[x][y] with loader_color 820199767f8SToomas Soome \ enabled) as set in loader.rc(5), et. al. 821199767f8SToomas Soome 822199767f8SToomas Soome getenv dup -1 = if 823199767f8SToomas Soome \ No caption set for this array index. Loop back to zero. 824199767f8SToomas Soome 825199767f8SToomas Soome drop ( n addr k -1 -- n addr k ) \ getenv cruft 826199767f8SToomas Soome drop 0 ( n addr k -- n addr 0 ) \ new value to store later 827199767f8SToomas Soome 828199767f8SToomas Soome 2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y) 829199767f8SToomas Soome loader_color? if 830199767f8SToomas Soome ansi_caption[x][y] 831199767f8SToomas Soome else 832199767f8SToomas Soome menu_caption[x][y] 833199767f8SToomas Soome then 834199767f8SToomas Soome ( n addr 0 n 48 -- n addr 0 c-addr/u ) 835199767f8SToomas Soome getenv dup -1 = if 836199767f8SToomas Soome \ Highly unlikely to occur, but to ensure things move 837199767f8SToomas Soome \ along smoothly, allocate a temporary NULL string 838199767f8SToomas Soome drop ( cruft ) s" " 839199767f8SToomas Soome then 840199767f8SToomas Soome then 841199767f8SToomas Soome 842199767f8SToomas Soome \ At this point, we should have the following on the stack (in order, 843199767f8SToomas Soome \ from bottom to top): 8441ea94c75SAndy Fiddaman \ 845199767f8SToomas Soome \ n - Ascii numeral representing the menu choice (inherited) 846199767f8SToomas Soome \ addr - address of our internal cycle_stateN variable 847199767f8SToomas Soome \ k - zero-based number we intend to store to the above 848199767f8SToomas Soome \ c-addr/u - string value we intend to store to menu_caption[x] 849199767f8SToomas Soome \ (or ansi_caption[x] with loader_color enabled) 8501ea94c75SAndy Fiddaman \ 851199767f8SToomas Soome \ Let's perform what we need to with the above. 852199767f8SToomas Soome 853199767f8SToomas Soome \ Assign array value text to menu caption 854199767f8SToomas Soome 4 pick ( n addr k c-addr/u -- n addr k c-addr/u n ) 855199767f8SToomas Soome loader_color? if 856199767f8SToomas Soome ansi_caption[x] 857199767f8SToomas Soome else 858199767f8SToomas Soome menu_caption[x] 859199767f8SToomas Soome then 860199767f8SToomas Soome setenv 861199767f8SToomas Soome 862199767f8SToomas Soome swap ! ( n addr k -- n ) \ update array state variable 863199767f8SToomas Soome; 864199767f8SToomas Soome 865199767f8SToomas Soomeonly forth definitions also menu-infrastructure 866199767f8SToomas Soome 867199767f8SToomas Soome\ Erase and redraw the menu. Useful if you change a caption and want to 868199767f8SToomas Soome\ update the menu to reflect the new value. 8691ea94c75SAndy Fiddaman\ 870199767f8SToomas Soome: menu-redraw ( -- ) 871199767f8SToomas Soome menu-erase 872199767f8SToomas Soome menu-create 873199767f8SToomas Soome; 874199767f8SToomas Soome 875a1625066SAndy Fiddaman: menu-box ( -- ) 876a1625066SAndy Fiddaman \ Interpret a custom frame type for the menu 877a1625066SAndy Fiddaman TRUE ( draw a box? default yes, but might be altered below ) 878a1625066SAndy Fiddaman s" loader_menu_frame" getenv dup -1 = if ( 1 ) 879a1625066SAndy Fiddaman drop \ no custom frame type 880a1625066SAndy Fiddaman else ( 1 ) 2dup s" single" compare-insensitive 0= if ( 2 ) 881a1625066SAndy Fiddaman f_single ( see frames.4th ) 882a1625066SAndy Fiddaman else ( 2 ) 2dup s" double" compare-insensitive 0= if ( 3 ) 883a1625066SAndy Fiddaman f_double ( see frames.4th ) 884a1625066SAndy Fiddaman else ( 3 ) s" none" compare-insensitive 0= if ( 4 ) 885a1625066SAndy Fiddaman drop FALSE \ don't draw a box 886a1625066SAndy Fiddaman ( 4 ) then ( 3 ) then ( 2 ) then ( 1 ) then 887a1625066SAndy Fiddaman if 888a1625066SAndy Fiddaman 42 13 menuX @ 3 - menuY @ 1- box \ Draw frame (w,h,x,y) 889a1625066SAndy Fiddaman then 890a1625066SAndy Fiddaman; 891a1625066SAndy Fiddaman 892199767f8SToomas Soome\ This function initializes the menu. Call this from your `loader.rc' file 893199767f8SToomas Soome\ before calling any other menu-related functions. 8941ea94c75SAndy Fiddaman\ 895199767f8SToomas Soome: menu-init ( -- ) 896199767f8SToomas Soome menu_start 897199767f8SToomas Soome 1- menuidx ! \ Initialize the starting index for the menu 898199767f8SToomas Soome 0 menurow ! \ Initialize the starting position for the menu 899199767f8SToomas Soome 900199767f8SToomas Soome \ Assign configuration values 901199767f8SToomas Soome s" loader_menu_y" getenv dup -1 = if 902199767f8SToomas Soome drop \ no custom row position 903199767f8SToomas Soome menu_default_y 904199767f8SToomas Soome else 905199767f8SToomas Soome \ make sure custom position is a number 906199767f8SToomas Soome ?number 0= if 907199767f8SToomas Soome menu_default_y \ or use default 908199767f8SToomas Soome then 909199767f8SToomas Soome then 910199767f8SToomas Soome menuY ! 911199767f8SToomas Soome s" loader_menu_x" getenv dup -1 = if 912199767f8SToomas Soome drop \ no custom column position 913199767f8SToomas Soome menu_default_x 914199767f8SToomas Soome else 915199767f8SToomas Soome \ make sure custom position is a number 916199767f8SToomas Soome ?number 0= if 917199767f8SToomas Soome menu_default_x \ or use default 918199767f8SToomas Soome then 919199767f8SToomas Soome then 920199767f8SToomas Soome menuX ! 921199767f8SToomas Soome 92263f9f2ffSToomas Soome ['] menu-box console-iterate 9231ea94c75SAndy Fiddaman at-bl 924199767f8SToomas Soome; 925199767f8SToomas Soome 926199767f8SToomas Soomealso menu-namespace 927199767f8SToomas Soome 928199767f8SToomas Soome\ Main function. Call this from your `loader.rc' file. 9291ea94c75SAndy Fiddaman\ 930199767f8SToomas Soome: menu-display ( -- ) 931199767f8SToomas Soome 932199767f8SToomas Soome 0 menu_timeout_enabled ! \ start with automatic timeout disabled 933199767f8SToomas Soome 934199767f8SToomas Soome \ check indication that automatic execution after delay is requested 935199767f8SToomas Soome s" menu_timeout_command" getenv -1 <> if ( Addr C -1 -- | Addr ) 936199767f8SToomas Soome drop ( just testing existence right now: Addr -- ) 937199767f8SToomas Soome 938199767f8SToomas Soome \ initialize state variables 939199767f8SToomas Soome seconds menu_time ! ( store the time we started ) 940199767f8SToomas Soome 1 menu_timeout_enabled ! ( enable automatic timeout ) 941199767f8SToomas Soome 942199767f8SToomas Soome \ read custom time-duration (if set) 943199767f8SToomas Soome s" autoboot_delay" getenv dup -1 = if 944199767f8SToomas Soome drop \ no custom duration (remove dup'd bunk -1) 945199767f8SToomas Soome menu_timeout_default \ use default setting 946199767f8SToomas Soome else 947199767f8SToomas Soome 2dup ?number 0= if ( if not a number ) 948199767f8SToomas Soome \ disable timeout if "NO", else use default 949199767f8SToomas Soome s" NO" compare-insensitive 0= if 950199767f8SToomas Soome 0 menu_timeout_enabled ! 951199767f8SToomas Soome 0 ( assigned to menu_timeout below ) 952199767f8SToomas Soome else 953199767f8SToomas Soome menu_timeout_default 954199767f8SToomas Soome then 955199767f8SToomas Soome else 956199767f8SToomas Soome -rot 2drop 957199767f8SToomas Soome 958199767f8SToomas Soome \ boot immediately if less than zero 959199767f8SToomas Soome dup 0< if 960199767f8SToomas Soome drop 961199767f8SToomas Soome menu-create 9621ea94c75SAndy Fiddaman at-bl 963199767f8SToomas Soome 0 boot 964199767f8SToomas Soome then 965199767f8SToomas Soome then 966199767f8SToomas Soome then 967199767f8SToomas Soome menu_timeout ! ( store value on stack from above ) 968199767f8SToomas Soome 969199767f8SToomas Soome menu_timeout_enabled @ 1 = if 970199767f8SToomas Soome \ read custom column position (if set) 971199767f8SToomas Soome s" loader_menu_timeout_x" getenv dup -1 = if 972199767f8SToomas Soome drop \ no custom column position 973199767f8SToomas Soome menu_timeout_default_x \ use default setting 974199767f8SToomas Soome else 975199767f8SToomas Soome \ make sure custom position is a number 976199767f8SToomas Soome ?number 0= if 977199767f8SToomas Soome menu_timeout_default_x \ or use default 978199767f8SToomas Soome then 979199767f8SToomas Soome then 980199767f8SToomas Soome menu_timeout_x ! ( store value on stack from above ) 9811ea94c75SAndy Fiddaman 982199767f8SToomas Soome \ read custom row position (if set) 983199767f8SToomas Soome s" loader_menu_timeout_y" getenv dup -1 = if 984199767f8SToomas Soome drop \ no custom row position 985199767f8SToomas Soome menu_timeout_default_y \ use default setting 986199767f8SToomas Soome else 987199767f8SToomas Soome \ make sure custom position is a number 988199767f8SToomas Soome ?number 0= if 989199767f8SToomas Soome menu_timeout_default_y \ or use default 990199767f8SToomas Soome then 991199767f8SToomas Soome then 992199767f8SToomas Soome menu_timeout_y ! ( store value on stack from above ) 993199767f8SToomas Soome then 994199767f8SToomas Soome then 995199767f8SToomas Soome 9965e897995SToomas Soome cursor-invisible cursor-set 997199767f8SToomas Soome menu-create 998199767f8SToomas Soome 999199767f8SToomas Soome begin \ Loop forever 1000199767f8SToomas Soome 10011ea94c75SAndy Fiddaman at-bl 1002cbce8145SToomas Soome \ restore cursor for case the getkey ends up in 1003cbce8145SToomas Soome \ booting the kernel. This does restore cursor for 1004cbce8145SToomas Soome \ serial terminals. 1005cbce8145SToomas Soome cursor-normal cursor-set 1006199767f8SToomas Soome getkey \ Block here, waiting for a key to be pressed 1007cbce8145SToomas Soome cursor-invisible cursor-set 1008199767f8SToomas Soome 1009199767f8SToomas Soome dup -1 = if 10105e897995SToomas Soome cursor-normal cursor-set 1011199767f8SToomas Soome drop exit \ Caught abort (abnormal return) 1012199767f8SToomas Soome then 1013199767f8SToomas Soome 1014199767f8SToomas Soome \ Boot if the user pressed Enter/Ctrl-M (13) or 1015199767f8SToomas Soome \ Ctrl-Enter/Ctrl-J (10) 1016199767f8SToomas Soome dup over 13 = swap 10 = or if 1017199767f8SToomas Soome drop ( no longer needed ) 10185e897995SToomas Soome cursor-normal cursor-set 1019199767f8SToomas Soome s" boot" evaluate 1020199767f8SToomas Soome exit ( pedantic; never reached ) 1021199767f8SToomas Soome then 1022199767f8SToomas Soome 1023199767f8SToomas Soome dup menureboot @ = if 0 reboot then 1024199767f8SToomas Soome 1025199767f8SToomas Soome \ Evaluate the decimal ASCII value against known menu item 1026199767f8SToomas Soome \ key associations and act accordingly 1027199767f8SToomas Soome 1028199767f8SToomas Soome 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') 1029199767f8SToomas Soome begin 1030199767f8SToomas Soome dup menukeyN @ 1031199767f8SToomas Soome rot tuck = if 1032199767f8SToomas Soome 1033199767f8SToomas Soome \ Adjust for missing ACPI menuitem on non-i386 10341ea94c75SAndy Fiddaman\ arch-i386? true <> menuacpi @ 0<> and if 10351ea94c75SAndy Fiddaman\ menuacpi @ over 2dup < -rot = or 10361ea94c75SAndy Fiddaman\ over 58 < and if 10371ea94c75SAndy Fiddaman\ ( key >= menuacpi && key < 58: N -- N ) 10381ea94c75SAndy Fiddaman\ 1+ 10391ea94c75SAndy Fiddaman\ then 10401ea94c75SAndy Fiddaman\ then 1041199767f8SToomas Soome 1042199767f8SToomas Soome \ Test for the environment variable 1043199767f8SToomas Soome dup menu_command[x] 1044199767f8SToomas Soome getenv dup -1 <> if 1045199767f8SToomas Soome \ Execute the stored procedure 1046ffb39f84SToomas Soome cursor-normal cursor-set 1047199767f8SToomas Soome evaluate 1048199767f8SToomas Soome 1049199767f8SToomas Soome \ We expect there to be a non-zero 1050199767f8SToomas Soome \ value left on the stack after 1051199767f8SToomas Soome \ executing the stored procedure. 1052199767f8SToomas Soome \ If so, continue to run, else exit. 1053199767f8SToomas Soome 1054199767f8SToomas Soome 0= if 1055199767f8SToomas Soome drop \ key pressed 1056199767f8SToomas Soome drop \ loop iterator 1057199767f8SToomas Soome exit 1058199767f8SToomas Soome else 1059199767f8SToomas Soome swap \ need iterator on top 1060199767f8SToomas Soome then 1061ffb39f84SToomas Soome cursor-invisible cursor-set 1062199767f8SToomas Soome then 1063199767f8SToomas Soome 1064199767f8SToomas Soome \ Re-adjust for missing ACPI menuitem 1065199767f8SToomas Soome\ arch-i386? true <> menuacpi @ 0<> and if 1066199767f8SToomas Soome\ swap 1067199767f8SToomas Soome\ menuacpi @ 1+ over 2dup < -rot = or 1068199767f8SToomas Soome\ over 59 < and if 1069199767f8SToomas Soome\ 1- 1070199767f8SToomas Soome\ then 1071199767f8SToomas Soome\ swap 1072199767f8SToomas Soome\ then 1073199767f8SToomas Soome else 1074199767f8SToomas Soome swap \ need iterator on top 1075199767f8SToomas Soome then 1076199767f8SToomas Soome 10771ea94c75SAndy Fiddaman \ 1078199767f8SToomas Soome \ Check for menu keycode shortcut(s) 10791ea94c75SAndy Fiddaman \ 1080199767f8SToomas Soome dup menu_keycode[x] 1081199767f8SToomas Soome getenv dup -1 = if 1082199767f8SToomas Soome drop 1083199767f8SToomas Soome else 1084199767f8SToomas Soome ?number 0<> if 1085199767f8SToomas Soome rot tuck = if 1086199767f8SToomas Soome swap 1087199767f8SToomas Soome dup menu_command[x] 1088199767f8SToomas Soome getenv dup -1 <> if 1089ffb39f84SToomas Soome cursor-normal 1090ffb39f84SToomas Soome cursor-set 1091199767f8SToomas Soome evaluate 1092199767f8SToomas Soome 0= if 1093199767f8SToomas Soome 2drop 1094199767f8SToomas Soome exit 1095199767f8SToomas Soome then 1096ffb39f84SToomas Soome cursor-invisible 1097ffb39f84SToomas Soome cursor-set 1098199767f8SToomas Soome else 1099199767f8SToomas Soome drop 1100199767f8SToomas Soome then 1101199767f8SToomas Soome else 1102199767f8SToomas Soome swap 1103199767f8SToomas Soome then 1104199767f8SToomas Soome then 1105199767f8SToomas Soome then 1106199767f8SToomas Soome 1107199767f8SToomas Soome 1+ dup 56 > \ increment iterator 1108199767f8SToomas Soome \ continue if less than 57 1109199767f8SToomas Soome until 1110199767f8SToomas Soome drop \ loop iterator 1111199767f8SToomas Soome drop \ key pressed 1112199767f8SToomas Soome 1113199767f8SToomas Soome again \ Non-operational key was pressed; repeat 1114199767f8SToomas Soome; 1115199767f8SToomas Soome 1116199767f8SToomas Soome\ This function unsets all the possible environment variables associated with 1117199767f8SToomas Soome\ creating the interactive menu. 11181ea94c75SAndy Fiddaman\ 1119199767f8SToomas Soome: menu-unset ( -- ) 1120199767f8SToomas Soome 1121199767f8SToomas Soome 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') 1122199767f8SToomas Soome begin 1123199767f8SToomas Soome dup menu_init[x] unsetenv \ menu initializer 1124199767f8SToomas Soome dup menu_command[x] unsetenv \ menu command 1125199767f8SToomas Soome dup menu_caption[x] unsetenv \ menu caption 1126199767f8SToomas Soome dup ansi_caption[x] unsetenv \ ANSI caption 1127199767f8SToomas Soome dup menu_keycode[x] unsetenv \ menu keycode 1128199767f8SToomas Soome dup toggled_text[x] unsetenv \ toggle_menuitem caption 1129199767f8SToomas Soome dup toggled_ansi[x] unsetenv \ toggle_menuitem ANSI caption 1130199767f8SToomas Soome 1131199767f8SToomas Soome 48 \ Iterator start (inner range 48 to 57; ASCII '0' to '9') 1132199767f8SToomas Soome begin 1133199767f8SToomas Soome \ cycle_menuitem caption and ANSI caption 1134199767f8SToomas Soome 2dup menu_caption[x][y] unsetenv 1135199767f8SToomas Soome 2dup ansi_caption[x][y] unsetenv 1136199767f8SToomas Soome 1+ dup 57 > 1137199767f8SToomas Soome until 1138199767f8SToomas Soome drop \ inner iterator 1139199767f8SToomas Soome 1140199767f8SToomas Soome 0 over menukeyN ! \ used by menu-create, menu-display 1141199767f8SToomas Soome 0 over init_stateN ! \ used by menu-create 1142199767f8SToomas Soome 0 over toggle_stateN ! \ used by toggle_menuitem 1143199767f8SToomas Soome 0 over init_textN c! \ used by toggle_menuitem 1144199767f8SToomas Soome 0 over cycle_stateN ! \ used by cycle_menuitem 1145199767f8SToomas Soome 1146199767f8SToomas Soome 1+ dup 56 > \ increment, continue if less than 57 1147199767f8SToomas Soome until 1148199767f8SToomas Soome drop \ iterator 1149199767f8SToomas Soome 1150199767f8SToomas Soome s" menu_timeout_command" unsetenv \ menu timeout command 1151199767f8SToomas Soome s" menu_reboot" unsetenv \ Reboot menu option flag 1152199767f8SToomas Soome s" menu_acpi" unsetenv \ ACPI menu option flag 1153a1625066SAndy Fiddaman s" menu_kmdb" unsetenv \ kmdb menu option flag 1154199767f8SToomas Soome s" menu_osconsole" unsetenv \ osconsole menu option flag 1155199767f8SToomas Soome s" menu_options" unsetenv \ Options separator flag 1156199767f8SToomas Soome s" menu_optionstext" unsetenv \ separator display text 1157199767f8SToomas Soome s" menu_init" unsetenv \ menu initializer 1158199767f8SToomas Soome 1159199767f8SToomas Soome 0 menureboot ! 1160199767f8SToomas Soome 0 menuacpi ! 1161a1625066SAndy Fiddaman 0 menukmdb ! 1162199767f8SToomas Soome 0 menuosconsole ! 1163199767f8SToomas Soome 0 menuoptions ! 1164199767f8SToomas Soome; 1165199767f8SToomas Soome 1166199767f8SToomas Soomeonly forth definitions also menu-infrastructure 1167199767f8SToomas Soome 1168199767f8SToomas Soome\ This function both unsets menu variables and visually erases the menu area 1169199767f8SToomas Soome\ in-preparation for another menu. 11701ea94c75SAndy Fiddaman\ 1171199767f8SToomas Soome: menu-clear ( -- ) 1172199767f8SToomas Soome menu-unset 1173199767f8SToomas Soome menu-erase 1174199767f8SToomas Soome; 1175199767f8SToomas Soome 1176199767f8SToomas Soomebullet menubllt ! 1177199767f8SToomas Soome 1178199767f8SToomas Soomealso menu-namespace 1179199767f8SToomas Soome 1180199767f8SToomas Soome\ Initialize our menu initialization state variables 1181199767f8SToomas Soome0 init_state1 ! 1182199767f8SToomas Soome0 init_state2 ! 1183199767f8SToomas Soome0 init_state3 ! 1184199767f8SToomas Soome0 init_state4 ! 1185199767f8SToomas Soome0 init_state5 ! 1186199767f8SToomas Soome0 init_state6 ! 1187199767f8SToomas Soome0 init_state7 ! 1188199767f8SToomas Soome0 init_state8 ! 1189199767f8SToomas Soome 1190199767f8SToomas Soome\ Initialize our boolean state variables 1191199767f8SToomas Soome0 toggle_state1 ! 1192199767f8SToomas Soome0 toggle_state2 ! 1193199767f8SToomas Soome0 toggle_state3 ! 1194199767f8SToomas Soome0 toggle_state4 ! 1195199767f8SToomas Soome0 toggle_state5 ! 1196199767f8SToomas Soome0 toggle_state6 ! 1197199767f8SToomas Soome0 toggle_state7 ! 1198199767f8SToomas Soome0 toggle_state8 ! 1199199767f8SToomas Soome 1200199767f8SToomas Soome\ Initialize our array state variables 1201199767f8SToomas Soome0 cycle_state1 ! 1202199767f8SToomas Soome0 cycle_state2 ! 1203199767f8SToomas Soome0 cycle_state3 ! 1204199767f8SToomas Soome0 cycle_state4 ! 1205199767f8SToomas Soome0 cycle_state5 ! 1206199767f8SToomas Soome0 cycle_state6 ! 1207199767f8SToomas Soome0 cycle_state7 ! 1208199767f8SToomas Soome0 cycle_state8 ! 1209199767f8SToomas Soome 1210199767f8SToomas Soome\ Initialize string containers 1211199767f8SToomas Soome0 init_text1 c! 1212199767f8SToomas Soome0 init_text2 c! 1213199767f8SToomas Soome0 init_text3 c! 1214199767f8SToomas Soome0 init_text4 c! 1215199767f8SToomas Soome0 init_text5 c! 1216199767f8SToomas Soome0 init_text6 c! 1217199767f8SToomas Soome0 init_text7 c! 1218199767f8SToomas Soome0 init_text8 c! 1219199767f8SToomas Soome 1220199767f8SToomas Soomeonly forth definitions 1221