PageRenderTime 22ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/illumos/illumos-gate
Forth | 76 lines | 68 code | 8 blank | 0 comment | 10 complexity | 9d10dec1fd0fe1fe25460da8c0f671e7 MD5 | raw file
  1. \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
  2. \ All rights reserved.
  3. \
  4. \ Redistribution and use in source and binary forms, with or without
  5. \ modification, are permitted provided that the following conditions
  6. \ are met:
  7. \ 1. Redistributions of source code must retain the above copyright
  8. \ notice, this list of conditions and the following disclaimer.
  9. \ 2. Redistributions in binary form must reproduce the above copyright
  10. \ notice, this list of conditions and the following disclaimer in the
  11. \ documentation and/or other materials provided with the distribution.
  12. \
  13. \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. \ SUCH DAMAGE.
  24. marker task-brand.4th
  25. variable brandX
  26. variable brandY
  27. \ Initialize brand placement to defaults
  28. 2 brandX !
  29. 1 brandY !
  30. \ This function draws any number of company brands at (loader_brand_x,
  31. \ loader_brand_y) if defined, or (2,1) (top-left). To choose your brand, set
  32. \ the variable `loader_brand' to the respective brand name.
  33. \
  34. \ NOTE: Each is defined as a brand function in /boot/brand-${loader_brand}.4th
  35. \ NOTE: If `/boot/brand-${loader_brand}.4th' does not exist or does not define
  36. \ a `brand' function, no brand is drawn.
  37. \
  38. : draw-brand ( -- ) \ at (loader_brand_x,loader_brand_y), else (2,1)
  39. s" loader_brand_x" getenv dup -1 <> if
  40. ?number 1 = if brandX ! then
  41. else drop then
  42. s" loader_brand_y" getenv dup -1 <> if
  43. ?number 1 = if brandY ! then
  44. else drop then
  45. \ If `brand' is defined, execute it
  46. s" brand" sfind ( -- xt|0 bool ) if
  47. brandX @ brandY @ rot execute
  48. else
  49. \ Not defined; try-include desired brand file
  50. drop ( xt = 0 ) \ cruft
  51. s" loader_brand" getenv dup -1 = over 0= or if
  52. dup 0= if 2drop else drop then \ getenv result unused
  53. s" try-include /boot/forth/brand-illumos.4th"
  54. else
  55. 2drop ( c-addr/u -- ) \ getenv result unused
  56. s" try-include /boot/forth/brand-${loader_brand}.4th"
  57. then
  58. evaluate
  59. 1 spaces
  60. \ Execute `brand' if defined now
  61. s" brand" sfind if
  62. brandX @ brandY @ rot execute
  63. else drop then
  64. then
  65. ;
  66. : draw-brand
  67. ['] draw-brand console-iterate
  68. ;