Keyboard Utilities



Keyboard Speaker


This program allows your BBC Micro to speak a word corresponding to the key you've pressed on the keyboard. The translation table is held in &A00 to &AFF and is filled up using the routine at lines 380 to 580. It can be turned off using *FX 13,2 and *FX 13,6.

   10 *FX 225 0
   20 O%=&B00
   30 FOR P=0 TO 1
   40   P%=&B00
   50   [OPT P*3
   60   CMP #2:BEQ event
   70   CMP #6:BEQ escape
   80   RTS
   90   .escape
  100   PHP:PHA:TYA:PHA
  110   LDA #125:JSR &FFF4
  120   LDY #27:JSR event
  130   PLA:TAY:PLA:PLP
  140   RTS
  150   .event PHP:PHA
  160   TXA:PHA
  170   TYA:PHA
  180   STY &70:JSR translate
  190   LDA #21:LDX #8:JSR &FFF4
  200   LDX #snd MOD256
  210   LDY #snd DIV256
  220   LDA #7:JSR &FFF1
  230   PLA:TAY
  240   PLA:TAX
  250   PLA:PLP
  260   .end RTS
  270   .translate LDA &0A00,Y
  280   CMP #0:BNE ok
  290   LDA #127
  300   .ok STA word
  310   RTS
  320   .snd BRK:]
  330   !(P%-1)=&0000FFFF
  340   !(P%+3)=&00000000
  350   word=P%+1
  360   NEXT
  370 !&220=!&220 AND &FFFF0000 OR O%
  380 FOR A%=0 TO 255
  390   B%=0
  400   IF A%>=48 AND A%<=57 THEN B%=A%
  410   IF A%>=65 AND A%<=90 THEN B%=A%
  420   IF A%>=97 AND A%<=122 THEN B%=A%
-32
  430   IF A%=13 THEN B%=252
  440   IF A%=ASC"+" THEN B%=A%
  450   IF A%=ASC"-" THEN B%=A%
  460   IF A%=ASC"*" THEN B%=A%
  470   IF A%=ASC"." THEN B%=A%
  480   IF A%=142 THEN B%=187
  490   IF A%=61 THEN B%=A%
  500   IF A%=ASC">" THEN B%=A%
  510   IF A%=ASC"<" THEN B%=A%
  520   IF A%=ASC"`" THEN B%=245
  530   IF A%=ASC"_" THEN B%=216
  540   IF A%=145 THEN B%=250
  550   IF A%=27 THEN B%=194
  560   IF A%=127 THEN B%=180
  570   A%?&A00=B%
  580   NEXT
  590 *FX 14 2
  600 *FX 14 6


Auto Repeat


Many commercial games disable the auto-repeat function. This means, for example, that if you wish to fire your laser several times rapidly, you have to lift your finger off the key and press it again every time you want to fire. This program allows you to fool the computer into thinking you have pressed the key over and over again incredibly quickly.
   Once you've entered and run this program, the computer will be ready for your game to be loaded. Make sure you don't press BREAK between running the auto-repeat program and loading the game you are to play. The key which this particular program repeats is the RETURN key (see the -74 in line 50). This can easily be changed to any key you want, just by modifying the value. The speed of the repeat is set in line 60. It is set here to 1 which means the repeat is continuous. Higher values slow the repeat rate down. He value of O% in line 40 will work with most programs. However, if you find that it doesn't work with a particular program (some problems occur with software-protected programs), change the &B00 to a lower value (which the program will not corrupt) such as &900.

   10 REM Auto Repeat on INKEY(key)
   20  
   30 VECTP=!&20A AND &FFFF
   40 O%=&B00
   50 key=-74
   60 speed=1
   70 REPEAT
   80   IF key<0 THEN key=key+256
   90   IF key>256 THEN key=key-256
  100   UNTIL key>=0 AND key<=256
  110 FOR P=0 TO 1
  120   P%=O%
  130   [OPT P*3
  140   CMP #&81:BEQ inkey
  150   JMP VECTP
  160   .inkey CPY #&80:BPL test
  170   JMP VECTP
  180   .test CPX#key:BEQ fire
  190   JMP VECTP
  200   .fire JSR VECTP
  210   BCS pfire
  220   LDA #0:STA flag
  230   RTS
  240   .pfire LDA flag
  250   CMP #speed:BEQ fireok
  260   INC flag:LDA #&81
  270   LDX #0:LDY #0:CLC:RTS
  280   .fireok LDA #0:STA flag
  290   LDA #&81:RTS
  300   ]
  310   flag=P%
  320   ?flag=speed
  330   NEXT
  340 !&20A=!&20A AND &FFFF0000 OR O%


Keyboard Sounder


This program gets the computer to emit a click sound each time a key is pressed. Once you've run the program, you can delete it. To turn on the 'click', use *FX 14,2 with *FX 13,2 to turn it off. The last pair of digits in line 190 controls the pitch (set in this listing to &FF). The volume is controlled by the second pair of digits in line 180, currently at &F1 (-15).

   10 *FX 225 0
   20 O%=&B00
   30 FOR P=0 TO 1
   40   P%=&B00
   50   [OPT P*3
   60   CMP #2:BNE end
   70   PHP:PHA
   80   TXA:PHA
   90   TYA:PHA
  100   LDX #snd MOD 256
  110   LDY #snd DIV 256
  120   LDA #7:JSR &FFF1
  130   PLA:TAY
  140   PLA:TAX
  150   PLA:PLP
  160   .end RTS
  170   .snd BRK:]
  180   !(P%-1)=&FFF10001
  190   !(P%+3)=&000100FF
  200   NEXT
  210 !&220=!&220 AND &FFFF0000 OR O%