home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 4: The Falcon Archive / nf_archive_four_v1.0.iso / ARCHIVE / WORK / MSX / GTK08777.ZIP / GTK.DEV / DUMTRACK.S < prev    next >
Text File  |  1999-03-18  |  255KB  |  10,238 lines

  1. ******************************************************************************
  2. *                            *
  3. *        G R A O U M F   T R A C K E R            *
  4. *                            *
  5. *    Soundtracker Falcon 030 32 voies au DSP            *
  6. *    Par Laurent de Soras (c) 1994-96                *
  7. *____________________________________________________________________________*
  8. *                            *
  9. *    Langage          :    Assembleur 68030 (sous Devpac 2.23)    *
  10. *    Nom du source    :    DUMTRACK.S                *
  11. *    Code généré      :    DUMTRACK.PGT            *
  12. *    Include          :    -                *
  13. *    IncBin           :    FONTE1.FNT                *
  14. *    Version          :    0.862                *
  15. *    Date             :    20/7/1996                *
  16. *                            *
  17. *    Routines diverses pour le Graoumf Tracker :            *
  18. *    Gestion de l'interface, conversions de modules, manipulations    *
  19. *    de samples, depackage, etc...                *
  20. *                            *
  21. *    Tab = 11                        *
  22. *                            *
  23. ******************************************************************************
  24.  
  25.  
  26.     opt    p=68030,x-,d-,e-,s-
  27.     Output    f:\dev.gtk\sys\dumtrack.pgt
  28.  
  29.  
  30.  
  31. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  32. *    Constantes                        *
  33. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  34.  
  35. MAX_SBYTE:        Equ    127
  36. MIN_SBYTE:        Equ    -128
  37. MAX_SWORD:        Equ    32767
  38. MIN_SWORD:        Equ    -32768
  39. MAX_SLONG:        Equ    $7fffffff
  40. MIN_SLONG:        Equ    -$80000000
  41.  
  42. NBRSAMPLES_MAXI:    Equ    1+255    ; Nombre maximum de samples (+1 vide)
  43. NBRINSTR_MAXI:    Equ    1+255    ; Nombre maximum d'instruments (+1 vide)
  44. NBRPATTERNS_VIDES:    Equ    2    ; Nombre de patterns vides
  45. NBRPATTERNS_MAXI:    Equ    256+NBRPATTERNS_VIDES    ; Nombre maximum de patterns (+n vides)
  46. NBRVOLENV_MAXI:    Equ    1+63    ; Nombre maximum d'enveloppes de volume (+1 vide)
  47. NBRTONENV_MAXI:    Equ    1+63    ; Nombre maximum d'enveloppes de tonalité (+1 vide)
  48. NBRPANENV_MAXI:    Equ    1+63    ; Nombre maximum d'enveloppes de panning (+1 vide)
  49.  
  50.  
  51.  
  52. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  53. *    Structures                        *
  54. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  55.  
  56. ;--- Chunk de description des samples ----------------------------------------
  57.         RsReset
  58. chunkid_s:        Rs.l    1    ; 'SAMP'
  59. chunksz_s:        Rs.l    1    ; Taille du chunk
  60. number_s:        Rs.w    1    ; Numéro du sample
  61. name_s:        Rs.b    28    ; Nom du sample
  62. stereo_s:        Rs.w    1    ; 0 = mono, 1 = stereo
  63. autobal_s:        Rs.w    1    ; Balance automatique, -1 = rien
  64. nbits_s:        Rs.w    1    ; 1 = 8 bits, 2 = 16 bits
  65. fech_s:        Rs.w    1    ; Fréquence d'échantillonnage du sample (8363 Hz par défaut)
  66. length_s:        Rs.l    1    ; Longueur du sample
  67. repeat_s:        Rs.l    1    ; Point de bouclage
  68. replen_s:        Rs.l    1    ; Longueur de boucle
  69. vol_s:        Rs.w    1    ; Volume   \ *** Ne pas dissocier
  70. ftune_s:        Rs.w    1    ; Finetune /
  71. codagev_s:        Rs.w    1    ; Version de codage
  72. data_s:        Rs    0    ; Début des données du sample
  73.  
  74. ;--- Chunk de description des instruments ------------------------------------
  75.         RsReset
  76. chunkid_i:        Rs.l    1    ; 'INST'
  77. chunksz_i:        Rs.l    1    ; Taille du chunk
  78. number_i:        Rs.w    1    ; Numéro de l'instrument
  79. name_i:        Rs.b    28    ; Nom de l'instrument
  80. type_i:        Rs.w    1    ; Type de l'instrument (0 = sample)
  81. vol_i:        Rs.w    1    ; Volume
  82. autobal_i:        Rs.w    1    ; Autobalance
  83. volenv_i:        Rs.w    1    ; Enveloppe de volume
  84. tonenv_i:        Rs.w    1    ; Enveloppe de tonalité
  85. panenv_i:        Rs.w    1    ; Enveloppe de panning
  86.         Rs.b    10    ; Réservé
  87. splnum_i:        Rs.b    128*2    ; Numéros de samples pour chaque note
  88. transp_i:        Equ    splnum_i+1
  89. next_i:        Rs    0
  90.  
  91. ;--- Structure d'une boîte ---------------------------------------------------
  92.         RsReset
  93. c_colonne:        Rs.w    1
  94. c_ligne:        Rs.w    1
  95. c_large:        Rs.w    1
  96. c_haut:        Rs.w    1
  97. c_cfond:        Rs.b    1
  98. c_cbordn:        Rs.b    1
  99. c_cborde:        Rs.b    1
  100. c_cbordo:        Rs.b    1
  101.  
  102. ;--- Structure d'un sample à mixer -------------------------------------------
  103.         RsReset
  104. mix_nbits:        Rs.w    1    ; Nombre d'octet par sample (1 ou 2)
  105. mix_sadr:        Rs.l    1    ; Adresse du sample
  106. mix_reps:        Rs.l    1    ; Point de début de répétition
  107. mix_repe:        Rs.l    1    ; Point de fin de répétition (fin du sample)
  108. mix_pos:        Rs.l    1    ; Position courante
  109. mix_volh:        Rs.l    1    ; Volume (du sample * master volume)
  110. mix_voll:        Rs.l    1
  111. mix_ivolh:        Rs.l    1    ; Incrément de volume pour chaque sample
  112. mix_ivoll:        Rs.l    1
  113. mix_next:        Rs    1
  114.         RsSet    -12
  115. mix2_adrbuf:    Rs.l    1
  116. mix2_lonbuf:    Rs.l    1
  117. mix2_nbits:    Rs.w    1
  118. mix2_nbrspl:    Rs.w    1
  119.  
  120. ;--- Informations sur un sample à digitaliser --------------------------------
  121.         RsReset
  122. rec_adresse:    Rs.l    1    ; Adresse de début d'enregistrement
  123. rec_longueur:    Rs.l    1    ; Longueur du sample à échantillonner
  124. rec_position:    Rs.l    1    ; Position courante d'échantillonnage
  125. rec_flag_loop:    Rs.w    1    ; bit 0 = Echantillonner en boucle (jusqu'à demande d'arrêt)
  126.                 ; bit 1 = Indique si on a déjà bouclé
  127. rec_nbits:        Rs.w    1    ; Nombre d'octets par sample (1 ou 2)
  128. rec_canal:        Rs.w    1    ; Canal d'enregistrement (1=L, 2=R, 3=L+R).
  129. rec_trigger:    Rs.w    1    ; Valeur mini à recevoir pour commencer l'éch. (/32768)
  130. rec_frequence:    Rs.w    1    ; Fréquence CODEC (valeur.w à placer en $FFFF8934)
  131. rec_next:        Rs    1
  132.  
  133. ;--- Informations sur l'effet de delay ---------------------------------------
  134.         RsReset
  135. dly_adrsource:    Rs.l    1    ; Adresse source
  136. dly_adrdest:    Rs.l    1    ; Adresse destination
  137. dly_adrbuf1:    Rs.l    1    ; Adresse buffer de delay
  138. dly_adrbuf2:    Rs.l    1    ; Adresse du buffer de retardement
  139. dly_sourcelen:    Rs.l    1    ; Longueur source
  140. dly_destlen:    Rs.l    1    ; Longueur destination
  141. dly_feedback:    Rs.l    1    ; Feedback (/32768)
  142. dly_timefeed:    Rs.l    1    ; Time feed (en octets)
  143. dly_time2:        Rs.l    1    ; Longueur du buffer 2 (octets)
  144. dly_drylevel:    Rs.l    1    ; Dry level (/32768)
  145. dly_mutein:    Rs.l    1    ; Mute in (en octets)
  146. dly_nbitssource:    Rs.b    1    ; Nombre d'octets par sample (source)
  147. dly_nbitsdest:    Rs.b    1    ; Nombre d'octets par sample (destination)
  148. dly_ntaps:        Rs.w    1    ; Nombre de taps
  149. dly_tapinfo:    Rs    1
  150.         RsReset        ; Puis pour chaque tap :
  151. dly_taptime:    Rs.l    1    ; Delay time
  152. dly_taplevel:    Rs.l    1    ; Level (/32768)
  153. dly_tapnext:    Rs    1
  154.  
  155. ;--- Informations sur l'effet de flanger -------------------------------------
  156.         RsReset
  157. fl_adrlspl:    Rs.l    1    ; Adresse du sample left
  158. fl_adrrspl:    Rs.l    1    ; Adresse du sample right
  159. fl_adrdest:    Rs.l    1    ; Adresse du sample destination
  160. fl_adrlbuf:    Rs.l    1    ; Adresse du buffer gauche
  161. fl_adrrbuf:    Rs.l    1    ; Adresse du buffer droit
  162. fl_adrsin:        Rs.l    1    ; Adresse de la table des sinus (4096,/4096)
  163. fl_lonlspl:    Rs.l    1    ; Adresse du sample source left
  164. fl_lonrspl:    Rs.l    1    ; Adresse du sample source right
  165. fl_londest:    Rs.l    1    ; Longueur du sample destination, en octets
  166. fl_lonbuf:        Rs.l    1    ; Longueur du buffer gauche (et droit), en octets
  167. fl_resoll:        Rs.w    1    ; Nombre d'octets par sample (source left)
  168. fl_resolr:        Rs.w    1    ; Nombre d'octets par sample (source right)
  169. fl_resold:        Rs.w    1    ; Nombre d'octets par sample (destination)
  170. fl_flags:        Rs.w    1    ; Flags : +1 = dest left, +2 = dest right
  171. fl_fdbkll:        Rs.l    1    ; Feedback left -> left (/65536)
  172. fl_fdbklr:        Rs.l    1    ; Feedback left -> right(/65536)
  173. fl_fdbkrl:        Rs.l    1    ; Feedback right -> left (/65536)
  174. fl_fdbkrr:        Rs.l    1    ; Feedback right -> right (/65536)
  175. fl_dryl:        Rs.l    1    ; Dry level left
  176. fl_dryr:        Rs.l    1    ; Dry level right
  177. fl_wetl:        Rs.l    1    ; Wet level left
  178. fl_wetr:        Rs.l    1    ; Wet level right
  179. fl_freq:        Rs.l    1    ; Frequence du flanger (65536*4096/FreqEch -> 1 Hz)
  180. fl_amp:        Rs.l    1    ; Amplitude du flanger (en octets)
  181. fl_time:        Rs.l    1    ; Temps de flange : 0 < time-amp < time+amp < lonbuf
  182. fl_initphase:    Rs.l    1    ; Phase initiale (0-4095 -> [0,2π[)
  183. ; Informations générées pendant le calcul:
  184. fl_destcpt:    Rs.l    1    ; Compteur de samples
  185. fl_lsplpos:    Rs.l    1    ; Postition dans le sample left
  186. fl_rsplpos:    Rs.l    1    ; Postition dans le sample right
  187. fl_bufpos:        Rs.l    1    ; Position dans les buffer
  188. fl_sincpt:        Rs.l    1    ; Compteur de sinus
  189. fl_inl:        Rs.w    1    ; Mémorisations des samples d'entrée left
  190. fl_inr:        Rs.w    1    ; et right
  191.  
  192. ;--- Informations sur l'effet de réverbération -------------------------------
  193.     ; -  -  - Sous-structures -  -  -
  194.         RsReset
  195. rev_eref_tapdelay:    Rs.l    1    ; Delay pour chaque tap de la réflexion primaire
  196. rev_eref_taplevel:    Rs.l    1    ; Niveau pour chaque tap de la réflexion primaire (/65536)
  197. rev_eref_end:    Rs    1
  198.         Rsreset
  199. rev_comb_adrbuf:    Rs.l    1    ; Adresses des buffers de chaque comb filter
  200. rev_comb_lonbuf:    Rs.l    1    ; Longueurs des buffers de chaque comb filter
  201. rev_comb_delay:    Rs.l    1    ; Delay de chaque comb filter
  202. rev_comb_fdbk:    Rs.l    1    ; Feedback de chaque comb filter (/65536)
  203. rev_comb_lpfg:    Rs.l    1    ; Gain LPF de chaque comb filter (/65536)
  204. ; Données générées pendant le calcul:
  205. rev_comb_pos:    Rs.l    1    ; Position dans les buffers de chaque comb filter
  206. rev_comb_lpfbuf:    Rs.l    1    ; Buffers LPF (1 sample 16 bits + 16 de signe) pour chaque comb filter
  207. rev_comb_end    Rs    1
  208.     ; -  -  - Structure principale -  -  -
  209.         RsReset
  210. rev_adrsource:    Rs.l    1    ; Adresse du sample source
  211. rev_adrdest:    Rs.l    1    ; Adresse du sample destination
  212. rev_lonsource:    Rs.l    1    ; Longueur du sample source, en octets
  213. rev_londest:    Rs.l    1    ; Longueur du sample destination, en octets
  214. rev_resolsource:    Rs.w    1    ; Résolution du sample source
  215. rev_resoldest:    Rs.w    1    ; Résolution du sample destination
  216. rev_drylevel:    Rs.l    1    ; Niveau dry (/65536)
  217. rev_ereflevel:    Rs.l    1    ; Niveau des réflections primaires(/65536)
  218. rev_revlevel:    Rs.l    1    ; Niveau de la reverb (/65536)
  219. rev_adrerefbuf:    Rs.l    1    ; Adresse du buffer des réflections primaires
  220. rev_lonerefbuf:    Rs.l    1    ; Longueur du buffer des réflections primaires
  221. rev_adradlybuf:    Rs.l    1    ; Adresse du buffer du delay d'alignement
  222. rev_lonadlybuf:    Rs.l    1    ; Longueur du buffer du delay d'alignement
  223. rev_adraprbuf:    Rs.l    1    ; Adresse du buffer de l'All Pass Reverb
  224. rev_lonaprbuf:    Rs.l    1    ; Longueur du buffer de l'All Pass Reverb
  225. rev_aprg:        Rs.l    1    ; Gain (feedback) de l'all pass reverb (/65536)
  226. rev_aprgneg:    Rs.l    1    ; Gain, négatif de l'all pass reverb (/65536)
  227. rev_apr1mg2:    Rs.l    1    ; 1 - gain**2 de l'all pass reverb (/65536)
  228. rev_erefntap:    Rs.w    1    ; Nombre de taps pour la réflection primaire (16 maxi)
  229. rev_earlyreflection:    Rs.b    16*rev_eref_end    ; Early Reflection
  230. rev_ncomb:        Rs.w    1    ; Nombre de comb filters (8 maxi)
  231. rev_comb:        Rs.b    8*rev_comb_end    ; Comb filters
  232. rev_aprdelay:    Rs.l    1    ; Delay de l'All Pass Reverb
  233. rev_adlydelay:    Rs.l    1    ; Delay d'alignement
  234. ; Informations générées pendant le calcul:
  235. rev_sourcepos:    Rs.l    1    ; Position du sample source
  236. rev_destpos:    Rs.l    1    ; Position du sample destination
  237. rev_erefpos:    Rs.l    1    ; Position dans le buffer des réflections primaires
  238. rev_aprpos:    Rs.l    1    ; Position dans le buffer de l'All Pass Reverb
  239. rev_adlypos:    Rs.l    1    ; Position dans le buffer de l'Alignement Delay
  240. rev_drysample:    Rs.l    1    ; Sample dry 16 bits signé 32 bits, avec le gain
  241. rev_erefspl0:    Rs.l    1    ; Sample réflection primaire 16 bits signé 32 bits
  242. rev_erefsample:    Rs.l    1    ; Idem, avec le gain
  243. rev_reverbsample:    Rs.l    1    ; Sample réverb 16 bits signé 32 bits
  244.  
  245. ;--- Informations sur l'effet de compression ---------------------------------
  246.         RsReset
  247. comp_adrsource:    Rs.l    1    ; Adresse du sample source
  248. comp_adrdest:    Rs.l    1    ; Adresse du sample destination
  249. comp_adrbuffer:    Rs.l    1    ; Adresse du buffer de volume (16 bits)
  250. comp_lonsource:    Rs.l    1    ; Longueur du sample source
  251. comp_lonbuffer:    Rs.l    1    ; Longueur du buffer de volume (64Ko maxi)
  252. comp_ressource:    Rs.w    1    ; Résolution du sample source
  253. comp_resdest:    Rs.w    1    ; Résolution du sample destination
  254. comp_speed:    Rs.l    1    ; Vitesse de compression (0-...), 0 = très élevée
  255. comp_level:    Rs.l    1    ; Niveau de compression (/65536)
  256. comp_initvolume:    Rs.l    1    ; Volume présumé de départ (/65536)
  257. ; Informations générées pendant le calcul:
  258. comp_volume:    Rs.l    1    ; Volume maximum courant (/65536)
  259. comp_ampli_int:    Rs.w    1    ; Coef courant d'amplification (entier)
  260. comp_ampli_frac:    Rs.l    1    ; Coef courant d'amplification (fractionnaire)
  261. comp_posbuffer:    Rs.l    1    ; Position actuelle du buffer
  262. comp_possource:    Rs.l    1    ; Position actuelle de la source/dest
  263.  
  264.  
  265.  
  266. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  267. *    Définition des macros                    *
  268. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  269.  
  270. ;----------------------------------------------------------------------------;
  271. ;    Transforme le paramètre de 4 bits en 4 registres contenant    ;
  272. ;    la valeur booléenne de chaque bit (0.b ou -1.b) : d2-d5    ;
  273. ;----------------------------------------------------------------------------;
  274. prend_couleurs:    MACRO
  275.     lsr.w    \1        ; d2-d5 contiennent la valeur
  276.     scs    d2        ; de chaque plan
  277.     lsr.w    \1
  278.     scs    d3
  279.     lsr.w    \1
  280.     scs    d4
  281.     lsr.w    \1
  282.     scs    d5
  283.     ENDM
  284.  
  285. ;----------------------------------------------------------------------------;
  286. ;    Echange les mots forts et faibles de d2-d5, contenant des    ;
  287. ;    plans de couleur                    ;
  288. ;----------------------------------------------------------------------------;
  289. inverse_couleurs:    MACRO
  290.     swap    d2
  291.     swap    d3
  292.     swap    d4
  293.     swap    d5
  294.     ENDM
  295.  
  296. ;----------------------------------------------------------------------------;
  297. ;    Affiche un pixel à l'adresse contenue dans a2        ;
  298. ;    Les plans On/Off sont contenus dans les registres.b d2-d5    ;
  299. ;    d1 contient le masque 1<<x, d0 le masque !(1<<x), où x est le    ;
  300. ;    numéro de pixel à afficher (0-7)                ;
  301. ;----------------------------------------------------------------------------;
  302. affiche_1pixel:    MACRO
  303.     tst.b    d2
  304.     beq.s    .1\@
  305.     or.b    d1,(a2)
  306.     bra.s    .5\@
  307. .1\@    and.b    d0,(a2)
  308. .5\@    addq.l    #2,a2
  309.     tst.b    d3
  310.     beq.s    .2\@
  311.     or.b    d1,(a2)
  312.     bra.s    .6\@
  313. .2\@    and.b    d0,(a2)
  314. .6\@    addq.l    #2,a2
  315.     tst.b    d4
  316.     beq.s    .3\@
  317.     or.b    d1,(a2)
  318.     bra.s    .7\@
  319. .3\@    and.b    d0,(a2)
  320. .7\@    addq.l    #2,a2
  321.     tst.b    d5
  322.     beq.s    .4\@
  323.     or.b    d1,(a2)
  324.     bra.s    .8\@
  325. .4\@    and.b    d0,(a2)
  326. .8\@    
  327.     ENDM
  328.  
  329. ;----------------------------------------------------------------------------;
  330. ;    Colorie 8 pixels contigus à l'adresse a2, avec les plans    ;
  331. ;    contenus dans les registres.b d2-d5            ;
  332. ;----------------------------------------------------------------------------;
  333. remplit8pixels:    MACRO
  334.     move.b    d2,(a2)        ; Remplit 8 pixels
  335.     addq.l    #2,a2
  336.     move.b    d3,(a2)
  337.     addq.l    #2,a2
  338.     move.b    d4,(a2)
  339.     addq.l    #2,a2
  340.     move.b    d5,(a2)
  341.     ENDM
  342.  
  343.  
  344.  
  345. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  346. *    Récapitulatif des routines                *
  347. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  348.  
  349. ; +00 : Reloge la routine. Renvoie l'adresse de adrecr
  350. ; +04 : Crée la fonte ombrée
  351. ; +08 : Dessine un cadre avec un texte centré
  352. ; +0C : Dessine un cadre dont les contours sont à l'intérieur
  353. ; +10 : Dessine un cadre dont les contours sont à l'extérieur
  354. ; +14 : Affiche une chaîne de caractères à l'écran, avec transparence
  355. ; +18 : Affiche une chaîne de caractères ombrés à l'écran, avec transparence
  356. ; +1C : Affiche une chaîne de caractères à l'écran, sans transparence
  357. ; +20 : Affiche un caractère à l'écran, avec transparence
  358. ; +24 : Affiche un caractère à l'écran, avec décalage de 4 pixels à droite et transparence
  359. ; +28 : Affiche un caractère à l'écran, avec transparence et décalé d'un pixel en bas à droite
  360. ; +2C : Affiche un caractère à l'écran, avec décalage de 5 pixels à droite, 1 pixel vers le bas,
  361. ;       en transparence
  362. ; +30 : Affiche un caractère à l'écran, sans transparence
  363. ; +34 : Affiche le pattern
  364. ; +38 : Affiche un bout de sample
  365. ; +3C : Convertit des patterns NoiseTracker au format .GTK
  366. ; +40 : Convertit un pattern 669 8 voies au foramt .GTK
  367. ; +44 : Convertit une voie au format MTM en voie au format GTK
  368. ; +48 : Signe un sample
  369. ; +4C : Convertit un sample stereo en mono (1 valeur sur 2)
  370. ; +50 : Convertit un sample stereo en mono (moyenne des 2 valeurs)
  371. ; +54 : Convertit un pattern OctaMED pro n voies en pattern GTK (n+1) voies
  372. ; +58 : Indique si une icône a été pressée
  373. ; +5C : Convertit un pattern au format S3M en pattern au format GTK
  374. ; +60 : Convertit un sample 16 bits Intel en 16 bits Motorola
  375. ; +64 : Convertit un pattern ULT en pattern GTK (renvoie la longueur du pattern ULT)
  376. ; +68 : Convertit un groupe de patterns d'un ancien format<4 GTK de 4 bytes/note en GTK 5
  377. ;       octets/note
  378. ; +6C : Efface un bloc de notes
  379. ; +70 : Copie un bloc de notes
  380. ; +74 : Décompacte un fichier ATOMIK PACKER 3.5
  381. ; +78 : Echange 2 blocs de notes
  382. ; +7C : Transpose un bloc de notes
  383. ; +80 : Décompacte un fichier PACK ICE 2.1
  384. ; +84 : Inverse les octets ou mots d'un morceau de mémoire
  385. ; +88 : Affiche un marqueur de sample
  386. ; +8C : Efface un marqueur de sample
  387. ; +90 : Copie un sample 8 bits en un sample 16 bits
  388. ; +94 : Copie un sample 16 bits en un sample 8 bits
  389. ; +98 : Convertit une ligne GTK en ligne MOD
  390. ; +9C : Cherche le volume maximum d'un sample
  391. ; +A0 : Change le volume d'un sample
  392. ; +A4 : Mixage de plusieurs samples
  393. ; +A8 : Affichage d'un vumètre
  394. ; +AC : Commence l'enregistrement d'un sample
  395. ; +B0 : Cherche le volume des buffers stereo de digitalisation
  396. ; +B4 : Rééchantillonne un sample
  397. ; +B8 : Transformée de Fourier pour 1 fréquence
  398. ; +BC : Effet de delay
  399. ; +C0 : Conversion d'un pattern Digital Tracker en pattern GT
  400. ; +C4 : Recherche du chunk suivant dans un module DTM
  401. ; +C8 : Conversion d'un patt GT en patt S3M
  402. ; +CC : Conversion d'un patt FT2 en patt GT
  403. ; +D0 : Conversion d'un sample absolu en delta packing
  404. ; +D4 : Conversion inverse
  405. ; +D8 : BMOVE rapide
  406. ; +DC : Effet de flanger stereo
  407. ; +E0 : Depackage ICE 2.4
  408. ; +E4 : Effet de réverbération
  409. ; +E8 : Grise une surface
  410. ; +EC : Conversion d'un sample 16 bits stereo en 8/16 bits mono/stereo, par moyenne.
  411. ; +F0 : Enregistrement d'un module sous forme de sample
  412. ; +F4 : Stoppe l'enregistrement d'un module sous forme de sample
  413. ; +F8 : Effet de compression
  414. ; +FC : Affichage de l'image de présentation
  415. ; +100: Transforme les codes clavier et extrait le numéro de fonction associé à la touche
  416. ; +104: Retrouve les instruments et samples utilisés dans le module
  417. ; +108: Décompression Speed Packer
  418.  
  419.  
  420.  
  421. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  422.  
  423.     TEXT
  424.  
  425.  
  426.  
  427. ;     Partie pour le GfA Basic. Il s'agit de sauter aux différentes routines,
  428. ; puis de récupérer dans les registres les paramètres placés sur la pile par
  429. ; le GfA.
  430.  
  431.     bra    relocation
  432.     bra    fabrique_fonte_ombr
  433.     bra    gfa_cadre_centre
  434.     bra    gfa_dessine_cadre_int
  435.  
  436.     bra    gfa_dessine_cadre_ext
  437.     bra    gfa_affchaine_trans
  438.     bra    gfa_affchaine_trans_ombr
  439.     bra    gfa_affchaine_notrans
  440.  
  441.     bra    gfa_affcar8x6
  442.     bra    gfa_affcar8x6_dec
  443.     bra    gfa_affcar8x6_ombr
  444.     bra    gfa_affcar8x6_ombr_dec
  445.  
  446.     bra    gfa_affcar8x6nt_ombr
  447.     bra    gfa_affiche_pattern
  448.     bra    gfa_affiche_sample
  449.     bra    gfa_convert_nt_2_gtk
  450.  
  451.     bra    gfa_convert_669_2_gtk
  452.     bra    gfa_convert_mtm_voice_2_gtk
  453.     bra    gfa_signe_sample
  454.     bra    gfa_stereo_2_mono_one
  455.  
  456.     bra    gfa_stereo_2_mono_ave
  457.     bra    gfa_convert_mmd1_2_gtk
  458.     bra    gfa_teste_icones
  459.     bra    gfa_convert_s3m_2_gtk
  460.  
  461.     bra    gfa_intel_16_bits
  462.     bra    gfa_convert_ult_2_gtk
  463.     bra    gfa_convert_gtk_2_gtk_vol
  464.     bra    gfa_clear_note_block
  465.  
  466.     bra    gfa_paste_note_block
  467.     bra    gfa_atomik_35_unpack
  468.     bra    gfa_swap_note_block
  469.     bra    gfa_transpose_note_block
  470.  
  471.     bra    gfa_packice_21_unpack
  472.     bra    gfa_invert_memory
  473.     bra    gfa_affiche_marqueur_sample
  474.     bra    gfa_efface_marqueur_sample
  475.  
  476.     bra    gfa_copy_sample_8_2_16
  477.     bra    gfa_copy_sample_16_2_8
  478.     bra    gfa_convert_gtk_2_nt
  479.     bra    gfa_cherche_volume_sample
  480.  
  481.     bra    gfa_change_volume_sample
  482.     bra    gfa_mixage_samples
  483.     bra    gfa_affiche_vumetre
  484.     bra    start_sample_recording
  485.  
  486.     bra    cherche_volume_buffer_stereo
  487.     bra    gfa_change_sample_frequency
  488.     bra    gfa_trans_fourier
  489.     bra    gfa_fx_delay
  490.  
  491.     bra    gfa_convert_dtm_2_gtk
  492.     bra    gfa_dtm_next_chunk
  493.     bra    gfa_convert_gtk_2_s3m
  494.     bra    gfa_convert_ft2_2_gtk
  495.  
  496.     bra    gfa_absolu_2_delta
  497.     bra    gfa_delta_2_absolu
  498.     bra    gfa_bmove
  499.     bra    gfa_fx_stereo_flanger
  500.  
  501.     bra    gfa_packice_24_unpack
  502.     bra    gfa_fx_reverberation
  503.     bra    gfa_grise_surface
  504.     bra    gfa_convert_stereo16
  505.  
  506.     bra    gfa_start_song_recording
  507.     bra    gfa_stop_song_recording
  508.     bra    gfa_fx_compression
  509.     bra    gfa_affiche_image_presentation
  510.  
  511.     bra    gfa_find_key_function
  512.     bra    gfa_find_used_samples_and_instruments
  513.     bra    gfa_speedpacker_unpack
  514.  
  515.  
  516.  
  517. gfa_cadre_centre:
  518.     movem.l    d0/a0/a1,-(sp)
  519.     move.l    12+4(sp),a0
  520.     move.l    12+8(sp),a1
  521.     move.w    12+12(sp),d0
  522.     bsr    cadre_centre
  523.     movem.l    (sp)+,d0/a0/a1
  524.     rts
  525.  
  526. gfa_dessine_cadre_int:
  527.     move.l    a0,-(sp)
  528.     move.l    4+4(sp),a0
  529.     bsr    dessine_cadre_int
  530.     move.l    (sp)+,a0
  531.     rts
  532.  
  533. gfa_dessine_cadre_ext:
  534.     move.l    a0,-(sp)
  535.     move.l    4+4(sp),a0
  536.     bsr    dessine_cadre_ext
  537.     move.l    (sp)+,a0
  538.     rts
  539.  
  540. gfa_affchaine_trans:
  541.     movem.l    d0/d2/d3/a1,-(sp)
  542.     move.l    16+4(sp),a1
  543.     move.w    16+8(sp),d3
  544.     move.w    16+10(sp),d2
  545.     move.w    16+12(sp),d0
  546.     bsr    affchaine_trans
  547.     movem.l    (sp)+,d0/d2/d3/a1
  548.     rts
  549.  
  550. gfa_affchaine_trans_ombr:
  551.     movem.l    d0-d3/a1,-(sp)
  552.     move.l    20+4(sp),a1
  553.     move.w    20+8(sp),d3
  554.     move.w    20+10(sp),d2
  555.     move.w    20+12(sp),d1
  556.     move.w    20+14(sp),d0
  557.     bsr    affchaine_trans_ombr
  558.     movem.l    (sp)+,d0-d3/a1
  559.     rts
  560.  
  561. gfa_affchaine_notrans:
  562.     movem.l    d0/d2/d3/a1,-(sp)
  563.     move.l    16+4(sp),a1
  564.     move.w    16+8(sp),d3
  565.     move.w    16+10(sp),d2
  566.     move.w    16+12(sp),d0
  567.     bsr    affchaine_notrans
  568.     movem.l    (sp)+,d0/d2/d3/a1
  569.     rts
  570.  
  571. gfa_affcar8x6:
  572.     movem.l    d0/d1/a0,-(sp)
  573.     move.l    12+4(sp),a0
  574.     move.w    12+8(sp),d1
  575.     move.w    12+10(sp),d0
  576.     bsr    affcar8x6
  577.     movem.l    (sp)+,d0/d1/a0
  578.     rts
  579.  
  580. gfa_affcar8x6_dec:
  581.     movem.l    d0/d1/a0,-(sp)
  582.     move.l    12+4(sp),a0
  583.     move.w    12+8(sp),d1
  584.     move.w    12+10(sp),d0
  585.     bsr    affcar8x6_dec
  586.     movem.l    (sp)+,d0/d1/a0
  587.     rts
  588.  
  589. gfa_affcar8x6_ombr:
  590.     movem.l    d0/d1/a0,-(sp)
  591.     move.l    12+4(sp),a0
  592.     move.w    12+8(sp),d1
  593.     move.w    12+10(sp),d0
  594.     bsr    affcar8x6_ombr
  595.     movem.l    (sp)+,d0/d1/a0
  596.     rts
  597.  
  598. gfa_affcar8x6_ombr_dec:
  599.     movem.l    d0/d1/a0,-(sp)
  600.     move.l    12+4(sp),a0
  601.     move.w    12+8(sp),d1
  602.     move.w    12+10(sp),d0
  603.     bsr    affcar8x6_ombr_dec
  604.     movem.l    (sp)+,d0/d1/a0
  605.     rts
  606.  
  607. gfa_affcar8x6nt_ombr:
  608.     movem.l    d0/d1/a0,-(sp)
  609.     move.l    12+4(sp),a0
  610.     move.w    12+8(sp),d1
  611.     move.w    12+10(sp),d0
  612.     bsr    affcar8x6nt_ombr
  613.     movem.l    (sp)+,d0/d1/a0
  614.     rts
  615.  
  616. gfa_affiche_pattern:
  617.     movem.l    d0-d2/a0-a2,-(sp)
  618.     move.w    24+4(sp),d0
  619.     move.l    24+6(sp),a0
  620.     move.l    24+10(sp),a1
  621.     move.l    24+14(sp),a2
  622.     move.w    24+18(sp),d1
  623.     move.w    24+20(sp),d2
  624.     bsr    affiche_pattern
  625.     movem.l    (sp)+,d0-d2/a0-a2
  626.     rts
  627.  
  628. gfa_affiche_sample:
  629.     movem.l    d0-d4/a0,-(sp)
  630.     move.l    24+4(sp),a0
  631.     move.l    24+8(sp),d0
  632.     move.w    24+12(sp),d1
  633.     move.w    24+14(sp),d2
  634.     move.w    24+16(sp),d3
  635.     move.w    24+18(sp),d4
  636.     bsr    affiche_sample
  637.     movem.l    (sp)+,d0-d4/a0
  638.     rts
  639.  
  640. gfa_convert_nt_2_gtk:
  641.     movem.l    d0/a0,-(sp)
  642.     move.l    8+4(sp),a0
  643.     move.l    8+8(sp),d0
  644.     bsr    convert_nt_2_gtk
  645.     movem.l    (sp)+,d0/a0
  646.     rts
  647.  
  648. gfa_convert_669_2_gtk:
  649.     movem.l    a0/a1,-(sp)
  650.     move.l    8+4(sp),a0
  651.     move.l    8+8(sp),a1
  652.     bsr    convert_669_2_gtk
  653.     movem.l    (sp)+,a0/a1
  654.     rts
  655.  
  656. gfa_convert_mtm_voice_2_gtk:
  657.     movem.l    d0/d1/a0/a1,-(sp)
  658.     move.l    16+4(sp),a0
  659.     move.l    16+8(sp),a1
  660.     move.w    16+12(sp),d0
  661.     move.w    16+14(sp),d1
  662.     bsr    convert_mtm_voice_2_gtk
  663.     movem.l    (sp)+,d0/d1/a0/a1
  664.     rts
  665.  
  666. gfa_signe_sample:
  667.     movem.l    d0/d1/a0,-(sp)
  668.     move.l    12+4(sp),a0
  669.     move.l    12+8(sp),d0
  670.     move.w    12+12(sp),d1
  671.     bsr    signe_sample
  672.     movem.l    (sp)+,d0/d1/a0
  673.     rts
  674.  
  675. gfa_stereo_2_mono_one:
  676.     movem.l    d0/d1/a0/a1,-(sp)
  677.     move.l    16+4(sp),a0
  678.     move.l    16+8(sp),a1
  679.     move.l    16+12(sp),d0
  680.     move.w    16+16(sp),d1
  681.     bsr    stereo_2_mono_one
  682.     movem.l    (sp)+,d0/d1/a0/a1
  683.     rts
  684.  
  685. gfa_stereo_2_mono_ave:
  686.     movem.l    d0/d1/a0/a1,-(sp)
  687.     move.l    16+4(sp),a0
  688.     move.l    16+8(sp),a1
  689.     move.l    16+12(sp),d0
  690.     move.w    16+16(sp),d1
  691.     bsr    stereo_2_mono_ave
  692.     movem.l    (sp)+,d0/d1/a0/a1
  693.     rts
  694.  
  695. gfa_convert_mmd1_2_gtk:
  696.     movem.l    d0/d1/d6/a0-a2,-(sp)
  697.     move.l    24+4(sp),a0
  698.     move.l    24+8(sp),a1
  699.     move.l    24+12(sp),a2
  700.     move.w    24+16(sp),d0
  701.     move.w    24+18(sp),d1
  702.     move.w    24+20(sp),d6
  703.     bsr    convert_mmd1_2_gtk
  704.     movem.l    (sp)+,d0/d1/d6/a0-a2
  705.     rts
  706.  
  707. gfa_teste_icones:
  708.     movem.l    d1/d2/a0,-(sp)
  709.     move.l    12+4(sp),a0
  710.     move.w    12+8(sp),d0
  711.     move.w    12+10(sp),d1
  712.     move.w    12+12(sp),d2
  713.     bsr    teste_icones
  714.     movem.l    (sp)+,d1/d2/a0
  715.     rts
  716.  
  717. gfa_convert_s3m_2_gtk:
  718.     movem.l    d0/a0-a2,-(sp)
  719.     move.l    16+4(sp),a0
  720.     move.l    16+8(sp),a1
  721.     move.l    16+12(sp),a2
  722.     move.w    16+16(sp),d0
  723.     bsr    convert_s3m_2_gtk
  724.     movem.l    (sp)+,d0/a0-a2
  725.     rts
  726.  
  727. gfa_intel_16_bits:
  728.     movem.l    d0/a0,-(sp)
  729.     move.l    8+4(sp),a0
  730.     move.l    8+8(sp),d0
  731.     bsr    intel_16_bits
  732.     movem.l    (sp)+,d0/a0
  733.     rts
  734.  
  735. gfa_convert_ult_2_gtk:
  736.     movem.l    a0/a1,-(sp)
  737.     move.l    8+4(sp),a0
  738.     move.l    8+8(sp),a1
  739.     move.w    8+12(sp),d0
  740.     bsr    convert_ult_2_gtk
  741.     movem.l    (sp)+,a0/a1
  742.     rts
  743.  
  744. gfa_convert_gtk_2_gtk_vol:
  745.     movem.l    d0/a0,-(sp)
  746.     move.l    8+4(sp),a0
  747.     move.l    8+8(sp),d0
  748.     bsr    convert_gtk_2_gtk_vol
  749.     movem.l    (sp)+,d0/a0
  750.     rts
  751.  
  752. gfa_clear_note_block:
  753.     move.l    a0,-(sp)
  754.     move.l    4+4(sp),a0
  755.     bsr    clear_note_block
  756.     move.l    (sp)+,a0
  757.     rts
  758.  
  759. gfa_paste_note_block:
  760.     move.l    a0,-(sp)
  761.     move.l    4+4(sp),a0
  762.     bsr    paste_note_block
  763.     move.l    (sp)+,a0
  764.     rts
  765.  
  766. gfa_atomik_35_unpack:
  767.     move.l    a0,-(sp)
  768.     move.l    4+4(sp),a0
  769.     bsr    atomik_35_unpack
  770.     move.l    (sp)+,a0
  771.     rts
  772.  
  773. gfa_swap_note_block:
  774.     move.l    a0,-(sp)
  775.     move.l    4+4(sp),a0
  776.     bsr    swap_note_block
  777.     move.l    (sp)+,a0
  778.     rts
  779.  
  780. gfa_transpose_note_block:
  781.     move.l    a0,-(sp)
  782.     move.l    4+4(sp),a0
  783.     bsr    transpose_note_block
  784.     move.l    (sp)+,a0
  785.     rts
  786.  
  787. gfa_packice_21_unpack:
  788.     move.l    a0,-(sp)
  789.     move.l    4+4(sp),a0
  790.     bsr    packice_21_unpack
  791.     move.l    (sp)+,a0
  792.     rts
  793.  
  794. gfa_invert_memory:
  795.     movem.l    d0-d1/a0,-(sp)
  796.     move.l    12+4(sp),a0
  797.     move.l    12+8(sp),d0
  798.     move.w    12+12(sp),d1
  799.     bsr    invert_memory
  800.     movem.l    (sp)+,d0-d1/a0
  801.     rts
  802.  
  803. gfa_affiche_marqueur_sample:
  804.     movem.l    d0-d6,-(sp)
  805.     move.l    28+4(sp),d0
  806.     move.w    28+8(sp),d1
  807.     move.w    28+10(sp),d2
  808.     move.w    28+12(sp),d3
  809.     move.w    28+14(sp),d4
  810.     move.l    28+16(sp),d5
  811.     move.w    28+20(sp),d6
  812.     bsr    affiche_marqueur_sample
  813.     movem.l    (sp)+,d0-d6
  814.     rts
  815.  
  816. gfa_efface_marqueur_sample:
  817.     movem.l    d0-d6,-(sp)
  818.     move.l    28+4(sp),d0
  819.     move.w    28+8(sp),d1
  820.     move.w    28+10(sp),d2
  821.     move.w    28+12(sp),d3
  822.     move.w    28+14(sp),d4
  823.     move.l    28+16(sp),d5
  824.     move.w    28+20(sp),d6
  825.     bsr    efface_marqueur_sample
  826.     movem.l    (sp)+,d0-d6
  827.     rts
  828.  
  829. gfa_copy_sample_8_2_16:
  830.     movem.l    d0/a0-a1,-(sp)
  831.     move.l    12+4(sp),a0
  832.     move.l    12+8(sp),a1
  833.     move.l    12+12(sp),d0
  834.     bsr    copy_sample_8_2_16
  835.     movem.l    (sp)+,d0/a0-a1
  836.     rts
  837.  
  838. gfa_copy_sample_16_2_8:
  839.     movem.l    d0/a0-a1,-(sp)
  840.     move.l    12+4(sp),a0
  841.     move.l    12+8(sp),a1
  842.     move.l    12+12(sp),d0
  843.     bsr    copy_sample_16_2_8
  844.     movem.l    (sp)+,d0/a0-a1
  845.     rts
  846.  
  847. gfa_convert_gtk_2_nt:
  848.     movem.l    d0/a0/a1/a3,-(sp)
  849.     move.l    16+4(sp),a0
  850.     move.l    16+8(sp),a1
  851.     move.l    16+12(sp),a3
  852.     move.w    16+16(sp),d0
  853.     bsr    convert_gtk_2_nt
  854.     movem.l    (sp)+,d0/a0/a1/a3
  855.     rts
  856.  
  857. gfa_cherche_volume_sample:
  858.     movem.l    d1-d2/a0,-(sp)
  859.     move.l    12+4(sp),a0
  860.     move.l    12+8(sp),d1
  861.     move.w    12+12(sp),d2
  862.     bsr    cherche_volume_sample
  863.     movem.l    (sp)+,d1-d2/a0
  864.     rts
  865.  
  866. gfa_change_volume_sample:
  867.     movem.l    d0-d4/a0,-(sp)
  868.     move.l    24+4(sp),a0
  869.     move.l    24+8(sp),d0
  870.     move.l    24+12(sp),d1
  871.     move.l    24+16(sp),d2
  872.     move.l    24+20(sp),d3
  873.     move.w    24+24(sp),d4
  874.     bsr    change_volume_sample
  875.     movem.l    (sp)+,d0-d4/a0
  876.     rts
  877.  
  878. gfa_mixage_samples:
  879.     move.l    a0,-(sp)
  880.     move.l    4+4(sp),a0
  881.     bsr    mixage_samples
  882.     move.l    (sp)+,a0
  883.     rts
  884.  
  885. gfa_affiche_vumetre:
  886.     movem.l    d0-d4,-(sp)
  887.     move.w    20+4(sp),d0
  888.     move.w    20+6(sp),d1
  889.     move.w    20+8(sp),d2
  890.     move.w    20+10(sp),d3
  891.     move.w    20+12(sp),d4
  892.     bsr    affiche_vumetre
  893.     movem.l    (sp)+,d0-d4
  894.     rts
  895.  
  896. gfa_change_sample_frequency:
  897.     movem.l    d0-d3/a0-a1,-(sp)
  898.     move.l    24+4(sp),a0
  899.     move.l    24+8(sp),a1
  900.     move.l    24+12(sp),d0
  901.     move.l    24+16(sp),d1
  902.     move.w    24+20(sp),d2
  903.     move.w    24+22(sp),d3
  904.     bsr    change_sample_frequency
  905.     movem.l    (sp)+,d0-d3/a0-a1
  906.     rts
  907.  
  908. gfa_trans_fourier:
  909.     movem.l    d1-d4/a0-a1,-(sp)
  910.     move.l    24+4(sp),a0
  911.     move.l    24+8(sp),d1
  912.     move.l    24+12(sp),d2
  913.     move.l    24+16(sp),d3
  914.     move.w    24+20(sp),d4
  915.     move.l    24+22(sp),a1
  916.     bsr    trans_fourier
  917.     movem.l    (sp)+,d1-d4/a0-a1
  918.     rts
  919.  
  920. gfa_fx_delay:
  921.     move.l    a0,-(sp)
  922.     move.l    4+4(sp),a0
  923.     bsr    fx_delay
  924.     move.l    (sp)+,a0
  925.     rts
  926.  
  927. gfa_convert_dtm_2_gtk:
  928.     movem.l    d0/a0-a1,-(sp)
  929.     move.l    12+4(sp),a0
  930.     move.l    12+8(sp),a1
  931.     move.l    12+12(sp),d0
  932.     bsr    convert_dtm_2_gtk
  933.     movem.l    (sp)+,d0/a0-a1
  934.     rts
  935.  
  936. gfa_dtm_next_chunk:
  937.     movem.l    a0-a1,-(sp)
  938.     move.l    8+4(sp),a0
  939.     move.l    8+8(sp),a1
  940.     bsr    dtm_next_chunk
  941.     movem.l    (sp)+,a0-a1
  942.     rts
  943.  
  944. gfa_convert_gtk_2_s3m:
  945.     movem.l    d0-d1/a0-a1,-(sp)
  946.     move.l    16+4(sp),a0
  947.     move.l    16+8(sp),a1
  948.     move.w    16+12(sp),d0
  949.     move.w    16+14(sp),d1
  950.     bsr    convert_gtk_2_s3m
  951.     movem.l    (sp)+,d0-d1/a0-a1
  952.     rts
  953.  
  954. gfa_convert_ft2_2_gtk:
  955.     movem.l    d0-d1/a0-a1,-(sp)
  956.     move.l    16+4(sp),a0
  957.     move.l    16+8(sp),a1
  958.     move.w    16+12(sp),d0
  959.     move.w    16+14(sp),d1
  960.     bsr    convert_ft2_2_gtk
  961.     movem.l    (sp)+,d0-d1/a0-a1
  962.     rts
  963.  
  964. gfa_absolu_2_delta:
  965.     movem.l    d0-d1/a0,-(sp)
  966.     move.l    12+4(sp),a0
  967.     move.l    12+8(sp),d0
  968.     move.w    12+12(sp),d1
  969.     bsr    absolu_2_delta
  970.     movem.l    (sp)+,d0-d1/a0
  971.     rts
  972.  
  973. gfa_delta_2_absolu:
  974.     movem.l    d0-d1/a0,-(sp)
  975.     move.l    12+4(sp),a0
  976.     move.l    12+8(sp),d0
  977.     move.w    12+12(sp),d1
  978.     bsr    delta_2_absolu
  979.     movem.l    (sp)+,d0-d1/a0
  980.     rts
  981.  
  982. gfa_bmove:
  983.     movem.l    d0/a0-a1,-(sp)
  984.     move.l    12+4(sp),a0
  985.     move.l    12+8(sp),a1
  986.     move.l    12+12(sp),d0
  987.     bsr    quick_bmove
  988.     movem.l    (sp)+,d0/a0-a1
  989.     rts
  990.  
  991. gfa_fx_stereo_flanger:
  992.     move.l    a0,-(sp)
  993.     move.l    4+4(sp),a0
  994.     bsr    fx_stereo_flanger
  995.     move.l    (sp)+,a0
  996.     rts
  997.  
  998. gfa_packice_24_unpack:
  999.     movem.l    a0/a3,-(sp)
  1000.     move.l    8+4(sp),a0
  1001.     bsr    packice_24_unpack
  1002.     movem.l    (sp)+,a0/a3
  1003.     rts
  1004.  
  1005. gfa_fx_reverberation:
  1006.     move.l    a0,-(sp)
  1007.     move.l    4+4(sp),a0
  1008.     bsr    fx_reverberation
  1009.     move.l    (sp)+,a0
  1010.     rts
  1011.  
  1012. gfa_grise_surface:
  1013.     movem.l    d0-d3,-(sp)
  1014.     move.w    16+4(sp),d0
  1015.     move.w    16+6(sp),d1
  1016.     move.w    16+8(sp),d2
  1017.     move.w    16+10(sp),d3
  1018.     bsr    grise_surface
  1019.     movem.l    (sp)+,d0-d3
  1020.     rts
  1021.  
  1022. gfa_convert_stereo16:
  1023.     movem.l    d0-d2/a0-a1,-(sp)
  1024.     move.l    20+4(sp),a0
  1025.     move.l    20+8(sp),a1
  1026.     move.l    20+12(sp),d0
  1027.     move.w    20+16(sp),d1
  1028.     move.w    20+18(sp),d2
  1029.     bsr    convert_stereo16
  1030.     movem.l    (sp)+,d0-d2/a0-a1
  1031.     rts
  1032.  
  1033. gfa_start_song_recording:
  1034.     bsr    start_song_recording
  1035.     rts
  1036.  
  1037. gfa_stop_song_recording:
  1038.     bsr    stop_song_recording
  1039.     rts
  1040.  
  1041. gfa_fx_compression:
  1042.     move.l    a0,-(sp)
  1043.     move.l    4+4(sp),a0
  1044.     bsr    fx_compression
  1045.     move.l    (sp)+,a0
  1046.     rts
  1047.  
  1048. gfa_affiche_image_presentation:
  1049.     movem.l    d0-d4/a0,-(sp)
  1050.     move.l    24+4(sp),a0
  1051.     move.w    24+8(sp),d0
  1052.     move.w    24+10(sp),d1
  1053.     move.w    24+12(sp),d2
  1054.     move.w    24+14(sp),d3
  1055.     move.w    24+16(sp),d4
  1056.     bsr    affiche_image_presentation
  1057.     movem.l    (sp)+,d0-d4/a0
  1058.     rts
  1059.  
  1060. gfa_find_key_function:
  1061.     movem.l    d1-d2/a0-a4,-(sp)
  1062.     move.l    28+4(sp),d0
  1063.     move.l    28+8(sp),d1
  1064.     move.w    28+12(sp),d2
  1065.     move.l    28+14(sp),a0
  1066.     move.l    28+18(sp),a1
  1067.     move.l    28+22(sp),a2
  1068.     move.l    28+26(sp),a3
  1069.     move.l    28+30(sp),a4
  1070.     bsr    find_key_function
  1071.     movem.l    (sp)+,d1-d2/a0-a4
  1072.     rts
  1073.  
  1074. gfa_find_used_samples_and_instruments:
  1075.     movem.l    a0-a3,-(sp)
  1076.     move.l    16+4(sp),a0
  1077.     move.l    16+8(sp),a1
  1078.     move.l    16+12(sp),a2
  1079.     move.l    16+16(sp),a3
  1080.     bsr    find_used_samples_and_instruments
  1081.     movem.l    (sp)+,a0-a3
  1082.     rts
  1083.  
  1084. gfa_speedpacker_unpack:
  1085.     movem.l    d0-d7/a0-a6,-(sp)
  1086.     move.l    60+4(sp),speedpacker_adr
  1087.     pea    speedpacker_unpack
  1088.     move.w    #$26,-(sp)
  1089.     trap    #14
  1090.     addq.l    #6,sp
  1091.     movem.l    (sp)+,d0-d7/a0-a6
  1092.     rts
  1093.  
  1094.  
  1095.  
  1096. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  1097.  
  1098. *============================================================================*
  1099. *    Routine de relocation des routines, servant au GfA Basic.    *
  1100. *    Ce sous-programme est appelé une seule fois au début, avant    *
  1101. *    toute opération.                    *
  1102. *    Fournir l'adresse du PRG chargé en 4(sp)            *
  1103. *    Renvoie l'adresse de 'adrecr' dans d0            *
  1104. *============================================================================*
  1105. relocation:   
  1106.     movem.l    d1/a0-a2,-(sp)
  1107.     move.l    16+4(sp),a0    ; 4(sp) : adresse du PRG
  1108.     move.l    2(a0),d0
  1109.     add.l    6(a0),d0
  1110.     add.l    14(a0),d0
  1111.     adda.l    #$1c,a0
  1112.     move.l    a0,d1
  1113.     movea.l    a0,a1
  1114.     movea.l    a1,a2
  1115.     adda.l    d0,a1
  1116.     move.l    (a1)+,d0
  1117.     adda.l    d0,a2
  1118.     add.l    d1,(a2)
  1119.     clr.l    d0
  1120. relocloop:    move.b    (a1)+,d0
  1121.     beq.s    reloc_end
  1122.     cmp.b    #1,d0
  1123.     beq.s    reloc_nxt
  1124.     adda.l    d0,a2
  1125.     add.l    d1,(a2)
  1126.     bra.s    relocloop
  1127. reloc_nxt:    adda.l    #$fe,a2
  1128.     bra.s    relocloop
  1129. reloc_end:
  1130.     clr.w    oldcolcurs
  1131.     clr.w    oldposcurs
  1132.     lea    adrecr(pc),a0
  1133.     move.l    a0,d0
  1134.     movem.l    (sp)+,d1/a0-a2
  1135.     rts
  1136.  
  1137.  
  1138.  
  1139. *============================================================================*
  1140. *    UNPACK source for SPACKERv3   (C)THE FIREHAWKS'92                 *
  1141. *    -------------------------------------------------                 *
  1142. *    in    a0: even address start packed block (pour .unpack)          *
  1143. *    out   d0: original length or 0 if not SPv3 packed                 *
  1144. *    =================================================                 *
  1145. *    Use AUTO_SP3.PRG for multiblk packed files                        *
  1146. *============================================================================*
  1147. speedpacker_unpack:
  1148.     move.l    speedpacker_adr(pc),a0
  1149.  
  1150. .unpack:
  1151.     moveq    #0,d0
  1152.     movem.l    d0-a6,-(sp)
  1153.     lea    sp3_53(pc),a6
  1154.     movea.l    a0,a1
  1155.     cmpi.l    #'SPv3',(a1)+
  1156.     bne.s    sp3_02
  1157.     tst.w    (a1)
  1158.     bne.s    sp3_02
  1159.     move.l    (a1)+,d5
  1160.     move.l    (a1)+,d0
  1161.     move.l    (a1)+,(sp)
  1162.     movea.l    a0,a2
  1163.     adda.l    d0,a0
  1164.     move.l    -(a0),-(a1)
  1165.     move.l    -(a0),-(a1)
  1166.     move.l    -(a0),-(a1)
  1167.     move.l    -(a0),-(a1)
  1168.     adda.l    (sp),a1
  1169.     lea    sp3_58-sp3_53(a6),a3
  1170.     moveq    #128-1,d0
  1171. sp3_01:    move.l    (a2)+,(a3)+
  1172.     dbf    d0,sp3_01
  1173.     suba.l    a2,a3
  1174.     move.l    a3,-(sp)
  1175.     bsr.s    sp3_03
  1176.     bsr    sp3_21
  1177.     move.b    -(a0),d0
  1178.     adda.l    (sp)+,a0
  1179.     move.b    d0,(a0)+
  1180.     lea    sp3_58-sp3_53(a6),a2
  1181.     bsr    sp3_22
  1182.     bsr    sp3_15
  1183. sp3_02:    movem.l    (sp)+,d0-a6
  1184.     rts
  1185. sp3_03:    move.w    SR,d1
  1186.     andi.w    #$2000,d1
  1187.     beq.s    sp3_04
  1188.     move.w    $FFFF8240.W,2(a6)
  1189.     btst    #1,$FFFF8260.W
  1190.     bne.s    sp3_04
  1191.     swap    d5
  1192. sp3_04:    clr.w    d5
  1193.     move.w    -(a0),d6
  1194.     lea    sp3_54-sp3_53(a6),a3
  1195.     move.b    d6,(a3)+
  1196.     moveq    #1,d3
  1197.     moveq    #6,d4
  1198. sp3_05:    cmp.b    d6,d3
  1199.     bne.s    sp3_06
  1200.     addq.w    #2,d3
  1201. sp3_06:    move.b    d3,(a3)+
  1202.     addq.w    #2,d3
  1203.     dbf    d4,sp3_05
  1204.     moveq    #$10,d4
  1205.     move.b    -(a0),(a3)+
  1206.     move.b    d4,(a3)+
  1207.     move.b    -(a0),(a3)+
  1208.     move.b    d4,(a3)+
  1209.     move.b    -(a0),d4
  1210.     move.w    d4,(a6)
  1211.     lea    sp3_57-sp3_53(a6),a5
  1212.     move.b    -(a0),d4
  1213.     lea    1(a5,d4.w),a3
  1214. sp3_07:    move.b    -(a0),-(a3)
  1215.     dbf    d4,sp3_07
  1216.     move.b    -(a0),-(a3)
  1217.     beq.s    sp3_08
  1218.     suba.w    d4,a0
  1219. sp3_08:    moveq    #0,d2
  1220.     move.b    -(a0),d2
  1221.     move.w    d2,d3
  1222.     move.b    -(a0),d7
  1223. sp3_09:    bsr.s    sp3_10
  1224.     bsr.s    sp3_10
  1225.     dbf    d2,sp3_09
  1226.     rts
  1227. sp3_10:    not.w    d4
  1228.     add.b    d7,d7
  1229.     bne.s    sp3_11
  1230.     move.b    -(a0),d7
  1231.     addx.b    d7,d7
  1232. sp3_11:    bcs.s    sp3_12
  1233.     move.w    d2,d0
  1234.     subq.w    #1,d3
  1235.     sub.w    d3,d0
  1236.     add.w    d0,d0
  1237.     add.w    d4,d0
  1238.     add.w    d0,d0
  1239.     neg.w    d0
  1240.     move.w    d0,-(a3)
  1241.     rts
  1242. sp3_12:    moveq    #2,d1
  1243.     bsr    sp3_44
  1244.     add.w    d0,d0
  1245.     beq.s    sp3_13
  1246.     move.b    d0,-(a3)
  1247.     moveq    #2,d1
  1248.     bsr    sp3_44
  1249.     add.w    d0,d0
  1250.     move.b    d0,-(a3)
  1251.     rts
  1252. sp3_13:    moveq    #2,d1
  1253.     bsr    sp3_44
  1254.     move.w    sp3_55-sp3_53(a6),d1
  1255.     add.w    d0,d0
  1256.     beq.s    sp3_14
  1257.     move.w    sp3_55+2-sp3_53(a6),d1
  1258. sp3_14:    or.w    d1,d0
  1259.     move.w    d0,-(a3)
  1260.     rts
  1261. sp3_15:    move.w    SR,d1
  1262.     andi.w    #$2000,d1
  1263.     beq.s    sp3_16
  1264.     move.w    2(a6),$FFFF8240.W
  1265. sp3_16:    tst.w    d6
  1266.     bpl.s    sp3_20
  1267.     movea.l    a1,a2
  1268.     movea.l    a1,a3
  1269.     adda.l    4(sp),a3
  1270. sp3_17:    moveq    #3,d6
  1271. sp3_18:    move.w    (a2)+,d0
  1272.     moveq    #3,d5
  1273. sp3_19:    add.w    d0,d0
  1274.     addx.w    d1,d1
  1275.     add.w    d0,d0
  1276.     addx.w    d2,d2
  1277.     add.w    d0,d0
  1278.     addx.w    d3,d3
  1279.     add.w    d0,d0
  1280.     addx.w    d4,d4
  1281.     dbf    d5,sp3_19
  1282.     dbf    d6,sp3_18
  1283.     cmpa.l    a2,a3
  1284.     blt.s    sp3_20
  1285.     movem.w    d1-d4,-8(a2)
  1286.     cmpa.l    a2,a3
  1287.     bne.s    sp3_17
  1288. sp3_20:    rts
  1289. sp3_21:    move.b    -(a0),-(a1)
  1290. sp3_22:    swap    d5
  1291.     beq.s    sp3_23
  1292.     move.w    d5,$FFFF8240.W
  1293. sp3_23:    lea    sp3_56+2-sp3_53(a6),a3
  1294.     cmpa.l    a0,a2
  1295.     blt.s    sp3_25
  1296.     rts
  1297. sp3_24:    adda.w    d3,a3
  1298. sp3_25:    add.b    d7,d7
  1299.     bcc.s    sp3_28
  1300.     beq.s    sp3_27
  1301. sp3_26:    move.w    (a3),d3
  1302.     bmi.s    sp3_24
  1303.     bra.s    sp3_29
  1304. sp3_27:    move.b    -(a0),d7
  1305.     addx.b    d7,d7
  1306.     bcs.s    sp3_26
  1307. sp3_28:    move.w    -(a3),d3
  1308.     bmi.s    sp3_24
  1309. sp3_29:    ext.w    d3
  1310.     jmp    sp3_30(pc,d3.w)
  1311. sp3_30:    bra.s    sp3_30
  1312.     bra.s    sp3_41
  1313.     bra.s    sp3_41
  1314.     bra.s    sp3_41
  1315.     bra.s    sp3_41
  1316.     bra.s    sp3_41
  1317.     bra.s    sp3_37
  1318.     bra.s    sp3_36
  1319.     bra.s    sp3_32
  1320.     bra.s    sp3_33
  1321.     bra.s    sp3_31
  1322.     bra.s    sp3_34
  1323.     bra.s    sp3_21
  1324. sp3_31:    move.b    (a5),-(a1)
  1325.     bra.s    sp3_22
  1326. sp3_32:    bsr.s    sp3_43
  1327.     move.b    1(a5,d0.w),-(a1)
  1328.     bra.s    sp3_22
  1329. sp3_33:    bsr.s    sp3_43
  1330.     add.w    (a6),d0
  1331.     move.b    1(a5,d0.w),-(a1)
  1332.     bra.s    sp3_22
  1333. sp3_34:    moveq    #3,d1
  1334.     bsr.s    sp3_44
  1335.     lsr.w    #1,d0
  1336.     bcc.s    sp3_35
  1337.     not.w    d0
  1338. sp3_35:    move.b    (a1),d1
  1339.     add.w    d0,d1
  1340.     move.b    d1,-(a1)
  1341.     bra.s    sp3_22
  1342. sp3_36:    lea    sp3_52-2-sp3_53(a6),a4
  1343.     bsr.s    sp3_48
  1344.     addi.w    #16,d0
  1345.     lea    1(a1,d0.w),a3
  1346.     move.b    -(a3),-(a1)
  1347.     move.b    -(a3),-(a1)
  1348.     bra    sp3_22
  1349. sp3_37:    moveq    #3,d1
  1350.     bsr.s    sp3_44
  1351.     tst.w    d0
  1352.     beq.s    sp3_38
  1353.     addq.w    #5,d0
  1354.     bra.s    sp3_40
  1355. sp3_38:    move.b    -(a0),d0
  1356.     beq.s    sp3_39
  1357.     addi.w    #20,d0
  1358.     bra.s    sp3_40
  1359. sp3_39:    moveq    #13,d1
  1360.     bsr.s    sp3_44
  1361.     addi.w    #276,d0
  1362. sp3_40:    move.w    d0,d3
  1363.     add.w    d3,d3
  1364. sp3_41:    lea    sp3_52-sp3_53(a6),a4
  1365.     bsr.s    sp3_48
  1366.     lsr.w    #1,d3
  1367.     lea    1(a1,d0.w),a3
  1368.     move.b    -(a3),-(a1)
  1369. sp3_42:    move.b    -(a3),-(a1)
  1370.     dbf    d3,sp3_42
  1371.     bra    sp3_22
  1372. sp3_43:    moveq    #0,d1
  1373.     move.b    (a3),d1
  1374. sp3_44:    moveq    #0,d0
  1375.     cmpi.w    #7,d1
  1376.     bpl.s    sp3_47
  1377. sp3_45:    add.b    d7,d7
  1378.     beq.s    sp3_46
  1379.     addx.w    d0,d0
  1380.     dbf    d1,sp3_45
  1381.     rts
  1382. sp3_46:    move.b    -(a0),d7
  1383.     addx.b    d7,d7
  1384.     addx.w    d0,d0
  1385.     dbf    d1,sp3_45
  1386.     rts
  1387. sp3_47:    move.b    -(a0),d0
  1388.     subq.w    #8,d1
  1389.     bpl.s    sp3_45
  1390.     rts
  1391. sp3_48:    moveq    #0,d1
  1392.     move.b    (a3),d1
  1393.     adda.w    d1,a4
  1394.     move.w    (a4),d1
  1395.     bsr.s    sp3_44
  1396.     tst.b    d6
  1397.     beq.s    sp3_51
  1398.     move.w    d0,d4
  1399.     andi.w    #$FFF0,d4
  1400.     andi.w    #$000F,d0
  1401.     beq.s    sp3_50
  1402.     lsr.w    #1,d0
  1403.     beq.s    sp3_49
  1404.     roxr.b    #1,d7
  1405.     bcc.s    sp3_50
  1406.     move.b    d7,(a0)+
  1407.     moveq    #-128,d7
  1408.     bra.s    sp3_50
  1409. sp3_49:    moveq    #2,d1
  1410.     bsr.s    sp3_44
  1411.     add.w    d0,d0
  1412.     or.w    d4,d0
  1413.     bra.s    sp3_51
  1414. sp3_50:    lea    sp3_54-sp3_53(a6),a3
  1415.     or.b    (a3,d0.w),d4
  1416.     move.w    d4,d0
  1417. sp3_51:    add.w    18(a4),d0
  1418.     rts
  1419.  
  1420.     DC.W    3
  1421. sp3_52:    DC.W    4,5,7,8,9,10,11,12
  1422.     DC.W    -16
  1423.     DC.W    0,32,96,352,864,1888,3936,8032
  1424.  
  1425. sp3_53:    DS.L    1
  1426. sp3_54:    DS.B    8
  1427. sp3_55:    DS.W    2*64
  1428. sp3_56:    DS.W    2
  1429.     DS.B    1
  1430. sp3_57:    DS.B    1
  1431.     DS.B    2*64
  1432. sp3_58:    DS.B    512
  1433.  
  1434.  
  1435.  
  1436. *============================================================================*
  1437. *    Trouve les samples et les instruments utilisés dans le module.    *
  1438. *    Regarde en fait si les longueurs et les noms ne sont pas à 0.    *
  1439. *    a0 = pointeur sur les adresses des samples            *
  1440. *    a1 = pointeur sur les chunks instruments (les uns à la suite    *
  1441. *         des autres)                    *
  1442. *    a2 = pointeur sur un tableau de flags (char) pour les samples.    *
  1443. *         Ce tableau doit déjà être initialisé à 0.        *
  1444. *    a3 = idem, pour les instruments                *
  1445. *    Renvoie le nombre de samples dans le mot fort de d0, et le    *
  1446. *    nombre d'instruments dans le mot faible.            *
  1447. *============================================================================*
  1448. find_used_samples_and_instruments:
  1449.     movem.l    d1-a6,-(sp)
  1450.     moveq    #0,d0        ; d0 = nombre de spl/instr utilisés
  1451.  
  1452. ;--- Cherche les samples utilisés --------------------------------------------
  1453.     moveq    #0,d1
  1454.     move.w    #NBRSAMPLES_MAXI-1,d1    ; d1 = Sample courant
  1455.  
  1456. .spl_loop:
  1457.     move.l    (a0,d1.w*4),a4    ; a4 = adresse du chunk du sample
  1458.     tst.l    length_s(a4)
  1459.     bgt.s    .spl_ok        ; Longueur > 0: ok
  1460.  
  1461.     lea    name_s(a4),a5    ; a5 = adresse du nom
  1462.     moveq    #28-1,d2        ; 28 caractères à tester
  1463. .splname_loop:
  1464.     cmp.b    #' ',(a5)+
  1465.     bne.s    .spl_ok        ; Nom utilisé: ok
  1466.     dbra    d2,.splname_loop
  1467.     bra.s    .spl_loopend
  1468.  
  1469. .spl_ok:    st    (a2,d1.w)
  1470.     addq.w    #1,d0
  1471.  
  1472. .spl_loopend:
  1473.     subq.w    #1,d1
  1474.     bgt.s    .spl_loop
  1475.  
  1476. ;--- Cherche les instruments utilisés ----------------------------------------
  1477.     swap    d0        ; Nbr d'instr en mot faible
  1478.     lea    (a1,next_i),a4    ; Pointe sur l'instrument 1
  1479.     moveq    #1,d1        ; d1 = instrument courant
  1480.  
  1481. .instr_loop:
  1482.     lea    name_i(a4),a5    ; a5 = adresse du nom
  1483.     moveq    #28-1,d2        ; 28 caractères à tester
  1484. .instrname_loop:
  1485.     cmp.b    #' ',(a5)+
  1486.     bne.s    .instr_ok        ; Nom utilisé: ok
  1487.     dbra    d2,.instrname_loop
  1488.  
  1489.     lea    splnum_i(a4),a5
  1490.     moveq    #0,d3
  1491.     moveq    #127,d2        ; Numéro de la note testée
  1492. .instr_splloop:
  1493.     move.b    (a5,d2.w*2),d3
  1494.     tst.b    (a2,d3.w)        ; Utilise un sample utilisé ?
  1495.     beq.s    .instr_nextspl
  1496.     tst.l    ([a0,d3.w*4],length_s)    ; Longueur du sample > 0 ?
  1497.     bgt.s    .instr_ok
  1498. .instr_nextspl:
  1499.     dbra    d2,.instr_splloop
  1500.     bra.s    .instr_loopend
  1501.  
  1502. .instr_ok:    st    (a3,d1.w)
  1503.     addq.w    #1,d0
  1504.  
  1505. .instr_loopend:
  1506.     add.w    #next_i,a4
  1507.     addq.w    #1,d1
  1508.     cmp.w    #NBRINSTR_MAXI-1,d1
  1509.     ble.s    .instr_loop
  1510.  
  1511.     movem.l    (sp)+,d1-a6
  1512.     rts
  1513.  
  1514.  
  1515.  
  1516.  
  1517. *============================================================================*
  1518. *    Décode un code clavier et cherche le numéro de la fonction    *
  1519. *    appelée.                        *
  1520. *    d0 = code clavier.l (Crawcin + Kbshift sur l'octet fort)    *
  1521. *    d1 = Etat.l: variables play% en mot fort, edit% en mot faible.    *
  1522. *    d2 = Nombre.w de fonctions                *
  1523. *    a0 = adresse des masques des fonctions            *
  1524. *    a1 = adresse des comparateurs des fonctions            *
  1525. *    a2 = adresse des codes ascii pour la 1ere ligne de touches    *
  1526. *    a3 = idem, 2ème                    *
  1527. *    a4 = idem, 3ème                    *
  1528. *    Au retour:                        *
  1529. *    d0 contient l'adresse d'une structure:            *
  1530. *    L : keycode complet                    *
  1531. *    W : numéro de touche (si groupement)            *
  1532. *    W : numéro de fonction (-1 si pas trouvée)            *
  1533. *============================================================================*
  1534. find_key_function:
  1535.     movem.l    d1-a6,-(sp)
  1536.  
  1537.  
  1538.  
  1539. ;≡≡≡ Retrouve le code clavier complet ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  1540.  
  1541. ;--- Repositionnement des bits -----------------------------------------------
  1542. ; Shift
  1543.     btst    #24,d0        ; Shift droit ?
  1544.     bne.s    .shiftok
  1545.     btst    #25,d0        ; Shift gauche ?
  1546.     beq.s    .shiftend
  1547. .shiftok:    bset    #8,d0
  1548. .shiftend:
  1549.  
  1550. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1551. ; Mode utilisé
  1552.  
  1553.     tst.w    d1        ; Edit ?
  1554.     beq.s    .playtst
  1555.     bset    #15,d0
  1556. .playtst:    swap    d1        ; Play ?
  1557.     tst.w    d1
  1558.     beq.s    .playtend
  1559.     bset    #14,d0
  1560. .playtend:
  1561.  
  1562. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1563. ; Conversion du code ascii minuscules -> majuscules
  1564.  
  1565.     cmp.b    #'a',d0
  1566.     blt.s    .lowerend
  1567.     cmp.b    #'z',d0
  1568.     bgt.s    .lowerend
  1569.     and.b    #%11011111,d0
  1570. .lowerend:
  1571.  
  1572.  
  1573.  
  1574. ;--- Modifie le code scan, en cas d'appui avec shift ou ctrl -----------------
  1575.  
  1576.     move.l    d0,d7
  1577.     swap    d7
  1578.     and.w    #$00FF,d7        ; d7 = code scan
  1579.     moveq    #0,d6        ; d6 = numéro de touche (pour les groupements)
  1580.  
  1581. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1582. ; Ctrl + gauche ou droite
  1583.  
  1584.     cmp.b    #115,d7        ; Flèche gauche
  1585.     bne.s    .right
  1586.     move.b    #75,d7
  1587.     bra    findkeyfunc_scancodeend
  1588.  
  1589. .right:    cmp.b    #116,d7        ; Flèche droite
  1590.     bne.s    .rightend
  1591.     move.b    #77,d7
  1592.     bra    findkeyfunc_scancodeend
  1593. .rightend:
  1594.  
  1595. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1596. ; Touches de fonction
  1597.  
  1598.     cmp.b    #59,d7        ; F1 à F10
  1599.     blt.s    .f11f20
  1600.     cmp.b    #68,d7
  1601.     bgt.s    .f11f20
  1602.     bset    #10,d0
  1603.     move.w    d7,d6
  1604.     sub.w    #59,d6        ; Donne la position de la touche
  1605.     bra.s    findkeyfunc_scancodeend
  1606.  
  1607. .f11f20    cmp.b    #84,d7        ; F11 à F20 ou shift + F1 à F10
  1608.     blt.s    .f11f20end
  1609.     cmp.b    #93,d7
  1610.     bgt.s    .f11f20end
  1611.     bset    #10,d0
  1612.     sub.w    #84-59,d7        ; Rétablit en F1 à F10
  1613.     bset    #8,d0        ; On force également shift
  1614.     move.w    d7,d6
  1615.     sub.w    #59,d6        ; Donne la position de la touche
  1616.     bra.s    findkeyfunc_scancodeend
  1617. .f11f20end:
  1618.  
  1619. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1620. ; Correction ASCII pour les lettres
  1621.  
  1622.     cmp.b    #16,d7        ; Première rangée de lettres
  1623.     blt.s    .row1end
  1624.     cmp.b    #25,d7
  1625.     bgt.s    .row1end
  1626.     move.b    -16(a2,d7.w),d0    ; Cherche dans la table le code ASCII
  1627.     bra.s    findkeyfunc_scancodeend
  1628. .row1end:
  1629.  
  1630.     cmp.b    #30,d7        ; Deuxième rangée de lettres
  1631.     blt.s    .row2end
  1632.     cmp.b    #39,d7
  1633.     bgt.s    .row2end
  1634.     move.b    -30(a3,d7.w),d0    ; Cherche dans la table le code ASCII
  1635.     bra.s    findkeyfunc_scancodeend
  1636. .row2end:
  1637.  
  1638.     cmp.b    #44,d7        ; Troisième rangée de lettres
  1639.     blt.s    .row3end
  1640.     cmp.b    #50,d7
  1641.     bgt.s    .row3end
  1642.     move.b    -44(a4,d7.w),d0    ; Cherche dans la table le code ASCII
  1643.     bra.s    findkeyfunc_scancodeend
  1644. .row3end:
  1645.  
  1646. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1647. ; Pavé numérique
  1648.  
  1649.     lea    numericpad_scancodes(pc),a5
  1650.     moveq    #0,d6
  1651. .padloop:    cmp.b    (a5)+,d7
  1652.     bne.s    .padcont
  1653.     bset    #9,d0
  1654.     bra.s    findkeyfunc_scancodeend
  1655. .padcont:    addq.w    #1,d6
  1656.     cmp.w    #16,d6        ; 16 touches en tout
  1657.     blt.s    .padloop
  1658.     moveq    #0,d6        ; Pas trouvé
  1659.  
  1660. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1661. findkeyfunc_scancodeend:
  1662.     swap    d0        ; Remet le bon code scan
  1663.     move.b    d7,d0
  1664.     swap    d0
  1665.     move.l    d0,keycode_result    ; Sauve-moi tout ça
  1666.     move.w    d6,keycode_result+4
  1667.  
  1668.  
  1669.  
  1670. ;≡≡≡ Recherche de la fonction ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  1671. findkeyfunc_search:
  1672.  
  1673.     moveq    #0,d7        ; Numéro de la fonction testée
  1674.     subq.w    #1,d2        ; Compteur de fonctions
  1675.  
  1676. .loop:
  1677.     move.l    (a0)+,d6        ; 1ère tentative
  1678.     move.l    (a1)+,d5
  1679.     beq.s    .tente2
  1680.     and.l    d0,d6
  1681.     cmp.l    d5,d6
  1682.     beq.s    .found
  1683. .tente2:    move.l    (a0)+,d6        ; 2ème tentative
  1684.     move.l    (a1)+,d5
  1685.     beq.s    .echec
  1686.     and.l    d0,d6
  1687.     cmp.l    d5,d6
  1688.     beq.s    .found
  1689. .echec:    addq.w    #1,d7
  1690.     dbra    d2,.loop
  1691.  
  1692.     move.w    #-1,keycode_result+6    ; On, n'a rien trouvé
  1693.     bra.s    findkeyfunc_end
  1694.  
  1695. .found:
  1696.     move.w    d7,keycode_result+6    ; Sauve le numéro de la fonction
  1697.  
  1698. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1699.  
  1700. findkeyfunc_end:
  1701.     move.l    #keycode_result,d0    ; Fournit l'adresse des résultats
  1702.  
  1703.     movem.l    (sp)+,d1-a6
  1704.     rts
  1705.  
  1706.  
  1707.  
  1708. *============================================================================*
  1709. *    Affiche l'image de présentation.                *
  1710. *    a0 = adresse de l'image avec son en-tête            *
  1711. *    d0 = abscisse.w d'affichage, en colonne            *
  1712. *    d1 = ligne.w d'affichage                *
  1713. *    d2 = ligne.w dans l'image                *
  1714. *    d3 = nombre.w de lignes à afficher            *
  1715. *    d4 = -1.w si on doit sauter des lignes, 0 sinon        *
  1716. *============================================================================*
  1717. affiche_image_presentation:
  1718.     movem.l    d0-a6,-(sp)
  1719.  
  1720.     move.l    adrecr(pc),a1
  1721.     mulu.w    linewidth(pc),d1
  1722.     add.l    d1,a1
  1723.     move.w    d0,d1
  1724.     and.w    #1,d1        ; d1 = parité de la colonne.
  1725.     lsl.w    #2,d0
  1726.     and.w    #-8,d0
  1727.     add.w    d1,d0
  1728.     add.w    d0,a1        ; a1 = adresse d'affichage
  1729.  
  1730.     mulu.w    2(a0),d2
  1731.     lea    8(a0,d2.l),a3    ; a3 = adresse de l'image à la bonne ligne
  1732.  
  1733.     mulu.w    #6,d1
  1734.     addq.w    #1,d1
  1735.     move.w    d1,d0        ; d0 = incrément d'adresse écran. Vaut 1 ou 7
  1736.     move.w    d4,d1        ; d1 = flag de saut de ligne
  1737.     move.w    d3,d5
  1738.     subq.w    #1,d5        ; d5 = compteur de lignes
  1739.  
  1740. .loop_y:
  1741.     move.l    a1,a2        ; a2 = registre utilisé pour afficher les lignes
  1742.     move.l    (a0),d6
  1743.     lsr.l    #3,d6
  1744.     subq.w    #1,d6        ; d6 = compteur de colonne
  1745.     movem.w    d0-d1/d5,-(sp)
  1746.  
  1747. .loop_x:
  1748.     movem.w    d0,-(sp)
  1749.     move.b    #%10000000,d1    ; Masque de pixel: 1<<x
  1750.     moveq    #7,d7        ; d7 = Compteur de pixels par colonne
  1751.     moveq    #0,d2
  1752.     moveq    #0,d3
  1753.     moveq    #0,d4
  1754.     moveq    #0,d5
  1755.  
  1756. .loop_c:                ; Transforme 8 pixels en 4 octets de bitplans
  1757.     move.b    (a3)+,d0
  1758. .plan1:    lsr.b    #1,d0
  1759.     bcc.s    .plan2
  1760.     add.b    d1,d2
  1761. .plan2:    lsr.b    #1,d0
  1762.     bcc.s    .plan3
  1763.     add.b    d1,d3
  1764. .plan3:    lsr.b    #1,d0
  1765.     bcc.s    .plan4
  1766.     add.b    d1,d4
  1767. .plan4:    lsr.b    #1,d0
  1768.     bcc.s    .finplans
  1769.     add.b    d1,d5
  1770. .finplans:
  1771.     lsr.b    #1,d1        ; Décale le masque
  1772.     dbra    d7,.loop_c
  1773.  
  1774.     move.b    d2,(a2)        ; Affiche les bitplans
  1775.     move.b    d3,2(a2)
  1776.     move.b    d4,4(a2)
  1777.     move.b    d5,6(a2)
  1778.     movem.w    (sp)+,d0
  1779.     add.w    d0,a2
  1780.     subq.w    #8,d0
  1781.     neg.w    d0
  1782.     dbra    d6,.loop_x
  1783.  
  1784.     movem.w    (sp)+,d0-d1/d5
  1785.     add.w    linewidth(pc),a1
  1786.     tst.w    d1
  1787.     beq.s    .no_lf        ; Si on est en mode pixels rectangles,
  1788.     add.l    (a0),a3        ; affiche une ligne sur deux.
  1789. .no_lf:    dbra    d5,.loop_y
  1790.  
  1791.     movem.l    (sp)+,d0-a6
  1792.     rts
  1793.  
  1794.  
  1795.  
  1796. *============================================================================*
  1797. *    Effet de compression                    *
  1798. *    a0 = Adresse du bloc d'infos                *
  1799. *============================================================================*
  1800. fx_compression:
  1801.     movem.l    d0-a6,-(sp)
  1802.  
  1803. ;--- Quelques tests de sécurité ----------------------------------------------
  1804.     tst.l    comp_lonsource(a0)
  1805.     ble    fxcomp_end
  1806.     tst.l    comp_lonbuffer(a0)
  1807.     ble    fxcomp_end
  1808.     tst.l    comp_speed(a0)
  1809.     ble    fxcomp_end
  1810.     tst.l    comp_level(a0)
  1811.     ble    fxcomp_end
  1812.  
  1813. ;--- Initialisation du buffer ------------------------------------------------
  1814.     move.l    comp_adrbuffer(a0),a1
  1815.     move.l    comp_lonbuffer(a0),d0
  1816.     move.l    comp_initvolume(a0),d1
  1817.     lsr.l    #1,d0        ; Bytes -> samples
  1818.     lsr.l    #1,d1        ; /65536 -> /32768
  1819.     cmp.l    #32767,d1        ; Limitation du volume initial
  1820.     ble.s    .suite1
  1821.     move.l    #32767,d1
  1822. .suite1:    move.l    d1,comp_volume(a0)
  1823.  
  1824.     subq.l    #1,d0
  1825.     swap    d0        ; Remplit le buffer avec des samples
  1826. fxcomp_initbuf_loop1:            ; du volume initial
  1827.     swap    d0
  1828. fxcomp_initbuf_loop2:
  1829.     move.w    d1,(a1)+
  1830.     dbra    d0,fxcomp_initbuf_loop2
  1831.     swap    d0
  1832.     dbra    d0,fxcomp_initbuf_loop1
  1833.  
  1834. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  1835.     clr.l    comp_possource(a0)
  1836.     clr.l    comp_posbuffer(a0)
  1837.     move.w    #1,comp_ampli_int(a0)    ; Coef d'ampli 1 par défaut
  1838.     clr.l    comp_ampli_frac(a0)
  1839.     move.l    comp_adrsource(a0),a1    ; a1 = adresse de la source
  1840.     move.l    comp_adrdest(a0),a2    ; a2 = adresse de la destination
  1841.     move.l    comp_adrbuffer(a0),a3    ; a3 = adresse du buffer
  1842.     move.l    comp_possource(a0),d1    ; d1 = position courante dans le sample
  1843.     move.l    comp_posbuffer(a0),d2    ; d2 = position courante dans le buffer
  1844.  
  1845. ;≡≡≡ Boucle principale ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  1846. fxcomp_mainloop:
  1847.     move.l    comp_speed(a0),d0    ; d0 = compteur de samples à amplifier
  1848.  
  1849. ;--- Boucle de copie et amplification de sample ------------------------------
  1850.     subq.l    #1,d0
  1851.     swap    d0
  1852. fxcomp_copyloop1:
  1853.     swap    d0
  1854. fxcomp_copyloop2:
  1855.  
  1856.     cmp.w    #2,comp_ressource(a0)    ; Prend le nouveau sample dans d3
  1857.     beq.s    .s16bits
  1858.     move.b    (a1)+,d3
  1859.     lsl.w    #8,d3
  1860.     addq.l    #1,d1        ; Incrémente la position du sample
  1861.     bra.s    .sfin
  1862. .s16bits:    move.w    (a1)+,d3
  1863.     addq.l    #2,d1        ; Incrémente la position du sample
  1864. .sfin:    ext.l    d3
  1865.  
  1866.     move.w    d3,d5        ; Valeur absolue de d5, limitée à 32767
  1867.     bpl.s    .absfin        ; Positif, c'est fini
  1868.     neg.w    d5        ; Renverse le signe
  1869.     bpl.s    .absfin        ; Si c'est encore négatif, c'est 32768
  1870.     move.w    #32767,d5
  1871. .absfin:    move.w    d5,(a3,d2.l)    ; Insère dans le buffer
  1872.  
  1873.     addq.l    #2,d2        ; Incrémente la position du buffer
  1874.     cmp.l    comp_lonbuffer(a0),d2
  1875.     blt.s    .incbuffin
  1876.     moveq    #0,d2
  1877. .incbuffin:
  1878.  
  1879.     move.w    d3,d5        ; Amplifie le sample
  1880.     muls.w    comp_ampli_int(a0),d5    ; d5 = partie entière amplifiée
  1881.     moveq    #0,d6        ; On ne prend que le frac de poids fort, ça suffit
  1882.     move.w    comp_ampli_frac(a0),d6
  1883.     muls.l    d6,d3
  1884.     swap    d3
  1885.     ext.l    d3
  1886.     add.l    d5,d3        ; d3 contient maintenant le sample amplifié
  1887.  
  1888.     cmp.l    #32767,d3        ; Limite le sample
  1889.     ble.s    .limsuite
  1890.     move.w    #32767,d3        ; Attention on ne remet qu'un mot court
  1891.     bra.s    .limfin
  1892. .limsuite:    cmp.l    #-32767,d3        ; -32767 maxi!
  1893.     bge.s    .limfin
  1894.     move.w    #-32767,d3
  1895. .limfin:
  1896.  
  1897.     cmp.w    #2,comp_resdest(a0)    ; Sauve le nouveau sample
  1898.     beq.s    .d16bits
  1899.     lsr.w    #8,d3
  1900.     move.b    d3,(a2)+
  1901.     bra.s    .dfin
  1902. .d16bits:    move.w    d3,(a2)+
  1903. .dfin:
  1904.  
  1905.     cmp.l    comp_lonsource(a0),d1    ; On a fini ?
  1906.     bge    fxcomp_end
  1907.  
  1908.     dbra    d0,fxcomp_copyloop2
  1909.     swap    d0
  1910.     dbra    d0,fxcomp_copyloop1
  1911.  
  1912. ;--- Réévaluation du coef d'amplification ------------------------------------
  1913.     moveq    #0,d4
  1914.     move.l    a3,a4
  1915.     move.l    comp_lonbuffer(a0),d0
  1916.     lsr.l    #1,d0
  1917.     subq.l    #1,d0
  1918.     swap    d0
  1919. fxcomp_chmaxloop1:
  1920.     swap    d0
  1921. fxcomp_chmaxloop2:
  1922.     cmp.w    (a4)+,d4
  1923.     bge.s    .loopend
  1924.     move.w    -2(a4),d4
  1925. .loopend:    dbra    d0,fxcomp_chmaxloop2
  1926.     swap    d0
  1927.     dbra    d0,fxcomp_chmaxloop1
  1928.     lsl.l    #1,d4        ; /32768 -> /65536
  1929.     move.l    d4,comp_volume(a0)
  1930.  
  1931.     tst.w    d4
  1932.     bne.s    .divvolok        ; Volume non nul, on peut diviser
  1933.     moveq    #1,d3        ; S'il est nul, on fait comme si coef 1
  1934.     moveq    #0,d6
  1935.     bra.s    .divvolf
  1936. .divvolok:    move.l    comp_level(a0),d3    ; d3 = volume à atteindre
  1937.     divul.l    d4,d5:d3        ; d3 = coef idéal partie entière, d5 = reste
  1938.     divu.l    d4,d5:d6        ; d6 = coef idéal partie fractionnaire
  1939. .divvolf:    moveq    #0,d4
  1940.     move.w    comp_ampli_int(a0),d4    ; d4 = ancien coef partie entière
  1941.     move.l    comp_ampli_frac(a0),d5    ; d5 = ancien coef partie fractionnaire
  1942.     sub.l    d5,d6        ; On va faire 15 * ancien + nouveau
  1943.     subx.l    d4,d3        ; En fait (nouveau - ancien) + 16 * ancien
  1944.     Rept    4
  1945.     add.l    d5,d5        ; 16 * ancien
  1946.     addx.l    d4,d4
  1947.     EndR
  1948.     add.l    d6,d5        ; + (nouveau - ancien)
  1949.     addx.l    d3,d4
  1950.     Rept    4
  1951.     lsr.l    d4        ; Divise le tout par 16
  1952.     roxr.l    d5
  1953.     EndR
  1954.     move.w    d4,comp_ampli_int(a0)
  1955.     move.l    d5,comp_ampli_frac(a0)
  1956.  
  1957.     bra    fxcomp_mainloop
  1958.  
  1959. fxcomp_end:
  1960.     movem.l    (sp)+,d0-a6
  1961.     rts
  1962.  
  1963.  
  1964.  
  1965. *============================================================================*
  1966. *    Enregistrement d'un module dans un sample            *
  1967. *    A exécuter après avoir lancé le DMA dans GTPLAY.PGT        *
  1968. *============================================================================*
  1969. start_song_recording:
  1970.     movem.l    d0-a6,-(sp)
  1971.     pea    start_song_recording2
  1972.     move.w    #$26,-(sp)
  1973.     trap    #14
  1974.     addq.l    #6,sp
  1975.     movem.l    (sp)+,d0-a6
  1976.     rts
  1977.  
  1978. start_song_recording2:
  1979.     move.l    songrecord_paramadr(pc),a0
  1980. .waitloop:    cmp.w    #2,(a0)        ; Attend que l'enregistrement ait commencé
  1981.     blt.s    .waitloop
  1982.  
  1983.     move.l    #0*4096,rec_sam_num_buf    ; On est sur le 1er buffer
  1984.  
  1985.     pea    sample_rec_buffer2+4096
  1986.     pea    sample_rec_buffer2(pc)
  1987.     move.w    #1,-(sp)
  1988.     move.w    #$83,-(sp)        ; Fixe le buffer d'enregistrement numéro 2
  1989.     trap    #14
  1990.     lea    12(sp),sp
  1991.  
  1992.     move.w    #2,-(sp)        ; Interruption à la fin de l'enregistrement
  1993.     move.w    #1,-(sp)        ; sur MFP gpi7
  1994.     move.w    #$87,-(sp)
  1995.     trap    #14
  1996.     addq.l    #6,sp
  1997.  
  1998.     bclr    #7,$fffffa13.w    ; Masque
  1999.     move.l    $13C.w,old_it_mfp15
  2000.     move.l    #interruption_rec_song,$13C.w
  2001.     bset    #7,$fffffa07.w    ; MFP-15
  2002.     bset    #3,$fffffa17.w    ; Fin d'it en soft
  2003.     bset    #7,$fffffa13.w    ; Démasque : c'est parti mon kiki !
  2004.  
  2005.     rts
  2006.  
  2007.  
  2008.  
  2009. ;≡≡≡ Interruption (MFP 15) de conversion buffer -> sample ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  2010.  
  2011. interruption_rec_song:
  2012.     movem.l    d0-a6,-(sp)
  2013.     and.w    #%1111100011111111,sr
  2014.     bclr    #7,$fffffa0f.w
  2015.  
  2016.     move.l    songrecord_paramadr(pc),a0
  2017.     cmp.w    #4,(a0)        ; Au bout de l'enregistrement ?
  2018.     beq    itrecsng_term
  2019.     tst.w    songrec_flag    ; Ordre d'arrêter ?
  2020.     beq    itrecsng_term
  2021.  
  2022.     lea    sample_rec_buffer(pc),a0    ; a0 pointe sur un buffer
  2023.     add.l    rec_sam_num_buf(pc),a0    ; Celui qu'on a enregistré
  2024.  
  2025.     move.l    songrec_adr_buffer,a2    ; a2 = adresse du buffer
  2026.     move.l    songrec_pos_buffer,d7    ; d7 = position courante dans le buffer
  2027.     move.w    songrec_bits,d1
  2028.     move.w    songrec_stereo,d2
  2029.     moveq    #4,d6
  2030.     sub.w    d1,d6
  2031.     sub.w    d2,d6        ; d6 = 2 - ((d1 - 1) + (d2 - 1))
  2032.     move.l    #4096,d5
  2033.     lsr.l    d6,d5        ; d5 = Taille de la copie dans le buffer final
  2034.     move.l    d5,d4        ; Sauve ça dans d4
  2035.     add.l    d7,d5        ; ajoute la position courante
  2036.     cmp.l    songrec_lon_buffer,d5    ; Y aura un débordement ?
  2037.     blt.s    itrecsng_nooverflow    ; Non, ça baigne
  2038.  
  2039. ;--- Conversion avec débordement (et éventuellement bouclage) ----------------
  2040.     move.l    songrec_lon_buffer,d5
  2041.     sub.l    d7,d5        ; d5 = taille qu'on peut placer avant la fin
  2042.     sub.l    d5,d4        ; d4 = le reste
  2043.     move.l    d5,d0
  2044.     lsl.l    d6,d0        ; Convertit en taille 16 bits/stereo
  2045.     lea    (a2,d7.l),a1
  2046.     bsr    convert_stereo16    ; Conversion
  2047.     clr.l    d7
  2048.     move.l    d7,songrec_pos_buffer
  2049.     move.l    songrec_pos_sample,d6
  2050.     add.l    d5,d6
  2051.     move.l    d6,songrec_pos_sample
  2052.     cmp.l    songrec_lon_sample,d6    ; Sample fini ?
  2053.     bge.s    itrecsng_term    ; Oui, on s'en va
  2054.     tst.w    songrec_type    ; Bouclage ?
  2055.     beq.s    itrecsng_term    ; Non, c'est fini alors
  2056.     add.l    d0,a0        ; Oui, on passe au reste
  2057.     tst.l    d4
  2058.     bge.s    itrecsng_nxtbuf
  2059.  
  2060. ;--- Conversion sans débordement ---------------------------------------------
  2061. itrecsng_nooverflow:
  2062.     lea    (a2,d7.l),a1
  2063.     move.l    d4,d0
  2064.     lsl.l    d6,d0
  2065.     bsr    convert_stereo16    ; Conversion
  2066.     add.l    d4,d7
  2067.     move.l    d7,songrec_pos_buffer
  2068.     move.l    songrec_pos_sample,d6
  2069.     add.l    d4,d6
  2070.     move.l    d6,songrec_pos_sample
  2071.     cmp.l    songrec_lon_sample,d6    ; Sample fini ?
  2072.     blt.s    itrecsng_nxtbuf
  2073.  
  2074. ;--- Sample fini, arrêt de l'interruption ------------------------------------
  2075. itrecsng_term:
  2076.     or.w    #$2700,sr        ; Evite les problèmes
  2077.     bsr    stopsngrec_rout
  2078.     bra.s    itsngrec_fin
  2079.  
  2080. ;--- Programmation du buffer suivant -----------------------------------------
  2081. itrecsng_nxtbuf:
  2082.     move.l    #sample_rec_buffer,d0    ; Pointe sur le buffer qu'il
  2083.     add.l    rec_sam_num_buf(pc),d0    ; faut enregistrer la prochaine fois
  2084.     move.l    d0,d1        ; d0 = adresse de début du nouveau buffer
  2085.     add.l    #4096,d1        ; d1 = adresse de fin du nouveau buffer
  2086.     move.b    $ffff8901.w,d2    ; Signale que c'est le buffer d'enregistrement
  2087.     or.b    #%10000000,d2    ; qu'on veut fixer
  2088.     move.b    d2,$ffff8901.w    ; Le nouveau buffer d'enregistrement est en fait
  2089.     move.b    d0,$ffff8907.w    ; le même que celui qu'on vient de convertir.
  2090.     lsr.w    #8,d0
  2091.     move.b    d0,$ffff8905.w
  2092.     swap    d0
  2093.     move.b    d0,$ffff8903.w
  2094.     move.b    d1,$ffff8913.w
  2095.     lsr.w    #8,d1
  2096.     move.b    d1,$ffff8911.w
  2097.     swap    d1
  2098.     move.b    d1,$ffff890f.w
  2099.     eor.l    #4096,rec_sam_num_buf    ; Change le buffer de conversion pour la prochaine fois
  2100.  
  2101. itsngrec_fin:
  2102.     movem.l    (sp)+,d0-a6
  2103.     rte
  2104.  
  2105.  
  2106.  
  2107. *============================================================================*
  2108. *    Stoppe l'enregistrement du module            *
  2109. *============================================================================*
  2110. stop_song_recording
  2111.     movem.l    d0-a6,-(sp)
  2112.     pea    stopsngrec_rout
  2113.     move.w    #$26,-(sp)
  2114.     trap    #14
  2115.     addq.l    #6,sp
  2116.     movem.l    (sp)+,d0-a6
  2117.     rts
  2118.  
  2119. stopsngrec_rout:
  2120.     clr.w    -(sp)        ; Plus d'interruption à la fin de l'enregistrement
  2121.     move.w    #1,-(sp)        ; sur MFP gpi7
  2122.     move.w    #$87,-(sp)
  2123.     trap    #14
  2124.     addq.l    #6,sp
  2125.  
  2126.     bclr    #7,$fffffa07.w    ; Annule MFP-15
  2127.     bclr    #7,$fffffa13.w    ; Masque l'interruption
  2128.     move.l    old_it_mfp15,$13C.w
  2129.  
  2130.     clr.w    -(sp)        ; Arret de l'enregistrement
  2131.     move.w    #$88,-(sp)
  2132.     trap    #14
  2133.     addq.l    #4,sp
  2134.  
  2135.     clr.w    songrec_flag    ; On a fini
  2136.  
  2137.     rts
  2138.  
  2139.  
  2140.  
  2141. *============================================================================*
  2142. *    Effet de réverbération                *
  2143. *    Les buffers doivent être déjà vides            *
  2144. *    a0 = adresse du bloc de données sur la reverb (voir les Rs avec    *
  2145. *         les rev_ )                    *
  2146. *============================================================================*
  2147. fx_reverberation:
  2148.     movem.l    d0-a6,-(sp)
  2149.  
  2150.     move.l    a0,d0        ; Si a0 = 0, on doit reprendre à
  2151.     beq    fxrev_reprise    ; partir de là ou on en était.
  2152.     move.l    #4096,d0        ; Tous les 4096 on indique la progression
  2153.     move.l    d0,progression_step
  2154.     move.l    d0,progression_cpt
  2155.     move.l    rev_londest(a0),progression_len
  2156.     clr.l    progression_pos
  2157.  
  2158. ;--- Initialisation ----------------------------------------------------------
  2159.     move.w    rev_ncomb(a0),d0
  2160.     clr.l    rev_sourcepos(a0)
  2161.     clr.l    rev_destpos(a0)
  2162.     clr.l    rev_erefpos(a0)
  2163.     clr.l    rev_aprpos(a0)
  2164.     clr.l    rev_adlypos(a0)
  2165.     lea    rev_comb(a0),a1
  2166.     move.w    rev_ncomb(a0),d0
  2167.     subq.w    #1,d0
  2168. .initloop:    clr.l    rev_comb_pos(a1)    ; Position dans les buffers de comb filter à 0
  2169.     clr.l    rev_comb_lpfbuf(a1)    ; Micro-buffer 1 sample des LPF pour comb filter effacé
  2170.     add.w    #rev_comb_end,a1
  2171.     dbra    d0,.initloop
  2172.  
  2173. ;--- Boucle de l'effet -------------------------------------------------------
  2174. ; Cherche le sample d'entrée
  2175. fxrev_loop:
  2176.     moveq    #0,d1        ; Futur sample source
  2177.     move.l    rev_sourcepos(a0),d0
  2178.     cmp.l    rev_lonsource(a0),d0    ; On a dépassé la fin ?
  2179.     bge.s    .sourcefini    ; Oui, on laisse le sample dry à 0
  2180.     cmp.w    #2,rev_resolsource(a0)
  2181.     beq.s    .in16bits
  2182.     move.b    ([rev_adrsource,a0],d0.l),d1    ; En 8 bits
  2183.     lsl.w    #8,d1
  2184.     addq.l    #1,rev_sourcepos(a0)
  2185.     bra.s    .sourcefini
  2186. .in16bits:    move.w    ([rev_adrsource,a0],d0.l),d1    ; En 16 bits
  2187.     addq.l    #2,rev_sourcepos(a0)
  2188. .sourcefini:
  2189.     move.l    d1,d3
  2190.     swap    d3
  2191.     muls.l    rev_drylevel(a0),d2:d3    ; Dry level
  2192.     move.l    d2,rev_drysample(a0)
  2193.  
  2194. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2195. ; FIR for early relfections
  2196.     move.l    rev_adrerefbuf(a0),a1    ; a1 = Adresse du buffer
  2197.     lea    rev_earlyreflection(a0),a2
  2198.     move.l    rev_erefpos(a0),d2    ; d2 = Position courante dans le buffer
  2199.  
  2200.     move.w    d1,(a1,d2.l)    ; L'entrée dans le buffer
  2201.     addq.l    #2,d2        ; Le buffer avance (on fait ça
  2202.     cmp.l    rev_lonerefbuf(a0),d2    ; au début cette fois-ci)
  2203.     blt.s    .erbufok
  2204.     moveq    #0,d2
  2205. .erbufok:    move.l    d2,rev_erefpos(a0)
  2206.  
  2207.     moveq    #0,d0        ; d0 = mixage des taps
  2208.     move.w    rev_erefntap(a0),d1
  2209.     subq.w    #1,d1        ; d1 = compteur de taps
  2210. .erefloop:
  2211.     move.l    d2,d3
  2212.     sub.l    (a2)+,d3            ; d3 = position du tap
  2213.     bpl.s    .ermodok            ; Pas de dépassement, ok
  2214.     add.l    rev_lonerefbuf(a0),d3        ; Sinon modulo taille du buffer
  2215. .ermodok:    move.w    (a1,d3.l),d3        ; Sample du tap dans d3
  2216.     swap    d3
  2217.     muls.l    (a2)+,d4:d3        ; Ajuste au bon level
  2218.     add.l    d4,d0            ; Mixe avec la totale
  2219.  
  2220.     dbra    d1,.erefloop    ; Tap suivant
  2221.     move.l    d0,rev_erefspl0(a0)    ; Sauve le résultat sans gain, pour les combs
  2222.     muls.l    rev_ereflevel(a0),d1:d0
  2223.     move.w    d1,rev_erefsample(a0)    ; Sauve le sample des réflections primaires,
  2224.     swap    d0        ; Mot fort
  2225.     move.w    d0,rev_erefsample+2(a0)    ; et mot faible
  2226.  
  2227. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2228. ; Comb filters
  2229.     moveq    #0,d5        ; Mixage des comb filters
  2230.     lea    rev_comb(a0),a1    ; a1 pointe sur les infos Comb Filters
  2231.     move.w    rev_ncomb(a0),d0
  2232.     subq.w    #1,d0        ; d0 = compteur de comb
  2233. .combloop:
  2234.     move.l    rev_comb_adrbuf(a1),a2    ; a2 = adresse du buffer comb
  2235.     move.l    rev_comb_pos(a1),d1        ; d1 = position dans le buffer
  2236.     move.l    d1,d2
  2237.     sub.l    rev_comb_delay(a1),d2        ; d2 = position avec delay
  2238.     bpl.s    .combok
  2239.     add.l    rev_comb_lonbuf(a1),d2
  2240. .combok:    move.w    (a2,d2.l),d2        ; d2 = sample en sortie de comb
  2241.     ext.l    d2
  2242.     add.l    d2,d5            ; Mixe avec la totale
  2243.  
  2244.     move.l    rev_comb_lpfbuf(a1),d3    ; Prend le sample dans le micro-buffer LPF
  2245.     muls.l    rev_comb_lpfg(a1),d4:d3    ; Gain LPF
  2246.     move.w    d4,d3            ; Rotation 16 bits vers la gauche
  2247.     swap    d3            ; de d4:d3 (on garde que les bits 16-47)
  2248.     add.l    d2,d3            ; Mixe avec la sortie de comb
  2249.  
  2250.     move.l    d3,rev_comb_lpfbuf(a1)    ; On sauve le résultat dans le
  2251.                     ; buffer LPF, en long
  2252.     muls.l    rev_comb_fdbk(a1),d4:d3    ; Pouf, feedback
  2253.     move.w    d4,d3
  2254.     swap    d3
  2255.     add.l    rev_erefspl0(a0),d3        ; On mixe avec l'Early Reflection
  2256.     cmp.l    #MAX_SWORD,d3        ; On s'assure
  2257.     ble.s    .mixcok1            ; qu'on tient bien dans 16
  2258.     move.w    #MAX_SWORD,d3        ; bits, sinon on coupe au-
  2259. .mixcok1:    cmp.l    #MIN_SWORD,d3        ; dessus et en au-dessous.
  2260.     bge.s    .mixcok2
  2261.     move.w    #MIN_SWORD,d3
  2262. .mixcok2:    move.w    d3,(a2,d1.l)        ; Pof, dans le buffer
  2263.  
  2264.     addq.l    #2,d1            ; Le buffer avance
  2265.     cmp.l    rev_comb_lonbuf(a1),d1
  2266.     blt.s    .cbufok
  2267.     moveq    #0,d1
  2268. .cbufok:    move.l    d1,rev_comb_pos(a1)
  2269.  
  2270.     add.w    #rev_comb_end,a1        ; Comb suivant
  2271.     dbra    d0,.combloop
  2272.  
  2273. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2274. ; All Pass Unit Reverberator
  2275.     move.l    d5,d0        ; d5 contenait l'entrée
  2276.     muls.l    rev_aprgneg(a0),d1:d0    ; Traite d0 pour le dry de l'APUR
  2277.     swap    d1        ; Entasse ça dans d1 qui servira de mixage
  2278.     swap    d0        ; Rotation gauche de 16 bits de d1:d0
  2279.     move.w    d0,d1        ;
  2280.  
  2281.     move.l    rev_adraprbuf(a0),a1    ; a1 = adresse du buffer
  2282.     move.l    rev_aprpos(a0),d0    ; d0 = position courante
  2283.     move.l    d0,d2
  2284.     sub.l    rev_aprdelay(a0),d2    ; d2 = position+delay
  2285.     bpl.s    .apurok
  2286.     add.l    rev_lonaprbuf(a0),d2
  2287. .apurok:    move.w    (a1,d2.l),d2
  2288.     swap    d2        ; d2 contient le sample retardé
  2289.  
  2290.     move.l    d2,d3
  2291.     muls.l    rev_aprg(a0),d4:d3    ; Feedback
  2292.     add.l    d5,d4        ; Mixe avec l'entrée
  2293.     cmp.l    #MAX_SWORD,d4    ; On s'assure
  2294.     ble.s    .mxaprok1        ; qu'on tient bien dans 16
  2295.     move.w    #MAX_SWORD,d4    ; bits, sinon on coupe au-
  2296. .mxaprok1:    cmp.l    #MIN_SWORD,d4    ; dessus et en au-dessous.
  2297.     bge.s    .mxaprok2
  2298.     move.w    #MIN_SWORD,d4
  2299. .mxaprok2:    move.w    d4,(a1,d0.l)    ; Pof, dans le buffer
  2300.  
  2301.     addq.l    #2,d0        ; Le buffer avance
  2302.     cmp.l    rev_lonaprbuf(a0),d0
  2303.     blt.s    .aprbufok
  2304.     moveq    #0,d0
  2305. .aprbufok:    move.l    d0,rev_aprpos(a0)
  2306.  
  2307.     muls.l    rev_apr1mg2(a0),d4:d2    ; Sortie du delay, recalibré
  2308.     add.l    d1,d4        ; Mixe pour la sortie
  2309.     cmp.l    #MAX_SWORD,d4    ; On s'assure
  2310.     ble.s    .mxaprok3        ; qu'on tient bien dans 16
  2311.     move.w    #MAX_SWORD,d4    ; bits, sinon on coupe au-
  2312. .mxaprok3:    cmp.l    #MIN_SWORD,d4    ; dessus et en au-dessous.
  2313.     bge.s    .mxaprok4
  2314.     move.w    #MIN_SWORD,d4
  2315. .mxaprok4:
  2316.  
  2317. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2318.     move.l    rev_adlypos(a0),d0    ; Position dans le delay d'alignement
  2319.     move.l    rev_adradlybuf(a0),a1
  2320.     move.w    d4,(a1,d0.l)    ; Le résultat de l'APR dans le buffer
  2321.  
  2322.     move.l    d0,d1
  2323.     sub.l    rev_adlydelay(a0),d1
  2324.     bpl.s    .adlyok
  2325.     add.l    rev_lonadlybuf(a0),d1
  2326. .adlyok:    move.w    (a1,d1.l),d1
  2327.     swap    d1
  2328.     muls.l    rev_revlevel(a0),d2:d1    ; d2 = sortie du delay d'alignement
  2329.  
  2330.     addq.l    #2,d0        ; Le buffer avance
  2331.     cmp.l    rev_lonadlybuf(a0),d0
  2332.     blt.s    .adbufok
  2333.     moveq    #0,d0
  2334. .adbufok:    move.l    d0,rev_adlypos(a0)
  2335.  
  2336. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2337. ; Mixage final
  2338.     add.l    rev_erefsample(a0),d2
  2339.     add.l    rev_drysample(a0),d2
  2340.     cmp.l    #MAX_SWORD,d2    ; On s'assure
  2341.     ble.s    .mxfinok1        ; qu'on tient bien dans 16
  2342.     move.w    #MAX_SWORD,d2    ; bits, sinon on coupe au-
  2343. .mxfinok1:    cmp.l    #MIN_SWORD,d2    ; dessus et en au-dessous.
  2344.     bge.s    .mxfinok2
  2345.     move.w    #MIN_SWORD,d2
  2346. .mxfinok2:
  2347.     move.l    rev_destpos(a0),d0    ; On stoque le résultat dans la destination
  2348.     cmp.l    rev_londest(a0),d0    ; Mais vérifie d'abord que c'est pas fini
  2349.     bge.s    fxrev_fin        ; Sinon on n'a plus rien à faire là
  2350.     moveq    #0,d1
  2351.     move.w    rev_resoldest(a0),d1    ; d1.l = nombre d'octets par sample (utilisé après)
  2352.     cmp.w    #2,d1
  2353.     beq.s    .fin16b
  2354.     asr.w    #8,d2
  2355.     move.b    d2,([rev_adrdest,a0],d0.l)
  2356.     addq.l    #1,d0
  2357.     bra    .fin816b
  2358. .fin16b:    move.w    d2,([rev_adrdest,a0],d0.l)
  2359.     addq.l    #2,d0
  2360. .fin816b:    move.l    d0,rev_destpos(a0)
  2361.  
  2362. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2363. ; Arrêt momentané pour affichage de la progression
  2364.     sub.l    d1,progression_cpt
  2365.     bgt    fxrev_loop
  2366.     move.l    progression_step(pc),d1
  2367.     move.l    d1,progression_cpt
  2368.     add.l    d1,progression_pos
  2369.     movem.l    d0-d7/a0-a6,progression_savedreg
  2370.     bra.s    fxrev_break
  2371.  
  2372. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2373. ; Reprise après affichage de la progression
  2374. fxrev_reprise:
  2375.     movem.l    progression_savedreg,d0-d7/a0-a6
  2376.     bra    fxrev_loop
  2377.  
  2378. fxrev_fin:
  2379.     move.l    progression_len(pc),progression_pos    ; Signale que tout est fini
  2380. fxrev_break:
  2381.     movem.l    (sp)+,d0-a6
  2382.     rts
  2383.  
  2384.  
  2385.  
  2386. *============================================================================*
  2387. *    Effet de stereo flanger                *
  2388. *    Les buffers doivent être déjà vides            *
  2389. *    a0 = adresse du bloc de données sur le flanger (voir les Rs avec    *
  2390. *         les fl_ )                    *
  2391. *      - L : Adresse du sample left                *
  2392. *      - L : Adresse du sample right                *
  2393. *      - L : Adresse du sample destination            *
  2394. *      - L : Adresse du buffer gauche                *
  2395. *      - L : Adresse du buffer droit                *
  2396. *      - L : Adresse de la table des sinus            *
  2397. *      - L : Longueur du sample source left, en octets        *
  2398. *      - L : Longueur du sample source right, en octets        *
  2399. *      - L : Longueur du sample destination, en octets        *
  2400. *      - L : Longueur du buffer 16 bits gauche (et droit), en octets    *
  2401. *      - W : Nombre d'octets par sample (source left)        *
  2402. *      - W : Nombre d'octets par sample (source right)        *
  2403. *      - W : Nombre d'octets par sample (destination)        *
  2404. *      - W : Flags : +1 = dest left,                *
  2405. *                    +2 = dest right,                *
  2406. *                    +4 = mixage mono si +1 et +2 sont mis        *
  2407. *      - L : Feedback left -> left (/65536)            *
  2408. *      - L : Feedback left -> right(/65536)            *
  2409. *      - L : Feedback right -> left (/65536)            *
  2410. *      - L : Feedback right -> right (/65536)            *
  2411. *      - L : Dry level left                *
  2412. *      - L : Dry level right                *
  2413. *      - L : Wet level left                *
  2414. *      - L : Wet level right                *
  2415. *      - L : Frequence du flanger (65536*4096/FreqEch -> 1 Hz)    *
  2416. *      - L : Amplitude du flanger (en octets)            *
  2417. *      - L : Flange time (en octets)                *
  2418. *      - W : Phase initiale (0-4095)                *
  2419. *============================================================================*
  2420. fx_stereo_flanger:
  2421.     movem.l    d0-a6,-(sp)
  2422.  
  2423.     move.l    a0,d0        ; Si a0 = 0, on doit reprendre à
  2424.     beq    fxfl_reprise    ; partir de là ou on en était.
  2425.     move.l    #4096,d0        ; Tous les 4096 on indique la progression
  2426.     move.l    d0,progression_step
  2427.     move.l    d0,progression_cpt
  2428.     move.l    fl_londest(a0),progression_len
  2429.     clr.l    progression_pos
  2430.  
  2431.  
  2432. ;--- Initialisation ----------------------------------------------------------
  2433.     move.l    fl_londest(a0),d0
  2434.     ble    fxfl_fin
  2435.     move.l    d0,fl_destcpt(a0)
  2436.     clr.l    fl_lsplpos(a0)
  2437.     clr.l    fl_rsplpos(a0)
  2438.     clr.l    fl_bufpos(a0)
  2439.     moveq    #0,d0
  2440.     move.w    fl_initphase(a0),d0
  2441.     swap    d0
  2442.     move.l    d0,fl_sincpt(a0)
  2443.     move.l    fl_adrdest(a0),a1    ; a1 = adresse destination
  2444.  
  2445. ;--- Boucle de l'effet -------------------------------------------------------
  2446. ; Calcul de la position de lecture dans le buffer
  2447. fxfl_mainloop:
  2448.     move.l    fl_bufpos(a0),d0    ; d0 = position courante dans le buffer
  2449.     move.l    fl_sincpt(a0),d1    ; d1 = compteur de sinus
  2450.     move.l    d1,d2
  2451.     swap    d2        ; d2 = mot fort du compteur de sinus
  2452.     move.w    ([fl_adrsin,a0],d2.w*2),d1
  2453.     ext.l    d1
  2454.     muls.l    fl_amp(a0),d1
  2455.     asr.l    #8,d1
  2456.     asr.l    #4,d1        ; d1 = sin(wt) * amp
  2457.     add.l    d1,d0
  2458.     sub.l    fl_time(a0),d0
  2459.     bpl.s    .sinok1
  2460.     add.l    fl_lonbuf(a0),d0
  2461. .sinok1:    cmp.l    fl_lonbuf(a0),d0
  2462.     blt.s    .sinok2
  2463.     sub.l    fl_lonbuf(a0),d0
  2464. .sinok2:    bclr    #0,d0        ; d0 = position dans le buffer, lecture
  2465.  
  2466. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2467. ; Mixage Wet (sortie buffer) + Dry à gauche
  2468.     move.l    fl_destcpt(a0),d7    ; d7 = compteur de destination
  2469.  
  2470. .destleft:
  2471.     btst    #0,fl_flags+1(a0)        ; Destination = left ?
  2472.     beq    .destrigh
  2473.     move.w    ([fl_adrlbuf,a0],d0.l),d1    ; d1 = sortie du buffer
  2474.     swap    d1
  2475.     muls.l    fl_wetl(a0),d2:d1
  2476.     ext.l    d2            ; d2 = Wet
  2477.     clr.w    fl_inl(a0)
  2478.     move.l    fl_lsplpos(a0),d1
  2479.     bmi.s    .lsplfini        ; Si pos<0, le sample source left était fini
  2480.     cmp.w    #2,fl_resoll(a0)
  2481.     bne.s    .8dl
  2482. .16dl:    move.w    ([fl_adrlspl,a0],d1.l),d3    ; Source 16 bits
  2483.     addq.l    #2,d1            ; Incrémente la position
  2484.     bra.s    .816dlfin
  2485. .8dl:    move.b    ([fl_adrlspl,a0],d1.l),d3    ; source 8 bits
  2486.     asl.w    #8,d3
  2487.     addq.l    #1,d1            ; Incrémente la position
  2488. .816dlfin:    move.w    d3,fl_inl(a0)        ; Sauve le sample 'in'
  2489.     swap    d3
  2490.     muls.l    fl_dryl(a0),d4:d3
  2491.     ext.l    d4            ; d4 = Dry L
  2492.     add.l    d4,d2            ; d2 = Dry + Wet
  2493.     cmp.l    fl_lonlspl(a0),d1
  2494.     blt.s    .lsplend
  2495.     moveq    #-1,d1
  2496. .lsplend:    move.l    d1,fl_lsplpos(a0)
  2497. .lsplfini:    cmp.w    #2,fl_resold(a0)
  2498.     bne.s    .8ldest
  2499.     move.l    d2,d3
  2500.     cmp.l    #MAX_SWORD,d3
  2501.     ble.s    .lsplok1
  2502.     move.w    #MAX_SWORD,d3
  2503. .lsplok1:    cmp.l    #MIN_SWORD,d3
  2504.     bge.s    .lsplok2
  2505.     move.w    #MIN_SWORD,d3
  2506. .lsplok2:    move.w    d3,(a1)+
  2507.     subq.l    #2,d7
  2508.     bra.s    .destrigh
  2509. .8ldest:    move.l    d2,d3
  2510.     asr.l    #8,d3
  2511.     cmp.w    #MAX_SBYTE,d3
  2512.     ble.s    .lsplok3
  2513.     moveq    #MAX_SBYTE,d3
  2514. .lsplok3:    cmp.w    #MIN_SBYTE,d3
  2515.     bge.s    .lsplok4
  2516.     moveq    #MIN_SBYTE,d3
  2517. .lsplok4:    move.b    d3,(a1)+
  2518.     subq.l    #1,d7
  2519.  
  2520. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2521. ; Mixage Wet (sortie buffer) + Dry à droite
  2522. .destrigh:
  2523.     btst    #1,fl_flags+1(a0)        ; Destination = right ?
  2524.     beq    .findest
  2525.     move.w    ([fl_adrrbuf,a0],d0.l),d1    ; d1 = sortie du buffer
  2526.     swap    d1
  2527.     muls.l    fl_wetr(a0),d6:d1
  2528.     ext.l    d6            ; d6 = Wet
  2529.     clr.w    fl_inr(a0)
  2530.     move.l    fl_rsplpos(a0),d1
  2531.     bmi.s    .rsplfini        ; Si pos<0, le sample source left était fini
  2532.     cmp.w    #2,fl_resolr(a0)
  2533.     bne.s    .8dr
  2534. .16dr:    move.w    ([fl_adrrspl,a0],d1.l),d5    ; Source 16 bits
  2535.     addq.l    #2,d1            ; Incrémente la position
  2536.     bra.s    .816drfin
  2537. .8dr:    move.b    ([fl_adrrspl,a0],d1.l),d5    ; source 8 bits
  2538.     asl.w    #8,d5
  2539.     addq.l    #1,d1            ; Incrémente la position
  2540. .816drfin:    move.w    d5,fl_inr(a0)        ; Sauve le sample 'in'
  2541.     swap    d5
  2542.     muls.l    fl_dryr(a0),d3:d5
  2543.     ext.l    d3            ; d3 = Dry R
  2544.     add.l    d3,d6            ; d6 = Dry + Wet
  2545.     cmp.l    fl_lonrspl(a0),d1
  2546.     blt.s    .rsplend
  2547.     moveq    #-4,d1
  2548. .rsplend:    move.l    d1,fl_rsplpos(a0)
  2549. .rsplfini:    move.l    d6,d5
  2550.     btst    #2,fl_flags+1(a0)        ; Mixage G-D ?
  2551.     beq.s    .rnomix
  2552.     add.l    d2,d5
  2553.     subq.l    #1,a1
  2554.     addq.l    #1,d7
  2555.     cmp.w    #2,fl_resold(a0)
  2556.     bne.s    .8rdest
  2557.     subq.l    #1,a1
  2558.     addq.l    #1,d7
  2559.     bra.s    .16rdest
  2560. .rnomix:    cmp.w    #2,fl_resold(a0)
  2561.     bne.s    .8rdest
  2562. .16rdest:    cmp.l    #MAX_SWORD,d5
  2563.     ble.s    .rsplok1
  2564.     move.w    #MAX_SWORD,d5
  2565. .rsplok1:    cmp.l    #MIN_SWORD,d5
  2566.     bge.s    .rsplok2
  2567.     move.w    #MIN_SWORD,d5
  2568. .rsplok2:    move.w    d5,(a1)+
  2569.     subq.l    #2,d7
  2570.     bra.s    .findest
  2571. .8rdest:    asr.l    #8,d5
  2572.     cmp.w    #MAX_SBYTE,d5
  2573.     ble.s    .rsplok3
  2574.     moveq    #MAX_SBYTE,d5
  2575. .rsplok3:    cmp.w    #MIN_SBYTE,d5
  2576.     bge.s    .rsplok4
  2577.     moveq    #MIN_SBYTE,d5
  2578. .rsplok4:    move.b    d5,(a1)+
  2579.     subq.l    #1,d7
  2580. .findest:                ; d0 = pos buf lect, d7 = cpt
  2581.  
  2582. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2583. ; Test de sortie
  2584.     move.l    d7,fl_destcpt(a0)
  2585.     bmi    fxfl_fin
  2586.     
  2587. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2588. ; Arrêt momentané pour affichage de la progression
  2589.     moveq    #0,d1
  2590.     move.w    fl_resold(a0),d1
  2591.     sub.l    d1,progression_cpt
  2592.     bgt.s    fxfl_feedback
  2593.     move.l    progression_step(pc),d1
  2594.     move.l    d1,progression_cpt
  2595.     add.l    d1,progression_pos
  2596.     movem.l    d0-d7/a0-a6,progression_savedreg
  2597.     bra    fxfl_break
  2598.  
  2599. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2600. ; Reprise après affichage de la progression
  2601. fxfl_reprise:
  2602.     movem.l    progression_savedreg,d0-d7/a0-a6
  2603.  
  2604. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2605. ; Feedback
  2606. fxfl_feedback:
  2607.     move.w    ([fl_adrlbuf,a0],d0.l),d1    ; d1 = sortie du buffer L
  2608.     swap    d1
  2609.     move.l    d1,d2
  2610.     muls.l    fl_fdbkll(a0),d3:d1
  2611.     ext.l    d3            ; d3 = feedback L->L
  2612.     muls.l    fl_fdbklr(a0),d4:d2
  2613.     ext.l    d4            ; d4 = feedback L->R
  2614.     move.w    ([fl_adrrbuf,a0],d0.l),d1    ; d1 = sortie du buffer L
  2615.     swap    d1
  2616.     move.l    d1,d2
  2617.     muls.l    fl_fdbkrl(a0),d5:d1
  2618.     ext.l    d5            ; d5 = feedback R->L
  2619.     muls.l    fl_fdbkrr(a0),d6:d2
  2620.     ext.l    d6            ; d6 = feedback R->R
  2621.  
  2622.     move.l    fl_bufpos(a0),d0    ; d0 = position dans le buffer en écriture
  2623.     move.w    fl_inl(a0),d1    ; Mixage entrée du buffer L
  2624.     ext.l    d1
  2625.     add.l    d3,d1
  2626.     add.l    d5,d1
  2627.     cmp.l    #MAX_SWORD,d1
  2628.     ble.s    .mixlok1
  2629.     move.w    #MAX_SWORD,d1
  2630. .mixlok1:    cmp.l    #MIN_SWORD,d1
  2631.     bge.s    .mixlok2
  2632.     move.w    #MIN_SWORD,d1
  2633. .mixlok2:    move.w    d1,([fl_adrlbuf,a0],d0.l)
  2634.     move.w    fl_inr(a0),d1    ; Mixage entrée du buffer R
  2635.     ext.l    d1
  2636.     add.l    d4,d1
  2637.     add.l    d6,d1
  2638.     cmp.l    #MAX_SWORD,d1
  2639.     ble.s    .mixrok1
  2640.     move.w    #MAX_SWORD,d1
  2641. .mixrok1:    cmp.l    #MIN_SWORD,d1
  2642.     bge.s    .mixrok2
  2643.     move.w    #MIN_SWORD,d1
  2644. .mixrok2:    move.w    d1,([fl_adrrbuf,a0],d0.l)
  2645.  
  2646. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2647. ; Avance le buffer
  2648.     addq.l    #2,d0        ; Nouvelle position d'écriture dans
  2649.     cmp.l    fl_lonbuf(a0),d0    ; le buffer
  2650.     blt.s    .nbufok
  2651.     moveq    #0,d0
  2652. .nbufok:    move.l    d0,fl_bufpos(a0)
  2653.     move.l    fl_sincpt(a0),d0
  2654.     add.l    fl_freq(a0),d0
  2655.     and.l    #$FFFffff,d0
  2656.     move.l    d0,fl_sincpt(a0)
  2657.     bra    fxfl_mainloop
  2658.  
  2659. fxfl_fin:
  2660.     move.l    progression_len(pc),progression_pos    ; Signale que tout est fini
  2661. fxfl_break:
  2662.     movem.l    (sp)+,d0-a6
  2663.     rts
  2664.  
  2665.  
  2666.  
  2667. *============================================================================*
  2668. *    BMOVE rapide                    *
  2669. *    a0 = adresse source                    *
  2670. *    a1 = adresse destination                *
  2671. *    d0 = longueur.l du bloc à déplacer, en octets        *
  2672. *============================================================================*
  2673. quick_bmove:
  2674.     movem.l    d0-d1/a0-a1,-(sp)
  2675.     tst.l    d0
  2676.     ble    .fin
  2677.     cmp.l    a0,a1
  2678.     bgt    .inverse
  2679.     beq    .fin
  2680.  
  2681. ;--- Transfert dans le sens normal -------------------------------------------
  2682.     move.l    d0,d1
  2683.     lsr.l    #8,d0
  2684.     and.w    #255,d1
  2685.     subq.w    #1,d1
  2686.     bmi.s    .bloc256n
  2687. .loopn1:    move.b    (a0)+,(a1)+
  2688.     dbra    d1,.loopn1
  2689. .bloc256n:    subq.l    #1,d0
  2690.     bmi    .fin
  2691.     swap    d0
  2692. .loopn2:    swap    d0
  2693. .loopn3:
  2694.     Rept    64
  2695.     move.l    (a0)+,(a1)+
  2696.     EndR
  2697.     dbra    d0,.loopn3
  2698.     swap    d0
  2699.     dbra    d0,.loopn2
  2700.     bra    .fin
  2701.  
  2702. ;--- Transfert dans le sens inverse ------------------------------------------
  2703. .inverse:
  2704.     add.l    d0,a0
  2705.     add.l    d0,a1
  2706.     move.l    d0,d1
  2707.     lsr.l    #8,d0
  2708.     and.w    #255,d1
  2709.     subq.w    #1,d1
  2710.     bmi.s    .bloc256i
  2711. .loopi1:    move.b    -(a0),-(a1)
  2712.     dbra    d1,.loopi1
  2713. .bloc256i:    subq.l    #1,d0
  2714.     bmi    .fin
  2715.     swap    d0
  2716. .loopi2:    swap    d0
  2717. .loopi3:
  2718.     Rept    64
  2719.     move.l    -(a0),-(a1)
  2720.     EndR
  2721.     dbra    d0,.loopi3
  2722.     swap    d0
  2723.     dbra    d0,.loopi2
  2724.  
  2725. .fin:    movem.l    (sp)+,d0-d1/a0-a1
  2726.     rts
  2727.  
  2728.  
  2729.  
  2730. *============================================================================*
  2731. *    Conversion d'un sample absolu (normal) en sample delta-packé    *
  2732. *    a0 = adresse du sample                *
  2733. *    d0 = longueur.l en octets                *
  2734. *    d1 = taille.w d'un sample (0 ou 1)            *
  2735. *============================================================================*
  2736. absolu_2_delta:
  2737.     movem.l    d0-d2/a0,-(sp)
  2738.     tst.l    d0
  2739.     beq.s    .fin
  2740.     moveq    #0,d2
  2741.     cmp.w    #2,d1
  2742.     beq.s    .16bits
  2743.  
  2744. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2745. .8bits:    subq.l    #1,d0
  2746.     swap    d0
  2747. .8loop2:    swap    d0
  2748. .8loop1:    move.b    (a0),d1
  2749.     sub.b    d2,(a0)+
  2750.     move.b    d1,d2
  2751.     dbra    d0,.8loop1
  2752.     swap    d0
  2753.     dbra    d0,.8loop2
  2754.     bra.s    .fin
  2755.  
  2756. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2757. .16bits:    lsr.l    #1,d0
  2758.     subq.l    #1,d0
  2759.     swap    d0
  2760. .16loop2:    swap    d0
  2761. .16loop1:    move.w    (a0),d1
  2762.     add.w    d2,(a0)+
  2763.     move.w    d1,d2
  2764.     dbra    d0,.16loop1
  2765.     swap    d0
  2766.     dbra    d0,.16loop2
  2767.  
  2768. .fin:    movem.l    (sp)+,d0-d2/a0
  2769.     rts
  2770.  
  2771.  
  2772.  
  2773. *============================================================================*
  2774. *    Conversion d'un sample delta-packé en sample absolu (normal)    *
  2775. *    a0 = adresse du sample                *
  2776. *    d0 = longueur.l en octets                *
  2777. *    d1 = taille.w d'un sample (0 ou 1)            *
  2778. *============================================================================*
  2779. delta_2_absolu:
  2780.     movem.l    d0-d2/a0,-(sp)
  2781.     tst.l    d0
  2782.     beq.s    .fin
  2783.     moveq    #0,d2
  2784.     cmp.w    #2,d1
  2785.     beq.s    .16bits
  2786.  
  2787. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2788. .8bits:    subq.l    #1,d0
  2789.     swap    d0
  2790. .8loop2:    swap    d0
  2791. .8loop1:    add.b    d2,(a0)
  2792.     move.b    (a0)+,d2
  2793.     dbra    d0,.8loop1
  2794.     swap    d0
  2795.     dbra    d0,.8loop2
  2796.     bra.s    .fin
  2797.  
  2798. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2799. .16bits:    lsr.l    #1,d0
  2800.     subq.l    #1,d0
  2801.     swap    d0
  2802. .16loop2:    swap    d0
  2803. .16loop1:    add.w    d2,(a0)
  2804.     move.w    (a0)+,d2
  2805.     dbra    d0,.16loop1
  2806.     swap    d0
  2807.     dbra    d0,.16loop2
  2808.  
  2809. .fin:    movem.l    (sp)+,d0-d2/a0
  2810.     rts
  2811.  
  2812.  
  2813.  
  2814. *============================================================================*
  2815. *    Convertit un pattern FT2 en GTK                *
  2816. *    a0 = adresse du pattern FT2                *
  2817. *    a1 = adresse du pattern GTK                *
  2818. *    d0 = nombre.w de voies                *
  2819. *    d1 = nombre.w de lignes                *
  2820. *============================================================================*
  2821. convert_ft2_2_gtk:
  2822.     movem.l    d0-a6,-(sp)
  2823.     mulu.w    d1,d0
  2824.     subq.w    #1,d0        ; d0 = compteur de notes
  2825.  
  2826. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2827. .noteloop:
  2828.     clr.l    (a1)        ; Graoumf note vide
  2829.     clr.b    4(a1)
  2830.     moveq    #%11111,d1        ; d1 = y a quoi dedans ?
  2831.     btst    #7,(a0)        ; par défaut, y a tout (note non packée)
  2832.     beq.s    .note
  2833.     move.b    (a0)+,d1        ; Bit 7 mis, la note est packée
  2834.  
  2835. .note:
  2836.     btst    #0,d1
  2837.     beq.s    .instrument
  2838.     move.b    (a0)+,d3
  2839.     cmp.b    #97,d3        ; ??? Effet de Note Cut ???
  2840.     bne.s    .notetest
  2841.     move.w    #$0A00,2(a1)
  2842.     bra.s    .instrument
  2843. .notetest:    cmp.b    #25,d3        ; Si on tombe en dessous de C-0, (+1)
  2844.     bge.s    .noteok
  2845.     add.b    #12,d3        ; on remonte d'une octave
  2846.     bra.s    .notetest
  2847. .noteok:    subq.b    #1,d3
  2848.     move.b    d3,(a1)
  2849.  
  2850. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2851. .instrument:
  2852.     btst    #1,d1
  2853.     beq.s    .volume
  2854.     move.b    (a0)+,1(a1)
  2855.  
  2856. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2857. .volume:
  2858.     moveq    #0,d2        ; d2 = effet (rien pour l'instant)
  2859.     btst    #2,d1
  2860.     beq    .effettype
  2861.     moveq    #0,d3
  2862.     move.b    (a0)+,d3
  2863.     cmp.w    #$10,d3
  2864.     blt    .effettype
  2865.     cmp.w    #$50,d3
  2866.     bgt.s    .vols1
  2867. .volok:    sub.b    #$10,d3        ; $10 - $50 : Volume
  2868.     lsl.w    #2,d3
  2869.     cmp.w    #$100,d3
  2870.     beq.s    .volmax
  2871.     tst.w    d3
  2872.     beq.s    .volnul
  2873.     move.b    d3,4(a1)
  2874.     bra    .effettype
  2875. .volnul:    move.w    #$2000,d2
  2876.     move.b    #1,4(a1)
  2877.     bra    .effettype
  2878. .volmax:    move.w    #$2100,d2
  2879.     move.b    #255,4(a1)
  2880.     bra    .effettype
  2881. .vols1:    cmp.w    #$60,d3
  2882.     blt    .effettype
  2883.     cmp.w    #$70,d3        ; $60 - $6f : Vol slide down
  2884.     bge.s    .volslup
  2885.     and.b    #15,d3
  2886.     lsl.b    #4,d3
  2887.     move.w    #$1500,d2
  2888.     move.b    d3,d2
  2889.     bra    .effettype
  2890. .volslup:    cmp.w    #$80,d3        ; $70 - $7f : Vol slide up
  2891.     bge.s    .fvolsldw
  2892.     and.b    #15,d3
  2893.     lsl.b    #4,d3
  2894.     move.w    #$1400,d2
  2895.     move.b    d3,d2
  2896.     bra    .effettype
  2897. .fvolsldw:    cmp.w    #$90,d3        ; $80 - $8f : Fine vol slide down
  2898.     bge.s    .fvolslup
  2899.     and.b    #15,d3
  2900.     lsl.b    #4,d3
  2901.     move.w    #$A500,d2
  2902.     move.b    d3,d2
  2903.     bra    .effettype
  2904. .fvolslup:    cmp.w    #$A0,d3        ; $90 - $9f : Fine vol slide up
  2905.     bge.s    .vibspd
  2906.     and.b    #15,d3
  2907.     lsl.b    #4,d3
  2908.     move.w    #$A400,d2
  2909.     move.b    d3,d2
  2910.     bra.s    .effettype
  2911. .vibspd:    cmp.w    #$b0,d3        ; $a0 - $af : Set vibrato speed
  2912.     bge.s    .vibrato
  2913.     and.b    #15,d3
  2914.     lsl.b    #4,d3
  2915.     move.w    #$400,d2
  2916.     move.b    d3,d2
  2917.     bra.s    .effettype
  2918. .vibrato:    cmp.w    #$c0,d3        ; $b0 - $bf : Vibrato
  2919.     bge.s    .setpan
  2920.     and.b    #15,d3
  2921.     move.w    #$400,d2
  2922.     move.b    d3,d2
  2923.     bra.s    .effettype
  2924. .setpan:    cmp.w    #$d0,d3        ; $c0 - $cf : Set panning
  2925.     bge.s    .pansllft
  2926.     and.b    #15,d3
  2927.     lsl.w    #8,d3
  2928.     add.w    #$4000,d3
  2929.     move.w    d3,d2
  2930.     bra.s    .effettype
  2931. .pansllft:    cmp.w    #$e0,d3        ; $d0 - $df : Panning slide left
  2932.     bge.s    .panslrig
  2933.     and.b    #15,d3
  2934.     lsl.b    #4,d3
  2935.     move.w    #$AE00,d2
  2936.     move.b    d3,d2
  2937.     bra.s    .effettype
  2938. .panslrig:    cmp.w    #$f0,d3        ; $e0 - $ef : Panning slide right
  2939.     bge.s    .toneport
  2940.     and.b    #15,d3
  2941.     lsl.b    #4,d3
  2942.     move.w    #$AF00,d2
  2943.     move.b    d3,d2
  2944.     bra.s    .effettype
  2945. .toneport:    and.b    #15,d3        ; $f0 - $ff : Tone portamento
  2946.     move.w    #$300,d2
  2947.     move.b    d3,d2
  2948.  
  2949. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  2950. .effettype:
  2951.     moveq    #0,d3
  2952.     btst    #3,d1
  2953.     beq.s    .effetparam
  2954.     move.b    (a0)+,d3        ; d3 = numéro d'effet
  2955.  
  2956. .effetparam:
  2957.     moveq    #0,d4
  2958.     btst    #4,d1
  2959.     beq.s    .fxconv
  2960.     move.b    (a0)+,d4        ; d4 = paramètre de l'effet
  2961.  
  2962. .fxconv:
  2963.     bsr    convert_xmfx_2_gtkfx
  2964.     move.w    d2,2(a1)
  2965.     addq.l    #5,a1
  2966.     dbra    d0,.noteloop
  2967.  
  2968.     movem.l    (sp)+,d0-a6
  2969.     rts
  2970.  
  2971.  
  2972.  
  2973. *============================================================================*
  2974. *    Converti un effet Fast Tracker 2 en un effet Graoumf Tracker    *
  2975. *    d2 = Note.l au format Graoumf (sans effet)            *
  2976. *    d3 = effet.b protracker (0-F)                *
  2977. *    d4 = paramètre.w protracker (0-FF)            *
  2978. *    Attention, ces registres ne sont pas sauvés            *
  2979. *    Au retour :                    *
  2980. *    d2 = Note + Effet                    *
  2981. *============================================================================*
  2982. convert_xmfx_2_gtkfx:
  2983.     cmp.b    #1,d3        ; Les effets qui ne changent pas
  2984.     beq.s    .nochange
  2985.     cmp.b    #2,d3
  2986.     beq.s    .nochange
  2987.     cmp.b    #3,d3
  2988.     beq.s    .nochange
  2989.     cmp.b    #4,d3
  2990.     beq.s    .nochange
  2991.     cmp.b    #7,d3
  2992.     beq.s    .nochange
  2993.     cmp.b    #$B,d3
  2994.     bne.s    .suite
  2995. .nochange:    move.w    d4,d2
  2996.     lsl.w    #8,d3
  2997.     add.w    d3,d2
  2998.     and.w    #$fff,d2
  2999.     bra    .fin
  3000.  
  3001. .suite:    tst.b    d3        ; Arpeggio
  3002.     bne.s    .5
  3003.     tst.b    d4
  3004.     beq    .fin
  3005.     add.w    #$1000,d4
  3006.     move.w    d4,d2
  3007.     bra    .fin
  3008.  
  3009. .5:    cmp.b    #5,d3        ; Vol slide + porta
  3010.     bne.s    .6
  3011.     move.w    d4,d3
  3012.     and.w    #$f,d3
  3013.     lsr.w    #4,d4
  3014.     sub.w    d3,d4
  3015.     add.w    d4,d4
  3016.     add.w    d4,d4
  3017.     bmi.s    .5neg
  3018.     add.w    #$1800,d4
  3019.     move.w    d4,d2
  3020.     bra    .fin
  3021. .5neg:    move.w    #$1900,d2
  3022.     sub.w    d4,d2
  3023.     bra    .fin
  3024.  
  3025. .6:    cmp.b    #6,d3        ; Vol slide + vib
  3026.     bne.s    .8
  3027.     move.w    d4,d3
  3028.     and.w    #$f,d3
  3029.     lsr.w    #4,d4
  3030.     sub.w    d3,d4
  3031.     add.w    d4,d4
  3032.     add.w    d4,d4
  3033.     bmi.s    .6neg
  3034.     add.w    #$1c00,d4
  3035.     move.w    d4,d2
  3036.     bra    .fin
  3037. .6neg:    move.w    #$1d00,d2
  3038.     sub.w    d4,d2
  3039.     bra    .fin
  3040.  
  3041. .8:    cmp.b    #8,d3        ; Set balance
  3042.     bne.s    .9
  3043.     add.w    #$400,d4
  3044.     lsl.w    #4,d4
  3045.     move.w    d4,d2
  3046.     bra    .fin
  3047.  
  3048. .9:    cmp.b    #9,d3        ; Play part of sample
  3049.     bne.s    .a
  3050.     add.w    #$9000,d4
  3051.     move.w    d4,d2
  3052.     bra    .fin
  3053.  
  3054. .a:    cmp.b    #10,d3        ; Vol slide
  3055.     bne.s    .c
  3056.     move.w    d4,d3
  3057.     and.w    #$f,d3
  3058.     lsr.w    #4,d4
  3059.     sub.w    d3,d4
  3060.     add.w    d4,d4
  3061.     add.w    d4,d4
  3062.     bmi.s    .aneg
  3063.     add.w    #$1400,d4
  3064.     move.w    d4,d2
  3065.     bra    .fin
  3066. .aneg:    move.w    #$1500,d2
  3067.     sub.w    d4,d2
  3068.     bra    .fin
  3069.  
  3070. .c:    cmp.b    #$c,d3        ; Set volume
  3071.     bne.s    .d
  3072.     add.w    d4,d4
  3073.     add.w    d4,d4
  3074.     add.w    #$2000,d4
  3075.     move.w    d4,d2
  3076.     bra    .fin
  3077.  
  3078. .d:    cmp.b    #$d,d3        ; Break pattern to line
  3079.     bne.s    .e
  3080.     move.w    d4,d3        ; Conversion BCD -> Hexa
  3081.     lsr.w    #4,d4
  3082.     mulu.w    #10,d4
  3083.     and.b    #$f,d3
  3084.     add.b    d3,d4
  3085.     move.w    #$D00,d2
  3086.     move.b    d4,d2
  3087.     bra    .fin
  3088.  
  3089. .e:    cmp.b    #14,d3        ; Effets étendus
  3090.     bne    .f
  3091.     move.w    d4,d3
  3092.     lsr.b    #4,d3
  3093.     and.b    #$f,d4
  3094. .e1:    cmp.b    #1,d3        ; Fine porta up
  3095.     bne.s    .e2
  3096.     add.w    #$1100,d4
  3097.     move.w    d4,d2
  3098.     bra    .fin
  3099.  
  3100. .e2:    cmp.b    #2,d3        ; Fine porta down
  3101.     bne.s    .e4
  3102.     add.w    #$1200,d4
  3103.     move.w    d4,d2
  3104.     bra    .fin
  3105.  
  3106. .e4:    cmp.b    #4,d3        ; Set vib wave
  3107.     bne.s    .e5
  3108.     add.w    #$c00,d4
  3109.     move.w    d4,d2
  3110.     bra    .fin
  3111.  
  3112. .e5:    cmp.b    #5,d3        ; Set finetune
  3113.     bne.s    .e6
  3114.     cmp.b    #7,d4
  3115.     bgt.s    .e5neg
  3116.     lsl.b    #4,d4
  3117.     add.w    #$800,d4
  3118.     move.w    d4,d2
  3119.     bra    .fin
  3120. .e5neg:    move.w    #$810,d2
  3121.     sub.w    d4,d2
  3122.     bra    .fin
  3123.  
  3124. .e6:    cmp.b    #6,d3        ; Pattern loop
  3125.     bne.s    .e7
  3126.     add.w    #$b100,d4
  3127.     move.w    d4,d2
  3128.     bra    .fin
  3129.  
  3130. .e7:    cmp.b    #7,d3        ; Set trem wave
  3131.     bne.s    .e8
  3132.     add.w    #$e00,d4
  3133.     move.w    d4,d2
  3134.     bra    .fin
  3135.  
  3136. .e8:    cmp.b    #8,d3        ; Set balance (2)
  3137.     bne.s    .e9
  3138.     lsl.w    #8,d4
  3139.     add.w    #$4000,d4
  3140.     move.w    d4,d2
  3141.     bra    .fin
  3142.  
  3143. .e9:    cmp.b    #9,d3        ; Retrig sample
  3144.     bne.s    .e10
  3145.     lsl.w    #8,d4
  3146.     add.w    #$7000,d4
  3147.     move.w    d4,d2
  3148.     bra    .fin
  3149.  
  3150. .e10:    cmp.b    #10,d3        ; Fine vol up
  3151.     bne.s    .e11
  3152.     move.w    #$a400,d2
  3153.     add.b    d4,d4
  3154.     add.b    d4,d4
  3155.     add.b    d4,d2
  3156.     bra    .fin
  3157.  
  3158. .e11:    cmp.b    #11,d3        ; Fine vol down
  3159.     bne.s    .e12
  3160.     move.w    #$a500,d2
  3161.     add.b    d4,d4
  3162.     add.b    d4,d4
  3163.     add.b    d4,d2
  3164.     bra    .fin
  3165.  
  3166. .e12:    cmp.b    #12,d3        ; Note cut
  3167.     bne.s    .e13
  3168.     add.w    #$a00,d4
  3169.     move.w    d4,d2
  3170.     bra    .fin
  3171.  
  3172. .e13:    cmp.b    #13,d3        ; Note delay
  3173.     bne.s    .ee
  3174.     add.w    #$900,d4
  3175.     move.w    d4,d2
  3176.     bra    .fin
  3177.  
  3178. .ee:    cmp.b    #$e,d3        ; Pattern delay
  3179.     bne    .fin
  3180.     add.w    #$aa00,d4
  3181.     move.w    d4,d2
  3182.     bra    .fin
  3183.  
  3184. .f:    cmp.b    #15,d3        ; Tempo
  3185.     bne.s    .k
  3186.     move.w    #$0F00,d2
  3187.     cmp.w    #$20,d4
  3188.     bge.s    .f_ok
  3189.     move.w    #$A800,d2
  3190. .f_ok:    move.b    d4,d2
  3191.     bra.s    .fin
  3192.  
  3193. .k:    cmp.b    #$14,d3        ; Key off
  3194.     bne.s    .p
  3195.     move.w    #$0A00,d2
  3196.     bra.s    .fin
  3197.  
  3198. .p:    cmp.b    #$19,d3        ; Panning slide
  3199.     bne.s    .r
  3200.     move.b    d4,d3
  3201.     lsr.b    #4,d3
  3202.     and.b    #15,d4
  3203.     sub.w    d3,d4
  3204.     bmi.s    .pneg
  3205.     move.w    #$AF00,d2
  3206.     move.b    d4,d2
  3207.     bra.s    .fin
  3208. .pneg:    move.w    #$AE00,d2
  3209.     sub.b    d4,d2
  3210.     bra.s    .fin
  3211.  
  3212. .r:    cmp.b    #$1b,d3        ; Multi retrig note
  3213.     bne.s    .t
  3214.     move.w    #$1300,d2        ; ??? Comme dans les S3M ???
  3215.     move.b    d4,d2
  3216.     bra.s    .fin
  3217.  
  3218. .t:    cmp.b    #$1d,d3        ; Tremor
  3219.     bne.s    .x
  3220.     move.w    #$B000,d2
  3221.     move.b    d4,d2
  3222.     bra.s    .fin
  3223.  
  3224. .x:    cmp.b    #$21,d3        ; Effets étendus II le retour
  3225.     bne.s    .fin
  3226.     move.b    d4,d3
  3227.     lsr.b    #4,d3
  3228.     and.b    #15,d4
  3229. .x1:    cmp.b    #$1,d3        ; Extra fine porta up
  3230.     bne.s    .x2
  3231.     move.w    #$AC00,d2
  3232.     lsl.b    #2,d3        ; 4x + précis pour FT2 comme pour ST3 ?
  3233.     move.b    d3,d2
  3234.     bra.s    .fin
  3235.  
  3236. .x2:    cmp.b    #$2,d3        ; Extra fine porta up
  3237.     bne.s    .fin
  3238.     move.w    #$AD00,d2
  3239.     lsl.b    #2,d3        ; 4x + précis pour FT2 comme pour ST3 ?
  3240.     move.b    d3,d2
  3241.  
  3242. .fin:    rts
  3243.  
  3244.  
  3245.  
  3246. *============================================================================*
  3247. *    Convertit un pattern GTK en S3M                *
  3248. *    a0 = adresse du pattern GTK                *
  3249. *    a1 = adresse du pattern S3M (pointe sur la longueur)        *
  3250. *    d0 = nombre.w de voies                *
  3251. *    d1 = nombre.w de lignes                *
  3252. *============================================================================*
  3253. convert_gtk_2_s3m:
  3254.     movem.l    d0-a6,-(sp)
  3255.     lea    2(a1),a2        ; a2 pointe sur les données compressées
  3256.     moveq    #63,d2        ; d2 = compteur de ligne
  3257.  
  3258. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3259. .lineloop:
  3260.     moveq    #0,d3        ; d3 = numéro de la voie courante
  3261.     move.w    d0,d4
  3262. .trkloop:
  3263.     tst.l    (a0)        ; Voie vide ?
  3264.     bne.s    .note
  3265.     tst.b    4(a0)
  3266.     beq    .nexttrack
  3267.  
  3268. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3269. .note:
  3270.     move.l    a2,a3        ; Sauve a2 dans a3
  3271.     clr.b    (a2)+
  3272.     move.b    d3,d4        ; d4 = byte d'info
  3273.     tst.w    (a0)        ; Note ou instr ?
  3274.     beq.s    .volume
  3275.     moveq    #0,d5
  3276.     move.b    (a0),d5        ; Convertion de la note
  3277.     bne.s    .cvnote
  3278.     move.b    #255,(a2)+        ; Si pas de note, 255
  3279.     bra.s    .cvinstr
  3280. .cvnote:    divu.w    #12,d5
  3281.     lsl.b    #4,d5
  3282.     move.b    d5,(a2)        ; L'octave
  3283.     swap    d5
  3284.     add.b    d5,(a2)+        ; Ajoute la note
  3285. .cvinstr:    move.b    1(a0),(a2)+
  3286.     or.b    #32,d4
  3287.  
  3288. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3289. .volume:
  3290.     move.b    2(a0),d5
  3291.     and.b    #$f0,d5
  3292.     cmp.b    #$20,d5        ; Volume par la commande 2xxx ?
  3293.     bne.s    .volume2
  3294.     move.w    2(a0),d5
  3295.     lsr.w    #2,d5
  3296.     and.b    #$7f,d5
  3297.     bra.s    .volok
  3298.  
  3299. .volume2:
  3300.     moveq    #0,d5
  3301.     move.b    4(a0),d5        ; Volume sur la colonne ?
  3302.     beq.s    .effet
  3303.     addq.w    #1,d5
  3304.     lsr.w    #2,d5
  3305. .volok:    move.b    d5,(a2)+
  3306.     or.b    #64,d4
  3307.  
  3308. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3309. .effet:
  3310.     tst.w    2(a0)
  3311.     beq    .fintrack
  3312.     move.w    2(a0),d5        ; d5 = commande + paramètre
  3313.     move.b    2(a0),d6        ; d6 = commande
  3314.     moveq    #0,d7
  3315.     move.b    d5,d7        ; d7 = paramètre
  3316.  
  3317. .01:    cmp.b    #$01,d6        ; Portamento up
  3318.     bne.s    .02
  3319.     add.w    #$600,d7
  3320.     bra    .fineffet
  3321. .02:    cmp.b    #$02,d6        ; Portamento down
  3322.     bne.s    .03
  3323.     add.w    #$500,d7
  3324.     bra    .fineffet
  3325. .03:    cmp.b    #$03,d6        ; Tone portamento
  3326.     beq.s    .03ok
  3327. .05:    cmp.b    #$05,d6        ; Tone portamento (+ vibrato)
  3328.     bne.s    .04
  3329. .03ok:    add.w    #$700,d7
  3330.     bra    .fineffet
  3331. .04:    cmp.b    #$04,d6        ; Vibrato
  3332.     beq.s    .04ok
  3333. .06:    cmp.b    #$06,d6        ; Vibrato (+ tone porta)
  3334.     bne.s    .07
  3335. .04ok:    add.w    #$800,d7
  3336.     bra    .fineffet
  3337. .07:    cmp.b    #$07,d6        ; Tremolo
  3338.     bne.s    .08
  3339.     add.w    #$1200,d7
  3340.     bra    .fineffet
  3341. .08:    cmp.b    #$08,d6        ; Detune
  3342.     bne.s    .09
  3343.     move.b    d7,d6
  3344.     lsr.b    #4,d7
  3345.     sub.b    d6,d7
  3346.     and.b    #15,d7
  3347.     add.w    #$1320,d7
  3348.     bra    .fineffet
  3349. .09:    cmp.b    #$09,d6        ; Note delay
  3350.     bne.s    .0A
  3351.     and.b    #15,d7
  3352.     add.w    #$13D0,d7
  3353.     bra    .fineffet
  3354. .0A:    cmp.b    #$0A,d6        ; Note cut
  3355.     bne.s    .0B
  3356.     and.b    #15,d7
  3357.     add.w    #$13C0,d7
  3358.     bra    .fineffet
  3359. .0B:    cmp.b    #$0B,d6        ; Jump to position
  3360.     bne.s    .0C
  3361.     add.w    #$200,d7
  3362.     bra    .fineffet
  3363. .0C:    cmp.b    #$0C,d6        ; Set vibrato waveform
  3364.     bne.s    .0D
  3365.     and.b    #15,d7
  3366.     add.w    #$1330,d7
  3367.     bra    .fineffet
  3368. .0D:    cmp.b    #$0D,d6        ; Break pattern
  3369.     bne.s    .0E
  3370.     move.l    d7,d5
  3371.     move.w    #$300,d7
  3372.     divu.w    #10,d5        ; Conversion Hexa -> BCD
  3373.     lsl.b    #4,d5
  3374.     add.b    d5,d7
  3375.     swap    d5
  3376.     move.b    d5,d7
  3377.     bra    .fineffet
  3378. .0E:    cmp.b    #$0E,d6        ; Set tremolo waveform
  3379.     bne.s    .0F
  3380.     add.w    #$1340,d7
  3381.     bra    .fineffet
  3382. .0F:    cmp.b    #$0F,d6        ; Set speed/tempo
  3383.     bne.s    .10
  3384.     cmp.w    #$20,d7
  3385.     blt.s    .0Fspeed
  3386.     add.w    #$1400-$100,d7
  3387. .0Fspeed:    add.w    #$100,d7
  3388.     bra    .fineffet
  3389. .10:    cmp.b    #$10,d6        ; Arpeggio
  3390.     bne.s    .11
  3391.     add.w    #$A00,d7
  3392.     bra    .fineffet
  3393. .11:    cmp.b    #$11,d6        ; Fine portamento up
  3394.     bne.s    .12
  3395.     and.b    #15,d7
  3396.     add.w    #$6F0,d7
  3397.     bra    .fineffet
  3398. .12:    cmp.b    #$12,d6        ; Fine portamento down
  3399.     bne.s    .13
  3400.     add.w    #$5F0,d7
  3401.     bra    .fineffet
  3402. .13:    cmp.b    #$13,d6        ; Roll + volume slide
  3403.     bne.s    .14
  3404.     add.w    #$1100,d7
  3405.     bra    .fineffet
  3406. .14:    cmp.b    #$14,d6        ; Linear volume slide up
  3407.     bne.s    .15
  3408.     lsl.b    #2,d7
  3409.     and.b    #$F0,d7
  3410.     add.w    #$400,d7
  3411.     bra    .fineffet
  3412. .15:    cmp.b    #$15,d6        ; Linear volume slide down
  3413.     bne.s    .18
  3414.     lsr.b    #2,d7
  3415.     and.b    #$F,d7
  3416.     add.w    #$400,d7
  3417.     bra    .fineffet
  3418. .18:    cmp.b    #$18,d6        ; Linear volume slide up + Tone portamento
  3419.     bne.s    .19
  3420.     lsl.b    #2,d7
  3421.     and.b    #$F0,d7
  3422.     add.w    #$C00,d7
  3423.     bra    .fineffet
  3424. .19:    cmp.b    #$19,d6        ; Linear volume slide down + Tone portamento
  3425.     bne.s    .1C
  3426.     lsr.b    #2,d7
  3427.     and.b    #$F,d7
  3428.     add.w    #$C00,d7
  3429.     bra    .fineffet
  3430. .1C:    cmp.b    #$1C,d6        ; Linear volume slide up + Vibrato
  3431.     bne.s    .1D
  3432.     lsl.b    #2,d7
  3433.     and.b    #$F0,d7
  3434.     add.w    #$B00,d7
  3435.     bra    .fineffet
  3436. .1D:    cmp.b    #$1D,d6        ; Linear volume slide down + Vibrato
  3437.     bne.s    .A4
  3438.     lsr.b    #2,d7
  3439.     and.b    #$F,d7
  3440.     add.w    #$B00,d7
  3441.     bra    .fineffet
  3442. .A4:    cmp.b    #$A4,d6        ; Fine linear volume slide up
  3443.     bne.s    .A5
  3444.     lsl.b    #2,d7
  3445.     and.b    #$F0,d7
  3446.     add.w    #$40F,d7
  3447.     bra    .fineffet
  3448. .A5:    cmp.b    #$A5,d6        ; Fine linear volume slide down
  3449.     bne.s    .A8
  3450.     lsr.b    #2,d7
  3451.     and.b    #$F,d7
  3452.     add.w    #$4F0,d7
  3453.     bra    .fineffet
  3454. .A8:    cmp.b    #$A8,d6        ; Set number of frames
  3455.     bne.s    .AA
  3456.     add.w    #$100,d7
  3457.     bra    .fineffet
  3458. .AA:    cmp.b    #$AA,d6        ; Pattern delay
  3459.     bne.s    .AB
  3460.     and.b    #15,d7
  3461.     add.w    #$13E0,d7
  3462.     bra    .fineffet
  3463. .AB:    cmp.b    #$AB,d6        ; Extra fine tone portamento
  3464.     bne.s    .AC
  3465.     lsr.b    #4,d7        ; Pas d'équivalent -> Tone p. normal
  3466.     add.w    #$700,d7
  3467.     bra    .fineffet
  3468. .AC:    cmp.b    #$AC,d6        ; Extra fine portamento up
  3469.     bne.s    .AD
  3470.     lsr.b    #2,d7
  3471.     and.b    #15,d7
  3472.     add.w    #$6E0,d7
  3473.     bra.s    .fineffet
  3474. .AD:    cmp.b    #$AD,d6        ; Extra fine portamento down
  3475.     bne.s    .B0
  3476.     lsr.b    #2,d7
  3477.     and.b    #15,d7
  3478.     add.w    #$5E0,d7
  3479.     bra.s    .fineffet
  3480. .B0:    cmp.b    #$B0,d6        ; Tremor
  3481.     bne.s    .B1
  3482.     add.w    #$900,d7
  3483.     bra.s    .fineffet
  3484. .B1:    cmp.b    #$B1,d6        ; Pattern loop
  3485.     bne.s    .1chiffre
  3486.     and.b    #15,d7
  3487.     add.w    #$13B0,d7
  3488.     bra.s    .fineffet
  3489.  
  3490. .1chiffre:    lsr.b    #4,d6        ; Les commandes qui ne prennent qu'un chiffre
  3491.     move.w    d5,d7
  3492.     and.w    #$fff,d7
  3493. .4:    cmp.b    #$4,d6        ; Set balance
  3494.     bne.s    .7
  3495.     lsr.w    #8,d7
  3496.     add.w    #$1380,d7
  3497.     bra.s    .fineffet
  3498. .7:    cmp.b    #$7,d6        ; Roll
  3499.     bne.s    .8
  3500.     lsr.w    #8,d7
  3501.     add.w    #$1100,d7
  3502.     bra.s    .fineffet
  3503. .8:    cmp.b    #$8,d6        ; Roll + volume slide (+ set balance)
  3504.     bne.s    .9
  3505.     and.w    #$ff,d7
  3506.     add.w    #$1100,d7
  3507.     bra.s    .fineffet
  3508. .9:    cmp.b    #$9,d6        ; Set sample offset
  3509.     bne.s    .paseffet        ; Sinon pas d'effet
  3510.     and.w    #$ff,d7
  3511.     add.w    #$F00,d7
  3512.     bra.s    .fineffet
  3513.  
  3514. .paseffet:    clr.w    d7
  3515. .fineffet:    move.w    d7,(a2)+
  3516.     or.b    #128,d4
  3517.  
  3518. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3519. .fintrack:
  3520.     move.b    d4,(a3)
  3521.  
  3522. .nexttrack:
  3523.     addq.l    #5,a0
  3524.     addq.w    #1,d3
  3525.     cmp.w    d0,d3
  3526.     blt    .trkloop
  3527.     clr.b    (a2)+
  3528.     dbra    d2,.lineloop
  3529.     sub.l    a1,a2        ; Longueur du pattern compressé
  3530.     move.w    a2,(a1)
  3531.     movem.l    (sp)+,d0-a6
  3532.     rts
  3533.  
  3534.  
  3535.  
  3536. *============================================================================*
  3537. *    Cherche le chunk suivant dans un module .DTM        *
  3538. *    a0 = adresse du début de la recherche            *
  3539. *    a1 = adresse de fin de la recherche            *
  3540. *    Renvoie l'adresse trouvée dans d0            *
  3541. *============================================================================*
  3542. dtm_next_chunk:
  3543.     movem.l    a0-a1,-(sp)
  3544. .loop:    move.l    (a0),d0
  3545.     cmp.l    #'S.Q.',d0
  3546.     beq.s    .fin
  3547.     cmp.l    #'PATT',d0
  3548.     beq.s    .fin
  3549.     cmp.l    #'INST',d0
  3550.     beq.s    .fin
  3551.     cmp.l    #'DAPT',d0
  3552.     beq.s    .fin
  3553.     cmp.l    #'DAIT',d0
  3554.     beq.s    .fin
  3555.     addq.l    #1,a0
  3556.     cmp.l    a1,a0
  3557.     blt.s    .loop
  3558. .fin:    move.l    a0,d0
  3559.     movem.l    (sp)+,a0-a1
  3560.     rts
  3561.  
  3562.  
  3563.  
  3564. *============================================================================*
  3565. *    Convertit un pattern Digital Tracker en pattern G.T.        *
  3566. *    a0 = Adresse du pattern DTM                *
  3567. *    a1 = Adresse du pattern GTK                *
  3568. *    d0 = Nombre.l de nores à convertir            *
  3569. *============================================================================*
  3570. convert_dtm_2_gtk:
  3571.     movem.l    d0-d4/a0-a1,-(sp)
  3572.  
  3573.     subq.l    #1,d0
  3574.     swap    d0
  3575. .loop1:    swap    d0
  3576. .loop2:
  3577. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3578.     moveq    #0,d2
  3579.     moveq    #0,d1
  3580.     move.b    (a0)+,d1
  3581.     beq.s    .pasnote
  3582.     move.b    d1,d2
  3583.     and.b    #15,d2
  3584.     subq.b    #1,d2
  3585.     lsr.b    #4,d1
  3586.     mulu.w    #12,d1
  3587.     add.b    d1,d2
  3588. .pasnote:    move.b    d2,(a1)        ; Note ok
  3589. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3590.     move.b    (a0),d1
  3591.     and.b    #$FC,d1
  3592.     move.b    d1,4(a1)        ; Volume ok
  3593.  
  3594. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3595.     move.w    (a0),d1
  3596.     lsr.w    #4,d1
  3597.     and.w    #63,d1
  3598.     move.b    d1,1(a1)        ; Instrument ok
  3599. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3600.     moveq    #0,d3
  3601.     moveq    #0,d4
  3602.     move.b    1(a0),d3
  3603.     and.b    #15,d3
  3604.     move.b    2(a0),d4
  3605.     moveq    #0,d2
  3606.     bsr    convert_dtmfx_2_gtkfx
  3607.     move.w    d2,2(a1)        ; Effet ok
  3608. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  3609.     addq.l    #3,a0
  3610.     addq.l    #5,a1
  3611.     dbra    d0,.loop2
  3612.     swap    d0
  3613.     dbra    d0,.loop1
  3614.  
  3615.     movem.l    (sp)+,d0-d4/a0-a1
  3616.     rts
  3617.  
  3618.  
  3619.  
  3620. *============================================================================*
  3621. *    Converti un effet Digital Tracker en un effet Graoumf Tracker    *
  3622. *    d2 = Note.l au format Graoumf (sans effet)            *
  3623. *    d3 = effet.b protracker (0-F)                *
  3624. *    d4 = paramètre.w protracker (0-FF)            *
  3625. *    Attention, ces registres ne sont pas sauvés            *
  3626. *    Au retour :                    *
  3627. *    d2 = Note + Effet                    *
  3628. *============================================================================*
  3629. convert_dtmfx_2_gtkfx:
  3630.     cmp.b    #1,d3        ; Les effets qui ne changent pas
  3631.     beq.s    .nochange
  3632.     cmp.b    #2,d3
  3633.     beq.s    .nochange
  3634.     cmp.b    #3,d3
  3635.     beq.s    .nochange
  3636.     cmp.b    #4,d3
  3637.     beq.s    .nochange
  3638.     cmp.b    #7,d3
  3639.     beq.s    .nochange
  3640.     cmp.b    #$B,d3
  3641.     bne.s    .suite
  3642. .nochange:    move.w    d4,d2
  3643.     lsl.w    #8,d3
  3644.     add.w    d3,d2
  3645.     and.w    #$fff,d2
  3646.     bra    .fin
  3647.  
  3648. .suite:    tst.b    d3        ; Arpeggio
  3649.     bne.s    .5
  3650.     tst.b    d4
  3651.     beq    .fin
  3652.     clr.w    d2        ; On inverse les paramètres
  3653.     move.b    d4,d2
  3654.     lsl.b    #4,d2
  3655.     lsr.b    #4,d4
  3656.     add.b    d4,d2
  3657.     add.w    #$1000,d2
  3658.     bra    .fin
  3659.  
  3660. .5:    cmp.b    #5,d3        ; Vol slide + porta
  3661.     bne.s    .6
  3662.     move.w    d4,d3
  3663.     and.w    #$f,d3
  3664.     lsr.w    #4,d4
  3665.     sub.w    d3,d4
  3666.     add.w    d4,d4
  3667.     add.w    d4,d4
  3668.     bmi.s    .5neg
  3669.     add.w    #$1800,d4
  3670.     move.w    d4,d2
  3671.     bra    .fin
  3672. .5neg:    move.w    #$1900,d2
  3673.     sub.w    d4,d2
  3674.     bra    .fin
  3675.  
  3676. .6:    cmp.b    #6,d3        ; Vol slide + vib
  3677.     bne.s    .8
  3678.     move.w    d4,d3
  3679.     and.w    #$f,d3
  3680.     lsr.w    #4,d4
  3681.     sub.w    d3,d4
  3682.     add.w    d4,d4
  3683.     add.w    d4,d4
  3684.     bmi.s    .6neg
  3685.     add.w    #$1c00,d4
  3686.     move.w    d4,d2
  3687.     bra    .fin
  3688. .6neg:    move.w    #$1d00,d2
  3689.     sub.w    d4,d2
  3690.     bra    .fin
  3691.  
  3692. .8:    cmp.b    #8,d3        ; Set balance
  3693.     bne.s    .9
  3694.     add.w    #$400,d4
  3695.     lsl.w    #4,d4
  3696.     move.w    d4,d2
  3697.     bra    .fin
  3698.  
  3699. .9:    cmp.b    #9,d3        ; Play part of sample
  3700.     bne.s    .a
  3701.     add.w    #$9000,d4
  3702.     move.w    d4,d2
  3703.     bra    .fin
  3704.  
  3705. .a:    cmp.b    #10,d3        ; Vol slide
  3706.     bne.s    .c
  3707.     move.w    d4,d3
  3708.     and.w    #$f,d3
  3709.     lsr.w    #4,d4
  3710.     sub.w    d3,d4
  3711.     add.w    d4,d4
  3712.     add.w    d4,d4
  3713.     bmi.s    .aneg
  3714.     add.w    #$1400,d4
  3715.     move.w    d4,d2
  3716.     bra    .fin
  3717. .aneg:    move.w    #$1500,d2
  3718.     sub.w    d4,d2
  3719.     bra    .fin
  3720.  
  3721. .c:    cmp.b    #$c,d3        ; Set volume
  3722.     bne.s    .d
  3723.     add.w    d4,d4
  3724.     add.w    d4,d4
  3725.     add.w    #$2000,d4
  3726.     move.w    d4,d2
  3727.     bra    .fin
  3728.  
  3729. .d:    cmp.b    #$d,d3        ; Break pattern to line
  3730.     bne.s    .e
  3731.     move.w    d4,d3        ; Conversion BCD -> Hexa
  3732.     lsr.w    #4,d4
  3733.     mulu.w    #10,d4
  3734.     and.b    #$f,d3
  3735.     add.b    d3,d4
  3736.     move.w    #$D00,d2
  3737.     move.b    d4,d2
  3738.     bra    .fin
  3739.  
  3740. .e:    cmp.b    #14,d3        ; Effets étendus
  3741.     bne    .f
  3742.     move.w    d4,d3
  3743.     lsr.b    #4,d3
  3744.     and.b    #$f,d4
  3745. .e1:    cmp.b    #1,d3        ; Fine porta up
  3746.     bne.s    .e2
  3747.     add.w    #$1100,d4
  3748.     move.w    d4,d2
  3749.     bra    .fin
  3750.  
  3751. .e2:    cmp.b    #2,d3        ; Fine porta down
  3752.     bne.s    .e4
  3753.     add.w    #$1200,d4
  3754.     move.w    d4,d2
  3755.     bra    .fin
  3756.  
  3757. .e4:    cmp.b    #4,d3        ; Set vib wave
  3758.     bne.s    .e5
  3759.     add.w    #$c00,d4
  3760.     move.w    d4,d2
  3761.     bra    .fin
  3762.  
  3763. .e5:    cmp.b    #5,d3        ; Set finetune
  3764.     bne.s    .e6
  3765.     cmp.b    #7,d4
  3766.     bgt.s    .e5neg
  3767.     lsl.b    #4,d4
  3768.     add.w    #$800,d4
  3769.     move.w    d4,d2
  3770.     bra    .fin
  3771. .e5neg:    move.w    #$810,d2
  3772.     sub.w    d4,d2
  3773.     bra    .fin
  3774.  
  3775. .e6:    cmp.b    #6,d3        ; Pattern loop
  3776.     bne.s    .e7
  3777.     add.w    #$b100,d4
  3778.     move.w    d4,d2
  3779.     bra    .fin
  3780.  
  3781. .e7:    cmp.b    #7,d3        ; Set trem wave
  3782.     bne.s    .e8
  3783.     add.w    #$e00,d4
  3784.     move.w    d4,d2
  3785.     bra    .fin
  3786.  
  3787. .e8:    cmp.b    #8,d3        ; Set balance (2)
  3788.     bne.s    .e9
  3789.     lsl.w    #8,d4
  3790.     add.w    #$4000,d4
  3791.     move.w    d4,d2
  3792.     bra    .fin
  3793.  
  3794. .e9:    cmp.b    #9,d3        ; Retrig sample
  3795.     bne.s    .e10
  3796.     lsl.w    #8,d4
  3797.     add.w    #$7000,d4
  3798.     move.w    d4,d2
  3799.     bra    .fin
  3800.  
  3801. .e10:    cmp.b    #10,d3        ; Fine vol up
  3802.     bne.s    .e11
  3803.     move.w    #$a400,d2
  3804.     add.b    d4,d4
  3805.     add.b    d4,d4
  3806.     add.b    d4,d2
  3807.     bra    .fin
  3808.  
  3809. .e11:    cmp.b    #11,d3        ; Fine vol down
  3810.     bne.s    .e12
  3811.     move.w    #$a500,d2
  3812.     add.b    d4,d4
  3813.     add.b    d4,d4
  3814.     add.b    d4,d2
  3815.     bra    .fin
  3816.  
  3817. .e12:    cmp.b    #12,d3        ; Note cut
  3818.     bne.s    .e13
  3819.     add.w    #$a00,d4
  3820.     move.w    d4,d2
  3821.     bra    .fin
  3822.  
  3823. .e13:    cmp.b    #13,d3        ; Note delay
  3824.     bne.s    .ee
  3825.     add.w    #$900,d4
  3826.     move.w    d4,d2
  3827.     bra    .fin
  3828.  
  3829. .ee:    cmp.b    #$e,d3        ; Pattern delay
  3830.     bne    .fin
  3831.     add.w    #$aa00,d4
  3832.     move.w    d4,d2
  3833.     bra    .fin
  3834.  
  3835. .f:    cmp.b    #15,d3        ; Tempo
  3836.     bne.s    .fin
  3837.     move.w    #$0F00,d2
  3838.     cmp.w    #$20,d4
  3839.     bge.s    .f_ok
  3840.     move.w    #$A800,d2
  3841. .f_ok:    move.b    d4,d2
  3842.  
  3843. .fin:    rts
  3844.  
  3845.  
  3846.  
  3847. *============================================================================*
  3848. *    Effet de delay sur un échantillon. Les buffers sont supposés    *
  3849. *    déjà vides.                    *
  3850. *    a0 = Adresse d'un bloc d'infos sur l'écho.            *
  3851. *    Ce bloc est composé de :                *
  3852. *      - L : Adresse source                *
  3853. *      - L : Adresse destination                *
  3854. *      - L : Adresse buffer de delay                *
  3855. *      - L : Adresse du buffer de retardement            *
  3856. *      - L : Longueur source                *
  3857. *      - L : Longueur destination                *
  3858. *      - L : Feedback (/65536)                *
  3859. *      - L : Time feed (en octets)                *
  3860. *      - L : Longueur du buffer de retardement (octets)        *
  3861. *      - L : Dry level (/65536)                *
  3862. *      - L : Mute in (en SAMPLES) ($7fffffff si pas de mute)    *
  3863. *      - B : Nombre d'octets par sample (source)            *
  3864. *      - B : Nombre d'octets par sample (destination)        *
  3865. *      - W : Nombre de taps                *
  3866. *      Puis pour chaque tap :                *
  3867. *        - L : Delay time (en octets)                *
  3868. *        - L : Level (/65536)                *
  3869. *============================================================================*
  3870. fx_delay:
  3871.     movem.l    d0-a6,-(sp)
  3872.     move.l    a0,d0        ; Si a0 = 0, on doit reprendre à
  3873.     bne.s    .new        ; partir de là ou on en était.
  3874.     jmp    ([progression_res_adr])
  3875. .new:
  3876.     move.l    #4096,d0        ; Tous les 4096 on indique la progression
  3877.     move.l    d0,progression_step
  3878.     move.l    d0,progression_cpt
  3879.     move.l    dly_destlen(a0),progression_len
  3880.     clr.l    progression_pos
  3881.     moveq    #0,d5        ; d5 = position dans le buffer 1
  3882.     moveq    #0,d6        ; d6 = position dans le buffer 2
  3883.     move.l    dly_adrsource(a0),a1
  3884.     move.l    dly_adrdest(a0),a2
  3885.     move.l    dly_adrbuf1(a0),a4    ; a4 = adresse du 1er buffer
  3886.     move.l    dly_adrbuf2(a0),a5    ; a5 = adresse du 2ème buffer
  3887.     cmp.b    #2,dly_nbitsdest(a0)
  3888.     beq    fxdly_16bits
  3889.  
  3890. ;≡≡≡ Delay en 8 bits ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  3891. fxdly_8bits:
  3892.     move.w    (a4,d5.l),fxdly_deb1    ; Le sample du buffer 1
  3893.     clr.w    (a4,d5.l)        ; Vide le nouveau sample buffer 1
  3894.     move.w    (a5,d6.l),fxdly_deb2    ; Le sample du buffer 2
  3895.     clr.w    (a5,d6.l)        ; Vide le nouveau sample buffer 2
  3896.     clr.l    d7
  3897.     tst.l    dly_sourcelen(a0)
  3898.     ble    .suite1        ; Plus de source, plus de tap
  3899.  
  3900. ;--- Mixage des taps dans les buffers ----------------------------------------
  3901.     moveq    #0,d7
  3902.     move.b    (a1)+,d7
  3903.     lsl.w    #8,d7
  3904.     cmp.b    #2,dly_nbitssource(a0)
  3905.     bne.s    .sourok
  3906.     move.b    (a1)+,d7
  3907.     subq.l    #1,dly_sourcelen(a0)
  3908. .sourok:    subq.l    #1,dly_sourcelen(a0)
  3909.     swap    d7        ; d7 = sample source
  3910.     tst.l    dly_mutein(a0)    ; On coupe la source du delay ?
  3911.     ble    .suite1
  3912.     lea    dly_tapinfo(a0),a3
  3913.     move.l    dly_timefeed(a0),d1    ; d1 = timefeed
  3914.     move.w    dly_ntaps(a0),d0    ; d0 = nombre de taps
  3915.     subq.w    #1,d0
  3916.  
  3917. .taploop:
  3918.     move.l    dly_taptime(a3),d2    ; d2 = longueur du tap
  3919.     beq.s    .debut1
  3920.     cmp.l    d1,d2        ; Mise en attente ou directement sur le buffer ?
  3921.     bge.s    .tap_en_attente
  3922.  
  3923. ; Tap directement sur le buffer (Delay time ≤ Time feed)
  3924.     add.l    d5,d2
  3925.     cmp.l    d1,d2
  3926.     blt.s    .buf1ok
  3927.     sub.l    d1,d2        ; d2 = position (mémoire) dans le buffer
  3928. .buf1ok:    move.l    d7,d3
  3929.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  3930.     move.w    (a4,d2.l),d3    ; d3 = sample du buffer
  3931.     ext.l    d3
  3932.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  3933.     cmp.l    #MAX_SWORD,d3
  3934.     ble.s    .ok3
  3935.     move.w    #MAX_SWORD,d3
  3936. .ok3:    cmp.l    #MIN_SWORD,d3
  3937.     bge.s    .ok4
  3938.     move.w    #MIN_SWORD,d3
  3939. .ok4:    move.w    d3,(a4,d2.l)    ; On remet tout ça dans le buffer
  3940.     bra    .nexttap
  3941.  
  3942. ; Tap sur le buffer d'attente (Delay time ≥ Timefeed)
  3943. .tap_en_attente:
  3944.     sub.l    d1,d2
  3945.     beq.s    .debut2
  3946.     move.l    dly_time2(a0),d3
  3947.     add.l    d6,d2
  3948.     cmp.l    d3,d2
  3949.     blt.s    .buf2ok
  3950.     sub.l    d3,d2        ; d2 = position (mémoire) dans le buffer
  3951. .buf2ok:    move.l    d7,d3
  3952.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  3953.     move.w    (a5,d2.l),d3    ; d3 = sample du buffer
  3954.     ext.l    d3
  3955.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  3956.     cmp.l    #MAX_SWORD,d3
  3957.     ble.s    .ok5
  3958.     move.w    #MAX_SWORD,d3
  3959. .ok5:    cmp.l    #MIN_SWORD,d3
  3960.     bge.s    .ok6
  3961.     move.w    #MIN_SWORD,d3
  3962. .ok6:    move.w    d3,(a5,d2.l)    ; On remet tout ça dans le buffer
  3963.     bra.s    .nexttap
  3964.  
  3965. ; Mixage sur le début du buffer 1
  3966. .debut1:
  3967.     move.l    d7,d3
  3968.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  3969.     move.w    fxdly_deb1(pc),d3    ; d3 = sample du buffer
  3970.     ext.l    d3
  3971.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  3972.     cmp.l    #MAX_SWORD,d3
  3973.     ble.s    .ok7
  3974.     move.w    #MAX_SWORD,d3
  3975. .ok7:    cmp.l    #MIN_SWORD,d3
  3976.     bge.s    .ok8
  3977.     move.w    #MIN_SWORD,d3
  3978. .ok8:    move.w    d3,fxdly_deb1    ; On remet tout ça dans le buffer
  3979.     bra.s    .nexttap
  3980.  
  3981. ; Mixage sur le début du buffer 2
  3982. .debut2:
  3983.     move.l    d7,d3
  3984.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  3985.     move.w    fxdly_deb2(pc),d3    ; d3 = sample du buffer
  3986.     ext.l    d3
  3987.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  3988.     cmp.l    #MAX_SWORD,d3
  3989.     ble.s    .ok9
  3990.     move.w    #MAX_SWORD,d3
  3991. .ok9:    cmp.l    #MIN_SWORD,d3
  3992.     bge.s    .ok10
  3993.     move.w    #MIN_SWORD,d3
  3994. .ok10:    move.w    d3,fxdly_deb2    ; On remet tout ça dans le buffer
  3995.  
  3996. .nexttap:    addq.l    #dly_tapnext,a3
  3997.     dbra    d0,.taploop
  3998.     subq.l    #1,dly_mutein(a0)
  3999.  
  4000. ;--- Feedback ----------------------------------------------------------------
  4001. .suite1:
  4002.     move.w    (a4,d5.l),d0
  4003.     ext.l    d0
  4004.     moveq    #0,d1
  4005.     move.w    fxdly_deb1,d1    ; Le sample du buffer 1
  4006.     swap    d1
  4007.     muls.l    dly_feedback(a0),d2:d1    ; Feedback
  4008.     add.l    d0,d2        ; Mixage avec avec les nouveaux éléments
  4009.     cmp.l    #MAX_SWORD,d2
  4010.     ble.s    .ok11
  4011.     move.w    #MAX_SWORD,d2
  4012. .ok11:    cmp.l    #MIN_SWORD,d2
  4013.     bge.s    .ok12
  4014.     move.w    #MIN_SWORD,d2
  4015. .ok12:    move.w    d2,(a4,d5.l)    ; Replace dans le buffer 1
  4016.  
  4017. ;--- Mixage du début du buffer 2 sur la fin du 1 -----------------------------
  4018.     move.w    fxdly_deb2,d0
  4019.     ext.l    d0
  4020.     move.w    (a4,d5.l),d1
  4021.     ext.l    d1
  4022.     add.l    d1,d0
  4023.     cmp.l    #MAX_SWORD,d0
  4024.     ble.s    .ok13
  4025.     move.w    #MAX_SWORD,d0
  4026. .ok13:    cmp.l    #MIN_SWORD,d0
  4027.     bge.s    .ok14
  4028.     move.w    #MIN_SWORD,d0
  4029. .ok14:    move.w    d0,(a4,d5.l)
  4030.  
  4031. ;--- Mixage dry/wet ----------------------------------------------------------
  4032.     moveq    #0,d0
  4033.     move.l    d7,d0    ; Reprend le sample source
  4034.     muls.l    dly_drylevel(a0),d1:d0    ; d1 contient le dry au bon niveau
  4035.     move.w    fxdly_deb1,d2    ; d2 = wet
  4036.     ext.l    d2
  4037.     add.l    d2,d1
  4038.     cmp.l    #MAX_SWORD,d1
  4039.     ble.s    .ok1
  4040.     move.w    #MAX_SWORD,d1
  4041. .ok1:    cmp.l    #MIN_SWORD,d1
  4042.     bge.s    .ok2
  4043.     move.w    #MIN_SWORD,d1
  4044. .ok2:    lsr.w    #8,d1        ; d1 = mixage dry/wet
  4045.     move.b    d1,(a2)+        ; Sample dest ok
  4046.  
  4047. ;--- Nouvelles positions -----------------------------------------------------
  4048.     addq.l    #2,d5        ; Nouvelle position du buffer 1
  4049.     cmp.l    dly_timefeed(a0),d5
  4050.     blt.s    .ok15
  4051.     moveq    #0,d5
  4052. .ok15:    addq.l    #2,d6        ; Nouvelle position du buffer 2
  4053.     cmp.l    dly_time2(a0),d6
  4054.     blt.s    .ok16
  4055.     moveq    #0,d6
  4056. .ok16:    move.l    dly_destlen(a0),d0
  4057.     subq.l    #1,d0
  4058.     bgt.s    .noend
  4059.     move.l    progression_len(pc),progression_pos    ; Signale que tout est fini
  4060.     bra    fxdly_fin    
  4061. .noend:    move.l    d0,dly_destlen(a0)
  4062.     subq.l    #1,progression_cpt
  4063.     bgt    fxdly_8bits
  4064.  
  4065. ;--- Arrêt momentané pour affichage de la progression ------------------------
  4066.     move.l    progression_step(pc),d0
  4067.     move.l    d0,progression_cpt
  4068.     add.l    d0,progression_pos
  4069.     movem.l    d0-d7/a0-a6,progression_savedreg
  4070.     move.l    #fxdly_reprise8bits,progression_res_adr
  4071. .fin:
  4072.     bra    fxdly_fin
  4073.  
  4074. ;--- Reprise après affichage de la progression -------------------------------
  4075. fxdly_reprise8bits
  4076.     movem.l    progression_savedreg,d0-d7/a0-a6
  4077.     bra    fxdly_8bits
  4078.  
  4079.  
  4080.  
  4081. ;≡≡≡ Delay en 16 bits ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  4082. fxdly_16bits:
  4083.     move.w    (a4,d5.l),fxdly_deb1    ; Le sample du buffer 1
  4084.     clr.w    (a4,d5.l)        ; Vide le nouveau sample buffer 1
  4085.     move.w    (a5,d6.l),fxdly_deb2    ; Le sample du buffer 2
  4086.     clr.w    (a5,d6.l)        ; Vide le nouveau sample buffer 2
  4087.     clr.l    d7
  4088.     tst.l    dly_sourcelen(a0)
  4089.     ble    .suite1        ; Plus de source, plus de tap
  4090.  
  4091. ;--- Mixage des taps dans les buffers ----------------------------------------
  4092.     moveq    #0,d7
  4093.     move.b    (a1)+,d7
  4094.     lsl.w    #8,d7
  4095.     cmp.b    #2,dly_nbitssource(a0)
  4096.     bne.s    .sourok
  4097.     move.b    (a1)+,d7
  4098.     subq.l    #1,dly_sourcelen(a0)
  4099. .sourok:    subq.l    #1,dly_sourcelen(a0)
  4100.     swap    d7        ; d7 = sample source
  4101.     tst.l    dly_mutein(a0)    ; On coupe la source du delay ?
  4102.     ble    .suite1
  4103.     lea    dly_tapinfo(a0),a3
  4104.     move.l    dly_timefeed(a0),d1    ; d1 = timefeed
  4105.     move.w    dly_ntaps(a0),d0    ; d0 = nombre de taps
  4106.     subq.w    #1,d0
  4107.  
  4108. .taploop:
  4109.     move.l    dly_taptime(a3),d2    ; d2 = longueur du tap
  4110.     beq.s    .debut1
  4111.     cmp.l    d1,d2        ; Mise en attente ou directement sur le buffer ?
  4112.     bge.s    .tap_en_attente
  4113.  
  4114. ; Tap directement sur le buffer (Delay time ≤ Time feed)
  4115.     add.l    d5,d2
  4116.     cmp.l    d1,d2
  4117.     blt.s    .buf1ok
  4118.     sub.l    d1,d2        ; d2 = position (mémoire) dans le buffer
  4119. .buf1ok:    move.l    d7,d3
  4120.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  4121.     move.w    (a4,d2.l),d3    ; d3 = sample du buffer
  4122.     ext.l    d3
  4123.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  4124.     cmp.l    #MAX_SWORD,d3
  4125.     ble.s    .ok3
  4126.     move.w    #MAX_SWORD,d3
  4127. .ok3:    cmp.l    #MIN_SWORD,d3
  4128.     bge.s    .ok4
  4129.     move.w    #MIN_SWORD,d3
  4130. .ok4:    move.w    d3,(a4,d2.l)    ; On remet tout ça dans le buffer
  4131.     bra    .nexttap
  4132.  
  4133. ; Tap sur le buffer d'attente (Delay time ≥ Timefeed)
  4134. .tap_en_attente:
  4135.     sub.l    d1,d2
  4136.     beq.s    .debut2
  4137.     move.l    dly_time2(a0),d3
  4138.     add.l    d6,d2
  4139.     cmp.l    d3,d2
  4140.     blt.s    .buf2ok
  4141.     sub.l    d3,d2        ; d2 = position (mémoire) dans le buffer
  4142. .buf2ok:    move.l    d7,d3
  4143.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  4144.     move.w    (a5,d2.l),d3    ; d3 = sample du buffer
  4145.     ext.l    d3
  4146.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  4147.     cmp.l    #MAX_SWORD,d3
  4148.     ble.s    .ok5
  4149.     move.w    #MAX_SWORD,d3
  4150. .ok5:    cmp.l    #MIN_SWORD,d3
  4151.     bge.s    .ok6
  4152.     move.w    #MIN_SWORD,d3
  4153. .ok6:    move.w    d3,(a5,d2.l)    ; On remet tout ça dans le buffer
  4154.     bra.s    .nexttap
  4155.  
  4156. ; Mixage sur le début du buffer 1
  4157. .debut1:
  4158.     move.l    d7,d3
  4159.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  4160.     move.w    fxdly_deb1(pc),d3    ; d3 = sample du buffer
  4161.     ext.l    d3
  4162.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  4163.     cmp.l    #MAX_SWORD,d3
  4164.     ble.s    .ok7
  4165.     move.w    #MAX_SWORD,d3
  4166. .ok7:    cmp.l    #MIN_SWORD,d3
  4167.     bge.s    .ok8
  4168.     move.w    #MIN_SWORD,d3
  4169. .ok8:    move.w    d3,fxdly_deb1    ; On remet tout ça dans le buffer
  4170.     bra.s    .nexttap
  4171.  
  4172. ; Mixage sur le début du buffer 2
  4173. .debut2:
  4174.     move.l    d7,d3
  4175.     muls.l    dly_taplevel(a3),d4:d3    ; d4 = entrée dans le buffer au bon niveau
  4176.     move.w    fxdly_deb2(pc),d3    ; d3 = sample du buffer
  4177.     ext.l    d3
  4178.     add.l    d4,d3        ; Mixage avec le contenu du buffer
  4179.     cmp.l    #MAX_SWORD,d3
  4180.     ble.s    .ok9
  4181.     move.w    #MAX_SWORD,d3
  4182. .ok9:    cmp.l    #MIN_SWORD,d3
  4183.     bge.s    .ok10
  4184.     move.w    #MIN_SWORD,d3
  4185. .ok10:    move.w    d3,fxdly_deb2    ; On remet tout ça dans le buffer
  4186.  
  4187. .nexttap:    addq.l    #dly_tapnext,a3
  4188.     dbra    d0,.taploop
  4189.     subq.l    #1,dly_mutein(a0)
  4190.  
  4191. ;--- Feedback ----------------------------------------------------------------
  4192. .suite1:
  4193.     move.w    (a4,d5.l),d0
  4194.     ext.l    d0
  4195.     moveq    #0,d1
  4196.     move.w    fxdly_deb1,d1    ; Le sample du buffer 1
  4197.     swap    d1
  4198.     muls.l    dly_feedback(a0),d2:d1    ; Feedback
  4199.     add.l    d0,d2        ; Mixage avec avec les nouveaux éléments
  4200.     cmp.l    #MAX_SWORD,d2
  4201.     ble.s    .ok11
  4202.     move.w    #MAX_SWORD,d2
  4203. .ok11:    cmp.l    #MIN_SWORD,d2
  4204.     bge.s    .ok12
  4205.     move.w    #MIN_SWORD,d2
  4206. .ok12:    move.w    d2,(a4,d5.l)    ; Replace dans le buffer 1
  4207.  
  4208. ;--- Mixage du début du buffer 2 sur la fin du 1 -----------------------------
  4209.     move.w    fxdly_deb2,d0
  4210.     ext.l    d0
  4211.     move.w    (a4,d5.l),d1
  4212.     ext.l    d1
  4213.     add.l    d1,d0
  4214.     cmp.l    #MAX_SWORD,d0
  4215.     ble.s    .ok13
  4216.     move.w    #MAX_SWORD,d0
  4217. .ok13:    cmp.l    #MIN_SWORD,d0
  4218.     bge.s    .ok14
  4219.     move.w    #MIN_SWORD,d0
  4220. .ok14:    move.w    d0,(a4,d5.l)
  4221.  
  4222. ;--- Mixage dry/wet ----------------------------------------------------------
  4223.     moveq    #0,d0
  4224.     move.l    d7,d0    ; Reprend le sample source
  4225.     muls.l    dly_drylevel(a0),d1:d0    ; d1 contient le dry au bon niveau
  4226.     move.w    fxdly_deb1,d2    ; d2 = wet
  4227.     ext.l    d2
  4228.     add.l    d2,d1        ; d1 = mixage dry/wet
  4229.     cmp.l    #MAX_SWORD,d1
  4230.     ble.s    .ok1
  4231.     move.w    #MAX_SWORD,d1
  4232. .ok1:    cmp.l    #MIN_SWORD,d1
  4233.     bge.s    .ok2
  4234.     move.w    #MIN_SWORD,d1
  4235. .ok2:    move.w    d1,(a2)+        ; Sample dest ok
  4236.  
  4237. ;--- Nouvelles positions -----------------------------------------------------
  4238.     addq.l    #2,d5        ; Nouvelle position du buffer 1
  4239.     cmp.l    dly_timefeed(a0),d5
  4240.     blt.s    .ok15
  4241.     moveq    #0,d5
  4242. .ok15:    addq.l    #2,d6        ; Nouvelle position du buffer 2
  4243.     cmp.l    dly_time2(a0),d6
  4244.     blt.s    .ok16
  4245.     moveq    #0,d6
  4246. .ok16:    move.l    dly_destlen(a0),d0
  4247.     subq.l    #2,d0
  4248.     bgt.s    .noend
  4249.     move.l    progression_len(pc),progression_pos    ; Signale que tout est fini
  4250.     bra    fxdly_fin    
  4251. .noend:    move.l    d0,dly_destlen(a0)
  4252.     subq.l    #2,progression_cpt
  4253.     bgt    fxdly_16bits
  4254.  
  4255. ;--- Arrêt momentané pour affichage de la progression ------------------------
  4256.     move.l    progression_step(pc),d0
  4257.     move.l    d0,progression_cpt
  4258.     add.l    d0,progression_pos
  4259.     movem.l    d0-d7/a0-a6,progression_savedreg
  4260.     move.l    #fxdly_reprise16bits,progression_res_adr
  4261. .fin:
  4262.     bra    fxdly_fin
  4263.  
  4264. ;--- Reprise après affichage de la progression -------------------------------
  4265. fxdly_reprise16bits
  4266.     movem.l    progression_savedreg,d0-d7/a0-a6
  4267.     bra    fxdly_16bits
  4268.  
  4269.  
  4270.  
  4271. fxdly_fin:
  4272.     movem.l    (sp)+,d0-a6
  4273.     rts
  4274.  
  4275.  
  4276.  
  4277. *============================================================================*
  4278. *    Transformée de Fourier pour 1 fréquence            *
  4279. *    a0 = Adresse du sample                *
  4280. *    a1 = Adresse d'une table de sinus            *
  4281. *    d1 = Longueur.l du sample                *
  4282. *    d2 = Fréquence.l d'échantillonnage            *
  4283. *    d3 = Fréquence.l à analyser                *
  4284. *    d4 = Nombre.w d'octets par sample            *
  4285. *    Renvoie l'adresse des puissance Re et Im dans d0 (2x32bits)    *
  4286. *============================================================================*
  4287. trans_fourier:
  4288.     movem.l    d1-a6,-(sp)
  4289.     lsl.l    #6,d3
  4290.     lsl.l    #6,d3
  4291.     moveq    #0,d6
  4292.     divul.l    d2,d5:d3        ; d3 = incrément poids fort *4096/2π
  4293.     and.w    #4095,d3        ; Modulo 2π
  4294.     divu.l    d2,d5:d6        ; d6 = Incrément.l fractionnaire *4096/2π
  4295.     move.w    d3,fft_incmsl
  4296.     move.l    d6,fft_inclsl
  4297.     clr.l    fft_poslsl
  4298.     clr.l    fft_remsl
  4299.     clr.l    fft_relsl
  4300.     clr.l    fft_immsl
  4301.     clr.l    fft_imlsl
  4302.     move.l    d1,-(sp)        ; Sauve la taille du sample
  4303.     lea    fft_poslsl(pc),a2
  4304.     cmp.w    #2,d4
  4305.     beq    .16bits
  4306.  
  4307. ;≡≡≡ En 8 bits ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  4308. ;--- Partie imaginaire -------------------------------------------------------
  4309. .8bits:
  4310.     subq.l    #1,d1        ; d1 = compteur
  4311.     moveq    #0,d5        ; d5 = position poids fort
  4312.     move.l    fft_inclsl(pc),d0    ; d0 = incrément fractionnaire
  4313.     move.w    fft_incmsl(pc),d3    ; d3 = incrément poids fort
  4314.     moveq    #0,d7        ; d7 = Energie imaginaire poids fort
  4315.     lea    fft_imlsl(pc),a3
  4316.     swap    d1
  4317. .8loop1:    swap    d1
  4318. .8loop2:    move.b    (a0)+,d2
  4319.     lsl.w    #8,d2        ; d2 = sample 16 bits
  4320.  
  4321.     moveq    #0,d6
  4322.     muls.w    (a1,d5.w*2),d2    ; * sin
  4323.     bpl.s    .8s1
  4324.     moveq    #-1,d6
  4325. .8s1:    add.l    d2,(a3)
  4326.     addx.l    d6,d7
  4327.  
  4328.     add.l    d0,(a2)
  4329.     addx.w    d3,d5
  4330.     and.w    #4095,d5
  4331.     dbra    d1,.8loop2
  4332.     swap    d1
  4333.     dbra    d1,.8loop1
  4334.     move.l    d7,fft_immsl
  4335.  
  4336. ;--- Partie réelle -----------------------------------------------------------
  4337.     move.l    (sp),d1
  4338.     subq.l    #1,d1        ; d1 = compteur
  4339.     move.w    #1024,d5        ; d5 = position poids fort -> cosinus
  4340.     move.l    fft_inclsl(pc),d0    ; d0 = incrément fractionnaire
  4341.     move.w    fft_incmsl(pc),d3    ; d3 = incrément poids fort
  4342.     moveq    #0,d7        ; d7 = Energie réelle poids fort
  4343.     lea    fft_relsl(pc),a3
  4344.     swap    d1
  4345. .8loop3:    swap    d1
  4346. .8loop4:    move.b    -(a0),d2
  4347.     lsl.w    #8,d2        ; d2 = sample 16 bits
  4348.  
  4349.     moveq    #0,d6
  4350.     muls.w    (a1,d5.w*2),d2    ; * cos
  4351.     bpl.s    .8s2
  4352.     moveq    #-1,d6
  4353. .8s2:    add.l    d2,(a3)
  4354.     addx.l    d6,d7
  4355.  
  4356.     add.l    d0,(a2)
  4357.     addx.w    d3,d5
  4358.     and.w    #4095,d5
  4359.     dbra    d1,.8loop4
  4360.     swap    d1
  4361.     dbra    d1,.8loop3
  4362.     move.l    d7,fft_remsl
  4363.  
  4364.     move.l    (sp)+,d1        ; Récupère la longueur
  4365.     move.l    fft_remsl(pc),d2
  4366.     move.l    fft_relsl(pc),d3
  4367.     divs.l    d1,d2:d3
  4368.     move.l    d3,fft_remsl    ; Sauve la partie réelle
  4369.     move.l    fft_immsl(pc),d2
  4370.     move.l    fft_imlsl(pc),d3
  4371.     divs.l    d1,d2:d3
  4372.     move.l    d3,fft_relsl    ; Sauve la partie imaginaire à coté
  4373.     bra    .fin
  4374.  
  4375. ;≡≡≡ En 16 bits ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  4376. ;--- Partie imaginaire -------------------------------------------------------
  4377. .16bits:
  4378.     lsr.l    #1,d1
  4379.     subq.l    #1,d1        ; d1 = compteur
  4380.     moveq    #0,d5        ; d5 = position poids fort
  4381.     move.l    fft_inclsl(pc),d0    ; d0 = incrément fractionnaire
  4382.     move.w    fft_incmsl(pc),d3    ; d3 = incrément poids fort
  4383.     moveq    #0,d7        ; d7 = Energie imaginaire poids fort
  4384.     lea    fft_imlsl(pc),a3
  4385.     swap    d1
  4386. .16loop1:    swap    d1
  4387. .16loop2:    move.w    (a0)+,d2
  4388.     move.l    d2,d4        ; d2 et d4 = sample 16 bits
  4389.  
  4390.     moveq    #0,d6
  4391.     muls.w    (a1,d5.w*2),d2    ; * sin
  4392.     bpl.s    .16s1
  4393.     moveq    #-1,d6
  4394. .16s1:    add.l    d2,(a3)
  4395.     addx.l    d6,d7
  4396.  
  4397.     add.l    d0,(a2)
  4398.     addx.w    d3,d5
  4399.     and.w    #4095,d5
  4400.     dbra    d1,.16loop2
  4401.     swap    d1
  4402.     dbra    d1,.16loop1
  4403.     move.l    d7,fft_immsl
  4404.  
  4405. ;--- Partie réelle -----------------------------------------------------------
  4406.     move.l    (sp),d1
  4407.     lsr.l    #1,d1
  4408.     subq.l    #1,d1        ; d1 = compteur
  4409.     move.w    #1024,d5        ; d5 = position poids fort -> cosinus
  4410.     move.l    fft_inclsl(pc),d0    ; d0 = incrément fractionnaire
  4411.     move.w    fft_incmsl(pc),d3    ; d3 = incrément poids fort
  4412.     moveq    #0,d7        ; d7 = Energie réelle poids fort
  4413.     lea    fft_relsl(pc),a3
  4414.     swap    d1
  4415. .16loop3:    swap    d1
  4416. .16loop4:    move.w    -(a0),d2
  4417.     move.l    d2,d4        ; d2 et d4 = sample 16 bits
  4418.  
  4419.     moveq    #0,d6
  4420.     muls.w    (a1,d5.w*2),d2    ; * cos
  4421.     bpl.s    .16s2
  4422.     moveq    #-1,d6
  4423. .16s2:    add.l    d2,(a3)
  4424.     addx.l    d6,d7
  4425.  
  4426.     add.l    d0,(a2)
  4427.     addx.w    d3,d5
  4428.     and.w    #4095,d5
  4429.     dbra    d1,.16loop4
  4430.     swap    d1
  4431.     dbra    d1,.16loop3
  4432.     move.l    d7,fft_remsl
  4433.  
  4434.     move.l    (sp)+,d1        ; Récupère la longueur
  4435.     lsr.l    #1,d1
  4436.     move.l    fft_remsl(pc),d2
  4437.     move.l    fft_relsl(pc),d3
  4438.     divs.l    d1,d2:d3
  4439.     move.l    d3,fft_remsl    ; Sauve la partie réelle
  4440.     move.l    fft_immsl(pc),d2
  4441.     move.l    fft_imlsl(pc),d3
  4442.     divs.l    d1,d2:d3
  4443.     move.l    d3,fft_relsl    ; Sauve la partie imaginaire à coté
  4444.  
  4445. .fin:    move.l    #fft_remsl,d0
  4446.     movem.l    (sp)+,d1-a6
  4447.     rts
  4448.  
  4449.  
  4450.  
  4451. *============================================================================*
  4452. *    Rééchantillonne un sample                *
  4453. *    a0 = adresse du sample source                *
  4454. *    a1 = adresse du sample destination            *
  4455. *    d0 = Longueur.l du sample source                *
  4456. *    d1 = Longueur.l du sample destination            *
  4457. *    d2 = Nombre.w d'octets par sample            *
  4458. *    d3 = Type.w de rééchantillonnage :            *
  4459. *         0 : Aucune interpolation                *
  4460. *         1 : Interpolation linéaire                *
  4461. *         2 : Interpolation du 3ème degré            *
  4462. *============================================================================*
  4463. change_sample_frequency:
  4464.     movem.l    d0-a6,-(sp)
  4465.     tst.w    d3        ; Quel type de rééchantillonnage ?
  4466.     beq.s    chgsamfreq_nointerp    ; 0 = pas d'interpolation
  4467.     cmp.w    #1,d3
  4468.     beq    chgsamfreq_interplin    ; 1 = interpolation linéaire
  4469.  
  4470. ;≡≡≡ Rééchantillonnage sans interpolation ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  4471. chgsamfreq_nointerp:
  4472.     move.l    d0,d7
  4473.     moveq    #0,d6
  4474.     divul.l    d1,d5:d7        ; d7 = partie entière de (lsour / ldest)
  4475.     divu.l    d1,d5:d6        ; d6 = partie fractionnaire de (lsour / ldest)
  4476.     cmp.w    #2,d2
  4477.     beq.s    .16bits
  4478.  
  4479. .8bits:
  4480.     move.l    d1,d2
  4481.     subq.l    #1,d2        ; d2 = compteur
  4482.     cmp.l    d0,d1        ; Destination > source ?
  4483.     bgt.s    .8backw        ; Oui, on marche à reculons
  4484.  
  4485. ;--- A l'endroit si dest<source ----------------------------------------------
  4486.     moveq    #0,d0        ; d0 = pointeur source
  4487.     moveq    #0,d1        ; d1 =    "       "    partie fractionnaire
  4488.     swap    d2
  4489. .8fwlp1:    swap    d2
  4490. .8fwlp2:    move.b    (a0,d0.l),(a1)+    ; Copie le sample
  4491.     add.l    d6,d1
  4492.     addx.l    d7,d0        ; Incrémente le pointeur
  4493.     dbra    d2,.8fwlp2
  4494.     swap    d2
  4495.     dbra    d2,.8fwlp1
  4496.     bra    chgsamfreq_end
  4497.  
  4498. ;--- A l'envers si dest>source -----------------------------------------------
  4499. .8backw:    add.l    d1,a1
  4500.     subq.l    #1,d0
  4501.     moveq    #-1,d1
  4502.     swap    d2
  4503. .8bwlp1:    swap    d2
  4504. .8bwlp2:    move.b    (a0,d0.l),-(a1)    ; Copie le sample
  4505.     sub.l    d6,d1
  4506.     bcc.s    .8nc
  4507.     subq.l    #1,d0
  4508. .8nc:    sub.l    d7,d0        ; Incrémente le pointeur
  4509.     dbra    d2,.8bwlp2
  4510.     swap    d2
  4511.     dbra    d2,.8bwlp1
  4512.     bra    chgsamfreq_end
  4513.  
  4514. .16bits:
  4515.     move.l    d1,d2
  4516.     lsr.l    #1,d2
  4517.     subq.l    #1,d2        ; d2 = compteur
  4518.     cmp.l    d0,d1        ; Destination > source ?
  4519.     bgt.s    .16backw        ; Oui, on marche à reculons
  4520.  
  4521. ;--- A l'endroit si dest<source ----------------------------------------------
  4522.     moveq    #0,d0        ; d0 = pointeur source
  4523.     moveq    #0,d1        ; d1 =    "       "    partie fractionnaire
  4524.     swap    d2
  4525. .16fwlp1:    swap    d2
  4526. .16fwlp2:    move.w    (a0,d0.l*2),(a1)+    ; Copie le sample
  4527.     add.l    d6,d1
  4528.     addx.l    d7,d0        ; Incrémente le pointeur
  4529.     dbra    d2,.16fwlp2
  4530.     swap    d2
  4531.     dbra    d2,.16fwlp1
  4532.     bra    chgsamfreq_end
  4533.  
  4534. ;--- A l'envers si dest>source -----------------------------------------------
  4535. .16backw:    add.l    d1,a1
  4536.     lsr.l    #1,d0
  4537.     subq.l    #1,d0
  4538.     moveq    #0,d1
  4539.     swap    d2
  4540. .16bwlp1:    swap    d2
  4541. .16bwlp2:    move.w    (a0,d0.l*2),-(a1)    ; Copie le sample
  4542.     sub.l    d6,d1
  4543.     bcc.s    .16nc
  4544.     subq.l    #1,d0
  4545. .16nc:    sub.l    d7,d0        ; Incrémente le pointeur
  4546.     dbra    d2,.16bwlp2
  4547.     swap    d2
  4548.     dbra    d2,.16bwlp1
  4549.     bra    chgsamfreq_end
  4550.  
  4551. ;≡≡≡ Rééchantillonnage avec interpolation linéaire ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  4552. chgsamfreq_interplin:
  4553.     move.l    d0,d7
  4554.     moveq    #0,d6
  4555.     divul.l    d1,d5:d7        ; d7 = partie entière de (lsour / ldest)
  4556.     divu.l    d1,d5:d6        ; d6 = partie fractionnaire de (lsour / ldest)
  4557.     cmp.w    #2,d2
  4558.     beq    .16bits
  4559.  
  4560. .8bits:
  4561.     move.l    d1,d2
  4562.     subq.l    #1,d2        ; d2 = compteur
  4563.     cmp.l    d0,d1        ; Destination > source ?
  4564.     bgt.s    .8backw        ; Oui, on marche à reculons
  4565.  
  4566. ;--- A l'endroit si dest<source ----------------------------------------------
  4567.     moveq    #0,d0        ; d0 = pointeur source
  4568.     moveq    #0,d1        ; d1 =    "       "    partie fractionnaire
  4569.     swap    d2
  4570. .8fwlp1:    swap    d2
  4571. .8fwlp2:
  4572.     move.b    1(a0,d0.l),d3    ; On prend le 2ème sample
  4573.     ext.w    d3
  4574.     move.l    d1,d4        ; On prend la partie fractionnaire
  4575.     swap    d4
  4576.     lsr.w    #1,d4        ; -> mot non signé 0-$7fff
  4577.     muls.w    d4,d3
  4578.  
  4579.     move.b    (a0,d0.l),d5    ; On prend le 1er sample
  4580.     ext.w    d5
  4581.     sub.w    #$8000,d4        ; d4 = - (1 - partie fractionnaire)
  4582.     muls.w    d4,d5        ; Le résultat est négatif
  4583.     sub.l    d5,d3        ; C'est pour ça qu'on le soustrait à l'autre
  4584.     add.l    d3,d3        ; Réajuste à cause du bit de signe
  4585.     swap    d3        ; On prend que ce dont on a besoin
  4586.     move.b    d3,(a1)+        ; Copie le sample
  4587.  
  4588.     add.l    d6,d1
  4589.     addx.l    d7,d0        ; Incrémente le pointeur
  4590.     dbra    d2,.8fwlp2
  4591.     swap    d2
  4592.     dbra    d2,.8fwlp1
  4593.     bra    chgsamfreq_end
  4594.  
  4595. ;--- A l'envers si dest>source -----------------------------------------------
  4596. .8backw:    add.l    d1,a1
  4597.     subq.l    #1,d0
  4598.     moveq    #-1,d1
  4599.     swap    d2
  4600. .8bwlp1:    swap    d2
  4601. .8bwlp2:
  4602.     move.b    1(a0,d0.l),d3    ; On prend le 2ème sample
  4603.     ext.w    d3
  4604.     move.l    d1,d4        ; On prend la partie fractionnaire
  4605.     swap    d4
  4606.     lsr.w    #1,d4        ; -> mot non signé 0-$7fff
  4607.     muls.w    d4,d3
  4608.  
  4609.     move.b    (a0,d0.l),d5    ; On prend le 1er sample
  4610.     ext.w    d5
  4611.     sub.w    #$8000,d4        ; d4 = - (1 - partie fractionnaire)
  4612.     muls.w    d4,d5        ; Le résultat est négatif
  4613.     sub.l    d5,d3        ; C'est pour ça qu'on le soustrait à l'autre
  4614.     add.l    d3,d3        ; Réajuste à cause du bit de signe
  4615.     swap    d3        ; On prend que ce dont on a besoin
  4616.     move.b    d3,-(a1)        ; Copie le sample
  4617.  
  4618.     sub.l    d6,d1
  4619.     bcc.s    .8nc
  4620.     subq.l    #1,d0
  4621. .8nc:    sub.l    d7,d0        ; Incrémente le pointeur
  4622.     dbra    d2,.8bwlp2
  4623.     swap    d2
  4624.     dbra    d2,.8bwlp1
  4625.     bra    chgsamfreq_end
  4626.  
  4627. .16bits:
  4628.     move.l    d1,d2
  4629.     lsr.l    #1,d2
  4630.     subq.l    #1,d2        ; d2 = compteur
  4631.     cmp.l    d0,d1        ; Destination > source ?
  4632.     bgt.s    .16backw        ; Oui, on marche à reculons
  4633.  
  4634. ;--- A l'endroit si dest<source ----------------------------------------------
  4635.     moveq    #0,d0        ; d0 = pointeur source
  4636.     moveq    #0,d1        ; d1 =    "       "    partie fractionnaire
  4637.     swap    d2
  4638. .16fwlp1:    swap    d2
  4639. .16fwlp2:
  4640.     move.w    2(a0,d0.l*2),d3    ; On prend le 2ème sample
  4641.     move.l    d1,d4        ; On prend la partie fractionnaire
  4642.     swap    d4
  4643.     lsr.w    #1,d4        ; -> mot non signé 0-$7fff
  4644.     muls.w    d4,d3
  4645.  
  4646.     move.w    (a0,d0.l*2),d5    ; On prend le 1er sample
  4647.     sub.w    #$8000,d4        ; d4 = - (1 - partie fractionnaire)
  4648.     muls.w    d4,d5        ; Le résultat est négatif
  4649.     sub.l    d5,d3        ; C'est pour ça qu'on le soustrait à l'autre
  4650.     add.l    d3,d3        ; Réajuste à cause du bit de signe
  4651.     swap    d3        ; On prend que ce dont on a besoin
  4652.     move.w    d3,(a1)+        ; Copie le sample
  4653.  
  4654.     add.l    d6,d1
  4655.     addx.l    d7,d0        ; Incrémente le pointeur
  4656.     dbra    d2,.16fwlp2
  4657.     swap    d2
  4658.     dbra    d2,.16fwlp1
  4659.     bra.s    chgsamfreq_end
  4660.  
  4661. ;--- A l'envers si dest>source -----------------------------------------------
  4662. .16backw:    add.l    d1,a1
  4663.     lsr.l    #1,d0
  4664.     subq.l    #1,d0
  4665.     moveq    #-1,d1
  4666.     swap    d2
  4667. .16bwlp1:    swap    d2
  4668. .16bwlp2:
  4669.     move.w    2(a0,d0.l*2),d3    ; On prend le 2ème sample
  4670.     move.l    d1,d4        ; On prend la partie fractionnaire
  4671.     swap    d4
  4672.     lsr.w    #1,d4        ; -> mot non signé 0-$7fff
  4673.     muls.w    d4,d3
  4674.  
  4675.     move.w    (a0,d0.l*2),d5    ; On prend le 1er sample
  4676.     sub.w    #$8000,d4        ; d4 = - (1 - partie fractionnaire)
  4677.     muls.w    d4,d5        ; Le résultat est négatif
  4678.     sub.l    d5,d3        ; C'est pour ça qu'on le soustrait à l'autre
  4679.     add.l    d3,d3        ; Réajuste à cause du bit de signe
  4680.     swap    d3        ; On prend que ce dont on a besoin
  4681.     move.w    d3,-(a1)        ; Copie le sample
  4682.  
  4683.     sub.l    d6,d1
  4684.     bcc.s    .16nc
  4685.     subq.l    #1,d0
  4686. .16nc:    sub.l    d7,d0        ; Incrémente le pointeur
  4687.     dbra    d2,.16bwlp2
  4688.     swap    d2
  4689.     dbra    d2,.16bwlp1
  4690.     bra.s    chgsamfreq_end
  4691.  
  4692.  
  4693.  
  4694.  
  4695.  
  4696.     nop
  4697.  
  4698.  
  4699.  
  4700.  
  4701.  
  4702.  
  4703. chgsamfreq_end:
  4704.     movem.l    (sp)+,d0-a6
  4705.     rts
  4706.  
  4707.  
  4708.  
  4709. *============================================================================*
  4710. *    Cherche les volumes stereo d'entrée de l'ADC en temps réel    *
  4711. *    Les buffers de digit ont du être activés au paravant        *
  4712. *    avec la fonction Start_Sample_Recording            *
  4713. *    Le volume est renvoyé dans d0, mot fort = L, mot faible = R    *
  4714. *============================================================================*
  4715. cherche_volume_buffer_stereo:
  4716.     movem.l    d1-d3/a0,-(sp)
  4717.     lea    sample_rec_buffer(pc),a0    ; a0 pointe sur un buffer
  4718.     add.l    rec_sam_num_buf(pc),a0    ; Ajuste sur le bon buffer
  4719.     moveq    #0,d0
  4720.     moveq    #0,d1
  4721.     moveq    #0,d2
  4722.     move.w    #1023,d3
  4723. .loop:
  4724. .left:    move.w    (a0)+,d2
  4725.     bmi.s    .neg_l
  4726.     neg.w    d2        ; d2 = - | d2 |
  4727. .neg_l:    cmp.w    d0,d2
  4728.     bge.s    .right
  4729.     move.w    d2,d0
  4730. .right:    move.w    (a0)+,d2
  4731.     bmi.s    .neg_r
  4732.     neg.w    d2        ; d2 = - | d2 |
  4733. .neg_r:    cmp.w    d1,d2
  4734.     bge.s    .next
  4735.     move.w    d2,d1
  4736. .next:    dbra    d3,.loop
  4737.  
  4738.     neg.w    d0
  4739.     swap    d0        ; d0 mot fort = volume L
  4740.     neg.w    d1
  4741.     move.w    d1,d0        ; d0 mot faible = volume R
  4742.  
  4743.     movem.l    (sp)+,d1-d3/a0
  4744.     rts
  4745.  
  4746.  
  4747.  
  4748. *============================================================================*
  4749. *    Digitalise un son à l'aide de la cartouche de ST Replay Pro    *
  4750. *============================================================================*
  4751. start_sample_recording_strp:
  4752.  
  4753.  
  4754.  
  4755.  
  4756.  
  4757. ;--- Interruption pour savoir si on dépasse le niveau minimum ----------------
  4758. interruption_rec_sam_strp_trigger:
  4759.     or.w    #$2700,sr
  4760.     movem.l    d0-a6,-(sp)
  4761.     move.l    adr_record_inf(pc),a0        ; a0 pointe sur les infos de digit
  4762.     move.w    $fffb0000,d0        ; d0 = sample recueilli sur la cartouche (12 bits)
  4763.  
  4764.  
  4765.  
  4766.  
  4767.     movem.l    (sp)+,d0-a6
  4768.     rte
  4769.  
  4770.  
  4771.  
  4772.  
  4773.  
  4774.  
  4775.  
  4776. *============================================================================*
  4777. *    Digitalise un son à l'aide de l'ADC            *
  4778. *============================================================================*
  4779. start_sample_recording:
  4780.     movem.l    d0-a6,-(sp)
  4781.     pea    start_sample_recording2
  4782.     move.w    #$26,-(sp)
  4783.     trap    #14
  4784.     addq.l    #6,sp
  4785.     movem.l    (sp)+,d0-a6
  4786.     rts
  4787.  
  4788. ;--- Démarrage de l'enregistrement. Routine Superviseur !!! -----------------
  4789. start_sample_recording2:
  4790.     move.w    #1,flag_sample_rec    ; Signale qu'on doit enregistrer
  4791.     move.w    #1,flag_sample_rec2    ; Signale qu'on va enregistrer
  4792.  
  4793.     move.l    $ffff8930.w,old_matrix_cnx    ; Sauve les configurations de la matrice
  4794.     move.w    $ffff8934.w,old_replay_frequency    ; ainsi que la fréquence de replay
  4795.  
  4796.     clr.w    -(sp)
  4797.     move.w    #5,-(sp)
  4798.     move.w    #$82,-(sp)        ; ADC input
  4799.     trap    #14
  4800.     addq.l    #6,sp
  4801.  
  4802.     pea    sample_rec_buffer+4096(pc)
  4803.     pea    sample_rec_buffer(pc)
  4804.     move.w    #1,-(sp)
  4805.     move.w    #$83,-(sp)        ; Fixe le buffer d'enregistrement
  4806.     trap    #14
  4807.     lea    12(sp),sp
  4808.  
  4809.     move.w    #1,-(sp)        ; 16 bits stereo
  4810.     move.w    #$84,-(sp)
  4811.     trap    #14
  4812.     addq.l    #4,sp
  4813.  
  4814.     move.w    #2,-(sp)        ; Interruption à la fin de l'enregistrement
  4815.     move.w    #1,-(sp)        ; sur MFP gpi7
  4816.     move.w    #$87,-(sp)
  4817.     trap    #14
  4818.     addq.l    #6,sp
  4819.  
  4820.     move.w    #1,-(sp)
  4821.     move.w    ([adr_record_inf],rec_frequence),-(sp)    ; Fréquence d'échantillonnage
  4822.     clr.w    -(sp)
  4823.     move.w    #%1001,-(sp)    ;  +---> DAC et DMA record
  4824.     move.w    #3,-(sp)        ; ADC----------------^
  4825.     move.w    #$8b,-(sp)
  4826.     trap    #14
  4827.     lea    12(sp),sp
  4828.  
  4829.     move.w    #%1100,-(sp)    ; Enregistrement en boucle
  4830.     move.w    #$88,-(sp)
  4831.     trap    #14
  4832.     addq.l    #4,sp
  4833.  
  4834.     pea    sample_rec_buffer2+4096(pc)
  4835.     pea    sample_rec_buffer2(pc)
  4836.     move.w    #1,-(sp)
  4837.     move.w    #$83,-(sp)        ; Fixe le buffer d'enregistrement numéro 2
  4838.     trap    #14
  4839.     lea    12(sp),sp
  4840.  
  4841.     clr.l    rec_sam_num_buf    ; Commence au buffer 0
  4842.  
  4843.     bclr    #7,$fffffa13.w    ; Masque
  4844.     move.l    $13C.w,old_it_mfp15
  4845.     move.l    #interruption_rec_sam_trigger,$13C.w
  4846.     bset    #7,$fffffa07.w    ; MFP-15
  4847.     bset    #3,$fffffa17.w    ; Fin d'it en soft
  4848.     bset    #7,$fffffa13.w    ; Démasque : c'est parti mon kiki !
  4849.  
  4850.     rts
  4851.  
  4852. ;--- Interruption (MFP 15) pour savoir si on dépasse le niveau minimum ------
  4853. interruption_rec_sam_trigger:
  4854.     movem.l    d0-d4/a0-a2,-(sp)
  4855.     and.w    #%1111100011111111,sr
  4856.     bclr    #7,$fffffa0f.w
  4857.  
  4858.     tst.w    flag_sample_rec(pc)
  4859.     beq    itrecsamrec_stop
  4860.     move.l    adr_record_inf(pc),a0        ; a0 pointe sur les infos de digit
  4861.     lea    sample_rec_buffer(pc),a1    ; a1 pointe sur un buffer
  4862.     add.l    rec_sam_num_buf(pc),a1    ; Ajuste sur le bon buffer
  4863.     moveq    #0,d0
  4864.     moveq    #0,d1
  4865.     moveq    #0,d2
  4866.     move.w    rec_trigger(a0),d0    ; d0 = valeur seuil
  4867.     move.l    #1023,d1        ; d1 = nbr - 1 d'ech à tester
  4868.     cmp.w    #3,rec_canal(a0)    ; Left + Right
  4869.     beq.s    itrecsamt_mono
  4870.     cmp.w    #1,rec_canal(a0)    ; Left
  4871.     beq.s    itrecsamt_left
  4872.     addq.l    #2,a1        ; Right
  4873.  
  4874. itrecsamt_left:
  4875.     move.w    (a1),d2
  4876.     bpl.s    .pos
  4877.     neg.w    d2        ; Valeur abs
  4878. .pos:    cmp.l    d0,d2
  4879.     bge.s    .trigok
  4880.     addq.l    #4,a1        ; Sample suivant
  4881.     dbra    d1,itrecsamt_left
  4882.     bra.s    itrecsamt_fin
  4883. .trigok:    move.l    #interruption_rec_sam_record,$13c    ; Maintenant on peut enregistrer
  4884.     addq.l    #1,d1
  4885.     bra    itrecsamrec_left
  4886.  
  4887. itrecsamt_mono:
  4888.     move.w    (a1),d2        ; Celui de gauche d'abord
  4889.     bpl.s    .pos1
  4890.     neg.w    d2        ; Valeur abs
  4891. .pos1:    cmp.l    d0,d2
  4892.     blt.s    .next
  4893.     move.w    2(a1),d2        ; Puis celui de droite
  4894.     bpl.s    .pos2
  4895.     neg.w    d2        ; Valeur abs
  4896. .pos2:    cmp.l    d0,d2
  4897.     bge.s    .trigok
  4898. .next    addq.l    #4,a1        ; Sample suivant
  4899.     dbra    d1,itrecsamt_left
  4900.     bra.s    itrecsamt_fin
  4901. .trigok:    move.l    #interruption_rec_sam_record,$13c    ; Maintenant on peut enregistrer
  4902.     addq.l    #1,d1
  4903.     bra    itrecsamrec_mono
  4904.  
  4905. itrecsamt_fin:
  4906.     or.w    #$2700,sr        ; Pour ne pas être dérangé
  4907.     move.w    #2,flag_sample_rec2    ; On est en phase de trigger
  4908.  
  4909.     move.l    #sample_rec_buffer,d1
  4910.     add.l    rec_sam_num_buf(pc),d1
  4911.     move.l    d1,d0        ; d0 = adresse début nouveau buffer
  4912.     add.l    #4096,d1        ; d1 = adresse fin nouveau buffer
  4913.     move.b    #$b0,$ffff8901.w
  4914.     move.b    d0,$ffff8907.w
  4915.     lsr.w    #8,d0
  4916.     move.b    d0,$ffff8905.w
  4917.     swap    d0
  4918.     move.b    d0,$ffff8903.w
  4919.     move.b    d1,$ffff8913.w
  4920.     lsr.w    #8,d1
  4921.     move.b    d1,$ffff8911.w
  4922.     swap    d1
  4923.     move.b    d1,$ffff890f.w
  4924.  
  4925.     eor.l    #4096,rec_sam_num_buf    ; Change de buffer pour la prochaine fois
  4926.     movem.l    (sp)+,d0-d4/a0-a2
  4927.     rte
  4928.  
  4929. ;--- Interruption (MFP 15) de transfert buffer -> sample --------------------
  4930. interruption_rec_sam_record:
  4931.     movem.l    d0-d4/a0-a2,-(sp)
  4932.     and.w    #%1111100011111111,sr
  4933.     bclr    #7,$fffffa0f.w
  4934.  
  4935.     tst.w    flag_sample_rec(pc)
  4936.     beq    itrecsamrec_stop
  4937.     move.l    adr_record_inf(pc),a0        ; a0 pointe sur les infos de digit
  4938.     lea    sample_rec_buffer(pc),a1    ; a1 pointe sur un buffer
  4939.     add.l    rec_sam_num_buf(pc),a1    ; Ajuste sur le bon buffer
  4940.     moveq    #0,d1
  4941.     move.l    #1024,d1        ; d1 = nbr d'ech à copier
  4942.     cmp.w    #3,rec_canal(a0)    ; Left + Right
  4943.     beq    itrecsamrec_mono
  4944.     cmp.w    #1,rec_canal(a0)    ; Left
  4945.     beq.s    itrecsamrec_left
  4946.     addq.l    #2,a1        ; Right
  4947.  
  4948. itrecsamrec_left:
  4949.     move.l    rec_adresse(a0),a2    ; a2 = adresse du sample
  4950.     move.l    rec_position(a0),d2    ; d2 = position dans le sample
  4951.     cmp.w    #2,rec_nbits(a0)
  4952.     beq.s    .16bits
  4953.  
  4954. .8bits:
  4955.     move.l    rec_longueur(a0),d3
  4956.     sub.l    d2,d3        ; d3 = nbr d'ech avant la fin du sample
  4957.     cmp.l    d3,d1
  4958.     blt.s    .8assez        ; Y en a assez
  4959.     sub.l    d3,d1
  4960.     subq.l    #1,d3
  4961. .8loopt:    move.b    (a1),(a2,d2.l)
  4962.     addq.l    #4,a1
  4963.     addq.l    #1,d2
  4964.     dbra    d3,.8loopt
  4965.     bra.s    .8com
  4966. .8assez:    subq.l    #1,d1
  4967. .8loopa:    move.b    (a1),(a2,d2.l)
  4968.     addq.l    #4,a1
  4969.     addq.l    #1,d2
  4970.     dbra    d1,.8loopa
  4971.     moveq    #0,d1
  4972. .8com:    move.l    d2,rec_position(a0)    ; Nouvelle position sauvée
  4973.     cmp.l    rec_longueur(a0),d2    ; On en est à la fin ?
  4974.     blt    itrecsamrec_fin    ; Non, on continuera la prochaine fois
  4975.     tst.w    rec_flag_loop(a0)
  4976.     beq    itrecsamrec_stop    ; C'est fini, on arrête
  4977.     moveq    #0,d2        ; Si on boucle, on continue
  4978.     move.l    d2,rec_position(a0)
  4979.     tst.l    d1
  4980.     ble    itrecsamrec_fin    ; A pu rien à transférer, on continue la prochaine fois
  4981.     bra.s    .8bits
  4982.  
  4983. .16bits:
  4984.     move.l    rec_longueur(a0),d3
  4985.     sub.l    d2,d3
  4986.     lsr.l    #1,d3        ; d3 = nbr d'ech avant la fin du sample
  4987.     cmp.l    d3,d1
  4988.     blt.s    .16assez        ; Y en a assez
  4989.     sub.l    d3,d1
  4990.     subq.l    #1,d3
  4991. .16loopt:    move.w    (a1),(a2,d2.l)
  4992.     addq.l    #4,a1
  4993.     addq.l    #2,d2
  4994.     dbra    d3,.16loopt
  4995.     bra.s    .16com
  4996. .16assez:    subq.l    #1,d1
  4997. .16loopa:    move.w    (a1),(a2,d2.l)
  4998.     addq.l    #4,a1
  4999.     addq.l    #2,d2
  5000.     dbra    d1,.16loopa
  5001.     moveq    #0,d1
  5002. .16com:    move.l    d2,rec_position(a0)    ; Nouvelle position sauvée
  5003.     cmp.l    rec_longueur(a0),d2    ; On en est à la fin ?
  5004.     blt    itrecsamrec_fin    ; Non, on continuera la prochaine fois
  5005.     tst.w    rec_flag_loop(a0)
  5006.     beq    itrecsamrec_stop    ; C'est fini, on arrête
  5007.     moveq    #0,d2        ; Si on boucle, on continue
  5008.     move.l    d2,rec_position(a0)
  5009.     tst.l    d1
  5010.     ble    itrecsamrec_fin    ; A pu rien à transférer, on continue la prochaine fois
  5011.     bra.s    .16bits
  5012.  
  5013. itrecsamrec_mono:
  5014.     move.l    rec_adresse(a0),a2    ; a2 = adresse du sample
  5015.     move.l    rec_position(a0),d2    ; d2 = position dans le sample
  5016.     cmp.w    #2,rec_nbits(a0)
  5017.     beq.s    .16bits
  5018.  
  5019. .8bits:
  5020.     move.l    rec_longueur(a0),d3
  5021.     sub.l    d2,d3        ; d3 = nbr d'ech avant la fin du sample
  5022.     cmp.l    d3,d1
  5023.     blt.s    .8assez        ; Y en a assez
  5024.     sub.l    d3,d1
  5025.     subq.l    #1,d3
  5026. .8loopt:    move.b    (a1),d0
  5027.     ext.w    d0
  5028.     move.b    2(a1),d4
  5029.     ext.w    d4
  5030.     add.w    d4,d0
  5031.     lsr.w    #1,d0
  5032.     move.b    d0,(a2,d2.l)
  5033.     addq.l    #4,a1
  5034.     addq.l    #1,d2
  5035.     dbra    d3,.8loopt
  5036.     bra.s    .8com
  5037. .8assez:    subq.l    #1,d1
  5038. .8loopa:    move.b    (a1),d0
  5039.     ext.w    d0
  5040.     move.b    2(a1),d4
  5041.     ext.w    d4
  5042.     add.w    d4,d0
  5043.     lsr.w    #1,d0
  5044.     move.b    d0,(a2,d2.l)
  5045.     addq.l    #4,a1
  5046.     addq.l    #1,d2
  5047.     dbra    d1,.8loopa
  5048.     moveq    #0,d1
  5049. .8com:    move.l    d2,rec_position(a0)    ; Nouvelle position sauvée
  5050.     cmp.l    rec_longueur(a0),d2    ; On en est à la fin ?
  5051.     blt    itrecsamrec_fin    ; Non, on continuera la prochaine fois
  5052.     tst.w    rec_flag_loop(a0)
  5053.     beq.s    itrecsamrec_stop    ; C'est fini, on arrête
  5054.     moveq    #0,d2        ; Si on boucle, on continue
  5055.     move.l    d2,rec_position(a0)
  5056.     tst.l    d1
  5057.     ble    itrecsamrec_fin    ; A pu rien à transférer, on continue la prochaine fois
  5058.     bra.s    .8bits
  5059.  
  5060. .16bits:
  5061.     move.l    rec_longueur(a0),d3
  5062.     sub.l    d2,d3
  5063.     lsr.l    #1,d3        ; d3 = nbr d'ech avant la fin du sample
  5064.     cmp.l    d3,d1
  5065.     blt.s    .16assez        ; Y en a assez
  5066.     sub.l    d3,d1
  5067.     subq.l    #1,d3
  5068. .16loopt:    move.w    (a1),d0
  5069.     ext.l    d0
  5070.     move.w    2(a1),d4
  5071.     ext.l    d4
  5072.     add.l    d4,d0
  5073.     lsr.l    #1,d0
  5074.     move.w    d0,(a2,d2.l)
  5075.     addq.l    #4,a1
  5076.     addq.l    #2,d2
  5077.     dbra    d3,.16loopt
  5078.     bra.s    .16com
  5079. .16assez:    subq.l    #1,d1
  5080. .16loopa:    move.w    (a1),d0
  5081.     ext.l    d0
  5082.     move.w    2(a1),d4
  5083.     ext.l    d4
  5084.     add.l    d4,d0
  5085.     lsr.l    #1,d0
  5086.     move.w    d0,(a2,d2.l)
  5087.     addq.l    #4,a1
  5088.     addq.l    #2,d2
  5089.     dbra    d1,.16loopa
  5090.     moveq    #0,d1
  5091. .16com:    move.l    d2,rec_position(a0)    ; Nouvelle position sauvée
  5092.     cmp.l    rec_longueur(a0),d2    ; On en est à la fin ?
  5093.     blt.s    itrecsamrec_fin    ; Non, on continuera la prochaine fois
  5094.     tst.w    rec_flag_loop(a0)
  5095.     beq.s    itrecsamrec_stop    ; C'est fini, on arrête
  5096.     moveq    #0,d2        ; Si on boucle, on continue
  5097.     move.l    d2,rec_position(a0)
  5098.     tst.l    d1
  5099.     ble.s    itrecsamrec_fin    ; A pu rien à transférer, on continue la prochaine fois
  5100.     bra.s    .16bits
  5101.  
  5102. itrecsamrec_stop:
  5103.     or.w    #$2700,sr        ; Evite les problèmes
  5104.     clr.w    -(sp)        ; Plus d'interruption à la fin de l'enregistrement
  5105.     move.w    #1,-(sp)        ; sur MFP gpi7
  5106.     move.w    #$87,-(sp)
  5107.     trap    #14
  5108.     addq.l    #6,sp
  5109.  
  5110.     clr.w    flag_sample_rec
  5111.     move.w    #4,flag_sample_rec2
  5112.     bclr    #7,$fffffa07.w    ; Annule MFP-15
  5113.     bclr    #7,$fffffa13.w    ; Masque l'interruption
  5114.     move.l    old_it_mfp15,$13C.w
  5115.  
  5116.     clr.w    -(sp)        ; Arret de l'enregistrement
  5117.     move.w    #$88,-(sp)
  5118.     trap    #14
  5119.     addq.l    #4,sp
  5120.  
  5121.     move.l    old_matrix_cnx(pc),$ffff8930.w    ; Reprend les configurations de la matrice
  5122.     move.w    old_replay_frequency(pc),$ffff8934.w    ; ainsi que la fréquence de replay
  5123.  
  5124.     bra.s    itrecsamrec_fin2
  5125.  
  5126. itrecsamrec_fin:
  5127.     or.w    #$2700,sr        ; Pour ne pas être dérangé
  5128.     move.w    #3,flag_sample_rec2    ; On est en phase d'enregistrement
  5129.  
  5130.     move.l    #sample_rec_buffer,d1
  5131.     add.l    rec_sam_num_buf(pc),d1
  5132.     move.l    d1,d0        ; d0 = adresse début nouveau buffer
  5133.     add.l    #4096,d1        ; d1 = adresse fin nouveau buffer
  5134.     move.b    #$b0,$ffff8901.w
  5135.     move.b    d0,$ffff8907.w
  5136.     lsr.w    #8,d0
  5137.     move.b    d0,$ffff8905.w
  5138.     swap    d0
  5139.     move.b    d0,$ffff8903.w
  5140.     move.b    d1,$ffff8913.w
  5141.     lsr.w    #8,d1
  5142.     move.b    d1,$ffff8911.w
  5143.     swap    d1
  5144.     move.b    d1,$ffff890f.w
  5145.  
  5146.     eor.l    #4096,rec_sam_num_buf    ; Change de buffer pour la prochaine fois
  5147.  
  5148. itrecsamrec_fin2:
  5149.     movem.l    (sp)+,d0-d4/a0-a2
  5150.     rte
  5151.  
  5152.  
  5153.  
  5154. *============================================================================*
  5155. *    Affiche un vumètre                    *
  5156. *    d0 = volume.w actuel                    *
  5157. *    d1 = volume.w maximum atteint récemment            *
  5158. *    d2 = colonne.w d'affichage (16 pixels/colonne)        *
  5159. *    d3 = ligne.w d'affichage                *
  5160. *    d4 = hauteur.w du vumètre en pixels            *
  5161. *============================================================================*
  5162. affiche_vumetre:
  5163.     movem.l    d0-d4/d6-d7/a0-a1,-(sp)
  5164.     move.l    adrecr(pc),a0
  5165.     lsl.w    #3,d2
  5166.     add.w    d2,a0
  5167.     moveq    #0,d2
  5168.     move.w    linewidth(pc),d2    ; d2 = largeur d'une ligne en octets
  5169.     mulu.w    d2,d3
  5170.     add.l    d3,a0        ; a0 = adresse d'affichage
  5171.     swap    d0        ; Volumes * $10000
  5172.     clr.w    d0
  5173.     tst.l    d0
  5174.     bpl.s    .vol1ok
  5175.     subq.l    #1,d0        ; Au cas ou volume = $8000 0000
  5176. .vol1ok:    swap    d1
  5177.     clr.w    d1
  5178.     tst.l    d1
  5179.     bpl.s    .vol2ok
  5180.     subq.l    #1,d1
  5181. .vol2ok:    move.l    #$7fffffff,d7
  5182.     move.l    d7,d6        ; d6 = volume à la 1ère ligne
  5183.     ext.l    d4
  5184.     divu.l    d4,d7        ; d7 = incrément de volume / ligne
  5185.     subq.w    #1,d4        ; d4 = compteur de ligne
  5186.  
  5187. .loop:    move.l    a0,a1
  5188.     cmp.l    d0,d6
  5189.     ble.s    .aff1        ; Si on est dans le volume normal
  5190.     cmp.l    d1,d6
  5191.     ble.s    .aff2        ; Si on est dans le volume "fantôme"
  5192. .aff0:    clr.l    (a1)+        ; Et si on n'a pas encore atteint 1 des 2 volumes
  5193.     clr.l    (a1)        ; Noir
  5194.     bra.s    .affnext
  5195. .aff1:    move.l    #$ffff0000,(a1)+    ; Bleu
  5196.     clr.l    (a1)
  5197.     bra.s    .affnext
  5198. .aff2:    clr.l    (a1)+        ; Marron
  5199.     move.l    #$ffff0000,(a1)
  5200. .affnext:    add.l    d2,a0
  5201.     sub.l    d7,d6
  5202.     dbra    d4,.loop
  5203.  
  5204.     movem.l    (sp)+,d0-d4/d6-d7/a0-a1
  5205.     rts
  5206.  
  5207.  
  5208.  
  5209. *============================================================================*
  5210. *    Mixage de plusieurs samples                *
  5211. *    a0 = adresse d'un bloc d'informations            *
  5212. *    Ce bloc est composé de :                *
  5213. *      - L : Adresse du buffer de destination            *
  5214. *      - L : Longueur du buffer en octets            *
  5215. *      - W : Taille d'un sample en octets (1 ou 2)        *
  5216. *      - W : Nombre de samples à mixer            *
  5217. *      - Informations sur chaque sample :            *
  5218. *         - W : Nombre d'octets par sample (1 ou 2)        *
  5219. *         - L : Adresse du sample                *
  5220. *         - L : Point de répétition du sample (-1 si pas boucle,    *
  5221. *               -2 si plus rien à jouer)            *
  5222. *         - L : Longueur du sample                *
  5223. *         - L : Position courante                *
  5224. *         - L : Volume de début (poids fort /32768)        *
  5225. *         - L : Volume de début (poids faible, 32 bits)        *
  5226. *         - L : Incrément de volume pour chaque sample (poids fort,    *
  5227. *               /32768)                    *
  5228. *         - L : Incrément de volume pour chaque sample (poids faible,    *
  5229. *               32 bits)                    *
  5230. *    Attention, le tableau est modifié pendant la routine        *
  5231. *============================================================================*
  5232. mixage_samples:
  5233.     movem.l    d0-a6,-(sp)
  5234.     add.w    #12,a0        ; a0 au début des descripteurs de sample
  5235.     tst.w    mix2_nbrspl(a0)    ; Tests de sécutité
  5236.     beq    mixspl_fin
  5237.     tst.l    mix2_lonbuf(a0)
  5238.     beq    mixspl_fin
  5239.  
  5240. mixspl_mainloop:
  5241.     moveq    #0,d1        ; d1 = sample destination
  5242.     move.l    a0,a1        ; a1 pointe sur les infos du spl
  5243.     move.w    mix2_nbrspl(a0),d0
  5244.     subq.w    #1,d0        ; d0 = compteur de sample
  5245.  
  5246. mixspl_splloop:
  5247.     cmp.l    #-2,mix_reps(a1)    ; Sample fini ?
  5248.     beq    mixspl_splfin    ; oui, suivant
  5249.     move.l    mix_pos(a1),d6    ; d6 = position du sample (réutilisé en fin de boucle)
  5250.     move.l    mix_volh(a1),d5    ; d5 = volume, poids fort (idem)
  5251.     cmp.w    #2,mix_nbits(a1)
  5252.     beq.s    .mix16
  5253.  
  5254. .mix8:    move.b    ([mix_sadr,a1],d6.l),d2    ; d2 = sample 8 bits
  5255.     asl.w    #8,d2        ; Conversion 16 bits
  5256.     tst.w    d2
  5257.     bmi.s    .mix16n
  5258.     bra.s    .mix16p
  5259.  
  5260. .mix16:    moveq    #0,d4
  5261.     move.w    ([mix_sadr,a1],d6.l),d2    ; d2 = sample 16 bits
  5262.     bpl.s    .mix16p        ; Si c'est positif
  5263.  
  5264. .mix16n:    neg.w    d2
  5265.     move.l    d5,d7
  5266.     add.l    d7,d7        ; Volume /32768 -> /65536
  5267.     move.w    d7,d4        ; d4 = vol mot faible
  5268.     clr.w    d7
  5269.     swap    d7        ; d7 = vol mot fort
  5270.     mulu.w    d2,d7
  5271.     mulu.w    d2,d4
  5272.     clr.w    d4
  5273.     swap    d4
  5274.     add.l    d4,d7        ; Mixage résultat mots fort et faible
  5275.     neg.l    d7
  5276.     add.l    d7,d1        ; Mixage résultat mot faible
  5277.     bra.s    .mixfin
  5278.  
  5279. .mix16p:    move.l    d5,d7
  5280.     add.l    d7,d7        ; Volume /32768 -> /65536
  5281.     move.w    d7,d4        ; d4 = vol mot faible
  5282.     clr.w    d7
  5283.     swap    d7        ; d7 = vol mot fort
  5284.     mulu.w    d2,d7
  5285.     mulu.w    d2,d4
  5286.     clr.w    d4
  5287.     swap    d4
  5288.     add.l    d4,d7        ; Mixage résultat mots fort et faible
  5289.     add.l    d7,d1        ; Mixage résultat mot faible
  5290.  
  5291. .mixfin:    moveq    #0,d7
  5292.     move.w    mix_nbits(a1),d7    ; Incrémente la position
  5293.     add.l    d7,d6
  5294.     move.l    d6,mix_pos(a1)
  5295.     cmp.l    mix_repe(a1),d6
  5296.     blt.s    .rep_fin
  5297.     move.l    mix_reps(a1),mix_pos(a1)    ; Bouclage
  5298.     tst.l    mix_reps(a1)    ; Mais, les répétitions étaient autorisées ?
  5299.     bpl.s    .rep_fin
  5300.     move.l    #-2,mix_reps(a1)    ; Non, c'est terminé
  5301. .rep_fin:    move.l    mix_ivoll(a1),d6    ; Incrémente le volume du sample
  5302.     move.l    mix_ivolh(a1),d7
  5303.     add.l    d6,mix_voll(a1)
  5304.     addx.l    d7,d5
  5305.     move.l    d5,mix_volh(a1)
  5306. mixspl_splfin:
  5307.     add.w    #mix_next,a1    ; Sample suivant
  5308.     dbra    d0,mixspl_splloop
  5309.  
  5310.     moveq    #0,d0
  5311.     move.w    mix2_nbits(a0),d0
  5312.     cmp.w    #2,d0
  5313.     beq.s    .dest16
  5314. .dest8:    asr.l    #8,d1        ; Conversion 8 bits
  5315.     cmp.w    #MAX_SBYTE,d1
  5316.     ble.s    .d8ok1
  5317.     moveq    #MAX_SBYTE,d1
  5318. .d8ok1:    cmp.w    #MIN_SBYTE,d1
  5319.     bge.s    .d8ok2
  5320.     moveq    #MIN_SBYTE,d1
  5321. .d8ok2:    move.b    d1,([mix2_adrbuf,a0])    ; Destination 8 bits
  5322.     bra.s    .destend
  5323. .dest16:    cmp.l    #MAX_SWORD,d1
  5324.     ble.s    .d16ok1
  5325.     move.w    #MAX_SWORD,d1
  5326. .d16ok1:    cmp.l    #MIN_SWORD,d1
  5327.     bge.s    .d16ok2
  5328.     move.w    #MIN_SWORD,d1
  5329. .d16ok2:    move.w    d1,([mix2_adrbuf,a0])    ; Destination 16 bits
  5330. .destend:    add.l    d0,mix2_adrbuf(a0)
  5331.     sub.l    d0,mix2_lonbuf(a0)
  5332.     bgt    mixspl_mainloop
  5333.  
  5334. mixspl_fin:
  5335.     movem.l    (sp)+,d0-a6
  5336.     rts
  5337.  
  5338.  
  5339.  
  5340. *============================================================================*
  5341. *    Modifie le volume d'un son                *
  5342. *    a0 = adresse du son                    *
  5343. *    d0 = longueur.l en octets                *
  5344. *    d1 = volume.l de début /32768                *
  5345. *    d2,d3 = incrément de volume pour chaque sample (d3 = précision)    *
  5346. *    d4 = nbr.w d'octets par sample (1 ou 2)            *
  5347. *============================================================================*
  5348. change_volume_sample:
  5349.     movem.l    d0-d7/a0,-(sp)
  5350.     add.l    d3,d3        ; Resize de 31 à 32 bits
  5351.     moveq    #0,d7        ; d7 = précision du volume courant
  5352.     cmp.w    #2,d4
  5353.     beq.s    .16bits
  5354. .8bits:
  5355.     subq.l    #1,d0
  5356.     swap    d0
  5357. .8_loop2:    swap    d0
  5358. .8_loop1:    move.l    d2,-(sp)
  5359.     move.b    (a0),d2
  5360.     extb.l    d2
  5361.     muls.l    d1,d2
  5362.     add.l    d2,d2
  5363.     swap    d2
  5364.     cmp.w    #MAX_SBYTE,d2
  5365.     ble.s    .8_t2
  5366.     moveq    #MAX_SBYTE,d2
  5367.     bra.s    .8_ok
  5368. .8_t2:    cmp.w    #MIN_SBYTE,d2
  5369.     bge.s    .8_ok
  5370.     moveq    #MIN_SBYTE,d2
  5371. .8_ok:    move.b    d2,(a0)+
  5372.     move.l    (sp)+,d2
  5373.     add.l    d3,d7        ; Change le volume pour le sample suivant
  5374.     addx.l    d2,d1
  5375.     dbra    d0,.8_loop1
  5376.     swap    d0
  5377.     dbra    d0,.8_loop2
  5378.     bra    .fin
  5379.  
  5380. .16bits:
  5381.     add.l    d1,d1        ; Convertit /32768 -> /65536
  5382.     add.l    d3,d3
  5383.     addx.l    d2,d2
  5384.     lsr.l    #1,d0
  5385.     subq.l    #1,d0
  5386.     swap    d0
  5387. .16_loop2:    swap    d0
  5388. .16_loop1:    move.l    d2,-(sp)
  5389.     move.l    d1,d5
  5390.     clr.w    d5
  5391.     swap    d5        ; d5 = poids.w fort du volume
  5392.     move.l    d1,d4
  5393.     and.l    #$FFFF,d4        ; d4 = poids.w faible du volume
  5394.     move.w    (a0),d2
  5395.     bpl.s    .16_positif
  5396.     neg.w    d2
  5397.     move.w    d2,d6
  5398.     mulu.w    d4,d2
  5399.     clr.w    d2
  5400.     swap    d2        ; d2 = résultat poids faible
  5401.     mulu.w    d5,d6        ; d6 = résultat poids fort
  5402.     add.l    d6,d2        ; d2 = résultat entier
  5403.     cmp.l    #32768,d2
  5404.     ble.s    .16_n_ok
  5405.     move.w    #32768,d2
  5406. .16_n_ok:    neg.w    d2
  5407.     move.w    d2,(a0)+
  5408.     move.l    (sp)+,d2
  5409.     add.l    d3,d7
  5410.     addx.l    d2,d1        ; Change le volume pour le sample suivant
  5411.     dbra    d0,.16_loop1
  5412.     swap    d0
  5413.     dbra    d0,.16_loop2
  5414.     bra.s    .fin
  5415. .16_positif:
  5416.     move.w    d2,d6
  5417.     mulu.w    d4,d2
  5418.     clr.w    d2
  5419.     swap    d2        ; d2 = résultat poids faible
  5420.     mulu.w    d5,d6        ; d6 = résultat poids fort
  5421.     add.l    d6,d2        ; d2 = résultat entier
  5422.     cmp.l    #MAX_SWORD,d2
  5423.     ble.s    .16_p_ok
  5424.     move.w    #MAX_SWORD,d2
  5425. .16_p_ok:    move.w    d2,(a0)+
  5426.     move.l    (sp)+,d2
  5427.     add.l    d3,d7
  5428.     addx.l    d2,d1        ; Change le volume pour le sample suivant
  5429.     dbra    d0,.16_loop1
  5430.     swap    d0
  5431.     dbra    d0,.16_loop2
  5432.  
  5433. .fin:
  5434.     movem.l    (sp)+,d0-d7/a0
  5435.     rts
  5436.  
  5437.  
  5438.  
  5439. *============================================================================*
  5440. *    Recherche du volume maximum d'un son            *
  5441. *    a0 = adresse du son                    *
  5442. *    d1 = longueur.l en octets                *
  5443. *    d2 = nombre.w d'octets par sample            *
  5444. *    Retour : volume dans d0                *
  5445. *============================================================================*
  5446. cherche_volume_sample:
  5447.     movem.l    d1/d2/a0,-(sp)
  5448.     moveq    #0,d0        ; Volume maxi dans d0
  5449.     bmi.s    .fin        ; Si longueur nulle
  5450.     subq.l    #1,d1
  5451.     cmp.w    #2,d2
  5452.     beq.s    .16bits
  5453.  
  5454.     swap    d1
  5455. .loop1:    swap    d1
  5456. .loop2:    move.b    (a0)+,d2
  5457.     ext.w    d2
  5458.     bpl.s    .suite1
  5459.     neg.w    d2        ; Valeur absolue
  5460. .suite1:    cmp.w    d0,d2
  5461.     ble.s    .suite2
  5462.     move.w    d2,d0
  5463. .suite2:    dbra    d1,.loop2
  5464.     swap    d1
  5465.     dbra    d1,.loop1
  5466.     bra.s    .fin
  5467.  
  5468. .16bits:    lsr.l    #1,d1
  5469.     swap    d1
  5470. .16loop1:    swap    d1
  5471. .16loop2:    move.w    (a0)+,d2
  5472.     ext.l    d2
  5473.     bpl.s    .16suite1
  5474.     neg.l    d2        ; Valeur absolue
  5475. .16suite1:    cmp.l    d0,d2
  5476.     ble.s    .16suite2
  5477.     move.l    d2,d0
  5478. .16suite2:    dbra    d1,.16loop2
  5479.     swap    d1
  5480.     dbra    d1,.16loop1
  5481.  
  5482. .fin:    movem.l    (sp)+,d1/d2/a0
  5483.     rts
  5484.  
  5485.  
  5486.  
  5487. *============================================================================*
  5488. *    Convertit une ligne GTK en ligne ProTracker            *
  5489. *    a0 = adresse de la ligne GTK                *
  5490. *    a1 = adresse de la ligne ProTracker            *
  5491. *    a3 = adresse de la table de correspondance des samples 256 octets    *
  5492. *         (256->32). Les samples inexistants sont mis à 0.b        *
  5493. *    d0 = longueur.w de la ligne GTK                *
  5494. *============================================================================*
  5495. convert_gtk_2_nt:
  5496.     movem.l    d0-d5/a0-a3,-(sp)
  5497.     lea    nt_pernote(pc),a2    ; a2 = adresse des périodes ProTracker
  5498.     subq.w    #1,d0
  5499.  
  5500. cv_gtk2nt_loop:
  5501.     moveq    #0,d1
  5502.     move.b    (a0)+,d1        ; d1 = note
  5503.     beq.s    .pas_note
  5504.     sub.w    #36,d1
  5505.     bpl.s    .note_t2
  5506. .note_t1:    add.w    #12,d1        ; Trop bas : ajoute 1 octave
  5507.     bmi.s    .note_t1
  5508. .note_t2:    cmp.w    #36,d1
  5509.     blt.s    .note_ok
  5510.     sub.w    #12,d1        ; Trop haut : enlève 1 octave
  5511.     bra.s    .note_t2
  5512. .note_ok:    move.w    (a2,d1.w*2),d1
  5513. .pas_note:    swap    d1        ; Note convertie
  5514.  
  5515.     moveq    #0,d2        ; d2 = instrument
  5516.     move.b    (a0)+,d2
  5517.     move.b    (a3,d2.w),d2    ; Nouveau numéro (pour passer de 256 samples à
  5518.     lsl.w    #8,d2        ; 255).
  5519.     move.w    d2,d1
  5520.     lsl.w    #4,d1        ; Poids faible ok
  5521.     and.w    #$F000,d2
  5522.     swap    d2
  5523.     add.l    d2,d1        ; Poids fort ok
  5524.  
  5525.     moveq    #0,d2        ; d2 = résultat de l'effet (0 par défaut)
  5526.     move.b    2(a0),d2
  5527.     beq.s    .no_vol
  5528.     lsr.b    #2,d2
  5529.     add.w    #$C00,d2        ; Volume sur la colonne
  5530.  
  5531. .no_vol:    moveq    #0,d4        ; On fait les effets maintenant
  5532.     moveq    #0,d5
  5533.     move.w    (a0),d3        ; d3.w = effet entier
  5534.     move.b    (a0)+,d4        ; d4.b = No d'effet
  5535.     move.b    (a0)+,d5        ; d5.b = paramètre
  5536.  
  5537.     cmp.b    #1,d4        ; Les effets qui ne changent pas
  5538.     beq.s    .nochange
  5539.     cmp.b    #2,d4
  5540.     beq.s    .nochange
  5541.     cmp.b    #3,d4
  5542.     beq.s    .nochange
  5543.     cmp.b    #4,d4
  5544.     beq.s    .nochange
  5545.     cmp.b    #7,d4
  5546.     beq.s    .nochange
  5547.     cmp.b    #$B,d4
  5548.     beq.s    .nochange
  5549.     cmp.b    #$F,d4
  5550.     bne.s    .suite
  5551. .nochange:    move.w    d3,d2
  5552.     bra    .fin
  5553.  
  5554. .suite:    cmp.b    #$05,d4        ; Porta (+vib)
  5555.     bne.s    .06
  5556.     move.w    #$300,d2
  5557.     move.w    d5,d2
  5558.     bra    .fin
  5559. .06:    cmp.b    #$06,d4        ; (vib+) Porta
  5560.     beq.s    .06_ok
  5561.     cmp.b    #$1A,d4        ; (vol sl up exp+) porta
  5562.     beq.s    .06_ok
  5563.     cmp.b    #$1B,d4        ; (vol sl down exp+) porta
  5564.     bne.s    .08
  5565. .06_ok:    move.w    #$300,d2
  5566.     bra    .fin
  5567. .08:    cmp.b    #$08,d4        ; Set finetune
  5568.     bne.s    .09
  5569.     move.b    d5,d4
  5570.     ; and.b    #15,d4        ; Inutile ?
  5571.     lsr.b    #4,d5
  5572.     sub.b    d4,d5
  5573.     and.b    #15,d5
  5574.     add.w    #$E50,d5
  5575.     move.w    d5,d2
  5576.     bra    .fin
  5577. .09:    cmp.b    #$09,d4        ; Note delay
  5578.     bne.s    .0A
  5579.     cmp.b    #15,d5
  5580.     ble.s    .09ok
  5581.     move.b    #15,d5
  5582. .09ok:    move.w    #$ED0,d2
  5583.     add.b    d5,d2
  5584.     bra    .fin
  5585. .0A:    cmp.b    #$0A,d4        ; Note cut
  5586.     bne.s    .0C
  5587.     cmp.b    #15,d5
  5588.     ble.s    .0Aok
  5589.     move.b    #15,d5
  5590. .0Aok:    move.w    #$EC0,d2
  5591.     add.b    d5,d2
  5592.     bra    .fin
  5593. .0C:    cmp.b    #$0C,d4        ; Set vib wave
  5594.     bne.s    .0D
  5595.     and.b    #15,d5
  5596.     move.w    #$E40,d2
  5597.     add.b    d5,d2
  5598.     bra    .fin
  5599. .0D:    cmp.b    #$0D,d4        ; Break pattern to line
  5600.     bne.s    .0E
  5601.     move.w    #$D00,d2
  5602.     divu.w    #10,d5        ; Conversion Hexa -> BCD
  5603.     lsl.b    #4,d5
  5604.     add.b    d5,d2
  5605.     swap    d5
  5606.     add.b    d5,d2
  5607.     bra    .fin
  5608. .0E:    cmp.b    #$0E,d4        ; Set trem wave
  5609.     bne.s    .10
  5610.     and.b    #15,d5
  5611.     move.w    #$E70,d2
  5612.     add.b    d5,d2
  5613.     bra    .fin
  5614. .10:    cmp.b    #$10,d4        ; Arpeggio
  5615.     bne.s    .11
  5616.     move.w    d5,d2
  5617.     bra    .fin
  5618. .11:    cmp.b    #$11,d4        ; Fine porta up
  5619.     bne.s    .12
  5620.     cmp.b    #15,d5
  5621.     ble.s    .11ok
  5622.     move.b    #15,d5
  5623. .11ok:    move.w    #$E10,d2
  5624.     add.b    d5,d2
  5625.     bra    .fin
  5626. .12:    cmp.b    #$12,d4        ; Fine porta down
  5627.     bne.s    .13
  5628.     cmp.b    #15,d5
  5629.     ble.s    .12ok
  5630.     move.b    #15,d5
  5631. .12ok:    move.w    #$E20,d2
  5632.     add.b    d5,d2
  5633.     bra    .fin
  5634. .13:    cmp.b    #$13,d4        ; Roll + vol slide
  5635.     bne.s    .14
  5636.     and.b    #15,d5
  5637.     move.w    #$E90,d2
  5638.     add.b    d5,d2
  5639.     bra    .fin
  5640. .14:    cmp.b    #$14,d4        ; Vol sl up
  5641.     bne.s    .15
  5642.     addq.w    #3,d5        ; Arrondit par excès
  5643.     add.w    d5,d5
  5644.     add.w    d5,d5
  5645.     and.w    #$F0,d5
  5646.     cmp.w    #$F0,d5
  5647.     ble.s    .14ok
  5648.     move.w    #$F0,d5
  5649. .14ok:    move.w    #$A00,d2
  5650.     move.b    d5,d2
  5651.     bra    .fin
  5652. .15:    cmp.b    #$15,d4        ; Vol sl down
  5653.     bne.s    .18
  5654.     addq.w    #3,d5
  5655.     lsr.w    #2,d5
  5656.     cmp.b    #15,d5
  5657.     ble.s    .15ok
  5658.     move.b    #15,d5
  5659. .15ok:    move.w    #$A00,d2
  5660.     move.b    d5,d2
  5661.     bra    .fin
  5662. .18    cmp.b    #$18,d4        ; Vol sl up + tone porta
  5663.     bne.s    .19
  5664.     addq.w    #3,d5
  5665.     add.w    d5,d5
  5666.     add.w    d5,d5
  5667.     and.w    #$F0,d5
  5668.     cmp.w    #$F0,d5
  5669.     ble.s    .18ok
  5670.     move.w    #$F0,d5
  5671. .18ok:    move.w    #$500,d2
  5672.     move.b    d5,d2
  5673.     bra    .fin
  5674. .19:    cmp.b    #$19,d4        ; Vol sl down + tone porta
  5675.     bne.s    .1C
  5676.     addq.w    #3,d5
  5677.     lsr.w    #2,d5
  5678.     cmp.b    #15,d5
  5679.     ble.s    .19ok
  5680.     move.b    #15,d5
  5681. .19ok:    move.w    #$500,d2
  5682.     move.b    d5,d2
  5683.     bra    .fin
  5684. .1C    cmp.b    #$1C,d4        ; Vol sl up + vib
  5685.     bne.s    .1D
  5686.     addq.w    #3,d5
  5687.     add.w    d5,d5
  5688.     add.w    d5,d5
  5689.     and.w    #$F0,d5
  5690.     cmp.w    #$F0,d5
  5691.     ble.s    .1Cok
  5692.     move.w    #$F0,d5
  5693. .1Cok:    move.w    #$600,d2
  5694.     move.b    d5,d2
  5695.     bra    .fin
  5696. .1D:    cmp.b    #$1D,d4        ; Vol sl down + vib
  5697.     bne.s    .A4
  5698.     addq.w    #3,d5
  5699.     lsr.w    #2,d5
  5700.     cmp.b    #15,d5
  5701.     ble.s    .1Dok
  5702.     move.b    #15,d5
  5703. .1Dok:    move.w    #$600,d2
  5704.     move.b    d5,d2
  5705.     bra    .fin
  5706. .A4:    cmp.b    #$A4,d4        ; Fine vol sl up
  5707.     bne.s    .A5
  5708.     addq.w    #3,d5
  5709.     lsr.w    #2,d5
  5710.     cmp.b    #15,d5
  5711.     ble.s    .A4ok
  5712.     move.b    #15,d5
  5713. .A4ok:    move.w    #$EA0,d2
  5714.     add.b    d5,d2
  5715.     bra    .fin
  5716. .A5:    cmp.b    #$A5,d4        ; Fine vol sl down
  5717.     bne.s    .A8
  5718.     addq.w    #3,d5
  5719.     lsr.w    #2,d5
  5720.     cmp.b    #15,d5
  5721.     ble.s    .A5ok
  5722.     move.b    #15,d5
  5723. .A5ok:    move.w    #$EB0,d2
  5724.     add.b    d5,d2
  5725.     bra    .fin
  5726. .A8:    cmp.b    #$A8,d4        ; Set nbr of frames
  5727.     bne.s    .AA
  5728.     move.w    #$F00,d2
  5729.     move.b    d5,d2
  5730.     bra    .fin
  5731. .AA:    cmp.b    #$AA,d4        ; Pattern delay
  5732.     bne.s    .AB
  5733.     cmp.b    #15,d5
  5734.     ble.s    .AAok
  5735.     move.b    #15,d5
  5736. .AAok:    move.w    #$EE0,d2
  5737.     add.b    d5,d2
  5738.     bra    .fin
  5739. .AB:    cmp.b    #$AB,d4        ; Extra fine tone porta
  5740.     bne.s    .AC
  5741.     add.w    #15,d5        ; Arrondissement par excès
  5742.     lsr.w    #4,d5
  5743.     move.w    #$300,d2
  5744.     move.b    d5,d2
  5745.     bra    .fin
  5746. .AC:    cmp.b    #$AC,d4        ; Extra fine porta up
  5747.     bne.s    .AD
  5748.     add.w    #15,d5        ; Arrondissement par excès
  5749.     lsr.w    #4,d5
  5750.     move.w    #$100,d2
  5751.     move.b    d5,d2
  5752.     bra    .fin
  5753. .AD:    cmp.b    #$AD,d4        ; Extra fine porta down
  5754.     bne.s    .2xxx
  5755.     add.w    #15,d5        ; Arrondissement optimal
  5756.     lsr.w    #4,d5
  5757.     move.w    #$200,d2
  5758.     move.b    d5,d2
  5759.     bra    .fin
  5760.  
  5761. .B1:    cmp.b    #$B1,d4        ; Pattern loop
  5762.     bne.s    .2xxx
  5763.     cmp.b    #15,d5
  5764.     ble.s    .B1ok
  5765.     move.b    #15,d5
  5766. .B1ok:    move.w    #$EB0,d2
  5767.     add.b    d5,d2
  5768.     bra.s    .fin
  5769.  
  5770. .2xxx:    lsr.b    #4,d4        ; d4 = numéro de fonction à 1 chiffre
  5771.     and.w    #$FFF,d3        ; d3 = paramètre à 3 chiffres
  5772.     cmp.b    #$2,d4        ; Set volume
  5773.     bne.s    .3xxx
  5774.     lsr.w    #2,d3
  5775.     cmp.w    #$40,d5
  5776.     ble.s    .2xxxok
  5777.     move.w    #$40,d5
  5778. .2xxxok:    move.w    #$C00,d2
  5779.     move.b    d3,d2
  5780.     bra.s    .fin
  5781. .3xxx:    cmp.b    #$3,d4        ; Set exp vol
  5782.     bne.s    .4xxx
  5783.     ; *** A faire...
  5784.     bra.s    .fin
  5785. .4xxx:    cmp.b    #$4,d4        ; Set balance (-> effet 8xx et non E8x)
  5786.     bne.s    .7xxx
  5787.     lsr.w    #4,d3
  5788.     move.w    #$800,d2
  5789.     move.b    d3,d2
  5790.     bra.s    .fin
  5791. .7xxx:    cmp.b    #$7,d4        ; Roll
  5792.     bne.s    .8xxx
  5793.     lsr.w    #8,d3
  5794.     move.w    #$E90,d2
  5795.     add.b    d3,d2
  5796.     bra.s    .fin
  5797. .8xxx:    cmp.b    #$8,d4        ; Roll + vol slide + set balance
  5798.     bne.s    .9xxx
  5799.     and.w    #15,d3
  5800.     move.w    #$E90,d2
  5801.     add.b    d3,d2
  5802.     bra.s    .fin
  5803. .9xxx:    cmp.b    #$9,d4        ; Offset sample
  5804.     bne.s    .fin
  5805.     cmp.w    #$FF,d5
  5806.     ble.s    .9xxxok
  5807.     move.w    #$FF,d5
  5808. .9xxxok:    move.w    #$900,d2
  5809.     move.b    d3,d2
  5810.  
  5811. .fin:    add.w    d2,d1        ; Effet converti
  5812.     addq.l    #1,a0        ; Saute la colonne de volume
  5813.  
  5814.     move.l    d1,(a1)+
  5815.     dbra    d0,cv_gtk2nt_loop
  5816.  
  5817.     movem.l    (sp)+,d0-d5/a0-a3
  5818.     rts
  5819.  
  5820.  
  5821.  
  5822. *============================================================================*
  5823. *    Copie un sample 8 bits en le transformant en sample 16 bits    *
  5824. *    a0 = adresse du sample                *
  5825. *    a1 = adresse destination                *
  5826. *    d0 = longueur du sample 8 bits en octets            *
  5827. *============================================================================*
  5828. copy_sample_8_2_16:
  5829.     movem.l    d0/a0-a1,-(sp)
  5830.     add.l    d0,a0
  5831.     add.l    d0,a1
  5832.     add.l    d0,a1
  5833.     subq.l    #1,d0
  5834.     bmi.s    .fin
  5835.     swap    d0
  5836. .loop1:    swap    d0
  5837. .loop2:    clr.b    -(a1)
  5838.     move.b    -(a0),-(a1)
  5839.     dbra    d0,.loop2
  5840.     swap    d0
  5841.     dbra    d0,.loop1
  5842. .fin:    movem.l    (sp)+,d0/a0-a1
  5843.     rts
  5844.  
  5845.  
  5846.  
  5847. *============================================================================*
  5848. *    Copie un sample 16 bits en le transformant en sample 8 bits    *
  5849. *    a0 = adresse du sample                *
  5850. *    a1 = adresse destination                *
  5851. *    d0 = longueur du sample 16 bits en octets            *
  5852. *============================================================================*
  5853. copy_sample_16_2_8:
  5854.     movem.l    d0/a0-a1,-(sp)
  5855.     lsr.l    #1,d0
  5856.     subq.l    #1,d0
  5857.     bmi.s    .fin
  5858.     swap    d0
  5859. .loop1:    swap    d0
  5860. .loop2:    move.b    (a0)+,(a1)+
  5861.     addq.l    #1,a0
  5862.     dbra    d0,.loop2
  5863.     swap    d0
  5864.     dbra    d0,.loop1
  5865. .fin:    movem.l    (sp)+,d0/a0-a1
  5866.     rts
  5867.  
  5868.  
  5869.  
  5870. *============================================================================*
  5871. *    Inverse un morceau de mémoire                *
  5872. *    a0 = adresse                    *
  5873. *    d0 = longueur.l en octets à inverser            *
  5874. *    d1 = nombre.w d'octets par unité de mémoire à inverser (1 ou 2)    *
  5875. *============================================================================*
  5876. invert_memory:
  5877.     movem.l    d0-d1/a0-a1,-(sp)
  5878.     lea    (a0,d0.l),a1
  5879.     lsr.l    #1,d0        ; Compteur : la moitié de la longueur (par défaut)
  5880.     cmp.w    #2,d1
  5881.     beq.s    .word
  5882.  
  5883.     subq.l    #1,d0        ; Inversion d'octets
  5884.     swap    d0
  5885. .loop_b1:    swap    d0
  5886. .loop_b2:    move.b    (a0),d1
  5887.     move.b    -(a1),(a0)+
  5888.     move.b    d1,(a1)
  5889.     dbra    d0,.loop_b2
  5890.     swap    d0
  5891.     dbra    d0,.loop_b1
  5892.     bra.s    .fin
  5893.  
  5894. .word:    lsr.l    #1,d0        ; La moitié car inversion de mots
  5895.     subq.l    #1,d0
  5896.     swap    d0
  5897. .loop_w1:    swap    d0
  5898. .loop_w2:    move.w    (a0),d1
  5899.     move.w    -(a1),(a0)+
  5900.     move.w    d1,(a1)
  5901.     dbra    d0,.loop_w2
  5902.     swap    d0
  5903.     dbra    d0,.loop_w1
  5904.  
  5905. .fin:    movem.l    (sp)+,d0-d1/a0-a1
  5906.     rts
  5907.  
  5908.  
  5909.  
  5910. *============================================================================*
  5911. *    Routine de décompression de l'Atomik Packer 3.5        *
  5912. *    a0 = adresse du fichier à décompresser            *
  5913. *============================================================================*
  5914. atomik_35_unpack:
  5915.     movem.l    a0-a6/d0-d7,-(a7)
  5916.     cmp.l    #$41544d35,(a0)+    ; Identificateur 'ATM5'
  5917.     bne    atm35_e1
  5918.     link    a2,#-$1c
  5919.     move.l    (a0)+,d0
  5920.     lea    4(a0,d0.l),a5
  5921.     move.l    d0,-(a7)
  5922.     move.l    a5,a4
  5923.     lea    128(a4),a5
  5924.     lea    -12(a4),a4
  5925.     move.l    (a0)+,d0
  5926.     move.l    a0,a6
  5927.     add.l    d0,a6
  5928.     moveq    #0,d0
  5929.     move.b    -(a6),d0
  5930.     move.w    d0,-2(a2)
  5931.     lsl.w    #2,d0
  5932.     sub.w    d0,a4
  5933.     lea    atm35_eb(pc),a3
  5934.     move.w    -2(a2),d0
  5935.     lsl.w    #2,d0
  5936.     add.w    #$8c,d0
  5937.     bra.s    atm35_b5
  5938. atm35_b4:    move.b    (a4)+,(a3)+
  5939.     subq.w    #1,d0
  5940. atm35_b5:    bne.s    atm35_b4
  5941.     movem.l    a3-a4,-(a7)
  5942.     pea    (a5)
  5943.     move.b    -(a6),d7
  5944.     bra    atm35_d5
  5945. atm35_b6:    move.w    d3,d5
  5946. atm35_b7:    add.b    d7,d7
  5947. atm35_b8:    dbcs    d5,atm35_b7
  5948.     beq.s    atm35_bb
  5949.     bcc.s    atm35_b9
  5950.     sub.w    d3,d5
  5951.     neg.w    d5
  5952.     bra.s    atm35_be
  5953. atm35_b9:    moveq    #3,d6
  5954.     bsr.s    atm35_c4
  5955.     beq.s    atm35_ba
  5956.     bra.s    atm35_bd
  5957. atm35_ba:    moveq    #7,d6
  5958.     bsr.s    atm35_c4
  5959.     beq.s    atm35_bc
  5960.     add.w    #$f,d5
  5961.     bra.s    atm35_bd
  5962. atm35_bb:    move.b    -(a6),d7
  5963.     addx.b    d7,d7
  5964.     bra.s    atm35_b8
  5965. atm35_bc:    moveq    #$d,d6
  5966.     bsr.s    atm35_c4
  5967.     add.w    #$10e,d5
  5968. atm35_bd:    add.w    d3,d5
  5969. atm35_be:    lea    atm35_e2(pc),a4
  5970.     move.w    d5,d2
  5971.     bne.s    atm35_c8
  5972.     add.b    d7,d7
  5973.     bne.s    atm35_bf
  5974.     move.b    -(a6),d7
  5975.     addx.b    d7,d7
  5976. atm35_bf:    bcs.s    atm35_c0
  5977.     moveq    #1,d6
  5978.     bra.s    atm35_c9
  5979. atm35_c0:    moveq    #3,d6
  5980.     bsr.s    atm35_c4
  5981.     tst.b    -28(a2)
  5982.     beq.s    atm35_c1
  5983.     move.b    -18(a2,d5.w),-(a5)
  5984.     bra    atm35_d4
  5985. atm35_c1:    move.b    (a5),d0
  5986.     btst    #3,d5
  5987.     bne.s    atm35_c2
  5988.     bra.s    atm35_c3
  5989. atm35_c2:    add.b    #-$10,d5
  5990. atm35_c3:    sub.b    d5,d0
  5991.     move.b    d0,-(a5)
  5992.     bra    atm35_d4
  5993. atm35_c4:    clr.w    d5
  5994. atm35_c5:    add.b    d7,d7
  5995.     beq.s    atm35_c7
  5996. atm35_c6:    addx.w    d5,d5
  5997.     dbra    d6,atm35_c5
  5998.     tst.w    d5
  5999.     rts
  6000. atm35_c7:    move.b    -(a6),d7
  6001.     addx.b    d7,d7
  6002.     bra.s    atm35_c6
  6003. atm35_c8:    moveq    #2,d6
  6004. atm35_c9:    bsr.s    atm35_c4
  6005.     move.w    d5,d4
  6006.     move.b    14(a4,d4.w),d6
  6007.     ext.w    d6
  6008.     tst.b    -27(a2)
  6009.     bne.s    atm35_ca
  6010.     addq.w    #4,d6
  6011.     bra.s    atm35_ce
  6012. atm35_ca:    bsr.s    atm35_c4
  6013.     move.w    d5,d1
  6014.     lsl.w    #4,d1
  6015.     moveq    #2,d6
  6016.     bsr.s    atm35_c4
  6017.     cmp.b    #7,d5
  6018.     blt.s    atm35_cc
  6019.     moveq    #0,d6
  6020.     bsr.s    atm35_c4
  6021.     beq.s    atm35_cb
  6022.     moveq    #2,d6
  6023.     bsr.s    atm35_c4
  6024.     add.w    d5,d5
  6025.     or.w    d1,d5
  6026.     bra.s    atm35_cf
  6027. atm35_cb:    or.b    -26(a2),d1
  6028.     bra.s    atm35_cd
  6029. atm35_cc:    or.b    -25(a2,d5.w),d1
  6030. atm35_cd:    move.w    d1,d5
  6031.     bra.s    atm35_cf
  6032. atm35_ce:    bsr.s    atm35_c4
  6033. atm35_cf:    add.w    d4,d4
  6034.     beq.s    atm35_d0
  6035.     add.w    -2(a4,d4.w),d5
  6036. atm35_d0:    lea    1(a5,d5.w),a4
  6037.     move.b    -(a4),-(a5)
  6038. atm35_d1:    move.b    -(a4),-(a5)
  6039.     dbra    d2,atm35_d1
  6040.     bra.s    atm35_d4
  6041. atm35_d2:    add.b    d7,d7
  6042.     bne.s    atm35_d3
  6043.     move.b    -(a6),d7
  6044.     addx.b    d7,d7
  6045. atm35_d3:    bcs.s    atm35_dd
  6046.     move.b    -(a6),-(a5)
  6047. atm35_d4:    cmp.l    a5,a3
  6048.     bne.s    atm35_d2
  6049.     cmp.l    a6,a0
  6050.     beq.s    atm35_de
  6051. atm35_d5:    moveq    #0,d6
  6052.     bsr    atm35_c4
  6053.     beq.s    atm35_d8
  6054.     move.b    -(a6),d0
  6055.     lea    -26(a2),a1
  6056.     move.b    d0,(a1)+
  6057.     moveq    #1,d1
  6058.     moveq    #6,d2
  6059. atm35_d6:    cmp.b    d0,d1
  6060.     bne.s    atm35_d7
  6061.     addq.w    #2,d1
  6062. atm35_d7:    move.b    d1,(a1)+
  6063.     addq.w    #2,d1
  6064.     dbra    d2,atm35_d6
  6065.     st    -27(a2)
  6066.     bra.s    atm35_d9
  6067. atm35_d8:    sf    -27(a2)
  6068. atm35_d9:    moveq    #0,d6
  6069.     bsr    atm35_c4
  6070.     beq.s    atm35_db
  6071.     lea    -18(a2),a1
  6072.     moveq    #$f,d0
  6073. atm35_da:    move.b    -(a6),(a1)+
  6074.     dbra    d0,atm35_da
  6075.     st    -28(a2)
  6076.     bra.s    atm35_dc
  6077. atm35_db:    sf    -28(a2)
  6078. atm35_dc:    clr.w    d3
  6079.     move.b    -(a6),d3
  6080.     move.b    -(a6),d0
  6081.     lsl.w    #8,d0
  6082.     move.b    -(a6),d0
  6083.     move.l    a5,a3
  6084.     sub.w    d0,a3
  6085.     bra.s    atm35_d2
  6086. atm35_dd:    bra    atm35_b6
  6087. atm35_de:    move.l    (a7)+,a0
  6088.     pea    (a2)
  6089.     bsr.s    atm35_e3
  6090.     move.l    (a7)+,a2
  6091.     movem.l    (a7)+,a3-a4
  6092.     move.l    (a7)+,d0
  6093.     bsr    atm35_e9
  6094.     move.w    -2(a2),d0
  6095.     lsl.w    #2,d0
  6096.     add.w    #$8c,d0
  6097.     bra.s    atm35_e0
  6098. atm35_df:    move.b    -(a3),-(a4)
  6099.     subq.w    #1,d0
  6100. atm35_e0:    bne.s    atm35_df
  6101.     unlk    a2
  6102. atm35_e1:    movem.l    (a7)+,a0-a6/d0-d7
  6103.     rts
  6104. atm35_e2:    dc.b    $00,$20,$00,$60,$01,$60,$03,$60
  6105.     dc.b    $07,$60,$0f,$60,$1f,$60,$00,$01
  6106.     dc.b    $03,$04,$05,$06,$07,$08
  6107. atm35_e3:    move.w    -2(a2),d7
  6108. atm35_e4:    dbra    d7,atm35_e5
  6109.     rts
  6110. atm35_e5:    move.l    -(a0),d0
  6111.     lea    0(a5,d0.l),a1
  6112.     lea    32000(a1),a2
  6113. atm35_e6:    moveq    #3,d6
  6114. atm35_e7:    move.w    (a1)+,d0
  6115.     moveq    #3,d5
  6116. atm35_e8:    add.w    d0,d0
  6117.     addx.w    d1,d1
  6118.     add.w    d0,d0
  6119.     addx.w    d2,d2
  6120.     add.w    d0,d0
  6121.     addx.w    d3,d3
  6122.     add.w    d0,d0
  6123.     addx.w    d4,d4
  6124.     dbra    d5,atm35_e8
  6125.     dbra    d6,atm35_e7
  6126.     movem.w    d1-d4,-8(a1)
  6127.     cmp.l    a1,a2
  6128.     bne.s    atm35_e6
  6129.     bra.s    atm35_e4
  6130. atm35_e9:    lsr.l    #4,d0
  6131.     lea    -12(a6),a6
  6132. atm35_ea:    move.l    (a5)+,(a6)+
  6133.     move.l    (a5)+,(a6)+
  6134.     move.l    (a5)+,(a6)+
  6135.     move.l    (a5)+,(a6)+
  6136.     dbra    d0,atm35_ea
  6137.     rts
  6138.  
  6139.  
  6140.  
  6141. *============================================================================*
  6142. *    Unpacking routine of PACK-ICE 2.4            *
  6143. *    a0 = Adress of packed data                *
  6144. *============================================================================*
  6145. packice_24_unpack:
  6146.     link    a3,#-120
  6147.     movem.l    d0-a6,-(sp)
  6148.     lea    120(a0),a4
  6149.     move.l    a4,a6
  6150.     bsr    .getinfo
  6151.     cmpi.l    #'ICE!',d0
  6152.     bne    .not_packed
  6153.     bsr.s    .getinfo
  6154.     lea.l    -8(a0,d0.l),a5
  6155.     bsr.s    .getinfo
  6156.     move.l    d0,(sp)
  6157.     adda.l    d0,a6
  6158.     move.l    a6,a1
  6159.  
  6160.     moveq    #119,d0
  6161. .save:    move.b    -(a1),-(a3)
  6162.     dbf    d0,.save
  6163.     move.l    a6,a3
  6164.     move.b    -(a5),d7
  6165.     bsr.s    .normal_bytes
  6166.     move.l    a3,a5
  6167.  
  6168.  
  6169.     bsr    .get_1_bit
  6170.     bcc.s    .no_picture
  6171.     move.w    #$0f9f,d7
  6172.     bsr    .get_1_bit
  6173.     bcc.s    .ice_00
  6174.     moveq    #15,d0
  6175.     bsr    .get_d0_bits
  6176.     move.w    d1,d7
  6177. .ice_00:    moveq    #3,d6
  6178. .ice_01:    move.w    -(a3),d4
  6179.     moveq    #3,d5
  6180. .ice_02:    add.w    d4,d4
  6181.     addx.w    d0,d0
  6182.     add.w    d4,d4
  6183.     addx.w    d1,d1
  6184.     add.w    d4,d4
  6185.     addx.w    d2,d2
  6186.     add.w    d4,d4
  6187.     addx.w    d3,d3
  6188.     dbra    d5,.ice_02
  6189.     dbra    d6,.ice_01
  6190.     movem.w    d0-d3,(a3)
  6191.     dbra    d7,.ice_00
  6192. .no_picture
  6193.     movem.l    (sp),d0-a3
  6194.  
  6195. .move    move.b    (a4)+,(a0)+
  6196.     subq.l    #1,d0
  6197.     bne.s    .move
  6198.     moveq    #119,d0
  6199. .rest    move.b    -(a3),-(a5)
  6200.     dbf    d0,.rest
  6201. .not_packed:
  6202.     movem.l    (sp)+,d0-a6
  6203.     unlk    a3
  6204.     rts
  6205.  
  6206. .getinfo: moveq    #3,d1
  6207. .getbytes: lsl.l    #8,d0
  6208.     move.b    (a0)+,d0
  6209.     dbf    d1,.getbytes
  6210.     rts
  6211.  
  6212. .normal_bytes:    
  6213.     bsr.s    .get_1_bit
  6214.     bcc.s    .test_if_end
  6215.     moveq.l    #0,d1
  6216.     bsr.s    .get_1_bit
  6217.     bcc.s    .copy_direkt
  6218.     lea.l    .direkt_tab+20(pc),a1
  6219.     moveq.l    #4,d3
  6220. .nextgb:    move.l    -(a1),d0
  6221.     bsr.s    .get_d0_bits
  6222.     swap.w    d0
  6223.     cmp.w    d0,d1
  6224.     dbne    d3,.nextgb
  6225. .no_more: add.l    20(a1),d1
  6226. .copy_direkt:    
  6227.     move.b    -(a5),-(a6)
  6228.     dbf    d1,.copy_direkt
  6229. .test_if_end:    
  6230.     cmpa.l    a4,a6
  6231.     bgt.s    .strings
  6232.     rts    
  6233.  
  6234. .get_1_bit:
  6235.     add.b    d7,d7
  6236.     bne.s    .bitfound
  6237.     move.b    -(a5),d7
  6238.     addx.b    d7,d7
  6239. .bitfound:
  6240.     rts    
  6241.  
  6242. .get_d0_bits:    
  6243.     moveq.l    #0,d1
  6244. .hole_bit_loop:    
  6245.     add.b    d7,d7
  6246.     bne.s    .on_d0
  6247.     move.b    -(a5),d7
  6248.     addx.b    d7,d7
  6249. .on_d0:    addx.w    d1,d1
  6250.     dbf    d0,.hole_bit_loop
  6251.     rts    
  6252.  
  6253.  
  6254. .strings: lea.l    .length_tab(pc),a1
  6255.     moveq.l    #3,d2
  6256. .get_length_bit:    
  6257.     bsr.s    .get_1_bit
  6258.     dbcc    d2,.get_length_bit
  6259. .no_length_bit:    
  6260.     moveq.l    #0,d4
  6261.     moveq.l    #0,d1
  6262.     move.b    1(a1,d2.w),d0
  6263.     ext.w    d0
  6264.     bmi.s    .no_über
  6265. .get_über:
  6266.     bsr.s    .get_d0_bits
  6267. .no_über:    move.b    6(a1,d2.w),d4
  6268.     add.w    d1,d4
  6269.     beq.s    .get_offset_2
  6270.  
  6271.  
  6272.     lea.l    .more_offset(pc),a1
  6273.     moveq.l    #1,d2
  6274. .getoffs: bsr.s    .get_1_bit
  6275.     dbcc    d2,.getoffs
  6276.     moveq.l    #0,d1
  6277.     move.b    1(a1,d2.w),d0
  6278.     ext.w    d0
  6279.     bsr.s    .get_d0_bits
  6280.     add.w    d2,d2
  6281.     add.w    6(a1,d2.w),d1
  6282.     bpl.s    .depack_bytes
  6283.     sub.w    d4,d1
  6284.     bra.s    .depack_bytes
  6285.  
  6286.  
  6287. .get_offset_2:    
  6288.     moveq.l    #0,d1
  6289.     moveq.l    #5,d0
  6290.     moveq.l    #-1,d2
  6291.     bsr.s    .get_1_bit
  6292.     bcc.s    .less_40
  6293.     moveq.l    #8,d0
  6294.     moveq.l    #$3f,d2
  6295. .less_40: bsr.s    .get_d0_bits
  6296.     add.w    d2,d1
  6297.  
  6298. .depack_bytes:
  6299.     lea.l    2(a6,d4.w),a1
  6300.     adda.w    d1,a1
  6301.     move.b    -(a1),-(a6)
  6302. .dep_b:    move.b    -(a1),-(a6)
  6303.     dbf    d4,.dep_b
  6304.     bra    .normal_bytes
  6305.  
  6306.  
  6307. .direkt_tab:
  6308.     dc.l    $7fff000e,$00ff0007,$00070002,$00030001,$00030001
  6309.     dc.l    270-1,15-1,8-1,5-1,2-1
  6310.  
  6311. .length_tab:
  6312.     dc.b    9,1,0,-1,-1
  6313.     dc.b    8,4,2,1,0
  6314.  
  6315. .more_offset:
  6316.     dc.b    11,4,7,0        ; Bits lesen
  6317.     dc.w    $11f,-1,$1f    ; Standard Offset
  6318.  
  6319.  
  6320.  
  6321. *============================================================================*
  6322. *    Unpacking source for Pack-Ice Version 2.1            *
  6323. *    a0 = pointer on packed data                *
  6324. *============================================================================*
  6325. packice_21_unpack:
  6326.     movem.l d0-a6,-(sp)        ; save registers
  6327.     cmpi.l    #'Ice!',(a0)+    ; Data packed?
  6328.     bne.s    .ice2_07        ; no!
  6329.     move.l    (a0)+,d0
  6330.     lea    -8(a0,d0.l),a5
  6331.     move.l    (a0)+,(sp)
  6332.     lea    108(a0),a4
  6333.     movea.l a4,a6
  6334.     adda.l    (sp),a6
  6335.     movea.l a6,a3
  6336.     movea.l a6,a1        ; save 120 bytes
  6337.     lea    ice2_21+120(pc),a2    ; at the end of the
  6338.     moveq    #$77,d0        ; unpacked data
  6339. .ice2_00:    move.b    -(a1),-(a2)
  6340.     dbra    d0,.ice2_00
  6341.     bsr    .ice2_0c
  6342.     bsr.s    .ice2_08
  6343.     bsr    .ice2_10        ;; Picture decrunch!
  6344.     bcc.s    .ice2_04        ;; These marked lines are only
  6345.     movea.l a3,a1        ;; necessary, if you selected the
  6346.     move.w    #$0f9f,d7        ;; additional picture packer
  6347. .ice2_01:    moveq    #3,d6        ;; in Pack-Ice.
  6348. .ice2_02:    move.w    -(a1),d4        ;;
  6349.     moveq    #3,d5        ;; If you never use the picture
  6350. .ice2_03:    add.w    d4,d4        ;; pack option, you may delete
  6351.     addx.w    d0,d0        ;; all the lines marked with ";;"
  6352.     add.w    d4,d4        ;;
  6353.     addx.w    d1,d1        ;;
  6354.     add.w    d4,d4        ;;
  6355.     addx.w    d2,d2        ;;
  6356.     add.w    d4,d4        ;;
  6357.     addx.w    d3,d3        ;;
  6358.     dbra    d5,.ice2_03    ;;
  6359.     dbra    d6,.ice2_02    ;;
  6360.     movem.w d0-d3,(a1)        ;;
  6361.     dbra    d7,.ice2_01    ;;
  6362. .ice2_04:    move.l    (sp),d0        ; move all data to
  6363.     lea    -120(a4),a1    ; 120 bytes lower
  6364. .ice2_05:    move.b    (a4)+,(a1)+
  6365.     dbra    d0,.ice2_05
  6366.     subi.l    #$010000,d0
  6367.     bpl.s    .ice2_05
  6368.     moveq    #$77,d0        ; restore saved data
  6369.     lea    ice2_21+120(pc),a2
  6370. .ice2_06:    move.b    -(a2),-(a3)
  6371.     dbra    d0,.ice2_06
  6372. .ice2_07:    movem.l (sp)+,d0-a6        ; restore registers
  6373.     rts
  6374. .ice2_08:    bsr.s    .ice2_10
  6375.     bcc.s    .ice2_0b
  6376.     moveq    #0,d1
  6377.     bsr.s    .ice2_10
  6378.     bcc.s    .ice2_0a
  6379.     lea    .ice2_1e(pc),a1
  6380.     moveq    #4,d3
  6381. .ice2_09:    move.l    -(a1),d0
  6382.     bsr.s    .ice2_13
  6383.     swap    d0
  6384.     cmp.w    d0,d1
  6385.     dbne    d3,.ice2_09
  6386.     add.l    20(a1),d1
  6387. .ice2_0a:    move.b    -(a5),-(a6)
  6388.     dbra    d1,.ice2_0a
  6389. .ice2_0b:    cmpa.l    a4,a6
  6390.     bgt.s    .ice2_16
  6391.     rts
  6392. .ice2_0c:    moveq    #3,d0
  6393. .ice2_0d:    move.b    -(a5),d7
  6394.     ror.l    #8,d7
  6395.     dbra    d0,.ice2_0d
  6396.     rts
  6397. .ice2_0e:    move.w    a5,d7
  6398.     btst    #0,d7
  6399.     bne.s    .ice2_0f
  6400.     move.l    -(a5),d7
  6401.     addx.l    d7,d7
  6402.     bra.s    .ice2_15
  6403. .ice2_0f:    move.l    -5(a5),d7
  6404.     lsl.l    #8,d7
  6405.     move.b    -(a5),d7
  6406.     subq.l    #3,a5
  6407.     add.l    d7,d7
  6408.     bset    #0,d7
  6409.     bra.s    .ice2_15
  6410. .ice2_10:    add.l    d7,d7
  6411.     beq.s    .ice2_11
  6412.     rts
  6413. .ice2_11:    move.w    a5,d7
  6414.     btst    #0,d7
  6415.     bne.s    .ice2_12
  6416.     move.l    -(a5),d7
  6417.     addx.l    d7,d7
  6418.     rts
  6419. .ice2_12:    move.l    -5(a5),d7
  6420.     lsl.l    #8,d7
  6421.     move.b    -(a5),d7
  6422.     subq.l    #3,a5
  6423.     add.l    d7,d7
  6424.     bset    #0,d7
  6425.     rts
  6426. .ice2_13:    moveq    #0,d1
  6427. .ice2_14:    add.l    d7,d7
  6428.     beq.s    .ice2_0e
  6429. .ice2_15:    addx.w    d1,d1
  6430.     dbra    d0,.ice2_14
  6431.     rts
  6432. .ice2_16:    lea    .ice2_1f(pc),a1
  6433.     moveq    #3,d2
  6434. .ice2_17:    bsr.s    .ice2_10
  6435.     dbcc    d2,.ice2_17
  6436.     moveq    #0,d4
  6437.     moveq    #0,d1
  6438.     move.b    1(a1,d2.w),d0
  6439.     ext.w    d0
  6440.     bmi.s    .ice2_18
  6441.     bsr.s    .ice2_13
  6442. .ice2_18:    move.b    6(a1,d2.w),d4
  6443.     add.w    d1,d4
  6444.     beq.s    .ice2_1a
  6445.     lea    .ice2_20(pc),a1
  6446.     moveq    #1,d2
  6447. .ice2_19:    bsr.s    .ice2_10
  6448.     dbcc    d2,.ice2_19
  6449.     moveq    #0,d1
  6450.     move.b    1(a1,d2.w),d0
  6451.     ext.w    d0
  6452.     bsr.s    .ice2_13
  6453.     add.w    d2,d2
  6454.     add.w    6(a1,d2.w),d1
  6455.     bra.s    .ice2_1c
  6456. .ice2_1a:    moveq    #0,d1
  6457.     moveq    #5,d0
  6458.     moveq    #0,d2
  6459.     bsr.s    .ice2_10
  6460.     bcc.s    .ice2_1b
  6461.     moveq    #8,d0
  6462.     moveq    #$40,d2
  6463. .ice2_1b:    bsr.s    .ice2_13
  6464.     add.w    d2,d1
  6465. .ice2_1c:    lea    2(a6,d4.w),a1
  6466.     adda.w    d1,a1
  6467.     move.b    -(a1),-(a6)
  6468. .ice2_1d:    move.b    -(a1),-(a6)
  6469.     dbra    d4,.ice2_1d
  6470.     bra    .ice2_08
  6471.     dc.b $7f,$ff,$00,$0e,$00,$ff,$00,$07
  6472.     dc.b $00,$07,$00,$02,$00,$03,$00,$01
  6473.     dc.b $00,$03,$00,$01
  6474. .ice2_1e:    dc.b $00,$00,$01,$0d,$00,$00,$00,$0e
  6475.     dc.b $00,$00,$00,$07,$00,$00,$00,$04
  6476.     dc.b $00,$00,$00,$01
  6477. .ice2_1f:    dc.b $09,$01,$00,$ff,$ff,$08,$04,$02
  6478.     dc.b $01,$00
  6479. .ice2_20:    dc.b $0b,$04,$07,$00,$01,$20,$00,$00
  6480.     dc.b $00,$20
  6481.  
  6482.  
  6483.  
  6484. *============================================================================*
  6485. *    Copie un groupe de note dans la partition                   Type:    *
  6486. *    a0 = pointeur sur un champ de description (à mettre : x ) : 0 1 2    *
  6487. *         -  0 : Adresse.l de la première note source à copier   x x x    *
  6488. *         -  4 : Adresse.l destination (ou transposition)        x x x    *
  6489. *         -  8 : Incrément.l entre chaque ligne                  x x x    *
  6490. *         - 12 : Nombre.w de lignes à copier                     x x x    *
  6491. *         - 14 : Adresses.4l des masques de bloc a1, a2, b1, b2  x x x    *
  6492. *         - 30 : Maskblock.w (0 ou 1)                            x x x    *
  6493. *         - 32 : Replaceblock.w (0 ou 1)                         x x x    *
  6494. *         - 34 : Nombre.w de pistes dans un pattern                x    *
  6495. *         - 36 : Nombre.w de pistes dans ce preset                   x    *
  6496. *         - 38 : Type.w de copie : 0=pattern, 1=piste, 2=preset  x x x    *
  6497. *         - 40 : Adresse.l du tableau d'arrangement des pistes       x    *
  6498. *                (sur le bon preset)                *
  6499. *============================================================================*
  6500.         rsreset
  6501. adrsour_bl:    rs.l    1
  6502. adrdest_bl:    rs.l    1
  6503. increm_bl:        rs.l    1
  6504. nlines_bl:        rs.w    1
  6505. adra1_bl:        rs.l    1
  6506. adra2_bl:        rs.l    1
  6507. adrb1_bl:        rs.l    1
  6508. adrb2_bl:        rs.l    1
  6509. maskblock_bl:    rs.w    1
  6510. replaceblock_bl:    rs.w    1
  6511. nbr_track_bl:    rs.w    1
  6512. preset_ntrk_bl:    rs.w    1
  6513. type_bl:        rs.w    1
  6514. adrpreset_bl:    rs.l    1
  6515.  
  6516. paste_note_block:
  6517.     movem.l    d0-d3/a1-a5,-(sp)
  6518.     move.l    adrsour_bl(a0),a1    ; a1 = adresse source
  6519.     move.l    adrdest_bl(a0),a2    ; a2 = adresse destination
  6520.     move.l    adrpreset_bl(a0),a3    ; a3 = adresse du preset
  6521.     move.l    increm_bl(a0),d0    ; d0 = incrément de ligne
  6522.     move.w    nlines_bl(a0),d1    ; d1 = compteur de lignes
  6523.     subq.w    #1,d1
  6524.     tst.w    type_bl(a0)
  6525.     bne.s    pnb_pattern
  6526.  
  6527. pnbtra_loop:            ; Track
  6528.     bsr    copie_note
  6529.     add.l    d0,a1
  6530.     add.l    d0,a2
  6531.     dbra    d1,pnbtra_loop
  6532.     bra.s    pnb_fin
  6533.  
  6534. pnb_pattern:            ; Pattern
  6535.     cmp.w    #1,type_bl(a0)
  6536.     bne.s    pnb_preset
  6537. pnbpat_loop1:
  6538.     move.l    a1,a4
  6539.     move.l    a2,a5
  6540.     move.w    nbr_track_bl(a0),d2
  6541.     subq.w    #1,d2
  6542. pnbpat_loop2:
  6543.     bsr    copie_note
  6544.     addq.l    #5,a1
  6545.     addq.l    #5,a2
  6546.     dbra    d2,pnbpat_loop2
  6547.     move.l    a4,a1
  6548.     move.l    a5,a2
  6549.     add.l    d0,a1
  6550.     add.l    d0,a2
  6551.     dbra    d1,pnbpat_loop1
  6552.     bra.s    pnb_fin
  6553.  
  6554. pnb_preset:            ; Preset
  6555. pnbpre_loop1:
  6556.     move.w    preset_ntrk_bl(a0),d2
  6557.     subq.w    #1,d2
  6558.     move.l    a1,a4
  6559.     move.l    a2,a5
  6560. pnbpre_loop2:
  6561.     move.w    (a3,d2.w*2),d3
  6562.     mulu.w    #5,d3
  6563.     add.l    d3,a1
  6564.     add.l    d3,a2
  6565.     bsr    copie_note
  6566.     move.l    a4,a1
  6567.     move.l    a5,a2
  6568.     dbra    d2,pnbpre_loop2
  6569.     add.l    d0,a1
  6570.     add.l    d0,a2
  6571.     dbra    d1,pnbpre_loop1
  6572.  
  6573. pnb_fin:
  6574.     movem.l    (sp)+,d0-d3/a1-a5
  6575.     rts
  6576.  
  6577.  
  6578.  
  6579. *============================================================================*
  6580. *    Echange des blocs de note dans un pattern            *
  6581. *    a0 = adresse des infos (voir + haut)            *
  6582. *    Pas besoin des masque ou de transparence (swap bourrin)    *
  6583. *============================================================================*
  6584. swap_note_block:
  6585.     movem.l    d0-d3/a1-a5,-(sp)
  6586.     move.l    adrsour_bl(a0),a1    ; a1 = adresse source
  6587.     move.l    adrdest_bl(a0),a2    ; a2 = adresse destination
  6588.     move.l    adrpreset_bl(a0),a3    ; a3 = adresse du preset
  6589.     move.l    increm_bl(a0),d0    ; d0 = incrément de ligne
  6590.     move.w    nlines_bl(a0),d1    ; d1 = compteur de lignes
  6591.     subq.w    #1,d1
  6592.     tst.w    type_bl(a0)
  6593.     bne.s    snb_pattern
  6594.  
  6595. snbtra_loop:            ; Track
  6596.     move.l    (a1),d3
  6597.     move.l    (a2),(a1)
  6598.     move.l    d3,(a2)
  6599.     move.b    4(a1),d3
  6600.     move.b    4(a2),4(a1)
  6601.     move.b    d3,4(a2)
  6602.     add.l    d0,a1
  6603.     add.l    d0,a2
  6604.     dbra    d1,snbtra_loop
  6605.     bra.s    snb_fin
  6606.  
  6607. snb_pattern:            ; Pattern
  6608.     cmp.w    #1,type_bl(a0)
  6609.     bne.s    snb_preset
  6610. snbpat_loop1:
  6611.     move.l    a1,a4
  6612.     move.l    a2,a5
  6613.     move.w    nbr_track_bl(a0),d2
  6614.     subq.w    #1,d2
  6615. snbpat_loop2:
  6616.     move.l    (a1),d3
  6617.     move.l    (a2),(a1)
  6618.     move.l    d3,(a2)
  6619.     move.b    4(a1),d3
  6620.     move.b    4(a2),4(a1)
  6621.     move.b    d3,4(a2)
  6622.     addq.l    #5,a1
  6623.     addq.l    #5,a2
  6624.     dbra    d2,snbpat_loop2
  6625.     move.l    a4,a1
  6626.     move.l    a5,a2
  6627.     add.l    d0,a1
  6628.     add.l    d0,a2
  6629.     dbra    d1,snbpat_loop1
  6630.     bra.s    snb_fin
  6631.  
  6632. snb_preset:            ; Preset
  6633. snbpre_loop1:
  6634.     move.w    preset_ntrk_bl(a0),d2
  6635.     subq.w    #1,d2
  6636.     move.l    a1,a4
  6637.     move.l    a2,a5
  6638. snbpre_loop2:
  6639.     move.w    (a3,d2.w*2),d3
  6640.     mulu.w    #5,d3
  6641.     add.l    d3,a1
  6642.     add.l    d3,a2
  6643.     move.l    (a1),d3
  6644.     move.l    (a2),(a1)
  6645.     move.l    d3,(a2)
  6646.     move.b    4(a1),d3
  6647.     move.b    4(a2),4(a1)
  6648.     move.b    d3,4(a2)
  6649.     move.l    a4,a1
  6650.     move.l    a5,a2
  6651.     dbra    d2,snbpre_loop2
  6652.     add.l    d0,a1
  6653.     add.l    d0,a2
  6654.     dbra    d1,snbpre_loop1
  6655.  
  6656. snb_fin:
  6657.     movem.l    (sp)+,d0-d3/a1-a5
  6658.     rts
  6659.  
  6660.  
  6661.  
  6662. *============================================================================*
  6663. *    Efface un bloc de notes dans un pattern            *
  6664. *    a0 = adresse des infos (voir plus haut)            *
  6665. *    Adresse source nécessaire                *
  6666. *    Pas besoin de masque destination                *
  6667. *============================================================================*
  6668. clear_note_block:
  6669.     movem.l    d0-d3/a1-a3,-(sp)
  6670.     move.l    adrsour_bl(a0),a1    ; a1 = adresse source
  6671.     move.l    adrpreset_bl(a0),a3    ; a3 = adresse du preset
  6672.     move.l    increm_bl(a0),d0    ; d0 = incrément de ligne
  6673.     move.w    nlines_bl(a0),d1    ; d1 = compteur de lignes
  6674.     subq.w    #1,d1
  6675.     tst.w    type_bl(a0)
  6676.     bne.s    cnb_pattern
  6677.  
  6678. cnbtra_loop:            ; Track
  6679.     bsr    clear_note
  6680.     add.l    d0,a1
  6681.     dbra    d1,cnbtra_loop
  6682.     bra.s    cnb_fin
  6683.  
  6684. cnb_pattern:            ; Pattern
  6685.     cmp.w    #1,type_bl(a0)
  6686.     bne.s    cnb_preset
  6687. cnbpat_loop1:
  6688.     move.l    a1,a2
  6689.     move.w    nbr_track_bl(a0),d2
  6690.     subq.w    #1,d2
  6691. cnbpat_loop2:
  6692.     bsr    clear_note
  6693.     addq.l    #5,a1
  6694.     dbra    d2,cnbpat_loop2
  6695.     move.l    a2,a1
  6696.     add.l    d0,a1
  6697.     dbra    d1,cnbpat_loop1
  6698.     bra.s    cnb_fin
  6699.  
  6700. cnb_preset:            ; Preset
  6701. cnbpre_loop1:
  6702.     move.w    preset_ntrk_bl(a0),d2
  6703.     subq.w    #1,d2
  6704.     move.l    a1,a2
  6705. cnbpre_loop2:
  6706.     move.w    (a3,d2.w*2),d3
  6707.     mulu.w    #5,d3
  6708.     add.l    d3,a1
  6709.     bsr    clear_note
  6710.     move.l    a2,a1
  6711.     dbra    d2,cnbpre_loop2
  6712.     add.l    d0,a1
  6713.     dbra    d1,cnbpre_loop1
  6714.  
  6715. cnb_fin:
  6716.     movem.l    (sp)+,d0-d3/a1-a3
  6717.     rts
  6718.  
  6719.  
  6720.  
  6721. *============================================================================*
  6722. *    Transpose un bloc de notes dans un pattern            *
  6723. *    a0 = adresse des infos (voir plus haut)            *
  6724. *    Adresse source nécessaire                *
  6725. *    Remplacer l'adresse destination par la transposition.l        *
  6726. *    Pas besoin de masque destination                *
  6727. *============================================================================*
  6728. transpose_note_block:
  6729.     movem.l    d0-d4/a1-a3,-(sp)
  6730.     move.l    adrsour_bl(a0),a1    ; a1 = adresse source
  6731.     move.l    adrdest_bl(a0),d4    ; d4 = transposition
  6732.     move.l    adrpreset_bl(a0),a3    ; a3 = adresse du preset
  6733.     move.l    increm_bl(a0),d0    ; d0 = incrément de ligne
  6734.     move.w    nlines_bl(a0),d1    ; d1 = compteur de lignes
  6735.     subq.w    #1,d1
  6736.     tst.w    type_bl(a0)
  6737.     bne.s    tnb_pattern
  6738.  
  6739. tnbtra_loop:            ; Track
  6740.     bsr    transpose_note
  6741.     add.l    d0,a1
  6742.     dbra    d1,tnbtra_loop
  6743.     bra.s    tnb_fin
  6744.  
  6745. tnb_pattern:            ; Pattern
  6746.     cmp.w    #1,type_bl(a0)
  6747.     bne.s    tnb_preset
  6748. tnbpat_loop1:
  6749.     move.l    a1,a2
  6750.     move.w    nbr_track_bl(a0),d2
  6751.     subq.w    #1,d2
  6752. tnbpat_loop2:
  6753.     bsr    transpose_note
  6754.     addq.l    #5,a1
  6755.     dbra    d2,tnbpat_loop2
  6756.     move.l    a2,a1
  6757.     add.l    d0,a1
  6758.     dbra    d1,tnbpat_loop1
  6759.     bra.s    tnb_fin
  6760.  
  6761. tnb_preset:            ; Preset
  6762. tnbpre_loop1:
  6763.     move.w    preset_ntrk_bl(a0),d2
  6764.     subq.w    #1,d2
  6765.     move.l    a1,a2
  6766. tnbpre_loop2:
  6767.     move.w    (a3,d2.w*2),d3
  6768.     mulu.w    #5,d3
  6769.     add.l    d3,a1
  6770.     bsr    transpose_note
  6771.     move.l    a2,a1
  6772.     dbra    d2,tnbpre_loop2
  6773.     add.l    d0,a1
  6774.     dbra    d1,tnbpre_loop1
  6775.  
  6776. tnb_fin:
  6777.     movem.l    (sp)+,d0-d4/a1-a3
  6778.     rts
  6779.  
  6780.  
  6781.  
  6782. *============================================================================*
  6783. *    Copie une note dans un pattern                *
  6784. *    a0 = adresse du champ d'infos (voir + haut)            *
  6785. *    a1 = adresse source                    *
  6786. *    a2 = adresse destination                *
  6787. *============================================================================*
  6788. copie_note:
  6789.     movem.l    d3/a4-a5,-(sp)
  6790.     tst.w    maskblock_bl(a0)
  6791.     bne.s    cn_masque
  6792.  
  6793. ; Sans masque
  6794.     tst.l    (a1)        ; source<>0 ?
  6795.     bne.s    .ok1
  6796.     tst.b    4(a1)
  6797.     bne.s    .ok1
  6798.     tst.w    replaceblock_bl(a0)    ; Replaceblock=0 ?
  6799.     bne.s    cn_fin
  6800. .ok1:    move.l    (a1),(a2)        ; Copie si source<>0 ou si replblock=0 sinon ne fait rien
  6801.     move.b    4(a1),4(a2)
  6802.     bra.s    cn_fin
  6803.  
  6804. ; Avec masque
  6805. cn_masque:
  6806.     tst.l    (a1)        ; source<>0 ?
  6807.     bne.s    .ok2
  6808.     tst.b    4(a1)
  6809.     bne.s    .ok2
  6810.     tst.w    replaceblock_bl(a0)    ; Replaceblock=0 ?
  6811.     bne.s    cn_fin
  6812.  
  6813. .ok2:                ; Copie si source<>0 ou si replblock=0 sinon ne fait rien
  6814.     move.l    adra1_bl(a0),a4    ; (source AND blmask_a1) = blmask_a2 ?
  6815.     move.l    adra2_bl(a0),a5
  6816.     move.l    (a1),d3
  6817.     and.l    (a4),d3
  6818.     cmp.l    (a5),d3
  6819.     bne.s    .else_if
  6820.     move.b    4(a1),d3
  6821.     and.b    4(a4),d3
  6822.     cmp.b    4(a5),d3
  6823.     bne.s    .else_if
  6824.     move.l    adrb1_bl(a0),a4    ; Oui, dest = ((source AND blmask_b1) OR blmask_b2)
  6825.     move.l    adrb2_bl(a0),a5
  6826.     move.l    (a1),d3
  6827.     and.l    (a4),d3
  6828.     or.l    (a5),d3
  6829.     move.l    d3,(a2)
  6830.     move.b    4(a1),d3
  6831.     and.b    4(a4),d3
  6832.     or.b    4(a5),d3
  6833.     move.b    d3,4(a2)
  6834.     bra.s    cn_fin
  6835. .else_if:                ; Sinon, replaceblock = 0 ?
  6836.     tst.w    replaceblock_bl(a0)
  6837.     bne.s    cn_fin        ; Non, on fait rien
  6838.     clr.l    (a2)        ; Oui, on efface la destination
  6839.     clr.b    4(a2)
  6840.  
  6841. cn_fin:
  6842.     movem.l    (sp)+,d3/a4-a5
  6843.     rts
  6844.  
  6845.  
  6846.  
  6847. *============================================================================*
  6848. *    Efface une note dans un pattern                *
  6849. *    a0 = adresse du champ d'infos (voir + haut)            *
  6850. *    a1 = adresse de la note                *
  6851. *============================================================================*
  6852. clear_note:
  6853.     movem.l    d3/a4-a5,-(sp)
  6854.     tst.w    maskblock_bl(a0)
  6855.     beq.s    clrn_sansmasque
  6856. ; Avec masque
  6857.     move.l    adra1_bl(a0),a4    ; (source AND blmask_a1) = blmask_a2 ?
  6858.     move.l    adra2_bl(a0),a5
  6859.     move.l    (a1),d3
  6860.     and.l    (a4),d3
  6861.     cmp.l    (a5),d3
  6862.     bne.s    clrn_fin
  6863.     move.b    4(a1),d3
  6864.     and.b    4(a4),d3
  6865.     cmp.b    4(a5),d3
  6866.     bne.s    clrn_fin
  6867. clrn_sansmasque:
  6868.     clr.l    (a1)
  6869.     clr.b    4(a1)
  6870.  
  6871. clrn_fin:
  6872.     movem.l    (sp)+,d3/a4-a5
  6873.     rts
  6874.  
  6875.  
  6876.  
  6877. *============================================================================*
  6878. *    Transpose une note dans un pattern            *
  6879. *    a0 = adresse du champ d'infos (voir + haut)            *
  6880. *    a1 = adresse de la note                *
  6881. *    d4 = transposition.w (ou .l)                *
  6882. *============================================================================*
  6883. transpose_note:
  6884.     movem.l    d3/a4-a5,-(sp)
  6885.     tst.b    (a1)        ; Pas de note ?
  6886.     beq.s    tran_fin        ; Alors on se tire
  6887.     tst.w    maskblock_bl(a0)
  6888.     beq.s    tran_sansmasque
  6889. ; Avec masque
  6890.     move.l    adra1_bl(a0),a4    ; (source AND blmask_a1) = blmask_a2 ?
  6891.     move.l    adra2_bl(a0),a5
  6892.     move.l    (a1),d3
  6893.     and.l    (a4),d3
  6894.     cmp.l    (a5),d3
  6895.     bne.s    tran_fin
  6896.     move.b    4(a1),d3
  6897.     and.b    4(a4),d3
  6898.     cmp.b    4(a5),d3
  6899.     bne.s    tran_fin
  6900. tran_sansmasque:
  6901.     moveq    #0,d3
  6902.     move.b    (a1),d3
  6903.     add.w    d4,d3
  6904.     cmp.w    #127,d3
  6905.     ble.s    .ok1
  6906.     moveq    #127,d3        ; Limite sup à G-8
  6907. .ok1:    cmp.w    #24,d3
  6908.     bge.s    .ok2
  6909.     moveq    #24,d3        ; Limite inf à C-0
  6910. .ok2:    move.b    d3,(a1)
  6911. tran_fin:
  6912.     movem.l    (sp)+,d3/a4-a5
  6913.     rts
  6914.  
  6915.  
  6916.  
  6917. *============================================================================*
  6918. *    Convertit un ancien groupe de patterns GT de 4 octets/note    *
  6919. *    en patterns GT de 5 octets/note (commande de volume)        *
  6920. *    a0 = adresse des patterns                *
  6921. *    d0 = taille.l des patterns (en nombre de notes)        *
  6922. *============================================================================*
  6923. convert_gtk_2_gtk_vol:
  6924.     movem.l    d0/a0-a1,-(sp)
  6925.     lea    (a0,d0.l*4),a0    ; Pointe sur la fin des anciens patterns
  6926.     lea    (a0,d0.l),a1    ; Pointe sur la fin des nouveaux
  6927. .loop1:    clr.b    -(a1)        ; Efface le volume interne
  6928.     move.l    -(a0),-(a1)    ; Recopie la note
  6929.     subq.l    #1,d0
  6930.     bne.s    .loop1
  6931.     movem.l    (sp)+,d0/a0-a1
  6932.     rts
  6933.  
  6934.  
  6935.  
  6936. *============================================================================*
  6937. *    Convertit une voie Ultra Tracker en Graoumf-voie        *
  6938. *    a0 = adresse de la voie ULT                *
  6939. *    a1 = adresse de la voie GTK                *
  6940. *    d0 = nombre.w de voies dans un pattern ULT            *
  6941. *    Renvoie dans d0.l la longueur du pattern ULT        *
  6942. *============================================================================*
  6943. convert_ult_2_gtk:
  6944.     movem.l    d1-d7/a0-a1,-(sp)
  6945.     move.w    d0,d1
  6946.     move.w    d1,d2
  6947.     add.w    d1,d1
  6948.     add.w    d1,d1
  6949.     add.w    d2,d1        ; d1 = incrément de ligne dans le pattern GTK
  6950.     moveq    #0,d0        ; d0 = longueur du pattern ULT
  6951.     moveq    #64,d6        ; d6 = nombre de lignes
  6952. cv_ult2gtk_loop2:
  6953.     move.b    (a0),d2
  6954.     moveq    #1,d5        ; Nombre de répétitions de la note par défaut
  6955.     cmp.b    #$FC,d2
  6956.     bne.s    .finsi1
  6957.     move.b    1(a0),d5        ; S'il y a répétition, prends le nombre
  6958.     addq.l    #2,a0
  6959.     addq.l    #2,d0
  6960. .finsi1:    subq.w    #1,d5
  6961.     moveq    #0,d2        ; d2 = la Graoumf-note
  6962.     move.b    (a0)+,d3
  6963.     beq.s    .nonote
  6964.     add.b    #23,d3        ; Additionne 2 octaves
  6965. .nonote:    lsl.w    #8,d3
  6966.     move.b    (a0)+,d3        ; L'instrument
  6967.     move.w    d3,d2
  6968.     swap    d2        ; Note et instrument convertis
  6969.  
  6970.     ; Les effets...
  6971.     moveq    #0,d7        ; Pas de volume interne
  6972.     cmp.b    #$99,(a0)        ; Fine sample offset
  6973.     bne.s    .suite
  6974.     move.w    1(a0),d2
  6975.     lsr.w    #6,d2
  6976.     add.w    #$9000,d2
  6977.     bra    .fin
  6978.  
  6979. .suite:    moveq    #0,d3
  6980.     moveq    #0,d4
  6981.     move.b    (a0),d3
  6982.     and.b    #$f,d3        ; d3 = numéro du 2ème effet
  6983.     move.b    1(a0),d4        ; d4 = paramètre
  6984.     bsr    convert_ultfx_2_gtkfx
  6985.     moveq    #0,d3
  6986.     moveq    #0,d4
  6987.     move.b    (a0),d3
  6988.     lsr.b    #4,d3        ; d3 = numéro du 1er effet
  6989.     move.b    2(a0),d4        ; d4 = paramètre
  6990.     bsr    convert_ultfx_2_gtkfx
  6991.  
  6992. .fin:    addq.l    #3,a0
  6993.     addq.l    #5,d0        ; Hop, 5 octets de plus
  6994.  
  6995. .repblk:    move.l    d2,(a1)        ; Met l'event
  6996.     move.b    d7,4(a1)        ; Met le volume interne
  6997.     add.w    d1,a1        ; Ligne suivante
  6998.     subq.w    #1,d6
  6999.     tst.w    d6
  7000.     beq.s    cv_ult2gtk_finvoie
  7001.     dbra    d5,.repblk        ; Répétition...
  7002.     bra    cv_ult2gtk_loop2    ; Série d'events suivante
  7003.  
  7004. cv_ult2gtk_finvoie:
  7005.     movem.l    (sp)+,d1-d7/a0-a1
  7006.     rts
  7007.  
  7008.  
  7009.  
  7010. *============================================================================*
  7011. *    Convertit un effet Ultra Tracker en effet GTK        *
  7012. *    d2 = note.l GTK (effet.w = 0)                *
  7013. *    d3 = effet                        *
  7014. *    d4 = paramètre                    *
  7015. *    d7 = volume interne                    *
  7016. *    En sortie :                    *
  7017. *    d2 = note.l GTK                    *
  7018. *    d7 = volume interne                    *
  7019. *============================================================================*
  7020. convert_ultfx_2_gtkfx:
  7021.     cmp.b    #$1,d3        ; Les effets qui ne changent pas
  7022.     beq.s    .no_chg        ; Porta up
  7023.     cmp.b    #$2,d3        ; Porta down
  7024.     beq.s    .no_chg
  7025.     cmp.b    #$3,d3        ; Tone porta
  7026.     beq.s    .no_chg
  7027.     cmp.b    #$4,d3        ; Vibrato
  7028.     beq.s    .no_chg
  7029.     cmp.b    #$7,d3        ; Tremolo
  7030.     bne.s    .0
  7031. .no_chg:    lsl.w    #8,d3
  7032.     add.w    d4,d3
  7033.     move.w    d3,d2
  7034.     bra    .fin
  7035.  
  7036. .0:    tst.b    d3        ; Arpeggio
  7037.     bne.s    .9
  7038.     tst.b    d4
  7039.     beq    .fin        ; Pas d'effet finalement
  7040.     add.w    #$1000,d4
  7041.     move.w    d4,d2
  7042.     bra    .fin
  7043.  
  7044. .9:    cmp.b    #$9,d3        ; Sample offset
  7045.     bne.s    .a
  7046.     add.w    d4,d4
  7047.     add.w    d4,d4
  7048.     add.w    #$9000,d4
  7049.     move.w    d4,d2
  7050.     bra    .fin
  7051.  
  7052. .a:    cmp.b    #$A,d3        ; Volume slide
  7053.     bne.s    ._b
  7054.     move.b    d4,d3
  7055.     lsr.b    #4,d4
  7056.     and.b    #15,d3
  7057.     sub.w    d3,d4
  7058.     bmi.s    .a_neg
  7059.     add.w    #$1400,d4
  7060.     move.w    d4,d2
  7061.     bra    .fin
  7062. .a_neg:    neg.w    d4
  7063.     add.w    #$1500,d4
  7064.     move.w    d4,d2
  7065.     bra    .fin
  7066.  
  7067. ._b:    cmp.b    #$B,d3        ; Balance
  7068.     bne.s    .c
  7069.     and.b    #15,d4
  7070.     lsl.w    #8,d4
  7071.     add.w    #$4000,d4
  7072.     move.w    d4,d2
  7073.     bra    .fin
  7074.  
  7075. .c:    cmp.b    #$C,d3        ; Volume
  7076.     bne.s    .d
  7077.     tst.b    d4
  7078.     bne.s    .c_norm
  7079.     move.w    #$2000,d2
  7080.     bra    .fin
  7081. .c_norm:    move.b    d4,d7
  7082.     bra    .fin
  7083.  
  7084. .d:    cmp.b    #$d,d3        ; Break pattern to line
  7085.     bne.s    .f
  7086.     move.w    d4,d3        ; Conversion BCD -> Hexa
  7087.     lsr.w    #4,d4
  7088.     mulu.w    #10,d4
  7089.     add.b    d3,d4
  7090.     move.w    #$D00,d2
  7091.     move.b    d4,d2
  7092.     bra    .fin
  7093.  
  7094. .f:    cmp.b    #$F,d3        ; Set speed/tempo
  7095.     bne.s    .e
  7096.     cmp.w    #$30,d4
  7097.     bge    .no_chg
  7098.     move.w    #$A800,d2
  7099.     add.w    d4,d2
  7100.     bra.s    .fin
  7101.  
  7102. .e:    cmp.b    #$E,d3        ; Effets étendus
  7103.     bne.s    .fin
  7104.     move.b    d4,d3
  7105.     lsr.b    #4,d3
  7106.     and.b    #15,d4
  7107.  
  7108. .e1:    cmp.b    #1,d3        ; Fine parta up
  7109.     bne.s    .e2
  7110.     add.w    #$1100,d4
  7111.     move.w    d4,d2
  7112.     bra.s    .fin
  7113.  
  7114. .e2:    cmp.b    #2,d3        ; Fine porta down
  7115.     bne.s    .e8
  7116.     add.w    #$1200,d4
  7117.     move.w    d4,d2
  7118.     bra.s    .fin
  7119.  
  7120. .e8:    cmp.b    #8,d3        ; Delay track
  7121.     bne.s    .e9
  7122.     add.w    #$AA00,d4
  7123.     move.w    d4,d2
  7124.     bra.s    .fin
  7125.  
  7126. .e9:    cmp.b    #9,d3        ; Retrig note
  7127.     bne.s    .ea
  7128.     add.b    #$70,d4
  7129.     lsl.w    #8,d4
  7130.     move.w    d4,d2
  7131.     bra.s    .fin
  7132.  
  7133. .ea:    cmp.b    #$A,d3        ; Fine volume up
  7134.     bne.s    .eb
  7135.     add.w    #$A400,d4
  7136.     move.w    d4,d2
  7137.     bra.s    .fin
  7138.  
  7139. .eb:    cmp.b    #$B,d3        ; Fine volume down
  7140.     bne.s    .ec
  7141.     add.w    #$A500,d4
  7142.     move.w    d4,d2
  7143.     bra.s    .fin
  7144.  
  7145. .ec:    cmp.b    #$C,d3        ; Cut note
  7146.     bne.s    .ed
  7147.     add.w    #$0A00,d4
  7148.     move.w    d4,d2
  7149.     bra.s    .fin
  7150.  
  7151. .ed:    cmp.b    #$D,d3        ; Note delay
  7152.     bne.s    .fin
  7153.     add.w    #$0900,d4
  7154.     move.w    d4,d2
  7155.  
  7156. .fin:    rts
  7157.  
  7158.  
  7159.  
  7160. *============================================================================*
  7161. *    Convertit un sample 16 bits Intel en 16 bits Motorola        *
  7162. *    a0 = adresse du sample                *
  7163. *    d0 = longueur.l du sample en octets            *
  7164. *============================================================================*
  7165. intel_16_bits:
  7166.     movem.l    d0/d1/a0,-(sp)
  7167.     tst.l    d0
  7168.     beq.s    .fin
  7169.     lsr.l    #1,d0
  7170.     swap    d0
  7171. .loop2:    swap    d0
  7172. .loop1:    move.b    1(a0),d1
  7173.     move.b    (a0)+,(a0)+
  7174.     move.b    d1,-2(a0)
  7175.     dbra    d0,.loop1
  7176.     swap    d0
  7177.     dbra    d0,.loop2
  7178. .fin:    movem.l    (sp)+,d0/d1/a0
  7179.     rts
  7180.  
  7181.  
  7182.  
  7183. *============================================================================*
  7184. *    Convertit un pattern Scream Tracker 3 compacté en pattern GTK    *
  7185. *    a0 = adresse du pattern S3M compacté (sans le mot de longueur)    *
  7186. *    a1 = adresse du pattern GTK                *
  7187. *    a2 = adresse de la table de correspondance des voies        *
  7188. *    d0 = nombre.w de voies dans le Graoumf-pattern        *
  7189. *============================================================================*
  7190. convert_s3m_2_gtk:
  7191.     movem.l    d0-d5/a0-a5,-(sp)
  7192.     lea    cv_s3m2gtk_slides+32*2(pc),a4
  7193.     moveq    #0,d1
  7194.     move.l    d1,d2
  7195.     move.l    d1,d3
  7196.     move.l    d1,d4
  7197.     movem.l    d1-d4,-(a4)    ; Réinitialise l'état des slides de
  7198.     movem.l    d1-d4,-(a4)    ; volume pour chaque voie
  7199.     movem.l    d1-d4,-(a4)    ; 4reg*4oct*4codes = 32voies*2octets
  7200.     movem.l    d1-d4,-(a4)
  7201.     lea    cv_s3m2gtk_porta+32(pc),a5
  7202.     movem.l    d1-d4,-(a5)    ; Idem, pour les portamentos
  7203.     movem.l    d1-d4,-(a5)
  7204.     move.w    d0,d1
  7205.     add.w    d0,d0
  7206.     add.w    d0,d0
  7207.     add.w    d1,d0        ; d0 = incrément d'adresse du pattern GTK
  7208.     moveq    #0,d1
  7209.     moveq    #63,d3        ; d3 = compteur de ligne
  7210.  
  7211. cv_s3m2gtk_loop1:
  7212.  
  7213. .newtrk:    move.b    (a0)+,d1        ; d1 = octet d'information
  7214.     beq    cv_s3m2gtk_finligne
  7215.     move.b    d1,d2
  7216.     and.b    #31,d2        ; Numéro de voie S3M
  7217.     lea    cv_s3m2gtk_slides(pc),a4
  7218.     lea    (a4,d2.w*2),a4    ; a4 pointe sur l'état du slide
  7219.     lea    cv_s3m2gtk_porta(pc),a5
  7220.     add.w    d2,a5        ; a5 pointe sur l'état du portamento
  7221.     move.b    (a2,d2.w),d2    ; d2 = numéro de voie GTK
  7222.     cmp.b    #255,d2
  7223.     bne.s    .track_ok
  7224.     btst    #5,d1        ; Si la voie n'est pas autorisée
  7225.     beq.s    .s1
  7226.     addq.l    #2,a0
  7227. .s1:    btst    #6,d1
  7228.     beq.s    .s2
  7229.     addq.l    #1,a0
  7230. .s2:    btst    #7,d1
  7231.     beq.s    .newtrk
  7232.     addq.l    #2,a0
  7233.     bra.s    .newtrk
  7234.  
  7235. .track_ok:
  7236.     lea    (a1,d2.w*4),a3
  7237.     lea    (a3,d2.w),a3    ; a3 pointe sur la note GTK
  7238.     btst    #5,d1        ; Note + Instrument ?
  7239.     beq.s    .no_note
  7240.     moveq    #0,d4
  7241.     move.b    (a0)+,d4
  7242.     move.b    (a0)+,1(a3)    ; Instrument converti
  7243.     cmp.w    #255,d4        ; Note vide ?
  7244.     bne.s    .note_s1
  7245.     bra.s    .no_note
  7246. .note_s1:    cmp.w    #254,d4        ; Coupe la note ?
  7247.     bne.s    .note_ok
  7248.     move.w    #$2000,2(a3)    ; Oui, met le volume à 0
  7249.     bra.s    .no_note
  7250. .note_ok:    move.w    d4,d5
  7251.     and.b    #$f,d4
  7252.     lsr.b    #4,d5
  7253.     mulu.w    #12,d5
  7254.     add.w    d5,d4
  7255.     cmp.b    #24,d4        ; Trop bas ?
  7256.     bge.s    .note_ok2
  7257.     moveq    #0,d4        ; alors on ne met rien
  7258. .note_ok2:    move.b    d4,(a3)        ; Note convertie
  7259.  
  7260. .no_note:    btst    #6,d1        ; Volume ?
  7261.     beq.s    .no_vol
  7262.     move.w    #$800,d4        ; $2000/4
  7263.     move.b    (a0)+,d4
  7264.     cmp.b    #255,d4
  7265.     beq.s    .no_vol
  7266.     add.w    d4,d4
  7267.     add.w    d4,d4        ; Convertit 0-64 en 0-256
  7268.     cmp.w    #$2100,d4
  7269.     bne.s    .vol_ok1
  7270.     move.w    d4,2(a3)        ; Volume $100 : commande 2100
  7271.     subq.w    #1,d4
  7272. .vol_ok1:    tst.b    d4
  7273.     bne.s    .vol_ok2
  7274.     move.w    d4,2(a3)        ; Volume 0 : commande 2000
  7275.     addq.w    #1,d4
  7276. .vol_ok2:    move.b    d4,4(a3)        ; Volume interne
  7277.  
  7278. .no_vol:    btst    #7,d1        ; Effet ?
  7279.     beq    .newtrk
  7280.     moveq    #0,d4
  7281.     moveq    #0,d5
  7282.     move.b    (a0)+,d4        ; d4 = effet
  7283.     move.b    (a0)+,d5        ; d5 = paramètre ( -> nouvel effet)
  7284.  
  7285. .1:    cmp.b    #$1,d4        ; Set Speed
  7286.     bne.s    .2
  7287.     add.w    #$A800,d5        ; -> Set Number of Frames
  7288.     bra    .finfx
  7289.  
  7290. .2:    cmp.b    #$2,d4        ; Jump to pos
  7291.     bne.s    .3
  7292.     add.w    #$B00,d5
  7293.     bra    .finfx
  7294.  
  7295. .3:    cmp.b    #$3,d4        ; Break pattern
  7296.     bne.s    .4
  7297.     move.w    d5,d4        ; Conversion BCD -> Hexa
  7298.     lsr.w    #4,d5
  7299.     mulu.w    #10,d5
  7300.     and.b    #15,d4
  7301.     add.b    d4,d5
  7302.     add.w    #$D00,d5
  7303.     bra    .finfx
  7304.  
  7305. .4:    cmp.b    #$4,d4        ; Volume Slide
  7306.     bne.s    .5
  7307.     move.w    d5,d1
  7308.     and.b    #$F,d1
  7309.     bne.s    .4_s1
  7310.     lsr.b    #2,d5        ; Volume slide up
  7311.     and.b    #$3C,d5
  7312.     beq.s    .4_cont
  7313.     add.w    #$1400,d5
  7314.     move.w    d5,(a4)        ; On sauve l'état de ce slide
  7315.     bra    .finfx
  7316. .4_cont:    move.w    (a4),d5        ; Si y avait pas de paramètre
  7317.     bra    .finfx
  7318. .4_s1:    cmp.b    #$F,d1
  7319.     bne.s    .4_s2
  7320.     lsr.b    #2,d5        ; Fine volume slide up
  7321.     and.b    #$3C,d5
  7322.     beq.s    .4_cont
  7323.     add.w    #$A400,d5
  7324.     move.w    d5,(a4)
  7325.     bra    .finfx
  7326. .4_s2:    move.w    d5,d1
  7327.     and.b    #$F0,d1
  7328.     bne.s    .4_s3
  7329.     and.b    #$F,d5        ; Volume slide down
  7330.     beq.s    .4_cont
  7331.     add.b    d5,d5
  7332.     add.b    d5,d5
  7333.     add.w    #$1500,d5
  7334.     move.w    d5,(a4)
  7335.     bra    .finfx
  7336. .4_s3:    and.b    #$F,d5        ; Fine volume slide down
  7337.     beq.s    .4_cont
  7338.     add.b    d5,d5
  7339.     add.b    d5,d5
  7340.     add.w    #$A500,d5
  7341.     move.w    d5,(a4)
  7342.     bra    .finfx
  7343.  
  7344. .5:    cmp.b    #$5,d4        ; Portamento down
  7345.     bne.s    .6
  7346.     move.w    d5,d1
  7347.     and.w    #$F0,d1
  7348.     cmp.b    #$F0,d1
  7349.     bne.s    .5_s1
  7350.     and.b    #$F,d5        ; Fine portamento down
  7351.     beq.s    .5_cont0
  7352.     move.b    d5,(a5)
  7353. .5_cont0:    move.b    (a5),d5
  7354.     add.w    #$1200,d5
  7355.     bra    .finfx
  7356. .5_s1:    cmp.b    #$E0,d1
  7357.     bne.s    .5_s2
  7358.     and.b    #$F,d5        ; Extra fine porta down
  7359.     beq.s    .5_cont1
  7360.     move.b    d5,(a5)
  7361. .5_cont1:    move.b    (a5),d5
  7362.     add.w    #$AD00,d5
  7363.     bra    .finfx
  7364. .5_s2:    tst.b    d5
  7365.     beq.s    .5_cont2
  7366.     move.b    d5,(a5)
  7367. .5_cont2:    move.b    (a5),d5
  7368.     add.w    #$200,d5        ; Normal porta down
  7369.     bra    .finfx
  7370.  
  7371. .6:    cmp.b    #$6,d4        ; Porta up
  7372.     bne.s    .7
  7373.     move.w    d5,d1
  7374.     and.w    #$F0,d1
  7375.     cmp.b    #$F0,d1
  7376.     bne.s    .6_s1
  7377.     and.b    #$F,d5        ; Fine portamento up
  7378.     beq.s    .6_cont0
  7379.     move.b    d5,(a5)
  7380. .6_cont0:    move.b    (a5),d5
  7381.     add.w    #$1100,d5
  7382.     bra    .finfx
  7383. .6_s1:    cmp.b    #$E0,d1
  7384.     bne.s    .6_s2
  7385.     and.b    #$F,d5        ; Extra fine porta up
  7386.     beq.s    .6_cont1
  7387.     move.b    d5,(a5)
  7388. .6_cont1:    move.b    (a5),d5
  7389.     add.w    #$AC00,d5
  7390.     bra    .finfx
  7391. .6_s2:    tst.b    d5
  7392.     beq.s    .6_cont2
  7393.     move.b    d5,(a5)
  7394. .6_cont2:    move.b    (a5),d5
  7395.     add.w    #$100,d5        ; Normal porta up
  7396.     bra    .finfx
  7397.  
  7398. .7:    cmp.b    #$7,d4        ; Tone portamento
  7399.     bne.s    .8
  7400.     add.w    #$300,d5
  7401.     bra    .finfx
  7402.  
  7403. .8:    cmp.b    #$8,d4        ; Vibrato
  7404.     bne.s    .9
  7405.     add.w    #$400,d5
  7406.     bra    .finfx
  7407.  
  7408. .9:    cmp.b    #$9,d4        ; Tremor
  7409.     bne.s    .a
  7410.     add.w    #$B000,d5
  7411.     bra    .finfx
  7412.  
  7413. .a:    cmp.b    #$a,d4        ; Arpeggio
  7414.     bne.s    .b_
  7415.     add.w    #$1000,d5
  7416.     bra    .finfx
  7417.  
  7418. .b_:    cmp.b    #$b,d4        ; Vib + Vol slide
  7419.     bne.s    .c
  7420.     move.w    d5,d4
  7421.     and.w    #$f,d4
  7422.     lsr.w    #4,d5
  7423.     sub.w    d4,d5
  7424.     add.w    d5,d5
  7425.     add.w    d5,d5
  7426.     beq.s    .b_cont
  7427.     bmi.s    .bneg
  7428.     add.w    #$1C00,d5
  7429.     move.w    d5,(a4)
  7430.     sub.b    #$1C-$14,(a4)
  7431.     bra    .finfx
  7432. .bneg:    sub.w    #$1D00,d5
  7433.     neg.w    d5
  7434.     move.w    d5,(a4)
  7435.     sub.b    #$1D-$14,(a4)
  7436.     bra    .finfx
  7437. .b_cont:    move.w    (a4),d5
  7438.     and.w    #$1ff,d5
  7439.     add.w    #$1C00,d5
  7440.     bra    .finfx
  7441.  
  7442. .c:    cmp.b    #$c,d4        ; Vol slide + Tone porta
  7443.     bne.s    .f
  7444.     move.w    d5,d4
  7445.     and.w    #$f,d4
  7446.     lsr.w    #4,d5
  7447.     sub.w    d4,d5
  7448.     add.w    d5,d5
  7449.     add.w    d5,d5
  7450.     beq.s    .c_cont
  7451.     bmi.s    .cneg
  7452.     add.w    #$1800,d5
  7453.     move.w    d5,(a4)
  7454.     sub.b    #$18-$14,(a4)
  7455.     bra    .finfx
  7456. .cneg:    sub.w    #$1900,d5
  7457.     neg.w    d5
  7458.     move.w    d5,(a4)
  7459.     sub.b    #$19-$14,(a4)
  7460.     bra    .finfx
  7461. .c_cont:    move.w    (a4),d5
  7462.     and.w    #$1ff,d5
  7463.     add.w    #$1800,d5
  7464.     bra    .finfx
  7465.  
  7466. .f:    cmp.b    #$f,d4        ; Sample offset
  7467.     bne.s    .11
  7468.     add.w    #$9000,d5
  7469.     bra    .finfx
  7470.  
  7471. .11:    cmp.b    #$11,d4        ; Retrig + volume slide
  7472.     bne.s    .12
  7473.     add.w    #$1300,d5
  7474.     bra    .finfx
  7475.  
  7476. .12:    cmp.b    #$12,d4        ; Tremolo
  7477.     bne.s    .13
  7478.     add.w    #$0700,d5
  7479.     bra    .finfx
  7480.  
  7481. .13:    cmp.b    #$13,d4        ; Effets étendus
  7482.     bne.s    .14
  7483.     move.b    d5,d4
  7484.     and.b    #$f,d5
  7485.     lsr.b    #4,d4
  7486.     cmp.b    #$2,d4        ; Set finetune
  7487.     bne.s    .13_3
  7488.     cmp.b    #7,d5
  7489.     bgt.s    .13_2_neg
  7490.     lsl.b    #4,d5
  7491.     add.w    #$800,d5
  7492.     bra.s    .finfx
  7493. .13_2_neg:    sub.b    #$10,d5
  7494.     neg.b    d5
  7495.     add.w    #$800,d5
  7496. .13_3:    cmp.b    #$3,d4        ; Set vibrato waveform
  7497.     bne.s    .13_4
  7498.     add.w    #$C00,d5
  7499.     bra.s    .finfx
  7500. .13_4:    cmp.b    #$4,d4        ; Set tremolo waveform
  7501.     bne.s    .13_8
  7502.     add.w    #$E00,d5
  7503.     bra.s    .finfx
  7504. .13_8:    cmp.b    #$8,d4        ; (Panoramic command)
  7505.     bne.s    .13_c
  7506.     add.b    #$40,d5
  7507.     lsl.w    #$8,d5
  7508.     bra.s    .finfx
  7509. .13_c:    cmp.b    #$c,d4        ; Notecut
  7510.     bne.s    .13_d
  7511.     add.w    #$A00,d5
  7512.     bra.s    .finfx
  7513. .13_d:    cmp.b    #$d,d4        ; Notedelay
  7514.     bne.s    .13_e
  7515.     add.w    #$900,d5
  7516.     bra.s    .finfx
  7517. .13_e:    cmp.b    #$e,d4        ; Patterndelay
  7518.     bne.s    .14
  7519.     add.w    #$AA00,d5
  7520.     bra.s    .finfx
  7521.     
  7522. .14:    cmp.b    #$14,d4        ; Set tempo
  7523.     bne.s    .defaut
  7524.     add.w    #$F00,d5
  7525.  
  7526. .finfx:    move.w    d5,2(a3)        ; Effet converti
  7527. .defaut:    bra    .newtrk
  7528.  
  7529. cv_s3m2gtk_finligne:
  7530.     add.w    d0,a1        ; Ligne suivante dans le pattern GTK
  7531.     dbra    d3,cv_s3m2gtk_loop1
  7532.     movem.l    (sp)+,d0-d5/a0-a5
  7533.     rts
  7534.  
  7535.  
  7536.  
  7537. *============================================================================*
  7538. *    Teste les coordonnées de la souris pour savoir sur quelle    *
  7539. *    icône on a cliqué.                    *
  7540. *    d0 = numéro.w du panneau d'icônes            *
  7541. *    d1 = x.w souris (pixels)                *
  7542. *    d2 = y.w souris (pixels)                *
  7543. *    a0 = adresse du tableau contenant les infos sur les panneaux    *
  7544. *         d'icônes                    *
  7545. *    Au retour :                    *
  7546. *    d0 = numéro d'icône, -1 si rien n'a été trouvé        *
  7547. *============================================================================*
  7548. teste_icones:
  7549.     movem.l    d1/d3/d4/a0,-(sp)
  7550.     mulu.w    #64*2*4,d0
  7551.     add.l    d0,a0
  7552.     asr.w    #3,d1        ; Convertit coo. x souris en colonnes
  7553.     moveq    #63,d0
  7554. .loop:    move.w    (a0),d3        ; d3 = abscisse (en colonnes) de l'icône
  7555.     bmi.s    .suite        ; Négatif : pas d'icône ici
  7556.     cmp.w    d3,d1
  7557.     blt.s    .suite
  7558.     move.w    2(a0),d4        ; d4 = ordonnée de l'icône (en pixels)
  7559.     cmp.w    d4,d2
  7560.     blt.s    .suite
  7561.     add.w    6(a0),d4        ; Additionne hauteur-1 en pixels
  7562.     cmp.w    d4,d2
  7563.     bgt.s    .suite
  7564.     add.w    4(a0),d3        ; Additionne largeur-1 en colonnes de caractères
  7565.     cmp.w    d3,d1
  7566.     ble.s    .ok
  7567. .suite:    addq.l    #8,a0        ; Icône suivante
  7568.     dbra    d0,.loop
  7569.     moveq    #-1,d0        ; Renvoie -1 : on a cliqué ailleurs
  7570.     movem.l    (sp)+,d1/d3/d4/a0
  7571.     rts
  7572. .ok:    sub.w    #63,d0
  7573.     neg.w    d0        ; Renvoie le numéro de l'icône (0-63)
  7574.     movem.l    (sp)+,d1/d3/d4/a0
  7575.     rts
  7576.  
  7577.  
  7578.  
  7579. *============================================================================*
  7580. *    Convertit un pattern au format OctaMED Pro de n voies en    *
  7581. *    un Graoumf-pattern de (n+k) voies            *
  7582. *    a0 = adresse du pattern OctaMED                *
  7583. *    a1 = adresse du Graoumf-pattern                *
  7584. *    a2 = adresse de la table des transpositions d'instrument    *
  7585. *    d0 = nombre.w de pistes OctaMED                *
  7586. *    d1 = nombre.w de lignes                *
  7587. *    d6 = différence.w entre le nombre de Graoumf-pistes et        *
  7588. *         d'Octa-pistes                    *
  7589. *============================================================================*
  7590. convert_mmd1_2_gtk:
  7591.     movem.l    d0-d6/a0-a2,-(sp)
  7592.     mulu.w    #5,d6        ; Différence * 5 octets
  7593.     subq.w    #1,d0        ; Pour le dbra
  7594.     subq.w    #1,d1        ; d1 = compteur de lignes
  7595. cv_mmd12gtk_loopl:
  7596.     move.w    d0,d5        ; d5 = compteur de voies
  7597. cv_mmd12gtk_loopv:
  7598.  
  7599.     moveq    #0,d3
  7600.     move.b    1(a0),d3        ; d3 = numéro de l'instrument
  7601.     and.b    #$3f,d3
  7602.     move.b    (a0),d4        ; d4 = note
  7603.     and.b    #$7f,d4
  7604.     beq.s    .pasnote
  7605.     add.b    (a2,d3.w),d4    ; Transpose
  7606. .pasnote:    move.b    d4,(a1)+        ; Note convertie
  7607.     move.b    d3,(a1)+        ; Instrument converti
  7608.     addq.l    #2,a0
  7609.  
  7610.     move.b    (a0)+,d3        ; d3 = numéro d'effet
  7611.     moveq    #0,d4
  7612.     move.b    (a0)+,d4        ; d4 = paramètre de l'effet
  7613.     clr.w    d2        ; d2 = Graoumf-effet
  7614.  
  7615.     cmp.b    #3,d3        ; Les effets qui ne changent pas
  7616.     beq.s    .nochange
  7617.     cmp.b    #4,d3
  7618.     beq.s    .nochange
  7619.     cmp.b    #7,d3
  7620.     beq.s    .nochange
  7621.     cmp.b    #$b,d3
  7622.     beq.s    .nochange
  7623.     cmp.b    #$f,d3
  7624.     bne.s    .suite
  7625.     tst.b    d4        ; Fonction F00 = break pattern (-> ligne 0)
  7626.     beq    .1d_set
  7627.     cmp.w    #$f0,d4        ; Fonction F : tempo seulement si 31 < x < 241
  7628.     bgt    .ffx        ; Si > 240, autres fonctions
  7629.     cmp.w    #$20,d4
  7630.     blt    .defaut
  7631. .nochange:    lsl.w    #8,d3
  7632.     add.w    d3,d4
  7633.     move.w    d4,d2
  7634.     bra    .fin
  7635.  
  7636. .suite:    tst.b    d3        ; Arpeggio
  7637.     bne.s    .01
  7638.     tst.b    d4
  7639.     beq    .fin
  7640.     add.w    #$1000,d4
  7641.     move.w    d4,d2
  7642.     bra    .fin
  7643.  
  7644. .01:    cmp.b    #1,d3        ; Porta up (rien si paramètre = 0)
  7645.     bne.s    .02
  7646.     tst.b    d4
  7647.     beq    .fin
  7648.     add.w    #$100,d4
  7649.     move.w    d4,d2
  7650.     bra    .fin
  7651.  
  7652. .02:    cmp.b    #2,d3        ; Porta down ( ... )
  7653.     bne.s    .05
  7654.     tst.b    d4
  7655.     beq    .fin
  7656.     add.w    #$200,d4
  7657.     move.w    d4,d2
  7658.     bra    .fin
  7659.  
  7660. .05:    cmp.b    #5,d3        ; Vol slide + porta
  7661.     bne.s    .06
  7662.     move.w    d4,d3
  7663.     and.w    #$f,d3
  7664.     lsr.w    #4,d4
  7665.     sub.w    d3,d4
  7666.     add.w    d4,d4
  7667.     add.w    d4,d4
  7668.     bmi.s    .05neg
  7669.     add.w    #$1800,d4
  7670.     move.w    d4,d2
  7671.     bra    .fin
  7672. .05neg:    move.w    #$1900,d2
  7673.     sub.w    d4,d2
  7674.     bra    .fin
  7675.  
  7676. .06:    cmp.b    #6,d3        ; Vol slide + vib
  7677.     bne.s    .09
  7678.     move.w    d4,d3
  7679.     and.w    #$f,d3
  7680.     lsr.w    #4,d4
  7681.     sub.w    d3,d4
  7682.     add.w    d4,d4
  7683.     add.w    d4,d4
  7684.     bmi.s    .06neg
  7685.     add.w    #$1c00,d4
  7686.     move.w    d4,d2
  7687.     bra    .fin
  7688. .06neg:    move.w    #$1d00,d2
  7689.     sub.w    d4,d2
  7690.     bra    .fin
  7691.  
  7692. .09:    cmp.b    #$9,d3        ; Set number of frames
  7693.     bne.s    .0a
  7694.     add.w    #$a800,d4
  7695.     move.w    d4,d2
  7696.     bra    .fin
  7697.  
  7698. .0a:    cmp.b    #$a,d3        ; Vol slide
  7699.     beq.s    .0d
  7700.     cmp.b    #$d,d3
  7701.     bne.s    .0c
  7702. .0d    move.w    d4,d3
  7703.     and.w    #$f,d3
  7704.     lsr.w    #4,d4
  7705.     sub.w    d3,d4
  7706.     add.w    d4,d4
  7707.     add.w    d4,d4
  7708.     bmi.s    .0aneg
  7709.     add.w    #$1400,d4
  7710.     move.w    d4,d2
  7711.     bra    .fin
  7712. .0aneg:    move.w    #$1500,d2
  7713.     sub.w    d4,d2
  7714.     bra    .fin
  7715.  
  7716. .0c:    cmp.b    #$c,d3        ; Set volume
  7717.     bne.s    .11
  7718.     add.w    d4,d4        ; <- En hexa ! (décimal pas fait)
  7719.     add.w    d4,d4
  7720.     add.w    #$2000,d4
  7721.     move.w    d4,d2
  7722.     bra    .fin
  7723.  
  7724. .11    cmp.b    #$11,d3        ; Fine porta up
  7725.     bne.s    .12
  7726.     add.w    #$1100,d4
  7727.     move.w    d4,d2
  7728.     bra    .fin
  7729.  
  7730. .12:    cmp.b    #$12,d3        ; Fine porta down
  7731.     bne.s    .15
  7732.     add.w    #$1200,d4
  7733.     move.w    d4,d2
  7734.     bra    .fin
  7735.  
  7736. .15:    cmp.b    #$15,d3        ; Set finetune
  7737.     bne.s    .18
  7738.     cmp.b    #7,d4
  7739.     bgt.s    .15neg
  7740.     add.w    #$800,d4
  7741.     move.w    d4,d2
  7742.     bra    .fin
  7743. .15neg:    move.w    #$810,d2
  7744.     sub.w    d4,d2
  7745.     bra    .fin
  7746.  
  7747. .18:    cmp.b    #$18,d3        ; Note cut
  7748.     bne.s    .19
  7749.     add.w    #$a00,d4
  7750.     move.w    d4,d2
  7751.     bra    .fin
  7752.  
  7753. .19:    cmp.b    #$19,d3        ; Play part of sample
  7754.     bne.s    .1a
  7755.     add.w    #$9000,d4
  7756.     move.w    d4,d2
  7757.     bra    .fin
  7758.  
  7759. .1a:    cmp.b    #$1a,d3        ; Fine vol up
  7760.     bne.s    .1b
  7761.     move.w    #$a400,d2
  7762.     add.b    d4,d4
  7763.     add.b    d4,d4
  7764.     add.b    d4,d2
  7765.     bra    .fin
  7766.  
  7767. .1b:    cmp.b    #$1b,d3        ; Fine vol down
  7768.     bne.s    .1d
  7769.     move.w    #$a500,d2
  7770.     add.b    d4,d4
  7771.     add.b    d4,d4
  7772.     add.b    d4,d2
  7773.     bra.s    .fin
  7774.  
  7775. .1d:    cmp.b    #$1d,d3        ; Break pattern
  7776.     bne.s    .1e
  7777. .1d_set:    add.w    #$d00,d4
  7778.     move.w    d4,d2
  7779.     bra.s    .fin
  7780.  
  7781. .1e:    cmp.b    #$1e,d3        ; Pattern delay
  7782.     bne.s    .1f
  7783.     add.w    #$aa00,d4
  7784.     move.w    d4,d2
  7785.     bra.s    .fin
  7786. .1f:    cmp.b    #$1f,d3        ; Note delay/Retrig sample
  7787.     bne.s    .defaut
  7788.     move.w    d4,d3
  7789.     and.b    #$f,d3
  7790.     beq.s    .1f_delay
  7791.     add.b    #$70,d3        ; -> Retrig
  7792.     lsl.w    #8,d3
  7793.     move.w    d3,d2
  7794.     bra.s    .fin
  7795. .1f_delay:    lsr.b    #4,d4        ; -> Delay
  7796.     add.w    #$a00,d4
  7797.     move.w    d4,d2
  7798.     bra.s    .fin
  7799.  
  7800. .ffx:    cmp.b    #$F1,d4        ; Fonctions spéciales
  7801.     bne.s    .ff2
  7802.     move.w    #$7302,d2        ; Joue 2 notes en double vitesse
  7803.     bra.s    .fin        ; La vitesse dépend en fait de ce qu'il y a avant!
  7804. .ff2:    cmp.b    #$F2,d4        ; Attend 1/2 note avant de jouer
  7805.     bne.s    .ff3
  7806.     move.w    #$0903,d2
  7807.     bra.s    .fin
  7808. .ff3:    cmp.b    #$F3,d4        ; Joue 3 notes en 1 temps
  7809.     bne.s    .ffd
  7810.     move.w    #$7202,d2
  7811.     bra.s    .fin
  7812. .ffd:    cmp.b    #$FD,d4        ; Change le pitch sans rejouer la note
  7813.     bne.s    .fff
  7814.     move.w    #$03FF,d2
  7815.     bra.s    .fin
  7816. .fff:    cmp.b    #$FF,d4        ; Arrête la note
  7817.     bne.s    .fin
  7818.     move.w    #$0A00,d2
  7819.     bra.s    .fin
  7820.  
  7821. .defaut:    clr.w    d2        ; rien par défaut
  7822.  
  7823. .fin:    move.w    d2,(a1)+        ; Effet converti
  7824.     clr.b    (a1)+        ; Efface le volume interne
  7825.     dbra    d5,cv_mmd12gtk_loopv
  7826.     add.w    d6,a1        ; Saute les dernières voies du Graoumf-pattern
  7827.     dbra    d1,cv_mmd12gtk_loopl
  7828.     movem.l    (sp)+,d0-d6/a0-a2
  7829.     rts
  7830.  
  7831.  
  7832.  
  7833. *============================================================================*
  7834. *    Transforme un sample stereo en mono en ne gardant qu'un    *
  7835. *    seul canal.                    *
  7836. *    a0 = adresse source                    *
  7837. *    a1 = adresse destination                *
  7838. *    d0 = longueur.l (du sample mono, en octet)            *
  7839. *    d1 = taille.w d'un sample (1 ou 2)            *
  7840. *============================================================================*
  7841. stereo_2_mono_one:
  7842.     movem.l    d0/d1/a0/a1,-(sp)
  7843.     cmp.b    #2,d1
  7844.     beq.s    .16loop
  7845.  
  7846. .8loop:    move.b    (a0),(a1)+
  7847.     addq.l    #2,a0
  7848.     subq.l    #1,d0
  7849.     bgt.s    .8loop
  7850.     bra.s    .fin
  7851.  
  7852. .16loop:    move.w    (a0),(a1)+
  7853.     addq.l    #4,a0
  7854.     subq.l    #2,d0
  7855.     bgt.s    .16loop
  7856.  
  7857. .fin    movem.l    (sp)+,d0/d1/a0/a1
  7858.     rts
  7859.  
  7860.  
  7861.  
  7862. *============================================================================*
  7863. *    Transforme un sample stereo en mono en moyennant les deux canaux    *
  7864. *    a0 = adresse source                    *
  7865. *    a1 = adresse destination                *
  7866. *    d0 = longueur.l (du sample mono, en octet)            *
  7867. *    d1 = taille.w d'un sample (1 ou 2)            *
  7868. *============================================================================*
  7869. stereo_2_mono_ave:
  7870.     movem.l    d0-d2/a0/a1,-(sp)
  7871.     moveq    #0,d2
  7872.     cmp.b    #2,d1
  7873.     beq.s    .16bits
  7874.  
  7875. .8loop:    move.b    (a0)+,d1
  7876.     move.b    (a0)+,d2
  7877.     ext.w    d1
  7878.     ext.w    d2
  7879.     add.w    d1,d2
  7880.     asr.w    #1,d2
  7881.     move.b    d2,(a1)+
  7882.     subq.l    #1,d0
  7883.     bgt.s    .8loop
  7884.     bra.s    .fin
  7885.  
  7886. .16bits:
  7887. .16loop:    move.w    (a0)+,d1
  7888.     move.w    (a0)+,d2
  7889.     ext.l    d1
  7890.     ext.l    d2
  7891.     add.l    d1,d2
  7892.     asr.l    #1,d2
  7893.     move.w    d2,(a1)+
  7894.     subq.l    #2,d0
  7895.     bgt.s    .16loop
  7896.  
  7897. .fin:    movem.l    (sp)+,d0-d2/a0/a1
  7898.     rts
  7899.  
  7900.  
  7901.  
  7902. *============================================================================*
  7903. *    Transforme un sample stereo 16 bits en 8/16 bits stereo/mono    *
  7904. *    en moyennant les deux canaux si mono est choisi. La conversion    *
  7905. *    NE peut PAS être faite "sur place".            *
  7906. *    a0 = adresse source                    *
  7907. *    a1 = adresse destination                *
  7908. *    d0 = longueur.l (du sample stereo 16 bits, en octet)        *
  7909. *    d1 = taille.w d'un sample destination (1 ou 2 pour 8 ou 16 bits)    *
  7910. *    d2 = Nombre.w de canaux pour le sample destination (1 ou 2)    *
  7911. *============================================================================*
  7912. convert_stereo16:
  7913.     movem.l    d0-d2/a0-a1,-(sp)
  7914.     lsr.l    #2,d0
  7915.     tst.l    d0
  7916.     beq.s    .fin
  7917.     subq.l    #1,d0
  7918.     cmp.w    #2,d1
  7919.     beq.s    .16bits
  7920.  
  7921. ;--- 8 bits ------------------------------------------------------------------
  7922. .8bits:
  7923.     cmp.w    #2,d2
  7924.     beq.s    .8stereo
  7925.  
  7926. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  7927. .8mono:    swap    d0
  7928. .8mloop1:    swap    d0
  7929. .8mloop2:    move.b    (a0),d1
  7930.     move.b    2(a0),d2
  7931.     ext.w    d1
  7932.     ext.w    d2
  7933.     add.w    d1,d2
  7934.     asr.w    #1,d2
  7935.     move.b    d2,(a1)+
  7936.     addq.l    #4,a0
  7937.     dbra    d0,.8mloop2
  7938.     swap    d0
  7939.     dbra    d0,.8mloop1
  7940.     bra.s    .fin
  7941.  
  7942. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  7943. .8stereo:    swap    d0
  7944. .8sloop1:    swap    d0
  7945. .8sloop2:    move.b    (a0),(a1)+
  7946.     move.b    2(a0),(a1)+
  7947.     addq.l    #4,a0
  7948.     dbra    d0,.8sloop2
  7949.     swap    d0
  7950.     dbra    d0,.8sloop1
  7951.     bra.s    .fin
  7952.  
  7953. ;--- 16 bits -----------------------------------------------------------------
  7954. .16bits:
  7955.     cmp.w    #2,d2
  7956.     beq.s    .16stereo
  7957.  
  7958. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  7959. .16mono:    swap    d0
  7960. .16mloop1:    swap    d0
  7961. .16mloop2:    move.w    (a0)+,d1
  7962.     move.w    (a0)+,d2
  7963.     ext.l    d1
  7964.     ext.l    d2
  7965.     add.l    d1,d2
  7966.     asr.l    #1,d2
  7967.     move.w    d2,(a1)+
  7968.     dbra    d0,.16mloop2
  7969.     swap    d0
  7970.     dbra    d0,.16mloop1
  7971.     bra.s    .fin
  7972.  
  7973. ; -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  7974. .16stereo:    swap    d0
  7975. .16sloop1:    swap    d0
  7976. .16sloop2:    move.l    (a0)+,(a1)+
  7977.     dbra    d0,.16sloop2
  7978.     swap    d0
  7979.     dbra    d0,.16sloop1
  7980.  
  7981. .fin:    movem.l    (sp)+,d0-d2/a0-a1
  7982.     rts
  7983.  
  7984.  
  7985.  
  7986. *============================================================================*
  7987. *    Signe un sample                    *
  7988. *    a0 = adresse                    *
  7989. *    d0 = longueur.l en octets                *
  7990. *    d1 = taile.w d'un sample (1 = 8 bits, 2 = 16 bits)        *
  7991. *============================================================================*
  7992. signe_sample:
  7993.     movem.l    d0-d2/a0,-(sp)
  7994.     extb.l    d1
  7995.     moveq    #-128,d2
  7996. .loop:    add.b    d2,(a0)
  7997.     add.w    d1,a0
  7998.     sub.l    d1,d0
  7999.     bgt.s    .loop
  8000.     movem.l    (sp)+,d0-d2/a0
  8001.     rts
  8002.  
  8003.  
  8004.  
  8005. *============================================================================*
  8006. *    Convertit des patterns au format NoiseTracker en patterns    *
  8007. *    au format Graoumf Tracker                *
  8008. *    a0 = adresse des patterns                *
  8009. *    d0 = longueur.l (en mots longs) de pattern NT à convertir    *
  8010. *============================================================================*
  8011. convert_nt_2_gtk:
  8012.     movem.l    d0-d5/a0-a3,-(sp)
  8013.  
  8014.     move.l    d0,d5        ; Conserve le nombre de notes dans d5
  8015.  
  8016. ;--- Conversion intégrale des notes ------------------------------------------
  8017.     lea    nt_pernote(pc),a1    ; a1 = adresse des périodes des notes NT
  8018.     lea    (a0,d0.l*4),a0    ; a0 pointe à la fin des patterns NT
  8019.     lea    (a0,d0.l),a3    ; a1 pointe à la fin des patterns GT
  8020.  
  8021. cv_nt2gtk_loop:
  8022.     move.l    -(a0),d1        ; d1 = ancienne note
  8023.     moveq    #0,d2        ; d2 = nouvelle note
  8024.     move.l    d1,d3
  8025.     and.l    #$0fff0000,d3
  8026.     beq.s    cv_nt2gtk_instr    ; S'il n'y a rien
  8027.     swap    d3
  8028.     moveq    #36,d4
  8029.     move.l    a1,a2
  8030. .loop:    cmp.w    (a2)+,d3        ; recherche la note
  8031.     beq.s    .finloop
  8032.     addq.w    #1,d4
  8033.     cmp.w    #72,d4
  8034.     bne.s    .loop
  8035.     moveq    #0,d4
  8036. .finloop:    lsl.w    #8,d4
  8037.     swap    d4
  8038.     move.l    d4,d2        ; Note convertie
  8039.  
  8040. cv_nt2gtk_instr:
  8041.     move.l    d1,d3
  8042.     and.l    #$f000f000,d3
  8043.     lsr.l    #8,d3
  8044.     swap    d3
  8045.     move.w    d3,d4
  8046.     swap    d3
  8047.     lsr.b    #4,d3
  8048.     add.w    d4,d3        ; d3 = instrument
  8049.     ext.l    d3        ; Vide la partie supérieure
  8050.     swap    d3
  8051.     add.l    d3,d2        ; Instrument converti
  8052.  
  8053.     moveq    #0,d3
  8054.     move.w    d1,d3
  8055.     lsr.w    #8,d3
  8056.     and.b    #$f,d3        ; d3 = numéro d'effet
  8057.     move.w    d1,d4
  8058.     and.w    #$ff,d4        ; d4 = paramètre 2 chiffres
  8059.  
  8060.     bsr    convert_profx_2_gtkfx    ; Convertit l'effet
  8061.  
  8062.     clr.b    -(a3)        ; Efface le volume interne
  8063.     move.l    d2,-(a3)        ; Met la note
  8064.     subq.l    #1,d0
  8065.     bne    cv_nt2gtk_loop
  8066.  
  8067. ;--- Elimine les slides avec paramètre nul -----------------------------------
  8068.     addq.l    #2,a3        ; a3 pointe sur l'effet de la première note
  8069.  
  8070. cv_nt2gtk_loop2:
  8071.     move.w    (a3),d0        ; d0 = effet
  8072.     cmp.w    #$100,d0        ; Porta up
  8073.     beq.s    .clr_fx
  8074.     cmp.w    #$200,d0        ; Porta down
  8075.     beq.s    .clr_fx
  8076.     cmp.w    #$1100,d0        ; Fine porta up
  8077.     beq.s    .clr_fx
  8078.     cmp.w    #$1200,d0        ; Fine porta down
  8079.     beq.s    .clr_fx
  8080.     cmp.w    #$1400,d0        ; Volume slide up
  8081.     beq.s    .clr_fx
  8082.     cmp.w    #$1500,d0        ; Volume slide down
  8083.     bne.s    .nextnote
  8084. .clr_fx:    clr.w    (a3)        ; Efface l'effet
  8085. .nextnote:    subq.l    #1,d5
  8086.     addq.l    #5,a3
  8087.     bne    cv_nt2gtk_loop2
  8088.  
  8089.     movem.l    (sp)+,d0-d5/a0-a3
  8090.     rts
  8091.  
  8092.  
  8093.  
  8094. *============================================================================*
  8095. *    Convertit un pattern au format 669 8 voies en un pattern    *
  8096. *    9 voies au format Graoumf Tracker            *
  8097. *    a0 = adresse du pattern 669                *
  8098. *    a1 = adresse du pattern GTK                *
  8099. *============================================================================*
  8100. convert_669_2_gtk:
  8101.     movem.l    d0-d3/a0-a2,-(sp)
  8102.     moveq    #63,d0        ; d0 = compteur de lignes
  8103.  
  8104. cv_6692gtk_loop1:
  8105.     move.l    a1,a2        ; a2 = pointe sur la voie sup. (1ère en fait) du pattern GT
  8106.     clr.l    (a1)+        ; Saute la voie suplémentaire
  8107.     clr.b    (a1)+
  8108.     moveq    #7,d1        ; d1 = compteur de voie
  8109.  
  8110. cv_6692gtk_loop2:
  8111.     move.b    (a0),d2
  8112.     cmp.b    #$ff,d2
  8113.     beq.s    cv_6692gtk_fx    ; Il n'y a ni note, ni changement de volume
  8114.     cmp.b    #$fe,d2
  8115.     beq.s    cv_6692gtk_vol    ; Il n'y a pas de note
  8116.     lsr.b    #2,d2
  8117.     cmp.b    #59,d2
  8118.     bgt.s    .trop        ; Si c'est trop haut, on baisse d'une octave
  8119.     add.b    #12,d2
  8120. .trop:    add.b    #12,d2        ; Met à la bonne octave
  8121.     move.b    d2,(a1)        ; Note convertie
  8122.  
  8123.     move.w    (a0),d2        ; Récupère le numéro de l'instrument
  8124.     lsr.w    #4,d2
  8125.     and.b    #63,d2
  8126.     addq.b    #1,d2        ; Samples : 0-63   ->   1-64
  8127.     move.b    d2,1(a1)        ; Numéro d'instrument converti
  8128.  
  8129. cv_6692gtk_vol:
  8130.     move.w    #$2000,d2        ; Fonction de volume
  8131.     move.b    1(a0),d2        ; Prend le volume comme paramètre
  8132.     lsl.b    #4,d2        ; Recalibre
  8133.     move.b    d2,4(a1)        ; Hop, volume converti en interne
  8134.     tst.b    d2
  8135.     bne.s    cv_6692gtk_fx
  8136.     move.w    d2,2(a1)        ; Volume 0 : commande 2000
  8137.  
  8138. cv_6692gtk_fx:
  8139.     move.b    2(a0),d2        ; Prend l'effet
  8140.     cmp.b    #$ff,d2
  8141.     beq.s    cv_6692gtk_next    ; En fait y en a pas, gros farceur !
  8142.     move.b    d2,d3
  8143.     lsr.b    #4,d3        ; d3 = paramètre
  8144.     and.b    #15,d2        ; d2 = effet
  8145.     bne.s    .portadwn        ; 0 = Porta up
  8146.     move.b    #1,2(a1)
  8147.     move.b    d3,3(a1)
  8148.     bra.s    cv_6692gtk_next
  8149. .portadwn:    subq.b    #1,d2        ; 1 = Porta down
  8150.     bne.s    .tonep
  8151.     move.b    #2,2(a1)
  8152.     move.b    d3,3(a1)
  8153.     bra.s    cv_6692gtk_next
  8154. .tonep:    subq.b    #1,d2        ; 2 = Tone portamento
  8155.     bne.s    .vib
  8156.     move.b    #3,2(a1)
  8157.     move.b    d3,3(a1)
  8158.     bra.s    cv_6692gtk_next
  8159. .vib:    subq.b    #1,d2        ; 3 = Vibrato
  8160.     bne.s    .detune
  8161.     move.b    #4,2(a1)
  8162.     lsl.b    #4,d3
  8163.     add.b    #2,d3        ; *** Amplitude arbitraire
  8164.     move.b    d3,3(a1)
  8165.     bra.s    cv_6692gtk_next
  8166. .detune:    subq.b    #1,d2        ; 4 = Detune *** ???
  8167.     bne.s    .setspeed
  8168.     move.b    #8,2(a1)
  8169.     cmp.b    #8,d3
  8170.     blt.s    .detunep
  8171.     sub.b    #16,d3        ; Detune négatif
  8172.     move.b    d3,3(a1)
  8173.     bra.s    cv_6692gtk_next
  8174. .detunep:    lsl.b    #4,d3        ; Detune positif
  8175.     move.b    d3,3(a1)
  8176.     bra.s    cv_6692gtk_next
  8177. .setspeed:    move.b    #$A8,2(a2)        ; 5 = Set nbr of frames
  8178.     add.b    #2,d3        ; *** ??? Pour une vitesse 4 on a un paramètre de 2 !!!
  8179.     move.b    d3,3(a2)        ; On met ça sur la voie supplémentaire
  8180.  
  8181. cv_6692gtk_next:
  8182.     addq.l    #3,a0
  8183.     addq.l    #5,a1
  8184.     dbra    d1,cv_6692gtk_loop2
  8185.  
  8186.     dbra    d0,cv_6692gtk_loop1
  8187.  
  8188.     movem.l    (sp)+,d0-d3/a0-a2
  8189.     rts
  8190.  
  8191.  
  8192.  
  8193. *============================================================================*
  8194. *    Convertit une voie au format MTM en voie au format Graoumf    *
  8195. *    Tracker                        *
  8196. *    a0 = adresse de la voie MTM                *
  8197. *    a1 = adresse de la voie GTK                *
  8198. *    d0 = nbr.w de voies d'un Graoumf-pattern            *
  8199. *    d1 = nbr.w de lignes à convertir                *
  8200. *============================================================================*
  8201. convert_mtm_voice_2_gtk:
  8202.     movem.l    d0-d4/a0/a1,-(sp)
  8203.     mulu.w    #5,d0        ; 1 Graoumf-note = 5 octets
  8204.     subq.w    #1,d1        ; d1 = compteur
  8205. cv_mtmv2gtk_loop:
  8206.     moveq    #0,d2
  8207.     move.w    d2,d4
  8208.     move.b    (a0),d2        ; Prend la note
  8209.     lsr.b    #2,d2
  8210.     tst.b    d2
  8211.     beq.s    .instr        ; Pas de note
  8212.     cmp.b    #59,d2
  8213.     bgt.s    .trop        ; Si c'est trop haut, on baise d'une octave
  8214.     add.b    #12,d2        ; Transpose 2 octaves au-dessus pour GT
  8215. .trop:    add.b    #12,d2
  8216.     lsl.w    #8,d2        ; Place la note à l'extrémité du mot
  8217. .instr:    move.w    (a0),d3        ; Prend l'instrument
  8218.     lsr.w    #4,d3
  8219.     and.b    #63,d3        ; Bien recalibré
  8220.     move.b    d3,d2        ; Place-le à l'autre extrémité...
  8221.     swap    d2        ; ...Et hop! Tour de passe-passe
  8222.     move.b    1(a0),d3
  8223.     and.b    #15,d3        ; d3 = effet
  8224.     move.b    2(a0),d4        ; d4 = paramètre
  8225.     bsr.s    convert_profx_2_gtkfx    ; Conversion de l'effet
  8226.     move.l    d2,(a1)        ; Pouf! on enregistre la note au bon format
  8227.     clr.b    4(a1)        ; Efface le volume interne
  8228.     addq.l    #3,a0        ; Suivant
  8229.     add.w    d0,a1        ; Ligne suivante
  8230.     dbra    d1,cv_mtmv2gtk_loop
  8231.     movem.l    (sp)+,d0-d4/a0/a1
  8232.     rts
  8233.  
  8234.  
  8235.  
  8236. *============================================================================*
  8237. *    Converti un effet Protracker en un effet Graoumf Tracker    *
  8238. *    d2 = Note.l au format Graoumf (sans effet)            *
  8239. *    d3 = effet.b protracker (0-F)                *
  8240. *    d4 = paramètre.w protracker (0-FF)            *
  8241. *    Attention, ces registres ne sont pas sauvés            *
  8242. *    Au retour :                    *
  8243. *    d2 = Note + Effet                    *
  8244. *============================================================================*
  8245. convert_profx_2_gtkfx:
  8246.     cmp.b    #1,d3        ; Les effets qui ne changent pas
  8247.     beq.s    .nochange
  8248.     cmp.b    #2,d3
  8249.     beq.s    .nochange
  8250.     cmp.b    #3,d3
  8251.     beq.s    .nochange
  8252.     cmp.b    #4,d3
  8253.     beq.s    .nochange
  8254.     cmp.b    #7,d3
  8255.     beq.s    .nochange
  8256.     cmp.b    #$B,d3
  8257.     bne.s    .suite
  8258. .nochange:    move.w    d4,d2
  8259.     lsl.w    #8,d3
  8260.     add.w    d3,d2
  8261.     and.w    #$fff,d2
  8262.     bra    .fin
  8263.  
  8264. .suite:    tst.b    d3        ; Arpeggio
  8265.     bne.s    .5
  8266.     tst.b    d4
  8267.     beq    .fin
  8268.     add.w    #$1000,d4
  8269.     move.w    d4,d2
  8270.     bra    .fin
  8271.  
  8272. .5:    cmp.b    #5,d3        ; Vol slide + porta
  8273.     bne.s    .6
  8274.     move.w    d4,d3
  8275.     and.w    #$f,d3
  8276.     lsr.w    #4,d4
  8277.     sub.w    d3,d4
  8278.     add.w    d4,d4
  8279.     add.w    d4,d4
  8280.     bmi.s    .5neg
  8281.     add.w    #$1800,d4
  8282.     move.w    d4,d2
  8283.     bra    .fin
  8284. .5neg:    move.w    #$1900,d2
  8285.     sub.w    d4,d2
  8286.     bra    .fin
  8287.  
  8288. .6:    cmp.b    #6,d3        ; Vol slide + vib
  8289.     bne.s    .8
  8290.     move.w    d4,d3
  8291.     and.w    #$f,d3
  8292.     lsr.w    #4,d4
  8293.     sub.w    d3,d4
  8294.     add.w    d4,d4
  8295.     add.w    d4,d4
  8296.     bmi.s    .6neg
  8297.     add.w    #$1c00,d4
  8298.     move.w    d4,d2
  8299.     bra    .fin
  8300. .6neg:    move.w    #$1d00,d2
  8301.     sub.w    d4,d2
  8302.     bra    .fin
  8303.  
  8304. .8:    cmp.b    #8,d3        ; Set balance
  8305.     bne.s    .9
  8306.     add.w    #$400,d4
  8307.     lsl.w    #4,d4
  8308.     move.w    d4,d2
  8309.     bra    .fin
  8310.  
  8311. .9:    cmp.b    #9,d3        ; Play part of sample
  8312.     bne.s    .a
  8313.     add.w    #$9000,d4
  8314.     move.w    d4,d2
  8315.     bra    .fin
  8316.  
  8317. .a:    cmp.b    #10,d3        ; Vol slide
  8318.     bne.s    .c
  8319.     move.w    d4,d3
  8320.     and.w    #$f,d3
  8321.     lsr.w    #4,d4
  8322.     sub.w    d3,d4
  8323.     add.w    d4,d4
  8324.     add.w    d4,d4
  8325.     bmi.s    .aneg
  8326.     add.w    #$1400,d4
  8327.     move.w    d4,d2
  8328.     bra    .fin
  8329. .aneg:    move.w    #$1500,d2
  8330.     sub.w    d4,d2
  8331.     bra    .fin
  8332.  
  8333. .c:    cmp.b    #$c,d3        ; Set volume
  8334.     bne.s    .d
  8335.     add.w    d4,d4
  8336.     add.w    d4,d4
  8337.     add.w    #$2000,d4
  8338.     move.w    d4,d2
  8339.     bra    .fin
  8340.  
  8341. .d:    cmp.b    #$d,d3        ; Break pattern to line
  8342.     bne.s    .e
  8343.     move.w    d4,d3        ; Conversion BCD -> Hexa
  8344.     lsr.w    #4,d4
  8345.     mulu.w    #10,d4
  8346.     and.b    #$f,d3
  8347.     add.b    d3,d4
  8348.     move.w    #$D00,d2
  8349.     move.b    d4,d2
  8350.     bra    .fin
  8351.  
  8352. .e:    cmp.b    #14,d3        ; Effets étendus
  8353.     bne    .f
  8354.     move.w    d4,d3
  8355.     lsr.b    #4,d3
  8356.     and.b    #$f,d4
  8357. .e1:    cmp.b    #1,d3        ; Fine porta up
  8358.     bne.s    .e2
  8359.     add.w    #$1100,d4
  8360.     move.w    d4,d2
  8361.     bra    .fin
  8362.  
  8363. .e2:    cmp.b    #2,d3        ; Fine porta down
  8364.     bne.s    .e4
  8365.     add.w    #$1200,d4
  8366.     move.w    d4,d2
  8367.     bra    .fin
  8368.  
  8369. .e4:    cmp.b    #4,d3        ; Set vib wave
  8370.     bne.s    .e5
  8371.     add.w    #$c00,d4
  8372.     move.w    d4,d2
  8373.     bra    .fin
  8374.  
  8375. .e5:    cmp.b    #5,d3        ; Set finetune
  8376.     bne.s    .e6
  8377.     cmp.b    #7,d4
  8378.     bgt.s    .e5neg
  8379.     lsl.b    #4,d4
  8380.     add.w    #$800,d4
  8381.     move.w    d4,d2
  8382.     bra    .fin
  8383. .e5neg:    move.w    #$810,d2
  8384.     sub.w    d4,d2
  8385.     bra    .fin
  8386.  
  8387. .e6:    cmp.b    #6,d3        ; Pattern loop
  8388.     bne.s    .e7
  8389.     add.w    #$b100,d4
  8390.     move.w    d4,d2
  8391.     bra    .fin
  8392.  
  8393. .e7:    cmp.b    #7,d3        ; Set trem wave
  8394.     bne.s    .e8
  8395.     add.w    #$e00,d4
  8396.     move.w    d4,d2
  8397.     bra    .fin
  8398.  
  8399. .e8:    cmp.b    #8,d3        ; Set balance (2)
  8400.     bne.s    .e9
  8401.     lsl.w    #8,d4
  8402.     add.w    #$4000,d4
  8403.     move.w    d4,d2
  8404.     bra    .fin
  8405.  
  8406. .e9:    cmp.b    #9,d3        ; Retrig sample
  8407.     bne.s    .e10
  8408.     lsl.w    #8,d4
  8409.     add.w    #$7000,d4
  8410.     move.w    d4,d2
  8411.     bra    .fin
  8412.  
  8413. .e10:    cmp.b    #10,d3        ; Fine vol up
  8414.     bne.s    .e11
  8415.     move.w    #$a400,d2
  8416.     add.b    d4,d4
  8417.     add.b    d4,d4
  8418.     add.b    d4,d2
  8419.     bra    .fin
  8420.  
  8421. .e11:    cmp.b    #11,d3        ; Fine vol down
  8422.     bne.s    .e12
  8423.     move.w    #$a500,d2
  8424.     add.b    d4,d4
  8425.     add.b    d4,d4
  8426.     add.b    d4,d2
  8427.     bra    .fin
  8428.  
  8429. .e12:    cmp.b    #12,d3        ; Note cut
  8430.     bne.s    .e13
  8431.     add.w    #$a00,d4
  8432.     move.w    d4,d2
  8433.     bra    .fin
  8434.  
  8435. .e13:    cmp.b    #13,d3        ; Note delay
  8436.     bne.s    .ee
  8437.     add.w    #$900,d4
  8438.     move.w    d4,d2
  8439.     bra    .fin
  8440.  
  8441. .ee:    cmp.b    #$e,d3        ; Pattern delay
  8442.     bne    .fin
  8443.     add.w    #$aa00,d4
  8444.     move.w    d4,d2
  8445.     bra    .fin
  8446.  
  8447. .f:    cmp.b    #15,d3        ; Tempo
  8448.     bne.s    .fin
  8449.     move.w    #$0F00,d2
  8450.     cmp.w    #$20,d4
  8451.     bge.s    .f_ok
  8452.     move.w    #$A800,d2
  8453. .f_ok:    move.b    d4,d2
  8454.  
  8455. .fin:    rts
  8456.  
  8457.  
  8458.  
  8459. *============================================================================*
  8460. *    Affiche un marqueur de sample                *
  8461. *    d0 = longueur.l en octets du sample affiché            *
  8462. *    d1 = nombre.w d'octets par sample            *
  8463. *    d2 = ligne.w d'affichage                *
  8464. *    d3 = largeur.w en pixels                *
  8465. *    d4 = hauteur.w en pixels                *
  8466. *    d5 = position.l du marqueur                *
  8467. *    d6 = numéro.w de plan (0-3)                *
  8468. *============================================================================*
  8469. affiche_marqueur_sample:
  8470.     movem.l    d0-d7/a1,-(sp)
  8471.     cmp.b    #2,d1
  8472.     bne.s    .finsi
  8473.     lsr.l    #1,d0
  8474.     lsr.l    #1,d5
  8475. .finsi:    move.l    adrecr(pc),a1
  8476.     mulu.w    linewidth(pc),d2
  8477.     addq.l    #8,a1
  8478.     add.w    d6,d6
  8479.     add.w    d6,a1        ; Ajuste sur la bonne colonne, puis sur le bon plan
  8480.     add.l    d2,a1        ; a1 = adresse d'affichage du début du sample
  8481.     moveq    #0,d6
  8482.     moveq    #0,d7
  8483.     move.w    d3,d7
  8484.     subq.l    #1,d7        ; d7 = largeur-1
  8485.     mulu.l    d5,d6:d7
  8486.     divu.l    d0,d6:d7        ; d7 = position du curseur en pixels
  8487.     move.l    d7,d3
  8488.     lsr.w    #1,d3
  8489.     and.w    #$FFF8,d3
  8490.     add.w    d3,a1        ; a1 = adresse d'affichage du marqueur
  8491.     not.b    d7
  8492.     and.w    #15,d7        ; d7 = Numéro du bit à positionner pour afficher le marqueur
  8493.     moveq    #0,d6
  8494.     bset    d7,d6        ; d6 = masque
  8495.     move.w    linewidth(pc),d2
  8496.     subq.w    #1,d4        ; d4 = compteur de ligne
  8497. .loop:    or.w    d6,(a1)        ; Pixel!
  8498.     add.w    d2,a1        ; Ligne suivante
  8499.     dbra    d4,.loop
  8500.     movem.l    (sp)+,d0-d7/a1
  8501.     rts
  8502.  
  8503.  
  8504.  
  8505. *============================================================================*
  8506. *    Efface un marqueur de sample                *
  8507. *    d0 = longueur.l en octets du sample affiché            *
  8508. *    d1 = nombre.w d'octets par sample            *
  8509. *    d2 = ligne.w d'affichage                *
  8510. *    d3 = largeur.w en pixels                *
  8511. *    d4 = hauteur.w en pixels                *
  8512. *    d5 = position.l du marqueur                *
  8513. *    d6 = numéro.w de plan (0-3)                *
  8514. *============================================================================*
  8515. efface_marqueur_sample:
  8516.     movem.l    d0-d7/a1,-(sp)
  8517.     cmp.b    #2,d1
  8518.     bne.s    .finsi
  8519.     lsr.l    #1,d0
  8520.     lsr.l    #1,d5
  8521. .finsi:    move.l    adrecr(pc),a1
  8522.     mulu.w    linewidth(pc),d2
  8523.     addq.l    #8,d2
  8524.     add.w    d6,d6
  8525.     add.w    d6,d2        ; Ajuste sur la bonne colonne, puis sur le bon plan
  8526.     add.l    d2,a1        ; a1 = adresse d'affichage du début du sample
  8527.     moveq    #0,d6
  8528.     moveq    #0,d7
  8529.     move.w    d3,d7
  8530.     subq.l    #1,d7        ; d7 = largeur-1
  8531.     mulu.l    d5,d6:d7
  8532.     divu.l    d0,d6:d7        ; d7 = position du curseur en pixels
  8533.     move.l    d7,d3
  8534.     lsr.w    #1,d3
  8535.     and.w    #$FFF8,d3
  8536.     add.w    d3,a1        ; a1 = adresse d'affichage du marqueur
  8537.     not.b    d7
  8538.     and.w    #15,d7        ; d7 = Numéro du bit à positionner pour effacer le marqueur
  8539.     moveq    #-1,d6
  8540.     bclr    d7,d6        ; d6 = masque
  8541.     move.w    linewidth(pc),d2
  8542.     subq.w    #1,d4        ; d4 = compteur de ligne
  8543. .loop:    and.w    d6,(a1)        ; Efface le pixel
  8544.     add.w    d2,a1        ; Ligne suivante
  8545.     dbra    d4,.loop
  8546.     movem.l    (sp)+,d0-d7/a1
  8547.     rts
  8548.  
  8549.  
  8550.  
  8551. *============================================================================*
  8552. *    Affiche un sample                    *
  8553. *    a0 = adresse du sample                *
  8554. *    d0 = Longueur en octets.l                *
  8555. *    d1 = nbr d'octets par sample (1 = 8 bits, 2 = 16 bits).w    *
  8556. *    d2 = ligne d'affichage.w                *
  8557. *    d3 = largeur (en colonnes de 16 pixels).w            *
  8558. *    d4 = hauteur.w                    *
  8559. *============================================================================*
  8560. affiche_sample:
  8561.     movem.l    d0-a6,-(sp)
  8562.     cmp.b    #2,d1
  8563.     bne.s    .finsi
  8564.     lsr.l    #1,d0        ; Convertit nbr d'octets en nbr de samples
  8565. .finsi:    move.l    adrecr(pc),a1
  8566.     mulu.w    linewidth(pc),d2
  8567.     addq.l    #8,d2
  8568.     add.l    d2,a1        ; a1 = adresse d'affichage
  8569.     move.w    d4,d2
  8570.     lsr.w    #1,d2
  8571.     mulu.w    linewidth(pc),d2
  8572.     lea    (a1,d2.l),a3    ; a3 = adresse de niveau 0
  8573.     moveq    #0,d2
  8574.     move.w    d3,d2
  8575.     lsl.w    #4,d2
  8576.     subq.w    #1,d2        ; d2 = nbr de pix -1
  8577.     moveq    #0,d7
  8578.     move.l    d0,d5
  8579.     divu.l    d2,d7:d5        ; d5 = incrément de sample, partie entière
  8580.     moveq    #0,d6        ;    = longueur spl / (nbr pix - 1)
  8581.     divu.l    d2,d7:d6        ; d6 = inc. de sample, partie décimale (en 2^-32)
  8582.     moveq    #0,d2
  8583.     subq.l    #1,d6        ;      - 1 micropoil pour laisser apparaître le dernier sample
  8584.     subx.l    d2,d5
  8585.     cmp.b    #2,d1        ; Sample 16 bits ?
  8586.     beq.s    aff_sam_16bits
  8587.     subq.w    #1,d3
  8588.     moveq    #0,d0        ; d0 = position dans le sample
  8589.     moveq    #0,d7        ; d7 = Position fine
  8590. aff_sam_loop1:
  8591.     move.w    d3,-(sp)
  8592.     move.l    a1,a2        ; a2 adresse écran
  8593.     move.w    d4,d2
  8594.     subq.w    #1,d2        ; d2 compteur de lignes
  8595. aff_sam_loop1_1:            ; Efface 16 colonnes
  8596.     clr.l    (a2)
  8597.     clr.l    4(a2)
  8598.     add.w    linewidth(pc),a2
  8599.     dbra    d2,aff_sam_loop1_1
  8600.     move.w    #$8000,d2        ; d2 = masque de bit
  8601.     moveq    #15,d1        ; d1 = compteur de colonne
  8602. aff_sam_loop1_2:
  8603.     move.l    a3,a2
  8604.     move.w    (a0,d0.l),d3
  8605.     clr.b    d3        ; d3 = sample
  8606.     muls.w    d4,d3
  8607.     swap    d3        ; d3 = hauteur de la ligne (signé)
  8608.     tst.w    d3
  8609.     bpl.s    aff_sam_positif
  8610.     neg.w    d3
  8611. .loop:    or.w    d2,(a2)
  8612.     or.w    d2,6(a2)
  8613.     sub.w    linewidth(pc),a2
  8614.     dbra    d3,.loop
  8615.     bra.s    aff_sam_finsi
  8616. aff_sam_positif:
  8617. .loop:    or.w    d2,(a2)
  8618.     or.w    d2,6(a2)
  8619.     add.w    linewidth(pc),a2
  8620.     dbra    d3,.loop
  8621. aff_sam_finsi:
  8622.     add.l    d6,d7        ; Prochain sample
  8623.     addx.l    d5,d0
  8624.     lsr.w    #1,d2
  8625.     dbra    d1,aff_sam_loop1_2
  8626.     addq.l    #8,a1
  8627.     addq.l    #8,a3
  8628.     move.w    (sp)+,d3
  8629.     dbra    d3,aff_sam_loop1
  8630.     movem.l    (sp)+,d0-a6
  8631.     rts
  8632.  
  8633. aff_sam_16bits:
  8634.     subq.w    #1,d3
  8635.     moveq    #0,d0        ; d0 = position dans le sample
  8636.     moveq    #0,d7        ; d7 = Position fine
  8637. aff_sam16_loop1:
  8638.     move.w    d3,-(sp)
  8639.     move.l    a1,a2        ; a2 adresse écran
  8640.     move.w    d4,d2
  8641.     subq.w    #1,d2        ; d2 compteur de lignes
  8642. aff_sam16_loop1_1:            ; Efface 16 colonnes
  8643.     clr.l    (a2)
  8644.     clr.l    4(a2)
  8645.     add.w    linewidth(pc),a2
  8646.     dbra    d2,aff_sam16_loop1_1
  8647.     move.w    #$8000,d2        ; d2 = masque de bit
  8648.     moveq    #15,d1        ; d1 = compteur de colonne
  8649. aff_sam16_loop1_2:
  8650.     move.l    a3,a2
  8651.     move.w    (a0,d0.l*2),d3    ; d3 = sample
  8652.     muls.w    d4,d3
  8653.     swap    d3        ; d3 = hauteur de la ligne (signé)
  8654.     tst.w    d3
  8655.     bpl.s    aff_sam16_positif
  8656.     neg.w    d3
  8657. .loop:    or.w    d2,(a2)
  8658.     or.w    d2,6(a2)
  8659.     sub.w    linewidth(pc),a2
  8660.     dbra    d3,.loop
  8661.     bra.s    aff_sam16_finsi
  8662. aff_sam16_positif:
  8663. .loop:    or.w    d2,(a2)
  8664.     or.w    d2,6(a2)
  8665.     add.w    linewidth(pc),a2
  8666.     dbra    d3,.loop
  8667. aff_sam16_finsi:
  8668.     add.l    d6,d7        ; Prochain sample
  8669.     addx.l    d5,d0
  8670.     lsr.w    #1,d2
  8671.     dbra    d1,aff_sam16_loop1_2
  8672.     addq.l    #8,a1
  8673.     addq.l    #8,a3
  8674.     move.w    (sp)+,d3
  8675.     dbra    d3,aff_sam16_loop1
  8676.     movem.l    (sp)+,d0-a6
  8677.     rts
  8678.  
  8679.  
  8680.  
  8681. *============================================================================*
  8682. *    Affiche un pattern.                    *
  8683. *    d0 = le numéro de la ligne à afficher            *
  8684. *    d1 = colonne du curseur                *
  8685. *    d2 = position du curseur dans la colonne (0-2/0-6/0-7)        *
  8686. *    a0 = adresse d'un tableau de renseignements:        *
  8687. *         - nbr voies.w                    *
  8688. *         - nbr lignes max.w                *
  8689. *         - nbr colonnes à afficher.w                *
  8690. *         - nbr lignes à afficher.w                *
  8691. *         - les numéros de voies associées à chaque colonne.w (32)    *
  8692. *         - Quantité d'affichage.w (0 = note + instr, 1 = normal,    *
  8693. *           2 = + effet + volume)                *
  8694. *    a1 = adresse du début du pattern                *
  8695. *    a2 = adresse d'affichage                *
  8696. *============================================================================*
  8697. affiche_pattern:
  8698.     movem.l    d0-a6,-(sp)
  8699.  
  8700. ;--- Préliminaires -----------------------------------------------------------
  8701. ; Calcule les index de voies pour le preset
  8702.     lea    8(a0),a3        ; a3 = adresse du preset
  8703.     lea    patpreset5(pc),a4    ; a4 = adresse du preset multiplié
  8704.     move.w    4(a0),d2
  8705.     subq.w    #1,d2        ; d2 = compteur de voies
  8706. .loop:
  8707.     move.w    (a3)+,d3
  8708.     move.w    d3,d4        ; {
  8709.     add.w    d3,d3        ;   d3 = d3 * 5
  8710.     add.w    d3,d3        ;
  8711.     add.w    d4,d3        ; }
  8712.     move.w    d3,(a4)+        ; On sauve le résultat, comme ça on
  8713.     dbra    d2,.loop        ; n'a plus à faire les multiplications
  8714.  
  8715. ; Calcule le numéro de la première ligne à afficher
  8716.     move.l    a0,a3        ; ≡≡≡> a3 = adresse du tableau désormais
  8717.     move.w    6(a3),d2        ; Prend le nombre total de lignes
  8718.     move.w    d2,d3        ; ≡≡≡> d3
  8719.     lsr.w    #1,d2        ; ... et le divise par 2
  8720.     move.w    d2,d6        ; d6 = numéro de ligne à afficher en rouge
  8721.     sub.w    d2,d0        ; d0 = numéro de raw pour la 1ère ligne
  8722.  
  8723. ; A partir de ça trouve la bonne adresse dans le pattern
  8724.     move.w    d0,d2        ; d2 = numéro de raw de la 1ère ligne
  8725.     add.w    d0,d0        ; {
  8726.     add.w    d0,d0        ;   d0 = d0 * 5
  8727.     add.w    d2,d0        ; }
  8728.     muls.w    (a3),d0        ; Multiplie par le nombre de voies
  8729.     add.l    d0,a1        ; a1 = bonne ligne du pattern
  8730.  
  8731.     subq.w    #1,d3        ; d3 = compteur de lignes
  8732.  
  8733. ; Choisit le bon type d'affichage
  8734.     tst.w    72(a3)
  8735.     beq.s    aff_pat_type0
  8736.     cmp.w    #2,72(a3)
  8737.     beq    aff_pat_type2
  8738.     bra    aff_pat_type1
  8739.  
  8740. ;--- Affichage type 0 : note + instrument ------------------------------------
  8741. aff_pat_type0:
  8742.  
  8743. ; Boucle en Y
  8744. ; Registres entrant : d2, d3, d6, a1, a2, a3
  8745. aff_pat_t0_loop_y:
  8746.  
  8747. ; Y a t-il une ligne à afficher ou du vide ?
  8748.     lea    1(a2),a0        ; a0 = adresse d'affichage des numéros
  8749.     tst.w    d2
  8750.     bmi    aff_pat_t0_blanc    ; Si raw < 0
  8751.     cmp.w    2(a3),d2
  8752.     bge    aff_pat_t0_blanc    ; ou si raw => taille en raws
  8753.  
  8754. ; Affiche les numéros de raw
  8755.     lea    table_byte2char(pc),a4
  8756.     move.b    (a4,d2.w*2),d1
  8757.     moveq    #1,d0        ; d0 = Couleur bleue
  8758.     cmp.w    d6,d3
  8759.     bne.s    .fc1
  8760.     moveq    #2,d0        ; ou rouge
  8761. .fc1:    bsr    affcar8x6_plan
  8762.     addq.l    #7,a0
  8763.     move.b    1(a4,d2.w*2),d1
  8764.     bsr    affcar8x6_plan
  8765.     addq.l    #8,a0        ; Pointe maintenant sur la 1ère colonne
  8766.  
  8767.     lea    patpreset5(pc),a4    ; a4 = adresse du preset multiplié
  8768.     move.w    4(a3),d7
  8769.     subq.w    #1,d7        ; d7 = compteur de colonnes
  8770.  
  8771. ; Boucle en x
  8772. ; Registres entrant : d0, d2, d3, d6, d7, a0, a1, a2, a3, a4
  8773. aff_pat_t0_loop_x:
  8774.     move.w    (a4)+,d5        ; Offset de la voie par rapport au début de raw
  8775.     lea    (a1,d5.w),a5    ; a5 sur la note à afficher
  8776.  
  8777. ; Affiche la note
  8778.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit être déjà nul !
  8779.     lea    nom_notes(pc),a6
  8780.     lea    (a6,d5.w*4),a6
  8781.     move.b    (a6)+,d1
  8782.     bsr    affcar8x6_plan
  8783.     addq.l    #1,a0
  8784.     move.b    (a6)+,d1
  8785.     bsr    affcar8x6_plan
  8786.     addq.l    #7,a0
  8787.     move.b    (a6),d1
  8788.     bsr    affcar8x6_plan
  8789.     addq.l    #1,a0
  8790.  
  8791. ; Affiche l'instrument
  8792.     lea    table_byte2char2(pc),a6
  8793.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  8794.     lea    (a6,d5.w*2),a6
  8795.     move.b    (a6)+,d1
  8796.     bsr    affcar8x6_plan
  8797.     addq.l    #7,a0
  8798.     move.b    (a6),d1
  8799.     bsr    affcar8x6_plan
  8800.     addq.l    #8,a0
  8801.  
  8802. ; Colonne suivante
  8803.     dbra    d7,aff_pat_t0_loop_x
  8804.  
  8805. ; Ligne suivante
  8806. aff_pat_t0_next_line
  8807.     addq.w    #1,d2        ; Raw suivante
  8808.     move.w    linewidth(pc),d4
  8809.     add.w    d4,d4        ; * 6
  8810.     move.w    d4,d5
  8811.     add.w    d5,d5
  8812.     add.w    d5,d4
  8813.     add.w    d4,a2        ; Ligne de caractères suivante
  8814.     move.w    (a3),d4
  8815.     add.w    d4,a1        ; * 5
  8816.     add.w    d4,d4
  8817.     add.w    d4,d4
  8818.     add.w    d4,a1        ; Ligne de pattern suivante
  8819.     dbra    d3,aff_pat_t0_loop_y
  8820.     bra    aff_pat_fin
  8821.  
  8822. ; Ligne non affichée
  8823. aff_pat_t0_blanc:
  8824.     move.w    #' ',d1
  8825.     bsr    affcar8x6nt_ombr
  8826.     addq.l    #7,a0
  8827.     bsr    affcar8x6nt_ombr
  8828.     addq.l    #8,a0
  8829.  
  8830.     move.w    4(a3),d7
  8831.     subq.w    #1,d7        ; d7 = compteur de colonnes
  8832.  
  8833. aff_pat_t0_blanc_loop_x:
  8834.     Rept    2
  8835.     bsr    affcar8x6nt_ombr
  8836.     addq.l    #1,a0
  8837.     bsr    affcar8x6nt_ombr
  8838.     addq.l    #7,a0
  8839.     EndR
  8840.     bsr    affcar8x6nt_ombr
  8841.     addq.l    #8,a0
  8842.     dbra    d7,aff_pat_t0_blanc_loop_x
  8843.  
  8844.     bra.s    aff_pat_t0_next_line
  8845.  
  8846. ;--- Affichage type 1 : note + instrument + effet ----------------------------
  8847. aff_pat_type1:
  8848.  
  8849. ; Boucle en Y
  8850. ; Registres entrant : d2, d3, d6, a1, a2, a3
  8851. aff_pat_t1_loop_y:
  8852.  
  8853. ; Y a t-il une ligne à afficher ou du vide ?
  8854.     lea    1(a2),a0        ; a0 = adresse d'affichage des numéros
  8855.     tst.w    d2
  8856.     bmi    aff_pat_t1_blanc    ; Si raw < 0
  8857.     cmp.w    2(a3),d2
  8858.     bge    aff_pat_t1_blanc    ; ou si raw => taille en raws
  8859.  
  8860. ; Affiche les numéros de raw
  8861.     lea    table_byte2char(pc),a4
  8862.     move.b    (a4,d2.w*2),d1
  8863.     moveq    #1,d0        ; d0 = Couleur bleue
  8864.     cmp.w    d6,d3
  8865.     bne.s    .fc1
  8866.     moveq    #2,d0        ; ou rouge
  8867. .fc1:    bsr    affcar8x6_plan
  8868.     addq.l    #7,a0
  8869.     move.b    1(a4,d2.w*2),d1
  8870.     bsr    affcar8x6_plan
  8871.     addq.l    #8,a0        ; Pointe maintenant sur la 1ère colonne
  8872.  
  8873.     lea    patpreset5(pc),a4    ; a4 = adresse du preset multiplié
  8874.     move.w    4(a3),d7
  8875.     subq.w    #1,d7        ; d7 = compteur de colonnes
  8876.  
  8877. ; Boucle en x
  8878. ; Registres entrant : d0, d2, d3, d6, d7, a0, a1, a2, a3, a4
  8879. aff_pat_t1_loop_x:
  8880.     move.w    (a4)+,d5        ; Offset de la voie par rapport au début de raw
  8881.     lea    (a1,d5.w),a5    ; a5 sur la note à afficher
  8882.  
  8883. ; Affiche la note
  8884.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit être déjà nul !
  8885.     lea    nom_notes(pc),a6
  8886.     lea    (a6,d5.w*4),a6
  8887.     move.b    (a6)+,d1
  8888.     bsr    affcar8x6_plan
  8889.     addq.l    #1,a0
  8890.     move.b    (a6)+,d1
  8891.     bsr    affcar8x6_plan
  8892.     addq.l    #7,a0
  8893.     move.b    (a6),d1
  8894.     bsr    affcar8x6_plan
  8895.     addq.l    #1,a0
  8896.  
  8897. ; Affiche l'instrument
  8898.     lea    table_byte2char2(pc),a6
  8899.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  8900.     lea    (a6,d5.w*2),a6
  8901.     move.b    (a6)+,d1
  8902.     bsr    affcar8x6_plan
  8903.     addq.l    #7,a0
  8904.     move.b    (a6),d1
  8905.     bsr    affcar8x6_plan
  8906.     addq.l    #1,a0
  8907.  
  8908.  
  8909. ; Affiche l'effet
  8910.     tst.w    (a5)
  8911.     beq.s    .pasfx        ; Pas d'effet : on n'affiche que des points
  8912.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  8913.     lea    table_byte2char3(pc),a6
  8914.     lea    (a6,d5.w*2),a6    ; Affichage avec un point à la place du 0
  8915.     move.b    (a6)+,d1
  8916.     bsr    affcar8x6_plan
  8917.     addq.l    #7,a0
  8918.     move.b    (a6),d1
  8919.     bsr    affcar8x6_plan
  8920.     addq.l    #1,a0
  8921.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  8922.     lea    table_byte2char(pc),a6
  8923.     lea    (a6,d5.w*2),a6    ; Affichage normal
  8924.     move.b    (a6)+,d1
  8925.     bsr    affcar8x6_plan
  8926.     addq.l    #7,a0
  8927.     move.b    (a6),d1
  8928.     bsr    affcar8x6_plan
  8929.     addq.l    #8,a0
  8930.     bra.s    .finfx
  8931.  
  8932. .pasfx:
  8933.     moveq    #9,d1        ; Met des points
  8934.     bsr    affcar8x6_plan
  8935.     addq.l    #7,a0
  8936.     bsr    affcar8x6_plan
  8937.     addq.l    #1,a0
  8938.     bsr    affcar8x6_plan
  8939.     addq.l    #7,a0
  8940.     bsr    affcar8x6_plan
  8941.     addq.l    #8,a0
  8942. .finfx:
  8943.  
  8944. ; Colonne suivante
  8945.     dbra    d7,aff_pat_t1_loop_x
  8946.  
  8947. ; Ligne suivante
  8948. aff_pat_t1_next_line
  8949.     addq.w    #1,d2        ; Raw suivante
  8950.     move.w    linewidth(pc),d4
  8951.     add.w    d4,d4        ; * 6
  8952.     move.w    d4,d5
  8953.     add.w    d5,d5
  8954.     add.w    d5,d4
  8955.     add.w    d4,a2        ; Ligne de caractères suivante
  8956.     move.w    (a3),d4
  8957.     add.w    d4,a1        ; * 5
  8958.     add.w    d4,d4
  8959.     add.w    d4,d4
  8960.     add.w    d4,a1        ; Ligne de pattern suivante
  8961.     dbra    d3,aff_pat_t1_loop_y
  8962.     bra    aff_pat_fin
  8963.  
  8964. ; Ligne non affichée
  8965. aff_pat_t1_blanc:
  8966.     move.w    #' ',d1
  8967.     bsr    affcar8x6nt_ombr
  8968.     addq.l    #7,a0
  8969.     bsr    affcar8x6nt_ombr
  8970.     addq.l    #8,a0
  8971.  
  8972.     move.w    4(a3),d7
  8973.     subq.w    #1,d7        ; d7 = compteur de colonnes
  8974.  
  8975. aff_pat_t1_blanc_loop_x:
  8976.     Rept    4
  8977.     bsr    affcar8x6nt_ombr
  8978.     addq.l    #1,a0
  8979.     bsr    affcar8x6nt_ombr
  8980.     addq.l    #7,a0
  8981.     EndR
  8982.     bsr    affcar8x6nt_ombr
  8983.     addq.l    #8,a0
  8984.     dbra    d7,aff_pat_t1_blanc_loop_x
  8985.  
  8986.     bra.s    aff_pat_t1_next_line
  8987.  
  8988. ;--- Affichage type 2 : note + instrument + effet + volume--------------------
  8989. aff_pat_type2:
  8990.  
  8991. ; Boucle en Y
  8992. ; Registres entrant : d2, d3, d6, a1, a2, a3
  8993. aff_pat_t2_loop_y:
  8994.  
  8995. ; Y a t-il une ligne à afficher ou du vide ?
  8996.     lea    1(a2),a0        ; a0 = adresse d'affichage des numéros
  8997.     tst.w    d2
  8998.     bmi    aff_pat_t2_blanc    ; Si raw < 0
  8999.     cmp.w    2(a3),d2
  9000.     bge    aff_pat_t2_blanc    ; ou si raw => taille en raws
  9001.  
  9002. ; Affiche les numéros de raw
  9003.     lea    table_byte2char(pc),a4
  9004.     move.b    (a4,d2.w*2),d1
  9005.     moveq    #1,d0        ; d0 = Couleur bleue
  9006.     cmp.w    d6,d3
  9007.     bne.s    .fc1
  9008.     moveq    #2,d0        ; ou rouge
  9009. .fc1:    bsr    affcar8x6_plan
  9010.     addq.l    #7,a0
  9011.     move.b    1(a4,d2.w*2),d1
  9012.     bsr    affcar8x6_plan
  9013.     addq.l    #8,a0        ; Pointe maintenant sur la 1ère colonne
  9014.  
  9015.     lea    patpreset5(pc),a4    ; a4 = adresse du preset multiplié
  9016.     move.w    4(a3),d7
  9017.     subq.w    #1,d7        ; d7 = compteur de colonnes
  9018.  
  9019. ; Boucle en x
  9020. ; Registres entrant : d0, d2, d3, d6, d7, a0, a1, a2, a3, a4
  9021. aff_pat_t2_loop_x:
  9022.     move.w    (a4)+,d5        ; Offset de la voie par rapport au début de raw
  9023.     lea    (a1,d5.w),a5    ; a5 sur la note à afficher
  9024.  
  9025. ; Affiche la note
  9026.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit être déjà nul !
  9027.     lea    nom_notes(pc),a6
  9028.     lea    (a6,d5.w*4),a6
  9029.     move.b    (a6)+,d1
  9030.     bsr    affcar8x6_plan
  9031.     addq.l    #1,a0
  9032.     move.b    (a6)+,d1
  9033.     bsr    affcar8x6_plan
  9034.     addq.l    #7,a0
  9035.     move.b    (a6),d1
  9036.     bsr    affcar8x6_plan
  9037.     addq.l    #1,a0
  9038.  
  9039. ; Affiche l'instrument
  9040.     lea    table_byte2char2(pc),a6
  9041.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  9042.     lea    (a6,d5.w*2),a6
  9043.     move.b    (a6)+,d1
  9044.     bsr    affcar8x6_plan
  9045.     addq.l    #7,a0
  9046.     move.b    (a6),d1
  9047.     bsr    affcar8x6_plan
  9048.     addq.l    #1,a0
  9049.  
  9050.  
  9051. ; Affiche l'effet
  9052.     tst.w    (a5)
  9053.     beq.s    .pasfx        ; Pas d'effet : on n'affiche que des points
  9054.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  9055.     lea    table_byte2char3(pc),a6
  9056.     lea    (a6,d5.w*2),a6    ; Affichage avec un point à la place du 0
  9057.     move.b    (a6)+,d1
  9058.     bsr    affcar8x6_plan
  9059.     addq.l    #7,a0
  9060.     move.b    (a6),d1
  9061.     bsr    affcar8x6_plan
  9062.     addq.l    #1,a0
  9063.     move.b    (a5)+,d5        ; *** Le MSByte de d5 doit déjà être nul !
  9064.     lea    table_byte2char(pc),a6
  9065.     lea    (a6,d5.w*2),a6    ; Affichage normal
  9066.     move.b    (a6)+,d1
  9067.     bsr    affcar8x6_plan
  9068.     addq.l    #7,a0
  9069.     move.b    (a6),d1
  9070.     bsr    affcar8x6_plan
  9071.     addq.l    #1,a0
  9072.     bra.s    .finfx
  9073.  
  9074. .pasfx:
  9075.     moveq    #9,d1        ; Met des points
  9076.     bsr    affcar8x6_plan
  9077.     addq.l    #7,a0
  9078.     bsr    affcar8x6_plan
  9079.     addq.l    #1,a0
  9080.     bsr    affcar8x6_plan
  9081.     addq.l    #7,a0
  9082.     bsr    affcar8x6_plan
  9083.     addq.l    #1,a0
  9084.     addq.l    #2,a5        ; Saute l'effet dans le pattern
  9085. .finfx:
  9086.  
  9087. ; Affiche le volume
  9088.     move.b    (a5),d5        ; *** Le MSByte de d5 doit déjà être nul !
  9089.     lea    table_byte2char2(pc),a6
  9090.     lea    (a6,d5.w*2),a6
  9091.     move.b    (a6)+,d1
  9092.     bsr    affcar8x6_plan
  9093.     addq.l    #7,a0
  9094.     move.b    (a6),d1
  9095.     bsr    affcar8x6_plan
  9096.     addq.l    #8,a0
  9097.  
  9098. ; Colonne suivante
  9099.     dbra    d7,aff_pat_t2_loop_x
  9100.  
  9101. ; Ligne suivante
  9102. aff_pat_t2_next_line
  9103.     addq.w    #1,d2        ; Raw suivante
  9104.     move.w    linewidth(pc),d4
  9105.     add.w    d4,d4        ; * 6
  9106.     move.w    d4,d5
  9107.     add.w    d5,d5
  9108.     add.w    d5,d4
  9109.     add.w    d4,a2        ; Ligne de caractères suivante
  9110.     move.w    (a3),d4
  9111.     add.w    d4,a1        ; * 5
  9112.     add.w    d4,d4
  9113.     add.w    d4,d4
  9114.     add.w    d4,a1        ; Ligne de pattern suivante
  9115.     dbra    d3,aff_pat_t2_loop_y
  9116.     bra    aff_pat_fin
  9117.  
  9118. ; Ligne non affichée
  9119. aff_pat_t2_blanc:
  9120.     move.w    #' ',d1
  9121.     bsr    affcar8x6nt_ombr
  9122.     addq.l    #7,a0
  9123.     bsr    affcar8x6nt_ombr
  9124.     addq.l    #8,a0
  9125.  
  9126.     move.w    4(a3),d7
  9127.     subq.w    #1,d7        ; d7 = compteur de colonnes
  9128.  
  9129. aff_pat_t2_blanc_loop_x:
  9130.     Rept    5
  9131.     bsr    affcar8x6nt_ombr
  9132.     addq.l    #1,a0
  9133.     bsr    affcar8x6nt_ombr
  9134.     addq.l    #7,a0
  9135.     EndR
  9136.     bsr    affcar8x6nt_ombr
  9137.     addq.l    #8,a0
  9138.     dbra    d7,aff_pat_t2_blanc_loop_x
  9139.  
  9140.     bra.s    aff_pat_t2_next_line
  9141.  
  9142. ;-----------------------------------------------------------------------------
  9143. aff_pat_fin:
  9144.     movem.l    (sp)+,d0-a6
  9145.     bsr    affiche_curseur    ; Va afficher le curseur
  9146.     rts
  9147.  
  9148.  
  9149.  
  9150. *============================================================================*
  9151. *    Affiche le curseur                    *
  9152. *    d1 = colonne du curseur                *
  9153. *    d2 = position du curseur dans la colonne (0-6)        *
  9154. *    a0 = tableau de renseignements (voir + haut)        *
  9155. *    a2 = adresse d'affichage                *
  9156. *============================================================================*
  9157. affiche_curseur:
  9158.     movem.l    d0-d3/a0/a2,-(sp)
  9159.  
  9160. ;--- Effaçage du curseur précédent -------------------------------------------
  9161.     move.w    oldcolcurs(pc),d1
  9162.     move.w    oldposcurs(pc),d2
  9163.     move.w    6(a0),d0
  9164.     and.b    #$FE,d0
  9165.     move.w    d0,d3
  9166.     add.w    d0,d0
  9167.     add.w    d3,d0        ; INT(d0/2) * 6
  9168.     mulu.w    linewidth(pc),d0
  9169.     add.l    d0,a2        ; a2 adresse de la ligne d'affichage
  9170.     lsl.w    #3,d1        ; d1 * 24, 40 ou 48
  9171.     move.w    d1,d3
  9172.     add.w    d1,d1
  9173.     tst.w    72(a0)
  9174.     beq.s    .ok24_e
  9175.     add.w    d1,d1
  9176.     cmp.w    #2,72(a0)
  9177.     bne.s    .ok40_e
  9178.     add.w    d3,d1
  9179. .ok40_e:
  9180. .ok24_e:    add.w    d3,d1
  9181.     add.w    d1,a2        ; Sur la bonne colonne
  9182.     lea    curs_x_table(pc),a0
  9183.     add.w    (a0,d2.w*2),a2    ; Position exacte
  9184.     move.w    linewidth(pc),d1
  9185.     Rept    5
  9186.     clr.b    (a2)        ; on efface
  9187.     add.w    d1,a2
  9188.     EndR
  9189.     clr.b    (a2)
  9190.     movem.l    (sp),d0-d3/a0/a2    ; *** Les données restent quand même dans la pile
  9191.  
  9192. ;--- Affichage du nouveau curseur --------------------------------------------
  9193.     move.w    d1,oldcolcurs
  9194.     move.w    d2,oldposcurs
  9195.     move.w    6(a0),d0
  9196.     and.b    #$FE,d0
  9197.     move.w    d0,d3
  9198.     add.w    d0,d0
  9199.     add.w    d3,d0        ; INT(d0/2) * 6
  9200.     mulu.w    linewidth(pc),d0
  9201.     add.l    d0,a2        ; a2 adresse de la ligne d'affichage
  9202.     lsl.w    #3,d1        ; d1 * 24, 40 ou 48
  9203.     move.w    d1,d3
  9204.     add.w    d1,d1
  9205.     tst.w    72(a0)
  9206.     beq.s    .ok24
  9207.     add.w    d1,d1
  9208.     cmp.w    #2,72(a0)
  9209.     bne.s    .ok40
  9210.     add.w    d3,d1
  9211. .ok40:
  9212. .ok24:    add.w    d3,d1
  9213.     add.w    d1,a2        ; Sur la bonne colonne
  9214.     lea    curs_x_table(pc),a0
  9215.     add.w    (a0,d2.w*2),a2    ; Position exacte
  9216.     moveq    #-1,d0
  9217.     move.w    linewidth(pc),d1
  9218.     Rept    5
  9219.     move.b    d0,(a2)        ; on colorie
  9220.     add.w    d1,a2
  9221.     EndR
  9222.     move.b    d0,(a2)
  9223.     movem.l    (sp)+,d0-d3/a0/a2
  9224.     rts
  9225.  
  9226.  
  9227.  
  9228. *============================================================================*
  9229. *    Grise une surface en mettant un pixel sur deux en noir.    *
  9230. *    d0 = Abscisse.w de la surface, en colonnes de 8 pixels        *
  9231. *    d1 = Ordonnée.w, en pixels                *
  9232. *    d2 = Longueur.w - 1 , en colonnes de 8 pixels        *
  9233. *    d3 = Hauteur.w - 1, en pixels                *
  9234. *============================================================================*
  9235. grise_surface:
  9236.     movem.l    d0-a6,-(sp)
  9237.     move.l    adrecr(pc),a0    ; Prend l'adresse de l'écran
  9238.     mulu.w    linewidth(pc),d1    ; Ordonnée en octets
  9239.     moveq    #1,d4        ; L'incrément pour passer d'une col à la suivante
  9240.     lsl.w    #2,d0
  9241.     btst    #2,d0
  9242.     beq.s    .suite
  9243.     subq.w    #3,d0        ; Colonne impaire, on corrige l'erreur commise
  9244.     moveq    #7,d4        ; Du coup on change l'incrément
  9245. .suite:    add.w    d0,a0
  9246.     add.l    d1,a0        ; Adresse de la partie à griser
  9247.     moveq    #%01010101,d1    ; Masque   : And
  9248.     moveq    #-$56,d7        ; Masque 2 : Or
  9249.     moveq    #%110,d5        ; Le schmurtz d'alternance
  9250. .loopy:
  9251.     move.w    d2,d0        ; d0 = compteur de colonnes
  9252.     move.l    a0,a1        ; a1 = adresse qu'on grise
  9253.     move.w    d4,d6        ; d6 = incrément d'adresse
  9254. .loopx:
  9255.     and.b    d1,(a1)        ; Masque les 4 plans
  9256.     and.b    d1,2(a1)
  9257.     or.b    d7,4(a1)
  9258.     or.b    d7,6(a1)
  9259.     add.w    d6,a1        ; Additionne 1 ou 7 à a1 pour changer de colonne
  9260.     eor.b    d5,d6        ; Alterne +1 <-> +7 à chaque fois
  9261.     dbra    d0,.loopx
  9262.  
  9263.     add.w    linewidth(pc),a0    ; Ligne suivante
  9264.     not.w    d1        ; On décale le masque pour faire une grille
  9265.     not.w    d7
  9266.     dbra    d3,.loopy
  9267.  
  9268.     movem.l    (sp)+,d0-a6
  9269.     rts
  9270.  
  9271.  
  9272.  
  9273. *============================================================================*
  9274. *    Cadre (bords intérieurs) avec un texte centré à l'intérieur    *
  9275. *    d0 = longueur.w maxi du texte (largeur du cadre, quoi)        *
  9276. *    a0 = adresse du tableau de données concernant le cadre        *
  9277. *    Seules les coordonnées, longueur et les couleurs doivent    *
  9278. *    être remplies                    *
  9279. *    a1 = adresse du texte. A la fin a1 pointe sur la chaine suivante    *
  9280. *============================================================================*
  9281. cadre_centre:
  9282.  
  9283.     movem.l    d0-d3,-(sp)
  9284.     move.w    d0,c_large(a0)
  9285.     bsr    dessine_cadre_int    ; Dessin du cadre
  9286.     add.w    c_colonne(a0),d0
  9287.     add.w    c_colonne(a0),d0    ; d0 = position x du milieu du cadre (4 pix)
  9288.     move.l    a1,a2
  9289.     addq.w    #2,d0
  9290. .loop    subq.w    #1,d0        ; Recherche la longueur de la
  9291.     tst.b    (a2)+        ; chaine (sans le 0 final)
  9292.     bne.s    .loop        ; Résultat : d0 position de la chaine
  9293.     move.w    d0,d2
  9294.     move.w    c_haut(a0),d3    ; Hauteur du cadre
  9295.     subq.w    #5,d3        ; Hauteur du texte
  9296.     asr.w    #1,d3        ; Moitié
  9297.     add.w    c_ligne(a0),d3    ; Numéro de ligne d'affichage pour le texte
  9298.     move.b    c_cbordo(a0),d0    ; Récupère les couleurs
  9299.     move.b    c_cborde(a0),d1
  9300.     bsr    affchaine_trans_ombr    ; Affichage du texte
  9301.     movem.l    (sp)+,d0-d3
  9302.     rts
  9303.  
  9304.  
  9305.  
  9306. *============================================================================*
  9307. *    Affiche un cadre aux coordonnées indiquées.            *
  9308. *    Les contours sont à l'intérieur                *
  9309. *    a0 pointe sur le tableau d'informations pour le cadre        *
  9310. *    Structure du tableau:                    *
  9311. *    - colonne.w    Une colonne fait 8 pixels        *
  9312. *    - ligne.w        Numéro de la ligne            *
  9313. *    - largeur.w    -1 (en colonnes)            *
  9314. *    - hauteur.w    -1                *
  9315. *    - couleur.b    du fond                *
  9316. *    - couleur.b    du bord normal            *
  9317. *    - couleur.b    du bord éclairé            *
  9318. *    - couleur.b    du bord ombré            *
  9319. *============================================================================*
  9320. dessine_cadre_int:
  9321.  
  9322.     movem.l    d0-d7/a0-a3,-(sp)
  9323.     move.l    adrecr(pc),a1    ; a1 = adresse de l'écran
  9324.     move.w    c_ligne(a0),d0
  9325.     muls.w    linewidth(pc),d0
  9326.     add.l    d0,a1        ; a1 à la bonne ligne
  9327.     move.w    c_large(a0),d6    ; d6 = largeur
  9328.     move.w    c_haut(a0),d7    ; d7 = hauteur
  9329.     move.w    c_colonne(a0),d0    ; d0 = numéro de colonne
  9330.     bclr    #0,d0
  9331.     lsl.w    #2,d0
  9332.     add.w    d0,a1        ; a1 = adresse d'affichage (haut-gauche)
  9333.  
  9334. ; Affichage du fond
  9335.     move.b    c_cfond(a0),d0    ; d0 = couleur du fond
  9336.     prend_couleurs    d0    ; d2-d5 contiennent la valeur de chaque plan
  9337.     move.w    linewidth(pc),d1    ; d1 = saut de ligne
  9338.     subq.w    #6,d1
  9339.     move.l    a1,a3
  9340.     btst    #0,c_colonne+1(a0)
  9341.     beq.s    descadr_paire    ; Colonne paire, ok
  9342.     addq.l    #1,a1        ; Sinon on rajoute 1 à l'adresse d'aff.
  9343.     move.l    a1,a3
  9344.  
  9345. descadr_impaire:            ; Affichage d'une colonne impaire
  9346.     move.l    a3,a2
  9347.     move.w    d7,d0        ; d0 = compteur de ligne
  9348. descadr_imploop:
  9349.     remplit8pixels
  9350.     add.w    d1,a2        ; Ligne suivante
  9351.     dbra    d0,descadr_imploop
  9352.     subq.w    #1,d6
  9353.     bmi.s    descadr_fondfin
  9354.     addq.l    #7,a3        ; Colonne suivante (paire maintenant)
  9355. descadr_paire:            ; Affichage d'une colonne impaire
  9356.     move.l    a3,a2
  9357.     move.w    d7,d0        ; d0 = compteur de ligne
  9358. descadr_ploop:
  9359.     remplit8pixels
  9360.     add.w    d1,a2        ; Ligne suivante
  9361.     dbra    d0,descadr_ploop
  9362.     addq.l    #1,a3        ; Colonne suivante (impaire maintenant)
  9363.     dbra    d6,descadr_impaire
  9364. descadr_fondfin:
  9365.  
  9366. ; Affichage des bords horizontaux hauts et bas
  9367.     move.b    c_cborde(a0),d0    ; d0 = couleur du bord éclairé
  9368.     prend_couleurs    d0
  9369.     inverse_couleurs
  9370.     move.b    c_cbordo(a0),d0    ; d0 = couleur du bord ombré
  9371.     prend_couleurs    d0
  9372.     inverse_couleurs
  9373.     move.l    a1,a2        ; a2 = adresse d'affichage
  9374.     move.w    c_large(a0),d6    ; d6 = largeur
  9375.     btst    #0,c_colonne+1(a0)
  9376.     beq.s    descadr_paire2    ; Si la colonne est paire
  9377.  
  9378. descadr_impaire2:            ; Affichage sur une colonne impaire
  9379.     remplit8pixels
  9380.     addq.l    #1,a2
  9381.     subq.w    #1,d6
  9382.     bmi.s    descadr_bordhfin1
  9383. descadr_paire2:            ; Affichage sur une colonne paire
  9384.     remplit8pixels
  9385.     subq.l    #5,a2
  9386.     dbra    d6,descadr_impaire2
  9387.     addq.l    #6,a2
  9388. descadr_bordhfin1:
  9389.     lea    -7(a2),a3        ; a3 adresse du coin haut-droit du cadre
  9390.  
  9391.     inverse_couleurs        ; Le bord ombré maintenant
  9392.     move.l    a1,a2
  9393.     move.w    c_haut(a0),d0
  9394.     muls.w    linewidth(pc),d0
  9395.     add.l    d0,a2        ; Dernière ligne
  9396.     move.w    c_large(a0),d6    ; d6 = largeur
  9397.     btst    #0,c_colonne+1(a0)
  9398.     beq.s    descadr_paire3    ; Si la colonne est paire
  9399.  
  9400. descadr_impaire3:            ; Affichage sur une colonne impaire
  9401.     remplit8pixels
  9402.     addq.l    #1,a2
  9403.     subq.w    #1,d6
  9404.     bmi.s    descadr_bordhfin2
  9405. descadr_paire3:            ; Affichage sur une colonne paire
  9406.     remplit8pixels
  9407.     subq.l    #5,a2
  9408.     dbra    d6,descadr_impaire3
  9409. descadr_bordhfin2:
  9410.  
  9411. ; Affiche les bords verticaux droit et gauche
  9412.     move.l    a3,a2
  9413.     moveq    #-2,d0
  9414.     moveq    #1,d1
  9415.     move.w    linewidth(pc),d6
  9416.     subq.w    #6,d6
  9417.     move.w    c_haut(a0),d7
  9418. descadr_borddloop:
  9419.     affiche_1pixel
  9420.     add.w    d6,a2
  9421.     dbra    d7,descadr_borddloop
  9422.  
  9423.     inverse_couleurs        ; Le bord gauche maintenant
  9424.     move.l    a1,a2
  9425.     moveq    #$7F,d0
  9426.     moveq    #-128,d1
  9427.     move.w    c_haut(a0),d7
  9428. descadr_bordgloop:
  9429.     affiche_1pixel
  9430.     add.w    d6,a2
  9431.     dbra    d7,descadr_bordgloop
  9432.  
  9433. ; Affiche maintenant les coins B-G et H-D
  9434.     sub.w    linewidth(pc),a2
  9435.     move.b    c_cbordn(a0),d6
  9436.     prend_couleurs    d6
  9437.     affiche_1pixel
  9438.  
  9439.     move.l    a3,a2
  9440.     moveq    #-2,d0
  9441.     moveq    #1,d1
  9442.     affiche_1pixel
  9443.  
  9444.     movem.l    (sp)+,d0-d7/a0-a3
  9445.     rts
  9446.  
  9447.  
  9448.  
  9449. *============================================================================*
  9450. *    Affiche un cadre aux coordonnées indiquées.            *
  9451. *    Les contours sont à l'extérieur                *
  9452. *    a0 pointe sur le tableau d'informations pour le cadre        *
  9453. *    Structure du tableau:                    *
  9454. *    - colonne.w    Une colonne fait 8 pixels        *
  9455. *    - ligne.w        Numéro de la ligne            *
  9456. *    - largeur.w    -1 (en colonnes)            *
  9457. *    - hauteur.w    -1                *
  9458. *    - couleur.b    du fond                *
  9459. *    - couleur.b    du bord normal            *
  9460. *    - couleur.b    du bord éclairé            *
  9461. *    - couleur.b    du bord ombré            *
  9462. *============================================================================*
  9463. dessine_cadre_ext:
  9464.  
  9465.     movem.l    d0-d7/a0-a3,-(sp)
  9466.     move.l    adrecr(pc),a1    ; a1 = adresse de l'écran
  9467.     move.w    c_ligne(a0),d0
  9468.     muls.w    linewidth(pc),d0
  9469.     add.l    d0,a1        ; a1 à la bonne ligne
  9470.     move.w    c_large(a0),d6    ; d6 = largeur
  9471.     move.w    c_haut(a0),d7    ; d7 = hauteur
  9472.     move.w    c_colonne(a0),d0    ; d0 = numéro de colonne
  9473.     bclr    #0,d0
  9474.     lsl.w    #2,d0
  9475.     add.w    d0,a1        ; a1 = adresse d'affichage (haut-gauche)
  9476.  
  9477. ; Affichage du fond
  9478.     move.b    c_cfond(a0),d0    ; d0 = couleur du fond
  9479.     prend_couleurs    d0    ; d2-d5 contiennent la valeur de chaque plan
  9480.     move.w    linewidth(pc),d1    ; d1 = saut de ligne
  9481.     subq.w    #6,d1
  9482.     move.l    a1,a3
  9483.     btst    #0,c_colonne+1(a0)
  9484.     beq.s    descadrext_paire    ; Colonne paire, ok
  9485.     addq.l    #1,a1        ; Sinon on rajoute 1 à l'adresse d'aff.
  9486.     move.l    a1,a3
  9487.  
  9488. descadrext_impaire:            ; Affichage d'une colonne impaire
  9489.     move.l    a3,a2
  9490.     move.w    d7,d0        ; d0 = compteur de ligne
  9491. descadrext_imploop:
  9492.     remplit8pixels
  9493.     add.w    d1,a2        ; Ligne suivante
  9494.     dbra    d0,descadrext_imploop
  9495.     subq.w    #1,d6
  9496.     bmi.s    descadrext_fondfin
  9497.     addq.l    #7,a3        ; Colonne suivante (paire maintenant)
  9498. descadrext_paire:            ; Affichage d'une colonne impaire
  9499.     move.l    a3,a2
  9500.     move.w    d7,d0        ; d0 = compteur de ligne
  9501. descadrext_ploop:
  9502.     remplit8pixels
  9503.     add.w    d1,a2        ; Ligne suivante
  9504.     dbra    d0,descadrext_ploop
  9505.     addq.l    #1,a3        ; Colonne suivante (impaire maintenant)
  9506.     dbra    d6,descadrext_impaire
  9507. descadrext_fondfin:
  9508.  
  9509. ; Affichage des bords horizontaux hauts et bas
  9510.     move.b    c_cborde(a0),d0    ; d0 = couleur du bord éclairé
  9511.     prend_couleurs    d0
  9512.     inverse_couleurs
  9513.     move.b    c_cbordo(a0),d0    ; d0 = couleur du bord ombré
  9514.     prend_couleurs    d0
  9515.     inverse_couleurs
  9516.     move.l    a1,a2        ; a2 = adresse d'affichage
  9517.     sub.w    linewidth(pc),a2    ; Commence une ligne plus haut
  9518.     move.w    c_large(a0),d6    ; d6 = largeur
  9519.     btst    #0,c_colonne+1(a0)
  9520.     beq.s    descadrext_paire2    ; Si la colonne est paire
  9521.  
  9522. descadrext_impaire2:            ; Affichage sur une colonne impaire
  9523.     remplit8pixels
  9524.     addq.l    #1,a2
  9525.     subq.w    #1,d6
  9526.     bmi.s    descadrext_bordhfin1
  9527. descadrext_paire2:            ; Affichage sur une colonne paire
  9528.     remplit8pixels
  9529.     subq.l    #5,a2
  9530.     dbra    d6,descadrext_impaire2
  9531. descadrext_bordhfin1:
  9532.     move.l    a2,a3        ; a3 adresse du coin haut-droit du cadre (extérieur)
  9533.  
  9534.     inverse_couleurs        ; Le bord ombré maintenant
  9535.     move.l    a1,a2
  9536.     move.w    c_haut(a0),d0
  9537.     addq.w    #1,d0
  9538.     muls.w    linewidth(pc),d0
  9539.     add.l    d0,a2        ; Après la dernière ligne
  9540.     move.w    c_large(a0),d6    ; d6 = largeur
  9541.     btst    #0,c_colonne+1(a0)
  9542.     beq.s    descadrext_paire3    ; Si la colonne est paire
  9543.  
  9544. descadrext_impaire3:            ; Affichage sur une colonne impaire
  9545.     remplit8pixels
  9546.     addq.l    #1,a2
  9547.     subq.w    #1,d6
  9548.     bmi.s    descadrext_bordhfin2
  9549. descadrext_paire3:            ; Affichage sur une colonne paire
  9550.     remplit8pixels
  9551.     subq.l    #5,a2
  9552.     dbra    d6,descadrext_impaire3
  9553. descadrext_bordhfin2:
  9554.  
  9555. ; Affiche les bords verticaux droit et gauche
  9556.     move.l    a3,a2
  9557.     moveq    #$7F,d0
  9558.     moveq    #-128,d1
  9559.     move.w    linewidth(pc),d6
  9560.     subq.w    #6,d6
  9561.     move.w    c_haut(a0),d7
  9562. descadrext_borddloop:
  9563.     affiche_1pixel
  9564.     add.w    d6,a2
  9565.     dbra    d7,descadrext_borddloop
  9566.  
  9567.     inverse_couleurs        ; Le bord gauche maintenant
  9568.     move.l    a1,a2
  9569.     btst    #0,c_colonne+1(a0)
  9570.     beq.s    descadrext_paire4
  9571.     addq.l    #6,a2
  9572. descadrext_paire4:
  9573.     subq.l    #7,a2
  9574.     moveq    #-2,d0
  9575.     moveq    #1,d1
  9576.     move.w    c_haut(a0),d7
  9577. descadrext_bordgloop:
  9578.     affiche_1pixel
  9579.     add.w    d6,a2
  9580.     dbra    d7,descadrext_bordgloop
  9581.  
  9582. ; Affiche maintenant les coins B-G et H-D
  9583.     sub.w    linewidth(pc),a2
  9584.     move.b    c_cbordn(a0),d6
  9585.     prend_couleurs    d6
  9586.     affiche_1pixel
  9587.  
  9588.     move.l    a3,a2
  9589.     moveq    #$7F,d0
  9590.     moveq    #-128,d1
  9591.     affiche_1pixel
  9592.  
  9593.     movem.l    (sp)+,d0-d7/a0-a3
  9594.     rts
  9595.  
  9596.  
  9597.  
  9598. *============================================================================*
  9599. *    Affiche une chaine ASCII en mode transparent        *
  9600. *    d0 = couleur                    *
  9601. *    d2 = position x (4 pixels)                *
  9602. *    d3 = position y                    *
  9603. *    a1 = adresse de la chaine (se termine par 0)        *
  9604. *    Au retour a1 pointe sur la chaine suivante            *
  9605. *============================================================================*
  9606. affchaine_trans:
  9607.  
  9608.     movem.l    d0-d3/a0,-(sp)
  9609.     move.l    adrecr(pc),a0
  9610.     muls.w    linewidth(pc),d3
  9611.     add.l    d3,a0        ; a0 à la bonne ligne écran
  9612.     moveq    #0,d1        ; Pour ne pas avoir de problème octet/mot
  9613.     lsl.w    d2
  9614.     bclr    #2,d2        ; Adresse paire ou impaire ?
  9615.     bne.s    .impaire
  9616.     bclr    #1,d2        ; Décalage ou pas ?
  9617.     bne.s    .paire_dec
  9618.  
  9619.     add.w    d2,a0        ; Paire normal
  9620. .loop1:    move.b    (a1)+,d1
  9621.     beq.s    affchaine1_fin
  9622.     bsr    affcar8x6
  9623.     addq.l    #1,a0
  9624. .entree1:    move.b    (a1)+,d1
  9625.     beq.s    affchaine1_fin
  9626.     bsr    affcar8x6
  9627.     addq.l    #7,a0
  9628.     bra.s    .loop1
  9629. .paire_dec:            ; Paire décalé
  9630.     add.w    d2,a0
  9631. .loop2:    move.b    (a1)+,d1
  9632.     beq.s    affchaine1_fin
  9633.     bsr    affcar8x6_dec
  9634.     addq.l    #1,a0
  9635. .entree2:    move.b    (a1)+,d1
  9636.     beq.s    affchaine1_fin
  9637.     bsr    affcar8x6_dec
  9638.     addq.l    #7,a0
  9639.     bra.s    .loop2
  9640.  
  9641. .impaire:
  9642.     bclr    #1,d2
  9643.     bne.s    .impaire_dec
  9644.     add.w    d2,a0        ; Impaire normal
  9645.     addq.l    #1,a0
  9646.     bra.s    .entree1
  9647. .impaire_dec:            ; Impaire décalé
  9648.     add.w    d2,a0
  9649.     addq.l    #1,a0
  9650.     bra.s    .entree2
  9651.  
  9652. affchaine1_fin:
  9653.     movem.l    (sp)+,d0-d3/a0
  9654.     rts
  9655.  
  9656.  
  9657.  
  9658. *============================================================================*
  9659. *    Affiche une chaine ASCII en mode transparent ombré        *
  9660. *    d0 = couleur de la partie ombrée                *
  9661. *    d1 = couleur de la partie éclairée            *
  9662. *    d2 = position x (4 pixels)                *
  9663. *    d3 = position y                    *
  9664. *    a1 = adresse de la chaine (se termine par 0)        *
  9665. *    Au retour a1 pointe sur la chaine suivante            *
  9666. *============================================================================*
  9667. affchaine_trans_ombr:
  9668.  
  9669.     move.w    d0,-(sp)
  9670.     move.l    a2,-(sp)
  9671.     move.l    a1,a2        ; Conserve l'adresse de de la chaine
  9672.     movem.l    d0-d3/a0,-(sp)    ; Affiche la partie ombrée
  9673.     move.l    adrecr(pc),a0
  9674.     muls.w    linewidth(pc),d3
  9675.     add.l    d3,a0        ; a0 à la bonne ligne écran
  9676.     moveq    #0,d1        ; Pour ne pas avoir de problème octet/mot
  9677.     lsl.w    d2
  9678.     bclr    #2,d2        ; Adresse paire ou impaire ?
  9679.     bne.s    .impaire
  9680.     bclr    #1,d2        ; Décalage ou pas ?
  9681.     bne.s    .paire_dec
  9682.  
  9683.     add.w    d2,a0        ; Paire normal
  9684. .loop1:    move.b    (a1)+,d1
  9685.     beq.s    affchaine2_fin
  9686.     bsr    affcar8x6_ombr
  9687.     addq.l    #1,a0
  9688. .entree1:    move.b    (a1)+,d1
  9689.     beq.s    affchaine2_fin
  9690.     bsr    affcar8x6_ombr
  9691.     addq.l    #7,a0
  9692.     bra.s    .loop1
  9693. .paire_dec:            ; Paire décalé
  9694.     add.w    d2,a0
  9695. .loop2:    move.b    (a1)+,d1
  9696.     beq.s    affchaine2_fin
  9697.     bsr    affcar8x6_ombr_dec
  9698.     addq.l    #1,a0
  9699. .entree2:    move.b    (a1)+,d1
  9700.     beq.s    affchaine2_fin
  9701.     bsr    affcar8x6_ombr_dec
  9702.     addq.l    #7,a0
  9703.     bra.s    .loop2
  9704.  
  9705. .impaire:
  9706.     bclr    #1,d2
  9707.     bne.s    .impaire_dec
  9708.     add.w    d2,a0        ; Impaire normal
  9709.     addq.l    #1,a0
  9710.     bra.s    .entree1
  9711. .impaire_dec:            ; Impaire décalé
  9712.     add.w    d2,a0
  9713.     addq.l    #1,a0
  9714.     bra.s    .entree2
  9715.  
  9716. affchaine2_fin:
  9717.     movem.l    (sp)+,d0-d3/a0
  9718.     move.l    a2,a1        ; a1 adresse de l'ancienne chaine
  9719.     move.w    d1,d0        ; d0 couleur éclairée
  9720.     bsr    affchaine_trans    ; Va afficher la partie éclairée
  9721.     move.l    (sp)+,a2
  9722.     move.w    (sp)+,d0
  9723.     rts
  9724.  
  9725.  
  9726.  
  9727. *============================================================================*
  9728. *    Affiche une chaine ASCII en mode replace            *
  9729. *    d0 = couleur                    *
  9730. *    d2 = position x (8 pixels)                *
  9731. *    d3 = position y                    *
  9732. *    a1 = adresse de la chaine (se termine par 0)        *
  9733. *    Au retour a1 pointe sur la chaine suivante            *
  9734. *============================================================================*
  9735. affchaine_notrans:
  9736.  
  9737.     movem.l    d0-d3/a0,-(sp)    ; Affiche la partie ombrée
  9738.     move.l    adrecr(pc),a0
  9739.     muls.w    linewidth(pc),d3
  9740.     add.l    d3,a0        ; a0 à la bonne ligne écran
  9741.     moveq    #0,d1        ; Pour ne pas avoir de problème octet/mot
  9742.     lsl.w    #2,d2
  9743.     bclr    #2,d2        ; Adresse paire ou impaire ?
  9744.     bne.s    .impaire
  9745.  
  9746.     add.w    d2,a0        ; Paire
  9747. .loop1:    move.b    (a1)+,d1
  9748.     beq.s    affchaine3_fin
  9749.     bsr    affcar8x6nt_ombr
  9750.     addq.l    #1,a0
  9751. .entree1:    move.b    (a1)+,d1
  9752.     beq.s    affchaine3_fin
  9753.     bsr    affcar8x6nt_ombr
  9754.     addq.l    #7,a0
  9755.     bra.s    .loop1
  9756.  
  9757. .impaire:
  9758.     add.w    d2,a0        ; Impaire
  9759.     addq.l    #1,a0
  9760.     bra.s    .entree1
  9761.  
  9762. affchaine3_fin:
  9763.     movem.l    (sp)+,d0-d3/a0
  9764.     rts
  9765.  
  9766.  
  9767.  
  9768. *============================================================================*
  9769. *    Affiche une chaine ASCII en mode plan            *
  9770. *    d0 = couleur                    *
  9771. *    d2 = position x (8 pixels)                *
  9772. *    d3 = position y                    *
  9773. *    a1 = adresse de la chaine (se termine par 0)        *
  9774. *    Au retour a1 pointe sur la chaine suivante            *
  9775. *============================================================================*
  9776. affchaine_plan:
  9777.  
  9778.     movem.l    d0-d3/a0,-(sp)    ; Affiche la partie ombrée
  9779.     move.l    adrecr(pc),a0
  9780.     muls.w    linewidth(pc),d3
  9781.     add.l    d3,a0        ; a0 à la bonne ligne écran
  9782.     moveq    #0,d1        ; Pour ne pas avoir de problème octet/mot
  9783.     lsl.w    #2,d2
  9784.     bclr    #2,d2        ; Adresse paire ou impaire ?
  9785.     bne.s    .impaire
  9786.  
  9787.     add.w    d2,a0        ; Paire
  9788. .loop1:    move.b    (a1)+,d1
  9789.     beq.s    affchaine4_fin
  9790.     bsr    affcar8x6_plan
  9791.     addq.l    #1,a0
  9792. .entree1:    move.b    (a1)+,d1
  9793.     beq.s    affchaine4_fin
  9794.     bsr    affcar8x6_plan
  9795.     addq.l    #7,a0
  9796.     bra.s    .loop1
  9797.  
  9798. .impaire:
  9799.     add.w    d2,a0        ; Impaire
  9800.     addq.l    #1,a0
  9801.     bra.s    .entree1
  9802.  
  9803. affchaine4_fin:
  9804.     movem.l    (sp)+,d0-d3/a0
  9805.     rts
  9806.  
  9807.  
  9808.  
  9809. *============================================================================*
  9810. *    Affiche un caractère 8x6 à l'adresse indiquée        *
  9811. *    d1 = numéro ASCII du caractère                *
  9812. *    d0 = couleur                    *
  9813. *    a0 = adresse d'affichage                *
  9814. *    Vitesse moyenne : 7800 caractères/seconde            *
  9815. *============================================================================*
  9816. affcar8x6:
  9817.  
  9818.     movem.l    d0-d5/a0-a1,-(sp)
  9819.     lea    fonte8x6(pc),a1
  9820.     move.w    linewidth(pc),d3
  9821. affcar1_bra:
  9822.     subq.w    #6,d3
  9823.     add.w    d1,d1
  9824.     add.w    d1,a1
  9825.     add.w    d1,d1
  9826.     add.w    d1,a1        ; a1 pointe sur le caractère
  9827.     moveq    #5,d1        ; 6 lignes
  9828. affcar1_loop:
  9829.     move.w    d0,d2
  9830.     move.b    (a1)+,d4
  9831.     move.w    d4,d5
  9832.     not.w    d5
  9833. affcar1_plan:
  9834.     and.b    d5,(a0)
  9835.     lsr.w    d2
  9836.     bcc.s    affcar1_suitea
  9837.     or.b    d4,(a0)
  9838. affcar1_suitea:
  9839.     addq.l    #2,a0
  9840.     and.b    d5,(a0)
  9841.     lsr.w    d2
  9842.     bcc.s    affcar1_suiteb
  9843.     or.b    d4,(a0)
  9844. affcar1_suiteb:
  9845.     addq.l    #2,a0
  9846.     and.b    d5,(a0)
  9847.     lsr.w    d2
  9848.     bcc.s    affcar1_suitec
  9849.     or.b    d4,(a0)
  9850. affcar1_suitec:
  9851.     addq.l    #2,a0
  9852.     and.b    d5,(a0)
  9853.     lsr.w    d2
  9854.     bcc.s    affcar1_suited
  9855.     or.b    d4,(a0)
  9856. affcar1_suited:
  9857.     add.w    d3,a0
  9858.     dbra    d1,affcar1_loop
  9859.     movem.l    (sp)+,d0-d5/a0-a1
  9860.     rts
  9861.  
  9862.  
  9863.  
  9864. *============================================================================*
  9865. *    Affiche un caractère 8x6 à l'adresse indiquée        *
  9866. *    avec un décalage de 4 pixels sur la droite            *
  9867. *    d1 = numéro ASCII du caractère                *
  9868. *    d0 = couleur                    *
  9869. *    a0 = adresse d'affichage                *
  9870. *============================================================================*
  9871. affcar8x6_dec:
  9872.  
  9873.     movem.l    d0-d7/a0-a2,-(sp)
  9874.     lea    fonte8x6(pc),a1
  9875.     move.w    linewidth(pc),d3
  9876. affcar2_bra:
  9877.     subq.w    #6,d3
  9878.     add.w    d1,d1
  9879.     add.w    d1,a1
  9880.     add.w    d1,d1
  9881.     add.w    d1,a1        ; a1 pointe sur le caractère
  9882.     lea    1(a0),a2
  9883.     move.w    a0,d1
  9884.     btst    #0,d1
  9885.     beq.s    affcar2_suite2
  9886.     addq.l    #6,a2
  9887. affcar2_suite2:
  9888.     moveq    #5,d1        ; 6 lignes
  9889. affcar2_loop:
  9890.     move.w    d0,d2
  9891.     move.b    (a1)+,d4
  9892.     move.w    d4,d6
  9893.     lsr.b    #4,d4
  9894.     lsl.b    #4,d6
  9895.     move.w    d4,d5
  9896.     move.w    d6,d7
  9897.     not.w    d5
  9898.     not.w    d7
  9899. affcar2_plan:
  9900.     and.b    d5,(a0)
  9901.     and.b    d7,(a2)
  9902.     lsr.w    d2
  9903.     bcc.s    affcar2_suitea
  9904.     or.b    d4,(a0)
  9905.     or.b    d6,(a2)
  9906. affcar2_suitea:
  9907.     addq.l    #2,a0
  9908.     addq.l    #2,a2
  9909.     and.b    d5,(a0)
  9910.     and.b    d7,(a2)
  9911.     lsr.w    d2
  9912.     bcc.s    affcar2_suiteb
  9913.     or.b    d4,(a0)
  9914.     or.b    d6,(a2)
  9915. affcar2_suiteb:
  9916.     addq.l    #2,a0
  9917.     addq.l    #2,a2
  9918.     and.b    d5,(a0)
  9919.     and.b    d7,(a2)
  9920.     lsr.w    d2
  9921.     bcc.s    affcar2_suitec
  9922.     or.b    d4,(a0)
  9923.     or.b    d6,(a2)
  9924. affcar2_suitec:
  9925.     addq.l    #2,a0
  9926.     addq.l    #2,a2
  9927.     and.b    d5,(a0)
  9928.     and.b    d7,(a2)
  9929.     lsr.w    d2
  9930.     bcc.s    affcar2_suited
  9931.     or.b    d4,(a0)
  9932.     or.b    d6,(a2)
  9933. affcar2_suited:
  9934.     add.w    d3,a0
  9935.     add.w    d3,a2
  9936.     dbra    d1,affcar2_loop
  9937.     movem.l    (sp)+,d0-d7/a0-a2
  9938.     rts
  9939.  
  9940.  
  9941.  
  9942. *============================================================================*
  9943. *    Affiche un caractère 8x6 à l'adresse indiquée décalé d'un pixel    *
  9944. *    en bas à droite                    *
  9945. *    d1 = numéro ASCII du caractère                *
  9946. *    d0 = couleur                    *
  9947. *    a0 = adresse d'affichage                *
  9948. *    Vitesse moyenne : 7700 caractères/seconde            *
  9949. *============================================================================*
  9950. affcar8x6_ombr:
  9951.  
  9952.     movem.l    d0-d5/a0-a1,-(sp)
  9953.     move.w    linewidth(pc),d3
  9954.     add.w    d3,a0
  9955.     lea    fonte8x6_ombr(pc),a1
  9956.     bra    affcar1_bra
  9957.  
  9958.  
  9959.  
  9960. *============================================================================*
  9961. *    Affiche un caractère 8x6 à l'adresse indiquée décalé d'un pixel    *
  9962. *    vers le bas et de 5 pixels sur la droite            *
  9963. *    d1 = numéro ASCII du caractère                *
  9964. *    d0 = couleur                    *
  9965. *    a0 = adresse d'affichage                *
  9966. *============================================================================*
  9967. affcar8x6_ombr_dec:
  9968.  
  9969.     movem.l    d0-d7/a0-a2,-(sp)
  9970.     move.w    linewidth(pc),d3
  9971.     add.w    d3,a0
  9972.     lea    fonte8x6_ombr(pc),a1
  9973.     bra    affcar2_bra
  9974.  
  9975.  
  9976.  
  9977. *============================================================================*
  9978. *    Affiche un caractère 8x6 à l'adresse indiquée sans transparence    *
  9979. *    Décalage d'1 pixel à droite                *
  9980. *    d0 = couleur                    *
  9981. *    d1 = numéro ASCII                    *
  9982. *    a0 = adresse d'affichage                *
  9983. *============================================================================*
  9984. affcar8x6nt_ombr:
  9985.     movem.l    d0-d2/a0-a2,-(sp)
  9986.     move.w    linewidth(pc),d2
  9987.     lea    fonte8x6_ombr(pc),a1
  9988.     and.w    #$FF,d1
  9989.     add.w    d1,d1
  9990.     add.w    d1,a1
  9991.     add.w    d1,d1
  9992.     add.w    d1,a1        ; a1 pointe sur le caractère
  9993.     move.w    #3,d1
  9994. affcar5_loop:
  9995.     move.l    a0,a2
  9996.     lsr.w    #1,d0
  9997.     bcc.s    .s1
  9998.     REPT    5
  9999.     move.b    (a1)+,(a2)
  10000.     add.w    d2,a2
  10001.     ENDR
  10002.     move.b    (a1),(a2)
  10003.     subq.l    #5,a1
  10004.     bra.s    .s2
  10005. .s1:    REPT    5
  10006.     clr.b    (a2)
  10007.     add.w    d2,a2
  10008.     ENDR
  10009.     clr.b    (a2)
  10010. .s2:    addq.l    #2,a0
  10011.     dbra    d1,affcar5_loop
  10012.     movem.l    (sp)+,d0-d2/a0-a2
  10013.     rts
  10014.  
  10015.  
  10016.  
  10017. *============================================================================*
  10018. *    Affiche un caractère 8x6 à l'adresse indiquée en ne modifiant    *
  10019. *    que les plans désignés par la couleur            *
  10020. *    Décalage d'1 pixel à droite                *
  10021. *    d0 = couleur                    *
  10022. *    d1 = numéro ASCII                    *
  10023. *    a0 = adresse d'affichage                *
  10024. *============================================================================*
  10025. affcar8x6_plan:
  10026.     movem.l    d0-d2/a0-a2,-(sp)
  10027.     move.w    linewidth(pc),d2
  10028.     lea    fonte8x6_ombr(pc),a1
  10029.     and.w    #$FF,d1
  10030.     add.w    d1,d1
  10031.     add.w    d1,a1
  10032.     add.w    d1,d1
  10033.     add.w    d1,a1        ; a1 pointe sur le caractère
  10034.     move.w    #3,d1
  10035. affcar6_loop:
  10036.     lsr.w    #1,d0
  10037.     bcc.s    .s1
  10038.     move.l    a0,a2
  10039.     REPT    5
  10040.     move.b    (a1)+,(a2)
  10041.     add.w    d2,a2
  10042.     ENDR
  10043.     move.b    (a1),(a2)
  10044.     subq.l    #5,a1
  10045. .s1:    addq.l    #2,a0
  10046.     dbra    d1,affcar6_loop
  10047.     movem.l    (sp)+,d0-d2/a0-a2
  10048.     rts
  10049.  
  10050.  
  10051.  
  10052. *============================================================================*
  10053. *    Fabrique la fonte ombrée à partir de la fonte déjà chargée    *
  10054. *============================================================================*
  10055. fabrique_fonte_ombr:
  10056.  
  10057.     movem.l    d1-d2/a1-a2,-(sp)
  10058.     lea    fonte8x6(pc),a2
  10059.     lea    fonte8x6_ombr(pc),a1
  10060.     move.w    #255,d2
  10061. fabrfnt_loop:
  10062.     REPT    6
  10063.     move.b    (a2)+,d1
  10064.     lsr.b    d1
  10065.     move.b    d1,(a1)+
  10066.     ENDR
  10067.     dbra    d2,fabrfnt_loop
  10068.     movem.l    (sp)+,d1-d2/a1-a2
  10069.     rts
  10070.  
  10071.  
  10072.  
  10073.  
  10074.  
  10075. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  10076.  
  10077.     DATA
  10078.  
  10079. ;--- Ne pas changer l'ordre de ces lignes !!! (cause GfA) --------------------
  10080. adrecr:        Ds.l    1    ; Adresse de l'écran
  10081. linewidth:        Ds.w    1    ; Largeur d'une ligne en octets
  10082. flag_sample_rec:    Ds.w    1    ; Flag d'ordre pour l'enregistrement
  10083.                 ; 0 = Ordre d'arrêter la digit
  10084.                 ; 1 = Ordre de commencer la digit
  10085. flag_sample_rec2:    Ds.w    1    ; Flag d'indication
  10086.                 ; 1 = On a déclenché quelque chose
  10087.                 ; 2 = Phase trigger active
  10088.                 ; 3 = Phase sampling active
  10089.                 ; 4 = Sampling fini
  10090. adr_record_inf:    Dc.l    record_inf    ; Adresse des infos pour la digit d'un son
  10091. adr_sam_rec_buffer:    Dc.l    sample_rec_buffer
  10092. rec_sam_num_buf:    Dc.l    0    ; Numéro*4096 du buffer sur lequel on enregistre (0 ou 4096)
  10093. fxdly_deb1:    Ds.w    1    ; Sample de début du buffer 1 (effet de Delay)
  10094. fxdly_deb2:    Ds.w    1    ; Sample de début du buffer 2
  10095. songrecord_paramadr:    Ds.l    1    ; Adresse des info sur l'enregistrement d'un mod (-> GTPLAY.PGT)
  10096. songrec_adr_buffer:    Ds.l    1    ; Adresse du buffer final pour l'enregistrement d'un module
  10097. songrec_lon_buffer:    Ds.l    1    ; Sa longueur en mémoire (en octets)
  10098. songrec_pos_buffer:    Ds.l    1    ; Position de l'enregistrement dans le buffer
  10099. songrec_lon_sample:    Ds.l    1    ; La longueur maximum de sample à enregistrer (octets)
  10100. songrec_pos_sample:    Ds.l    1    ; Position de l'enregistrement dans le sample
  10101. songrec_type:    Ds.w    1    ; Type: 0 = normal, 1 = bouclage
  10102. songrec_flag:    Ds.w    1    ; 0 = arrête, 1 = continue à recopier
  10103. songrec_bits:    Ds.w    1    ; 1 = 8 bits, 2 = 16 bits
  10104. songrec_stereo:    Ds.w    1    ; 1 = mono, 2 = stereo
  10105. ; sngrecparamadr+32
  10106. progression_pos:    Ds.l    1    ; Nombre courant d'opérations effectuées
  10107. progression_len:    Ds.l    1    ; Nombre total d'opérations à effectuer
  10108.  
  10109. ;--- Maintenant c'est bon ----------------------------------------------------
  10110. numericpad_scancodes:    Dc.b    99,100,101,102
  10111.         Dc.b    103,104,105,74
  10112.         Dc.b    106,107,108,78
  10113.         Dc.b    109,110,111,114
  10114.  
  10115. fonte8x6:        incbin    'FONTE1.FNT'
  10116.  
  10117. nom_notes:    dc.b    '--- C#= D-= D#= E-= F-= F#= G-= G#= A-= A#= B-= '
  10118.     dc.b    'C-- C#- D-- D#- E-- F-- F#- G-- G#- A-- A#- B-- '
  10119.     dc.b    'C-0 C#0 D-0 D#0 E-0 F-0 F#0 G-0 G#0 A-0 A#0 B-0 '
  10120.     dc.b    'C-1 C#1 D-1 D#1 E-1 F-1 F#1 G-1 G#1 A-1 A#1 B-1 '
  10121.     dc.b    'C-2 C#2 D-2 D#2 E-2 F-2 F#2 G-2 G#2 A-2 A#2 B-2 '
  10122.     dc.b    'C-3 C#3 D-3 D#3 E-3 F-3 F#3 G-3 G#3 A-3 A#3 B-3 '
  10123.     dc.b    'C-4 C#4 D-4 D#4 E-4 F-4 F#4 G-4 G#4 A-4 A#4 B-4 '
  10124.     dc.b    'C-5 C#5 D-5 D#5 E-5 F-5 F#5 G-5 G#5 A-5 A#5 B-5 '
  10125.     dc.b    'C-6 C#6 D-6 D#6 E-6 F-6 F#6 G-6 G#6 A-6 A#6 B-6 '
  10126.     dc.b    'C-7 C#7 D-7 D#7 E-7 F-7 F#7 G-7 G#7 A-7 A#7 B-7 '
  10127.     dc.b    'C-8 C#8 D-8 D#8 E-8 F-8 F#8 G-8 '
  10128.  
  10129. curs_x_table:            ; Colonne 4 (+16), plan 3 (+6)
  10130.     dc.w    22        ; Offset Note
  10131.     dc.w    31,38        ; Offset Instrument
  10132.     dc.w    39,46,47,54    ; Offset Effet
  10133.     dc.w    55,62        ; Offset Volume
  10134.  
  10135. nt_pernote:
  10136.     Dc.w    $358,$328,$2FA,$2D0,$2A6,$280
  10137.     Dc.w    $25C,$23A,$21A,$1FC,$1E0,$1C5
  10138.     Dc.w    $1AC,$194,$17D,$168,$153,$140
  10139.     Dc.w    $12E,$11D,$10D,$0FE,$0F0,$0E2
  10140.     Dc.w    $0D6,$0CA,$0BE,$0B4,$0AA,$0A0
  10141.     Dc.w    $097,$08F,$087,$07F,$078,$071
  10142.  
  10143. table_byte2char:            ; Conversion byte -> ASCII hexa
  10144.     dc.b    '000102030405060708090A0B0C0D0E0F'
  10145.     dc.b    '101112131415161718191A1B1C1D1E1F'
  10146.     dc.b    '202122232425262728292A2B2C2D2E2F'
  10147.     dc.b    '303132333435363738393A3B3C3D3E3F'
  10148.     dc.b    '404142434445464748494A4B4C4D4E4F'
  10149.     dc.b    '505152535455565758595A5B5C5D5E5F'
  10150.     dc.b    '606162636465666768696A6B6C6D6E6F'
  10151.     dc.b    '707172737475767778797A7B7C7D7E7F'
  10152.     dc.b    '808182838485868788898A8B8C8D8E8F'
  10153.     dc.b    '909192939495969798999A9B9C9D9E9F'
  10154.     dc.b    'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'
  10155.     dc.b    'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'
  10156.     dc.b    'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'
  10157.     dc.b    'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'
  10158.     dc.b    'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'
  10159.     dc.b    'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'
  10160. table_byte2char2:            ; Conversion byte -> ASCII hexa, remplace 0 par ' '
  10161.     dc.b    '   1 2 3 4 5 6 7 8 9 A B C D E F'
  10162.     dc.b    '101112131415161718191A1B1C1D1E1F'
  10163.     dc.b    '202122232425262728292A2B2C2D2E2F'
  10164.     dc.b    '303132333435363738393A3B3C3D3E3F'
  10165.     dc.b    '404142434445464748494A4B4C4D4E4F'
  10166.     dc.b    '505152535455565758595A5B5C5D5E5F'
  10167.     dc.b    '606162636465666768696A6B6C6D6E6F'
  10168.     dc.b    '707172737475767778797A7B7C7D7E7F'
  10169.     dc.b    '808182838485868788898A8B8C8D8E8F'
  10170.     dc.b    '909192939495969798999A9B9C9D9E9F'
  10171.     dc.b    'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'
  10172.     dc.b    'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'
  10173.     dc.b    'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'
  10174.     dc.b    'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'
  10175.     dc.b    'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'
  10176.     dc.b    'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'
  10177. table_byte2char3:            ; Conversion byte -> ASCII hexa, remplace 0 par un point
  10178.     dc.b    9,'0',9,'1',9,'2',9,'3',9,'4',9,'5',9,'6',9,'7'
  10179.     dc.b    9,'8',9,'9',9,'A',9,'B',9,'C',9,'D',9,'E',9,'F'
  10180.     dc.b    '101112131415161718191A1B1C1D1E1F'
  10181.     dc.b    '202122232425262728292A2B2C2D2E2F'
  10182.     dc.b    '303132333435363738393A3B3C3D3E3F'
  10183.     dc.b    '404142434445464748494A4B4C4D4E4F'
  10184.     dc.b    '505152535455565758595A5B5C5D5E5F'
  10185.     dc.b    '606162636465666768696A6B6C6D6E6F'
  10186.     dc.b    '707172737475767778797A7B7C7D7E7F'
  10187.     dc.b    '808182838485868788898A8B8C8D8E8F'
  10188.     dc.b    '909192939495969798999A9B9C9D9E9F'
  10189.     dc.b    'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'
  10190.     dc.b    'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'
  10191.     dc.b    'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'
  10192.     dc.b    'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'
  10193.     dc.b    'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'
  10194.     dc.b    'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'
  10195.  
  10196.  
  10197.  
  10198. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  10199.  
  10200.     BSS
  10201.  
  10202. old_it_mfp15:    Ds.l    1    ; Adresse de l'ancienne interruption MFP 15
  10203. old_replay_frequency:    Ds.w    1    ; Ancienne fréquence de replay (contenu du MOT $ffff8934)
  10204. old_matrix_cnx:    Ds.l    1    ; Ancienne connection de la matrice
  10205. keycode_result:    Ds.l    1    ; \
  10206.         Ds.w    1    ;  > *** Ne pas dissocier
  10207.         Ds.w    1    ; /
  10208. fft_poslsl:    Ds.l    1    ; Position.l fractionnaire *4096/2π
  10209. fft_incmsl:    Ds.w    1    ; Incrément.w poids fort *4096/2π
  10210. fft_inclsl:    Ds.l    1    ; Incrément.l fractionnaire *4096/2π
  10211. fft_remsl:        Ds.l    1    ; Energie, partie réelle
  10212. fft_relsl:        Ds.l    1    ; Energie, partie réelle fractionnaire
  10213. fft_immsl:        Ds.l    1    ; Energie, partie imaginaire
  10214. fft_imlsl:        Ds.l    1    ; Energie, partie imaginaire fractionnaire
  10215. progression_savedreg:    Ds.l    8+7    ; Espace de sauvegarde de d0-d7/a0-a6
  10216. progression_res_adr:    Ds.l    1    ; Adresse de reprise
  10217. progression_step:    Ds.l    1    ; Nombre d'opération entre chaque indication de progression
  10218. progression_cpt:    Ds.l    1    ; Compteur d'opérations (decrémenté). 0 = arrêt et affichage de progression
  10219. oldcolcurs:    ds.w    1    ; Ancienne colonne d'affichage du curseur
  10220. oldposcurs:    ds.w    1    ; Ancienne position d'affichage du curseur dans la colonne
  10221. patpreset5:    ds.w    32    ; Mémorisation du préset d'aff de pat, * 5
  10222. cv_s3m2gtk_slides:    ds.w    32    ; Mémorisation de l'état des slides de vol pour chaque voie
  10223. cv_s3m2gtk_porta:    ds.b    32    ; Mémorisation de l'état des portamentos chaque voie
  10224. fonte8x6_ombr:    ds.b    6*256
  10225. ; Espace pour les decrunchers (le même pour tous)
  10226. ice2_21:        ; ds.w    60    ; free space (can be put in BSS)
  10227. speedpacker_adr:    ; ds.l    1    ; Mémorise l'adresse de décompactage
  10228. atm35_eb:        ds.w    142    ; Espace pour Atomik Packer 3.5
  10229. record_inf:    ds.b    rec_next    ; Infos pour la digit d'un son
  10230.         EVEN
  10231. ; Buffer pour la digitalisation d'un son
  10232. sample_rec_buffer:    ds.b    1024*2*2
  10233. sample_rec_buffer2:    ds.b    1024*2*2
  10234.  
  10235.  
  10236.  
  10237. *≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈*
  10238.