home *** CD-ROM | disk | FTP | other *** search
/ Sound, Music & MIDI Collection 2 / SMMVOL2.bin / DOS / SS_PLAY / FUNK106.ZIP / FUNK_S.ZIP / FUNK.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-17  |  138.4 KB  |  5,735 lines

  1. ;=1.06=;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;                                                                          ;
  3. ; FunkTracker - By Super Real Darwin!                                      ;
  4. ;               Designed & Coded By Jason Nunn (JsNO)                      ;
  5. ;                                                                          ;
  6. ; Thanks go to Tom Verbeure/Synergy as he composed a faster frequency      ;
  7. ; transformer, making my DAC routines alot tighter. On ya mate :).         ;
  8. ; ...and Adam's little fix ups etc.                                        ;
  9. ;                                                                          ;
  10. ; Snail: 32 Rothdale Road, Moil, Darwin, NT, 0810, Australia               ;
  11. ; Email: jsno@amigar.apana.org.au                                          ;
  12. ; BBS  : ■ Amiga Retreat BBS                                               ;
  13. ;          (089)451516  (3:850/105)                                        ;
  14. ;        ■ Sentinel BBS (SRD's base)                                       ;
  15. ;          (089)452708                                                     ;
  16. ;                                                                          ;
  17. ; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;
  18. ; RUNNING IN PROTECTED MODE USING DOS32 By Adam Seychell                   ;
  19. ; Snail: 16 Avion Place, Westmeadows, VIC, 3049, AUSTRALIA                 ;
  20. ; Email: s921880@minyos.xx.rmit.edu.au                                     ;
  21. ; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;
  22. ;                                                                          ;
  23. ; This code is a byproduct of our productions, and have given it to the    ;
  24. ; public domain condition free. Please fill free to use it in your         ;
  25. ; productions.                                                             ;
  26. ;                                                                          ;
  27. ; If anybody modifies this code for more channels, then please replace the ;
  28. ; preamble (now "Funk") to "Fv**". The ** is a dec number ranging from 0   ;
  29. ; to 99. For example, if the song is a 32 channel module, then the preamble;
  30. ; is "Fv32". 10 Channels is "Fv10".                                        ;
  31. ;                                                                          ;
  32. ;=====================================================================     ;
  33. ; EDITOR CODE                                                              ;
  34. ;                                                                          ;
  35. ; At the application level, this is the editor of funktracker. It does     ;
  36. ; everything accept (physically) play the music :).                        ;
  37. ;                                                                          ;
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  39. ideal
  40. p386
  41. model small
  42.  
  43. segment code32 public 'code' use32
  44. assume cs:code32,ds:code32,es:code32,fs:code32,gs:code32,ss:code32
  45. include "dos32.inc"
  46.  
  47. include "funklite.asm"
  48.  
  49. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  50. ;                                                                          ;
  51. ; editor data                                                              ;
  52. ;                                                                          ;
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54.  
  55. kb_up                 = 4800h  ;just keyboards equates.
  56. kb_down               = 5000h
  57. kb_left               = 4B00h
  58. kb_right              = 4D00h
  59. kb_home               = 4700h
  60. kb_end                = 4F00h
  61. kb_f1                 = 3B00h
  62. kb_f2                 = 3C00h
  63. kb_f3                 = 3D00h
  64. kb_f4                 = 3E00h
  65. kb_f5                 = 3F00h
  66. kb_altf5              = 6c00h
  67. kb_f6                 = 4000h
  68. kb_altf6              = 6d00h
  69. kb_f8                 = 4200h
  70. kb_f9                 = 4300h
  71. kb_f10                = 4400h
  72. kb_pageup             = 4900h
  73. kb_pagedn             = 5100h
  74. kb_insert             = 5200h
  75. kb_delete             = 5300h
  76. kb_altc               = 2e00h
  77. kb_altv               = 2f00h
  78. kb_altb               = 3000h
  79. kb_alte               = 1200h
  80. kb_alto               = 1800h
  81. kb_altx               = 2d00h
  82. kb_altn               = 3100h
  83. kb_altm               = 3200h
  84. kb_altz               = 2c00h
  85. kb_alts               = 1f00h
  86. kb_altd               = 2000h
  87.  
  88. nibble_display        db "0123456789ABCDEF"
  89. note_display          db "C-1C#1D-1D#1E-1F-1F#1G-1G#1A-1A#1B-1"
  90.                       db "C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
  91.                       db "C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
  92.                       db "C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
  93.                       db "C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
  94.                       db "???RLO■■■   "
  95. file_search_all       db "*.*",0
  96. file_search_funk      db "*.FNK",0
  97. file_search_wav       db "*.WAV",0
  98. file_temp             db "\{funky}.tmp"
  99. numread               dd ?
  100. file_handle_funk2     dd ?
  101.  
  102. edit_mode             db 0
  103. pat_number            db 0
  104. pat_real              db 0
  105. pat_hl                db 0
  106. pat_chan              db 0
  107. pat_old_hl            db 0
  108. pat_old_chan          db 0
  109. ;;;;;;
  110. sel_flag              db 0
  111. sel_area_pattern      dw 0
  112. sel_area_chan1        db 0
  113. sel_area_chan2        db 0
  114. sel_area_trek1        db 0
  115. sel_area_trek2        db 0
  116. temp_pattern          db 600h dup(?)
  117. copied_flag           db 0
  118. copied_area_chan1     db 0
  119. copied_area_chan2     db 0
  120. copied_area_trek1     db 0
  121. copied_area_trek2     db 0
  122. ;;;;;;
  123. sam_real              db 0
  124. sam_hl                db 0
  125. sam_col               db 0
  126. note                  db 0
  127. octave                db 0
  128. seq_real              db 0
  129. seq_hl                db 0
  130. fdir_real             dw 0
  131. fdir_hl               db 0
  132. fdir_length           dw 0
  133. song_name             db "NEW_SONG.FNK",0
  134. initial_dir           db 80 dup(0)
  135. song_dir              db 80 dup(0)
  136. sample_dir            db 80 dup(0)
  137. trakplay_type         db ?
  138.  
  139. key1_map              db 0,160,160,160,160,160,255
  140. key2_map              db 2,160,160,160,255
  141. key3_map              db 4,160,160,160,158,2,158,2,255
  142. key4_map              db 6,160,160,160,255
  143. key5_map              db 8,160,160,160,158,2,158,2,255
  144. key6_map              db 10,160,160,160,160,160,255
  145. key7_map              db 12,160,160,160,255
  146. key8_map              db 14,160,160,160,158,2,158,2,255
  147. key9_map              db 16,160,160,160,255
  148. keya_map              db 18,160,160,160,158,2,158,2,255
  149. keyb_map              db 20,160,160,160,255
  150. keyc_map              db 22,160,160,160,158,2,158,2,255
  151.  
  152. dis_keyboard_map:     dd  key1_map, key2_map, key3_map, key4_map, key5_map
  153.                       dd  key6_map, key7_map, key8_map, key9_map, keya_map
  154.                       dd  keyb_map, keyc_map
  155.  
  156. main_screen:
  157. include "main_sc.asm"
  158. main_screen_size      = $-main_screen
  159.  
  160. pe_screen:
  161. include "mode_pe.asm"
  162. pe_screen_size        = $-pe_screen
  163.  
  164. se_screen:
  165. include "mode_se.asm"
  166. se_screen_size        = $-se_screen
  167.  
  168. trakd_screen:
  169. include "mode_d.asm"
  170. trakd_screen_size     = $-trakd_screen
  171.  
  172. trakp_screen:
  173. include "mode_ply.asm"
  174. trakp_screen_size     = $-trakp_screen
  175.  
  176. modefile_screen:
  177. include "modefile.asm"
  178. modefile_screen_size  = $-modefile_screen
  179.  
  180. comms_screen:
  181. include "comms.asm"
  182. comms_screen_size     = $-comms_screen
  183.  
  184. help_screen:
  185. include "help.asm"
  186. help_screen_size      = $-help_screen
  187.  
  188. start_screen:
  189. include "start.asm"
  190. start_screen_size     = $-start_screen
  191.  
  192. end_screen:
  193. include "end.asm"
  194. end_screen_size       = $-end_screen
  195.  
  196. splash_screen:
  197. include "splash.asm"
  198.  
  199. resample_window:
  200. include "resample.asm"
  201.  
  202. font_data:
  203. include "funkfont.asm"
  204.  
  205. struc tdta
  206.   reserved             db 21 dup(?)
  207.   attr                 db ?
  208.   time                 dw ?
  209.   date                 dw ?
  210.   filesize             dd ?
  211.   fname                db 13 dup(?)
  212. ends
  213.  
  214. struc tfdirectory
  215.   attr                 db ?
  216.   fname                db 13 dup(?)
  217. ends
  218. fdir_max_length        = 3000
  219. fdirectory_buffer      dd ?
  220.  
  221. fade_palette_buf       db 64*3 dup(?)
  222.  
  223. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  224. ;                                                                         ;
  225. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  226. proc key_pressed2
  227.   push   esi
  228.   mov    esi,[Zero_Addr]
  229.   add    esi,41ah
  230.   mov    ax,[esi]
  231.   cmp    ax,[word esi+2]
  232.   jne    @@l
  233.   pop    esi
  234.   clc
  235.   ret
  236. @@l:
  237.   movzx  eax,ax
  238.   add    eax,400h
  239.   add    eax,[Zero_Addr]
  240.   mov    ax,[word eax]
  241.   pop    esi
  242.   stc
  243.   ret
  244. endp
  245.  
  246. proc get_key
  247. @@l:
  248.   call   key_pressed2
  249.   jnc    @@l
  250.   mov    eax,0
  251.   int    16h
  252.   ret
  253. endp
  254.  
  255. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  256. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  257. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  258. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  259. ;                                                                          ;
  260. ;                                                                          ;
  261. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  262. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  263. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  264. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  265. MACRO @WaitVert
  266. LOCAL    @@VR
  267.   mov    edx,3dah
  268. @@VR:
  269.   in     al,dx
  270.   test   al,8
  271.   jz     @@VR
  272. ENDM
  273.  
  274. MACRO @WaitVertEnd
  275. LOCAL    @@NVR
  276.   mov    edx,3dah
  277. @@NVR:
  278.   in     al,dx
  279.   test   al,8
  280.   jnz    @@NVR
  281. ENDM
  282.  
  283. ;esi = offset to palette
  284. ;ecx = number of color values to write
  285. ;al  = starting palette register
  286. proc WritePalette
  287.   cli
  288.   mov    edx,03c8h
  289.   out    dx,al
  290.   inc    dx
  291.   cld
  292.   rep    outsb
  293.   sti
  294.   ret
  295. endp
  296.  
  297. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  298. ;                                                                         ;
  299. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  300. ; cx = scroll factor
  301. proc scroll_sc
  302.   cli
  303.   mov    eax,ecx
  304.   mov    bl,80
  305.   mul    bl
  306.   mov    ebx,eax
  307.   mov    edx,3d4h
  308.   mov    al,0ch
  309.   mov    ah,bh      ;write the HIGH byte
  310.   out    dx,ax
  311.   mov    edx,3d4h
  312.   mov    al,0dh
  313.   mov    ah,bl      ;write the LOW byte
  314.   out    dx,ax
  315.   sti
  316.   ret
  317. endp
  318.  
  319. proc help_sc1
  320.   mov    edi,[_0b8000h]
  321.   add    edi,(50*160)
  322.   push   edi ecx
  323.   mov    ecx,(160*50)/4
  324.   xor    eax,eax
  325.   rep    stosd
  326.   pop    ecx edi
  327.   call   uncrush_text
  328.   xor    ecx,ecx
  329. @@sd:
  330.   @WaitVertEnd
  331.   call   scroll_sc
  332.   @WaitVert
  333.   inc    ecx
  334.   cmp    ecx,50
  335.   jbe    @@sd
  336.   ret
  337. endp
  338.  
  339. proc help_sc2
  340.   mov    ecx,50
  341. @@sd2:
  342.   @WaitVertEnd
  343.   call   scroll_sc
  344.   @WaitVert
  345.   dec    ecx
  346.   jnz    @@sd2
  347.   call   scroll_sc
  348.   ret
  349. endp
  350.  
  351. proc help_scroll
  352.   call   help_sc1
  353.   call   get_key
  354.   call   help_sc2
  355.   ret
  356. endp
  357.  
  358. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  359. ;                                                                         ;
  360. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  361. proc text_ded_pfout
  362.   XOR    AL,AL                                          ;fade screen
  363.   MOV    ecx,(64*3)
  364.   lea    edi,[fade_palette_buf]
  365.   cli
  366.   MOV    eDX,3c7h
  367.   OUT    DX,AL
  368.   ADD    eDX,2
  369.   rep    insb
  370.   sti
  371.   mov    ecx,64
  372. @@fade_out_loop:
  373.   push   ecx
  374.   lea    edi,[fade_palette_buf]
  375.   mov    ecx,(64*3)
  376. @@fade_loop:
  377.   mov    al,[byte edi]
  378.   or     al,al
  379.   jz     @@dont_dec
  380.   dec    [byte edi]
  381. @@dont_dec:
  382.   inc    edi
  383.   dec    ecx
  384.   jnz    @@fade_loop
  385.   xor    al,al
  386.   mov    ecx,64*3
  387.   lea    esi,[fade_palette_buf]
  388.   call   WritePalette
  389.   @WaitVertEnd
  390.   @WaitVert
  391.   pop    ecx
  392.   dec    ecx
  393.   jnz    @@fade_out_loop
  394.   ret
  395. endp
  396.  
  397. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  398. ;                                                                          ;
  399. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  400. proc dis_sbar
  401.   xor    al,al
  402. @@write_entry:
  403.   push   edi ecx eax
  404.   cmp    al,dl
  405.   je     @@hle
  406.   jmp    @@hlne
  407. @@hle:
  408.   mov    al,bh
  409.   jmp    @@write_lin
  410. @@hlne:
  411.   mov    al,bl
  412. @@write_lin:
  413.   stosb
  414.   inc    edi
  415.   dec    ecx
  416.   jnz    @@write_lin
  417.   pop    eax ecx edi
  418.   add    edi,160
  419.   inc    al
  420.   cmp    al,dh
  421.   jb     @@write_entry
  422.   ret
  423. endp
  424.  
  425. ; al = menu no
  426. proc hl_menus
  427.   mov    edi,[_0b8000h]
  428.   add    edi,(50*160)+((2*2)+(2*160))+1
  429.   mov    [byte edi],04ch
  430.   mov    edi,[_0b8000h]
  431.   add    edi,(50*160)+((2*2)+(12*160))+1
  432.   mov    [byte edi],04ch
  433.   mov    edi,[_0b8000h]
  434.   add    edi,(50*160)+((35*2)+(12*160))+1
  435.   mov    [byte edi],04ch
  436.   mov    edi,[_0b8000h]
  437.   add    edi,(50*160)+((45*2)+(12*160))+1
  438.   mov    [byte edi],04ch
  439.   mov    edi,[_0b8000h]
  440.   add    edi,(50*160)+((53*2)+(12*160))+1
  441.   mov    [byte edi],04ch
  442.   mov    edi,[_0b8000h]
  443.   add    edi,(50*160)+((61*2)+(12*160))+1
  444.   mov    [byte edi],04ch
  445.   cmp    al,0
  446.   je     @@1
  447.   cmp    al,1
  448.   je     @@2
  449.   cmp    al,2
  450.   je     @@3
  451.   cmp    al,3
  452.   je     @@4
  453.   cmp    al,4
  454.   je     @@5
  455.   cmp    al,5
  456.   je     @@6
  457.   ret
  458. @@1:
  459.   mov    edi,[_0b8000h]
  460.   add    edi,(50*160)+((2*2)+(2*160))+1
  461.   mov    [byte edi],04eh
  462.   ret
  463. @@2:
  464.   mov    edi,[_0b8000h]
  465.   add    edi,(50*160)+((2*2)+(12*160))+1
  466.   mov    [byte edi],04eh
  467.   ret
  468. @@3:
  469.   mov    edi,[_0b8000h]
  470.   add    edi,(50*160)+((35*2)+(12*160))+1
  471.   mov    [byte edi],04eh
  472.   ret
  473. @@4:
  474.   mov    edi,[_0b8000h]
  475.   add    edi,(50*160)+((45*2)+(12*160))+1
  476.   mov    [byte edi],04eh
  477.   ret
  478. @@5:
  479.   mov    edi,[_0b8000h]
  480.   add    edi,(50*160)+((53*2)+(12*160))+1
  481.   mov    [byte edi],04eh
  482.   ret
  483. @@6:
  484.   mov    edi,[_0b8000h]
  485.   add    edi,(50*160)+((61*2)+(12*160))+1
  486.   mov    [byte edi],04eh
  487.   ret
  488. endp
  489.  
  490. proc setting_dct
  491. ;display card type
  492.   mov    dh,08h                          ; no of entries
  493.   mov    dl,[byte init_settings.card_type]
  494.   mov    ebx,6770h                       ; colour of hl
  495.   mov    edi,[_0b8000h]
  496.   add    edi,(50*160)+((2*2)+(13*160))+1
  497.   mov    ecx,28                          ; length
  498.   call   dis_sbar
  499.   ret
  500. endp
  501.  
  502. proc setting_dpt
  503. ;display port number
  504.   mov    dh,06h                          ; no of entries
  505.   mov    dl,[byte init_settings.port_no]
  506.   shr    dl,4
  507.   dec    dl
  508.   mov    ebx,6770h                       ; colour of hl
  509.   mov    edi,[_0b8000h]
  510.   add    edi,(50*160)+((35*2)+(13*160))+1
  511.   mov    ecx,5                           ; length
  512.   call   dis_sbar
  513.   ret
  514. endp
  515.  
  516. set_irq_ptr           db ?
  517.  
  518. proc setting_dirqt
  519. ;display IRQ number
  520.   mov    dh,07h                          ; no of entries
  521.   mov    dl,[byte set_irq_ptr]
  522.   mov    ebx,6770h                       ; colour of hl
  523.   mov    edi,[_0b8000h]
  524.   add    edi,(50*160)+((45*2)+(13*160))+1
  525.   mov    ecx,3                           ; length
  526.   call   dis_sbar
  527.   ret
  528. endp
  529.  
  530. proc setting_ddmat
  531. ;display DMA number
  532.   mov    dh,08h                          ; no of entries
  533.   mov    dl,[byte init_settings.dma_no]
  534.   dec    dl
  535.   mov    ebx,6770h                       ; colour of hl
  536.   mov    edi,[_0b8000h]
  537.   add    edi,(50*160)+((53*2)+(13*160))+1
  538.   mov    ecx,3                           ; length
  539.   call   dis_sbar
  540.   ret
  541. endp
  542.  
  543. proc setting_dsratet
  544. ;display sample rate
  545.   mov    dh,5                            ; no of entries
  546.   mov    dl,[byte init_settings.DAC_Samplerate]
  547.   mov    ebx,6770h                       ; colour of hl
  548.   mov    edi,[_0b8000h]
  549.   add    edi,(50*160)+((61*2)+(13*160))+1
  550.   mov    ecx,16                          ; length
  551.   call   dis_sbar
  552.   ret
  553. endp
  554.  
  555. proc setting_get_card
  556.   mov    al,1
  557.   call   hl_menus
  558. @@dis_main:
  559.   call   setting_dct
  560.   call   get_key
  561.   cmp    al,13
  562.   je     @@action
  563.   cmp    ax,kb_up
  564.   je     @@dec_hl
  565.   cmp    ax,kb_down
  566.   je     @@inc_hl
  567.   jmp    @@dis_main
  568. @@dec_hl:
  569.   cmp    [byte init_settings.card_type],0
  570.   jz     @@dis_main
  571.   dec    [byte init_settings.card_type]
  572.   jmp    @@dis_main
  573. @@inc_hl:
  574.   cmp    [byte init_settings.card_type],PAS16_CARD
  575.   je     @@dis_main
  576.   inc    [byte init_settings.card_type]
  577.   jmp    @@dis_main
  578. @@action:
  579.   ret
  580. endp
  581.  
  582. proc setting_get_port
  583.   mov    al,2
  584.   call   hl_menus
  585. @@dis_main:
  586.   call   setting_dpt
  587.   call   get_key
  588.   cmp    al,13
  589.   je     @@action
  590.   cmp    ax,kb_up
  591.   je     @@dec_hl
  592.   cmp    ax,kb_down
  593.   je     @@inc_hl
  594.   jmp    @@dis_main
  595. @@dec_hl:
  596.   cmp    [dword init_settings.port_no],210h
  597.   jz     @@dis_main
  598.   sub    [dword init_settings.port_no],010h
  599.   jmp    @@dis_main
  600. @@inc_hl:
  601.   cmp    [dword init_settings.port_no],260h
  602.   je     @@dis_main
  603.   add    [dword init_settings.port_no],010h
  604.   jmp    @@dis_main
  605. @@action:
  606.   ret
  607. endp
  608.  
  609. proc setting_get_irq
  610.   mov    al,3
  611.   call   hl_menus
  612. @@dis_main:
  613.   call   setting_dirqt
  614.   call   get_key
  615.   cmp    al,13
  616.   je     @@action
  617.   cmp    ax,kb_up
  618.   je     @@dec_hl
  619.   cmp    ax,kb_down
  620.   je     @@inc_hl
  621.   jmp    @@dis_main
  622. @@dec_hl:
  623.   cmp    [byte set_irq_ptr],0
  624.   jz     @@dis_main
  625.   dec    [byte set_irq_ptr]
  626.   jmp    @@dis_main
  627. @@inc_hl:
  628.   cmp    [byte set_irq_ptr],6
  629.   je     @@dis_main
  630.   inc    [byte set_irq_ptr]
  631.   jmp    @@dis_main
  632. @@action:
  633.   ret
  634. endp
  635.  
  636. proc setting_get_dma
  637.   mov    al,4
  638.   call   hl_menus
  639. @@dis_main:
  640.   call   setting_ddmat
  641.   call   get_key
  642.   cmp    al,13
  643.   je     @@action
  644.   cmp    ax,kb_up
  645.   je     @@dec_hl
  646.   cmp    ax,kb_down
  647.   je     @@inc_hl
  648.   jmp    @@dis_main
  649. @@dec_hl:
  650.   cmp    [byte init_settings.dma_no],1
  651.   je     @@dis_main
  652.   dec    [byte init_settings.dma_no]
  653.   jmp    @@dis_main
  654. @@inc_hl:
  655.   cmp    [byte init_settings.dma_no],8
  656.   je     @@dis_main
  657.   inc    [byte init_settings.dma_no]
  658.   jmp    @@dis_main
  659. @@action:
  660.   ret
  661. endp
  662.  
  663. proc setting_get_samplerate
  664.   mov    al,5
  665.   call   hl_menus
  666. @@dis_main:
  667.   call   setting_dsratet
  668.   call   get_key
  669.   cmp    al,13
  670.   je     @@action
  671.   cmp    ax,kb_up
  672.   je     @@dec_hl
  673.   cmp    ax,kb_down
  674.   je     @@inc_hl
  675.   jmp    @@dis_main
  676. @@dec_hl:
  677.   cmp    [byte init_settings.DAC_Samplerate],0
  678.   jz     @@dis_main
  679.   dec    [byte init_settings.DAC_Samplerate]
  680.   jmp    @@dis_main
  681. @@inc_hl:
  682.   cmp    [byte init_settings.DAC_Samplerate],4
  683.   je     @@dis_main
  684.   inc    [byte init_settings.DAC_Samplerate]
  685.   jmp    @@dis_main
  686. @@action:
  687.   ret
  688. endp
  689.  
  690. proc card_settings
  691.   call   text_ded_pfout
  692.   mov    eax,3h
  693.   int    10h
  694.   mov    ah,02h
  695.   xor    bh,bh
  696.   mov    edx,6400h
  697.   int    10h
  698.   mov    eax,3d00h                                      ;open file
  699.   lea    edx,[@@config_file]
  700.   int    21h
  701.   jnc    @@file_opened
  702.   mov    ecx,start_screen_size
  703.   lea    esi,[start_screen]
  704.   call   help_sc1
  705.  
  706.   mov    [byte set_irq_ptr],0
  707.   lea    esi,[@@irq_set]
  708.   xor    ecx,ecx
  709. @@search_irq:
  710.   mov    al,[byte esi+ecx]
  711.   cmp    al,[byte init_settings.irq_no]
  712.   je     @@irq_found
  713.   inc    cl
  714.   cmp    cl,8
  715.   jb     @@search_irq
  716.   jmp    @@irq_cont
  717. @@irq_found:
  718.   mov    [byte set_irq_ptr],cl
  719. @@irq_cont:
  720.   call   setting_dct
  721.   call   setting_dpt
  722.   call   setting_dirqt
  723.   call   setting_ddmat
  724.   call   setting_dsratet
  725. ;main loop
  726.   mov    al,0
  727.   call   hl_menus
  728.   mov    bx,6770h  ; colour of hl    ; colour of ll
  729. @@dis_main:
  730.   mov    edi,[_0b8000h]
  731.   add    edi,(50*160)+((2*2)+(3*160))+1
  732.   mov    ecx,29   ; length
  733.   mov    dh,3
  734.   mov    dl,[@@__ptr]
  735.   call   dis_sbar
  736.   call   get_key
  737.   cmp    al,13
  738.   je     @@action
  739.   cmp    ax,kb_up
  740.   je     @@dec_hl
  741.   cmp    ax,kb_down
  742.   je     @@inc_hl
  743.   jmp    @@dis_main
  744. @@dec_hl:
  745.   cmp    [byte @@__ptr],0
  746.   je     @@dis_main
  747.   dec    [byte @@__ptr]
  748.   jmp    @@dis_main
  749. @@inc_hl:
  750.   cmp    [byte @@__ptr],2
  751.   je     @@dis_main
  752.   inc    [byte @@__ptr]
  753.   jmp    @@dis_main
  754. @@action:
  755.   cmp    [byte @@__ptr],0
  756.   je     @@set_card
  757.   cmp    [byte @@__ptr],1
  758.   je     @@done
  759.   cmp    [byte @@__ptr],2
  760.   je     @@abend
  761.   jmp    @@dis_main
  762. @@set_card:
  763.   call   setting_get_card
  764.   call   setting_get_port
  765.   call   setting_get_irq
  766.   call   setting_get_dma
  767.   call   setting_get_samplerate
  768.   mov    al,0
  769.   call   hl_menus
  770.   jmp    @@dis_main
  771. @@abend:
  772.   call   help_sc2
  773.   stc
  774.   ret
  775. @@done:
  776.   movzx  ebx,[byte set_irq_ptr]
  777.   mov    al,[byte ebx+@@irq_set]
  778.   mov    [byte init_settings.irq_no],al
  779.   call   help_sc2
  780. @@skip:
  781.   mov    ah,3ch                                 ; create file
  782.   lea    edx,[@@config_file]
  783.   xor    ecx,ecx
  784.   int    21h
  785.   mov    ebx,eax
  786.   mov    ah,40h                                 ; write file
  787.   jmp    @@do_stuff
  788. @@file_opened:
  789.   mov    ebx,eax
  790.   mov    ah,3fh                                 ;read config
  791. @@do_stuff:
  792.   lea    edx,[init_settings]
  793.   mov    ecx,size init_settings
  794.   int    21h
  795.   mov    ah,3eh                                 ;close file
  796.   int    21h
  797.   clc
  798.   ret
  799. @@__ptr  db 0
  800. @@irq_set:
  801.   db     02,03,05,07,11,12,15
  802. @@config_file:
  803.   db     "funk~.cfg",0
  804. endp
  805.  
  806. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  807. ;                                                                          ;
  808. ; SETUP_SCREEN PROC: Modified By Adam Seychell 14/03/94  in V1.02          ;
  809. ;                                                                          ;
  810. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  811. proc setup_screen
  812.  
  813.         mov     bl,00h                 ;  goto Text Mode 80x50
  814.         mov     ah,11h
  815.         mov     al,12h
  816.         int     10h
  817.  
  818.  
  819.     ; set up registers to accsess one Bit plane  only
  820.     ; set for sequentual memory addressing
  821.         mov dx,3C4h             ; sequencer reg group
  822.         mov al,4
  823.         mov ah,0111b
  824.         out dx,ax
  825.  
  826.         mov dx,3CEh             ; The Graphics Controller reg group
  827.         mov al,5                ; Mode Register
  828.         mov ah,00000000b
  829.         out dx,ax
  830.  
  831.         mov dx,3ceh             ; The Graphics Controller reg group
  832.         mov al,6                ; Misellaneous Register
  833.         mov ah,1100b
  834.         out dx,ax
  835.  
  836.       ; set Map Mask Register
  837.         mov dx,3c4h             ; sequencer reg group
  838.         mov al,2
  839.         mov ah,0100b            ; to write to bit plane 2 ( font memory )
  840.         out dx,ax
  841.  
  842.      ; can now fill up the video font memory
  843.  
  844.         mov     edi,[_0b8000h]
  845.         xor     edx,edx
  846. @@fill_font:
  847.         mov     eax,[Dword PTR font_data+EDX]
  848.         mov     [edi],eax
  849.         mov     eax,[Dword PTR font_data+EDX+4]
  850.         mov     [edi+4],eax
  851.         add     edi,32
  852.         add     edx,8
  853.         cmp     edx,255*8
  854.         jb      @@fill_font
  855.  
  856.  
  857.  
  858.   ;      set up registers to accsess one Bit plane 0 and 1 chained together
  859.   ; i.e return to it's normal write mode.
  860.   ;
  861.         mov dx,3C4h             ; sequencer reg group
  862.         mov al,4
  863.         mov ah,00011b           ; Chain four enabled
  864.         out dx,ax
  865.  
  866.         mov dx,3CEh             ; The Graphics Controller reg group
  867.         mov al,5                ; Mode Register
  868.         mov ah,00010000b
  869.         out dx,ax
  870.  
  871.         mov al,6                ; Miscellaneous Register
  872.         mov ah,1110b
  873.         out dx,ax
  874.  
  875.      ; set Map Mask Register
  876.         mov dx,3c4h             ; sequencer reg group
  877.         mov al,2
  878.         mov ah,0011b            ; to write to bit plane 0 and 1
  879.         out dx,ax
  880.  
  881.     ;------- end of font filling code --------------------
  882.  
  883.   mov    ah,02h
  884.   xor    bh,bh
  885.   mov    edx,6400h
  886.   int    10h
  887.   mov    al,1
  888.   mov    ecx,3
  889.   lea    esi,[@@colour]
  890.   call   WritePalette
  891.   mov    al,5
  892.   mov    ecx,3
  893.   lea    esi,[@@colour+3]
  894.   call   WritePalette
  895.   mov    al,3ah
  896.   mov    ecx,3
  897.   lea    esi,[@@colour+6]
  898.   call   WritePalette
  899.   mov    al,3bh
  900.   mov    ecx,3
  901.   lea    esi,[@@colour+9]
  902.   call   WritePalette
  903.   mov    al,3dh
  904.   mov    ecx,3
  905.   lea    esi,[@@colour+12]
  906.   call   WritePalette
  907.   mov    al,3eh
  908.   mov    ecx,3
  909.   lea    esi,[@@colour+15]
  910.   call   WritePalette
  911.   ret
  912. @@colour:
  913.   db     12h,13h,1bh   ;01
  914.   db     0ch,12h,29h   ;05
  915.   db     1ch,38h,26h   ;3a
  916.   db     08h,3fh,38h   ;3b
  917.   db     00h,20h,2fh   ;3d
  918.   db     31h,31h,00h   ;3e
  919. endp
  920.  
  921.  
  922. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  923. ;                                                                          ;
  924. ; ch = size of edit                                                        ;
  925. ; dl = x, dh = y                                                           ;
  926. ;                                                                          ;
  927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  928. proc get_input
  929.   movzx  edi,dh
  930.   mov    eax,edi
  931.   shl    edi,7
  932.   shl    eax,5
  933.   add    edi,eax
  934.   movzx  eax,dl
  935.   shl    eax,1
  936.   add    edi,eax
  937.   add    edi,[_0b8000h]
  938.   push   edi
  939.   push   edi
  940.   mov    cl,ch
  941.   mov    eax,6f20h
  942. @@set_bound:
  943.   stosw
  944.   dec    cl
  945.   jnz    @@set_bound
  946.   pop    edi
  947. @@get_input:
  948.   cmp    cl,ch
  949.   ja     @@exit
  950.   jae    @@ign
  951.   mov    ah,02h
  952.   xor    bh,bh
  953.   int    10h
  954. @@ign:
  955.   call   get_key
  956.   cmp    al,27
  957.   je     @@abort
  958.   cmp    al,13
  959.   je     @@exit
  960.   cmp    al,8
  961.   je     @@back_space
  962.   cmp    al,31
  963.   jbe    @@get_input
  964.   cmp    cl,ch
  965.   jae    @@ignore_write
  966.   mov    ah,6fh
  967.   stosw
  968. @@ignore_write:
  969.   inc    cl
  970.   inc    dl
  971.   jmp    @@get_input
  972. @@back_space:
  973.   or     cl,cl
  974.   jz     @@get_input
  975.   dec    cl
  976.   dec    dl
  977.   sub    edi,2
  978.   mov    [word edi],6f20h
  979.   jmp    @@get_input
  980. @@exit:
  981.   mov    ah,02h
  982.   xor    bh,bh
  983.   mov    edx,1900h
  984.   int    10h
  985.   pop    edi
  986.   clc
  987.   ret
  988. @@abort:
  989.   mov    ah,02h
  990.   xor    bh,bh
  991.   mov    edx,6400h
  992.   int    10h
  993.   pop    edi
  994.   stc
  995.   ret
  996. endp
  997.  
  998. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  999. ;                                                                          ;
  1000. ; edi = screen pos, returns al                                             ;
  1001. ;                                                                          ;
  1002. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1003. proc get_inib
  1004.   xor    ebx,ebx
  1005. @@find_com_loop:
  1006.   mov    al,[byte ebx+nibble_display]
  1007.   cmp    al,[byte edi]
  1008.   je     @@num_found
  1009.   mov    al,[byte ebx+@@nibble_display2]
  1010.   cmp    al,[byte edi]
  1011.   je     @@num_found
  1012.   inc    ebx
  1013.   cmp    ebx,16
  1014.   jb     @@find_com_loop
  1015.   xor    bl,bl
  1016. @@num_found:
  1017.   add    edi,2
  1018.   ret
  1019. @@nibble_display2:
  1020.   db     "0123456789abcdef"
  1021. endp
  1022.  
  1023. proc get_ibyte
  1024.   call   get_inib
  1025.   push   ebx
  1026.   call   get_inib
  1027.   pop    eax
  1028.   shl    al,4
  1029.   and    bl,1111b
  1030.   or     al,bl
  1031.   ret
  1032. endp
  1033.  
  1034. proc get_idword
  1035.   call   get_ibyte
  1036.   shl    eax,24
  1037.   mov    ebx,eax
  1038.   push   ebx
  1039.   call   get_ibyte
  1040.   pop    ebx
  1041.   shl    eax,16
  1042.   and    eax,00FF0000h
  1043.   or     ebx,eax
  1044.   push   ebx
  1045.   call   get_ibyte
  1046.   pop    ebx
  1047.   shl    eax,8
  1048.   and    eax,0000FF00h
  1049.   or     ebx,eax
  1050.   push   ebx
  1051.   call   get_ibyte
  1052.   pop    ebx
  1053.   and    eax,000000FFh
  1054.   or     ebx,eax
  1055.   ret
  1056. endp
  1057.  
  1058. ; cl = size of string; returns esi of string data
  1059. proc get_string
  1060. @@sg_loop:
  1061.   mov    al,[byte edi]
  1062.   mov    [byte esi],al
  1063.   inc    esi
  1064.   add    edi,2
  1065.   dec    cl
  1066.   jnz    @@sg_loop
  1067.   ret
  1068. endp
  1069.  
  1070. ;esi  Crunched image source pointer.
  1071. ;edi  screen
  1072. ;ecx  Length of crunched image source data.
  1073. proc uncrush_text
  1074.   MOV    edx,edi
  1075.   XOR    EAX,EAX
  1076. @@LOOPA:
  1077.   LODSB
  1078.   CMP    AL,32
  1079.   JC     @@ForeGround
  1080.   STOSW
  1081. @@Next:
  1082.   dec    ecx
  1083.   jnz    @@LOOPA
  1084.   JMP    @@Done
  1085. @@ForeGround:
  1086.   CMP    AL,16
  1087.   JNC    @@BackGround
  1088.   AND    AH,0F0H
  1089.   OR     AH,AL
  1090.   JMP    @@Next
  1091. @@BackGround:
  1092.   CMP    AL,24
  1093.   JZ     @@NextLine
  1094.   JNC    @@FlashBitToggle
  1095.   SUB    AL,16
  1096.   ADD    AL,AL
  1097.   ADD    AL,AL
  1098.   ADD    AL,AL
  1099.   ADD    AL,AL
  1100.   AND    AH,8FH
  1101.   OR     AH,AL
  1102.   JMP    @@Next
  1103. @@NextLine:
  1104.   ADD    edx,160
  1105.   MOV    edi,edx
  1106.   JMP    @@Next
  1107. @@FlashBitToggle:
  1108.   CMP    AL,27
  1109.   JC     @@MultiOutput
  1110.   JNZ    @@Next
  1111.   XOR    AH,128
  1112.   JMP    @@Next
  1113. @@MultiOutput:
  1114.   CMP    AL,25
  1115.   MOV    ebx,ecx
  1116.   LODSB
  1117.   MOV    CL,AL
  1118.   MOV    AL,32
  1119.   JZ     @@StartOutput
  1120.   LODSB
  1121.   DEC    ebx
  1122. @@StartOutput:
  1123.   XOR    CH,CH
  1124.   inc    ecx
  1125.   REP STOSW
  1126.   MOV    ecx,ebx
  1127.   dec    ecx
  1128.   LOOPNZ @@LOOPA
  1129. @@Done:
  1130.   ret
  1131. endp
  1132.  
  1133. proc DecSizeSet
  1134.   mov    ecx,eax
  1135. @@dec83:
  1136.   mov    eax,ecx
  1137.   xor    edx,edx
  1138.   div    [dword esi+@@Dec_divider]
  1139.   mov    ecx,edx
  1140.   add    al,'0'
  1141.   mov    [edi],al
  1142.   add    edi,2
  1143.   sub    esi,4
  1144.   jge    @@dec83
  1145.   ret
  1146. @@dec_divider:
  1147.   dd 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000
  1148. endp
  1149.  
  1150. proc print_decn1
  1151.   add    edi,[_0b8000h]
  1152.   and    eax,0ffh
  1153.   mov    esi,4*1
  1154.   call   DecSizeSet
  1155.   ret
  1156. endp
  1157.  
  1158. proc print_decn3
  1159.   add    edi,[_0b8000h]
  1160.   and    eax,03fffh
  1161.   mov    esi,4*3
  1162.   call   DecSizeSet
  1163.   ret
  1164. endp
  1165.  
  1166. proc print_decn5
  1167.   add    edi,[_0b8000h]
  1168.   mov    esi,4*4
  1169.   call     DecSizeSet
  1170.   ret
  1171. endp
  1172.  
  1173. proc print_decn9
  1174.   add    edi,[_0b8000h]
  1175.   mov    esi,4*9
  1176.   call     DecSizeSet
  1177.   ret
  1178. endp
  1179.  
  1180. ; edi = position (x * (y*160))
  1181. ; bl  = number
  1182. ; ah  = colour
  1183. proc display_nibble
  1184.   add    edi,[_0b8000h]
  1185.   and    ebx,1111b
  1186.   mov    al,[byte ebx+nibble_display]
  1187.   mov    [edi],ax
  1188.   add    edi,2
  1189.   ret
  1190. endp
  1191.  
  1192. ; edi = position (x * (y*160))
  1193. ; bl  = number
  1194. ; ah  = colour
  1195. proc display_byte
  1196.   add    edi,[_0b8000h]
  1197. proc display_byte_f
  1198.   push   ebx
  1199.   and    ebx,11110000b
  1200.   shr    bl,4
  1201.   mov    al,[byte ebx+nibble_display]
  1202.   mov    [edi],ax
  1203.   add    edi,2
  1204.   pop    ebx
  1205.   and    ebx,00001111b
  1206.   mov    al,[byte ebx+nibble_display]
  1207.   mov    [edi],ax
  1208.   add    edi,2
  1209.   ret
  1210. endp
  1211. endp
  1212.  
  1213. ; edi = position (x * (y*160))
  1214. ; ecx = number
  1215. ; ah  = colour
  1216. proc display_word
  1217.   and    ecx,0ffffh
  1218.   add    edi,[_0b8000h]
  1219.   mov    ebx,ecx
  1220.   shr    ebx,12
  1221.   mov    al,[byte ebx+nibble_display]
  1222.   mov    [edi],ax
  1223.   add    edi,2
  1224.   mov    ebx,ecx
  1225.   shr    ebx,8
  1226.   and    ebx,1111b
  1227.   mov    al,[byte ebx+nibble_display]
  1228.   mov    [edi],ax
  1229.   add    edi,2
  1230.   mov    ebx,ecx
  1231.   shr    ebx,4
  1232.   and    ebx,1111b
  1233.   mov    al,[byte ebx+nibble_display]
  1234.   mov    [edi],ax
  1235.   add    edi,2
  1236.   mov    ebx,ecx
  1237.   and    ebx,1111b
  1238.   mov    al,[byte ebx+nibble_display]
  1239.   mov    [edi],ax
  1240.   add    edi,2
  1241.   ret
  1242. endp
  1243.  
  1244. ; edi = position (x * (y*160))
  1245. ; ecx = number
  1246. ; ah  = colour
  1247. proc display_dword
  1248.   add    edi,[_0b8000h]
  1249.   mov    ebx,ecx
  1250.   shr    ebx,28
  1251.   mov    al,[byte ebx+nibble_display]
  1252.   mov    [edi],ax
  1253.   add    edi,2
  1254.   mov    ebx,ecx
  1255.   shr    ebx,24
  1256.   and    ebx,1111b
  1257.   mov    al,[byte ebx+nibble_display]
  1258.   mov    [edi],ax
  1259.   add    edi,2
  1260.   mov    ebx,ecx
  1261.   shr    ebx,20
  1262.   and    ebx,1111b
  1263.   mov    al,[byte ebx+nibble_display]
  1264.   mov    [edi],ax
  1265.   add    edi,2
  1266.   mov    ebx,ecx
  1267.   shr    ebx,16
  1268.   and    ebx,1111b
  1269.   mov    al,[byte ebx+nibble_display]
  1270.   mov    [edi],ax
  1271.   add    edi,2
  1272.   mov    ebx,ecx
  1273.   shr    ebx,12
  1274.   and    ebx,1111b
  1275.   mov    al,[byte ebx+nibble_display]
  1276.   mov    [edi],ax
  1277.   add    edi,2
  1278.   mov    ebx,ecx
  1279.   shr    ebx,8
  1280.   and    ebx,1111b
  1281.   mov    al,[byte ebx+nibble_display]
  1282.   mov    [edi],ax
  1283.   add    edi,2
  1284.   mov    ebx,ecx
  1285.   shr    ebx,4
  1286.   and    ebx,1111b
  1287.   mov    al,[byte ebx+nibble_display]
  1288.   mov    [edi],ax
  1289.   add    edi,2
  1290.   mov    ebx,ecx
  1291.   and    ebx,1111b
  1292.   mov    al,[byte ebx+nibble_display]
  1293.   mov    [edi],ax
  1294.   add    edi,2
  1295.   ret
  1296. endp
  1297.  
  1298. ; edi = position (x * (y*160))
  1299. ; bx  = number    value(hi):command(lo)
  1300. ; ah  = colour
  1301. proc display_command
  1302.   add    edi,[_0b8000h]
  1303. proc display_command_f
  1304.   cmp    bl,0fh
  1305.   je     @@blank
  1306.   mov    al,"a"
  1307.   add    al,bl
  1308.   mov    [edi],ax
  1309.   add    edi,2
  1310.   push   ebx
  1311.   and    ebx,1111000000000000b
  1312.   shr    ebx,12
  1313.   mov    al,[byte ebx+nibble_display]
  1314.   mov    [edi],ax
  1315.   add    edi,2
  1316.   pop    ebx
  1317.   and    ebx,0000111100000000b
  1318.   shr    ebx,8
  1319.   mov    al,[byte ebx+nibble_display]
  1320.   mov    [edi],ax
  1321.   add    edi,2
  1322.   ret
  1323. @@blank:
  1324.   mov    al,"-"
  1325.   mov    [edi],ax
  1326.   add    edi,2
  1327.   mov    [edi],ax
  1328.   add    edi,2
  1329.   mov    [edi],ax
  1330.   add    edi,2
  1331.   ret
  1332. endp
  1333. endp
  1334.  
  1335. ; edi = position (x * (y*160))
  1336. ; ah  = colour
  1337. proc display_note
  1338.   add    edi,[_0b8000h]
  1339. proc display_note_f
  1340.   lea    ebx,[ebx*2+ebx]
  1341.   mov    al,[byte ebx+note_display]
  1342.   mov    [edi],ax
  1343.   add    edi,2
  1344.   mov    al,[byte ebx+note_display+1]
  1345.   mov    [edi],ax
  1346.   add    edi,2
  1347.   mov    al,[byte ebx+note_display+2]
  1348.   mov    [edi],ax
  1349.   add    edi,2
  1350.   ret
  1351. endp
  1352. endp
  1353.  
  1354. ; byte_write1: esi = string addr  null terminated
  1355. ;              edi = position
  1356. ;              cl = len
  1357. ;              ah  = colour
  1358. proc byte_write1
  1359.   add    edi,[_0b8000h]
  1360. @@str_copy_loop:
  1361.   mov    al,[esi]
  1362.   inc    esi
  1363.   or     al,al
  1364.   jz     @@paint_nulls
  1365.   cmp    al,"."
  1366.   je     @@paint_nulls
  1367.   stosw
  1368.   dec    cl
  1369.   jnz    @@str_copy_loop
  1370. @@paint_nulls:
  1371.   xor    al,al
  1372. @@paint_nl:
  1373.   or     cl,cl
  1374.   jz     @@exit
  1375.   mov    [edi],ax
  1376.   add    edi,2
  1377.   dec    cl
  1378.   jmp    @@paint_nl
  1379. @@exit:
  1380.   ret
  1381. endp
  1382.  
  1383. ; byte_write2: esi = string addr  null terminated
  1384. ;              edi = position
  1385. ;              cl = len
  1386. ;              ah  = colour
  1387. proc byte_write2
  1388.   add    edi,[_0b8000h]
  1389. @@str_copy_loop:
  1390.   mov    al,[esi]
  1391.   inc    esi
  1392.   mov    [edi],ax
  1393.   add    edi,2
  1394.   dec    cl
  1395.   jnz    @@str_copy_loop
  1396.   ret
  1397. endp
  1398.  
  1399. ; esi = ANSIIZ
  1400. proc display_bm
  1401.   mov    edi,(49*160)
  1402.   mov    cl,80
  1403.   mov    ah,8eh
  1404.   call   byte_write1
  1405.   ret
  1406. endp
  1407.  
  1408. proc clear_bm
  1409.   mov    edi,[_0b8000h]
  1410.   add    edi,(49*160)
  1411.   xor    eax,eax
  1412.   mov    ecx,160/4
  1413.   rep    stosd
  1414.   ret
  1415. endp
  1416.  
  1417. macro @error_mess string
  1418. local @@tttext, @@skip
  1419.   jmp    @@skip
  1420.   ifb    <string>
  1421. @@tttext:
  1422.   db     " - Hit any key",0
  1423.   else
  1424. @@tttext:
  1425.   db     string, " - Hit any key",0
  1426.   endif
  1427. @@skip:
  1428.   push   edi esi ecx
  1429.   lea    esi,[@@tttext]
  1430.   call   display_bm
  1431.   call   get_key
  1432.   call   clear_bm
  1433.   pop    ecx esi edi
  1434. endm
  1435.  
  1436. macro @splash_on_sm string
  1437. local @@tttext, @@skip
  1438.   jmp    @@skip
  1439.   ifb    <string>
  1440. @@tttext:
  1441.   db     0
  1442.   else
  1443. @@tttext:
  1444.   db     string, 0
  1445.   endif
  1446. @@skip:
  1447.   push   edi esi ecx
  1448.   lea    esi,[@@tttext]
  1449.   call   display_bm
  1450.   pop    ecx esi edi
  1451. endm
  1452.  
  1453. ;@STDIO MACRO: Modified By Adam Seychell 14/03/94 in V1.02
  1454. macro @stdio string
  1455. local @@tttext, @@skip
  1456.   jmp    @@skip
  1457.   ifb    <string>
  1458. @@tttext:
  1459.   db     "$"
  1460.   else
  1461. @@tttext:
  1462.   db     string, "$"
  1463.   endif
  1464. @@skip:
  1465.   push   eax edx
  1466.   lea    edx,[@@tttext]
  1467.   mov    ah,9
  1468.   int    21h
  1469.   pop    edx eax
  1470. endm
  1471.  
  1472. macro @splash_off_sm string
  1473. local @@tttext, @@skip
  1474.   push   edi esi ecx
  1475.   call   clear_bm
  1476.   pop    ecx esi edi
  1477. endm
  1478.  
  1479. ;esi = source buffer
  1480. ;edi = video buffer
  1481. ;dl = height
  1482. ;ebx = width
  1483. proc paint_window
  1484. @@splash_loop:
  1485.   mov    ecx,ebx
  1486.   rep    movsw
  1487.   mov    eax,80
  1488.   sub    eax,ebx
  1489.   lea    eax,[eax*2]
  1490.   add    edi,eax
  1491.   dec    dl
  1492.   jnz    @@splash_loop
  1493.   ret
  1494. endp
  1495.  
  1496. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1497. ;                                                                          ;
  1498. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1499. proc scroll_display32
  1500.   mov    edi,[_0b8000h]
  1501.   add    edi,(78*2)+(2*160)
  1502.   xor    cl,cl
  1503. @@clear_scroll:
  1504.   mov    al,"▒"
  1505.   cmp    cl,dl
  1506.   jne    @@cont2
  1507.   mov    al,17
  1508. @@cont2:
  1509.   stosb
  1510.   add    edi,159
  1511.   inc    cl
  1512.   cmp    cl,32
  1513.   jb     @@clear_scroll
  1514.   ret
  1515. endp
  1516.  
  1517. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1518. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1519. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1520. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1521. ;                                                                          ;
  1522. ;display keyboard                                                          ;
  1523. ;                                                                          ;
  1524. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1525. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1526. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1527. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1528.  
  1529. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1530. ;                                                                          ;
  1531. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1532. proc play_keynote
  1533.   cli
  1534.   mov    al,size tfunk_chan
  1535.   mul    [byte pat_chan]
  1536.   movzx  edi,ax
  1537.   add    edi,offset funk_chan1
  1538.   mov    al,[byte sam_hl]
  1539.   add    al,[byte sam_real]
  1540.   mov    [byte edi+tfunk_chan.sample],al
  1541.   movzx  eax,al
  1542.   shl    eax,5
  1543.   add    eax,offset funk_sb
  1544.   cmp    [dword eax+tfunk_sb.length],0
  1545.   je     @@endendend
  1546.   mov    [byte edi+tfunk_chan.funkctrl],10b       ; set funkctrl
  1547.   mov    ebx,[dword eax+tfunk_sb.start]
  1548.   cmp    ebx,0ffffffffh
  1549.   je     @@dont_loop
  1550.   mov    [byte edi+tfunk_chan.funkctrl],11b       ; set funkctrl
  1551. @@dont_loop:
  1552.   mov    [dword edi+tfunk_chan.start],ebx
  1553.   mov    ebx,[dword eax+tfunk_sb.length]
  1554.   mov    [dword edi+tfunk_chan.length],ebx
  1555.   mov    bl,[byte eax+tfunk_sb.balance]
  1556.   mov    [byte edi+tfunk_chan.balance],bl
  1557.   mov    bl,[byte eax+tfunk_sb.pt_and_sop]        ; get both port type and sample ofs parm
  1558.   mov    dl,bl
  1559.   shr    bl,4
  1560.   and    dl,1111b
  1561.   mov    [byte edi+tfunk_chan.port_type],bl
  1562.   mov    [byte edi+tfunk_chan.sample_ofs_parm],dl
  1563.   mov    bl,[byte eax+tfunk_sb.vv_waveform]       ; get both vibrato wf & tremola wf
  1564.   mov    dl,bl
  1565.   shr    bl,4
  1566.   and    dl,1111b
  1567.   mov    [byte edi+tfunk_chan.vib_waveform],bl
  1568.   mov    [byte edi+tfunk_chan.vol_vib_waveform],dl
  1569.   mov    bl,[byte eax+tfunk_sb.rl_and_as]         ; get both retrig speed & arp speed
  1570.   mov    dl,bl
  1571.   shr    bl,4
  1572.   and    dl,1111b
  1573.   mov    [byte edi+tfunk_chan.retrig_limit],bl
  1574.   mov    [byte edi+tfunk_chan.arp_speed],dl
  1575.   mov    bl,[byte eax+tfunk_sb.volume]
  1576.   mov    [byte edi+tfunk_chan.volume],bl
  1577.   call   vol_to_realvol
  1578.   call   [dword CARD_volume_convert]
  1579.   mov    al,[byte octave]
  1580.   mov    bl,al
  1581.   shl    al,3
  1582.   shl    bl,2
  1583.   add    bl,al
  1584.   add    bl,[byte note]
  1585.   mov    [byte edi+tfunk_chan.note],bl
  1586.   @note_2_ifreq
  1587.   mov    [word edi+tfunk_chan.ifreq],bx
  1588.   call   ifreq_to_rfreq
  1589.   mov    [dword edi+tfunk_chan.rfreq],eax
  1590.   call   [dword CARD_freq_convert]
  1591.   movzx  esi,[byte edi+tfunk_chan.sample]
  1592.   lea    esi,[esi*4]
  1593.   mov    eax,[dword esi+funk_info.sample_ptrs]
  1594.   add    [dword edi+tfunk_chan.start],eax
  1595.   add    [dword edi+tfunk_chan.length],eax
  1596.   mov    [dword edi+tfunk_chan.CARD_sample_ptr],eax
  1597. @@endendend:
  1598.   sti
  1599.   ret
  1600. endp
  1601.  
  1602. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1603. ;                                                                          ;
  1604. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1605. proc clr_keyboard
  1606.   mov    edi,[_0b8000h]
  1607.   add    edi,((1*2)+(42*160))+1
  1608.   mov    ch,6
  1609. @@clr_row:
  1610.   mov    cl,(12)*5
  1611. @@clr_line:
  1612.   mov    [byte edi],07h
  1613.   add    edi,2
  1614.   dec    cl
  1615.   jnz    @@clr_line
  1616.   add    edi,160-((12*2)*5)
  1617.   dec    ch
  1618.   jnz    @@clr_row
  1619.   ret
  1620. endp
  1621.  
  1622. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1623. ;                                                                          ;
  1624. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1625. proc dis_keyboard
  1626.   call   clr_keyboard
  1627.  
  1628.   movzx  ebx,[byte note]
  1629.   lea    ebx,[ebx*4]
  1630.   mov    esi,[dword ebx+dis_keyboard_map]
  1631.  
  1632.   mov    edi,[_0b8000h]
  1633.   add    edi,((1*2)+(42*160))+1
  1634.   movzx  eax,[byte octave]
  1635.   mov    ebx,eax
  1636.   shl    eax,4
  1637.   shl    ebx,3
  1638.   add    edi,eax
  1639.   add    edi,ebx
  1640. @@map_key:
  1641.   lodsb
  1642.   cmp    al,255
  1643.   je     @@done
  1644.   movzx  eax,al
  1645.   add    edi,eax
  1646.   mov    [byte edi],22h
  1647.   jmp    @@map_key
  1648. @@done:
  1649.   ret
  1650. endp
  1651.  
  1652. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1653. ;                                                                          ;
  1654. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1655. proc mus_kb_input
  1656.   cmp    al,"z"
  1657.   je     @@key1
  1658.   cmp    al,"Z"
  1659.   je     @@key1
  1660.   cmp    al,"s"
  1661.   je     @@key2
  1662.   cmp    al,"S"
  1663.   je     @@key2
  1664.   cmp    al,"x"
  1665.   je     @@key3
  1666.   cmp    al,"X"
  1667.   je     @@key3
  1668.   cmp    al,"d"
  1669.   je     @@key4
  1670.   cmp    al,"D"
  1671.   je     @@key4
  1672.   cmp    al,"c"
  1673.   je     @@key5
  1674.   cmp    al,"C"
  1675.   je     @@key5
  1676.   cmp    al,"v"
  1677.   je     @@key6
  1678.   cmp    al,"V"
  1679.   je     @@key6
  1680.   cmp    al,"g"
  1681.   je     @@key7
  1682.   cmp    al,"G"
  1683.   je     @@key7
  1684.   cmp    al,"b"
  1685.   je     @@key8
  1686.   cmp    al,"B"
  1687.   je     @@key8
  1688.   cmp    al,"h"
  1689.   je     @@key9
  1690.   cmp    al,"H"
  1691.   je     @@key9
  1692.   cmp    al,"n"
  1693.   je     @@key10
  1694.   cmp    al,"N"
  1695.   je     @@key10
  1696.   cmp    al,"j"
  1697.   je     @@key11
  1698.   cmp    al,"J"
  1699.   je     @@key11
  1700.   cmp    al,"m"
  1701.   je     @@key12
  1702.   cmp    al,"M"
  1703.   je     @@key12
  1704.   ret
  1705. @@key1:
  1706.   mov    [byte note],0
  1707.   call   enter_slot
  1708.   call   dis_keyboard
  1709.   call   play_keynote
  1710.   ret
  1711. @@key2:
  1712.   mov    [byte note],1
  1713.   call   enter_slot
  1714.   call   dis_keyboard
  1715.   call   play_keynote
  1716.   ret
  1717. @@key3:
  1718.   mov    [byte note],2
  1719.   call   enter_slot
  1720.   call   dis_keyboard
  1721.   call   play_keynote
  1722.   ret
  1723. @@key4:
  1724.   mov    [byte note],3
  1725.   call   enter_slot
  1726.   call   dis_keyboard
  1727.   call   play_keynote
  1728.   ret
  1729. @@key5:
  1730.   mov    [byte note],4
  1731.   call   enter_slot
  1732.   call   dis_keyboard
  1733.   call   play_keynote
  1734.   ret
  1735. @@key6:
  1736.   mov    [byte note],5
  1737.   call   enter_slot
  1738.   call   dis_keyboard
  1739.   call   play_keynote
  1740.   ret
  1741. @@key7:
  1742.   mov    [byte note],6
  1743.   call   enter_slot
  1744.   call   dis_keyboard
  1745.   call   play_keynote
  1746.   ret
  1747. @@key8:
  1748.   mov    [byte note],7
  1749.   call   enter_slot
  1750.   call   dis_keyboard
  1751.   call   play_keynote
  1752.   ret
  1753. @@key9:
  1754.   mov    [byte note],8
  1755.   call   enter_slot
  1756.   call   dis_keyboard
  1757.   call   play_keynote
  1758.   ret
  1759. @@key10:
  1760.   mov    [byte note],9
  1761.   call   enter_slot
  1762.   call   dis_keyboard
  1763.   call   play_keynote
  1764.   ret
  1765. @@key11:
  1766.   mov    [byte note],10
  1767.   call   enter_slot
  1768.   call   dis_keyboard
  1769.   call   play_keynote
  1770.   ret
  1771. @@key12:
  1772.   mov    [byte note],11
  1773.   call   enter_slot
  1774.   call   dis_keyboard
  1775.   call   play_keynote
  1776.   ret
  1777. endp
  1778.  
  1779. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1780. ;                                                                          ;
  1781. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1782. proc update_octave
  1783.   mov    edi,[_0b8000h]
  1784.   mov    [byte edi+((06*2)+(41*160))+1],1eh
  1785.   mov    [byte edi+((06*2)+(41*160))+3],1eh
  1786.   mov    [byte edi+((18*2)+(41*160))+1],1eh
  1787.   mov    [byte edi+((18*2)+(41*160))+3],1eh
  1788.   mov    [byte edi+((30*2)+(41*160))+1],1eh
  1789.   mov    [byte edi+((30*2)+(41*160))+3],1eh
  1790.   mov    [byte edi+((42*2)+(41*160))+1],1eh
  1791.   mov    [byte edi+((42*2)+(41*160))+3],1eh
  1792.   mov    [byte edi+((54*2)+(41*160))+1],1eh
  1793.   mov    [byte edi+((54*2)+(41*160))+3],1eh
  1794.   cmp    [byte octave],0
  1795.   je     @@oct1
  1796.   cmp    [byte octave],1
  1797.   je     @@oct2
  1798.   cmp    [byte octave],2
  1799.   je     @@oct3
  1800.   cmp    [byte octave],3
  1801.   je     @@oct4
  1802.   cmp    [byte octave],4
  1803.   je     @@oct5
  1804.   ret
  1805. @@oct1:
  1806.   mov    [byte edi+((06*2)+(41*160))+1],1fh
  1807.   mov    [byte edi+((06*2)+(41*160))+3],1fh
  1808.   ret
  1809. @@oct2:
  1810.   mov    [byte edi+((18*2)+(41*160))+1],1fh
  1811.   mov    [byte edi+((18*2)+(41*160))+3],1fh
  1812.   ret
  1813. @@oct3:
  1814.   mov    [byte edi+((30*2)+(41*160))+1],1fh
  1815.   mov    [byte edi+((30*2)+(41*160))+3],1fh
  1816.   ret
  1817. @@oct4:
  1818.   mov    [byte edi+((42*2)+(41*160))+1],1fh
  1819.   mov    [byte edi+((42*2)+(41*160))+3],1fh
  1820.   ret
  1821. @@oct5:
  1822.   mov    [byte edi+((54*2)+(41*160))+1],1fh
  1823.   mov    [byte edi+((54*2)+(41*160))+3],1fh
  1824.   ret
  1825. endp
  1826.  
  1827. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1828. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1829. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1830. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1831. ;                                                                          ;
  1832. ; file operations                                                          ;
  1833. ;                                                                          ;
  1834. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1835. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1836. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1837. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1838. proc get_directory
  1839.   mov    [byte esi],"a"
  1840.   mov    [byte esi+1],":"
  1841.   mov    [byte esi+2],"\"
  1842.   mov    [byte esi+3],0
  1843.   mov    ah,19h
  1844.   int    21h
  1845.   add    [byte esi],al
  1846.   add    esi,3
  1847.   mov    ah,47h
  1848.   xor    dl,dl
  1849.   int    21h
  1850.   ret
  1851. endp
  1852.  
  1853. ; edx = pointer to buffer
  1854. proc set_directory
  1855.   mov    ah,3bh
  1856.   push   ds
  1857.   pop    es
  1858.   int    21h
  1859.   ret
  1860. endp
  1861.  
  1862. ; ecx <- eax
  1863. proc intel_2_motorola
  1864.   mov    cl,al
  1865.   shl    ecx,8
  1866.   shr    eax,8
  1867.  
  1868.   mov    cl,al
  1869.   shl    ecx,8
  1870.   shr    eax,8
  1871.  
  1872.   mov    cl,al
  1873.   shl    ecx,8
  1874.   shr    eax,8
  1875.  
  1876.   mov    cl,al
  1877.   ret
  1878. endp
  1879.  
  1880. ; bl = 1 - get directory
  1881. proc load_fset
  1882.   xor    ebp,ebp
  1883.   mov    edi,[fdirectory_buffer]
  1884. @@l:
  1885.   cmp    [byte edi+tfdirectory.attr],0ffh
  1886.   je     @@end
  1887.   add    edi,size tfdirectory
  1888.   inc    ebp
  1889. @@end:
  1890.   mov    [@@base_entry],ebp
  1891.  
  1892.   mov    ah,4eh
  1893.   mov    ecx,10h
  1894.   int    21h
  1895.   jnc    @@load_next
  1896.   ret
  1897. @@load_next:
  1898.   mov    esi,[dword PSP_addr]
  1899.   add    esi,80h
  1900.   or     bl,bl
  1901.   jz     @@aas
  1902.   cmp    [byte esi+tdta.attr],10h
  1903.   je     @@readln
  1904.   jmp    @@next_DTA
  1905. @@aas:
  1906.   cmp    [byte esi+tdta.attr],10h
  1907.   je     @@next_DTA
  1908. @@readln:
  1909.   mov    eax,ebp
  1910.   mov    ecx,size tfdirectory
  1911.   mul    ecx
  1912.   mov    edi,[fdirectory_buffer]
  1913.   add    edi,eax
  1914.  
  1915.   mov    eax,[dword esi+tdta.fname]
  1916.   call   intel_2_motorola
  1917.   mov    edx,ecx
  1918.   mov    eax,[dword edi+tfdirectory.fname]
  1919.   call   intel_2_motorola
  1920.   cmp    edx,ecx
  1921.   ja     @@next_line
  1922. ;;;INSERT SPACE and add;;;;;;;;;;;
  1923.   mov    ecx,fdir_max_length-1
  1924.   sub    ecx,ebp
  1925.   js     @@dont_shift
  1926.   jz     @@dont_shift
  1927.  
  1928.   push   esi edi
  1929.   mov    edi,[fdirectory_buffer]
  1930.   add    edi,(size tfdirectory)*fdir_max_length
  1931.   mov    esi,edi
  1932.   sub    esi,(size tfdirectory)
  1933.   mov    eax,(size tfdirectory)
  1934.   mul    ecx
  1935.   mov    ecx,eax
  1936.   inc    ecx
  1937.   std
  1938.   rep    movsb
  1939.   cld
  1940.   pop    edi esi
  1941.  
  1942. @@dont_shift:
  1943.   mov    al,[byte esi+tdta.attr]
  1944.   mov    [byte edi+tfdirectory.attr],al
  1945.   lea    esi,[esi+tdta.fname]
  1946.   lea    edi,[edi+tfdirectory.fname]
  1947.   mov    ecx,13
  1948.   rep    movsb
  1949.   mov    ebp,[@@base_entry]
  1950.   inc    [word fdir_length]
  1951.   cmp    [word fdir_length],fdir_max_length
  1952.   jbe    @@next_DTA
  1953.   ret
  1954. ;;;NEXT LINE;;;;;;;;;;;;;;;;;;;;;;
  1955. @@next_line:
  1956.   inc    ebp
  1957.   jmp    @@load_next
  1958. @@next_DTA:
  1959.   mov    ah,4fh
  1960.   int    21h
  1961.   jnc    @@load_next
  1962.   ret
  1963. @@base_entry          dd ?
  1964. endp
  1965.  
  1966. proc load_fdirectory
  1967.   push   edx
  1968.   mov    edi,[fdirectory_buffer]
  1969.   mov    ecx,(size tfdirectory)*(fdir_max_length)
  1970.   mov    al,0ffh
  1971.   rep    stosb
  1972.   mov    [word fdir_real],0
  1973.   mov    [byte fdir_hl],0
  1974.   mov    [word fdir_length],0
  1975.   mov    bl,1
  1976.   lea    edx,[file_search_all]
  1977.   call   load_fset
  1978.   xor    bl,bl
  1979.   pop    edx
  1980.   call   load_fset
  1981.   ret
  1982. endp
  1983.  
  1984. proc display_fdir
  1985.   cmp    [word fdir_length],0
  1986.   jne    @@cont
  1987.   ret
  1988. @@cont:
  1989.   mov    dl,[byte fdir_hl]
  1990.   call   scroll_display32
  1991.   mov    eax,size tfdirectory
  1992.   mul    [word fdir_real]
  1993.   movzx  esi,ax
  1994.   add    esi,[dword fdirectory_buffer]
  1995.   mov    edi,[_0b8000h]
  1996.   add    edi,(3*2)+(2*160)
  1997.   movzx  edx,[word fdir_real]
  1998.   xor    bl,bl
  1999. @@display_loop:
  2000.   push   esi edi
  2001.   mov    ecx,19
  2002.   mov    ah,0fh
  2003.   cmp    dx,[word fdir_length]
  2004.   jae    @@paint_blank
  2005.   cmp    [byte esi+tfdirectory.attr],10h
  2006.   jne    @@dont_dd
  2007.   mov    ah,0eh
  2008. @@dont_dd:
  2009.   cmp    bl,[byte fdir_hl]
  2010.   jne    @@dont_dd2
  2011.   add    ah,70h
  2012. @@dont_dd2:
  2013.   lea    esi,[esi+tfdirectory.fname]
  2014. @@dis_name:
  2015.   lodsb
  2016.   or     al,al
  2017.   jz     @@exit_fn
  2018.   stosw
  2019.   dec    cl
  2020.   jnz    @@dis_name
  2021.   jmp    @@exit_fn
  2022. @@paint_blank:
  2023.   xor    al,al
  2024. @@exit_fn:
  2025.   rep    stosw
  2026.   pop    edi esi
  2027.   add    esi,size tfdirectory
  2028.   add    edi,160
  2029.   inc    edx
  2030.   inc    bl
  2031.   cmp    bl,32
  2032.   jb     @@display_loop
  2033.   ret
  2034. endp
  2035.  
  2036. proc goto_end_str
  2037.   xor    ebx,ebx
  2038. @@get_str_len:
  2039.   cmp    [byte edi+ebx],0
  2040.   je     @@e_get_str_len
  2041.   inc    ebx
  2042.   jmp    @@get_str_len
  2043. @@e_get_str_len:
  2044.   ret
  2045. endp
  2046.  
  2047. proc mini_trans_str
  2048. @@copy_str:
  2049.   mov    al,[byte esi]
  2050.   mov    [byte edi+ebx],al
  2051.   or     al,al
  2052.   je     @@e_copy_str
  2053.   inc    ebx
  2054.   inc    esi
  2055.   jmp    @@copy_str
  2056. @@e_copy_str:
  2057.   ret
  2058. endp
  2059.  
  2060. proc fdir_scroll_up
  2061.   cmp    [byte fdir_hl],0
  2062.   je     @@adj_real_bk
  2063.   dec    [byte fdir_hl]
  2064.   ret
  2065. @@adj_real_bk:
  2066.   cmp    [word fdir_real],0
  2067.   je     @@end
  2068.   dec    [word fdir_real]
  2069. @@end:
  2070.   ret
  2071. endp
  2072.  
  2073. proc fdir_scroll_dn
  2074.   movzx  ax,[byte fdir_hl]
  2075.   inc    ax
  2076.   cmp    [byte fdir_hl],31
  2077.   je     @@adj_real_fd
  2078.   cmp    ax,[word fdir_length]
  2079.   je     @@end
  2080.   inc    [byte fdir_hl]
  2081.   ret
  2082. @@adj_real_fd:
  2083.   add    ax,[word fdir_real]
  2084.   cmp    ax,[word fdir_length]
  2085.   je     @@end
  2086.   inc    [word fdir_real]
  2087. @@end:
  2088.   ret
  2089. endp
  2090.  
  2091. proc fdir_scroll_pageup
  2092.   mov    cl,16
  2093. @@sl:
  2094.   call   fdir_scroll_up
  2095.   dec    cl
  2096.   jnz    @@sl
  2097.   ret
  2098. endp
  2099.  
  2100. proc fdir_scroll_pagedn
  2101.   mov    cl,16
  2102. @@sl:
  2103.   call   fdir_scroll_dn
  2104.   dec    cl
  2105.   jnz    @@sl
  2106.   ret
  2107. endp
  2108.  
  2109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2110. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2112. ;                                                                          ;
  2113. ; pattern editor                                                           ;
  2114. ;                                                                          ;
  2115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2116. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2118.  
  2119. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2120. ;                                                                          ;
  2121. ; esi = pattern number, dl = chan, dh = real + hl                          ;
  2122. ;                                                                          ;
  2123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2124. proc calc_data
  2125.   mov    eax,esi                                  ; bx * 600h
  2126.   shl    eax,10
  2127.   shl    esi,9
  2128.   add    esi,eax
  2129.   movzx  eax,dh
  2130.   mov    ebx,eax
  2131.   shl    eax,4
  2132.   shl    ebx,3
  2133.   add    esi,eax
  2134.   add    esi,ebx
  2135.   movzx  eax,dl                                   ; [byte pe.chan]
  2136.   lea    eax,[eax*2+eax]
  2137.   add    esi,eax
  2138.   add    esi,[dword funk_pd_ptr]
  2139.   ret
  2140. endp
  2141.  
  2142. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2143. ;                                                                          ;
  2144. ; esi = pattern numebr, dl = chan, dh = real + hl, ch = hl                 ;
  2145. ; cl  = colour ofs                                                         ;
  2146. ;                                                                          ;
  2147. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2148. proc display_slot_f
  2149.   cmp    [byte sel_flag],0
  2150.   je     @@paint_slot
  2151.   cmp    dl,[sel_area_chan1]
  2152.   jae    @@pass1
  2153.   jmp    @@paint_slot
  2154. @@pass1:
  2155.   cmp    dl,[sel_area_chan2]
  2156.   jbe    @@pass2
  2157.   jmp    @@paint_slot
  2158. @@pass2:
  2159.   cmp    dh,[sel_area_trek1]
  2160.   jae    @@pass3
  2161.   jmp    @@paint_slot
  2162. @@pass3:
  2163.   cmp    dh,[sel_area_trek2]
  2164.   jbe    @@pass4
  2165.   jmp    @@paint_slot
  2166. @@pass4:
  2167.   cmp    si,[word sel_area_pattern]
  2168.   je     @@pass5
  2169.   jmp    @@paint_slot
  2170. @@pass5:
  2171.   add    cl,50h
  2172. @@paint_slot:
  2173.   call   calc_data
  2174.   mov    edi,[_0b8000h]                           ; calc ofs
  2175.   add    edi,(4*2)+(2*160)
  2176.   xor    eax,eax
  2177.   mov    eax,160
  2178.   mul    ch
  2179.   add    edi,eax
  2180.   mov    eax,18
  2181.   mul    dl
  2182.   add    edi,eax
  2183.   mov    al,[byte esi]
  2184.   shr    al,2
  2185.   push   eax
  2186.   cmp    al,3Fh                                   ;IF FULL SLOT or SAMPLE
  2187.   je     @@display_nullslot
  2188.   mov    bx,[word esi]                            ; display sample no
  2189.   xchg   bl,bh
  2190.   shr    bx,4
  2191.   and    bl,03fh
  2192.   mov    ah,10
  2193.   add    ah,cl
  2194.   call   display_byte_f
  2195.   jmp    @@cont
  2196. @@display_nullslot:
  2197.   mov    ah,cl
  2198.   mov    al," "
  2199.   stosw
  2200.   stosw
  2201. @@cont:
  2202.   pop    ebx
  2203.   and    ebx,03fh                                 ; display note
  2204.   mov    ah,11
  2205.   add    ah,cl
  2206.   call   display_note_f
  2207.   mov    bx,[word esi+1]
  2208.   and    bl,1111b
  2209.   mov    ah,12
  2210.   add    ah,cl
  2211.   call   display_command_f
  2212.   ret
  2213. endp
  2214.  
  2215. ; cl = colour offset
  2216. proc display_slot
  2217.   push   ecx
  2218.   movzx  esi,[byte pat_number]
  2219.   mov    dl,[byte pat_old_chan]
  2220.   mov    dh,[byte pat_real]
  2221.   mov    ch,[byte pat_old_hl]
  2222.   add    dh,ch
  2223.   xor    cl,cl
  2224.   call   display_slot_f
  2225.   pop    ecx
  2226.   movzx  esi,[byte pat_number]
  2227.   mov    dl,[byte pat_chan]
  2228.   mov    dh,[byte pat_real]
  2229.   mov    ch,[byte pat_hl]
  2230.   add    dh,ch
  2231.   call   display_slot_f
  2232.   mov    ax,[word pat_hl]
  2233.   mov    [word pat_old_hl],ax
  2234.   ret
  2235. endp
  2236.  
  2237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2238. ;                                                                          ;
  2239. ; esi = pattern number, dh = pattern real position                         ;
  2240. ;                                                                          ;
  2241. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2242. proc display_pattern
  2243.   mov    edi,[_0b8000h]
  2244.   add    edi,(1*2)+(2*160)
  2245.   xor    ch,ch
  2246. @@paint_treks:
  2247.   push   edi
  2248.   mov    ah,7
  2249.   mov    ebx,esi
  2250.   mov    al,[byte ebx+funk_hr.break_list]
  2251.   mov    bl,dh
  2252.   cmp    al,bl
  2253.   jne    @@pbbb
  2254.   mov    ah,14
  2255. @@pbbb:
  2256.   call   display_byte_f
  2257.   xor    dl,dl
  2258. @@paint_slots:
  2259.   push   esi
  2260.   xor    cl,cl
  2261.   call   display_slot_f
  2262.   pop    esi
  2263.   inc    dl
  2264.   cmp    dl,8
  2265.   jb     @@paint_slots
  2266.   pop    edi
  2267.   add    edi,160
  2268.   inc    dh
  2269.   inc    ch
  2270.   cmp    ch,32
  2271.   jb     @@paint_treks
  2272.   ret
  2273. endp
  2274.  
  2275. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2276. ;                                                                          ;
  2277. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2278. proc pat_scroll_up
  2279.   cmp    [byte pat_hl],0
  2280.   je     @@adj_real_bk
  2281.   dec    [byte pat_hl]
  2282.   jmp    @@end
  2283. @@adj_real_bk:
  2284.   cmp    [byte pat_real],0
  2285.   je     @@end
  2286.   dec    [byte pat_real]
  2287.   movzx  esi,[byte pat_number]
  2288.   mov    dh,[byte pat_real]
  2289.   call   display_pattern
  2290. @@end:
  2291.   mov    cl,20h
  2292.   call   display_slot
  2293.   ret
  2294. endp
  2295.  
  2296. proc pat_scroll_dn
  2297.   cmp    [byte pat_hl],31
  2298.   je     @@adj_real_fd
  2299.   inc    [byte pat_hl]
  2300.   jmp    @@end
  2301. @@adj_real_fd:
  2302.   cmp    [byte pat_real],(64-32)                  ; 32
  2303.   je     @@end
  2304.   inc    [byte pat_real]
  2305.   movzx  esi,[byte pat_number]
  2306.   mov    dh,[byte pat_real]
  2307.   call   display_pattern
  2308. @@end:
  2309.   mov    cl,20h
  2310.   call   display_slot
  2311.   ret
  2312. endp
  2313.  
  2314. proc pat_pageup
  2315.   mov    cl,16
  2316. @@scl:
  2317.   cmp    [byte pat_hl],0
  2318.   je     @@adj_real_bk
  2319.   dec    [byte pat_hl]
  2320.   jmp    @@end
  2321. @@adj_real_bk:
  2322.   cmp    [byte pat_real],0
  2323.   je     @@end
  2324.   dec    [byte pat_real]
  2325. @@end:
  2326.   dec    cl
  2327.   jnz    @@scl
  2328.   movzx  esi,[byte pat_number]
  2329.   mov    dh,[byte byte pat_real]
  2330.   call   display_pattern
  2331.   mov    cl,20h
  2332.   call   display_slot
  2333.   ret
  2334. endp
  2335.  
  2336. proc pat_pagedn
  2337.   mov    cl,16
  2338. @@scl:
  2339.   cmp    [byte pat_hl],31
  2340.   je     @@adj_real_fd
  2341.   inc    [byte pat_hl]
  2342.   jmp    @@end
  2343. @@adj_real_fd:
  2344.   cmp    [byte pat_real],(64-32)                  ; 32
  2345.   je     @@end
  2346.   inc    [byte pat_real]
  2347. @@end:
  2348.   dec    cl
  2349.   jnz    @@scl
  2350.   movzx  esi,[byte pat_number]
  2351.   mov    dh,[byte pat_real]
  2352.   call   display_pattern
  2353.   mov    cl,20h
  2354.   call   display_slot
  2355.   ret
  2356. endp
  2357.  
  2358. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2359. ;                                                                          ;
  2360. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2361. proc set_select_start
  2362.   mov    [byte sel_flag],1
  2363.   mov    al,[byte pat_number]
  2364.   mov    [byte sel_area_pattern],al
  2365.   mov    al,[byte pat_chan]
  2366.   mov    [byte sel_area_chan1],al
  2367.   mov    [byte sel_area_chan2],al
  2368.   mov    al,[byte pat_real]
  2369.   add    al,[byte pat_hl]
  2370.   mov    [byte sel_area_trek1],al
  2371.   mov    [byte sel_area_trek2],al
  2372.   movzx  esi,[byte pat_number]
  2373.   mov    dh,[byte pat_real]
  2374.   call   display_pattern
  2375.   mov    cl,20h
  2376.   call   display_slot
  2377.   ret
  2378. endp
  2379.  
  2380. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2381. ;                                                                          ;
  2382. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2383. proc set_select_end
  2384.   cmp    [byte sel_flag],0
  2385.   je     @@end
  2386.   mov    al,[byte pat_number]
  2387.   mov    [byte sel_area_pattern],al
  2388.   mov    al,[byte pat_chan]
  2389.   mov    [byte sel_area_chan2],al
  2390.   mov    al,[byte pat_real]
  2391.   add    al,[byte pat_hl]
  2392.   mov    [byte sel_area_trek2],al
  2393.   mov    al,[byte sel_area_chan1]
  2394.   cmp    al,[byte sel_area_chan2]
  2395.   jbe    @@test1
  2396.   xchg   al,[byte sel_area_chan2]
  2397.   mov    [byte sel_area_chan1],al
  2398. @@test1:
  2399.   mov    al,[byte sel_area_trek1]
  2400.   cmp    al,[byte sel_area_trek2]
  2401.   jbe    @@test2
  2402.   xchg   al,[byte sel_area_trek2]
  2403.   mov    [byte sel_area_trek1],al
  2404. @@test2:
  2405.   movzx  esi,[byte pat_number]
  2406.   mov    dh,[byte pat_real]
  2407.   call   display_pattern
  2408.   mov    cl,20h
  2409.   call   display_slot
  2410. @@end:
  2411.   ret
  2412. endp
  2413.  
  2414. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2415. ;                                                                          ;
  2416. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2417. proc copy_select
  2418.   cmp    [byte sel_flag],0
  2419.   je     @@end
  2420.   mov    [byte sel_flag],0
  2421.   mov    [byte copied_flag],1
  2422.   mov    eax,[dword sel_area_chan1]
  2423.   mov    [dword copied_area_chan1],eax
  2424.   movzx  esi,[byte pat_number]
  2425.   mov    eax,esi                                  ; bx * 600h
  2426.   shl    eax,10
  2427.   shl    esi,9
  2428.   add    esi,eax
  2429.   add    esi,[dword funk_pd_ptr]
  2430.   lea    edi,[temp_pattern]
  2431.   mov    ecx,600h
  2432.   rep    movsb
  2433.   movzx  esi,[byte pat_number]
  2434.   mov    dh,[byte pat_real]
  2435.   call   display_pattern
  2436.   mov    cl,20h
  2437.   call   display_slot
  2438. @@end:
  2439.   ret
  2440. endp
  2441.  
  2442. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2443. ;                                                                          ;
  2444. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2445. proc paste_select
  2446.   cmp    [byte copied_flag],0
  2447.   je     @@end
  2448.   mov    dh,[byte copied_area_trek1]
  2449. @@copy_trek:
  2450.   mov    dl,[byte copied_area_chan1]
  2451. @@copy_slot:
  2452.   push   edx
  2453.   lea    edi,[temp_pattern]
  2454.   movzx  eax,dh
  2455.   mov    ebx,eax
  2456.   shl    eax,4
  2457.   shl    ebx,3
  2458.   add    edi,eax
  2459.   add    edi,ebx
  2460.   movzx  eax,dl
  2461.   lea    eax,[eax*2+eax]
  2462.   add    edi,eax
  2463.   sub    dh,[byte copied_area_trek1]
  2464.   sub    dl,[byte copied_area_chan1]
  2465.   add    dh,[byte pat_real]
  2466.   add    dh,[byte pat_hl]
  2467.   add    dl,[byte pat_chan]
  2468.   cmp    dl,7
  2469.   ja     @@ignore_paste
  2470.   cmp    dh,03fh
  2471.   ja     @@ignore_paste
  2472.   movzx  esi,[byte pat_number]
  2473.   call   calc_data
  2474.   mov    ax,[word edi]
  2475.   mov    bl,[byte edi+2]
  2476.   mov    [word esi],ax
  2477.   mov    [byte esi+2],bl
  2478. @@ignore_paste:
  2479.   pop    edx
  2480.   inc    dl
  2481.   cmp    dl,[copied_area_chan2]
  2482.   jbe    @@copy_slot
  2483.   inc    dh
  2484.   cmp    dh,[byte copied_area_trek2]
  2485.   jbe    @@copy_trek
  2486.   movzx  esi,[byte pat_number]
  2487.   mov    dh,[byte pat_real]
  2488.   call   display_pattern
  2489.   mov    cl,20h
  2490.   call   display_slot
  2491. @@end:
  2492.   ret
  2493. endp
  2494.  
  2495. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2496. ;                                                                          ;
  2497. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2498. proc clear_select
  2499.   cmp    [byte sel_flag],0
  2500.   je     @@end
  2501.   mov    [byte sel_flag],0
  2502.   mov    dh,[byte sel_area_trek1]
  2503. @@copy_trek:
  2504.   mov    dl,[byte sel_area_chan1]
  2505. @@copy_slot:
  2506.   push   edx
  2507.   movzx  esi,[byte pat_number]
  2508.   call   calc_data
  2509.   @mini_clear_slot
  2510. @@ignore_paste:
  2511.   pop    edx
  2512.   inc    dl
  2513.   cmp    dl,[sel_area_chan2]
  2514.   jbe    @@copy_slot
  2515.   inc    dh
  2516.   cmp    dh,[byte sel_area_trek2]
  2517.   jbe    @@copy_trek
  2518.   movzx  esi,[byte pat_number]
  2519.   mov    dh,[byte pat_real]
  2520.   call   display_pattern
  2521.   mov    cl,20h
  2522.   call   display_slot
  2523. @@end:
  2524.   ret
  2525. endp
  2526.  
  2527. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2528. ;                                                                          ;
  2529. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2530. proc enter_slot
  2531.   cmp    [byte edit_mode],1
  2532.   je     @@pe
  2533.   ret
  2534. @@pe:
  2535.   movzx  esi,[byte pat_number]
  2536.   mov    dl,[byte pat_chan]
  2537.   mov    dh,[byte pat_real]
  2538.   add    dh,[byte pat_hl]
  2539.   call   calc_data
  2540.   mov    al,[byte octave]
  2541.   mov    bl,al
  2542.   shl    al,3
  2543.   shl    bl,2
  2544.   add    al,bl
  2545.   add    al,[byte note]
  2546.   mov    [byte esi],al
  2547.   shl    [byte esi],2
  2548.   mov    al,[byte sam_real]
  2549.   add    al,[byte sam_hl]
  2550.   push   eax
  2551.   shr    al,4
  2552.   or     [byte esi],al
  2553.   pop    eax
  2554.   shl    al,4
  2555.   or     al,0fh
  2556.   mov    [byte esi+1],al
  2557.   mov    [byte esi+2],0
  2558.   call   pat_scroll_dn
  2559.   ret
  2560. endp
  2561.  
  2562. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2563. ;                                                                          ;
  2564. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2565. proc erase_slot
  2566.   movzx  esi,[byte pat_number]
  2567.   mov    dl,[byte pat_chan]
  2568.   mov    dh,[byte pat_real]
  2569.   add    dh,[byte pat_hl]
  2570.   call   calc_data
  2571.   @mini_clear_slot
  2572.   call   pat_scroll_dn
  2573.   ret
  2574. endp
  2575.  
  2576. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2577. ;                                                                          ;
  2578. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2579. proc insert_slot
  2580.   mov    dh,[byte pat_real]
  2581.   add    dh,[byte pat_hl]
  2582.   cmp    dh,03fh
  2583.   je     @@dont_ad
  2584.   movzx  esi,[byte pat_number]
  2585.   mov    dl,[byte pat_chan]
  2586.   mov    ch,dh
  2587.   mov    dh,03fh
  2588.   call   calc_data
  2589. @@add_loop:
  2590.   mov    ax,[word esi-24]
  2591.   mov    [word esi],ax
  2592.   mov    al,[byte esi-22]
  2593.   mov    [byte esi+2],al
  2594.   dec    dh
  2595.   sub    esi,24
  2596.   cmp    dh,ch
  2597.   ja     @@add_loop
  2598. @@dont_ad:
  2599.   movzx  esi,[byte pat_number]
  2600.   mov    dl,[byte pat_chan]
  2601.   mov    dh,[byte pat_real]
  2602.   add    dh,[byte pat_hl]
  2603.   call   calc_data
  2604.   @mini_clear_slot
  2605.   movzx  esi,[byte pat_number]
  2606.   mov    dh,[byte pat_real]
  2607.   call   display_pattern
  2608.   mov    cl,20h
  2609.   call   display_slot
  2610.   ret
  2611. endp
  2612.  
  2613. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2614. ;                                                                          ;
  2615. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2616. proc delete_slot
  2617.   movzx  esi,[byte pat_number]
  2618.   mov    dl,[byte pat_chan]
  2619.   mov    dh,[byte pat_real]
  2620.   add    dh,[byte pat_hl]
  2621.   call   calc_data
  2622.   cmp    dh,03fh
  2623.   je     @@dont_ad
  2624. @@del_loop:
  2625.   mov    ax,[word esi+24]
  2626.   mov    [word esi],ax
  2627.   mov    al,[byte esi+26]
  2628.   mov    [byte esi+2],al
  2629.   inc    dh
  2630.   add    esi,24
  2631.   cmp    dh,3fh
  2632.   jb     @@del_loop
  2633. @@dont_ad:
  2634.   @mini_clear_slot
  2635.   movzx  esi,[byte pat_number]
  2636.   mov    dh,[byte pat_real]
  2637.   call   display_pattern
  2638.   mov    cl,20h
  2639.   call   display_slot
  2640.   ret
  2641. endp
  2642.  
  2643. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2644. ;                                                                          ;
  2645. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2646. proc setto_ReLOad_slot
  2647.   movzx  esi,[byte pat_number]
  2648.   mov    dl,[byte pat_chan]
  2649.   mov    dh,[byte pat_real]
  2650.   add    dh,[byte pat_hl]
  2651.   call   calc_data
  2652.   @mini_clear_slot
  2653.   mov    [byte esi],0f4h
  2654.   call   pat_scroll_dn
  2655.   ret
  2656. endp
  2657.  
  2658. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2659. ;                                                                          ;
  2660. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2661. proc enter_sample
  2662.   mov    ch,2
  2663.   mov    dh,[byte pat_hl]
  2664.   add    dh,2
  2665.   mov    dl,[byte pat_chan]
  2666.   shl    dl,3
  2667.   add    dl,[byte pat_chan]
  2668.   add    dl,4
  2669.   call   get_input
  2670.   jc     @@abort
  2671.   movzx  esi,[byte pat_number]
  2672.   mov    dl,[byte pat_chan]
  2673.   mov    dh,[byte pat_real]
  2674.   add    dh,[byte pat_hl]
  2675.   call   calc_data
  2676.   call   get_ibyte
  2677.   cmp    al,40h
  2678.   jb     @@ovs
  2679.   xor    al,al
  2680. @@ovs:
  2681.   mov    bl,[byte esi]
  2682.   shr    bl,2
  2683.   cmp    bl,3fh
  2684.   je     @@con_sample_only
  2685.   and    [byte esi],11111100b
  2686.   jmp    @@set_sample
  2687. @@con_sample_only:
  2688.   mov    [byte esi],0f8h
  2689. @@set_sample:
  2690.   mov    bl,al
  2691.   shr    bl,4
  2692.   shl    al,4
  2693.   or     [byte esi],bl
  2694.   and    [byte esi+1],1111b
  2695.   or     [byte esi+1],al
  2696. @@abort:
  2697.   mov    cl,20h
  2698.   call   display_slot
  2699.   ret
  2700. endp
  2701.  
  2702. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2703. ;                                                                          ;
  2704. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2705. proc enter_command
  2706. @@repeat:
  2707.   mov    ch,3
  2708.   mov    dh,[byte pat_hl]
  2709.   add    dh,2
  2710.   mov    dl,[byte pat_chan]
  2711.   shl    dl,3
  2712.   add    dl,[byte pat_chan]
  2713.   add    dl,9
  2714.   call   get_input
  2715.   jc     @@abort
  2716.   movzx  esi,[byte pat_number]
  2717.   mov    dl,[byte pat_chan]
  2718.   mov    dh,[byte pat_real]
  2719.   add    dh,[byte pat_hl]
  2720.   call   calc_data
  2721.   cmp    [byte edi],"?"                                ; help function
  2722.   je     @@help
  2723.   jmp    @@cont
  2724. @@help:
  2725.   mov    ecx,comms_screen_size
  2726.   lea    esi,[comms_screen]
  2727.   call   help_scroll
  2728.   jmp    @@repeat
  2729. @@cont:
  2730.   xor    ebx,ebx
  2731. @@find_com_loop:
  2732.   mov    al,[byte ebx+@@coms_test1]
  2733.   cmp    al,[byte edi]
  2734.   je     @@com_found
  2735.   add    al,("a"-"A")
  2736.   cmp    al,[byte edi]
  2737.   je     @@com_found
  2738.   inc    ebx
  2739.   cmp    ebx,15
  2740.   jb     @@find_com_loop
  2741.   and    [byte esi+1],11110000b
  2742.   or     [byte esi+1],00001111b
  2743.   mov    [byte esi+2],0
  2744.   jmp    @@abort
  2745. @@com_found:
  2746.   and    [byte esi+1],11110000b
  2747.   or     [byte esi+1],bl
  2748.   add    edi,2
  2749.   call   get_ibyte
  2750.   mov    [byte esi+2],al
  2751. @@abort:
  2752.   mov    cl,20h
  2753.   call   display_slot
  2754.   ret
  2755. @@coms_test1:
  2756.   db     "ABCDEFGHIJKLMNO"
  2757. endp
  2758.  
  2759. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2760. ;                                                                          ;
  2761. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2762. proc display_seqlist
  2763.   mov    dl,[byte seq_real]
  2764.   add    dl,[byte seq_hl]
  2765.   shr    dl,3
  2766.   call   scroll_display32
  2767.   mov    edi,[_0b8000h]
  2768.   add    edi,(76*2)+(2*160)
  2769.   xor    cl,cl
  2770. @@display_seq:
  2771.   push   edi
  2772.   mov    ah,7
  2773.   cmp    cl,[byte seq_hl]
  2774.   jne    @@pbbb
  2775.   mov    ah,14
  2776. @@pbbb:
  2777.   mov    bl,cl
  2778.   add    bl,[byte seq_real]
  2779.   cmp    bl,[byte funk_hr.loop_order]
  2780.   jne    @@pbbb2
  2781.   dec    ah
  2782. @@pbbb2:
  2783.   movzx  ebx,[byte seq_real]
  2784.   add    bl,cl
  2785.   mov    bl,[byte ebx+funk_hr.order_list]
  2786.   cmp    bl,0ffh
  2787.   je     @@display_null
  2788.   call   display_byte_f
  2789.   jmp    @@cont
  2790. @@display_null:
  2791.   mov    al,"-"
  2792.   stosw
  2793.   stosw
  2794. @@cont:
  2795.   pop    edi
  2796.   add    edi,160
  2797.   inc    cl
  2798.   cmp    cl,32
  2799.   jb     @@display_seq
  2800.   ret
  2801. endp
  2802.  
  2803. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2804. ;                                                                          ;
  2805. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2806. proc seq_scroll_up
  2807.   cmp    [byte seq_hl],0
  2808.   je     @@adj_real_bk
  2809.   dec    [byte seq_hl]
  2810.   jmp    @@end
  2811. @@adj_real_bk:
  2812.   cmp    [byte seq_real],0
  2813.   je     @@end
  2814.   dec    [byte seq_real]
  2815. @@end:
  2816.   call   display_seqlist
  2817.   ret
  2818. endp
  2819.  
  2820. proc seq_scroll_dn
  2821.   cmp    [byte seq_hl],31
  2822.   je     @@adj_real_fd
  2823.   inc    [byte seq_hl]
  2824.   jmp    @@end
  2825. @@adj_real_fd:
  2826.   cmp    [byte seq_real],(256-32)
  2827.   je     @@end
  2828.   inc    [byte seq_real]
  2829. @@end:
  2830.   call   display_seqlist
  2831.   ret
  2832. endp
  2833.  
  2834. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2835. ;                                                                          ;
  2836. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2837. proc seq_add
  2838.   mov    dl,[byte seq_real]
  2839.   add    dl,[byte seq_hl]
  2840.   movzx  edx,dl
  2841.   cmp    dl,0ffh
  2842.   je     @@dont_ad
  2843.   mov    ebx,0ffh
  2844. @@add_loop:
  2845.   mov    al,[byte ebx+(offset funk_hr.order_list-1)]
  2846.   mov    [byte ebx+funk_hr.order_list],al
  2847.   dec    ebx
  2848.   cmp    ebx,edx
  2849.   ja     @@add_loop
  2850. @@dont_ad:
  2851.   mov    al,[byte pat_number]
  2852.   mov    [byte edx+funk_hr.order_list],al
  2853.   call   seq_scroll_dn
  2854.   ret
  2855. endp
  2856.  
  2857. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2858. ;                                                                          ;
  2859. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2860. proc seq_del
  2861.   call   seq_scroll_up
  2862.   mov    bl,[byte seq_real]
  2863.   add    bl,[byte seq_hl]
  2864.   movzx  ebx,bl
  2865.   cmp    bl,0ffh
  2866.   je     @@dont_ad
  2867. @@del_loop:
  2868.   mov    al,[byte ebx+(offset funk_hr.order_list+1)]
  2869.   mov    [byte ebx+funk_hr.order_list],al
  2870.   inc    ebx
  2871.   cmp    ebx,0ffh
  2872.   jb     @@del_loop
  2873. @@dont_ad:
  2874.   mov    [byte ebx+funk_hr.order_list],0ffh
  2875.   call   display_seqlist
  2876.   ret
  2877. endp
  2878.  
  2879. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2880. ;                                                                          ;
  2881. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2882. proc dis_sample_name
  2883.   mov    edi,(17*2)+(36*160)
  2884.   mov    bl,[byte sam_hl]
  2885.   add    bl,[byte sam_real]
  2886.   mov    ah,13h
  2887.   call   display_byte
  2888.   mov    al,[byte sam_hl]
  2889.   add    al,[byte sam_real]
  2890.   movzx  esi,al
  2891.   shl    esi,5
  2892.   add    esi,offset funk_sb
  2893.   mov    edi,(20*2)+(36*160)
  2894.   mov    cl,19
  2895.   mov    ah,13h
  2896.   call   byte_write2
  2897. endp
  2898.  
  2899. proc dis_pattern_no
  2900.   mov    edi,(55*2)+(36*160)
  2901.   mov    bl,[byte pat_number]
  2902.   mov    ah,13h
  2903.   call   display_byte
  2904.   mov    edi,(1*2)+(1*160)
  2905.   mov    bl,[byte pat_number]
  2906.   mov    ah,0fh
  2907.   call   display_byte
  2908.   ret
  2909. endp
  2910.  
  2911. proc dis_order_loop
  2912.   mov    edi,(17*2)+(37*160)
  2913.   mov    bl,[byte funk_hr.loop_order]
  2914.   mov    ah,13h
  2915.   call   display_byte
  2916.   ret
  2917. endp
  2918.  
  2919. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2920. ;                                                                          ;
  2921. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2922. proc edit_order_loop
  2923.   mov    al,[byte seq_real]
  2924.   add    al,[byte seq_hl]
  2925.   mov    [byte funk_hr.loop_order],al
  2926.   call   display_seqlist
  2927.   call   dis_order_loop
  2928.   ret
  2929. endp
  2930.  
  2931. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2932. ;                                                                          ;
  2933. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2934. proc dis_chan_status
  2935.   mov    edi,[_0b8000h]
  2936.   add    edi,(7*2)+(1*160)+1
  2937.  
  2938.   lea    esi,[funk_chan1]
  2939.   mov    cl,8
  2940. @@discs:
  2941.   mov    al,07h
  2942.   cmp    [byte esi+tfunk_chan.channel_kill],PLAY
  2943.   jne    @@dont_ad
  2944.   mov    al,0ch
  2945. @@dont_ad:
  2946.   mov    [byte edi],al
  2947.   mov    [byte edi+2],al
  2948.   add    esi,size tfunk_chan
  2949.   add    edi,9*2
  2950.   dec    cl
  2951.   jnz    @@discs
  2952.   ret
  2953. endp
  2954.  
  2955. proc channel_toggle
  2956.   cmp    al,"1"
  2957.   je     @@toggle1
  2958.   cmp    al,"2"
  2959.   je     @@toggle2
  2960.   cmp    al,"3"
  2961.   je     @@toggle3
  2962.   cmp    al,"4"
  2963.   je     @@toggle4
  2964.   cmp    al,"5"
  2965.   je     @@toggle5
  2966.   cmp    al,"6"
  2967.   je     @@toggle6
  2968.   cmp    al,"7"
  2969.   je     @@toggle7
  2970.   cmp    al,"8"
  2971.   je     @@toggle8
  2972.   ret
  2973. @@toggle1:
  2974.   xor    [byte funk_chan1.channel_kill],PLAY
  2975.   mov    edi,offset funk_chan1
  2976.   call   [dword CARD_volume_convert]
  2977.   call   dis_chan_status
  2978.   ret
  2979. @@toggle2:
  2980.   xor    [byte funk_chan2.channel_kill],PLAY
  2981.   mov    edi,offset funk_chan2
  2982.   call   [dword CARD_volume_convert]
  2983.   call   dis_chan_status
  2984.   ret
  2985. @@toggle3:
  2986.   xor    [byte funk_chan3.channel_kill],PLAY
  2987.   mov    edi,offset funk_chan3
  2988.   call   [dword CARD_volume_convert]
  2989.   call   dis_chan_status
  2990.   ret
  2991. @@toggle4:
  2992.   xor    [byte funk_chan4.channel_kill],PLAY
  2993.   mov    edi,offset funk_chan4
  2994.   call   [dword CARD_volume_convert]
  2995.   call   dis_chan_status
  2996.   ret
  2997. @@toggle5:
  2998.   xor    [byte funk_chan5.channel_kill],PLAY
  2999.   mov    edi,offset funk_chan5
  3000.   call   [dword CARD_volume_convert]
  3001.   call   dis_chan_status
  3002.   ret
  3003. @@toggle6:
  3004.   xor    [byte funk_chan6.channel_kill],PLAY
  3005.   mov    edi,offset funk_chan6
  3006.   call   [dword CARD_volume_convert]
  3007.   call   dis_chan_status
  3008.   ret
  3009. @@toggle7:
  3010.   xor    [byte funk_chan7.channel_kill],PLAY
  3011.   mov    edi,offset funk_chan7
  3012.   call   [dword CARD_volume_convert]
  3013.   call   dis_chan_status
  3014.   ret
  3015. @@toggle8:
  3016.   xor    [byte funk_chan8.channel_kill],PLAY
  3017.   mov    edi,offset funk_chan8
  3018.   call   [dword CARD_volume_convert]
  3019.   call   dis_chan_status
  3020.   ret
  3021. endp
  3022.  
  3023. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3024. ;                                                                          ;
  3025. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3026. proc pe_handle
  3027.   cmp    ax,kb_up
  3028.   je     @@hkb_up
  3029.   cmp    ax,kb_down
  3030.   je     @@hkb_down
  3031.   cmp    ax,kb_left
  3032.   je     @@hkb_left
  3033.   cmp    ax,kb_right
  3034.   je     @@hkb_right
  3035.   push   eax
  3036.   call   mus_kb_input
  3037.   pop    eax
  3038.   cmp    ax,kb_altb
  3039.   je     @@select_start
  3040.   cmp    ax,kb_alte
  3041.   je     @@select_end
  3042.   cmp    ax,kb_altc
  3043.   je     @@copy_sel
  3044.   cmp    ax,kb_alto
  3045.   je     @@paste_sel
  3046.   cmp    ax,kb_altz
  3047.   je     @@clear_sel
  3048.   cmp    al," "
  3049.   je     @@erase_slot
  3050.   cmp    al,"/"
  3051.   je     @@dec_oct
  3052.   cmp    al,"*"
  3053.   je     @@inc_oct
  3054.   cmp    al,"-"
  3055.   je     @@dec_pat
  3056.   cmp    al,"+"
  3057.   je     @@inc_pat
  3058.   cmp    al,13
  3059.   je     @@set_bp
  3060.   cmp    al,"'"
  3061.   je     @@set_RLO
  3062.   cmp    al,"["
  3063.   je     @@edits
  3064.   cmp    al,"]"
  3065.   je     @@editc
  3066.   cmp    ax,kb_home
  3067.   je     @@hkb_home
  3068.   cmp    ax,kb_end
  3069.   je     @@hkb_end
  3070.   cmp    al,"9"
  3071.   je     @@seqadd
  3072.   cmp    al,"0"
  3073.   je     @@seqdel
  3074.   cmp    ax,kb_pageup
  3075.   je     @@hkb_pageup
  3076.   cmp    ax,kb_pagedn
  3077.   je     @@hkb_pagedn
  3078.   cmp    ax,kb_insert
  3079.   je     @@insert_slot
  3080.   cmp    ax,kb_delete
  3081.   je     @@delete_slot
  3082.   cmp    al,'p'
  3083.   je     @@inc_sam
  3084.   cmp    al,'o'
  3085.   je     @@dec_sam
  3086.   cmp    ax,kb_alts
  3087.   je     @@edit_ol
  3088.   call   channel_toggle
  3089.   jmp    @@input_loop
  3090. @@hkb_up:
  3091.   call   pat_scroll_up
  3092.   jmp    @@input_loop
  3093. @@hkb_down:
  3094.   call   pat_scroll_dn
  3095.   jmp    @@input_loop
  3096. @@hkb_left:
  3097.   cmp    [byte pat_chan],0
  3098.   je     @@input_loop
  3099.   dec    [byte pat_chan]
  3100.   mov    cl,20h
  3101.   call   display_slot
  3102.   jmp    @@input_loop
  3103. @@hkb_right:
  3104.   cmp    [byte pat_chan],7
  3105.   je     @@input_loop
  3106.   inc    [byte pat_chan]
  3107.   mov    cl,20h
  3108.   call   display_slot
  3109.   jmp    @@input_loop
  3110. @@select_start:
  3111.   call   set_select_start
  3112.   jmp    @@input_loop
  3113. @@select_end:
  3114.   call   set_select_end
  3115.   jmp    @@input_loop
  3116. @@copy_sel:
  3117.   call   copy_select
  3118.   jmp    @@input_loop
  3119. @@paste_sel:
  3120.   call   paste_select
  3121.   jmp    @@input_loop
  3122. @@clear_sel:
  3123.   call   clear_select
  3124.   jmp    @@input_loop
  3125. @@erase_slot:
  3126.   call   erase_slot
  3127.   jmp    @@input_loop
  3128. @@dec_oct:
  3129.   cmp    [byte octave],0
  3130.   je     @@input_loop
  3131.   dec    [byte octave]
  3132.   call   update_octave
  3133.   jmp    @@input_loop
  3134. @@inc_oct:
  3135.   cmp    [byte octave],4
  3136.   je     @@input_loop
  3137.   inc    [byte octave]
  3138.   call   update_octave
  3139.   jmp    @@input_loop
  3140. @@dec_pat:
  3141.   cmp    [byte pat_number],0
  3142.   je     @@input_loop
  3143.   dec    [byte pat_number]
  3144.   call   dis_pattern_no
  3145.   movzx  esi,[byte pat_number]
  3146.   mov    dh,[byte pat_real]
  3147.   call   display_pattern
  3148.   mov    cl,20h
  3149.   call   display_slot
  3150.   jmp    @@input_loop
  3151. @@inc_pat:
  3152.   cmp    [byte pat_number],07fh
  3153.   je     @@input_loop
  3154.   inc    [byte pat_number]
  3155.   call   dis_pattern_no
  3156.   movzx  esi,[byte pat_number]
  3157.   mov    dh,[byte pat_real]
  3158.   call   display_pattern
  3159.   mov    cl,20h
  3160.   call   display_slot
  3161.   jmp    @@input_loop
  3162. @@set_bp:
  3163.   mov    al,[byte pat_real]
  3164.   add    al,[byte pat_hl]
  3165.   movzx  ebx,[byte pat_number]
  3166.   mov    [byte ebx+funk_hr.break_list],al
  3167.   movzx  esi,[byte pat_number]
  3168.   mov    dh,[byte pat_real]
  3169.   call   display_pattern
  3170.   mov    cl,20h
  3171.   call   display_slot
  3172.   jmp    @@input_loop
  3173. @@set_RLO:
  3174.   call   setto_ReLOad_slot
  3175.   jmp    @@input_loop
  3176. @@edits:
  3177.   call   enter_sample
  3178.   jmp    @@input_loop
  3179. @@editc:
  3180.   call   enter_command
  3181.   jmp    @@input_loop
  3182. @@hkb_home:
  3183.   call   seq_scroll_up
  3184.   jmp    @@input_loop
  3185. @@hkb_end:
  3186.   call   seq_scroll_dn
  3187.   jmp    @@input_loop
  3188. @@seqadd:
  3189.   call   seq_add
  3190.   jmp    @@input_loop
  3191. @@seqdel:
  3192.   call   seq_del
  3193.   jmp    @@input_loop
  3194. @@hkb_pageup:
  3195.   call   pat_pageup
  3196.   jmp    @@input_loop
  3197. @@hkb_pagedn:
  3198.   call   pat_pagedn
  3199.   jmp    @@input_loop
  3200. @@insert_slot:
  3201.   call   insert_slot
  3202.   jmp    @@input_loop
  3203. @@delete_slot:
  3204.   call   delete_slot
  3205.   jmp    @@input_loop
  3206. @@inc_sam:
  3207.   call   sam_scroll_dn
  3208.   call   dis_sample_name
  3209.   jmp    @@input_loop
  3210. @@dec_sam:
  3211.   call   sam_scroll_up
  3212.   call   dis_sample_name
  3213.   jmp    @@input_loop
  3214. @@edit_ol:
  3215.   call   edit_order_loop
  3216. @@input_loop:
  3217.   ret
  3218. endp
  3219.  
  3220. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3221. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3222. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3223. ;                                                                          ;
  3224. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3225. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3227.  
  3228. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3229. ;                                                                          ;
  3230. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3231. macro @hl_field n
  3232. local @@dont_hl
  3233.   mov    ah,03h
  3234.   mov    cl,[byte @@line]
  3235.   cmp    cl,[byte sam_hl]
  3236.   jne    @@dont_hl
  3237.   mov    ah,03bh
  3238.   cmp    [byte sam_col],n
  3239.   jne    @@dont_hl
  3240.   add    ah,11h
  3241. @@dont_hl:
  3242. endm
  3243.  
  3244. proc display_samples
  3245.   mov    dl,[byte sam_real]
  3246.   add    dl,[byte sam_hl]
  3247.   shr    dl,1
  3248.   call   scroll_display32
  3249.   mov    [byte @@line],0
  3250.   xor    edx,edx
  3251.   movzx  esi,[byte sam_real]
  3252.   shl    esi,5
  3253.   add    esi,offset funk_sb
  3254. @@display_treks:
  3255.   mov    ah,03h
  3256.   mov    cl,[byte @@line]
  3257.   cmp    cl,[byte sam_hl]
  3258.   jne    @@dont_hl
  3259.   mov    ah,03bh
  3260. @@dont_hl:
  3261.   mov    edi,(3*2)+(2*160)
  3262.   add    edi,edx
  3263.   mov    bl,[byte @@line]
  3264.   add    bl,[byte sam_real]
  3265.   call   display_byte
  3266.   @hl_field 0
  3267.   push   esi
  3268.   mov    edi,(8*2)+(2*160)
  3269.   add    edi,edx
  3270.   add    edi,[_0b8000h]
  3271.   mov    ch,19
  3272.   lea    esi,[esi+tfunk_sb.sname]
  3273. @@dis_sname:
  3274.   lodsb
  3275.   stosw
  3276.   dec    ch
  3277.   jnz    @@dis_sname
  3278.   pop    esi
  3279.   @hl_field 1
  3280.   mov    edi,(29*2)+(2*160)
  3281.   add    edi,edx
  3282.   mov    ecx,[dword esi+tfunk_sb.start]
  3283.   call   display_dword
  3284.   mov    edi,(39*2)+(2*160)
  3285.   add    edi,edx
  3286.   mov    ecx,[dword esi+tfunk_sb.length]
  3287.   call   display_dword
  3288.   @hl_field 2
  3289.   mov    edi,(49*2)+(2*160)
  3290.   add    edi,edx
  3291.   mov    bl,[byte esi+tfunk_sb.volume]
  3292.   call   display_byte
  3293.   @hl_field 3
  3294.   mov    edi,(53*2)+(2*160)
  3295.   add    edi,edx
  3296.   mov    bl,[byte esi+tfunk_sb.balance]
  3297.   call   display_byte
  3298.   @hl_field 4
  3299.   mov    edi,(57*2)+(2*160)
  3300.   add    edi,edx
  3301.   mov    bl,[byte esi+tfunk_sb.pt_and_sop]
  3302.   shr    bl,4
  3303.   call   display_nibble
  3304.   @hl_field 5
  3305.   mov    edi,(60*2)+(2*160)
  3306.   add    edi,edx
  3307.   mov    bl,[byte esi+tfunk_sb.pt_and_sop]
  3308.   call   display_nibble
  3309.   @hl_field 6
  3310.   mov    edi,(63*2)+(2*160)
  3311.   add    edi,edx
  3312.   mov    bl,[byte esi+tfunk_sb.vv_waveform]
  3313.   shr    bl,4
  3314.   call   display_nibble
  3315.   @hl_field 7
  3316.   mov    edi,(66*2)+(2*160)
  3317.   add    edi,edx
  3318.   mov    bl,[byte esi+tfunk_sb.vv_waveform]
  3319.   call   display_nibble
  3320.   @hl_field 8
  3321.   mov    edi,(69*2)+(2*160)
  3322.   add    edi,edx
  3323.   mov    bl,[byte esi+tfunk_sb.rl_and_as]
  3324.   shr    bl,4
  3325.   call   display_nibble
  3326.   @hl_field 9
  3327.   mov    edi,(72*2)+(2*160)
  3328.   add    edi,edx
  3329.   mov    bl,[byte esi+tfunk_sb.rl_and_as]
  3330.   call   display_nibble
  3331.   add    esi,size tfunk_sb
  3332.   add    edx,160
  3333.   inc    [byte @@line]
  3334.   cmp    [byte @@line],32
  3335.   jb     @@display_treks
  3336.   ret
  3337. @@line:
  3338.   db     ?
  3339. endp
  3340.  
  3341. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3342. ;                                                                          ;
  3343. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3344. proc sam_scroll_up
  3345.   cmp    [byte sam_hl],0
  3346.   je     @@adj_real_bk
  3347.   dec    [byte sam_hl]
  3348.   jmp    @@end
  3349. @@adj_real_bk:
  3350.   cmp    [byte sam_real],0
  3351.   je     @@end
  3352.   dec    [byte sam_real]
  3353. @@end:
  3354.   ret
  3355. endp
  3356.  
  3357. proc sam_scroll_dn
  3358.   cmp    [byte sam_hl],31
  3359.   je     @@adj_real_fd
  3360.   inc    [byte sam_hl]
  3361.   jmp    @@end
  3362. @@adj_real_fd:
  3363.   cmp    [byte sam_real],(64-32)
  3364.   je     @@end
  3365.   inc    [byte sam_real]
  3366. @@end:
  3367.   ret
  3368. endp
  3369.  
  3370. proc sam_pageup
  3371.   mov    cl,16
  3372. @@sp:
  3373.   call   sam_scroll_up
  3374.   dec    cl
  3375.   jnz    @@sp
  3376.   ret
  3377. endp
  3378.  
  3379. proc sam_pagedn
  3380.   mov    cl,16
  3381. @@sp:
  3382.   call   sam_scroll_dn
  3383.   dec    cl
  3384.   jnz    @@sp
  3385.   ret
  3386. endp
  3387.  
  3388. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3389. ;                                                                          ;
  3390. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3391. proc sam_ins_nd
  3392.   mov    dl,[byte sam_real]
  3393.   add    dl,[byte sam_hl]
  3394.   movzx  edx,dl
  3395.   cmp    edx,3fh
  3396.   je     @@dont_ad
  3397.   mov    edi,03fh
  3398. @@add_loop:
  3399.   push   edi
  3400.   shl    edi,5
  3401.   add    edi,offset funk_sb
  3402.   mov    esi,edi
  3403.   sub    esi,size tfunk_sb
  3404.   mov    ecx,size tfunk_sb
  3405.   rep    movsb
  3406.   pop    edi
  3407.   dec    edi
  3408.   cmp    edi,edx
  3409.   ja     @@add_loop
  3410. @@dont_ad:
  3411.   mov    edi,edx
  3412.   shl    edi,5
  3413.   add    edi,offset funk_sb
  3414.   mov    al,20h
  3415.   mov    ecx,19
  3416.   rep    stosb
  3417.   sub    edi,19
  3418.   mov    [dword edi+tfunk_sb.start],0ffffffffh
  3419.   mov    [dword edi+tfunk_sb.length],0
  3420.   mov    [byte edi+tfunk_sb.balance],80h
  3421.   mov    [byte edi+tfunk_sb.volume],0ffh
  3422.   mov    [byte edi+tfunk_sb.pt_and_sop],08h
  3423.   mov    [byte edi+tfunk_sb.vv_waveform],0
  3424.   mov    [byte edi+tfunk_sb.rl_and_as],43h
  3425.   mov    bl,[byte sam_real]
  3426.   add    bl,[byte sam_hl]
  3427.   movzx  ebx,dl
  3428.   lea    ebx,[ebx*2]
  3429.   mov    [dword ebx+funk_info.sample_ptrs],0
  3430.   call   resync_sample_ptrs
  3431.   ret
  3432. endp
  3433.  
  3434. proc sam_ins
  3435.   call   stop_all_voices
  3436.   @splash_on_sm  "Rearranging memory, please wait"
  3437.   call   sam_ins_nd
  3438.   call   display_samples
  3439.   call   display_s_info
  3440.   @splash_off_sm
  3441.   ret
  3442. endp
  3443.  
  3444. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3445. ;                                                                          ;
  3446. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3447. proc del_sample
  3448.   mov    dl,[byte sam_real]
  3449.   add    dl,[byte sam_hl]
  3450.   movzx  edx,dl
  3451.   mov    ebx,edx
  3452.   lea    ebx,[ebx*4]
  3453.   shl    edx,5
  3454.   add    edx,offset funk_sb
  3455.   mov    ecx,[dword sample_block_size]
  3456.   sub    ecx,[dword edx+tfunk_sb.length]
  3457.   sub    ecx,[dword ebx+funk_info.sample_ptrs]
  3458.   inc    ecx
  3459.   mov    edi,[dword ebx+funk_info.sample_ptrs]
  3460.   mov    esi,edi
  3461.   add    esi,[dword edx+tfunk_sb.length]
  3462.   mov    al,[byte init_settings.card_type]
  3463.   cmp    al,SB_CARD
  3464.   je     @@DAC_CARD
  3465.   cmp    al,SBPRO_CARD
  3466.   je     @@DAC_CARD
  3467.   cmp    al,GUS_VARB_CARD
  3468.   je     @@GUS_CARD
  3469.   cmp    al,SB15EM_CARD
  3470.   je     @@DAC_CARD
  3471.   cmp    al,SB16_CARD
  3472.   je     @@DAC_CARD
  3473.   cmp    al,GUS_FIXB_CARD
  3474.   je     @@GUS_CARD
  3475.   cmp    al,PAS16_CARD
  3476.   je     @@DAC_CARD
  3477.   ret
  3478. @@DAC_CARD:
  3479.   rep    movsb
  3480.   ret
  3481. @@GUS_CARD:
  3482.   push   esi edi ecx
  3483.   call   GUS_reset
  3484.   pop    ecx edi esi
  3485. @@GUS_loop:
  3486.   call   GUS_mem_in
  3487.   call   GUS_mem_out
  3488.   inc    esi
  3489.   inc    edi
  3490.   dec    ecx
  3491.   jnz    @@GUS_loop
  3492.   call   GUS_reset
  3493.   call   GUS_intready
  3494.   ret
  3495. endp
  3496.  
  3497. proc sam_del_nd
  3498.   call   del_sample
  3499.   mov    dl,[byte sam_real]
  3500.   add    dl,[byte sam_hl]
  3501.   movzx  edi,dl
  3502.   cmp    edi,3fh
  3503.   je     @@dont_ad
  3504. @@del_loop:
  3505.   push   edi
  3506.   shl    edi,5
  3507.   add    edi,offset funk_sb
  3508.   mov    esi,edi
  3509.   add    esi,size tfunk_sb
  3510.   mov    ecx,size tfunk_sb
  3511.   rep    movsb
  3512.   pop    edi
  3513.   inc    edi
  3514.   cmp    edi,3fh
  3515.   jb     @@del_loop
  3516. @@dont_ad:
  3517.   shl    edi,5
  3518.   add    edi,offset funk_sb
  3519.   mov    al,20h
  3520.   mov    ecx,19
  3521.   rep    stosb
  3522.   sub    edi,19
  3523.   mov    [dword edi+tfunk_sb.start],0ffffffffh
  3524.   mov    [dword edi+tfunk_sb.length],0
  3525.   mov    [byte edi+tfunk_sb.balance],80h
  3526.   mov    [byte edi+tfunk_sb.volume],0ffh
  3527.   mov    [byte edi+tfunk_sb.pt_and_sop],08h
  3528.   mov    [byte edi+tfunk_sb.vv_waveform],0
  3529.   mov    [byte edi+tfunk_sb.rl_and_as],43h
  3530.   call   resync_sample_ptrs
  3531.   ret
  3532. endp
  3533.  
  3534. proc sam_del
  3535.   call   stop_all_voices
  3536.   @splash_on_sm  "Rearranging memory, please wait"
  3537.   call   sam_del_nd
  3538.   call   display_samples
  3539.   call   display_s_info
  3540.   @splash_off_sm
  3541.   ret
  3542. endp
  3543.  
  3544. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3545. ;                                                                          ;
  3546. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3547. proc edit_sname
  3548.   mov    ch,19
  3549.   mov    dh,[byte sam_hl]
  3550.   add    dh,2
  3551.   mov    dl,8
  3552.   call   get_input
  3553.   jc     @@abort
  3554.   mov    al,[byte sam_real]
  3555.   add    al,[byte sam_hl]
  3556.   movzx  esi,al
  3557.   shl    esi,5
  3558.   add    esi,offset funk_sb
  3559.   mov    cl,19
  3560.   call   get_string
  3561. @@abort:
  3562.   call   display_samples
  3563.   ret
  3564. endp
  3565.  
  3566. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3567. ;                                                                          ;
  3568. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3569. proc edit_sstart
  3570.   mov    ch,8
  3571.   mov    dh,[byte sam_hl]
  3572.   add    dh,2
  3573.   mov    dl,29
  3574.   call   get_input
  3575.   jc     @@abort
  3576.   call   get_idword
  3577.   mov    al,[byte sam_real]
  3578.   add    al,[byte sam_hl]
  3579.   movzx  esi,al
  3580.   shl    esi,5
  3581.   add    esi,offset funk_sb
  3582.   mov    [dword esi+tfunk_sb.start],ebx
  3583. @@abort:
  3584.   call   display_samples
  3585.   ret
  3586. endp
  3587.  
  3588. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3589. ;                                                                          ;
  3590. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3591. proc edit_svolume
  3592.   mov    ch,2
  3593.   mov    dh,[byte sam_hl]
  3594.   add    dh,2
  3595.   mov    dl,49
  3596.   call   get_input
  3597.   jc     @@abort
  3598.   call   get_ibyte
  3599.   mov    bl,[byte sam_real]
  3600.   add    bl,[byte sam_hl]
  3601.   movzx  esi,bl
  3602.   shl    esi,5
  3603.   add    esi,offset funk_sb
  3604.   mov    [byte esi+tfunk_sb.volume],al
  3605. @@abort:
  3606.   call   display_samples
  3607.   ret
  3608. endp
  3609.  
  3610. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3611. ;                                                                          ;
  3612. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3613. proc edit_sbalance
  3614.   mov    ch,2
  3615.   mov    dh,[byte sam_hl]
  3616.   add    dh,2
  3617.   mov    dl,53
  3618.   call   get_input
  3619.   jc     @@abort
  3620.   call   get_ibyte
  3621.   mov    bl,[byte sam_real]
  3622.   add    bl,[byte sam_hl]
  3623.   movzx  esi,bl
  3624.   shl    esi,5
  3625.   add    esi,offset funk_sb
  3626.   mov    [byte esi+tfunk_sb.balance],al
  3627. @@abort:
  3628.   call   display_samples
  3629.   ret
  3630. endp
  3631.  
  3632. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3633. ;                                                                          ;
  3634. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3635. proc edit_port_type
  3636.   mov    ch,1
  3637.   mov    dh,[byte sam_hl]
  3638.   add    dh,2
  3639.   mov    dl,57
  3640.   call   get_input
  3641.   jc     @@abort
  3642.   call   get_inib
  3643.   cmp    bl,1
  3644.   jbe    @@dont_adjust
  3645.   mov    bl,1
  3646. @@dont_adjust:
  3647.   mov    al,[byte sam_real]
  3648.   add    al,[byte sam_hl]
  3649.   movzx  esi,al
  3650.   shl    esi,5
  3651.   add    esi,offset funk_sb
  3652.   shl    bl,4
  3653.   and    [byte esi+tfunk_sb.pt_and_sop],1111b
  3654.   or     [byte esi+tfunk_sb.pt_and_sop],bl
  3655. @@abort:
  3656.   call   display_samples
  3657.   ret
  3658. endp
  3659.  
  3660. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3661. ;                                                                          ;
  3662. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3663. proc edit_ssample_op
  3664.   mov    ch,1
  3665.   mov    dh,[byte sam_hl]
  3666.   add    dh,2
  3667.   mov    dl,60
  3668.   call   get_input
  3669.   jc     @@abort
  3670.   call   get_inib
  3671.   mov    al,[byte sam_real]
  3672.   add    al,[byte sam_hl]
  3673.   movzx  esi,al
  3674.   shl    esi,5
  3675.   add    esi,offset funk_sb
  3676.   and    [byte esi+tfunk_sb.pt_and_sop],11110000b
  3677.   or     [byte esi+tfunk_sb.pt_and_sop],bl
  3678. @@abort:
  3679.   call   display_samples
  3680.   ret
  3681. endp
  3682.  
  3683. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3684. ;                                                                          ;
  3685. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3686. proc edit_svwt
  3687.   mov    ch,1
  3688.   mov    dh,[byte sam_hl]
  3689.   add    dh,2
  3690.   mov    dl,63
  3691.   call   get_input
  3692.   jc     @@abort
  3693.   call   get_inib
  3694.   cmp    bl,4
  3695.   jbe    @@dont_adjust
  3696.   mov    bl,4
  3697. @@dont_adjust:
  3698.   mov    al,[byte sam_real]
  3699.   add    al,[byte sam_hl]
  3700.   movzx  esi,al
  3701.   shl    esi,5
  3702.   add    esi,offset funk_sb
  3703.   shl    bl,4
  3704.   and    [byte esi+tfunk_sb.vv_waveform],1111b
  3705.   or     [byte esi+tfunk_sb.vv_waveform],bl
  3706. @@abort:
  3707.   call   display_samples
  3708.   ret
  3709. endp
  3710.  
  3711. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3712. ;                                                                          ;
  3713. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3714. proc edit_svvwt
  3715.   mov    ch,1
  3716.   mov    dh,[byte sam_hl]
  3717.   add    dh,2
  3718.   mov    dl,66
  3719.   call   get_input
  3720.   jc     @@abort
  3721.   call   get_inib
  3722.   cmp    bl,4
  3723.   jbe    @@dont_adjust
  3724.   mov    bl,4
  3725. @@dont_adjust:
  3726.   mov    al,[byte sam_real]
  3727.   add    al,[byte sam_hl]
  3728.   movzx  esi,al
  3729.   shl    esi,5
  3730.   add    esi,offset funk_sb
  3731.   and    [byte esi+tfunk_sb.vv_waveform],11110000b
  3732.   or     [byte esi+tfunk_sb.vv_waveform],bl
  3733. @@abort:
  3734.   call   display_samples
  3735.   ret
  3736. endp
  3737.  
  3738. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3739. ;                                                                          ;
  3740. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3741. proc edit_retriglim
  3742.   mov    ch,1
  3743.   mov    dh,[byte sam_hl]
  3744.   add    dh,2
  3745.   mov    dl,69
  3746.   call   get_input
  3747.   jc     @@abort
  3748.   call   get_inib
  3749.   mov    al,[byte sam_real]
  3750.   add    al,[byte sam_hl]
  3751.   movzx  esi,al
  3752.   shl    esi,5
  3753.   add    esi,offset funk_sb
  3754.   shl    bl,4
  3755.   and    [byte esi+tfunk_sb.rl_and_as],1111b
  3756.   or     [byte esi+tfunk_sb.rl_and_as],bl
  3757. @@abort:
  3758.   call   display_samples
  3759.   ret
  3760. endp
  3761.  
  3762. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3763. ;                                                                          ;
  3764. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3765. proc edit_arpspeed
  3766.   mov    ch,1
  3767.   mov    dh,[byte sam_hl]
  3768.   add    dh,2
  3769.   mov    dl,72
  3770.   call   get_input
  3771.   jc     @@abort
  3772.   call   get_inib
  3773.   mov    al,[byte sam_real]
  3774.   add    al,[byte sam_hl]
  3775.   movzx  esi,al
  3776.   shl    esi,5
  3777.   add    esi,offset funk_sb
  3778.   and    [byte esi+tfunk_sb.rl_and_as],11110000b
  3779.   or     [byte esi+tfunk_sb.rl_and_as],bl
  3780. @@abort:
  3781.   call   display_samples
  3782.   ret
  3783. endp
  3784.  
  3785. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3786. ;                                                                          ;
  3787. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3788. proc insert_space
  3789.   mov    dl,[byte sam_real]
  3790.   add    dl,[byte sam_hl]
  3791.   movzx  edx,dl
  3792.   mov    ebx,edx
  3793.   shl    edx,5
  3794.   lea    ebx,[ebx*4]
  3795.   add    edx,offset funk_sb
  3796.   mov    ecx,[dword sample_block_size]
  3797.   sub    ecx,[dword edx+tfunk_sb.length]
  3798.   sub    ecx,[dword ebx+funk_info.sample_ptrs]
  3799.   inc    ecx
  3800.   mov    edi,[dword sample_block_size]
  3801.   mov    esi,edi
  3802.   sub    esi,[dword edx+tfunk_sb.length]
  3803.   mov    al,[byte init_settings.card_type]
  3804.   cmp    al,SB_CARD
  3805.   je     @@DAC_CARD
  3806.   cmp    al,SBPRO_CARD
  3807.   je     @@DAC_CARD
  3808.   cmp    al,GUS_VARB_CARD
  3809.   je     @@GUS_CARD
  3810.   cmp    al,SB15EM_CARD
  3811.   je     @@DAC_CARD
  3812.   cmp    al,SB16_CARD
  3813.   je     @@DAC_CARD
  3814.   cmp    al,GUS_FIXB_CARD
  3815.   je     @@GUS_CARD
  3816.   cmp    al,PAS16_CARD
  3817.   je     @@DAC_CARD
  3818.   ret
  3819. @@DAC_CARD:
  3820.   std
  3821.   rep    movsb
  3822.   cld
  3823.   ret
  3824. @@GUS_CARD:
  3825.   push   esi edi ecx
  3826.   call   GUS_reset
  3827.   pop    ecx edi esi
  3828. @@gus_loop:
  3829.   call   GUS_mem_in
  3830.   call   GUS_mem_out
  3831.   dec    esi
  3832.   dec    edi
  3833.   dec    ecx
  3834.   jnz    @@gus_loop
  3835.   call   GUS_reset
  3836.   call   GUS_intready
  3837.   ret
  3838. endp
  3839.  
  3840. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3841. ;                                                                          ;
  3842. ; edx = ptr to sample block info                                           ;
  3843. ; ebx = ptr to sample ptrs                                                 ;
  3844. ;                                                                          ;
  3845. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3846. ;eax = length
  3847. proc convert_sine
  3848.   push   edx eax
  3849. @@cs:
  3850.   xor    [byte edx],80h
  3851.   inc    edx
  3852.   dec    eax
  3853.   jnz    @@cs
  3854.   pop    eax edx
  3855.   ret
  3856. endp
  3857.  
  3858. proc load_sample
  3859.   mov    al,[byte init_settings.card_type]
  3860.   cmp    al,SB_CARD
  3861.   je     @@DAC_CARD
  3862.   cmp    al,SBPRO_CARD
  3863.   je     @@DAC_CARD
  3864.   cmp    al,GUS_VARB_CARD
  3865.   je     @@GUS_CARD
  3866.   cmp    al,SB15EM_CARD
  3867.   je     @@DAC_CARD
  3868.   cmp    al,SB16_CARD
  3869.   je     @@DAC_CARD
  3870.   cmp    al,GUS_FIXB_CARD
  3871.   je     @@GUS_CARD
  3872.   cmp    al,PAS16_CARD
  3873.   je     @@DAC_CARD
  3874.   ret
  3875. @@DAC_CARD:
  3876.   mov    esi,[dword edx+tfunk_sb.length]
  3877.   mov    edx,[dword ebx+funk_info.sample_ptrs]
  3878.   mov    ebx,[dword file_handle_funk]
  3879. @@SB_load_sample_loop:
  3880.   mov    ah,3fh
  3881.   mov    ecx,40000
  3882.   cmp    ecx,esi
  3883.   jbe    @@SB_dont_adjust
  3884.   mov    ecx,esi
  3885. @@SB_dont_adjust:
  3886.   int    21h
  3887.   call   convert_sine
  3888.   add    edx,eax
  3889.   sub    esi,eax
  3890.   jnz    @@SB_load_sample_loop
  3891.   ret
  3892. @@GUS_CARD:
  3893.   push   edx ebx
  3894.   call   GUS_reset
  3895.   pop    ebx edx
  3896.   mov    ebp,[dword edx+tfunk_sb.length]
  3897.   mov    edi,[dword ebx+funk_info.sample_ptrs]
  3898.   mov    ebx,[dword file_handle_funk]
  3899. @@GUS_load_sample_loop:
  3900.   mov    ah,3fh
  3901.   mov    edx,[dword fdirectory_buffer]
  3902.   mov    ecx,40000
  3903.   cmp    ecx,ebp
  3904.   jbe    @@GUS_dont_adjust
  3905.   mov    ecx,ebp
  3906. @@GUS_dont_adjust:
  3907.   int    21h
  3908.   call   convert_sine
  3909.   mov    esi,[dword fdirectory_buffer]
  3910.   push   eax
  3911.   call   gus_upload
  3912.   pop    eax
  3913.   sub    ebp,eax
  3914.   jnz    @@GUS_load_sample_loop
  3915.   call   GUS_reset
  3916.   call   GUS_intready
  3917.   ret
  3918. endp
  3919.  
  3920. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3921. ;                                                                          ;
  3922. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3923. proc dis_resamwin
  3924.   lea    esi,[resample_window]
  3925.   mov    edi,[_0b8000h]
  3926.   add    edi,(((78-25)/2)*2)+(((40-12)/2)*160)
  3927.   mov    ebx,25
  3928.   mov    dl,12
  3929.   call   paint_window
  3930.  
  3931.   xor    ecx,ecx
  3932.   xor    edx,edx
  3933. @@select_src:
  3934.   push   ecx edx
  3935.   mov    dh,04h                          ; no of entries
  3936.   mov    ebx,2f07h                       ; colour of hl
  3937.   mov    edi,[_0b8000h]
  3938.   add    edi,((((78-25)/2)+1)*2)+((((40-12)/2)+5)*160)+1
  3939.   mov    ecx,9                           ; length
  3940.   call   dis_sbar
  3941.   pop    edx ecx
  3942. @@again:
  3943.   call   get_key
  3944.   cmp    al,27
  3945.   je     @@finish
  3946.   cmp    al,13
  3947.   je     @@select_tar
  3948.   cmp    ax,kb_up
  3949.   je     @@up
  3950.   cmp    ax,kb_down
  3951.   je     @@dn
  3952.   jmp    @@again
  3953. @@up:
  3954.   cmp    dl,0
  3955.   je     @@again
  3956.   dec    dl
  3957.   jmp    @@select_src
  3958. @@dn:
  3959.   cmp    dl,3
  3960.   je     @@again
  3961.   inc    dl
  3962.   jmp    @@select_src
  3963. @@select_tar:
  3964.   cmp    dl,0
  3965.   je     @@sr_8000
  3966.   cmp    dl,1
  3967.   je     @@sr_11025
  3968.   cmp    dl,2
  3969.   je     @@sr_22050
  3970.   cmp    dl,3
  3971.   je     @@sr_44100
  3972. @@sr_8000:
  3973.   mov    ecx,8000
  3974.   jmp    @@sr_cont
  3975. @@sr_11025:
  3976.   mov    ecx,11025
  3977.   jmp    @@sr_cont
  3978. @@sr_22050:
  3979.   mov    ecx,22050
  3980.   jmp    @@sr_cont
  3981. @@sr_44100:
  3982.   mov    ecx,44100
  3983. @@sr_cont:
  3984.   mov    edx,ecx
  3985. @@tar_l:
  3986.   push   ecx edx
  3987.   mov    eax,edx
  3988.   mov    edi,((((78-25)/2)+13)*2)+((((40-12)/2)+6)*160)
  3989.   call   print_decn5
  3990.   pop    edx ecx
  3991. @@tar_again:
  3992.   call   get_key
  3993.   cmp    al,27
  3994.   je     @@finish
  3995.   cmp    al,13
  3996.   je     @@finish
  3997.   cmp    ax,kb_up
  3998.   je     @@tar_up
  3999.   cmp    ax,kb_down
  4000.   je     @@tar_dn
  4001.   cmp    ax,kb_pageup
  4002.   je     @@tar_pdup
  4003.   cmp    ax,kb_pagedn
  4004.   je     @@tar_pddn
  4005.   jmp    @@tar_again
  4006. @@tar_up:
  4007.   cmp    edx,0
  4008.   je     @@tar_again
  4009.   dec    edx
  4010.   jmp    @@tar_l
  4011. @@tar_dn:
  4012.   cmp    edx,88200
  4013.   je     @@tar_again
  4014.   inc    edx
  4015.   jmp    @@tar_l
  4016. @@tar_pdup:
  4017.   sub    edx,100
  4018.   cmp    edx,0
  4019.   jge    @@tar_l
  4020.   mov    edx,0
  4021.   jmp    @@tar_l
  4022. @@tar_pddn:
  4023.   add    edx,100
  4024.   cmp    edx,88200
  4025.   jle    @@tar_l
  4026.   mov    edx,88200
  4027.   jmp    @@tar_l
  4028. @@finish:
  4029.   ret
  4030. endp
  4031.  
  4032. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4033. ;                                                                          ;
  4034. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4035. FTRANS_INB_SIZE       = 2048
  4036. FTRANS_OUTB_SIZE      = 2048
  4037. ftrans_scr_len        dd ?
  4038.  
  4039. proc ftrans_read
  4040.   push   edx
  4041.   mov    ecx,FTRANS_INB_SIZE
  4042.   cmp    ecx,[ftrans_scr_len]
  4043.   jbe    @@cont
  4044.   mov    ecx,[ftrans_scr_len]
  4045. @@cont:
  4046.   mov    ebx,[dword file_handle_funk]
  4047.   mov    edx,[fdirectory_buffer]
  4048.   mov    ah,3fh
  4049.   int    21h
  4050.   mov    [numread],eax
  4051.   sub    [ftrans_scr_len],eax
  4052.   pop    edx
  4053.   xor    esi,esi
  4054.   ret
  4055. endp
  4056.  
  4057. proc ftrans_write
  4058.   push   edx
  4059.   mov    ecx,edi
  4060.   mov    ebx,[dword file_handle_funk2]
  4061.   mov    edx,[fdirectory_buffer]
  4062.   add    edx,FTRANS_INB_SIZE
  4063.   mov    ah,40h
  4064.   int    21h
  4065.   pop    edx
  4066.   xor    edi,edi
  4067.   ret
  4068. endp
  4069.  
  4070. ;eax = target freq
  4071. ;ebx = source freq
  4072. ;ecx = scr len
  4073. proc ftrans_buffer
  4074.   mov    [@@target_freq],eax
  4075.   mov    [@@source_freq],ebx
  4076.   mov    [ftrans_scr_len],ecx
  4077.   mov    eax,[@@target_freq]
  4078.   mov    edx,eax
  4079.   shl    eax,16
  4080.   shr    edx,16
  4081.   div    [dword @@source_freq]
  4082.   mov    edx,eax
  4083.   mov    ebp,edx
  4084.   shl    edx,16
  4085.   shr    ebp,16
  4086.   xor    esi,esi
  4087.   xor    edi,edi
  4088.   call   ftrans_read
  4089.   jc     @@error_trans
  4090.   cmp    [dword numread],0
  4091.   je     @@done
  4092. @@mix_loop:
  4093.   mov    ebx,[fdirectory_buffer]
  4094.   mov    al,[esi+ebx]
  4095.   mov    ebx,[fdirectory_buffer]
  4096.   mov    [edi+ebx+FTRANS_INB_SIZE],al
  4097.   inc    edi
  4098.   add    [dword @@freq_attract],edx
  4099.   adc    esi,ebp
  4100.   cmp    esi,[numread]
  4101.   jb     @@cont
  4102.   call   ftrans_read
  4103.   jc     @@error_trans
  4104.   cmp    [dword numread],0
  4105.   je     @@done
  4106. @@cont:
  4107.   cmp    edi,FTRANS_OUTB_SIZE
  4108.   jb     @@mix_loop
  4109.   call   ftrans_write
  4110.   jc     @@error_trans
  4111.   jmp    @@mix_loop
  4112. @@error_trans:
  4113.   @error_mess "Error: Can not transform sample"
  4114.   stc
  4115.   ret
  4116. @@done:
  4117.   cmp    edi,0
  4118.   je     @@cont2
  4119.   call   ftrans_write
  4120. @@cont2:
  4121.   clc
  4122.   ret
  4123. @@freq_attract        dd 0
  4124. @@target_freq         dd ?
  4125. @@source_freq         dd ?
  4126. endp
  4127.  
  4128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4129. ;                                                                          ;
  4130. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4131.  
  4132. struc triff_hr
  4133.   rID                 dd ?      ; Contains the characters "RIFF"
  4134.   rLen                dd ?      ; The length of the data in the next chunk
  4135. ends
  4136.  
  4137. struc twaveformat
  4138.   wID                 dd ?      ; Contains the characters "WAVE"
  4139.   fId                 dd ?      ; Contains the characters "fmt"
  4140.   fLen                dd ?      ; Length of data in the format chunk
  4141.   wFormatTag          dw ?      ; *
  4142.   nChannels           dw ?      ; Number of channels, 1=mono, 2=stereo
  4143.   nSamplesPerSec      dw ?      ; Playback frequency
  4144.   nAvgBytesPerSec     dw ?      ; **
  4145.   nBlockAlign         dw ?      ; ***
  4146.   FormatSpecific      dw ?      ; Format specific data area
  4147.   blank               dd ?
  4148. ends
  4149.  
  4150. struc twavedata
  4151.   dId                 dd ?      ; Contains the characters "data"
  4152.   dLen                dd ?      ; Length of data in the dData field
  4153. ends
  4154.  
  4155. riff_hr               triff_hr <>
  4156. waveformat            twaveformat <>
  4157. wavedata              twavedata <>
  4158.  
  4159. proc load_single_sample
  4160.   call   dis_resamwin
  4161.   mov    [@@src_freq],ecx
  4162.   mov    [@@dst_freq],edx
  4163.   @splash_on_sm  "Loading sample, please wait"
  4164.   mov    dl,[byte sam_real]
  4165.   add    dl,[byte sam_hl]
  4166.   movzx  edx,dl
  4167.   shl    edx,5
  4168.   add    edx,offset funk_sb
  4169.   mov    eax,3d00h
  4170.   int    21h
  4171.   jc     @@mess1
  4172.   mov    [dword file_handle_funk],eax
  4173.   mov    ebx,eax
  4174.   mov    ebp,edx
  4175.   mov    ah,3fh                                         ; load riff header
  4176.   lea    edx,[riff_hr]
  4177.   mov    ecx,size triff_hr
  4178.   int    21h
  4179.   cmp    [dword riff_hr.rID],"FFIR"
  4180.   jne    @@not_wave_mess
  4181.   mov    ah,3fh                                         ; load wave header
  4182.   lea    edx,[waveformat]
  4183.   mov    ecx,size twaveformat
  4184.   int    21h
  4185.   cmp    [dword waveformat.wID],"EVAW"
  4186.   jne    @@not_wave_mess
  4187.   cmp    [dword waveformat.fId]," tmf"
  4188.   jne    @@not_wave_mess
  4189.   mov    ah,3fh                                         ; load data header
  4190.   lea    edx,[wavedata]
  4191.   mov    ecx,size twavedata
  4192.   int    21h
  4193.   cmp    [dword wavedata.dId],"atad"
  4194.   jne    @@not_wave_mess
  4195.   cmp    [dword wavedata.dLen],0
  4196.   je     @@closef
  4197.   mov    eax,[@@src_freq]
  4198.   cmp    eax,[@@dst_freq]
  4199.   je     @@load_normal
  4200. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4201.   mov    edx,offset file_temp
  4202.   mov    eax,3c00h
  4203.   xor    ecx,ecx
  4204.   int    21h
  4205.   jc     @@mess2
  4206.   mov    [dword file_handle_funk2],eax
  4207.  
  4208.   mov    eax,[@@src_freq]
  4209.   mov    ebx,[@@dst_freq]
  4210.   mov    ecx,[dword wavedata.dLen]
  4211.   push   ebp
  4212.   call   ftrans_buffer
  4213.   pop    ebp
  4214.   jnc    @@no_ftrans_error
  4215.   mov    ebx,[dword file_handle_funk2]
  4216.   mov    ah,3eh
  4217.   int    21h
  4218.   jmp    @@closef
  4219. @@no_ftrans_error:
  4220.   mov    ebx,[dword file_handle_funk]
  4221.   mov    ah,3eh
  4222.   int    21h
  4223.   mov    eax,[dword file_handle_funk2]
  4224.   mov    [dword file_handle_funk],eax
  4225.  
  4226.   mov    ebx,[dword file_handle_funk]
  4227.   mov    eax,4202h
  4228.   xor    edx,edx
  4229.   int    21h
  4230.   push   eax
  4231.   mov    ebx,[dword file_handle_funk]
  4232.   mov    eax,4200h
  4233.   xor    edx,edx
  4234.   int    21h
  4235.   pop    eax
  4236.   jmp    @@load_data
  4237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4238. @@load_normal:
  4239.   mov    eax,[dword wavedata.dLen]
  4240. @@load_data:
  4241.   mov    edx,ebp
  4242.   mov    ebx,[dword sample_memory_lim]
  4243.   mov    ecx,[dword sample_block_size]
  4244.   sub    ecx,[dword funk_info.sample_ptrs]
  4245.   sub    ebx,ecx
  4246.   cmp    eax,ebx
  4247.   ja     @@out_of_mem
  4248.   mov    [dword edx+tfunk_sb.length],eax
  4249.   call   resync_sample_ptrs
  4250.   call   insert_space
  4251.   mov    dl,[byte sam_real]
  4252.   add    dl,[byte sam_hl]
  4253.   movzx  edx,dl
  4254.   mov    ebx,edx
  4255.   shl    edx,5
  4256.   lea    ebx,[ebx*4]
  4257.   add    edx,offset funk_sb
  4258.   call   load_sample
  4259.   mov    ebx,[dword file_handle_funk]
  4260.   mov    ah,3eh                                         ; close
  4261.   int    21h
  4262.   @splash_off_sm
  4263.   ret
  4264. @@mess1:
  4265.   @error_mess "Error: Can not load sample"
  4266.   ret
  4267. @@mess2:
  4268.   @error_mess "Error: Can not load sample"
  4269.   jmp    @@closef
  4270. @@out_of_mem:
  4271.   @error_mess "Error: Out of sample memory; Can not load sample"
  4272.   jmp    @@closef
  4273. @@not_wave_mess:
  4274.   @error_mess "Error: Not a recognised Windows WAVE file"
  4275.   jmp    @@closef
  4276. @@closef:
  4277.   mov    ebx,[dword file_handle_funk]
  4278.   mov    ah,3eh                                   ; close
  4279.   int    21h
  4280.   ret
  4281. @@src_freq            dd ?
  4282. @@dst_freq            dd ?
  4283. endp
  4284.  
  4285. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4286. ;                                                                          ;
  4287. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4288. proc select_sample_file
  4289.   call   stop_all_voices
  4290.   lea    edx,[sample_dir]
  4291.   call   set_directory
  4292.   mov    ecx,modefile_screen_size
  4293.   lea    esi,[modefile_screen]
  4294.   mov    edi,[_0b8000h]
  4295.   call   uncrush_text
  4296.   lea    edx,[file_search_wav]
  4297.   call   load_fdirectory
  4298.   call   display_fdir
  4299. @@input_loop:
  4300.   call   get_key
  4301.   cmp    al,27
  4302.   je     @@exit
  4303.   cmp    ax,kb_up
  4304.   je     @@hkb_up
  4305.   cmp    ax,kb_down
  4306.   je     @@hkb_down
  4307.   cmp    ax,kb_pageup
  4308.   je     @@hkb_pageup
  4309.   cmp    ax,kb_pagedn
  4310.   je     @@hkb_pagedn
  4311.   cmp    al,13
  4312.   je     @@enter_key
  4313.   jmp    @@input_loop
  4314. @@scroll_fdir_up:
  4315.   call   display_fdir
  4316.   jmp    @@input_loop
  4317. @@scroll_fdir_dw:
  4318.   call   display_fdir
  4319.   jmp    @@input_loop
  4320. @@hkb_up:
  4321.   call   fdir_scroll_up
  4322.   call   display_fdir
  4323.   jmp    @@input_loop
  4324. @@hkb_down:
  4325.   call   fdir_scroll_dn
  4326.   call   display_fdir
  4327.   jmp    @@input_loop
  4328. @@hkb_pageup:
  4329.   call   fdir_scroll_pageup
  4330.   call   display_fdir
  4331.   jmp    @@input_loop
  4332. @@hkb_pagedn:
  4333.   call   fdir_scroll_pagedn
  4334.   call   display_fdir
  4335.   jmp    @@input_loop
  4336. @@enter_key:
  4337.   mov    cl,size tfdirectory
  4338.   mov    ax,[word fdir_real]
  4339.   add    al,[byte fdir_hl]
  4340.   adc    ah,0
  4341.   mul    cl
  4342.   movzx  esi,ax
  4343.   add    esi,[dword fdirectory_buffer]
  4344.   cmp    [byte esi+tfdirectory.attr],10h
  4345.   jne    @@load_file
  4346.   push   esi
  4347.   lea    esi,[sample_dir]
  4348.   mov    edi,esi
  4349.   call   get_directory
  4350.   pop    esi
  4351.   lea    esi,[esi+tfdirectory.fname]
  4352.   call   goto_end_str
  4353.   cmp    ebx,3
  4354.   jne    @@form_path2
  4355.   call   mini_trans_str
  4356.   jmp    @@change_dir
  4357. @@form_path2:
  4358.   mov    [byte edi+ebx],'\'
  4359.   inc    ebx
  4360.   call   mini_trans_str
  4361. @@change_dir:
  4362.   lea    edx,[sample_dir]
  4363.   call   set_directory
  4364.   lea    esi,[sample_dir]
  4365.   call   get_directory
  4366.   lea    edx,[file_search_wav]
  4367.   call   load_fdirectory
  4368.   call   display_fdir
  4369.   jmp    @@input_loop
  4370. @@load_file:
  4371.   push   esi
  4372.   mov    al,[byte sam_real]
  4373.   add    al,[byte sam_hl]
  4374.   movzx  esi,al
  4375.   shl    esi,5
  4376.   add    esi,offset funk_sb
  4377.   cmp    [dword esi+tfunk_sb.length],0
  4378.   je     @@dont_del
  4379.   call   sam_del_nd
  4380.   call   sam_ins_nd
  4381. @@dont_del:
  4382.   pop    esi
  4383.   mov    al,[byte sam_real]
  4384.   add    al,[byte sam_hl]
  4385.   movzx  edi,al
  4386.   shl    edi,5
  4387.   add    edi,offset funk_sb
  4388.   push   edi
  4389.   mov    ecx,19
  4390.   mov    al," "
  4391. @@clr_sname:
  4392.   stosb
  4393.   dec    ecx
  4394.   jnz    @@clr_sname
  4395.   pop    edi
  4396.   lea    esi,[esi+tfdirectory.fname]
  4397.   xor    ebx,ebx
  4398.   call   mini_trans_str
  4399.   call   load_single_sample
  4400. ;;;;;;;;;;;;
  4401.   mov    edx,offset file_temp
  4402.   mov    ah,41h
  4403.   int    21h
  4404. ;;;;;;;;;;;
  4405. @@exit:
  4406.   call   display_mode
  4407.   ret
  4408. endp
  4409.  
  4410. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4411. ;                                                                          ;
  4412. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4413. proc se_handle
  4414.   cmp    ax,kb_up
  4415.   je     @@hkb_up
  4416.   cmp    ax,kb_down
  4417.   je     @@hkb_down
  4418.   cmp    ax,kb_pageup
  4419.   je     @@hkb_pageup
  4420.   cmp    ax,kb_pagedn
  4421.   je     @@hkb_pagedn
  4422.   cmp    ax,kb_left
  4423.   je     @@hkb_left
  4424.   cmp    ax,kb_right
  4425.   je     @@hkb_right
  4426.   cmp    al,"/"
  4427.   je     @@dec_oct
  4428.   cmp    al,"*"
  4429.   je     @@inc_oct
  4430.   push   eax
  4431.   call   mus_kb_input
  4432.   pop    eax
  4433.   cmp    al,"["
  4434.   je     @@edit_field
  4435.   cmp    ax,kb_insert
  4436.   je     @@insert_sb
  4437.   cmp    ax,kb_delete
  4438.   je     @@delete_sb
  4439.   cmp    al," "
  4440.   je     @@load_sample
  4441.   jmp    @@input_loop
  4442. @@hkb_up:
  4443.   call   sam_scroll_up
  4444.   call   display_samples
  4445.   jmp    @@input_loop
  4446. @@hkb_down:
  4447.   call   sam_scroll_dn
  4448.   call   display_samples
  4449.   jmp    @@input_loop
  4450. @@hkb_pageup:
  4451.   call   sam_pageup
  4452.   call   display_samples
  4453.   jmp    @@input_loop
  4454. @@hkb_pagedn:
  4455.   call   sam_pagedn
  4456.   call   display_samples
  4457.   jmp    @@input_loop
  4458. @@hkb_left:
  4459.   cmp    [byte sam_col],0
  4460.   je     @@input_loop
  4461.   dec    [byte sam_col]
  4462.   call   display_samples
  4463.   jmp    @@input_loop
  4464. @@hkb_right:
  4465.   cmp    [byte sam_col],9
  4466.   je     @@input_loop
  4467.   inc    [byte sam_col]
  4468.   call   display_samples
  4469.   jmp    @@input_loop
  4470. @@dec_oct:
  4471.   cmp    [byte octave],0
  4472.   je     @@input_loop
  4473.   dec    [byte octave]
  4474.   call   update_octave
  4475.   jmp    @@input_loop
  4476. @@inc_oct:
  4477.   cmp    [byte octave],4
  4478.   je     @@input_loop
  4479.   inc    [byte octave]
  4480.   call   update_octave
  4481.   jmp    @@input_loop
  4482. @@edit_field:
  4483.   cmp    [byte sam_col],1
  4484.   je     @@edit_f2
  4485.   cmp    [byte sam_col],2
  4486.   je     @@edit_f3
  4487.   cmp    [byte sam_col],3
  4488.   je     @@edit_f4
  4489.   cmp    [byte sam_col],4
  4490.   je     @@edit_f5
  4491.   cmp    [byte sam_col],5
  4492.   je     @@edit_f6
  4493.   cmp    [byte sam_col],6
  4494.   je     @@edit_f7
  4495.   cmp    [byte sam_col],7
  4496.   je     @@edit_f8
  4497.   cmp    [byte sam_col],8
  4498.   je     @@edit_f9
  4499.   cmp    [byte sam_col],9
  4500.   je     @@edit_f10
  4501. @@edit_f1:
  4502.   call   edit_sname
  4503.   jmp    @@input_loop
  4504. @@edit_f2:
  4505.   call   edit_sstart
  4506.   jmp    @@input_loop
  4507. @@edit_f3:
  4508.   call   edit_svolume
  4509.   jmp    @@input_loop
  4510. @@edit_f4:
  4511.   call   edit_sbalance
  4512.   jmp    @@input_loop
  4513. @@edit_f5:
  4514.   call   edit_port_type
  4515.   jmp    @@input_loop
  4516. @@edit_f6:
  4517.   call   edit_ssample_op
  4518.   jmp    @@input_loop
  4519. @@edit_f7:
  4520.   call   edit_svwt
  4521.   jmp    @@input_loop
  4522. @@edit_f8:
  4523.   call   edit_svvwt
  4524.   jmp    @@input_loop
  4525. @@edit_f9:
  4526.   call   edit_retriglim
  4527.   jmp    @@input_loop
  4528. @@edit_f10:
  4529.   call   edit_arpspeed
  4530.   jmp    @@input_loop
  4531. @@insert_sb:
  4532.   call   sam_ins
  4533.   jmp    @@input_loop
  4534. @@delete_sb:
  4535.   call   sam_del
  4536.   jmp    @@input_loop
  4537. @@load_sample:
  4538.   call   select_sample_file
  4539.   jmp    @@input_loop
  4540. @@input_loop:
  4541.   ret
  4542. endp
  4543.  
  4544. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4545. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4546. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4547. ;                                                                          ;
  4548. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4549. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4550. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4551.  
  4552. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4553. ;                                                                          ;
  4554. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4555. proc trak_seq_info
  4556.   mov    ah,13h
  4557.   mov    edi,(12*2)+(46*160)
  4558.   mov    bl,[byte funk_info.sequence_ofs]
  4559.   call   display_byte
  4560.  
  4561.   mov    edi,(28*2)+(46*160)
  4562.   movzx  ebx,[byte funk_info.sequence_ofs]
  4563.   mov    bl,[byte ebx+funk_hr.order_list]
  4564.   call   display_byte
  4565.  
  4566.   mov    edi,(28*2)+(47*160)
  4567.   mov    bl,[byte funk_info.pattern_ofs]
  4568.   call   display_byte
  4569.  
  4570.   mov    edi,(39*2)+(46*160)
  4571.   mov    bl,[byte funk_info.tempo]
  4572.   call   display_nibble
  4573.  
  4574.   mov    edi,(39*2)+(47*160)
  4575.   mov    bl,[byte funk_info.master_volume]
  4576.   call   display_nibble
  4577.   ret
  4578. endp
  4579.  
  4580. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4581. ;                                                                          ;
  4582. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4583. proc track_screen_debug
  4584.   call   trak_seq_info
  4585.   mov    ah,03h
  4586.   lea    esi,[funk_chan1]
  4587.   mov    cl,8
  4588.   xor    edx,edx
  4589. @@display_chan_dump:
  4590.   push   ecx edx
  4591. ;;;
  4592.   mov    edi,(1*2)+(37*160)
  4593.   add    edi,edx
  4594.   movzx  ebx,[word esi+tfunk_chan.command]
  4595.   call   display_command
  4596. ;;
  4597.   mov    edi,(5*2)+(37*160)
  4598.   add    edi,edx
  4599.   mov    bl,[byte esi+tfunk_chan.sample]
  4600.   call   display_byte
  4601. ;;;
  4602.   mov    edi,(8*2)+(37*160)
  4603.   add    edi,edx
  4604.   mov    bl,[byte esi+tfunk_chan.balance]
  4605.   call   display_byte
  4606. ;;;
  4607.   mov    edi,(10*2)+(37*160)
  4608.   add    edi,edx
  4609.   mov    bl,[byte esi+tfunk_chan.port_type]
  4610.   call   display_nibble
  4611. ;;;
  4612.   mov    edi,(11*2)+(37*160)
  4613.   add    edi,edx
  4614.   mov    bl,[byte esi+tfunk_chan.sample_ofs_parm]
  4615.   call   display_nibble
  4616. ;;;
  4617.   mov    edi,(12*2)+(37*160)
  4618.   add    edi,edx
  4619.   mov    bl,[byte esi+tfunk_chan.vib_waveform]
  4620.   call   display_nibble
  4621. ;;;
  4622.   mov    edi,(13*2)+(37*160)
  4623.   add    edi,edx
  4624.   mov    bl,[byte esi+tfunk_chan.vol_vib_waveform]
  4625.   call   display_nibble
  4626. ;;;
  4627.   mov    edi,(14*2)+(37*160)
  4628.   add    edi,edx
  4629.   mov    bl,[byte esi+tfunk_chan.retrig_limit]
  4630.   call   display_nibble
  4631. ;;;
  4632.   mov    edi,(15*2)+(37*160)
  4633.   add    edi,edx
  4634.   mov    bl,[byte esi+tfunk_chan.arp_speed]
  4635.   call   display_nibble
  4636. ;;;
  4637.   mov    edi,(16*2)+(37*160)
  4638.   add    edi,edx
  4639.   mov    bl,[byte esi+tfunk_chan.funkctrl]
  4640.   call   display_nibble
  4641. ;;;
  4642.   mov    edi,(18*2)+(37*160)
  4643.   add    edi,edx
  4644.   movzx  ebx,[word esi+tfunk_chan.note_command]
  4645.   call   display_command
  4646. ;;
  4647.   mov    edi,(22*2)+(37*160)
  4648.   add    edi,edx
  4649.   movzx  ebx,[byte esi+tfunk_chan.note]
  4650.   call   display_note
  4651. ;;;
  4652.   mov    edi,(26*2)+(37*160)
  4653.   add    edi,edx
  4654.   mov    ecx,[dword esi+tfunk_chan.ifreq]
  4655.   call   display_word
  4656. ;;;
  4657.   mov    edi,(31*2)+(37*160)
  4658.   add    edi,edx
  4659.   mov    ecx,[dword esi+tfunk_chan.ifreq_vibrato]
  4660.   call   display_word
  4661. ;;;
  4662.   mov    edi,(36*2)+(37*160)
  4663.   add    edi,edx
  4664.   mov    ecx,[dword esi+tfunk_chan.ifreq_portdest]
  4665.   call   display_word
  4666. ;;;
  4667.   mov    edi,(41*2)+(37*160)
  4668.   add    edi,edx
  4669.   mov    ecx,[dword esi+tfunk_chan.rfreq]
  4670.   call   display_dword
  4671. ;;;
  4672.   mov    edi,(50*2)+(37*160)
  4673.   add    edi,edx
  4674.   mov    ecx,[dword esi+tfunk_chan.rfreq_adjust]
  4675.   call   display_word
  4676. ;;;
  4677.   mov    edi,(55*2)+(37*160)
  4678.   add    edi,edx
  4679.   mov    ecx,[dword esi+tfunk_chan.rfreq_portdest]
  4680.   call   display_dword
  4681. ;;;
  4682.   mov    edi,(64*2)+(37*160)
  4683.   add    edi,edx
  4684.   movzx  ebx,[word esi+tfunk_chan.volume_command]
  4685.   call   display_command
  4686. ;;
  4687.   mov    edi,(68*2)+(37*160)
  4688.   add    edi,edx
  4689.   mov    bl,[byte esi+tfunk_chan.volume]
  4690.   call   display_byte
  4691. ;;;
  4692.   mov    edi,(71*2)+(37*160)
  4693.   add    edi,edx
  4694.   mov    bl,[byte esi+tfunk_chan.volume_vibrato]
  4695.   call   display_byte
  4696. ;;;
  4697.   mov    edi,(74*2)+(37*160)
  4698.   add    edi,edx
  4699.   mov    bl,[byte esi+tfunk_chan.volume_portdest]
  4700.   call   display_byte
  4701. ;;;
  4702.   mov    edi,(77*2)+(37*160)
  4703.   add    edi,edx
  4704.   mov    bl,[byte esi+tfunk_chan.rvolume]
  4705.   call   display_byte
  4706. ;;;
  4707.   pop    edx ecx
  4708.   add    esi,size tfunk_chan
  4709.   add    dx,160
  4710.   dec    cl
  4711.   jnz    @@display_chan_dump
  4712.   ret
  4713. endp
  4714.  
  4715. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4716. ;                                                                          ;
  4717. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4718. proc track_screen_play
  4719.   call   trak_seq_info
  4720.   lea    esi,[funk_chan1]
  4721.   mov    cl,8
  4722.   xor    edx,edx
  4723. @@display_chan_dump:
  4724.   push   ecx edx
  4725. ;;;
  4726.   mov    ah,0fh
  4727.   push   esi
  4728.   mov    al,[byte esi+tfunk_chan.sample]
  4729.   movzx  esi,al
  4730.   shl    esi,5
  4731.   add    esi,offset funk_sb
  4732.   mov    edi,(1*2)+(36*160)
  4733.   add    edi,edx
  4734.   mov    cl,19
  4735.   call   byte_write2
  4736.   pop    esi
  4737. ;;;
  4738.   mov    ah,03h
  4739.   mov    edi,(56*2)+(36*160)
  4740.   add    edi,edx
  4741.   movzx  ebx,[word esi+tfunk_chan.command]
  4742.   call   display_command
  4743. ;;
  4744.   mov    edi,(61*2)+(36*160)
  4745.   add    edi,edx
  4746.   movzx  ebx,[word esi+tfunk_chan.note_command]
  4747.   call   display_command
  4748. ;;
  4749.   mov    edi,(66*2)+(36*160)
  4750.   add    edi,edx
  4751.   movzx  ebx,[word esi+tfunk_chan.volume_command]
  4752.   call   display_command
  4753. ;;
  4754.   mov    edi,(22*2)+(36*160)
  4755.   add    edi,[_0b8000h]
  4756.   add    edi,edx
  4757.   mov    bl,[byte esi+tfunk_chan.rvolume]
  4758.   shr    bl,3
  4759.   xor    cl,cl
  4760. @@p_trek_bar:
  4761.   cmp    cl,bl
  4762.   je     @@paint_end
  4763.   mov    al," "
  4764.   ja     @@asd
  4765.   mov    al,205
  4766.   jmp    @@asd
  4767. @@paint_end:
  4768.   mov    al,[byte esi+tfunk_chan.rvolume]
  4769.   and    al,111b
  4770.   add    al,198
  4771. @@asd:
  4772.   stosb
  4773.   inc    edi
  4774.   inc    cl
  4775.   cmp    cl,32
  4776.   jnz    @@p_trek_bar
  4777. ;;
  4778.   pop    edx ecx
  4779.   add    esi,size tfunk_chan
  4780.   add    edx,160
  4781.   dec    cl
  4782.   jnz    @@display_chan_dump
  4783.  
  4784.   ret
  4785. endp
  4786.  
  4787. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4788. ;                                                                          ;
  4789. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4790. ; dl = colour adjust ; eax = pattern ofs
  4791. proc display_trak
  4792.   and    al,11111b
  4793.   mov    edi,[_0b8000h]
  4794.   add    edi,((4*2)+(2*160))+1
  4795.   mov    ebx,eax
  4796.   shl    eax,7
  4797.   shl    ebx,5
  4798.   add    edi,eax
  4799.   add    edi,ebx
  4800.   mov    cl,9*8
  4801. @@hl_trek:
  4802.   and    [byte edi],1111b
  4803.   or     [byte edi],dl
  4804.   add    edi,2
  4805.   dec    cl
  4806.   jnz    @@hl_trek
  4807.   ret
  4808. endp
  4809.  
  4810. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4811. ;                                                                          ;
  4812. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4813. proc trak_pattern
  4814.   movzx  ebx,[byte funk_info.sequence_ofs]
  4815.   cmp    bl,80h
  4816.   jae    @@end
  4817.   cmp    bl,[byte sequence_ofs_old]
  4818.   jne    @@draw_pat
  4819.   mov    al,[byte pattern_ofs2_old]
  4820.   mov    ah,[byte funk_info.pattern_ofs]
  4821.   shr    al,5
  4822.   shr    ah,5
  4823.   cmp    al,ah
  4824.   je     @@clear_bar
  4825. @@draw_pat:
  4826.   mov    [byte sequence_ofs_old],bl
  4827.   movzx  ebx,[byte ebx+funk_hr.order_list]
  4828.   movzx  esi,bl
  4829.   mov    dh,[byte funk_info.pattern_ofs]
  4830.   and    dh,100000b
  4831.   call   display_pattern
  4832.   jmp    @@set_bar
  4833. @@clear_bar:
  4834.   xor    dl,dl
  4835.   movzx  eax,[byte pattern_ofs2_old]
  4836.   call   display_trak
  4837. @@set_bar:
  4838.   mov    dl,70h
  4839.   movzx  eax,[byte funk_info.pattern_ofs]
  4840.   mov    [byte pattern_ofs2_old],al
  4841.   call   display_trak
  4842. @@end:
  4843.   ret
  4844. endp
  4845.  
  4846. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4847. ;                                                                          ;
  4848. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4849. proc trak_play
  4850.   call   resync_sample_ptrs
  4851.   call   init_for_play
  4852.   cmp    [byte trakplay_type],2                        ; 1 = ply
  4853.   jb     @@dont_pay_from_mod
  4854.   movzx  eax,[byte seq_real]
  4855.   add    al,[byte seq_hl]
  4856.   cmp    [byte eax+funk_hr.order_list],080h
  4857.   jae    @@mess2
  4858.   @splash_on_sm "Backtracking, please wait"
  4859.   cli
  4860.   mov    [byte funk_info.trek_status],PLAY
  4861.   mov    al,[byte seq_real]
  4862.   add    al,[byte seq_hl]
  4863. @@back_trak:
  4864.   push   eax
  4865.   call   funk_tracker
  4866.   pop    eax
  4867.   cmp    [byte funk_info.sequence_ofs],al
  4868.   jne    @@back_trak
  4869.   mov    [byte funk_info.trek_status],STOP
  4870.   call   stop_all_voices
  4871.   sti
  4872.   sub    [byte trakplay_type],2
  4873.   @splash_off_sm
  4874. @@dont_pay_from_mod:
  4875.   mov    ecx,main_screen_size
  4876.   lea    esi,[main_screen]
  4877.   mov    edi,[_0b8000h]
  4878.   call   uncrush_text
  4879.   lea    esi,[song_name]
  4880.   mov    edi,(72*2)
  4881.   mov    cl,8
  4882.   mov    ah,0dh
  4883.   call   byte_write1
  4884.   cmp    [byte trakplay_type],1                        ; 1 = ply
  4885.   je     @@dis_ply
  4886.   mov    ecx,trakd_screen_size
  4887.   lea    esi,[trakd_screen]
  4888.   mov    edi,[_0b8000h]
  4889.   add    edi,5600
  4890.   call   uncrush_text
  4891.   jmp    @@dis_done
  4892. @@dis_ply:
  4893.   mov    ecx,trakp_screen_size
  4894.   lea    esi,[trakp_screen]
  4895.   mov    edi,[_0b8000h]
  4896.   add    edi,5600
  4897.   call   uncrush_text
  4898. @@dis_done:
  4899.   call   dis_chan_status
  4900.   call   display_seqlist
  4901.   cmp    [byte funk_info.no_of_sequences],0ffh
  4902.   je     @@mess1
  4903.   mov    [byte funk_info.trek_status],PLAY
  4904. @@input_loop:
  4905.   @WaitVertEnd
  4906.   @WaitVert
  4907.   call   trak_pattern
  4908.   cmp    [byte trakplay_type],1                        ; 1 = ply
  4909.   je     @@trak_ply
  4910.   call   track_screen_debug
  4911.   jmp    @@trak_done
  4912. @@trak_ply:
  4913.   call   track_screen_play
  4914. @@trak_done:
  4915.   cmp    [byte funk_info.trek_status],STOP
  4916.   je     @@exit
  4917.   call   key_pressed2
  4918.   jnc    @@input_loop
  4919.   call   get_key
  4920.   cmp    al,27
  4921.   je     @@exit
  4922.   call   channel_toggle
  4923.   jmp    @@input_loop
  4924. @@exit:
  4925.   mov    [byte funk_info.trek_status],STOP
  4926.   call   stop_all_voices
  4927.   ret
  4928. @@mess1:
  4929.   @error_mess "You can not play a song with an empty order list"
  4930.   ret
  4931. @@mess2:
  4932.   @error_mess "backtrack order out of range, try another sequence"
  4933.   ret
  4934. endp
  4935.  
  4936. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4937. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4938. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4939. ;                                                                          ;
  4940. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4941. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4942. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4943.  
  4944. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4945. ;                                                                          ;
  4946. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4947. proc init_vars
  4948.   mov    [byte edit_mode],0
  4949.   mov    [byte pat_number],0
  4950.   mov    [byte pat_real],0
  4951.   mov    [byte pat_hl],0
  4952.   mov    [byte pat_chan],0
  4953.   mov    [byte pat_old_hl],0
  4954.   mov    [byte pat_old_chan],0
  4955.   mov    [byte sam_real],0
  4956.   mov    [byte sam_hl],0
  4957.   mov    [byte sam_col],0
  4958.   mov    [byte note],0
  4959.   mov    [byte octave],2
  4960.   mov    [byte seq_real],0
  4961.   mov    [byte seq_hl],0
  4962.   mov    [word fdir_real],0
  4963.   mov    [byte fdir_hl],0
  4964.   ret
  4965. endp
  4966.  
  4967. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4968. ;                                                                          ;
  4969. ; displays file direct                                                     ;
  4970. ;                                                                          ;
  4971. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4972. proc sload_funk
  4973.   call   stop_all_voices
  4974.   lea    edx,[song_dir]
  4975.   call   set_directory
  4976.   mov    ecx,modefile_screen_size
  4977.   lea    esi,[modefile_screen]
  4978.   mov    edi,[_0b8000h]
  4979.   call   uncrush_text
  4980.   lea    edx,[file_search_funk]
  4981.   call   load_fdirectory
  4982.   call   display_fdir
  4983. @@input_loop:
  4984.   call   get_key
  4985.   cmp    al,27
  4986.   je     @@exit
  4987.   cmp    ax,kb_up
  4988.   je     @@hkb_up
  4989.   cmp    ax,kb_down
  4990.   je     @@hkb_down
  4991.   cmp    ax,kb_pageup
  4992.   je     @@hkb_pageup
  4993.   cmp    ax,kb_pagedn
  4994.   je     @@hkb_pagedn
  4995.   cmp    al,13
  4996.   je     @@enter_key
  4997.   jmp    @@input_loop
  4998. @@scroll_fdir_up:
  4999.   call   display_fdir
  5000.   jmp    @@input_loop
  5001. @@scroll_fdir_dw:
  5002.   call   display_fdir
  5003.   jmp    @@input_loop
  5004. @@hkb_up:
  5005.   call   fdir_scroll_up
  5006.   call   display_fdir
  5007.   jmp    @@input_loop
  5008. @@hkb_down:
  5009.   call   fdir_scroll_dn
  5010.   call   display_fdir
  5011.   jmp    @@input_loop
  5012. @@hkb_pageup:
  5013.   call   fdir_scroll_pageup
  5014.   call   display_fdir
  5015.   jmp    @@input_loop
  5016. @@hkb_pagedn:
  5017.   call   fdir_scroll_pagedn
  5018.   call   display_fdir
  5019.   jmp    @@input_loop
  5020. @@enter_key:
  5021.   mov    cl,size tfdirectory
  5022.   mov    ax,[word fdir_real]
  5023.   add    al,[byte fdir_hl]
  5024.   adc    ah,0
  5025.   mul    cl
  5026.   movzx  esi,ax
  5027.   add    esi,[dword fdirectory_buffer]
  5028.   cmp    [byte esi+tfdirectory.attr],10h
  5029.   jne    @@load_file
  5030.   push   esi
  5031.   lea    esi,[song_dir]
  5032.   mov    edi,esi
  5033.   call   get_directory
  5034.   pop    esi
  5035.   lea    esi,[esi+tfdirectory.fname]
  5036.   call   goto_end_str
  5037.   cmp    ebx,3
  5038.   jne    @@form_path2
  5039.   call   mini_trans_str
  5040.   jmp    @@change_dir
  5041. @@form_path2:
  5042.   mov    [byte edi+ebx],'\'
  5043.   inc    ebx
  5044.   call   mini_trans_str
  5045. @@change_dir:
  5046.   lea    edx,[song_dir]
  5047.   call   set_directory
  5048.   lea    esi,[song_dir]
  5049.   call   get_directory
  5050.   lea    edx,[file_search_funk]
  5051.   call   load_fdirectory
  5052.   call   display_fdir
  5053.   jmp    @@input_loop
  5054. @@load_file:
  5055.   lea    edi,[song_name]
  5056.   lea    esi,[esi+tfdirectory.fname]
  5057.   xor    ebx,ebx
  5058.   call   mini_trans_str
  5059.   lea    esi,[song_name]
  5060.   mov    edi,(72*2)
  5061.   mov    cl,8
  5062.   mov    ah,0dh
  5063.   call   byte_write1
  5064.   lea    edx,[song_name]
  5065.   @splash_on_sm  "Loading music, please wait"
  5066.   call   load_funk_module
  5067.   cmp    al,1
  5068.   je     @@mess1
  5069.   cmp    al,2
  5070.   je     @@mess2
  5071.   cmp    al,3
  5072.   je     @@mess3
  5073.   @splash_off_sm
  5074.   jmp    @@end_mess
  5075. @@mess1:
  5076.   @error_mess "Error: Can not load song"
  5077.   jmp    @@end_mess
  5078. @@mess2:
  5079.   @error_mess "Error: A corrupted or invalid funk song!"
  5080.   jmp    @@end_mess
  5081. @@mess3:
  5082.   @error_mess "Abort: Not enough sample memory"
  5083. @@end_mess:
  5084.   call   init_vars
  5085. @@exit:
  5086.   call   display_mode
  5087.   ret
  5088. endp
  5089.  
  5090. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5091. ;                                                                          ;
  5092. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5093. proc isave_funk_module
  5094.   @splash_on_sm  "Saving your music, please wait"
  5095.   call   save_funk_module
  5096.   cmp    al,1
  5097.   je     @@mess1
  5098.   cmp    al,2
  5099.   je     @@mess2
  5100.   cmp    al,3
  5101.   je     @@mess3
  5102.   cmp    al,4
  5103.   je     @@mess4
  5104.   @splash_off_sm
  5105.   ret
  5106. @@mess1:
  5107.   @error_mess "Error: Can not save song with empty order list"
  5108.   ret
  5109. @@mess2:
  5110.   @error_mess "Error: Can not save song with no samples"
  5111.   ret
  5112. @@mess3:
  5113.   @error_mess "Error: Unable to save song"
  5114.   ret
  5115. @@mess4:
  5116.   @error_mess "Error: Not enough space on harddisk to save song"
  5117.   ret
  5118. endp
  5119.  
  5120. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5121. ;                                                                          ;
  5122. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5123. proc ssave_funk
  5124.   mov    ch,8
  5125.   mov    edx,0048h
  5126.   call   get_input
  5127.   jc     @@abort
  5128.   lea    esi,[song_name]
  5129.   mov    cl,8
  5130.   call   get_string
  5131.   mov    [byte esi],"."
  5132.   mov    [byte esi+1],"F"
  5133.   mov    [byte esi+2],"N"
  5134.   mov    [byte esi+3],"K"
  5135.   mov    [byte esi+4],0
  5136.   lea    edx,[song_dir]
  5137.   call   set_directory
  5138.   lea    edx,[song_name]
  5139.   call   isave_funk_module
  5140. @@abort:
  5141.   lea    esi,[song_name]
  5142.   mov    edi,(72*2)
  5143.   mov    cl,8
  5144.   mov    ah,0dh
  5145.   call   byte_write1
  5146.   ret
  5147. endp
  5148.  
  5149. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5150. ;                                                                          ;
  5151. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5152. proc dump_GUSmem
  5153.   mov    al,[byte init_settings.card_type]
  5154.   cmp    al,GUS_VARB_CARD
  5155.   je     @@GUS_mem_move
  5156.   cmp    al,GUS_FIXB_CARD
  5157.   je     @@GUS_mem_move
  5158.   ret
  5159. @@GUS_mem_move:
  5160. ; disk space test
  5161.   mov    ah,36h
  5162.   xor    dl,dl
  5163.   int    21h
  5164.   mul    ecx
  5165.   mul    ebx
  5166.   or     edx,edx
  5167.   jz     @@heaps_of_space
  5168.   cmp    eax,[dword sample_memory_lim]
  5169.   jb     @@mess3
  5170. @@heaps_of_space:
  5171.   @splash_on_sm  "dumping GUSmem to '\GUS_DUMP·SND', please wait"
  5172.   mov    eax,3c00h
  5173.   lea    edx,[@@dump_name]                        ; create
  5174.   xor    ecx,ecx
  5175.   int    21h
  5176.   jc     @@mess3
  5177.   mov    [dword file_handle_funk],eax
  5178.   call   GUS_reset
  5179.   mov    eax,[dword sample_memory_lim]
  5180.   or     eax,eax
  5181.   jz     @@end
  5182.   mov    ebx,4000h
  5183.   xor    edx,edx
  5184.   div    ebx
  5185.   mov    ecx,eax
  5186.   mov    esi,[dword funk_info.sample_ptrs]
  5187. @@dnlop:
  5188.   push   ecx
  5189.   mov    edi,[dword fdirectory_buffer]
  5190.   mov    ecx,4000h
  5191.   call   GUS_dnload
  5192.   mov    ebx,[dword file_handle_funk]
  5193.   mov    edx,[dword fdirectory_buffer]
  5194.   mov    ecx,4000h
  5195.   mov    ah,40h
  5196.   int    21h
  5197.   pop    ecx
  5198.   dec    ecx
  5199.   jnz    @@dnlop
  5200.   call   GUS_reset
  5201. @@end:
  5202.   mov    ebx,[dword file_handle_funk]
  5203.   mov    ah,3eh                                   ; close
  5204.   int    21h
  5205.   call   GUS_intready
  5206.   @splash_off_sm
  5207.   ret
  5208. @@dump_name:
  5209.   db     "\GUS_DUMP.SND",0
  5210. @@mess3:
  5211.   @error_mess "Error: Unable to save dump"
  5212.   ret
  5213. endp
  5214.  
  5215. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5216. ;                                                                          ;
  5217. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5218. proc display_s_info
  5219.   mov    edi,(16*2)+(37*160)
  5220.   mov    eax,[dword sample_memory_lim]
  5221.   call   print_decn9
  5222.   mov    edi,(46*2)+(37*160)
  5223.   mov    eax,[dword sample_block_size]
  5224.   sub    eax,[dword funk_info.sample_ptrs]
  5225.   call   print_decn9
  5226.   mov    edi,(46*2)+(38*160)
  5227.   mov    eax,[dword sample_memory_lim]
  5228.   mov    ecx,[dword sample_block_size]
  5229.   sub    ecx,[dword funk_info.sample_ptrs]
  5230.   sub    eax,ecx
  5231.   call   print_decn9
  5232.   ret
  5233. endp
  5234.  
  5235. proc other_info
  5236. ;Display date
  5237.   mov    al,[byte funk_hr.info]
  5238.   and    al,11111b
  5239.   mov    edi,(68*2)+(40*160)
  5240.   call   print_decn1
  5241.   movzx  eax,[word funk_hr.info]
  5242.   shr    eax,5
  5243.   and    al,1111b
  5244.   mov    edi,(71*2)+(40*160)
  5245.   call   print_decn1
  5246.   movzx  eax,[word funk_hr.info]
  5247.   shr    eax,9
  5248.   and    eax,1111111b
  5249.   add    eax,1980
  5250.   mov    edi,(74*2)+(40*160)
  5251.   call   print_decn3
  5252. ;display cpu
  5253.   movzx  esi,[byte 2+funk_hr.info]
  5254.   shr    esi,1
  5255.   and    esi,1111000b
  5256.   add    esi,offset @@cpu_display
  5257.   mov    edi,(68*2)+(41*160)
  5258.   mov    ah,1dh
  5259.   mov    cl,8
  5260.   call   byte_write2
  5261. ;display card
  5262.   movzx  esi,[byte 2+funk_hr.info]
  5263.   and    esi,1111b
  5264.   lea    esi,[esi*8]
  5265.   add    esi,offset @@card_display
  5266.   mov    edi,(68*2)+(42*160)
  5267.   mov    ah,1dh
  5268.   mov    cl,8
  5269.   call   byte_write2
  5270. ; display memory
  5271.   movzx  eax,[byte 3+funk_hr.info]
  5272.   and    al,11111110b
  5273.   add    al,2
  5274.   shl    eax,18
  5275.   mov    edi,(68*2)+(43*160)
  5276.   call   print_decn9
  5277. ;precision
  5278.   lea    esi,[@@precision1]
  5279.   test   [byte 3+funk_hr.info],10000000b
  5280.   jz     @@8bit_module
  5281.   lea    esi,[@@precision2]
  5282. @@8bit_module:
  5283.   mov    edi,(68*2)+(44*160)
  5284.   mov    ah,1dh
  5285.   mov    cl,2
  5286.   call   byte_write2
  5287. ; LZH size
  5288.   mov    edi,(68*2)+(45*160)
  5289.   mov    eax,[dword funk_hr.LZH_check_size]
  5290.   call   print_decn9
  5291. ; LZH checksum
  5292.   mov    edi,(68*2)+(46*160)
  5293.   mov    ecx,[dword funk_hr.LZH_check_sum]
  5294.   mov    ah,1dh
  5295.   call   display_dword
  5296.   ret
  5297. @@cpu_display:
  5298.   db     "Unknown "     ;0
  5299.   db     "IBM ????"     ;1
  5300.   db     "IBM ????"     ;2
  5301.   db     "Intel386"     ;3
  5302.   db     "Intel486"     ;4
  5303.   db     "Pentium "     ;5
  5304.   db     ">Pentium"     ;6
  5305.   db     ">Pentium"     ;7
  5306.   db     ">Pentium"     ;8
  5307.   db     ">Pentium"     ;9
  5308.   db     ">Pentium"     ;a
  5309.   db     ">Pentium"     ;b
  5310.   db     ">Pentium"     ;c
  5311.   db     ">Pentium"     ;d
  5312.   db     ">Pentium"     ;e
  5313.   db     ">Pentium"     ;f
  5314. @@card_display:
  5315.   db     "SB 2.0  "     ;0
  5316.   db     "SB PRO  "     ;1
  5317.   db     "GUS v<> "     ;2
  5318.   db     "SB COMP "     ;3
  5319.   db     "SB 16   "     ;4
  5320.   db     "GUS f<> "     ;5
  5321.   db     "Ripped  "     ;6
  5322.   db     "PAS 16  "     ;7
  5323.   db     "????????"     ;8
  5324.   db     "????????"     ;9
  5325.   db     "????????"     ;a
  5326.   db     "????????"     ;b
  5327.   db     "????????"     ;c
  5328.   db     "????????"     ;d
  5329.   db     "????????"     ;e
  5330.   db     "????????"     ;f
  5331. @@precision1:
  5332.   db     "08"
  5333. @@precision2:
  5334.   db     "16"
  5335. endp
  5336.  
  5337. proc display_mode
  5338.   @WaitVertEnd
  5339.   cmp    [byte edit_mode],0
  5340.   je     @@se
  5341.   cmp    [byte edit_mode],1
  5342.   je     @@pe
  5343.   ret
  5344. @@se:
  5345.   mov    ecx,se_screen_size
  5346.   lea    esi,[se_screen]
  5347.   mov    edi,[_0b8000h]
  5348.   call   uncrush_text
  5349.   call   display_samples
  5350.   call   display_s_info
  5351.   call   update_octave
  5352.   call   other_info
  5353.   jmp    @@all
  5354. @@pe:
  5355.   mov    ecx,main_screen_size
  5356.   lea    esi,[main_screen]
  5357.   mov    edi,[_0b8000h]
  5358.   call   uncrush_text
  5359.   mov    ecx,pe_screen_size
  5360.   lea    esi,[pe_screen]
  5361.   mov    edi,[_0b8000h]
  5362.   add    edi,5600
  5363.   call   uncrush_text
  5364.   call   dis_sample_name
  5365.   call   dis_pattern_no
  5366.   call   dis_order_loop
  5367.   call   update_octave
  5368.   movzx  esi,[byte pat_number]
  5369.   mov    dh,[byte pat_real]
  5370.   call   display_pattern
  5371.   call   display_seqlist
  5372.   mov    cl,20h
  5373.   call   display_slot
  5374.   call   dis_chan_status
  5375. @@all:
  5376.   lea    esi,[song_name]
  5377.   mov    edi,(72*2)
  5378.   mov    cl,8
  5379.   mov    ah,0dh
  5380.   call   byte_write1
  5381.   ret
  5382. endp
  5383.  
  5384. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5385. ;                                                                          ;
  5386. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5387. proc set_colour
  5388.   @splash_on_sm  "What Colour do you wish to change?: "
  5389.   mov    ch,2
  5390.   mov    dh,49
  5391.   mov    dl,36
  5392.   call   get_input
  5393.   jc     @@abort
  5394.   call   get_ibyte
  5395.   mov    [byte @@colour],al
  5396.   lea    edi,[@@red_v]
  5397.   mov    ecx,3
  5398.   mov    edx,3c7h                                   ; read palette
  5399.   out    dx,al
  5400.   add    edx,2
  5401.   rep    insb
  5402. ; returns al
  5403. @@input_loop:
  5404.   call   get_key
  5405.   cmp    al,27
  5406.   je     @@abort
  5407.   cmp    al,"q"
  5408.   je     @@dec_r
  5409.   cmp    al,"a"
  5410.   je     @@inc_r
  5411.   cmp    al,"w"
  5412.   je     @@dec_g
  5413.   cmp    al,"s"
  5414.   je     @@inc_g
  5415.   cmp    al,"e"
  5416.   je     @@dec_b
  5417.   cmp    al,"d"
  5418.   je     @@inc_b
  5419.   jmp    @@input_loop
  5420. @@dec_r:
  5421.   cmp    [byte @@red_v],0
  5422.   je     @@input_loop
  5423.   dec    [byte @@red_v]
  5424.   jmp    @@set_pal
  5425. @@inc_r:
  5426.   cmp    [byte @@red_v],63
  5427.   je     @@input_loop
  5428.   inc    [byte @@red_v]
  5429.   jmp    @@set_pal
  5430. @@dec_g:
  5431.   cmp    [byte @@grn_v],0
  5432.   je     @@input_loop
  5433.   dec    [byte @@grn_v]
  5434.   jmp    @@set_pal
  5435. @@inc_g:
  5436.   cmp    [byte @@grn_v],63
  5437.   je     @@input_loop
  5438.   inc    [byte @@grn_v]
  5439.   jmp    @@set_pal
  5440. @@dec_b:
  5441.   cmp    [byte @@ble_v],0
  5442.   je     @@input_loop
  5443.   dec    [byte @@ble_v]
  5444.   jmp    @@set_pal
  5445. @@inc_b:
  5446.   cmp    [byte @@ble_v],63
  5447.   je     @@input_loop
  5448.   inc    [byte @@ble_v]
  5449. @@set_pal:
  5450.   lea    esi,[@@red_v]
  5451.   mov    ecx,3
  5452.   mov    edx,3c8h                                   ; read palette
  5453.   mov    al,[byte @@colour]
  5454.   out    dx,al
  5455.   inc    edx
  5456.   rep    outsb
  5457.   mov    ah,0fh
  5458.   mov    edi,(60*2)+(49*160)
  5459.   mov    bl,[byte @@red_v]
  5460.   call   display_byte
  5461.   mov    edi,(64*2)+(49*160)
  5462.   mov    bl,[byte @@grn_v]
  5463.   call   display_byte
  5464.   mov    edi,(68*2)+(49*160)
  5465.   mov    bl,[byte @@ble_v]
  5466.   call   display_byte
  5467.   jmp    @@input_loop
  5468. @@abort:
  5469.   @splash_off_sm
  5470.   ret
  5471. @@red_v:
  5472.   db     ?
  5473. @@grn_v:
  5474.   db     ?
  5475. @@ble_v:
  5476.   db     ?
  5477. @@colour:
  5478.   db     ?
  5479. endp
  5480.  
  5481. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5482. ;                                                                          ;
  5483. ; Shell to MessyDOS (from DOS32 libraries)                                 ;
  5484. ;                                                                          ;
  5485. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5486. proc dos_shell
  5487.   mov    eax,3h
  5488.   int    10h
  5489.   mov    edx,offset @@shell_mess
  5490.   mov    ah,9
  5491.   int    21h
  5492. ; search for the "COMSPEC=" environemnt varibles
  5493.   mov    ax,0EE02h                        ;Get DOS32 address information
  5494.   int    31h                              ;Returns EDI -> environment address
  5495. @@get_str_loop:
  5496.   cmp    [dword edi],'SMOC'               ;cmp the string "COMSPEC="
  5497.   jne    @@not_string
  5498.   cmp    [dword edi+4],'=CEP'
  5499.   je     @@got_string                     ;if equal exit loop
  5500. @@not_string:
  5501.   mov    al,0                             ; Scan environment for a zero
  5502.   mov    ecx,20000                        ; and get next varible
  5503.   repne  scasb
  5504.   jmp    @@get_str_loop                   ; loop around again
  5505. @@got_string:
  5506.   add    edi,8
  5507.   mov    edx,edi
  5508. ;  mov    [comspec_ptr],edi                ; save address of the envir
  5509. ; Call the 32bit version of the "load and execute" DOS service
  5510.   mov    ah,4Bh
  5511.   mov    al,0
  5512.   mov    edi,00000                        ; DS:EDI -> envrironment
  5513.   mov    esi,Offset @@dummy_cmd_tail      ; DS:ESI -> command tail
  5514. ;  mov    edx,[comspec_ptr]                ; DS:EDX -> ASCIIZ string
  5515.   int    21h
  5516.   call   setup_screen
  5517.   call   display_mode
  5518.   ret
  5519. @@shell_mess:         db "Type 'exit' to return to tracker...$"
  5520. @@dummy_cmd_tail      db 1,' '
  5521. endp
  5522.  
  5523. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5524. ;                                                                          ;
  5525. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5526. proc main_handle
  5527.   call   display_mode
  5528.   lea    esi,[splash_screen]
  5529.   mov    edi,[_0b8000h]
  5530.   add    edi,(19*2)+(14*160)
  5531.   mov    ebx,42
  5532.   mov    dl,12
  5533.   call   paint_window
  5534.  
  5535.   call   get_key
  5536.   call   display_mode
  5537. @@input_loop:
  5538.   call   get_key
  5539.   cmp    ax,kb_altx
  5540.   je     @@exit
  5541.   cmp    ax,kb_f1
  5542.   je     @@set_to_se
  5543.   cmp    ax,kb_f2
  5544.   je     @@set_to_pe
  5545.   cmp    ax,kb_f3
  5546.   je     @@dis_help
  5547.   cmp    ax,kb_f5
  5548.   je     @@set_to_trakdbg
  5549.   cmp    ax,kb_altf5
  5550.   je     @@set_to_trakply
  5551.   cmp    ax,kb_f6
  5552.   je     @@set_to_trakfm_dbg
  5553.   cmp    ax,kb_altf6
  5554.   je     @@set_to_trakfm_ply
  5555.   cmp    ax,kb_f8
  5556.   je     @@load
  5557.   cmp    ax,kb_f9
  5558.   je     @@saveas
  5559.   cmp    ax,kb_f10
  5560.   je     @@save
  5561.   cmp    ax,kb_altv
  5562.   je     @@dumptofile
  5563.   cmp    ax,kb_altn
  5564.   je     @@clear_module
  5565.   cmp    ax,kb_altm
  5566.   je     @@set_colour
  5567.   cmp    ax,kb_altd
  5568.   je     @@dosshell
  5569.   cmp    [byte edit_mode],0
  5570.   je     @@se
  5571.   cmp    [byte edit_mode],1
  5572.   je     @@pe
  5573.   jmp    @@input_loop
  5574. @@dis_help:
  5575.   mov    ecx,help_screen_size
  5576.   lea    esi,[help_screen]
  5577.   call   help_scroll
  5578.   jmp    @@input_loop
  5579. @@set_to_se:
  5580.   mov    [byte edit_mode],0
  5581.   call   display_mode
  5582.   jmp    @@input_loop
  5583. @@set_to_pe:
  5584.   mov    [byte edit_mode],1
  5585.   call   display_mode
  5586.   jmp    @@input_loop
  5587. @@set_to_trakdbg:
  5588.   mov    [byte trakplay_type],0
  5589.   call   trak_play
  5590.   call   display_mode
  5591.   jmp    @@input_loop
  5592. @@set_to_trakply:
  5593.   mov    [byte trakplay_type],1
  5594.   call   trak_play
  5595.   call   display_mode
  5596.   jmp    @@input_loop
  5597. @@set_to_trakfm_dbg:
  5598.   mov    [byte trakplay_type],2
  5599.   call   trak_play
  5600.   call   display_mode
  5601.   jmp    @@input_loop
  5602. @@set_to_trakfm_ply:
  5603.   mov    [byte trakplay_type],3
  5604.   call   trak_play
  5605.   call   display_mode
  5606.   jmp    @@input_loop
  5607. @@se:
  5608.   call   se_handle
  5609.   jmp    @@input_loop
  5610. @@pe:
  5611.   call   pe_handle
  5612.   jmp    @@input_loop
  5613. @@load:
  5614.   call   sload_funk
  5615.   jmp    @@input_loop
  5616. @@saveas:
  5617.   call   ssave_funk
  5618.   jmp    @@input_loop
  5619. @@save:
  5620.   lea    edx,[song_dir]
  5621.   call   set_directory
  5622.   lea    edx,[song_name]
  5623.   call   isave_funk_module
  5624.   jmp    @@input_loop
  5625. @@clear_module:
  5626.   lea    esi,[@@file_name]
  5627.   lea    edi,[song_name]
  5628.   mov    ecx,13
  5629.   rep    movsb
  5630.   call   clear_all_funk
  5631.   call   display_mode
  5632.   jmp    @@input_loop
  5633. @@set_colour:
  5634.   call   set_colour
  5635.   jmp    @@input_loop
  5636. @@dumptofile:
  5637.   call   dump_GUSmem
  5638.   jmp    @@input_loop
  5639. @@dosshell:
  5640.   call   dos_shell
  5641.   jmp    @@input_loop
  5642. @@exit:
  5643.   @splash_on_sm  "Retreating?, Do you wish to save your music? (y/n)"
  5644.   call   get_key
  5645.   cmp    al,"y"
  5646.   je     @@save_song
  5647.   cmp    al,"Y"
  5648.   je     @@save_song
  5649.   ret
  5650. @@save_song:
  5651.   lea    edx,[song_dir]
  5652.   call   set_directory
  5653.   lea    edx,[song_name]
  5654.   call   isave_funk_module
  5655.   ret
  5656. @@file_name:
  5657.   db     "NEW_SONG.FNK",0
  5658. endp
  5659.  
  5660. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5661. ;                                                                         ;
  5662. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5663. start32:
  5664. ;  call   debug
  5665.   cld
  5666.  
  5667.   @stdio "FunkTracker/Super Real Darwin! - Coded by Jason Nunn (JsNO)",13,10
  5668.   call   get_cpuid
  5669.  
  5670.   call   scard_env
  5671.   cmp    [byte init_settings.card_type],0ffh
  5672.   jne    @@no_default
  5673.   mov    [byte init_settings.card_type],0
  5674.   mov    [word init_settings.PORT_no],210h
  5675.   mov    [byte init_settings.IRQ_no],2
  5676.   mov    [byte init_settings.DMA_no],1
  5677.   mov    [byte init_settings.IRQ_no2],2
  5678.   mov    [byte init_settings.DMA_no2],1
  5679. @@no_default:
  5680.   call   card_settings
  5681.   jc     @@byebye
  5682.   mov    eax,size tfdirectory
  5683.   mov    ecx,fdir_max_length
  5684.   mul    ecx
  5685.   add    eax,1000h
  5686.   mov    edx,eax
  5687.   call   Allocate_Memory
  5688.   jc     @@memory_error
  5689.   mov    [dword fdirectory_buffer],edx
  5690.   call   init_vars
  5691.   call   scard_detect
  5692.   jc     @@card_not_found
  5693.   lea    esi,[initial_dir]
  5694.   call   get_directory
  5695.   lea    esi,[song_dir]
  5696.   call   get_directory
  5697.   lea    esi,[sample_dir]
  5698.   call   get_directory
  5699.   call   scard_init
  5700.   call   clear_all_funk
  5701.   call   setup_screen
  5702.   call   main_handle
  5703.   call   scard_deinit
  5704.   call   text_ded_pfout
  5705.   lea    edx,[initial_dir]
  5706.   call   set_directory
  5707. @@byebye:
  5708.   mov    eax,3h
  5709.   int    10h
  5710.   mov    ecx,end_screen_size
  5711.   lea    esi,[end_screen]
  5712.   mov    edi,[_0b8000h]
  5713.   call   uncrush_text
  5714.   mov    ah,02h
  5715.   xor    bh,bh
  5716.   mov    edx,0a00h
  5717.   int    10h
  5718.   mov    eax,4c00h
  5719.   int    21h
  5720. @@card_not_found:
  5721.   mov    eax,3h
  5722.   int    10h
  5723.   @stdio "Soundcard not Detected/ or possible DMA allocation error.",13,10
  5724.   mov    eax,4c00h
  5725.   int    21h
  5726. @@memory_error:
  5727.   mov    eax,3h
  5728.   int    10h
  5729.   @stdio "Memory Error. FunkTracker unable to run.",13,10
  5730.   mov    eax,4c00h
  5731.   int    21h
  5732. ends
  5733.  
  5734. end
  5735.