SB BBC @ GBR Oldie hints/tips #067-068 Hints and tips from the archives of Wakefield BBC Micro User Group... 67. Sideways ROM search ~~~~~~~~~~~~~~~~~~~ This is an interesting little program, adapted from one supplied by Dave Woodhead. It searches sideways ROMs, looking for words of more than one letter, and it then prints them on the screen. You get a lot of garbage also, but it's fun looking at all the commands and error messages. The ROM number will be 0 to 3 on a standard machine, and up to 15 if you have an expansion board. The Basic ROM is a good starting point, and this is usually in socket 0 on a standard machine. The program expects a 16k ROM, eg Basic or Watford DFS, but if the ROM is only 8k, as many are, then the search will run through twice. You can limit the search to 8k by altering the &BFFF to &9FFF in line 20. Please note that the use of Y% in line 10 is essential, even though it doesn't seem to do anything! If nothing appears on the screen within a few seconds, then the socket is empty. The Operating System ROM is NOT a sideways ROM, and so cannot be searched with this program, unless you have, say, an old OS 0.10 chip to plug into a spare sideways socket. 10 INPUT "ROM Number ",Y% 20 FOR !&F6=&8000 TO &BFFF 30 C%=USR(&FFB9) AND &FF 40 IF (C%>64 AND C%<91) OR (C%>96 AND C%<123) THEN VDU C% ELSE IF POS=1 THEN VDU 13 ELSE IF POS>1 THEN PRINT 50 NEXT:PRINT'"End of Search" 68. Secure cipher code ~~~~~~~~~~~~~~~~~~ One of the most fascinating stories of World War II concerns how British Intelligence were able to crack the codes generated by the German "Enigma" cipher machines. Thanks to a simple but elegant idea from James Slater, you too can produce very secure code using your Beeb. The method relies on the fact that you can "seed" the random number generator to start at different points in the pseudo-random sequence, and the message can't be decoded unless you know the "key" integer number used to seed the generator in the first place. The ASCII code is shifted by a random amount each time, and if you type a continuous string of A's, you will see the result! Note that the random number generator on the Master/Compact is coded differently from that on a BBC B/B+, so there is no compatibility between them when using this technique. The more digits you use in your key number, the harder it will be to crack the code by chance. The message may contain any keyboard character, including , but not . I am sure this cipher would not be considered secure in the context of giant business computers, which can try umpteen millions of combinations in a short time, but I reckon it could be a useful way of protecting private data on micros. If you make the alterations shown underneath, only capitals will be allowed, and the test is forced into 5-letter groups for extra security. Try it, it's great fun, but NOT over the air - it's strictly against the rules! 100 MODE6:INPUT''"Enter CODE KEY... "n% 110 randomize=RND(-(ABS(n%))) 120 PRINT'"Decipher or Encipher (D/E) ? "; 130 REPEATg$=CHR$(GETAND&DF):c%=INSTR("DE",g$)*2-3:UNTILc%<>-3 140 PRINTg$''"Please type your MESSAGE"' 150 REPEAT:REPEATg%=GET:UNTILg%>31ANDg%<127 160 IFPOS>38THENPRINT'' 170 k%=g%-32+c%*(RND(95)-1):VDUg%,10,8(k%+95)MOD95+32,11 180 UNTILFALSE Alternative lines for 5-letter groups, capitals only: 150 REPEAT:REPEATg%=GET:UNTILg%>64ANDg%<91 160 IFPOS>35THENPRINT'''" ";ELSEIFPOS MOD6=0 THEN PRINT" "; 170 k%=g%-65+c%*(RND(25)-1):VDUg%,10,8(k%+25)MOD25+65,11 73 Rick G4BLT @ GB7WRG