home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / mus / delitracker-2.01.lha / DeliTracker / Files / developer.lha / Developer / Examples / TestPlayer.s < prev   
Text File  |  1994-04-15  |  14KB  |  547 lines

  1. **
  2. **    Testplayer.s
  3. **
  4. **    A sample player that visually reports DeliTracker's actions
  5. **    within external players.
  6. **
  7. **    Use the source as a skeleton model for your own players.
  8. **    Refer to the sample sources for additional information.
  9. **
  10. **    Once assembled, load this player into DeliTracker, and try
  11. **    playing the file 'testmodule'.  It is only a textfile with
  12. **    the word "TEST" at the beginning.  Notice now that
  13. **    DeliTracker's actions on the module are visible.  This should
  14. **    aid you in your coding sequences.
  15. **
  16. **    Original source by Peter Kunath and Frank Riffel of Delirium.
  17. **
  18. **    English, comments, and general banter by Kevin Dackiw.
  19. **
  20. **    Have any problems/concerns/ideas?  Feel free to contact the
  21. **    authors:
  22. **
  23. **    Frank Riffel
  24. **    Merkstr. 27
  25. **    82405 Wessobrunn
  26. **    Germany
  27. **
  28.  
  29.     incdir    "includes:"
  30.     include "dos/dos.i"
  31.     include    "intuition/intuition.i"
  32.     include    "misc/DevpacMacros.i"
  33.     include    "misc/DeliPlayer.i"
  34.  
  35. ;
  36. ;
  37.     SECTION Player,Code
  38. ;
  39. ;
  40.  
  41.     PLAYERHEADER PlayerTagArray            ; define start of header
  42.  
  43.     dc.b '$VER: TestPlayer V2.01 (15 Apr 94)',0    ; for OS 2.0 version command
  44.     even
  45.  
  46. PlayerTagArray
  47.     dc.l    DTP_RequestDTVersion,16            ; define all the tags
  48.     dc.l    DTP_PlayerVersion,02<<16+01
  49.     dc.l    DTP_PlayerName,PName            ; for the player
  50.     dc.l    DTP_Creator,CName
  51.     dc.l    DTP_DeliBase,delibase
  52.     dc.l    DTP_Check1,Chk                ; omit any unused
  53.     dc.l    DTP_Config,Config            ; functions as
  54.     dc.l    DTP_UserConfig,UserConfig        ; needed!
  55.     dc.l    DTP_SubSongRange,SubSong
  56.     dc.l    DTP_Process,Begin
  57.     dc.l    DTP_Priority,0
  58.     dc.l    DTP_StackSize,4096
  59.     dc.l    DTP_MsgPort,DeliPort
  60.     dc.l    DTP_InitPlayer,InitPlay
  61.     dc.l    DTP_EndPlayer,EndPlay
  62.     dc.l    DTP_InitSound,InitSnd
  63.     dc.l    DTP_EndSound,EndSnd
  64.     dc.l    DTP_StartInt,StartSnd
  65.     dc.l    DTP_StopInt,StopSnd
  66.     dc.l    DTP_Volume,Volume
  67.     dc.l    DTP_Balance,Balance
  68.     dc.l    DTP_Faster,Faster
  69.     dc.l    DTP_Slower,Slower
  70.     dc.l    DTP_PrevPatt,PrevPatt
  71.     dc.l    DTP_NextPatt,NextPatt
  72.     dc.l    DTP_PrevSong,PrevSub
  73.     dc.l    DTP_NextSong,NextSub
  74.     dc.l    TAG_DONE                ; signify end of tags
  75.  
  76. *-----------------------------------------------------------------------*
  77. ;
  78. ; Playername / creatorname
  79. ;
  80. *-----------------------------------------------------------------------*
  81.  
  82. PName    dc.b    'TestPlayer',0
  83. CName    dc.b    'Written by Delirium for Testpurposes',0
  84.     even
  85.  
  86. *-----------------------------------------------------------------------*
  87. ;
  88. ; Player Task
  89. ;
  90. *-----------------------------------------------------------------------*
  91.  
  92. Begin
  93.     move.l    delibase,a5            ; get DeliBase
  94.     move.l    dtg_DOSBase(a5),_DOSBase
  95.     move.l    dtg_IntuitionBase(a5),_IntuitionBase
  96.  
  97.     bsr    About                ; display About-Requester
  98.  
  99.     move.l    #ConsoleName,d1
  100.     move.l    #MODE_NEWFILE,d2
  101.     CALLDOS Open
  102.     move.l    d0,d1
  103.     beq    Quit                ; Error
  104.     CALLDOS SelectOutput
  105.     move.l    d0,_OldOutput
  106.  
  107.     lea    StartTxt0,a0            ; fetch text
  108.     bsr    WriteInfoTxt            ; output
  109.  
  110. ;--------------------------------------------------------------------------
  111. ;
  112. ; Mainloop
  113.  
  114. MainLoop
  115.     move.l    #SIGBREAKF_CTRL_C,d0        ; quit on CTRL-C
  116.  
  117.     move.l    DeliPort,a0
  118.     move.b    MP_SIGBIT(a0),d1        ; DeliMask holen
  119.     bset.l    d1,d0
  120.  
  121.     CALLEXEC Wait                ; Schlaf gut
  122.  
  123.     btst.l    #SIGBREAKB_CTRL_C,d0        ; CTRL-C signal ?
  124.     beq.s    DeliCollect            ; nope !
  125.     bsr    Exit                ; suicide :)
  126.  
  127. DeliCollect                    ; collect DeliTracker msg's
  128.     move.l    DeliPort,a0
  129.     CALLEXEC GetMsg
  130.     tst.l    d0                ; Msg da ?
  131.     beq.s    CollectDone            ; Nein !
  132.     move.l    d0,-(sp)            ; store ^Msg
  133.     move.l    d0,a0
  134.     move.l    DTMN_Function(a0),a0        ; get CMD
  135.     jsr    (a0)                ; Befehl ausführen
  136.     move.l    (sp)+,a1            ; restore ^Msg
  137.     move.l    d0,DTMN_Result(a1)        ; set Result
  138.     CALLEXEC ReplyMsg            ; return to sender
  139.     bra.s    DeliCollect
  140.  
  141. CollectDone
  142.     tst.w    QuitFlag            ; schon Ende ?
  143.     bne    MainLoop            ; noch nicht !
  144.  
  145. ;--------------------------------------------------------------------------
  146. ;
  147. ; quit Player
  148.  
  149. Cleanup
  150.     lea    QuitTxt0,a0            ; fetch text
  151.     bra    WriteInfoTxt            ; output
  152.  
  153.     move.l    _OldOutput,d1
  154.     CALLDOS SelectOutput
  155.     move.l    d0,d1
  156.     CALLDOS Close
  157. Quit
  158.     rts
  159.  
  160.  
  161. ;--------------------------------------------------------------------------
  162. ;
  163. ; End Player
  164.  
  165. Exit
  166.     clr.w    QuitFlag            ; quit Player
  167.     rts
  168.  
  169.  
  170. ;--------------------------------------------------------------------------
  171. ;
  172. ; About Gesülze
  173.  
  174. About
  175.     sub.l    a0,a0
  176.     lea    AboutReqStruct,a1        ; EasyStruct
  177.     sub.l    a2,a2
  178.     sub.l    a3,a3
  179.     CALLINT    EasyRequestArgs
  180.     rts
  181.  
  182.  
  183. *-----------------------------------------------------------------------*
  184. ;
  185. ; Check if the module is a TestPlayer-Module (THIS ROUTINE MUST EXIST!!!)
  186. ;
  187. *-----------------------------------------------------------------------*
  188.  
  189. Chk
  190.     move.l    delibase,a0            ; ^DeliBase
  191.     move.l    dtg_ChkData(a0),a0        ; get module base from DT
  192.     moveq    #0,d0                ; clear register
  193.     cmpi.l    #'TEST',(a0)            ; supported type ?
  194.     sne    d0                ; no - signal false
  195.     rts                    ; leave
  196.  
  197.  
  198. *-----------------------------------------------------------------------*
  199. ;
  200. ; Initialize the player
  201. ;
  202. *-----------------------------------------------------------------------*
  203.  
  204. InitPlay
  205.     lea    InitTxt1,a0            ; fetch text
  206.     bsr    WriteInfoTxt            ; output
  207.     moveq    #0,d0                ; no error
  208.     rts
  209.  
  210.  
  211. *-----------------------------------------------------------------------*
  212. ;
  213. ; Clean up the player
  214. ;
  215. *-----------------------------------------------------------------------*
  216.  
  217. EndPlay
  218.     lea    EndTxt1,a0            ; fetch text
  219.     bra    WriteInfoTxt            ; output
  220.  
  221.  
  222. *-----------------------------------------------------------------------*
  223. ;
  224. ; Initialize the module
  225. ;
  226. *-----------------------------------------------------------------------*
  227.  
  228. InitSnd
  229.     lea    InitTxt2,a0            ; fetch text
  230.     bra    WriteInfoTxt            ; output
  231.  
  232.  
  233. *-----------------------------------------------------------------------*
  234. ;
  235. ; End sound
  236. ;
  237. *-----------------------------------------------------------------------*
  238.  
  239. EndSnd
  240.     lea    EndTxt2,a0            ; fetch text
  241.     bra    WriteInfoTxt            ; output
  242.  
  243.  
  244. *-----------------------------------------------------------------------*
  245. ;
  246. ; Start interrupts
  247. ;
  248. *-----------------------------------------------------------------------*
  249.  
  250. StartSnd
  251.     lea    StartTxt,a0            ; fetch text
  252.     bra    WriteInfoTxt            ; output
  253.  
  254.  
  255. *-----------------------------------------------------------------------*
  256. ;
  257. ; Start interrupts
  258. ;
  259. *-----------------------------------------------------------------------*
  260.  
  261. StopSnd
  262.     lea    StopTxt,a0            ; fetch text
  263.     bra    WriteInfoTxt            ; output
  264.  
  265.  
  266. *-----------------------------------------------------------------------*
  267. ;
  268. ; IMPORTANT NOTE:
  269. ;    There is a BIG difference between the »Config« and the
  270. ;    »UserConfig« Routine !!! The Config routine is immediately
  271. ;    called after that the Player is loaded. It is used to
  272. ;    configure player (e.g. load config file and set pathes)!
  273. ;    The UserConfig routine is only called if the User selects
  274. ;    the player in the PrefWindow and presses the Config Player
  275. ;    GADGET. This routine is thought as a method of getting
  276. ;    informations (playerspecific preferences) from the user
  277. ;    (e.g. pathes for instruments or maximum memory usage).
  278. ;    The difference between Config and InitPlayer is that
  279. ;    Config is called ONCE the player is loaded and that
  280. ;    InitPlayer is called every time a module is played.
  281. ;
  282. *-----------------------------------------------------------------------*
  283. ;
  284. ; get/set playerspecific preferences (configuration routines)
  285. ;
  286. *-----------------------------------------------------------------------*
  287.  
  288. UserConfig
  289.     lea    InfoTxt1,a0            ; fetch text
  290.     bra    WriteInfoTxt            ; output
  291.  
  292. Config
  293.     lea    InfoTxt2,a0            ; fetch text
  294.     bsr    WriteInfoTxt            ; output
  295.     moveq    #0,d0                ; no error
  296.     rts
  297.  
  298.  
  299. *-----------------------------------------------------------------------*
  300. ;
  301. ; Patterncontrol
  302. ;
  303. *-----------------------------------------------------------------------*
  304.  
  305. NextPatt
  306.     lea    InfoTxt3,a0            ; fetch text
  307.     bra    WriteInfoTxt            ; output
  308.  
  309. PrevPatt
  310.     lea    InfoTxt4,a0            ; fetch text
  311.     bra    WriteInfoTxt            ; output
  312.  
  313.  
  314. *-----------------------------------------------------------------------*
  315. ;
  316. ; Subsongcontrol
  317. ;
  318. *-----------------------------------------------------------------------*
  319.  
  320. SubSong
  321.     lea    InfoTxt9,a0            ; fetch text
  322.     bra    WriteInfoTxt            ; output
  323.  
  324. NextSub
  325.     lea    InfoTxt5,a0            ; fetch text
  326.     bra    WriteInfoTxt            ; output
  327.  
  328. PrevSub
  329.     lea    InfoTxt6,a0            ; fetch text
  330.     bra    WriteInfoTxt            ; output
  331.  
  332.  
  333. *-----------------------------------------------------------------------*
  334. ;
  335. ; Speedcontrol
  336. ;
  337. *-----------------------------------------------------------------------*
  338.  
  339. Faster
  340.     lea    InfoTxt7,a0            ; f