The Audible Apple

 

 

 

 

    The three machine language subroutines listed here
produce audio signals at the output normally used to write
to tape from the cassette interface.  For the best effect,
try connecting the output to the input of an audio amplifier.  
If there is no amp available, you can record the output on
tape and listen to the output.
     The subroutine at $300 creats an audio tone whose pitch
is determined by the value loaded in $16 and whose duration
depends on the number loaded in $15.  The routine at $318 is
identical, except that it creates no sounds.  It can be used
for rests if you use the routines for music, or for calibrated
intervals of silence for other applications.  I have worked out
the values to plug into $16 to create a musical scale, but
can't find the information now, so will let you work that out.  
The two BASIC routines here will give you a quick demonstration
of the possibilities.

10  for I=1 to 255 step 4      
20  FOR J=1 TO 255 STEP 4      
30  POKE 22,J: POKE 21,I       
40  CALL 768                   
50  NEXT J,I
60  END

10  I= RND(256): J= RND(256)
20  POKE 22,I: POKE 21,J
30  CALL 768
40  GOTO 10

     The subroutine at $330 uses the first two to generate
Morse Code.  To use it, store an ASCII character in $OE (14d)
and CALL 816.  The ASCII value is used to enter a conversion
table at $#AO to $3DF, which returns an eight bit pattern
defining the Morse equivalent of the letter.  The scheme for
storing the code characters is best explained with an example.

     The letter "L" in Morse id "dit dah dit dit".  Beginning
with the most significant bit of the 8 bit byte, a zero represents
a "dit" and a one represents a "dah".  After the last bit of
the Morse character, a final one serves as a stop bit.  The
remaining bits of the byte are zeros.  The "L" would be stored
as "01001000", or $48.  An "A", which is "dit dah" would be
encoded as "01100000", or $60.

     To convert this representation to actual Morse, one executes
a series of left shifts (ASL's).  After each shift, first check
to see if the word has gone to zero, indicating that the "stop"
bit has just moved into the carry.  If it did, you have completed
outputting the character code, and must follow it with the standard
character space.  If it did not go to zero, the state of the carry
flag tells you whether to output a dit or a dah.
     As with the tone generation routines, the Morse routine
can be driven from APPLE BASIC with a lttle finagling.  Use
the keyboard and CRT routines accompanying the cryptogram
program to Poke a string of characters into a table, then
transfer them to the Morse routine in sequence.  A neat code
practice generator should be:

 


10   N=0
20   FOR I=1 TO 5:  T= 192+RND(26)
30   POKE 14,T: CALL 15 : CALL 816
40   NEXT I: N=N+1: IF N MOD 6 THEN 60
50   PRINT
60   POKE 15,160: CALL 15: CALL 816
70   GOTO 10

     This should give you five letter groups of random characters
and display them on the CRT for checking your copy.  Oh yes!,
the Morse routine alters the character you stuffed into the
mailbox register, so be sure to call the CRT routine before
calling the Morse routine.

     Now for an apology.  These subroutines were cobbled up in
a hurry to get ready for a demonstration ath the local ham club
and they lack some refinements that would really be desirable
if you intend to use them extensively.  They could be implemented
in much less memory, if that were a consideration, and the
Morse routine requires a lot of hassle to change speeds.  The
values given here make it run at about 14 words per minute, to
change speeds, you must alter the "load immediate" instructions
at #342, $349, $352, $359, $362, & $36A.  These instructions
set up the length of a dit, an internal space between code
elements (equal to a dit, but silent), a dah, another internal
space, a space between letters, and a space between words--in
the order listed.  Smaller numbers mean faster code, just
remember to keep the proportions the same.
     I just spotted the odd looking sequence at $330 and $331.  
I could have used simply "LDY $OE" instead of "LDA $OE, TAY".  
Obviously this was done late at night.

 

300      A4 16      LDY      $16
302      A5 15      LDA      $15
304      85 17      STA      $17
306      A2 FF      LDX      #$FF
308      88         DEY
309      D0 05      BNE      $0310
30B      80 28 CO   STA      $COZ8
30E      A4 16      LDY      $16
310      CA         DEX
311      DO F5      BNE      $0308
313      C6 17      DEC      $17
315      D0 EF      BNE      $0306
317      60         RTS
318      A4 16      LDY      $16
31A      A5 15      LDY      $15
31C      85 17      STA      $17
31E      A2 FF      LDX      #$FF
320      88         DEY
321      D0 O5      BNE      $0328
323      80 28 BO   STA      $B028
326      A4 16      LDY      $16
328      CA         DEX
329      D0 F5      BNE      $0320
32B      C6 17      DEC      $17
32D      D0 EF      BNE      $0318
32F      60         RTS
330      A5 OE      LDA      $OE
332      A8         TAY
333      B9 00 03   LDA      $0300,Y
336      85 OE      STA      $OE
338      C9 80      CMP      #$80
33A      FD 26      BEQ      $0362
33C      06 OE      ASL      $OE
33E      F0 2A      BEQ      $036A
340      80 10      BCS      $0352
342      A9 20      LDA      #$20
344      85 15      STA      $15
346      20 03 00   JSR      $0300
349      A9 20      LDA      #$20
34B      85 15      STA      $15
340      20 18 03   JSR      $0318
350      00 EA      BNE      $033C
352      A9 60      LDA      #$60
354      85 15      STA      $15
356      20 00 03   JSR      $0300
359      A9 20      LDA      #$20
35B      85 15      STA      $15
35D      20 18 03   JSR      $0318
360      F0 DA      BEQ      $033C
362      A9 80      LDA      #$80
364      85 15      STA      $15

 

366      20 18 03   JSR      $0318
369      60         RTS
36A      A9 40      LDA      #$40
36C      85 15      STA      $15
36E      20 18 03   JSR      $0318
371      60         RTS


03A0 80 80 80 80 80 80 80 80
03A8 80 80 80 80 CE 80 56 94
03B0 FC 7C 3C 1C 0C 0F 84 C4
03B8 E4 F4 80 80 80 80 80 32
03C0 80 60 88 A8 90 40 28 D0
03C8 08 20 78 B0 48 E0 A0 F0
03D0 68 D8 50 10 C0 30 18 70
03D8 98 B8 C8 80 80 80 80 80

         03D0 is 68

Computer Type: 
Manufacturer: