1\ Copyright (c) 2003 Scott Long <scottl@FreeBSD.org> 2\ Copyright (c) 2012-2015 Devin Teske <dteske@FreeBSD.org> 3\ All rights reserved. 4\ 5\ Redistribution and use in source and binary forms, with or without 6\ modification, are permitted provided that the following conditions 7\ are met: 8\ 1. Redistributions of source code must retain the above copyright 9\ notice, this list of conditions and the following disclaimer. 10\ 2. Redistributions in binary form must reproduce the above copyright 11\ notice, this list of conditions and the following disclaimer in the 12\ documentation and/or other materials provided with the distribution. 13\ 14\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24\ SUCH DAMAGE. 25\ 26\ $FreeBSD: releng/11.0/sys/boot/forth/frames.4th 280937 2015-04-01 01:54:28Z dteske $ 27 28marker task-frames.4th 29 30vocabulary frame-drawing 31only forth also frame-drawing definitions 32 33\ XXX Filled boxes are left as an exercise for the reader... ;-/ 34 35variable h_el 36variable v_el 37variable lt_el 38variable lb_el 39variable rt_el 40variable rb_el 41variable fill 42 43\ ASCII frames (used when serial console is detected) 44 45 constant ascii_dash 45 61 constant ascii_equal 46124 constant ascii_pipe 47 43 constant ascii_plus 48 49s" arch-pc98" environment? [if] 50 \ Single frames 51 149 constant sh_el 52 150 constant sv_el 53 152 constant slt_el 54 154 constant slb_el 55 153 constant srt_el 56 155 constant srb_el 57 \ Double frames 58 149 constant dh_el 59 150 constant dv_el 60 152 constant dlt_el 61 154 constant dlb_el 62 153 constant drt_el 63 155 constant drb_el 64 \ Fillings 65 0 constant fill_none 66 32 constant fill_blank 67 135 constant fill_dark 68 135 constant fill_med 69 135 constant fill_bright 70[else] 71 \ Single frames 72 196 constant sh_el 73 179 constant sv_el 74 218 constant slt_el 75 192 constant slb_el 76 191 constant srt_el 77 217 constant srb_el 78 \ Double frames 79 205 constant dh_el 80 186 constant dv_el 81 201 constant dlt_el 82 200 constant dlb_el 83 187 constant drt_el 84 188 constant drb_el 85 \ Fillings 86 0 constant fill_none 87 32 constant fill_blank 88 176 constant fill_dark 89 177 constant fill_med 90 178 constant fill_bright 91[then] 92 93only forth definitions also frame-drawing 94 95: hline ( len x y -- ) \ Draw horizontal single line 96 at-xy \ move cursor 97 0 do 98 h_el @ emit 99 loop 100; 101 102: f_ascii ( -- ) ( -- ) \ set frames to ascii 103 ascii_dash h_el ! 104 ascii_pipe v_el ! 105 ascii_plus lt_el ! 106 ascii_plus lb_el ! 107 ascii_plus rt_el ! 108 ascii_plus rb_el ! 109; 110 111: f_single ( -- ) \ set frames to single 112 boot_serial? if f_ascii exit then 113 sh_el h_el ! 114 sv_el v_el ! 115 slt_el lt_el ! 116 slb_el lb_el ! 117 srt_el rt_el ! 118 srb_el rb_el ! 119; 120 121: f_double ( -- ) \ set frames to double 122 boot_serial? if 123 f_ascii 124 ascii_equal h_el ! 125 exit 126 then 127 dh_el h_el ! 128 dv_el v_el ! 129 dlt_el lt_el ! 130 dlb_el lb_el ! 131 drt_el rt_el ! 132 drb_el rb_el ! 133; 134 135: vline ( len x y -- ) \ Draw vertical single line 136 2dup 4 pick 137 0 do 138 at-xy 139 v_el @ emit 140 1+ 141 2dup 142 loop 143 2drop 2drop drop 144; 145 146: box ( w h x y -- ) \ Draw a box 147 2dup 1+ 4 pick 1- -rot 148 vline \ Draw left vert line 149 2dup 1+ swap 5 pick + swap 4 pick 1- -rot 150 vline \ Draw right vert line 151 2dup swap 1+ swap 5 pick 1- -rot 152 hline \ Draw top horiz line 153 2dup swap 1+ swap 4 pick + 5 pick 1- -rot 154 hline \ Draw bottom horiz line 155 2dup at-xy lt_el @ emit \ Draw left-top corner 156 2dup 4 pick + at-xy lb_el @ emit \ Draw left bottom corner 157 2dup swap 5 pick + swap at-xy rt_el @ emit \ Draw right top corner 158 2 pick + swap 3 pick + swap at-xy rb_el @ emit 159 2drop 160; 161 162f_single 163fill_none fill ! 164 165only forth definitions 166