home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Sound / mhi_dev / MASPro / Source / mas_interrupt.s < prev    next >
Encoding:
Text File  |  2001-03-30  |  2.9 KB  |  154 lines

  1. ;a2
  2. ;struct MPHandle
  3. ;{
  4. ;   APTR data;             /* current buffer node              */   4   0
  5. ;   APTR endnode;          /* node at the end of the list     */   4   4
  6. ;   struct Task *task;      /* task that wants signals         */      4    8
  7. ;   ULONG mhisignal;       /* signal mask to use               */   4    12
  8. ;     UBYTE status;                                                                  1   16
  9. ;};
  10.  
  11. ;a3
  12. ;struct MPBufferNode
  13. ;{
  14. ;   struct MinNode  my_MinNode;     8   0
  15. ;   APTR    buffer;                 4   8
  16. ;   APTR    pos;                    4   12
  17. ;   ULONG   bytesleft;              4   16
  18. ;};
  19.  
  20. ;****************************************************************
  21.  
  22.     incdir Fireball:StormC/Asm-Includes
  23.     INCLUDE "exec/types.i"
  24.     INCLUDE "hardware/custom.i"
  25.     INCLUDE "hardware/intbits.i"
  26.  
  27. JSRLIB MACRO
  28.     XREF    _LVO\1
  29.     JSR    _LVO\1(A6)
  30.     ENDM
  31.  
  32.     xdef        _dcr_pro_int
  33.  
  34.     section code
  35.     
  36. _dcr_pro_int:                    ;this is the routine which gets executed each time the Timer fires.
  37.  
  38.     cmp.b        #0,16(a1)        ;are we in play mode?
  39.     bne        quick_exit        ;nope, so exit
  40.  
  41.     btst.b    #0,$bfd000        ;check if mas3507 is demanding data
  42.     beq        quick_exit        ;nope, so exit
  43.  
  44.     MOVEM.l    d0-d7/a0-a3,-(a7)   ;save registers
  45.  
  46. node_loop
  47.  
  48.                                     ;a pointer to our interupt data is in a1
  49.     move.l    (a1),a2            ;interupt data node address
  50.     beq        quick_exit2        ;no data, so exit
  51.  
  52.     move.l    12(a2),a0        ;data position
  53.     move.l    16(a2),d7        ;bytes left to process
  54.     beq        next_node        ;if no more data skip to next node
  55. ;    beq        quick_exit
  56.  
  57. ;    move.w    #63,d6            ;byte counter
  58.     cmp.l        #200,d7
  59.     bge        max
  60. ;    bset.b    #1,$bfe001
  61.     move.l    d7,d6
  62.     move.l    d7,d4
  63.     sub.w        #1,d6
  64.     jmp        byteloop
  65. max
  66.     move.w    #199,d6
  67.     move.l    #200,d4
  68.  
  69. byteloop
  70.  
  71.     move.b    (a0)+,d0            ;get data
  72.  
  73.     move.l    #3,d5
  74.  
  75. bitloop
  76.  
  77.     move.b    d0,d1
  78.     and.b        #%10000000,d1
  79.     ror.b        #7,d1
  80.     bset.b    #1,d1
  81.     move.b    d1,$bfe101
  82.  
  83.     rol.b        #1,d0
  84.     move.b    d0,d1
  85.     and.b        #%10000000,d1
  86.     ror.b        #7,d1
  87. ;    bclr.b    #1,d1
  88.     move.b    d1,$bfe101
  89.     rol.b        #1,d0
  90.  
  91.     dbra        d5,bitloop
  92.  
  93.     dbra        d6,byteloop
  94.  
  95. ;    eori.B    #$02,$bfe001
  96.  
  97.     move.l    a0,12(a2)        ;save address
  98. ;    sub.l        #64,d7            ;subtract bytes from bytesleft
  99.     sub.l        d4,d7
  100.     bge        no_zero
  101.     move.l    #0,d7
  102. no_zero
  103.     move.l    d7,16(a2)        ;save it back out
  104.  
  105.     move.b    #0,16(a1)
  106.  
  107.     movem.l    (a7)+,d0-d7/a0-a3        ;restore registers
  108. ;    bclr.b  #1,$bfe001
  109.     rts
  110.  
  111. quick_exit
  112.  
  113. ;    movem.l    (a7)+,d0-d7/a0-a3        ;restore registers
  114. ;    bset.b    #1,$bfe001                ;led off        
  115. ;    moveq        #0,d0
  116.     RTS
  117.  
  118. quick_exit2
  119.  
  120.     movem.l    (a7)+,d0-d7/a0-a3        ;restore registers
  121. ;    bclr.b    #1,$bfe001                ;led off
  122. ;    moveq        #0,d0
  123.     RTS
  124.  
  125. next_node
  126. ;    bclr.b    #1,$bfe001
  127.  
  128.     move.l    a1,d7                ;save a1
  129.     move.l    12(a1),d0        ;get signal mask
  130.     move.l    8(a1),a1            ;get task address
  131.     JSRLIB    Signal            ;signal task
  132.     move.l    d7,a1                ;restore a1
  133.  
  134.     move.l    4(a1),d0
  135.     cmp.l        a2,d0                ;is this the last node?
  136.     beq        end_play            ;it is so exit
  137.  
  138. ;    bset.b    #1,$bfe001
  139.  
  140.     move.l    (a2),(a1)
  141.     beq        end_play
  142.     move.l    (a2),a2            ;get next buffer data
  143.     move.l    a2,(a1)            ;update data address
  144.     jmp        node_loop
  145.  
  146. end_play
  147.  
  148.     move.l    #0,(a1)            ;clear data address
  149.     move.b    #2,16(a1)        ;out of data flag in status
  150.     bclr.b    #1,$bfe001
  151.     movem.l    (a7)+,d0-d7/a0-a3
  152.     rts
  153.     
  154.     end