home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / APLSND.PAS < prev    next >
Pascal/Delphi Source File  |  2000-06-30  |  2KB  |  74 lines

  1. Program AppleSound;
  2.  
  3. { This program loads a 6502 sound routine at apple address $302
  4.    then duration and frequency are loaded into $300 and $301
  5.    ($F300 and $F301 in Z80) finally the routine is called using
  6.    a general call to an apple subroutine.
  7.  
  8.   You can use this routine (try different durations and frequencies)
  9.    to get sound from your apple almost like the SOUND procedure
  10.    available to our IBM Turbo friends.
  11. }
  12.  
  13.  
  14. {=========================================================================}
  15. { This is a general procedure which will transfer control to a 6502 subroutine
  16.    in Apple memory.  The argument is the address (in 6502 address location).
  17.  
  18.     This procedure can easily be included in any program .
  19. }
  20.  
  21.   Procedure call_appl(AppleAddr : integer);
  22.  
  23.    Begin
  24.     inline($2A/>AppleAddr/$22/$F3D0/$2A/$F3DE/$77);
  25.    End;
  26.  
  27.       { here is the Z80 source code
  28.  
  29.         LD    HL,(addr)    ;get the apple address
  30.         LD    (0F3D0H),HL  ;store it in vector
  31.         LD    HL,(0F3DEH)  ;get the softcard address
  32.         LD    (HL),A       ;hit the softcard address
  33.       }
  34.  
  35. {============================================================================}
  36.  
  37.   Procedure LoadSnd;
  38.  
  39.     CONST
  40.       snd : array [0..25] of byte =
  41.       ($AC,01,03,$AE,01,03,$A9,04,$20,$A8,$FC,$AD,$30,$C0,
  42.        $E8,$D0,$FD,$88,$D0,$EF,$CE,00,03,$D0,$E7,$60);
  43.  
  44.     var
  45.       i : integer;
  46.  
  47.     Begin
  48.       for i:= 0 to 25 do
  49.        mem[$F302+i] := snd[i];
  50.     End;
  51.  
  52.    { now the sound routine is loaded }
  53.  
  54.   Procedure Sound(duration,frequency : byte);
  55.  
  56.     Begin
  57.       mem[$F300] := duration;
  58.       mem[$F301] := frequency;
  59.       call_appl($0302);
  60.     End;
  61.  
  62.   BEGIN
  63.     LoadSnd;
  64.     Sound(10,125);
  65.     Delay(100);
  66.     Sound(10,125);
  67.     Delay(100);
  68.     Sound(10,125);
  69.     Delay(100);
  70.     Sound(18,95);
  71.     Repeat until keypressed;
  72.   END.
  73.  
  74.