PageRenderTime 41ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/src/boot/forth/beastie.4th

https://github.com/illumos/illumos-gate
Forth | 112 lines | 98 code | 14 blank | 0 comment | 12 complexity | bbf098a7a430f98a2e91a92b458bf550 MD5 | raw file
  1. \ Copyright (c) 2003 Scott Long <scottl@FreeBSD.org>
  2. \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
  3. \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
  4. \ All rights reserved.
  5. \
  6. \ Redistribution and use in source and binary forms, with or without
  7. \ modification, are permitted provided that the following conditions
  8. \ are met:
  9. \ 1. Redistributions of source code must retain the above copyright
  10. \ notice, this list of conditions and the following disclaimer.
  11. \ 2. Redistributions in binary form must reproduce the above copyright
  12. \ notice, this list of conditions and the following disclaimer in the
  13. \ documentation and/or other materials provided with the distribution.
  14. \
  15. \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  16. \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  19. \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21. \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23. \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. \ SUCH DAMAGE.
  26. marker task-beastie.4th
  27. only forth definitions
  28. variable logoX
  29. variable logoY
  30. \ Initialize logo placement to defaults
  31. 46 logoX !
  32. 4 logoY !
  33. \ This function draws any number of beastie logos at (loader_logo_x,
  34. \ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
  35. \ your beastie, set the variable `loader_logo' to the respective logo name.
  36. \
  37. \ NOTE: Each is defined as a logo function in /boot/logo-${loader_logo}.4th
  38. \ NOTE: If `/boot/logo-${loader_logo}.4th' does not exist or does not define
  39. \ a `logo' function, no beastie is drawn.
  40. \
  41. : draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
  42. s" loader_logo_x" getenv dup -1 <> if
  43. ?number 1 = if logoX ! then
  44. else drop then
  45. s" loader_logo_y" getenv dup -1 <> if
  46. ?number 1 = if logoY ! then
  47. else drop then
  48. \ If `logo' is defined, execute it
  49. s" logo" sfind ( -- xt|0 bool ) if
  50. logoX @ logoY @ rot execute
  51. else
  52. \ Not defined; try-include desired logo file
  53. drop ( xt = 0 ) \ cruft
  54. s" loader_logo" getenv dup -1 = over 0= or if
  55. dup 0= if 2drop else drop then \ getenv result unused
  56. loader_color? if
  57. s" try-include /boot/forth/logo-orb.4th"
  58. else
  59. s" try-include /boot/forth/logo-orbbw.4th"
  60. then
  61. else
  62. 2drop ( c-addr/u -- ) \ getenv result unused
  63. s" try-include /boot/forth/logo-${loader_logo}.4th"
  64. then
  65. evaluate
  66. 1 spaces
  67. \ Execute `logo' if defined now
  68. s" logo" sfind if
  69. logoX @ logoY @ rot execute
  70. else drop then
  71. then
  72. ;
  73. : draw-beastie
  74. ['] draw-beastie console-iterate
  75. ;
  76. also support-functions
  77. : beastie-start ( -- ) \ starts the menu
  78. s" beastie_disable" getenv dup -1 <> if
  79. s" YES" compare-insensitive 0= if
  80. any_conf_read? if
  81. load_xen_throw
  82. load_kernel
  83. load_modules
  84. then
  85. exit \ to autoboot (default)
  86. then
  87. else drop then
  88. s" loader_delay" getenv -1 = if
  89. s" include /boot/forth/menu.rc" evaluate
  90. else
  91. drop
  92. ." Loading Menu (Ctrl-C to Abort)" cr
  93. s" set delay_command='include /boot/forth/menu.rc'" evaluate
  94. s" set delay_showdots" evaluate
  95. delay_execute
  96. then
  97. ;
  98. only forth definitions