home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / CRYS250.ZIP / STINTER.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-12-23  |  7.8 KB  |  493 lines

  1. ;**************************************************************************
  2. ;*    Ce module contient les routines servant à rechercher les
  3. ;*    informations sur la musique dans le module ST3010
  4. ;* Programmé par Sébastien Granjoux
  5. ;* Commencé le 26/12/93
  6. ;* Dernière modif 26/12/93
  7.  
  8.  
  9. IDEAL
  10. P386N
  11. MODEL SMALL
  12.  
  13. PUBLIC    getname
  14. PUBLIC    getinst
  15. PUBLIC    getdevice
  16. PUBLIC    getmaxseq
  17. PUBLIC    dectostr
  18. PUBLIC    gettempo
  19. PUBLIC    getpattern
  20. PUBLIC    getvoice
  21. PUBLIC    gonextpos
  22.  
  23.  
  24. STRUC VOIX
  25.     endsamp DW 33
  26.     volume    DB 0
  27.     extra    DB 0
  28.     adrvoc    DP 0
  29.     lenrep    DW 32        ; evite un bug
  30.     play    DW 0        ; note joué
  31.     newnote    DW 0        ; note d'arrivé (vibrato et portamento)
  32.     oldnote DW 0        ; note précédente (portamento)
  33.     effet   DW 0
  34.     note1   DW 0
  35.     note2   DW 0
  36.     oldport DW 0
  37.     amplit    DW 0
  38.     vitesse DB 0
  39.     temp    DB 0
  40.     tremolo DB 0
  41.     tremvit DB 0
  42.     oldvol    DB 0
  43.     compte    DB 0
  44.     inst    DB 0    ;bit 7 changer vol,6 changer adr,5 changer inst
  45.         gusinf    DB 0    ;bit 3 new vol,2 nul vol,1 change adr,0 new inst
  46.             DB 0
  47.     effnb    DB 0
  48.     looppos DW 0
  49. ENDS
  50.  
  51. EXTRN    TAB_ARPEGE:far
  52. EXTRN    Nb_voice:far
  53. EXTRN    Voix1:far
  54. EXTRN    Music:far
  55. EXTRN    INSTRUMENT
  56. EXTRN    Instruments:far
  57. EXTRN    Sequence:far
  58. EXTRN    Tempo:far
  59. EXTRN    Speed:far
  60. EXTRN    Ligne:far
  61. EXTRN    Partition:far
  62. EXTRN    Position:far
  63.  
  64. DATASEG
  65.  
  66. INST_LEN    EQU    32
  67.  
  68. inst        DW    0
  69.  
  70.         ASSUME ds:SEG Voix1
  71.  
  72. cur_voice    DW    OFFSET Voix1
  73.         ASSUME ds:_DATA
  74.  
  75.  
  76. Lastvol        DB    8 DUP (0)
  77.  
  78. DEVICE_LEN    EQU    5
  79.  
  80. Devices         DW    OFFSET nuldev
  81.         DW    OFFSET spkdev
  82.         DW    OFFSET dacdev
  83.         DW    OFFSET sbdev
  84.                 DW    OFFSET gusdev
  85.  
  86. Nuldev        DB    'Rien',0
  87. Spkdev        DB    'le haut parleur interne',0
  88. Dacdev        DB    'un DAC sur un port parallèle',0
  89. Sbdev        DB    'une carte sound blaster',0
  90. Gusdev        DB    'une Gravis Ultra Sound',0
  91.  
  92. CODESEG
  93.  
  94. ;************************************************************************
  95. ;*    Renvoit le nom de la musique
  96. ;*
  97. ;* Entrée:
  98. ;*    ES:DI    buffer où copier le nom musique
  99.  
  100. PROC    getname
  101.  
  102.     push    ds
  103.     mov    ax,SEG Music
  104.     mov    ds,ax
  105.     ASSUME    ds:SEG Music
  106.     mov     si,OFFSET Music
  107.  
  108.     mov    cx,10
  109.     rep    movsw
  110.  
  111.     pop    ds
  112.     ASSUME    ds:_DATA
  113.  
  114.     ret
  115.  
  116. ENDP
  117.  
  118. ;************************************************************************
  119. ;*    Renvoit les instruments de la musique
  120. ;*
  121. ;* Entrée:
  122. ;*    ES:DI    buffer où copier le nom de l'instrument
  123.  
  124. PROC    getinst
  125.  
  126.     push    ds
  127.     mov    si,[word ptr ds:OFFSET inst]
  128.  
  129.     mov    ax,SEG Instruments
  130.     mov    ds,ax
  131.     ASSUME    ds:SEG Instruments
  132.  
  133.     add    si,OFFSET Instruments
  134.  
  135.     mov    cx,11
  136.     rep    movsw
  137.  
  138.     sub    si,OFFSET Instruments+22
  139.     add    si,INST_LEN
  140.     cmp    si,(INST_LEN)*32
  141.     jb    @@no_loop
  142.     xor    si,si
  143. @@no_loop:
  144.     pop    ds
  145.     ASSUME    ds:_DATA
  146.  
  147.     mov    [word ptr ds:OFFSET inst],si
  148.  
  149.     ret
  150.  
  151. ENDP
  152.  
  153. ;************************************************************************
  154. ;*    Renvoit le nom de l'appareil de sortie du son
  155. ;*
  156. ;* Entrée:
  157. ;*    ES:DI    buffer où copier le nom de l'appareil
  158. ;*    DL    numero de l'appareil
  159.  
  160. PROC    getdevice
  161.  
  162.     and    dx,00ffh
  163.     mov    si,dx
  164.     shl    si,1
  165.     mov    si,[ds:OFFSET Devices+si]
  166.  
  167.     mov    cx,16
  168.     rep    movsw
  169.  
  170.     ret
  171.  
  172. ENDP
  173.  
  174. ;***************************************************************************
  175. ;*    Renvoit le nombre de position totale de la musique
  176. ;* Sortie:
  177. ;*    AL    nombre de position totale
  178.  
  179. PROC    getmaxseq
  180.  
  181.  
  182.     push    ds
  183.     mov    ax,SEG Sequence
  184.     mov    ds,ax
  185.  
  186.     ASSUME    ds:SEG Sequence
  187.  
  188.     mov    al,[ds:OFFSET Sequence]
  189.     dec    al
  190.  
  191.     pop    ds
  192.     ASSUME    ds:_DATA
  193.  
  194.     ret
  195.  
  196. ENDP
  197.  
  198. ;***************************************************************************
  199. ;*    Convertie un nombre en DL en une chaine de caractère représentant
  200. ;*    ce nombre en décimal
  201. ;*
  202. ;* Entrée:
  203. ;*    DS:DI    adresse de la zone où mettre la chaine sur 3 octet
  204. ;*    AL    nombre à convertir
  205.  
  206. PROC    dectostr
  207.  
  208.     xor    ah,ah
  209.     mov    bl,100
  210.     div    bl
  211.     or    al,al
  212.     jne    @@number
  213.     sub    al,'0'-' '
  214. @@number:
  215.     add    al,'0'
  216.     mov    [byte ptr ds:di],al
  217.     inc    di
  218.     mov    al,ah
  219.     xor    ah,ah
  220.     mov    bl,10
  221.     div    bl
  222.     or    al,al
  223.     add    al,'0'
  224.     mov    [byte ptr ds:di],al
  225.         inc    di
  226.     add    ah,'0'
  227.     mov    [byte ptr ds:di],ah
  228.  
  229.     ret
  230.  
  231. ENDP
  232.  
  233. ;***************************************************************************
  234. ;*    Renvoit le tempo dans al et ah
  235. ;*
  236. ;* Sortie:
  237. ;*    AL    tempo normale
  238. ;*    AH    tempo étendue
  239.  
  240. PROC    gettempo
  241.  
  242.     push    ds
  243.     mov    ax,SEG Sequence
  244.     mov    ds,ax
  245.  
  246.     ASSUME    ds:SEG Sequence
  247.  
  248.     mov    ax,[ds:OFFSET Speed]
  249.     mov    bx,100
  250.     mul    bx
  251.     mov    al,[ds:OFFSET Tempo]
  252.  
  253.     pop    ds
  254.     ASSUME    ds:_DATA
  255.  
  256.     ret
  257.  
  258. ENDP
  259.  
  260. ;***************************************************************************
  261. ;*    Renvoit la position dans la séquence ainsi que le pattern et la
  262. ;*    ligne
  263. ;*
  264. ;* Sortie:
  265. ;*    AL    position dans la séquence
  266. ;*    AH    pattern
  267. ;*    DL    ligne
  268.  
  269. PROC    getpattern
  270.  
  271.     push    ds
  272.     mov    ax,SEG Ligne
  273.     mov    ds,ax
  274.  
  275.     ASSUME    ds:SEG Ligne
  276.     mov    eax,[dword ptr ds:OFFSET Ligne]
  277.     shr    ax,2
  278.     mov    cl,[ds:OFFSET Nb_voice]
  279.     div    cl
  280.     mov    dl,al
  281.     shr    eax,16
  282.  
  283.     ASSUME    ds:SEG Partition
  284.     sub    ax,[ds:OFFSET Partition]
  285.         neg    cl
  286.         add    cl,6
  287.     shl    ax,cl
  288.  
  289.     ASSUME    ds:SEG Sequence
  290.     mov    al,[ds:OFFSET Position]
  291.  
  292.     pop    ds
  293.     ASSUME    ds:_DATA
  294.  
  295.     ret
  296.  
  297. ENDP
  298.  
  299. ;*************************************************************************
  300. ;*    Donne des informations sur les voix à chaque tour
  301. ;*
  302. ;* Sortie:
  303. ;*    AL    instrument
  304. ;*    AH    volume
  305. ;*    BL    note*2
  306. ;*    BH    effet*2
  307. ;*    CH    octet joué
  308.  
  309. PROC    getvoice
  310.  
  311.     push    ds
  312.  
  313.     ASSUME    ds:_DATA
  314.     mov    si,[ds:OFFSET cur_voice]
  315.     mov    ax,SEG Voix1
  316.     mov    ds,ax
  317.  
  318.     ASSUME    ds:SEG Voix1
  319.     mov    cx,[(VOIX PTR ds:si).newnote]
  320.  
  321.     ASSUME    ds:SEG TAB_ARPEGE
  322.     mov     bx,OFFSET TAB_ARPEGE-2
  323. @@not_find:
  324.     add     bx,2
  325.     cmp     cx,[ds:bx]
  326.     jb      @@not_find
  327.  
  328.     sub    bx,OFFSET TAB_ARPEGE
  329.  
  330.     ASSUME    ds:SEG Voix1
  331.     mov    bh,[(VOIX PTR ds:si).effnb]
  332.     mov    ch,[(VOIX PTR ds:si).inst]
  333.     and    ch,1fh
  334.     mov    dl,[(VOIX PTR ds:si).volume]
  335.     mov    cl,[ds:OFFSET Nb_voice]
  336.  
  337.     lds    edi,[(VOIX PTR ds:si).adrvoc]
  338.  
  339.     mov    al,[ds:di]
  340.     mul    dl
  341.     mov    al,ch
  342.     mov    ch,ah
  343.     mov     ah,dl
  344.  
  345.     pop    ds
  346.     ASSUME    ds:_DATA
  347.  
  348.  
  349.     mov    di,[cs:cur_vol]
  350.  
  351. ;        pushad
  352. ;        xor    edx,edx
  353. ;        mov    dx,di
  354. ;        call    writelong
  355. ;        popad
  356.  
  357.     mov    dl,[ds:di]
  358.     shr    ch,2
  359.     add    dl,ch
  360.     mov    ch,dl
  361.     shr    ch,4
  362.     sub    dl,ch
  363.     mov    [ds:di],dl
  364.     inc    di
  365.  
  366.     ASSUME    ds:SEG Voix1
  367.  
  368.     add    si,SIZE VOIX
  369.     push    ax
  370.     mov    al,SIZE VOIX
  371.     mul    cl
  372.     mov    dx,ax
  373.     pop    ax
  374.     add    dx,OFFSET Voix1
  375.     cmp    si,dx
  376.     jb    @@ok
  377.     mov    si,OFFSET Voix1
  378.     ASSUME    ds:_DATA
  379.     mov    di,OFFSET Lastvol
  380. @@ok:
  381.     ASSUME    ds:_DATA
  382.  
  383.     mov    [ds:OFFSET cur_voice],si
  384.     mov    [cs:cur_vol],di
  385.     ret
  386. ENDP
  387.  
  388. cur_vol        DW    OFFSET Lastvol
  389. SCREEN_POS    DW 640
  390.  
  391. ;***************************************************************************
  392. ;*    Ecrit un nombre en EAX sur 32 bits en chaine de caractère
  393. ;*    correspondant à se représentation hexadécimal
  394. ;*
  395. ;* Entrée:
  396. ;*    EDX    nombre à convertir
  397.  
  398. PROC    writelong
  399.  
  400.     push    es
  401.     mov    ax,0b800h
  402.     mov    es,ax
  403.     mov    di,[cs:SCREEN_POS]
  404.     add    di,16
  405.  
  406.     mov    ax,'h'
  407.     std
  408.     stosb
  409.  
  410.     mov    cl,4
  411. @@next_digit:
  412.     movzx    ax,dl
  413.     shr    edx,8
  414.     shl    ax,4
  415.     shr    al,4
  416.     xchg    al,ah
  417.     and    ax,0f0fh
  418.     add    ax,3030h
  419.     cmp    al,3Ah
  420.     jb    @@al_ok
  421.     add    al,7
  422. @@al_ok:
  423.     cmp    ah,3Ah
  424.     jb    @@ah_ok
  425.     add    ah,7
  426. @@ah_ok:
  427.     xchg    al,ah
  428.     dec    di
  429.     stosb
  430.     dec    di
  431.     mov    al,ah
  432.     stosb
  433.     dec    cl
  434.     jne    @@next_digit
  435.  
  436.     cld
  437.  
  438.     add    di,19
  439.     mov    al,' '
  440.     stosb
  441.     inc    di
  442.  
  443.     pop    es
  444.  
  445.     cmp    di,4000
  446.     jb    @@ok
  447.     mov    di,0
  448. @@ok:
  449.     mov    [cs:SCREEN_POS],di
  450.  
  451.  
  452.     ret
  453.  
  454. ENDP
  455.  
  456.  
  457. ;*************************************************************************
  458. ;*    Passe au à la position suivante
  459.  
  460. PROC    gonextpos
  461.  
  462.     push    ds
  463.  
  464.     mov    ax,SEG Position
  465.     mov    ds,ax
  466.     ASSUME    ds:SEG Position
  467.     mov    bx,[ds:OFFSET Position]
  468.  
  469.     mov     bl,[ds:OFFSET Position]
  470.     inc     bl
  471.     cmp     bl,[byte ptr ds:OFFSET Sequence]
  472.     jb     @@not_end_seq
  473.  
  474.     xor    bl,bl
  475. @@not_end_seq:
  476.      mov    [ds:OFFSET Position],bl
  477.      mov    al,[byte ptr ds:OFFSET Sequence+2+bx]
  478.      mov    cl,[ds:OFFSET Nb_voice]
  479.      mul    cl
  480.      shl    ax,4
  481.      add    ax,[ds:OFFSET Partition]
  482.      mov    [word ptr ds:OFFSET Ligne+2],ax
  483.      mov    [word ptr ds:OFFSET Ligne],0
  484.  
  485.     pop    ds
  486.     ASSUME    ds:_DATA
  487.  
  488.     ret
  489. ENDP
  490.  
  491. ENDS
  492.  
  493. END