home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / gallery / a_vt.asm < prev    next >
Assembly Source File  |  1994-06-14  |  7KB  |  225 lines

  1. ;  A_VT.ASM -- VT interface routines  // A.R-M. 7/93
  2.  
  3. ;  updated for DemoVT 1.51  //  ARM 6/94
  4. ;  ("sceptical" comments refer to the original, totally undocumented,
  5. ;   DemoVT release... it's grown considerable more understandable
  6. ;   since then O;-)
  7.  
  8.  
  9. ; (this is just VTASM.INC//JCAB translated to assemblable code.
  10. ;  Who knows? It might even work! ;-D)
  11.  
  12.  
  13. ;    JCAB, love the way you document your code!
  14.  
  15.  
  16.         IDEAL
  17.         MODEL Compact, Pascal
  18.         P286
  19.  
  20. STRUC   TChanData
  21.           Period DW ?
  22.           Inst   DB ?
  23.           Vol    DB ?
  24. ENDS
  25.  
  26. STRUC   SRI
  27.   ; These are modified by DemoVT, and you can read them.
  28.       Semaphores     DB 256 DUP(?)      ; Array of semaphores. You can read or
  29.                                         ; modify them (usually cleaning them).
  30.  
  31.  
  32.       ChansTrig      DB  32 DUP(?)      ; == 1 -> channel retriggered a note.
  33.       NumChannels    DB ?               ; Number of channels in the MOD.
  34.  
  35.       CtrlEntryPoint DD ?               ; Address of ther DemoVT service proc.
  36.       TickCounter    DD ?               ; This one provides some form for you
  37.                                         ; to do timing, incremented at 50Hz.
  38.       RegEntryPoint  DD ?               ; DVT Service taking parm in AX.
  39.  
  40.       ChansData      TChanData 32 DUP (<>) ; Per-channel info.
  41.  
  42.       Pos            DB ?               ; Note in the current pattern.
  43.       Seq            DB ?               ; Number of playing pattern.
  44.  
  45.                      DB 81 DUP(?)      ; Reserved.
  46.  
  47.   ; These are supposed to be modified by you to tell DemoVT your intentions. :)
  48.                      DB  ?              ; Reserved.
  49.                      DW  ?              ; Reserved.
  50.  
  51.       JumpNewPos     DB  ?              ; Indicates that you want to jump to
  52.                                         ; another position inside the MOD.
  53.       JumpPosSeq     DB  ?              ; Sequence position to jump to.
  54.       JumpPosNote    DB  ?              ; Note inside the pattern to jump to.
  55.  
  56.       SoundVolume    DB  ?              ; Put your favourite volume here.
  57.                                         ; You can perform fades and the like.
  58.                                         ; 0-255.
  59.       Abort          DB ?               ; Set to 1 to force DVT to exit after
  60.                                         ; your program exits.
  61.  
  62.                      DB 248 DUP(?)      ; Reserved.
  63.  
  64. ENDS
  65.  
  66.  
  67.  
  68.   MagicAX    = 5654h;  {'VT'}
  69.   MagicBX    = 5472h;  {'Tr'}
  70.   MagicCX    = 6163h;  {'ac'}
  71.   MagicXorBX = 6B65h;  {'ke'}
  72.   MagicXorCX = 7220h;  {'r '}
  73.  
  74.  
  75.         CODESEG
  76.  
  77. ;       ASSUME:ALL_routines,wreck:ALL_registers  }:-)
  78.  
  79. PUBLIC InitMusic           ; I guess you call this before anything else...
  80. PUBLIC CallMusic           ; Beats me! Does it start the music or something like that?
  81. PUBLIC VTConnectTimer      ; Probably resets timer counter and starts counting...
  82. PUBLIC VTDisconnectTimer   ; Stops counter from counting, I imagine
  83. PUBLIC VTGetTickCounter    ; Reads counter
  84. PUBLIC VTWaitForStart
  85. PUBLIC VTBeginSync
  86.  
  87. ; Oh, by the way, that's a 50 Hz timer up there...
  88.  
  89. VTRunInfo  SRI <>
  90.  
  91. AppIDFound DD 0
  92. DVTRunInfo DD 0
  93. TickVal    DW 0
  94.  
  95.         PROC InitMusic NEAR
  96.                 MOV     AX,MagicAX
  97.                 MOV     BX,MagicBX   ; playing it safe, huh?
  98.                 MOV     CX,MagicCX   ; hehehe!
  99.  
  100.                 XOR     DI,DI
  101.                 MOV     ES,DI
  102.  
  103. ; Oh, oh, if this is an address he's passing, I'm a gonner!
  104.  
  105.                 INT     2Fh
  106.                 XOR     DL,DL
  107.                 AND     AX,AX
  108.                 JNZ     @@no
  109.                 CMP     BX,MagicBX XOR MagicXorBX
  110.                 JNZ     @@no
  111.                 CMP     CX,MagicCX XOR MagicXorCX
  112.                 JNZ     @@no
  113.  
  114. ; Man! When this guy want's to make sure, HE MAKES SURE!  =:-o
  115.  
  116.                 INC     DL
  117.                 MOV     [word ptr AppIDFound+2],ES
  118.                 MOV     [word ptr AppIDFound],DI
  119.                 LES     DI,[ES:DI-4]
  120.                 MOV     [word ptr DVTRunInfo+2],ES
  121.                 MOV     [word ptr DVTRunInfo],DI
  122.         @@no:   MOV     AL,DL
  123.  
  124. ; returns 1 if successful, 0 if not... at least I got this part!
  125.  
  126.                 RET
  127.         ENDP
  128.  
  129.  
  130. ; As best as I can determine this one here calculates PI to
  131. ; a thousand decimals...  }:-D
  132.  
  133.         PROC CallMusic NEAR
  134.                 CMP     [word ptr DVTRunInfo+2],0
  135.                 JZ      @@Fin
  136.                 LES     SI,[DVTRunInfo]
  137.                 PUSH    2
  138.                 CALL    [ES:SI+SRI.CtrlEntryPoint]
  139.         @@Fin:
  140.                 RET
  141.         ENDP
  142.  
  143.  
  144.         PROC VTConnectTimer NEAR
  145.                 CMP     [word ptr DVTRunInfo+2],0
  146.                 JZ      @@Fin
  147.                 LES     SI,[DVTRunInfo]
  148.                 PUSH    0
  149.                 CALL    [ES:SI+SRI.CtrlEntryPoint]
  150.         @@Fin:
  151.                 RET
  152.         ENDP
  153.  
  154.         PROC VTDisconnectTimer NEAR
  155.                 CMP     [word ptr DVTRunInfo+2],0
  156.                 JZ      @@Fin
  157.                 LES     SI,[DVTRunInfo]
  158.                 PUSH    1
  159.                 CALL    [ES:SI+SRI.CtrlEntryPoint]
  160.         @@Fin:
  161.                 RET
  162.         ENDP
  163.  
  164.         PROC VTGetTickCounter NEAR
  165. ;               XOR     AX,AX
  166. ;               XOR     DX,DX
  167. P386
  168.                 xor eax,eax
  169. P286
  170.                 CMP     [word ptr DVTRunInfo+2],0
  171.                 JZ      @@Fin
  172.                 LES     SI,[DVTRunInfo]
  173. ;                MOV     AX,[WORD PTR ES:SI+SRI.TickCounter]
  174. ;                MOV     DX,[WORD PTR ES:(SI+2)+SRI.TickCounter]
  175.  
  176. ; returning values in DX:AX, how gauche!  |-D
  177. P386
  178.                 mov     eax, [es:si+SRI.TickCounter]
  179. P286
  180. ; ...aaah, that's much better!   ]:-D
  181.  
  182.         @@Fin:
  183.                 RET
  184.         ENDP
  185.  
  186.  
  187.         PROC VTBeginSync NEAR
  188.                 CMP     [WORD PTR DVTRunInfo+2],0
  189.                 JZ      @@Fin
  190.                 LES     SI,[DVTRunInfo]
  191.                 PUSH    3
  192.                 CALL    [ES:SI+SRI.CtrlEntryPoint]
  193.         @@Fin:
  194.                 RET
  195.         ENDP
  196.  
  197.         PROC VTWaitForStart NEAR
  198.                 CMP     [WORD PTR DVTRunInfo+2],0
  199.                 JZ      @@Fin
  200.                 CALL    VTGetTickCounter
  201.                 XOR     AX,AX
  202.                 MOV     [WORD PTR ES:SI+SRI.TickCounter],AX
  203.                 MOV     [WORD PTR ES:(SI+2)+SRI.TickCounter],AX
  204.  
  205.                 MOV     [TickVal],AX
  206.         @@lp:
  207.                 CALL    CallMusic
  208.                 CALL    VTGetTickCounter
  209.                 SUB     AX,25
  210.                 CMP     AX,[TickVal]
  211.                 JL      @@lp
  212.  
  213.                 XOR     AX,AX
  214.                 MOV     [WORD PTR ES:SI+SRI.TickCounter],AX
  215.                 MOV     [WORD PTR ES:(SI+2)+SRI.TickCounter],AX
  216.         @@Fin:
  217.                 RET
  218.         ENDP
  219.  
  220.  
  221.         END
  222.  
  223. ; FINALLY! IT ASSEMBLES!!!
  224.  
  225.