     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: 04/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                                  ; 04/06/2024 (non-VRA simuation)
    20                                  ; Interpolated sampling rate version (48 kHz - VRA disabled) - playwav8.s-
    21                                  
    22                                  ; CODE
    23                                  
    24                                  ; 14/07/2020
    25                                  ; 31/12/2017
    26                                  ; TRDOS 386 (v2.0) system calls
    27                                  _ver 	equ 0
    28                                  _exit 	equ 1
    29                                  _fork 	equ 2
    30                                  _read 	equ 3
    31                                  _write	equ 4
    32                                  _open	equ 5
    33                                  _close 	equ 6
    34                                  _wait 	equ 7
    35                                  _create	equ 8
    36                                  _rename	equ 9
    37                                  _delete	equ 10
    38                                  _exec	equ 11
    39                                  _chdir	equ 12
    40                                  _time 	equ 13
    41                                  _mkdir 	equ 14
    42                                  _chmod	equ 15
    43                                  _rmdir	equ 16
    44                                  _break	equ 17
    45                                  _drive	equ 18
    46                                  _seek	equ 19
    47                                  _tell 	equ 20
    48                                  _memory	equ 21
    49                                  _prompt	equ 22
    50                                  _path	equ 23
    51                                  _env	equ 24
    52                                  _stime	equ 25
    53                                  _quit	equ 26
    54                                  _intr	equ 27
    55                                  _dir	equ 28
    56                                  _emt 	equ 29
    57                                  _ldrvt 	equ 30
    58                                  _video 	equ 31
    59                                  _audio	equ 32
    60                                  _timer	equ 33
    61                                  _sleep	equ 34
    62                                  _msg    equ 35
    63                                  _geterr	equ 36
    64                                  _fpstat	equ 37
    65                                  _pri	equ 38
    66                                  _rele	equ 39
    67                                  _fff	equ 40
    68                                  _fnf	equ 41
    69                                  _alloc	equ 42
    70                                  _dalloc equ 43
    71                                  _calbac equ 44
    72                                  _dma	equ 45
    73                                  
    74                                  %macro sys 1-4
    75                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    76                                      ; 03/09/2015	
    77                                      ; 13/04/2015
    78                                      ; Retro UNIX 386 v1 system call.	
    79                                      %if %0 >= 2   
    80                                          mov ebx, %2
    81                                          %if %0 >= 3    
    82                                              mov ecx, %3
    83                                              %if %0 = 4
    84                                                 mov edx, %4   
    85                                              %endif
    86                                          %endif
    87                                      %endif
    88                                      mov eax, %1
    89                                      ;int 30h
    90                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
    91                                  %endmacro
    92                                  
    93                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    94                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    95                                  
    96                                  BUFFERSIZE	equ	32768	; audio buffer size 
    97                                  ENDOFFILE       equ     1	; flag for knowing end of file
    98                                  
    99                                  [BITS 32]
   100                                  
   101                                  [ORG 0] 
   102                                  
   103                                  _STARTUP:
   104                                  	; Prints the Credits Text.
   105                                  	sys	_msg, Credits, 255, 0Bh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000000 BB[40200000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000005 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000000A BA0B000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000000F B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000014 CD40                <1>  int 40h
   106                                  
   107                                  	; clear bss
   108 00000016 B9[99230000]            	mov	ecx, bss_end
   109 0000001B BF[0D230000]            	mov	edi, bss_start
   110 00000020 29F9                    	sub	ecx, edi
   111 00000022 D1E9                    	shr	ecx, 1
   112 00000024 31C0                    	xor	eax, eax
   113 00000026 F366AB                  	rep	stosw
   114                                  
   115                                  	; Detect (& Enable) AC'97 Audio Device
   116 00000029 E87D040000              	call	DetectAC97
   117 0000002E 731B                    	jnc     short GetFileName
   118                                  
   119                                  _dev_not_ready:
   120                                  ; couldn't find the audio device!
   121                                  	sys	_msg, noDevMsg, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000030 BB[04210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000035 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000003A BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000003F B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000044 CD40                <1>  int 40h
   122 00000046 E93A040000                      jmp     Exit
   123                                  
   124                                  GetFileName:  
   125 0000004B 89E6                    	mov	esi, esp
   126 0000004D AD                      	lodsd
   127 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   128                                  	       ; (program file name & mod file name)
   129 00000051 0F823C040000            	jb	pmsg_usage ; nothing to do
   130                                  
   131 00000057 AD                      	lodsd ; program file name address 
   132 00000058 AD                      	lodsd ; mod file name address (file to be read)
   133 00000059 89C6                    	mov	esi, eax
   134 0000005B BF[39230000]            	mov	edi, wav_file_name
   135                                  ScanName:       
   136 00000060 AC                      	lodsb
   137 00000061 84C0                    	test	al, al
   138 00000063 0F842A040000            	je	pmsg_usage
   139 00000069 3C20                    	cmp	al, 20h
   140 0000006B 74F3                    	je	short ScanName	; scan start of name.
   141 0000006D AA                      	stosb
   142 0000006E B4FF                    	mov	ah, 0FFh
   143                                  a_0:	
   144 00000070 FEC4                    	inc	ah
   145                                  a_1:
   146 00000072 AC                      	lodsb
   147 00000073 AA                      	stosb
   148 00000074 3C2E                    	cmp	al, '.'
   149 00000076 74F8                    	je	short a_0	
   150 00000078 20C0                    	and	al, al
   151 0000007A 75F6                    	jnz	short a_1
   152                                  
   153 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   154 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   155                                  SetExt:
   156 00000080 4F                      	dec	edi
   157 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   158 00000087 C6470400                	mov	byte [edi+4], 0
   159                                  
   160                                  _1:
   161                                  
   162                                  ; 26/11/2023
   163                                  %if 0
   164                                  	; Allocate Audio Buffer (for user)
   165                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   166                                  	; 26/11/2023
   167                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   168                                  	jnc	short _2
   169                                  error_exit:
   170                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   171                                  	jmp	Exit
   172                                  _2:
   173                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   174                                  	; bl = 0, bh = 4
   175                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   176                                  
   177                                  	sys	_video, 0400h
   178                                  	cmp	eax, 0B8000h
   179                                  	jne	short error_exit
   180                                  
   181                                  	; Initialize Audio Device (bh = 3)
   182                                  	sys	_audio, 0301h, 0, audio_int_handler 
   183                                  ;	jc	short error_exit
   184                                  _3:
   185                                  
   186                                  %endif
   187 0000008B E869060000              	call	write_audio_dev_info 
   188                                  
   189                                  ; open the file
   190                                          ; open existing file
   191 00000090 E823040000                      call    openFile ; no error? ok.
   192 00000095 731B                            jnc     short _gsr
   193                                  
   194                                  ; file not found!
   195                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000097 BB[2F210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000009C B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000000A1 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000000A6 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000000AB CD40                <1>  int 40h
   196                                  _exit_:
   197 000000AD E9D3030000                      jmp     Exit
   198                                  
   199                                  _gsr:  
   200 000000B2 E83B040000                     	call    getSampleRate		; read the sample rate
   201                                                                          ; pass it onto codec.
   202                                  	;jc	Exit
   203                                  	; 25/11/2023
   204 000000B7 72F4                    	jc	short _exit_
   205                                  
   206 000000B9 66A3[12230000]          	mov	[sample_rate], ax
   207 000000BF 880D[10230000]          	mov	[stmo], cl
   208 000000C5 8815[11230000]          	mov	[bps], dl
   209                                  
   210                                  	; 26/11/2023
   211 000000CB C605[8C230000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   212 000000D2 FEC9                    	dec	cl
   213 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   214 000000D6 FE05[8C230000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   215                                  _gsr_1:	
   216 000000DC 80FA08                  	cmp	dl, 8 
   217 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   218 000000E1 FE05[8C230000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   219                                  _gsr_2:	
   220                                  	; 06/06/2017
   221                                  	sys	_audio, 0E00h ; get audio controller info
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000000E7 BB000E0000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000000EC B820000000          <1>  mov eax, %1
    89                              <1> 
    90 000000F1 CD40                <1>  int 40h
   222 000000F3 0F82E0020000            	jc	error_exit ; 25/11/2023
   223                                  
   224                                  	;cmp	ah, 2 ; ICH ? (Intel AC'97 Audio Controller)
   225                                  	;jne	_dev_not_ready	
   226                                  
   227                                  	; EAX = IRQ Number in AL
   228                                  	;	Audio Device Number in AH 
   229                                  	; EBX = DEV/VENDOR ID
   230                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   231                                  	; ECX = BUS/DEV/FN 
   232                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   233                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   234                                  	;      (Low word, DX = NAMBAR address)
   235                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   236                                  
   237 000000F9 A2[8B230000]            	mov	[ac97_int_ln_reg], al
   238 000000FE 891D[8D230000]          	mov	[dev_vendor], ebx
   239 00000104 890D[91230000]          	mov	[bus_dev_fn], ecx
   240                                  	;mov	[ac97_NamBar], dx
   241                                  	;shr	dx, 16
   242                                  	;mov	[ac97_NabmBar], dx
   243 0000010A 8915[95230000]          	mov	[ac97_NamBar], edx	
   244                                    
   245                                  	; 01/06/2024
   246                                  	; Reset Audio Device (bh = 8)
   247                                  	sys	_audio, 0800h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000110 BB00080000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000115 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 0000011A CD40                <1>  int 40h
   248                                  	;jc	error_exit	
   249 0000011C 7216                    	jc	short init_err
   250                                  
   251 0000011E E8B8060000              	call	write_ac97_pci_dev_info
   252                                  
   253                                  ; 04/06/2024
   254                                  %if 0
   255                                  	; 01/06/2024
   256                                  	; 25/11/2023
   257                                  	; Get AC'97 Codec info
   258                                  	; (Function 14, sub function 1)
   259                                  	sys	_audio, 0E01h
   260                                  	; Save Variable Rate Audio support bit
   261                                  	and	al, 1
   262                                  	mov	[VRA], al
   263                                  %endif
   264                                  
   265                                  	; 25/11/2023
   266 00000123 E87A080000              	call	write_VRA_info
   267                                  
   268                                  	; 01/05/2017
   269 00000128 E8E3050000              	call	write_wav_file_info
   270                                  
   271                                  	; 25/11/2023
   272                                  	; ------------------------------------------
   273                                  
   274                                  ; 04/06/2024
   275                                  %if 0
   276                                  	cmp	byte [VRA], 1
   277                                  	jb	short chk_sample_rate
   278                                  %else
   279                                  	; 04/06/2024
   280                                  	; (non-VRA simulation)
   281 0000012D EB20                    	jmp	short chk_sample_rate
   282                                  %endif
   283                                  
   284                                  playwav_48_khz:	
   285                                  	;mov	dword [loadfromwavfile], loadFromFile
   286                                  	;mov	dword [buffersize], 65536
   287 0000012F E98C020000              	jmp	PlayNow
   288                                  
   289                                  	; 01/06/2024
   290                                  init_err:
   291                                  	sys	_msg, msg_init_err, 255, 0Eh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000134 BB[68210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000139 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000013E BA0E000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000143 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000148 CD40                <1>  int 40h
   292 0000014A E936030000              	jmp	Exit
   293                                  
   294                                  chk_sample_rate:
   295                                  	; set conversion parameters
   296                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   297 0000014F 66A1[12230000]          	mov	ax, [sample_rate]
   298 00000155 663D80BB                	cmp	ax, 48000
   299 00000159 74D4                    	je	short playwav_48_khz
   300                                  chk_22khz:
   301 0000015B 663D2256                	cmp	ax, 22050
   302 0000015F 7545                    	jne	short chk_11khz
   303 00000161 803D[11230000]08        	cmp	byte [bps], 8
   304 00000168 7615                    	jna	short chk_22khz_1
   305 0000016A BB[2B160000]            	mov	ebx, load_22khz_stereo_16_bit
   306 0000016F 803D[10230000]01        	cmp	byte [stmo], 1 
   307 00000176 751A                    	jne	short chk_22khz_2
   308 00000178 BB[9E150000]            	mov	ebx, load_22khz_mono_16_bit
   309 0000017D EB13                    	jmp	short chk_22khz_2
   310                                  chk_22khz_1:
   311 0000017F BB[17150000]            	mov	ebx, load_22khz_stereo_8_bit
   312 00000184 803D[10230000]01        	cmp	byte [stmo], 1 
   313 0000018B 7505                    	jne	short chk_22khz_2
   314 0000018D BB[8E140000]            	mov	ebx, load_22khz_mono_8_bit
   315                                  chk_22khz_2:
   316 00000192 B85A1D0000              	mov	eax, 7514  ; (442*17)
   317 00000197 BA25000000              	mov	edx, 37
   318 0000019C B911000000              	mov	ecx, 17 
   319 000001A1 E9BA010000              	jmp	set_sizes	
   320                                  chk_11khz:
   321 000001A6 663D112B                	cmp	ax, 11025
   322 000001AA 7545                    	jne	short chk_44khz
   323 000001AC 803D[11230000]08        	cmp	byte [bps], 8
   324 000001B3 7615                    	jna	short chk_11khz_1
   325 000001B5 BB[47180000]            	mov	ebx, load_11khz_stereo_16_bit
   326 000001BA 803D[10230000]01        	cmp	byte [stmo], 1 
   327 000001C1 751A                    	jne	short chk_11khz_2
   328 000001C3 BB[CE170000]            	mov	ebx, load_11khz_mono_16_bit
   329 000001C8 EB13                    	jmp	short chk_11khz_2
   330                                  chk_11khz_1:
   331 000001CA BB[54170000]            	mov	ebx, load_11khz_stereo_8_bit
   332 000001CF 803D[10230000]01        	cmp	byte [stmo], 1 
   333 000001D6 7505                    	jne	short chk_11khz_2
   334 000001D8 BB[DC160000]            	mov	ebx, load_11khz_mono_8_bit
   335                                  chk_11khz_2:
   336 000001DD B8AD0E0000              	mov	eax, 3757  ; (221*17)
   337 000001E2 BA4A000000              	mov	edx, 74
   338 000001E7 B911000000              	mov	ecx, 17
   339 000001EC E96F010000              	jmp	set_sizes 
   340                                  chk_44khz:
   341 000001F1 663D44AC                	cmp	ax, 44100
   342 000001F5 7545                    	jne	short chk_16khz
   343 000001F7 803D[11230000]08        	cmp	byte [bps], 8
   344 000001FE 7615                    	jna	short chk_44khz_1
   345 00000200 BB[6E1A0000]            	mov	ebx, load_44khz_stereo_16_bit
   346 00000205 803D[10230000]01        	cmp	byte [stmo], 1 
   347 0000020C 751A                    	jne	short chk_44khz_2
   348 0000020E BB[F5190000]            	mov	ebx, load_44khz_mono_16_bit
   349 00000213 EB13                    	jmp	short chk_44khz_2
   350                                  chk_44khz_1:
   351 00000215 BB[78190000]            	mov	ebx, load_44khz_stereo_8_bit
   352 0000021A 803D[10230000]01        	cmp	byte [stmo], 1 
   353 00000221 7505                    	jne	short chk_44khz_2
   354 00000223 BB[FC180000]            	mov	ebx, load_44khz_mono_8_bit
   355                                  chk_44khz_2:
   356 00000228 B8D93A0000              	mov	eax, 15065 ; (655*23)
   357 0000022D BA19000000              	mov	edx, 25
   358 00000232 B917000000              	mov	ecx, 23
   359 00000237 E924010000              	jmp	set_sizes 
   360                                  chk_16khz:
   361 0000023C 663D803E                	cmp	ax, 16000
   362 00000240 7545                    	jne	short chk_8khz
   363 00000242 803D[11230000]08        	cmp	byte [bps], 8
   364 00000249 7615                    	jna	short chk_16khz_1
   365 0000024B BB[D30F0000]            	mov	ebx, load_16khz_stereo_16_bit
   366 00000250 803D[10230000]01        	cmp	byte [stmo], 1 
   367 00000257 751A                    	jne	short chk_16khz_2
   368 00000259 BB[520F0000]            	mov	ebx, load_16khz_mono_16_bit
   369 0000025E EB13                    	jmp	short chk_16khz_2
   370                                  chk_16khz_1:
   371 00000260 BB[980E0000]            	mov	ebx, load_16khz_stereo_8_bit
   372 00000265 803D[10230000]01        	cmp	byte [stmo], 1 
   373 0000026C 7505                    	jne	short chk_16khz_2
   374 0000026E BB[190E0000]            	mov	ebx, load_16khz_mono_8_bit
   375                                  chk_16khz_2:
   376 00000273 B855150000              	mov	eax, 5461
   377 00000278 BA03000000              	mov	edx, 3
   378 0000027D B901000000              	mov	ecx, 1
   379 00000282 E9D9000000              	jmp	set_sizes 
   380                                  chk_8khz:
   381 00000287 663D401F                	cmp	ax, 8000
   382 0000028B 7545                    	jne	short chk_24khz
   383 0000028D 803D[11230000]08        	cmp	byte [bps], 8
   384 00000294 7615                    	jna	short chk_8khz_1
   385 00000296 BB[CE0C0000]            	mov	ebx, load_8khz_stereo_16_bit
   386 0000029B 803D[10230000]01        	cmp	byte [stmo], 1 
   387 000002A2 751A                    	jne	short chk_8khz_2
   388 000002A4 BB[FE0B0000]            	mov	ebx, load_8khz_mono_16_bit
   389 000002A9 EB13                    	jmp	short chk_8khz_2
   390                                  chk_8khz_1:
   391 000002AB BB[CE0A0000]            	mov	ebx, load_8khz_stereo_8_bit
   392 000002B0 803D[10230000]01        	cmp	byte [stmo], 1 
   393 000002B7 7505                    	jne	short chk_8khz_2
   394 000002B9 BB[EF090000]            	mov	ebx, load_8khz_mono_8_bit
   395                                  chk_8khz_2:
   396 000002BE B8AA0A0000              	mov	eax, 2730
   397 000002C3 BA06000000              	mov	edx, 6
   398 000002C8 B901000000              	mov	ecx, 1
   399 000002CD E98E000000              	jmp	set_sizes 
   400                                  chk_24khz:
   401 000002D2 663DC05D                	cmp	ax, 24000
   402 000002D6 7542                    	jne	short chk_32khz
   403 000002D8 803D[11230000]08        	cmp	byte [bps], 8
   404 000002DF 7615                    	jna	short chk_24khz_1
   405 000002E1 BB[FD110000]            	mov	ebx, load_24khz_stereo_16_bit
   406 000002E6 803D[10230000]01        	cmp	byte [stmo], 1 
   407 000002ED 751A                    	jne	short chk_24khz_2
   408 000002EF BB[9A110000]            	mov	ebx, load_24khz_mono_16_bit
   409 000002F4 EB13                    	jmp	short chk_24khz_2
   410                                  chk_24khz_1:
   411 000002F6 BB[10110000]            	mov	ebx, load_24khz_stereo_8_bit
   412 000002FB 803D[10230000]01        	cmp	byte [stmo], 1 
   413 00000302 7505                    	jne	short chk_24khz_2
   414 00000304 BB[A9100000]            	mov	ebx, load_24khz_mono_8_bit
   415                                  chk_24khz_2:
   416 00000309 B800200000              	mov	eax, 8192
   417 0000030E BA02000000              	mov	edx, 2
   418 00000313 B901000000              	mov	ecx, 1
   419 00000318 EB46                    	jmp	short set_sizes 
   420                                  chk_32khz:
   421 0000031A 663D007D                	cmp	ax, 32000
   422 0000031E 7579                    	jne	short vra_needed
   423 00000320 803D[11230000]08        	cmp	byte [bps], 8
   424 00000327 7615                    	jna	short chk_32khz_1
   425 00000329 BB[FE130000]            	mov	ebx, load_32khz_stereo_16_bit
   426 0000032E 803D[10230000]01        	cmp	byte [stmo], 1 
   427 00000335 751A                    	jne	short chk_32khz_2
   428 00000337 BB[94130000]            	mov	ebx, load_32khz_mono_16_bit
   429 0000033C EB13                    	jmp	short chk_32khz_2
   430                                  chk_32khz_1:
   431 0000033E BB[F7120000]            	mov	ebx, load_32khz_stereo_8_bit
   432 00000343 803D[10230000]01        	cmp	byte [stmo], 1 
   433 0000034A 7505                    	jne	short chk_32khz_2
   434 0000034C BB[84120000]            	mov	ebx, load_32khz_mono_8_bit
   435                                  chk_32khz_2:
   436 00000351 B8AA2A0000              	mov	eax, 10922
   437 00000356 BA03000000              	mov	edx, 3
   438 0000035B B902000000              	mov	ecx, 2
   439                                  	;jmp	short set_sizes 
   440                                  set_sizes:
   441 00000360 803D[10230000]01        	cmp	byte [stmo], 1
   442 00000367 7402                    	je	short ss_1
   443 00000369 D1E0                    	shl	eax, 1
   444                                  ss_1:
   445 0000036B 803D[11230000]08        	cmp	byte [bps], 8
   446 00000372 7602                    	jna	short ss_2
   447                                  	; 16 bit samples
   448 00000374 D1E0                    	shl	eax, 1
   449                                  ss_2:
   450 00000376 A3[B8030000]            	mov	[loadsize], eax
   451 0000037B F7E2                    	mul	edx
   452                                  	;cmp	ecx, 1
   453                                  	;je	short ss_3
   454                                  ;ss_3:
   455 0000037D F7F1                    	div	ecx
   456 0000037F 8A0D[8C230000]          	mov	cl, [fbs_shift]
   457 00000385 D3E0                    	shl	eax, cl
   458                                  	; 26/11/2023
   459                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   460                                  
   461                                  	;;;
   462                                  	; 04/06/2024 (8 byte alignment for BDL)
   463 00000387 83C007                  	add	eax, 7
   464 0000038A 24F8                    	and	al, ~7
   465                                  	;;;
   466                                  
   467 0000038C A3[BC030000]            	mov	[buffersize], eax ; buffer size in bytes 
   468 00000391 891D[B4030000]          	mov	[loadfromwavfile], ebx
   469 00000397 EB27                    	jmp	short PlayNow
   470                                  
   471                                  vra_needed:
   472                                  	sys	_msg, msg_no_vra, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000399 BB[99210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000039E B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003A3 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003A8 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000003AD CD40                <1>  int 40h
   473 000003AF E9D1000000              	jmp	Exit
   474                                  
   475                                  	; 26/11/2023
   476                                  	; 13/11/2023
   477                                  loadfromwavfile:
   478 000003B4 [81050000]              	dd	loadFromFile
   479                                  loadsize:	; read from wav file
   480 000003B8 00000000                	dd	0
   481                                  buffersize:	; write to DMA buffer
   482 000003BC 00000100                	dd	65536 ; bytes
   483                                  
   484                                  PlayNow: 
   485                                  
   486                                  ; 26/11/2023
   487                                  %if 1
   488                                  	; Allocate Audio Buffer (for user)
   489                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   490                                  	; 26/11/2023
   491                                  	sys	_audio, 0200h, [buffersize], audio_buffer
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003C0 BB00020000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000003C5 8B0D[BC030000]      <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003CB BA[00300000]        <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003D0 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 000003D5 CD40                <1>  int 40h
   492 000003D7 731B                    	jnc	short _2
   493                                  
   494                                  	; 26/11/2023 - temporary
   495                                  	;sys	_msg, test_1, 255, 0Ch
   496                                  
   497                                  error_exit:
   498                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003D9 BB[48210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000003DE B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003E3 BA0E000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003E8 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000003ED CD40                <1>  int 40h
   499 000003EF E991000000              	jmp	Exit
   500                                  _2:
   501                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   502                                  	; bl = 0, bh = 4
   503                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   504                                  
   505                                  	sys	_video, 0400h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003F4 BB00040000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003F9 B81F000000          <1>  mov eax, %1
    89                              <1> 
    90 000003FE CD40                <1>  int 40h
   506 00000400 3D00800B00              	cmp	eax, 0B8000h
   507 00000405 75D2                    	jne	short error_exit
   508                                  
   509                                  	; 01/06/2024
   510                                  	; Initialize Audio Device (bh = 3)
   511                                  	sys	_audio, 0301h, 0, audio_int_handler 
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000407 BB01030000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000040C B900000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000411 BA[50050000]        <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000416 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 0000041B CD40                <1>  int 40h
   512                                  	;jc	short error_exit
   513 0000041D 0F8211FDFFFF            	jc	init_err
   514                                  _3:
   515                                  
   516                                  %endif
   517                                  
   518                                  ;
   519                                  ; position file pointer to start in actual wav data
   520                                  ; MUCH improvement should really be done here to check if sample size is
   521                                  ; supported, make sure there are 2 channels, etc.  
   522                                  ;
   523                                          ;mov     ah, 42h
   524                                          ;mov     al, 0	; from start of file
   525                                          ;mov     bx, [FileHandle]
   526                                          ;xor     cx, cx
   527                                          ;mov     dx, 44	; jump past .wav/riff header
   528                                          ;int     21h
   529                                  
   530                                  	sys	_seek, [FileHandle], 44, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000423 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000429 B92C000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000042E BA00000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000433 B813000000          <1>  mov eax, %1
    89                              <1> 
    90 00000438 CD40                <1>  int 40h
   531                                  
   532                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000043A BB[1E220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000043F B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000444 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000449 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000044E CD40                <1>  int 40h
   533                                  
   534                                  ; play the .wav file. Most of the good stuff is in here.
   535                                  
   536 00000450 E8E1010000                      call    PlayWav
   537                                  
   538                                  ; close the .wav file and exit.
   539                                  
   540                                  StopPlaying:
   541                                  	; Stop Playing
   542                                  	sys	_audio, 0700h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000455 BB00070000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000045A B820000000          <1>  mov eax, %1
    89                              <1> 
    90 0000045F CD40                <1>  int 40h
   543                                  	; Cancel callback service (for user)
   544                                  	sys	_audio, 0900h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000461 BB00090000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000466 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 0000046B CD40                <1>  int 40h
   545                                  	; Deallocate Audio Buffer (for user)
   546                                  	sys	_audio, 0A00h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000046D BB000A0000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000472 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 00000477 CD40                <1>  int 40h
   547                                  	; Disable Audio Device
   548                                  	sys	_audio, 0C00h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000479 BB000C0000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000047E B820000000          <1>  mov eax, %1
    89                              <1> 
    90 00000483 CD40                <1>  int 40h
   549                                  Exit:  
   550 00000485 E847000000                      call    closeFile
   551                                           
   552                                  	sys	_exit	; Bye!
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80                              <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000048A B801000000          <1>  mov eax, %1
    89                              <1> 
    90 0000048F CD40                <1>  int 40h
   553                                  here:
   554 00000491 EBFE                    	jmp	short here
   555                                  
   556                                  pmsg_usage:
   557                                  	sys	_msg, msg_usage, 255, 0Bh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000493 BB[E5200000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000498 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000049D BA0B000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000004A2 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000004A7 CD40                <1>  int 40h
   558 000004A9 EBDA                    	jmp	short Exit
   559                                  
   560                                  	; 25/11/2023
   561                                  DetectAC97:
   562                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   563                                          sys	_audio, 0102h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000004AB BB02010000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000004B0 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 000004B5 CD40                <1>  int 40h
   564                                  
   565                                  ; 01/06/2024
   566                                  %if 0
   567                                  	jc	short DetectAC97_retn
   568                                  
   569                                  	; 25/11/2023
   570                                  	; Get AC'97 Codec info
   571                                  	; (Function 14, sub function 1)
   572                                  	sys	_audio, 0E01h
   573                                  	; Save Variable Rate Audio support bit
   574                                  	and	al, 1
   575                                  	mov	[VRA], al
   576                                  %endif
   577                                  
   578                                  DetectAC97_retn:
   579 000004B7 C3                      	retn
   580                                  
   581                                  ;open or create file
   582                                  ;
   583                                  ;input: ds:dx-->filename (asciiz)
   584                                  ;       al=file Mode (create or open)
   585                                  ;output: none  cs:[FileHandle] filled
   586                                  ;
   587                                  openFile:
   588                                  	;mov	ah, 3Bh	; start with a mode
   589                                  	;add	ah, al	; add in create or open mode
   590                                  	;xor	ecx, ecx
   591                                  	;int	21h
   592                                  	;jc	short _of1
   593                                  	;;mov	[cs:FileHandle], ax
   594                                  
   595                                  	sys	_open, wav_file_name, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000004B8 BB[39230000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000004BD B900000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000004C2 B805000000          <1>  mov eax, %1
    89                              <1> 
    90 000004C7 CD40                <1>  int 40h
   596 000004C9 7205                    	jc	short _of1
   597                                  
   598 000004CB A3[3C200000]            	mov	[FileHandle], eax
   599                                  _of1:
   600 000004D0 C3                      	retn
   601                                  
   602                                  ; close the currently open file
   603                                  ; input: none, uses cs:[FileHandle]
   604                                  closeFile:
   605 000004D1 833D[3C200000]FF        	cmp	dword [FileHandle], -1
   606 000004D8 7417                    	je	short _cf1
   607                                  	;mov    bx, [FileHandle]  
   608                                  	;mov    ax, 3E00h
   609                                          ;int    21h              ;close file
   610                                  
   611                                  	sys	_close, [FileHandle]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000004DA 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000004E0 B806000000          <1>  mov eax, %1
    89                              <1> 
    90 000004E5 CD40                <1>  int 40h
   612 000004E7 C705[3C200000]FFFF-     	mov 	dword [FileHandle], -1
   612 000004EF FFFF               
   613                                  _cf1:
   614 000004F1 C3                      	retn
   615                                  
   616                                  getSampleRate:
   617                                  	
   618                                  ; reads the sample rate from the .wav file.
   619                                  ; entry: none - assumes file is already open
   620                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   621                                  ;	cx = number of channels (mono=1, stereo=2)
   622                                  ;	dx = bits per sample (8, 16)
   623                                  
   624 000004F2 53                      	push    ebx
   625                                  
   626                                          ;mov	ah, 42h
   627                                          ;mov	al, 0	; from start of file
   628                                          ;mov	bx, [FileHandle]
   629                                          ;xor	ecx, ecx
   630                                          ;mov	dx, 08h	; "WAVE"
   631                                          ;int	21h
   632                                  	
   633                                  	sys	_seek, [FileHandle], 8, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000004F3 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000004F9 B908000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000004FE BA00000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000503 B813000000          <1>  mov eax, %1
    89                              <1> 
    90 00000508 CD40                <1>  int 40h
   634                                  
   635                                          ;mov	dx, smpRBuff
   636                                          ;mov	cx, 28	; 28 bytes
   637                                  	;mov	ah, 3fh
   638                                          ;int	21h
   639                                  
   640                                  	sys	_read, [FileHandle], smpRBuff, 28
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000050A 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000510 B9[1D230000]        <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000515 BA1C000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000051A B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000051F CD40                <1>  int 40h
   641                                  
   642 00000521 813D[1D230000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   642 00000529 5645               
   643 0000052B 7520                    	jne	short gsr_stc
   644                                  
   645 0000052D 66833D[29230000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   646 00000535 7516                    	jne	short gsr_stc
   647                                  
   648 00000537 668B0D[2B230000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   649 0000053E 66A1[2D230000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   650 00000544 668B15[37230000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   651                                  gsr_retn:
   652 0000054B 5B                              pop     ebx
   653 0000054C C3                              retn
   654                                  gsr_stc:
   655 0000054D F9                      	stc
   656 0000054E EBFB                    	jmp	short gsr_retn
   657                                  
   658                                  audio_int_handler:
   659                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   660                                  
   661                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   662                                  	
   663                                  	;cmp	byte [cbs_busy], 1
   664                                  	;jnb	short _callback_bsy_retn
   665                                  	
   666                                  	;mov	byte [cbs_busy], 1
   667                                  
   668 00000550 A0[19230000]            	mov	al, [half_buff]
   669                                  
   670 00000555 3C01                    	cmp	al, 1
   671 00000557 721A                    	jb	short _callback_retn
   672                                  
   673                                  	; 18/08/2020
   674 00000559 C605[1A230000]01        	mov	byte [srb], 1
   675                                  
   676 00000560 8035[19230000]03        	xor	byte [half_buff], 3 ; 2->1, 1->2
   677                                  
   678 00000567 0430                    	add	al, '0'
   679                                  tL0:	; 26/11/2023
   680 00000569 B44E                    	mov	ah, 4Eh
   681 0000056B BB00800B00              	mov	ebx, 0B8000h ; video display page address
   682 00000570 668903                  	mov	[ebx], ax ; show playing buffer (1, 2)
   683                                  _callback_retn:
   684                                  	;mov	byte [cbs_busy], 0
   685                                  _callback_bsy_retn:
   686                                  	sys	_rele ; return from callback service 
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80                              <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000573 B827000000          <1>  mov eax, %1
    89                              <1> 
    90 00000578 CD40                <1>  int 40h
   687                                  	; we must not come here !
   688                                  	sys	_exit
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80                              <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000057A B801000000          <1>  mov eax, %1
    89                              <1> 
    90 0000057F CD40                <1>  int 40h
   689                                  	
   690                                  loadFromFile:
   691                                  	; 26/11/2023
   692 00000581 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
   693                                  					; last of the file?
   694 00000588 7402                    	jz	short lff_0		; no
   695 0000058A F9                      	stc
   696 0000058B C3                      	retn
   697                                  lff_0:
   698                                  	; 13/06/2017
   699                                  	;mov	edx, BUFFERSIZE
   700                                  	; 26/11/2023
   701 0000058C BF[00300000]            	mov	edi, audio_buffer
   702 00000591 8B15[BC030000]          	mov	edx, [buffersize]	; bytes
   703 00000597 8A0D[8C230000]          	mov	cl, [fbs_shift]   
   704 0000059D 20C9                    	and	cl, cl
   705 0000059F 7409                    	jz	short lff_1 ; stereo, 16 bit
   706                                  
   707                                  	; fbs_shift =
   708                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   709                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   710 000005A1 D3EA                    	shr	edx, cl
   711                                  	;inc	edx
   712                                  
   713 000005A3 BE[00300100]            	mov     esi, temp_buffer
   714 000005A8 EB02                    	jmp	short lff_2
   715                                  lff_1:
   716                                  	;mov	esi, audio_buffer
   717 000005AA 89FE                    	mov	esi, edi ; audio_buffer
   718                                  lff_2:
   719                                  	; 17/03/2017
   720                                  	; esi = buffer address
   721                                  	; edx = buffer size
   722                                   
   723                                  	; 26/11/2023
   724                                  	; load file into memory
   725                                  	sys 	_read, [FileHandle], esi
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000005AC 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000005B2 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000005B4 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000005B9 CD40                <1>  int 40h
   726 000005BB 89D1                    	mov	ecx, edx
   727 000005BD 724A                    	jc	short padfill ; error !
   728                                  
   729 000005BF 21C0                    	and	eax, eax
   730 000005C1 7446                    	jz	short padfill
   731                                  lff_3:
   732                                  	; 26/11/2023
   733 000005C3 8A1D[8C230000]          	mov	bl, [fbs_shift]
   734 000005C9 20DB                    	and	bl, bl
   735 000005CB 745C                    	jz	short lff_11
   736                                  
   737 000005CD 29C1                    	sub	ecx, eax
   738 000005CF 89CD                    	mov	ebp, ecx
   739                                  
   740                                  	;mov	esi, temp_buffer
   741                                  	;mov	edi, audio_buffer
   742 000005D1 89C1                    	mov	ecx, eax   ; byte count
   743                                  
   744 000005D3 803D[11230000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   745 000005DA 751E                    	jne	short lff_6 ; 16 bit samples
   746                                  	; 8 bit samples
   747 000005DC FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   748 000005DE 740E                    	jz	short lff_5 ; 8 bit, stereo
   749                                  lff_4:
   750                                  	; mono & 8 bit
   751 000005E0 AC                      	lodsb
   752 000005E1 2C80                    	sub	al, 80h ; 08/11/2023
   753 000005E3 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   754 000005E6 66AB                    	stosw	; left channel
   755 000005E8 66AB                    	stosw	; right channel
   756 000005EA E2F4                    	loop	lff_4
   757 000005EC EB16                    	jmp	short lff_8
   758                                  lff_5:
   759                                  	; stereo & 8 bit
   760 000005EE AC                      	lodsb
   761 000005EF 2C80                    	sub	al, 80h ; 08/11/2023
   762 000005F1 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   763 000005F4 66AB                    	stosw
   764 000005F6 E2F6                    	loop	lff_5			
   765 000005F8 EB0A                    	jmp	short lff_8
   766                                  lff_6:
   767 000005FA D1E9                    	shr	ecx, 1 ; word count
   768                                  lff_7:
   769 000005FC 66AD                    	lodsw
   770 000005FE 66AB                    	stosw	; left channel
   771 00000600 66AB                    	stosw	; right channel
   772 00000602 E2F8                    	loop	lff_7
   773                                  lff_8:
   774                                  	; 27/11/2023
   775 00000604 F8                      	clc
   776 00000605 89E9                    	mov	ecx, ebp
   777 00000607 E314                    	jecxz	endLFF_retn
   778                                  	
   779                                  padfill:
   780 00000609 803D[11230000]10        	cmp 	byte [bps], 16
   781 00000610 740C                    	je	short lff_10
   782                                  	; Minimum Value = 0
   783 00000612 30C0                            xor     al, al
   784 00000614 F3AA                    	rep	stosb
   785                                  lff_9:
   786 00000616 800D[18230000]01                or	byte [flags], ENDOFFILE	; end of file flag
   787                                  endLFF_retn:
   788 0000061D C3                              retn
   789                                  lff_10:
   790 0000061E 31C0                    	xor	eax, eax
   791                                  	; Minimum value = 8000h (-32768)
   792 00000620 D1E9                    	shr	ecx, 1 
   793 00000622 B480                    	mov	ah, 80h ; ax = -32768
   794 00000624 F366AB                  	rep	stosw
   795 00000627 EBED                    	jmp	short lff_9
   796                                  
   797                                  lff_11:
   798                                  	; 16 bit stereo
   799                                  	; ecx = buffer size
   800                                  	; eax = read count
   801 00000629 29C1                    	sub	ecx, eax
   802 0000062B 76F0                    	jna	short endLFF_retn
   803 0000062D 01C7                    	add	edi, eax  ; audio_buffer + eax
   804 0000062F EBED                    	jmp	short lff_10 ; padfill
   805                                  
   806                                  error_exit_2:
   807                                  	; 26/11/2023 - temporary
   808                                  	;sys	_msg, test_2, 255, 0Ch
   809                                  
   810 00000631 E9A3FDFFFF              	jmp	error_exit
   811                                  	
   812                                  	; 26/11/2023 - temporary
   813                                  ;test_1:
   814                                  ;	db 13, 10, 'Test 1', 13,10, 0
   815                                  ;test_2:
   816                                  ;	db 13, 10, 'Test 2', 13,10, 0
   817                                  	
   818                                  PlayWav:
   819                                  	; 26/11/2023
   820                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   821                                  	; 13/06/2017
   822                                  	; Convert 8 bit samples to 16 bit samples
   823                                  	; and convert mono samples to stereo samples
   824                                  
   825                                  	; 26/11/2023
   826                                  	; load 32768 bytes into audio buffer
   827                                  	;mov	edi, audio_buffer
   828                                  	;;mov	edx, BUFFERSIZE
   829                                  	; 26/11/2023
   830                                  	;mov	edx, [buffersize]
   831                                  	;call	loadFromFile
   832                                  	; 26/11/2023
   833 00000636 FF15[B4030000]          	call	dword [loadfromwavfile]
   834 0000063C 72F3                    	jc	short error_exit_2
   835 0000063E C605[19230000]01        	mov	byte [half_buff], 1 ; (DMA) Buffer 1
   836                                  
   837                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   838 00000645 F605[18230000]01        	test    byte [flags], ENDOFFILE  ; end of file
   839 0000064C 7512                    	jnz	short _6 ; yes
   840                                  			 ; bypass filling dma half buffer 2
   841                                  
   842                                  	; bh = 16 : update (current, first) dma half buffer
   843                                  	; bl = 0  : then switch to the next (second) half buffer
   844                                  	sys	_audio, 1000h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000064E BB00100000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000653 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 00000658 CD40                <1>  int 40h
   845                                  
   846                                  	; 18/08/2020
   847                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
   848                                  
   849                                  	; audio_buffer must be filled again after above system call 
   850                                  	; (Because audio interrupt will be generated by AC97 hardware
   851                                  	; at the end of the first half of dma buffer.. so, 
   852                                  	; the second half must be ready. 'sound_play' will use it.)
   853                                  
   854                                  	; 26/11/2023
   855                                  	;mov	edi, audio_buffer
   856                                  	;;mov	edx, BUFFERSIZE
   857                                  	; 26/11/2023
   858                                  	;mov	edx, [buffersize]
   859                                  	;call	loadFromFile
   860                                  	; 26/11/2023
   861 0000065A FF15[B4030000]          	call	dword [loadfromwavfile]
   862                                  	;jc	short p_return
   863                                  _6:
   864                                  	; Set Master Volume Level (BL=0 or 80h)
   865                                  	; 	for next playing (BL>=80h)
   866                                  	;sys	_audio, 0B80h, 1D1Dh
   867                                  	sys	_audio, 0B00h, 1D1Dh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000660 BB000B0000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000665 B91D1D0000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000066A B820000000          <1>  mov eax, %1
    89                              <1> 
    90 0000066F CD40                <1>  int 40h
   868                                  
   869                                  	; 18/08/2020
   870                                  	;mov	byte [volume_level], 1Dh
   871 00000671 880D[1B230000]          	mov	[volume_level], cl
   872                                  
   873                                  	; Start	to play
   874                                  	;mov	al, [bps]
   875                                  	;shr	al, 4 ; 8 -> 0, 16 -> 1
   876                                  	;shl	al, 1 ; 16 -> 2, 8 -> 0
   877                                  	;mov	bl, [stmo]
   878                                  	;dec	bl
   879                                  	;or	bl, al
   880                                  	;mov	cx, [sample_rate]
   881                                  	; 04/06/2024
   882                                  	; (non-VRA simulation)
   883 00000677 66B980BB                 	mov	cx, 48000 ; 48 kHz
   884 0000067B B303                    	mov	bl, 3  ; 16 bit, stereo
   885                                  	
   886 0000067D B704                    	mov	bh, 4 ; start to play
   887                                  	sys	_audio
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80                              <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000067F B820000000          <1>  mov eax, %1
    89                              <1> 
    90 00000684 CD40                <1>  int 40h
   888                                  
   889                                  	;mov	ebx, 0B8000h ; video display page address
   890                                  	;mov	ah, 4Eh
   891                                  	;mov	al, [half_buffer]
   892                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   893                                  
   894                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   895                                  	; Here..
   896                                  	; If byte [flags] <> ENDOFFILE ...
   897                                  	; user's audio_buffer has been copied to dma half buffer 2
   898                                  
   899                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
   900                                  
   901                                  	; audio_buffer must be filled again after above system call 
   902                                  	; (Because, audio interrupt will be generated by VT8237R
   903                                  	; at the end of the first half of dma buffer.. so, 
   904                                  	; the 2nd half of dma buffer is ready but the 1st half
   905                                  	; must be filled again.)
   906                                  
   907                                  	; 18/08/2020
   908 00000686 F605[18230000]01        	test    byte [flags], ENDOFFILE  ; end of file
   909 0000068D 7506                    	jnz	short p_loop ; yes
   910                                  
   911                                  	; 18/08/2020
   912                                  	; load 32768 bytes into audio buffer
   913                                  	;; (for the second half of DMA buffer)
   914                                  	; 27/11/2023
   915                                  	; 20/05/2017
   916                                  	;mov	edi, audio_buffer
   917                                  	;mov	edx, BUFFERSIZE
   918                                  	; 26/11/2023
   919                                  	;mov	edx, [buffersize]
   920                                  	;call	loadFromFile
   921                                  	; 26/11/2023
   922 0000068F FF15[B4030000]          	call	dword [loadfromwavfile]
   923                                  	;jc	short p_return
   924                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
   925                                  
   926                                  	; we need to wait for 'SRB' (audio interrupt)
   927                                  	; (we can not return from 'PlayWav' here 
   928                                  	;  even if we have got an error from file reading)
   929                                  	; ((!!current audio data must be played!!))
   930                                  
   931                                  	; 18/08/2020
   932                                  	;mov	byte [srb], 1
   933                                  
   934                                  p_loop:
   935                                  	;mov	ah, 1		; any key pressed?
   936                                  	;int	32h		; no, Loop.
   937                                  	;jz	short q_loop
   938                                  	;
   939                                  	;mov	ah, 0		; flush key buffer...
   940                                  	;int	32h
   941                                  
   942                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   943 00000695 803D[1A230000]00        	cmp	byte [srb], 0
   944 0000069C 760F                    	jna	short q_loop
   945 0000069E C605[1A230000]00        	mov	byte [srb], 0
   946                                  	; 27/11/2023
   947                                  	;mov	edi, audio_buffer
   948                                  	;mov	edx, BUFFERSIZE
   949                                  	; 26/11/2023
   950                                  	;mov	edx, [buffersize]
   951                                  	;call	loadFromFile
   952                                  	; 26/11/2023
   953 000006A5 FF15[B4030000]          	call	dword [loadfromwavfile]
   954 000006AB 7212                    	jc	short p_return
   955                                  q_loop:
   956 000006AD B401                    	mov     ah, 1		; any key pressed?
   957 000006AF CD32                    	int     32h		; no, Loop.
   958 000006B1 74E2                    	jz	short p_loop
   959                                  
   960 000006B3 B400                    	mov     ah, 0		; flush key buffer...
   961 000006B5 CD32                    	int     32h
   962                                  	
   963 000006B7 3C2B                    	cmp	al, '+' ; increase sound volume
   964 000006B9 740C                    	je	short inc_volume_level
   965 000006BB 3C2D                    	cmp	al, '-'
   966 000006BD 742B                    	je	short dec_volume_level
   967                                  
   968                                  p_return:
   969 000006BF C605[19230000]00        	mov	byte [half_buff], 0
   970 000006C6 C3                      	retn
   971                                  
   972                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   973                                  inc_volume_level:
   974 000006C7 8A0D[1B230000]          	mov	cl, [volume_level]
   975 000006CD 80F91F                  	cmp	cl, 1Fh ; 31
   976 000006D0 73DB                    	jnb	short q_loop
   977 000006D2 FEC1                    	inc	cl
   978                                  change_volume_level:
   979 000006D4 880D[1B230000]          	mov	[volume_level], cl
   980 000006DA 88CD                    	mov	ch, cl
   981                                  	; Set Master Volume Level
   982                                  	sys	_audio, 0B00h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000006DC BB000B0000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000006E1 B820000000          <1>  mov eax, %1
    89                              <1> 
    90 000006E6 CD40                <1>  int 40h
   983 000006E8 EBAB                    	jmp	short p_loop
   984                                  dec_volume_level:
   985 000006EA 8A0D[1B230000]          	mov	cl, [volume_level]
   986 000006F0 80F901                  	cmp	cl, 1 ; 1
   987 000006F3 76A0                    	jna	short p_loop
   988 000006F5 FEC9                    	dec	cl
   989 000006F7 EBDB                    	jmp	short change_volume_level
   990                                  
   991                                  write_audio_dev_info:
   992                                  	; EBX = Message address
   993                                  	; ECX = Max. message length (or stop on ZERO character)
   994                                  	;	(1 to 255)
   995                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
   996                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000006F9 BB[BC200000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000006FE B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000703 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000708 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000070D CD40                <1>  int 40h
   997 0000070F C3                      	retn
   998                                  
   999                                  write_wav_file_info:
  1000                                  	; 01/05/2017
  1001                                  	sys	_msg, msgWavFileName, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000710 BB[D2210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000715 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000071A BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000071F B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000724 CD40                <1>  int 40h
  1002                                  	sys	_msg, wav_file_name, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000726 BB[39230000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000072B B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000730 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000735 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000073A CD40                <1>  int 40h
  1003                                  
  1004                                  write_sample_rate:
  1005                                  	; 01/05/2017
  1006 0000073C 66A1[12230000]          	mov	ax, [sample_rate]
  1007                                  	; ax = sample rate (hertz)
  1008 00000742 31D2                    	xor	edx, edx
  1009 00000744 66B90A00                	mov	cx, 10
  1010 00000748 66F7F1                  	div	cx
  1011 0000074B 0015[F7210000]          	add	[msgHertz+4], dl
  1012 00000751 29D2                    	sub	edx, edx
  1013 00000753 66F7F1                  	div	cx
  1014 00000756 0015[F6210000]          	add	[msgHertz+3], dl
  1015 0000075C 29D2                    	sub	edx, edx
  1016 0000075E 66F7F1                  	div	cx
  1017 00000761 0015[F5210000]          	add	[msgHertz+2], dl
  1018 00000767 29D2                    	sub	edx, edx
  1019 00000769 66F7F1                  	div	cx
  1020 0000076C 0015[F4210000]          	add	[msgHertz+1], dl
  1021 00000772 0005[F3210000]          	add	[msgHertz], al
  1022                                  	
  1023                                  	sys	_msg, msgSampleRate, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000778 BB[E4210000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000077D B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000782 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000787 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000078C CD40                <1>  int 40h
  1024                                  
  1025 0000078E BE[0E220000]            	mov	esi, msg16Bits
  1026 00000793 803D[11230000]10        	cmp	byte [bps], 16
  1027 0000079A 7405                    	je	short wsr_1
  1028 0000079C BE[FE210000]            	mov	esi, msg8Bits
  1029                                  wsr_1:
  1030                                  	sys	_msg, esi, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000007A1 89F3                <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000007A3 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000007A8 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000007AD B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000007B2 CD40                <1>  int 40h
  1031                                  
  1032 000007B4 BE[07220000]            	mov	esi, msgMono
  1033 000007B9 803D[10230000]01        	cmp	byte [stmo], 1
  1034 000007C0 7405                    	je	short wsr_2
  1035 000007C2 BE[18220000]            	mov	esi, msgStereo		
  1036                                  wsr_2:
  1037                                  	sys	_msg, esi, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000007C7 89F3                <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000007C9 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000007CE BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000007D3 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000007D8 CD40                <1>  int 40h
  1038 000007DA C3                              retn
  1039                                  
  1040                                  write_ac97_pci_dev_info:
  1041                                  	; 06/06/2017
  1042                                  	; 03/06/2017
  1043                                  	; BUS/DEV/FN
  1044                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1045                                  	; DEV/VENDOR
  1046                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1047                                  
  1048 000007DB 8B35[8D230000]          	mov	esi, [dev_vendor]
  1049 000007E1 89F0                    	mov	eax, esi
  1050 000007E3 0FB6D8                  	movzx	ebx, al
  1051 000007E6 88DA                    	mov	dl, bl
  1052 000007E8 80E30F                  	and	bl, 0Fh
  1053 000007EB 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1054 000007F1 A2[66220000]            	mov	[msgVendorId+3], al
  1055 000007F6 88D3                    	mov	bl, dl
  1056 000007F8 C0EB04                  	shr	bl, 4
  1057 000007FB 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1058 00000801 A2[65220000]            	mov	[msgVendorId+2], al
  1059 00000806 88E3                    	mov	bl, ah
  1060 00000808 88DA                    	mov	dl, bl
  1061 0000080A 80E30F                  	and	bl, 0Fh
  1062 0000080D 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1063 00000813 A2[64220000]            	mov	[msgVendorId+1], al
  1064 00000818 88D3                    	mov	bl, dl
  1065 0000081A C0EB04                  	shr	bl, 4
  1066 0000081D 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1067 00000823 A2[63220000]            	mov	[msgVendorId], al
  1068 00000828 C1E810                  	shr	eax, 16
  1069 0000082B 88C3                    	mov	bl, al
  1070 0000082D 88DA                    	mov	dl, bl
  1071 0000082F 80E30F                  	and	bl, 0Fh
  1072 00000832 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1073 00000838 A2[77220000]            	mov	[msgDevId+3], al
  1074 0000083D 88D3                    	mov	bl, dl
  1075 0000083F C0EB04                  	shr	bl, 4
  1076 00000842 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1077 00000848 A2[76220000]            	mov	[msgDevId+2], al
  1078 0000084D 88E3                    	mov	bl, ah
  1079 0000084F 88DA                    	mov	dl, bl
  1080 00000851 80E30F                  	and	bl, 0Fh
  1081 00000854 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1082 0000085A A2[75220000]            	mov	[msgDevId+1], al
  1083 0000085F 88D3                    	mov	bl, dl
  1084 00000861 C0EB04                  	shr	bl, 4
  1085 00000864 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1086 0000086A A2[74220000]            	mov	[msgDevId], al
  1087                                  
  1088 0000086F 8B35[91230000]          	mov	esi, [bus_dev_fn]
  1089 00000875 C1EE08                  	shr	esi, 8
  1090 00000878 6689F0                  	mov	ax, si
  1091 0000087B 88C3                    	mov	bl, al
  1092 0000087D 88DA                    	mov	dl, bl
  1093 0000087F 80E307                  	and	bl, 7 ; bit 0,1,2
  1094 00000882 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1095 00000888 A2[9B220000]            	mov	[msgFncNo+1], al
  1096 0000088D 88D3                    	mov	bl, dl
  1097 0000088F C0EB03                  	shr	bl, 3
  1098 00000892 88DA                    	mov	dl, bl
  1099 00000894 80E30F                  	and	bl, 0Fh
  1100 00000897 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1101 0000089D A2[8D220000]            	mov	[msgDevNo+1], al
  1102 000008A2 88D3                    	mov	bl, dl
  1103 000008A4 C0EB04                  	shr	bl, 4
  1104 000008A7 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1105 000008AD A2[8C220000]            	mov	[msgDevNo], al
  1106 000008B2 88E3                    	mov	bl, ah
  1107 000008B4 88DA                    	mov	dl, bl
  1108 000008B6 80E30F                  	and	bl, 0Fh
  1109 000008B9 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1110 000008BF A2[81220000]            	mov	[msgBusNo+1], al
  1111 000008C4 88D3                    	mov	bl, dl
  1112 000008C6 C0EB04                  	shr	bl, 4
  1113 000008C9 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1114 000008CF A2[80220000]            	mov	[msgBusNo], al
  1115                                  
  1116 000008D4 66A1[95230000]          	mov	ax, [ac97_NamBar]
  1117 000008DA 88C3                    	mov	bl, al
  1118 000008DC 88DA                    	mov	dl, bl
  1119 000008DE 80E30F                  	and	bl, 0Fh
  1120 000008E1 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1121 000008E7 A2[AA220000]            	mov	[msgNamBar+3], al
  1122 000008EC 88D3                    	mov	bl, dl
  1123 000008EE C0EB04                  	shr	bl, 4
  1124 000008F1 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1125 000008F7 A2[A9220000]            	mov	[msgNamBar+2], al
  1126 000008FC 88E3                    	mov	bl, ah
  1127 000008FE 88DA                    	mov	dl, bl
  1128 00000900 80E30F                  	and	bl, 0Fh
  1129 00000903 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1130 00000909 A2[A8220000]            	mov	[msgNamBar+1], al
  1131 0000090E 88D3                    	mov	bl, dl
  1132 00000910 C0EB04                  	shr	bl, 4
  1133 00000913 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1134 00000919 A2[A7220000]            	mov	[msgNamBar], al
  1135                                  
  1136 0000091E 66A1[97230000]          	mov	ax, [ac97_NabmBar]
  1137 00000924 88C3                    	mov	bl, al
  1138 00000926 88DA                    	mov	dl, bl
  1139 00000928 80E30F                  	and	bl, 0Fh
  1140 0000092B 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1141 00000931 A2[BA220000]            	mov	[msgNabmBar+3], al
  1142 00000936 88D3                    	mov	bl, dl
  1143 00000938 C0EB04                  	shr	bl, 4
  1144 0000093B 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1145 00000941 A2[B9220000]            	mov	[msgNabmBar+2], al
  1146 00000946 88E3                    	mov	bl, ah
  1147 00000948 88DA                    	mov	dl, bl
  1148 0000094A 80E30F                  	and	bl, 0Fh
  1149 0000094D 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1150 00000953 A2[B8220000]            	mov	[msgNabmBar+1], al
  1151 00000958 88D3                    	mov	bl, dl
  1152 0000095A C0EB04                  	shr	bl, 4
  1153 0000095D 8A83[21220000]          	mov	al, [ebx+hex_chars]
  1154 00000963 A2[B7220000]            	mov	[msgNabmBar], al
  1155                                  
  1156 00000968 30E4                    	xor	ah, ah
  1157 0000096A A0[8B230000]            	mov	al, [ac97_int_ln_reg]
  1158 0000096F B10A                    	mov	cl, 10
  1159 00000971 F6F1                    	div	cl
  1160 00000973 660105[C3220000]        	add	[msgIRQ], ax
  1161 0000097A 20C0                    	and	al, al
  1162 0000097C 750D                    	jnz	short _w_ac97imsg_
  1163 0000097E A0[C4220000]            	mov	al, [msgIRQ+1]
  1164 00000983 B420                    	mov	ah, ' '
  1165 00000985 66A3[C3220000]          	mov	[msgIRQ], ax
  1166                                  _w_ac97imsg_:
  1167                                  	sys	_msg, msgAC97Info, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000098B BB[32220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000990 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000995 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000099A B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000099F CD40                <1>  int 40h
  1168                                  
  1169 000009A1 C3                              retn
  1170                                  
  1171                                  write_VRA_info:
  1172                                  	; 25/11/2023
  1173                                  	sys	_msg, msgVRAheader, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009A2 BB[C8220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000009A7 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009AC BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009B1 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000009B6 CD40                <1>  int 40h
  1174 000009B8 803D[1C230000]00        	cmp	byte [VRA], 0
  1175 000009BF 7617                    	jna	short _w_VRAi_no
  1176                                  _w_VRAi_yes:
  1177                                  	sys	_msg, msgVRAyes, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009C1 BB[D6220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000009C6 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009CB BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009D0 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000009D5 CD40                <1>  int 40h
  1178 000009D7 C3                      	retn
  1179                                  _w_VRAi_no:
  1180                                  	sys	_msg, msgVRAno, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009D8 BB[DC220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000009DD B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009E2 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009E7 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000009EC CD40                <1>  int 40h
  1181 000009EE C3                      	retn
  1182                                  
  1183                                  ; 26/11/2023
  1184                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1185                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1186                                  ; 14/11/2023
  1187                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1188                                  ; --------------------------------------------------------
  1189                                  
  1190                                  ;;Note:	At the end of every buffer load,
  1191                                  ;;	during buffer switch/swap, there will be discontinuity
  1192                                  ;;	between the last converted sample and the 1st sample
  1193                                  ;;	of the next buffer.
  1194                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1195                                  ;;	-To avoid this defect, the 1st sample of
  1196                                  ;;	the next buffer may be read from the wav file but
  1197                                  ;;	the file pointer would need to be set to 1 sample back
  1198                                  ;;	again via seek system call. Time comsumption problem! -
  1199                                  ;;
  1200                                  ;;	Erdogan Tan - 15/11/2023
  1201                                  ;;
  1202                                  ;;	((If entire wav data would be loaded at once.. conversion
  1203                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1204                                  ;;	64KB buffer limit is important also it is important
  1205                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1206                                  ;;	I have tested this program by using 2-30MB wav files.))
  1207                                  ;;
  1208                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1209                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1210                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1211                                  ;;			Realtek ALC850 codec.
  1212                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1213                                  
  1214                                  load_8khz_mono_8_bit:
  1215                                  	; 15/11/2023
  1216                                  	; 14/11/2023
  1217                                  	; 13/11/2023
  1218 000009EF F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1219                                  					; last of the file?
  1220 000009F6 7402                    	jz	short lff8m_0		; no
  1221 000009F8 F9                      	stc
  1222 000009F9 C3                      	retn
  1223                                  
  1224                                  lff8m_0:
  1225 000009FA BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1226                                          ;mov	edx, [loadsize]
  1227                                  
  1228                                  	; esi = buffer address
  1229                                  	;; edx = buffer size
  1230                                  
  1231                                  	; load file into memory
  1232                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009FF 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000A05 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000A07 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000A0D B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000A12 CD40                <1>  int 40h
  1233 00000A14 7305                    	jnc	short lff8m_6
  1234 00000A16 E9AA000000              	jmp	lff8m_5  ; error !
  1235                                  
  1236                                  lff8m_6:
  1237 00000A1B BF[00300000]            	mov	edi, audio_buffer
  1238 00000A20 21C0                    	and	eax, eax
  1239 00000A22 0F8494000000            	jz	lff8_eof
  1240                                  
  1241 00000A28 89C1                    	mov	ecx, eax		; byte count
  1242                                  lff8m_1:
  1243 00000A2A AC                      	lodsb
  1244 00000A2B A2[33200000]            	mov	[previous_val], al
  1245 00000A30 2C80                    	sub	al, 80h
  1246 00000A32 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1247 00000A36 66AB                    	stosw		; original sample (left channel)
  1248 00000A38 66AB                    	stosw		; original sample (right channel)
  1249                                  	;xor	eax, eax
  1250 00000A3A B080                    	mov	al, 80h
  1251 00000A3C 49                      	dec	ecx
  1252 00000A3D 7402                    	jz	short lff8m_2
  1253 00000A3F 8A06                    	mov	al, [esi]
  1254                                  lff8m_2:
  1255                                  	;mov	[next_val], ax
  1256 00000A41 88C7                    	mov	bh, al	; [next_val]
  1257 00000A43 8A25[33200000]          	mov	ah, [previous_val]
  1258 00000A49 00E0                    	add	al, ah	; [previous_val]
  1259 00000A4B D0D8                    	rcr	al, 1
  1260 00000A4D 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1261 00000A4F 00E0                    	add	al, ah	; [previous_val]
  1262 00000A51 D0D8                    	rcr	al, 1	
  1263 00000A53 88C3                    	mov	bl, al 	; this is temporary interpolation value	
  1264 00000A55 00E0                    	add	al, ah	; [previous_val]
  1265 00000A57 D0D8                    	rcr	al, 1
  1266 00000A59 2C80                    	sub	al, 80h
  1267 00000A5B 66C1E008                	shl	ax, 8	
  1268 00000A5F 66AB                    	stosw		; this is 1st interpolated sample (L)
  1269 00000A61 66AB                    	stosw		; this is 1st interpolated sample (R)
  1270 00000A63 88D8                    	mov	al, bl
  1271 00000A65 00D0                    	add	al, dl
  1272 00000A67 D0D8                    	rcr	al, 1
  1273 00000A69 2C80                    	sub	al, 80h
  1274 00000A6B 66C1E008                	shl	ax, 8
  1275 00000A6F 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1276 00000A71 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1277 00000A73 88D0                    	mov	al, dl
  1278 00000A75 2C80                    	sub	al, 80h
  1279 00000A77 66C1E008                	shl	ax, 8
  1280 00000A7B 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1281 00000A7D 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1282                                  	;mov	al, [next_val]
  1283 00000A7F 88F8                    	mov	al, bh
  1284 00000A81 00D0                    	add	al, dl
  1285 00000A83 D0D8                    	rcr	al, 1
  1286 00000A85 88C3                    	mov	bl, al	; this is temporary interpolation value
  1287 00000A87 00D0                    	add	al, dl
  1288 00000A89 D0D8                    	rcr	al, 1
  1289 00000A8B 2C80                    	sub	al, 80h
  1290 00000A8D 66C1E008                	shl	ax, 8
  1291 00000A91 66AB                    	stosw		; this is 4th interpolated sample (L)
  1292 00000A93 66AB                    	stosw		; this is 4th interpolated sample (R)
  1293                                  	;mov	al, [next_val]
  1294 00000A95 88F8                    	mov	al, bh
  1295 00000A97 00D8                    	add	al, bl
  1296 00000A99 D0D8                    	rcr	al, 1
  1297 00000A9B 2C80                    	sub	al, 80h
  1298 00000A9D 66C1E008                	shl	ax, 8
  1299 00000AA1 66AB                    	stosw		; this is 5th interpolated sample (L)
  1300 00000AA3 66AB                    	stosw		; this is 5th interpolated sample (R)
  1301                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1302 00000AA5 09C9                    	or	ecx, ecx
  1303 00000AA7 7581                    	jnz	short lff8m_1
  1304                                  
  1305                                  	; --------------
  1306                                  
  1307                                  lff8s_3:
  1308                                  lff8m_3:
  1309                                  lff8s2_3:
  1310                                  lff8m2_3:
  1311                                  lff16s_3:
  1312                                  lff16m_3:
  1313                                  lff16s2_3:
  1314                                  lff16m2_3:
  1315                                  lff24_3:
  1316                                  lff32_3:
  1317                                  lff44_3:
  1318                                  lff22_3:
  1319                                  lff11_3:
  1320                                  	; 01/06/2024 (BugFix)
  1321 00000AA9 8B0D[BC030000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1322                                  	;shl	ecx, 1	; byte count ; Bug !
  1323 00000AAF 29F9                    	sub	ecx, edi
  1324 00000AB1 7607                    	jna	short lff8m_4
  1325                                  	;inc	ecx
  1326 00000AB3 C1E902                  	shr	ecx, 2
  1327 00000AB6 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros	
  1328 00000AB8 F3AB                    	rep	stosd
  1329                                  lff8m_4:
  1330                                  	; 01/06/2024 (BugFix)
  1331                                  	; cf=1 ; Bug !
  1332 00000ABA F8                      	clc
  1333 00000ABB C3                      	retn
  1334                                  
  1335                                  lff8_eof:
  1336                                  lff16_eof:
  1337                                  lff24_eof:
  1338                                  lff32_eof:
  1339                                  lff44_eof:
  1340                                  lff22_eof:
  1341                                  lff11_eof:
  1342                                  	; 15/11/2023
  1343 00000ABC C605[18230000]01        	mov	byte [flags], ENDOFFILE
  1344 00000AC3 EBE4                    	jmp	short lff8m_3
  1345                                  
  1346                                  lff8s_5:
  1347                                  lff8m_5:
  1348                                  lff8s2_5:
  1349                                  lff8m2_5:
  1350                                  lff16s_5:
  1351                                  lff16m_5:
  1352                                  lff16s2_5:
  1353                                  lff16m2_5:
  1354                                  lff24_5:
  1355                                  lff32_5:
  1356                                  lff44_5:
  1357                                  lff22_5:
  1358                                  lff11_5:
  1359 00000AC5 B021                    	mov	al, '!'  ; error
  1360 00000AC7 E89DFAFFFF              	call	tL0
  1361                                  	
  1362                                  	;jmp	short lff8m_3
  1363                                  	; 15/11/2023
  1364 00000ACC EBEE                    	jmp	lff8_eof
  1365                                  
  1366                                  	; --------------
  1367                                  
  1368                                  load_8khz_stereo_8_bit:
  1369                                  	; 15/11/2023
  1370                                  	; 14/11/2023
  1371                                  	; 13/11/2023
  1372 00000ACE F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1373                                  					; last of the file?
  1374 00000AD5 7402                    	jz	short lff8s_0		; no
  1375 00000AD7 F9                      	stc
  1376 00000AD8 C3                      	retn
  1377                                  
  1378                                  lff8s_0:
  1379 00000AD9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1380                                          ;mov	edx, [loadsize]
  1381                                  
  1382                                  	; esi = buffer address
  1383                                  	;; edx = buffer size
  1384                                  
  1385                                  	; load file into memory
  1386                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000ADE 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000AE4 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000AE6 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000AEC B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000AF1 CD40                <1>  int 40h
  1387 00000AF3 72D0                    	jc	short lff8s_5 ; error !
  1388                                  
  1389 00000AF5 BF[00300000]            	mov	edi, audio_buffer
  1390                                  	
  1391 00000AFA D1E8                    	shr	eax, 1
  1392 00000AFC 74BE                    	jz	short lff8_eof
  1393                                  
  1394 00000AFE 89C1                    	mov	ecx, eax	; word count
  1395                                  lff8s_1:
  1396 00000B00 AC                      	lodsb
  1397 00000B01 A2[33200000]            	mov	[previous_val_l], al
  1398 00000B06 2C80                    	sub	al, 80h
  1399 00000B08 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1400 00000B0C 66AB                    	stosw		; original sample (L)
  1401 00000B0E AC                      	lodsb
  1402 00000B0F A2[35200000]            	mov	[previous_val_r], al
  1403 00000B14 2C80                    	sub	al, 80h
  1404 00000B16 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1405 00000B1A 66AB                    	stosw		; original sample (R)
  1406                                  
  1407                                  	;xor	eax, eax
  1408 00000B1C 66B88080                	mov	ax, 8080h
  1409 00000B20 49                      	dec	ecx
  1410 00000B21 7403                    	jz	short lff8s_2
  1411                                  		; convert 8 bit sample to 16 bit sample
  1412 00000B23 668B06                  	mov	ax, [esi]
  1413                                  lff8s_2:
  1414 00000B26 A2[37200000]            	mov	[next_val_l], al
  1415 00000B2B 8825[39200000]          	mov	[next_val_r], ah
  1416 00000B31 8A25[33200000]          	mov	ah, [previous_val_l]
  1417 00000B37 00E0                    	add	al, ah
  1418 00000B39 D0D8                    	rcr	al, 1
  1419 00000B3B 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1420 00000B3D 00E0                    	add	al, ah
  1421 00000B3F D0D8                    	rcr	al, 1	
  1422 00000B41 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1423 00000B43 00E0                    	add	al, ah
  1424 00000B45 D0D8                    	rcr	al, 1
  1425 00000B47 2C80                    	sub	al, 80h
  1426 00000B49 66C1E008                	shl	ax, 8
  1427 00000B4D 66AB                    	stosw		; this is 1st interpolated sample (L)
  1428 00000B4F A0[39200000]            	mov	al, [next_val_r]
  1429 00000B54 8A25[35200000]          	mov	ah, [previous_val_r]
  1430 00000B5A 00E0                    	add	al, ah
  1431 00000B5C D0D8                    	rcr	al, 1
  1432 00000B5E 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1433 00000B60 00E0                    	add	al, ah
  1434 00000B62 D0D8                    	rcr	al, 1
  1435 00000B64 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1436 00000B66 00E0                    	add	al, ah
  1437 00000B68 D0D8                    	rcr	al, 1
  1438 00000B6A 2C80                    	sub	al, 80h
  1439 00000B6C 66C1E008                	shl	ax, 8
  1440 00000B70 66AB                    	stosw		; this is 1st interpolated sample (R)
  1441 00000B72 88D8                    	mov	al, bl
  1442 00000B74 00D0                    	add	al, dl
  1443 00000B76 D0D8                    	rcr	al, 1
  1444 00000B78 2C80                    	sub	al, 80h
  1445 00000B7A 66C1E008                	shl	ax, 8
  1446 00000B7E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1447 00000B80 88F8                    	mov	al, bh
  1448 00000B82 00F0                    	add	al, dh
  1449 00000B84 D0D8                    	rcr	al, 1
  1450 00000B86 2C80                    	sub	al, 80h
  1451 00000B88 66C1E008                	shl	ax, 8
  1452 00000B8C 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1453 00000B8E 88D0                    	mov	al, dl
  1454 00000B90 2C80                    	sub	al, 80h
  1455 00000B92 66C1E008                	shl	ax, 8
  1456 00000B96 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1457 00000B98 88F0                    	mov	al, dh
  1458 00000B9A 2C80                    	sub	al, 80h
  1459 00000B9C 66C1E008                	shl	ax, 8
  1460 00000BA0 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1461 00000BA2 A0[37200000]            	mov	al, [next_val_l]
  1462 00000BA7 00D0                    	add	al, dl
  1463 00000BA9 D0D8                    	rcr	al, 1
  1464 00000BAB 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1465 00000BAD 00D0                    	add	al, dl
  1466 00000BAF D0D8                    	rcr	al, 1
  1467 00000BB1 2C80                    	sub	al, 80h
  1468 00000BB3 66C1E008                	shl	ax, 8
  1469 00000BB7 66AB                    	stosw		; this is 4th interpolated sample (L)
  1470 00000BB9 A0[39200000]            	mov	al, [next_val_r]
  1471 00000BBE 00F0                    	add	al, dh
  1472 00000BC0 D0D8                    	rcr	al, 1
  1473 00000BC2 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1474 00000BC4 00F0                    	add	al, dh
  1475 00000BC6 D0D8                    	rcr	al, 1
  1476 00000BC8 2C80                    	sub	al, 80h
  1477 00000BCA 66C1E008                	shl	ax, 8
  1478 00000BCE 66AB                    	stosw		; this is 4th interpolated sample (R)
  1479 00000BD0 A0[37200000]            	mov	al, [next_val_l]
  1480 00000BD5 00D8                    	add	al, bl
  1481 00000BD7 D0D8                    	rcr	al, 1
  1482 00000BD9 2C80                    	sub	al, 80h
  1483 00000BDB 66C1E008                	shl	ax, 8
  1484 00000BDF 66AB                    	stosw		; this is 5th interpolated sample (L)
  1485 00000BE1 A0[39200000]            	mov	al, [next_val_r]
  1486 00000BE6 00F8                    	add	al, bh
  1487 00000BE8 D0D8                    	rcr	al, 1
  1488 00000BEA 2C80                    	sub	al, 80h
  1489 00000BEC 66C1E008                	shl	ax, 8
  1490 00000BF0 66AB                    	stosw		; this is 5th interpolated sample (R)
  1491                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1492 00000BF2 E305                    	jecxz	lff8s_6
  1493 00000BF4 E907FFFFFF              	jmp	lff8s_1
  1494                                  lff8s_6:
  1495 00000BF9 E9ABFEFFFF              	jmp	lff8s_3
  1496                                  
  1497                                  load_8khz_mono_16_bit:
  1498                                  	; 13/11/2023
  1499 00000BFE F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1500                                  					; last of the file?
  1501 00000C05 7402                    	jz	short lff8m2_0		; no
  1502 00000C07 F9                      	stc
  1503 00000C08 C3                      	retn
  1504                                  
  1505                                  lff8m2_0:
  1506 00000C09 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1507                                          ;mov	edx, [loadsize]
  1508                                  
  1509                                  	; esi = buffer address
  1510                                  	;; edx = buffer size
  1511                                  
  1512                                  	; load file into memory
  1513                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000C0E 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000C14 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000C16 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000C1C B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000C21 CD40                <1>  int 40h
  1514 00000C23 0F82A0000000            	jc	lff8m2_7 ; error !
  1515                                  
  1516 00000C29 BF[00300000]            	mov	edi, audio_buffer
  1517                                  	
  1518 00000C2E D1E8                    	shr	eax, 1
  1519 00000C30 7505                    	jnz	short lff8m2_8
  1520 00000C32 E985FEFFFF              	jmp	lff8_eof
  1521                                  
  1522                                  lff8m2_8:
  1523 00000C37 89C1                    	mov	ecx, eax	; word count
  1524                                  lff8m2_1:
  1525 00000C39 66AD                    	lodsw
  1526 00000C3B 66AB                    	stosw		; original sample (left channel)
  1527 00000C3D 66AB                    	stosw		; original sample (right channel)
  1528 00000C3F 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1529 00000C42 66A3[33200000]          	mov	[previous_val], ax
  1530 00000C48 31C0                    	xor	eax, eax
  1531 00000C4A 49                      	dec	ecx
  1532 00000C4B 7403                    	jz	short lff8m2_2
  1533 00000C4D 668B06                  	mov	ax, [esi]
  1534                                  lff8m2_2:
  1535 00000C50 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1536 00000C53 89C5                    	mov	ebp, eax	; [next_val]
  1537 00000C55 660305[33200000]        	add	ax, [previous_val]
  1538 00000C5C 66D1D8                  	rcr	ax, 1
  1539 00000C5F 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1540 00000C61 660305[33200000]        	add	ax, [previous_val]
  1541 00000C68 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1542 00000C6B 89C3                    	mov	ebx, eax 		
  1543 00000C6D 660305[33200000]        	add	ax, [previous_val]
  1544 00000C74 66D1D8                  	rcr	ax, 1
  1545 00000C77 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1546 00000C7A 66AB                    	stosw		; this is 1st interpolated sample (L)
  1547 00000C7C 66AB                    	stosw		; this is 1st interpolated sample (R)
  1548 00000C7E 89D8                    	mov	eax, ebx
  1549 00000C80 6601D0                  	add	ax, dx
  1550 00000C83 66D1D8                  	rcr	ax, 1
  1551 00000C86 80EC80                  	sub	ah, 80h
  1552 00000C89 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1553 00000C8B 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1554 00000C8D 89D0                    	mov	eax, edx
  1555 00000C8F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1556 00000C92 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1557 00000C94 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1558 00000C96 89E8                    	mov	eax, ebp
  1559 00000C98 6601D0                  	add	ax, dx
  1560 00000C9B 66D1D8                  	rcr	ax, 1
  1561 00000C9E 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1562 00000CA0 6601D0                  	add	ax, dx
  1563 00000CA3 66D1D8                  	rcr	ax, 1
  1564 00000CA6 80EC80                  	sub	ah, 80h
  1565 00000CA9 66AB                    	stosw		; this is 4th interpolated sample (L)
  1566 00000CAB 66AB                    	stosw		; this is 4th interpolated sample (R)
  1567 00000CAD 89E8                    	mov	eax, ebp
  1568 00000CAF 6601D8                  	add	ax, bx
  1569 00000CB2 66D1D8                  	rcr	ax, 1
  1570 00000CB5 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1571 00000CB8 66AB                    	stosw		; this is 5th interpolated sample (L)
  1572 00000CBA 66AB                    	stosw		; this is 5th interpolated sample (R)
  1573                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1574 00000CBC 09C9                    	or	ecx, ecx
  1575 00000CBE 0F8575FFFFFF            	jnz	lff8m2_1
  1576 00000CC4 E9E0FDFFFF              	jmp	lff8m2_3
  1577                                  
  1578                                  lff8m2_7:
  1579                                  lff8s2_7:
  1580 00000CC9 E9F7FDFFFF              	jmp	lff8m2_5  ; error
  1581                                  
  1582                                  load_8khz_stereo_16_bit:
  1583                                  	; 16/11/2023
  1584                                  	; 15/11/2023
  1585                                  	; 13/11/2023
  1586 00000CCE F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1587                                  					; last of the file?
  1588 00000CD5 7402                    	jz	short lff8s2_0		; no
  1589 00000CD7 F9                      	stc
  1590 00000CD8 C3                      	retn
  1591                                  
  1592                                  lff8s2_0:
  1593 00000CD9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1594                                          ;mov	edx, [loadsize]
  1595                                  
  1596                                  	; esi = buffer address
  1597                                  	;; edx = buffer size
  1598                                  
  1599                                  	; load file into memory
  1600                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000CDE 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000CE4 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000CE6 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000CEC B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000CF1 CD40                <1>  int 40h
  1601 00000CF3 72D4                    	jc	short lff8s2_7 ; error !
  1602                                  
  1603 00000CF5 BF[00300000]            	mov	edi, audio_buffer
  1604                                  	
  1605 00000CFA C1E802                  	shr	eax, 2
  1606 00000CFD 7505                    	jnz	short lff8s2_8
  1607 00000CFF E9B8FDFFFF              	jmp	lff8_eof
  1608                                  
  1609                                  lff8s2_8:
  1610 00000D04 89C1                    	mov	ecx, eax ; dword count
  1611                                  lff8s2_1:
  1612 00000D06 66AD                    	lodsw
  1613 00000D08 66AB                    	stosw		; original sample (L)
  1614                                  	; 15/11/2023
  1615 00000D0A 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1616 00000D0D 66A3[33200000]          	mov	[previous_val_l], ax
  1617 00000D13 66AD                    	lodsw
  1618 00000D15 66AB                    	stosw		; original sample (R)
  1619 00000D17 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1620 00000D1A 66A3[35200000]          	mov	[previous_val_r], ax
  1621 00000D20 31D2                    	xor	edx, edx
  1622 00000D22 31C0                    	xor	eax, eax
  1623                                  	; 16/11/2023
  1624 00000D24 49                      	dec	ecx
  1625 00000D25 7407                    	jz	short lff8s2_2
  1626 00000D27 668B06                  	mov	ax, [esi]
  1627 00000D2A 668B5602                	mov	dx, [esi+2]
  1628                                  lff8s2_2:
  1629 00000D2E 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1630 00000D31 66A3[37200000]          	mov	[next_val_l], ax
  1631 00000D37 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1632 00000D3A 668915[39200000]        	mov	[next_val_r], dx
  1633 00000D41 660305[33200000]        	add	ax, [previous_val_l]
  1634 00000D48 66D1D8                  	rcr	ax, 1
  1635 00000D4B 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1636 00000D4D 660305[33200000]        	add	ax, [previous_val_l]
  1637 00000D54 66D1D8                  	rcr	ax, 1	
  1638 00000D57 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1639 00000D59 660305[33200000]        	add	ax, [previous_val_l]
  1640 00000D60 66D1D8                  	rcr	ax, 1
  1641 00000D63 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1642 00000D66 66AB                    	stosw		; this is 1st interpolated sample (L)
  1643 00000D68 66A1[39200000]          	mov	ax, [next_val_r]
  1644 00000D6E 660305[35200000]        	add	ax, [previous_val_r]
  1645 00000D75 66D1D8                  	rcr	ax, 1
  1646 00000D78 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1647 00000D7A 660305[35200000]        	add	ax, [previous_val_r]
  1648 00000D81 66D1D8                  	rcr	ax, 1
  1649 00000D84 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1650 00000D85 660305[35200000]        	add	ax, [previous_val_r]
  1651 00000D8C 66D1D8                  	rcr	ax, 1
  1652 00000D8F 80EC80                  	sub	ah, 80h
  1653 00000D92 66AB                    	stosw		; this is 1st interpolated sample (R)
  1654 00000D94 89D8                    	mov	eax, ebx
  1655 00000D96 6601D0                  	add	ax, dx
  1656 00000D99 66D1D8                  	rcr	ax, 1
  1657 00000D9C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1658 00000D9F 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1659 00000DA1 58                      	pop	eax ; *
  1660 00000DA2 6601E8                  	add	ax, bp
  1661 00000DA5 66D1D8                  	rcr	ax, 1
  1662 00000DA8 80EC80                  	sub	ah, 80h
  1663 00000DAB 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1664 00000DAD 89D0                    	mov	eax, edx
  1665 00000DAF 80EC80                  	sub	ah, 80h
  1666 00000DB2 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1667 00000DB4 89E8                    	mov	eax, ebp
  1668 00000DB6 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1669 00000DB9 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1670 00000DBB 66A1[37200000]          	mov	ax, [next_val_l]
  1671 00000DC1 6601D0                  	add	ax, dx
  1672 00000DC4 66D1D8                  	rcr	ax, 1
  1673 00000DC7 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1674 00000DC9 6601D0                  	add	ax, dx
  1675 00000DCC 66D1D8                  	rcr	ax, 1
  1676 00000DCF 80EC80                  	sub	ah, 80h
  1677 00000DD2 66AB                    	stosw		; this is 4th interpolated sample (L)
  1678 00000DD4 66A1[39200000]          	mov	ax, [next_val_r]
  1679 00000DDA 6601E8                  	add	ax, bp
  1680 00000DDD 66D1D8                  	rcr	ax, 1
  1681 00000DE0 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1682 00000DE1 6601E8                  	add	ax, bp
  1683 00000DE4 66D1D8                  	rcr	ax, 1
  1684 00000DE7 80EC80                  	sub	ah, 80h
  1685 00000DEA 66AB                    	stosw		; this is 4th interpolated sample (R)
  1686 00000DEC 66A1[37200000]          	mov	ax, [next_val_l]
  1687 00000DF2 6601D8                  	add	ax, bx
  1688 00000DF5 66D1D8                  	rcr	ax, 1
  1689 00000DF8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1690 00000DFB 66AB                    	stosw		; this is 5th interpolated sample (L)
  1691 00000DFD 58                      	pop	eax ; **
  1692 00000DFE 660305[39200000]        	add	ax, [next_val_r]
  1693 00000E05 66D1D8                  	rcr	ax, 1
  1694 00000E08 80EC80                  	sub	ah, 80h
  1695 00000E0B 66AB                    	stosw		; this is 5th interpolated sample (R)
  1696                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1697 00000E0D E305                    	jecxz	lff8_s2_9
  1698 00000E0F E9F2FEFFFF              	jmp	lff8s2_1
  1699                                  lff8_s2_9:
  1700 00000E14 E990FCFFFF              	jmp	lff8s2_3
  1701                                  
  1702                                  ; .....................
  1703                                  
  1704                                  load_16khz_mono_8_bit:
  1705                                  	; 14/11/2023
  1706                                  	; 13/11/2023
  1707 00000E19 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1708                                  					; last of the file?
  1709 00000E20 7402                    	jz	short lff16m_0		; no
  1710 00000E22 F9                      	stc
  1711 00000E23 C3                      	retn
  1712                                  
  1713                                  lff16m_0:
  1714 00000E24 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1715                                          ;mov	edx, [loadsize]
  1716                                  
  1717                                  	; esi = buffer address
  1718                                  	;; edx = buffer size
  1719                                  
  1720                                  	; load file into memory
  1721                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000E29 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000E2F 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000E31 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000E37 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000E3C CD40                <1>  int 40h
  1722 00000E3E 7253                    	jc	short lff16m_7 ; error !
  1723                                  
  1724 00000E40 BF[00300000]            	mov	edi, audio_buffer
  1725                                  	
  1726 00000E45 21C0                    	and	eax, eax
  1727 00000E47 7505                    	jnz	short lff16m_8
  1728 00000E49 E96EFCFFFF              	jmp	lff16_eof
  1729                                  
  1730                                  lff16m_8:
  1731 00000E4E 89C1                    	mov	ecx, eax		; byte count
  1732                                  lff16m_1:
  1733 00000E50 AC                      	lodsb
  1734                                  	;mov	[previous_val], al
  1735 00000E51 88C3                    	mov	bl, al
  1736 00000E53 2C80                    	sub	al, 80h
  1737 00000E55 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1738 00000E59 66AB                    	stosw		; original sample (left channel)
  1739 00000E5B 66AB                    	stosw		; original sample (right channel)
  1740                                  	;xor	ax, ax
  1741                                  	; 14/11/22023
  1742 00000E5D B080                    	mov	al, 80h
  1743 00000E5F 49                      	dec	ecx
  1744 00000E60 7402                    	jz	short lff16m_2
  1745 00000E62 8A06                    	mov	al, [esi]
  1746                                  lff16m_2:
  1747                                  	;mov	[next_val], al
  1748 00000E64 88C7                    	mov	bh, al
  1749                                  	;add	al, [previous_val]
  1750 00000E66 00D8                    	add	al, bl
  1751 00000E68 D0D8                    	rcr	al, 1
  1752 00000E6A 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1753                                  	;add	al, [previous_val]
  1754 00000E6C 00D8                    	add	al, bl
  1755 00000E6E D0D8                    	rcr	al, 1
  1756 00000E70 2C80                    	sub	al, 80h
  1757 00000E72 66C1E008                	shl	ax, 8
  1758 00000E76 66AB                    	stosw		; this is 1st interpolated sample (L)
  1759 00000E78 66AB                    	stosw		; this is 1st interpolated sample (R)
  1760                                  	;mov	al, [next_val]
  1761 00000E7A 88F8                    	mov	al, bh
  1762 00000E7C 00D0                    	add	al, dl
  1763 00000E7E D0D8                    	rcr	al, 1
  1764 00000E80 2C80                    	sub	al, 80h
  1765 00000E82 66C1E008                	shl	ax, 8
  1766 00000E86 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1767 00000E88 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1768                                  	
  1769                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1770 00000E8A 09C9                    	or	ecx, ecx
  1771 00000E8C 75C2                    	jnz	short lff16m_1
  1772 00000E8E E916FCFFFF              	jmp	lff16m_3
  1773                                  
  1774                                  lff16m_7:
  1775                                  lff16s_7:
  1776 00000E93 E92DFCFFFF              	jmp	lff16m_5  ; error
  1777                                  
  1778                                  load_16khz_stereo_8_bit:
  1779                                  	; 14/11/2023
  1780                                  	; 13/11/2023
  1781 00000E98 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1782                                  					; last of the file?
  1783 00000E9F 7402                    	jz	short lff16s_0		; no
  1784 00000EA1 F9                      	stc
  1785 00000EA2 C3                      	retn
  1786                                  
  1787                                  lff16s_0:
  1788 00000EA3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1789                                          ;mov	edx, [loadsize]
  1790                                  
  1791                                  	; esi = buffer address
  1792                                  	;; edx = buffer size
  1793                                  
  1794                                  	; load file into memory
  1795                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000EA8 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000EAE 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000EB0 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000EB6 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000EBB CD40                <1>  int 40h
  1796 00000EBD 72D4                    	jc	short lff16s_7 ; error !
  1797                                  
  1798 00000EBF BF[00300000]            	mov	edi, audio_buffer
  1799                                  	
  1800 00000EC4 D1E8                    	shr	eax, 1
  1801 00000EC6 7505                    	jnz	short lff16s_8
  1802 00000EC8 E9EFFBFFFF              	jmp	lff16_eof
  1803                                  
  1804                                  lff16s_8:
  1805 00000ECD 89C1                    	mov	ecx, eax	; word count
  1806                                  lff16s_1:
  1807 00000ECF AC                      	lodsb
  1808 00000ED0 A2[33200000]            	mov	[previous_val_l], al
  1809 00000ED5 2C80                    	sub	al, 80h
  1810 00000ED7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1811 00000EDB 66AB                    	stosw		; original sample (L)
  1812 00000EDD AC                      	lodsb
  1813 00000EDE A2[35200000]            	mov	[previous_val_r], al
  1814 00000EE3 2C80                    	sub	al, 80h
  1815 00000EE5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1816 00000EE9 66AB                    	stosw		; original sample (R)
  1817                                  
  1818                                  	;xor	eax, eax
  1819 00000EEB 66B88080                	mov	ax, 8080h
  1820 00000EEF 49                      	dec	ecx
  1821 00000EF0 7403                    	jz	short lff16s_2
  1822                                  		; convert 8 bit sample to 16 bit sample
  1823 00000EF2 668B06                  	mov	ax, [esi]
  1824                                  lff16s_2:
  1825                                  	;mov	[next_val_l], al
  1826                                  	;mov	[next_val_r], ah
  1827 00000EF5 89C3                    	mov	ebx, eax
  1828 00000EF7 0205[33200000]          	add	al, [previous_val_l]
  1829 00000EFD D0D8                    	rcr	al, 1
  1830 00000EFF 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  1831 00000F01 0205[33200000]          	add	al, [previous_val_l]
  1832 00000F07 D0D8                    	rcr	al, 1
  1833 00000F09 2C80                    	sub	al, 80h
  1834 00000F0B 66C1E008                	shl	ax, 8
  1835 00000F0F 66AB                    	stosw		; this is 1st interpolated sample (L)
  1836 00000F11 88F8                    	mov	al, bh	; [next_val_r]
  1837 00000F13 0205[35200000]          	add	al, [previous_val_r]
  1838 00000F19 D0D8                    	rcr	al, 1
  1839 00000F1B 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  1840 00000F1D 0205[35200000]          	add	al, [previous_val_r]
  1841 00000F23 D0D8                    	rcr	al, 1
  1842 00000F25 2C80                    	sub	al, 80h
  1843 00000F27 66C1E008                	shl	ax, 8
  1844 00000F2B 66AB                    	stosw		; this is 1st interpolated sample (R)
  1845 00000F2D 88D0                    	mov	al, dl
  1846 00000F2F 00D8                    	add	al, bl	; [next_val_l]
  1847 00000F31 D0D8                    	rcr	al, 1
  1848 00000F33 2C80                    	sub	al, 80h
  1849 00000F35 66C1E008                	shl	ax, 8
  1850 00000F39 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1851 00000F3B 88F0                    	mov	al, dh
  1852 00000F3D 00F8                    	add	al, bh	; [next_val_r]
  1853 00000F3F D0D8                    	rcr	al, 1
  1854 00000F41 2C80                    	sub	al, 80h
  1855 00000F43 66C1E008                	shl	ax, 8
  1856 00000F47 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1857                                  	
  1858                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1859 00000F49 09C9                    	or	ecx, ecx
  1860 00000F4B 7582                    	jnz	short lff16s_1
  1861 00000F4D E957FBFFFF              	jmp	lff16s_3
  1862                                  
  1863                                  load_16khz_mono_16_bit:
  1864                                  	; 15/11/2023
  1865                                  	; 13/11/2023
  1866 00000F52 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1867                                  					; last of the file?
  1868 00000F59 7402                    	jz	short lff16m2_0		; no
  1869 00000F5B F9                      	stc
  1870 00000F5C C3                      	retn
  1871                                  
  1872                                  lff16m2_0:
  1873 00000F5D BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1874                                          ;mov	edx, [loadsize]
  1875                                  
  1876                                  	; esi = buffer address
  1877                                  	;; edx = buffer size
  1878                                  
  1879                                  	; load file into memory
  1880                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000F62 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000F68 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000F6A 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000F70 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000F75 CD40                <1>  int 40h
  1881 00000F77 7255                    	jc	short lff16m2_7 ; error !
  1882                                  
  1883 00000F79 BF[00300000]            	mov	edi, audio_buffer
  1884                                  	
  1885 00000F7E D1E8                    	shr	eax, 1
  1886 00000F80 7505                    	jnz	short lff16m2_8
  1887 00000F82 E935FBFFFF              	jmp	lff16_eof
  1888                                  
  1889                                  lff16m2_8:
  1890 00000F87 89C1                    	mov	ecx, eax  ; word count
  1891                                  lff16m2_1:
  1892 00000F89 66AD                    	lodsw
  1893 00000F8B 66AB                    	stosw		; original sample (left channel)
  1894 00000F8D 66AB                    	stosw		; original sample (right channel)
  1895 00000F8F 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1896                                  	;mov	[previous_val], ax
  1897 00000F92 89C3                    	mov	ebx, eax	
  1898 00000F94 31C0                    	xor	eax, eax
  1899 00000F96 49                      	dec	ecx
  1900 00000F97 7403                    	jz	short lff16m2_2
  1901 00000F99 668B06                  	mov	ax, [esi]
  1902                                  lff16m2_2:
  1903 00000F9C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1904 00000F9F 89C5                    	mov	ebp, eax	; [next_val]
  1905                                  	;add	ax, [previous_val]
  1906 00000FA1 6601D8                  	add	ax, bx
  1907 00000FA4 66D1D8                  	rcr	ax, 1
  1908 00000FA7 89C2                    	mov	edx, eax ; this is temporary interpolation value
  1909                                  	;add	ax, [previous_val]
  1910 00000FA9 6601D8                  	add	ax, bx
  1911 00000FAC 66D1D8                  	rcr	ax, 1
  1912 00000FAF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1913 00000FB2 66AB                    	stosw		; this is 1st interpolated sample (L)
  1914 00000FB4 66AB                    	stosw		; this is 1st interpolated sample (R)
  1915 00000FB6 89E8                    	mov	eax, ebp 
  1916 00000FB8 6601D0                  	add	ax, dx
  1917 00000FBB 66D1D8                  	rcr	ax, 1
  1918 00000FBE 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1919 00000FC1 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1920 00000FC3 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1921                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1922 00000FC5 09C9                    	or	ecx, ecx
  1923 00000FC7 75C0                    	jnz	short lff16m2_1
  1924 00000FC9 E9DBFAFFFF              	jmp	lff16m2_3
  1925                                  
  1926                                  lff16m2_7:
  1927                                  lff16s2_7:
  1928 00000FCE E9F2FAFFFF              	jmp	lff16m2_5  ; error
  1929                                  
  1930                                  load_16khz_stereo_16_bit:
  1931                                  	; 16/11/2023
  1932                                  	; 15/11/2023
  1933                                  	; 13/11/2023
  1934 00000FD3 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1935                                  					; last of the file?
  1936 00000FDA 7402                    	jz	short lff16s2_0		; no
  1937 00000FDC F9                      	stc
  1938 00000FDD C3                      	retn
  1939                                  
  1940                                  lff16s2_0:
  1941 00000FDE BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1942                                          ;mov	edx, [loadsize]
  1943                                  
  1944                                  	; esi = buffer address
  1945                                  	;; edx = buffer size
  1946                                  
  1947                                  	; load file into memory
  1948                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000FE3 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000FE9 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000FEB 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000FF1 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000FF6 CD40                <1>  int 40h
  1949 00000FF8 72D4                    	jc	short lff16s2_7 ; error !
  1950                                  
  1951 00000FFA BF[00300000]            	mov	edi, audio_buffer
  1952                                  	
  1953 00000FFF C1E802                  	shr	eax, 2
  1954 00001002 7505                    	jnz	short lff16s2_8
  1955 00001004 E9B3FAFFFF              	jmp	lff16_eof
  1956                                  
  1957                                  lff16s2_8:
  1958 00001009 89C1                    	mov	ecx, eax  ; dword count
  1959                                  lff16s2_1:
  1960 0000100B 66AD                    	lodsw
  1961 0000100D 66AB                    	stosw		; original sample (L)
  1962 0000100F 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1963 00001012 66A3[33200000]          	mov	[previous_val_l], ax
  1964 00001018 66AD                    	lodsw
  1965 0000101A 66AB                    	stosw		; original sample (R)
  1966 0000101C 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1967 0000101F 66A3[35200000]          	mov	[previous_val_r], ax
  1968 00001025 31D2                    	xor	edx, edx
  1969 00001027 31C0                    	xor	eax, eax
  1970                                  	; 16/11/2023
  1971 00001029 49                      	dec	ecx
  1972 0000102A 7407                    	jz	short lff16s2_2
  1973 0000102C 668B06                  	mov	ax, [esi]
  1974 0000102F 668B5602                	mov	dx, [esi+2]
  1975                                  lff16s2_2:
  1976 00001033 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1977                                  	;mov	[next_val_l], ax
  1978 00001036 89C5                    	mov	ebp, eax
  1979 00001038 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  1980 0000103B 668915[39200000]        	mov	[next_val_r], dx
  1981 00001042 660305[33200000]        	add	ax, [previous_val_l]
  1982 00001049 66D1D8                  	rcr	ax, 1
  1983 0000104C 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  1984 0000104E 660305[33200000]        	add	ax, [previous_val_l]
  1985 00001055 66D1D8                  	rcr	ax, 1
  1986 00001058 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  1987 0000105B 66AB                    	stosw		; this is 1st interpolated sample (L)
  1988 0000105D 66A1[39200000]          	mov	ax, [next_val_r]
  1989 00001063 660305[35200000]        	add	ax, [previous_val_r]
  1990 0000106A 66D1D8                  	rcr	ax, 1
  1991 0000106D 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  1992 0000106F 660305[35200000]        	add	ax, [previous_val_r]
  1993 00001076 66D1D8                  	rcr	ax, 1
  1994 00001079 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1995 0000107C 66AB                    	stosw		; this is 1st interpolated sample (R)
  1996                                  	;mov	ax, [next_val_l]
  1997 0000107E 89E8                    	mov	eax, ebp
  1998 00001080 6601D0                  	add	ax, dx
  1999 00001083 66D1D8                  	rcr	ax, 1
  2000 00001086 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2001 00001089 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2002 0000108B 66A1[39200000]          	mov	ax, [next_val_r]
  2003 00001091 6601D8                  	add	ax, bx
  2004 00001094 66D1D8                  	rcr	ax, 1
  2005 00001097 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2006 0000109A 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2007                                  	
  2008                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2009 0000109C 09C9                    	or	ecx, ecx
  2010 0000109E 0F8567FFFFFF            	jnz	lff16s2_1
  2011 000010A4 E900FAFFFF              	jmp	lff16s2_3
  2012                                  
  2013                                  ; .....................
  2014                                  
  2015                                  load_24khz_mono_8_bit:
  2016                                  	; 15/11/2023
  2017 000010A9 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2018                                  					; last of the file?
  2019 000010B0 7402                    	jz	short lff24m_0		; no
  2020 000010B2 F9                      	stc
  2021 000010B3 C3                      	retn
  2022                                  
  2023                                  lff24m_0:
  2024 000010B4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2025                                          ;mov	edx, [loadsize]
  2026                                  
  2027                                  	; esi = buffer address
  2028                                  	;; edx = buffer size
  2029                                  
  2030                                  	; load file into memory
  2031                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000010B9 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000010BF 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000010C1 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000010C7 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000010CC CD40                <1>  int 40h
  2032 000010CE 723B                    	jc	short lff24m_7 ; error !
  2033                                  
  2034 000010D0 BF[00300000]            	mov	edi, audio_buffer
  2035                                  	
  2036 000010D5 21C0                    	and	eax, eax
  2037 000010D7 7505                    	jnz	short lff24m_8
  2038 000010D9 E9DEF9FFFF              	jmp	lff24_eof
  2039                                  
  2040                                  lff24m_8:
  2041 000010DE 89C1                    	mov	ecx, eax	; byte count
  2042                                  lff24m_1:
  2043 000010E0 AC                      	lodsb
  2044                                  	;mov	[previous_val], al
  2045 000010E1 88C3                    	mov	bl, al
  2046 000010E3 2C80                    	sub	al, 80h
  2047 000010E5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2048 000010E9 66AB                    	stosw		; original sample (left channel)
  2049 000010EB 66AB                    	stosw		; original sample (right channel)
  2050                                  	;xor	eax, eax
  2051 000010ED B080                    	mov	al, 80h
  2052 000010EF 49                      	dec	ecx
  2053 000010F0 7402                    	jz	short lff24m_2
  2054 000010F2 8A06                    	mov	al, [esi]
  2055                                  lff24m_2:
  2056                                  	;;mov	[next_val], al
  2057                                  	;mov	bh, al
  2058                                  	;add	al, [previous_val]
  2059 000010F4 00D8                    	add	al, bl
  2060 000010F6 D0D8                    	rcr	al, 1
  2061 000010F8 2C80                    	sub	al, 80h
  2062 000010FA 66C1E008                	shl	ax, 8
  2063 000010FE 66AB                    	stosw		; this is interpolated sample (L)
  2064 00001100 66AB                    	stosw		; this is interpolated sample (R)
  2065                                  	
  2066                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2067 00001102 09C9                    	or	ecx, ecx
  2068 00001104 75DA                    	jnz	short lff24m_1
  2069 00001106 E99EF9FFFF              	jmp	lff24_3
  2070                                  
  2071                                  lff24m_7:
  2072                                  lff24s_7:
  2073 0000110B E9B5F9FFFF              	jmp	lff24_5  ; error
  2074                                  
  2075                                  load_24khz_stereo_8_bit:
  2076                                  	; 15/11/2023
  2077 00001110 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2078                                  					; last of the file?
  2079 00001117 7402                    	jz	short lff24s_0		; no
  2080 00001119 F9                      	stc
  2081 0000111A C3                      	retn
  2082                                  
  2083                                  lff24s_0:
  2084 0000111B BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2085                                          ;mov	edx, [loadsize]
  2086                                  
  2087                                  	; esi = buffer address
  2088                                  	;; edx = buffer size
  2089                                  
  2090                                  	; load file into memory
  2091                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001120 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001126 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001128 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000112E B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001133 CD40                <1>  int 40h
  2092 00001135 72D4                    	jc	short lff24s_7 ; error !
  2093                                  
  2094 00001137 BF[00300000]            	mov	edi, audio_buffer
  2095                                  	
  2096 0000113C D1E8                    	shr	eax, 1
  2097 0000113E 7505                    	jnz	short lff24s_8
  2098 00001140 E977F9FFFF              	jmp	lff24_eof
  2099                                  
  2100                                  lff24s_8:
  2101 00001145 89C1                    	mov	ecx, eax  ; word count
  2102                                  lff24s_1:
  2103 00001147 AC                      	lodsb
  2104 00001148 A2[33200000]            	mov	[previous_val_l], al
  2105 0000114D 2C80                    	sub	al, 80h
  2106 0000114F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2107 00001153 66AB                    	stosw		; original sample (L)
  2108 00001155 AC                      	lodsb
  2109 00001156 A2[35200000]            	mov	[previous_val_r], al
  2110 0000115B 2C80                    	sub	al, 80h
  2111 0000115D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2112 00001161 66AB                    	stosw		; original sample (R)
  2113                                  
  2114                                  	;xor	eax, eax
  2115 00001163 66B88080                	mov	ax, 8080h
  2116 00001167 49                      	dec	ecx
  2117 00001168 7403                    	jz	short lff24s_2
  2118                                  		; convert 8 bit sample to 16 bit sample
  2119 0000116A 668B06                  	mov	ax, [esi]
  2120                                  lff24s_2:
  2121                                  	;;mov	[next_val_l], al
  2122                                  	;;mov	[next_val_r], ah
  2123                                  	;mov	bx, ax
  2124 0000116D 88E7                    	mov	bh, ah
  2125 0000116F 0205[33200000]          	add	al, [previous_val_l]
  2126 00001175 D0D8                    	rcr	al, 1
  2127                                  	;mov	dl, al
  2128 00001177 2C80                    	sub	al, 80h
  2129 00001179 66C1E008                	shl	ax, 8
  2130 0000117D 66AB                    	stosw		; this is interpolated sample (L)
  2131 0000117F 88F8                    	mov	al, bh	; [next_val_r]
  2132 00001181 0205[35200000]          	add	al, [previous_val_r]
  2133 00001187 D0D8                    	rcr	al, 1
  2134                                  	;mov	dh, al
  2135 00001189 2C80                    	sub	al, 80h
  2136 0000118B 66C1E008                	shl	ax, 8
  2137 0000118F 66AB                    	stosw		; this is interpolated sample (R)
  2138                                  		
  2139                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2140 00001191 09C9                    	or	ecx, ecx
  2141 00001193 75B2                    	jnz	short lff24s_1
  2142 00001195 E90FF9FFFF              	jmp	lff24_3
  2143                                  
  2144                                  load_24khz_mono_16_bit:
  2145                                  	; 15/11/2023
  2146 0000119A F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2147                                  					; last of the file?
  2148 000011A1 7402                    	jz	short lff24m2_0		; no
  2149 000011A3 F9                      	stc
  2150 000011A4 C3                      	retn
  2151                                  
  2152                                  lff24m2_0:
  2153 000011A5 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2154                                          ;mov	edx, [loadsize]
  2155                                  
  2156                                  	; esi = buffer address
  2157                                  	;; edx = buffer size
  2158                                  
  2159                                  	; load file into memory
  2160                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000011AA 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000011B0 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000011B2 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000011B8 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000011BD CD40                <1>  int 40h
  2161 000011BF 7237                    	jc	short lff24m2_7 ; error !
  2162                                  
  2163 000011C1 BF[00300000]            	mov	edi, audio_buffer
  2164                                  	
  2165 000011C6 D1E8                    	shr	eax, 1
  2166 000011C8 7505                    	jnz	short lff24m2_8
  2167 000011CA E9EDF8FFFF              	jmp	lff24_eof
  2168                                  
  2169                                  lff24m2_8:
  2170 000011CF 89C1                    	mov	ecx, eax  ; word count
  2171                                  lff24m2_1:
  2172 000011D1 66AD                    	lodsw
  2173 000011D3 66AB                    	stosw		; original sample (left channel)
  2174 000011D5 66AB                    	stosw		; original sample (right channel)
  2175 000011D7 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2176                                  	;mov	[previous_val], ax
  2177                                  	;mov	ebx, eax	
  2178                                  	;xor	eax, eax
  2179 000011DA 31DB                    	xor	ebx, ebx
  2180 000011DC 49                      	dec	ecx
  2181 000011DD 7403                    	jz	short lff24m2_2
  2182                                  	;mov	ax, [esi]
  2183 000011DF 668B1E                  	mov	bx, [esi]
  2184                                  lff24m2_2:
  2185                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2186                                  	;mov	ebp, eax	; [next_val]
  2187                                  	;add	ax, [previous_val]
  2188                                  	; ax = [previous_val]
  2189                                  	; bx = [next_val]
  2190 000011E2 6601D8                  	add	ax, bx
  2191 000011E5 66D1D8                  	rcr	ax, 1
  2192 000011E8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2193 000011EB 66AB                    	stosw		; this is interpolated sample (L)
  2194 000011ED 66AB                    	stosw		; this is interpolated sample (R)
  2195                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2196 000011EF 09C9                    	or	ecx, ecx
  2197 000011F1 75DE                    	jnz	short lff24m2_1
  2198 000011F3 E9B1F8FFFF              	jmp	lff24_3
  2199                                  
  2200                                  lff24m2_7:
  2201                                  lff24s2_7:
  2202 000011F8 E9C8F8FFFF              	jmp	lff24_5  ; error
  2203                                  
  2204                                  load_24khz_stereo_16_bit:
  2205                                  	; 16/11/2023
  2206                                  	; 15/11/2023
  2207 000011FD F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2208                                  					; last of the file?
  2209 00001204 7402                    	jz	short lff24s2_0		; no
  2210 00001206 F9                      	stc
  2211 00001207 C3                      	retn
  2212                                  
  2213                                  lff24s2_0:
  2214 00001208 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2215                                          ;mov	edx, [loadsize]
  2216                                  
  2217                                  	; esi = buffer address
  2218                                  	;; edx = buffer size
  2219                                  
  2220                                  	; load file into memory
  2221                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000120D 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001213 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001215 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000121B B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001220 CD40                <1>  int 40h
  2222 00001222 72D4                    	jc	short lff24s2_7 ; error !
  2223                                  
  2224 00001224 BF[00300000]            	mov	edi, audio_buffer
  2225                                  	
  2226 00001229 C1E802                  	shr	eax, 2
  2227 0000122C 7505                    	jnz	short lff24s2_8
  2228 0000122E E989F8FFFF              	jmp	lff24_eof
  2229                                  
  2230                                  lff24s2_8:
  2231 00001233 89C1                    	mov	ecx, eax  ; dword count
  2232                                  lff24s2_1:
  2233 00001235 66AD                    	lodsw
  2234 00001237 66AB                    	stosw		; original sample (L)
  2235 00001239 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2236 0000123C 66A3[33200000]          	mov	[previous_val_l], ax
  2237 00001242 66AD                    	lodsw
  2238 00001244 66AB                    	stosw		; original sample (R)
  2239 00001246 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2240                                  	;mov	[previous_val_r], ax
  2241 00001249 89C3                    	mov	ebx, eax
  2242 0000124B 31D2                    	xor	edx, edx
  2243 0000124D 31C0                    	xor	eax, eax
  2244                                  	; 16/11/2023
  2245 0000124F 49                      	dec	ecx
  2246 00001250 7407                    	jz	short lff24s2_2
  2247 00001252 668B06                  	mov	ax, [esi]
  2248 00001255 668B5602                	mov	dx, [esi+2]
  2249                                  lff24s2_2:
  2250 00001259 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2251                                  	;;mov	[next_val_l], ax
  2252                                  	;mov	ebp, eax
  2253 0000125C 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2254                                  	;mov	[next_val_r], dx
  2255 0000125F 660305[33200000]        	add	ax, [previous_val_l]
  2256 00001266 66D1D8                  	rcr	ax, 1
  2257 00001269 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2258 0000126C 66AB                    	stosw		; this is interpolated sample (L)
  2259                                  	;mov	ax, [next_val_r]
  2260 0000126E 89D0                    	mov	eax, edx
  2261                                  	;add	ax, [previous_val_r]
  2262 00001270 6601D8                  	add	ax, bx
  2263 00001273 66D1D8                  	rcr	ax, 1
  2264 00001276 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2265 00001279 66AB                    	stosw		; this is interpolated sample (R)
  2266                                  	
  2267                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2268 0000127B 09C9                    	or	ecx, ecx
  2269 0000127D 75B6                    	jnz	short lff24s2_1
  2270 0000127F E925F8FFFF              	jmp	lff24_3
  2271                                  
  2272                                  ; .....................
  2273                                  
  2274                                  load_32khz_mono_8_bit:
  2275                                  	; 15/11/2023
  2276 00001284 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2277                                  					; last of the file?
  2278 0000128B 7402                    	jz	short lff32m_0		; no
  2279 0000128D F9                      	stc
  2280 0000128E C3                      	retn
  2281                                  
  2282                                  lff32m_0:
  2283 0000128F BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2284                                          ;mov	edx, [loadsize]
  2285                                  
  2286                                  	; esi = buffer address
  2287                                  	;; edx = buffer size
  2288                                  
  2289                                  	; load file into memory
  2290                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001294 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000129A 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000129C 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000012A2 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000012A7 CD40                <1>  int 40h
  2291 000012A9 7247                    	jc	short lff32m_7 ; error !
  2292                                  
  2293 000012AB BF[00300000]            	mov	edi, audio_buffer
  2294                                  	
  2295 000012B0 21C0                    	and	eax, eax
  2296 000012B2 7505                    	jnz	short lff32m_8
  2297 000012B4 E903F8FFFF              	jmp	lff32_eof
  2298                                  
  2299                                  lff32m_8:
  2300 000012B9 89C1                    	mov	ecx, eax	; byte count
  2301                                  lff32m_1:
  2302 000012BB AC                      	lodsb
  2303                                  	;mov	[previous_val], al
  2304 000012BC 88C3                    	mov	bl, al
  2305 000012BE 2C80                    	sub	al, 80h
  2306 000012C0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2307 000012C4 66AB                    	stosw		; original sample (left channel)
  2308 000012C6 66AB                    	stosw		; original sample (right channel)
  2309                                  	;xor	eax, eax
  2310 000012C8 B080                    	mov	al, 80h
  2311 000012CA 49                      	dec	ecx
  2312 000012CB 7402                    	jz	short lff32m_2
  2313 000012CD 8A06                    	mov	al, [esi]
  2314                                  lff32m_2:
  2315                                  	;;mov	[next_val], al
  2316                                  	;mov	bh, al
  2317                                  	;add	al, [previous_val]
  2318 000012CF 00D8                    	add	al, bl
  2319 000012D1 D0D8                    	rcr	al, 1
  2320 000012D3 2C80                    	sub	al, 80h
  2321 000012D5 66C1E008                	shl	ax, 8
  2322 000012D9 66AB                    	stosw		; this is interpolated sample (L)
  2323 000012DB 66AB                    	stosw		; this is interpolated sample (R)
  2324                                  	
  2325                                  	; different than 8-16-24 kHZ !
  2326                                  	; 'original-interpolated-original' trio samples 
  2327 000012DD E30E                    	jecxz	lff32m_3
  2328                                  
  2329 000012DF AC                      	lodsb
  2330 000012E0 2C80                    	sub	al, 80h
  2331 000012E2 66C1E008                	shl	ax, 8
  2332 000012E6 66AB                    	stosw		; original sample (left channel)
  2333 000012E8 66AB                    	stosw		; original sample (right channel)
  2334                                  
  2335                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2336 000012EA 49                      	dec	ecx
  2337 000012EB 75CE                    	jnz	short lff32m_1
  2338                                  lff32m_3:
  2339 000012ED E9B7F7FFFF              	jmp	lff32_3
  2340                                  
  2341                                  lff32m_7:
  2342                                  lff32s_7:
  2343 000012F2 E9CEF7FFFF              	jmp	lff32_5  ; error
  2344                                  
  2345                                  load_32khz_stereo_8_bit:
  2346                                  	; 15/11/2023
  2347 000012F7 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2348                                  					; last of the file?
  2349 000012FE 7402                    	jz	short lff32s_0		; no
  2350 00001300 F9                      	stc
  2351 00001301 C3                      	retn
  2352                                  
  2353                                  lff32s_0:
  2354 00001302 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2355                                          ;mov	edx, [loadsize]
  2356                                  
  2357                                  	; esi = buffer address
  2358                                  	;; edx = buffer size
  2359                                  
  2360                                  	; load file into memory
  2361                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001307 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000130D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000130F 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001315 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000131A CD40                <1>  int 40h
  2362 0000131C 72D4                    	jc	short lff32s_7 ; error !
  2363                                  
  2364 0000131E BF[00300000]            	mov	edi, audio_buffer
  2365                                  	
  2366 00001323 D1E8                    	shr	eax, 1
  2367 00001325 7505                    	jnz	short lff32s_8
  2368 00001327 E990F7FFFF              	jmp	lff32_eof
  2369                                  
  2370                                  lff32s_8:
  2371 0000132C 89C1                    	mov	ecx, eax  ; word count
  2372                                  lff32s_1:
  2373 0000132E AC                      	lodsb
  2374 0000132F A2[33200000]            	mov	[previous_val_l], al
  2375 00001334 2C80                    	sub	al, 80h
  2376 00001336 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2377 0000133A 66AB                    	stosw		; original sample (L)
  2378 0000133C AC                      	lodsb
  2379 0000133D A2[35200000]            	mov	[previous_val_r], al
  2380 00001342 2C80                    	sub	al, 80h
  2381 00001344 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2382 00001348 66AB                    	stosw		; original sample (R)
  2383                                  
  2384                                  	;xor	eax, eax
  2385 0000134A 66B88080                	mov	ax, 8080h
  2386 0000134E 49                      	dec	ecx
  2387 0000134F 7403                    	jz	short lff32s_2
  2388                                  		; convert 8 bit sample to 16 bit sample
  2389 00001351 668B06                  	mov	ax, [esi]
  2390                                  lff32s_2:
  2391                                  	;;mov	[next_val_l], al
  2392                                  	;;mov	[next_val_r], ah
  2393                                  	;mov	bx, ax
  2394 00001354 88E7                    	mov	bh, ah
  2395 00001356 0205[33200000]          	add	al, [previous_val_l]
  2396 0000135C D0D8                    	rcr	al, 1
  2397                                  	;mov	dl, al
  2398 0000135E 2C80                    	sub	al, 80h
  2399 00001360 66C1E008                	shl	ax, 8
  2400 00001364 66AB                    	stosw		; this is interpolated sample (L)
  2401 00001366 88F8                    	mov	al, bh	; [next_val_r]
  2402 00001368 0205[35200000]          	add	al, [previous_val_r]
  2403 0000136E D0D8                    	rcr	al, 1
  2404                                  	;mov	dh, al
  2405 00001370 2C80                    	sub	al, 80h
  2406 00001372 66C1E008                	shl	ax, 8
  2407 00001376 66AB                    	stosw		; this is interpolated sample (R)
  2408                                  
  2409                                  	; different than 8-16-24 kHZ !
  2410                                  	; 'original-interpolated-original' trio samples 
  2411 00001378 E315                    	jecxz	lff32s_3
  2412                                  
  2413 0000137A AC                      	lodsb
  2414 0000137B 2C80                    	sub	al, 80h
  2415 0000137D 66C1E008                	shl	ax, 8
  2416 00001381 66AB                    	stosw		; original sample (left channel)
  2417                                  
  2418 00001383 AC                      	lodsb
  2419 00001384 2C80                    	sub	al, 80h
  2420 00001386 66C1E008                	shl	ax, 8
  2421 0000138A 66AB                    	stosw		; original sample (right channel)
  2422                                  		
  2423                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2424 0000138C 49                      	dec	ecx
  2425 0000138D 759F                    	jnz	short lff32s_1
  2426                                  lff32s_3:
  2427 0000138F E915F7FFFF              	jmp	lff32_3
  2428                                  
  2429                                  load_32khz_mono_16_bit:
  2430                                  	; 15/11/2023
  2431 00001394 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2432                                  					; last of the file?
  2433 0000139B 7402                    	jz	short lff32m2_0		; no
  2434 0000139D F9                      	stc
  2435 0000139E C3                      	retn
  2436                                  
  2437                                  lff32m2_0:
  2438 0000139F BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2439                                          ;mov	edx, [loadsize]
  2440                                  
  2441                                  	; esi = buffer address
  2442                                  	;; edx = buffer size
  2443                                  
  2444                                  	; load file into memory
  2445                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000013A4 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000013AA 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000013AC 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000013B2 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000013B7 CD40                <1>  int 40h
  2446 000013B9 723E                    	jc	short lff32m2_7 ; error !
  2447                                  
  2448 000013BB BF[00300000]            	mov	edi, audio_buffer
  2449                                  	
  2450 000013C0 D1E8                    	shr	eax, 1
  2451 000013C2 7505                    	jnz	short lff32m2_8
  2452 000013C4 E9F3F6FFFF              	jmp	lff32_eof
  2453                                  
  2454                                  lff32m2_8:
  2455 000013C9 89C1                    	mov	ecx, eax  ; word count
  2456                                  lff32m2_1:
  2457 000013CB 66AD                    	lodsw
  2458 000013CD 66AB                    	stosw		; original sample (left channel)
  2459 000013CF 66AB                    	stosw		; original sample (right channel)
  2460 000013D1 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2461                                  	;mov	[previous_val], ax
  2462                                  	;mov	ebx, eax	
  2463                                  	;xor	eax, eax
  2464 000013D4 31DB                    	xor	ebx, ebx
  2465 000013D6 49                      	dec	ecx
  2466 000013D7 7403                    	jz	short lff32m2_2
  2467                                  	;mov	ax, [esi]
  2468 000013D9 668B1E                  	mov	bx, [esi]
  2469                                  lff32m2_2:
  2470                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2471                                  	;mov	ebp, eax	; [next_val]
  2472                                  	;add	ax, [previous_val]
  2473                                  	; ax = [previous_val]
  2474                                  	; bx = [next_val]
  2475 000013DC 6601D8                  	add	ax, bx
  2476 000013DF 66D1D8                  	rcr	ax, 1
  2477 000013E2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2478 000013E5 66AB                    	stosw		; this is interpolated sample (L)
  2479 000013E7 66AB                    	stosw		; this is interpolated sample (R)
  2480                                  
  2481                                  	; different than 8-16-24 kHZ !
  2482                                  	; 'original-interpolated-original' trio samples 
  2483 000013E9 E309                    	jecxz	lff32m2_3
  2484                                  
  2485 000013EB 66AD                    	lodsw
  2486 000013ED 66AB                    	stosw		; original sample (left channel)
  2487 000013EF 66AB                    	stosw		; original sample (right channel)
  2488                                  
  2489                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2490 000013F1 49                      	dec	ecx
  2491 000013F2 75D7                    	jnz	short lff32m2_1
  2492                                  lff32m2_3:
  2493 000013F4 E9B0F6FFFF              	jmp	lff32_3
  2494                                  
  2495                                  lff32m2_7:
  2496                                  lff32s2_7:
  2497 000013F9 E9C7F6FFFF              	jmp	lff32_5  ; error
  2498                                  
  2499                                  load_32khz_stereo_16_bit:
  2500                                  	; 16/11/2023
  2501                                  	; 15/11/2023
  2502 000013FE F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2503                                  					; last of the file?
  2504 00001405 7402                    	jz	short lff32s2_0		; no
  2505 00001407 F9                      	stc
  2506 00001408 C3                      	retn
  2507                                  
  2508                                  lff32s2_0:
  2509 00001409 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2510                                          ;mov	edx, [loadsize]
  2511                                  
  2512                                  	; esi = buffer address
  2513                                  	;; edx = buffer size
  2514                                  
  2515                                  	; load file into memory
  2516                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000140E 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001414 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001416 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000141C B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001421 CD40                <1>  int 40h
  2517 00001423 72D4                    	jc	short lff32s2_7 ; error !
  2518                                  
  2519 00001425 BF[00300000]            	mov	edi, audio_buffer
  2520                                  	
  2521 0000142A C1E802                  	shr	eax, 2
  2522 0000142D 7505                    	jnz	short lff32s2_8
  2523 0000142F E988F6FFFF              	jmp	lff32_eof
  2524                                  
  2525                                  lff32s2_8:
  2526 00001434 89C1                    	mov	ecx, eax ; dword count
  2527                                  lff32s2_1:
  2528 00001436 66AD                    	lodsw
  2529 00001438 66AB                    	stosw		; original sample (L)
  2530 0000143A 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2531 0000143D 66A3[33200000]          	mov	[previous_val_l], ax
  2532 00001443 66AD                    	lodsw
  2533 00001445 66AB                    	stosw		; original sample (R)
  2534 00001447 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2535                                  	;mov	[previous_val_r], ax
  2536 0000144A 89C3                    	mov	ebx, eax
  2537 0000144C 31D2                    	xor	edx, edx
  2538 0000144E 31C0                    	xor	eax, eax
  2539                                  	; 16/11/2023
  2540 00001450 49                      	dec	ecx
  2541 00001451 7407                    	jz	short lff32s2_2
  2542 00001453 668B06                  	mov	ax, [esi]
  2543 00001456 668B5602                	mov	dx, [esi+2]
  2544                                  lff32s2_2:
  2545 0000145A 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2546                                  	;;mov	[next_val_l], ax
  2547                                  	;mov	ebp, eax
  2548 0000145D 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2549                                  	;mov	[next_val_r], dx
  2550 00001460 660305[33200000]        	add	ax, [previous_val_l]
  2551 00001467 66D1D8                  	rcr	ax, 1
  2552 0000146A 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2553 0000146D 66AB                    	stosw		; this is interpolated sample (L)
  2554                                  	;mov	ax, [next_val_r]
  2555 0000146F 89D0                    	mov	eax, edx
  2556                                  	;add	ax, [previous_val_r]
  2557 00001471 6601D8                  	add	ax, bx
  2558 00001474 66D1D8                  	rcr	ax, 1
  2559 00001477 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2560 0000147A 66AB                    	stosw		; this is interpolated sample (R)
  2561                                  
  2562                                  	; different than 8-16-24 kHZ !
  2563                                  	; 'original-interpolated-original' trio samples 
  2564 0000147C E30B                    	jecxz	lff32s2_3
  2565                                  
  2566 0000147E 66AD                    	lodsw
  2567 00001480 66AB                    	stosw	; original sample (L)
  2568 00001482 66AD                    	lodsw
  2569 00001484 66AB                    	stosw	; original sample (R)
  2570                                  	
  2571                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2572 00001486 49                      	dec	ecx
  2573 00001487 75AD                    	jnz	short lff32s2_1
  2574                                  lff32s2_3:
  2575 00001489 E91BF6FFFF              	jmp	lff32_3
  2576                                  
  2577                                  ; .....................
  2578                                  
  2579                                  load_22khz_mono_8_bit:
  2580                                  	; 16/11/2023
  2581 0000148E F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2582                                  					; last of the file?
  2583 00001495 7402                    	jz	short lff22m_0		; no
  2584 00001497 F9                      	stc
  2585 00001498 C3                      	retn
  2586                                  
  2587                                  lff22m_0:
  2588 00001499 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2589                                          ;mov	edx, [loadsize]
  2590                                  
  2591                                  	; esi = buffer address
  2592                                  	;; edx = buffer size
  2593                                  
  2594                                  	; load file into memory
  2595                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000149E 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000014A4 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000014A6 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000014AC B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000014B1 CD40                <1>  int 40h
  2596 000014B3 725D                    	jc	short lff22m_7 ; error !
  2597                                  
  2598 000014B5 BF[00300000]            	mov	edi, audio_buffer
  2599                                  	
  2600 000014BA 21C0                    	and	eax, eax
  2601 000014BC 7505                    	jnz	short lff22m_8
  2602 000014BE E9F9F5FFFF              	jmp	lff22_eof
  2603                                  
  2604                                  lff22m_8:
  2605 000014C3 89C1                    	mov	ecx, eax	; byte count
  2606                                  lff22m_9:
  2607 000014C5 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2608 000014CA C605[3B200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2609                                  lff22m_1:
  2610                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2611 000014D1 AC                      	lodsb
  2612 000014D2 B280                    	mov	dl, 80h
  2613 000014D4 49                      	dec	ecx
  2614 000014D5 7402                    	jz	short lff22m_2_1
  2615 000014D7 8A16                    	mov	dl, [esi]
  2616                                  lff22m_2_1:	
  2617                                  	; al = [previous_val]
  2618                                  	; dl = [next_val]
  2619 000014D9 E80F060000              	call	interpolating_3_8bit_mono ; 1 of 17
  2620 000014DE E32D                    	jecxz	lff22m_3
  2621                                  lff22m_2_2:
  2622 000014E0 AC                      	lodsb
  2623 000014E1 B280                    	mov	dl, 80h
  2624 000014E3 49                      	dec	ecx
  2625 000014E4 7402                    	jz	short lff22m_2_3
  2626 000014E6 8A16                    	mov	dl, [esi]
  2627                                  lff22m_2_3:
  2628 000014E8 E884060000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2629 000014ED E31E                    	jecxz	lff22m_3
  2630 000014EF 4D                      	dec	ebp
  2631 000014F0 75EE                    	jnz	short lff22m_2_2
  2632                                  
  2633 000014F2 A0[3B200000]            	mov	al, [faz]
  2634 000014F7 FEC8                    	dec	al
  2635 000014F9 74CA                    	jz	short lff22m_9
  2636 000014FB FE0D[3B200000]          	dec	byte [faz]
  2637 00001501 BD04000000              	mov	ebp, 4
  2638 00001506 FEC8                    	dec	al
  2639 00001508 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2640 0000150A 45                      	inc	ebp ; 5
  2641 0000150B EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2642                                  
  2643                                  lff22m_3:
  2644                                  lff22s_3:
  2645 0000150D E997F5FFFF              	jmp	lff22_3	; padfill
  2646                                  		; (put zeros in the remain words of the buffer)
  2647                                  lff22m_7:
  2648                                  lff22s_7:
  2649 00001512 E9AEF5FFFF              	jmp	lff22_5  ; error
  2650                                  
  2651                                  load_22khz_stereo_8_bit:
  2652                                  	; 16/11/2023
  2653 00001517 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2654                                  					; last of the file?
  2655 0000151E 7402                    	jz	short lff22s_0		; no
  2656 00001520 F9                      	stc
  2657 00001521 C3                      	retn
  2658                                  
  2659                                  lff22s_0:
  2660 00001522 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2661                                          ;mov	edx, [loadsize]
  2662                                  
  2663                                  	; esi = buffer address
  2664                                  	;; edx = buffer size
  2665                                  
  2666                                  	; load file into memory
  2667                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001527 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000152D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000152F 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001535 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000153A CD40                <1>  int 40h
  2668 0000153C 72D4                    	jc	short lff22s_7 ; error !
  2669                                  
  2670 0000153E BF[00300000]            	mov	edi, audio_buffer
  2671                                  	
  2672 00001543 D1E8                    	shr	eax, 1
  2673 00001545 7505                    	jnz	short lff22s_8
  2674 00001547 E970F5FFFF              	jmp	lff22_eof
  2675                                  
  2676                                  lff22s_8:
  2677 0000154C 89C1                    	mov	ecx, eax	; word count
  2678                                  lff22s_9:
  2679 0000154E BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2680 00001553 C605[3B200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2681                                  lff22s_1:
  2682                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2683 0000155A 66AD                    	lodsw
  2684 0000155C 66BA8080                	mov	dx, 8080h
  2685 00001560 49                      	dec	ecx
  2686 00001561 7403                    	jz	short lff22s_2_1 
  2687 00001563 668B16                  	mov	dx, [esi]
  2688                                  lff22s_2_1:	
  2689                                  	; al = [previous_val_l]
  2690                                  	; ah = [previous_val_r]
  2691                                  	; dl = [next_val_l]
  2692                                  	; dh = [next_val_r]	
  2693 00001566 E8B3050000              	call	interpolating_3_8bit_stereo ; 1 of 17 
  2694 0000156B E3A0                    	jecxz	lff22s_3
  2695                                  lff22s_2_2:
  2696 0000156D 66AD                    	lodsw
  2697 0000156F 66BA8080                	mov	dx, 8080h
  2698 00001573 49                      	dec	ecx
  2699 00001574 7403                    	jz	short lff22s_2_3
  2700 00001576 668B16                  	mov	dx, [esi]
  2701                                  lff22s_2_3:
  2702 00001579 E810060000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2703 0000157E E38D                    	jecxz	lff22s_3
  2704 00001580 4D                      	dec	ebp
  2705 00001581 75EA                    	jnz	short lff22s_2_2
  2706                                  
  2707 00001583 A0[3B200000]            	mov	al, [faz]
  2708 00001588 FEC8                    	dec	al
  2709 0000158A 74C2                    	jz	short lff22s_9
  2710 0000158C FE0D[3B200000]          	dec	byte [faz]
  2711 00001592 BD04000000              	mov	ebp, 4
  2712 00001597 FEC8                    	dec	al
  2713 00001599 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2714 0000159B 45                      	inc	ebp ; 5
  2715 0000159C EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2716                                  
  2717                                  load_22khz_mono_16_bit:
  2718                                  	; 16/11/2023
  2719 0000159E F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2720                                  					; last of the file?
  2721 000015A5 7402                    	jz	short lff22m2_0		; no
  2722 000015A7 F9                      	stc
  2723 000015A8 C3                      	retn
  2724                                  
  2725                                  lff22m2_0:
  2726 000015A9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2727                                          ;mov	edx, [loadsize]
  2728                                  
  2729                                  	; esi = buffer address
  2730                                  	;; edx = buffer size
  2731                                  
  2732                                  	; load file into memory
  2733                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000015AE 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000015B4 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000015B6 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000015BC B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000015C1 CD40                <1>  int 40h
  2734 000015C3 7261                    	jc	short lff22m2_7 ; error !
  2735                                  
  2736 000015C5 BF[00300000]            	mov	edi, audio_buffer
  2737                                  	
  2738 000015CA D1E8                    	shr	eax, 1
  2739 000015CC 7505                    	jnz	short lff22m2_8
  2740 000015CE E9E9F4FFFF              	jmp	lff22_eof
  2741                                  
  2742                                  lff22m2_8:
  2743 000015D3 89C1                    	mov	ecx, eax	; word count
  2744                                  lff22m2_9:
  2745 000015D5 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2746 000015DA C605[3B200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2747                                  lff22m2_1:
  2748                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2749 000015E1 66AD                    	lodsw
  2750 000015E3 31D2                    	xor	edx, edx
  2751 000015E5 49                      	dec	ecx
  2752 000015E6 7403                    	jz	short lff22m2_2_1
  2753 000015E8 668B16                  	mov	dx, [esi]
  2754                                  lff22m2_2_1:	
  2755                                  	; ax = [previous_val]
  2756                                  	; dx = [next_val]
  2757 000015EB E8CF050000              	call	interpolating_3_16bit_mono ; 1 of 17
  2758 000015F0 E32F                    	jecxz	lff22m2_3
  2759                                  lff22m2_2_2:
  2760 000015F2 66AD                    	lodsw
  2761 000015F4 31D2                    	xor	edx, edx
  2762 000015F6 49                      	dec	ecx
  2763 000015F7 7403                    	jz	short lff22m2_2_3
  2764 000015F9 668B16                  	mov	dx, [esi]
  2765                                  lff22m2_2_3:
  2766 000015FC E851060000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2767 00001601 E31E                    	jecxz	lff22m2_3
  2768 00001603 4D                      	dec	ebp
  2769 00001604 75EC                    	jnz	short lff22m2_2_2
  2770                                  
  2771 00001606 A0[3B200000]            	mov	al, [faz]
  2772 0000160B FEC8                    	dec	al
  2773 0000160D 74C6                    	jz	short lff22m2_9
  2774 0000160F FE0D[3B200000]          	dec	byte [faz]
  2775 00001615 BD04000000              	mov	ebp, 4
  2776 0000161A FEC8                    	dec	al
  2777 0000161C 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2778 0000161E 45                      	inc	ebp ; 5
  2779 0000161F EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2780                                  
  2781                                  lff22m2_3:
  2782                                  lff22s2_3:
  2783 00001621 E983F4FFFF              	jmp	lff22_3	; padfill
  2784                                  		; (put zeros in the remain words of the buffer)
  2785                                  lff22m2_7:
  2786                                  lff22s2_7:
  2787 00001626 E99AF4FFFF              	jmp	lff22_5  ; error
  2788                                  
  2789                                  load_22khz_stereo_16_bit:
  2790                                  	; 16/11/2023
  2791 0000162B F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2792                                  					; last of the file?
  2793 00001632 7402                    	jz	short lff22s2_0		; no
  2794 00001634 F9                      	stc
  2795 00001635 C3                      	retn
  2796                                  
  2797                                  lff22s2_0:
  2798 00001636 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2799                                          ;mov	edx, [loadsize]
  2800                                  
  2801                                  	; esi = buffer address
  2802                                  	;; edx = buffer size
  2803                                  
  2804                                  	; load file into memory
  2805                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000163B 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001641 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001643 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001649 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000164E CD40                <1>  int 40h
  2806 00001650 72D4                    	jc	short lff22s2_7 ; error !
  2807                                  
  2808 00001652 BF[00300000]            	mov	edi, audio_buffer
  2809                                  	
  2810 00001657 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  2811 0000165A 7505                    	jnz	short lff22s2_8
  2812 0000165C E95BF4FFFF              	jmp	lff22_eof
  2813                                  
  2814                                  lff22s2_8:
  2815 00001661 89C1                    	mov	ecx, eax	; dword count
  2816                                  lff22s2_9:
  2817 00001663 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2818 00001668 C605[3B200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2819                                  lff22s2_1:
  2820                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2821 0000166F 66AD                    	lodsw
  2822 00001671 89C3                    	mov	ebx, eax
  2823 00001673 66AD                    	lodsw
  2824 00001675 8B16                    	mov	edx, [esi]
  2825 00001677 668915[37200000]        	mov	[next_val_l], dx
  2826                                  	; 26/11/2023
  2827 0000167E C1EA10                  	shr	edx, 16
  2828 00001681 49                      	dec	ecx
  2829 00001682 7509                    	jnz	short lff22s2_2_1
  2830 00001684 31D2                    	xor	edx, edx ; 0
  2831 00001686 668915[37200000]        	mov	[next_val_l], dx
  2832                                  lff22s2_2_1:
  2833                                  	; bx = [previous_val_l]
  2834                                  	; ax = [previous_val_r]
  2835                                  	; [next_val_l]
  2836                                  	; dx = [next_val_r]
  2837 0000168D E85D050000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  2838 00001692 E38D                    	jecxz	lff22s2_3
  2839                                  lff22s2_2_2:
  2840 00001694 66AD                    	lodsw
  2841 00001696 89C3                    	mov	ebx, eax
  2842 00001698 66AD                    	lodsw
  2843 0000169A 8B16                    	mov	edx, [esi]
  2844 0000169C 668915[37200000]        	mov	[next_val_l], dx
  2845                                  	; 26/11/2023
  2846 000016A3 C1EA10                  	shr	edx, 16
  2847 000016A6 49                      	dec	ecx
  2848 000016A7 7509                    	jnz	short lff22s2_2_3
  2849 000016A9 31D2                    	xor	edx, edx ; 0
  2850 000016AB 668915[37200000]        	mov	[next_val_l], dx
  2851                                  lff22s2_2_3:
  2852 000016B2 E8B3050000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  2853 000016B7 E31E                    	jecxz	lff22s2_2_4
  2854                                  
  2855 000016B9 4D                      	dec	ebp
  2856 000016BA 75D8                    	jnz	short lff22s2_2_2
  2857                                  
  2858 000016BC A0[3B200000]            	mov	al, [faz]
  2859 000016C1 FEC8                    	dec	al
  2860 000016C3 749E                    	jz	short lff22s2_9
  2861 000016C5 FE0D[3B200000]          	dec	byte [faz]
  2862 000016CB BD04000000              	mov	ebp, 4
  2863 000016D0 FEC8                    	dec	al
  2864 000016D2 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2865 000016D4 45                      	inc	ebp ; 5
  2866 000016D5 EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2867                                  
  2868                                  lff22s2_2_4:
  2869                                  	; 26/11/2023
  2870 000016D7 E9CDF3FFFF              	jmp	lff22_3	; padfill
  2871                                  
  2872                                  ; .....................
  2873                                  
  2874                                  load_11khz_mono_8_bit:
  2875                                  	; 18/11/2023
  2876 000016DC F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2877                                  					; last of the file?
  2878 000016E3 7402                    	jz	short lff11m_0		; no
  2879 000016E5 F9                      	stc
  2880 000016E6 C3                      	retn
  2881                                  
  2882                                  lff11m_0:
  2883 000016E7 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2884                                          ;mov	edx, [loadsize]
  2885                                  
  2886                                  	; esi = buffer address
  2887                                  	;; edx = buffer size
  2888                                  
  2889                                  	; load file into memory
  2890                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000016EC 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000016F2 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000016F4 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000016FA B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000016FF CD40                <1>  int 40h
  2891 00001701 7247                    	jc	short lff11m_7 ; error !
  2892                                  
  2893 00001703 BF[00300000]            	mov	edi, audio_buffer
  2894                                  	
  2895 00001708 21C0                    	and	eax, eax
  2896 0000170A 7505                    	jnz	short lff11m_8
  2897 0000170C E9ABF3FFFF              	jmp	lff11_eof
  2898                                  
  2899                                  lff11m_8:
  2900 00001711 89C1                    	mov	ecx, eax		; byte count
  2901                                  lff11m_9:
  2902 00001713 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  2903                                  lff11m_1:
  2904                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2905 00001718 AC                      	lodsb
  2906 00001719 B280                    	mov	dl, 80h
  2907 0000171B 49                      	dec	ecx
  2908 0000171C 7402                    	jz	short lff11m_2_1
  2909 0000171E 8A16                    	mov	dl, [esi]
  2910                                  lff11m_2_1:	
  2911                                  	; al = [previous_val]
  2912                                  	; dl = [next_val]
  2913 00001720 E876050000              	call	interpolating_5_8bit_mono
  2914 00001725 E328                    	jecxz	lff11m_3
  2915                                  lff11m_2_2:
  2916 00001727 AC                      	lodsb
  2917 00001728 B280                    	mov	dl, 80h
  2918 0000172A 49                      	dec	ecx
  2919 0000172B 7402                    	jz	short lff11m_2_3
  2920 0000172D 8A16                    	mov	dl, [esi]
  2921                                  lff11m_2_3:
  2922 0000172F E873060000               	call	interpolating_4_8bit_mono
  2923 00001734 E319                    	jecxz	lff11m_3
  2924                                  
  2925 00001736 4D                      	dec	ebp
  2926 00001737 74DA                    	jz	short lff11m_9
  2927                                  
  2928 00001739 AC                      	lodsb
  2929 0000173A B280                    	mov	dl, 80h
  2930 0000173C 49                      	dec	ecx
  2931 0000173D 7402                    	jz	short lff11m_2_4
  2932 0000173F 8A16                    	mov	dl, [esi]
  2933                                  lff11m_2_4:
  2934 00001741 E861060000              	call	interpolating_4_8bit_mono
  2935 00001746 E307                    	jecxz	lff11m_3
  2936 00001748 EBCE                    	jmp	short lff11m_1
  2937                                  
  2938                                  lff11m_7:
  2939                                  lff11s_7:
  2940 0000174A E976F3FFFF              	jmp	lff11_5  ; error
  2941                                  
  2942                                  lff11m_3:
  2943                                  lff11s_3:
  2944 0000174F E955F3FFFF              	jmp	lff11_3	; padfill
  2945                                  		; (put zeros in the remain words of the buffer)
  2946                                  
  2947                                  load_11khz_stereo_8_bit:
  2948                                  	; 18/11/2023
  2949 00001754 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2950                                  					; last of the file?
  2951 0000175B 7402                    	jz	short lff11s_0		; no
  2952 0000175D F9                      	stc
  2953 0000175E C3                      	retn
  2954                                  
  2955                                  lff11s_0:
  2956 0000175F BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2957                                          ;mov	edx, [loadsize]
  2958                                  
  2959                                  	; esi = buffer address
  2960                                  	;; edx = buffer size
  2961                                  
  2962                                  	; load file into memory
  2963                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001764 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000176A 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000176C 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001772 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001777 CD40                <1>  int 40h
  2964 00001779 72CF                    	jc	short lff11s_7 ; error !
  2965                                  
  2966 0000177B BF[00300000]            	mov	edi, audio_buffer
  2967                                  	
  2968 00001780 D1E8                    	shr	eax, 1
  2969 00001782 7505                    	jnz	short lff11s_8
  2970 00001784 E933F3FFFF              	jmp	lff11_eof
  2971                                  
  2972                                  lff11s_8:
  2973 00001789 89C1                    	mov	ecx, eax	; word count
  2974                                  lff11s_9:
  2975 0000178B BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  2976                                  lff11s_1:
  2977                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2978 00001790 66AD                    	lodsw
  2979 00001792 66BA8080                	mov	dx, 8080h
  2980 00001796 49                      	dec	ecx
  2981 00001797 7403                    	jz	short lff11s_2_1 
  2982 00001799 668B16                  	mov	dx, [esi]
  2983                                  lff11s_2_1:	
  2984                                  	; al = [previous_val_l]
  2985                                  	; ah = [previous_val_r]
  2986                                  	; dl = [next_val_l]
  2987                                  	; dh = [next_val_r]	
  2988 0000179C E859050000              	call	interpolating_5_8bit_stereo
  2989 000017A1 E3AC                    	jecxz	lff11s_3
  2990                                  lff11s_2_2:
  2991 000017A3 66AD                    	lodsw
  2992 000017A5 66BA8080                	mov	dx, 8080h
  2993 000017A9 49                      	dec	ecx
  2994 000017AA 7403                    	jz	short lff11s_2_3
  2995 000017AC 668B16                  	mov	dx, [esi]
  2996                                  lff11s_2_3:
  2997 000017AF E832060000               	call	interpolating_4_8bit_stereo
  2998 000017B4 E399                    	jecxz	lff11s_3
  2999                                  	
  3000 000017B6 4D                      	dec	ebp
  3001 000017B7 74D2                    	jz	short lff11s_9
  3002                                  
  3003 000017B9 66AD                    	lodsw
  3004 000017BB 66BA8080                	mov	dx, 8080h
  3005 000017BF 49                      	dec	ecx
  3006 000017C0 7403                    	jz	short lff11s_2_4
  3007 000017C2 668B16                  	mov	dx, [esi]
  3008                                  lff11s_2_4:
  3009 000017C5 E81C060000              	call	interpolating_4_8bit_stereo
  3010 000017CA E383                    	jecxz	lff11s_3
  3011 000017CC EBC2                    	jmp	short lff11s_1
  3012                                  
  3013                                  load_11khz_mono_16_bit:
  3014                                  	; 18/11/2023
  3015 000017CE F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3016                                  					; last of the file?
  3017 000017D5 7402                    	jz	short lff11m2_0		; no
  3018 000017D7 F9                      	stc
  3019 000017D8 C3                      	retn
  3020                                  
  3021                                  lff11m2_0:
  3022 000017D9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3023                                          ;mov	edx, [loadsize]
  3024                                  
  3025                                  	; esi = buffer address
  3026                                  	;; edx = buffer size
  3027                                  
  3028                                  	; load file into memory
  3029                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000017DE 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000017E4 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000017E6 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000017EC B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000017F1 CD40                <1>  int 40h
  3030 000017F3 724D                    	jc	short lff11m2_7 ; error !
  3031                                  
  3032 000017F5 BF[00300000]            	mov	edi, audio_buffer
  3033                                  	
  3034 000017FA D1E8                    	shr	eax, 1
  3035 000017FC 7505                    	jnz	short lff11m2_8
  3036 000017FE E9B9F2FFFF              	jmp	lff11_eof
  3037                                  
  3038                                  lff11m2_8:
  3039 00001803 89C1                    	mov	ecx, eax	; word count
  3040                                  lff11m2_9:
  3041 00001805 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3042                                  lff11m2_1:
  3043                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3044 0000180A 66AD                    	lodsw
  3045 0000180C 31D2                    	xor	edx, edx
  3046 0000180E 49                      	dec	ecx
  3047 0000180F 7403                    	jz	short lff11m2_2_1
  3048 00001811 668B16                  	mov	dx, [esi]
  3049                                  lff11m2_2_1:	
  3050                                  	; ax = [previous_val]
  3051                                  	; dx = [next_val]
  3052 00001814 E83A060000              	call	interpolating_5_16bit_mono
  3053 00001819 E362                    	jecxz	lff11m2_3
  3054                                  lff11m2_2_2:
  3055 0000181B 66AD                    	lodsw
  3056 0000181D 31D2                    	xor	edx, edx
  3057 0000181F 49                      	dec	ecx
  3058 00001820 7403                    	jz	short lff11m2_2_3
  3059 00001822 668B16                  	mov	dx, [esi]
  3060                                  lff11m2_2_3:
  3061 00001825 E853070000               	call	interpolating_4_16bit_mono
  3062 0000182A E351                    	jecxz	lff11m2_3
  3063                                  
  3064 0000182C 4D                      	dec	ebp
  3065 0000182D 74D6                    	jz	short lff11m2_9
  3066                                  
  3067 0000182F 66AD                    	lodsw
  3068 00001831 31D2                    	xor	edx, edx
  3069 00001833 49                      	dec	ecx
  3070 00001834 7403                    	jz	short lff11m2_2_4
  3071 00001836 668B16                  	mov	dx, [esi]
  3072                                  lff11m2_2_4:
  3073 00001839 E83F070000               	call	interpolating_4_16bit_mono
  3074 0000183E E33D                    	jecxz	lff11m2_3
  3075 00001840 EBC8                    	jmp	short lff11m2_1
  3076                                  
  3077                                  lff11m2_7:
  3078                                  lff11s2_7:
  3079 00001842 E97EF2FFFF              	jmp	lff11_5  ; error
  3080                                  
  3081                                  load_11khz_stereo_16_bit:
  3082                                  	; 18/11/2023
  3083 00001847 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3084                                  					; last of the file?
  3085 0000184E 7402                    	jz	short lff11s2_0		; no
  3086 00001850 F9                      	stc
  3087 00001851 C3                      	retn
  3088                                  
  3089                                  lff11s2_0:
  3090 00001852 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3091                                          ;mov	edx, [loadsize]
  3092                                  
  3093                                  	; esi = buffer address
  3094                                  	;; edx = buffer size
  3095                                  
  3096                                  	; load file into memory
  3097                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001857 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000185D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000185F 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001865 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000186A CD40                <1>  int 40h
  3098 0000186C 72D4                    	jc	short lff11s2_7 ; error !
  3099                                  
  3100 0000186E BF[00300000]            	mov	edi, audio_buffer
  3101                                  	
  3102 00001873 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3103 00001876 750A                    	jnz	short lff11s2_8
  3104 00001878 E93FF2FFFF              	jmp	lff11_eof
  3105                                  
  3106                                  lff11m2_3:
  3107                                  lff11s2_3:
  3108 0000187D E927F2FFFF              	jmp	lff11_3	; padfill
  3109                                  		; (put zeros in the remain words of the buffer)
  3110                                  
  3111                                  lff11s2_8:
  3112 00001882 89C1                    	mov	ecx, eax	; dword count
  3113                                  lff11s2_9:
  3114 00001884 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3115                                  lff11s2_1:
  3116                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3117 00001889 66AD                    	lodsw
  3118 0000188B 89C3                    	mov	ebx, eax
  3119 0000188D 66AD                    	lodsw
  3120 0000188F 8B16                    	mov	edx, [esi]
  3121 00001891 8915[37200000]          	mov	[next_val_l], edx
  3122                                  	; 26/11/2023
  3123 00001897 C1EA10                  	shr	edx, 16
  3124                                  	;mov	[next_val_r], dx
  3125 0000189A 49                      	dec	ecx
  3126 0000189B 7509                    	jnz	short lff11s2_2_1
  3127 0000189D 31D2                    	xor	edx, edx ; 0
  3128 0000189F 668915[37200000]        	mov	[next_val_l], dx
  3129                                  	;mov	[next_val_r], dx
  3130                                  lff11s2_2_1:
  3131                                  	; bx = [previous_val_l]
  3132                                  	; ax = [previous_val_r]
  3133                                  	; [next_val_l]
  3134                                  	; dx = [next_val_r]
  3135 000018A6 E803060000              	call	interpolating_5_16bit_stereo
  3136 000018AB E3D0                    	jecxz	lff11s2_3
  3137                                  lff11s2_2_2:
  3138 000018AD 66AD                    	lodsw
  3139 000018AF 89C3                    	mov	ebx, eax
  3140 000018B1 66AD                    	lodsw
  3141 000018B3 8B16                    	mov	edx, [esi]
  3142 000018B5 668915[37200000]        	mov	[next_val_l], dx
  3143                                  	; 26/11/2023
  3144 000018BC C1EA10                  	shr	edx, 16
  3145                                  	;mov	[next_val_r], dx
  3146 000018BF 49                      	dec	ecx
  3147 000018C0 7509                    	jnz	short lff11s2_2_3
  3148 000018C2 31D2                    	xor	edx, edx ; 0
  3149 000018C4 668915[37200000]        	mov	[next_val_l], dx
  3150                                  	;mov	[next_val_r], dx
  3151                                  lff11s2_2_3:
  3152 000018CB E8E6060000               	call	interpolating_4_16bit_stereo
  3153 000018D0 E3AB                    	jecxz	lff11s2_3
  3154                                  	
  3155 000018D2 4D                      	dec	ebp
  3156 000018D3 74AF                    	jz	short lff11s2_9
  3157                                  
  3158 000018D5 66AD                    	lodsw
  3159 000018D7 89C3                    	mov	ebx, eax
  3160 000018D9 66AD                    	lodsw
  3161 000018DB 8B16                    	mov	edx, [esi]
  3162 000018DD 668915[37200000]        	mov	[next_val_l], dx
  3163                                  	; 26/11/2023
  3164 000018E4 C1EA10                  	shr	edx, 16
  3165                                  	;mov	[next_val_r], dx
  3166 000018E7 49                      	dec	ecx
  3167 000018E8 7509                    	jnz	short lff11s2_2_4
  3168 000018EA 31D2                    	xor	edx, edx ; 0
  3169 000018EC 668915[37200000]        	mov	[next_val_l], dx
  3170                                  	;mov	[next_val_r], dx
  3171                                  lff11s2_2_4:
  3172 000018F3 E8BE060000               	call	interpolating_4_16bit_stereo
  3173 000018F8 E383                    	jecxz	lff11s2_3
  3174 000018FA EB8D                    	jmp	short lff11s2_1
  3175                                  
  3176                                  ; .....................
  3177                                  
  3178                                  load_44khz_mono_8_bit:
  3179                                  	; 18/11/2023
  3180 000018FC F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3181                                  					; last of the file?
  3182 00001903 7402                    	jz	short lff44m_0		; no
  3183 00001905 F9                      	stc
  3184 00001906 C3                      	retn
  3185                                  
  3186                                  lff44m_0:
  3187 00001907 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3188                                          ;mov	edx, [loadsize]
  3189                                  
  3190                                  	; esi = buffer address
  3191                                  	;; edx = buffer size
  3192                                  
  3193                                  	; load file into memory
  3194                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000190C 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001912 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001914 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000191A B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000191F CD40                <1>  int 40h
  3195 00001921 7250                    	jc	short lff44m_7 ; error !
  3196                                  
  3197 00001923 BF[00300000]            	mov	edi, audio_buffer
  3198                                  	
  3199 00001928 21C0                    	and	eax, eax
  3200 0000192A 7505                    	jnz	short lff44m_8
  3201 0000192C E98BF1FFFF              	jmp	lff44_eof
  3202                                  
  3203                                  lff44m_8:
  3204 00001931 89C1                    	mov	ecx, eax	; byte count
  3205                                  lff44m_9:
  3206 00001933 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3207 00001938 C605[3B200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3208                                  lff44m_1:
  3209                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3210                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3211 0000193F AC                      	lodsb
  3212 00001940 B280                    	mov	dl, 80h
  3213 00001942 49                      	dec	ecx
  3214 00001943 7402                    	jz	short lff44m_2_1
  3215 00001945 8A16                    	mov	dl, [esi]
  3216                                  lff44m_2_1:	
  3217                                  	; al = [previous_val]
  3218                                  	; dl = [next_val]
  3219 00001947 E825020000              	call	interpolating_2_8bit_mono
  3220 0000194C E320                    	jecxz	lff44m_3
  3221                                  lff44m_2_2:
  3222 0000194E AC                      	lodsb
  3223 0000194F 2C80                    	sub	al, 80h
  3224 00001951 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3225 00001955 66AB                    	stosw		; (L)
  3226 00001957 66AB                    	stosw		; (R)	
  3227                                  
  3228 00001959 49                      	dec	ecx
  3229 0000195A 7412                    	jz	short lff44m_3	
  3230 0000195C 4D                      	dec	ebp
  3231 0000195D 75EF                    	jnz	short lff44m_2_2
  3232                                  	
  3233 0000195F FE0D[3B200000]          	dec	byte [faz]
  3234 00001965 74CC                    	jz	short lff44m_9 
  3235 00001967 BD0B000000              	mov	ebp, 11
  3236 0000196C EBD1                    	jmp	short lff44m_1
  3237                                  
  3238                                  lff44m_3:
  3239                                  lff44s_3:
  3240 0000196E E936F1FFFF              	jmp	lff44_3	; padfill
  3241                                  		; (put zeros in the remain words of the buffer)
  3242                                  lff44m_7:
  3243                                  lff44s_7:
  3244 00001973 E94DF1FFFF              	jmp	lff44_5  ; error
  3245                                  
  3246                                  load_44khz_stereo_8_bit:
  3247                                  	; 16/11/2023
  3248 00001978 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3249                                  					; last of the file?
  3250 0000197F 7402                    	jz	short lff44s_0		; no
  3251 00001981 F9                      	stc
  3252 00001982 C3                      	retn
  3253                                  
  3254                                  lff44s_0:
  3255 00001983 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3256                                          ;mov	edx, [loadsize]
  3257                                  
  3258                                  	; esi = buffer address
  3259                                  	;; edx = buffer size
  3260                                  
  3261                                  	; load file into memory
  3262                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001988 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000198E 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001990 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001996 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000199B CD40                <1>  int 40h
  3263 0000199D 72D4                    	jc	short lff44s_7 ; error !
  3264                                  
  3265 0000199F BF[00300000]            	mov	edi, audio_buffer
  3266                                  	
  3267 000019A4 D1E8                    	shr	eax, 1
  3268 000019A6 7505                    	jnz	short lff44s_8
  3269 000019A8 E90FF1FFFF              	jmp	lff44_eof
  3270                                  
  3271                                  lff44s_8:
  3272 000019AD 89C1                    	mov	ecx, eax	; word count
  3273                                  lff44s_9:
  3274 000019AF BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3275 000019B4 C605[3B200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3276                                  lff44s_1:
  3277                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3278                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3279 000019BB 66AD                    	lodsw
  3280 000019BD 66BA8080                	mov	dx, 8080h
  3281 000019C1 49                      	dec	ecx
  3282 000019C2 7403                    	jz	short lff44s_2_1 
  3283 000019C4 668B16                  	mov	dx, [esi]
  3284                                  lff44s_2_1:	
  3285                                  	; al = [previous_val_l]
  3286                                  	; ah = [previous_val_r]
  3287                                  	; dl = [next_val_l]
  3288                                  	; dh = [next_val_r]	
  3289 000019C7 E8C2010000              	call	interpolating_2_8bit_stereo
  3290 000019CC E3A0                    	jecxz	lff44s_3
  3291                                  lff44s_2_2:
  3292 000019CE AC                      	lodsb
  3293 000019CF 2C80                    	sub	al, 80h
  3294 000019D1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3295 000019D5 66AB                    	stosw		; (L)
  3296 000019D7 AC                      	lodsb
  3297 000019D8 2C80                    	sub	al, 80h
  3298 000019DA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3299 000019DE 66AB                    	stosw		; (R)
  3300                                  
  3301 000019E0 49                      	dec	ecx
  3302 000019E1 748B                    	jz	short lff44s_3	
  3303 000019E3 4D                      	dec	ebp
  3304 000019E4 75E8                    	jnz	short lff44s_2_2
  3305                                  	
  3306 000019E6 FE0D[3B200000]          	dec	byte [faz]
  3307 000019EC 74C1                    	jz	short lff44s_9 
  3308 000019EE BD0B000000              	mov	ebp, 11
  3309 000019F3 EBC6                    	jmp	short lff44s_1
  3310                                  
  3311                                  load_44khz_mono_16_bit:
  3312                                  	; 18/11/2023
  3313 000019F5 F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3314                                  					; last of the file?
  3315 000019FC 7402                    	jz	short lff44m2_0		; no
  3316 000019FE F9                      	stc
  3317 000019FF C3                      	retn
  3318                                  
  3319                                  lff44m2_0:
  3320 00001A00 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3321                                          ;mov	edx, [loadsize]
  3322                                  
  3323                                  	; esi = buffer address
  3324                                  	;; edx = buffer size
  3325                                  
  3326                                  	; load file into memory
  3327                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001A05 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001A0B 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001A0D 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001A13 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001A18 CD40                <1>  int 40h
  3328 00001A1A 724D                    	jc	short lff44m2_7 ; error !
  3329                                  
  3330 00001A1C BF[00300000]            	mov	edi, audio_buffer
  3331                                  	
  3332 00001A21 D1E8                    	shr	eax, 1
  3333 00001A23 7505                    	jnz	short lff44m2_8
  3334 00001A25 E992F0FFFF              	jmp	lff44_eof
  3335                                  
  3336                                  lff44m2_8:
  3337 00001A2A 89C1                    	mov	ecx, eax	; word count
  3338                                  lff44m2_9:
  3339 00001A2C BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3340 00001A31 C605[3B200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3341                                  lff44m2_1:
  3342                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3343                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3344 00001A38 66AD                    	lodsw
  3345 00001A3A 31D2                    	xor	edx, edx
  3346 00001A3C 49                      	dec	ecx
  3347 00001A3D 7403                    	jz	short lff44m2_2_1
  3348 00001A3F 668B16                  	mov	dx, [esi]
  3349                                  lff44m2_2_1:	
  3350                                  	; ax = [previous_val]
  3351                                  	; dx = [next_val]
  3352 00001A42 E80B020000              	call	interpolating_2_16bit_mono
  3353 00001A47 E31B                    	jecxz	lff44m2_3
  3354                                  lff44m2_2_2:
  3355 00001A49 66AD                    	lodsw
  3356 00001A4B 66AB                    	stosw		; (L)eft Channel
  3357 00001A4D 66AB                    	stosw		; (R)ight Channel
  3358                                  
  3359 00001A4F 49                      	dec	ecx
  3360 00001A50 7412                    	jz	short lff44m2_3	
  3361 00001A52 4D                      	dec	ebp
  3362 00001A53 75F4                    	jnz	short lff44m2_2_2
  3363                                  	
  3364 00001A55 FE0D[3B200000]          	dec	byte [faz]
  3365 00001A5B 74CF                    	jz	short lff44m2_9 
  3366 00001A5D BD0B000000              	mov	ebp, 11
  3367 00001A62 EBD4                    	jmp	short lff44m2_1
  3368                                  
  3369                                  lff44m2_3:
  3370                                  lff44s2_3:
  3371 00001A64 E940F0FFFF              	jmp	lff44_3	; padfill
  3372                                  		; (put zeros in the remain words of the buffer)
  3373                                  lff44m2_7:
  3374                                  lff44s2_7:
  3375 00001A69 E957F0FFFF              	jmp	lff44_5  ; error
  3376                                  
  3377                                  load_44khz_stereo_16_bit:
  3378                                  	; 18/11/2023
  3379 00001A6E F605[18230000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3380                                  					; last of the file?
  3381 00001A75 7402                    	jz	short lff44s2_0		; no
  3382 00001A77 F9                      	stc
  3383 00001A78 C3                      	retn
  3384                                  
  3385                                  lff44s2_0:
  3386 00001A79 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3387                                          ;mov	edx, [loadsize]
  3388                                  
  3389                                  	; esi = buffer address
  3390                                  	;; edx = buffer size
  3391                                  
  3392                                  	; load file into memory
  3393                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001A7E 8B1D[3C200000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001A84 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001A86 8B15[B8030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001A8C B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001A91 CD40                <1>  int 40h
  3394 00001A93 72D4                    	jc	short lff44s2_7 ; error !
  3395                                  
  3396 00001A95 BF[00300000]            	mov	edi, audio_buffer
  3397                                  	
  3398 00001A9A C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3399 00001A9D 7505                    	jnz	short lff44s2_8
  3400 00001A9F E918F0FFFF              	jmp	lff44_eof
  3401                                  
  3402                                  lff44s2_8:
  3403 00001AA4 89C1                    	mov	ecx, eax	; dword count
  3404                                  lff44s2_9:
  3405 00001AA6 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3406 00001AAB C605[3B200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3407                                  lff44s2_1:
  3408                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3409                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3410 00001AB2 66AD                    	lodsw
  3411 00001AB4 89C3                    	mov	ebx, eax
  3412 00001AB6 66AD                    	lodsw
  3413                                  	;mov	dx, [esi]
  3414                                  	;mov	[next_val_l], dx
  3415                                  	;mov	dx, [esi+2]
  3416                                  	; 26/11/2023
  3417 00001AB8 8B16                    	mov	edx, [esi]
  3418 00001ABA 668915[37200000]        	mov	[next_val_l], dx
  3419 00001AC1 C1EA10                  	shr	edx, 16
  3420 00001AC4 49                      	dec	ecx
  3421 00001AC5 7509                    	jnz	short lff44s2_2_1
  3422 00001AC7 31D2                    	xor	edx, edx ; 0
  3423 00001AC9 668915[37200000]        	mov	[next_val_l], dx
  3424                                  lff44s2_2_1:
  3425                                  	; bx = [previous_val_l]
  3426                                  	; ax = [previous_val_r]
  3427                                  	; [next_val_l]
  3428                                  	; dx = [next_val_r]
  3429 00001AD0 E895010000              	call	interpolating_2_16bit_stereo
  3430 00001AD5 E38D                    	jecxz	lff44s2_3
  3431                                  lff44s2_2_2:
  3432                                  	;movsw		; (L)eft Channel
  3433                                  	;movsw		; (R)ight Channel
  3434 00001AD7 A5                      	movsd
  3435                                  
  3436 00001AD8 49                      	dec	ecx
  3437 00001AD9 7489                    	jz	short lff44s2_3	
  3438 00001ADB 4D                      	dec	ebp
  3439 00001ADC 75F9                    	jnz	short lff44s2_2_2
  3440                                  	
  3441 00001ADE FE0D[3B200000]          	dec	byte [faz]
  3442 00001AE4 74C0                    	jz	short lff44s2_9 
  3443 00001AE6 BD0B000000              	mov	ebp, 11
  3444 00001AEB EBC5                    	jmp	short lff44s2_1
  3445                                  
  3446                                  ; .....................
  3447                                  
  3448                                  interpolating_3_8bit_mono:
  3449                                  	; 16/11/2023
  3450                                  	; al = [previous_val]
  3451                                  	; dl = [next_val]
  3452                                  	; original-interpolated-interpolated
  3453 00001AED 88C3                    	mov	bl, al
  3454 00001AEF 2C80                    	sub	al, 80h
  3455 00001AF1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3456 00001AF5 66AB                    	stosw		; original sample (L)
  3457 00001AF7 66AB                    	stosw		; original sample (R)
  3458 00001AF9 88D8                    	mov	al, bl
  3459 00001AFB 00D0                    	add	al, dl	
  3460 00001AFD D0D8                    	rcr	al, 1
  3461 00001AFF 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3462 00001B01 00D8                    	add	al, bl
  3463 00001B03 D0D8                    	rcr	al, 1
  3464 00001B05 2C80                    	sub	al, 80h
  3465 00001B07 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3466 00001B0B 66AB                    	stosw		; interpolated sample 1 (L)
  3467 00001B0D 66AB                    	stosw		; interpolated sample 1 (R)
  3468 00001B0F 88F8                    	mov	al, bh
  3469 00001B11 00D0                    	add	al, dl	; [next_val]
  3470 00001B13 D0D8                    	rcr	al, 1
  3471 00001B15 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3472 00001B19 66AB                    	stosw		; interpolated sample 2 (L)
  3473 00001B1B 66AB                    	stosw		; interpolated sample 2 (R)
  3474 00001B1D C3                      	retn
  3475                                  
  3476                                  interpolating_3_8bit_stereo:
  3477                                  	; 16/11/2023
  3478                                  	; al = [previous_val_l]
  3479                                  	; ah = [previous_val_r]
  3480                                  	; dl = [next_val_l]
  3481                                  	; dh = [next_val_r]	
  3482                                  	; original-interpolated-interpolated
  3483 00001B1E 89C3                    	mov	ebx, eax
  3484 00001B20 2C80                    	sub	al, 80h
  3485 00001B22 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3486 00001B26 66AB                    	stosw		; original sample (L)
  3487 00001B28 88F8                    	mov	al, bh
  3488 00001B2A 2C80                    	sub	al, 80h
  3489 00001B2C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3490 00001B30 66AB                    	stosw		; original sample (R)
  3491 00001B32 88D8                    	mov	al, bl
  3492 00001B34 00D0                    	add	al, dl	; [next_val_l]	
  3493 00001B36 D0D8                    	rcr	al, 1
  3494 00001B38 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3495 00001B39 00D8                    	add	al, bl	; [previous_val_l]
  3496 00001B3B D0D8                    	rcr	al, 1
  3497 00001B3D 2C80                    	sub	al, 80h
  3498 00001B3F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3499 00001B43 66AB                    	stosw		; interpolated sample 1 (L)
  3500 00001B45 88F8                    	mov	al, bh
  3501 00001B47 00F0                    	add	al, dh	; [next_val_r]
  3502 00001B49 D0D8                    	rcr	al, 1
  3503 00001B4B 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3504 00001B4C 00F8                    	add	al, bh	; [previous_val_r]
  3505 00001B4E D0D8                    	rcr	al, 1
  3506 00001B50 2C80                    	sub	al, 80h
  3507 00001B52 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3508 00001B56 66AB                    	stosw		; interpolated sample 1 (R)
  3509 00001B58 5B                      	pop	ebx ; **
  3510 00001B59 58                      	pop	eax ; *
  3511 00001B5A 00D0                    	add	al, dl	; [next_val_l]
  3512 00001B5C D0D8                    	rcr	al, 1
  3513 00001B5E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3514 00001B62 66AB                    	stosw		; interpolated sample 2 (L)
  3515 00001B64 88D8                    	mov	al, bl
  3516 00001B66 00F0                    	add	al, dh	; [next_val_r]
  3517 00001B68 D0D8                    	rcr	al, 1
  3518 00001B6A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3519 00001B6E 66AB                    	stosw		; interpolated sample 2 (R)
  3520 00001B70 C3                      	retn
  3521                                  
  3522                                  interpolating_2_8bit_mono:
  3523                                  	; 16/11/2023
  3524                                  	; al = [previous_val]
  3525                                  	; dl = [next_val]
  3526                                  	; original-interpolated
  3527 00001B71 88C3                    	mov	bl, al
  3528 00001B73 2C80                    	sub	al, 80h
  3529 00001B75 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3530 00001B79 66AB                    	stosw		; original sample (L)
  3531 00001B7B 66AB                    	stosw		; original sample (R)
  3532 00001B7D 88D8                    	mov	al, bl
  3533 00001B7F 00D0                    	add	al, dl	
  3534 00001B81 D0D8                    	rcr	al, 1
  3535 00001B83 2C80                    	sub	al, 80h
  3536 00001B85 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3537 00001B89 66AB                    	stosw		; interpolated sample (L)
  3538 00001B8B 66AB                    	stosw		; interpolated sample (R)
  3539 00001B8D C3                      	retn
  3540                                  
  3541                                  interpolating_2_8bit_stereo:
  3542                                  	; 16/11/2023
  3543                                  	; al = [previous_val_l]
  3544                                  	; ah = [previous_val_r]
  3545                                  	; dl = [next_val_l]
  3546                                  	; dh = [next_val_r]	
  3547                                  	; original-interpolated
  3548 00001B8E 89C3                    	mov	ebx, eax
  3549 00001B90 2C80                    	sub	al, 80h
  3550 00001B92 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3551 00001B96 66AB                    	stosw		; original sample (L)
  3552 00001B98 88F8                    	mov	al, bh
  3553 00001B9A 2C80                    	sub	al, 80h
  3554 00001B9C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3555 00001BA0 66AB                    	stosw		; original sample (R)
  3556 00001BA2 88D8                    	mov	al, bl	; [previous_val_l]
  3557 00001BA4 00D0                    	add	al, dl	; [next_val_l]	
  3558 00001BA6 D0D8                    	rcr	al, 1
  3559 00001BA8 2C80                    	sub	al, 80h
  3560 00001BAA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3561 00001BAE 66AB                    	stosw		; interpolated sample (L)
  3562 00001BB0 88F8                    	mov	al, bh
  3563 00001BB2 00F0                    	add	al, dh	; [next_val_r]
  3564 00001BB4 D0D8                    	rcr	al, 1
  3565 00001BB6 2C80                    	sub	al, 80h
  3566 00001BB8 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3567 00001BBC 66AB                    	stosw		; interpolated sample (R)
  3568 00001BBE C3                      	retn
  3569                                  
  3570                                  interpolating_3_16bit_mono:
  3571                                  	; 16/11/2023
  3572                                  	; ax = [previous_val]
  3573                                  	; dx = [next_val]
  3574                                  	; original-interpolated-interpolated
  3575                                  
  3576 00001BBF 66AB                    	stosw		; original sample (L)
  3577 00001BC1 66AB                    	stosw		; original sample (R)
  3578 00001BC3 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3579 00001BC6 50                      	push	eax ; *	; [previous_val]
  3580 00001BC7 80C680                  	add	dh, 80h
  3581 00001BCA 6601D0                  	add	ax, dx
  3582 00001BCD 66D1D8                  	rcr	ax, 1
  3583 00001BD0 5B                      	pop	ebx ; *		
  3584 00001BD1 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3585 00001BD2 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3586 00001BD5 66D1D8                  	rcr	ax, 1
  3587 00001BD8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3588 00001BDB 66AB                    	stosw 		; interpolated sample 1 (L)
  3589 00001BDD 66AB                    	stosw		; interpolated sample 1 (R)
  3590 00001BDF 89D8                    	mov	eax, ebx
  3591 00001BE1 6601D0                  	add	ax, dx	 ;interpolated middle + [next_val]
  3592 00001BE4 66D1D8                  	rcr	ax, 1
  3593 00001BE7 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3594 00001BEA 66AB                    	stosw		; interpolated sample 2 (L)
  3595 00001BEC 66AB                    	stosw		; interpolated sample 2 (R)
  3596 00001BEE C3                      	retn
  3597                                  
  3598                                  interpolating_3_16bit_stereo:
  3599                                  	; 16/11/2023
  3600                                  	; bx = [previous_val_l]
  3601                                  	; ax = [previous_val_r]
  3602                                  	; [next_val_l]
  3603                                  	; dx = [next_val_r]
  3604                                  	; original-interpolated-interpolated
  3605                                  
  3606 00001BEF 93                      	xchg	eax, ebx
  3607 00001BF0 66AB                    	stosw		; original sample (L)
  3608 00001BF2 93                      	xchg	eax, ebx
  3609 00001BF3 66AB                    	stosw		; original sample (R)
  3610 00001BF5 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3611 00001BF8 50                      	push	eax ; *	; [previous_val_r]
  3612 00001BF9 80C780                  	add	bh, 80h
  3613 00001BFC 8005[38200000]80        	add	byte [next_val_l+1], 80h
  3614 00001C03 66A1[37200000]          	mov	ax, [next_val_l]
  3615 00001C09 6601D8                  	add	ax, bx	; [previous_val_l]
  3616 00001C0C 66D1D8                  	rcr	ax, 1
  3617 00001C0F 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  3618 00001C10 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3619 00001C13 66D1D8                  	rcr	ax, 1
  3620 00001C16 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3621 00001C19 66AB                    	stosw 		; interpolated sample 1 (L)
  3622 00001C1B 58                      	pop	eax  ; *
  3623 00001C1C 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  3624 00001C1F 52                      	push	edx  ; * ; [next_val_r]
  3625 00001C20 92                      	xchg	eax, edx
  3626 00001C21 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  3627 00001C24 66D1D8                  	rcr	ax, 1	; / 2
  3628 00001C27 50                      	push	eax ; ** ; interpolated middle (R)
  3629 00001C28 6601D0                  	add	ax, dx	; + [previous_val_r]
  3630 00001C2B 66D1D8                  	rcr	ax, 1
  3631 00001C2E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3632 00001C31 66AB                    	stosw 		; interpolated sample 1 (R)
  3633 00001C33 66A1[37200000]          	mov	ax, [next_val_l]
  3634 00001C39 6601D8                  	add	ax, bx	; + interpolated middle (L)
  3635 00001C3C 66D1D8                  	rcr	ax, 1
  3636 00001C3F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3637 00001C42 66AB                    	stosw 		; interpolated sample 2 (L)
  3638 00001C44 58                      	pop	eax ; **
  3639 00001C45 5A                      	pop	edx ; *	
  3640 00001C46 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  3641 00001C49 66D1D8                  	rcr	ax, 1	; / 2
  3642 00001C4C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3643 00001C4F 66AB                    	stosw 		; interpolated sample 2 (L)
  3644 00001C51 C3                      	retn
  3645                                  
  3646                                  interpolating_2_16bit_mono:
  3647                                  	; 16/11/2023
  3648                                  	; ax = [previous_val]
  3649                                  	; dx = [next_val]
  3650                                  	; original-interpolated
  3651                                  
  3652 00001C52 66AB                    	stosw		; original sample (L)
  3653 00001C54 66AB                    	stosw		; original sample (R)
  3654 00001C56 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3655 00001C59 80C680                  	add	dh, 80h
  3656 00001C5C 6601D0                  	add	ax, dx
  3657 00001C5F 66D1D8                  	rcr	ax, 1
  3658 00001C62 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3659 00001C65 66AB                    	stosw		; interpolated sample (L)
  3660 00001C67 66AB                    	stosw		; interpolated sample (R)
  3661 00001C69 C3                      	retn
  3662                                  
  3663                                  interpolating_2_16bit_stereo:
  3664                                  	; 16/11/2023
  3665                                  	; bx = [previous_val_l]
  3666                                  	; ax = [previous_val_r]
  3667                                  	; [next_val_l]
  3668                                  	; dx = [next_val_r]
  3669                                  	; original-interpolated
  3670                                  
  3671 00001C6A 93                      	xchg	eax, ebx
  3672 00001C6B 66AB                    	stosw		; original sample (L)
  3673 00001C6D 93                      	xchg	eax, ebx
  3674 00001C6E 66AB                    	stosw		; original sample (R)
  3675 00001C70 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3676 00001C73 80C680                  	add	dh, 80h
  3677 00001C76 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  3678 00001C79 66D1D8                  	rcr	ax, 1	; / 2
  3679 00001C7C 50                      	push	eax ; *	; interpolated sample (R)
  3680 00001C7D 66A1[37200000]          	mov	ax, [next_val_l]
  3681 00001C83 80C480                  	add	ah, 80h
  3682 00001C86 80C780                  	add	bh, 80h
  3683 00001C89 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  3684 00001C8C 66D1D8                  	rcr	ax, 1	; / 2		
  3685 00001C8F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3686 00001C92 66AB                    	stosw 		; interpolated sample (L)
  3687 00001C94 58                      	pop	eax ; *	
  3688 00001C95 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3689 00001C98 66AB                    	stosw 		; interpolated sample (R)
  3690 00001C9A C3                      	retn
  3691                                  
  3692                                  interpolating_5_8bit_mono:
  3693                                  	; 17/11/2023
  3694                                  	; al = [previous_val]
  3695                                  	; dl = [next_val]
  3696                                  	; original-interpltd-interpltd-interpltd-interpltd
  3697 00001C9B 88C3                    	mov	bl, al
  3698 00001C9D 2C80                    	sub	al, 80h
  3699 00001C9F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3700 00001CA3 66AB                    	stosw		; original sample (L)
  3701 00001CA5 66AB                    	stosw		; original sample (R)
  3702 00001CA7 88D8                    	mov	al, bl
  3703 00001CA9 00D0                    	add	al, dl	
  3704 00001CAB D0D8                    	rcr	al, 1
  3705 00001CAD 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3706 00001CAF 00D8                    	add	al, bl  ; [previous_val]
  3707 00001CB1 D0D8                    	rcr	al, 1 	
  3708 00001CB3 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  3709 00001CB5 00D8                    	add	al, bl
  3710 00001CB7 D0D8                    	rcr	al, 1
  3711 00001CB9 2C80                    	sub	al, 80h
  3712 00001CBB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3713 00001CBF 66AB                    	stosw		; interpolated sample 1 (L)
  3714 00001CC1 66AB                    	stosw		; interpolated sample 1 (R)
  3715 00001CC3 88F8                    	mov	al, bh
  3716 00001CC5 00F0                    	add	al, dh
  3717 00001CC7 D0D8                    	rcr	al, 1
  3718 00001CC9 2C80                    	sub	al, 80h
  3719 00001CCB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3720 00001CCF 66AB                    	stosw		; interpolated sample 2 (L)
  3721 00001CD1 66AB                    	stosw		; interpolated sample 2 (R)
  3722 00001CD3 88F8                    	mov	al, bh
  3723 00001CD5 00D0                    	add	al, dl	; [next_val]
  3724 00001CD7 D0D8                    	rcr	al, 1
  3725 00001CD9 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  3726 00001CDB 00F8                    	add	al, bh
  3727 00001CDD D0D8                    	rcr	al, 1
  3728 00001CDF 2C80                    	sub	al, 80h
  3729 00001CE1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3730 00001CE5 66AB                    	stosw		; interpolated sample 3 (L)
  3731 00001CE7 66AB                    	stosw		; interpolated sample 3 (R)
  3732 00001CE9 88F0                    	mov	al, dh
  3733 00001CEB 00D0                    	add	al, dl
  3734 00001CED D0D8                    	rcr	al, 1
  3735 00001CEF 2C80                    	sub	al, 80h
  3736 00001CF1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3737 00001CF5 66AB                    	stosw		; interpolated sample 4 (L)
  3738 00001CF7 66AB                    	stosw		; interpolated sample 4 (R)
  3739 00001CF9 C3                      	retn
  3740                                  
  3741                                  interpolating_5_8bit_stereo:
  3742                                  	; 17/11/2023
  3743                                  	; al = [previous_val_l]
  3744                                  	; ah = [previous_val_r]
  3745                                  	; dl = [next_val_l]
  3746                                  	; dh = [next_val_r]	
  3747                                  	; original-interpltd-interpltd-interpltd-interpltd
  3748 00001CFA 89C3                    	mov	ebx, eax
  3749 00001CFC 2C80                    	sub	al, 80h
  3750 00001CFE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3751 00001D02 66AB                    	stosw		; original sample (L)
  3752 00001D04 88F8                    	mov	al, bh
  3753 00001D06 2C80                    	sub	al, 80h
  3754 00001D08 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3755 00001D0C 66AB                    	stosw		; original sample (R)
  3756 00001D0E 52                      	push	edx ; *
  3757 00001D0F 88D8                    	mov	al, bl
  3758 00001D11 00D0                    	add	al, dl	; [next_val_l]
  3759 00001D13 D0D8                    	rcr	al, 1
  3760 00001D15 50                      	push	eax ; **	; al = interpolated middle (L) (temporary)
  3761 00001D16 00D8                    	add	al, bl	; [previous_val_l]
  3762 00001D18 D0D8                    	rcr	al, 1
  3763 00001D1A 86C3                    	xchg	al, bl	
  3764 00001D1C 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  3765 00001D1E D0D8                    	rcr	al, 1
  3766 00001D20 2C80                    	sub	al, 80h
  3767 00001D22 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3768 00001D26 66AB                    	stosw		; interpolated sample 1 (L)
  3769 00001D28 88F8                    	mov	al, bh
  3770 00001D2A 00F0                    	add	al, dh	; [next_val_r]
  3771 00001D2C D0D8                    	rcr	al, 1
  3772 00001D2E 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  3773 00001D2F 00F8                    	add	al, bh	; [previous_val_r]
  3774 00001D31 D0D8                    	rcr	al, 1
  3775 00001D33 86C7                    	xchg	al, bh	
  3776 00001D35 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  3777 00001D37 D0D8                    	rcr	al, 1
  3778 00001D39 2C80                    	sub	al, 80h
  3779 00001D3B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3780 00001D3F 66AB                    	stosw		; interpolated sample 1 (R)
  3781 00001D41 5A                      	pop	edx ; ***
  3782 00001D42 58                      	pop	eax ; **	; al = interpolated middle (L) (temporary)
  3783 00001D43 86C3                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  3784 00001D45 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  3785 00001D47 D0D8                    	rcr	al, 1
  3786 00001D49 2C80                    	sub	al, 80h
  3787 00001D4B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3788 00001D4F 66AB                    	stosw		; interpolated sample 2 (L)	
  3789 00001D51 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  3790 00001D53 86C7                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  3791 00001D55 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  3792 00001D57 D0D8                    	rcr	al, 1
  3793 00001D59 2C80                    	sub	al, 80h
  3794 00001D5B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3795 00001D5F 66AB                    	stosw		; interpolated sample 2 (R)
  3796 00001D61 5A                      	pop	edx ; *
  3797 00001D62 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  3798 00001D64 00D0                    	add	al, dl	; [next_val_l]
  3799 00001D66 D0D8                    	rcr	al, 1
  3800 00001D68 86C3                    	xchg	al, bl	; al = interpolated middle (R) (temporary)	
  3801 00001D6A 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp) 
  3802 00001D6C D0D8                    	rcr	al, 1
  3803 00001D6E 2C80                    	sub	al, 80h
  3804 00001D70 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3805 00001D74 66AB                    	stosw		; interpolated sample 3 (L)
  3806 00001D76 88F8                    	mov	al, bh	
  3807 00001D78 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  3808 00001D7A D0D8                    	rcr	al, 1
  3809 00001D7C 86C7                    	xchg	al, bh	; al = interpolated middle (R)
  3810 00001D7E 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  3811 00001D80 D0D8                    	rcr	al, 1
  3812 00001D82 2C80                    	sub	al, 80h
  3813 00001D84 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3814 00001D88 66AB                    	stosw		; interpolated sample 3 (R)
  3815 00001D8A 88D8                    	mov	al, bl
  3816 00001D8C 00D0                    	add	al, dl	; [next_val_l]
  3817 00001D8E D0D8                    	rcr	al, 1
  3818 00001D90 2C80                    	sub	al, 80h
  3819 00001D92 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3820 00001D96 66AB                    	stosw		; interpolated sample 4 (L)
  3821 00001D98 88F8                    	mov	al, bh
  3822 00001D9A 00F0                    	add	al, dh	; [next_val_r]
  3823 00001D9C D0D8                    	rcr	al, 1
  3824 00001D9E 2C80                    	sub	al, 80h
  3825 00001DA0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3826 00001DA4 66AB                    	stosw		; interpolated sample 4 (R)
  3827 00001DA6 C3                      	retn
  3828                                  
  3829                                  interpolating_4_8bit_mono:
  3830                                  	; 17/11/2023
  3831                                  	; al = [previous_val]
  3832                                  	; dl = [next_val]
  3833                                  	; original-interpolated-interpolated-interpolated
  3834 00001DA7 88C3                    	mov	bl, al
  3835 00001DA9 2C80                    	sub	al, 80h
  3836 00001DAB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3837 00001DAF 66AB                    	stosw		; original sample (L)
  3838 00001DB1 66AB                    	stosw		; original sample (R)
  3839 00001DB3 88D8                    	mov	al, bl
  3840 00001DB5 00D0                    	add	al, dl	
  3841 00001DB7 D0D8                    	rcr	al, 1
  3842 00001DB9 86C3                    	xchg	al, bl  ; al = [previous_val]
  3843 00001DBB 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  3844 00001DBD D0D8                    	rcr	al, 1 	
  3845 00001DBF 2C80                    	sub	al, 80h
  3846 00001DC1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3847 00001DC5 66AB                    	stosw		; interpolated sample 1 (L)
  3848 00001DC7 66AB                    	stosw		; interpolated sample 1 (R)
  3849 00001DC9 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  3850 00001DCB 2C80                    	sub	al, 80h
  3851 00001DCD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3852 00001DD1 66AB                    	stosw		; interpolated sample 2 (L)
  3853 00001DD3 66AB                    	stosw		; interpolated sample 2 (R)
  3854 00001DD5 88D8                    	mov	al, bl
  3855 00001DD7 00D0                    	add	al, dl	; [next_val]
  3856 00001DD9 D0D8                    	rcr	al, 1
  3857 00001DDB 2C80                    	sub	al, 80h
  3858 00001DDD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3859 00001DE1 66AB                    	stosw		; interpolated sample 3 (L)
  3860 00001DE3 66AB                    	stosw		; interpolated sample 3 (R)
  3861 00001DE5 C3                      	retn
  3862                                  
  3863                                  interpolating_4_8bit_stereo:
  3864                                  	; 17/11/2023
  3865                                  	; al = [previous_val_l]
  3866                                  	; ah = [previous_val_r]
  3867                                  	; dl = [next_val_l]
  3868                                  	; dh = [next_val_r]	
  3869                                  	; original-interpolated-interpolated-interpolated
  3870 00001DE6 89C3                    	mov	ebx, eax
  3871 00001DE8 2C80                    	sub	al, 80h
  3872 00001DEA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3873 00001DEE 66AB                    	stosw		; original sample (L)
  3874 00001DF0 88F8                    	mov	al, bh
  3875 00001DF2 2C80                    	sub	al, 80h
  3876 00001DF4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3877 00001DF8 66AB                    	stosw		; original sample (R)
  3878 00001DFA 88D8                    	mov	al, bl
  3879 00001DFC 00D0                    	add	al, dl	; [next_val_l]
  3880 00001DFE D0D8                    	rcr	al, 1
  3881 00001E00 86C3                    	xchg	al, bl	; al = [previous_val_l]
  3882 00001E02 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  3883 00001E04 D0D8                    	rcr	al, 1
  3884 00001E06 2C80                    	sub	al, 80h
  3885 00001E08 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3886 00001E0C 66AB                    	stosw		; interpolated sample 1 (L)
  3887 00001E0E 88F8                    	mov	al, bh
  3888 00001E10 00F0                    	add	al, dh	; [next_val_r]
  3889 00001E12 D0D8                    	rcr	al, 1
  3890 00001E14 86C7                    	xchg	al, bh	; al = [previous_val_h]
  3891 00001E16 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  3892 00001E18 D0D8                    	rcr	al, 1
  3893 00001E1A 2C80                    	sub	al, 80h
  3894 00001E1C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3895 00001E20 66AB                    	stosw		; interpolated sample 1 (R)
  3896 00001E22 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  3897 00001E24 2C80                    	sub	al, 80h
  3898 00001E26 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3899 00001E2A 66AB                    	stosw		; interpolated sample 2 (L)
  3900 00001E2C 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  3901 00001E2E 2C80                    	sub	al, 80h
  3902 00001E30 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3903 00001E34 66AB                    	stosw		; interpolated sample 2 (L)
  3904 00001E36 88D8                    	mov	al, bl
  3905 00001E38 00D0                    	add	al, dl	; [next_val_l]
  3906 00001E3A D0D8                    	rcr	al, 1
  3907 00001E3C 2C80                    	sub	al, 80h
  3908 00001E3E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3909 00001E42 66AB                    	stosw		; interpolated sample 3 (L)
  3910 00001E44 88F8                    	mov	al, bh
  3911 00001E46 00F0                    	add	al, dh	; [next_val_r]
  3912 00001E48 D0D8                    	rcr	al, 1
  3913 00001E4A 2C80                    	sub	al, 80h
  3914 00001E4C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3915 00001E50 66AB                    	stosw		; interpolated sample 3 (R)
  3916 00001E52 C3                      	retn
  3917                                  
  3918                                  interpolating_5_16bit_mono:
  3919                                  	; 18/11/2023
  3920                                  	; ax = [previous_val]
  3921                                  	; dx = [next_val]
  3922                                  	; original-interpltd-interpltd-interpltd-interpltd
  3923 00001E53 66AB                    	stosw		; original sample (L)
  3924 00001E55 66AB                    	stosw		; original sample (R)
  3925 00001E57 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3926 00001E5A 89C3                    	mov	ebx, eax ; [previous_val]
  3927 00001E5C 80C680                  	add	dh, 80h
  3928 00001E5F 6601D0                  	add	ax, dx
  3929 00001E62 66D1D8                  	rcr	ax, 1
  3930 00001E65 50                      	push	eax ; *	; interpolated middle (temporary)
  3931 00001E66 6601D8                  	add	ax, bx	; interpolated middle + [previous_val] 
  3932 00001E69 66D1D8                  	rcr	ax, 1
  3933 00001E6C 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  3934 00001E6D 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  3935 00001E70 66D1D8                  	rcr	ax, 1	
  3936 00001E73 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3937 00001E76 66AB                    	stosw 		; interpolated sample 1 (L)
  3938 00001E78 66AB                    	stosw		; interpolated sample 1 (R)
  3939 00001E7A 58                      	pop	eax ; **	
  3940 00001E7B 5B                      	pop	ebx ; *
  3941 00001E7C 6601D8                  	add	ax, bx	; 1st quarter + middle
  3942 00001E7F 66D1D8                  	rcr	ax, 1	; / 2
  3943 00001E82 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  3944 00001E85 66AB                    	stosw		; interpolated sample 2 (L)
  3945 00001E87 66AB                    	stosw		; interpolated sample 2 (R)		
  3946 00001E89 89D8                    	mov	eax, ebx
  3947 00001E8B 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  3948 00001E8E 66D1D8                  	rcr	ax, 1
  3949 00001E91 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  3950 00001E92 6601D8                  	add	ax, bx	; + interpolated middle
  3951 00001E95 66D1D8                  	rcr	ax, 1
  3952 00001E98 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3953 00001E9B 66AB                    	stosw		; interpolated sample 3 (L)
  3954 00001E9D 66AB                    	stosw		; interpolated sample 3 (R)
  3955 00001E9F 58                      	pop	eax ; *	
  3956 00001EA0 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  3957 00001EA3 66D1D8                  	rcr	ax, 1	; / 2
  3958 00001EA6 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3959 00001EA9 66AB                    	stosw		; interpolated sample 4 (L)
  3960 00001EAB 66AB                    	stosw		; interpolated sample 4 (R)
  3961 00001EAD C3                      	retn
  3962                                  
  3963                                  interpolating_5_16bit_stereo:
  3964                                  	; 18/11/2023
  3965                                  	; bx = [previous_val_l]
  3966                                  	; ax = [previous_val_r]
  3967                                  	; [next_val_l]
  3968                                  	; [next_val_r]
  3969                                  	; original-interpltd-interpltd-interpltd-interpltd
  3970 00001EAE 51                      	push	ecx ; !
  3971 00001EAF 93                      	xchg	eax, ebx
  3972 00001EB0 66AB                    	stosw		; original sample (L)
  3973 00001EB2 93                      	xchg	eax, ebx
  3974 00001EB3 66AB                    	stosw		; original sample (R)
  3975 00001EB5 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3976 00001EB8 50                      	push	eax ; *	; [previous_val_r]
  3977 00001EB9 80C780                  	add	bh, 80h
  3978 00001EBC 8005[38200000]80        	add	byte [next_val_l+1], 80h
  3979 00001EC3 66A1[37200000]          	mov	ax, [next_val_l]
  3980 00001EC9 6601D8                  	add	ax, bx	; [previous_val_l]
  3981 00001ECC 66D1D8                  	rcr	ax, 1
  3982 00001ECF 89C1                    	mov	ecx, eax ; interpolated middle (L)
  3983 00001ED1 6601D8                  	add	ax, bx	
  3984 00001ED4 66D1D8                  	rcr	ax, 1
  3985 00001ED7 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)	
  3986 00001ED9 6601D8                  	add	ax, bx	; [previous_val_l]
  3987 00001EDC 66D1D8                  	rcr	ax, 1
  3988 00001EDF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3989 00001EE2 66AB                    	stosw 		; interpolated sample 1 (L)
  3990 00001EE4 89C8                    	mov	eax, ecx
  3991 00001EE6 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L) 
  3992 00001EE9 66D1D8                  	rcr	ax, 1	; / 2
  3993 00001EEC 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  3994 00001EEE 5A                      	pop	edx ; *	; [previous_val_r]
  3995 00001EEF 89D0                    	mov	eax, edx
  3996 00001EF1 8005[3A200000]80        	add	byte [next_val_r+1], 80h
  3997 00001EF8 660305[39200000]        	add	ax, [next_val_r]
  3998 00001EFF 66D1D8                  	rcr	ax, 1
  3999 00001F02 50                      	push	eax ; *	; interpolated middle (R)
  4000 00001F03 6601D0                  	add	ax, dx
  4001 00001F06 66D1D8                  	rcr	ax, 1
  4002 00001F09 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  4003 00001F0A 6601D0                  	add	ax, dx	; [previous_val_r]
  4004 00001F0D 66D1D8                  	rcr	ax, 1
  4005 00001F10 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4006 00001F13 66AB                    	stosw 		; interpolated sample 1 (R)
  4007 00001F15 89D8                    	mov	eax, ebx
  4008 00001F17 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4009 00001F1A 66AB                    	stosw 		; interpolated sample 2 (L)
  4010 00001F1C 58                      	pop	eax ; **
  4011 00001F1D 5A                      	pop	edx ; *
  4012 00001F1E 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  4013 00001F21 66D1D8                  	rcr	ax, 1	; / 2
  4014 00001F24 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4015 00001F27 66AB                    	stosw 		; interpolated sample 2 (R)
  4016 00001F29 89C8                    	mov	eax, ecx
  4017 00001F2B 660305[37200000]        	add	ax, [next_val_l]
  4018 00001F32 66D1D8                  	rcr	ax, 1
  4019 00001F35 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  4020 00001F36 6601C8                  	add	ax, cx	; interpolated middle (L)
  4021 00001F39 66D1D8                  	rcr	ax, 1
  4022 00001F3C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4023 00001F3F 66AB                    	stosw 		; interpolated sample 3 (L)
  4024 00001F41 89D0                    	mov	eax, edx
  4025 00001F43 660305[39200000]        	add	ax, [next_val_r]
  4026 00001F4A 66D1D8                  	rcr	ax, 1
  4027 00001F4D 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4028 00001F4E 6601D0                  	add	ax, dx	; interpolated middle (R)
  4029 00001F51 66D1D8                  	rcr	ax, 1
  4030 00001F54 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4031 00001F57 66AB                    	stosw 		; interpolated sample 3 (R)
  4032 00001F59 5B                      	pop	ebx ; **
  4033 00001F5A 58                      	pop	eax ; *
  4034 00001F5B 660305[37200000]        	add	ax, [next_val_l]
  4035 00001F62 66D1D8                  	rcr	ax, 1
  4036 00001F65 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4037 00001F68 66AB                    	stosw 		; interpolated sample 4 (L)
  4038 00001F6A 89D8                    	mov	eax, ebx	
  4039 00001F6C 660305[39200000]        	add	ax, [next_val_r]
  4040 00001F73 66D1D8                  	rcr	ax, 1
  4041 00001F76 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4042 00001F79 66AB                    	stosw 		; interpolated sample 4 (R)
  4043 00001F7B 59                      	pop	ecx ; !
  4044 00001F7C C3                      	retn
  4045                                  
  4046                                  interpolating_4_16bit_mono:
  4047                                  	; 18/11/2023
  4048                                  	; ax = [previous_val]
  4049                                  	; dx = [next_val]
  4050                                  	; original-interpolated
  4051                                  
  4052 00001F7D 66AB                    	stosw		; original sample (L)
  4053 00001F7F 66AB                    	stosw		; original sample (R)
  4054 00001F81 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4055 00001F84 89C3                    	mov	ebx, eax ; [previous_val]
  4056 00001F86 80C680                  	add	dh, 80h
  4057 00001F89 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4058 00001F8C 66D1D8                  	rcr	ax, 1
  4059 00001F8F 93                      	xchg	eax, ebx	
  4060 00001F90 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4061 00001F93 66D1D8                  	rcr	ax, 1
  4062 00001F96 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4063 00001F99 66AB                    	stosw 		; interpolated sample 1 (L)
  4064 00001F9B 66AB                    	stosw		; interpolated sample 1 (R)
  4065 00001F9D 89D8                    	mov	eax, ebx ; interpolated middle
  4066 00001F9F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4067 00001FA2 66AB                    	stosw 		; interpolated sample 2 (L)
  4068 00001FA4 66AB                    	stosw		; interpolated sample 2 (R)
  4069 00001FA6 89D8                    	mov	eax, ebx
  4070 00001FA8 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4071 00001FAB 66D1D8                  	rcr	ax, 1
  4072 00001FAE 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4073 00001FB1 66AB                    	stosw		; interpolated sample 3 (L)
  4074 00001FB3 66AB                    	stosw		; interpolated sample 3 (R)
  4075 00001FB5 C3                      	retn
  4076                                  
  4077                                  interpolating_4_16bit_stereo:
  4078                                  	; 18/11/2023
  4079                                  	; bx = [previous_val_l]
  4080                                  	; ax = [previous_val_r]
  4081                                  	; [next_val_l]
  4082                                  	; [next_val_r]
  4083                                  	; original-interpolated-interpolated-interpolated
  4084 00001FB6 93                      	xchg	eax, ebx
  4085 00001FB7 66AB                    	stosw		; original sample (L)
  4086 00001FB9 93                      	xchg	eax, ebx
  4087 00001FBA 66AB                    	stosw		; original sample (R)
  4088 00001FBC 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4089 00001FBF 89C2                    	mov	edx, eax ; [previous_val_r]
  4090 00001FC1 80C780                  	add	bh, 80h
  4091 00001FC4 8005[38200000]80        	add	byte [next_val_l+1], 80h
  4092 00001FCB 66A1[37200000]          	mov	ax, [next_val_l]
  4093 00001FD1 6601D8                  	add	ax, bx	; [previous_val_l]
  4094 00001FD4 66D1D8                  	rcr	ax, 1
  4095 00001FD7 93                      	xchg	eax, ebx	
  4096 00001FD8 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4097 00001FDB 66D1D8                  	rcr	ax, 1
  4098 00001FDE 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4099 00001FE1 66AB                    	stosw 		; interpolated sample 1 (L)
  4100 00001FE3 8005[3A200000]80        	add	byte [next_val_r+1], 80h
  4101 00001FEA 89D0                    	mov	eax, edx ; [previous_val_r]
  4102 00001FEC 660305[39200000]        	add	ax, [next_val_r]
  4103 00001FF3 66D1D8                  	rcr	ax, 1
  4104 00001FF6 92                      	xchg	eax, edx	
  4105 00001FF7 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4106 00001FFA 66D1D8                  	rcr	ax, 1
  4107 00001FFD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4108 00002000 66AB                    	stosw 		; interpolated sample 1 (R)
  4109 00002002 89D8                    	mov	eax, ebx
  4110 00002004 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4111 00002007 66AB                    	stosw 		; interpolated sample 2 (L)
  4112 00002009 89D0                    	mov	eax, edx
  4113 0000200B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4114 0000200E 66AB                    	stosw 		; interpolated sample 2 (R)
  4115 00002010 89D8                    	mov	eax, ebx
  4116 00002012 660305[37200000]        	add	ax, [next_val_l]
  4117 00002019 66D1D8                  	rcr	ax, 1
  4118 0000201C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4119 0000201F 66AB                    	stosw 		; interpolated sample 3 (L)
  4120 00002021 89D0                    	mov	eax, edx
  4121 00002023 660305[39200000]        	add	ax, [next_val_r]
  4122 0000202A 66D1D8                  	rcr	ax, 1
  4123 0000202D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4124 00002030 66AB                    	stosw 		; interpolated sample 3 (R)
  4125 00002032 C3                      	retn
  4126                                  
  4127                                  ; 13/11/2023
  4128                                  previous_val:
  4129 00002033 0000                    previous_val_l: dw 0
  4130 00002035 0000                    previous_val_r: dw 0
  4131                                  next_val:
  4132 00002037 0000                    next_val_l: dw 0
  4133 00002039 0000                    next_val_r: dw 0
  4134                                  
  4135                                  ; 16/11/2023
  4136 0000203B 00                      faz:	db 0	
  4137                                  	
  4138                                  ; --------------------------------------------------------
  4139                                  
  4140                                  ; DATA
  4141                                  
  4142                                  FileHandle:	
  4143 0000203C FFFFFFFF                	dd	-1
  4144                                  
  4145                                  Credits:
  4146 00002040 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  4146 00002049 506C6179657220666F-
  4146 00002052 72205452444F532033-
  4146 0000205B 383620627920457264-
  4146 00002064 6F67616E2054616E2E-
  4146 0000206D 20                 
  4147                                  	;;db	'August 2020.',10,13,0
  4148                                  	;db	'November 2023.',10,13,0
  4149 0000206E 4A756E652032303234-     	db	'June 2024.', 10,13,0
  4149 00002077 2E0A0D00           
  4150 0000207B 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  4150 00002084 370A0D00           
  4151 00002088 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  4151 00002091 300A0D00           
  4152 00002095 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  4152 0000209E 330A0D00           
  4153 000020A2 30312F30362F323032-     	db	'01/06/2024', 10,13,0
  4153 000020AB 340A0D00           
  4154 000020AF 30342F30362F323032-     	db	'04/06/2024', 10,13,0
  4154 000020B8 340A0D00           
  4155                                  
  4156                                  msgAudioCardInfo:
  4157 000020BC 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  4157 000020C5 204143393720284943-
  4157 000020CE 482920417564696F20-
  4157 000020D7 436F6E74726F6C6C65-
  4157 000020E0 722E0A0D00         
  4158                                  
  4159                                  msg_usage:
  4160 000020E5 75736167653A20706C-     	db	'usage: playwav6 filename.wav',10,13,0
  4160 000020EE 617977617636206669-
  4160 000020F7 6C656E616D652E7761-
  4160 00002100 760A0D00           
  4161                                  
  4162                                  noDevMsg:
  4163 00002104 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  4163 0000210D 61626C6520746F2066-
  4163 00002116 696E64204143393720-
  4163 0000211F 617564696F20646576-
  4163 00002128 69636521           
  4164 0000212C 0A0D00                  	db	10,13,0
  4165                                  
  4166                                  noFileErrMsg:
  4167 0000212F 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  4167 00002138 6C65206E6F7420666F-
  4167 00002141 756E642E0A0D00     
  4168                                  
  4169                                  trdos386_err_msg:
  4170 00002148 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  4170 00002151 2053797374656D2063-
  4170 0000215A 616C6C206572726F72-
  4170 00002163 20210A0D00         
  4171                                  
  4172                                  ; 01/06/2024
  4173                                  msg_init_err:
  4174 00002168 0A0D                    	db	10,13
  4175 0000216A 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  4175 00002173 726F6C6C65722F436F-
  4175 0000217C 64656320696E697469-
  4175 00002185 616C697A6174696F6E-
  4175 0000218E 206572726F722021   
  4176 00002196 0A0D00                  	db	10,13,0
  4177                                  
  4178                                  ; 25/11/2023
  4179                                  msg_no_vra:
  4180 00002199 0A0D                    	db	10,13
  4181 0000219B 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  4181 000021A4 70706F72742021204F-
  4181 000021AD 6E6C79203438206B48-
  4181 000021B6 5A2073616D706C6520-
  4181 000021BF 726174652073757070-
  4181 000021C8 6F727465642021     
  4182 000021CF 0A0D00                  	db	10,13,0
  4183                                  
  4184 000021D2 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  4184 000021DB 65204E616D653A2000 
  4185 000021E4 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  4185 000021ED 526174653A20       
  4186 000021F3 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  4186 000021FC 2000               
  4187 000021FE 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  4188 00002207 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  4189 0000220E 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  4189 00002217 00                 
  4190 00002218 53746572656F            msgStereo:	db "Stereo"
  4191 0000221E 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  4192                                  
  4193                                  ; 03/06/2017
  4194 00002221 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  4194 0000222A 3941424344454600   
  4195 00002232 0D0A                    msgAC97Info	db 0Dh, 0Ah
  4196 00002234 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  4196 0000223D 6F20436F6E74726F6C-
  4196 00002246 6C6572202620436F64-
  4196 0000224F 656320496E666F0D0A 
  4197 00002258 56656E646F72204944-     		db "Vendor ID: "
  4197 00002261 3A20               
  4198 00002263 303030306820446576-     msgVendorId	db "0000h Device ID: "
  4198 0000226C 6963652049443A20   
  4199 00002274 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  4200 0000227B 4275733A20              		db "Bus: "
  4201 00002280 303068204465766963-     msgBusNo	db "00h Device: "
  4201 00002289 653A20             
  4202 0000228C 3030682046756E6374-     msgDevNo	db "00h Function: "
  4202 00002295 696F6E3A20         
  4203 0000229A 303068                  msgFncNo	db "00h"
  4204 0000229D 0D0A                    		db 0Dh, 0Ah
  4205 0000229F 4E414D4241523A20        		db "NAMBAR: "
  4206 000022A7 30303030682020          msgNamBar	db "0000h  "
  4207 000022AE 4E41424D4241523A20      		db "NABMBAR: "
  4208 000022B7 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  4208 000022C0 513A20             
  4209 000022C3 3030                    msgIRQ		dw 3030h
  4210 000022C5 0D0A00                  		db 0Dh, 0Ah, 0
  4211                                  ; 25/11/2023
  4212 000022C8 56524120737570706F-     msgVRAheader:	db "VRA support: "
  4212 000022D1 72743A20           
  4213 000022D5 00                      		db 0	
  4214 000022D6 5945530D0A00            msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  4215 000022DC 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  4216 000022E1 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  4216 000022EA 617465642073616D70-
  4216 000022F3 6C6520726174652070-
  4216 000022FC 6C6179696E67206D65-
  4216 00002305 74686F6429         
  4217 0000230A 0D0A00                  		db 0Dh, 0Ah, 0	
  4218                                  EOF: 
  4219                                  
  4220                                  ; BSS
  4221                                  
  4222                                  bss_start:
  4223                                  
  4224                                  ABSOLUTE bss_start
  4225                                  
  4226 0000230D ??????                  alignb 4
  4227                                  
  4228 00002310 ??                      stmo:		resb 1 ; stereo or mono (1=stereo) 
  4229 00002311 ??                      bps:		resb 1 ; bits per sample (8,16)
  4230 00002312 ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  4231                                  
  4232                                  ; 25/11/2023
  4233 00002314 ????????                bufferSize:	resd 1
  4234                                  
  4235 00002318 ??                      flags:		resb 1
  4236                                  ;cbs_busy:	resb 1 
  4237 00002319 ??                      half_buff:	resb 1
  4238 0000231A ??                      srb:		resb 1
  4239                                  ; 18/08/2020
  4240 0000231B ??                      volume_level:	resb 1
  4241                                  ; 25/11/2023
  4242 0000231C ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  4243                                  
  4244 0000231D <res 1Ch>               smpRBuff:	resw 14 
  4245                                  
  4246                                  wav_file_name:
  4247 00002339 <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  4248                                  
  4249 00002389 ????                    		resw 1
  4250 0000238B ??                      ac97_int_ln_reg: resb 1
  4251 0000238C ??                      fbs_shift:	resb 1 ; 26/11/2023
  4252 0000238D ????????                dev_vendor:	resd 1
  4253 00002391 ????????                bus_dev_fn:	resd 1
  4254 00002395 ????                    ac97_NamBar:	resw 1
  4255 00002397 ????                    ac97_NabmBar:	resw 1
  4256                                  
  4257                                  bss_end:
  4258 00002399 <res C67h>              alignb 4096
  4259                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  4260                                  ; 26/11/2023
  4261 00003000 <res 10000h>            audio_buffer:	resb 65536
  4262                                  ; 13/06/2017
  4263                                  ;temp_buffer:	resb BUFFERSIZE
  4264                                  ; 26/11/2023
  4265 00013000 <res 10000h>            temp_buffer:	resb 65536
