home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 3: The Continuation / 17-Bit_The_Continuation_Disc.iso / files / 2432.dms / 2432.adf / PINKNOISE / PINKnoise.s < prev   
Text File  |  1992-12-16  |  5KB  |  275 lines

  1. datalen    EQU    $8000            ; min: $15a , max $1fffe
  2.  
  3.     INCDIR    "include:"
  4.     INCLUDE    "exec/types.i"
  5.     INCLUDE    "exec/exec_lib.i"
  6.     INCLUDE    "exec/libraries.i"
  7.     INCLUDE    "exec/strings.i"
  8.     INCLUDE    "libraries/dos.i"
  9.     INCLUDE    "libraries/dos_lib.i"
  10.     INCLUDE    "libraries/dosextens.i"
  11.     INCLUDE    "intuition/intuition.i"
  12.     INCLUDE    "intuition/intuitionbase.i"
  13.     INCLUDE    "intuition/intuition_lib.i"
  14.     INCLUDE    "intuition/screens.i"
  15.     INCLUDE    "graphics/graphics_lib.i"
  16.     INCLUDE "hardware/custom.i" 
  17.     INCLUDE "hardware/dmabits.i"
  18.  
  19. custom    EQU    $dff000
  20.  
  21. ***************************************** FAST WB STARTUP CODE
  22.  
  23.     movea.l    a0,a3
  24.     suba.l    a1,a1
  25.     movea.l    4.w,a6
  26.     jsr    _LVOFindTask(a6)
  27.     movea.l    d0,a2
  28.     tst.l    pr_CLI(a2)
  29.     bne.s    defchan
  30.  
  31.     lea    pr_MsgPort(a2),a0    ; wb message
  32.     jsr    _LVOWaitPort(a6)
  33.     lea    pr_MsgPort(a2),a0
  34.     jsr    _LVOGetMsg(a6)
  35.  
  36.     movea.l    d0,a4
  37.     jsr    defchan
  38.     movea.l    a4,a1
  39.  
  40.     movea.l    4.w,a6
  41.     jsr    _LVOReplyMsg(a6)
  42.     moveq    #RETURN_OK,d0
  43.     rts                ; back to wb
  44.  
  45. ***************************************** GET FIRST 0-3 OCCURRENCE IN CMDLINE
  46.  
  47. defchan    move.l    #$00030000+DMAF_AUD3,d3    ; default channel
  48. getcmd    move.b    (a3)+,d0
  49.     cmpi.b    #"?",d0
  50.     beq    help
  51.     cmpi.b    #LF,d0
  52.     ble.s    kickver
  53.     cmpi.b    #"0",d0
  54.     blt.s    getcmd
  55.     cmpi.b    #"2",d0
  56.     bgt.s    getcmd
  57.     andi.w    #%11,d0            ; channels 0,1, or 2
  58.     moveq    #0,d3
  59.     move.w    d0,d3
  60.     swap    d3
  61.     bset    d0,d3
  62.  
  63. ***************************************** NEW WINDOW'S dY, dH IF KS 2.0+
  64.  
  65. kickver    cmpi.w    #34,LIB_VERSION(a6)    ; ks 1.3
  66.     ble.s    openint
  67.     addi.w    #1,nwindow+nw_TopEdge
  68.     addi.w    #1,nwindow+nw_Height
  69.  
  70. openint    moveq    #RETURN_FAIL+1,d7    ; returncode = 21 - no int.lib
  71.     lea    intname,a1
  72.     moveq    #33,d0            ; ks 1.2+
  73.     jsr    _LVOOpenLibrary(a6)
  74.     beq    fault
  75.     move.l    d0,a6
  76.  
  77. ***************************************** GET WB STRUCTURE
  78.  
  79.     addq.l    #1,d7            ; returncode = 22 - wb is closed
  80.     lea    auddata,a0
  81.     move.l    #sc_SIZEOF,d0
  82.     moveq    #WBENCHSCREEN,d1
  83.     jsr    _LVOGetScreenData(a6)
  84.     beq    clsint
  85.  
  86. ***************************************** SET WINDOW'S TOP EDGE AND HEIGHT
  87.  
  88.     moveq    #0,d0
  89.     move.b    auddata+sc_BarHeight,d0
  90.     add.w    d0,nwindow+nw_TopEdge
  91.     add.w    d0,nwindow+nw_Height
  92.  
  93. ;    move.l    auddata+sc_Width,nwindow+nw_MaxWidth
  94.  
  95. ***************************************** SET WINDOW'S WIDTH
  96.  
  97.     addq.l    #1,d7            ; returncode = 23 - no gfx.lib
  98.     movea.l    a6,a5
  99.     movea.l    4.w,a6
  100.     lea    gfxname,a1
  101.     moveq    #33,d0            ; ks 1.2+
  102.     jsr    _LVOOpenLibrary(a6)
  103.     beq    clsint
  104.  
  105.     move.l    d0,a6
  106.     move.l    wtitle,a0
  107.     lea    auddata+sc_RastPort,a1
  108.     moveq    #endwtit-eotitle-1,d0
  109.     jsr    _LVOTextLength(a6)
  110.     add.w    d0,nwindow+nw_Width
  111.  
  112. ***************************************** CHECK IF WINDOW'S WIDTH IS OK
  113.  
  114.     move.w    nwindow+nw_Width,d0
  115.     cmp.w    auddata+sc_Width,d0
  116.     ble.s    minwid
  117.     move.w    auddata+sc_Width,nwindow+nw_Width
  118. minwid    cmpi.w    #83,nwindow+nw_Width
  119.     bgt.s    clsgfx
  120.     move.w    #83,nwindow+nw_Width
  121.  
  122. clsgfx    movea.l    a6,a1
  123.     movea.l    4.w,a6
  124.     jsr    _LVOCloseLibrary(a6)
  125.     exg.l    a5,a6
  126.  
  127. ***************************************** BUILD PINK-NOISE SAMPLE
  128.  
  129.     lea    auddata,a0
  130.     move.w    #datalen-1,d0
  131. filldat    move.b    custom+vhposr,d2
  132.     eor.b    d2,d1
  133.     move.b    custom+vhposr+1,d2
  134.     eor.b    d2,d1
  135.     move.b    -1(a0),d2
  136.     eor.b    d2,d1
  137.     add.b    -2(a0),d1
  138.     move.b    d1,d2
  139.     andi.w    #%1111,d2
  140. delay    dbf    d2,delay
  141.     move.b    d1,(a0)+
  142.     dbf    d0,filldat
  143.  
  144. ***************************************** PREPARE PAULA'S REGISTERS
  145.  
  146.     lea    custom+aud,a0
  147.     swap    d3
  148.     move.w    d3,d0
  149.     mulu    #$10,d0
  150.     swap    d3
  151. setcust    move.l    #auddata,ac_ptr(a0,d0.w)
  152.     move.w    #(datalen/2),ac_len(a0,d0.w)
  153.     move.w    #200,ac_per(a0,d0.w)
  154.     move.w    #64,ac_vol(a0,d0.w)
  155.  
  156. ***************************************** OPEN THE WINDOW
  157.  
  158.     addq.l    #1,d7            ; returncode = 24 - no window
  159.     lea    nwindow,a0
  160.     jsr    _LVOOpenWindow(a6)
  161.     beq.s    clsint
  162.     movea.l    d0,a2
  163.  
  164. **************************************** PLAY THE SAMPLE
  165.  
  166.     bset    #DMAB_SETCLR,d3
  167.     move.w    d3,custom+dmacon
  168.  
  169. **************************************** WAIT THE USER HITS THE CLS_GAD
  170.  
  171.     exg.l    a5,a6
  172.     move.l    wd_UserPort(a2),a0
  173.     jsr    _LVOWaitPort(a6)
  174.     move.l    wd_UserPort(a2),a0
  175.     jsr    _LVOGetMsg(a6)
  176.     movea.l    d0,a1
  177.     jsr    _LVOReplyMsg(a6)
  178.     exg.l    a5,a6
  179.  
  180. **************************************** STOP THE SAMPLE
  181.  
  182.     bclr    #DMAB_SETCLR,d3
  183.     move.w    d3,custom+dmacon
  184.  
  185. **************************************** FREE ALL RESOURCES
  186.  
  187.     movea.l    a2,a0
  188.     jsr    _LVOCloseWindow(a6)
  189.  
  190.     moveq    #RETURN_OK,d7
  191. clsint    movea.l    a6,a1
  192.     movea.l    4.w,a6
  193.     jsr    _LVOCloseLibrary(a6)
  194.  
  195. **************************************** CLEAR BSS (PURE PGM)
  196.  
  197. fault    lea    auddata,a0
  198.     move.l    #(datalen/4)-1,d0
  199. pure    move.l    #0,(a0)+
  200.     dbf    d0,pure
  201.  
  202.     lea    purepos,a0
  203.     lea    nwindow,a1
  204.     move.l    (a0)+,(a1)+
  205.     move.l    (a0)+,(a1)+
  206.  
  207.     move.l    d7,d0
  208.     rts
  209.  
  210. **************************************** FREE ALL RESOURCES
  211.  
  212. help    moveq    #RETURN_FAIL+5,d7    ; returncode = 25 - no dos.lib
  213.     lea    dosname,a1
  214.     moveq    #33,d0            ; ks 1.2+
  215.     jsr    _LVOOpenLibrary(a6)
  216.     beq.s    fault
  217.     move.l    d0,a6
  218.  
  219.     moveq    #RETURN_OK,d7
  220.     jsr    _LVOOutput(a6)
  221.     beq.s    clsdos
  222.  
  223.     move.l    d0,d1
  224.     move.l    #wtitle,d2
  225.     move.l    #endhelp-wtitle,d3
  226.     move.b    #" ",eotitle
  227.     jsr    _LVOWrite(a6)
  228.     move.b    #EOS,eotitle
  229.  
  230. clsdos    movea.l    a6,a1
  231.     movea.l    4.w,a6
  232.     jsr    _LVOCloseLibrary(a6)
  233.  
  234.     bra.s    fault
  235.  
  236.  
  237.     SECTION    pinksample,bss_c
  238.  
  239.  
  240.     DS.B    2
  241. auddata    DS.B    datalen
  242.  
  243.  
  244.     SECTION    strings,data
  245.  
  246. purepos    DC.W    0,1,84,0
  247. nwindow    DC.W    0,1
  248.     DC.W    84,0
  249.     DC.B    0,1
  250.     DC.L    CLOSEWINDOW
  251.     DC.L    WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE
  252.     DC.L    0
  253.     DC.L    0
  254.     DC.L    wtitle
  255.     DC.L    0
  256.     DC.L    0
  257.     DC.W    0,0,0,0
  258.     DC.W    WBENCHSCREEN
  259.  
  260.     DC.B    "$VER: "
  261. wtitle    DC.B    "PINKnoise V1.00"
  262. eotitle    DC.B    EOS,"- by /\/ / /-<",LF
  263. endwtit    ;    dummy
  264.  
  265.     DC.B    "args: [0|1|2|3]/S - default channel is 3",LF
  266. ;    DC.B    "the parser will scan first occurrence of one of the args",LF
  267. endhelp    ;    dummy
  268.  
  269. intname    INTNAME
  270. gfxname    GRAFNAME
  271. dosname    DOSNAME
  272.  
  273.     EVEN
  274.     END
  275.