/sys/boot/forth/frames.4th

https://bitbucket.org/iorivur/freebsd-bhyve-with-suspend-resume · Forth · 128 lines · 117 code · 11 blank · 0 comment · 3 complexity · 2ad068f564aee5601457de6bbfc296df MD5 · raw file

  1. \ Words implementing frame drawing
  2. \ XXX Filled boxes are left as an exercise for the reader... ;-/
  3. \ $FreeBSD: head/sys/boot/forth/frames.4th 244048 2012-12-09 15:25:34Z dteske $
  4. marker task-frames.4th
  5. variable h_el
  6. variable v_el
  7. variable lt_el
  8. variable lb_el
  9. variable rt_el
  10. variable rb_el
  11. variable fill
  12. \ ASCII frames (used when serial console is detected)
  13. 45 constant ascii_dash
  14. 124 constant ascii_pipe
  15. 43 constant ascii_plus
  16. s" arch-pc98" environment? [if]
  17. \ Single frames
  18. 149 constant sh_el
  19. 150 constant sv_el
  20. 152 constant slt_el
  21. 154 constant slb_el
  22. 153 constant srt_el
  23. 155 constant srb_el
  24. \ Double frames
  25. 149 constant dh_el
  26. 150 constant dv_el
  27. 152 constant dlt_el
  28. 154 constant dlb_el
  29. 153 constant drt_el
  30. 155 constant drb_el
  31. \ Fillings
  32. 0 constant fill_none
  33. 32 constant fill_blank
  34. 135 constant fill_dark
  35. 135 constant fill_med
  36. 135 constant fill_bright
  37. [else]
  38. \ Single frames
  39. 196 constant sh_el
  40. 179 constant sv_el
  41. 218 constant slt_el
  42. 192 constant slb_el
  43. 191 constant srt_el
  44. 217 constant srb_el
  45. \ Double frames
  46. 205 constant dh_el
  47. 186 constant dv_el
  48. 201 constant dlt_el
  49. 200 constant dlb_el
  50. 187 constant drt_el
  51. 188 constant drb_el
  52. \ Fillings
  53. 0 constant fill_none
  54. 32 constant fill_blank
  55. 176 constant fill_dark
  56. 177 constant fill_med
  57. 178 constant fill_bright
  58. [then]
  59. : hline ( len x y -- ) \ Draw horizontal single line
  60. at-xy \ move cursor
  61. 0 do
  62. h_el @ emit
  63. loop
  64. ;
  65. : f_ascii ( -- ) ( -- ) \ set frames to ascii
  66. ascii_dash h_el !
  67. ascii_pipe v_el !
  68. ascii_plus lt_el !
  69. ascii_plus lb_el !
  70. ascii_plus rt_el !
  71. ascii_plus rb_el !
  72. ;
  73. : f_single ( -- ) \ set frames to single
  74. boot_serial? if f_ascii exit then
  75. sh_el h_el !
  76. sv_el v_el !
  77. slt_el lt_el !
  78. slb_el lb_el !
  79. srt_el rt_el !
  80. srb_el rb_el !
  81. ;
  82. : f_double ( -- ) \ set frames to double
  83. boot_serial? if f_ascii exit then
  84. dh_el h_el !
  85. dv_el v_el !
  86. dlt_el lt_el !
  87. dlb_el lb_el !
  88. drt_el rt_el !
  89. drb_el rb_el !
  90. ;
  91. : vline ( len x y -- ) \ Draw vertical single line
  92. 2dup 4 pick
  93. 0 do
  94. at-xy
  95. v_el @ emit
  96. 1+
  97. 2dup
  98. loop
  99. 2drop 2drop drop
  100. ;
  101. : box ( w h x y -- ) \ Draw a box
  102. 2dup 1+ 4 pick 1- -rot
  103. vline \ Draw left vert line
  104. 2dup 1+ swap 5 pick + swap 4 pick 1- -rot
  105. vline \ Draw right vert line
  106. 2dup swap 1+ swap 5 pick 1- -rot
  107. hline \ Draw top horiz line
  108. 2dup swap 1+ swap 4 pick + 5 pick 1- -rot
  109. hline \ Draw bottom horiz line
  110. 2dup at-xy lt_el @ emit \ Draw left-top corner
  111. 2dup 4 pick + at-xy lb_el @ emit \ Draw left bottom corner
  112. 2dup swap 5 pick + swap at-xy rt_el @ emit \ Draw right top corner
  113. 2 pick + swap 3 pick + swap at-xy rb_el @ emit
  114. 2drop
  115. ;
  116. f_single
  117. fill_none fill !