home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 4: Demo 1 / almathera_demo1.bin / sourcecode / german / soundtest.s < prev    next >
Text File  |  1995-03-17  |  2KB  |  115 lines

  1. org $35000
  2. load $35000
  3. ;
  4. ;  Digitized Sound Test
  5. ;  
  6. ;  by THE MAD THINKER on 28-Feb-87
  7. ;
  8. ; ---- memory usage
  9. MaxSnd=20480
  10. SndBuffer=$45000
  11. ; ---- exec.library 
  12. AbsExecBase=$4
  13. OpenLibrary=-408
  14. CloseLibrary=-414
  15. ; ---- dos.library
  16. Open=-30
  17. Close=-36
  18. Read=-42
  19. OPEN_OLD=1005
  20. ; ---- Program Entry Point !
  21. start:
  22.   move.l sp,initialSP
  23.   move.l AbsExecBase,a6
  24.   lea    DosName,a1
  25.   jsr    OpenLibrary(a6)
  26. ; ---- Load Digitized Data in ram
  27.   move.l d0,a6
  28.   move.l #FileName,d1
  29.   move.l #OPEN_OLD,d2
  30.   jsr    Open(a6)
  31.   move.l d0,d7
  32.   move.l d0,d1
  33.   move.l #SndBuffer,d2
  34.   move.l #MaxSnd,d3
  35.   jsr    Read(a6)
  36.   lsr.l  #1,d0
  37.   move.w d0,SndLen  ; len in words 
  38.   move.l d7,d1
  39.   jsr    Close(a6)
  40.   move.l a6,a1
  41.   move.l AbsExecBase,a6
  42.   jsr    CloseLibrary(a6)
  43. ; ---- setup system interrupts
  44.   move.l $70,OldVector
  45.   move.l #SndHandler,$70
  46.   move.w #$0080,$dff09c
  47.   move.w #$8080,$dff09a
  48. ; ---- setup sound registers
  49.   move.w #497,$dff0a6
  50.   move.w #1,timer
  51. ; ---- main sound loop
  52. loop:
  53.   btst  #6,$bfe001
  54.   beq.s fire
  55.   btst  #7,$bfe001
  56.   bne.s loop
  57.   bra.s  stopsnd
  58. ; --- start sound
  59. fire:
  60.   move.l #SndBuffer,$dff0a0  ; location register
  61.   move.w SndLen,$dff0a4
  62.   move.w #64,$dff0a8 ; volume
  63.   move.w #$8001,$dff096
  64.   move.l #10,d1
  65. ach2:
  66.   move.l #$ffffffff,d0
  67. ach:
  68.   dbra d0,ach
  69.   dbra d1,ach2
  70.   bra.s loop
  71. ; --- end of sound
  72. stopsnd:
  73.   move.w #$0001,$dff096
  74.   move.w #$0080,$dff09a
  75.   move.l OldVector,$70
  76.   move.l initialSP,sp
  77. illegal
  78.  
  79. ; --- Wait one scan line
  80. waitlin:
  81.   move.w $dff006,d0
  82.   lsr.w #8,d0
  83. wi1:
  84.   move.w $dff006,d1
  85.   lsr.w #8,d1
  86.   cmp.w d0,d1
  87.   beq.s wi1
  88.   rts
  89. ; --- Interrupt Sound Handler
  90. SndHandler:
  91.   move SR,-(sp)
  92.   move.l d0,-(sp)
  93.   btst  #7,$dff01f
  94.   beq.s weg
  95.   move.w #$0080,$dff09c
  96. ; -- play sound
  97.   subq.w #1,timer
  98.   bpl.s weg
  99.   move.w #$0001,$dff096
  100.   move.w #1,timer
  101.  weg:
  102.   bchg  #1,$bfe001
  103.   move.l (sp)+,d0
  104.   move (sp)+,SR
  105.   rte
  106. ; --- Data area
  107. FileName: DC.B 'df1:sound',0
  108.   even
  109. DosName: DC.B 'dos.library',0
  110.   even
  111. SndLen: blk.w 1,0
  112. OldVector: blk.l 1,0
  113. initialSP: blk.l 1,0
  114. timer: blk.w 1,0
  115.