I did this for Q-Route, and so thought that now the time is nigh to release the code for this common problem. There is some details about it in the SBASIC/SuperBASIC Reference Manual, but for Q-Route, I wrote my own commands - ATEXT, RFCURSOR, RFLINE and RFPOINT which all use the same co-ordinate system.
Code: Select all
100 REMark To start, some QL dependent variables
110 char_width0%=6: REMark value for csize 0,0
120 char_width1=8.45: REMark value for csize 1,0
130 char_height%=10: REMark height in pixels
140 graf_scale=256: REMark resolution used for graphics
150 ww%=448: REMark window width
160 wh%=200: REMark window height
170 wind_scalex=(1/ww%)*(graf_scale*(100/wh%*ww%/135.5))
180 wind_scaley=(1/wh%)*graf_scale
190 WINDOW #2,ww%,wh%,0,0
200 SCALE #2,graf_scale,0,0
205 tw=char_width0% : REMark which character width will we use for text?
210 DEFine PROCedure printat (x1,y1,s$)
220 atx=tw*(x1-1)
230 aty=(y1-1)*char_height%
240 ATEXT atx,aty,s$
250 END DEFine
260 :
270 DEFine PROCedure ATEXT(linex1,liney1,txt)
280 LOCal pos%
290 IF liney1<0 OR linex1>ww%:RETurn
300 IF liney1+char_height%>wh%:RETurn
310 txt$=txt
320 len_txt=LEN(txt$):IF len_txt=0:RETurn
330 IF linex1+len_txt*char_width0%<0:RETurn
340 txt_x%=linex1:pos%=1
350 pos%=pos%+(-linex1/char_width0%)*(linex1<0):IF pos%>1:txt_x%=0
360 RFCURSOR txt_x%,liney1
370 FOR txt%=pos% TO len_txt
380 IF txt_x%+char_width0%>ww%:EXIT txt%
390 PRINT#2,txt$(txt%);
400 txt_x%=txt_x%+char_width0%
410 END FOR txt%
420 END DEFine
430 :
440 DEFine PROCedure RFLINE(linex1,liney1,linex2,liney2)
450 LINE #2,linex1*wind_scalex,(wh%-liney1)*wind_scaley TO linex2*wind_scalex,(wh%-liney2)*wind_scaley
460 END DEFine
470 :
480 DEFine PROCedure RFCURSOR(linex1,liney1)
490 CURSOR #2,linex1*wind_scalex,(WINDTAB(2,5)-liney1)*wind_scaley,0,0
500 END DEFine
510 :
520 DEFine PROCedure RFPOINT(linex1,liney1)
530 POINT #2,linex1*wind_scalex,(WINDTAB(2,5)-liney1)*wind_scaley
540 END DEFine