SB BBC @ GBR Oldie hints/tips #069-071 Hints and tips from the archives of Wakefield BBC Micro User Group... 69. Ignoring shift/caps lock ~~~~~~~~~~~~~~~~~~~~~~~~ Simple routines which GET a character from the keyboard can be defeated by the CAPS and SHIFT LOCK settings. For example, if you are supposed to be answering "Y" or "N" to a question, then a "y" or "n" may confuse matters. Alternatively, if you are selecting from a menu, and should be entering a number from "1" to "5", then "!" or "%" will not do. If you have Wordwise, try using the main menu with the SHIFT LOCK set, and you'll see what I mean. You could overcome this by setting the required shift, from inside the program, with *FX202. A better way is to use AND and OR to ignore the effect of any binary bits which alter with the shift settings. This exploits the fact that "A" in binary ASCII is 01000001 and "a" is 01100001, and so on. Only the 3rd most significant bit is different, (bit 5), and we need to make sure it is always 0. The binary number 11011111 is DF in Hex, so, instead of A$=GET$ to get a "Y" or "N" answer, use A$=CHR$(GET AND &DF), which will always return capital letters. This can conveniently be used in a Function; ie A$=FNget, where the Function is defined as DEFFNget:=CHR$(GET AND &DF). In a similar fashion, a "1" in binary ASCII is 00110001, and a "!" is 00100001. Only bit 4 differs, and this time we want to make sure it is always a 1, and 00010000 is 10 in Hex. So, for numbers, instead of using A=VAL(GET$) or A=GET-48, you can use A=(GET OR &10)-48. Again, it is handy to use a Function; ie A=FNnum, which is defined as DEFFNnum:=(GET OR &10)-48. Letters (capitals) - DEF FNget:=CHR$(GET AND &DF) Numbers (digits) - DEF FNnum:=(GET OR &10)-48 70. Caps lock and shift lock ~~~~~~~~~~~~~~~~~~~~~~~~ If you use the keyboard with the off, then you have to press to get upper-case letters. As an alternative, you can hold down , press and release , and then release . You will now find that you will get upper-case normally, but lower-case if you hold . The effect is cancelled by pressing or . This can also be achieved from within a program with *FX202,160 , normal is *FX202,32 , normal Shift Lock is *FX202,16 , and no lock at all is *FX202,48 . You should really follow these calls with *FX118 , to make sure the keyboard LEDs change, but it doesn't seem to be necessary. *FX202,160 - Reverse Caps Lock *FX202,48 - No Lock at all *FX202,32 - Normal Caps Lock *FX202,16 - Normal Shift Lock 71. Acorn DFS 0.90 and 1.20 (DNFS) workspace ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ** GENERAL ALLOCATION ** Memory Locations Function ~~~~~~~~~~~~~~~~ ~~~~~~~~ &D00- DFF General Workspace E00- EFF Copy of Track-0 Sector-0 (with variations) F00- FFF Copy of Track-0 Sector-1 1000-10FF General Workspace 1100-11FF Parameter Blocks for Files 1200-12FF 1st File Buffer + SPOOL/EXEC 1300-13FF 2nd File Buffer 1400-14FF 3rd File Buffer 1500-15FF 4th File Buffer 1600-16FF 5th File Buffer 1700-18FF Further Workspace ** USEFUL LOCATIONS ** {A} means ascii code {N} means literal number &E00-E07 {A} First 8 bytes of disc Title, (see &F00-&F03). E08-E0E {A} First Filename, (7 bytes, padded with spaces). E0F {A} First Directory, (00 if same as current directory). NB: MSB of directory will be set if file is locked. You should AND this byte with 127 to get directory, and AND it with 128 to detect if it is locked. E10-E16 {A} Second Filename E17 {A} Second Directory E18-E1E {A} Third Filename E1F {A} Third Directory E20-E26 {A} Fourth Filename E27 {A} Fourth Directory etc.. EF8-EFE {A} Thirty-First Filename EFF {A} Thirty-First Directory F00-F03 {A} Last 4 bytes of disc Title (If less than 12 characterss, title is terminated with 00 on 0.90, but padded with spaces on 1.20.) F04 {N} Number of writes to the Catalogue. (Hex number which appears after disc Title) F05 {N} Number of files on disc, multiplied by 8. F06 {N} !BOOT file *OPT4 Option number. (eg 3 for EXEC). 0.90 1.20 &10CA &10C9 {A} Current Directory 10CB 10CA {N} Current Drive number 10CC 10CB {A} Library Directory 10CD 10CC {N} Library Drive number 73 Rick G4BLT @ GB7WRG