BlockFount

This is merely the skelton of a block fount toolkit. Whenever I "need" something like this, I add, remove, or alter things as required.

This demo uses the existing fount connected with a channel, but doesnt concern itself with things like CSIZE or CHAR_INC, or the rules concerning the uses of fount #1 and fount #2. They are relatively easy to implement if need be. Actually, there is no need to use the channel attached fount at all: Simply LBYTES a valid fount and use the load address as the basis. (See my FountView for an alternative implemetation.(Oops! That needs some spit'n polish first.))

As it stands, the demonstration harness is designed to be LRUNed in a standard S*BASIC mode 4 window - anything else will look odd - but its easy enough to change. It should run on any QL platform (albeit excruciatingly slowly on a BBQL!) This particular demo needs my Channel toolkit or equivalent.

10 rem LRESPR 'dev4_tks_chn_CHANS_BIN'
12 :
14 cw = 1: rem FOPEN("con")
16 BF_INIT#cw; 3
18 BF_PRINT 'Welcome to', 7: BF_LF
20 BF_PRINT 'BLOCKFOUNT', 6: BF_LF
22 BF_PRINT '  script  ', 4: BF_LF
24 BF_PRINT '==========', 1: BF_LF
26 PAUSE#cw; 200
28 BF_PRINT 'This is a very, very long line of text, just to show how things go', 7
30 PAUSE#cw; 200
32 :
34 :
100 rem + ------------------------------------------------------------------------ +
102 rem |<                              Block Fount                               >|
104 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
106 rem |                Selected, simplified Block Fount routines                 |
108 rem |                                                                          |
110 rem | bsz%                   - "pixel" size of BF                              |
112 rem |                                                                          |
114 rem | Sets up GLOBal variables:                                                |
116 rem |  wsx%/wsy%             - Window dimensions (Could be outside procedure)  |
118 rem |  bf_fa                 - fount1 address                                  |
120 rem |  bf_ch                 - current channel number used                     |
122 rem |  bf_csx%/bf_csy%       - BF charcter size                                |
124 rem |  bf_mgx%/bf_mgy%       - left and top margins                            |
126 rem |  bf_spx%/bf_spy%       - inter-character/line spacing                    |
128 rem |  bf_lln%               - line length in BF char size                     |
130 rem |  bf_pgh%               - line height in BF char size                     |
132 rem |  bf_bsz%               - block size (ie a "pixel" in BF char size)       |
134 rem |  bf_px%/bf_py%         - current cursor position in BF char size         |
136 rem + ------------------------------------------------------------------------ +
138 rem | V0.01, pjw, 2015 Feb 23, based on earlier work                           |
140 rem | V0.02, pjw, 2017 Feb 03, further development                             |
142 rem | V0.03, pjw, 2019 Jun 20, tidied up                                       |
144 rem + ------------------------------------------------------------------------ +
146 :
148 DEFine PROCedure BF_INIT(ch, bsz%)
150 wsx%    = SD_XSIZE(ch)
152 wsy%    = SD_YSIZE(ch)
154 bf_fa   = SD_FONT1(ch)
156 :
158 bf_mgx% = 10: bf_mgy% = 10
160 bf_spx% =  0: bf_spy% =  0
162 bf_csx% = bsz% * 8 + bf_spx%
164 bf_csy% = bsz% * 9 + bf_spy%
166 bf_lln% = INT(wsx% - bf_mgx%) / bf_csx%
168 bf_pgh% = INT(wsy% - bf_mgy%) / bf_csy%
170 bf_bsz% = bsz%
172 bf_ch   = ch
174 BF_CLS
176 END DEFine BF_INIT
178 :
180 :
182 rem + ------------------------------------------------------------------------ +
184 rem |<                                 BF_CLS                                 >|
186 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
188 rem |                      Clear screen and reset cursor                       |
190 rem |                                                                          |
192 rem + ------------------------------------------------------------------------ +
194 rem | V0.01, pjw                                                               |
196 rem + ------------------------------------------------------------------------ +
198 :
200 DEFine PROCedure BF_CLS
202 CLS#bf_ch
204 bf_px%  = 0: bf_py% = 0
206 END DEFine BF_CLS
208 :
210 :
212 rem + ------------------------------------------------------------------------ +
214 rem |<                                 BF_CHR                                 >|
216 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
218 rem |                       Draw a Block Fount Character                       |
220 rem |                                                                          |
222 rem | Draw character k$ at position atx%, aty%, in colour col                  |
224 rem + ------------------------------------------------------------------------ +
226 rem | V0.01, pjw                                                               |
228 rem + ------------------------------------------------------------------------ +
230 :
232 DEFine PROCedure BF_CHR(k$, atx%, aty%, col)
234 LOCal i, c, r%, k%, ax%, ay%, ca
236 k% = CODE(k$): rem IF k% = 10: k% = 32: rem Alternative handling of CHR$(10)..
238 :
240 IF k% < PEEK(bf_fa) OR k% > (PEEK(bf_fa) + PEEK(bf_fa + 1)) THEN
242  k% = PEEK(bf_fa)
244 END IF
246 :
248 ca = bf_fa + 2 - (PEEK(bf_fa) - k%) * 9
250 ax% = atx% * bf_csx% + bf_mgx%: ay% = aty% * bf_csy% + bf_mgy%
252 FOR i = 0 TO 8
254  r% = PEEK(ca + i)
256  FOR  c = 0 TO 7
258   IF BTST%(r%, c) THEN
260    BLOCK#bf_ch; bf_bsz%, bf_bsz%, ax% + (7 - c) * bf_bsz%, ay% + i * bf_bsz%, col
262   END IF
264  END FOR c
266 END FOR i
268 END DEFine BF_CHR
270 :
272 :
274 rem + ------------------------------------------------------------------------ +
276 rem |<                                BF_BLANK                                >|
278 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
280 rem |                Block out character at position atx%/aty%                 |
282 rem |                                                                          |
284 rem + ------------------------------------------------------------------------ +
286 rem | V0.01, pjw                                                               |
288 rem + ------------------------------------------------------------------------ +
290 :
292 DEFine PROCedure BF_BLANK(atx%, aty%, col)
294 BLOCK#bf_ch; bf_csx%, bf_csy%, atx% * bf_csx%, aty% * bf_csy%, col
296 END DEFine BF_BLANK
298 :
300 :
302 rem + ------------------------------------------------------------------------ +
304 rem |<                                BF_PRINT                                >|
306 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
308 rem |                       Print a string of characters                       |
310 rem |                                                                          |
312 rem | If it reaches the end of a line it moves the cursor to a new line.       |
314 rem | If it reaches the end of the pages, the page is scrolled                 |
316 rem + ------------------------------------------------------------------------ +
318 rem | V0.01, pjw                                                               |
320 rem + ------------------------------------------------------------------------ +
322 :
324 DEFine PROCedure BF_PRINT(str$, col)
326 LOCal i
328 FOR i = 1 TO LEN(str$)
330  IF bf_px% >= bf_lln%: BF_LF
332  BF_CHR str$(i), bf_px%, bf_py%, col
334  bf_px% = bf_px% + 1
336 END FOR i
338 END DEFine BF_PRINT
340 :
342 :
344 rem + ------------------------------------------------------------------------ +
346 rem |<                                 BF_LF                                  >|
348 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
350 rem |                                Line feed                                 |
352 rem |                                                                          |
354 rem + ------------------------------------------------------------------------ +
356 rem | V0.01, pjw                                                               |
358 rem + ------------------------------------------------------------------------ +
360 :
362 DEFine PROCedure BF_LF
364 bf_px% = 0: bf_py% = bf_py% + 1
366 IF bf_py% >= bf_pgh% THEN
368  SCROLL#bf_ch; -bf_csy%
370  bf_py% = bf_pgh% - 1
372 END IF
374 END DEFine BF_LF
376 :
378 :
380 :
1000 rem + ************************************************************************ +
1001 rem *<                      Miscellaneous help routines                       >*
1002 rem + ************************************************************************ +
1003 :
1004 DEFine FuNction BTST%(flg%, btn%): RETurn (2 ^ btn% && flg%) <> 0: END DEFine
1005 DEFine FuNction SD_FONT1(ch): RETurn CHAN_L (#ch;  42): END DEFine : rem   >>
     $2a font1 addresses, primary first font
1006 DEFine FuNction SD_XSIZE(ch): RETurn CHAN_W%(#ch;  28): END DEFine : rem   >>
     $1c window width, exclusive of border
1007 DEFine FuNction SD_YSIZE(ch): RETurn CHAN_W%(#ch;  30): END DEFine : rem  $1e ditto height
1008 :
1009 :
  
Generated with sb2htm on 2019 Jun 20
©pjwitte March 2oi9