Monday, 22 October 2018

Answer to a question on the QLforum



In answer to polka's question in the QL Forum, here is a snippet of my boot code that allows the selection of multiple hardware configurations using a single boot file and to load alternative operating systems if desired.

The key elements are a timed loop that will start a default configuration if nothing is selected during the timeout period. Otherwise if an alternative configuration is chosen a file that indicates the selected cofiguration is written to the primary partition of the hard disk. This is used after the configuration of smsq/e is loaded and started by the boot file to set up the drivers and programs for the previously selected configurations.Nothing is written to these file but they could be used to add different adaptions to the boot.  



1000 REMark Overwrite the ROM SMSQ/E 2.91
1010 :
1020 REMark -- Mount Win2_,Win3_& Win4_ to make immediatly available --
1030 WIN_DRIVE 2,0,1 : WIN_DRIVE 3,0,2 : WIN_DRIVE 4,0,3 : ft=0
1040 REMark for the moment DONT automatically mount all drives except backup
1050 REMark AS DISK IS NOT ATTACHED
1060 REMark for the 1ST IDE SLAVE channel
1070 REMark WIN_DRIVE 5,1,0:WIN_DRIVE 6,1,1:WIN_DRIVE 7,1,2:WIN_DRIVE 8,1,3
1080 REMark for the 2ND IDE MASTER channel
1090 REMark WIN_DRIVE 5,2,0:WIN_DRIVE 6,2,1:WIN_DRIVE 7,2,2:WIN_DRIVE 8,2,3
1100 :
1110 WINDOW #0;SCR_XLIM(#0),SCR_YLIM(#0),0,0:CSIZE#0,0,0:INK#0,2:PAPER#0,0:CLS#0
1120 IF PEEKS$(2,3)='RES': GO TO 1930
1130 :
1140 WINDOW #1;256,128,128,64:INK#1,4:PAPER#1,0
1150 PAPER#1,0
1160 INK#1,7:PRINT "F1";:INK#1,4:PRINT " for SMSQ/E 3.33 (QMAC) + FAT32"
1170 INK#1,7:PRINT "F2";:INK#1,4:PRINT " for SMSQ/E 3.33 (QMAC) + QUBide"
1180 INK#1,7:PRINT "F3";:INK#1,4:PRINT " for SMSQ/E 3.33 (QMAC) + Win5-8"
1190 INK#1,7:PRINT "F4";:INK#1,4:PRINT " for SMSQ/E 3.33 + FAT16"
1200 PRINT
1210 INK#1,7:PRINT "F5";:INK#1,4:PRINT " for Test Versions of SMSQE & QPAC2"
1220 INK#1,7:PRINT "F6";:INK#1,4:PRINT " for QDOS Classic"
1230 INK#1,7:PRINT "F7";:INK#1,4:PRINT " for Mode4 SMSQ/E 3.32"
1240 INK#1,7:PRINT "F8";:INK#1,4:PRINT " for SMSQE Compile Enviroment"
1250 INK#1,7:PRINT "F9";:INK#1,4:PRINT " for SMSQ/E 3.13 mode 4 and PSION Chess"
1260 PRINT
1270 PRINT "   Timeout SMSQ/E 3.33 (QMAC) Win1-4 only"
1280 :
1290 timeout=DATE
1300 timeout=timeout+15
1310 REPeat lp
1320 IF PEEKS$(2,3)='RES':EXIT lp
1330 key=CODE(INKEY$(#0))
1340 SELect ON key
1350 :
1360   =232 : REMark F1 overwrite the ROM with SMSQ/E 3.33
1370          OPEN_OVER#3,"Win1_DoMountFat32":CLOSE#3:key=0
1380          AT#0,2,12
1390          PRINT#0,"INSERT CADDY with FAT32 CF card. Press ANYKEY"
1400          PAUSE#0
1410          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq333_ROM"
1420 :
1430   =236 : REMark F2 go with SMSQ/E 3.33 + QUBide
1440          OPEN_OVER#3,"Win1_DoQUBide":CLOSE#3:key=0
1450          AT#0,2,12
1460          PRINT#0,"INSERT CADDY with QUBide CF card. Press ANYKEY" : PAUSE#0
1470          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq333_ROM"
1480 :
1490   =240 : REMark F3 go with SMSQ/E 3.33 and Wins 5-8
1500          OPEN_OVER#3,"Win1_DoMountAll":CLOSE#3:key=0
1510          AT#0,2,12
1520          PRINT#0,"INSERT CADDY with HD containing Win5-8. Press ANYKEY" : PAUSE#0
1530          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq333_ROM"
1540 :
1550   =244 : REMark F4 Use the new version of SMSQ/E with 3.33
1560          OPEN_OVER#3,"Win1_DoFAT16":CLOSE#3:key=0  : AT#0,2,15
1570          PRINT#0,"INSERT CADDY with FAT16 CF card. Press ANYKEY" : PAUSE#0
1580          IF PEEKS$(2,3)<>'RES':LRESPR "WIN1_SMS_Q40smsq333_rom"
1590          REMark IF PEEKS$(2,3)<>'RES':LRESPR "WIN1_rom"
1600 :
1610   =248 : REMark F5 Test version of SMSQ/E
1620          OPEN_NEW#3,"Win1_TestQPAC2":CLOSE#3:AT#0,2,12
1630          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMQ_smsq_q40_testrom"
1640 :
1650   =234 : REMark F6 load QDOS Classic
1660           LRESPR Win1_Classic_SoftRom_rext
1670           COPY Win1_CLASSIC_CLASSICr_rom TO ram1_CLASSICr_rom
1680           PRINT#0,"Wait for Drive Light to go out, then Press Anykey to continue"
1690           PAUSE
1700           SOFTROM ram1_CLASSICr_rom
1710 :
1720   =238 : REMark F7 boot Mode 4 from Win1_
1730          OPEN_NEW#3,"Win1_Mode4":CLOSE#3
1740          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq332mode4_ROM"
1750 :
1760   =242 : REMark F8 Try SMSQ/E compile environment
1770          OPEN_NEW#3,"Win1_CmpEnv":CLOSE#3
1780          BEEP 5000,0
1790          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq333_rom"
1800 :
1810   =246 : REMark F9 boot 3.13 into mode 4
1820          OPEN_NEW#3,"Win1_psionchess":CLOSE#3
1830          IF PEEKS$(2,3)<>'RES':LRESPR "WIN1_SMS_q40mode4_rom"
1840 :
1850   =250 : REMark F10 smsq/e 3.33
1860          IF PEEKS$(2,3)<>'RES':LRESPR "Win1_SMS_Q40smsq333_rom"
1870 :
1880 END SELect
1890 IF DATE>timeout
1900      key=0:IF PEEKS$(2,3)<>'RES':LRESPR  "Win1_SMS_Q40smsq333_rom":EXIT lp
1910 END IF
1920 END REPeat lp
1930 :
1940 drv$="WIN1_"         : REMark Boot default directory
1950 REMark -- LOAD Enviroment Variable support early --
1960 LRESPR(drv$&"env_bin") : REMark used by all c68 progs
1970 :
1980 errt=FOPEN("Win1_DoMountFAT32")
1990 IF errt>0
2000    CLOSE#errt:DELETE "Win1_DoMountFAT32"
2010    WIN_DRIVE 5,2,0,0,"QXL.WIN"
2020    OPEN_OVER#3,ram1_Win5dump: DIR#3,Win5_:CLOSE#3:DELETE ram1_Win5dump
2030    SETENV "HDTYPE=FAT32"
2040 END IF
2050 :
2060 errt=FOPEN("Win1_DoMountAll")
2070 IF errt>0
2080    CLOSE#errt:DELETE "Win1_DoMountAll"
2090    WIN_DRIVE 5,2,0:WIN_DRIVE 6,2,1:WIN_DRIVE 7,2,2:WIN_DRIVE 8,2,3
2100    SETENV "HDTYPE=ALLWINS"
2110 END IF
2120 :
2130 errt=FOPEN("Win1_DoFAT16")
2140 IF errt>0
2150    CLOSE#errt:DELETE "Win1_DoFAT16" : WIN_DRIVE 5,2,0,0
2160    SETENV "HDTYPE=FAT16"
2170 END IF
2180 :
2190 errt=FOPEN("Win1_CmpEnv") : IF errt>0 :CLOSE#errt:LRUN Win1_Bootsmq_bas
2200 :
2210 errt=FOPEN("Win1_psionchess")
2220   IF errt>0
2230     CLOSE#errt:DELETE Win1_psionchess
2240     EX Win1_PRG_PSION_Chess_exe:STOP
2250   END IF
2260 :
2270 errt=FOPEN("Win1_Mode4")
2280 IF errt>0
2290    CLOSE#errt:DELETE "Win1_Mode4"
2300    REMark LRESPR("Win3_QTOP_thorgold_bin"):EX Win3_QTOP_TINDEX : STOP
2310    LRUN Win4_StartUp_Qx0boot
2320 END IF
2330 :
2340 TK2_EXT:IF VER$(1)>2.95 AND VER$(1)<=3.03:Set_Mode4_Colours
2350 key=KEYROW(7):REMark press "x" to load ProWess
2360 :
2370  IF VER$(1)<3 .03="" span="">
2380    LRESPR ('WIN1_CACHEMODES_rext') :WRITETHROUGH
2390    REMark LRESPR ('WIN1_MOVP4SMSQ60_cde')
2400 END IF
2410 REMark although MOVEP instruction removed from SMSQ/E 3.00 on there are some in Text87
2420 REMark so LRESPR 060 patch anyway
2430 LRESPR ('WIN1_MOVP4SMSQ60_cde')
2440 :
2450 IF VER$(1)=2.98 AND (key=0 OR key=8):DISP_SIZE 1024,512
2460 IF VER$(1)=2.99 AND (key=0 OR key=8):DISP_SIZE 1024,512
2470 :
2480 IF key=64:STOP
2490 :
2500 REMark -- Set Some Default Devices --
2510 IF SCR_LLEN>=128
2520   PWSDIR$="Win1_PWS_"  : REMark ProWesS default directory
2530 END IF
2540 DATA_USE "WIN1_" : PROG_USE "WIN1_"
2550 DEV_USE 1,Win1_PRG_EDT_ : REMark Editor 2.05 directory
2555 DEV_USE 8,FLP1_ : REMark make a device for CUE shell on Q68 to access a floppy
2560 :
2570 REMark set Colour Theme
2580 IF VER$(1)>=3.03:EX Win1_COLOUR_CoCo_setconf_bas;"Win1_COLOUR_CoCo_Themes_greys_thm,0"
2590 IF VER$(1)>=3.03:EX Win1_COLOUR_CoCo_setconf_bas;"Win1_COLOUR_CoCo_Themes_cream_thm,1"
2600 IF VER$(1)>=3.03:EX Win1_COLOUR_CoCo_setconf_bas;"Win1_COLOUR_CoCo_Themes_blueme_thm,2"
2610 IF VER$(1)>=3.03:EX Win1_COLOUR_CoCo_setconf_bas;"Win1_COLOUR_CoCo_Themes_copper_thm,3"
2620 :
2630 REMark set up window colours
2640 tcol=0
2650 IF VER$(1)>2.95:COLOUR_PAL:tcol=176
2660 WINDOW #0;SCR_XLIM(#0),SCR_YLIM(#0),0,0:CSIZE#0,0,0:INK#0,4:PAPER#0,tcol:CLS#0
2670 :
2680 BGCOLOUR_24 $919FCC : REMark BGCOLOUR_24 $AAAAFF : REMark BGCOLOUR_24 $878787
2685 REMark BGCOLOUR_24 $0
2690 : REMark Can we use ProWess
2700 errt=FOPEN("Win1_DoProWess")
2710 IF errt>0 : key=8 : CLOSE#errt:DELETE Win1_DoProWess
2720 IF SCR_LLEN>=128 AND key=8
2730   IF PWSDIR$(LEN(PWSDIR$))<>"_" THEN PWSDIR$=PWSDIR$&'_'
2740   LRESPR PWSDIR$&"ext_dll_rext"
2750   LRESPR PWSDIR$&"ext_syslib_rext"
2760   LRESPR PWSDIR$&"ext_global_rext"
2770   LRESPR PWSDIR$&"ext_PWbasic_rext"
2780   dd_err=0 : REMark for DATAdesign error trapping
2790 END IF
2800 :
2810 :
2820 REMark -- LOAD Extended environment extensions --
2830 IF VER$(1)>3.02
2840   LRESPR(drv$&"menu_rext")
2850   errt=FOPEN("Win1_TestQPAC2")
2860   IF errt>0
2870     CLOSE#errt:DELETE Win1_TestQPAC2
2880     LRESPR(drv$&"QPAC2_test")
2890   ELSE
2900     REMark LRESPR(drv$&"QPAC2_patch")
2910     LRESPR(drv$&"QPAC2_145a")
2920   END IF
2930 ELSE
2940   LRESPR("Win1_PRG_QD98_Menu_rext_old")
2950   LRESPR("Win1_TOOLS_QPAC2_Qpac2_139")
2960 END IF
2970 LRESPR ("Win1_QPTR")
2980 :
2990 REMark - Any more resident extensions?
3000 REMark --LOAD SERNET --
3010   BAUD 2,115200  : SER_ROOM 2,4096
3020   LRESPR("Win1_PRG_SERNET_sernet_rext")
3030   SNET 2
3040   SERNET
3050 :
3060 REMark install PFF virutal device whatever
3070 LRESPR ("Win1_PrinCtrl_PFF_bin")
3080 :
 and so on for loading extensions.

Saturday, 6 October 2018

Reading Long File Names on FAT formatted SD cards

FAT drivers have been embedded in smsq/e for some time. Initially FAT12 for DOS formatted floppy disks and now FAT16 for the Q68. One frustrating thing about the drivers is that they only support the DOS short file name naming convention of 11 characters. This truncates names and makes it difficult to identify files in a list of similarly named files as shown.


The conventions for constructing LFNs can be found on the internet so after a bit of SBASIC work here is a first iteration of a menu system to manage files via their LFN on FAT 16 formatted disks.

The interface still needs a bit of work.

Multiple files can now be copied, moved or deleted from the FAT16 formatted SDHC card using their LFNs.