     1                                  ; ****************************************************************************
     2                                  ; playwav6.s (for TRDOS 386)
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; PLAYWAV6.PRG ! AC'97 (ICH) .WAV PLAYER program by Erdogan TAN
     5                                  ;
     6                                  ; 25/11/2023
     7                                  ;
     8                                  ; [ Last Modification: 01/06/2024 ]
     9                                  ;
    10                                  ; Modified from PLAYWAV5.PRG .wav player program by Erdogan Tan, 18/08/2020
    11                                  ;
    12                                  ; Assembler: NASM version 2.15
    13                                  ;	     nasm playwav6.s -l playwav6.txt -o PLAYWAV6.PRG	
    14                                  ; ----------------------------------------------------------------------------
    15                                  ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
    16                                  
    17                                  ; previous version: playwav3.s (17/06/2017)
    18                                  
    19                                  ; CODE
    20                                  
    21                                  ; 14/07/2020
    22                                  ; 31/12/2017
    23                                  ; TRDOS 386 (v2.0) system calls
    24                                  _ver 	equ 0
    25                                  _exit 	equ 1
    26                                  _fork 	equ 2
    27                                  _read 	equ 3
    28                                  _write	equ 4
    29                                  _open	equ 5
    30                                  _close 	equ 6
    31                                  _wait 	equ 7
    32                                  _create	equ 8
    33                                  _rename	equ 9
    34                                  _delete	equ 10
    35                                  _exec	equ 11
    36                                  _chdir	equ 12
    37                                  _time 	equ 13
    38                                  _mkdir 	equ 14
    39                                  _chmod	equ 15
    40                                  _rmdir	equ 16
    41                                  _break	equ 17
    42                                  _drive	equ 18
    43                                  _seek	equ 19
    44                                  _tell 	equ 20
    45                                  _memory	equ 21
    46                                  _prompt	equ 22
    47                                  _path	equ 23
    48                                  _env	equ 24
    49                                  _stime	equ 25
    50                                  _quit	equ 26
    51                                  _intr	equ 27
    52                                  _dir	equ 28
    53                                  _emt 	equ 29
    54                                  _ldrvt 	equ 30
    55                                  _video 	equ 31
    56                                  _audio	equ 32
    57                                  _timer	equ 33
    58                                  _sleep	equ 34
    59                                  _msg    equ 35
    60                                  _geterr	equ 36
    61                                  _fpstat	equ 37
    62                                  _pri	equ 38
    63                                  _rele	equ 39
    64                                  _fff	equ 40
    65                                  _fnf	equ 41
    66                                  _alloc	equ 42
    67                                  _dalloc equ 43
    68                                  _calbac equ 44
    69                                  _dma	equ 45
    70                                  
    71                                  %macro sys 1-4
    72                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    73                                      ; 03/09/2015	
    74                                      ; 13/04/2015
    75                                      ; Retro UNIX 386 v1 system call.	
    76                                      %if %0 >= 2   
    77                                          mov ebx, %2
    78                                          %if %0 >= 3    
    79                                              mov ecx, %3
    80                                              %if %0 = 4
    81                                                 mov edx, %4   
    82                                              %endif
    83                                          %endif
    84                                      %endif
    85                                      mov eax, %1
    86                                      ;int 30h
    87                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
    88                                  %endmacro
    89                                  
    90                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    91                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    92                                  
    93                                  BUFFERSIZE	equ	32768	; audio buffer size 
    94                                  ENDOFFILE       equ     1	; flag for knowing end of file
    95                                  
    96                                  [BITS 32]
    97                                  
    98                                  [ORG 0] 
    99                                  
   100                                  _STARTUP:
   101                                  	; Prints the Credits Text.
   102                                  	sys	_msg, Credits, 255, 0Bh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000000 BB[6A200000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000005 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000000A BA0B000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000000F B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000014 CD40                <1>  int 40h
   103                                  
   104                                  	; clear bss
   105 00000016 B9[B5230000]            	mov	ecx, bss_end
   106 0000001B BF[2A230000]            	mov	edi, bss_start
   107 00000020 29F9                    	sub	ecx, edi
   108 00000022 D1E9                    	shr	ecx, 1
   109 00000024 31C0                    	xor	eax, eax
   110 00000026 F366AB                  	rep	stosw
   111                                  
   112                                  	; Detect (& Enable) AC'97 Audio Device
   113 00000029 E892040000              	call	DetectAC97
   114 0000002E 731B                    	jnc     short GetFileName
   115                                  
   116                                  _dev_not_ready:
   117                                  ; couldn't find the audio device!
   118                                  	sys	_msg, noDevMsg, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000030 BB[21210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000035 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000003A BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000003F B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000044 CD40                <1>  int 40h
   119 00000046 E94F040000                      jmp     Exit
   120                                  
   121                                  GetFileName:  
   122 0000004B 89E6                    	mov	esi, esp
   123 0000004D AD                      	lodsd
   124 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   125                                  	       ; (program file name & mod file name)
   126 00000051 0F8251040000            	jb	pmsg_usage ; nothing to do
   127                                  
   128 00000057 AD                      	lodsd ; program file name address 
   129 00000058 AD                      	lodsd ; mod file name address (file to be read)
   130 00000059 89C6                    	mov	esi, eax
   131 0000005B BF[55230000]            	mov	edi, wav_file_name
   132                                  ScanName:       
   133 00000060 AC                      	lodsb
   134 00000061 84C0                    	test	al, al
   135 00000063 0F843F040000            	je	pmsg_usage
   136 00000069 3C20                    	cmp	al, 20h
   137 0000006B 74F3                    	je	short ScanName	; scan start of name.
   138 0000006D AA                      	stosb
   139 0000006E B4FF                    	mov	ah, 0FFh
   140                                  a_0:	
   141 00000070 FEC4                    	inc	ah
   142                                  a_1:
   143 00000072 AC                      	lodsb
   144 00000073 AA                      	stosb
   145 00000074 3C2E                    	cmp	al, '.'
   146 00000076 74F8                    	je	short a_0	
   147 00000078 20C0                    	and	al, al
   148 0000007A 75F6                    	jnz	short a_1
   149                                  
   150 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   151 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   152                                  SetExt:
   153 00000080 4F                      	dec	edi
   154 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   155 00000087 C6470400                	mov	byte [edi+4], 0
   156                                  
   157                                  _1:
   158                                  
   159                                  ; 26/11/2023
   160                                  %if 0
   161                                  	; Allocate Audio Buffer (for user)
   162                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   163                                  	; 26/11/2023
   164                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   165                                  	jnc	short _2
   166                                  error_exit:
   167                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   168                                  	jmp	Exit
   169                                  _2:
   170                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   171                                  	; bl = 0, bh = 4
   172                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   173                                  
   174                                  	sys	_video, 0400h
   175                                  	cmp	eax, 0B8000h
   176                                  	jne	short error_exit
   177                                  
   178                                  	; Initialize Audio Device (bh = 3)
   179                                  	sys	_audio, 0301h, 0, audio_int_handler 
   180                                  ;	jc	short error_exit
   181                                  _3:
   182                                  
   183                                  %endif
   184 0000008B E893060000              	call	write_audio_dev_info 
   185                                  
   186                                  ; open the file
   187                                          ; open existing file
   188 00000090 E838040000                      call    openFile ; no error? ok.
   189 00000095 731B                            jnc     short _gsr
   190                                  
   191                                  ; file not found!
   192                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000097 BB[4C210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000009C B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000000A1 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000000A6 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000000AB CD40                <1>  int 40h
   193                                  _exit_:
   194 000000AD E9E8030000                      jmp     Exit
   195                                  
   196                                  _gsr:  
   197 000000B2 E850040000                     	call    getSampleRate		; read the sample rate
   198                                                                          ; pass it onto codec.
   199                                  	;jc	Exit
   200                                  	; 25/11/2023
   201 000000B7 72F4                    	jc	short _exit_
   202                                  
   203 000000B9 66A3[2E230000]          	mov	[sample_rate], ax
   204 000000BF 880D[2C230000]          	mov	[stmo], cl
   205 000000C5 8815[2D230000]          	mov	[bps], dl
   206                                  
   207                                  	; 26/11/2023
   208 000000CB C605[A8230000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   209 000000D2 FEC9                    	dec	cl
   210 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   211 000000D6 FE05[A8230000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   212                                  _gsr_1:	
   213 000000DC 80FA08                  	cmp	dl, 8 
   214 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   215 000000E1 FE05[A8230000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   216                                  _gsr_2:	
   217                                  	; 06/06/2017
   218                                  	sys	_audio, 0E00h ; get audio controller info
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000000E7 BB000E0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000000EC B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000000F1 CD40                <1>  int 40h
   219 000000F3 0F82F5020000            	jc	error_exit ; 25/11/2023
   220                                  
   221                                  	;cmp	ah, 2 ; ICH ? (Intel AC'97 Audio Controller)
   222                                  	;jne	_dev_not_ready	
   223                                  
   224                                  	; EAX = IRQ Number in AL
   225                                  	;	Audio Device Number in AH 
   226                                  	; EBX = DEV/VENDOR ID
   227                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   228                                  	; ECX = BUS/DEV/FN 
   229                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   230                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   231                                  	;      (Low word, DX = NAMBAR address)
   232                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   233                                  
   234 000000F9 A2[A7230000]            	mov	[ac97_int_ln_reg], al
   235 000000FE 891D[A9230000]          	mov	[dev_vendor], ebx
   236 00000104 890D[AD230000]          	mov	[bus_dev_fn], ecx
   237                                  	;mov	[ac97_NamBar], dx
   238                                  	;shr	dx, 16
   239                                  	;mov	[ac97_NabmBar], dx
   240 0000010A 8915[B1230000]          	mov	[ac97_NamBar], edx	
   241                                    
   242                                  	; 01/06/2024
   243                                  	; Reset Audio Device (bh = 8)
   244                                  	sys	_audio, 0800h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000110 BB00080000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000115 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000011A CD40                <1>  int 40h
   245                                  	;jc	error_exit	
   246 0000011C 7230                    	jc	short init_err
   247                                  
   248 0000011E E8E2060000              	call	write_ac97_pci_dev_info
   249                                  
   250                                  	; 01/06/2024
   251                                  	; 25/11/2023
   252                                  	; Get AC'97 Codec info
   253                                  	; (Function 14, sub function 1)
   254                                  	sys	_audio, 0E01h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000123 BB010E0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000128 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000012D CD40                <1>  int 40h
   255                                  	; Save Variable Rate Audio support bit
   256 0000012F 2401                    	and	al, 1
   257 00000131 A2[38230000]            	mov	[VRA], al
   258                                  
   259                                  	; 25/11/2023
   260 00000136 E891080000              	call	write_VRA_info
   261                                  
   262                                  	; 01/05/2017
   263 0000013B E8FA050000              	call	write_wav_file_info
   264                                  
   265                                  	; 25/11/2023
   266                                  	; ------------------------------------------
   267                                  
   268 00000140 803D[38230000]01        	cmp	byte [VRA], 1
   269 00000147 7220                    	jb	short chk_sample_rate
   270                                  
   271                                  playwav_48_khz:	
   272                                  	;mov	dword [loadfromwavfile], loadFromFile
   273                                  	;mov	dword [buffersize], 65536
   274 00000149 E987020000              	jmp	PlayNow
   275                                  
   276                                  	; 01/06/2024
   277                                  init_err:
   278                                  	sys	_msg, msg_init_err, 255, 0Eh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000014E BB[85210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000153 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000158 BA0E000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000015D B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000162 CD40                <1>  int 40h
   279 00000164 E931030000              	jmp	Exit
   280                                  
   281                                  chk_sample_rate:
   282                                  	; set conversion parameters
   283                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   284 00000169 66A1[2E230000]          	mov	ax, [sample_rate]
   285 0000016F 663D80BB                	cmp	ax, 48000
   286 00000173 74D4                    	je	short playwav_48_khz
   287                                  chk_22khz:
   288 00000175 663D2256                	cmp	ax, 22050
   289 00000179 7545                    	jne	short chk_11khz
   290 0000017B 803D[2D230000]08        	cmp	byte [bps], 8
   291 00000182 7615                    	jna	short chk_22khz_1
   292 00000184 BB[55160000]            	mov	ebx, load_22khz_stereo_16_bit
   293 00000189 803D[2C230000]01        	cmp	byte [stmo], 1 
   294 00000190 751A                    	jne	short chk_22khz_2
   295 00000192 BB[C8150000]            	mov	ebx, load_22khz_mono_16_bit
   296 00000197 EB13                    	jmp	short chk_22khz_2
   297                                  chk_22khz_1:
   298 00000199 BB[41150000]            	mov	ebx, load_22khz_stereo_8_bit
   299 0000019E 803D[2C230000]01        	cmp	byte [stmo], 1 
   300 000001A5 7505                    	jne	short chk_22khz_2
   301 000001A7 BB[B8140000]            	mov	ebx, load_22khz_mono_8_bit
   302                                  chk_22khz_2:
   303 000001AC B85A1D0000              	mov	eax, 7514  ; (442*17)
   304 000001B1 BA25000000              	mov	edx, 37
   305 000001B6 B911000000              	mov	ecx, 17 
   306 000001BB E9BA010000              	jmp	set_sizes	
   307                                  chk_11khz:
   308 000001C0 663D112B                	cmp	ax, 11025
   309 000001C4 7545                    	jne	short chk_44khz
   310 000001C6 803D[2D230000]08        	cmp	byte [bps], 8
   311 000001CD 7615                    	jna	short chk_11khz_1
   312 000001CF BB[71180000]            	mov	ebx, load_11khz_stereo_16_bit
   313 000001D4 803D[2C230000]01        	cmp	byte [stmo], 1 
   314 000001DB 751A                    	jne	short chk_11khz_2
   315 000001DD BB[F8170000]            	mov	ebx, load_11khz_mono_16_bit
   316 000001E2 EB13                    	jmp	short chk_11khz_2
   317                                  chk_11khz_1:
   318 000001E4 BB[7E170000]            	mov	ebx, load_11khz_stereo_8_bit
   319 000001E9 803D[2C230000]01        	cmp	byte [stmo], 1 
   320 000001F0 7505                    	jne	short chk_11khz_2
   321 000001F2 BB[06170000]            	mov	ebx, load_11khz_mono_8_bit
   322                                  chk_11khz_2:
   323 000001F7 B8AD0E0000              	mov	eax, 3757  ; (221*17)
   324 000001FC BA4A000000              	mov	edx, 74
   325 00000201 B911000000              	mov	ecx, 17
   326 00000206 E96F010000              	jmp	set_sizes 
   327                                  chk_44khz:
   328 0000020B 663D44AC                	cmp	ax, 44100
   329 0000020F 7545                    	jne	short chk_16khz
   330 00000211 803D[2D230000]08        	cmp	byte [bps], 8
   331 00000218 7615                    	jna	short chk_44khz_1
   332 0000021A BB[981A0000]            	mov	ebx, load_44khz_stereo_16_bit
   333 0000021F 803D[2C230000]01        	cmp	byte [stmo], 1 
   334 00000226 751A                    	jne	short chk_44khz_2
   335 00000228 BB[1F1A0000]            	mov	ebx, load_44khz_mono_16_bit
   336 0000022D EB13                    	jmp	short chk_44khz_2
   337                                  chk_44khz_1:
   338 0000022F BB[A2190000]            	mov	ebx, load_44khz_stereo_8_bit
   339 00000234 803D[2C230000]01        	cmp	byte [stmo], 1 
   340 0000023B 7505                    	jne	short chk_44khz_2
   341 0000023D BB[26190000]            	mov	ebx, load_44khz_mono_8_bit
   342                                  chk_44khz_2:
   343 00000242 B8D93A0000              	mov	eax, 15065 ; (655*23)
   344 00000247 BA19000000              	mov	edx, 25
   345 0000024C B917000000              	mov	ecx, 23
   346 00000251 E924010000              	jmp	set_sizes 
   347                                  chk_16khz:
   348 00000256 663D803E                	cmp	ax, 16000
   349 0000025A 7545                    	jne	short chk_8khz
   350 0000025C 803D[2D230000]08        	cmp	byte [bps], 8
   351 00000263 7615                    	jna	short chk_16khz_1
   352 00000265 BB[FD0F0000]            	mov	ebx, load_16khz_stereo_16_bit
   353 0000026A 803D[2C230000]01        	cmp	byte [stmo], 1 
   354 00000271 751A                    	jne	short chk_16khz_2
   355 00000273 BB[7C0F0000]            	mov	ebx, load_16khz_mono_16_bit
   356 00000278 EB13                    	jmp	short chk_16khz_2
   357                                  chk_16khz_1:
   358 0000027A BB[C20E0000]            	mov	ebx, load_16khz_stereo_8_bit
   359 0000027F 803D[2C230000]01        	cmp	byte [stmo], 1 
   360 00000286 7505                    	jne	short chk_16khz_2
   361 00000288 BB[430E0000]            	mov	ebx, load_16khz_mono_8_bit
   362                                  chk_16khz_2:
   363 0000028D B855150000              	mov	eax, 5461
   364 00000292 BA03000000              	mov	edx, 3
   365 00000297 B901000000              	mov	ecx, 1
   366 0000029C E9D9000000              	jmp	set_sizes 
   367                                  chk_8khz:
   368 000002A1 663D401F                	cmp	ax, 8000
   369 000002A5 7545                    	jne	short chk_24khz
   370 000002A7 803D[2D230000]08        	cmp	byte [bps], 8
   371 000002AE 7615                    	jna	short chk_8khz_1
   372 000002B0 BB[F80C0000]            	mov	ebx, load_8khz_stereo_16_bit
   373 000002B5 803D[2C230000]01        	cmp	byte [stmo], 1 
   374 000002BC 751A                    	jne	short chk_8khz_2
   375 000002BE BB[280C0000]            	mov	ebx, load_8khz_mono_16_bit
   376 000002C3 EB13                    	jmp	short chk_8khz_2
   377                                  chk_8khz_1:
   378 000002C5 BB[F80A0000]            	mov	ebx, load_8khz_stereo_8_bit
   379 000002CA 803D[2C230000]01        	cmp	byte [stmo], 1 
   380 000002D1 7505                    	jne	short chk_8khz_2
   381 000002D3 BB[190A0000]            	mov	ebx, load_8khz_mono_8_bit
   382                                  chk_8khz_2:
   383 000002D8 B8AA0A0000              	mov	eax, 2730
   384 000002DD BA06000000              	mov	edx, 6
   385 000002E2 B901000000              	mov	ecx, 1
   386 000002E7 E98E000000              	jmp	set_sizes 
   387                                  chk_24khz:
   388 000002EC 663DC05D                	cmp	ax, 24000
   389 000002F0 7542                    	jne	short chk_32khz
   390 000002F2 803D[2D230000]08        	cmp	byte [bps], 8
   391 000002F9 7615                    	jna	short chk_24khz_1
   392 000002FB BB[27120000]            	mov	ebx, load_24khz_stereo_16_bit
   393 00000300 803D[2C230000]01        	cmp	byte [stmo], 1 
   394 00000307 751A                    	jne	short chk_24khz_2
   395 00000309 BB[C4110000]            	mov	ebx, load_24khz_mono_16_bit
   396 0000030E EB13                    	jmp	short chk_24khz_2
   397                                  chk_24khz_1:
   398 00000310 BB[3A110000]            	mov	ebx, load_24khz_stereo_8_bit
   399 00000315 803D[2C230000]01        	cmp	byte [stmo], 1 
   400 0000031C 7505                    	jne	short chk_24khz_2
   401 0000031E BB[D3100000]            	mov	ebx, load_24khz_mono_8_bit
   402                                  chk_24khz_2:
   403 00000323 B800200000              	mov	eax, 8192
   404 00000328 BA02000000              	mov	edx, 2
   405 0000032D B901000000              	mov	ecx, 1
   406 00000332 EB46                    	jmp	short set_sizes 
   407                                  chk_32khz:
   408 00000334 663D007D                	cmp	ax, 32000
   409 00000338 7574                    	jne	short vra_needed
   410 0000033A 803D[2D230000]08        	cmp	byte [bps], 8
   411 00000341 7615                    	jna	short chk_32khz_1
   412 00000343 BB[28140000]            	mov	ebx, load_32khz_stereo_16_bit
   413 00000348 803D[2C230000]01        	cmp	byte [stmo], 1 
   414 0000034F 751A                    	jne	short chk_32khz_2
   415 00000351 BB[BE130000]            	mov	ebx, load_32khz_mono_16_bit
   416 00000356 EB13                    	jmp	short chk_32khz_2
   417                                  chk_32khz_1:
   418 00000358 BB[21130000]            	mov	ebx, load_32khz_stereo_8_bit
   419 0000035D 803D[2C230000]01        	cmp	byte [stmo], 1 
   420 00000364 7505                    	jne	short chk_32khz_2
   421 00000366 BB[AE120000]            	mov	ebx, load_32khz_mono_8_bit
   422                                  chk_32khz_2:
   423 0000036B B8AA2A0000              	mov	eax, 10922
   424 00000370 BA03000000              	mov	edx, 3
   425 00000375 B902000000              	mov	ecx, 2
   426                                  	;jmp	short set_sizes 
   427                                  set_sizes:
   428 0000037A 803D[2C230000]01        	cmp	byte [stmo], 1
   429 00000381 7402                    	je	short ss_1
   430 00000383 D1E0                    	shl	eax, 1
   431                                  ss_1:
   432 00000385 803D[2D230000]08        	cmp	byte [bps], 8
   433 0000038C 7602                    	jna	short ss_2
   434                                  	; 16 bit samples
   435 0000038E D1E0                    	shl	eax, 1
   436                                  ss_2:
   437 00000390 A3[CD030000]            	mov	[loadsize], eax
   438 00000395 F7E2                    	mul	edx
   439                                  	;cmp	ecx, 1
   440                                  	;je	short ss_3
   441                                  ;ss_3:
   442 00000397 F7F1                    	div	ecx
   443 00000399 8A0D[A8230000]          	mov	cl, [fbs_shift]
   444 0000039F D3E0                    	shl	eax, cl
   445                                  	; 26/11/2023
   446                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   447 000003A1 A3[D1030000]            	mov	[buffersize], eax ; buffer size in bytes 
   448 000003A6 891D[C9030000]          	mov	[loadfromwavfile], ebx
   449 000003AC EB27                    	jmp	short PlayNow
   450                                  
   451                                  vra_needed:
   452                                  	sys	_msg, msg_no_vra, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003AE BB[B6210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003B3 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000003B8 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000003BD B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000003C2 CD40                <1>  int 40h
   453 000003C4 E9D1000000              	jmp	Exit
   454                                  
   455                                  	; 26/11/2023
   456                                  	; 13/11/2023
   457                                  loadfromwavfile:
   458 000003C9 [96050000]              	dd	loadFromFile
   459                                  loadsize:	; read from wav file
   460 000003CD 00000000                	dd	0
   461                                  buffersize:	; write to DMA buffer
   462 000003D1 00000100                	dd	65536 ; bytes
   463                                  
   464                                  PlayNow: 
   465                                  
   466                                  ; 26/11/2023
   467                                  %if 1
   468                                  	; Allocate Audio Buffer (for user)
   469                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   470                                  	; 26/11/2023
   471                                  	sys	_audio, 0200h, [buffersize], audio_buffer
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003D5 BB00020000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003DA 8B0D[D1030000]      <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000003E0 BA[00300000]        <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000003E5 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000003EA CD40                <1>  int 40h
   472 000003EC 731B                    	jnc	short _2
   473                                  
   474                                  	; 26/11/2023 - temporary
   475                                  	;sys	_msg, test_1, 255, 0Ch
   476                                  
   477                                  error_exit:
   478                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003EE BB[65210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003F3 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000003F8 BA0E000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000003FD B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000402 CD40                <1>  int 40h
   479 00000404 E991000000              	jmp	Exit
   480                                  _2:
   481                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   482                                  	; bl = 0, bh = 4
   483                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   484                                  
   485                                  	sys	_video, 0400h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000409 BB00040000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000040E B81F000000          <1>  mov eax, %1
    86                              <1> 
    87 00000413 CD40                <1>  int 40h
   486 00000415 3D00800B00              	cmp	eax, 0B8000h
   487 0000041A 75D2                    	jne	short error_exit
   488                                  
   489                                  	; 01/06/2024
   490                                  	; Initialize Audio Device (bh = 3)
   491                                  	sys	_audio, 0301h, 0, audio_int_handler 
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000041C BB01030000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000421 B900000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000426 BA[65050000]        <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000042B B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000430 CD40                <1>  int 40h
   492                                  	;jc	short error_exit
   493 00000432 0F8216FDFFFF            	jc	init_err
   494                                  _3:
   495                                  
   496                                  %endif
   497                                  
   498                                  ;
   499                                  ; position file pointer to start in actual wav data
   500                                  ; MUCH improvement should really be done here to check if sample size is
   501                                  ; supported, make sure there are 2 channels, etc.  
   502                                  ;
   503                                          ;mov     ah, 42h
   504                                          ;mov     al, 0	; from start of file
   505                                          ;mov     bx, [FileHandle]
   506                                          ;xor     cx, cx
   507                                          ;mov     dx, 44	; jump past .wav/riff header
   508                                          ;int     21h
   509                                  
   510                                  	sys	_seek, [FileHandle], 44, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000438 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000043E B92C000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000443 BA00000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000448 B813000000          <1>  mov eax, %1
    86                              <1> 
    87 0000044D CD40                <1>  int 40h
   511                                  
   512                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000044F BB[3B220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000454 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000459 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000045E B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000463 CD40                <1>  int 40h
   513                                  
   514                                  ; play the .wav file. Most of the good stuff is in here.
   515                                  
   516 00000465 E8E1010000                      call    PlayWav
   517                                  
   518                                  ; close the .wav file and exit.
   519                                  
   520                                  StopPlaying:
   521                                  	; Stop Playing
   522                                  	sys	_audio, 0700h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000046A BB00070000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000046F B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000474 CD40                <1>  int 40h
   523                                  	; Cancel callback service (for user)
   524                                  	sys	_audio, 0900h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000476 BB00090000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000047B B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000480 CD40                <1>  int 40h
   525                                  	; Deallocate Audio Buffer (for user)
   526                                  	sys	_audio, 0A00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000482 BB000A0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000487 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000048C CD40                <1>  int 40h
   527                                  	; Disable Audio Device
   528                                  	sys	_audio, 0C00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000048E BB000C0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000493 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000498 CD40                <1>  int 40h
   529                                  Exit:  
   530 0000049A E847000000                      call    closeFile
   531                                           
   532                                  	sys	_exit	; Bye!
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000049F B801000000          <1>  mov eax, %1
    86                              <1> 
    87 000004A4 CD40                <1>  int 40h
   533                                  here:
   534 000004A6 EBFE                    	jmp	short here
   535                                  
   536                                  pmsg_usage:
   537                                  	sys	_msg, msg_usage, 255, 0Bh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004A8 BB[02210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000004AD B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000004B2 BA0B000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004B7 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000004BC CD40                <1>  int 40h
   538 000004BE EBDA                    	jmp	short Exit
   539                                  
   540                                  	; 25/11/2023
   541                                  DetectAC97:
   542                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   543                                          sys	_audio, 0102h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004C0 BB02010000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004C5 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000004CA CD40                <1>  int 40h
   544                                  
   545                                  ; 01/06/2024
   546                                  %if 0
   547                                  	jc	short DetectAC97_retn
   548                                  
   549                                  	; 25/11/2023
   550                                  	; Get AC'97 Codec info
   551                                  	; (Function 14, sub function 1)
   552                                  	sys	_audio, 0E01h
   553                                  	; Save Variable Rate Audio support bit
   554                                  	and	al, 1
   555                                  	mov	[VRA], al
   556                                  %endif
   557                                  
   558                                  DetectAC97_retn:
   559 000004CC C3                      	retn
   560                                  
   561                                  ;open or create file
   562                                  ;
   563                                  ;input: ds:dx-->filename (asciiz)
   564                                  ;       al=file Mode (create or open)
   565                                  ;output: none  cs:[FileHandle] filled
   566                                  ;
   567                                  openFile:
   568                                  	;mov	ah, 3Bh	; start with a mode
   569                                  	;add	ah, al	; add in create or open mode
   570                                  	;xor	ecx, ecx
   571                                  	;int	21h
   572                                  	;jc	short _of1
   573                                  	;;mov	[cs:FileHandle], ax
   574                                  
   575                                  	sys	_open, wav_file_name, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004CD BB[55230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000004D2 B900000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004D7 B805000000          <1>  mov eax, %1
    86                              <1> 
    87 000004DC CD40                <1>  int 40h
   576 000004DE 7205                    	jc	short _of1
   577                                  
   578 000004E0 A3[66200000]            	mov	[FileHandle], eax
   579                                  _of1:
   580 000004E5 C3                      	retn
   581                                  
   582                                  ; close the currently open file
   583                                  ; input: none, uses cs:[FileHandle]
   584                                  closeFile:
   585 000004E6 833D[66200000]FF        	cmp	dword [FileHandle], -1
   586 000004ED 7417                    	je	short _cf1
   587                                  	;mov    bx, [FileHandle]  
   588                                  	;mov    ax, 3E00h
   589                                          ;int    21h              ;close file
   590                                  
   591                                  	sys	_close, [FileHandle]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004EF 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004F5 B806000000          <1>  mov eax, %1
    86                              <1> 
    87 000004FA CD40                <1>  int 40h
   592 000004FC C705[66200000]FFFF-     	mov 	dword [FileHandle], -1
   592 00000504 FFFF               
   593                                  _cf1:
   594 00000506 C3                      	retn
   595                                  
   596                                  getSampleRate:
   597                                  	
   598                                  ; reads the sample rate from the .wav file.
   599                                  ; entry: none - assumes file is already open
   600                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   601                                  ;	cx = number of channels (mono=1, stereo=2)
   602                                  ;	dx = bits per sample (8, 16)
   603                                  
   604 00000507 53                      	push    ebx
   605                                  
   606                                          ;mov	ah, 42h
   607                                          ;mov	al, 0	; from start of file
   608                                          ;mov	bx, [FileHandle]
   609                                          ;xor	ecx, ecx
   610                                          ;mov	dx, 08h	; "WAVE"
   611                                          ;int	21h
   612                                  	
   613                                  	sys	_seek, [FileHandle], 8, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000508 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000050E B908000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000513 BA00000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000518 B813000000          <1>  mov eax, %1
    86                              <1> 
    87 0000051D CD40                <1>  int 40h
   614                                  
   615                                          ;mov	dx, smpRBuff
   616                                          ;mov	cx, 28	; 28 bytes
   617                                  	;mov	ah, 3fh
   618                                          ;int	21h
   619                                  
   620                                  	sys	_read, [FileHandle], smpRBuff, 28
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000051F 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000525 B9[39230000]        <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000052A BA1C000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000052F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000534 CD40                <1>  int 40h
   621                                  
   622 00000536 813D[39230000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   622 0000053E 5645               
   623 00000540 7520                    	jne	short gsr_stc
   624                                  
   625 00000542 66833D[45230000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   626 0000054A 7516                    	jne	short gsr_stc
   627                                  
   628 0000054C 668B0D[47230000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   629 00000553 66A1[49230000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   630 00000559 668B15[53230000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   631                                  gsr_retn:
   632 00000560 5B                              pop     ebx
   633 00000561 C3                              retn
   634                                  gsr_stc:
   635 00000562 F9                      	stc
   636 00000563 EBFB                    	jmp	short gsr_retn
   637                                  
   638                                  audio_int_handler:
   639                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   640                                  
   641                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   642                                  	
   643                                  	;cmp	byte [cbs_busy], 1
   644                                  	;jnb	short _callback_bsy_retn
   645                                  	
   646                                  	;mov	byte [cbs_busy], 1
   647                                  
   648 00000565 A0[35230000]            	mov	al, [half_buff]
   649                                  
   650 0000056A 3C01                    	cmp	al, 1
   651 0000056C 721A                    	jb	short _callback_retn
   652                                  
   653                                  	; 18/08/2020
   654 0000056E C605[36230000]01        	mov	byte [srb], 1
   655                                  
   656 00000575 8035[35230000]03        	xor	byte [half_buff], 3 ; 2->1, 1->2
   657                                  
   658 0000057C 0430                    	add	al, '0'
   659                                  tL0:	; 26/11/2023
   660 0000057E B44E                    	mov	ah, 4Eh
   661 00000580 BB00800B00              	mov	ebx, 0B8000h ; video display page address
   662 00000585 668903                  	mov	[ebx], ax ; show playing buffer (1, 2)
   663                                  _callback_retn:
   664                                  	;mov	byte [cbs_busy], 0
   665                                  _callback_bsy_retn:
   666                                  	sys	_rele ; return from callback service 
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000588 B827000000          <1>  mov eax, %1
    86                              <1> 
    87 0000058D CD40                <1>  int 40h
   667                                  	; we must not come here !
   668                                  	sys	_exit
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000058F B801000000          <1>  mov eax, %1
    86                              <1> 
    87 00000594 CD40                <1>  int 40h
   669                                  	
   670                                  loadFromFile:
   671                                  	; 26/11/2023
   672 00000596 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
   673                                  					; last of the file?
   674 0000059D 7402                    	jz	short lff_0		; no
   675 0000059F F9                      	stc
   676 000005A0 C3                      	retn
   677                                  lff_0:
   678                                  	; 13/06/2017
   679                                  	;mov	edx, BUFFERSIZE
   680                                  	; 26/11/2023
   681 000005A1 BF[00300000]            	mov	edi, audio_buffer
   682 000005A6 8B15[D1030000]          	mov	edx, [buffersize]	; bytes
   683 000005AC 8A0D[A8230000]          	mov	cl, [fbs_shift]   
   684 000005B2 20C9                    	and	cl, cl
   685 000005B4 7409                    	jz	short lff_1 ; stereo, 16 bit
   686                                  
   687                                  	; fbs_shift =
   688                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   689                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   690 000005B6 D3EA                    	shr	edx, cl
   691                                  	;inc	edx
   692                                  
   693 000005B8 BE[00300100]            	mov     esi, temp_buffer
   694 000005BD EB02                    	jmp	short lff_2
   695                                  lff_1:
   696                                  	;mov	esi, audio_buffer
   697 000005BF 89FE                    	mov	esi, edi ; audio_buffer
   698                                  lff_2:
   699                                  	; 17/03/2017
   700                                  	; esi = buffer address
   701                                  	; edx = buffer size
   702                                   
   703                                  	; 26/11/2023
   704                                  	; load file into memory
   705                                  	sys 	_read, [FileHandle], esi
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000005C1 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000005C7 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000005C9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000005CE CD40                <1>  int 40h
   706 000005D0 89D1                    	mov	ecx, edx
   707 000005D2 724A                    	jc	short padfill ; error !
   708                                  
   709 000005D4 21C0                    	and	eax, eax
   710 000005D6 7446                    	jz	short padfill
   711                                  lff_3:
   712                                  	; 26/11/2023
   713 000005D8 8A1D[A8230000]          	mov	bl, [fbs_shift]
   714 000005DE 20DB                    	and	bl, bl
   715 000005E0 745C                    	jz	short lff_11
   716                                  
   717 000005E2 29C1                    	sub	ecx, eax
   718 000005E4 89CD                    	mov	ebp, ecx
   719                                  
   720                                  	;mov	esi, temp_buffer
   721                                  	;mov	edi, audio_buffer
   722 000005E6 89C1                    	mov	ecx, eax   ; byte count
   723                                  
   724 000005E8 803D[2D230000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   725 000005EF 751E                    	jne	short lff_6 ; 16 bit samples
   726                                  	; 8 bit samples
   727 000005F1 FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   728 000005F3 740E                    	jz	short lff_5 ; 8 bit, stereo
   729                                  lff_4:
   730                                  	; mono & 8 bit
   731 000005F5 AC                      	lodsb
   732 000005F6 2C80                    	sub	al, 80h ; 08/11/2023
   733 000005F8 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   734 000005FB 66AB                    	stosw	; left channel
   735 000005FD 66AB                    	stosw	; right channel
   736 000005FF E2F4                    	loop	lff_4
   737 00000601 EB16                    	jmp	short lff_8
   738                                  lff_5:
   739                                  	; stereo & 8 bit
   740 00000603 AC                      	lodsb
   741 00000604 2C80                    	sub	al, 80h ; 08/11/2023
   742 00000606 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   743 00000609 66AB                    	stosw
   744 0000060B E2F6                    	loop	lff_5			
   745 0000060D EB0A                    	jmp	short lff_8
   746                                  lff_6:
   747 0000060F D1E9                    	shr	ecx, 1 ; word count
   748                                  lff_7:
   749 00000611 66AD                    	lodsw
   750 00000613 66AB                    	stosw	; left channel
   751 00000615 66AB                    	stosw	; right channel
   752 00000617 E2F8                    	loop	lff_7
   753                                  lff_8:
   754                                  	; 27/11/2023
   755 00000619 F8                      	clc
   756 0000061A 89E9                    	mov	ecx, ebp
   757 0000061C E314                    	jecxz	endLFF_retn
   758                                  	
   759                                  padfill:
   760 0000061E 803D[2D230000]10        	cmp 	byte [bps], 16
   761 00000625 740C                    	je	short lff_10
   762                                  	; Minimum Value = 0
   763 00000627 30C0                            xor     al, al
   764 00000629 F3AA                    	rep	stosb
   765                                  lff_9:
   766 0000062B 800D[34230000]01                or	byte [flags], ENDOFFILE	; end of file flag
   767                                  endLFF_retn:
   768 00000632 C3                              retn
   769                                  lff_10:
   770 00000633 31C0                    	xor	eax, eax
   771                                  	; Minimum value = 8000h (-32768)
   772 00000635 D1E9                    	shr	ecx, 1 
   773 00000637 B480                    	mov	ah, 80h ; ax = -32768
   774 00000639 F366AB                  	rep	stosw
   775 0000063C EBED                    	jmp	short lff_9
   776                                  
   777                                  lff_11:
   778                                  	; 16 bit stereo
   779                                  	; ecx = buffer size
   780                                  	; eax = read count
   781 0000063E 29C1                    	sub	ecx, eax
   782 00000640 76F0                    	jna	short endLFF_retn
   783 00000642 01C7                    	add	edi, eax  ; audio_buffer + eax
   784 00000644 EBED                    	jmp	short lff_10 ; padfill
   785                                  
   786                                  error_exit_2:
   787                                  	; 26/11/2023 - temporary
   788                                  	;sys	_msg, test_2, 255, 0Ch
   789                                  
   790 00000646 E9A3FDFFFF              	jmp	error_exit
   791                                  	
   792                                  	; 26/11/2023 - temporary
   793                                  ;test_1:
   794                                  ;	db 13, 10, 'Test 1', 13,10, 0
   795                                  ;test_2:
   796                                  ;	db 13, 10, 'Test 2', 13,10, 0
   797                                  	
   798                                  PlayWav:
   799                                  	; 26/11/2023
   800                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   801                                  	; 13/06/2017
   802                                  	; Convert 8 bit samples to 16 bit samples
   803                                  	; and convert mono samples to stereo samples
   804                                  
   805                                  	; 26/11/2023
   806                                  	; load 32768 bytes into audio buffer
   807                                  	;mov	edi, audio_buffer
   808                                  	;;mov	edx, BUFFERSIZE
   809                                  	; 26/11/2023
   810                                  	;mov	edx, [buffersize]
   811                                  	;call	loadFromFile
   812                                  	; 26/11/2023
   813 0000064B FF15[C9030000]          	call	dword [loadfromwavfile]
   814 00000651 72F3                    	jc	short error_exit_2
   815 00000653 C605[35230000]01        	mov	byte [half_buff], 1 ; (DMA) Buffer 1
   816                                  
   817                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   818 0000065A F605[34230000]01        	test    byte [flags], ENDOFFILE  ; end of file
   819 00000661 7512                    	jnz	short _6 ; yes
   820                                  			 ; bypass filling dma half buffer 2
   821                                  
   822                                  	; bh = 16 : update (current, first) dma half buffer
   823                                  	; bl = 0  : then switch to the next (second) half buffer
   824                                  	sys	_audio, 1000h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000663 BB00100000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000668 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000066D CD40                <1>  int 40h
   825                                  
   826                                  	; 18/08/2020
   827                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
   828                                  
   829                                  	; audio_buffer must be filled again after above system call 
   830                                  	; (Because audio interrupt will be generated by AC97 hardware
   831                                  	; at the end of the first half of dma buffer.. so, 
   832                                  	; the second half must be ready. 'sound_play' will use it.)
   833                                  
   834                                  	; 26/11/2023
   835                                  	;mov	edi, audio_buffer
   836                                  	;;mov	edx, BUFFERSIZE
   837                                  	; 26/11/2023
   838                                  	;mov	edx, [buffersize]
   839                                  	;call	loadFromFile
   840                                  	; 26/11/2023
   841 0000066F FF15[C9030000]          	call	dword [loadfromwavfile]
   842                                  	;jc	short p_return
   843                                  _6:
   844                                  	; Set Master Volume Level (BL=0 or 80h)
   845                                  	; 	for next playing (BL>=80h)
   846                                  	;sys	_audio, 0B80h, 1D1Dh
   847                                  	sys	_audio, 0B00h, 1D1Dh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000675 BB000B0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000067A B91D1D0000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000067F B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000684 CD40                <1>  int 40h
   848                                  
   849                                  	; 18/08/2020
   850                                  	;mov	byte [volume_level], 1Dh
   851 00000686 880D[37230000]          	mov	[volume_level], cl
   852                                  
   853                                  	; Start	to play
   854 0000068C A0[2D230000]            	mov	al, [bps]
   855 00000691 C0E804                  	shr	al, 4 ; 8 -> 0, 16 -> 1
   856 00000694 D0E0                    	shl	al, 1 ; 16 -> 2, 8 -> 0
   857 00000696 8A1D[2C230000]          	mov	bl, [stmo]
   858 0000069C FECB                    	dec	bl
   859 0000069E 08C3                    	or	bl, al
   860 000006A0 668B0D[2E230000]        	mov	cx, [sample_rate] 
   861 000006A7 B704                    	mov	bh, 4 ; start to play
   862                                  	sys	_audio
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000006A9 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000006AE CD40                <1>  int 40h
   863                                  
   864                                  	;mov	ebx, 0B8000h ; video display page address
   865                                  	;mov	ah, 4Eh
   866                                  	;mov	al, [half_buffer]
   867                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   868                                  
   869                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   870                                  	; Here..
   871                                  	; If byte [flags] <> ENDOFFILE ...
   872                                  	; user's audio_buffer has been copied to dma half buffer 2
   873                                  
   874                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
   875                                  
   876                                  	; audio_buffer must be filled again after above system call 
   877                                  	; (Because, audio interrupt will be generated by VT8237R
   878                                  	; at the end of the first half of dma buffer.. so, 
   879                                  	; the 2nd half of dma buffer is ready but the 1st half
   880                                  	; must be filled again.)
   881                                  
   882                                  	; 18/08/2020
   883 000006B0 F605[34230000]01        	test    byte [flags], ENDOFFILE  ; end of file
   884 000006B7 7506                    	jnz	short p_loop ; yes
   885                                  
   886                                  	; 18/08/2020
   887                                  	; load 32768 bytes into audio buffer
   888                                  	;; (for the second half of DMA buffer)
   889                                  	; 27/11/2023
   890                                  	; 20/05/2017
   891                                  	;mov	edi, audio_buffer
   892                                  	;mov	edx, BUFFERSIZE
   893                                  	; 26/11/2023
   894                                  	;mov	edx, [buffersize]
   895                                  	;call	loadFromFile
   896                                  	; 26/11/2023
   897 000006B9 FF15[C9030000]          	call	dword [loadfromwavfile]
   898                                  	;jc	short p_return
   899                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
   900                                  
   901                                  	; we need to wait for 'SRB' (audio interrupt)
   902                                  	; (we can not return from 'PlayWav' here 
   903                                  	;  even if we have got an error from file reading)
   904                                  	; ((!!current audio data must be played!!))
   905                                  
   906                                  	; 18/08/2020
   907                                  	;mov	byte [srb], 1
   908                                  
   909                                  p_loop:
   910                                  	;mov	ah, 1		; any key pressed?
   911                                  	;int	32h		; no, Loop.
   912                                  	;jz	short q_loop
   913                                  	;
   914                                  	;mov	ah, 0		; flush key buffer...
   915                                  	;int	32h
   916                                  
   917                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   918 000006BF 803D[36230000]00        	cmp	byte [srb], 0
   919 000006C6 760F                    	jna	short q_loop
   920 000006C8 C605[36230000]00        	mov	byte [srb], 0
   921                                  	; 27/11/2023
   922                                  	;mov	edi, audio_buffer
   923                                  	;mov	edx, BUFFERSIZE
   924                                  	; 26/11/2023
   925                                  	;mov	edx, [buffersize]
   926                                  	;call	loadFromFile
   927                                  	; 26/11/2023
   928 000006CF FF15[C9030000]          	call	dword [loadfromwavfile]
   929 000006D5 7212                    	jc	short p_return
   930                                  q_loop:
   931 000006D7 B401                    	mov     ah, 1		; any key pressed?
   932 000006D9 CD32                    	int     32h		; no, Loop.
   933 000006DB 74E2                    	jz	short p_loop
   934                                  
   935 000006DD B400                    	mov     ah, 0		; flush key buffer...
   936 000006DF CD32                    	int     32h
   937                                  	
   938 000006E1 3C2B                    	cmp	al, '+' ; increase sound volume
   939 000006E3 740C                    	je	short inc_volume_level
   940 000006E5 3C2D                    	cmp	al, '-'
   941 000006E7 742B                    	je	short dec_volume_level
   942                                  
   943                                  p_return:
   944 000006E9 C605[35230000]00        	mov	byte [half_buff], 0
   945 000006F0 C3                      	retn
   946                                  
   947                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   948                                  inc_volume_level:
   949 000006F1 8A0D[37230000]          	mov	cl, [volume_level]
   950 000006F7 80F91F                  	cmp	cl, 1Fh ; 31
   951 000006FA 73DB                    	jnb	short q_loop
   952 000006FC FEC1                    	inc	cl
   953                                  change_volume_level:
   954 000006FE 880D[37230000]          	mov	[volume_level], cl
   955 00000704 88CD                    	mov	ch, cl
   956                                  	; Set Master Volume Level
   957                                  	sys	_audio, 0B00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000706 BB000B0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000070B B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000710 CD40                <1>  int 40h
   958 00000712 EBAB                    	jmp	short p_loop
   959                                  dec_volume_level:
   960 00000714 8A0D[37230000]          	mov	cl, [volume_level]
   961 0000071A 80F901                  	cmp	cl, 1 ; 1
   962 0000071D 76A0                    	jna	short p_loop
   963 0000071F FEC9                    	dec	cl
   964 00000721 EBDB                    	jmp	short change_volume_level
   965                                  
   966                                  write_audio_dev_info:
   967                                  	; EBX = Message address
   968                                  	; ECX = Max. message length (or stop on ZERO character)
   969                                  	;	(1 to 255)
   970                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
   971                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000723 BB[D9200000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000728 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000072D BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000732 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000737 CD40                <1>  int 40h
   972 00000739 C3                      	retn
   973                                  
   974                                  write_wav_file_info:
   975                                  	; 01/05/2017
   976                                  	sys	_msg, msgWavFileName, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000073A BB[EF210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000073F B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000744 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000749 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000074E CD40                <1>  int 40h
   977                                  	sys	_msg, wav_file_name, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000750 BB[55230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000755 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000075A BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000075F B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000764 CD40                <1>  int 40h
   978                                  
   979                                  write_sample_rate:
   980                                  	; 01/05/2017
   981 00000766 66A1[2E230000]          	mov	ax, [sample_rate]
   982                                  	; ax = sample rate (hertz)
   983 0000076C 31D2                    	xor	edx, edx
   984 0000076E 66B90A00                	mov	cx, 10
   985 00000772 66F7F1                  	div	cx
   986 00000775 0015[14220000]          	add	[msgHertz+4], dl
   987 0000077B 29D2                    	sub	edx, edx
   988 0000077D 66F7F1                  	div	cx
   989 00000780 0015[13220000]          	add	[msgHertz+3], dl
   990 00000786 29D2                    	sub	edx, edx
   991 00000788 66F7F1                  	div	cx
   992 0000078B 0015[12220000]          	add	[msgHertz+2], dl
   993 00000791 29D2                    	sub	edx, edx
   994 00000793 66F7F1                  	div	cx
   995 00000796 0015[11220000]          	add	[msgHertz+1], dl
   996 0000079C 0005[10220000]          	add	[msgHertz], al
   997                                  	
   998                                  	sys	_msg, msgSampleRate, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007A2 BB[01220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007A7 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000007AC BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000007B1 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000007B6 CD40                <1>  int 40h
   999                                  
  1000 000007B8 BE[2B220000]            	mov	esi, msg16Bits
  1001 000007BD 803D[2D230000]10        	cmp	byte [bps], 16
  1002 000007C4 7405                    	je	short wsr_1
  1003 000007C6 BE[1B220000]            	mov	esi, msg8Bits
  1004                                  wsr_1:
  1005                                  	sys	_msg, esi, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007CB 89F3                <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007CD B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000007D2 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000007D7 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000007DC CD40                <1>  int 40h
  1006                                  
  1007 000007DE BE[24220000]            	mov	esi, msgMono
  1008 000007E3 803D[2C230000]01        	cmp	byte [stmo], 1
  1009 000007EA 7405                    	je	short wsr_2
  1010 000007EC BE[35220000]            	mov	esi, msgStereo		
  1011                                  wsr_2:
  1012                                  	sys	_msg, esi, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007F1 89F3                <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007F3 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000007F8 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000007FD B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000802 CD40                <1>  int 40h
  1013 00000804 C3                              retn
  1014                                  
  1015                                  write_ac97_pci_dev_info:
  1016                                  	; 06/06/2017
  1017                                  	; 03/06/2017
  1018                                  	; BUS/DEV/FN
  1019                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1020                                  	; DEV/VENDOR
  1021                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1022                                  
  1023 00000805 8B35[A9230000]          	mov	esi, [dev_vendor]
  1024 0000080B 89F0                    	mov	eax, esi
  1025 0000080D 0FB6D8                  	movzx	ebx, al
  1026 00000810 88DA                    	mov	dl, bl
  1027 00000812 80E30F                  	and	bl, 0Fh
  1028 00000815 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1029 0000081B A2[83220000]            	mov	[msgVendorId+3], al
  1030 00000820 88D3                    	mov	bl, dl
  1031 00000822 C0EB04                  	shr	bl, 4
  1032 00000825 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1033 0000082B A2[82220000]            	mov	[msgVendorId+2], al
  1034 00000830 88E3                    	mov	bl, ah
  1035 00000832 88DA                    	mov	dl, bl
  1036 00000834 80E30F                  	and	bl, 0Fh
  1037 00000837 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1038 0000083D A2[81220000]            	mov	[msgVendorId+1], al
  1039 00000842 88D3                    	mov	bl, dl
  1040 00000844 C0EB04                  	shr	bl, 4
  1041 00000847 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1042 0000084D A2[80220000]            	mov	[msgVendorId], al
  1043 00000852 C1E810                  	shr	eax, 16
  1044 00000855 88C3                    	mov	bl, al
  1045 00000857 88DA                    	mov	dl, bl
  1046 00000859 80E30F                  	and	bl, 0Fh
  1047 0000085C 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1048 00000862 A2[94220000]            	mov	[msgDevId+3], al
  1049 00000867 88D3                    	mov	bl, dl
  1050 00000869 C0EB04                  	shr	bl, 4
  1051 0000086C 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1052 00000872 A2[93220000]            	mov	[msgDevId+2], al
  1053 00000877 88E3                    	mov	bl, ah
  1054 00000879 88DA                    	mov	dl, bl
  1055 0000087B 80E30F                  	and	bl, 0Fh
  1056 0000087E 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1057 00000884 A2[92220000]            	mov	[msgDevId+1], al
  1058 00000889 88D3                    	mov	bl, dl
  1059 0000088B C0EB04                  	shr	bl, 4
  1060 0000088E 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1061 00000894 A2[91220000]            	mov	[msgDevId], al
  1062                                  
  1063 00000899 8B35[AD230000]          	mov	esi, [bus_dev_fn]
  1064 0000089F C1EE08                  	shr	esi, 8
  1065 000008A2 6689F0                  	mov	ax, si
  1066 000008A5 88C3                    	mov	bl, al
  1067 000008A7 88DA                    	mov	dl, bl
  1068 000008A9 80E307                  	and	bl, 7 ; bit 0,1,2
  1069 000008AC 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1070 000008B2 A2[B8220000]            	mov	[msgFncNo+1], al
  1071 000008B7 88D3                    	mov	bl, dl
  1072 000008B9 C0EB03                  	shr	bl, 3
  1073 000008BC 88DA                    	mov	dl, bl
  1074 000008BE 80E30F                  	and	bl, 0Fh
  1075 000008C1 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1076 000008C7 A2[AA220000]            	mov	[msgDevNo+1], al
  1077 000008CC 88D3                    	mov	bl, dl
  1078 000008CE C0EB04                  	shr	bl, 4
  1079 000008D1 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1080 000008D7 A2[A9220000]            	mov	[msgDevNo], al
  1081 000008DC 88E3                    	mov	bl, ah
  1082 000008DE 88DA                    	mov	dl, bl
  1083 000008E0 80E30F                  	and	bl, 0Fh
  1084 000008E3 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1085 000008E9 A2[9E220000]            	mov	[msgBusNo+1], al
  1086 000008EE 88D3                    	mov	bl, dl
  1087 000008F0 C0EB04                  	shr	bl, 4
  1088 000008F3 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1089 000008F9 A2[9D220000]            	mov	[msgBusNo], al
  1090                                  
  1091 000008FE 66A1[B1230000]          	mov	ax, [ac97_NamBar]
  1092 00000904 88C3                    	mov	bl, al
  1093 00000906 88DA                    	mov	dl, bl
  1094 00000908 80E30F                  	and	bl, 0Fh
  1095 0000090B 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1096 00000911 A2[C7220000]            	mov	[msgNamBar+3], al
  1097 00000916 88D3                    	mov	bl, dl
  1098 00000918 C0EB04                  	shr	bl, 4
  1099 0000091B 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1100 00000921 A2[C6220000]            	mov	[msgNamBar+2], al
  1101 00000926 88E3                    	mov	bl, ah
  1102 00000928 88DA                    	mov	dl, bl
  1103 0000092A 80E30F                  	and	bl, 0Fh
  1104 0000092D 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1105 00000933 A2[C5220000]            	mov	[msgNamBar+1], al
  1106 00000938 88D3                    	mov	bl, dl
  1107 0000093A C0EB04                  	shr	bl, 4
  1108 0000093D 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1109 00000943 A2[C4220000]            	mov	[msgNamBar], al
  1110                                  
  1111 00000948 66A1[B3230000]          	mov	ax, [ac97_NabmBar]
  1112 0000094E 88C3                    	mov	bl, al
  1113 00000950 88DA                    	mov	dl, bl
  1114 00000952 80E30F                  	and	bl, 0Fh
  1115 00000955 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1116 0000095B A2[D7220000]            	mov	[msgNabmBar+3], al
  1117 00000960 88D3                    	mov	bl, dl
  1118 00000962 C0EB04                  	shr	bl, 4
  1119 00000965 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1120 0000096B A2[D6220000]            	mov	[msgNabmBar+2], al
  1121 00000970 88E3                    	mov	bl, ah
  1122 00000972 88DA                    	mov	dl, bl
  1123 00000974 80E30F                  	and	bl, 0Fh
  1124 00000977 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1125 0000097D A2[D5220000]            	mov	[msgNabmBar+1], al
  1126 00000982 88D3                    	mov	bl, dl
  1127 00000984 C0EB04                  	shr	bl, 4
  1128 00000987 8A83[3E220000]          	mov	al, [ebx+hex_chars]
  1129 0000098D A2[D4220000]            	mov	[msgNabmBar], al
  1130                                  
  1131 00000992 30E4                    	xor	ah, ah
  1132 00000994 A0[A7230000]            	mov	al, [ac97_int_ln_reg]
  1133 00000999 B10A                    	mov	cl, 10
  1134 0000099B F6F1                    	div	cl
  1135 0000099D 660105[E0220000]        	add	[msgIRQ], ax
  1136 000009A4 20C0                    	and	al, al
  1137 000009A6 750D                    	jnz	short _w_ac97imsg_
  1138 000009A8 A0[E1220000]            	mov	al, [msgIRQ+1]
  1139 000009AD B420                    	mov	ah, ' '
  1140 000009AF 66A3[E0220000]          	mov	[msgIRQ], ax
  1141                                  _w_ac97imsg_:
  1142                                  	sys	_msg, msgAC97Info, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009B5 BB[4F220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009BA B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009BF BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000009C4 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000009C9 CD40                <1>  int 40h
  1143                                  
  1144 000009CB C3                              retn
  1145                                  
  1146                                  write_VRA_info:
  1147                                  	; 25/11/2023
  1148                                  	sys	_msg, msgVRAheader, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009CC BB[E5220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009D1 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009D6 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000009DB B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000009E0 CD40                <1>  int 40h
  1149 000009E2 803D[38230000]00        	cmp	byte [VRA], 0
  1150 000009E9 7617                    	jna	short _w_VRAi_no
  1151                                  _w_VRAi_yes:
  1152                                  	sys	_msg, msgVRAyes, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009EB BB[F3220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009F0 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009F5 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000009FA B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000009FF CD40                <1>  int 40h
  1153 00000A01 C3                      	retn
  1154                                  _w_VRAi_no:
  1155                                  	sys	_msg, msgVRAno, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000A02 BB[F9220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000A07 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000A0C BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000A11 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000A16 CD40                <1>  int 40h
  1156 00000A18 C3                      	retn
  1157                                  
  1158                                  ; 26/11/2023
  1159                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1160                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1161                                  ; 14/11/2023
  1162                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1163                                  ; --------------------------------------------------------
  1164                                  
  1165                                  ;;Note:	At the end of every buffer load,
  1166                                  ;;	during buffer switch/swap, there will be discontinuity
  1167                                  ;;	between the last converted sample and the 1st sample
  1168                                  ;;	of the next buffer.
  1169                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1170                                  ;;	-To avoid this defect, the 1st sample of
  1171                                  ;;	the next buffer may be read from the wav file but
  1172                                  ;;	the file pointer would need to be set to 1 sample back
  1173                                  ;;	again via seek system call. Time comsumption problem! -
  1174                                  ;;
  1175                                  ;;	Erdogan Tan - 15/11/2023
  1176                                  ;;
  1177                                  ;;	((If entire wav data would be loaded at once.. conversion
  1178                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1179                                  ;;	64KB buffer limit is important also it is important
  1180                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1181                                  ;;	I have tested this program by using 2-30MB wav files.))
  1182                                  ;;
  1183                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1184                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1185                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1186                                  ;;			Realtek ALC850 codec.
  1187                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1188                                  
  1189                                  load_8khz_mono_8_bit:
  1190                                  	; 15/11/2023
  1191                                  	; 14/11/2023
  1192                                  	; 13/11/2023
  1193 00000A19 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1194                                  					; last of the file?
  1195 00000A20 7402                    	jz	short lff8m_0		; no
  1196 00000A22 F9                      	stc
  1197 00000A23 C3                      	retn
  1198                                  
  1199                                  lff8m_0:
  1200 00000A24 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1201                                          ;mov	edx, [loadsize]
  1202                                  
  1203                                  	; esi = buffer address
  1204                                  	;; edx = buffer size
  1205                                  
  1206                                  	; load file into memory
  1207                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000A29 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000A2F 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000A31 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000A37 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000A3C CD40                <1>  int 40h
  1208 00000A3E 7305                    	jnc	short lff8m_6
  1209 00000A40 E9AA000000              	jmp	lff8m_5  ; error !
  1210                                  
  1211                                  lff8m_6:
  1212 00000A45 BF[00300000]            	mov	edi, audio_buffer
  1213 00000A4A 21C0                    	and	eax, eax
  1214 00000A4C 0F8494000000            	jz	lff8_eof
  1215                                  
  1216 00000A52 89C1                    	mov	ecx, eax		; byte count
  1217                                  lff8m_1:
  1218 00000A54 AC                      	lodsb
  1219 00000A55 A2[5D200000]            	mov	[previous_val], al
  1220 00000A5A 2C80                    	sub	al, 80h
  1221 00000A5C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1222 00000A60 66AB                    	stosw		; original sample (left channel)
  1223 00000A62 66AB                    	stosw		; original sample (right channel)
  1224                                  	;xor	eax, eax
  1225 00000A64 B080                    	mov	al, 80h
  1226 00000A66 49                      	dec	ecx
  1227 00000A67 7402                    	jz	short lff8m_2
  1228 00000A69 8A06                    	mov	al, [esi]
  1229                                  lff8m_2:
  1230                                  	;mov	[next_val], ax
  1231 00000A6B 88C7                    	mov	bh, al	; [next_val]
  1232 00000A6D 8A25[5D200000]          	mov	ah, [previous_val]
  1233 00000A73 00E0                    	add	al, ah	; [previous_val]
  1234 00000A75 D0D8                    	rcr	al, 1
  1235 00000A77 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1236 00000A79 00E0                    	add	al, ah	; [previous_val]
  1237 00000A7B D0D8                    	rcr	al, 1	
  1238 00000A7D 88C3                    	mov	bl, al 	; this is temporary interpolation value	
  1239 00000A7F 00E0                    	add	al, ah	; [previous_val]
  1240 00000A81 D0D8                    	rcr	al, 1
  1241 00000A83 2C80                    	sub	al, 80h
  1242 00000A85 66C1E008                	shl	ax, 8	
  1243 00000A89 66AB                    	stosw		; this is 1st interpolated sample (L)
  1244 00000A8B 66AB                    	stosw		; this is 1st interpolated sample (R)
  1245 00000A8D 88D8                    	mov	al, bl
  1246 00000A8F 00D0                    	add	al, dl
  1247 00000A91 D0D8                    	rcr	al, 1
  1248 00000A93 2C80                    	sub	al, 80h
  1249 00000A95 66C1E008                	shl	ax, 8
  1250 00000A99 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1251 00000A9B 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1252 00000A9D 88D0                    	mov	al, dl
  1253 00000A9F 2C80                    	sub	al, 80h
  1254 00000AA1 66C1E008                	shl	ax, 8
  1255 00000AA5 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1256 00000AA7 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1257                                  	;mov	al, [next_val]
  1258 00000AA9 88F8                    	mov	al, bh
  1259 00000AAB 00D0                    	add	al, dl
  1260 00000AAD D0D8                    	rcr	al, 1
  1261 00000AAF 88C3                    	mov	bl, al	; this is temporary interpolation value
  1262 00000AB1 00D0                    	add	al, dl
  1263 00000AB3 D0D8                    	rcr	al, 1
  1264 00000AB5 2C80                    	sub	al, 80h
  1265 00000AB7 66C1E008                	shl	ax, 8
  1266 00000ABB 66AB                    	stosw		; this is 4th interpolated sample (L)
  1267 00000ABD 66AB                    	stosw		; this is 4th interpolated sample (R)
  1268                                  	;mov	al, [next_val]
  1269 00000ABF 88F8                    	mov	al, bh
  1270 00000AC1 00D8                    	add	al, bl
  1271 00000AC3 D0D8                    	rcr	al, 1
  1272 00000AC5 2C80                    	sub	al, 80h
  1273 00000AC7 66C1E008                	shl	ax, 8
  1274 00000ACB 66AB                    	stosw		; this is 5th interpolated sample (L)
  1275 00000ACD 66AB                    	stosw		; this is 5th interpolated sample (R)
  1276                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1277 00000ACF 09C9                    	or	ecx, ecx
  1278 00000AD1 7581                    	jnz	short lff8m_1
  1279                                  
  1280                                  	; --------------
  1281                                  
  1282                                  lff8s_3:
  1283                                  lff8m_3:
  1284                                  lff8s2_3:
  1285                                  lff8m2_3:
  1286                                  lff16s_3:
  1287                                  lff16m_3:
  1288                                  lff16s2_3:
  1289                                  lff16m2_3:
  1290                                  lff24_3:
  1291                                  lff32_3:
  1292                                  lff44_3:
  1293                                  lff22_3:
  1294                                  lff11_3:
  1295                                  	; 01/06/2024 (BugFix)
  1296 00000AD3 8B0D[D1030000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1297                                  	;shl	ecx, 1	; byte count ; Bug !
  1298 00000AD9 29F9                    	sub	ecx, edi
  1299 00000ADB 7607                    	jna	short lff8m_4
  1300                                  	;inc	ecx
  1301 00000ADD C1E902                  	shr	ecx, 2
  1302 00000AE0 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros	
  1303 00000AE2 F3AB                    	rep	stosd
  1304                                  lff8m_4:
  1305                                  	; 01/06/2024 (BugFix)
  1306                                  	; cf=1 ; Bug !
  1307 00000AE4 F8                      	clc
  1308 00000AE5 C3                      	retn
  1309                                  
  1310                                  lff8_eof:
  1311                                  lff16_eof:
  1312                                  lff24_eof:
  1313                                  lff32_eof:
  1314                                  lff44_eof:
  1315                                  lff22_eof:
  1316                                  lff11_eof:
  1317                                  	; 15/11/2023
  1318 00000AE6 C605[34230000]01        	mov	byte [flags], ENDOFFILE
  1319 00000AED EBE4                    	jmp	short lff8m_3
  1320                                  
  1321                                  lff8s_5:
  1322                                  lff8m_5:
  1323                                  lff8s2_5:
  1324                                  lff8m2_5:
  1325                                  lff16s_5:
  1326                                  lff16m_5:
  1327                                  lff16s2_5:
  1328                                  lff16m2_5:
  1329                                  lff24_5:
  1330                                  lff32_5:
  1331                                  lff44_5:
  1332                                  lff22_5:
  1333                                  lff11_5:
  1334 00000AEF B021                    	mov	al, '!'  ; error
  1335 00000AF1 E888FAFFFF              	call	tL0
  1336                                  	
  1337                                  	;jmp	short lff8m_3
  1338                                  	; 15/11/2023
  1339 00000AF6 EBEE                    	jmp	lff8_eof
  1340                                  
  1341                                  	; --------------
  1342                                  
  1343                                  load_8khz_stereo_8_bit:
  1344                                  	; 15/11/2023
  1345                                  	; 14/11/2023
  1346                                  	; 13/11/2023
  1347 00000AF8 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1348                                  					; last of the file?
  1349 00000AFF 7402                    	jz	short lff8s_0		; no
  1350 00000B01 F9                      	stc
  1351 00000B02 C3                      	retn
  1352                                  
  1353                                  lff8s_0:
  1354 00000B03 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1355                                          ;mov	edx, [loadsize]
  1356                                  
  1357                                  	; esi = buffer address
  1358                                  	;; edx = buffer size
  1359                                  
  1360                                  	; load file into memory
  1361                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000B08 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000B0E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000B10 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000B16 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000B1B CD40                <1>  int 40h
  1362 00000B1D 72D0                    	jc	short lff8s_5 ; error !
  1363                                  
  1364 00000B1F BF[00300000]            	mov	edi, audio_buffer
  1365                                  	
  1366 00000B24 D1E8                    	shr	eax, 1
  1367 00000B26 74BE                    	jz	short lff8_eof
  1368                                  
  1369 00000B28 89C1                    	mov	ecx, eax	; word count
  1370                                  lff8s_1:
  1371 00000B2A AC                      	lodsb
  1372 00000B2B A2[5D200000]            	mov	[previous_val_l], al
  1373 00000B30 2C80                    	sub	al, 80h
  1374 00000B32 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1375 00000B36 66AB                    	stosw		; original sample (L)
  1376 00000B38 AC                      	lodsb
  1377 00000B39 A2[5F200000]            	mov	[previous_val_r], al
  1378 00000B3E 2C80                    	sub	al, 80h
  1379 00000B40 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1380 00000B44 66AB                    	stosw		; original sample (R)
  1381                                  
  1382                                  	;xor	eax, eax
  1383 00000B46 66B88080                	mov	ax, 8080h
  1384 00000B4A 49                      	dec	ecx
  1385 00000B4B 7403                    	jz	short lff8s_2
  1386                                  		; convert 8 bit sample to 16 bit sample
  1387 00000B4D 668B06                  	mov	ax, [esi]
  1388                                  lff8s_2:
  1389 00000B50 A2[61200000]            	mov	[next_val_l], al
  1390 00000B55 8825[63200000]          	mov	[next_val_r], ah
  1391 00000B5B 8A25[5D200000]          	mov	ah, [previous_val_l]
  1392 00000B61 00E0                    	add	al, ah
  1393 00000B63 D0D8                    	rcr	al, 1
  1394 00000B65 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1395 00000B67 00E0                    	add	al, ah
  1396 00000B69 D0D8                    	rcr	al, 1	
  1397 00000B6B 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1398 00000B6D 00E0                    	add	al, ah
  1399 00000B6F D0D8                    	rcr	al, 1
  1400 00000B71 2C80                    	sub	al, 80h
  1401 00000B73 66C1E008                	shl	ax, 8
  1402 00000B77 66AB                    	stosw		; this is 1st interpolated sample (L)
  1403 00000B79 A0[63200000]            	mov	al, [next_val_r]
  1404 00000B7E 8A25[5F200000]          	mov	ah, [previous_val_r]
  1405 00000B84 00E0                    	add	al, ah
  1406 00000B86 D0D8                    	rcr	al, 1
  1407 00000B88 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1408 00000B8A 00E0                    	add	al, ah
  1409 00000B8C D0D8                    	rcr	al, 1
  1410 00000B8E 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1411 00000B90 00E0                    	add	al, ah
  1412 00000B92 D0D8                    	rcr	al, 1
  1413 00000B94 2C80                    	sub	al, 80h
  1414 00000B96 66C1E008                	shl	ax, 8
  1415 00000B9A 66AB                    	stosw		; this is 1st interpolated sample (R)
  1416 00000B9C 88D8                    	mov	al, bl
  1417 00000B9E 00D0                    	add	al, dl
  1418 00000BA0 D0D8                    	rcr	al, 1
  1419 00000BA2 2C80                    	sub	al, 80h
  1420 00000BA4 66C1E008                	shl	ax, 8
  1421 00000BA8 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1422 00000BAA 88F8                    	mov	al, bh
  1423 00000BAC 00F0                    	add	al, dh
  1424 00000BAE D0D8                    	rcr	al, 1
  1425 00000BB0 2C80                    	sub	al, 80h
  1426 00000BB2 66C1E008                	shl	ax, 8
  1427 00000BB6 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1428 00000BB8 88D0                    	mov	al, dl
  1429 00000BBA 2C80                    	sub	al, 80h
  1430 00000BBC 66C1E008                	shl	ax, 8
  1431 00000BC0 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1432 00000BC2 88F0                    	mov	al, dh
  1433 00000BC4 2C80                    	sub	al, 80h
  1434 00000BC6 66C1E008                	shl	ax, 8
  1435 00000BCA 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1436 00000BCC A0[61200000]            	mov	al, [next_val_l]
  1437 00000BD1 00D0                    	add	al, dl
  1438 00000BD3 D0D8                    	rcr	al, 1
  1439 00000BD5 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1440 00000BD7 00D0                    	add	al, dl
  1441 00000BD9 D0D8                    	rcr	al, 1
  1442 00000BDB 2C80                    	sub	al, 80h
  1443 00000BDD 66C1E008                	shl	ax, 8
  1444 00000BE1 66AB                    	stosw		; this is 4th interpolated sample (L)
  1445 00000BE3 A0[63200000]            	mov	al, [next_val_r]
  1446 00000BE8 00F0                    	add	al, dh
  1447 00000BEA D0D8                    	rcr	al, 1
  1448 00000BEC 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1449 00000BEE 00F0                    	add	al, dh
  1450 00000BF0 D0D8                    	rcr	al, 1
  1451 00000BF2 2C80                    	sub	al, 80h
  1452 00000BF4 66C1E008                	shl	ax, 8
  1453 00000BF8 66AB                    	stosw		; this is 4th interpolated sample (R)
  1454 00000BFA A0[61200000]            	mov	al, [next_val_l]
  1455 00000BFF 00D8                    	add	al, bl
  1456 00000C01 D0D8                    	rcr	al, 1
  1457 00000C03 2C80                    	sub	al, 80h
  1458 00000C05 66C1E008                	shl	ax, 8
  1459 00000C09 66AB                    	stosw		; this is 5th interpolated sample (L)
  1460 00000C0B A0[63200000]            	mov	al, [next_val_r]
  1461 00000C10 00F8                    	add	al, bh
  1462 00000C12 D0D8                    	rcr	al, 1
  1463 00000C14 2C80                    	sub	al, 80h
  1464 00000C16 66C1E008                	shl	ax, 8
  1465 00000C1A 66AB                    	stosw		; this is 5th interpolated sample (R)
  1466                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1467 00000C1C E305                    	jecxz	lff8s_6
  1468 00000C1E E907FFFFFF              	jmp	lff8s_1
  1469                                  lff8s_6:
  1470 00000C23 E9ABFEFFFF              	jmp	lff8s_3
  1471                                  
  1472                                  load_8khz_mono_16_bit:
  1473                                  	; 13/11/2023
  1474 00000C28 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1475                                  					; last of the file?
  1476 00000C2F 7402                    	jz	short lff8m2_0		; no
  1477 00000C31 F9                      	stc
  1478 00000C32 C3                      	retn
  1479                                  
  1480                                  lff8m2_0:
  1481 00000C33 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1482                                          ;mov	edx, [loadsize]
  1483                                  
  1484                                  	; esi = buffer address
  1485                                  	;; edx = buffer size
  1486                                  
  1487                                  	; load file into memory
  1488                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000C38 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000C3E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000C40 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000C46 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000C4B CD40                <1>  int 40h
  1489 00000C4D 0F82A0000000            	jc	lff8m2_7 ; error !
  1490                                  
  1491 00000C53 BF[00300000]            	mov	edi, audio_buffer
  1492                                  	
  1493 00000C58 D1E8                    	shr	eax, 1
  1494 00000C5A 7505                    	jnz	short lff8m2_8
  1495 00000C5C E985FEFFFF              	jmp	lff8_eof
  1496                                  
  1497                                  lff8m2_8:
  1498 00000C61 89C1                    	mov	ecx, eax	; word count
  1499                                  lff8m2_1:
  1500 00000C63 66AD                    	lodsw
  1501 00000C65 66AB                    	stosw		; original sample (left channel)
  1502 00000C67 66AB                    	stosw		; original sample (right channel)
  1503 00000C69 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1504 00000C6C 66A3[5D200000]          	mov	[previous_val], ax
  1505 00000C72 31C0                    	xor	eax, eax
  1506 00000C74 49                      	dec	ecx
  1507 00000C75 7403                    	jz	short lff8m2_2
  1508 00000C77 668B06                  	mov	ax, [esi]
  1509                                  lff8m2_2:
  1510 00000C7A 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1511 00000C7D 89C5                    	mov	ebp, eax	; [next_val]
  1512 00000C7F 660305[5D200000]        	add	ax, [previous_val]
  1513 00000C86 66D1D8                  	rcr	ax, 1
  1514 00000C89 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1515 00000C8B 660305[5D200000]        	add	ax, [previous_val]
  1516 00000C92 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1517 00000C95 89C3                    	mov	ebx, eax 		
  1518 00000C97 660305[5D200000]        	add	ax, [previous_val]
  1519 00000C9E 66D1D8                  	rcr	ax, 1
  1520 00000CA1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1521 00000CA4 66AB                    	stosw		; this is 1st interpolated sample (L)
  1522 00000CA6 66AB                    	stosw		; this is 1st interpolated sample (R)
  1523 00000CA8 89D8                    	mov	eax, ebx
  1524 00000CAA 6601D0                  	add	ax, dx
  1525 00000CAD 66D1D8                  	rcr	ax, 1
  1526 00000CB0 80EC80                  	sub	ah, 80h
  1527 00000CB3 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1528 00000CB5 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1529 00000CB7 89D0                    	mov	eax, edx
  1530 00000CB9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1531 00000CBC 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1532 00000CBE 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1533 00000CC0 89E8                    	mov	eax, ebp
  1534 00000CC2 6601D0                  	add	ax, dx
  1535 00000CC5 66D1D8                  	rcr	ax, 1
  1536 00000CC8 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1537 00000CCA 6601D0                  	add	ax, dx
  1538 00000CCD 66D1D8                  	rcr	ax, 1
  1539 00000CD0 80EC80                  	sub	ah, 80h
  1540 00000CD3 66AB                    	stosw		; this is 4th interpolated sample (L)
  1541 00000CD5 66AB                    	stosw		; this is 4th interpolated sample (R)
  1542 00000CD7 89E8                    	mov	eax, ebp
  1543 00000CD9 6601D8                  	add	ax, bx
  1544 00000CDC 66D1D8                  	rcr	ax, 1
  1545 00000CDF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1546 00000CE2 66AB                    	stosw		; this is 5th interpolated sample (L)
  1547 00000CE4 66AB                    	stosw		; this is 5th interpolated sample (R)
  1548                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1549 00000CE6 09C9                    	or	ecx, ecx
  1550 00000CE8 0F8575FFFFFF            	jnz	lff8m2_1
  1551 00000CEE E9E0FDFFFF              	jmp	lff8m2_3
  1552                                  
  1553                                  lff8m2_7:
  1554                                  lff8s2_7:
  1555 00000CF3 E9F7FDFFFF              	jmp	lff8m2_5  ; error
  1556                                  
  1557                                  load_8khz_stereo_16_bit:
  1558                                  	; 16/11/2023
  1559                                  	; 15/11/2023
  1560                                  	; 13/11/2023
  1561 00000CF8 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1562                                  					; last of the file?
  1563 00000CFF 7402                    	jz	short lff8s2_0		; no
  1564 00000D01 F9                      	stc
  1565 00000D02 C3                      	retn
  1566                                  
  1567                                  lff8s2_0:
  1568 00000D03 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1569                                          ;mov	edx, [loadsize]
  1570                                  
  1571                                  	; esi = buffer address
  1572                                  	;; edx = buffer size
  1573                                  
  1574                                  	; load file into memory
  1575                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000D08 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000D0E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000D10 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000D16 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000D1B CD40                <1>  int 40h
  1576 00000D1D 72D4                    	jc	short lff8s2_7 ; error !
  1577                                  
  1578 00000D1F BF[00300000]            	mov	edi, audio_buffer
  1579                                  	
  1580 00000D24 C1E802                  	shr	eax, 2
  1581 00000D27 7505                    	jnz	short lff8s2_8
  1582 00000D29 E9B8FDFFFF              	jmp	lff8_eof
  1583                                  
  1584                                  lff8s2_8:
  1585 00000D2E 89C1                    	mov	ecx, eax ; dword count
  1586                                  lff8s2_1:
  1587 00000D30 66AD                    	lodsw
  1588 00000D32 66AB                    	stosw		; original sample (L)
  1589                                  	; 15/11/2023
  1590 00000D34 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1591 00000D37 66A3[5D200000]          	mov	[previous_val_l], ax
  1592 00000D3D 66AD                    	lodsw
  1593 00000D3F 66AB                    	stosw		; original sample (R)
  1594 00000D41 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1595 00000D44 66A3[5F200000]          	mov	[previous_val_r], ax
  1596 00000D4A 31D2                    	xor	edx, edx
  1597 00000D4C 31C0                    	xor	eax, eax
  1598                                  	; 16/11/2023
  1599 00000D4E 49                      	dec	ecx
  1600 00000D4F 7407                    	jz	short lff8s2_2
  1601 00000D51 668B06                  	mov	ax, [esi]
  1602 00000D54 668B5602                	mov	dx, [esi+2]
  1603                                  lff8s2_2:
  1604 00000D58 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1605 00000D5B 66A3[61200000]          	mov	[next_val_l], ax
  1606 00000D61 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1607 00000D64 668915[63200000]        	mov	[next_val_r], dx
  1608 00000D6B 660305[5D200000]        	add	ax, [previous_val_l]
  1609 00000D72 66D1D8                  	rcr	ax, 1
  1610 00000D75 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1611 00000D77 660305[5D200000]        	add	ax, [previous_val_l]
  1612 00000D7E 66D1D8                  	rcr	ax, 1	
  1613 00000D81 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1614 00000D83 660305[5D200000]        	add	ax, [previous_val_l]
  1615 00000D8A 66D1D8                  	rcr	ax, 1
  1616 00000D8D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1617 00000D90 66AB                    	stosw		; this is 1st interpolated sample (L)
  1618 00000D92 66A1[63200000]          	mov	ax, [next_val_r]
  1619 00000D98 660305[5F200000]        	add	ax, [previous_val_r]
  1620 00000D9F 66D1D8                  	rcr	ax, 1
  1621 00000DA2 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1622 00000DA4 660305[5F200000]        	add	ax, [previous_val_r]
  1623 00000DAB 66D1D8                  	rcr	ax, 1
  1624 00000DAE 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1625 00000DAF 660305[5F200000]        	add	ax, [previous_val_r]
  1626 00000DB6 66D1D8                  	rcr	ax, 1
  1627 00000DB9 80EC80                  	sub	ah, 80h
  1628 00000DBC 66AB                    	stosw		; this is 1st interpolated sample (R)
  1629 00000DBE 89D8                    	mov	eax, ebx
  1630 00000DC0 6601D0                  	add	ax, dx
  1631 00000DC3 66D1D8                  	rcr	ax, 1
  1632 00000DC6 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1633 00000DC9 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1634 00000DCB 58                      	pop	eax ; *
  1635 00000DCC 6601E8                  	add	ax, bp
  1636 00000DCF 66D1D8                  	rcr	ax, 1
  1637 00000DD2 80EC80                  	sub	ah, 80h
  1638 00000DD5 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1639 00000DD7 89D0                    	mov	eax, edx
  1640 00000DD9 80EC80                  	sub	ah, 80h
  1641 00000DDC 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1642 00000DDE 89E8                    	mov	eax, ebp
  1643 00000DE0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1644 00000DE3 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1645 00000DE5 66A1[61200000]          	mov	ax, [next_val_l]
  1646 00000DEB 6601D0                  	add	ax, dx
  1647 00000DEE 66D1D8                  	rcr	ax, 1
  1648 00000DF1 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1649 00000DF3 6601D0                  	add	ax, dx
  1650 00000DF6 66D1D8                  	rcr	ax, 1
  1651 00000DF9 80EC80                  	sub	ah, 80h
  1652 00000DFC 66AB                    	stosw		; this is 4th interpolated sample (L)
  1653 00000DFE 66A1[63200000]          	mov	ax, [next_val_r]
  1654 00000E04 6601E8                  	add	ax, bp
  1655 00000E07 66D1D8                  	rcr	ax, 1
  1656 00000E0A 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1657 00000E0B 6601E8                  	add	ax, bp
  1658 00000E0E 66D1D8                  	rcr	ax, 1
  1659 00000E11 80EC80                  	sub	ah, 80h
  1660 00000E14 66AB                    	stosw		; this is 4th interpolated sample (R)
  1661 00000E16 66A1[61200000]          	mov	ax, [next_val_l]
  1662 00000E1C 6601D8                  	add	ax, bx
  1663 00000E1F 66D1D8                  	rcr	ax, 1
  1664 00000E22 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1665 00000E25 66AB                    	stosw		; this is 5th interpolated sample (L)
  1666 00000E27 58                      	pop	eax ; **
  1667 00000E28 660305[63200000]        	add	ax, [next_val_r]
  1668 00000E2F 66D1D8                  	rcr	ax, 1
  1669 00000E32 80EC80                  	sub	ah, 80h
  1670 00000E35 66AB                    	stosw		; this is 5th interpolated sample (R)
  1671                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1672 00000E37 E305                    	jecxz	lff8_s2_9
  1673 00000E39 E9F2FEFFFF              	jmp	lff8s2_1
  1674                                  lff8_s2_9:
  1675 00000E3E E990FCFFFF              	jmp	lff8s2_3
  1676                                  
  1677                                  ; .....................
  1678                                  
  1679                                  load_16khz_mono_8_bit:
  1680                                  	; 14/11/2023
  1681                                  	; 13/11/2023
  1682 00000E43 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1683                                  					; last of the file?
  1684 00000E4A 7402                    	jz	short lff16m_0		; no
  1685 00000E4C F9                      	stc
  1686 00000E4D C3                      	retn
  1687                                  
  1688                                  lff16m_0:
  1689 00000E4E BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1690                                          ;mov	edx, [loadsize]
  1691                                  
  1692                                  	; esi = buffer address
  1693                                  	;; edx = buffer size
  1694                                  
  1695                                  	; load file into memory
  1696                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000E53 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000E59 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000E5B 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000E61 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000E66 CD40                <1>  int 40h
  1697 00000E68 7253                    	jc	short lff16m_7 ; error !
  1698                                  
  1699 00000E6A BF[00300000]            	mov	edi, audio_buffer
  1700                                  	
  1701 00000E6F 21C0                    	and	eax, eax
  1702 00000E71 7505                    	jnz	short lff16m_8
  1703 00000E73 E96EFCFFFF              	jmp	lff16_eof
  1704                                  
  1705                                  lff16m_8:
  1706 00000E78 89C1                    	mov	ecx, eax		; byte count
  1707                                  lff16m_1:
  1708 00000E7A AC                      	lodsb
  1709                                  	;mov	[previous_val], al
  1710 00000E7B 88C3                    	mov	bl, al
  1711 00000E7D 2C80                    	sub	al, 80h
  1712 00000E7F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1713 00000E83 66AB                    	stosw		; original sample (left channel)
  1714 00000E85 66AB                    	stosw		; original sample (right channel)
  1715                                  	;xor	ax, ax
  1716                                  	; 14/11/22023
  1717 00000E87 B080                    	mov	al, 80h
  1718 00000E89 49                      	dec	ecx
  1719 00000E8A 7402                    	jz	short lff16m_2
  1720 00000E8C 8A06                    	mov	al, [esi]
  1721                                  lff16m_2:
  1722                                  	;mov	[next_val], al
  1723 00000E8E 88C7                    	mov	bh, al
  1724                                  	;add	al, [previous_val]
  1725 00000E90 00D8                    	add	al, bl
  1726 00000E92 D0D8                    	rcr	al, 1
  1727 00000E94 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1728                                  	;add	al, [previous_val]
  1729 00000E96 00D8                    	add	al, bl
  1730 00000E98 D0D8                    	rcr	al, 1
  1731 00000E9A 2C80                    	sub	al, 80h
  1732 00000E9C 66C1E008                	shl	ax, 8
  1733 00000EA0 66AB                    	stosw		; this is 1st interpolated sample (L)
  1734 00000EA2 66AB                    	stosw		; this is 1st interpolated sample (R)
  1735                                  	;mov	al, [next_val]
  1736 00000EA4 88F8                    	mov	al, bh
  1737 00000EA6 00D0                    	add	al, dl
  1738 00000EA8 D0D8                    	rcr	al, 1
  1739 00000EAA 2C80                    	sub	al, 80h
  1740 00000EAC 66C1E008                	shl	ax, 8
  1741 00000EB0 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1742 00000EB2 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1743                                  	
  1744                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1745 00000EB4 09C9                    	or	ecx, ecx
  1746 00000EB6 75C2                    	jnz	short lff16m_1
  1747 00000EB8 E916FCFFFF              	jmp	lff16m_3
  1748                                  
  1749                                  lff16m_7:
  1750                                  lff16s_7:
  1751 00000EBD E92DFCFFFF              	jmp	lff16m_5  ; error
  1752                                  
  1753                                  load_16khz_stereo_8_bit:
  1754                                  	; 14/11/2023
  1755                                  	; 13/11/2023
  1756 00000EC2 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1757                                  					; last of the file?
  1758 00000EC9 7402                    	jz	short lff16s_0		; no
  1759 00000ECB F9                      	stc
  1760 00000ECC C3                      	retn
  1761                                  
  1762                                  lff16s_0:
  1763 00000ECD BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1764                                          ;mov	edx, [loadsize]
  1765                                  
  1766                                  	; esi = buffer address
  1767                                  	;; edx = buffer size
  1768                                  
  1769                                  	; load file into memory
  1770                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000ED2 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000ED8 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000EDA 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000EE0 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000EE5 CD40                <1>  int 40h
  1771 00000EE7 72D4                    	jc	short lff16s_7 ; error !
  1772                                  
  1773 00000EE9 BF[00300000]            	mov	edi, audio_buffer
  1774                                  	
  1775 00000EEE D1E8                    	shr	eax, 1
  1776 00000EF0 7505                    	jnz	short lff16s_8
  1777 00000EF2 E9EFFBFFFF              	jmp	lff16_eof
  1778                                  
  1779                                  lff16s_8:
  1780 00000EF7 89C1                    	mov	ecx, eax	; word count
  1781                                  lff16s_1:
  1782 00000EF9 AC                      	lodsb
  1783 00000EFA A2[5D200000]            	mov	[previous_val_l], al
  1784 00000EFF 2C80                    	sub	al, 80h
  1785 00000F01 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1786 00000F05 66AB                    	stosw		; original sample (L)
  1787 00000F07 AC                      	lodsb
  1788 00000F08 A2[5F200000]            	mov	[previous_val_r], al
  1789 00000F0D 2C80                    	sub	al, 80h
  1790 00000F0F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1791 00000F13 66AB                    	stosw		; original sample (R)
  1792                                  
  1793                                  	;xor	eax, eax
  1794 00000F15 66B88080                	mov	ax, 8080h
  1795 00000F19 49                      	dec	ecx
  1796 00000F1A 7403                    	jz	short lff16s_2
  1797                                  		; convert 8 bit sample to 16 bit sample
  1798 00000F1C 668B06                  	mov	ax, [esi]
  1799                                  lff16s_2:
  1800                                  	;mov	[next_val_l], al
  1801                                  	;mov	[next_val_r], ah
  1802 00000F1F 89C3                    	mov	ebx, eax
  1803 00000F21 0205[5D200000]          	add	al, [previous_val_l]
  1804 00000F27 D0D8                    	rcr	al, 1
  1805 00000F29 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  1806 00000F2B 0205[5D200000]          	add	al, [previous_val_l]
  1807 00000F31 D0D8                    	rcr	al, 1
  1808 00000F33 2C80                    	sub	al, 80h
  1809 00000F35 66C1E008                	shl	ax, 8
  1810 00000F39 66AB                    	stosw		; this is 1st interpolated sample (L)
  1811 00000F3B 88F8                    	mov	al, bh	; [next_val_r]
  1812 00000F3D 0205[5F200000]          	add	al, [previous_val_r]
  1813 00000F43 D0D8                    	rcr	al, 1
  1814 00000F45 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  1815 00000F47 0205[5F200000]          	add	al, [previous_val_r]
  1816 00000F4D D0D8                    	rcr	al, 1
  1817 00000F4F 2C80                    	sub	al, 80h
  1818 00000F51 66C1E008                	shl	ax, 8
  1819 00000F55 66AB                    	stosw		; this is 1st interpolated sample (R)
  1820 00000F57 88D0                    	mov	al, dl
  1821 00000F59 00D8                    	add	al, bl	; [next_val_l]
  1822 00000F5B D0D8                    	rcr	al, 1
  1823 00000F5D 2C80                    	sub	al, 80h
  1824 00000F5F 66C1E008                	shl	ax, 8
  1825 00000F63 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1826 00000F65 88F0                    	mov	al, dh
  1827 00000F67 00F8                    	add	al, bh	; [next_val_r]
  1828 00000F69 D0D8                    	rcr	al, 1
  1829 00000F6B 2C80                    	sub	al, 80h
  1830 00000F6D 66C1E008                	shl	ax, 8
  1831 00000F71 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1832                                  	
  1833                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1834 00000F73 09C9                    	or	ecx, ecx
  1835 00000F75 7582                    	jnz	short lff16s_1
  1836 00000F77 E957FBFFFF              	jmp	lff16s_3
  1837                                  
  1838                                  load_16khz_mono_16_bit:
  1839                                  	; 15/11/2023
  1840                                  	; 13/11/2023
  1841 00000F7C F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1842                                  					; last of the file?
  1843 00000F83 7402                    	jz	short lff16m2_0		; no
  1844 00000F85 F9                      	stc
  1845 00000F86 C3                      	retn
  1846                                  
  1847                                  lff16m2_0:
  1848 00000F87 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1849                                          ;mov	edx, [loadsize]
  1850                                  
  1851                                  	; esi = buffer address
  1852                                  	;; edx = buffer size
  1853                                  
  1854                                  	; load file into memory
  1855                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000F8C 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000F92 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000F94 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000F9A B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000F9F CD40                <1>  int 40h
  1856 00000FA1 7255                    	jc	short lff16m2_7 ; error !
  1857                                  
  1858 00000FA3 BF[00300000]            	mov	edi, audio_buffer
  1859                                  	
  1860 00000FA8 D1E8                    	shr	eax, 1
  1861 00000FAA 7505                    	jnz	short lff16m2_8
  1862 00000FAC E935FBFFFF              	jmp	lff16_eof
  1863                                  
  1864                                  lff16m2_8:
  1865 00000FB1 89C1                    	mov	ecx, eax  ; word count
  1866                                  lff16m2_1:
  1867 00000FB3 66AD                    	lodsw
  1868 00000FB5 66AB                    	stosw		; original sample (left channel)
  1869 00000FB7 66AB                    	stosw		; original sample (right channel)
  1870 00000FB9 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1871                                  	;mov	[previous_val], ax
  1872 00000FBC 89C3                    	mov	ebx, eax	
  1873 00000FBE 31C0                    	xor	eax, eax
  1874 00000FC0 49                      	dec	ecx
  1875 00000FC1 7403                    	jz	short lff16m2_2
  1876 00000FC3 668B06                  	mov	ax, [esi]
  1877                                  lff16m2_2:
  1878 00000FC6 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1879 00000FC9 89C5                    	mov	ebp, eax	; [next_val]
  1880                                  	;add	ax, [previous_val]
  1881 00000FCB 6601D8                  	add	ax, bx
  1882 00000FCE 66D1D8                  	rcr	ax, 1
  1883 00000FD1 89C2                    	mov	edx, eax ; this is temporary interpolation value
  1884                                  	;add	ax, [previous_val]
  1885 00000FD3 6601D8                  	add	ax, bx
  1886 00000FD6 66D1D8                  	rcr	ax, 1
  1887 00000FD9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1888 00000FDC 66AB                    	stosw		; this is 1st interpolated sample (L)
  1889 00000FDE 66AB                    	stosw		; this is 1st interpolated sample (R)
  1890 00000FE0 89E8                    	mov	eax, ebp 
  1891 00000FE2 6601D0                  	add	ax, dx
  1892 00000FE5 66D1D8                  	rcr	ax, 1
  1893 00000FE8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1894 00000FEB 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1895 00000FED 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1896                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1897 00000FEF 09C9                    	or	ecx, ecx
  1898 00000FF1 75C0                    	jnz	short lff16m2_1
  1899 00000FF3 E9DBFAFFFF              	jmp	lff16m2_3
  1900                                  
  1901                                  lff16m2_7:
  1902                                  lff16s2_7:
  1903 00000FF8 E9F2FAFFFF              	jmp	lff16m2_5  ; error
  1904                                  
  1905                                  load_16khz_stereo_16_bit:
  1906                                  	; 16/11/2023
  1907                                  	; 15/11/2023
  1908                                  	; 13/11/2023
  1909 00000FFD F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1910                                  					; last of the file?
  1911 00001004 7402                    	jz	short lff16s2_0		; no
  1912 00001006 F9                      	stc
  1913 00001007 C3                      	retn
  1914                                  
  1915                                  lff16s2_0:
  1916 00001008 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1917                                          ;mov	edx, [loadsize]
  1918                                  
  1919                                  	; esi = buffer address
  1920                                  	;; edx = buffer size
  1921                                  
  1922                                  	; load file into memory
  1923                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000100D 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001013 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001015 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000101B B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001020 CD40                <1>  int 40h
  1924 00001022 72D4                    	jc	short lff16s2_7 ; error !
  1925                                  
  1926 00001024 BF[00300000]            	mov	edi, audio_buffer
  1927                                  	
  1928 00001029 C1E802                  	shr	eax, 2
  1929 0000102C 7505                    	jnz	short lff16s2_8
  1930 0000102E E9B3FAFFFF              	jmp	lff16_eof
  1931                                  
  1932                                  lff16s2_8:
  1933 00001033 89C1                    	mov	ecx, eax  ; dword count
  1934                                  lff16s2_1:
  1935 00001035 66AD                    	lodsw
  1936 00001037 66AB                    	stosw		; original sample (L)
  1937 00001039 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1938 0000103C 66A3[5D200000]          	mov	[previous_val_l], ax
  1939 00001042 66AD                    	lodsw
  1940 00001044 66AB                    	stosw		; original sample (R)
  1941 00001046 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1942 00001049 66A3[5F200000]          	mov	[previous_val_r], ax
  1943 0000104F 31D2                    	xor	edx, edx
  1944 00001051 31C0                    	xor	eax, eax
  1945                                  	; 16/11/2023
  1946 00001053 49                      	dec	ecx
  1947 00001054 7407                    	jz	short lff16s2_2
  1948 00001056 668B06                  	mov	ax, [esi]
  1949 00001059 668B5602                	mov	dx, [esi+2]
  1950                                  lff16s2_2:
  1951 0000105D 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1952                                  	;mov	[next_val_l], ax
  1953 00001060 89C5                    	mov	ebp, eax
  1954 00001062 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  1955 00001065 668915[63200000]        	mov	[next_val_r], dx
  1956 0000106C 660305[5D200000]        	add	ax, [previous_val_l]
  1957 00001073 66D1D8                  	rcr	ax, 1
  1958 00001076 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  1959 00001078 660305[5D200000]        	add	ax, [previous_val_l]
  1960 0000107F 66D1D8                  	rcr	ax, 1
  1961 00001082 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  1962 00001085 66AB                    	stosw		; this is 1st interpolated sample (L)
  1963 00001087 66A1[63200000]          	mov	ax, [next_val_r]
  1964 0000108D 660305[5F200000]        	add	ax, [previous_val_r]
  1965 00001094 66D1D8                  	rcr	ax, 1
  1966 00001097 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  1967 00001099 660305[5F200000]        	add	ax, [previous_val_r]
  1968 000010A0 66D1D8                  	rcr	ax, 1
  1969 000010A3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1970 000010A6 66AB                    	stosw		; this is 1st interpolated sample (R)
  1971                                  	;mov	ax, [next_val_l]
  1972 000010A8 89E8                    	mov	eax, ebp
  1973 000010AA 6601D0                  	add	ax, dx
  1974 000010AD 66D1D8                  	rcr	ax, 1
  1975 000010B0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1976 000010B3 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1977 000010B5 66A1[63200000]          	mov	ax, [next_val_r]
  1978 000010BB 6601D8                  	add	ax, bx
  1979 000010BE 66D1D8                  	rcr	ax, 1
  1980 000010C1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1981 000010C4 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1982                                  	
  1983                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1984 000010C6 09C9                    	or	ecx, ecx
  1985 000010C8 0F8567FFFFFF            	jnz	lff16s2_1
  1986 000010CE E900FAFFFF              	jmp	lff16s2_3
  1987                                  
  1988                                  ; .....................
  1989                                  
  1990                                  load_24khz_mono_8_bit:
  1991                                  	; 15/11/2023
  1992 000010D3 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1993                                  					; last of the file?
  1994 000010DA 7402                    	jz	short lff24m_0		; no
  1995 000010DC F9                      	stc
  1996 000010DD C3                      	retn
  1997                                  
  1998                                  lff24m_0:
  1999 000010DE BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2000                                          ;mov	edx, [loadsize]
  2001                                  
  2002                                  	; esi = buffer address
  2003                                  	;; edx = buffer size
  2004                                  
  2005                                  	; load file into memory
  2006                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000010E3 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000010E9 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000010EB 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000010F1 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000010F6 CD40                <1>  int 40h
  2007 000010F8 723B                    	jc	short lff24m_7 ; error !
  2008                                  
  2009 000010FA BF[00300000]            	mov	edi, audio_buffer
  2010                                  	
  2011 000010FF 21C0                    	and	eax, eax
  2012 00001101 7505                    	jnz	short lff24m_8
  2013 00001103 E9DEF9FFFF              	jmp	lff24_eof
  2014                                  
  2015                                  lff24m_8:
  2016 00001108 89C1                    	mov	ecx, eax	; byte count
  2017                                  lff24m_1:
  2018 0000110A AC                      	lodsb
  2019                                  	;mov	[previous_val], al
  2020 0000110B 88C3                    	mov	bl, al
  2021 0000110D 2C80                    	sub	al, 80h
  2022 0000110F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2023 00001113 66AB                    	stosw		; original sample (left channel)
  2024 00001115 66AB                    	stosw		; original sample (right channel)
  2025                                  	;xor	eax, eax
  2026 00001117 B080                    	mov	al, 80h
  2027 00001119 49                      	dec	ecx
  2028 0000111A 7402                    	jz	short lff24m_2
  2029 0000111C 8A06                    	mov	al, [esi]
  2030                                  lff24m_2:
  2031                                  	;;mov	[next_val], al
  2032                                  	;mov	bh, al
  2033                                  	;add	al, [previous_val]
  2034 0000111E 00D8                    	add	al, bl
  2035 00001120 D0D8                    	rcr	al, 1
  2036 00001122 2C80                    	sub	al, 80h
  2037 00001124 66C1E008                	shl	ax, 8
  2038 00001128 66AB                    	stosw		; this is interpolated sample (L)
  2039 0000112A 66AB                    	stosw		; this is interpolated sample (R)
  2040                                  	
  2041                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2042 0000112C 09C9                    	or	ecx, ecx
  2043 0000112E 75DA                    	jnz	short lff24m_1
  2044 00001130 E99EF9FFFF              	jmp	lff24_3
  2045                                  
  2046                                  lff24m_7:
  2047                                  lff24s_7:
  2048 00001135 E9B5F9FFFF              	jmp	lff24_5  ; error
  2049                                  
  2050                                  load_24khz_stereo_8_bit:
  2051                                  	; 15/11/2023
  2052 0000113A F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2053                                  					; last of the file?
  2054 00001141 7402                    	jz	short lff24s_0		; no
  2055 00001143 F9                      	stc
  2056 00001144 C3                      	retn
  2057                                  
  2058                                  lff24s_0:
  2059 00001145 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2060                                          ;mov	edx, [loadsize]
  2061                                  
  2062                                  	; esi = buffer address
  2063                                  	;; edx = buffer size
  2064                                  
  2065                                  	; load file into memory
  2066                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000114A 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001150 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001152 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001158 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000115D CD40                <1>  int 40h
  2067 0000115F 72D4                    	jc	short lff24s_7 ; error !
  2068                                  
  2069 00001161 BF[00300000]            	mov	edi, audio_buffer
  2070                                  	
  2071 00001166 D1E8                    	shr	eax, 1
  2072 00001168 7505                    	jnz	short lff24s_8
  2073 0000116A E977F9FFFF              	jmp	lff24_eof
  2074                                  
  2075                                  lff24s_8:
  2076 0000116F 89C1                    	mov	ecx, eax  ; word count
  2077                                  lff24s_1:
  2078 00001171 AC                      	lodsb
  2079 00001172 A2[5D200000]            	mov	[previous_val_l], al
  2080 00001177 2C80                    	sub	al, 80h
  2081 00001179 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2082 0000117D 66AB                    	stosw		; original sample (L)
  2083 0000117F AC                      	lodsb
  2084 00001180 A2[5F200000]            	mov	[previous_val_r], al
  2085 00001185 2C80                    	sub	al, 80h
  2086 00001187 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2087 0000118B 66AB                    	stosw		; original sample (R)
  2088                                  
  2089                                  	;xor	eax, eax
  2090 0000118D 66B88080                	mov	ax, 8080h
  2091 00001191 49                      	dec	ecx
  2092 00001192 7403                    	jz	short lff24s_2
  2093                                  		; convert 8 bit sample to 16 bit sample
  2094 00001194 668B06                  	mov	ax, [esi]
  2095                                  lff24s_2:
  2096                                  	;;mov	[next_val_l], al
  2097                                  	;;mov	[next_val_r], ah
  2098                                  	;mov	bx, ax
  2099 00001197 88E7                    	mov	bh, ah
  2100 00001199 0205[5D200000]          	add	al, [previous_val_l]
  2101 0000119F D0D8                    	rcr	al, 1
  2102                                  	;mov	dl, al
  2103 000011A1 2C80                    	sub	al, 80h
  2104 000011A3 66C1E008                	shl	ax, 8
  2105 000011A7 66AB                    	stosw		; this is interpolated sample (L)
  2106 000011A9 88F8                    	mov	al, bh	; [next_val_r]
  2107 000011AB 0205[5F200000]          	add	al, [previous_val_r]
  2108 000011B1 D0D8                    	rcr	al, 1
  2109                                  	;mov	dh, al
  2110 000011B3 2C80                    	sub	al, 80h
  2111 000011B5 66C1E008                	shl	ax, 8
  2112 000011B9 66AB                    	stosw		; this is interpolated sample (R)
  2113                                  		
  2114                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2115 000011BB 09C9                    	or	ecx, ecx
  2116 000011BD 75B2                    	jnz	short lff24s_1
  2117 000011BF E90FF9FFFF              	jmp	lff24_3
  2118                                  
  2119                                  load_24khz_mono_16_bit:
  2120                                  	; 15/11/2023
  2121 000011C4 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2122                                  					; last of the file?
  2123 000011CB 7402                    	jz	short lff24m2_0		; no
  2124 000011CD F9                      	stc
  2125 000011CE C3                      	retn
  2126                                  
  2127                                  lff24m2_0:
  2128 000011CF BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2129                                          ;mov	edx, [loadsize]
  2130                                  
  2131                                  	; esi = buffer address
  2132                                  	;; edx = buffer size
  2133                                  
  2134                                  	; load file into memory
  2135                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000011D4 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000011DA 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000011DC 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000011E2 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000011E7 CD40                <1>  int 40h
  2136 000011E9 7237                    	jc	short lff24m2_7 ; error !
  2137                                  
  2138 000011EB BF[00300000]            	mov	edi, audio_buffer
  2139                                  	
  2140 000011F0 D1E8                    	shr	eax, 1
  2141 000011F2 7505                    	jnz	short lff24m2_8
  2142 000011F4 E9EDF8FFFF              	jmp	lff24_eof
  2143                                  
  2144                                  lff24m2_8:
  2145 000011F9 89C1                    	mov	ecx, eax  ; word count
  2146                                  lff24m2_1:
  2147 000011FB 66AD                    	lodsw
  2148 000011FD 66AB                    	stosw		; original sample (left channel)
  2149 000011FF 66AB                    	stosw		; original sample (right channel)
  2150 00001201 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2151                                  	;mov	[previous_val], ax
  2152                                  	;mov	ebx, eax	
  2153                                  	;xor	eax, eax
  2154 00001204 31DB                    	xor	ebx, ebx
  2155 00001206 49                      	dec	ecx
  2156 00001207 7403                    	jz	short lff24m2_2
  2157                                  	;mov	ax, [esi]
  2158 00001209 668B1E                  	mov	bx, [esi]
  2159                                  lff24m2_2:
  2160                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2161                                  	;mov	ebp, eax	; [next_val]
  2162                                  	;add	ax, [previous_val]
  2163                                  	; ax = [previous_val]
  2164                                  	; bx = [next_val]
  2165 0000120C 6601D8                  	add	ax, bx
  2166 0000120F 66D1D8                  	rcr	ax, 1
  2167 00001212 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2168 00001215 66AB                    	stosw		; this is interpolated sample (L)
  2169 00001217 66AB                    	stosw		; this is interpolated sample (R)
  2170                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2171 00001219 09C9                    	or	ecx, ecx
  2172 0000121B 75DE                    	jnz	short lff24m2_1
  2173 0000121D E9B1F8FFFF              	jmp	lff24_3
  2174                                  
  2175                                  lff24m2_7:
  2176                                  lff24s2_7:
  2177 00001222 E9C8F8FFFF              	jmp	lff24_5  ; error
  2178                                  
  2179                                  load_24khz_stereo_16_bit:
  2180                                  	; 16/11/2023
  2181                                  	; 15/11/2023
  2182 00001227 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2183                                  					; last of the file?
  2184 0000122E 7402                    	jz	short lff24s2_0		; no
  2185 00001230 F9                      	stc
  2186 00001231 C3                      	retn
  2187                                  
  2188                                  lff24s2_0:
  2189 00001232 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2190                                          ;mov	edx, [loadsize]
  2191                                  
  2192                                  	; esi = buffer address
  2193                                  	;; edx = buffer size
  2194                                  
  2195                                  	; load file into memory
  2196                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001237 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000123D 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000123F 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001245 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000124A CD40                <1>  int 40h
  2197 0000124C 72D4                    	jc	short lff24s2_7 ; error !
  2198                                  
  2199 0000124E BF[00300000]            	mov	edi, audio_buffer
  2200                                  	
  2201 00001253 C1E802                  	shr	eax, 2
  2202 00001256 7505                    	jnz	short lff24s2_8
  2203 00001258 E989F8FFFF              	jmp	lff24_eof
  2204                                  
  2205                                  lff24s2_8:
  2206 0000125D 89C1                    	mov	ecx, eax  ; dword count
  2207                                  lff24s2_1:
  2208 0000125F 66AD                    	lodsw
  2209 00001261 66AB                    	stosw		; original sample (L)
  2210 00001263 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2211 00001266 66A3[5D200000]          	mov	[previous_val_l], ax
  2212 0000126C 66AD                    	lodsw
  2213 0000126E 66AB                    	stosw		; original sample (R)
  2214 00001270 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2215                                  	;mov	[previous_val_r], ax
  2216 00001273 89C3                    	mov	ebx, eax
  2217 00001275 31D2                    	xor	edx, edx
  2218 00001277 31C0                    	xor	eax, eax
  2219                                  	; 16/11/2023
  2220 00001279 49                      	dec	ecx
  2221 0000127A 7407                    	jz	short lff24s2_2
  2222 0000127C 668B06                  	mov	ax, [esi]
  2223 0000127F 668B5602                	mov	dx, [esi+2]
  2224                                  lff24s2_2:
  2225 00001283 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2226                                  	;;mov	[next_val_l], ax
  2227                                  	;mov	ebp, eax
  2228 00001286 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2229                                  	;mov	[next_val_r], dx
  2230 00001289 660305[5D200000]        	add	ax, [previous_val_l]
  2231 00001290 66D1D8                  	rcr	ax, 1
  2232 00001293 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2233 00001296 66AB                    	stosw		; this is interpolated sample (L)
  2234                                  	;mov	ax, [next_val_r]
  2235 00001298 89D0                    	mov	eax, edx
  2236                                  	;add	ax, [previous_val_r]
  2237 0000129A 6601D8                  	add	ax, bx
  2238 0000129D 66D1D8                  	rcr	ax, 1
  2239 000012A0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2240 000012A3 66AB                    	stosw		; this is interpolated sample (R)
  2241                                  	
  2242                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2243 000012A5 09C9                    	or	ecx, ecx
  2244 000012A7 75B6                    	jnz	short lff24s2_1
  2245 000012A9 E925F8FFFF              	jmp	lff24_3
  2246                                  
  2247                                  ; .....................
  2248                                  
  2249                                  load_32khz_mono_8_bit:
  2250                                  	; 15/11/2023
  2251 000012AE F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2252                                  					; last of the file?
  2253 000012B5 7402                    	jz	short lff32m_0		; no
  2254 000012B7 F9                      	stc
  2255 000012B8 C3                      	retn
  2256                                  
  2257                                  lff32m_0:
  2258 000012B9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2259                                          ;mov	edx, [loadsize]
  2260                                  
  2261                                  	; esi = buffer address
  2262                                  	;; edx = buffer size
  2263                                  
  2264                                  	; load file into memory
  2265                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000012BE 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000012C4 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000012C6 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000012CC B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000012D1 CD40                <1>  int 40h
  2266 000012D3 7247                    	jc	short lff32m_7 ; error !
  2267                                  
  2268 000012D5 BF[00300000]            	mov	edi, audio_buffer
  2269                                  	
  2270 000012DA 21C0                    	and	eax, eax
  2271 000012DC 7505                    	jnz	short lff32m_8
  2272 000012DE E903F8FFFF              	jmp	lff32_eof
  2273                                  
  2274                                  lff32m_8:
  2275 000012E3 89C1                    	mov	ecx, eax	; byte count
  2276                                  lff32m_1:
  2277 000012E5 AC                      	lodsb
  2278                                  	;mov	[previous_val], al
  2279 000012E6 88C3                    	mov	bl, al
  2280 000012E8 2C80                    	sub	al, 80h
  2281 000012EA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2282 000012EE 66AB                    	stosw		; original sample (left channel)
  2283 000012F0 66AB                    	stosw		; original sample (right channel)
  2284                                  	;xor	eax, eax
  2285 000012F2 B080                    	mov	al, 80h
  2286 000012F4 49                      	dec	ecx
  2287 000012F5 7402                    	jz	short lff32m_2
  2288 000012F7 8A06                    	mov	al, [esi]
  2289                                  lff32m_2:
  2290                                  	;;mov	[next_val], al
  2291                                  	;mov	bh, al
  2292                                  	;add	al, [previous_val]
  2293 000012F9 00D8                    	add	al, bl
  2294 000012FB D0D8                    	rcr	al, 1
  2295 000012FD 2C80                    	sub	al, 80h
  2296 000012FF 66C1E008                	shl	ax, 8
  2297 00001303 66AB                    	stosw		; this is interpolated sample (L)
  2298 00001305 66AB                    	stosw		; this is interpolated sample (R)
  2299                                  	
  2300                                  	; different than 8-16-24 kHZ !
  2301                                  	; 'original-interpolated-original' trio samples 
  2302 00001307 E30E                    	jecxz	lff32m_3
  2303                                  
  2304 00001309 AC                      	lodsb
  2305 0000130A 2C80                    	sub	al, 80h
  2306 0000130C 66C1E008                	shl	ax, 8
  2307 00001310 66AB                    	stosw		; original sample (left channel)
  2308 00001312 66AB                    	stosw		; original sample (right channel)
  2309                                  
  2310                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2311 00001314 49                      	dec	ecx
  2312 00001315 75CE                    	jnz	short lff32m_1
  2313                                  lff32m_3:
  2314 00001317 E9B7F7FFFF              	jmp	lff32_3
  2315                                  
  2316                                  lff32m_7:
  2317                                  lff32s_7:
  2318 0000131C E9CEF7FFFF              	jmp	lff32_5  ; error
  2319                                  
  2320                                  load_32khz_stereo_8_bit:
  2321                                  	; 15/11/2023
  2322 00001321 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2323                                  					; last of the file?
  2324 00001328 7402                    	jz	short lff32s_0		; no
  2325 0000132A F9                      	stc
  2326 0000132B C3                      	retn
  2327                                  
  2328                                  lff32s_0:
  2329 0000132C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2330                                          ;mov	edx, [loadsize]
  2331                                  
  2332                                  	; esi = buffer address
  2333                                  	;; edx = buffer size
  2334                                  
  2335                                  	; load file into memory
  2336                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001331 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001337 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001339 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000133F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001344 CD40                <1>  int 40h
  2337 00001346 72D4                    	jc	short lff32s_7 ; error !
  2338                                  
  2339 00001348 BF[00300000]            	mov	edi, audio_buffer
  2340                                  	
  2341 0000134D D1E8                    	shr	eax, 1
  2342 0000134F 7505                    	jnz	short lff32s_8
  2343 00001351 E990F7FFFF              	jmp	lff32_eof
  2344                                  
  2345                                  lff32s_8:
  2346 00001356 89C1                    	mov	ecx, eax  ; word count
  2347                                  lff32s_1:
  2348 00001358 AC                      	lodsb
  2349 00001359 A2[5D200000]            	mov	[previous_val_l], al
  2350 0000135E 2C80                    	sub	al, 80h
  2351 00001360 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2352 00001364 66AB                    	stosw		; original sample (L)
  2353 00001366 AC                      	lodsb
  2354 00001367 A2[5F200000]            	mov	[previous_val_r], al
  2355 0000136C 2C80                    	sub	al, 80h
  2356 0000136E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2357 00001372 66AB                    	stosw		; original sample (R)
  2358                                  
  2359                                  	;xor	eax, eax
  2360 00001374 66B88080                	mov	ax, 8080h
  2361 00001378 49                      	dec	ecx
  2362 00001379 7403                    	jz	short lff32s_2
  2363                                  		; convert 8 bit sample to 16 bit sample
  2364 0000137B 668B06                  	mov	ax, [esi]
  2365                                  lff32s_2:
  2366                                  	;;mov	[next_val_l], al
  2367                                  	;;mov	[next_val_r], ah
  2368                                  	;mov	bx, ax
  2369 0000137E 88E7                    	mov	bh, ah
  2370 00001380 0205[5D200000]          	add	al, [previous_val_l]
  2371 00001386 D0D8                    	rcr	al, 1
  2372                                  	;mov	dl, al
  2373 00001388 2C80                    	sub	al, 80h
  2374 0000138A 66C1E008                	shl	ax, 8
  2375 0000138E 66AB                    	stosw		; this is interpolated sample (L)
  2376 00001390 88F8                    	mov	al, bh	; [next_val_r]
  2377 00001392 0205[5F200000]          	add	al, [previous_val_r]
  2378 00001398 D0D8                    	rcr	al, 1
  2379                                  	;mov	dh, al
  2380 0000139A 2C80                    	sub	al, 80h
  2381 0000139C 66C1E008                	shl	ax, 8
  2382 000013A0 66AB                    	stosw		; this is interpolated sample (R)
  2383                                  
  2384                                  	; different than 8-16-24 kHZ !
  2385                                  	; 'original-interpolated-original' trio samples 
  2386 000013A2 E315                    	jecxz	lff32s_3
  2387                                  
  2388 000013A4 AC                      	lodsb
  2389 000013A5 2C80                    	sub	al, 80h
  2390 000013A7 66C1E008                	shl	ax, 8
  2391 000013AB 66AB                    	stosw		; original sample (left channel)
  2392                                  
  2393 000013AD AC                      	lodsb
  2394 000013AE 2C80                    	sub	al, 80h
  2395 000013B0 66C1E008                	shl	ax, 8
  2396 000013B4 66AB                    	stosw		; original sample (right channel)
  2397                                  		
  2398                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2399 000013B6 49                      	dec	ecx
  2400 000013B7 759F                    	jnz	short lff32s_1
  2401                                  lff32s_3:
  2402 000013B9 E915F7FFFF              	jmp	lff32_3
  2403                                  
  2404                                  load_32khz_mono_16_bit:
  2405                                  	; 15/11/2023
  2406 000013BE F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2407                                  					; last of the file?
  2408 000013C5 7402                    	jz	short lff32m2_0		; no
  2409 000013C7 F9                      	stc
  2410 000013C8 C3                      	retn
  2411                                  
  2412                                  lff32m2_0:
  2413 000013C9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2414                                          ;mov	edx, [loadsize]
  2415                                  
  2416                                  	; esi = buffer address
  2417                                  	;; edx = buffer size
  2418                                  
  2419                                  	; load file into memory
  2420                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000013CE 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000013D4 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000013D6 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000013DC B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000013E1 CD40                <1>  int 40h
  2421 000013E3 723E                    	jc	short lff32m2_7 ; error !
  2422                                  
  2423 000013E5 BF[00300000]            	mov	edi, audio_buffer
  2424                                  	
  2425 000013EA D1E8                    	shr	eax, 1
  2426 000013EC 7505                    	jnz	short lff32m2_8
  2427 000013EE E9F3F6FFFF              	jmp	lff32_eof
  2428                                  
  2429                                  lff32m2_8:
  2430 000013F3 89C1                    	mov	ecx, eax  ; word count
  2431                                  lff32m2_1:
  2432 000013F5 66AD                    	lodsw
  2433 000013F7 66AB                    	stosw		; original sample (left channel)
  2434 000013F9 66AB                    	stosw		; original sample (right channel)
  2435 000013FB 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2436                                  	;mov	[previous_val], ax
  2437                                  	;mov	ebx, eax	
  2438                                  	;xor	eax, eax
  2439 000013FE 31DB                    	xor	ebx, ebx
  2440 00001400 49                      	dec	ecx
  2441 00001401 7403                    	jz	short lff32m2_2
  2442                                  	;mov	ax, [esi]
  2443 00001403 668B1E                  	mov	bx, [esi]
  2444                                  lff32m2_2:
  2445                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2446                                  	;mov	ebp, eax	; [next_val]
  2447                                  	;add	ax, [previous_val]
  2448                                  	; ax = [previous_val]
  2449                                  	; bx = [next_val]
  2450 00001406 6601D8                  	add	ax, bx
  2451 00001409 66D1D8                  	rcr	ax, 1
  2452 0000140C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2453 0000140F 66AB                    	stosw		; this is interpolated sample (L)
  2454 00001411 66AB                    	stosw		; this is interpolated sample (R)
  2455                                  
  2456                                  	; different than 8-16-24 kHZ !
  2457                                  	; 'original-interpolated-original' trio samples 
  2458 00001413 E309                    	jecxz	lff32m2_3
  2459                                  
  2460 00001415 66AD                    	lodsw
  2461 00001417 66AB                    	stosw		; original sample (left channel)
  2462 00001419 66AB                    	stosw		; original sample (right channel)
  2463                                  
  2464                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2465 0000141B 49                      	dec	ecx
  2466 0000141C 75D7                    	jnz	short lff32m2_1
  2467                                  lff32m2_3:
  2468 0000141E E9B0F6FFFF              	jmp	lff32_3
  2469                                  
  2470                                  lff32m2_7:
  2471                                  lff32s2_7:
  2472 00001423 E9C7F6FFFF              	jmp	lff32_5  ; error
  2473                                  
  2474                                  load_32khz_stereo_16_bit:
  2475                                  	; 16/11/2023
  2476                                  	; 15/11/2023
  2477 00001428 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2478                                  					; last of the file?
  2479 0000142F 7402                    	jz	short lff32s2_0		; no
  2480 00001431 F9                      	stc
  2481 00001432 C3                      	retn
  2482                                  
  2483                                  lff32s2_0:
  2484 00001433 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2485                                          ;mov	edx, [loadsize]
  2486                                  
  2487                                  	; esi = buffer address
  2488                                  	;; edx = buffer size
  2489                                  
  2490                                  	; load file into memory
  2491                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001438 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000143E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001440 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001446 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000144B CD40                <1>  int 40h
  2492 0000144D 72D4                    	jc	short lff32s2_7 ; error !
  2493                                  
  2494 0000144F BF[00300000]            	mov	edi, audio_buffer
  2495                                  	
  2496 00001454 C1E802                  	shr	eax, 2
  2497 00001457 7505                    	jnz	short lff32s2_8
  2498 00001459 E988F6FFFF              	jmp	lff32_eof
  2499                                  
  2500                                  lff32s2_8:
  2501 0000145E 89C1                    	mov	ecx, eax ; dword count
  2502                                  lff32s2_1:
  2503 00001460 66AD                    	lodsw
  2504 00001462 66AB                    	stosw		; original sample (L)
  2505 00001464 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2506 00001467 66A3[5D200000]          	mov	[previous_val_l], ax
  2507 0000146D 66AD                    	lodsw
  2508 0000146F 66AB                    	stosw		; original sample (R)
  2509 00001471 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2510                                  	;mov	[previous_val_r], ax
  2511 00001474 89C3                    	mov	ebx, eax
  2512 00001476 31D2                    	xor	edx, edx
  2513 00001478 31C0                    	xor	eax, eax
  2514                                  	; 16/11/2023
  2515 0000147A 49                      	dec	ecx
  2516 0000147B 7407                    	jz	short lff32s2_2
  2517 0000147D 668B06                  	mov	ax, [esi]
  2518 00001480 668B5602                	mov	dx, [esi+2]
  2519                                  lff32s2_2:
  2520 00001484 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2521                                  	;;mov	[next_val_l], ax
  2522                                  	;mov	ebp, eax
  2523 00001487 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2524                                  	;mov	[next_val_r], dx
  2525 0000148A 660305[5D200000]        	add	ax, [previous_val_l]
  2526 00001491 66D1D8                  	rcr	ax, 1
  2527 00001494 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2528 00001497 66AB                    	stosw		; this is interpolated sample (L)
  2529                                  	;mov	ax, [next_val_r]
  2530 00001499 89D0                    	mov	eax, edx
  2531                                  	;add	ax, [previous_val_r]
  2532 0000149B 6601D8                  	add	ax, bx
  2533 0000149E 66D1D8                  	rcr	ax, 1
  2534 000014A1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2535 000014A4 66AB                    	stosw		; this is interpolated sample (R)
  2536                                  
  2537                                  	; different than 8-16-24 kHZ !
  2538                                  	; 'original-interpolated-original' trio samples 
  2539 000014A6 E30B                    	jecxz	lff32s2_3
  2540                                  
  2541 000014A8 66AD                    	lodsw
  2542 000014AA 66AB                    	stosw	; original sample (L)
  2543 000014AC 66AD                    	lodsw
  2544 000014AE 66AB                    	stosw	; original sample (R)
  2545                                  	
  2546                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2547 000014B0 49                      	dec	ecx
  2548 000014B1 75AD                    	jnz	short lff32s2_1
  2549                                  lff32s2_3:
  2550 000014B3 E91BF6FFFF              	jmp	lff32_3
  2551                                  
  2552                                  ; .....................
  2553                                  
  2554                                  load_22khz_mono_8_bit:
  2555                                  	; 16/11/2023
  2556 000014B8 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2557                                  					; last of the file?
  2558 000014BF 7402                    	jz	short lff22m_0		; no
  2559 000014C1 F9                      	stc
  2560 000014C2 C3                      	retn
  2561                                  
  2562                                  lff22m_0:
  2563 000014C3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2564                                          ;mov	edx, [loadsize]
  2565                                  
  2566                                  	; esi = buffer address
  2567                                  	;; edx = buffer size
  2568                                  
  2569                                  	; load file into memory
  2570                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000014C8 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000014CE 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000014D0 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000014D6 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000014DB CD40                <1>  int 40h
  2571 000014DD 725D                    	jc	short lff22m_7 ; error !
  2572                                  
  2573 000014DF BF[00300000]            	mov	edi, audio_buffer
  2574                                  	
  2575 000014E4 21C0                    	and	eax, eax
  2576 000014E6 7505                    	jnz	short lff22m_8
  2577 000014E8 E9F9F5FFFF              	jmp	lff22_eof
  2578                                  
  2579                                  lff22m_8:
  2580 000014ED 89C1                    	mov	ecx, eax	; byte count
  2581                                  lff22m_9:
  2582 000014EF BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2583 000014F4 C605[65200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2584                                  lff22m_1:
  2585                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2586 000014FB AC                      	lodsb
  2587 000014FC B280                    	mov	dl, 80h
  2588 000014FE 49                      	dec	ecx
  2589 000014FF 7402                    	jz	short lff22m_2_1
  2590 00001501 8A16                    	mov	dl, [esi]
  2591                                  lff22m_2_1:	
  2592                                  	; al = [previous_val]
  2593                                  	; dl = [next_val]
  2594 00001503 E80F060000              	call	interpolating_3_8bit_mono ; 1 of 17
  2595 00001508 E32D                    	jecxz	lff22m_3
  2596                                  lff22m_2_2:
  2597 0000150A AC                      	lodsb
  2598 0000150B B280                    	mov	dl, 80h
  2599 0000150D 49                      	dec	ecx
  2600 0000150E 7402                    	jz	short lff22m_2_3
  2601 00001510 8A16                    	mov	dl, [esi]
  2602                                  lff22m_2_3:
  2603 00001512 E884060000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2604 00001517 E31E                    	jecxz	lff22m_3
  2605 00001519 4D                      	dec	ebp
  2606 0000151A 75EE                    	jnz	short lff22m_2_2
  2607                                  
  2608 0000151C A0[65200000]            	mov	al, [faz]
  2609 00001521 FEC8                    	dec	al
  2610 00001523 74CA                    	jz	short lff22m_9
  2611 00001525 FE0D[65200000]          	dec	byte [faz]
  2612 0000152B BD04000000              	mov	ebp, 4
  2613 00001530 FEC8                    	dec	al
  2614 00001532 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2615 00001534 45                      	inc	ebp ; 5
  2616 00001535 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2617                                  
  2618                                  lff22m_3:
  2619                                  lff22s_3:
  2620 00001537 E997F5FFFF              	jmp	lff22_3	; padfill
  2621                                  		; (put zeros in the remain words of the buffer)
  2622                                  lff22m_7:
  2623                                  lff22s_7:
  2624 0000153C E9AEF5FFFF              	jmp	lff22_5  ; error
  2625                                  
  2626                                  load_22khz_stereo_8_bit:
  2627                                  	; 16/11/2023
  2628 00001541 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2629                                  					; last of the file?
  2630 00001548 7402                    	jz	short lff22s_0		; no
  2631 0000154A F9                      	stc
  2632 0000154B C3                      	retn
  2633                                  
  2634                                  lff22s_0:
  2635 0000154C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2636                                          ;mov	edx, [loadsize]
  2637                                  
  2638                                  	; esi = buffer address
  2639                                  	;; edx = buffer size
  2640                                  
  2641                                  	; load file into memory
  2642                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001551 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001557 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001559 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000155F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001564 CD40                <1>  int 40h
  2643 00001566 72D4                    	jc	short lff22s_7 ; error !
  2644                                  
  2645 00001568 BF[00300000]            	mov	edi, audio_buffer
  2646                                  	
  2647 0000156D D1E8                    	shr	eax, 1
  2648 0000156F 7505                    	jnz	short lff22s_8
  2649 00001571 E970F5FFFF              	jmp	lff22_eof
  2650                                  
  2651                                  lff22s_8:
  2652 00001576 89C1                    	mov	ecx, eax	; word count
  2653                                  lff22s_9:
  2654 00001578 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2655 0000157D C605[65200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2656                                  lff22s_1:
  2657                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2658 00001584 66AD                    	lodsw
  2659 00001586 66BA8080                	mov	dx, 8080h
  2660 0000158A 49                      	dec	ecx
  2661 0000158B 7403                    	jz	short lff22s_2_1 
  2662 0000158D 668B16                  	mov	dx, [esi]
  2663                                  lff22s_2_1:	
  2664                                  	; al = [previous_val_l]
  2665                                  	; ah = [previous_val_r]
  2666                                  	; dl = [next_val_l]
  2667                                  	; dh = [next_val_r]	
  2668 00001590 E8B3050000              	call	interpolating_3_8bit_stereo ; 1 of 17 
  2669 00001595 E3A0                    	jecxz	lff22s_3
  2670                                  lff22s_2_2:
  2671 00001597 66AD                    	lodsw
  2672 00001599 66BA8080                	mov	dx, 8080h
  2673 0000159D 49                      	dec	ecx
  2674 0000159E 7403                    	jz	short lff22s_2_3
  2675 000015A0 668B16                  	mov	dx, [esi]
  2676                                  lff22s_2_3:
  2677 000015A3 E810060000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2678 000015A8 E38D                    	jecxz	lff22s_3
  2679 000015AA 4D                      	dec	ebp
  2680 000015AB 75EA                    	jnz	short lff22s_2_2
  2681                                  
  2682 000015AD A0[65200000]            	mov	al, [faz]
  2683 000015B2 FEC8                    	dec	al
  2684 000015B4 74C2                    	jz	short lff22s_9
  2685 000015B6 FE0D[65200000]          	dec	byte [faz]
  2686 000015BC BD04000000              	mov	ebp, 4
  2687 000015C1 FEC8                    	dec	al
  2688 000015C3 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2689 000015C5 45                      	inc	ebp ; 5
  2690 000015C6 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2691                                  
  2692                                  load_22khz_mono_16_bit:
  2693                                  	; 16/11/2023
  2694 000015C8 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2695                                  					; last of the file?
  2696 000015CF 7402                    	jz	short lff22m2_0		; no
  2697 000015D1 F9                      	stc
  2698 000015D2 C3                      	retn
  2699                                  
  2700                                  lff22m2_0:
  2701 000015D3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2702                                          ;mov	edx, [loadsize]
  2703                                  
  2704                                  	; esi = buffer address
  2705                                  	;; edx = buffer size
  2706                                  
  2707                                  	; load file into memory
  2708                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000015D8 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000015DE 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000015E0 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000015E6 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000015EB CD40                <1>  int 40h
  2709 000015ED 7261                    	jc	short lff22m2_7 ; error !
  2710                                  
  2711 000015EF BF[00300000]            	mov	edi, audio_buffer
  2712                                  	
  2713 000015F4 D1E8                    	shr	eax, 1
  2714 000015F6 7505                    	jnz	short lff22m2_8
  2715 000015F8 E9E9F4FFFF              	jmp	lff22_eof
  2716                                  
  2717                                  lff22m2_8:
  2718 000015FD 89C1                    	mov	ecx, eax	; word count
  2719                                  lff22m2_9:
  2720 000015FF BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2721 00001604 C605[65200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2722                                  lff22m2_1:
  2723                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2724 0000160B 66AD                    	lodsw
  2725 0000160D 31D2                    	xor	edx, edx
  2726 0000160F 49                      	dec	ecx
  2727 00001610 7403                    	jz	short lff22m2_2_1
  2728 00001612 668B16                  	mov	dx, [esi]
  2729                                  lff22m2_2_1:	
  2730                                  	; ax = [previous_val]
  2731                                  	; dx = [next_val]
  2732 00001615 E8CF050000              	call	interpolating_3_16bit_mono ; 1 of 17
  2733 0000161A E32F                    	jecxz	lff22m2_3
  2734                                  lff22m2_2_2:
  2735 0000161C 66AD                    	lodsw
  2736 0000161E 31D2                    	xor	edx, edx
  2737 00001620 49                      	dec	ecx
  2738 00001621 7403                    	jz	short lff22m2_2_3
  2739 00001623 668B16                  	mov	dx, [esi]
  2740                                  lff22m2_2_3:
  2741 00001626 E851060000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2742 0000162B E31E                    	jecxz	lff22m2_3
  2743 0000162D 4D                      	dec	ebp
  2744 0000162E 75EC                    	jnz	short lff22m2_2_2
  2745                                  
  2746 00001630 A0[65200000]            	mov	al, [faz]
  2747 00001635 FEC8                    	dec	al
  2748 00001637 74C6                    	jz	short lff22m2_9
  2749 00001639 FE0D[65200000]          	dec	byte [faz]
  2750 0000163F BD04000000              	mov	ebp, 4
  2751 00001644 FEC8                    	dec	al
  2752 00001646 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2753 00001648 45                      	inc	ebp ; 5
  2754 00001649 EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2755                                  
  2756                                  lff22m2_3:
  2757                                  lff22s2_3:
  2758 0000164B E983F4FFFF              	jmp	lff22_3	; padfill
  2759                                  		; (put zeros in the remain words of the buffer)
  2760                                  lff22m2_7:
  2761                                  lff22s2_7:
  2762 00001650 E99AF4FFFF              	jmp	lff22_5  ; error
  2763                                  
  2764                                  load_22khz_stereo_16_bit:
  2765                                  	; 16/11/2023
  2766 00001655 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2767                                  					; last of the file?
  2768 0000165C 7402                    	jz	short lff22s2_0		; no
  2769 0000165E F9                      	stc
  2770 0000165F C3                      	retn
  2771                                  
  2772                                  lff22s2_0:
  2773 00001660 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2774                                          ;mov	edx, [loadsize]
  2775                                  
  2776                                  	; esi = buffer address
  2777                                  	;; edx = buffer size
  2778                                  
  2779                                  	; load file into memory
  2780                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001665 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000166B 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000166D 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001673 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001678 CD40                <1>  int 40h
  2781 0000167A 72D4                    	jc	short lff22s2_7 ; error !
  2782                                  
  2783 0000167C BF[00300000]            	mov	edi, audio_buffer
  2784                                  	
  2785 00001681 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  2786 00001684 7505                    	jnz	short lff22s2_8
  2787 00001686 E95BF4FFFF              	jmp	lff22_eof
  2788                                  
  2789                                  lff22s2_8:
  2790 0000168B 89C1                    	mov	ecx, eax	; dword count
  2791                                  lff22s2_9:
  2792 0000168D BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2793 00001692 C605[65200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2794                                  lff22s2_1:
  2795                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2796 00001699 66AD                    	lodsw
  2797 0000169B 89C3                    	mov	ebx, eax
  2798 0000169D 66AD                    	lodsw
  2799 0000169F 8B16                    	mov	edx, [esi]
  2800 000016A1 668915[61200000]        	mov	[next_val_l], dx
  2801                                  	; 26/11/2023
  2802 000016A8 C1EA10                  	shr	edx, 16
  2803 000016AB 49                      	dec	ecx
  2804 000016AC 7509                    	jnz	short lff22s2_2_1
  2805 000016AE 31D2                    	xor	edx, edx ; 0
  2806 000016B0 668915[61200000]        	mov	[next_val_l], dx
  2807                                  lff22s2_2_1:
  2808                                  	; bx = [previous_val_l]
  2809                                  	; ax = [previous_val_r]
  2810                                  	; [next_val_l]
  2811                                  	; dx = [next_val_r]
  2812 000016B7 E85D050000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  2813 000016BC E38D                    	jecxz	lff22s2_3
  2814                                  lff22s2_2_2:
  2815 000016BE 66AD                    	lodsw
  2816 000016C0 89C3                    	mov	ebx, eax
  2817 000016C2 66AD                    	lodsw
  2818 000016C4 8B16                    	mov	edx, [esi]
  2819 000016C6 668915[61200000]        	mov	[next_val_l], dx
  2820                                  	; 26/11/2023
  2821 000016CD C1EA10                  	shr	edx, 16
  2822 000016D0 49                      	dec	ecx
  2823 000016D1 7509                    	jnz	short lff22s2_2_3
  2824 000016D3 31D2                    	xor	edx, edx ; 0
  2825 000016D5 668915[61200000]        	mov	[next_val_l], dx
  2826                                  lff22s2_2_3:
  2827 000016DC E8B3050000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  2828 000016E1 E31E                    	jecxz	lff22s2_2_4
  2829                                  
  2830 000016E3 4D                      	dec	ebp
  2831 000016E4 75D8                    	jnz	short lff22s2_2_2
  2832                                  
  2833 000016E6 A0[65200000]            	mov	al, [faz]
  2834 000016EB FEC8                    	dec	al
  2835 000016ED 749E                    	jz	short lff22s2_9
  2836 000016EF FE0D[65200000]          	dec	byte [faz]
  2837 000016F5 BD04000000              	mov	ebp, 4
  2838 000016FA FEC8                    	dec	al
  2839 000016FC 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2840 000016FE 45                      	inc	ebp ; 5
  2841 000016FF EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2842                                  
  2843                                  lff22s2_2_4:
  2844                                  	; 26/11/2023
  2845 00001701 E9CDF3FFFF              	jmp	lff22_3	; padfill
  2846                                  
  2847                                  ; .....................
  2848                                  
  2849                                  load_11khz_mono_8_bit:
  2850                                  	; 18/11/2023
  2851 00001706 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2852                                  					; last of the file?
  2853 0000170D 7402                    	jz	short lff11m_0		; no
  2854 0000170F F9                      	stc
  2855 00001710 C3                      	retn
  2856                                  
  2857                                  lff11m_0:
  2858 00001711 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2859                                          ;mov	edx, [loadsize]
  2860                                  
  2861                                  	; esi = buffer address
  2862                                  	;; edx = buffer size
  2863                                  
  2864                                  	; load file into memory
  2865                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001716 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000171C 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000171E 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001724 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001729 CD40                <1>  int 40h
  2866 0000172B 7247                    	jc	short lff11m_7 ; error !
  2867                                  
  2868 0000172D BF[00300000]            	mov	edi, audio_buffer
  2869                                  	
  2870 00001732 21C0                    	and	eax, eax
  2871 00001734 7505                    	jnz	short lff11m_8
  2872 00001736 E9ABF3FFFF              	jmp	lff11_eof
  2873                                  
  2874                                  lff11m_8:
  2875 0000173B 89C1                    	mov	ecx, eax		; byte count
  2876                                  lff11m_9:
  2877 0000173D BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  2878                                  lff11m_1:
  2879                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2880 00001742 AC                      	lodsb
  2881 00001743 B280                    	mov	dl, 80h
  2882 00001745 49                      	dec	ecx
  2883 00001746 7402                    	jz	short lff11m_2_1
  2884 00001748 8A16                    	mov	dl, [esi]
  2885                                  lff11m_2_1:	
  2886                                  	; al = [previous_val]
  2887                                  	; dl = [next_val]
  2888 0000174A E876050000              	call	interpolating_5_8bit_mono
  2889 0000174F E328                    	jecxz	lff11m_3
  2890                                  lff11m_2_2:
  2891 00001751 AC                      	lodsb
  2892 00001752 B280                    	mov	dl, 80h
  2893 00001754 49                      	dec	ecx
  2894 00001755 7402                    	jz	short lff11m_2_3
  2895 00001757 8A16                    	mov	dl, [esi]
  2896                                  lff11m_2_3:
  2897 00001759 E873060000               	call	interpolating_4_8bit_mono
  2898 0000175E E319                    	jecxz	lff11m_3
  2899                                  
  2900 00001760 4D                      	dec	ebp
  2901 00001761 74DA                    	jz	short lff11m_9
  2902                                  
  2903 00001763 AC                      	lodsb
  2904 00001764 B280                    	mov	dl, 80h
  2905 00001766 49                      	dec	ecx
  2906 00001767 7402                    	jz	short lff11m_2_4
  2907 00001769 8A16                    	mov	dl, [esi]
  2908                                  lff11m_2_4:
  2909 0000176B E861060000              	call	interpolating_4_8bit_mono
  2910 00001770 E307                    	jecxz	lff11m_3
  2911 00001772 EBCE                    	jmp	short lff11m_1
  2912                                  
  2913                                  lff11m_7:
  2914                                  lff11s_7:
  2915 00001774 E976F3FFFF              	jmp	lff11_5  ; error
  2916                                  
  2917                                  lff11m_3:
  2918                                  lff11s_3:
  2919 00001779 E955F3FFFF              	jmp	lff11_3	; padfill
  2920                                  		; (put zeros in the remain words of the buffer)
  2921                                  
  2922                                  load_11khz_stereo_8_bit:
  2923                                  	; 18/11/2023
  2924 0000177E F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2925                                  					; last of the file?
  2926 00001785 7402                    	jz	short lff11s_0		; no
  2927 00001787 F9                      	stc
  2928 00001788 C3                      	retn
  2929                                  
  2930                                  lff11s_0:
  2931 00001789 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2932                                          ;mov	edx, [loadsize]
  2933                                  
  2934                                  	; esi = buffer address
  2935                                  	;; edx = buffer size
  2936                                  
  2937                                  	; load file into memory
  2938                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000178E 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001794 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001796 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000179C B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000017A1 CD40                <1>  int 40h
  2939 000017A3 72CF                    	jc	short lff11s_7 ; error !
  2940                                  
  2941 000017A5 BF[00300000]            	mov	edi, audio_buffer
  2942                                  	
  2943 000017AA D1E8                    	shr	eax, 1
  2944 000017AC 7505                    	jnz	short lff11s_8
  2945 000017AE E933F3FFFF              	jmp	lff11_eof
  2946                                  
  2947                                  lff11s_8:
  2948 000017B3 89C1                    	mov	ecx, eax	; word count
  2949                                  lff11s_9:
  2950 000017B5 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  2951                                  lff11s_1:
  2952                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2953 000017BA 66AD                    	lodsw
  2954 000017BC 66BA8080                	mov	dx, 8080h
  2955 000017C0 49                      	dec	ecx
  2956 000017C1 7403                    	jz	short lff11s_2_1 
  2957 000017C3 668B16                  	mov	dx, [esi]
  2958                                  lff11s_2_1:	
  2959                                  	; al = [previous_val_l]
  2960                                  	; ah = [previous_val_r]
  2961                                  	; dl = [next_val_l]
  2962                                  	; dh = [next_val_r]	
  2963 000017C6 E859050000              	call	interpolating_5_8bit_stereo
  2964 000017CB E3AC                    	jecxz	lff11s_3
  2965                                  lff11s_2_2:
  2966 000017CD 66AD                    	lodsw
  2967 000017CF 66BA8080                	mov	dx, 8080h
  2968 000017D3 49                      	dec	ecx
  2969 000017D4 7403                    	jz	short lff11s_2_3
  2970 000017D6 668B16                  	mov	dx, [esi]
  2971                                  lff11s_2_3:
  2972 000017D9 E832060000               	call	interpolating_4_8bit_stereo
  2973 000017DE E399                    	jecxz	lff11s_3
  2974                                  	
  2975 000017E0 4D                      	dec	ebp
  2976 000017E1 74D2                    	jz	short lff11s_9
  2977                                  
  2978 000017E3 66AD                    	lodsw
  2979 000017E5 66BA8080                	mov	dx, 8080h
  2980 000017E9 49                      	dec	ecx
  2981 000017EA 7403                    	jz	short lff11s_2_4
  2982 000017EC 668B16                  	mov	dx, [esi]
  2983                                  lff11s_2_4:
  2984 000017EF E81C060000              	call	interpolating_4_8bit_stereo
  2985 000017F4 E383                    	jecxz	lff11s_3
  2986 000017F6 EBC2                    	jmp	short lff11s_1
  2987                                  
  2988                                  load_11khz_mono_16_bit:
  2989                                  	; 18/11/2023
  2990 000017F8 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2991                                  					; last of the file?
  2992 000017FF 7402                    	jz	short lff11m2_0		; no
  2993 00001801 F9                      	stc
  2994 00001802 C3                      	retn
  2995                                  
  2996                                  lff11m2_0:
  2997 00001803 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2998                                          ;mov	edx, [loadsize]
  2999                                  
  3000                                  	; esi = buffer address
  3001                                  	;; edx = buffer size
  3002                                  
  3003                                  	; load file into memory
  3004                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001808 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000180E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001810 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001816 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000181B CD40                <1>  int 40h
  3005 0000181D 724D                    	jc	short lff11m2_7 ; error !
  3006                                  
  3007 0000181F BF[00300000]            	mov	edi, audio_buffer
  3008                                  	
  3009 00001824 D1E8                    	shr	eax, 1
  3010 00001826 7505                    	jnz	short lff11m2_8
  3011 00001828 E9B9F2FFFF              	jmp	lff11_eof
  3012                                  
  3013                                  lff11m2_8:
  3014 0000182D 89C1                    	mov	ecx, eax	; word count
  3015                                  lff11m2_9:
  3016 0000182F BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3017                                  lff11m2_1:
  3018                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3019 00001834 66AD                    	lodsw
  3020 00001836 31D2                    	xor	edx, edx
  3021 00001838 49                      	dec	ecx
  3022 00001839 7403                    	jz	short lff11m2_2_1
  3023 0000183B 668B16                  	mov	dx, [esi]
  3024                                  lff11m2_2_1:	
  3025                                  	; ax = [previous_val]
  3026                                  	; dx = [next_val]
  3027 0000183E E83A060000              	call	interpolating_5_16bit_mono
  3028 00001843 E362                    	jecxz	lff11m2_3
  3029                                  lff11m2_2_2:
  3030 00001845 66AD                    	lodsw
  3031 00001847 31D2                    	xor	edx, edx
  3032 00001849 49                      	dec	ecx
  3033 0000184A 7403                    	jz	short lff11m2_2_3
  3034 0000184C 668B16                  	mov	dx, [esi]
  3035                                  lff11m2_2_3:
  3036 0000184F E853070000               	call	interpolating_4_16bit_mono
  3037 00001854 E351                    	jecxz	lff11m2_3
  3038                                  
  3039 00001856 4D                      	dec	ebp
  3040 00001857 74D6                    	jz	short lff11m2_9
  3041                                  
  3042 00001859 66AD                    	lodsw
  3043 0000185B 31D2                    	xor	edx, edx
  3044 0000185D 49                      	dec	ecx
  3045 0000185E 7403                    	jz	short lff11m2_2_4
  3046 00001860 668B16                  	mov	dx, [esi]
  3047                                  lff11m2_2_4:
  3048 00001863 E83F070000               	call	interpolating_4_16bit_mono
  3049 00001868 E33D                    	jecxz	lff11m2_3
  3050 0000186A EBC8                    	jmp	short lff11m2_1
  3051                                  
  3052                                  lff11m2_7:
  3053                                  lff11s2_7:
  3054 0000186C E97EF2FFFF              	jmp	lff11_5  ; error
  3055                                  
  3056                                  load_11khz_stereo_16_bit:
  3057                                  	; 18/11/2023
  3058 00001871 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3059                                  					; last of the file?
  3060 00001878 7402                    	jz	short lff11s2_0		; no
  3061 0000187A F9                      	stc
  3062 0000187B C3                      	retn
  3063                                  
  3064                                  lff11s2_0:
  3065 0000187C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3066                                          ;mov	edx, [loadsize]
  3067                                  
  3068                                  	; esi = buffer address
  3069                                  	;; edx = buffer size
  3070                                  
  3071                                  	; load file into memory
  3072                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001881 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001887 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001889 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000188F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001894 CD40                <1>  int 40h
  3073 00001896 72D4                    	jc	short lff11s2_7 ; error !
  3074                                  
  3075 00001898 BF[00300000]            	mov	edi, audio_buffer
  3076                                  	
  3077 0000189D C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3078 000018A0 750A                    	jnz	short lff11s2_8
  3079 000018A2 E93FF2FFFF              	jmp	lff11_eof
  3080                                  
  3081                                  lff11m2_3:
  3082                                  lff11s2_3:
  3083 000018A7 E927F2FFFF              	jmp	lff11_3	; padfill
  3084                                  		; (put zeros in the remain words of the buffer)
  3085                                  
  3086                                  lff11s2_8:
  3087 000018AC 89C1                    	mov	ecx, eax	; dword count
  3088                                  lff11s2_9:
  3089 000018AE BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3090                                  lff11s2_1:
  3091                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3092 000018B3 66AD                    	lodsw
  3093 000018B5 89C3                    	mov	ebx, eax
  3094 000018B7 66AD                    	lodsw
  3095 000018B9 8B16                    	mov	edx, [esi]
  3096 000018BB 8915[61200000]          	mov	[next_val_l], edx
  3097                                  	; 26/11/2023
  3098 000018C1 C1EA10                  	shr	edx, 16
  3099                                  	;mov	[next_val_r], dx
  3100 000018C4 49                      	dec	ecx
  3101 000018C5 7509                    	jnz	short lff11s2_2_1
  3102 000018C7 31D2                    	xor	edx, edx ; 0
  3103 000018C9 668915[61200000]        	mov	[next_val_l], dx
  3104                                  	;mov	[next_val_r], dx
  3105                                  lff11s2_2_1:
  3106                                  	; bx = [previous_val_l]
  3107                                  	; ax = [previous_val_r]
  3108                                  	; [next_val_l]
  3109                                  	; dx = [next_val_r]
  3110 000018D0 E803060000              	call	interpolating_5_16bit_stereo
  3111 000018D5 E3D0                    	jecxz	lff11s2_3
  3112                                  lff11s2_2_2:
  3113 000018D7 66AD                    	lodsw
  3114 000018D9 89C3                    	mov	ebx, eax
  3115 000018DB 66AD                    	lodsw
  3116 000018DD 8B16                    	mov	edx, [esi]
  3117 000018DF 668915[61200000]        	mov	[next_val_l], dx
  3118                                  	; 26/11/2023
  3119 000018E6 C1EA10                  	shr	edx, 16
  3120                                  	;mov	[next_val_r], dx
  3121 000018E9 49                      	dec	ecx
  3122 000018EA 7509                    	jnz	short lff11s2_2_3
  3123 000018EC 31D2                    	xor	edx, edx ; 0
  3124 000018EE 668915[61200000]        	mov	[next_val_l], dx
  3125                                  	;mov	[next_val_r], dx
  3126                                  lff11s2_2_3:
  3127 000018F5 E8E6060000               	call	interpolating_4_16bit_stereo
  3128 000018FA E3AB                    	jecxz	lff11s2_3
  3129                                  	
  3130 000018FC 4D                      	dec	ebp
  3131 000018FD 74AF                    	jz	short lff11s2_9
  3132                                  
  3133 000018FF 66AD                    	lodsw
  3134 00001901 89C3                    	mov	ebx, eax
  3135 00001903 66AD                    	lodsw
  3136 00001905 8B16                    	mov	edx, [esi]
  3137 00001907 668915[61200000]        	mov	[next_val_l], dx
  3138                                  	; 26/11/2023
  3139 0000190E C1EA10                  	shr	edx, 16
  3140                                  	;mov	[next_val_r], dx
  3141 00001911 49                      	dec	ecx
  3142 00001912 7509                    	jnz	short lff11s2_2_4
  3143 00001914 31D2                    	xor	edx, edx ; 0
  3144 00001916 668915[61200000]        	mov	[next_val_l], dx
  3145                                  	;mov	[next_val_r], dx
  3146                                  lff11s2_2_4:
  3147 0000191D E8BE060000               	call	interpolating_4_16bit_stereo
  3148 00001922 E383                    	jecxz	lff11s2_3
  3149 00001924 EB8D                    	jmp	short lff11s2_1
  3150                                  
  3151                                  ; .....................
  3152                                  
  3153                                  load_44khz_mono_8_bit:
  3154                                  	; 18/11/2023
  3155 00001926 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3156                                  					; last of the file?
  3157 0000192D 7402                    	jz	short lff44m_0		; no
  3158 0000192F F9                      	stc
  3159 00001930 C3                      	retn
  3160                                  
  3161                                  lff44m_0:
  3162 00001931 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3163                                          ;mov	edx, [loadsize]
  3164                                  
  3165                                  	; esi = buffer address
  3166                                  	;; edx = buffer size
  3167                                  
  3168                                  	; load file into memory
  3169                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001936 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000193C 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000193E 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001944 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001949 CD40                <1>  int 40h
  3170 0000194B 7250                    	jc	short lff44m_7 ; error !
  3171                                  
  3172 0000194D BF[00300000]            	mov	edi, audio_buffer
  3173                                  	
  3174 00001952 21C0                    	and	eax, eax
  3175 00001954 7505                    	jnz	short lff44m_8
  3176 00001956 E98BF1FFFF              	jmp	lff44_eof
  3177                                  
  3178                                  lff44m_8:
  3179 0000195B 89C1                    	mov	ecx, eax	; byte count
  3180                                  lff44m_9:
  3181 0000195D BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3182 00001962 C605[65200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3183                                  lff44m_1:
  3184                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3185                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3186 00001969 AC                      	lodsb
  3187 0000196A B280                    	mov	dl, 80h
  3188 0000196C 49                      	dec	ecx
  3189 0000196D 7402                    	jz	short lff44m_2_1
  3190 0000196F 8A16                    	mov	dl, [esi]
  3191                                  lff44m_2_1:	
  3192                                  	; al = [previous_val]
  3193                                  	; dl = [next_val]
  3194 00001971 E825020000              	call	interpolating_2_8bit_mono
  3195 00001976 E320                    	jecxz	lff44m_3
  3196                                  lff44m_2_2:
  3197 00001978 AC                      	lodsb
  3198 00001979 2C80                    	sub	al, 80h
  3199 0000197B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3200 0000197F 66AB                    	stosw		; (L)
  3201 00001981 66AB                    	stosw		; (R)	
  3202                                  
  3203 00001983 49                      	dec	ecx
  3204 00001984 7412                    	jz	short lff44m_3	
  3205 00001986 4D                      	dec	ebp
  3206 00001987 75EF                    	jnz	short lff44m_2_2
  3207                                  	
  3208 00001989 FE0D[65200000]          	dec	byte [faz]
  3209 0000198F 74CC                    	jz	short lff44m_9 
  3210 00001991 BD0B000000              	mov	ebp, 11
  3211 00001996 EBD1                    	jmp	short lff44m_1
  3212                                  
  3213                                  lff44m_3:
  3214                                  lff44s_3:
  3215 00001998 E936F1FFFF              	jmp	lff44_3	; padfill
  3216                                  		; (put zeros in the remain words of the buffer)
  3217                                  lff44m_7:
  3218                                  lff44s_7:
  3219 0000199D E94DF1FFFF              	jmp	lff44_5  ; error
  3220                                  
  3221                                  load_44khz_stereo_8_bit:
  3222                                  	; 16/11/2023
  3223 000019A2 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3224                                  					; last of the file?
  3225 000019A9 7402                    	jz	short lff44s_0		; no
  3226 000019AB F9                      	stc
  3227 000019AC C3                      	retn
  3228                                  
  3229                                  lff44s_0:
  3230 000019AD BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3231                                          ;mov	edx, [loadsize]
  3232                                  
  3233                                  	; esi = buffer address
  3234                                  	;; edx = buffer size
  3235                                  
  3236                                  	; load file into memory
  3237                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000019B2 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000019B8 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000019BA 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000019C0 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000019C5 CD40                <1>  int 40h
  3238 000019C7 72D4                    	jc	short lff44s_7 ; error !
  3239                                  
  3240 000019C9 BF[00300000]            	mov	edi, audio_buffer
  3241                                  	
  3242 000019CE D1E8                    	shr	eax, 1
  3243 000019D0 7505                    	jnz	short lff44s_8
  3244 000019D2 E90FF1FFFF              	jmp	lff44_eof
  3245                                  
  3246                                  lff44s_8:
  3247 000019D7 89C1                    	mov	ecx, eax	; word count
  3248                                  lff44s_9:
  3249 000019D9 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3250 000019DE C605[65200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3251                                  lff44s_1:
  3252                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3253                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3254 000019E5 66AD                    	lodsw
  3255 000019E7 66BA8080                	mov	dx, 8080h
  3256 000019EB 49                      	dec	ecx
  3257 000019EC 7403                    	jz	short lff44s_2_1 
  3258 000019EE 668B16                  	mov	dx, [esi]
  3259                                  lff44s_2_1:	
  3260                                  	; al = [previous_val_l]
  3261                                  	; ah = [previous_val_r]
  3262                                  	; dl = [next_val_l]
  3263                                  	; dh = [next_val_r]	
  3264 000019F1 E8C2010000              	call	interpolating_2_8bit_stereo
  3265 000019F6 E3A0                    	jecxz	lff44s_3
  3266                                  lff44s_2_2:
  3267 000019F8 AC                      	lodsb
  3268 000019F9 2C80                    	sub	al, 80h
  3269 000019FB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3270 000019FF 66AB                    	stosw		; (L)
  3271 00001A01 AC                      	lodsb
  3272 00001A02 2C80                    	sub	al, 80h
  3273 00001A04 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3274 00001A08 66AB                    	stosw		; (R)
  3275                                  
  3276 00001A0A 49                      	dec	ecx
  3277 00001A0B 748B                    	jz	short lff44s_3	
  3278 00001A0D 4D                      	dec	ebp
  3279 00001A0E 75E8                    	jnz	short lff44s_2_2
  3280                                  	
  3281 00001A10 FE0D[65200000]          	dec	byte [faz]
  3282 00001A16 74C1                    	jz	short lff44s_9 
  3283 00001A18 BD0B000000              	mov	ebp, 11
  3284 00001A1D EBC6                    	jmp	short lff44s_1
  3285                                  
  3286                                  load_44khz_mono_16_bit:
  3287                                  	; 18/11/2023
  3288 00001A1F F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3289                                  					; last of the file?
  3290 00001A26 7402                    	jz	short lff44m2_0		; no
  3291 00001A28 F9                      	stc
  3292 00001A29 C3                      	retn
  3293                                  
  3294                                  lff44m2_0:
  3295 00001A2A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3296                                          ;mov	edx, [loadsize]
  3297                                  
  3298                                  	; esi = buffer address
  3299                                  	;; edx = buffer size
  3300                                  
  3301                                  	; load file into memory
  3302                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001A2F 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001A35 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001A37 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001A3D B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001A42 CD40                <1>  int 40h
  3303 00001A44 724D                    	jc	short lff44m2_7 ; error !
  3304                                  
  3305 00001A46 BF[00300000]            	mov	edi, audio_buffer
  3306                                  	
  3307 00001A4B D1E8                    	shr	eax, 1
  3308 00001A4D 7505                    	jnz	short lff44m2_8
  3309 00001A4F E992F0FFFF              	jmp	lff44_eof
  3310                                  
  3311                                  lff44m2_8:
  3312 00001A54 89C1                    	mov	ecx, eax	; word count
  3313                                  lff44m2_9:
  3314 00001A56 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3315 00001A5B C605[65200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3316                                  lff44m2_1:
  3317                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3318                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3319 00001A62 66AD                    	lodsw
  3320 00001A64 31D2                    	xor	edx, edx
  3321 00001A66 49                      	dec	ecx
  3322 00001A67 7403                    	jz	short lff44m2_2_1
  3323 00001A69 668B16                  	mov	dx, [esi]
  3324                                  lff44m2_2_1:	
  3325                                  	; ax = [previous_val]
  3326                                  	; dx = [next_val]
  3327 00001A6C E80B020000              	call	interpolating_2_16bit_mono
  3328 00001A71 E31B                    	jecxz	lff44m2_3
  3329                                  lff44m2_2_2:
  3330 00001A73 66AD                    	lodsw
  3331 00001A75 66AB                    	stosw		; (L)eft Channel
  3332 00001A77 66AB                    	stosw		; (R)ight Channel
  3333                                  
  3334 00001A79 49                      	dec	ecx
  3335 00001A7A 7412                    	jz	short lff44m2_3	
  3336 00001A7C 4D                      	dec	ebp
  3337 00001A7D 75F4                    	jnz	short lff44m2_2_2
  3338                                  	
  3339 00001A7F FE0D[65200000]          	dec	byte [faz]
  3340 00001A85 74CF                    	jz	short lff44m2_9 
  3341 00001A87 BD0B000000              	mov	ebp, 11
  3342 00001A8C EBD4                    	jmp	short lff44m2_1
  3343                                  
  3344                                  lff44m2_3:
  3345                                  lff44s2_3:
  3346 00001A8E E940F0FFFF              	jmp	lff44_3	; padfill
  3347                                  		; (put zeros in the remain words of the buffer)
  3348                                  lff44m2_7:
  3349                                  lff44s2_7:
  3350 00001A93 E957F0FFFF              	jmp	lff44_5  ; error
  3351                                  
  3352                                  load_44khz_stereo_16_bit:
  3353                                  	; 18/11/2023
  3354 00001A98 F605[34230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3355                                  					; last of the file?
  3356 00001A9F 7402                    	jz	short lff44s2_0		; no
  3357 00001AA1 F9                      	stc
  3358 00001AA2 C3                      	retn
  3359                                  
  3360                                  lff44s2_0:
  3361 00001AA3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3362                                          ;mov	edx, [loadsize]
  3363                                  
  3364                                  	; esi = buffer address
  3365                                  	;; edx = buffer size
  3366                                  
  3367                                  	; load file into memory
  3368                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001AA8 8B1D[66200000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001AAE 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001AB0 8B15[CD030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001AB6 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001ABB CD40                <1>  int 40h
  3369 00001ABD 72D4                    	jc	short lff44s2_7 ; error !
  3370                                  
  3371 00001ABF BF[00300000]            	mov	edi, audio_buffer
  3372                                  	
  3373 00001AC4 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3374 00001AC7 7505                    	jnz	short lff44s2_8
  3375 00001AC9 E918F0FFFF              	jmp	lff44_eof
  3376                                  
  3377                                  lff44s2_8:
  3378 00001ACE 89C1                    	mov	ecx, eax	; dword count
  3379                                  lff44s2_9:
  3380 00001AD0 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3381 00001AD5 C605[65200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3382                                  lff44s2_1:
  3383                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3384                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3385 00001ADC 66AD                    	lodsw
  3386 00001ADE 89C3                    	mov	ebx, eax
  3387 00001AE0 66AD                    	lodsw
  3388                                  	;mov	dx, [esi]
  3389                                  	;mov	[next_val_l], dx
  3390                                  	;mov	dx, [esi+2]
  3391                                  	; 26/11/2023
  3392 00001AE2 8B16                    	mov	edx, [esi]
  3393 00001AE4 668915[61200000]        	mov	[next_val_l], dx
  3394 00001AEB C1EA10                  	shr	edx, 16
  3395 00001AEE 49                      	dec	ecx
  3396 00001AEF 7509                    	jnz	short lff44s2_2_1
  3397 00001AF1 31D2                    	xor	edx, edx ; 0
  3398 00001AF3 668915[61200000]        	mov	[next_val_l], dx
  3399                                  lff44s2_2_1:
  3400                                  	; bx = [previous_val_l]
  3401                                  	; ax = [previous_val_r]
  3402                                  	; [next_val_l]
  3403                                  	; dx = [next_val_r]
  3404 00001AFA E895010000              	call	interpolating_2_16bit_stereo
  3405 00001AFF E38D                    	jecxz	lff44s2_3
  3406                                  lff44s2_2_2:
  3407                                  	;movsw		; (L)eft Channel
  3408                                  	;movsw		; (R)ight Channel
  3409 00001B01 A5                      	movsd
  3410                                  
  3411 00001B02 49                      	dec	ecx
  3412 00001B03 7489                    	jz	short lff44s2_3	
  3413 00001B05 4D                      	dec	ebp
  3414 00001B06 75F9                    	jnz	short lff44s2_2_2
  3415                                  	
  3416 00001B08 FE0D[65200000]          	dec	byte [faz]
  3417 00001B0E 74C0                    	jz	short lff44s2_9 
  3418 00001B10 BD0B000000              	mov	ebp, 11
  3419 00001B15 EBC5                    	jmp	short lff44s2_1
  3420                                  
  3421                                  ; .....................
  3422                                  
  3423                                  interpolating_3_8bit_mono:
  3424                                  	; 16/11/2023
  3425                                  	; al = [previous_val]
  3426                                  	; dl = [next_val]
  3427                                  	; original-interpolated-interpolated
  3428 00001B17 88C3                    	mov	bl, al
  3429 00001B19 2C80                    	sub	al, 80h
  3430 00001B1B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3431 00001B1F 66AB                    	stosw		; original sample (L)
  3432 00001B21 66AB                    	stosw		; original sample (R)
  3433 00001B23 88D8                    	mov	al, bl
  3434 00001B25 00D0                    	add	al, dl	
  3435 00001B27 D0D8                    	rcr	al, 1
  3436 00001B29 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3437 00001B2B 00D8                    	add	al, bl
  3438 00001B2D D0D8                    	rcr	al, 1
  3439 00001B2F 2C80                    	sub	al, 80h
  3440 00001B31 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3441 00001B35 66AB                    	stosw		; interpolated sample 1 (L)
  3442 00001B37 66AB                    	stosw		; interpolated sample 1 (R)
  3443 00001B39 88F8                    	mov	al, bh
  3444 00001B3B 00D0                    	add	al, dl	; [next_val]
  3445 00001B3D D0D8                    	rcr	al, 1
  3446 00001B3F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3447 00001B43 66AB                    	stosw		; interpolated sample 2 (L)
  3448 00001B45 66AB                    	stosw		; interpolated sample 2 (R)
  3449 00001B47 C3                      	retn
  3450                                  
  3451                                  interpolating_3_8bit_stereo:
  3452                                  	; 16/11/2023
  3453                                  	; al = [previous_val_l]
  3454                                  	; ah = [previous_val_r]
  3455                                  	; dl = [next_val_l]
  3456                                  	; dh = [next_val_r]	
  3457                                  	; original-interpolated-interpolated
  3458 00001B48 89C3                    	mov	ebx, eax
  3459 00001B4A 2C80                    	sub	al, 80h
  3460 00001B4C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3461 00001B50 66AB                    	stosw		; original sample (L)
  3462 00001B52 88F8                    	mov	al, bh
  3463 00001B54 2C80                    	sub	al, 80h
  3464 00001B56 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3465 00001B5A 66AB                    	stosw		; original sample (R)
  3466 00001B5C 88D8                    	mov	al, bl
  3467 00001B5E 00D0                    	add	al, dl	; [next_val_l]	
  3468 00001B60 D0D8                    	rcr	al, 1
  3469 00001B62 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3470 00001B63 00D8                    	add	al, bl	; [previous_val_l]
  3471 00001B65 D0D8                    	rcr	al, 1
  3472 00001B67 2C80                    	sub	al, 80h
  3473 00001B69 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3474 00001B6D 66AB                    	stosw		; interpolated sample 1 (L)
  3475 00001B6F 88F8                    	mov	al, bh
  3476 00001B71 00F0                    	add	al, dh	; [next_val_r]
  3477 00001B73 D0D8                    	rcr	al, 1
  3478 00001B75 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3479 00001B76 00F8                    	add	al, bh	; [previous_val_r]
  3480 00001B78 D0D8                    	rcr	al, 1
  3481 00001B7A 2C80                    	sub	al, 80h
  3482 00001B7C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3483 00001B80 66AB                    	stosw		; interpolated sample 1 (R)
  3484 00001B82 5B                      	pop	ebx ; **
  3485 00001B83 58                      	pop	eax ; *
  3486 00001B84 00D0                    	add	al, dl	; [next_val_l]
  3487 00001B86 D0D8                    	rcr	al, 1
  3488 00001B88 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3489 00001B8C 66AB                    	stosw		; interpolated sample 2 (L)
  3490 00001B8E 88D8                    	mov	al, bl
  3491 00001B90 00F0                    	add	al, dh	; [next_val_r]
  3492 00001B92 D0D8                    	rcr	al, 1
  3493 00001B94 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3494 00001B98 66AB                    	stosw		; interpolated sample 2 (R)
  3495 00001B9A C3                      	retn
  3496                                  
  3497                                  interpolating_2_8bit_mono:
  3498                                  	; 16/11/2023
  3499                                  	; al = [previous_val]
  3500                                  	; dl = [next_val]
  3501                                  	; original-interpolated
  3502 00001B9B 88C3                    	mov	bl, al
  3503 00001B9D 2C80                    	sub	al, 80h
  3504 00001B9F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3505 00001BA3 66AB                    	stosw		; original sample (L)
  3506 00001BA5 66AB                    	stosw		; original sample (R)
  3507 00001BA7 88D8                    	mov	al, bl
  3508 00001BA9 00D0                    	add	al, dl	
  3509 00001BAB D0D8                    	rcr	al, 1
  3510 00001BAD 2C80                    	sub	al, 80h
  3511 00001BAF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3512 00001BB3 66AB                    	stosw		; interpolated sample (L)
  3513 00001BB5 66AB                    	stosw		; interpolated sample (R)
  3514 00001BB7 C3                      	retn
  3515                                  
  3516                                  interpolating_2_8bit_stereo:
  3517                                  	; 16/11/2023
  3518                                  	; al = [previous_val_l]
  3519                                  	; ah = [previous_val_r]
  3520                                  	; dl = [next_val_l]
  3521                                  	; dh = [next_val_r]	
  3522                                  	; original-interpolated
  3523 00001BB8 89C3                    	mov	ebx, eax
  3524 00001BBA 2C80                    	sub	al, 80h
  3525 00001BBC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3526 00001BC0 66AB                    	stosw		; original sample (L)
  3527 00001BC2 88F8                    	mov	al, bh
  3528 00001BC4 2C80                    	sub	al, 80h
  3529 00001BC6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3530 00001BCA 66AB                    	stosw		; original sample (R)
  3531 00001BCC 88D8                    	mov	al, bl	; [previous_val_l]
  3532 00001BCE 00D0                    	add	al, dl	; [next_val_l]	
  3533 00001BD0 D0D8                    	rcr	al, 1
  3534 00001BD2 2C80                    	sub	al, 80h
  3535 00001BD4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3536 00001BD8 66AB                    	stosw		; interpolated sample (L)
  3537 00001BDA 88F8                    	mov	al, bh
  3538 00001BDC 00F0                    	add	al, dh	; [next_val_r]
  3539 00001BDE D0D8                    	rcr	al, 1
  3540 00001BE0 2C80                    	sub	al, 80h
  3541 00001BE2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3542 00001BE6 66AB                    	stosw		; interpolated sample (R)
  3543 00001BE8 C3                      	retn
  3544                                  
  3545                                  interpolating_3_16bit_mono:
  3546                                  	; 16/11/2023
  3547                                  	; ax = [previous_val]
  3548                                  	; dx = [next_val]
  3549                                  	; original-interpolated-interpolated
  3550                                  
  3551 00001BE9 66AB                    	stosw		; original sample (L)
  3552 00001BEB 66AB                    	stosw		; original sample (R)
  3553 00001BED 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3554 00001BF0 50                      	push	eax ; *	; [previous_val]
  3555 00001BF1 80C680                  	add	dh, 80h
  3556 00001BF4 6601D0                  	add	ax, dx
  3557 00001BF7 66D1D8                  	rcr	ax, 1
  3558 00001BFA 5B                      	pop	ebx ; *		
  3559 00001BFB 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3560 00001BFC 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3561 00001BFF 66D1D8                  	rcr	ax, 1
  3562 00001C02 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3563 00001C05 66AB                    	stosw 		; interpolated sample 1 (L)
  3564 00001C07 66AB                    	stosw		; interpolated sample 1 (R)
  3565 00001C09 89D8                    	mov	eax, ebx
  3566 00001C0B 6601D0                  	add	ax, dx	 ;interpolated middle + [next_val]
  3567 00001C0E 66D1D8                  	rcr	ax, 1
  3568 00001C11 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3569 00001C14 66AB                    	stosw		; interpolated sample 2 (L)
  3570 00001C16 66AB                    	stosw		; interpolated sample 2 (R)
  3571 00001C18 C3                      	retn
  3572                                  
  3573                                  interpolating_3_16bit_stereo:
  3574                                  	; 16/11/2023
  3575                                  	; bx = [previous_val_l]
  3576                                  	; ax = [previous_val_r]
  3577                                  	; [next_val_l]
  3578                                  	; dx = [next_val_r]
  3579                                  	; original-interpolated-interpolated
  3580                                  
  3581 00001C19 93                      	xchg	eax, ebx
  3582 00001C1A 66AB                    	stosw		; original sample (L)
  3583 00001C1C 93                      	xchg	eax, ebx
  3584 00001C1D 66AB                    	stosw		; original sample (R)
  3585 00001C1F 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3586 00001C22 50                      	push	eax ; *	; [previous_val_r]
  3587 00001C23 80C780                  	add	bh, 80h
  3588 00001C26 8005[62200000]80        	add	byte [next_val_l+1], 80h
  3589 00001C2D 66A1[61200000]          	mov	ax, [next_val_l]
  3590 00001C33 6601D8                  	add	ax, bx	; [previous_val_l]
  3591 00001C36 66D1D8                  	rcr	ax, 1
  3592 00001C39 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  3593 00001C3A 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3594 00001C3D 66D1D8                  	rcr	ax, 1
  3595 00001C40 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3596 00001C43 66AB                    	stosw 		; interpolated sample 1 (L)
  3597 00001C45 58                      	pop	eax  ; *
  3598 00001C46 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  3599 00001C49 52                      	push	edx  ; * ; [next_val_r]
  3600 00001C4A 92                      	xchg	eax, edx
  3601 00001C4B 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  3602 00001C4E 66D1D8                  	rcr	ax, 1	; / 2
  3603 00001C51 50                      	push	eax ; ** ; interpolated middle (R)
  3604 00001C52 6601D0                  	add	ax, dx	; + [previous_val_r]
  3605 00001C55 66D1D8                  	rcr	ax, 1
  3606 00001C58 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3607 00001C5B 66AB                    	stosw 		; interpolated sample 1 (R)
  3608 00001C5D 66A1[61200000]          	mov	ax, [next_val_l]
  3609 00001C63 6601D8                  	add	ax, bx	; + interpolated middle (L)
  3610 00001C66 66D1D8                  	rcr	ax, 1
  3611 00001C69 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3612 00001C6C 66AB                    	stosw 		; interpolated sample 2 (L)
  3613 00001C6E 58                      	pop	eax ; **
  3614 00001C6F 5A                      	pop	edx ; *	
  3615 00001C70 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  3616 00001C73 66D1D8                  	rcr	ax, 1	; / 2
  3617 00001C76 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3618 00001C79 66AB                    	stosw 		; interpolated sample 2 (L)
  3619 00001C7B C3                      	retn
  3620                                  
  3621                                  interpolating_2_16bit_mono:
  3622                                  	; 16/11/2023
  3623                                  	; ax = [previous_val]
  3624                                  	; dx = [next_val]
  3625                                  	; original-interpolated
  3626                                  
  3627 00001C7C 66AB                    	stosw		; original sample (L)
  3628 00001C7E 66AB                    	stosw		; original sample (R)
  3629 00001C80 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3630 00001C83 80C680                  	add	dh, 80h
  3631 00001C86 6601D0                  	add	ax, dx
  3632 00001C89 66D1D8                  	rcr	ax, 1
  3633 00001C8C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3634 00001C8F 66AB                    	stosw		; interpolated sample (L)
  3635 00001C91 66AB                    	stosw		; interpolated sample (R)
  3636 00001C93 C3                      	retn
  3637                                  
  3638                                  interpolating_2_16bit_stereo:
  3639                                  	; 16/11/2023
  3640                                  	; bx = [previous_val_l]
  3641                                  	; ax = [previous_val_r]
  3642                                  	; [next_val_l]
  3643                                  	; dx = [next_val_r]
  3644                                  	; original-interpolated
  3645                                  
  3646 00001C94 93                      	xchg	eax, ebx
  3647 00001C95 66AB                    	stosw		; original sample (L)
  3648 00001C97 93                      	xchg	eax, ebx
  3649 00001C98 66AB                    	stosw		; original sample (R)
  3650 00001C9A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3651 00001C9D 80C680                  	add	dh, 80h
  3652 00001CA0 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  3653 00001CA3 66D1D8                  	rcr	ax, 1	; / 2
  3654 00001CA6 50                      	push	eax ; *	; interpolated sample (R)
  3655 00001CA7 66A1[61200000]          	mov	ax, [next_val_l]
  3656 00001CAD 80C480                  	add	ah, 80h
  3657 00001CB0 80C780                  	add	bh, 80h
  3658 00001CB3 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  3659 00001CB6 66D1D8                  	rcr	ax, 1	; / 2		
  3660 00001CB9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3661 00001CBC 66AB                    	stosw 		; interpolated sample (L)
  3662 00001CBE 58                      	pop	eax ; *	
  3663 00001CBF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3664 00001CC2 66AB                    	stosw 		; interpolated sample (R)
  3665 00001CC4 C3                      	retn
  3666                                  
  3667                                  interpolating_5_8bit_mono:
  3668                                  	; 17/11/2023
  3669                                  	; al = [previous_val]
  3670                                  	; dl = [next_val]
  3671                                  	; original-interpltd-interpltd-interpltd-interpltd
  3672 00001CC5 88C3                    	mov	bl, al
  3673 00001CC7 2C80                    	sub	al, 80h
  3674 00001CC9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3675 00001CCD 66AB                    	stosw		; original sample (L)
  3676 00001CCF 66AB                    	stosw		; original sample (R)
  3677 00001CD1 88D8                    	mov	al, bl
  3678 00001CD3 00D0                    	add	al, dl	
  3679 00001CD5 D0D8                    	rcr	al, 1
  3680 00001CD7 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3681 00001CD9 00D8                    	add	al, bl  ; [previous_val]
  3682 00001CDB D0D8                    	rcr	al, 1 	
  3683 00001CDD 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  3684 00001CDF 00D8                    	add	al, bl
  3685 00001CE1 D0D8                    	rcr	al, 1
  3686 00001CE3 2C80                    	sub	al, 80h
  3687 00001CE5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3688 00001CE9 66AB                    	stosw		; interpolated sample 1 (L)
  3689 00001CEB 66AB                    	stosw		; interpolated sample 1 (R)
  3690 00001CED 88F8                    	mov	al, bh
  3691 00001CEF 00F0                    	add	al, dh
  3692 00001CF1 D0D8                    	rcr	al, 1
  3693 00001CF3 2C80                    	sub	al, 80h
  3694 00001CF5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3695 00001CF9 66AB                    	stosw		; interpolated sample 2 (L)
  3696 00001CFB 66AB                    	stosw		; interpolated sample 2 (R)
  3697 00001CFD 88F8                    	mov	al, bh
  3698 00001CFF 00D0                    	add	al, dl	; [next_val]
  3699 00001D01 D0D8                    	rcr	al, 1
  3700 00001D03 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  3701 00001D05 00F8                    	add	al, bh
  3702 00001D07 D0D8                    	rcr	al, 1
  3703 00001D09 2C80                    	sub	al, 80h
  3704 00001D0B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3705 00001D0F 66AB                    	stosw		; interpolated sample 3 (L)
  3706 00001D11 66AB                    	stosw		; interpolated sample 3 (R)
  3707 00001D13 88F0                    	mov	al, dh
  3708 00001D15 00D0                    	add	al, dl
  3709 00001D17 D0D8                    	rcr	al, 1
  3710 00001D19 2C80                    	sub	al, 80h
  3711 00001D1B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3712 00001D1F 66AB                    	stosw		; interpolated sample 4 (L)
  3713 00001D21 66AB                    	stosw		; interpolated sample 4 (R)
  3714 00001D23 C3                      	retn
  3715                                  
  3716                                  interpolating_5_8bit_stereo:
  3717                                  	; 17/11/2023
  3718                                  	; al = [previous_val_l]
  3719                                  	; ah = [previous_val_r]
  3720                                  	; dl = [next_val_l]
  3721                                  	; dh = [next_val_r]	
  3722                                  	; original-interpltd-interpltd-interpltd-interpltd
  3723 00001D24 89C3                    	mov	ebx, eax
  3724 00001D26 2C80                    	sub	al, 80h
  3725 00001D28 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3726 00001D2C 66AB                    	stosw		; original sample (L)
  3727 00001D2E 88F8                    	mov	al, bh
  3728 00001D30 2C80                    	sub	al, 80h
  3729 00001D32 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3730 00001D36 66AB                    	stosw		; original sample (R)
  3731 00001D38 52                      	push	edx ; *
  3732 00001D39 88D8                    	mov	al, bl
  3733 00001D3B 00D0                    	add	al, dl	; [next_val_l]
  3734 00001D3D D0D8                    	rcr	al, 1
  3735 00001D3F 50                      	push	eax ; **	; al = interpolated middle (L) (temporary)
  3736 00001D40 00D8                    	add	al, bl	; [previous_val_l]
  3737 00001D42 D0D8                    	rcr	al, 1
  3738 00001D44 86C3                    	xchg	al, bl	
  3739 00001D46 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  3740 00001D48 D0D8                    	rcr	al, 1
  3741 00001D4A 2C80                    	sub	al, 80h
  3742 00001D4C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3743 00001D50 66AB                    	stosw		; interpolated sample 1 (L)
  3744 00001D52 88F8                    	mov	al, bh
  3745 00001D54 00F0                    	add	al, dh	; [next_val_r]
  3746 00001D56 D0D8                    	rcr	al, 1
  3747 00001D58 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  3748 00001D59 00F8                    	add	al, bh	; [previous_val_r]
  3749 00001D5B D0D8                    	rcr	al, 1
  3750 00001D5D 86C7                    	xchg	al, bh	
  3751 00001D5F 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  3752 00001D61 D0D8                    	rcr	al, 1
  3753 00001D63 2C80                    	sub	al, 80h
  3754 00001D65 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3755 00001D69 66AB                    	stosw		; interpolated sample 1 (R)
  3756 00001D6B 5A                      	pop	edx ; ***
  3757 00001D6C 58                      	pop	eax ; **	; al = interpolated middle (L) (temporary)
  3758 00001D6D 86C3                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  3759 00001D6F 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  3760 00001D71 D0D8                    	rcr	al, 1
  3761 00001D73 2C80                    	sub	al, 80h
  3762 00001D75 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3763 00001D79 66AB                    	stosw		; interpolated sample 2 (L)	
  3764 00001D7B 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  3765 00001D7D 86C7                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  3766 00001D7F 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  3767 00001D81 D0D8                    	rcr	al, 1
  3768 00001D83 2C80                    	sub	al, 80h
  3769 00001D85 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3770 00001D89 66AB                    	stosw		; interpolated sample 2 (R)
  3771 00001D8B 5A                      	pop	edx ; *
  3772 00001D8C 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  3773 00001D8E 00D0                    	add	al, dl	; [next_val_l]
  3774 00001D90 D0D8                    	rcr	al, 1
  3775 00001D92 86C3                    	xchg	al, bl	; al = interpolated middle (R) (temporary)	
  3776 00001D94 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp) 
  3777 00001D96 D0D8                    	rcr	al, 1
  3778 00001D98 2C80                    	sub	al, 80h
  3779 00001D9A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3780 00001D9E 66AB                    	stosw		; interpolated sample 3 (L)
  3781 00001DA0 88F8                    	mov	al, bh	
  3782 00001DA2 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  3783 00001DA4 D0D8                    	rcr	al, 1
  3784 00001DA6 86C7                    	xchg	al, bh	; al = interpolated middle (R)
  3785 00001DA8 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  3786 00001DAA D0D8                    	rcr	al, 1
  3787 00001DAC 2C80                    	sub	al, 80h
  3788 00001DAE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3789 00001DB2 66AB                    	stosw		; interpolated sample 3 (R)
  3790 00001DB4 88D8                    	mov	al, bl
  3791 00001DB6 00D0                    	add	al, dl	; [next_val_l]
  3792 00001DB8 D0D8                    	rcr	al, 1
  3793 00001DBA 2C80                    	sub	al, 80h
  3794 00001DBC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3795 00001DC0 66AB                    	stosw		; interpolated sample 4 (L)
  3796 00001DC2 88F8                    	mov	al, bh
  3797 00001DC4 00F0                    	add	al, dh	; [next_val_r]
  3798 00001DC6 D0D8                    	rcr	al, 1
  3799 00001DC8 2C80                    	sub	al, 80h
  3800 00001DCA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3801 00001DCE 66AB                    	stosw		; interpolated sample 4 (R)
  3802 00001DD0 C3                      	retn
  3803                                  
  3804                                  interpolating_4_8bit_mono:
  3805                                  	; 17/11/2023
  3806                                  	; al = [previous_val]
  3807                                  	; dl = [next_val]
  3808                                  	; original-interpolated-interpolated-interpolated
  3809 00001DD1 88C3                    	mov	bl, al
  3810 00001DD3 2C80                    	sub	al, 80h
  3811 00001DD5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3812 00001DD9 66AB                    	stosw		; original sample (L)
  3813 00001DDB 66AB                    	stosw		; original sample (R)
  3814 00001DDD 88D8                    	mov	al, bl
  3815 00001DDF 00D0                    	add	al, dl	
  3816 00001DE1 D0D8                    	rcr	al, 1
  3817 00001DE3 86C3                    	xchg	al, bl  ; al = [previous_val]
  3818 00001DE5 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  3819 00001DE7 D0D8                    	rcr	al, 1 	
  3820 00001DE9 2C80                    	sub	al, 80h
  3821 00001DEB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3822 00001DEF 66AB                    	stosw		; interpolated sample 1 (L)
  3823 00001DF1 66AB                    	stosw		; interpolated sample 1 (R)
  3824 00001DF3 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  3825 00001DF5 2C80                    	sub	al, 80h
  3826 00001DF7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3827 00001DFB 66AB                    	stosw		; interpolated sample 2 (L)
  3828 00001DFD 66AB                    	stosw		; interpolated sample 2 (R)
  3829 00001DFF 88D8                    	mov	al, bl
  3830 00001E01 00D0                    	add	al, dl	; [next_val]
  3831 00001E03 D0D8                    	rcr	al, 1
  3832 00001E05 2C80                    	sub	al, 80h
  3833 00001E07 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3834 00001E0B 66AB                    	stosw		; interpolated sample 3 (L)
  3835 00001E0D 66AB                    	stosw		; interpolated sample 3 (R)
  3836 00001E0F C3                      	retn
  3837                                  
  3838                                  interpolating_4_8bit_stereo:
  3839                                  	; 17/11/2023
  3840                                  	; al = [previous_val_l]
  3841                                  	; ah = [previous_val_r]
  3842                                  	; dl = [next_val_l]
  3843                                  	; dh = [next_val_r]	
  3844                                  	; original-interpolated-interpolated-interpolated
  3845 00001E10 89C3                    	mov	ebx, eax
  3846 00001E12 2C80                    	sub	al, 80h
  3847 00001E14 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3848 00001E18 66AB                    	stosw		; original sample (L)
  3849 00001E1A 88F8                    	mov	al, bh
  3850 00001E1C 2C80                    	sub	al, 80h
  3851 00001E1E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3852 00001E22 66AB                    	stosw		; original sample (R)
  3853 00001E24 88D8                    	mov	al, bl
  3854 00001E26 00D0                    	add	al, dl	; [next_val_l]
  3855 00001E28 D0D8                    	rcr	al, 1
  3856 00001E2A 86C3                    	xchg	al, bl	; al = [previous_val_l]
  3857 00001E2C 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  3858 00001E2E D0D8                    	rcr	al, 1
  3859 00001E30 2C80                    	sub	al, 80h
  3860 00001E32 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3861 00001E36 66AB                    	stosw		; interpolated sample 1 (L)
  3862 00001E38 88F8                    	mov	al, bh
  3863 00001E3A 00F0                    	add	al, dh	; [next_val_r]
  3864 00001E3C D0D8                    	rcr	al, 1
  3865 00001E3E 86C7                    	xchg	al, bh	; al = [previous_val_h]
  3866 00001E40 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  3867 00001E42 D0D8                    	rcr	al, 1
  3868 00001E44 2C80                    	sub	al, 80h
  3869 00001E46 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3870 00001E4A 66AB                    	stosw		; interpolated sample 1 (R)
  3871 00001E4C 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  3872 00001E4E 2C80                    	sub	al, 80h
  3873 00001E50 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3874 00001E54 66AB                    	stosw		; interpolated sample 2 (L)
  3875 00001E56 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  3876 00001E58 2C80                    	sub	al, 80h
  3877 00001E5A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3878 00001E5E 66AB                    	stosw		; interpolated sample 2 (L)
  3879 00001E60 88D8                    	mov	al, bl
  3880 00001E62 00D0                    	add	al, dl	; [next_val_l]
  3881 00001E64 D0D8                    	rcr	al, 1
  3882 00001E66 2C80                    	sub	al, 80h
  3883 00001E68 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3884 00001E6C 66AB                    	stosw		; interpolated sample 3 (L)
  3885 00001E6E 88F8                    	mov	al, bh
  3886 00001E70 00F0                    	add	al, dh	; [next_val_r]
  3887 00001E72 D0D8                    	rcr	al, 1
  3888 00001E74 2C80                    	sub	al, 80h
  3889 00001E76 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3890 00001E7A 66AB                    	stosw		; interpolated sample 3 (R)
  3891 00001E7C C3                      	retn
  3892                                  
  3893                                  interpolating_5_16bit_mono:
  3894                                  	; 18/11/2023
  3895                                  	; ax = [previous_val]
  3896                                  	; dx = [next_val]
  3897                                  	; original-interpltd-interpltd-interpltd-interpltd
  3898 00001E7D 66AB                    	stosw		; original sample (L)
  3899 00001E7F 66AB                    	stosw		; original sample (R)
  3900 00001E81 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3901 00001E84 89C3                    	mov	ebx, eax ; [previous_val]
  3902 00001E86 80C680                  	add	dh, 80h
  3903 00001E89 6601D0                  	add	ax, dx
  3904 00001E8C 66D1D8                  	rcr	ax, 1
  3905 00001E8F 50                      	push	eax ; *	; interpolated middle (temporary)
  3906 00001E90 6601D8                  	add	ax, bx	; interpolated middle + [previous_val] 
  3907 00001E93 66D1D8                  	rcr	ax, 1
  3908 00001E96 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  3909 00001E97 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  3910 00001E9A 66D1D8                  	rcr	ax, 1	
  3911 00001E9D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3912 00001EA0 66AB                    	stosw 		; interpolated sample 1 (L)
  3913 00001EA2 66AB                    	stosw		; interpolated sample 1 (R)
  3914 00001EA4 58                      	pop	eax ; **	
  3915 00001EA5 5B                      	pop	ebx ; *
  3916 00001EA6 6601D8                  	add	ax, bx	; 1st quarter + middle
  3917 00001EA9 66D1D8                  	rcr	ax, 1	; / 2
  3918 00001EAC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  3919 00001EAF 66AB                    	stosw		; interpolated sample 2 (L)
  3920 00001EB1 66AB                    	stosw		; interpolated sample 2 (R)		
  3921 00001EB3 89D8                    	mov	eax, ebx
  3922 00001EB5 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  3923 00001EB8 66D1D8                  	rcr	ax, 1
  3924 00001EBB 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  3925 00001EBC 6601D8                  	add	ax, bx	; + interpolated middle
  3926 00001EBF 66D1D8                  	rcr	ax, 1
  3927 00001EC2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3928 00001EC5 66AB                    	stosw		; interpolated sample 3 (L)
  3929 00001EC7 66AB                    	stosw		; interpolated sample 3 (R)
  3930 00001EC9 58                      	pop	eax ; *	
  3931 00001ECA 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  3932 00001ECD 66D1D8                  	rcr	ax, 1	; / 2
  3933 00001ED0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3934 00001ED3 66AB                    	stosw		; interpolated sample 4 (L)
  3935 00001ED5 66AB                    	stosw		; interpolated sample 4 (R)
  3936 00001ED7 C3                      	retn
  3937                                  
  3938                                  interpolating_5_16bit_stereo:
  3939                                  	; 18/11/2023
  3940                                  	; bx = [previous_val_l]
  3941                                  	; ax = [previous_val_r]
  3942                                  	; [next_val_l]
  3943                                  	; [next_val_r]
  3944                                  	; original-interpltd-interpltd-interpltd-interpltd
  3945 00001ED8 51                      	push	ecx ; !
  3946 00001ED9 93                      	xchg	eax, ebx
  3947 00001EDA 66AB                    	stosw		; original sample (L)
  3948 00001EDC 93                      	xchg	eax, ebx
  3949 00001EDD 66AB                    	stosw		; original sample (R)
  3950 00001EDF 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3951 00001EE2 50                      	push	eax ; *	; [previous_val_r]
  3952 00001EE3 80C780                  	add	bh, 80h
  3953 00001EE6 8005[62200000]80        	add	byte [next_val_l+1], 80h
  3954 00001EED 66A1[61200000]          	mov	ax, [next_val_l]
  3955 00001EF3 6601D8                  	add	ax, bx	; [previous_val_l]
  3956 00001EF6 66D1D8                  	rcr	ax, 1
  3957 00001EF9 89C1                    	mov	ecx, eax ; interpolated middle (L)
  3958 00001EFB 6601D8                  	add	ax, bx	
  3959 00001EFE 66D1D8                  	rcr	ax, 1
  3960 00001F01 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)	
  3961 00001F03 6601D8                  	add	ax, bx	; [previous_val_l]
  3962 00001F06 66D1D8                  	rcr	ax, 1
  3963 00001F09 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3964 00001F0C 66AB                    	stosw 		; interpolated sample 1 (L)
  3965 00001F0E 89C8                    	mov	eax, ecx
  3966 00001F10 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L) 
  3967 00001F13 66D1D8                  	rcr	ax, 1	; / 2
  3968 00001F16 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  3969 00001F18 5A                      	pop	edx ; *	; [previous_val_r]
  3970 00001F19 89D0                    	mov	eax, edx
  3971 00001F1B 8005[64200000]80        	add	byte [next_val_r+1], 80h
  3972 00001F22 660305[63200000]        	add	ax, [next_val_r]
  3973 00001F29 66D1D8                  	rcr	ax, 1
  3974 00001F2C 50                      	push	eax ; *	; interpolated middle (R)
  3975 00001F2D 6601D0                  	add	ax, dx
  3976 00001F30 66D1D8                  	rcr	ax, 1
  3977 00001F33 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  3978 00001F34 6601D0                  	add	ax, dx	; [previous_val_r]
  3979 00001F37 66D1D8                  	rcr	ax, 1
  3980 00001F3A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3981 00001F3D 66AB                    	stosw 		; interpolated sample 1 (R)
  3982 00001F3F 89D8                    	mov	eax, ebx
  3983 00001F41 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3984 00001F44 66AB                    	stosw 		; interpolated sample 2 (L)
  3985 00001F46 58                      	pop	eax ; **
  3986 00001F47 5A                      	pop	edx ; *
  3987 00001F48 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  3988 00001F4B 66D1D8                  	rcr	ax, 1	; / 2
  3989 00001F4E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3990 00001F51 66AB                    	stosw 		; interpolated sample 2 (R)
  3991 00001F53 89C8                    	mov	eax, ecx
  3992 00001F55 660305[61200000]        	add	ax, [next_val_l]
  3993 00001F5C 66D1D8                  	rcr	ax, 1
  3994 00001F5F 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  3995 00001F60 6601C8                  	add	ax, cx	; interpolated middle (L)
  3996 00001F63 66D1D8                  	rcr	ax, 1
  3997 00001F66 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3998 00001F69 66AB                    	stosw 		; interpolated sample 3 (L)
  3999 00001F6B 89D0                    	mov	eax, edx
  4000 00001F6D 660305[63200000]        	add	ax, [next_val_r]
  4001 00001F74 66D1D8                  	rcr	ax, 1
  4002 00001F77 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4003 00001F78 6601D0                  	add	ax, dx	; interpolated middle (R)
  4004 00001F7B 66D1D8                  	rcr	ax, 1
  4005 00001F7E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4006 00001F81 66AB                    	stosw 		; interpolated sample 3 (R)
  4007 00001F83 5B                      	pop	ebx ; **
  4008 00001F84 58                      	pop	eax ; *
  4009 00001F85 660305[61200000]        	add	ax, [next_val_l]
  4010 00001F8C 66D1D8                  	rcr	ax, 1
  4011 00001F8F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4012 00001F92 66AB                    	stosw 		; interpolated sample 4 (L)
  4013 00001F94 89D8                    	mov	eax, ebx	
  4014 00001F96 660305[63200000]        	add	ax, [next_val_r]
  4015 00001F9D 66D1D8                  	rcr	ax, 1
  4016 00001FA0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4017 00001FA3 66AB                    	stosw 		; interpolated sample 4 (R)
  4018 00001FA5 59                      	pop	ecx ; !
  4019 00001FA6 C3                      	retn
  4020                                  
  4021                                  interpolating_4_16bit_mono:
  4022                                  	; 18/11/2023
  4023                                  	; ax = [previous_val]
  4024                                  	; dx = [next_val]
  4025                                  	; original-interpolated
  4026                                  
  4027 00001FA7 66AB                    	stosw		; original sample (L)
  4028 00001FA9 66AB                    	stosw		; original sample (R)
  4029 00001FAB 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4030 00001FAE 89C3                    	mov	ebx, eax ; [previous_val]
  4031 00001FB0 80C680                  	add	dh, 80h
  4032 00001FB3 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4033 00001FB6 66D1D8                  	rcr	ax, 1
  4034 00001FB9 93                      	xchg	eax, ebx	
  4035 00001FBA 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4036 00001FBD 66D1D8                  	rcr	ax, 1
  4037 00001FC0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4038 00001FC3 66AB                    	stosw 		; interpolated sample 1 (L)
  4039 00001FC5 66AB                    	stosw		; interpolated sample 1 (R)
  4040 00001FC7 89D8                    	mov	eax, ebx ; interpolated middle
  4041 00001FC9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4042 00001FCC 66AB                    	stosw 		; interpolated sample 2 (L)
  4043 00001FCE 66AB                    	stosw		; interpolated sample 2 (R)
  4044 00001FD0 89D8                    	mov	eax, ebx
  4045 00001FD2 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4046 00001FD5 66D1D8                  	rcr	ax, 1
  4047 00001FD8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4048 00001FDB 66AB                    	stosw		; interpolated sample 3 (L)
  4049 00001FDD 66AB                    	stosw		; interpolated sample 3 (R)
  4050 00001FDF C3                      	retn
  4051                                  
  4052                                  interpolating_4_16bit_stereo:
  4053                                  	; 18/11/2023
  4054                                  	; bx = [previous_val_l]
  4055                                  	; ax = [previous_val_r]
  4056                                  	; [next_val_l]
  4057                                  	; [next_val_r]
  4058                                  	; original-interpolated-interpolated-interpolated
  4059 00001FE0 93                      	xchg	eax, ebx
  4060 00001FE1 66AB                    	stosw		; original sample (L)
  4061 00001FE3 93                      	xchg	eax, ebx
  4062 00001FE4 66AB                    	stosw		; original sample (R)
  4063 00001FE6 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4064 00001FE9 89C2                    	mov	edx, eax ; [previous_val_r]
  4065 00001FEB 80C780                  	add	bh, 80h
  4066 00001FEE 8005[62200000]80        	add	byte [next_val_l+1], 80h
  4067 00001FF5 66A1[61200000]          	mov	ax, [next_val_l]
  4068 00001FFB 6601D8                  	add	ax, bx	; [previous_val_l]
  4069 00001FFE 66D1D8                  	rcr	ax, 1
  4070 00002001 93                      	xchg	eax, ebx	
  4071 00002002 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4072 00002005 66D1D8                  	rcr	ax, 1
  4073 00002008 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4074 0000200B 66AB                    	stosw 		; interpolated sample 1 (L)
  4075 0000200D 8005[64200000]80        	add	byte [next_val_r+1], 80h
  4076 00002014 89D0                    	mov	eax, edx ; [previous_val_r]
  4077 00002016 660305[63200000]        	add	ax, [next_val_r]
  4078 0000201D 66D1D8                  	rcr	ax, 1
  4079 00002020 92                      	xchg	eax, edx	
  4080 00002021 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4081 00002024 66D1D8                  	rcr	ax, 1
  4082 00002027 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4083 0000202A 66AB                    	stosw 		; interpolated sample 1 (R)
  4084 0000202C 89D8                    	mov	eax, ebx
  4085 0000202E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4086 00002031 66AB                    	stosw 		; interpolated sample 2 (L)
  4087 00002033 89D0                    	mov	eax, edx
  4088 00002035 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4089 00002038 66AB                    	stosw 		; interpolated sample 2 (R)
  4090 0000203A 89D8                    	mov	eax, ebx
  4091 0000203C 660305[61200000]        	add	ax, [next_val_l]
  4092 00002043 66D1D8                  	rcr	ax, 1
  4093 00002046 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4094 00002049 66AB                    	stosw 		; interpolated sample 3 (L)
  4095 0000204B 89D0                    	mov	eax, edx
  4096 0000204D 660305[63200000]        	add	ax, [next_val_r]
  4097 00002054 66D1D8                  	rcr	ax, 1
  4098 00002057 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4099 0000205A 66AB                    	stosw 		; interpolated sample 3 (R)
  4100 0000205C C3                      	retn
  4101                                  
  4102                                  ; 13/11/2023
  4103                                  previous_val:
  4104 0000205D 0000                    previous_val_l: dw 0
  4105 0000205F 0000                    previous_val_r: dw 0
  4106                                  next_val:
  4107 00002061 0000                    next_val_l: dw 0
  4108 00002063 0000                    next_val_r: dw 0
  4109                                  
  4110                                  ; 16/11/2023
  4111 00002065 00                      faz:	db 0	
  4112                                  	
  4113                                  ; --------------------------------------------------------
  4114                                  
  4115                                  ; DATA
  4116                                  
  4117                                  FileHandle:	
  4118 00002066 FFFFFFFF                	dd	-1
  4119                                  
  4120                                  Credits:
  4121 0000206A 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  4121 00002073 506C6179657220666F-
  4121 0000207C 72205452444F532033-
  4121 00002085 383620627920457264-
  4121 0000208E 6F67616E2054616E2E-
  4121 00002097 20                 
  4122                                  	;;db	'August 2020.',10,13,0
  4123                                  	;db	'November 2023.',10,13,0
  4124 00002098 4A756E652032303234-     	db	'June 2024.', 10,13,0
  4124 000020A1 2E0A0D00           
  4125 000020A5 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  4125 000020AE 370A0D00           
  4126 000020B2 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  4126 000020BB 300A0D00           
  4127 000020BF 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  4127 000020C8 330A0D00           
  4128 000020CC 30312F30362F323032-     	db	'01/06/2024', 10,13,0
  4128 000020D5 340A0D00           
  4129                                  
  4130                                  msgAudioCardInfo:
  4131 000020D9 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  4131 000020E2 204143393720284943-
  4131 000020EB 482920417564696F20-
  4131 000020F4 436F6E74726F6C6C65-
  4131 000020FD 722E0A0D00         
  4132                                  
  4133                                  msg_usage:
  4134 00002102 75736167653A20706C-     	db	'usage: playwav6 filename.wav',10,13,0
  4134 0000210B 617977617636206669-
  4134 00002114 6C656E616D652E7761-
  4134 0000211D 760A0D00           
  4135                                  
  4136                                  noDevMsg:
  4137 00002121 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  4137 0000212A 61626C6520746F2066-
  4137 00002133 696E64204143393720-
  4137 0000213C 617564696F20646576-
  4137 00002145 69636521           
  4138 00002149 0A0D00                  	db	10,13,0
  4139                                  
  4140                                  noFileErrMsg:
  4141 0000214C 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  4141 00002155 6C65206E6F7420666F-
  4141 0000215E 756E642E0A0D00     
  4142                                  
  4143                                  trdos386_err_msg:
  4144 00002165 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  4144 0000216E 2053797374656D2063-
  4144 00002177 616C6C206572726F72-
  4144 00002180 20210A0D00         
  4145                                  
  4146                                  ; 01/06/2024
  4147                                  msg_init_err:
  4148 00002185 0A0D                    	db	10,13
  4149 00002187 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  4149 00002190 726F6C6C65722F436F-
  4149 00002199 64656320696E697469-
  4149 000021A2 616C697A6174696F6E-
  4149 000021AB 206572726F722021   
  4150 000021B3 0A0D00                  	db	10,13,0
  4151                                  
  4152                                  ; 25/11/2023
  4153                                  msg_no_vra:
  4154 000021B6 0A0D                    	db	10,13
  4155 000021B8 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  4155 000021C1 70706F72742021204F-
  4155 000021CA 6E6C79203438206B48-
  4155 000021D3 5A2073616D706C6520-
  4155 000021DC 726174652073757070-
  4155 000021E5 6F727465642021     
  4156 000021EC 0A0D00                  	db	10,13,0
  4157                                  
  4158 000021EF 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  4158 000021F8 65204E616D653A2000 
  4159 00002201 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  4159 0000220A 526174653A20       
  4160 00002210 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  4160 00002219 2000               
  4161 0000221B 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  4162 00002224 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  4163 0000222B 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  4163 00002234 00                 
  4164 00002235 53746572656F            msgStereo:	db "Stereo"
  4165 0000223B 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  4166                                  
  4167                                  ; 03/06/2017
  4168 0000223E 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  4168 00002247 3941424344454600   
  4169 0000224F 0D0A                    msgAC97Info	db 0Dh, 0Ah
  4170 00002251 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  4170 0000225A 6F20436F6E74726F6C-
  4170 00002263 6C6572202620436F64-
  4170 0000226C 656320496E666F0D0A 
  4171 00002275 56656E646F72204944-     		db "Vendor ID: "
  4171 0000227E 3A20               
  4172 00002280 303030306820446576-     msgVendorId	db "0000h Device ID: "
  4172 00002289 6963652049443A20   
  4173 00002291 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  4174 00002298 4275733A20              		db "Bus: "
  4175 0000229D 303068204465766963-     msgBusNo	db "00h Device: "
  4175 000022A6 653A20             
  4176 000022A9 3030682046756E6374-     msgDevNo	db "00h Function: "
  4176 000022B2 696F6E3A20         
  4177 000022B7 303068                  msgFncNo	db "00h"
  4178 000022BA 0D0A                    		db 0Dh, 0Ah
  4179 000022BC 4E414D4241523A20        		db "NAMBAR: "
  4180 000022C4 30303030682020          msgNamBar	db "0000h  "
  4181 000022CB 4E41424D4241523A20      		db "NABMBAR: "
  4182 000022D4 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  4182 000022DD 513A20             
  4183 000022E0 3030                    msgIRQ		dw 3030h
  4184 000022E2 0D0A00                  		db 0Dh, 0Ah, 0
  4185                                  ; 25/11/2023
  4186 000022E5 56524120737570706F-     msgVRAheader:	db "VRA support: "
  4186 000022EE 72743A20           
  4187 000022F2 00                      		db 0	
  4188 000022F3 5945530D0A00            msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  4189 000022F9 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  4190 000022FE 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  4190 00002307 617465642073616D70-
  4190 00002310 6C6520726174652070-
  4190 00002319 6C6179696E67206D65-
  4190 00002322 74686F6429         
  4191 00002327 0D0A00                  		db 0Dh, 0Ah, 0	
  4192                                  EOF: 
  4193                                  
  4194                                  ; BSS
  4195                                  
  4196                                  bss_start:
  4197                                  
  4198                                  ABSOLUTE bss_start
  4199                                  
  4200 0000232A ????                    alignb 4
  4201                                  
  4202 0000232C ??                      stmo:		resb 1 ; stereo or mono (1=stereo) 
  4203 0000232D ??                      bps:		resb 1 ; bits per sample (8,16)
  4204 0000232E ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  4205                                  
  4206                                  ; 25/11/2023
  4207 00002330 ????????                bufferSize:	resd 1
  4208                                  
  4209 00002334 ??                      flags:		resb 1
  4210                                  ;cbs_busy:	resb 1 
  4211 00002335 ??                      half_buff:	resb 1
  4212 00002336 ??                      srb:		resb 1
  4213                                  ; 18/08/2020
  4214 00002337 ??                      volume_level:	resb 1
  4215                                  ; 25/11/2023
  4216 00002338 ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  4217                                  
  4218 00002339 <res 1Ch>               smpRBuff:	resw 14 
  4219                                  
  4220                                  wav_file_name:
  4221 00002355 <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  4222                                  
  4223 000023A5 ????                    		resw 1
  4224 000023A7 ??                      ac97_int_ln_reg: resb 1
  4225 000023A8 ??                      fbs_shift:	resb 1 ; 26/11/2023
  4226 000023A9 ????????                dev_vendor:	resd 1
  4227 000023AD ????????                bus_dev_fn:	resd 1
  4228 000023B1 ????                    ac97_NamBar:	resw 1
  4229 000023B3 ????                    ac97_NabmBar:	resw 1
  4230                                  
  4231                                  bss_end:
  4232 000023B5 <res C4Bh>              alignb 4096
  4233                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  4234                                  ; 26/11/2023
  4235 00003000 <res 10000h>            audio_buffer:	resb 65536
  4236                                  ; 13/06/2017
  4237                                  ;temp_buffer:	resb BUFFERSIZE
  4238                                  ; 26/11/2023
  4239 00013000 <res 10000h>            temp_buffer:	resb 65536
