Tuesday, 27 December 2011

One Hundredth Post Milestone for this Blog

It has arrived - the hundredth post for QL heaven. Here at QL Heaven the wonder is that 100 posts were filled so easily and that there are still ideas to try, and  plans to fulfil for this blog. The two hundredth post might just be achievable over the next year or 2 or 3.

For the 100th post a review of the most popular posts on this blog seemed appropriate. Here they are in descending order of hits according to google analytics.

1st - The 21st Century Black Box Sinclair QL Project here
2nd - First Post here
3rd - Ser-Usb Part 4 here
4th - Sinclair QL Shock here
5th - Jan Jones Designer and Writer of Sinclairs QL SuperBasic Language here
6th - Ser-USB Part 3 here
7th - QPC2 on Windows 7 here
8th - Still Off Topic here
9th - SerUSB Update and SuperForth now PD thanks to QL Users here
10th - April/May 2011 Quanta Magazine here

Of the top 10 3 featured the latest QL Hardware - the SerUSB device and one suggested a way to install a picoITX motherboard PC in a QL case. Hence there still is quite a bit of interest in QL hardware.

What were the least popular posts about? Here are some images from the least popular posts.

QL Heaven's thanks to all who have shown interest in this blog, those who have left comments and especially to the blog's one follower.

Have a Good New Year when it comes. 

Monday, 26 December 2011

SBASIC another listing

There are a plethora of interesting listings to be found in QL User, QL World, Quanta magazine, QLToday and other defunct publications. The length of the listing to be typed is often off putting. Interest in listings here at QL Heaven has been revived with the realisation that the new scanner has inbuilt OCR software that is really quite good. So as a starter here is a snipped of code written by Steve Poole, published in Quanta magazine some time ago and scanned, OCRed and touched up in less than an hour. 

100 :
110 CLEAR : REMark Text-Tumbler. Perspective Animation by S. Poole v30
120 rs=50 : slp = 0 : qz=rs*TAN(RAD(slp)):scy = .5 : Nb = 13 : DIM t(Nb,5): zz =  -5
130 Xaxis = 1 : Yaxis = 2 : Zaxis = 3
140 r90 = RAD(90) : r180 = PI : r270 = RAD(270) : r360=PI*2 : ac = 512 : dn = 256
150 WINDOW ac,dn,0,0 :PAPER 0 : INK 7 : CLS : WINDOW #2,512,206,0,0 : INK#0,7
160 SCX = .75*scy*(ac/dn) : SCALE scy,-SCX/2,-scy/2
170 cx = 0 : cy = scy : cz = qz : tz = qz : REMark cy=scy
180 tx = (rs*SIN(RAD(ng-180)))+cx : ty=(rs*COS(RAD(ng-180)))+cy : Fx=cx-tx: fy=cy-ty
190 fh=((Fx^2)+(fy^2))^.5 : fz=cz-tz : c=ATAN_(fy,Fx) : b=ATAN_(fz,fh)
210 FOR f=1 TO Nb : READ t(f,Xaxis),t(f,Yaxis),t(f,Zaxis):END FOR f
215 REPeat loop
220   FOR axis = 3 TO 1 STEP -1
230     FOR thru=0 TO r360 STEP PI/10
240       CLS
250       FOR f = 1 TO Nb
255         CIRCLE 0,0,1E-2
260         rotate axis,thru,t(f,Xaxis),t(f,Yaxis),t(f,Zaxis)
270         ok=VIEW_(Rx,Ry,Rz) : t(f,4)=m : t(f,5)=n
280       END FOR f
290     LINE t(1,4),t(1,5) TO t(2,4),t(2,5) TO t(3,4),t(3,5) TO t(4,4),t(4,5)
300     LINE TO t(5,4),t(5,5) TO t(6,4),t(6,5) TO t(7,4),t(7,5) TO t(8,4),t(8,5)
310     LINE TO t(1,4),t(1,5), t(9,4),t(9,5) TO t(10,4),t(10,5)
320     LINE t(11,4),t(11,5) TO t(12,4),t(12,5) TO t(13,4),t(13,5)
325     PAUSE 10: IF KEYROW(1): EXIT loop
330    END FOR thru
340  END FOR axis
345 END REPeat loop
350 WINDOW 512,206,0,0: CLS
360 :
370 DEFine PROCedure rotate(axe,agl,xx,yy,zz)
380 Rx=xx: Ry=yy: Rz=zz : IF Rx=0: IF Ry=0 : IF Rz=0: RETurn
390 op=Rz : aj=Rx: IF axe=Xaxis: aj=Ry: END IF : IF axe=Zaxis: op=Ry
400 Sop=(op>0)-(op<0): Saj=(aj>0)-(aj<0): hp=((op^2)+(aj^2))^.5
410 IF Sop=0 AND Saj=0: GO TO 590
420 IF Sop=0 AND Saj>0: ang=0
430 IF Sop>0 AND Saj>0: ang=ASIN(ABS(op/hp))
440 IF Sop>0 AND Saj=0: ang=r90
450 IF Sop>0 AND Saj<0: ang=r180-ASIN(ABS(op/hp))
460 IF Sop=0 AND Saj<0: ang=r180
470 IF Sop480 IF Sop<0 AND Saj=0: ang=r270
490 IF Sop<0 AND Saj>0: ang=r360-ASIN(ABS(op/hp))
500 ang=ang+agl: IF ang<0 : ang=ang+r360: END IF
505 IF ang>=r360:ang=ang-r360: END IF
510 IF ang=0 : Sop=0: Saj=1 : op=0 :aj=hp
520 IF ang>0: IF ang530 IF ang=r90: Sop=1: Saj=0 : op=hp: aj=0
540 IF ang>r90 : IF ang550 IF ang=r180 : Sop=0 : Saj=-1:op=0: aj=hp
560 IF ang>r180 : IF ang570 IF ang=r270: Sop=-1: Saj=0:op=hp: aj=0
580 IF ang>r270 :Sop=-1:Saj=l:ng=r360-ang:op=hp*SIN(ng):aj=hp*COS(ng)
590 IF axe=Xaxis: Ry=aj*Saj: Rz=op*Sop: Rx=xx
600 IF axe=Yaxis: Rx=aj*Saj: Rz=op*Sop: Ry=yy
610 IF axe=Zaxis : Rx=aj*Saj: Ry=op-Sop : Rz=zz
620 END DEFine rotate
630 :
640 DEFine FuNction VIEW_(vx,vy,vz)
650 lx=vx-tx: ly=vy-ty: lh=((lx^2)+(ly^2))^.5
660 lz=vz-tz: e=ATAN_(lz,lh)-b: h=ATAN_(ly,lx)-c
670 IF h > PI: h=h-PI*2: END IF : IF h<-PI: h=h+PI*2: END IF
680 IF e > PI: e=e-PI*2: END IF : IF e<-PI: e=e+PI*2: END IF
690 m=TAN(h)*1 : n=-1*TAN(e)*((m^2)+1)^.5: RETurn 1
700 END DEFine  VIEW_
710 :
720 DEFine FuNction ATAN_(oo,aa)
730 so=(oo>0)-(oo<0): sa=(aa>0)-(aa<0)
740 IF (so=0 OR so='1') AND sa=0: RETurn 0: END IF
750 IF so=0 AND sa='1': RETurn r90: END IF
760 IF so=-1 AND sa=0: RETurn r180 : END IF
770 IF so=0 AND sa=-1: RETurn r270: END IF
780 oa=ATAN(aa/oo)
790 IF so='1'AND sa='1': RETurn oa: END IF
800 IF so=-1 AND (sa='1'OR sa=-1): RETurn r180+oa: END IF
810 IF so='1'AND sa=-1: RETurn r360+oa: END IF
820 END DEFine ATAN_
830 :
840 DATA -7,-6,zz,-9,-6,zz,-11,-4,zz,-11,4,zz,-9,6,zz,-5,6,zz,-3,4,zz
850 DATA -3,-2,zz,-3,-6,zz,-7,-2,zz,3,6,zz,3,-6,zz,11,-6,zz

Saturday, 24 December 2011

Vanilla 3D Noughts and Crosses Enjoy

Updated 31st January 2012

3D Noughts and Crosses the listing in vanilla. Here it is. Mainly bug free in the sense that limited testing has revealed no more obvious bugs. It is still possible that some remain hidden. Or some were introduced when this listing was copied from QD via the scrap to Windows clipboard and pasted in to blogger. Who knows. The only way to find out is to copy the listing back into a QL emulator on your PC.

