home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / SOUND / CRYS270.ZIP / CRYS.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-06-26  |  30.6 KB  |  1,741 lines

  1. ;**************************************************************************
  2. ;*    Player de mod, cela fait office d'exemple d'utilisation en
  3. ;*    assembleur d'utilisation des routines et vous permet de juger de
  4. ;*    la qualité (ou des défauts) des routines de CRYSTAL...
  5. ;*
  6. ;* Programmé par Sébastien Granjoux
  7. ;* Commencé en février 93
  8. ;* Dernière modif 10/04/95
  9.  
  10. IDEAL
  11.  
  12. P386N
  13. MODEL    SMALL
  14.  
  15. PUBLIC    main
  16.  
  17. VERNB    EQU    "2.70"
  18. DATE    EQU    "12/05/95"
  19.  
  20. EXTRN    SetMode3:near
  21. EXTRN    ResetMode:near
  22. EXTRN    SetPage:near
  23. EXTRN    PutCpkBlk:near
  24. EXTRN    PutText:near
  25. EXTRN    PutVu:near
  26.  
  27. EXTRN    GetMixRate:near
  28. EXTRN    GetVoiceByte:near
  29. EXTRN    GetName:near
  30. EXTRN    GetTempo:near
  31. EXTRN    GetModInf:near
  32. EXTRN    GetPattern:near
  33. EXTRN    GetVoice:near
  34.  
  35. EXTRN    USESPK:far
  36. EXTRN    USEGUS:far
  37. EXTRN    USESP:far
  38. EXTRN    USESB:far
  39. EXTRN    USEDAC:far
  40. EXTRN    USEADL:far
  41. EXTRN    CHANGEVOL:far
  42. EXTRN    DETECTSND:far
  43. EXTRN    FLOADMOD:far
  44. EXTRN    UNLOADMOD:far
  45. EXTRN    SETMOD:far
  46. EXTRN    MAKEMOD:far
  47. EXTRN    STARTMOD:far
  48. EXTRN    STOPMOD:far
  49. EXTRN    TOGGLEVOC:far
  50. EXTRN    LOCKMOD:far
  51. EXTRN    SETMODPOS:far
  52. EXTRN    GETMODPOS:far
  53.  
  54. INCLUDE "CRYSERR.INC"
  55. INCLUDE "CRYSID.INC"
  56.  
  57. DEV_NAME_LEN    EQU    32
  58. NB_SAMPLE    EQU    31
  59.  
  60. DATASEG
  61.  
  62. PROGRAM_MSG    DB 'Crystal Player V',VERNB,' Par Sébastien Granjoux',09h,09h,09h,09h,DATE,0dh,0ah
  63.         DB 'Ce programme permet de jouer des fichiers MOD.',0ah,0dh
  64.         DB 'Il s''utilise de la manière suivante :',0dh,0ah,0dh,0ah
  65.         DB 09h,'CRYS [/SK|/AD|/DCl|/SBp,i|/GSp] [/FRf] nom du fichier mod',0dh,0ah
  66.         DB 0ah,0dh
  67.         DB 09h,'  /SK permet d''utiliser le speaker',0dh,0ah
  68.         DB 09h,'  /AD permet d''utiliser une carte adlib',0dh,0ah
  69.         DB 09h,'  /DCl permet d''utiliser un DAC sur le port parallèle l(1-4)',0dh,0ah
  70.         DB 09h,'  /SBp,i,d permet d''utiliser une soundblaster (8 bits mono) sur le port',0dh,0ah
  71.         DB 09h,'           p avec l''irq i et le canal DMA d',0dh,0ah
  72.         DB 09h,'  /SPp,i,d permet d''utiliser une soundblaster pro (8 bits stereo) sur',0dh,0ah
  73.         DB 09h,'           le port p avec l''irq i et le canal DMA d',0dh,0ah
  74.         DB 09h,'  /GSp permet d''utiliser une GUS sur le port p',0dh,0ah
  75.         DB 09h,'  /FRf permet de donner la fréquence de mixage en disaine de Hz',0dh,0ah
  76.         DB 0dh,0ah,'Par défaut le player recherche dans les variables d''environnement la carte',0dh,0ah
  77.         DB 'sonore à utiliser ou les paramètres manquant et joue vers 20Khz.',0dh,0ah
  78.         DB 0dh,0ah
  79.         DB '$'
  80.  
  81. MAIN_SCR:
  82.     DB      27,2,'Crystal Player Version ',VERNB,' Programmé par '
  83.     DB    'Sébastien Granjoux',11,8,'le ',DATE,10
  84. MUSIC_INF:
  85.     DB    01,23,' Musique: ',27,69 DUP (' '),10
  86. DEVICE_INF:
  87.     DB    23,' Sur: ',27,DEV_NAME_LEN DUP (' '),23,'A ',27,'00000 Hz'
  88.     DB    23,'  Temps: ',27,'00:00',10
  89. MODULE_INF:
  90.     DB    23,' Sequence: ',27,'000/000',23,'  Pattern: ',27,'000'
  91.     DB    23,'  Ligne: ',27,'00',23,'  Tempo: ',27,'00/000'
  92.     DB    23,'  Volume: ',27,'000',10
  93. EXTRA_INF:
  94.     DB    23,' Mémoire utilisé: ',27,'000 Ko'
  95.     DB    23,'  CPU utilisé: ',27,'00 %',10
  96. VUMETER_SCR:
  97.     DB    25,'┌',12,4,'─┬',12,24,'─┬',12,4,'─┬'
  98.     DB    12,5,'─┬',12,18,'─┬',12,18,'─┐',10
  99.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  100.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  101.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  102.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  103.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  104.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  105.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  106.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  107.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  108.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  109.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  110.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  111.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  112.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  113.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  114.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  115.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  116.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  117.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  118.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  119.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  120.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  121.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  122.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  123.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  124.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  125.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  126.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  127.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  128.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  129.     DB    25,'│',30,11,4,25,'│',31,11,24,25,'│ ',19,'00',25,' │'
  130.     DB    26,11,5,25,'│',21,11,18,25,'│ ',16,12,16,'■',25,' │',10
  131.     DB      25,'└',12,4,'─┴',12,24,'─┴',12,4,'─┴'
  132.     DB    12,5,'─┴',12,18,'─┴',12,18,'─┘',10,10
  133.     DB    2,'  ',26,'F1 ',27,'Aide  ',26,'F2 ',27,'Vu-metres  '
  134.     DB    26,'F3 ',27,'Instruments  ',11,26
  135.     DB    26,'Esc ',27,'Quitter',11,2
  136.     DB    0
  137.  
  138. SAMPLE_SCR:
  139.     DB    25,'┌',12,78,'─┐',10
  140. FIRST_SAMPLE:
  141.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  142.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  143.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  144.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  145.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  146.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  147.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  148.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  149.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  150.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  151.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  152.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  153.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  154.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  155.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  156.     DB    25,'│',11,6,27,32 DUP (' '),11,2,32 DUP (' '),25,11,6,'│',10
  157.     DB      25,'└',12,78,'─┘',10,0
  158.  
  159. HELP_SCR:
  160.     DB    25,'┌',12,78,'─┐',10
  161.     DB    25,'│',27,11,29,'Touches utilisables',11,30,25,'│',10
  162.     DB    25,'│',27,11,28,12,21,'─',11,29,25,'│',10
  163.     DB    25,'│',27,11,34,12,9,'─',11,35,25,'│',10
  164.     DB    25,'│',27,11,78,25,'│',10
  165.     DB    25,'│',27,11,78,25,'│',10
  166.     DB    25,'│',27,'Pause       : Pause                    ',11,39,25,'│',10
  167.     DB    25,'│',27,'Arret Defil : Arret sur un pattern     ',11,39,25,'│',10
  168.     DB    25,'│',27,'1 .. 0      : Voix on/off              ',11,39,25,'│',10
  169.     DB    25,'│',27,'Fin         : Passer au pattern suivant',11,39,25,'│',10
  170.     DB    25,'│',27,'+/-         : Changer le volume global ',11,39,25,'│',10
  171.     DB    25,'│',27,'Curseur     : Changer de position      ',11,39,25,'│',10
  172.     DB    25,'│',27,11,78,25,'│',10
  173.     DB    25,'│',27,11,78,25,'│',10
  174.     DB    25,'│',27,11,78,25,'│',10
  175.     DB    25,'│',27,11,78,25,'│',10
  176.     DB    25,'│',27,11,78,25,'│',10
  177.     DB      25,'└',12,78,'─┘',10,0
  178.  
  179. LIST_EFFET    DB 'ARPEGGIO        '
  180.         DB 'PORTAMENTO UP   '
  181.         DB 'PORTAMENTO DOWN '
  182.         DB 'TONE PORTAMENTO '
  183.         DB 'VIBRATO         '
  184.         DB 'PORTAMENTO+SLIDE'
  185.         DB 'VIBRATO+SLIDE   '
  186.         DB 'TREMOLO         '
  187.         DB 'PHASOR EFFECT   '
  188.         DB 'PLAY SAMPLE PART'
  189.         DB 'VOLUME SLIDE    '
  190.         DB 'POSITION JUMP   '
  191.         DB 'SET VOLUME      '
  192.         DB 'PATTERN BREAK   '
  193.         DB '                '
  194.         DB 'SET SPEED       '
  195.         DB 'SET BPM         '
  196.         DB 'TREMOR          '
  197.         DB '                '
  198.         DB '                '
  199.         DB '                '
  200.         DB '                '
  201.         DB '                '
  202.         DB '                '
  203.         DB '                '
  204.         DB '                '
  205.         DB '                '
  206.         DB '                '
  207.         DB '                '
  208.         DB '                '
  209.         DB '                '
  210.         DB '                '
  211.         DB 'SET FILTER      '
  212.         DB 'FINE PORT UP    '
  213.         DB 'FINE PORT DOWN  '
  214.         DB 'SET GLISSANDO   '
  215.         DB 'SET VIBRATO     '
  216.         DB 'SET FINETUNE    '
  217.         DB 'LOOP            '
  218.         DB 'SET TREMOLO     '
  219.         DB 'STOP            '
  220.         DB 'RETTRIG SAMPLE  '
  221.         DB 'FINE SLIDE UP   '
  222.         DB 'FINE SLIDE DOWN '
  223.         DB 'NOTE CUT        '
  224.         DB 'NOTE DELAY      '
  225.         DB 'PATTERN DELAY   '
  226.         DB '                '
  227.  
  228. LIST_NOTE    DB 'C-0','C#0','D-0','D#0','E-0','F-0'
  229.         DB 'F#0','G-0','G#0','A-0','A#0','B-0'
  230.         DB '   '
  231.  
  232. FIRST_ERROR    EQU    1
  233. LAST_ERROR    EQU    22
  234.  
  235. UNKNOW_ERROR    DB    'Erreur inconnu$'
  236. ERROR1        DB    'Fonction inconnu$'
  237. ERROR2        DB    'Fichier introuvable$'
  238. ERROR3        DB    'Chemin introuvable$'
  239. ERROR4        DB    'Trop de fichier ouvert$'
  240. ERROR5        DB    'Accès refusé$'
  241. ERROR6        DB    'Handle inconnu$'
  242. ERROR7        DB    'Bloc de contrôle mémoire détruit$'
  243. ERROR8        DB    'Mémoire insuffisante$'
  244. ERROR9        DB    'Adresse mémoire incorrect$'
  245. ERROR10        DB    'Environnement incorrect$'
  246. ERROR11        DB    'Trop de pattern$'
  247. ERROR12        DB    'Sample trop grand$'
  248. ERROR13        DB    'Port parallèle introuvable$'
  249. ERROR14        DB    'Sound blaster introuvable$'
  250. ERROR15        DB    'GUS introuvable$'
  251. ERROR16        DB    'Pas assez de mémoire sur la GUS$'
  252. ERROR17        DB    'Drivers introuvable$'
  253. ERROR18        DB    'Voix inconnu$'
  254. ERROR19        DB    'Carte son introuvable$'
  255. ERROR20        DB    'Carte Adlib introuvable$'
  256. ERROR21        DB    'Trop de drivers chargé$'
  257.  
  258. MSG_ERROR    DW    OFFSET ERROR1
  259.         DW    OFFSET ERROR2
  260.         DW    OFFSET ERROR3
  261.         DW    OFFSET ERROR4
  262.         DW    OFFSET ERROR5
  263.         DW    OFFSET ERROR6
  264.         DW    OFFSET ERROR7
  265.         DW    OFFSET ERROR8
  266.         DW    OFFSET ERROR9
  267.         DW    OFFSET ERROR10
  268.         DW    OFFSET ERROR11
  269.         DW    OFFSET ERROR12
  270.         DW    OFFSET ERROR13
  271.         DW    OFFSET ERROR14
  272.         DW    OFFSET ERROR15
  273.         DW    OFFSET ERROR16
  274.         DW    OFFSET ERROR17
  275.         DW    OFFSET ERROR18
  276.         DW    OFFSET ERROR19
  277.         DW    OFFSET ERROR20
  278.         DW    OFFSET ERROR21
  279.         DW    OFFSET PROGRAM_MSG
  280.  
  281. Old_int9    DD 0
  282.  
  283. Device        DW THE_BEST
  284. Port        DW 0
  285. Irq        DB 0
  286. Dma        DB 0
  287. MixSpeed    DW 0
  288. MasterVol    DB 63
  289. ModVoice    DB 0
  290. StartTime    DD 0
  291. StartMem    DW 0
  292. VBLChrono    DD 1
  293. PlayChrono    DD 1
  294. LastChrono    DB 0
  295. Mode        DB 2
  296. VuMeters    DB 32 DUP (0)
  297. CutVoices    DW 0
  298. SeqLength    DB 0
  299.  
  300. BIOS_SEG    EQU    40h
  301. BIOS_CHRONO    EQU    6Ch
  302.  
  303. USINGMSG    DB    'Utilise $'
  304. DEVICEMSG    DW    OFFSET NOS_DEV,0
  305.         DW    OFFSET SPK_DEV,0
  306.         DW    OFFSET DAC_DEV,1
  307.         DW    OFFSET SB_DEV,4
  308.         DW    OFFSET GUS_DEV,2
  309.         DW    OFFSET SP_DEV,4
  310.         DW    OFFSET ADL_DEV,0
  311.  
  312. NOS_DEV        DB    'rien$'
  313. SPK_DEV        DB    'le haut parleur interne$'
  314. DAC_DEV        DB    'un DAC$'
  315. SB_DEV        DB    'une SoundBlaster$'
  316. GUS_DEV        DB    'une Gravis Ultra Sound$'
  317. SP_DEV        DB    'une SoundBlaster Pro$'
  318. ADL_DEV        DB    'une carte adlib $'
  319.  
  320. ADRMSG        DB    ' à l''adresse $'
  321. PORTMSG        DB    ' sur le port parallèle $'
  322. IRQMSG        DB    ' avec l''IRQ $'
  323. DMAMSG        DB    ' et le DMA 1$'
  324. NEWLINE        DB    0ah,0dh,'$'
  325. GUSMSG        DB    'Chargement des samples ...',0ah,0dh,'$'
  326.  
  327. DevFrq        DW    0,1900,2200,2200,0,2200,1700
  328.  
  329. Buffer:
  330. Filename    DB 128+4 DUP (0)
  331.  
  332. ExecBlk        DW    0
  333.         DW    OFFSET CmdLine
  334.         DW    SEG CmdLine
  335.         DD    -1
  336.         DD    -1
  337.  
  338. CmdLine        DB    00,0Dh
  339. OldStack    DD    0
  340. ComSpecMsg    DB    'COMSPEC',0
  341. DefaultCom    DB    'C:\COMMAND.COM',0
  342.  
  343. CODESEG
  344.  
  345. PROC    main
  346.  
  347.     mov    ax,es        ; Recupérer la place déjà prise par le player
  348.     dec    ax
  349.     mov    es,ax
  350.     mov    cx,[es:3]
  351.     inc    ax
  352.     mov    es,ax
  353.     mov    ah,48h        ; Récupérer la mémoire libre
  354.     mov    bx,0FFFFh
  355.     int    21h
  356.     add    bx,dx
  357.     mov    [StartMem],bx
  358.  
  359.     push    es
  360.     push    ds
  361.  
  362.     call    Usegus
  363.     call    Usesp
  364.     call    Usesb
  365.     call    Usedac
  366.     call    Usespk
  367.     call    Useadl
  368.  
  369.     pop    es
  370.     pop    ds
  371.     mov    si,80h
  372.     mov    di,OFFSET Filename
  373.     call    getarg
  374.     push    es
  375.     pop    ds
  376.     cmp    al,1
  377.     jae    @@mod_file_ok
  378.     mov    ax,BAD_ARG
  379.     jmp    error
  380. @@mod_file_ok:
  381.  
  382.     mov    si,OFFSET Filename
  383.     mov    di,si
  384.     mov    bx,OFFSET Irq
  385. @@get_arg:
  386.     lodsb
  387.     cmp    al,'-'
  388.     je    @@get_switch
  389.     cmp    al,','
  390.     je    @@get_sup
  391.     or    al,al
  392.     je    @@line_used
  393.  
  394. @@get_file:
  395.     stosb
  396.     lodsb
  397.     or    al,al
  398.     jne    @@get_file
  399.     jmp    @@get_arg
  400.  
  401. @@get_sup:
  402.     mov    ax,BAD_ARG
  403.     cmp    bx,OFFSET Dma
  404.     ja    error
  405.     call    get_dec
  406.     jc    @@no_sup
  407.     mov    [bx],al
  408. @@no_sup:
  409.     inc    si
  410.     inc    bx
  411.     jmp    @@get_arg
  412.  
  413. @@get_switch:
  414.     mov    bx,OFFSET Irq
  415.     lodsw
  416.     cmp    ax,'RF'
  417.     je    @@get_freq
  418.     cmp    ax,'BS'
  419.     je    @@get_sb
  420.     cmp    ax,'KS'
  421.     je    @@get_spk
  422.     cmp    ax,'CD'
  423.     je    @@get_dac
  424.     cmp    ax,'SG'
  425.     je    @@get_gus
  426.     cmp    ax,'PS'
  427.     je    @@get_sp
  428.     cmp    ax,'DA'
  429.     je    @@get_adlib
  430.     cmp    ax,'LN'
  431.     je    @@get_null
  432.     mov    ax,BAD_ARG
  433.     jmp    error
  434. @@get_freq:
  435.     call    get_dec
  436.     inc    si
  437.     mov    [MixSpeed],ax
  438.     jmp    @@get_arg
  439. @@get_spk:
  440.     mov    [Device],PC_SPEAKER
  441.     lodsb
  442.     or    al,al
  443.     je    @@get_arg
  444.     mov    ax,BAD_ARG
  445.     jmp    error
  446. @@get_dac:
  447.     mov    [Device],DAC_ON_LPT
  448.     jmp    @@get_device
  449. @@get_sb:
  450.     mov    [Device],SOUNDBLASTER
  451.     jmp    @@get_device
  452. @@get_sp:
  453.     mov    [Device],SOUNDPRO
  454.     jmp    @@get_device
  455. @@get_gus:
  456.     mov    [Device],GUS
  457.     jmp    @@get_device
  458. @@get_null:
  459.     mov    [Device],NO_DEVICE
  460.     jmp    @@get_device
  461. @@get_adlib:
  462.     mov    [Device],ADLIB
  463. @@get_device:
  464.     call    get_hex
  465.     inc    si
  466.     jc    @@get_arg
  467.     mov    [Port],ax
  468.     jmp    @@get_arg
  469.  
  470. @@line_used:
  471.     xor    al,al
  472.     stosb
  473.  
  474.     push    ds
  475.     push    OFFSET Device
  476.     push    ds
  477.     push    OFFSET Port
  478.     push    ds
  479.     push    OFFSET Irq
  480.     push    ds
  481.     push    OFFSET Dma
  482.     call    Detectsnd
  483.     jnc    @@ok
  484.     cmp    ax,DRV_NOT_FOUND
  485.     je    error
  486. @@ok:
  487.  
  488.     mov    di,OFFSET Filename
  489.     xor    al,al
  490.     repne    scasb
  491.     dec    di
  492.     mov    eax,[es:di-4]
  493.     and    eax,0DFDFDFFFh
  494.     cmp    eax,'DOM.'
  495.     je    @@loadmod
  496.     sub    di,4
  497.     mov    cx,4
  498.     mov    al,'.'
  499.     repne    scasb
  500.     je    @@loadmod
  501.     mov    [byte ptr es:di],al
  502.     mov    [dword ptr es:di+1],'DOM'
  503.  
  504. @@loadmod:
  505.     push    ds
  506.     push    OFFSET Filename
  507.     call    far Floadmod
  508.     jc    error
  509.  
  510. @@loadok:
  511.  
  512.     call    putcard        ; Affiche la carte utilisé
  513.  
  514.     call    PutMusInf
  515.  
  516.     cmp    [MixSpeed],0
  517.     jne    @@keep_freq
  518.     mov    bx,[Device]
  519.     add    bx,bx
  520.     mov    ax,[OFFSET DevFrq+bx]
  521.     mov    [MixSpeed],ax
  522. @@keep_freq:
  523.     push    [MixSpeed]
  524.     push    [word ptr ds:OFFSET Device]
  525.     push    [word ptr ds:OFFSET Port]
  526.     push    [word ptr ds:OFFSET Irq]
  527.     push    [word ptr ds:OFFSET Dma]
  528.  
  529.     call    far Setmod
  530.     jc    error
  531.  
  532.     call    PutDevInf
  533.  
  534.     call    setmode3
  535.  
  536.     mov    si,OFFSET MAIN_SCR
  537.     xor    dx,dx
  538.     call    PutCpkBlk
  539.  
  540.     push    es        ; Sauvegarde l'interruption clavier
  541.     mov    ax,3509h
  542.     int    21h
  543.     mov    [word ptr ds:OFFSET Old_int9],bx
  544.     mov    [word ptr ds:OFFSET Old_int9+2],es
  545.     pop    es
  546.     push    ds        ; Utilise une interruption clavier simplifiée
  547.     mov    ax,cs
  548.     mov    ds,ax
  549.     cli
  550.     mov    dx,OFFSET hitkey
  551.     mov    ax,2509h
  552.     int    21h
  553.     sti
  554.     pop    ds
  555.  
  556.     call    far MakeMod
  557.     call    far MakeMod
  558.  
  559.     mov    bx,16
  560.     call    waitVBL
  561. test_loop:
  562.     push    bx
  563.  
  564.     call    PutModInf
  565.  
  566.     cmp    [Mode],2
  567.     jmp    $+2
  568.  
  569.     mov    al,[cs:Key]
  570.     or    al,al
  571.     je    @@loop_end
  572.     cmp    al,1
  573.     je    @@loop_end
  574.     cmp    al,17
  575.     jbe    @@loop_end
  576.     cmp    al,61
  577.     je    @@loop_end
  578.     cmp    al,60
  579.     je    @@loop_end
  580.     cmp    al,59
  581.     je    @@loop_end
  582.     cmp    al,69
  583.     je    @@loop_end
  584.     cmp    al,79
  585.     je    @@loop_end
  586.     cmp    al,70
  587.     je    @@loop_end
  588.     cmp    al,78
  589.     je    @@loop_end
  590.     cmp    al,74
  591.     je    @@loop_end
  592.     jmp    @@loop_end
  593. @@loop_end:
  594.     xor    ecx,ecx
  595.     call    waitVBL
  596.     add    [VBLChrono],ecx
  597.     pop    bx
  598.     dec    bx
  599.     jne    test_loop
  600.  
  601.  
  602.     call    far StartMod
  603.     call    GetTime
  604.     mov    [ds:StartTime],eax
  605.  
  606.     call    WaitVBL
  607. main_loop:
  608.     push    bx
  609.  
  610.     call    far MakeMod
  611.     call    far MakeMod
  612.  
  613.     call    PutModInf
  614.  
  615.     cmp    [Mode],2
  616.     jne    @@no_refresh
  617.     call    PutVuMeter
  618. @@no_refresh:
  619.  
  620.     mov    al,[cs:Key]
  621.     or    al,al
  622.     je    @@end_main
  623.     cmp    al,1
  624.     je    @@exit
  625.     cmp    al,17
  626.     jbe    @@mute
  627.     cmp    al,61
  628.     je    @@sample
  629.     cmp    al,60
  630.     je    @@vumeter
  631.     cmp    al,59
  632.     je    @@help
  633.     cmp    al,69
  634.     je    @@pause
  635.     cmp    al,63
  636.     je    @@dosshell
  637.     cmp    al,79
  638.     je    @@end_pat
  639.     cmp    al,70
  640.     je    @@lock_pat
  641.     cmp    al,78
  642.     je    @@plus
  643.     cmp    al,74
  644.     je    @@minus
  645.     cmp    al,75
  646.     je    @@backward
  647.     cmp    al,77
  648.     je    @@forward
  649.  
  650. @@end_main:
  651.     test    [cs:Mode],80h
  652.     jnz    @@no_chrono
  653.     xor    ecx,ecx
  654.     call    waitVBL
  655.     mov    eax,[PlayChrono]
  656.     shr    eax,4
  657.     sub    eax,ecx
  658.     sub    [PlayChrono],eax
  659.  
  660. @@no_chrono:
  661.     pop    bx
  662.     jmp    main_loop
  663.  
  664. @@help:
  665.     mov    [cs:Key],0
  666.     and    [Mode],0F0h
  667.     or    [Mode],1
  668.     mov    si,OFFSET HELP_SCR
  669.     mov    dx,0500h
  670.     call    PutCpkBlk
  671.     jmp    @@end_main
  672.  
  673. @@sample:
  674.     mov    [cs:Key],0
  675.     and    [Mode],0F0h
  676.     or    [Mode],3
  677.     mov    si,OFFSET SAMPLE_SCR
  678.     mov    dx,0500h
  679.     call    PutCpkBlk
  680.     jmp    @@end_main
  681.  
  682. @@vumeter:
  683.     mov    [cs:Key],0
  684.     and    [Mode],0F0h
  685.     or    [Mode],2
  686.     mov    si,OFFSET VUMETER_SCR
  687.     mov    dx,0500h
  688.     call    PutCpkBlk
  689.     call    PutVuMeter
  690.     jmp    @@end_main
  691.  
  692. @@pause:
  693.     mov    [cs:Key],0
  694.     xor    [Mode],80h
  695.     test    [Mode],80h
  696.     jz    @@unpause
  697.     call    far StopMod
  698.     jmp    @@end_main
  699. @@unpause:
  700.     call    far StartMod
  701.     jmp    @@end_main
  702.  
  703. @@mute:
  704.     mov    [cs:Key],0
  705.     sub    al,2
  706.     push    ax
  707.     mov    cl,al
  708.     mov    ax,1
  709.     shl    ax,cl
  710.     xor    [ds:CutVoices],ax
  711.     call    TOGGLEVOC
  712.     jmp     @@end_main
  713.  
  714. @@lock_pat:
  715.     mov    [cs:Key],0
  716.     call     LOCKMOD
  717.     jmp    @@end_main
  718.  
  719. @@end_pat:
  720.     mov    [cs:Key],0
  721.     call    GETMODPOS
  722.     and    ax,0FFC0h
  723.     add    ax,64
  724.     movzx    bx,[ds:SeqLength]
  725.     shl    bx,6
  726.     cmp    ax,bx
  727.     je    @@end_main
  728.     push    ax
  729.     call    SETMODPOS
  730.     jmp    @@end_main
  731.  
  732. @@plus:
  733.     mov    [cs:Key],0
  734.     cmp    [ds:MasterVol],63
  735.     je    @@end_main
  736.     inc    [ds:MasterVol]
  737.     push    [word ptr ds:MasterVol]
  738.     call    CHANGEVOL
  739.     jmp    @@end_main
  740.  
  741. @@minus:
  742.     mov    [cs:Key],0
  743.     cmp    [ds:MasterVol],0
  744.     je    @@end_main
  745.     dec    [ds:MasterVol]
  746.     push    [word ptr ds:MasterVol]
  747.     call    CHANGEVOL
  748.     jmp    @@end_main
  749.  
  750. @@forward:
  751.     mov    [cs:Key],0
  752.     call    GETMODPOS
  753.     inc    ax
  754.     movzx    bx,[ds:SeqLength]
  755.     shl    bx,6
  756.     cmp    ax,bx
  757.     je    @@end_main
  758.     push    ax
  759.     call    SETMODPOS
  760.     jmp    @@end_main
  761.  
  762. @@backward:
  763.     mov    [cs:Key],0
  764.     call    GETMODPOS
  765.     or    ax,ax
  766.     je    @@end_main
  767.     dec    ax
  768.     push    ax
  769.     call    SETMODPOS
  770.     jmp    @@end_main
  771.  
  772. @@dosshell:
  773.     push    es
  774.     mov    ah,62h
  775.     int    21h
  776.     mov    es,bx
  777.     mov    es,[es:2Ch]
  778.     mov    si,OFFSET ComSpecMsg
  779.     xor    di,di
  780.     mov    cx,0ffffh
  781. @@search_comspec:
  782.     rep    cmpsb
  783.     cmp    [byte ptr ds:si-1],0
  784.     jne    @@next_string
  785.     cmp    [byte ptr es:di-1],'='
  786.     je    @@find_comspec
  787. @@next_string:
  788.     mov    si,OFFSET ComSpecMsg
  789.     xor    al,al
  790.     repne    scasb
  791.     cmp    [byte ptr es:di],0
  792.     jne    @@search_comspec
  793.  
  794.     push    ds
  795.     pop    es
  796.     mov     di,OFFSET DefaultCom
  797.  
  798. @@find_comspec:
  799.     push    ds
  800.     mov    [word ptr cs:OFFSET OldStack+2],ss
  801.     mov    [word ptr cs:OFFSET OldStack],sp
  802.  
  803.     push    ds        ; Reprend l'ancienne interruption clavier
  804.     cli
  805.     mov    ax,2509h
  806.     lds    dx,[dword ptr ds:OFFSET Old_int9]
  807.     int    21h
  808.     sti
  809.     pop    ds
  810.  
  811.     call    resetmode
  812.  
  813.     push    es
  814.     push    ds
  815.     pop    es
  816.     pop    ds
  817.     mov    ax,4B00h
  818.     mov    bx,OFFSET ExecBlk
  819.     mov    dx,di
  820.     int    21h
  821.  
  822.     lss    sp,[cs:OFFSET OldStack]
  823.     pop    ds
  824.     pop    es
  825.  
  826.     call    putcard        ; Affiche la carte utilisé
  827.  
  828.     call    setmode3
  829.  
  830.     mov    si,OFFSET MAIN_SCR
  831.     xor    dx,dx
  832.     call    PutCpkBlk
  833.  
  834.     push    ds
  835.     push    cs
  836.     pop    ds
  837.     mov    dx,OFFSET hitkey
  838.     mov    ax,2509h
  839.     cli
  840.     int    21h
  841.     sti
  842.     pop    ds
  843.     mov    [cs:Key],0
  844.     and    [Mode],0F0h
  845.     or    [Mode],2
  846.  
  847.     jmp    @@no_chrono
  848.  
  849. @@exit:
  850.  
  851.     call    far Stopmod
  852.  
  853.     push    ds        ; Reprend l'ancienne interruption clavier
  854.     cli
  855.     mov    ax,2509h
  856.     lds    dx,[dword ptr ds:OFFSET Old_int9]
  857.     int    21h
  858.     sti
  859.     pop    ds
  860.  
  861.     call    resetmode
  862.  
  863.     call    Unloadmod
  864.  
  865.     mov    ax,4c00h
  866.     int    21h
  867.  
  868. error:
  869.     cmp    ax,256
  870.     jbe    @@dos_error
  871.     sub    ax,246
  872. @@dos_error:
  873.     mov    bx,_DATA
  874.     mov    ds,bx
  875.     sub    ax,FIRST_ERROR
  876.     jb    @@unknow
  877.     cmp    ax,LAST_ERROR
  878.     ja    @@unknow
  879.     mov    bx,ax
  880.     shl    bx,1
  881.     mov     dx,[ds:bx+MSG_ERROR]
  882.     mov    ah,09h
  883.     int    21h
  884.     mov    ax,bx
  885.     shl    bx,1
  886.     mov    ah,4ch
  887.     int    21h
  888.  
  889. @@unknow:
  890.     mov    dx,OFFSET UNKNOW_ERROR
  891.     mov    ah,09h
  892.     int    21h
  893.     mov    ax,4cffh
  894.     int    21h
  895.  
  896. ENDP
  897.  
  898. ;***************************************************************************
  899. ;*    Convertit un nombre sous forme de chaine de caractère en ds:si
  900. ;*    en binaire dans ax,ds:si pointant sur la fin du nombre
  901. ;*
  902. ;* Entrée:
  903. ;*    DS:SI    représentation décimal du nombre
  904. ;* Sortie:
  905. ;*    AX    nombre
  906. ;*    C=1    si la chaine n'est pas un nombre
  907.  
  908. PROC    get_dec
  909.  
  910.     xor    ax,ax
  911.     xor    dh,dh
  912.     mov    dl,[ds:si]
  913.     sub    dl,'0'
  914.     jl    @@error
  915.     cmp    dl,9
  916.     ja    @@error
  917.  
  918. @@next_digit:
  919.     inc    si
  920.  
  921.     lea    ax,[eax*4+eax]
  922.     shl    ax,1
  923.     add     ax,dx
  924.  
  925.     mov    dl,[ds:si]
  926.     sub    dl,'0'
  927.     jl    @@no_digit
  928.     cmp    dl,9
  929.     jbe    @@next_digit
  930.  
  931. @@no_digit:
  932.     clc
  933.     ret
  934. @@error:
  935.     stc
  936.     ret
  937. ENDP
  938.  
  939. ;***************************************************************************
  940. ;*    Convertit un nombre sous forme de chaine de caractère en ds:si
  941. ;*    en binaire dans ax,ds:si pointant sur la fin du nombre
  942. ;*
  943. ;* Entrée:
  944. ;*    DS:SI    représentation hexadécimal du nombre
  945. ;* Sortie:
  946. ;*    AX    nombre
  947. ;*    C=1    si la chaine n'est pas un nombre
  948.  
  949. PROC    get_hex
  950.  
  951.     xor    ax,ax
  952.     xor    dh,dh
  953.     mov    dl,[ds:si]
  954.     sub    dl,'0'
  955.     jl    @@error
  956.     cmp    dl,9
  957.     jbe    @@next_digit
  958.         and    dl,1fh
  959.     xor    dl,18h
  960.     inc    dl
  961.     cmp    dl,0fh
  962.         ja    @@error
  963. @@next_digit:
  964.     inc    si
  965.  
  966.     shl    ax,4
  967.     add     ax,dx
  968.  
  969.     mov    dl,[ds:si]
  970.     sub    dl,'0'
  971.     jl    @@no_digit
  972.     cmp    dl,9
  973.     jbe    @@next_digit
  974.     and    dl,1fh
  975.         xor    dl,18h
  976.     inc    dl
  977.     cmp    dl,0fh
  978.         jbe    @@next_digit
  979. @@no_digit:
  980.     clc
  981.     ret
  982. @@error:
  983.     stc
  984.     ret
  985. ENDP
  986.  
  987. ;***************************************************************************
  988. ;*    Convertie un nombre en DL en une chaine de caractère représentant
  989. ;*    ce nombre en décimal
  990. ;*
  991. ;* Entrée:
  992. ;*    DS:DI    adresse de la zone où mettre la chaine sur 3 octet
  993. ;*    AX    nombre à convertir
  994. ;*    CX    nombre de chiffre (1,10,100,1000,10000)
  995.  
  996. PROC    DecToStr
  997.  
  998.     xor    dx,dx
  999.     div    cx
  1000.     or    al,al
  1001.     jne    @@number
  1002.     sub    al,'0'-' '
  1003. @@number:
  1004.     add    al,'0'
  1005.     mov    [ds:di],al
  1006.     inc    di
  1007.     push    dx
  1008.     xor    dx,dx
  1009.     mov    ax,cx
  1010.     mov    cx,10
  1011.     div    cx
  1012.     or    ax,ax
  1013.     mov    cx,ax
  1014.     pop    ax
  1015.     je    @@exit
  1016.  
  1017. @@next:
  1018.     xor    dx,dx
  1019.     div    cx
  1020.     or    al,al
  1021.     add    al,'0'
  1022.     mov    [ds:di],al
  1023.     inc    di
  1024.     push    dx
  1025.     xor    dx,dx
  1026.     mov    ax,cx
  1027.     mov    cx,10
  1028.     div    cx
  1029.     or    ax,ax
  1030.     mov    cx,ax
  1031.     pop    ax
  1032.     jne    @@next
  1033.  
  1034. @@exit:
  1035.  
  1036.     ret
  1037.  
  1038. ENDP
  1039.  
  1040.  
  1041. Key    DB    0
  1042.  
  1043. ;***************************************************************************
  1044. ;*      interruption qui remplace l'interruption 09, elle est très simple
  1045. ;*    pour éviter que le programme reste trop longtemps avec les
  1046. ;*    interruption coupées.
  1047.  
  1048. PROC    hitkey FAR
  1049.  
  1050.     push    ax
  1051.  
  1052.     in      al,60h
  1053.     or      al,al
  1054.     js      @@relache
  1055.  
  1056.     mov     [cs:OFFSET Key],al
  1057.  
  1058.     mov     al,61h
  1059.     out     20h,al
  1060.  
  1061.     pop     ax
  1062.     iret
  1063.  
  1064. @@relache:
  1065.     mov     al,61h
  1066.     out     20h,al
  1067.  
  1068.     pop     ax
  1069.     iret
  1070.  
  1071. ENDP
  1072.  
  1073.  
  1074. SCREEN_POS    DW 640
  1075.  
  1076. ;***************************************************************************
  1077. ;*    Ecrit un nombre en EAX sur 32 bits en chaine de caractère
  1078. ;*    correspondant à se représentation hexadécimal
  1079. ;*
  1080. ;* Entrée:
  1081. ;*    EDX    nombre à convertir
  1082.  
  1083. PROC    writelong    FAR
  1084.  
  1085.     push    es
  1086.     mov    ax,0b800h
  1087.     mov    es,ax
  1088.     mov    di,[cs:SCREEN_POS]
  1089.     add    di,16
  1090.  
  1091.     mov    ax,'h'
  1092.     std
  1093.     stosb
  1094.  
  1095.     mov    cl,4
  1096. @@next_digit:
  1097.     movzx    ax,dl
  1098.     shr    edx,8
  1099.     shl    ax,4
  1100.     shr    al,4
  1101.     xchg    al,ah
  1102.     and    ax,0f0fh
  1103.     add    ax,3030h
  1104.     cmp    al,3Ah
  1105.     jb    @@al_ok
  1106.     add    al,7
  1107. @@al_ok:
  1108.     cmp    ah,3Ah
  1109.     jb    @@ah_ok
  1110.     add    ah,7
  1111. @@ah_ok:
  1112.     xchg    al,ah
  1113.     dec    di
  1114.     stosb
  1115.     dec    di
  1116.     mov    al,ah
  1117.     stosb
  1118.     dec    cl
  1119.     jne    @@next_digit
  1120.  
  1121.     cld
  1122.  
  1123.     add    di,19
  1124.     mov    al,' '
  1125.     stosb
  1126.     inc    di
  1127.  
  1128.     pop    es
  1129.  
  1130.     cmp    di,4000
  1131.     jb    @@ok
  1132.     mov    di,0
  1133. @@ok:
  1134.     mov    [cs:SCREEN_POS],di
  1135.  
  1136.     ret
  1137.  
  1138. ENDP
  1139.  
  1140.  
  1141.  
  1142. ;***************************************************************************
  1143. ;*    Cette routine sépare les arguments de la ligne de commande par un
  1144. ;*    zero,deplus les switchs sont mis en majuscule.Les switchs doivents
  1145. ;*    commencer par '-','/' ou '+' et le '/' est toujours transformé en '-'
  1146. ;*    deplus les virgules se retrouve toujours en début de mots.Enfin
  1147. ;*    si une chaine est mis entre '"' elle n'est pas modifié.
  1148. ;*
  1149. ;* Entrée:
  1150. ;*    DS:SI    adresse de la ligne de commande
  1151. ;*      ES:DI    adresse du buffer devant contenir la ligne modifié
  1152. ;* Sortie:
  1153. ;*    AL    nombre d'arguments sans les switchs
  1154.  
  1155. PROC    getarg
  1156.  
  1157.     lodsb
  1158.     mov    cl,al
  1159.     xor    ch,ch
  1160.  
  1161. @@search_letter:
  1162.     dec    cl
  1163.     jl    @@nothing_left
  1164.     lodsb
  1165.     cmp    al,' '
  1166.     je    @@search_letter
  1167.     cmp    al,09
  1168.     je    @@search_letter
  1169.     inc    ch
  1170.     cmp    al,'+'
  1171.     je    @@switch
  1172.     cmp    al,'-'
  1173.     je    @@switch
  1174.     cmp    al,'/'
  1175.     jne    @@letter
  1176.     mov    al,'-'
  1177. @@switch:
  1178.     stosb
  1179.     dec    ch
  1180.  
  1181. @@majuscule:
  1182.     dec    cl
  1183.     jl    @@nothing_left
  1184.     lodsb
  1185.     mov    ah,al
  1186.     and    ah,0dfh
  1187.     cmp    ah,'A'
  1188.     jb    @@search_white
  1189.     cmp    ah,'Z'
  1190.     ja    @@search_white
  1191.     mov    al,ah
  1192.     stosb
  1193.     jmp    @@majuscule
  1194.  
  1195. @@string:
  1196.     stosb
  1197.     dec    cl
  1198.     jl    @@nothing_left
  1199.     lodsb
  1200.     cmp    al,'"'
  1201.     jne    @@string
  1202.  
  1203. @@letter:
  1204.     stosb
  1205.     lodsb
  1206.     dec    cl
  1207.     jl    @@nothing_left
  1208.  
  1209. @@search_white:
  1210.     cmp    al,'"'
  1211.     je    @@string
  1212.     cmp    al,' '
  1213.     je    @@find_white
  1214.     cmp    al,09
  1215.     je    @@find_white
  1216.     cmp    al,','
  1217.     jne    @@letter
  1218.     mov    ah,al
  1219.     xor    al,al
  1220.     stosw
  1221.     cmp    [byte ptr ds:si],','
  1222.         jne    @@search_letter
  1223.     stosb
  1224.     jmp    @@search_letter
  1225.  
  1226. @@find_white:
  1227.     xor    al,al
  1228.     stosb
  1229.     jmp    @@search_letter
  1230.  
  1231. @@nothing_left:
  1232.     xor    ax,ax
  1233.     stosw
  1234.     mov    al,ch
  1235.  
  1236.     ret
  1237.  
  1238. ENDP
  1239.  
  1240. ;**************************************************************************
  1241. ;*    Affiche une ligne de texte donnant la carte sonore utilisé
  1242. ;*
  1243. ;* Attention:
  1244. ;*    Les variables Device,Port,Irq et DMA doivent être définis ainsi
  1245. ;*    que des messages
  1246.  
  1247. PROC    putcard
  1248.  
  1249.     mov    ah,09h
  1250.     mov    dx,OFFSET USINGMSG
  1251.     int    21h
  1252.  
  1253.     mov    bl,[byte ptr ds:OFFSET Device]
  1254.     xor    bh,bh
  1255.     shl    bx,2
  1256.     add    bx,OFFSET DEVICEMSG
  1257.     mov    dx,[ds:bx]
  1258.     mov    ah,09h
  1259.     int    21h
  1260.  
  1261.     mov    cl,[ds:bx+2]
  1262.     or    cl,cl
  1263.     je    @@thats_all
  1264.  
  1265.     mov    ah,09h
  1266.     mov    dx,OFFSET ADRMSG
  1267.     dec    cl
  1268.     jne     @@adr_msg
  1269.     mov    dx,OFFSET PORTMSG
  1270. @@adr_msg:
  1271.     int    21h
  1272.  
  1273.     mov    bx,[ds:Port]
  1274.     or    bh,bh
  1275.     je    @@no_first_digit
  1276.  
  1277.     mov    dl,bh
  1278.     add    dl,'0'
  1279.     mov    ah,02h
  1280.     int    21h
  1281.  
  1282.     mov    dl,bl
  1283.     shr    dl,4
  1284.     and    dl,0fh
  1285.     add    dl,'0'
  1286.     cmp    dl,'9'
  1287.     jbe    @@no_hexa
  1288.     add    dl,7
  1289. @@no_hexa:
  1290.     mov    ah,02h
  1291.     int    21h
  1292.  
  1293.     and    bl,0fh
  1294. @@no_first_digit:
  1295.     mov    dl,bl
  1296.     add    dl,'0'
  1297.     mov    ah,02h
  1298.     int    21h
  1299.  
  1300.     dec    cl
  1301.     jle    @@thats_all
  1302.  
  1303.     mov    ah,09h
  1304.     mov    dx,OFFSET IRQMSG
  1305.     int    21h
  1306.  
  1307.     mov    dl,[ds:Irq]
  1308.     add    dl,'0'
  1309.     mov    ah,02h
  1310.     int    21h
  1311.  
  1312.     dec    cl
  1313.     jle    @@thats_all
  1314.  
  1315.     mov    ah,09h
  1316.     mov    dx,OFFSET DMAMSG
  1317.     int    21h
  1318.  
  1319. @@thats_all:
  1320.  
  1321.     mov    ah,09h
  1322.     mov    dx,OFFSET NEWLINE
  1323.     int    21h
  1324.  
  1325.     cmp    [byte ptr ds:Device],4
  1326.     je    @@loadsamp
  1327.  
  1328.     ret
  1329. @@loadsamp:
  1330.  
  1331.     mov    ah,09h
  1332.     mov    dx,OFFSET GUSMSG
  1333.     int    21h
  1334.  
  1335.     ret
  1336.  
  1337. ENDP
  1338.  
  1339. ;****************************************************************************
  1340. ;*    Rafraichie les informations après un LOADMOD
  1341.  
  1342. PROC    PutMusInf
  1343.  
  1344.     push    ds
  1345.     pop    es
  1346.     mov    di,OFFSET MUSIC_INF+13
  1347.     mov    bl,0
  1348.     call    GetName
  1349.  
  1350.     call    GetModInf
  1351.     mov    [ModVoice],ah
  1352.     mov    [SeqLength],al
  1353.     mov    cx,100
  1354.     xor    ah,ah
  1355.     mov    di,OFFSET MODULE_INF+17
  1356.     call    DecToStr
  1357.  
  1358.     mov    dl,1
  1359.     mov    di,OFFSET FIRST_SAMPLE+5
  1360. @@next_sample:
  1361.     mov    bl,dl
  1362.     push    di
  1363.     call    GetName
  1364.     pop    di
  1365.     add    di,34
  1366.     add    dl,15
  1367.     mov    bl,dl
  1368.     push    di
  1369.     call    GetName
  1370.     pop    di
  1371.     add    di,42
  1372.     sub    dl,14
  1373.     cmp    dl,NB_SAMPLE/2+1
  1374.     jne    @@next_sample
  1375.  
  1376.     mov    ah,48h
  1377.     mov    bx,0FFFFh
  1378.     int    21h
  1379.     mov    ax,[ds:StartMem]
  1380.     sub    ax,bx
  1381.     mov    cx,100
  1382.     shr    ax,6
  1383.     mov    di,OFFSET EXTRA_INF+20
  1384.     call    DecToStr
  1385.  
  1386.     ret
  1387.  
  1388. ENDP
  1389.  
  1390. ;****************************************************************************
  1391. ;*    Rafraichie les informations après un SETMOD
  1392. ;*
  1393.  
  1394. PROC    PutDevInf
  1395.  
  1396.     mov    bl,[byte ptr ds:OFFSET Device]
  1397.     xor    bh,bh
  1398.     shl    bx,2
  1399.     add    bx,OFFSET DEVICEMSG
  1400.     mov    si,[ds:bx]
  1401.     mov    di,OFFSET DEVICE_INF+8
  1402.  
  1403.     push    es
  1404.     push    ds
  1405.     pop    es
  1406.     mov    cx,DEV_NAME_LEN
  1407. @@next_char:
  1408.     lodsb
  1409.     cmp    al,'$'
  1410.     je    @@fill_with_space
  1411.     stosb
  1412.     dec    cx
  1413.     jne    @@next_char
  1414. @@fill_with_space:
  1415.     mov    al,' '
  1416.     rep    stosb
  1417.  
  1418.     mov    cx,10000
  1419.     call    GetMixRate
  1420.     lea    ax,[eax*4+eax]
  1421.     add    ax,ax
  1422.     mov    di,OFFSET DEVICE_INF+44
  1423.     call    DecToStr
  1424.  
  1425.     pop    es
  1426.     ret
  1427.  
  1428. ENDP
  1429.  
  1430. ;****************************************************************************
  1431. ;*    Lit le compteur horaire du BIOS
  1432.  
  1433. PROC    GetTime
  1434.  
  1435.     push    ds
  1436.     mov    ax,BIOS_SEG
  1437.     mov    ds,ax
  1438.     mov    eax,[ds:BIOS_CHRONO]
  1439.     pop    ds
  1440.     mov    [ds:StartTime],eax
  1441.  
  1442.     ret
  1443.  
  1444. ENDP
  1445.  
  1446. ;****************************************************************************
  1447. ;*    Rafraichissement des informations après un MAKEMOD
  1448. ;*    Le rafraichissement se fait directement à l'ecran.
  1449.  
  1450. PROC    PutModInf
  1451.  
  1452.     mov    cx,100
  1453.     movzx    ax,[ds:MasterVol]
  1454.     mov    di,OFFSET Buffer
  1455.     call    DecToStr
  1456.     mov    si,OFFSET Buffer
  1457.     mov    cl,3
  1458.     mov    dx,0344h
  1459.     call    PutText
  1460.  
  1461.  
  1462.     call    GetTempo
  1463.     push    ax
  1464.     mov     di,OFFSET Buffer
  1465.     xor    ah,ah
  1466.     mov    cx,10
  1467.     call    DecToStr
  1468.     mov    si,OFFSET Buffer
  1469.     mov    cl,2
  1470.     mov    dx,0334h
  1471.     call    PutText
  1472.  
  1473.     pop    ax
  1474.     mov    al,ah
  1475.     mov     di,OFFSET Buffer
  1476.     xor    ah,ah
  1477.     mov    cx,100
  1478.     call    DecToStr
  1479.     mov    [byte ptr ds:di],0
  1480.     mov    si,OFFSET Buffer
  1481.     mov    cl,3
  1482.     mov    dx,0337h
  1483.     call    PutText
  1484.  
  1485.     call    GetPattern
  1486.     push    dx
  1487.     push    ax
  1488.     mov    di,OFFSET Buffer
  1489.     xor    ah,ah
  1490.     mov    cx,100
  1491.     call    DecToStr
  1492.     mov    [byte ptr ds:di],0
  1493.     mov    si,OFFSET Buffer
  1494.     mov    dx,031Dh
  1495.     mov    cl,3
  1496.     call    PutText
  1497.  
  1498.     pop    ax
  1499.     mov    al,ah
  1500.     mov    di,OFFSET Buffer
  1501.     xor    ah,ah
  1502.     mov    cx,100
  1503.     call    DecToStr
  1504.     mov    [byte ptr ds:di],0
  1505.     mov    si,OFFSET Buffer
  1506.     mov    dx,030Bh
  1507.     mov    cl,3
  1508.     call    PutText
  1509.  
  1510.     pop    ax
  1511.     mov    di,OFFSET Buffer
  1512.     xor    ah,ah
  1513.     mov     cx,10
  1514.     call    DecToStr
  1515.     mov    [byte ptr ds:di],0
  1516.     mov    si,OFFSET Buffer
  1517.     mov    dx,0329h
  1518.     mov    cl,2
  1519.     call    PutText
  1520.  
  1521.     push    ds
  1522.     mov    ax,BIOS_SEG
  1523.     mov    ds,ax
  1524.     mov    eax,[ds:BIOS_CHRONO]
  1525.     pop    ds
  1526.     sub    eax,[ds:StartTime]
  1527.     xor    dx,dx
  1528.     mov    bx,1092
  1529.     div    bx
  1530.     push    dx
  1531.     mov    di,OFFSET Buffer
  1532.     mov    cx,10
  1533.     call    DecToStr
  1534.     mov    [byte ptr ds:di],0
  1535.     mov    si,OFFSET Buffer
  1536.     mov    dx,0239h
  1537.     mov    cl,2
  1538.     call    PutText
  1539.  
  1540.     pop    ax
  1541.     xor    dx,dx
  1542.     shl    ax,4
  1543.     mov    bx,291
  1544.     div    bx
  1545.     mov    di,OFFSET Buffer
  1546.     mov    cx,10
  1547.     call    DecToStr
  1548.     mov    [byte ptr ds:di],0
  1549.     mov    si,OFFSET Buffer
  1550.     cmp    [byte ptr ds:si],' '
  1551.     jne    @@no_0
  1552.     mov    [byte ptr ds:si],'0'
  1553. @@no_0:
  1554.     mov    dx,023Ch
  1555.     mov    cl,2
  1556.     call    PutText
  1557.  
  1558.  
  1559.     mov    eax,[ds:PlayChrono]
  1560.     lea    eax,[eax*4+eax]
  1561.     lea    eax,[eax*4+eax]
  1562.     shl    eax,2
  1563.     xor    edx,edx
  1564.     div    [ds:VBLChrono]
  1565.     sub    ax,100
  1566.     neg    ax
  1567.     mov    bl,al
  1568.     inc    bl
  1569.     sub    bl,[ds:LastChrono]
  1570.     cmp    bl,2
  1571.     jae    @@no_hyster
  1572.     mov    al,[ds:LastChrono]
  1573. @@no_hyster:
  1574.     mov    [ds:LastChrono],al
  1575.     xor    ah,ah
  1576.     cmp    al,100
  1577.     jb    @@under100
  1578.     xor    al,al
  1579. @@under100:
  1580.     mov    cx,10
  1581.     mov    di,OFFSET Buffer
  1582.     call    DecToStr
  1583.     mov    [byte ptr ds:di],0
  1584.     mov    si,OFFSET Buffer
  1585.     mov    dx,0427h
  1586.     mov    cl,2
  1587.     call    PutText
  1588.  
  1589.     ret
  1590. ENDP
  1591.  
  1592. ;****************************************************************************
  1593. ;*    Rafraichie les vu metres
  1594. ;*
  1595.  
  1596. PROC    PutVuMeter
  1597.  
  1598.     mov    bl,[ModVoice]
  1599.     dec    bl
  1600. @@next_voice:
  1601.     call    GetVoice
  1602.     push    cx
  1603.     push    dx
  1604.  
  1605.     mov    al,dl
  1606.     xor    ah,ah
  1607.     mov    di,OFFSET Buffer
  1608.     mov    cx,10
  1609.     call    DecToStr
  1610.     mov    [byte ptr ds:di],0
  1611.     mov    si,OFFSET Buffer
  1612.     mov    dh,bl
  1613.     add    dh,6
  1614.     mov    dl,2
  1615.     mov    cl,2
  1616.     call    PutText
  1617.  
  1618.     pop    ax
  1619.     push    ax
  1620.  
  1621.     dec    al
  1622.     mov    si,OFFSET FIRST_SAMPLE+5
  1623.     jns    @@no_null_samp
  1624.     xor    al,al
  1625.     add    si,76*15
  1626. @@no_null_samp:
  1627.     and    al,1Fh
  1628.     cmp    al,15
  1629.     jb    @@first_row
  1630.     add    si,34
  1631.     sub    al,15
  1632. @@first_row:
  1633.     mov    dl,76
  1634.     mul    dl
  1635.     add    si,ax
  1636.     mov    dh,bl
  1637.     add    dh,6
  1638.     mov    dl,7
  1639.     mov    cl,22
  1640.     call    PutText
  1641.  
  1642.     pop    ax
  1643.     shr    ax,8
  1644.     shl    ax,4
  1645.     mov    si,ax
  1646.     add    si,OFFSET LIST_EFFET
  1647.     mov    dh,bl
  1648.     add    dh,6
  1649.     mov    dl,43
  1650.     mov    cl,16
  1651.     call    PutText
  1652.  
  1653.     pop    ax
  1654.     push    ax
  1655.     mov    bh,al
  1656.     and    ax,0Fh
  1657.     lea    ax,[eax*2+eax]
  1658.     mov    si,ax
  1659.     add    si,OFFSET LIST_NOTE
  1660.     mov    dh,bl
  1661.     add    dh,6
  1662.     mov    dl,37
  1663.     mov    cl,3
  1664.     call    PutText
  1665.     shr    bh,4
  1666.     or    bh,bh
  1667.     je    @@no_oct
  1668.     add    [es:di-2],bh
  1669. @@no_oct:
  1670.  
  1671.     pop    ax
  1672.     shr    ax,8
  1673.     mov    di,OFFSET Buffer
  1674.     mov    cx,10
  1675.     call    DecToStr
  1676.     mov    [byte ptr ds:di],0
  1677.     mov    si,OFFSET Buffer
  1678.     mov    dh,bl
  1679.     add    dh,6
  1680.     mov    dl,32
  1681.     mov    cl,2
  1682.     call    PutText
  1683.  
  1684.     mov     ax,1
  1685.     mov    cl,bl
  1686.     shl    ax,cl
  1687.     test    [CutVoices],ax
  1688.     jnz    @@mute_voice
  1689.     call    GetVoiceByte
  1690.     xor    bh,bh
  1691.     mov    ah,[ds:OFFSET VuMeters+bx]
  1692.     shr    ah,2
  1693.     shr    al,2
  1694.     sub    al,ah
  1695.     add    [ds:OFFSET VuMeters+bx],al
  1696.     mov    cl,[ds:OFFSET VuMeters+bx]
  1697.     shr    cl,4
  1698.     mov    ch,16
  1699.     mov    dh,bl
  1700.     add    dh,6
  1701.     mov    dl,62
  1702.     call    PutVu
  1703. @@mute_voice:
  1704.  
  1705.     dec    bl
  1706.     jns    @@next_voice
  1707.  
  1708.     ret
  1709.  
  1710. ENDP
  1711.  
  1712. VER_RETRACE    EQU    3dah
  1713.  
  1714. ;****************************************************************************
  1715. ;*    Attend une VBL en comptant dans CX
  1716.  
  1717. PROC    WaitVBL
  1718.  
  1719.         mov    dx,VER_RETRACE
  1720. @@wait1:
  1721.         inc    ecx
  1722.         in    al,dx
  1723.         test    al,8
  1724.         jnz    @@wait1
  1725.  
  1726. @@wait2:
  1727.         inc    ecx
  1728.         in    al,dx
  1729.         test    al,8
  1730.         jz    @@wait2
  1731.  
  1732.         ret
  1733. ENDP
  1734.  
  1735. ENDS
  1736.  
  1737. STACK    400h
  1738.  
  1739. END
  1740.  
  1741.