PageRenderTime 35ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/share/examples/bootforth/frames.4th

https://repo.or.cz/dragonfly/vkernel-mp.git
Forth | 91 lines | 81 code | 10 blank | 0 comment | 1 complexity | 2d8dd59ade025cc2eeb9f181b1bc1c54 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Unlicense, BSD-3-Clause, ISC, GPL-2.0, AGPL-1.0
  1. \ Words implementing frame drawing
  2. \ XXX Filled boxes are left as an exercise for the reader... ;-/
  3. \ $FreeBSD: src/share/examples/bootforth/frames.4th,v 1.2 1999/08/28 00:19:09 peter Exp $
  4. \ $DragonFly: src/share/examples/bootforth/frames.4th,v 1.2 2003/06/17 06:36:57 dillon Exp $
  5. marker task-frames.4th
  6. variable h_el
  7. variable v_el
  8. variable lt_el
  9. variable lb_el
  10. variable rt_el
  11. variable rb_el
  12. variable fill
  13. \ Single frames
  14. 196 constant sh_el
  15. 179 constant sv_el
  16. 218 constant slt_el
  17. 192 constant slb_el
  18. 191 constant srt_el
  19. 217 constant srb_el
  20. \ Double frames
  21. 205 constant dh_el
  22. 186 constant dv_el
  23. 201 constant dlt_el
  24. 200 constant dlb_el
  25. 187 constant drt_el
  26. 188 constant drb_el
  27. \ Fillings
  28. 0 constant fill_none
  29. 32 constant fill_blank
  30. 176 constant fill_dark
  31. 177 constant fill_med
  32. 178 constant fill_bright
  33. : hline ( len x y -- ) \ Draw horizontal single line
  34. at-xy \ move cursor
  35. 0 do
  36. h_el @ emit
  37. loop
  38. ;
  39. : f_single ( -- ) \ set frames to single
  40. sh_el h_el !
  41. sv_el v_el !
  42. slt_el lt_el !
  43. slb_el lb_el !
  44. srt_el rt_el !
  45. srb_el rb_el !
  46. ;
  47. : f_double ( -- ) \ set frames to double
  48. dh_el h_el !
  49. dv_el v_el !
  50. dlt_el lt_el !
  51. dlb_el lb_el !
  52. drt_el rt_el !
  53. drb_el rb_el !
  54. ;
  55. : vline ( len x y -- ) \ Draw vertical single line
  56. 2dup 4 pick
  57. 0 do
  58. at-xy
  59. v_el @ emit
  60. 1+
  61. 2dup
  62. loop
  63. 2drop 2drop drop
  64. ;
  65. : box ( w h x y -- ) \ Draw a box
  66. 2dup 1+ 4 pick 1- -rot
  67. vline \ Draw left vert line
  68. 2dup 1+ swap 5 pick + swap 4 pick 1- -rot
  69. vline \ Draw right vert line
  70. 2dup swap 1+ swap 5 pick 1- -rot
  71. hline \ Draw top horiz line
  72. 2dup swap 1+ swap 4 pick + 5 pick 1- -rot
  73. hline \ Draw bottom horiz line
  74. 2dup at-xy lt_el @ emit \ Draw left-top corner
  75. 2dup 4 pick + at-xy lb_el @ emit \ Draw left bottom corner
  76. 2dup swap 5 pick + swap at-xy rt_el @ emit \ Draw right top corner
  77. 2 pick + swap 3 pick + swap at-xy rb_el @ emit
  78. 2drop
  79. ;
  80. f_single
  81. fill_none fill !