home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / audio / multiplay / misca.asm < prev    next >
Assembly Source File  |  1992-09-14  |  12KB  |  415 lines

  1. * MultiPlayer
  2. * Copyright (C) 1992 Bryan Ford
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * I (the author of MultiPlayer) can be contacted on the Internet at
  19. * "bryan.ford@m.cc.utah.edu".  See "Player.doc" for other addresses.
  20. *
  21. * $Id: misca.asm,v 5.1 92/09/14 18:40:10 BAF Exp $
  22. *
  23.  
  24.         include "exec/types.i"
  25.         include "exec/nodes.i"
  26.         include "exec/interrupts.i"
  27.         include "exec/funcdef.i"
  28.         include "exec/execbase.i"
  29.         include "exec/exec_lib.i"
  30.         include "intuition/intuition_lib.i"
  31.         include "intuition/intuitionbase.i"
  32.         include "dos/dos.i"
  33.         include "bry/macros.i"
  34.         include "player.i"
  35.  
  36.         xref    _LinkerDB,_SysBase,_sysflags,_procpt,_songpos,_songlen
  37.         xref    _curmod,_fadevol,_fadeinc,playervolume
  38.         xref    _sysflags,_playing,_songtime,_songendtime
  39.         xref    _spectrum,_flashactive,_flashytaskptr
  40.         xref    scopechandata,notetab,scrollline,scrolllines,_scopeinterval
  41.  
  42.         xdef    intsongpos,intrepeat,intflashnote,intflashsample,intflashscroll,clearflash
  43.         xdef    _vblankint,_scopeinterval
  44.  
  45.         code    text
  46.  
  47.         xref    _IntuitionBase
  48.  
  49. *** intsongpos - Set a new song position, callable from an interrupt
  50. * d0.w = Position in song
  51. * d1.w = Length of song
  52. * Returns ALL registers saved (convenience for internal players)
  53. intsongpos:
  54.         movem.l d0-d1/a0-a1/a6,-(sp)
  55.         lea     _LinkerDB,a1
  56.         move.l  d0,_songpos(a1)         ; Store the new values
  57.         move.l  d1,_songlen(a1)
  58.         bset    #SB_TIMERUP,_sysflags(a1)
  59.         bra.s   intsig
  60.  
  61. *** intrepeat - Signal the MultiPlayer task that the module is repeating
  62. * Returns ALL registers saved (convenience for internal players)
  63. intrepeat:
  64.         movem.l d0-d1/a0-a1/a6,-(sp)
  65.         lea     _LinkerDB,a1
  66.  
  67.         cmpi.b  #PM_OVEROVER,_playmode(a1)
  68.         beq.b   intout
  69.  
  70.         bset    #SB_REPEAT,_sysflags(a1)
  71.  
  72.         move.l  _curmod(a1),d0
  73.         bz.b    intsig
  74.         move.l  d0,a0
  75.         tst.w   mn_volume(a0)
  76.         bmi.b   intsig
  77.         btst    #MNB_ENDFADE,mn_flags(a0)
  78.         bz.b    intsig
  79.         move.w  #128,_fadevol(a1)
  80.         move.w  #-1,_fadeinc(a1)
  81.         bra.b   intout
  82.  
  83. intsig:
  84.         move.l  _SysBase(a1),a6         ; Signal the main task
  85.         move.l  _procpt(a1),a1
  86.         move.l  #SIGBREAKF_CTRL_F,d0
  87.         jsr     _LVOSignal(a6)
  88. intout
  89.         movem.l (sp)+,d0-d1/a0-a1/a6
  90.         rts
  91.  
  92.  
  93. *** vblankfunc - Vertical blank function
  94. vblankfunc:
  95.         move.l  a1,a5
  96.  
  97.         tst.b   _playing(a5)            ; Don't do anything unless we're playing something
  98.         bz.b    \out
  99.  
  100.         move.w  _fadevol(a5),d0         ; Perform any fading in progress
  101.         bgt     \fade
  102. \fadeback
  103.  
  104.         movem.l _songtime(a5),d0/d1     ; Update the song time
  105.         addq.l  #1,d0
  106.         move.l  d0,_songtime(a5)
  107.         tst.l   d1
  108.         bz.b    \endback
  109.         cmp.l   d1,d0
  110.         bhs     \endhit
  111. \endback
  112.  
  113.         subq.b  #1,seccnt(a5)           ; Signal the main task every second
  114.         bz      \second
  115. \secback
  116.  
  117.         subq.b  #1,flashycnt(a5)        ; Signal the main task every flash
  118.         bnz.b   \flashback
  119.         move.b  #FFperF,flashycnt(a5)
  120.         tst.b   _flashactive(a5)        ; Only if flashy window is operative
  121.         bnz     \flashy
  122. \flashback
  123.  
  124. \out
  125.         moveq   #0,d0
  126.         rts
  127.  
  128. \fade
  129.         add.w   _fadeinc(a5),d0
  130.         bz.b    \fadedone
  131.         cmp.w   #128,d0
  132.         bls.b   \fadenotdone
  133.         mq      #-1,d0
  134. \fadedone
  135.         move.w  d0,_fadevol(a5)
  136.         bset    #SB_FADEDONE,_sysflags(a5)
  137.         pea     \fadeback(pc)
  138.         bra.b   \int
  139. \fadenotdone
  140.         move.w  d0,_fadevol(a5)
  141.         exg     a4,a5
  142.         bsr     playervolume
  143.         exg     a4,a5
  144.         bra.b   \fadeback
  145.  
  146. \second:                                ; Signal that a second has elapsed
  147.         move.l  _SysBase(a5),a1
  148.         move.b  VBlankFrequency(a1),seccnt(a5)
  149.         bset    #SB_SECOND,_sysflags(a5)
  150.         pea     \secback(pc)
  151.  
  152. \int:
  153.         move.l  _procpt(a5),a1          ; Signal the main task
  154.         move.l  #SIGBREAKF_CTRL_F,d0
  155.         move.l  _SysBase(a5),a6
  156.         jmp     _LVOSignal(a6)
  157.  
  158. \endhit:                                ; Signal that we (may be) repeating
  159.         btst    #SB_REPEAT,_sysflags(a5)
  160.         bnz     \endback
  161.         pea     \endback(pc)
  162.         bra     intrepeat
  163.  
  164. \flashy                                 ; Signal to update the flashy window
  165.         mq      #4-1,d0                 ; Update the scope channels
  166.         lea     scopechandata+scd_SIZEOF*4(a5),a0
  167. \scopechan
  168.         suba.w  #scd_SIZEOF,a0
  169.         tst.w   scd_len(a0)
  170.         bz.b    \scopechandone
  171.         move.w  scd_pos(a0),d1
  172.         add.w   scd_inc(a0),d1
  173.         bcs.b   \scopechanovf
  174.         move.w  d1,scd_pos(a0)
  175.         add.w   #SCOPEWIDTH,d1
  176.         cmp.w   scd_len(a0),d1
  177.         bhi.b   \scopechanovf
  178. \scopechandone
  179.         dbra    d0,\scopechan
  180.  
  181.         move.l  _flashytaskptr(a5),d1   ; Signal the flashy task
  182.         bz      \flashback
  183.         move.l  d1,a1
  184.         move.l  #SIGBREAKF_CTRL_F,d0
  185.         move.l  _SysBase(a5),a6
  186.         pea     \flashback(pc)
  187.         jmp     _LVOSignal(a6)
  188.  
  189. \scopechanovf                           ; Got to the end of the sample
  190.         move.w  scd_rep(a0),scd_pos(a0)
  191.         bnz.b   \scopechandone
  192. \scopechanoff                           ; Turn channel off
  193.         clr.w   scd_len(a0)
  194.         bra.b   \scopechandone
  195.  
  196.  
  197. *** clearflash - Clear the flashy display
  198. clearflash
  199.         lea     _spectrum(a4),a0        ; Clear the spectrum display
  200.         mq      #SPECTRUMRES/4-1,d0
  201. 1$      clr.l   (a0)+
  202.         dbra    d0,1$
  203.         clr.w   scopechandata+scd_len(a4) ; Stop the scope
  204.         clr.w   scopechandata+scd_SIZEOF+scd_len(a4)
  205.         clr.w   scopechandata+scd_SIZEOF*2+scd_len(a4)
  206.         clr.w   scopechandata+scd_SIZEOF*3+scd_len(a4)
  207.         clr.w   scrolllines(a4)         ; Clear the note scroller
  208.         st.b    _flashactive(a4)
  209.         rts
  210.  
  211. *** intflashnote - Start a new note in the spectrogram
  212. * d0.b = Channel (0-4)
  213. * d1.b = Note frequency (0-255)
  214. * d2.b = Volume (0-64)
  215. intflashnote
  216.         push    d0-d2/a0/a4
  217.         lea     _LinkerDB,a4
  218.  
  219.         tst.b   _flashflags(a4)
  220.         bz.b    \out
  221.  
  222.         lsr.b   #4,d1                   ; Set the spectrogram
  223.         ext.w   d1
  224.         lsr.b   #1,d2
  225.         lea     _spectrum(a4),a0
  226.         bmi     \out
  227.         cmp.b   0(a0,d1.w),d2
  228.         bls.b   \nomiddle
  229.         move.b  d2,0(a0,d1.w)
  230. \nomiddle
  231.         lsr.w   #1,d2
  232.         cmp.b   -1(a0,d1.w),d2
  233.         bls.b   \noleft
  234.         move.b  d2,-1(a0,d1.w)
  235. \noleft
  236.         cmp.b   1(a0,d1.w),d2
  237.         bls.b   \noright
  238.         move.b  d2,1(a0,d1.w)
  239. \noright
  240.  
  241.         st.b    _flashactive(a4)        ; There's now something to display
  242. \out
  243.         pop     d0-d2/a0/a4
  244.         rts
  245.  
  246. *** intflashsample - Start a new note in the scope
  247. * d0.w = Channel (0-4)
  248. * a0 = Sample data pointer
  249. * d1.w = Period at which this sample will play
  250. * d2.w = Sample length in bytes (0 = turn channel off)
  251. * d3.w = Repeat part length in bytes (0 = no repeat)
  252. intflashsample
  253.         push    d0-d4/a1/a4
  254.         lea     _LinkerDB,a4
  255.  
  256.         tst.b   _flashflags(a4)
  257.         bz.b    \outout
  258.  
  259.         ext.w   d0
  260.  
  261.         cmp.w   #4,d0                   ; Protection
  262.         bhs.b   \out
  263.         tst.w   d1
  264.         bz.b    \out
  265.  
  266.         move.w  d0,d4                   ; Find the appropriate channel data structure
  267.         lea     scopechandata(a4),a1
  268.         lsl.w   #4,d4
  269.         add.w   d4,a1
  270.  
  271.         move.w  d2,scd_len(a1)
  272.         bz.b    \out
  273.         move.l  a0,scd_sample(a1)
  274.         clr.w   scd_pos(a1)
  275.         sub.w   d3,d2
  276.         bnz.b   \smallrep
  277.         mq      #1,d2
  278. \smallrep
  279.         cmp.w   #2,d3
  280.         bhi.b   \hasrep
  281.         mq      #0,d2
  282. \hasrep move.w  d2,scd_rep(a1)
  283.         cmp.w   scd_per(a1),d1
  284.         beq.b   \nodiv
  285.         move.l  _scopeinterval(a4),d0
  286.         divu.w  d1,d0
  287.         move.w  d1,scd_per(a1)
  288.         move.w  d0,scd_inc(a1)
  289. \nodiv
  290. *        mq      #SCOPEWIDTH,d0          ; Prevent static displays for short samples
  291. *        add.w   scd_inc(a1),d0
  292. *        cmp.w   scd_len(a1),d0
  293. *        blo.b   \out
  294. *        move.w  #SCOPEWIDTH,scd_inc(a1)
  295. \out
  296.         st.b    _flashactive(a4)
  297. \outout
  298.         pop     d0-d4/a1/a4
  299.         rts
  300.  
  301. *** intflashscroll - Change note scroller position
  302. * Must have already set notetab and scrollmod
  303. * d0.w = Current line number
  304. * d1.w = Number of lines in this pattern
  305. intflashscroll
  306.         move.w  d0,scrollline
  307.         move.w  d1,scrolllines
  308.         st.b    _flashactive
  309.         rts
  310.  
  311.         data    __MERGED
  312.  
  313.         xdef    _prefs,_prefsend
  314.  
  315. _prefs                                  ; All the saved preferences variables
  316.         dcxd.b  playmode,PM_SEQUENCE
  317.         dcxd.b  showmode,SM_SEQUENCE0
  318.  
  319.         dcxd.w  zoomwinleft,$135
  320.         dcxd.w  zoomwintop,$a
  321.  
  322.         dcxd.w  progwinleft,$13a
  323.         dcxd.w  progwintop,$25
  324.  
  325.         dcxd.w  prefswinleft,$3
  326.         dcxd.w  prefswintop,$23
  327.  
  328.         dcxd.w  spectrumwinleft,$5
  329.         dcxd.w  spectrumwintop,$a
  330.  
  331.         dcxd.w  scopewinleft,$99
  332.         dcxd.w  scopewintop,$a
  333.  
  334.         dcxd.w  channelwinleft,$135
  335.         dcxd.w  channelwintop,$a
  336.  
  337.         dcxd.b  flashflags,0
  338.         dcxd.b  keepprog,0
  339.  
  340.         dcxd.w  tinywinleft,-1
  341.         dcxd.w  tinywintop,0
  342.  
  343.         dcxd.w  qscopewinleft,$99
  344.         dcxd.w  qscopewintop,$42
  345.  
  346.         dcxd.w  notewinleft,$5
  347.         dcxd.w  notewintop,$42
  348.  
  349.         dcxd.w  settingswinleft,$2
  350.         dcxd.w  settingswintop,$3
  351.  
  352.         dcxd.b  pausefade,1
  353.  
  354.         dsxd.b  hotkey,30+1
  355.  
  356.         dcxd.w  mspeed,50
  357.         dcxd.w  mvolume,100
  358.         dcxd.w  mbalance,0
  359.  
  360.         dcxd.w  modfrleft,0
  361.         dcxd.w  modfrtop,0
  362.         dcxd.w  modfrwidth,0
  363.         dcxd.w  modfrheight,0
  364.  
  365.         dcxd.w  progfrleft,0
  366.         dcxd.w  progfrtop,0
  367.         dcxd.w  progfrwidth,0
  368.         dcxd.w  progfrheight,0
  369.  
  370.         dcxd.w  infowinleft,2
  371.         dcxd.w  infowintop,80
  372.  
  373.         dcxd.b  appicon,0
  374.  
  375.         dsxd.b  mainfontname,0
  376.         dc.b    "topaz.font",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0          ; 31 bytes
  377.         dsxd.b  listfontname,0
  378.         dc.b    "topaz.font",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0          ; 31 bytes
  379.         dcxd.w  mainfontsize,8
  380.         dcxd.w  listfontsize,8
  381.  
  382.         dcxd.w  fontreqleft,0
  383.         dcxd.w  fontreqtop,0
  384.         dcxd.w  fontreqwidth,0
  385.         dcxd.w  fontreqheight,0
  386.  
  387.         dcxd.b  contprogonerr,0
  388.  
  389.         dcxd.b  appicona,0
  390.  
  391. * This setting is controlled by the Nasty Audio button on the Prefs window.  If set, audio channels
  392. * are always allocated at maximum priority, disallowing any other programs from playing beeps and
  393. * other sounds on top of the music.
  394.         dcxd.b  nasty_audio,0
  395.  
  396. _prefsend
  397.  
  398.                 even
  399.  
  400. rnd             ds.l    2
  401.  
  402. _vblankint:
  403.                 dc.l    0,0
  404.                 dc.b    NT_INTERRUPT,-10
  405.                 dc.l    intname
  406.                 dc.l    _LinkerDB
  407.                 dc.l    vblankfunc
  408.  
  409. intname         dc.b    "MultiPlayer VBlank",0
  410.  
  411. seccnt          dc.b    1
  412. flashycnt       dc.b    1
  413.  
  414.         end
  415.