xref: /freebsd/share/examples/bootforth/frames.4th (revision 2008043f386721d58158e37e0d7e50df8095942d)
1\ Words implementing frame drawing
2\ XXX Filled boxes are left as an exercise for the reader... ;-/
3
4marker task-frames.4th
5
6variable h_el
7variable v_el
8variable lt_el
9variable lb_el
10variable rt_el
11variable rb_el
12variable fill
13
14\ Single frames
15196 constant sh_el
16179 constant sv_el
17218 constant slt_el
18192 constant slb_el
19191 constant srt_el
20217 constant srb_el
21\ Double frames
22205 constant dh_el
23186 constant dv_el
24201 constant dlt_el
25200 constant dlb_el
26187 constant drt_el
27188 constant drb_el
28\ Fillings
290 constant fill_none
3032 constant fill_blank
31176 constant fill_dark
32177 constant fill_med
33178 constant fill_bright
34
35: hline	( len x y -- )	\ Draw horizontal single line
36	at-xy		\ move cursor
37	0 do
38		h_el @ emit
39	loop
40;
41
42: f_single	( -- )	\ set frames to single
43	sh_el h_el !
44	sv_el v_el !
45	slt_el lt_el !
46	slb_el lb_el !
47	srt_el rt_el !
48	srb_el rb_el !
49;
50
51: f_double	( -- )	\ set frames to double
52	dh_el h_el !
53	dv_el v_el !
54	dlt_el lt_el !
55	dlb_el lb_el !
56	drt_el rt_el !
57	drb_el rb_el !
58;
59
60: vline	( len x y -- )	\ Draw vertical single line
61	2dup 4 pick
62	0 do
63		at-xy
64		v_el @ emit
65		1+
66		2dup
67	loop
68	2drop 2drop drop
69;
70
71: box	( w h x y -- )	\ Draw a box
72	2dup 1+ 4 pick 1- -rot
73	vline		\ Draw left vert line
74	2dup 1+ swap 5 pick + swap 4 pick 1- -rot
75	vline		\ Draw right vert line
76	2dup swap 1+ swap 5 pick 1- -rot
77	hline		\ Draw top horiz line
78	2dup swap 1+ swap 4 pick + 5 pick 1- -rot
79	hline		\ Draw bottom horiz line
80	2dup at-xy lt_el @ emit	\ Draw left-top corner
81	2dup 4 pick + at-xy lb_el @ emit	\ Draw left bottom corner
82	2dup swap 5 pick + swap at-xy rt_el @ emit	\ Draw right top corner
83	2 pick + swap 3 pick + swap at-xy rb_el @ emit
84	2drop
85;
86
87f_single
88fill_none fill !
89