10 REMark 3d noughts and crosses
20 :
30 :
50 :
60 initialise : REMark all game data and variables
70 display_board true% : REMark display empty board  - once only
80 REPeat until_no_more_games
90     init_for_new_game
100       REPeat until_end_of_game
110          IF whos_go% = you% THEN
120                move% = get_your_move
130          ELSE
140                move% = generate_my_move
150          END IF
160          update_board(move%): result%=update_game_tables (move%)
170          IF result% <> game_not_over% THEN EXIT until_end_of_game
180          whos_go% = whos_go%*-1
190       END REPeat until_end_of_game
200       new_game% = game_over (result%)
210       IF NOT new_game% THEN EXIT until_no_more_games
220       display_board false%
230 END REPeat until_no_more_games
240 CLOSE#4 : CLOSE#5 : STOP
250 :
260 :
270 DEFine FuNction generate_my_move
280 LOCal i,j,p%,sq%,my2_count%,your2_count%,val,maxval,pathv
290 CLS #5 : PRINT#5," MY MOVE":PRINT#5,"    ...THINKING"
300 IF moves%<2 THEN
310    PAUSE 75
320    IF board%(1) = 0 THEN RETurn 1
330    IF board%(4) = 0 THEN RETurn 4
340 END IF
350 IF moves% > 4 THEN
360    p%=0
370    FOR i = 1 TO 76
380      IF path_value(i) = me% * 3 THEN RETurn find_square (i)
390      IF path_value(i) = you% * 3 THEN p% = i
400    END FOR i
410    IF p% > 0 THEN RETurn find_square (p%)
420 END IF
430 maxval = -1 : sq% = 0
440 FOR i = 1 TO 64
450    IF board%(i) = 0 THEN
460       val=0 :my2_count%=0 : your2_count%=0
470       FOR j= 1 TO sq_to_path%(i,0)
480          pathv = path_value(sq_to_path%(i,j))
490          IF pathv <> dead% THEN
495             IF pathv = 2 * me% THEN my2_count% = my2_count% + 1
500             IF pathv = 2*you% THEN your2_count%= your2_count% + 1
510             val = val +ABS(pathv) + .2 + 5E-2 * (pathv >0)
520          END IF
530       NEXT j
540         IF my2_count% > 1 THEN RETurn i
550         IF your2_count% > 1 THEN sq% = i * -1
560         IF   val >maxval AND sq% >= 0 THEN
570             maxval = val : sq% =i
580          END IF
590        END FOR j
600    END IF
610 END FOR i
620 RETurn ABS(sq%)
630 END DEFine
640 :
650 DEFine FuNction find_square(path%)
660   LOCal i
670   FOR i = 1 TO 4
680     IF board%(winning_paths%(path%,i)) = 0 THEN RETurn winning_paths%(path%,i)
690    END FOR i
700 STOP : REMark software error
710 END DEFine
720 :
730 DEFine PROCedure update_board(m%)
740   board%(m%) = whos_go% : moves% = moves% + 1
750   fill_previous_square
760   print_square m%,(whos_go%+3),1,true%
770 END DEFine
780 :
790 DEFine FuNction update_game_tables (sq%)
800 LOCal i,p%
810   FOR i = 1 TO sq_to_path%(sq%,0)
820       p% = sq_to_path%(sq%,i)
830       IF path_value(p%) <> dead% THEN
840         IF path_value(p%)*whos_go% < 0 THEN
850            path_value(p%) = dead%
860            dead_paths% = dead_paths% + 1
870            IF dead_paths% = 76 THEN RETurn stalemate%
880         ELSE
890            path_value(p%) = path_value(p%) + whos_go%
900            IF path_value(p%) = 4 * whos_go% THEN
910               highlight_winning_path(p%)
920               RETurn whos_go%
930            END IF
940          END IF
950       END IF
960    END FOR i
970 RETurn game_not_over%
980 END DEFine
990 :
1000 DEFine FuNction get_your_move
1010   LOCal x%,x,k%
1020   CLS#5 : PRINT#5,"    YOUR MOVE"
1026   FOR x = 1 TO 64 : IF board%(x) = 0 THEN x%=x : EXIT x
1040   REPeat until_enter
1050       print_square x%,7,0,false% : x = x%
1060       REPeat get_cursor
1070          k%=CODE(INKEY$(-1))
1080          IF k%= 10  THEN EXIT get_cursor
1090          IF k%= 32  THEN x% = find_next_sq (x%,16) : EXIT get_cursor
1100          IF k%= 192 THEN x% = find_next_sq (x%,-1) : EXIT get_cursor
1110          IF k%= 200 THEN x% = find_next_sq (x%,1)  : EXIT get_cursor
1120          IF k%= 216 THEN x% = find_next_sq (x%,4)  : EXIT get_cursor
1130          IF k%= 208 THEN x% = find_next_sq (x%,-4) : EXIT get_cursor
1140       END REPeat get_cursor
1150       print_square x,0,0,false%
1160    IF k% = 10 THEN RETurn x%
1170   END REPeat until_enter
1180 END DEFine
1190 :
1200 DEFine FuNction find_next_sq(start%,offset%)
1210 LOCal x%
1220 x%=start% : REMark x% = (start% + offset% + 63) mod 64 +1
1230 REMark if offset% > 0 then offset% = 1 : else offset = -1
1240 IF offset% = 16 THEN x%=(x%+15) DIV 16*16 : offset% = 1
1250    REPeat find_empty_sq
1260      x%=(x%+offset%+63) MOD 64 + 1 : REMark if board%(x%)=0 then return X%
1270      IF board%(x%) = 0 THEN RETurn x%
1280      REMark x% = x% + offset% : if x%= 0 OR x% = 65 then x% = (x% + 63) mod 64 + 1
1290    END REPeat find_empty_sq
1300 END DEFine
1310 :
1320 DEFine PROCedure fill_previous_square
1330   IF prev_ink <> 0 THEN INK#4,prev_ink : print_x% = save_x% : print_y% = save_y% : fill_square 1, false%
1340 END DEFine
1350 :
1360 DEFine PROCedure print_square (sq%,ik%,fill%,half_sq%)
1370 LOCal plane%,col%,row%,locink%
1380 plane% = invert ((sq%-1) DIV 16)
1390 row%   = invert (((sq%-1) MOD 16) DIV 4)
1400 col%   =        (sq%-1) MOD 4
1410 print_x% = x0% + (col%*xsq%)+(row%*(x01%-x0%) DIV 4) : REMark + 5
1420 print_y% = y0% + (plane%*y_diff%) + (row%*ysq%) : REMark + 1
1430 INK#4,ik%
1440 IF half_sq% THEN
1450    save_x% = print_x% : save_y% = print_y% : prev_ink = ik%
1460 END IF
1470   fill_square fill%,half_sq%
1480   INK#4,0
1490 END DEFine
1500 :
1510 DEFine FuNction invert(n%)
1520 IF n%=0 THEN RETurn 3
1530 IF n%=1 THEN RETurn 2
1540 IF n%=2 THEN RETurn 1
1550 RETurn 0
1560 END DEFine
1570 :
1580 DEFine PROCedure fill_square (fill%,half%)
1590   FILL#4,fill%
1600   IF NOT half% THEN
1610       LINE#4,print_x%+3,print_y%+1 TO print_x%+xsq%-1,print_y%+1 TO print_x%+xsq%-3+(x01%-x0%) DIV 4,print_y%+ysq%-1 TO print_x%+1+(x01%-x0%) DIV 4, print_¼y%+ysq%-1 TO print_x%+3,print_y%+1
1620   ELSE
1630       LINE#4,print_x%+3,print_y%+1 TO print_x%+xsq%-1,print_y%+1 TO print_x%+1+(x01%-x0%) DIV 4,print_y%+ysq%-1 TO print_x%+3, print_y%+1
1640   END IF
1650 FILL#4,0
1660 END DEFine
1670 :
1680 DEFine PROCedure highlight_winning_path (path%)
1690 LOCal i%,sq%
1700   FOR i = 1 TO 4
1710     sq%= winning_paths%(path%,i)
1720     print_square winning_paths%(path%,i),7,1,true%
1730   END FOR i
1740 END DEFine
1750 :
1760 DEFine PROCedure init_board_variables
1770 x0%=10 : y0%=4 : x1%=50 : y1%=24 : x01%=30 : x11%=70 : y_diff%=24
1780 xsq%=(x1%-x0%) DIV 4 : ysq% = (y1%-y0%) DIV 4
1790 END DEFine
1800 :
1810 DEFine PROCedure display_board (init%)
1820 prev_ink=0
1830 IF init% THEN
1840   PAPER #4,0 : INK #4,7 : CLS#4
1850     FOR i = 0 TO 3
1860       FOR j = 0 TO 4
1870         fromx% = x0% +(j*(x01%-x0%)DIV 4 ) : fromy% = y0% + (i*y_diff%) + (ysq%*j)
1880         IF j = 0 THEN
1890           FILL #4,1
1900           LINE #4,fromx%,fromy% TO fromx%+x1%-x0%,fromy% TO fromx%+x1%-x0%,fromy%-2 TO fromx%,fromy%-2 TO fromx%,fromy%
1910           FILL #4,0
1920         END IF
1930         LINE #4,fromx%,fromy% TO fromx% + x1%-x0%,fromy%
1940         fromx% = x0% +j * xsq% : fromy% = y0% + i * y_diff%
1950         LINE #4,fromx%,fromy% TO fromx% + x01%-x0%,fromy% + y1%-y0%
1960         IF j = 4 THEN
1970           FILL #4,1
1980           LINE #4,fromx%,fromy% TO fromx%+x01%-x0%,fromy% + y1%-y0% TO fromx%+x01%-x0%,fromy%+y1%-y0%-2 TO fromx%,fromy%-2 TO fromx%,fromy%
1990           FILL #4,0
2000         END IF
2010      END FOR j
2020    END FOR i
2030  ELSE
2040     FOR i = 1 TO 64
2050       IF board%(i) <> 0 THEN print_square i,0,1,false%
2060     END FOR i
2070  END IF
2080 END DEFine
2090 :
2100 DEFine FuNction game_over (res%)
2110  LOCal r% : r% = true%
2120  CLS#5
2130  IF res% = you% THEN PRINT #5,"     YOU WIN"
2140  IF res% = me%  THEN PRINT #5,"      I WIN"
2150  IF res% = stalemate% THEN PRINT #5,"  STALEMATE"
2160  PRINT # 5,"ANOTHER GAME? Y/N";
2170  REPeat another_game
2180    q$ = INKEY$(#5,-1)
2190    IF q$ = "y" THEN EXIT another_game
2195    IF q$ = "Y" THEN EXIT another_game
2200    IF q$ = "n" THEN r%= false% : EXIT another_game
2205    IF q$ = "N" THEN r%= false% : EXIT another_game
2210  END REPeat another_game
2220  CLS#5 : RETurn r%
2230 END DEFine
2240 :
2250 DEFine PROCedure init_for_new_game
2260 moves%=0 : dead_paths% = 0
2270 FOR i = 1 TO 76 : path_value(i) = 0 : END FOR i
2280 FOR i = 1 TO 64 : board%(i) = 0 : END FOR i
2290 IF RND < .5 THEN whos_go% = you% : ELSE whos_go% = me%
2300 END DEFine
2310 :
2320 DEFine PROCedure initialise
2330 DIM board%(64),winning_paths%(76,4),sq_to_path%(64,8)
2340 DIM path_value(76)
2350 REMark MODE 4
2360 BORDER#1,0:PAPER#1,0:BORDER#2,0:PAPER#2,0:CLS#1:CLS#2
2370 OPEN#4,scr_226x206a43x0 : BORDER#4,2,4 : PAPER#4,7
2380 OPEN#5,con_226x44a43x211 : BORDER#5,2,4 : PAPER#5,0 : INK#5,7 : CLS#5 : CSIZE#5,2,1
2390 instructions
2400 init_winning_paths
2410 init_board_variables
2420 true% = (1=1) : false% = (1=2)
2430 first%=true% : you% = -1 : me% = 1
2440 game_not_over% = 0
2450 stalemate% = 99
2460 dead% = 99
2480 END DEFine
2490 :
2500 DEFine PROCedure init_winning_paths
2510 LOCal x%,no_of_datasets%,first%,sq_inc%,path_inc%,no_of_paths%,val%
2520 x%=1
2530 READ no_of_datasets%
2540 FOR i = 1 TO no_of_datasets%
2550    READ first%,sq_inc%,path_inc%,no_of_paths%
2560    val% = first%
2570    FOR j = 1 TO no_of_paths%
2580        FOR k = 1 TO 4
2590            winning_paths%(x%,k) = val%
2600            sq_to_path%(val%,0) = sq_to_path%(val%,0)+1
2610            sq_to_path%(val%,sq_to_path%(val%,0))=x%
2620            val% = val% + sq_inc%
2630        END FOR k
2640        val% = val% - 4 * sq_inc% +path_inc%
2650        x% = x% + 1
2660    END FOR j
2670 END FOR i
2680 END DEFine
2690 :
2700 DATA 16
2710 DATA 1,1,4,16
2720 DATA 1,4,1,4
2730 DATA 17,4,1,4
2740 DATA 33,4,1,4
2750 DATA 49,4,1,4
2760 DATA 1,15,1,16
2770 DATA 1,5,16,4
2780 DATA 4,3,16,4
2790 DATA 1,17,4,4
2800 DATA 1,20,1,4
2810 DATA 13,12,1,4
2820 DATA 4,15,4,4
2830 DATA 1,21,0,1
2840 DATA 4,19,0,1
2850 DATA 13,13,0,1
2860 DATA 16,11,0,1
2865 :
2870 DEFine PROCedure instructions
2880 CLS#4 : INK#4,0
2900 PRINT#4,"       ======================"
2910 PRINT#4," This is noughts and crosses played"
2920 PRINT#4,"         on a 4x4x4x4 grid."
2930 PRINT#4," The object of the game is to get 4"
2940 PRINT#4,"    in a line through the grid."
2950 PRINT#4," When it is your turn to move,  use"
2960 PRINT#4," the cursor keys to move the cursor"
2970 PRINT#4," in the indicated direction, or the"
2980 PRINT#4," SPACE bar to move it into the next"
2990 PRINT#4,"             plane."
3000 PRINT#4," when you  have located the desired"
3010 PRINT#4," square,press the ENTER key to make"
3020 PRINT#4," your move.  ALL WILL BECOME CLEAR."
3030 PRINT#4
3060 END DEFine

Friday, 23 December 2011

3D Noughts and Crosses Debugged!

Here it is game in progress. The bug that took QL Heaven 3 weeks to track down was in the location in the code that it was thought to be. It escaped examination of the code while running the program. It escaped notice while cross checking a printout of the listing against the original listing in the magazine. What identified it was manually checking the calculations that these few lines did. Then the penny dropped. Of the three calculations two called the invert function. One did not, but in the listing QL Heaven had typed in all 3 did.  Hence the unexpected outputs of the program but not an obvious crash. It goes to show that you see what you expect to see and that's is the sole reason why it took so long to track this particular bug down. The program seems to play a reasonably mean game. But it is early days and as its strategies become known it may eventually prove to become a pushover. This thought makes QL Heaven think of some AI listing that had been published in QL World at some time. Could they be incorporated to give the program an opportunity to learn the style of its opponent as well?

The immediate plans for the program are to refurbish it with a movable window, perhaps re scalable, GD2 driver colours some icons instead of the filled in squares.
We will see what can be done.

Saturday, 17 December 2011

Debugging Listings and the Future is Black

Two ideas in  one post. QL Heaven has been unable to post for a while thanks to BT (British Telecom for non UK readers). QL Heaven recently moved to BT's Infinity Broadband service. Up to 41 MB downloads and an uncapped connection. Cable connection not required. It was great until the outage, only a few weeks after the connection had been set up. 5 days no service despite 4 conversations with the "help line service" which is based outside the UK. Eventually an engineer was promised and arrived. It took the engineer half a day to fix the problem which was something to do with the frequencies in the fiber optic cables, ie nothing to do with QL Heaven at all.


Problems aside QL Heaven has been trying to debug the 3D noughts and crosses listing on the basis of run the program and see where it fails and try to pick out the bug from the code running. This is proving somewhat inconclusive. QL Heaven has identified a number of typos that have made problems but many remain. Is there a structure or scientific way to debug programs. QL Heaven has decided the logical way to proceed now is to print out the typed in listing and compare it line by line with the QL World listing. Is there any6 simpler way to sort this out?

The Future is Black

On the QL user listing Peter Graf has been describing his progress with installing a SD card reader in one of the MDV slots of a basic QL. This has generated much interest. Memory Lane computing is also progressing with a ROM slot SD card reader project for black box QLs. The future is black.

A SuperGold card replacement is now definitely needed.

Additionally the Aurora replacement motherboard has a ROM slot. This slot was backwards compatible when the Aurora was launched baut could need an adapter for ROM modules that was available from QUBBESoft PD at the time Aurora was launched. QUBBESoft has stopped trading some time ago. Non the less the details should be obtainable. Imagine an Aurora board with SD card hard drive in the ROM slot installed in an original QL case and able to display on modern TFT monitors as the Aurora display sizes are compatible with these unlike most bits of QL hardware.

A SuperGold card replacement is now definitely definitely needed.

Sunday, 4 December 2011

Debugging 3D Noughts and Crosses

The debugging is taking longer than I had hoped. Found one typo type bug but there are more. Some may be structural as SBASIC is slightly dufferent from QDOS.

Wednesday, 30 November 2011

QL Stuff for Sale

QLs, QL books, memory expansions including Supergold cards, ROMs, magazines and all sorts of QL bits and pieces are for sale at the moment. Once there was a single page of second hand QL items on ebay, now there are 3 pages there and from the King of second hand QL items RWAP software there are 5 pages of a mega amount of stuff on the Sell My Retro site here. Browsing through this stuff QL Heaven spotted a QL User magazine that did not seem to be in the QL Heaven Library. There needs to be a check as QL Heaven has so many old QL magazines that sometimes the fading brain cells forget what is there. QL heaven has been kown to accidentally buy 2 copies of the same second hand magazine and then have to put the spare out on ebay. Anyway, back to the point does anyone have an interest in collecting these dust old magazines and if so for what? 

Saturday, 19 November 2011


QL Heaven has just been completing its re-subscription to Quanta for 2012. It is that time of year. If you are a member of Quanta you have to resubscribe. If you are not a member of Quanta and are interested in the QL why are you not a member of Quanta? Quanta despite all the mud slung at it in the last 10 years has as the latest magazine cover states been supporting the QL since 1984. It is the only remaining organisation (club) that has been there for QLers since the QL was launched. Its strength is its members. Now that is  a statement that flies in the face of conventional wisdom on the QL-users list (by the way that has gone really quiet for the past few weeks). Its members, both past and present are its strength because of the software written for the library, because of a willingness to write for the magazine, because its members have as individuals been responsible for many of the hardware and software developments in the last 20 years, because its members support QLToday the only "commercial" QL magazine, because its members blog, because its members run software repositories and help sites on the internet, because its members subscribe to the QL-users list, because its members help other QL users regardless of whether they subscribe to Quanta or not and most importantly because its current members are not quitters by instinct. While at present membership is down from thousands to a few hundred, with the internet and a rebasing of the subscription to ensure financial viability there is no reason why Quanta cannot continue until the last few QLers expire.

On another point the emag version of the Quanta magazine has markedly improved in quality which begs the question of why in this era of cheap broadband should anyone want the paper version any more. Anyway Quanta has finally bit the bullet and made the emag subscription cheaper than the paper magazine - about time too and well done for the decision and quality.

In case anyone is wondering QLHeaven does not own Quanta and is not a member of the Quanta committee so has completely impartial views with respect to Quanta. One final thought for Quanta - what about an ebay presence to sell subscription to recruit new members?

Sunday, 13 November 2011

3D Noughts and Crosses from QLWorld July 1986

The listing has finally been completely typed in. But as ever there are bugs. Some are typing errors that need to be tracked down and fixed. Some are possibly down to the fact that smsq/e is somewhat different from QDOS. At some point the black box original QL in QL Heavens possession will need to be reassembled, fired up and used to test the program.

Ultimately the intention is to update the program and publish it in updated form on this blog. Here are some pictures to show that it is partly running.

Sunday, 6 November 2011

ebay and the QL market place and QL books

The QL part of ebay remains buoyant with 4 pages of items. There is a QL offered as a buy it now for £70 including p&p. But before anyone rushes to a bargain it is described as "don't know if it is working". So £70 for spares is expensive.

More usefully there is a batch of books for sale including Andy Pennell's guide to the QL operating system. Titled "The Sinclair QDOS Companion". This is one of the 3 essential books that QL Heaven has used over the years to achieve programming results. The insights into the QDOS/SMSQE OS given in this book are essential if any understanding of the secrets of the OS is needed to achieve programming results. It does not matter that this book was originally published in 1985. The info in it is  still relevant especially as a rump of Quanta membership still adhere to original black box QLs running QDOS and SuperBasic so any current program that intends to be backwards compatible needs to understand and obey the OS rules described therein. In addition for more modern systems like QPC2 smsq/e is more backwards compatible than Windows has been up to Windows 7 so the book is still more than useful.

Sunday, 23 October 2011

PagePrint listing from QL World

QL Heaven has always been a fan of SNG's listings in QL World. At QL Heaven 2 programs have been used to print to a HP 840 via the serial port from a Q60 (no serial ports on the PCs here for QPC2). These have been, Ghostscript, and PagePrint (by SNG from QL World). One problem for QL Heaven has been the old style user interfaces they have. So here is PagePrint with a GD2 user interface and menu extension integrated to select files:

Here is the code :

1000 REMark PAGE_PRINT 1.5 by Simon Goodwin, 6th May 1993 Tweak by ME 2nd October 2009
1010 REMark Generates ASCII, Epson, HP PCL 3+, version 1.5
1020 REMark QL SuperBasic; uses PAN#0,0,115(SD.CURSEN)
1030 :
1040 REMark Turbo favours: IMPLICIT% i,j,k
1042 TURBO_objfil "ram1_PagePrint"
1044 TURBO_taskn  "PagePrint 09"
1046 TURBO_objdat 20
1048 TURBO_repfil
1050 TURBO_diags  'dis' : TURBO_struct 'str' : TURBO_model  '<'
1052 TURBO_optim  'br'  : TURBO_windo  0     : TURBO_locstr 'Crt'
1054 :
1056 dir$="Win1_"
1060 page_length%=70
1070 column_gap%=4
1080 tab_width%=8
1090 print_device$="par"
1095 :
1140 STOP
1150 :
1160 DEFine FuNction CHOICES%
1170 min_height%=10 : max_height%=4000
1180 WINDOW 452,52,36+xpos%,18+ypos% : WM_PAPER $201 : CLS
1190 WINDOW 452,52,30+xpos%,15+ypos% : WM_BORDER 1,$400 : WM_PAPER $201 : CLS
1200 CSIZE 0,0 : AT 1,11 : CSIZE 2,1 : WM_INK $202
1210 PRINT "Qdos PAGE PRINTING Utility"
1220 REMark Make Italic Banner
1230 FOR j=1 TO 9 : WINDOW 350,2,80+xpos%,ypos%+(25+j*2) : PAN 10-j
1240 WINDOW 448,50,32+xpos%,16+ypos% : CSIZE 1,0 : AT 3,4
1250 PRINT "For QL World, Version 1.5 @ 1993 Simon N Goodwin"
1260 REMark Add shadow to main window
1270 WINDOW 452,132,36+xpos%,78+ypos% : WM_PAPER $201 : CLS
1280 WINDOW 452,132,30+xpos%,75+ypos% : WM_BORDER 1,$400 : WM_PAPER $201 : CLS
1290 file$=FILE_SELECT$("Select a File to Print","",dir$,"",9,10,90,)
1295 PRINT\"File to print is: ";file$
1300 IF file$="" : PRINT#0,"Cancelled." : PAUSE 100: STOP
1310 REMark Add FTEST or DEVICE_STATUS here
1320 REPeat get_width
1330   PRINT\"Column width (e.g. 40): ";
1340   cols_used%=POSINT(#1)
1350   IF cols_used%<1 OR cols_used%>127
1360     PRINT \"Please specify a width between 1 and 127."
1370   ELSE
1380     EXIT get_width
1390   END IF
1400 END REPeat get_width
1410 col_spacing%=cols_used% + column_gap%
1420 WINDOW #0,452,32,36+xpos%,218+ypos% : WM_PAPER#0,201 : CLS#0
1430 WINDOW #0,452,32,30+xpos%,215+ypos% : WM_BORDER #0,1,$400 : WM_PAPER #0,$201
1440 CLS#0 : WM_BORDER #0,4,$400 : WM_INK #0,$202 : CSIZE #0,1,0
1450 :
1460 CLS : WM_PAPER $205 : WM_INK $206 : CSIZE 2,0
1470 AT 1,3:PRINT " Printer        Lines    Columns "
1480 AT 2,3:PRINT " standard       /page     /page  "
1490 i=1 : WM_PAPER $20A : WM_INK $20B : SHOW_VER$
1500 WM_PAPER $201 : WM_INK $202 : FOR i=2 TO pages% : SHOW_VER$
1510 PRINT #0;"For best PAGE PRINT results, pick the ";
1520 PRINT #0;"version to suit ";
1530 WM_INK #0,$202 : PRINT #0;"your "; : WM_INK #0,$202
1540 PRINT #0;"eyes and printer. Press ENTER to use the menu. ";
1550 SURE_PAUSE : i=1
1560 REPeat choose
1570   CLS #0
1580   PRINT #0;" Use the verical arrows (  ) to choose a version."
1590   PRINT #0;" Press SPACE to confirm or ESC to return to BASIC."
1600   REPeat poll
1610     PAUSE : k=KEYROW(1)
1620     IF k=0 : NEXT poll
1630     IF (k && 128) AND i1640       SHOW_VER$ : i=i+1 : WM_PAPER $20A : WM_INK $20B
1650       SHOW_VER$ : WM_PAPER $201 :WM_INK $202
1660     END IF
1670     IF (k && 4) AND i>1
1680        SHOW_VER$ : i=i-1 : WM_PAPER $20A : WM_INK $20B
1690        SHOW_VER$ : WM_PAPER $201 : WM_INK $202
1700     END IF
1710     IF k && 64
1720       CLS #0
1730       PRINT  #0;"PAGE PRINT version " & i;
1740       PRINT #0;" selected - are you sure?";
1750       IF YEA_OR_NAY : EXIT choose : ELSE NEXT choose
1760     END IF
1770     IF (k && 8)
1780       CLS #0 : PRINT #0;" Cancelled." : STOP
1790     END IF
1800   END REPeat poll
1810 END REPeat choose
1820 CLS #0
1830 PRINT #0;"The default paper size is A4, with ";
1840 PRINT #0;page_length%;" lines per page."
1850 IF i>=epson%
1860   PRINT #0," Do you want to change this";
1870   IF YEA_OR_NAY
1880     REPeat get_length
1890       CLS #0 : PRINT #0;"Enter page length, in standard ";
1900       PRINT #0;'3.1mm or 1/6" lines ?'
1910       page_length%=POSINT(#0)
1920       IF page_length%max_height%
1930         PRINT #0;" Sorry, this software expects ";
1940         PRINT #0;min_height%;" to ";max_height%;" lines/page. "
1950         PRINT #0;"Press ENTER to try again or ESC to quit. ";
1960         SURE_PAUSE
1970       ELSE
1980         EXIT get_length
1990       END IF
2000     END REPeat get_length
2010   END IF
2020   REMark work out gap between pages
2030   blanks%=5 * (1+(i=4 OR i=5))
2040   temp%=(height%(i) + blanks%)/70 * page_length% - blanks%
2050   height%(i)=temp%
2060 ELSE
2070  blanks%=0 : REMark no explicit blank lines in HP mode
2080 END IF
2090 RETurn i
2110 :
2120 DEFine PROCedure SHOW_VER$
2130 AT i+3,3 : PRINT title$(i);
2140 PRINT TO 20;height%(i) TO 29;
2150 PRINT (width%(i) + column_gap%) DIV col_spacing% TO 35
2170 :
2180 DEFine FuNction YEA_OR_NAY
2190 LOCal k$(2)
2200 PRINT #0;" (Y/N) ";
2210 REPeat loop
2220   k$=INKEY$(#0,-1)
2230   IF k$=="y" OR k$=="n" : EXIT loop
2240 END REPeat loop
2250 PRINT #0;k$ : RETurn k$<>"n"
2270 :
2280 DEFine PROCedure SURE_PAUSE
2290 PAN #0,0,115 : REMark turn cursor on
2300 REMark CURSEN#0
2310 PAUSE 5 : PAUSE 5 : PAUSE 5 : REMark lose key bounce
2320 IF INKEY$(#0,-1)=esc$ : PRINT #0\\"Escape pressed." : STOP
2340 :
2350 DEFine FuNction POSINT(channel%)
2360 LOCal k$(6)
2370 INPUT#channel%;k$
2380 IF "e" INSTR k$ OR k$="" THEN k$="0"
2390 IF k$<0 OR k$>32767 THEN k$=""
2400 RETurn "0" & k$
2420 :
2430 DEFine PROCedure PREPARE
2440 LOCal i
2450 tab$=CHR$(9) : esc$=CHR$(27) : space$=CHR$(32)
2460 hpx$=esc$ & "&" : hpt$=esc$ & "(" : formfeed$=CHR$(12)
2470 print%=3
2480 disk%=4
2490 epson_init$=esc$ & "@" : REMark reset Epson to power-up state
2500 REMark LF -> CR/LF, Wrap at right margin if line overflows
2510 hp_init$=hpx$ & "s0C" & hpx$ & "k2G" & hpx$
2520 REMark  Use portrait A4 paper, PC*%) character set
2530 hp_init$=hp_init$ & "126a0ol2dl44p01l28F" & hpt$ & "(12U"
2540 LET spec_max%=32 : REMark length limit for page setup strings
2550 LET title_max%=12: REMark Limiting length of printer name
2560 LET pages%=7 : REMark Total number of formats
2570 LET epson%=3 : REMark First Epson variant
2580 REMark Aim to be ready for anything
2590 DIM width%(pages%),height%(pages%)
2600 DIM page_spec$(pages%,spec_max%),title$(pages%,title_max%)
2610 RESTORE 2740
2620 FOR i=1 TO pages%
2630   READ title$(i)
2640   READ temp$ : IF i2650   READ width%(i),height%(i)
2660 END FOR i
2670 REMark Control codes don't suit constant data
2680 page_spec$(3)=CHR$(15) & esc$ & "M"
2690 page_spec$(5)=CHR$(15) & esc$ & "3" & CHR$(18) & esc$ & "S0"
2700 page_spec$(4)=page_spec$(5) & esc$ & "M"
2710 page_spec$(6)=CHR$(15)
2730 :
2740 REMark Name, setup string, width, height in characters
2750 DATA "HP 1","s0p12h6v0s0b6t2Q",96,130
2760 DATA "HP 2","s0p24h6v0s0b6t2Q",192,130
2770 DATA "New Epson 1","",160,65
2780 DATA "New Epson 2","",160,110
2790 DATA "Old Epson","",132,110
2800 DATA "Condensed","",132,65
2810 DATA "Plain ASCII","",80,65
2820 :
2840 LOCal t%
2850 form%=CHOICES%
2860 REMark INPUT "File Name     : ";file$
2870 REMark INPUT "Column width  : ";cols_used%
2880 REMark INPUT "Format (1..7) : ";form%
2890 REMark blanks%=5*(1 + (form%=4 or form%=5))
2900 REMark col_spacing%=cols_used%+column_gap%
2910 IF form%2920   pr_init$=hp_init$
2930 ELSE
2940   pr_init$=epson_init$
2950 END IF
2960 page_size$=page_spec$(form%)
2970 t%=width%(form%) : REMark "JM" bodge
2980 DIM grid$(height%(form%),t%)
3010 :
3040 page_count%=0 : row%=1 : col%=1
3060 IF row%+col%<>2 : PRINT_PAGE : REMark Do anything left
3070 CLOSE#print%
3080 CLS#0 : PRINT#0;page_count%; " page";
3090 IF page_count%<>1 : PRINT#0;"s";
3100 PRINT#0;" printed."
3120 :
3130 DEFine PROCedure PRINT_INIT
3140 OPEN#print%,print_device$
3150 PRINT#print%;pr_init$;
3160 PRINT#print%;page_size$;
3180 :
3190 DEFine PROCedure PRINT_FILE
3200 OPEN_IN#disk%,file$
3210 REPeat add_line
3220   IF EOF(#disk%) : EXIT add_line
3230   INPUT #disk%;line$;
3240   EXPAND_TABS line$
3250   BUFFER line$
3260 END REPeat add_line
3270 CLOSE#disk%
3280 CLOSE#disk%
3300 :
3310 REFERENCE line$ : REMark Turbo only
3320 DEFine PROCedure EXPAND_TABS(t$)
3330 LOCal t%,f$(tab_width%)
3340 REPeat look
3350   t%=tab$ INSTR t$
3360   IF t%= 0 OR t%=LEN(t$) : EXIT look
3370   f$=FILL$(space$,tab_width% - (t%-1) MOD tab_width%)
3380   t$=t$(1 TO t%-1) & f$ & t$(t%+1 TO )
3390 END REPeat look
3410 :
3420 DEFine PROCedure BUFFER(line$)
3430 grid$(row%,col% TO col%+cols_used%-1)=line$
3440 row%=row%+1
3450 IF row% > height%(form%)
3460   row%=1 : REMark back to top
3470   col%=col% + col_spacing%
3480   IF col%-1 > width%(form%)-cols_used%
3490     PRINT_PAGE
3500     col%=1
3510   END IF
3520 END IF
3540 :
3550 DEFine PROCedure PRINT_PAGE
3560 LOCal i
3570 FOR i=1 TO height%(form%)
3580    PRINT #print%;grid$(i,1 TO width%(form%))
3590 END FOR i
3600 IF form%3610   PRINT#print%;form_feed$;
3620 ELSE
3630   REMark Skip Perforation
3640   FOR i=1 TO blanks% : PRINT #print%
3650 END IF
3660 page_count%=page_count%+1
3690 :
3700 DEFine PROCedure BLANK_PAGE
3710 LOCal j
3720 FOR j=1 TO height%(form%)
3730   grid$(j)=FILL$(space$,width%(form%))
3740 END FOR j
3760 :
3810 errt=FOPEN(#0,'con_')
3820 errt=FOPEN(#1,'con_')
3830 wndo_wd%=512 : wndo_ht%=256
3840 xpos%=(SCR_XLIM(#0)-wndo_wd%)DIV 2 : ypos%=(SCR_YLIM(#0)-wndo_ht%) DIV 2
3850 OUTLN#0,wndo_wd%,wndo_ht%,xpos%,ypos%
3860 WM_PAPER#0,$201 : WM_INK#0,$202 : WM_BORDER#0,4,$400 : CLS#0

Sunday, 9 October 2011

Windraw_bas SBASIC tool

There are many editing tools for SBASIC. - QD and the editor built into SBASIC and accessed by the ED command being amongst the best. Some also like the Editor from DP. QD is amongst QL Heavens favourite programmes but there are times especially when typing in SBASIC listing that ED is preferable. Launching Windraw_bas as a daughter SBASIC job from Launchpad allows a movable reconfigurable set of SBASIC windows to configure for an SBASIC editing session using ED. Here is Windraw_bas and below some pictures of it in action. Credits to James Lucy and SA Hall and also QL Heaven for a tweak to this program.

100 REMark Move & Resize Basic's Windows
110 REMark James Lucy's program, much added to by S.A.Hall 04/06/97.
120 :
130 WDB0 = PEEK_L(PEEK_L(!!120))
140 xs=800:ys=400:xo=200:yo=68 : REMark my preferences for setup
150 :
160 errt=FOPEN(#0,con_)
170 errt=FOPEN(#1,con_):errt=FOPEN(#2,con_) : Get_pal 0
180 x% = SCR_XLIM(#0) :y% = SCR_YLIM(#0)        : REMark Get Screen Dims
190 setscreens:OUTLN#0,xs,ys,xo,yo
200 s=20                                        : REMark  speed to 10
210 POKE_W !!136,0                              : REMark caps lock off
220 REPeat draw_box
230   key=CODE(INKEY$(-1))                      : REMark Wait for key
240   m=1
250   SELect ON key
260    =102 : s=20                              : REMark "f" fast, moves in steps of 10
270    =115 : s=1                               : REMark "s" slow, moves in steps of 1
280    =208 : yo=yo-s : IF yo<0: yo=0           : REMark csr up
290    =216 : yo=yo+s : IF yo+ys>y%:yo=yo-s      : REMark csr down
300    =192:xo=xo-s:IF xo<0:xo=0                    : REMark csr left
310    =200:xo=xo+s: IF xo+xs>x%:xo=xo-s            : REMark csr right
320                                                REMark shift csr down
330    =220:ys=ys+s:m=0:IF ys+yo>y%:ys=y%-yo :m=0
340                                                REMark shift csr up
350    =212:ys=ys-s:m=0:IF ys<80:ys=80       :m=0
360                                                REMark shift csr right
370    =204:xs=xs+s:m=0:IF xs+xo>x%:xs=x%-xo :m=0
380                                                REMark shift csr left
390    =196:xs=xs-s:m=0:IF xs<160:xs=160     :m=0
400    =10: setscreens:CLS#0:CLS:CLS#2:NEW          : REMark Hit ; outline
410 END SELect
420 OUTLN#0,xs,ys,xo,yo:BORDER#0,1,Wbcol:CLS#0
430 IF m=1 :setscreens
440 IF s= 20 : a$='Fast':ELSE a$='Slow'
450 AT#0,0,1:PRINT#0, xs;'x';ys;' a ';xo;'x';yo;' ';:WM_INK#0,Wicol:PRINT#0,a$: OVER#0,-1
460 WM_INK#0,Wicol
470 END REPeat draw_box
480 :
490 DEFine PROCedure setscreens
500 xs12 = INT(xs*.5)                               : REMark Divide width &
510 xs2=INT(xs*.75)
520 ys12 = INT(ys*.8)                         : REMark Divide height to
530 ys0 = INT(ys*.2)                          : REMark keep it in scale
540 WINDOW#0,xs,ys0,xo,ys12+yo :WM_PAPER#0,Wpcol:INK#0,0:WM_BORDER#0,1,Wbcol
550 WINDOW xs,ys12,xo,yo:WM_PAPER Wpcol:WM_INK Wicol: WM_BORDER 1,Wbcol
560 WINDOW#2,xs2,ys12,xo,yo:WM_PAPER#2,Wpcol:WM_INK#2,Wicol:WM_BORDER#2,1,Wbcol:CSIZE#2,1,0
570 END DEFine
580 :
590 DEFine PROCedure Get_pal (syspal)
600 LOCal mem,num
610 REMark this is a general function to GET a system palette....
620   num = 57                  : REMark number of entries in palette
630   mem = ALCHP(num * 2)      : REMark mem needed for palette entries
640   SP_GET syspal,mem,0,57
650   Wpcol=PEEK_W (mem+23*2)    : REMark get palette entries in memory
660   Wicol=PEEK_W (mem+4)
670   Wbcol=PEEK_W (mem)         : REMark get palette entries in memory
680   CLCHP mem
690 END DEFine Get_pal
700 :

Sunday, 2 October 2011

Plodding on with SBASIC listing typing and feelings of mortality

Typing in 3D noughts and crosses from the QL World is like watching paint dry. But it is still progressing. The finished listing will be published and then any tweaks needed to update it for modern QL systems. The QL world has been quietish since the last QL Today was published. Thinner and lighter than before. Feels a bit like the last days of QL World but at least QL Today is not published by the late Robert Maxwell. Nor is there an employees pension fund to dip into. On ebay last night there are now 4 pages of QL items for sale. QLs in good condition still seem to be going for around £100 (UK). I dont know if the increase in QL items means more interest in QLing or a rush to get out before the end. Time will tell but one thing is certain which is that the end of the QL has been predicted before time and again staring when sinclair launched the QL before it was ready and then a year or so later when sinclair sold out to Amstrad. These predictions and been wrong so far but unfortunately its a bit like the mafia hit - it just need to be on the money the once and then you are dead and out while the QL has to be lucky every time.

                          Anyway here is the latest QL Today cover :

Sunday, 25 September 2011

QL World Programs

Its been a while sine QL Heaven posted. In the QL cyber world there has been an update to the SerUSB drivers, Quanta magazine and QL Today have been published and the first packed QL DVD Rom has been produced by the publishers of QL Today. Definitely and achievement. Here there has been some QLing going on. Since its not clear what new programs would exite and since QL Heaven cannot decide what to write next it has been decided to try to type in some of the old QL World magazine programs and see if they could be updated for the 21st century. Unfortunately typing in listings is a bit like watching paint dry but any way some typing has been done :

10 REMark 3d noughts and crosses
20 :
30 :
50 :
60 initialise : REMark all game data and variables
70 display_board true% : REMark display empty board  - once only
80 REPeat until_no_more_games
90     init_for_new_game
100       REPeat until_end_of_game
110          IF whos_go% = you% THEN
120                move% = get_your_move
130          ELSE
140                move% = generate_my_move
150          END IF
160          update_board(move%): result%=update_game_tables (move%)
170          IF result% <> game_not_over% THEN EXIT until_end_of_game
180          whos_go% = whos_go%*-1
190       END REPeat until_end_of_game
200       new_game% = game_over (result%)
210       IF NOT new_game% THEN EXIT until_no_more_games
220       display_board false%
230 END REPeat until_no_more_games
240 CLOSE#4 : CLOSE#5 : STOP
250 :
260 :
270 DEFine FuNction generate_my_move
280 LOCal i,j,p%,sq%,my2_count%,your2_count%,val,maxval,pathv
290 CLS #5 : PRINT#5," MY MOVE":PRINT#5,"    ....KING"
300 IF move%<2 THEN
310    PAUSE 75
320    IF board%(1) = 0 THEN RETurn 1
330    IF board%(4) = 0 THEN RETurn 4
340 END IF
350 IF moves% > 4 THEN
360    p%=0
370    FOR i = 1 TO 76
380      IF pathvalue(i) = me% * 3 THEN RETurn find_square (i)
390      IF pathvalue(i) = you% * 3 THEN p% = i
400    END FOR i
410    IF p% > 0 THEN RETurn find_square (p%)
420 END IF
430 maxval = -1 : sq% = 0
440 FOR i = 1 TO 64
450    IF board%(i) = 0 THEN
500    IF pathv = 2*you% THEN your2_count%= your2_count% + 1
510    val = val +ABS(pathv) = .2 = 5E-2 * (pathv >0)
520 END IF
530 NEXT j
540    IF my2_count% > 1 THEN RETurn 1
550    IF your2_count% > 1 THEN sq% = i * -1
560    IF   val >maxval AND sq% >= 0 THEN
570       maxval = val : sq% =i
580    END IF
590 END FOR j
600 END IF
610 END FOR i
620 RETurn ABS(sq%)
630 END DEFine
640 :

There is a lot more to come.

Thursday, 1 September 2011

QL World SBASIC Programs

Which QL World type in listing SuperBasic programs are worthy of the 21st century. Suggestions please.

Saturday, 27 August 2011

New Software for the QL and SMSQ/E

No announcements or answers here in QL Heaven. Just two questions, what new software to existing users need and which bits of existing software need updating. Just a bit of market research and wondering what software to write next. Any suggestions leave as a comment please. Thanks

Monday, 8 August 2011

What do QLers want for their next QL?

This question occurred to QL Heaven when perusing the latest posts on the ql-users list regarding the Raspberry Pi PC on a USB stick. Mouths watered at the prospect of a QL running on this system and porting a QL OS onto it. Reality eventually bit through Marcel Kilgus who posted in response to an earlier post speculating about running QPC2 under WINE on Linux on a Raspberry Pi - "

Norman Dunbar wrote:
> Well, I suspect that QPC will run under WINE on any flavour of Linux,
 >and not necessarily one that has an Intel Processor of x86 fame beneath

Hmm, where to begin... The very name of WINE itself stands for "Wine
Is Not an Emulator". It does not do ANY CPU emulation. So, running QPC
is downright out. Actually there is a WINE port for ARM, but it only
works with Windows apps that have been cross-compiled for the ARM
architecture (QPC, being much assembler code, cannot be cross
Additionally there is a way to employ the QEMU x86 emulator, but
I somehow doubt running an unsupported QEMU solution on such a slow
and limited platform would really work or be anything near usable.

> More specifically, SuperBasic is "just" a language - albeit a good one.
> So I suppose someone could write a SuperBasic interpreter/compiler in,
> say C, to be packaged up and/or compiled from source on any Linux.

While this is true, most power of the language comes from its
extensions and these would all have to be rewritten, too.

Cheers, Marcel"

Basically, no pun intended, it seems that QPC2 is written in assembler and therefore cannot be ported to non PC systems while SBASIC could be ported as a language but with out all the extensions written for it.

Yet what we know about the QL scene from the survey conducted earlier this year is that most QLers have either or both a black box QL, (plus or minus an expansion card) plus QPC2 emulator running on a PC.
The black box give the nostalgia return while QPC2 gives power, flexibility and ease of undertaking complex computing tasks on a QL like system. This takes QL Heaven back to one of its earlier posts suggesting that the future of the QL should be on a mini PC system as the list was suggesting but one that while small can run windows and therefore QPC2, but is small enough to be installed in the carcass of a QL black box.

Sunday, 31 July 2011

SBASIC is it over complex??

SuperBasic and its successor SBasic have been around for coming up for 30 years. The programming language was designed to be expandable and it has been enhanced in all sorts of ways the added toolkits etc. QL Heaven realised this when George Gwilt announced on the ql-user list

"Version 3.39 of Turbo Tk Code is on my site http://gwiltprogs.info/

This version allows COMMAND_LINE to select a daughter SBASIC's channel 0 by
giving as a parameter the ID of any channel opened to that SBASIC. The opened
channel does not need to be a CON device."

After reading this post QL Heaven realised that within the scope of QL heaven's programming there was no conceivable use for this tweak. A quick check using Toolkit 2's EXTRAS command demonstrated that the modest implementation of QPC2 on the laptop had 1044 keywords, the list finishing with GETENV$. What does that keyword do. How many are on the list that QL Heaven has never used. How many Keywords are on your QL and how many do you use?

Sunday, 17 July 2011

The Button Frame

QL heaven wonders how many QLers actually do anything with the button frame other than to put buttons to sleep in it. QL heaven got fed up with the button frame at the top left corner of the screen and has for may years placed it indented 40x20 pixels - suits the Q60 screen resolution. Admittedly that change is quite tame but no one seems to anything at all with the button frame.

Now the Ser-USB device has moved 120+MB of data from the Q60 - which is about 10 years old, and while going strong may not last forever, QL Heaven is looking at making a useful set up with QPC2. Screen resolution is one issue with emulators as the QL uses a 2:1 ratio but PC monitors traditionally had a more square type of resolution. This seems to be changing with the wide screen flat screen monitors now favoured in the PC world. QL Heaven's PC has a 23" flat screen monitor that supports resolutions close to 2:1 ratio thereby making the QL fonts and programs appear more as expected.

The resolution that seems to work best with QPC2 on QL Heaven's monitor is 1366x768 giving a ratio of 1.8 approximately. The screen shot from QPC2 also shows that modern PC hardware can emulate faster that native QL hardware now. The Q60 managed around 150 bogomips but QPC2 is getting over 200.

Getting back to the button frame QPAC2 can be configured to place the button frame anywhere and any size within screen limits. Jochen Merz released a button frame SBASIC extension enabling SBASIC programmers to create button tools. The GD2 colours and icon editors enable the programmer to create icons for these button tools. Effectively all the prerequisites are there for QLers to create a modern interface such as seen on the latest Macs where there is a row of 3D icon tools at the bottom of the screen.

Is anyone doing this, perhaps it belongs in QL Heavens crazy idea list.

Sunday, 3 July 2011

Jan Jones SuperBasic Book

Just found this on Amazon at around £20 GB. Also downloadable as a pdf. Doubtless technically an infringement of copyright. None the less it is still available for anyone coming back to the QL.

April/May 2011 Quanta Magazine

Its just out. New editor and one that sounds like a stayer and not a runner. Thanks of course to John Gilpin who has done so much to keep Quanta going during the past few years. Anyway late or not here is the content page. So if you are reading this as a QLer and are not a member of Quanta why not join. Its the only international club for Qlers. The magazine can be in colour as a .pdf or in black and white as paper. Why bother with paper these days, see below.

The image repository is here

Monday, 20 June 2011

Been Busy Copying files

The Ser-USB device loaned to QL Heaven has looked like this most of the last week. The activity LED and incandescent blue as it transferred around 128MB of files in several loads form the hard drive of the QL on to a QXL.win file of the laptop.

Ok its not exactly lightning speed even at baud 115200 but it is practicable and works. Are there any other uses for this amazing bit of QL hardware?

Wednesday, 15 June 2011

Sinclair QL Shock

Do you fancy this QL? It is an early model and rare.

It is for sale on ebay for £999 buy it now as a collectors item. There has been one offer so far. QL Heaven which is a fan of the QL in its many forms is shocked that QL collecting has become a pastime of investment bankers.

Read all about it here

Tuesday, 14 June 2011

QPC2 on Windows 7

QPC2 is the commercial QL emulator for the PC. There are also a number of other emulators that are shareware and are also very capable. Recently at QL Heaven the local PC was "upgraded" to Windows 7 and new things happened with QPC2. Basically files save to the QXL.win hard disk container were not retained after QPC2 was shut down. This it seems is down to permissions in the latest version of windows. This did not seem to be an issue with XP before. The solution after struggling around a bit was to run QPC2 always as the administrator to allow it to write to the PC's hard drive through the QXL.win filing system.

Incidentally as part of the investigation QPC2 3.34 (vista) was installed but this neither helped or showed any compatibility problems as did the previous version of QPC2 that had been in use of XP.

Monday, 13 June 2011

Ser-USB update and Super Forth now PD thanks to QL-Users

Still working with Ser-USB here at QL heaven. Testing has resulted in 50+MB of programs and data transferred from a QL to QPC2 on a laptop which itself has no serial ports. It is amazing what this bit of technology can do. As the transfer rate is slow, think an old style USB1 slow stick and then a bit slower but given time its now possible to port masses of programs and data across the disparate QL systems which all use different hard drive filing systems. How mad is that!. Black box QLs and Aurora use the Rebel Qubide driver, the Qx0 hardware emulators use a variant of an atari hard disk scheme, while the QPC2 uses a container file called a QXL.win file.

Over on the QL-users list because Rich had a client who was seeking a manual for SuperForth someone wondered where the author of that program was now. Low and behold someone else knew of his blog. He was contacted and gave his consent to the release of the SuperForth program to the public domain. Next while arranging for someone's paper copy of the manual another QLer reported that it had already been scanned in and was on the World of Spectrum site. Finally Dilwyn place SuperForth and a link to the pdf manual on his website. This all happened while most of us were at work. Speedy work for an obsolete computer systems supporters

Sunday, 5 June 2011

Ser-USB Part 4

QL Heaven has again been allowed to play with a SerUSB device. This time copying files from the SD card inserted into the device to QPC2's Win2_ on a PC. The laptop QL Heaven uses does not have a serial port so a USB to serial converter was installed. One was bought from Amazon for 8.40 euro, an ABC electronics product. It came with a mini CD with drivers which included Windows 7 drivers. Installed straightforwardly. Only point to note is that even although the laptop did not have any serial ports, it was installed as com3. Not really a problem. The assignment can be changed on the PC in Device Manager or more swiftly QPC2 was configured to attach ser1_ to com3. End of story. Anyway here is the device attached to the SerUSB device.

It works! And here is the device copying files from the SD card to the Win2_ QXL.win file on the Laptop's hard drive.

The process is not entirely seamless as some errors do occur. Copying directories with large numbers of files or extremely large QL files can lock up the SerUSB device necessitating a restart of the device and QPC2.
Large files that caused a lockup had to be be copied on their own. Sometimes they had to be copied to the ram disk as occasionally copying to the QXL.win file caused the laptop to crash. Exciting stuff but still a better way of transferring large quantities of files from one QL system to another. 

Sunday, 29 May 2011

Ser-USB Part 3

To use a  Ser-USB device on a QL obviously requires a connection with the serial port. After that the card or stick attached to the device needs formatting. The easy way to format uses the supplied Partition Manager task. This gives the option to initialise the device which is formatting and creating the root partition. After this has been accomplished subsequent partitions can be created simply through partition manager. So far QL Heaven has been playing about with making partitions and copying files to them and from them to get a feel for the system. Here are some screen shots of this happening. With the eye of faith you can see Qtrans (Dilwyn Jones program) displaying the contents of USB1_ and USB2_. 

The curvature of the image is down to the fact that this is a photograph of a CRT screen. The partitions can be quite large. No upper limit on partition size is mentioned in the manual but the practicalities of transferring files through the serial port should limit ambition. none the less it is possible to copy directories and then sub directories within the directory all to the USB device and then retrieve files.The question then is how large are directories on a QL root directory. There are no smsq/e functions to return this as far as QL Heaven is aware. So as there was a need here is QL Heavens SBASIC directory sizing program. The directory SBASIC containing all the _bas files has just been sized at 4MB and 486 files.

Saturday, 28 May 2011

Ser-USB Part 2

QL Heaven has been allowed to play with a ser-USB device during the past week. There is probably only a few things that can be done with this type of device. At QL Heaven the principal benefit from this device is access to a portable medium larger than a high density floppy disk that can be read by any QL that has access to serial ports.This can leave some PCs challenged these days as more modern motherboards tend to have only USB slots and SATA slots. A driver for the PC emulators that could read the QL, presumably QUBIDE formatted USB sticks that the device creates would be the ideal way around this. By the way the biggest QL partition QL Heaven has created so far is 20MB. More on the device later.

Sunday, 22 May 2011

The Ser-USB Device

QL Heaven has been allowed to play a bit with the new Ser-USB device. It is a compact transparent blue box. There are 2 USB slots and a SD card slot. On the reverse side is the 5v power connector and the reset button.
The Hardware comes with a disk with the necessary drivers to be LRESPRed, a file with additional S*BASIC commands, a partition manager task, a monitor task and some other files.

QL Heaven has seen files copied via the QL serial port to a card in the device and EXed out into QD. The speed of the process depends on the BAUD rates supported by the QL serial ports. For files bigger than a few kilobytes a SuperHermes chip or emulator with serial ports able to support 54860 baud or higher is necessity.

Anyway above is a first glimpse.

Wednesday, 18 May 2011


QL Heaven has seen and got to touch one of these new hardware devices for the QL. The package from memory lane computing is comprehensive and professional. The build quality of the device is excellent. It is supplied with a 44 page manual describing the operation of the device and its set up. Along with this and the device is a double density disk with all the drivers and software plus a cable to connect the device to the serial post of the QL. QL Heaven hopes to be able to report on how it works in the near future.

Saturday, 14 May 2011

QL Hardware News

The Ser-USB hardware adapter has been released by Memory Lane Computing. QL Heaven is hoping to get sight of this exciting new product. USB ports on a QL and access to flash card storage deices that are portable across the various hardware configurations of the QL. About time something like this existed. There are MBs of QL software in the public domain these days but the only direction of transfer depended on PCs burning to CDs and CD access on the QL.

Here is a picture of the device. :

On ebay there has been a lot of QL activity. Hardware and magazines and software. Up to 3 pages of QL stuff some going for amazing prices such as £35-00 for an non functional QL! Here at QL heaven we are interested in the old magazines for sale as some have amazing bits of code as listings to type in and play about with. More on that later perhaps.

Sunday, 8 May 2011

Jan Jones Designer and Writer of Sinclair's QL SuperBASIC language

QL Heaven discovered yesterday that Jan Jones is still a writer, but not about the QL at all. To quote her

"I am, first and foremost, a writer of romance. I believe that everybody, no matter how stressful their life, is entitled to at least one happy ending."

 If it seems unbelievable here i sthe link to her web site Jan Jones Website

Saturday, 7 May 2011

The 21st Century Black Box Sinclair QL project

Space 1999 is toast. The moon is still in orbit around Earth. While there is ample overwhelming evidence of alien life on Mars, NASA and the scientific community remain in total denial. But that life is undoubtedly native to Mars so we keep the moon and have not met any extra solar aliens either.

In the 21st Century the QL aficionados thirst for new hardware to run their QL programs on. OK some claim they do not, but the QL Heavens analysts suspect that despite their daytime denials they still dream of it and of the golden age of QL hardware which was the 1990s. New QL hardware disappeared with space 1999 although the moon remained.

So what now. It is time for QL Heaven to bring back the black box QL. This is a long term project and will cost a good bit of dough. So do not expect immediate results but over the next few months and longer the project will be documented here.

First off the internal dimensions of the original QL case. These are obviously important for the fitting of new gubbins. The internal width of the case is 120 mm exactly. The gap between the casing screws holding the top to the bottom of the case is 140 mm. The depth of the lower case is 22mm and that of the upper case is 22mm. The feet that tilt the QL to a typing angle give a maximum of 20 mm. The maximum depth therefore varies from close to 60 mm at the back down to 40 mm at the front. Here is my photographic evidence.

By the way and for information there are a few 1990 hardware bits, no space aliens, on this QL motherboard. At the far left is a Goldcard interfaced to the QL. At the left side the microdrives located at the lower right of the motherboard is a superHermes card. The keyboard ribbons are disconnected in this image.

Tuesday, 26 April 2011

Future QL Hardware

The QL sold most when it was marketed as a bundle. With software, printer and a keen price. One of the desirable and attractive features of the system was its distinctive black box styling. This at a time when all home computers had their own distinctive design.

The last 20 years of hardware development for the QL has seen it boxed up in PC style tower cases to look like a "proper computer". This was probably a mistake. I recently came across this web site http://www.mini-itx.com/store/, marketing nano itx boards and lo and behold several enterprising individuals have boxed these up in old computer cases and installed emulators. The QL has several excellent emulators that could run under windows on one of these boards. This is the opporunity for back to future QL hardware! Or back to black as someone else said.

I have no commercial interest in the miniitx store and where marked images are their copyright.