     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: 06/06/2024 ]
     9                                  ;
    10                                  ; Modified from PLAYWAV5.PRG .wav player program by Erdogan Tan, 18/08/2020
    11                                  ;
    12                                  ; Assembler: NASM version 2.15
    13                                  ;	     nasm playwav6.s -l playwav6.txt -o PLAYWAV6.PRG	
    14                                  ; ----------------------------------------------------------------------------
    15                                  ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
    16                                  
    17                                  ; previous version: playwav3.s (17/06/2017)
    18                                  
    19                                  ; CODE
    20                                  
    21                                  ; 14/07/2020
    22                                  ; 31/12/2017
    23                                  ; TRDOS 386 (v2.0) system calls
    24                                  _ver 	equ 0
    25                                  _exit 	equ 1
    26                                  _fork 	equ 2
    27                                  _read 	equ 3
    28                                  _write	equ 4
    29                                  _open	equ 5
    30                                  _close 	equ 6
    31                                  _wait 	equ 7
    32                                  _create	equ 8
    33                                  _rename	equ 9
    34                                  _delete	equ 10
    35                                  _exec	equ 11
    36                                  _chdir	equ 12
    37                                  _time 	equ 13
    38                                  _mkdir 	equ 14
    39                                  _chmod	equ 15
    40                                  _rmdir	equ 16
    41                                  _break	equ 17
    42                                  _drive	equ 18
    43                                  _seek	equ 19
    44                                  _tell 	equ 20
    45                                  _memory	equ 21
    46                                  _prompt	equ 22
    47                                  _path	equ 23
    48                                  _env	equ 24
    49                                  _stime	equ 25
    50                                  _quit	equ 26
    51                                  _intr	equ 27
    52                                  _dir	equ 28
    53                                  _emt 	equ 29
    54                                  _ldrvt 	equ 30
    55                                  _video 	equ 31
    56                                  _audio	equ 32
    57                                  _timer	equ 33
    58                                  _sleep	equ 34
    59                                  _msg    equ 35
    60                                  _geterr	equ 36
    61                                  _fpstat	equ 37
    62                                  _pri	equ 38
    63                                  _rele	equ 39
    64                                  _fff	equ 40
    65                                  _fnf	equ 41
    66                                  _alloc	equ 42
    67                                  _dalloc equ 43
    68                                  _calbac equ 44
    69                                  _dma	equ 45
    70                                  
    71                                  %macro sys 1-4
    72                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    73                                      ; 03/09/2015	
    74                                      ; 13/04/2015
    75                                      ; Retro UNIX 386 v1 system call.	
    76                                      %if %0 >= 2   
    77                                          mov ebx, %2
    78                                          %if %0 >= 3    
    79                                              mov ecx, %3
    80                                              %if %0 = 4
    81                                                 mov edx, %4   
    82                                              %endif
    83                                          %endif
    84                                      %endif
    85                                      mov eax, %1
    86                                      ;int 30h
    87                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
    88                                  %endmacro
    89                                  
    90                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    91                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    92                                  
    93                                  BUFFERSIZE	equ	32768	; audio buffer size 
    94                                  ENDOFFILE       equ     1	; flag for knowing end of file
    95                                  
    96                                  [BITS 32]
    97                                  
    98                                  [ORG 0] 
    99                                  
   100                                  _STARTUP:
   101                                  	; Prints the Credits Text.
   102                                  	sys	_msg, Credits, 255, 0Bh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000000 BB[0D210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000005 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000000A BA0B000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000000F B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000014 CD40                <1>  int 40h
   103                                  
   104                                  	; clear bss
   105 00000016 B9[99240000]            	mov	ecx, bss_end
   106 0000001B BF[0D240000]            	mov	edi, bss_start
   107 00000020 29F9                    	sub	ecx, edi
   108 00000022 D1E9                    	shr	ecx, 1
   109 00000024 31C0                    	xor	eax, eax
   110 00000026 F366AB                  	rep	stosw
   111                                  
   112                                  	; Detect (& Enable) AC'97 Audio Device
   113 00000029 E89B040000              	call	DetectAC97
   114 0000002E 731B                    	jnc     short GetFileName
   115                                  
   116                                  _dev_not_ready:
   117                                  ; couldn't find the audio device!
   118                                  	sys	_msg, noDevMsg, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000030 BB[D1210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000035 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000003A BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000003F B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000044 CD40                <1>  int 40h
   119 00000046 E958040000                      jmp     Exit
   120                                  
   121                                  GetFileName:  
   122 0000004B 89E6                    	mov	esi, esp
   123 0000004D AD                      	lodsd
   124 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   125                                  	       ; (program file name & mod file name)
   126 00000051 0F825A040000            	jb	pmsg_usage ; nothing to do
   127                                  
   128 00000057 AD                      	lodsd ; program file name address 
   129 00000058 AD                      	lodsd ; mod file name address (file to be read)
   130 00000059 89C6                    	mov	esi, eax
   131 0000005B BF[39240000]            	mov	edi, wav_file_name
   132                                  ScanName:       
   133 00000060 AC                      	lodsb
   134 00000061 84C0                    	test	al, al
   135 00000063 0F8448040000            	je	pmsg_usage
   136 00000069 3C20                    	cmp	al, 20h
   137 0000006B 74F3                    	je	short ScanName	; scan start of name.
   138 0000006D AA                      	stosb
   139 0000006E B4FF                    	mov	ah, 0FFh
   140                                  a_0:	
   141 00000070 FEC4                    	inc	ah
   142                                  a_1:
   143 00000072 AC                      	lodsb
   144 00000073 AA                      	stosb
   145 00000074 3C2E                    	cmp	al, '.'
   146 00000076 74F8                    	je	short a_0	
   147 00000078 20C0                    	and	al, al
   148 0000007A 75F6                    	jnz	short a_1
   149                                  
   150 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   151 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   152                                  SetExt:
   153 00000080 4F                      	dec	edi
   154 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   155 00000087 C6470400                	mov	byte [edi+4], 0
   156                                  
   157                                  _1:
   158                                  
   159                                  ; 26/11/2023
   160                                  %if 0
   161                                  	; Allocate Audio Buffer (for user)
   162                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   163                                  	; 26/11/2023
   164                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   165                                  	jnc	short _2
   166                                  error_exit:
   167                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   168                                  	jmp	Exit
   169                                  _2:
   170                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   171                                  	; bl = 0, bh = 4
   172                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   173                                  
   174                                  	sys	_video, 0400h
   175                                  	cmp	eax, 0B8000h
   176                                  	jne	short error_exit
   177                                  
   178                                  	; Initialize Audio Device (bh = 3)
   179                                  	sys	_audio, 0301h, 0, audio_int_handler 
   180                                  ;	jc	short error_exit
   181                                  _3:
   182                                  
   183                                  %endif
   184 0000008B E89C060000              	call	write_audio_dev_info 
   185                                  
   186                                  ; open the file
   187                                          ; open existing file
   188 00000090 E841040000                      call    openFile ; no error? ok.
   189 00000095 731B                            jnc     short _gsr
   190                                  
   191                                  ; file not found!
   192                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000097 BB[FC210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000009C B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000000A1 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000000A6 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000000AB CD40                <1>  int 40h
   193                                  _exit_:
   194 000000AD E9F1030000                      jmp     Exit
   195                                  
   196                                  _gsr:  
   197 000000B2 E859040000                     	call    getSampleRate		; read the sample rate
   198                                                                          ; pass it onto codec.
   199                                  	;jc	Exit
   200                                  	; 25/11/2023
   201 000000B7 72F4                    	jc	short _exit_
   202                                  
   203 000000B9 66A3[12240000]          	mov	[sample_rate], ax
   204 000000BF 880D[10240000]          	mov	[stmo], cl
   205 000000C5 8815[11240000]          	mov	[bps], dl
   206                                  
   207                                  	; 26/11/2023
   208 000000CB C605[8C240000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   209 000000D2 FEC9                    	dec	cl
   210 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   211 000000D6 FE05[8C240000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   212                                  _gsr_1:	
   213 000000DC 80FA08                  	cmp	dl, 8 
   214 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   215 000000E1 FE05[8C240000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   216                                  _gsr_2:	
   217                                  	; 06/06/2017
   218                                  	sys	_audio, 0E00h ; get audio controller info
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000000E7 BB000E0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000000EC B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000000F1 CD40                <1>  int 40h
   219 000000F3 0F82FE020000            	jc	error_exit ; 25/11/2023
   220                                  
   221                                  	;cmp	ah, 2 ; ICH ? (Intel AC'97 Audio Controller)
   222                                  	;jne	_dev_not_ready	
   223                                  
   224                                  	; EAX = IRQ Number in AL
   225                                  	;	Audio Device Number in AH 
   226                                  	; EBX = DEV/VENDOR ID
   227                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   228                                  	; ECX = BUS/DEV/FN 
   229                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   230                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   231                                  	;      (Low word, DX = NAMBAR address)
   232                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   233                                  
   234 000000F9 A2[8B240000]            	mov	[ac97_int_ln_reg], al
   235 000000FE 891D[8D240000]          	mov	[dev_vendor], ebx
   236 00000104 890D[91240000]          	mov	[bus_dev_fn], ecx
   237                                  	;mov	[ac97_NamBar], dx
   238                                  	;shr	dx, 16
   239                                  	;mov	[ac97_NabmBar], dx
   240 0000010A 8915[95240000]          	mov	[ac97_NamBar], edx	
   241                                    
   242                                  	; 06/06/2024
   243                                  	;; 01/06/2024
   244                                  	;; Reset Audio Device (bh = 8)
   245                                  	;sys	_audio, 0800h
   246                                  	;;jc	error_exit	
   247                                  	;jc	short init_err
   248                                  
   249 00000110 E8F9060000              	call	write_ac97_pci_dev_info
   250                                  
   251                                  	; 01/06/2024
   252                                  	; 25/11/2023
   253                                  	; Get AC'97 Codec info
   254                                  	; (Function 14, sub function 1)
   255                                  	sys	_audio, 0E01h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000115 BB010E0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000011A B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000011F CD40                <1>  int 40h
   256                                  	; 06/06/2024
   257 00000121 7310                    	jnc	short _gsr_3
   258                                  
   259                                  	; 06/06/2024
   260                                  	; a 2nd attempt
   261                                  	sys	_audio, 0E01h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000123 BB010E0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000128 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000012D CD40                <1>  int 40h
   262 0000012F 7302                    	jnc	short _gsr_3
   263                                  
   264 00000131 D1E0                    	shl	eax, 1 ; clears AL BIT 0
   265                                  _gsr_3:
   266                                  	; Save Variable Rate Audio support bit
   267 00000133 2401                    	and	al, 1
   268 00000135 A2[1C240000]            	mov	[VRA], al
   269                                  
   270                                  	; 06/06/2024
   271                                  	; ebx = codec vendor id1 & id2 (bx)
   272 0000013A E8E3080000              	call	write_codec_info
   273                                  
   274                                  	; 25/11/2023
   275 0000013F E891080000              	call	write_VRA_info
   276                                  
   277                                  	; 01/05/2017
   278 00000144 E8FA050000              	call	write_wav_file_info
   279                                  
   280                                  	; 25/11/2023
   281                                  	; ------------------------------------------
   282                                  
   283 00000149 803D[1C240000]01        	cmp	byte [VRA], 1
   284 00000150 7220                    	jb	short chk_sample_rate
   285                                  
   286                                  playwav_48_khz:	
   287                                  	;mov	dword [loadfromwavfile], loadFromFile
   288                                  	;mov	dword [buffersize], 65536
   289 00000152 E987020000              	jmp	PlayNow
   290                                  
   291                                  	; 01/06/2024
   292                                  init_err:
   293                                  	sys	_msg, msg_init_err, 255, 0Eh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000157 BB[35220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000015C B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000161 BA0E000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000166 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000016B CD40                <1>  int 40h
   294 0000016D E931030000              	jmp	Exit
   295                                  
   296                                  chk_sample_rate:
   297                                  	; set conversion parameters
   298                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   299 00000172 66A1[12240000]          	mov	ax, [sample_rate]
   300 00000178 663D80BB                	cmp	ax, 48000
   301 0000017C 74D4                    	je	short playwav_48_khz
   302                                  chk_22khz:
   303 0000017E 663D2256                	cmp	ax, 22050
   304 00000182 7545                    	jne	short chk_11khz
   305 00000184 803D[11240000]08        	cmp	byte [bps], 8
   306 0000018B 7615                    	jna	short chk_22khz_1
   307 0000018D BB[F8160000]            	mov	ebx, load_22khz_stereo_16_bit
   308 00000192 803D[10240000]01        	cmp	byte [stmo], 1 
   309 00000199 751A                    	jne	short chk_22khz_2
   310 0000019B BB[6B160000]            	mov	ebx, load_22khz_mono_16_bit
   311 000001A0 EB13                    	jmp	short chk_22khz_2
   312                                  chk_22khz_1:
   313 000001A2 BB[E4150000]            	mov	ebx, load_22khz_stereo_8_bit
   314 000001A7 803D[10240000]01        	cmp	byte [stmo], 1 
   315 000001AE 7505                    	jne	short chk_22khz_2
   316 000001B0 BB[5B150000]            	mov	ebx, load_22khz_mono_8_bit
   317                                  chk_22khz_2:
   318 000001B5 B85A1D0000              	mov	eax, 7514  ; (442*17)
   319 000001BA BA25000000              	mov	edx, 37
   320 000001BF B911000000              	mov	ecx, 17 
   321 000001C4 E9BA010000              	jmp	set_sizes	
   322                                  chk_11khz:
   323 000001C9 663D112B                	cmp	ax, 11025
   324 000001CD 7545                    	jne	short chk_44khz
   325 000001CF 803D[11240000]08        	cmp	byte [bps], 8
   326 000001D6 7615                    	jna	short chk_11khz_1
   327 000001D8 BB[14190000]            	mov	ebx, load_11khz_stereo_16_bit
   328 000001DD 803D[10240000]01        	cmp	byte [stmo], 1 
   329 000001E4 751A                    	jne	short chk_11khz_2
   330 000001E6 BB[9B180000]            	mov	ebx, load_11khz_mono_16_bit
   331 000001EB EB13                    	jmp	short chk_11khz_2
   332                                  chk_11khz_1:
   333 000001ED BB[21180000]            	mov	ebx, load_11khz_stereo_8_bit
   334 000001F2 803D[10240000]01        	cmp	byte [stmo], 1 
   335 000001F9 7505                    	jne	short chk_11khz_2
   336 000001FB BB[A9170000]            	mov	ebx, load_11khz_mono_8_bit
   337                                  chk_11khz_2:
   338 00000200 B8AD0E0000              	mov	eax, 3757  ; (221*17)
   339 00000205 BA4A000000              	mov	edx, 74
   340 0000020A B911000000              	mov	ecx, 17
   341 0000020F E96F010000              	jmp	set_sizes 
   342                                  chk_44khz:
   343 00000214 663D44AC                	cmp	ax, 44100
   344 00000218 7545                    	jne	short chk_16khz
   345 0000021A 803D[11240000]08        	cmp	byte [bps], 8
   346 00000221 7615                    	jna	short chk_44khz_1
   347 00000223 BB[3B1B0000]            	mov	ebx, load_44khz_stereo_16_bit
   348 00000228 803D[10240000]01        	cmp	byte [stmo], 1 
   349 0000022F 751A                    	jne	short chk_44khz_2
   350 00000231 BB[C21A0000]            	mov	ebx, load_44khz_mono_16_bit
   351 00000236 EB13                    	jmp	short chk_44khz_2
   352                                  chk_44khz_1:
   353 00000238 BB[451A0000]            	mov	ebx, load_44khz_stereo_8_bit
   354 0000023D 803D[10240000]01        	cmp	byte [stmo], 1 
   355 00000244 7505                    	jne	short chk_44khz_2
   356 00000246 BB[C9190000]            	mov	ebx, load_44khz_mono_8_bit
   357                                  chk_44khz_2:
   358 0000024B B8D93A0000              	mov	eax, 15065 ; (655*23)
   359 00000250 BA19000000              	mov	edx, 25
   360 00000255 B917000000              	mov	ecx, 23
   361 0000025A E924010000              	jmp	set_sizes 
   362                                  chk_16khz:
   363 0000025F 663D803E                	cmp	ax, 16000
   364 00000263 7545                    	jne	short chk_8khz
   365 00000265 803D[11240000]08        	cmp	byte [bps], 8
   366 0000026C 7615                    	jna	short chk_16khz_1
   367 0000026E BB[A0100000]            	mov	ebx, load_16khz_stereo_16_bit
   368 00000273 803D[10240000]01        	cmp	byte [stmo], 1 
   369 0000027A 751A                    	jne	short chk_16khz_2
   370 0000027C BB[1F100000]            	mov	ebx, load_16khz_mono_16_bit
   371 00000281 EB13                    	jmp	short chk_16khz_2
   372                                  chk_16khz_1:
   373 00000283 BB[650F0000]            	mov	ebx, load_16khz_stereo_8_bit
   374 00000288 803D[10240000]01        	cmp	byte [stmo], 1 
   375 0000028F 7505                    	jne	short chk_16khz_2
   376 00000291 BB[E60E0000]            	mov	ebx, load_16khz_mono_8_bit
   377                                  chk_16khz_2:
   378 00000296 B855150000              	mov	eax, 5461
   379 0000029B BA03000000              	mov	edx, 3
   380 000002A0 B901000000              	mov	ecx, 1
   381 000002A5 E9D9000000              	jmp	set_sizes 
   382                                  chk_8khz:
   383 000002AA 663D401F                	cmp	ax, 8000
   384 000002AE 7545                    	jne	short chk_24khz
   385 000002B0 803D[11240000]08        	cmp	byte [bps], 8
   386 000002B7 7615                    	jna	short chk_8khz_1
   387 000002B9 BB[9B0D0000]            	mov	ebx, load_8khz_stereo_16_bit
   388 000002BE 803D[10240000]01        	cmp	byte [stmo], 1 
   389 000002C5 751A                    	jne	short chk_8khz_2
   390 000002C7 BB[CB0C0000]            	mov	ebx, load_8khz_mono_16_bit
   391 000002CC EB13                    	jmp	short chk_8khz_2
   392                                  chk_8khz_1:
   393 000002CE BB[9B0B0000]            	mov	ebx, load_8khz_stereo_8_bit
   394 000002D3 803D[10240000]01        	cmp	byte [stmo], 1 
   395 000002DA 7505                    	jne	short chk_8khz_2
   396 000002DC BB[BC0A0000]            	mov	ebx, load_8khz_mono_8_bit
   397                                  chk_8khz_2:
   398 000002E1 B8AA0A0000              	mov	eax, 2730
   399 000002E6 BA06000000              	mov	edx, 6
   400 000002EB B901000000              	mov	ecx, 1
   401 000002F0 E98E000000              	jmp	set_sizes 
   402                                  chk_24khz:
   403 000002F5 663DC05D                	cmp	ax, 24000
   404 000002F9 7542                    	jne	short chk_32khz
   405 000002FB 803D[11240000]08        	cmp	byte [bps], 8
   406 00000302 7615                    	jna	short chk_24khz_1
   407 00000304 BB[CA120000]            	mov	ebx, load_24khz_stereo_16_bit
   408 00000309 803D[10240000]01        	cmp	byte [stmo], 1 
   409 00000310 751A                    	jne	short chk_24khz_2
   410 00000312 BB[67120000]            	mov	ebx, load_24khz_mono_16_bit
   411 00000317 EB13                    	jmp	short chk_24khz_2
   412                                  chk_24khz_1:
   413 00000319 BB[DD110000]            	mov	ebx, load_24khz_stereo_8_bit
   414 0000031E 803D[10240000]01        	cmp	byte [stmo], 1 
   415 00000325 7505                    	jne	short chk_24khz_2
   416 00000327 BB[76110000]            	mov	ebx, load_24khz_mono_8_bit
   417                                  chk_24khz_2:
   418 0000032C B800200000              	mov	eax, 8192
   419 00000331 BA02000000              	mov	edx, 2
   420 00000336 B901000000              	mov	ecx, 1
   421 0000033B EB46                    	jmp	short set_sizes 
   422                                  chk_32khz:
   423 0000033D 663D007D                	cmp	ax, 32000
   424 00000341 7574                    	jne	short vra_needed
   425 00000343 803D[11240000]08        	cmp	byte [bps], 8
   426 0000034A 7615                    	jna	short chk_32khz_1
   427 0000034C BB[CB140000]            	mov	ebx, load_32khz_stereo_16_bit
   428 00000351 803D[10240000]01        	cmp	byte [stmo], 1 
   429 00000358 751A                    	jne	short chk_32khz_2
   430 0000035A BB[61140000]            	mov	ebx, load_32khz_mono_16_bit
   431 0000035F EB13                    	jmp	short chk_32khz_2
   432                                  chk_32khz_1:
   433 00000361 BB[C4130000]            	mov	ebx, load_32khz_stereo_8_bit
   434 00000366 803D[10240000]01        	cmp	byte [stmo], 1 
   435 0000036D 7505                    	jne	short chk_32khz_2
   436 0000036F BB[51130000]            	mov	ebx, load_32khz_mono_8_bit
   437                                  chk_32khz_2:
   438 00000374 B8AA2A0000              	mov	eax, 10922
   439 00000379 BA03000000              	mov	edx, 3
   440 0000037E B902000000              	mov	ecx, 2
   441                                  	;jmp	short set_sizes 
   442                                  set_sizes:
   443 00000383 803D[10240000]01        	cmp	byte [stmo], 1
   444 0000038A 7402                    	je	short ss_1
   445 0000038C D1E0                    	shl	eax, 1
   446                                  ss_1:
   447 0000038E 803D[11240000]08        	cmp	byte [bps], 8
   448 00000395 7602                    	jna	short ss_2
   449                                  	; 16 bit samples
   450 00000397 D1E0                    	shl	eax, 1
   451                                  ss_2:
   452 00000399 A3[D6030000]            	mov	[loadsize], eax
   453 0000039E F7E2                    	mul	edx
   454                                  	;cmp	ecx, 1
   455                                  	;je	short ss_3
   456                                  ;ss_3:
   457 000003A0 F7F1                    	div	ecx
   458 000003A2 8A0D[8C240000]          	mov	cl, [fbs_shift]
   459 000003A8 D3E0                    	shl	eax, cl
   460                                  	; 26/11/2023
   461                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   462 000003AA A3[DA030000]            	mov	[buffersize], eax ; buffer size in bytes 
   463 000003AF 891D[D2030000]          	mov	[loadfromwavfile], ebx
   464 000003B5 EB27                    	jmp	short PlayNow
   465                                  
   466                                  vra_needed:
   467                                  	sys	_msg, msg_no_vra, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003B7 BB[66220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003BC B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000003C1 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000003C6 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000003CB CD40                <1>  int 40h
   468 000003CD E9D1000000              	jmp	Exit
   469                                  
   470                                  	; 26/11/2023
   471                                  	; 13/11/2023
   472                                  loadfromwavfile:
   473 000003D2 [9F050000]              	dd	loadFromFile
   474                                  loadsize:	; read from wav file
   475 000003D6 00000000                	dd	0
   476                                  buffersize:	; write to DMA buffer
   477 000003DA 00000100                	dd	65536 ; bytes
   478                                  
   479                                  PlayNow: 
   480                                  
   481                                  ; 26/11/2023
   482                                  %if 1
   483                                  	; Allocate Audio Buffer (for user)
   484                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   485                                  	; 26/11/2023
   486                                  	sys	_audio, 0200h, [buffersize], audio_buffer
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003DE BB00020000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003E3 8B0D[DA030000]      <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000003E9 BA[00300000]        <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000003EE B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000003F3 CD40                <1>  int 40h
   487 000003F5 731B                    	jnc	short _2
   488                                  
   489                                  	; 26/11/2023 - temporary
   490                                  	;sys	_msg, test_1, 255, 0Ch
   491                                  
   492                                  error_exit:
   493                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000003F7 BB[15220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000003FC B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000401 BA0E000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000406 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000040B CD40                <1>  int 40h
   494 0000040D E991000000              	jmp	Exit
   495                                  _2:
   496                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   497                                  	; bl = 0, bh = 4
   498                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   499                                  
   500                                  	sys	_video, 0400h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000412 BB00040000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000417 B81F000000          <1>  mov eax, %1
    86                              <1> 
    87 0000041C CD40                <1>  int 40h
   501 0000041E 3D00800B00              	cmp	eax, 0B8000h
   502 00000423 75D2                    	jne	short error_exit
   503                                  
   504                                  	; 01/06/2024
   505                                  	; Initialize Audio Device (bh = 3)
   506                                  	sys	_audio, 0301h, 0, audio_int_handler 
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000425 BB01030000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000042A B900000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000042F BA[6E050000]        <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000434 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000439 CD40                <1>  int 40h
   507                                  	;jc	short error_exit
   508 0000043B 0F8216FDFFFF            	jc	init_err
   509                                  _3:
   510                                  
   511                                  %endif
   512                                  
   513                                  ;
   514                                  ; position file pointer to start in actual wav data
   515                                  ; MUCH improvement should really be done here to check if sample size is
   516                                  ; supported, make sure there are 2 channels, etc.  
   517                                  ;
   518                                          ;mov     ah, 42h
   519                                          ;mov     al, 0	; from start of file
   520                                          ;mov     bx, [FileHandle]
   521                                          ;xor     cx, cx
   522                                          ;mov     dx, 44	; jump past .wav/riff header
   523                                          ;int     21h
   524                                  
   525                                  	sys	_seek, [FileHandle], 44, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000441 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000447 B92C000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000044C BA00000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000451 B813000000          <1>  mov eax, %1
    86                              <1> 
    87 00000456 CD40                <1>  int 40h
   526                                  
   527                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000458 BB[EB220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000045D B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000462 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000467 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000046C CD40                <1>  int 40h
   528                                  
   529                                  ; play the .wav file. Most of the good stuff is in here.
   530                                  
   531 0000046E E8E1010000                      call    PlayWav
   532                                  
   533                                  ; close the .wav file and exit.
   534                                  
   535                                  StopPlaying:
   536                                  	; Stop Playing
   537                                  	sys	_audio, 0700h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000473 BB00070000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000478 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000047D CD40                <1>  int 40h
   538                                  	; Cancel callback service (for user)
   539                                  	sys	_audio, 0900h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000047F BB00090000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000484 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000489 CD40                <1>  int 40h
   540                                  	; Deallocate Audio Buffer (for user)
   541                                  	sys	_audio, 0A00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000048B BB000A0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000490 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000495 CD40                <1>  int 40h
   542                                  	; Disable Audio Device
   543                                  	sys	_audio, 0C00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000497 BB000C0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000049C B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000004A1 CD40                <1>  int 40h
   544                                  Exit:  
   545 000004A3 E847000000                      call    closeFile
   546                                           
   547                                  	sys	_exit	; Bye!
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004A8 B801000000          <1>  mov eax, %1
    86                              <1> 
    87 000004AD CD40                <1>  int 40h
   548                                  here:
   549 000004AF EBFE                    	jmp	short here
   550                                  
   551                                  pmsg_usage:
   552                                  	sys	_msg, msg_usage, 255, 0Bh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004B1 BB[B2210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000004B6 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000004BB BA0B000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004C0 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000004C5 CD40                <1>  int 40h
   553 000004C7 EBDA                    	jmp	short Exit
   554                                  
   555                                  	; 25/11/2023
   556                                  DetectAC97:
   557                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   558                                          sys	_audio, 0102h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004C9 BB02010000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004CE B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000004D3 CD40                <1>  int 40h
   559                                  
   560                                  ; 01/06/2024
   561                                  %if 0
   562                                  	jc	short DetectAC97_retn
   563                                  
   564                                  	; 25/11/2023
   565                                  	; Get AC'97 Codec info
   566                                  	; (Function 14, sub function 1)
   567                                  	sys	_audio, 0E01h
   568                                  	; Save Variable Rate Audio support bit
   569                                  	and	al, 1
   570                                  	mov	[VRA], al
   571                                  %endif
   572                                  
   573                                  DetectAC97_retn:
   574 000004D5 C3                      	retn
   575                                  
   576                                  ;open or create file
   577                                  ;
   578                                  ;input: ds:dx-->filename (asciiz)
   579                                  ;       al=file Mode (create or open)
   580                                  ;output: none  cs:[FileHandle] filled
   581                                  ;
   582                                  openFile:
   583                                  	;mov	ah, 3Bh	; start with a mode
   584                                  	;add	ah, al	; add in create or open mode
   585                                  	;xor	ecx, ecx
   586                                  	;int	21h
   587                                  	;jc	short _of1
   588                                  	;;mov	[cs:FileHandle], ax
   589                                  
   590                                  	sys	_open, wav_file_name, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004D6 BB[39240000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000004DB B900000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004E0 B805000000          <1>  mov eax, %1
    86                              <1> 
    87 000004E5 CD40                <1>  int 40h
   591 000004E7 7205                    	jc	short _of1
   592                                  
   593 000004E9 A3[09210000]            	mov	[FileHandle], eax
   594                                  _of1:
   595 000004EE C3                      	retn
   596                                  
   597                                  ; close the currently open file
   598                                  ; input: none, uses cs:[FileHandle]
   599                                  closeFile:
   600 000004EF 833D[09210000]FF        	cmp	dword [FileHandle], -1
   601 000004F6 7417                    	je	short _cf1
   602                                  	;mov    bx, [FileHandle]  
   603                                  	;mov    ax, 3E00h
   604                                          ;int    21h              ;close file
   605                                  
   606                                  	sys	_close, [FileHandle]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000004F8 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000004FE B806000000          <1>  mov eax, %1
    86                              <1> 
    87 00000503 CD40                <1>  int 40h
   607 00000505 C705[09210000]FFFF-     	mov 	dword [FileHandle], -1
   607 0000050D FFFF               
   608                                  _cf1:
   609 0000050F C3                      	retn
   610                                  
   611                                  getSampleRate:
   612                                  	
   613                                  ; reads the sample rate from the .wav file.
   614                                  ; entry: none - assumes file is already open
   615                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   616                                  ;	cx = number of channels (mono=1, stereo=2)
   617                                  ;	dx = bits per sample (8, 16)
   618                                  
   619 00000510 53                      	push    ebx
   620                                  
   621                                          ;mov	ah, 42h
   622                                          ;mov	al, 0	; from start of file
   623                                          ;mov	bx, [FileHandle]
   624                                          ;xor	ecx, ecx
   625                                          ;mov	dx, 08h	; "WAVE"
   626                                          ;int	21h
   627                                  	
   628                                  	sys	_seek, [FileHandle], 8, 0
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000511 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000517 B908000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000051C BA00000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000521 B813000000          <1>  mov eax, %1
    86                              <1> 
    87 00000526 CD40                <1>  int 40h
   629                                  
   630                                          ;mov	dx, smpRBuff
   631                                          ;mov	cx, 28	; 28 bytes
   632                                  	;mov	ah, 3fh
   633                                          ;int	21h
   634                                  
   635                                  	sys	_read, [FileHandle], smpRBuff, 28
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000528 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000052E B9[1D240000]        <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000533 BA1C000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000538 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000053D CD40                <1>  int 40h
   636                                  
   637 0000053F 813D[1D240000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   637 00000547 5645               
   638 00000549 7520                    	jne	short gsr_stc
   639                                  
   640 0000054B 66833D[29240000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   641 00000553 7516                    	jne	short gsr_stc
   642                                  
   643 00000555 668B0D[2B240000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   644 0000055C 66A1[2D240000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   645 00000562 668B15[37240000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   646                                  gsr_retn:
   647 00000569 5B                              pop     ebx
   648 0000056A C3                              retn
   649                                  gsr_stc:
   650 0000056B F9                      	stc
   651 0000056C EBFB                    	jmp	short gsr_retn
   652                                  
   653                                  audio_int_handler:
   654                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   655                                  
   656                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   657                                  	
   658                                  	;cmp	byte [cbs_busy], 1
   659                                  	;jnb	short _callback_bsy_retn
   660                                  	
   661                                  	;mov	byte [cbs_busy], 1
   662                                  
   663 0000056E A0[19240000]            	mov	al, [half_buff]
   664                                  
   665 00000573 3C01                    	cmp	al, 1
   666 00000575 721A                    	jb	short _callback_retn
   667                                  
   668                                  	; 18/08/2020
   669 00000577 C605[1A240000]01        	mov	byte [srb], 1
   670                                  
   671 0000057E 8035[19240000]03        	xor	byte [half_buff], 3 ; 2->1, 1->2
   672                                  
   673 00000585 0430                    	add	al, '0'
   674                                  tL0:	; 26/11/2023
   675 00000587 B44E                    	mov	ah, 4Eh
   676 00000589 BB00800B00              	mov	ebx, 0B8000h ; video display page address
   677 0000058E 668903                  	mov	[ebx], ax ; show playing buffer (1, 2)
   678                                  _callback_retn:
   679                                  	;mov	byte [cbs_busy], 0
   680                                  _callback_bsy_retn:
   681                                  	sys	_rele ; return from callback service 
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000591 B827000000          <1>  mov eax, %1
    86                              <1> 
    87 00000596 CD40                <1>  int 40h
   682                                  	; we must not come here !
   683                                  	sys	_exit
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000598 B801000000          <1>  mov eax, %1
    86                              <1> 
    87 0000059D CD40                <1>  int 40h
   684                                  	
   685                                  loadFromFile:
   686                                  	; 26/11/2023
   687 0000059F F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
   688                                  					; last of the file?
   689 000005A6 7402                    	jz	short lff_0		; no
   690 000005A8 F9                      	stc
   691 000005A9 C3                      	retn
   692                                  lff_0:
   693                                  	; 13/06/2017
   694                                  	;mov	edx, BUFFERSIZE
   695                                  	; 26/11/2023
   696 000005AA BF[00300000]            	mov	edi, audio_buffer
   697 000005AF 8B15[DA030000]          	mov	edx, [buffersize]	; bytes
   698 000005B5 8A0D[8C240000]          	mov	cl, [fbs_shift]   
   699 000005BB 20C9                    	and	cl, cl
   700 000005BD 7409                    	jz	short lff_1 ; stereo, 16 bit
   701                                  
   702                                  	; fbs_shift =
   703                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   704                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   705 000005BF D3EA                    	shr	edx, cl
   706                                  	;inc	edx
   707                                  
   708 000005C1 BE[00300100]            	mov     esi, temp_buffer
   709 000005C6 EB02                    	jmp	short lff_2
   710                                  lff_1:
   711                                  	;mov	esi, audio_buffer
   712 000005C8 89FE                    	mov	esi, edi ; audio_buffer
   713                                  lff_2:
   714                                  	; 17/03/2017
   715                                  	; esi = buffer address
   716                                  	; edx = buffer size
   717                                   
   718                                  	; 26/11/2023
   719                                  	; load file into memory
   720                                  	sys 	_read, [FileHandle], esi
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000005CA 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000005D0 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000005D2 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000005D7 CD40                <1>  int 40h
   721 000005D9 89D1                    	mov	ecx, edx
   722 000005DB 724A                    	jc	short padfill ; error !
   723                                  
   724 000005DD 21C0                    	and	eax, eax
   725 000005DF 7446                    	jz	short padfill
   726                                  lff_3:
   727                                  	; 26/11/2023
   728 000005E1 8A1D[8C240000]          	mov	bl, [fbs_shift]
   729 000005E7 20DB                    	and	bl, bl
   730 000005E9 745C                    	jz	short lff_11
   731                                  
   732 000005EB 29C1                    	sub	ecx, eax
   733 000005ED 89CD                    	mov	ebp, ecx
   734                                  
   735                                  	;mov	esi, temp_buffer
   736                                  	;mov	edi, audio_buffer
   737 000005EF 89C1                    	mov	ecx, eax   ; byte count
   738                                  
   739 000005F1 803D[11240000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   740 000005F8 751E                    	jne	short lff_6 ; 16 bit samples
   741                                  	; 8 bit samples
   742 000005FA FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   743 000005FC 740E                    	jz	short lff_5 ; 8 bit, stereo
   744                                  lff_4:
   745                                  	; mono & 8 bit
   746 000005FE AC                      	lodsb
   747 000005FF 2C80                    	sub	al, 80h ; 08/11/2023
   748 00000601 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   749 00000604 66AB                    	stosw	; left channel
   750 00000606 66AB                    	stosw	; right channel
   751 00000608 E2F4                    	loop	lff_4
   752 0000060A EB16                    	jmp	short lff_8
   753                                  lff_5:
   754                                  	; stereo & 8 bit
   755 0000060C AC                      	lodsb
   756 0000060D 2C80                    	sub	al, 80h ; 08/11/2023
   757 0000060F C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   758 00000612 66AB                    	stosw
   759 00000614 E2F6                    	loop	lff_5			
   760 00000616 EB0A                    	jmp	short lff_8
   761                                  lff_6:
   762 00000618 D1E9                    	shr	ecx, 1 ; word count
   763                                  lff_7:
   764 0000061A 66AD                    	lodsw
   765 0000061C 66AB                    	stosw	; left channel
   766 0000061E 66AB                    	stosw	; right channel
   767 00000620 E2F8                    	loop	lff_7
   768                                  lff_8:
   769                                  	; 27/11/2023
   770 00000622 F8                      	clc
   771 00000623 89E9                    	mov	ecx, ebp
   772 00000625 E314                    	jecxz	endLFF_retn
   773                                  	
   774                                  padfill:
   775 00000627 803D[11240000]10        	cmp 	byte [bps], 16
   776 0000062E 740C                    	je	short lff_10
   777                                  	; Minimum Value = 0
   778 00000630 30C0                            xor     al, al
   779 00000632 F3AA                    	rep	stosb
   780                                  lff_9:
   781 00000634 800D[18240000]01                or	byte [flags], ENDOFFILE	; end of file flag
   782                                  endLFF_retn:
   783 0000063B C3                              retn
   784                                  lff_10:
   785 0000063C 31C0                    	xor	eax, eax
   786                                  	; Minimum value = 8000h (-32768)
   787 0000063E D1E9                    	shr	ecx, 1 
   788 00000640 B480                    	mov	ah, 80h ; ax = -32768
   789 00000642 F366AB                  	rep	stosw
   790 00000645 EBED                    	jmp	short lff_9
   791                                  
   792                                  lff_11:
   793                                  	; 16 bit stereo
   794                                  	; ecx = buffer size
   795                                  	; eax = read count
   796 00000647 29C1                    	sub	ecx, eax
   797 00000649 76F0                    	jna	short endLFF_retn
   798 0000064B 01C7                    	add	edi, eax  ; audio_buffer + eax
   799 0000064D EBED                    	jmp	short lff_10 ; padfill
   800                                  
   801                                  error_exit_2:
   802                                  	; 26/11/2023 - temporary
   803                                  	;sys	_msg, test_2, 255, 0Ch
   804                                  
   805 0000064F E9A3FDFFFF              	jmp	error_exit
   806                                  	
   807                                  	; 26/11/2023 - temporary
   808                                  ;test_1:
   809                                  ;	db 13, 10, 'Test 1', 13,10, 0
   810                                  ;test_2:
   811                                  ;	db 13, 10, 'Test 2', 13,10, 0
   812                                  	
   813                                  PlayWav:
   814                                  	; 26/11/2023
   815                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   816                                  	; 13/06/2017
   817                                  	; Convert 8 bit samples to 16 bit samples
   818                                  	; and convert mono samples to stereo samples
   819                                  
   820                                  	; 26/11/2023
   821                                  	; load 32768 bytes into audio buffer
   822                                  	;mov	edi, audio_buffer
   823                                  	;;mov	edx, BUFFERSIZE
   824                                  	; 26/11/2023
   825                                  	;mov	edx, [buffersize]
   826                                  	;call	loadFromFile
   827                                  	; 26/11/2023
   828 00000654 FF15[D2030000]          	call	dword [loadfromwavfile]
   829 0000065A 72F3                    	jc	short error_exit_2
   830 0000065C C605[19240000]01        	mov	byte [half_buff], 1 ; (DMA) Buffer 1
   831                                  
   832                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   833 00000663 F605[18240000]01        	test    byte [flags], ENDOFFILE  ; end of file
   834 0000066A 7512                    	jnz	short _6 ; yes
   835                                  			 ; bypass filling dma half buffer 2
   836                                  
   837                                  	; bh = 16 : update (current, first) dma half buffer
   838                                  	; bl = 0  : then switch to the next (second) half buffer
   839                                  	sys	_audio, 1000h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000066C BB00100000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000671 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000676 CD40                <1>  int 40h
   840                                  
   841                                  	; 18/08/2020
   842                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
   843                                  
   844                                  	; audio_buffer must be filled again after above system call 
   845                                  	; (Because audio interrupt will be generated by AC97 hardware
   846                                  	; at the end of the first half of dma buffer.. so, 
   847                                  	; the second half must be ready. 'sound_play' will use it.)
   848                                  
   849                                  	; 26/11/2023
   850                                  	;mov	edi, audio_buffer
   851                                  	;;mov	edx, BUFFERSIZE
   852                                  	; 26/11/2023
   853                                  	;mov	edx, [buffersize]
   854                                  	;call	loadFromFile
   855                                  	; 26/11/2023
   856 00000678 FF15[D2030000]          	call	dword [loadfromwavfile]
   857                                  	;jc	short p_return
   858                                  _6:
   859                                  	; Set Master Volume Level (BL=0 or 80h)
   860                                  	; 	for next playing (BL>=80h)
   861                                  	;sys	_audio, 0B80h, 1D1Dh
   862                                  	sys	_audio, 0B00h, 1D1Dh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000067E BB000B0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000683 B91D1D0000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000688 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 0000068D CD40                <1>  int 40h
   863                                  
   864                                  	; 18/08/2020
   865                                  	;mov	byte [volume_level], 1Dh
   866 0000068F 880D[1B240000]          	mov	[volume_level], cl
   867                                  
   868                                  	; Start	to play
   869 00000695 A0[11240000]            	mov	al, [bps]
   870 0000069A C0E804                  	shr	al, 4 ; 8 -> 0, 16 -> 1
   871 0000069D D0E0                    	shl	al, 1 ; 16 -> 2, 8 -> 0
   872 0000069F 8A1D[10240000]          	mov	bl, [stmo]
   873 000006A5 FECB                    	dec	bl
   874 000006A7 08C3                    	or	bl, al
   875 000006A9 668B0D[12240000]        	mov	cx, [sample_rate] 
   876 000006B0 B704                    	mov	bh, 4 ; start to play
   877                                  	sys	_audio
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77                              <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000006B2 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 000006B7 CD40                <1>  int 40h
   878                                  
   879                                  	;mov	ebx, 0B8000h ; video display page address
   880                                  	;mov	ah, 4Eh
   881                                  	;mov	al, [half_buffer]
   882                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   883                                  
   884                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   885                                  	; Here..
   886                                  	; If byte [flags] <> ENDOFFILE ...
   887                                  	; user's audio_buffer has been copied to dma half buffer 2
   888                                  
   889                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
   890                                  
   891                                  	; audio_buffer must be filled again after above system call 
   892                                  	; (Because, audio interrupt will be generated by VT8237R
   893                                  	; at the end of the first half of dma buffer.. so, 
   894                                  	; the 2nd half of dma buffer is ready but the 1st half
   895                                  	; must be filled again.)
   896                                  
   897                                  	; 18/08/2020
   898 000006B9 F605[18240000]01        	test    byte [flags], ENDOFFILE  ; end of file
   899 000006C0 7506                    	jnz	short p_loop ; yes
   900                                  
   901                                  	; 18/08/2020
   902                                  	; load 32768 bytes into audio buffer
   903                                  	;; (for the second half of DMA buffer)
   904                                  	; 27/11/2023
   905                                  	; 20/05/2017
   906                                  	;mov	edi, audio_buffer
   907                                  	;mov	edx, BUFFERSIZE
   908                                  	; 26/11/2023
   909                                  	;mov	edx, [buffersize]
   910                                  	;call	loadFromFile
   911                                  	; 26/11/2023
   912 000006C2 FF15[D2030000]          	call	dword [loadfromwavfile]
   913                                  	;jc	short p_return
   914                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
   915                                  
   916                                  	; we need to wait for 'SRB' (audio interrupt)
   917                                  	; (we can not return from 'PlayWav' here 
   918                                  	;  even if we have got an error from file reading)
   919                                  	; ((!!current audio data must be played!!))
   920                                  
   921                                  	; 18/08/2020
   922                                  	;mov	byte [srb], 1
   923                                  
   924                                  p_loop:
   925                                  	;mov	ah, 1		; any key pressed?
   926                                  	;int	32h		; no, Loop.
   927                                  	;jz	short q_loop
   928                                  	;
   929                                  	;mov	ah, 0		; flush key buffer...
   930                                  	;int	32h
   931                                  
   932                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   933 000006C8 803D[1A240000]00        	cmp	byte [srb], 0
   934 000006CF 760F                    	jna	short q_loop
   935 000006D1 C605[1A240000]00        	mov	byte [srb], 0
   936                                  	; 27/11/2023
   937                                  	;mov	edi, audio_buffer
   938                                  	;mov	edx, BUFFERSIZE
   939                                  	; 26/11/2023
   940                                  	;mov	edx, [buffersize]
   941                                  	;call	loadFromFile
   942                                  	; 26/11/2023
   943 000006D8 FF15[D2030000]          	call	dword [loadfromwavfile]
   944 000006DE 7212                    	jc	short p_return
   945                                  q_loop:
   946 000006E0 B401                    	mov     ah, 1		; any key pressed?
   947 000006E2 CD32                    	int     32h		; no, Loop.
   948 000006E4 74E2                    	jz	short p_loop
   949                                  
   950 000006E6 B400                    	mov     ah, 0		; flush key buffer...
   951 000006E8 CD32                    	int     32h
   952                                  	
   953 000006EA 3C2B                    	cmp	al, '+' ; increase sound volume
   954 000006EC 740C                    	je	short inc_volume_level
   955 000006EE 3C2D                    	cmp	al, '-'
   956 000006F0 742B                    	je	short dec_volume_level
   957                                  
   958                                  p_return:
   959 000006F2 C605[19240000]00        	mov	byte [half_buff], 0
   960 000006F9 C3                      	retn
   961                                  
   962                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   963                                  inc_volume_level:
   964 000006FA 8A0D[1B240000]          	mov	cl, [volume_level]
   965 00000700 80F91F                  	cmp	cl, 1Fh ; 31
   966 00000703 73DB                    	jnb	short q_loop
   967 00000705 FEC1                    	inc	cl
   968                                  change_volume_level:
   969 00000707 880D[1B240000]          	mov	[volume_level], cl
   970 0000070D 88CD                    	mov	ch, cl
   971                                  	; Set Master Volume Level
   972                                  	sys	_audio, 0B00h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000070F BB000B0000          <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79                              <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81                              <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000714 B820000000          <1>  mov eax, %1
    86                              <1> 
    87 00000719 CD40                <1>  int 40h
   973 0000071B EBAB                    	jmp	short p_loop
   974                                  dec_volume_level:
   975 0000071D 8A0D[1B240000]          	mov	cl, [volume_level]
   976 00000723 80F901                  	cmp	cl, 1 ; 1
   977 00000726 76A0                    	jna	short p_loop
   978 00000728 FEC9                    	dec	cl
   979 0000072A EBDB                    	jmp	short change_volume_level
   980                                  
   981                                  write_audio_dev_info:
   982                                  	; EBX = Message address
   983                                  	; ECX = Max. message length (or stop on ZERO character)
   984                                  	;	(1 to 255)
   985                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
   986                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000072C BB[89210000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000731 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000736 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000073B B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000740 CD40                <1>  int 40h
   987 00000742 C3                      	retn
   988                                  
   989                                  write_wav_file_info:
   990                                  	; 01/05/2017
   991                                  	sys	_msg, msgWavFileName, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000743 BB[9F220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000748 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000074D BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000752 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000757 CD40                <1>  int 40h
   992                                  	sys	_msg, wav_file_name, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000759 BB[39240000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000075E B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000763 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000768 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000076D CD40                <1>  int 40h
   993                                  
   994                                  write_sample_rate:
   995                                  	; 01/05/2017
   996 0000076F 66A1[12240000]          	mov	ax, [sample_rate]
   997                                  	; ax = sample rate (hertz)
   998 00000775 31D2                    	xor	edx, edx
   999 00000777 66B90A00                	mov	cx, 10
  1000 0000077B 66F7F1                  	div	cx
  1001 0000077E 0015[C4220000]          	add	[msgHertz+4], dl
  1002 00000784 29D2                    	sub	edx, edx
  1003 00000786 66F7F1                  	div	cx
  1004 00000789 0015[C3220000]          	add	[msgHertz+3], dl
  1005 0000078F 29D2                    	sub	edx, edx
  1006 00000791 66F7F1                  	div	cx
  1007 00000794 0015[C2220000]          	add	[msgHertz+2], dl
  1008 0000079A 29D2                    	sub	edx, edx
  1009 0000079C 66F7F1                  	div	cx
  1010 0000079F 0015[C1220000]          	add	[msgHertz+1], dl
  1011 000007A5 0005[C0220000]          	add	[msgHertz], al
  1012                                  	
  1013                                  	sys	_msg, msgSampleRate, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007AB BB[B1220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007B0 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000007B5 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000007BA B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000007BF CD40                <1>  int 40h
  1014                                  
  1015 000007C1 BE[DB220000]            	mov	esi, msg16Bits
  1016 000007C6 803D[11240000]10        	cmp	byte [bps], 16
  1017 000007CD 7405                    	je	short wsr_1
  1018 000007CF BE[CB220000]            	mov	esi, msg8Bits
  1019                                  wsr_1:
  1020                                  	sys	_msg, esi, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007D4 89F3                <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007D6 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000007DB BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000007E0 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000007E5 CD40                <1>  int 40h
  1021                                  
  1022 000007E7 BE[D4220000]            	mov	esi, msgMono
  1023 000007EC 803D[10240000]01        	cmp	byte [stmo], 1
  1024 000007F3 7405                    	je	short wsr_2
  1025 000007F5 BE[E5220000]            	mov	esi, msgStereo		
  1026                                  wsr_2:
  1027                                  	sys	_msg, esi, 255, 0Fh
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000007FA 89F3                <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000007FC B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000801 BA0F000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000806 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 0000080B CD40                <1>  int 40h
  1028 0000080D C3                              retn
  1029                                  
  1030                                  write_ac97_pci_dev_info:
  1031                                  	; 06/06/2017
  1032                                  	; 03/06/2017
  1033                                  	; BUS/DEV/FN
  1034                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1035                                  	; DEV/VENDOR
  1036                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1037                                  
  1038 0000080E 8B35[8D240000]          	mov	esi, [dev_vendor]
  1039 00000814 89F0                    	mov	eax, esi
  1040 00000816 0FB6D8                  	movzx	ebx, al
  1041 00000819 88DA                    	mov	dl, bl
  1042 0000081B 80E30F                  	and	bl, 0Fh
  1043 0000081E 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1044 00000824 A2[33230000]            	mov	[msgVendorId+3], al
  1045 00000829 88D3                    	mov	bl, dl
  1046 0000082B C0EB04                  	shr	bl, 4
  1047 0000082E 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1048 00000834 A2[32230000]            	mov	[msgVendorId+2], al
  1049 00000839 88E3                    	mov	bl, ah
  1050 0000083B 88DA                    	mov	dl, bl
  1051 0000083D 80E30F                  	and	bl, 0Fh
  1052 00000840 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1053 00000846 A2[31230000]            	mov	[msgVendorId+1], al
  1054 0000084B 88D3                    	mov	bl, dl
  1055 0000084D C0EB04                  	shr	bl, 4
  1056 00000850 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1057 00000856 A2[30230000]            	mov	[msgVendorId], al
  1058 0000085B C1E810                  	shr	eax, 16
  1059 0000085E 88C3                    	mov	bl, al
  1060 00000860 88DA                    	mov	dl, bl
  1061 00000862 80E30F                  	and	bl, 0Fh
  1062 00000865 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1063 0000086B A2[44230000]            	mov	[msgDevId+3], al
  1064 00000870 88D3                    	mov	bl, dl
  1065 00000872 C0EB04                  	shr	bl, 4
  1066 00000875 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1067 0000087B A2[43230000]            	mov	[msgDevId+2], al
  1068 00000880 88E3                    	mov	bl, ah
  1069 00000882 88DA                    	mov	dl, bl
  1070 00000884 80E30F                  	and	bl, 0Fh
  1071 00000887 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1072 0000088D A2[42230000]            	mov	[msgDevId+1], al
  1073 00000892 88D3                    	mov	bl, dl
  1074 00000894 C0EB04                  	shr	bl, 4
  1075 00000897 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1076 0000089D A2[41230000]            	mov	[msgDevId], al
  1077                                  
  1078 000008A2 8B35[91240000]          	mov	esi, [bus_dev_fn]
  1079 000008A8 C1EE08                  	shr	esi, 8
  1080 000008AB 6689F0                  	mov	ax, si
  1081 000008AE 88C3                    	mov	bl, al
  1082 000008B0 88DA                    	mov	dl, bl
  1083 000008B2 80E307                  	and	bl, 7 ; bit 0,1,2
  1084 000008B5 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1085 000008BB A2[68230000]            	mov	[msgFncNo+1], al
  1086 000008C0 88D3                    	mov	bl, dl
  1087 000008C2 C0EB03                  	shr	bl, 3
  1088 000008C5 88DA                    	mov	dl, bl
  1089 000008C7 80E30F                  	and	bl, 0Fh
  1090 000008CA 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1091 000008D0 A2[5A230000]            	mov	[msgDevNo+1], al
  1092 000008D5 88D3                    	mov	bl, dl
  1093 000008D7 C0EB04                  	shr	bl, 4
  1094 000008DA 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1095 000008E0 A2[59230000]            	mov	[msgDevNo], al
  1096 000008E5 88E3                    	mov	bl, ah
  1097 000008E7 88DA                    	mov	dl, bl
  1098 000008E9 80E30F                  	and	bl, 0Fh
  1099 000008EC 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1100 000008F2 A2[4E230000]            	mov	[msgBusNo+1], al
  1101 000008F7 88D3                    	mov	bl, dl
  1102 000008F9 C0EB04                  	shr	bl, 4
  1103 000008FC 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1104 00000902 A2[4D230000]            	mov	[msgBusNo], al
  1105                                  
  1106 00000907 66A1[95240000]          	mov	ax, [ac97_NamBar]
  1107 0000090D 88C3                    	mov	bl, al
  1108 0000090F 88DA                    	mov	dl, bl
  1109 00000911 80E30F                  	and	bl, 0Fh
  1110 00000914 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1111 0000091A A2[77230000]            	mov	[msgNamBar+3], al
  1112 0000091F 88D3                    	mov	bl, dl
  1113 00000921 C0EB04                  	shr	bl, 4
  1114 00000924 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1115 0000092A A2[76230000]            	mov	[msgNamBar+2], al
  1116 0000092F 88E3                    	mov	bl, ah
  1117 00000931 88DA                    	mov	dl, bl
  1118 00000933 80E30F                  	and	bl, 0Fh
  1119 00000936 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1120 0000093C A2[75230000]            	mov	[msgNamBar+1], al
  1121 00000941 88D3                    	mov	bl, dl
  1122 00000943 C0EB04                  	shr	bl, 4
  1123 00000946 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1124 0000094C A2[74230000]            	mov	[msgNamBar], al
  1125                                  
  1126 00000951 66A1[97240000]          	mov	ax, [ac97_NabmBar]
  1127 00000957 88C3                    	mov	bl, al
  1128 00000959 88DA                    	mov	dl, bl
  1129 0000095B 80E30F                  	and	bl, 0Fh
  1130 0000095E 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1131 00000964 A2[87230000]            	mov	[msgNabmBar+3], al
  1132 00000969 88D3                    	mov	bl, dl
  1133 0000096B C0EB04                  	shr	bl, 4
  1134 0000096E 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1135 00000974 A2[86230000]            	mov	[msgNabmBar+2], al
  1136 00000979 88E3                    	mov	bl, ah
  1137 0000097B 88DA                    	mov	dl, bl
  1138 0000097D 80E30F                  	and	bl, 0Fh
  1139 00000980 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1140 00000986 A2[85230000]            	mov	[msgNabmBar+1], al
  1141 0000098B 88D3                    	mov	bl, dl
  1142 0000098D C0EB04                  	shr	bl, 4
  1143 00000990 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1144 00000996 A2[84230000]            	mov	[msgNabmBar], al
  1145                                  
  1146 0000099B 30E4                    	xor	ah, ah
  1147 0000099D A0[8B240000]            	mov	al, [ac97_int_ln_reg]
  1148 000009A2 B10A                    	mov	cl, 10
  1149 000009A4 F6F1                    	div	cl
  1150 000009A6 660105[90230000]        	add	[msgIRQ], ax
  1151 000009AD 20C0                    	and	al, al
  1152 000009AF 750D                    	jnz	short _w_ac97imsg_
  1153 000009B1 A0[91230000]            	mov	al, [msgIRQ+1]
  1154 000009B6 B420                    	mov	ah, ' '
  1155 000009B8 66A3[90230000]          	mov	[msgIRQ], ax
  1156                                  _w_ac97imsg_:
  1157                                  	sys	_msg, msgAC97Info, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009BE BB[FF220000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009C3 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009C8 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000009CD B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000009D2 CD40                <1>  int 40h
  1158                                  
  1159 000009D4 C3                              retn
  1160                                  
  1161                                  write_VRA_info:
  1162                                  	; 25/11/2023
  1163                                  	sys	_msg, msgVRAheader, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009D5 BB[C8230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009DA B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009DF BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000009E4 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 000009E9 CD40                <1>  int 40h
  1164 000009EB 803D[1C240000]00        	cmp	byte [VRA], 0
  1165 000009F2 7617                    	jna	short _w_VRAi_no
  1166                                  _w_VRAi_yes:
  1167                                  	sys	_msg, msgVRAyes, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000009F4 BB[D6230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000009F9 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000009FE BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000A03 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000A08 CD40                <1>  int 40h
  1168 00000A0A C3                      	retn
  1169                                  _w_VRAi_no:
  1170                                  	sys	_msg, msgVRAno, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000A0B BB[DC230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000A10 B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000A15 BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000A1A B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000A1F CD40                <1>  int 40h
  1171 00000A21 C3                      	retn
  1172                                  
  1173                                  	; 06/06/2024
  1174                                  write_codec_info:
  1175 00000A22 89DA                    	mov	edx, ebx
  1176 00000A24 83E30F                  	and	ebx, 0Fh
  1177 00000A27 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1178 00000A2D A2[C1230000]            	mov	[msgCodecId2+3], al
  1179 00000A32 88D3                    	mov	bl, dl
  1180 00000A34 C0EB04                  	shr	bl, 4
  1181 00000A37 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1182 00000A3D A2[C0230000]            	mov	[msgCodecId2+2], al
  1183 00000A42 88F3                    	mov	bl, dh
  1184 00000A44 80E30F                  	and	bl, 0Fh
  1185 00000A47 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1186 00000A4D A2[BF230000]            	mov	[msgCodecId2+1], al
  1187 00000A52 88F3                    	mov	bl, dh
  1188 00000A54 C0EB04                  	shr	bl, 4
  1189 00000A57 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1190 00000A5D A2[BE230000]            	mov	[msgCodecId2], al
  1191 00000A62 C1EA10                  	shr	edx, 16
  1192 00000A65 88D3                    	mov	bl, dl
  1193 00000A67 80E30F                  	and	bl, 0Fh
  1194 00000A6A 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1195 00000A70 A2[AE230000]            	mov	[msgCodecId1+3], al
  1196 00000A75 88D3                    	mov	bl, dl
  1197 00000A77 C0EB04                  	shr	bl, 4
  1198 00000A7A 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1199 00000A80 A2[AD230000]            	mov	[msgCodecId1+2], al
  1200 00000A85 88F3                    	mov	bl, dh
  1201 00000A87 80E30F                  	and	bl, 0Fh
  1202 00000A8A 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1203 00000A90 A2[AC230000]            	mov	[msgCodecId1+1], al
  1204 00000A95 88F3                    	mov	bl, dh
  1205 00000A97 C0EB04                  	shr	bl, 4
  1206 00000A9A 8A83[EE220000]          	mov	al, [ebx+hex_chars]
  1207 00000AA0 A2[AB230000]            	mov	[msgCodecId1], al
  1208                                  	;
  1209                                  	sys	_msg, msgCodec, 255, 07h
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000AA5 BB[95230000]        <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000AAA B9FF000000          <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000AAF BA07000000          <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000AB4 B823000000          <1>  mov eax, %1
    86                              <1> 
    87 00000AB9 CD40                <1>  int 40h
  1210 00000ABB C3                      	retn
  1211                                  
  1212                                  ; 26/11/2023
  1213                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1214                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1215                                  ; 14/11/2023
  1216                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1217                                  ; --------------------------------------------------------
  1218                                  
  1219                                  ;;Note:	At the end of every buffer load,
  1220                                  ;;	during buffer switch/swap, there will be discontinuity
  1221                                  ;;	between the last converted sample and the 1st sample
  1222                                  ;;	of the next buffer.
  1223                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1224                                  ;;	-To avoid this defect, the 1st sample of
  1225                                  ;;	the next buffer may be read from the wav file but
  1226                                  ;;	the file pointer would need to be set to 1 sample back
  1227                                  ;;	again via seek system call. Time comsumption problem! -
  1228                                  ;;
  1229                                  ;;	Erdogan Tan - 15/11/2023
  1230                                  ;;
  1231                                  ;;	((If entire wav data would be loaded at once.. conversion
  1232                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1233                                  ;;	64KB buffer limit is important also it is important
  1234                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1235                                  ;;	I have tested this program by using 2-30MB wav files.))
  1236                                  ;;
  1237                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1238                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1239                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1240                                  ;;			Realtek ALC850 codec.
  1241                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1242                                  
  1243                                  load_8khz_mono_8_bit:
  1244                                  	; 15/11/2023
  1245                                  	; 14/11/2023
  1246                                  	; 13/11/2023
  1247 00000ABC F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1248                                  					; last of the file?
  1249 00000AC3 7402                    	jz	short lff8m_0		; no
  1250 00000AC5 F9                      	stc
  1251 00000AC6 C3                      	retn
  1252                                  
  1253                                  lff8m_0:
  1254 00000AC7 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1255                                          ;mov	edx, [loadsize]
  1256                                  
  1257                                  	; esi = buffer address
  1258                                  	;; edx = buffer size
  1259                                  
  1260                                  	; load file into memory
  1261                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000ACC 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000AD2 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000AD4 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000ADA B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000ADF CD40                <1>  int 40h
  1262 00000AE1 7305                    	jnc	short lff8m_6
  1263 00000AE3 E9AA000000              	jmp	lff8m_5  ; error !
  1264                                  
  1265                                  lff8m_6:
  1266 00000AE8 BF[00300000]            	mov	edi, audio_buffer
  1267 00000AED 21C0                    	and	eax, eax
  1268 00000AEF 0F8494000000            	jz	lff8_eof
  1269                                  
  1270 00000AF5 89C1                    	mov	ecx, eax		; byte count
  1271                                  lff8m_1:
  1272 00000AF7 AC                      	lodsb
  1273 00000AF8 A2[00210000]            	mov	[previous_val], al
  1274 00000AFD 2C80                    	sub	al, 80h
  1275 00000AFF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1276 00000B03 66AB                    	stosw		; original sample (left channel)
  1277 00000B05 66AB                    	stosw		; original sample (right channel)
  1278                                  	;xor	eax, eax
  1279 00000B07 B080                    	mov	al, 80h
  1280 00000B09 49                      	dec	ecx
  1281 00000B0A 7402                    	jz	short lff8m_2
  1282 00000B0C 8A06                    	mov	al, [esi]
  1283                                  lff8m_2:
  1284                                  	;mov	[next_val], ax
  1285 00000B0E 88C7                    	mov	bh, al	; [next_val]
  1286 00000B10 8A25[00210000]          	mov	ah, [previous_val]
  1287 00000B16 00E0                    	add	al, ah	; [previous_val]
  1288 00000B18 D0D8                    	rcr	al, 1
  1289 00000B1A 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1290 00000B1C 00E0                    	add	al, ah	; [previous_val]
  1291 00000B1E D0D8                    	rcr	al, 1	
  1292 00000B20 88C3                    	mov	bl, al 	; this is temporary interpolation value	
  1293 00000B22 00E0                    	add	al, ah	; [previous_val]
  1294 00000B24 D0D8                    	rcr	al, 1
  1295 00000B26 2C80                    	sub	al, 80h
  1296 00000B28 66C1E008                	shl	ax, 8	
  1297 00000B2C 66AB                    	stosw		; this is 1st interpolated sample (L)
  1298 00000B2E 66AB                    	stosw		; this is 1st interpolated sample (R)
  1299 00000B30 88D8                    	mov	al, bl
  1300 00000B32 00D0                    	add	al, dl
  1301 00000B34 D0D8                    	rcr	al, 1
  1302 00000B36 2C80                    	sub	al, 80h
  1303 00000B38 66C1E008                	shl	ax, 8
  1304 00000B3C 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1305 00000B3E 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1306 00000B40 88D0                    	mov	al, dl
  1307 00000B42 2C80                    	sub	al, 80h
  1308 00000B44 66C1E008                	shl	ax, 8
  1309 00000B48 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1310 00000B4A 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1311                                  	;mov	al, [next_val]
  1312 00000B4C 88F8                    	mov	al, bh
  1313 00000B4E 00D0                    	add	al, dl
  1314 00000B50 D0D8                    	rcr	al, 1
  1315 00000B52 88C3                    	mov	bl, al	; this is temporary interpolation value
  1316 00000B54 00D0                    	add	al, dl
  1317 00000B56 D0D8                    	rcr	al, 1
  1318 00000B58 2C80                    	sub	al, 80h
  1319 00000B5A 66C1E008                	shl	ax, 8
  1320 00000B5E 66AB                    	stosw		; this is 4th interpolated sample (L)
  1321 00000B60 66AB                    	stosw		; this is 4th interpolated sample (R)
  1322                                  	;mov	al, [next_val]
  1323 00000B62 88F8                    	mov	al, bh
  1324 00000B64 00D8                    	add	al, bl
  1325 00000B66 D0D8                    	rcr	al, 1
  1326 00000B68 2C80                    	sub	al, 80h
  1327 00000B6A 66C1E008                	shl	ax, 8
  1328 00000B6E 66AB                    	stosw		; this is 5th interpolated sample (L)
  1329 00000B70 66AB                    	stosw		; this is 5th interpolated sample (R)
  1330                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1331 00000B72 09C9                    	or	ecx, ecx
  1332 00000B74 7581                    	jnz	short lff8m_1
  1333                                  
  1334                                  	; --------------
  1335                                  
  1336                                  lff8s_3:
  1337                                  lff8m_3:
  1338                                  lff8s2_3:
  1339                                  lff8m2_3:
  1340                                  lff16s_3:
  1341                                  lff16m_3:
  1342                                  lff16s2_3:
  1343                                  lff16m2_3:
  1344                                  lff24_3:
  1345                                  lff32_3:
  1346                                  lff44_3:
  1347                                  lff22_3:
  1348                                  lff11_3:
  1349                                  	; 01/06/2024 (BugFix)
  1350 00000B76 8B0D[DA030000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1351                                  	;shl	ecx, 1	; byte count ; Bug !
  1352 00000B7C 29F9                    	sub	ecx, edi
  1353 00000B7E 7607                    	jna	short lff8m_4
  1354                                  	;inc	ecx
  1355 00000B80 C1E902                  	shr	ecx, 2
  1356 00000B83 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros	
  1357 00000B85 F3AB                    	rep	stosd
  1358                                  lff8m_4:
  1359                                  	; 01/06/2024 (BugFix)
  1360                                  	; cf=1 ; Bug !
  1361 00000B87 F8                      	clc
  1362 00000B88 C3                      	retn
  1363                                  
  1364                                  lff8_eof:
  1365                                  lff16_eof:
  1366                                  lff24_eof:
  1367                                  lff32_eof:
  1368                                  lff44_eof:
  1369                                  lff22_eof:
  1370                                  lff11_eof:
  1371                                  	; 15/11/2023
  1372 00000B89 C605[18240000]01        	mov	byte [flags], ENDOFFILE
  1373 00000B90 EBE4                    	jmp	short lff8m_3
  1374                                  
  1375                                  lff8s_5:
  1376                                  lff8m_5:
  1377                                  lff8s2_5:
  1378                                  lff8m2_5:
  1379                                  lff16s_5:
  1380                                  lff16m_5:
  1381                                  lff16s2_5:
  1382                                  lff16m2_5:
  1383                                  lff24_5:
  1384                                  lff32_5:
  1385                                  lff44_5:
  1386                                  lff22_5:
  1387                                  lff11_5:
  1388 00000B92 B021                    	mov	al, '!'  ; error
  1389 00000B94 E8EEF9FFFF              	call	tL0
  1390                                  	
  1391                                  	;jmp	short lff8m_3
  1392                                  	; 15/11/2023
  1393 00000B99 EBEE                    	jmp	lff8_eof
  1394                                  
  1395                                  	; --------------
  1396                                  
  1397                                  load_8khz_stereo_8_bit:
  1398                                  	; 15/11/2023
  1399                                  	; 14/11/2023
  1400                                  	; 13/11/2023
  1401 00000B9B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1402                                  					; last of the file?
  1403 00000BA2 7402                    	jz	short lff8s_0		; no
  1404 00000BA4 F9                      	stc
  1405 00000BA5 C3                      	retn
  1406                                  
  1407                                  lff8s_0:
  1408 00000BA6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1409                                          ;mov	edx, [loadsize]
  1410                                  
  1411                                  	; esi = buffer address
  1412                                  	;; edx = buffer size
  1413                                  
  1414                                  	; load file into memory
  1415                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000BAB 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000BB1 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000BB3 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000BB9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000BBE CD40                <1>  int 40h
  1416 00000BC0 72D0                    	jc	short lff8s_5 ; error !
  1417                                  
  1418 00000BC2 BF[00300000]            	mov	edi, audio_buffer
  1419                                  	
  1420 00000BC7 D1E8                    	shr	eax, 1
  1421 00000BC9 74BE                    	jz	short lff8_eof
  1422                                  
  1423 00000BCB 89C1                    	mov	ecx, eax	; word count
  1424                                  lff8s_1:
  1425 00000BCD AC                      	lodsb
  1426 00000BCE A2[00210000]            	mov	[previous_val_l], al
  1427 00000BD3 2C80                    	sub	al, 80h
  1428 00000BD5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1429 00000BD9 66AB                    	stosw		; original sample (L)
  1430 00000BDB AC                      	lodsb
  1431 00000BDC A2[02210000]            	mov	[previous_val_r], al
  1432 00000BE1 2C80                    	sub	al, 80h
  1433 00000BE3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1434 00000BE7 66AB                    	stosw		; original sample (R)
  1435                                  
  1436                                  	;xor	eax, eax
  1437 00000BE9 66B88080                	mov	ax, 8080h
  1438 00000BED 49                      	dec	ecx
  1439 00000BEE 7403                    	jz	short lff8s_2
  1440                                  		; convert 8 bit sample to 16 bit sample
  1441 00000BF0 668B06                  	mov	ax, [esi]
  1442                                  lff8s_2:
  1443 00000BF3 A2[04210000]            	mov	[next_val_l], al
  1444 00000BF8 8825[06210000]          	mov	[next_val_r], ah
  1445 00000BFE 8A25[00210000]          	mov	ah, [previous_val_l]
  1446 00000C04 00E0                    	add	al, ah
  1447 00000C06 D0D8                    	rcr	al, 1
  1448 00000C08 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1449 00000C0A 00E0                    	add	al, ah
  1450 00000C0C D0D8                    	rcr	al, 1	
  1451 00000C0E 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1452 00000C10 00E0                    	add	al, ah
  1453 00000C12 D0D8                    	rcr	al, 1
  1454 00000C14 2C80                    	sub	al, 80h
  1455 00000C16 66C1E008                	shl	ax, 8
  1456 00000C1A 66AB                    	stosw		; this is 1st interpolated sample (L)
  1457 00000C1C A0[06210000]            	mov	al, [next_val_r]
  1458 00000C21 8A25[02210000]          	mov	ah, [previous_val_r]
  1459 00000C27 00E0                    	add	al, ah
  1460 00000C29 D0D8                    	rcr	al, 1
  1461 00000C2B 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1462 00000C2D 00E0                    	add	al, ah
  1463 00000C2F D0D8                    	rcr	al, 1
  1464 00000C31 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1465 00000C33 00E0                    	add	al, ah
  1466 00000C35 D0D8                    	rcr	al, 1
  1467 00000C37 2C80                    	sub	al, 80h
  1468 00000C39 66C1E008                	shl	ax, 8
  1469 00000C3D 66AB                    	stosw		; this is 1st interpolated sample (R)
  1470 00000C3F 88D8                    	mov	al, bl
  1471 00000C41 00D0                    	add	al, dl
  1472 00000C43 D0D8                    	rcr	al, 1
  1473 00000C45 2C80                    	sub	al, 80h
  1474 00000C47 66C1E008                	shl	ax, 8
  1475 00000C4B 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1476 00000C4D 88F8                    	mov	al, bh
  1477 00000C4F 00F0                    	add	al, dh
  1478 00000C51 D0D8                    	rcr	al, 1
  1479 00000C53 2C80                    	sub	al, 80h
  1480 00000C55 66C1E008                	shl	ax, 8
  1481 00000C59 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1482 00000C5B 88D0                    	mov	al, dl
  1483 00000C5D 2C80                    	sub	al, 80h
  1484 00000C5F 66C1E008                	shl	ax, 8
  1485 00000C63 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1486 00000C65 88F0                    	mov	al, dh
  1487 00000C67 2C80                    	sub	al, 80h
  1488 00000C69 66C1E008                	shl	ax, 8
  1489 00000C6D 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1490 00000C6F A0[04210000]            	mov	al, [next_val_l]
  1491 00000C74 00D0                    	add	al, dl
  1492 00000C76 D0D8                    	rcr	al, 1
  1493 00000C78 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1494 00000C7A 00D0                    	add	al, dl
  1495 00000C7C D0D8                    	rcr	al, 1
  1496 00000C7E 2C80                    	sub	al, 80h
  1497 00000C80 66C1E008                	shl	ax, 8
  1498 00000C84 66AB                    	stosw		; this is 4th interpolated sample (L)
  1499 00000C86 A0[06210000]            	mov	al, [next_val_r]
  1500 00000C8B 00F0                    	add	al, dh
  1501 00000C8D D0D8                    	rcr	al, 1
  1502 00000C8F 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1503 00000C91 00F0                    	add	al, dh
  1504 00000C93 D0D8                    	rcr	al, 1
  1505 00000C95 2C80                    	sub	al, 80h
  1506 00000C97 66C1E008                	shl	ax, 8
  1507 00000C9B 66AB                    	stosw		; this is 4th interpolated sample (R)
  1508 00000C9D A0[04210000]            	mov	al, [next_val_l]
  1509 00000CA2 00D8                    	add	al, bl
  1510 00000CA4 D0D8                    	rcr	al, 1
  1511 00000CA6 2C80                    	sub	al, 80h
  1512 00000CA8 66C1E008                	shl	ax, 8
  1513 00000CAC 66AB                    	stosw		; this is 5th interpolated sample (L)
  1514 00000CAE A0[06210000]            	mov	al, [next_val_r]
  1515 00000CB3 00F8                    	add	al, bh
  1516 00000CB5 D0D8                    	rcr	al, 1
  1517 00000CB7 2C80                    	sub	al, 80h
  1518 00000CB9 66C1E008                	shl	ax, 8
  1519 00000CBD 66AB                    	stosw		; this is 5th interpolated sample (R)
  1520                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1521 00000CBF E305                    	jecxz	lff8s_6
  1522 00000CC1 E907FFFFFF              	jmp	lff8s_1
  1523                                  lff8s_6:
  1524 00000CC6 E9ABFEFFFF              	jmp	lff8s_3
  1525                                  
  1526                                  load_8khz_mono_16_bit:
  1527                                  	; 13/11/2023
  1528 00000CCB F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1529                                  					; last of the file?
  1530 00000CD2 7402                    	jz	short lff8m2_0		; no
  1531 00000CD4 F9                      	stc
  1532 00000CD5 C3                      	retn
  1533                                  
  1534                                  lff8m2_0:
  1535 00000CD6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1536                                          ;mov	edx, [loadsize]
  1537                                  
  1538                                  	; esi = buffer address
  1539                                  	;; edx = buffer size
  1540                                  
  1541                                  	; load file into memory
  1542                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000CDB 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000CE1 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000CE3 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000CE9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000CEE CD40                <1>  int 40h
  1543 00000CF0 0F82A0000000            	jc	lff8m2_7 ; error !
  1544                                  
  1545 00000CF6 BF[00300000]            	mov	edi, audio_buffer
  1546                                  	
  1547 00000CFB D1E8                    	shr	eax, 1
  1548 00000CFD 7505                    	jnz	short lff8m2_8
  1549 00000CFF E985FEFFFF              	jmp	lff8_eof
  1550                                  
  1551                                  lff8m2_8:
  1552 00000D04 89C1                    	mov	ecx, eax	; word count
  1553                                  lff8m2_1:
  1554 00000D06 66AD                    	lodsw
  1555 00000D08 66AB                    	stosw		; original sample (left channel)
  1556 00000D0A 66AB                    	stosw		; original sample (right channel)
  1557 00000D0C 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1558 00000D0F 66A3[00210000]          	mov	[previous_val], ax
  1559 00000D15 31C0                    	xor	eax, eax
  1560 00000D17 49                      	dec	ecx
  1561 00000D18 7403                    	jz	short lff8m2_2
  1562 00000D1A 668B06                  	mov	ax, [esi]
  1563                                  lff8m2_2:
  1564 00000D1D 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1565 00000D20 89C5                    	mov	ebp, eax	; [next_val]
  1566 00000D22 660305[00210000]        	add	ax, [previous_val]
  1567 00000D29 66D1D8                  	rcr	ax, 1
  1568 00000D2C 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1569 00000D2E 660305[00210000]        	add	ax, [previous_val]
  1570 00000D35 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1571 00000D38 89C3                    	mov	ebx, eax 		
  1572 00000D3A 660305[00210000]        	add	ax, [previous_val]
  1573 00000D41 66D1D8                  	rcr	ax, 1
  1574 00000D44 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1575 00000D47 66AB                    	stosw		; this is 1st interpolated sample (L)
  1576 00000D49 66AB                    	stosw		; this is 1st interpolated sample (R)
  1577 00000D4B 89D8                    	mov	eax, ebx
  1578 00000D4D 6601D0                  	add	ax, dx
  1579 00000D50 66D1D8                  	rcr	ax, 1
  1580 00000D53 80EC80                  	sub	ah, 80h
  1581 00000D56 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1582 00000D58 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1583 00000D5A 89D0                    	mov	eax, edx
  1584 00000D5C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1585 00000D5F 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1586 00000D61 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1587 00000D63 89E8                    	mov	eax, ebp
  1588 00000D65 6601D0                  	add	ax, dx
  1589 00000D68 66D1D8                  	rcr	ax, 1
  1590 00000D6B 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1591 00000D6D 6601D0                  	add	ax, dx
  1592 00000D70 66D1D8                  	rcr	ax, 1
  1593 00000D73 80EC80                  	sub	ah, 80h
  1594 00000D76 66AB                    	stosw		; this is 4th interpolated sample (L)
  1595 00000D78 66AB                    	stosw		; this is 4th interpolated sample (R)
  1596 00000D7A 89E8                    	mov	eax, ebp
  1597 00000D7C 6601D8                  	add	ax, bx
  1598 00000D7F 66D1D8                  	rcr	ax, 1
  1599 00000D82 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1600 00000D85 66AB                    	stosw		; this is 5th interpolated sample (L)
  1601 00000D87 66AB                    	stosw		; this is 5th interpolated sample (R)
  1602                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1603 00000D89 09C9                    	or	ecx, ecx
  1604 00000D8B 0F8575FFFFFF            	jnz	lff8m2_1
  1605 00000D91 E9E0FDFFFF              	jmp	lff8m2_3
  1606                                  
  1607                                  lff8m2_7:
  1608                                  lff8s2_7:
  1609 00000D96 E9F7FDFFFF              	jmp	lff8m2_5  ; error
  1610                                  
  1611                                  load_8khz_stereo_16_bit:
  1612                                  	; 16/11/2023
  1613                                  	; 15/11/2023
  1614                                  	; 13/11/2023
  1615 00000D9B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1616                                  					; last of the file?
  1617 00000DA2 7402                    	jz	short lff8s2_0		; no
  1618 00000DA4 F9                      	stc
  1619 00000DA5 C3                      	retn
  1620                                  
  1621                                  lff8s2_0:
  1622 00000DA6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1623                                          ;mov	edx, [loadsize]
  1624                                  
  1625                                  	; esi = buffer address
  1626                                  	;; edx = buffer size
  1627                                  
  1628                                  	; load file into memory
  1629                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000DAB 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000DB1 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000DB3 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000DB9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000DBE CD40                <1>  int 40h
  1630 00000DC0 72D4                    	jc	short lff8s2_7 ; error !
  1631                                  
  1632 00000DC2 BF[00300000]            	mov	edi, audio_buffer
  1633                                  	
  1634 00000DC7 C1E802                  	shr	eax, 2
  1635 00000DCA 7505                    	jnz	short lff8s2_8
  1636 00000DCC E9B8FDFFFF              	jmp	lff8_eof
  1637                                  
  1638                                  lff8s2_8:
  1639 00000DD1 89C1                    	mov	ecx, eax ; dword count
  1640                                  lff8s2_1:
  1641 00000DD3 66AD                    	lodsw
  1642 00000DD5 66AB                    	stosw		; original sample (L)
  1643                                  	; 15/11/2023
  1644 00000DD7 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1645 00000DDA 66A3[00210000]          	mov	[previous_val_l], ax
  1646 00000DE0 66AD                    	lodsw
  1647 00000DE2 66AB                    	stosw		; original sample (R)
  1648 00000DE4 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1649 00000DE7 66A3[02210000]          	mov	[previous_val_r], ax
  1650 00000DED 31D2                    	xor	edx, edx
  1651 00000DEF 31C0                    	xor	eax, eax
  1652                                  	; 16/11/2023
  1653 00000DF1 49                      	dec	ecx
  1654 00000DF2 7407                    	jz	short lff8s2_2
  1655 00000DF4 668B06                  	mov	ax, [esi]
  1656 00000DF7 668B5602                	mov	dx, [esi+2]
  1657                                  lff8s2_2:
  1658 00000DFB 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1659 00000DFE 66A3[04210000]          	mov	[next_val_l], ax
  1660 00000E04 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1661 00000E07 668915[06210000]        	mov	[next_val_r], dx
  1662 00000E0E 660305[00210000]        	add	ax, [previous_val_l]
  1663 00000E15 66D1D8                  	rcr	ax, 1
  1664 00000E18 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1665 00000E1A 660305[00210000]        	add	ax, [previous_val_l]
  1666 00000E21 66D1D8                  	rcr	ax, 1	
  1667 00000E24 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1668 00000E26 660305[00210000]        	add	ax, [previous_val_l]
  1669 00000E2D 66D1D8                  	rcr	ax, 1
  1670 00000E30 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1671 00000E33 66AB                    	stosw		; this is 1st interpolated sample (L)
  1672 00000E35 66A1[06210000]          	mov	ax, [next_val_r]
  1673 00000E3B 660305[02210000]        	add	ax, [previous_val_r]
  1674 00000E42 66D1D8                  	rcr	ax, 1
  1675 00000E45 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1676 00000E47 660305[02210000]        	add	ax, [previous_val_r]
  1677 00000E4E 66D1D8                  	rcr	ax, 1
  1678 00000E51 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1679 00000E52 660305[02210000]        	add	ax, [previous_val_r]
  1680 00000E59 66D1D8                  	rcr	ax, 1
  1681 00000E5C 80EC80                  	sub	ah, 80h
  1682 00000E5F 66AB                    	stosw		; this is 1st interpolated sample (R)
  1683 00000E61 89D8                    	mov	eax, ebx
  1684 00000E63 6601D0                  	add	ax, dx
  1685 00000E66 66D1D8                  	rcr	ax, 1
  1686 00000E69 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1687 00000E6C 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1688 00000E6E 58                      	pop	eax ; *
  1689 00000E6F 6601E8                  	add	ax, bp
  1690 00000E72 66D1D8                  	rcr	ax, 1
  1691 00000E75 80EC80                  	sub	ah, 80h
  1692 00000E78 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1693 00000E7A 89D0                    	mov	eax, edx
  1694 00000E7C 80EC80                  	sub	ah, 80h
  1695 00000E7F 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1696 00000E81 89E8                    	mov	eax, ebp
  1697 00000E83 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1698 00000E86 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1699 00000E88 66A1[04210000]          	mov	ax, [next_val_l]
  1700 00000E8E 6601D0                  	add	ax, dx
  1701 00000E91 66D1D8                  	rcr	ax, 1
  1702 00000E94 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1703 00000E96 6601D0                  	add	ax, dx
  1704 00000E99 66D1D8                  	rcr	ax, 1
  1705 00000E9C 80EC80                  	sub	ah, 80h
  1706 00000E9F 66AB                    	stosw		; this is 4th interpolated sample (L)
  1707 00000EA1 66A1[06210000]          	mov	ax, [next_val_r]
  1708 00000EA7 6601E8                  	add	ax, bp
  1709 00000EAA 66D1D8                  	rcr	ax, 1
  1710 00000EAD 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1711 00000EAE 6601E8                  	add	ax, bp
  1712 00000EB1 66D1D8                  	rcr	ax, 1
  1713 00000EB4 80EC80                  	sub	ah, 80h
  1714 00000EB7 66AB                    	stosw		; this is 4th interpolated sample (R)
  1715 00000EB9 66A1[04210000]          	mov	ax, [next_val_l]
  1716 00000EBF 6601D8                  	add	ax, bx
  1717 00000EC2 66D1D8                  	rcr	ax, 1
  1718 00000EC5 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1719 00000EC8 66AB                    	stosw		; this is 5th interpolated sample (L)
  1720 00000ECA 58                      	pop	eax ; **
  1721 00000ECB 660305[06210000]        	add	ax, [next_val_r]
  1722 00000ED2 66D1D8                  	rcr	ax, 1
  1723 00000ED5 80EC80                  	sub	ah, 80h
  1724 00000ED8 66AB                    	stosw		; this is 5th interpolated sample (R)
  1725                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1726 00000EDA E305                    	jecxz	lff8_s2_9
  1727 00000EDC E9F2FEFFFF              	jmp	lff8s2_1
  1728                                  lff8_s2_9:
  1729 00000EE1 E990FCFFFF              	jmp	lff8s2_3
  1730                                  
  1731                                  ; .....................
  1732                                  
  1733                                  load_16khz_mono_8_bit:
  1734                                  	; 14/11/2023
  1735                                  	; 13/11/2023
  1736 00000EE6 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1737                                  					; last of the file?
  1738 00000EED 7402                    	jz	short lff16m_0		; no
  1739 00000EEF F9                      	stc
  1740 00000EF0 C3                      	retn
  1741                                  
  1742                                  lff16m_0:
  1743 00000EF1 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1744                                          ;mov	edx, [loadsize]
  1745                                  
  1746                                  	; esi = buffer address
  1747                                  	;; edx = buffer size
  1748                                  
  1749                                  	; load file into memory
  1750                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000EF6 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000EFC 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000EFE 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000F04 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000F09 CD40                <1>  int 40h
  1751 00000F0B 7253                    	jc	short lff16m_7 ; error !
  1752                                  
  1753 00000F0D BF[00300000]            	mov	edi, audio_buffer
  1754                                  	
  1755 00000F12 21C0                    	and	eax, eax
  1756 00000F14 7505                    	jnz	short lff16m_8
  1757 00000F16 E96EFCFFFF              	jmp	lff16_eof
  1758                                  
  1759                                  lff16m_8:
  1760 00000F1B 89C1                    	mov	ecx, eax		; byte count
  1761                                  lff16m_1:
  1762 00000F1D AC                      	lodsb
  1763                                  	;mov	[previous_val], al
  1764 00000F1E 88C3                    	mov	bl, al
  1765 00000F20 2C80                    	sub	al, 80h
  1766 00000F22 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1767 00000F26 66AB                    	stosw		; original sample (left channel)
  1768 00000F28 66AB                    	stosw		; original sample (right channel)
  1769                                  	;xor	ax, ax
  1770                                  	; 14/11/22023
  1771 00000F2A B080                    	mov	al, 80h
  1772 00000F2C 49                      	dec	ecx
  1773 00000F2D 7402                    	jz	short lff16m_2
  1774 00000F2F 8A06                    	mov	al, [esi]
  1775                                  lff16m_2:
  1776                                  	;mov	[next_val], al
  1777 00000F31 88C7                    	mov	bh, al
  1778                                  	;add	al, [previous_val]
  1779 00000F33 00D8                    	add	al, bl
  1780 00000F35 D0D8                    	rcr	al, 1
  1781 00000F37 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1782                                  	;add	al, [previous_val]
  1783 00000F39 00D8                    	add	al, bl
  1784 00000F3B D0D8                    	rcr	al, 1
  1785 00000F3D 2C80                    	sub	al, 80h
  1786 00000F3F 66C1E008                	shl	ax, 8
  1787 00000F43 66AB                    	stosw		; this is 1st interpolated sample (L)
  1788 00000F45 66AB                    	stosw		; this is 1st interpolated sample (R)
  1789                                  	;mov	al, [next_val]
  1790 00000F47 88F8                    	mov	al, bh
  1791 00000F49 00D0                    	add	al, dl
  1792 00000F4B D0D8                    	rcr	al, 1
  1793 00000F4D 2C80                    	sub	al, 80h
  1794 00000F4F 66C1E008                	shl	ax, 8
  1795 00000F53 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1796 00000F55 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1797                                  	
  1798                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1799 00000F57 09C9                    	or	ecx, ecx
  1800 00000F59 75C2                    	jnz	short lff16m_1
  1801 00000F5B E916FCFFFF              	jmp	lff16m_3
  1802                                  
  1803                                  lff16m_7:
  1804                                  lff16s_7:
  1805 00000F60 E92DFCFFFF              	jmp	lff16m_5  ; error
  1806                                  
  1807                                  load_16khz_stereo_8_bit:
  1808                                  	; 14/11/2023
  1809                                  	; 13/11/2023
  1810 00000F65 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1811                                  					; last of the file?
  1812 00000F6C 7402                    	jz	short lff16s_0		; no
  1813 00000F6E F9                      	stc
  1814 00000F6F C3                      	retn
  1815                                  
  1816                                  lff16s_0:
  1817 00000F70 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1818                                          ;mov	edx, [loadsize]
  1819                                  
  1820                                  	; esi = buffer address
  1821                                  	;; edx = buffer size
  1822                                  
  1823                                  	; load file into memory
  1824                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00000F75 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00000F7B 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00000F7D 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00000F83 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00000F88 CD40                <1>  int 40h
  1825 00000F8A 72D4                    	jc	short lff16s_7 ; error !
  1826                                  
  1827 00000F8C BF[00300000]            	mov	edi, audio_buffer
  1828                                  	
  1829 00000F91 D1E8                    	shr	eax, 1
  1830 00000F93 7505                    	jnz	short lff16s_8
  1831 00000F95 E9EFFBFFFF              	jmp	lff16_eof
  1832                                  
  1833                                  lff16s_8:
  1834 00000F9A 89C1                    	mov	ecx, eax	; word count
  1835                                  lff16s_1:
  1836 00000F9C AC                      	lodsb
  1837 00000F9D A2[00210000]            	mov	[previous_val_l], al
  1838 00000FA2 2C80                    	sub	al, 80h
  1839 00000FA4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1840 00000FA8 66AB                    	stosw		; original sample (L)
  1841 00000FAA AC                      	lodsb
  1842 00000FAB A2[02210000]            	mov	[previous_val_r], al
  1843 00000FB0 2C80                    	sub	al, 80h
  1844 00000FB2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1845 00000FB6 66AB                    	stosw		; original sample (R)
  1846                                  
  1847                                  	;xor	eax, eax
  1848 00000FB8 66B88080                	mov	ax, 8080h
  1849 00000FBC 49                      	dec	ecx
  1850 00000FBD 7403                    	jz	short lff16s_2
  1851                                  		; convert 8 bit sample to 16 bit sample
  1852 00000FBF 668B06                  	mov	ax, [esi]
  1853                                  lff16s_2:
  1854                                  	;mov	[next_val_l], al
  1855                                  	;mov	[next_val_r], ah
  1856 00000FC2 89C3                    	mov	ebx, eax
  1857 00000FC4 0205[00210000]          	add	al, [previous_val_l]
  1858 00000FCA D0D8                    	rcr	al, 1
  1859 00000FCC 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  1860 00000FCE 0205[00210000]          	add	al, [previous_val_l]
  1861 00000FD4 D0D8                    	rcr	al, 1
  1862 00000FD6 2C80                    	sub	al, 80h
  1863 00000FD8 66C1E008                	shl	ax, 8
  1864 00000FDC 66AB                    	stosw		; this is 1st interpolated sample (L)
  1865 00000FDE 88F8                    	mov	al, bh	; [next_val_r]
  1866 00000FE0 0205[02210000]          	add	al, [previous_val_r]
  1867 00000FE6 D0D8                    	rcr	al, 1
  1868 00000FE8 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  1869 00000FEA 0205[02210000]          	add	al, [previous_val_r]
  1870 00000FF0 D0D8                    	rcr	al, 1
  1871 00000FF2 2C80                    	sub	al, 80h
  1872 00000FF4 66C1E008                	shl	ax, 8
  1873 00000FF8 66AB                    	stosw		; this is 1st interpolated sample (R)
  1874 00000FFA 88D0                    	mov	al, dl
  1875 00000FFC 00D8                    	add	al, bl	; [next_val_l]
  1876 00000FFE D0D8                    	rcr	al, 1
  1877 00001000 2C80                    	sub	al, 80h
  1878 00001002 66C1E008                	shl	ax, 8
  1879 00001006 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1880 00001008 88F0                    	mov	al, dh
  1881 0000100A 00F8                    	add	al, bh	; [next_val_r]
  1882 0000100C D0D8                    	rcr	al, 1
  1883 0000100E 2C80                    	sub	al, 80h
  1884 00001010 66C1E008                	shl	ax, 8
  1885 00001014 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1886                                  	
  1887                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1888 00001016 09C9                    	or	ecx, ecx
  1889 00001018 7582                    	jnz	short lff16s_1
  1890 0000101A E957FBFFFF              	jmp	lff16s_3
  1891                                  
  1892                                  load_16khz_mono_16_bit:
  1893                                  	; 15/11/2023
  1894                                  	; 13/11/2023
  1895 0000101F F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1896                                  					; last of the file?
  1897 00001026 7402                    	jz	short lff16m2_0		; no
  1898 00001028 F9                      	stc
  1899 00001029 C3                      	retn
  1900                                  
  1901                                  lff16m2_0:
  1902 0000102A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1903                                          ;mov	edx, [loadsize]
  1904                                  
  1905                                  	; esi = buffer address
  1906                                  	;; edx = buffer size
  1907                                  
  1908                                  	; load file into memory
  1909                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000102F 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001035 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001037 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000103D B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001042 CD40                <1>  int 40h
  1910 00001044 7255                    	jc	short lff16m2_7 ; error !
  1911                                  
  1912 00001046 BF[00300000]            	mov	edi, audio_buffer
  1913                                  	
  1914 0000104B D1E8                    	shr	eax, 1
  1915 0000104D 7505                    	jnz	short lff16m2_8
  1916 0000104F E935FBFFFF              	jmp	lff16_eof
  1917                                  
  1918                                  lff16m2_8:
  1919 00001054 89C1                    	mov	ecx, eax  ; word count
  1920                                  lff16m2_1:
  1921 00001056 66AD                    	lodsw
  1922 00001058 66AB                    	stosw		; original sample (left channel)
  1923 0000105A 66AB                    	stosw		; original sample (right channel)
  1924 0000105C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1925                                  	;mov	[previous_val], ax
  1926 0000105F 89C3                    	mov	ebx, eax	
  1927 00001061 31C0                    	xor	eax, eax
  1928 00001063 49                      	dec	ecx
  1929 00001064 7403                    	jz	short lff16m2_2
  1930 00001066 668B06                  	mov	ax, [esi]
  1931                                  lff16m2_2:
  1932 00001069 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1933 0000106C 89C5                    	mov	ebp, eax	; [next_val]
  1934                                  	;add	ax, [previous_val]
  1935 0000106E 6601D8                  	add	ax, bx
  1936 00001071 66D1D8                  	rcr	ax, 1
  1937 00001074 89C2                    	mov	edx, eax ; this is temporary interpolation value
  1938                                  	;add	ax, [previous_val]
  1939 00001076 6601D8                  	add	ax, bx
  1940 00001079 66D1D8                  	rcr	ax, 1
  1941 0000107C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1942 0000107F 66AB                    	stosw		; this is 1st interpolated sample (L)
  1943 00001081 66AB                    	stosw		; this is 1st interpolated sample (R)
  1944 00001083 89E8                    	mov	eax, ebp 
  1945 00001085 6601D0                  	add	ax, dx
  1946 00001088 66D1D8                  	rcr	ax, 1
  1947 0000108B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1948 0000108E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1949 00001090 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1950                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1951 00001092 09C9                    	or	ecx, ecx
  1952 00001094 75C0                    	jnz	short lff16m2_1
  1953 00001096 E9DBFAFFFF              	jmp	lff16m2_3
  1954                                  
  1955                                  lff16m2_7:
  1956                                  lff16s2_7:
  1957 0000109B E9F2FAFFFF              	jmp	lff16m2_5  ; error
  1958                                  
  1959                                  load_16khz_stereo_16_bit:
  1960                                  	; 16/11/2023
  1961                                  	; 15/11/2023
  1962                                  	; 13/11/2023
  1963 000010A0 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1964                                  					; last of the file?
  1965 000010A7 7402                    	jz	short lff16s2_0		; no
  1966 000010A9 F9                      	stc
  1967 000010AA C3                      	retn
  1968                                  
  1969                                  lff16s2_0:
  1970 000010AB BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1971                                          ;mov	edx, [loadsize]
  1972                                  
  1973                                  	; esi = buffer address
  1974                                  	;; edx = buffer size
  1975                                  
  1976                                  	; load file into memory
  1977                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000010B0 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000010B6 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000010B8 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000010BE B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000010C3 CD40                <1>  int 40h
  1978 000010C5 72D4                    	jc	short lff16s2_7 ; error !
  1979                                  
  1980 000010C7 BF[00300000]            	mov	edi, audio_buffer
  1981                                  	
  1982 000010CC C1E802                  	shr	eax, 2
  1983 000010CF 7505                    	jnz	short lff16s2_8
  1984 000010D1 E9B3FAFFFF              	jmp	lff16_eof
  1985                                  
  1986                                  lff16s2_8:
  1987 000010D6 89C1                    	mov	ecx, eax  ; dword count
  1988                                  lff16s2_1:
  1989 000010D8 66AD                    	lodsw
  1990 000010DA 66AB                    	stosw		; original sample (L)
  1991 000010DC 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1992 000010DF 66A3[00210000]          	mov	[previous_val_l], ax
  1993 000010E5 66AD                    	lodsw
  1994 000010E7 66AB                    	stosw		; original sample (R)
  1995 000010E9 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  1996 000010EC 66A3[02210000]          	mov	[previous_val_r], ax
  1997 000010F2 31D2                    	xor	edx, edx
  1998 000010F4 31C0                    	xor	eax, eax
  1999                                  	; 16/11/2023
  2000 000010F6 49                      	dec	ecx
  2001 000010F7 7407                    	jz	short lff16s2_2
  2002 000010F9 668B06                  	mov	ax, [esi]
  2003 000010FC 668B5602                	mov	dx, [esi+2]
  2004                                  lff16s2_2:
  2005 00001100 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2006                                  	;mov	[next_val_l], ax
  2007 00001103 89C5                    	mov	ebp, eax
  2008 00001105 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2009 00001108 668915[06210000]        	mov	[next_val_r], dx
  2010 0000110F 660305[00210000]        	add	ax, [previous_val_l]
  2011 00001116 66D1D8                  	rcr	ax, 1
  2012 00001119 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  2013 0000111B 660305[00210000]        	add	ax, [previous_val_l]
  2014 00001122 66D1D8                  	rcr	ax, 1
  2015 00001125 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2016 00001128 66AB                    	stosw		; this is 1st interpolated sample (L)
  2017 0000112A 66A1[06210000]          	mov	ax, [next_val_r]
  2018 00001130 660305[02210000]        	add	ax, [previous_val_r]
  2019 00001137 66D1D8                  	rcr	ax, 1
  2020 0000113A 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  2021 0000113C 660305[02210000]        	add	ax, [previous_val_r]
  2022 00001143 66D1D8                  	rcr	ax, 1
  2023 00001146 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2024 00001149 66AB                    	stosw		; this is 1st interpolated sample (R)
  2025                                  	;mov	ax, [next_val_l]
  2026 0000114B 89E8                    	mov	eax, ebp
  2027 0000114D 6601D0                  	add	ax, dx
  2028 00001150 66D1D8                  	rcr	ax, 1
  2029 00001153 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2030 00001156 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2031 00001158 66A1[06210000]          	mov	ax, [next_val_r]
  2032 0000115E 6601D8                  	add	ax, bx
  2033 00001161 66D1D8                  	rcr	ax, 1
  2034 00001164 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2035 00001167 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2036                                  	
  2037                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2038 00001169 09C9                    	or	ecx, ecx
  2039 0000116B 0F8567FFFFFF            	jnz	lff16s2_1
  2040 00001171 E900FAFFFF              	jmp	lff16s2_3
  2041                                  
  2042                                  ; .....................
  2043                                  
  2044                                  load_24khz_mono_8_bit:
  2045                                  	; 15/11/2023
  2046 00001176 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2047                                  					; last of the file?
  2048 0000117D 7402                    	jz	short lff24m_0		; no
  2049 0000117F F9                      	stc
  2050 00001180 C3                      	retn
  2051                                  
  2052                                  lff24m_0:
  2053 00001181 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2054                                          ;mov	edx, [loadsize]
  2055                                  
  2056                                  	; esi = buffer address
  2057                                  	;; edx = buffer size
  2058                                  
  2059                                  	; load file into memory
  2060                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001186 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000118C 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000118E 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001194 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001199 CD40                <1>  int 40h
  2061 0000119B 723B                    	jc	short lff24m_7 ; error !
  2062                                  
  2063 0000119D BF[00300000]            	mov	edi, audio_buffer
  2064                                  	
  2065 000011A2 21C0                    	and	eax, eax
  2066 000011A4 7505                    	jnz	short lff24m_8
  2067 000011A6 E9DEF9FFFF              	jmp	lff24_eof
  2068                                  
  2069                                  lff24m_8:
  2070 000011AB 89C1                    	mov	ecx, eax	; byte count
  2071                                  lff24m_1:
  2072 000011AD AC                      	lodsb
  2073                                  	;mov	[previous_val], al
  2074 000011AE 88C3                    	mov	bl, al
  2075 000011B0 2C80                    	sub	al, 80h
  2076 000011B2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2077 000011B6 66AB                    	stosw		; original sample (left channel)
  2078 000011B8 66AB                    	stosw		; original sample (right channel)
  2079                                  	;xor	eax, eax
  2080 000011BA B080                    	mov	al, 80h
  2081 000011BC 49                      	dec	ecx
  2082 000011BD 7402                    	jz	short lff24m_2
  2083 000011BF 8A06                    	mov	al, [esi]
  2084                                  lff24m_2:
  2085                                  	;;mov	[next_val], al
  2086                                  	;mov	bh, al
  2087                                  	;add	al, [previous_val]
  2088 000011C1 00D8                    	add	al, bl
  2089 000011C3 D0D8                    	rcr	al, 1
  2090 000011C5 2C80                    	sub	al, 80h
  2091 000011C7 66C1E008                	shl	ax, 8
  2092 000011CB 66AB                    	stosw		; this is interpolated sample (L)
  2093 000011CD 66AB                    	stosw		; this is interpolated sample (R)
  2094                                  	
  2095                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2096 000011CF 09C9                    	or	ecx, ecx
  2097 000011D1 75DA                    	jnz	short lff24m_1
  2098 000011D3 E99EF9FFFF              	jmp	lff24_3
  2099                                  
  2100                                  lff24m_7:
  2101                                  lff24s_7:
  2102 000011D8 E9B5F9FFFF              	jmp	lff24_5  ; error
  2103                                  
  2104                                  load_24khz_stereo_8_bit:
  2105                                  	; 15/11/2023
  2106 000011DD F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2107                                  					; last of the file?
  2108 000011E4 7402                    	jz	short lff24s_0		; no
  2109 000011E6 F9                      	stc
  2110 000011E7 C3                      	retn
  2111                                  
  2112                                  lff24s_0:
  2113 000011E8 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2114                                          ;mov	edx, [loadsize]
  2115                                  
  2116                                  	; esi = buffer address
  2117                                  	;; edx = buffer size
  2118                                  
  2119                                  	; load file into memory
  2120                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000011ED 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000011F3 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000011F5 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000011FB B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001200 CD40                <1>  int 40h
  2121 00001202 72D4                    	jc	short lff24s_7 ; error !
  2122                                  
  2123 00001204 BF[00300000]            	mov	edi, audio_buffer
  2124                                  	
  2125 00001209 D1E8                    	shr	eax, 1
  2126 0000120B 7505                    	jnz	short lff24s_8
  2127 0000120D E977F9FFFF              	jmp	lff24_eof
  2128                                  
  2129                                  lff24s_8:
  2130 00001212 89C1                    	mov	ecx, eax  ; word count
  2131                                  lff24s_1:
  2132 00001214 AC                      	lodsb
  2133 00001215 A2[00210000]            	mov	[previous_val_l], al
  2134 0000121A 2C80                    	sub	al, 80h
  2135 0000121C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2136 00001220 66AB                    	stosw		; original sample (L)
  2137 00001222 AC                      	lodsb
  2138 00001223 A2[02210000]            	mov	[previous_val_r], al
  2139 00001228 2C80                    	sub	al, 80h
  2140 0000122A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2141 0000122E 66AB                    	stosw		; original sample (R)
  2142                                  
  2143                                  	;xor	eax, eax
  2144 00001230 66B88080                	mov	ax, 8080h
  2145 00001234 49                      	dec	ecx
  2146 00001235 7403                    	jz	short lff24s_2
  2147                                  		; convert 8 bit sample to 16 bit sample
  2148 00001237 668B06                  	mov	ax, [esi]
  2149                                  lff24s_2:
  2150                                  	;;mov	[next_val_l], al
  2151                                  	;;mov	[next_val_r], ah
  2152                                  	;mov	bx, ax
  2153 0000123A 88E7                    	mov	bh, ah
  2154 0000123C 0205[00210000]          	add	al, [previous_val_l]
  2155 00001242 D0D8                    	rcr	al, 1
  2156                                  	;mov	dl, al
  2157 00001244 2C80                    	sub	al, 80h
  2158 00001246 66C1E008                	shl	ax, 8
  2159 0000124A 66AB                    	stosw		; this is interpolated sample (L)
  2160 0000124C 88F8                    	mov	al, bh	; [next_val_r]
  2161 0000124E 0205[02210000]          	add	al, [previous_val_r]
  2162 00001254 D0D8                    	rcr	al, 1
  2163                                  	;mov	dh, al
  2164 00001256 2C80                    	sub	al, 80h
  2165 00001258 66C1E008                	shl	ax, 8
  2166 0000125C 66AB                    	stosw		; this is interpolated sample (R)
  2167                                  		
  2168                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2169 0000125E 09C9                    	or	ecx, ecx
  2170 00001260 75B2                    	jnz	short lff24s_1
  2171 00001262 E90FF9FFFF              	jmp	lff24_3
  2172                                  
  2173                                  load_24khz_mono_16_bit:
  2174                                  	; 15/11/2023
  2175 00001267 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2176                                  					; last of the file?
  2177 0000126E 7402                    	jz	short lff24m2_0		; no
  2178 00001270 F9                      	stc
  2179 00001271 C3                      	retn
  2180                                  
  2181                                  lff24m2_0:
  2182 00001272 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2183                                          ;mov	edx, [loadsize]
  2184                                  
  2185                                  	; esi = buffer address
  2186                                  	;; edx = buffer size
  2187                                  
  2188                                  	; load file into memory
  2189                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001277 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000127D 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000127F 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001285 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000128A CD40                <1>  int 40h
  2190 0000128C 7237                    	jc	short lff24m2_7 ; error !
  2191                                  
  2192 0000128E BF[00300000]            	mov	edi, audio_buffer
  2193                                  	
  2194 00001293 D1E8                    	shr	eax, 1
  2195 00001295 7505                    	jnz	short lff24m2_8
  2196 00001297 E9EDF8FFFF              	jmp	lff24_eof
  2197                                  
  2198                                  lff24m2_8:
  2199 0000129C 89C1                    	mov	ecx, eax  ; word count
  2200                                  lff24m2_1:
  2201 0000129E 66AD                    	lodsw
  2202 000012A0 66AB                    	stosw		; original sample (left channel)
  2203 000012A2 66AB                    	stosw		; original sample (right channel)
  2204 000012A4 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2205                                  	;mov	[previous_val], ax
  2206                                  	;mov	ebx, eax	
  2207                                  	;xor	eax, eax
  2208 000012A7 31DB                    	xor	ebx, ebx
  2209 000012A9 49                      	dec	ecx
  2210 000012AA 7403                    	jz	short lff24m2_2
  2211                                  	;mov	ax, [esi]
  2212 000012AC 668B1E                  	mov	bx, [esi]
  2213                                  lff24m2_2:
  2214                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2215                                  	;mov	ebp, eax	; [next_val]
  2216                                  	;add	ax, [previous_val]
  2217                                  	; ax = [previous_val]
  2218                                  	; bx = [next_val]
  2219 000012AF 6601D8                  	add	ax, bx
  2220 000012B2 66D1D8                  	rcr	ax, 1
  2221 000012B5 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2222 000012B8 66AB                    	stosw		; this is interpolated sample (L)
  2223 000012BA 66AB                    	stosw		; this is interpolated sample (R)
  2224                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2225 000012BC 09C9                    	or	ecx, ecx
  2226 000012BE 75DE                    	jnz	short lff24m2_1
  2227 000012C0 E9B1F8FFFF              	jmp	lff24_3
  2228                                  
  2229                                  lff24m2_7:
  2230                                  lff24s2_7:
  2231 000012C5 E9C8F8FFFF              	jmp	lff24_5  ; error
  2232                                  
  2233                                  load_24khz_stereo_16_bit:
  2234                                  	; 16/11/2023
  2235                                  	; 15/11/2023
  2236 000012CA F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2237                                  					; last of the file?
  2238 000012D1 7402                    	jz	short lff24s2_0		; no
  2239 000012D3 F9                      	stc
  2240 000012D4 C3                      	retn
  2241                                  
  2242                                  lff24s2_0:
  2243 000012D5 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2244                                          ;mov	edx, [loadsize]
  2245                                  
  2246                                  	; esi = buffer address
  2247                                  	;; edx = buffer size
  2248                                  
  2249                                  	; load file into memory
  2250                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000012DA 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000012E0 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000012E2 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000012E8 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000012ED CD40                <1>  int 40h
  2251 000012EF 72D4                    	jc	short lff24s2_7 ; error !
  2252                                  
  2253 000012F1 BF[00300000]            	mov	edi, audio_buffer
  2254                                  	
  2255 000012F6 C1E802                  	shr	eax, 2
  2256 000012F9 7505                    	jnz	short lff24s2_8
  2257 000012FB E989F8FFFF              	jmp	lff24_eof
  2258                                  
  2259                                  lff24s2_8:
  2260 00001300 89C1                    	mov	ecx, eax  ; dword count
  2261                                  lff24s2_1:
  2262 00001302 66AD                    	lodsw
  2263 00001304 66AB                    	stosw		; original sample (L)
  2264 00001306 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2265 00001309 66A3[00210000]          	mov	[previous_val_l], ax
  2266 0000130F 66AD                    	lodsw
  2267 00001311 66AB                    	stosw		; original sample (R)
  2268 00001313 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2269                                  	;mov	[previous_val_r], ax
  2270 00001316 89C3                    	mov	ebx, eax
  2271 00001318 31D2                    	xor	edx, edx
  2272 0000131A 31C0                    	xor	eax, eax
  2273                                  	; 16/11/2023
  2274 0000131C 49                      	dec	ecx
  2275 0000131D 7407                    	jz	short lff24s2_2
  2276 0000131F 668B06                  	mov	ax, [esi]
  2277 00001322 668B5602                	mov	dx, [esi+2]
  2278                                  lff24s2_2:
  2279 00001326 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2280                                  	;;mov	[next_val_l], ax
  2281                                  	;mov	ebp, eax
  2282 00001329 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2283                                  	;mov	[next_val_r], dx
  2284 0000132C 660305[00210000]        	add	ax, [previous_val_l]
  2285 00001333 66D1D8                  	rcr	ax, 1
  2286 00001336 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2287 00001339 66AB                    	stosw		; this is interpolated sample (L)
  2288                                  	;mov	ax, [next_val_r]
  2289 0000133B 89D0                    	mov	eax, edx
  2290                                  	;add	ax, [previous_val_r]
  2291 0000133D 6601D8                  	add	ax, bx
  2292 00001340 66D1D8                  	rcr	ax, 1
  2293 00001343 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2294 00001346 66AB                    	stosw		; this is interpolated sample (R)
  2295                                  	
  2296                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2297 00001348 09C9                    	or	ecx, ecx
  2298 0000134A 75B6                    	jnz	short lff24s2_1
  2299 0000134C E925F8FFFF              	jmp	lff24_3
  2300                                  
  2301                                  ; .....................
  2302                                  
  2303                                  load_32khz_mono_8_bit:
  2304                                  	; 15/11/2023
  2305 00001351 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2306                                  					; last of the file?
  2307 00001358 7402                    	jz	short lff32m_0		; no
  2308 0000135A F9                      	stc
  2309 0000135B C3                      	retn
  2310                                  
  2311                                  lff32m_0:
  2312 0000135C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2313                                          ;mov	edx, [loadsize]
  2314                                  
  2315                                  	; esi = buffer address
  2316                                  	;; edx = buffer size
  2317                                  
  2318                                  	; load file into memory
  2319                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001361 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001367 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001369 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000136F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001374 CD40                <1>  int 40h
  2320 00001376 7247                    	jc	short lff32m_7 ; error !
  2321                                  
  2322 00001378 BF[00300000]            	mov	edi, audio_buffer
  2323                                  	
  2324 0000137D 21C0                    	and	eax, eax
  2325 0000137F 7505                    	jnz	short lff32m_8
  2326 00001381 E903F8FFFF              	jmp	lff32_eof
  2327                                  
  2328                                  lff32m_8:
  2329 00001386 89C1                    	mov	ecx, eax	; byte count
  2330                                  lff32m_1:
  2331 00001388 AC                      	lodsb
  2332                                  	;mov	[previous_val], al
  2333 00001389 88C3                    	mov	bl, al
  2334 0000138B 2C80                    	sub	al, 80h
  2335 0000138D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2336 00001391 66AB                    	stosw		; original sample (left channel)
  2337 00001393 66AB                    	stosw		; original sample (right channel)
  2338                                  	;xor	eax, eax
  2339 00001395 B080                    	mov	al, 80h
  2340 00001397 49                      	dec	ecx
  2341 00001398 7402                    	jz	short lff32m_2
  2342 0000139A 8A06                    	mov	al, [esi]
  2343                                  lff32m_2:
  2344                                  	;;mov	[next_val], al
  2345                                  	;mov	bh, al
  2346                                  	;add	al, [previous_val]
  2347 0000139C 00D8                    	add	al, bl
  2348 0000139E D0D8                    	rcr	al, 1
  2349 000013A0 2C80                    	sub	al, 80h
  2350 000013A2 66C1E008                	shl	ax, 8
  2351 000013A6 66AB                    	stosw		; this is interpolated sample (L)
  2352 000013A8 66AB                    	stosw		; this is interpolated sample (R)
  2353                                  	
  2354                                  	; different than 8-16-24 kHZ !
  2355                                  	; 'original-interpolated-original' trio samples 
  2356 000013AA E30E                    	jecxz	lff32m_3
  2357                                  
  2358 000013AC AC                      	lodsb
  2359 000013AD 2C80                    	sub	al, 80h
  2360 000013AF 66C1E008                	shl	ax, 8
  2361 000013B3 66AB                    	stosw		; original sample (left channel)
  2362 000013B5 66AB                    	stosw		; original sample (right channel)
  2363                                  
  2364                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2365 000013B7 49                      	dec	ecx
  2366 000013B8 75CE                    	jnz	short lff32m_1
  2367                                  lff32m_3:
  2368 000013BA E9B7F7FFFF              	jmp	lff32_3
  2369                                  
  2370                                  lff32m_7:
  2371                                  lff32s_7:
  2372 000013BF E9CEF7FFFF              	jmp	lff32_5  ; error
  2373                                  
  2374                                  load_32khz_stereo_8_bit:
  2375                                  	; 15/11/2023
  2376 000013C4 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2377                                  					; last of the file?
  2378 000013CB 7402                    	jz	short lff32s_0		; no
  2379 000013CD F9                      	stc
  2380 000013CE C3                      	retn
  2381                                  
  2382                                  lff32s_0:
  2383 000013CF BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2384                                          ;mov	edx, [loadsize]
  2385                                  
  2386                                  	; esi = buffer address
  2387                                  	;; edx = buffer size
  2388                                  
  2389                                  	; load file into memory
  2390                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000013D4 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000013DA 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000013DC 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000013E2 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000013E7 CD40                <1>  int 40h
  2391 000013E9 72D4                    	jc	short lff32s_7 ; error !
  2392                                  
  2393 000013EB BF[00300000]            	mov	edi, audio_buffer
  2394                                  	
  2395 000013F0 D1E8                    	shr	eax, 1
  2396 000013F2 7505                    	jnz	short lff32s_8
  2397 000013F4 E990F7FFFF              	jmp	lff32_eof
  2398                                  
  2399                                  lff32s_8:
  2400 000013F9 89C1                    	mov	ecx, eax  ; word count
  2401                                  lff32s_1:
  2402 000013FB AC                      	lodsb
  2403 000013FC A2[00210000]            	mov	[previous_val_l], al
  2404 00001401 2C80                    	sub	al, 80h
  2405 00001403 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2406 00001407 66AB                    	stosw		; original sample (L)
  2407 00001409 AC                      	lodsb
  2408 0000140A A2[02210000]            	mov	[previous_val_r], al
  2409 0000140F 2C80                    	sub	al, 80h
  2410 00001411 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2411 00001415 66AB                    	stosw		; original sample (R)
  2412                                  
  2413                                  	;xor	eax, eax
  2414 00001417 66B88080                	mov	ax, 8080h
  2415 0000141B 49                      	dec	ecx
  2416 0000141C 7403                    	jz	short lff32s_2
  2417                                  		; convert 8 bit sample to 16 bit sample
  2418 0000141E 668B06                  	mov	ax, [esi]
  2419                                  lff32s_2:
  2420                                  	;;mov	[next_val_l], al
  2421                                  	;;mov	[next_val_r], ah
  2422                                  	;mov	bx, ax
  2423 00001421 88E7                    	mov	bh, ah
  2424 00001423 0205[00210000]          	add	al, [previous_val_l]
  2425 00001429 D0D8                    	rcr	al, 1
  2426                                  	;mov	dl, al
  2427 0000142B 2C80                    	sub	al, 80h
  2428 0000142D 66C1E008                	shl	ax, 8
  2429 00001431 66AB                    	stosw		; this is interpolated sample (L)
  2430 00001433 88F8                    	mov	al, bh	; [next_val_r]
  2431 00001435 0205[02210000]          	add	al, [previous_val_r]
  2432 0000143B D0D8                    	rcr	al, 1
  2433                                  	;mov	dh, al
  2434 0000143D 2C80                    	sub	al, 80h
  2435 0000143F 66C1E008                	shl	ax, 8
  2436 00001443 66AB                    	stosw		; this is interpolated sample (R)
  2437                                  
  2438                                  	; different than 8-16-24 kHZ !
  2439                                  	; 'original-interpolated-original' trio samples 
  2440 00001445 E315                    	jecxz	lff32s_3
  2441                                  
  2442 00001447 AC                      	lodsb
  2443 00001448 2C80                    	sub	al, 80h
  2444 0000144A 66C1E008                	shl	ax, 8
  2445 0000144E 66AB                    	stosw		; original sample (left channel)
  2446                                  
  2447 00001450 AC                      	lodsb
  2448 00001451 2C80                    	sub	al, 80h
  2449 00001453 66C1E008                	shl	ax, 8
  2450 00001457 66AB                    	stosw		; original sample (right channel)
  2451                                  		
  2452                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2453 00001459 49                      	dec	ecx
  2454 0000145A 759F                    	jnz	short lff32s_1
  2455                                  lff32s_3:
  2456 0000145C E915F7FFFF              	jmp	lff32_3
  2457                                  
  2458                                  load_32khz_mono_16_bit:
  2459                                  	; 15/11/2023
  2460 00001461 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2461                                  					; last of the file?
  2462 00001468 7402                    	jz	short lff32m2_0		; no
  2463 0000146A F9                      	stc
  2464 0000146B C3                      	retn
  2465                                  
  2466                                  lff32m2_0:
  2467 0000146C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2468                                          ;mov	edx, [loadsize]
  2469                                  
  2470                                  	; esi = buffer address
  2471                                  	;; edx = buffer size
  2472                                  
  2473                                  	; load file into memory
  2474                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001471 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001477 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001479 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000147F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001484 CD40                <1>  int 40h
  2475 00001486 723E                    	jc	short lff32m2_7 ; error !
  2476                                  
  2477 00001488 BF[00300000]            	mov	edi, audio_buffer
  2478                                  	
  2479 0000148D D1E8                    	shr	eax, 1
  2480 0000148F 7505                    	jnz	short lff32m2_8
  2481 00001491 E9F3F6FFFF              	jmp	lff32_eof
  2482                                  
  2483                                  lff32m2_8:
  2484 00001496 89C1                    	mov	ecx, eax  ; word count
  2485                                  lff32m2_1:
  2486 00001498 66AD                    	lodsw
  2487 0000149A 66AB                    	stosw		; original sample (left channel)
  2488 0000149C 66AB                    	stosw		; original sample (right channel)
  2489 0000149E 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2490                                  	;mov	[previous_val], ax
  2491                                  	;mov	ebx, eax	
  2492                                  	;xor	eax, eax
  2493 000014A1 31DB                    	xor	ebx, ebx
  2494 000014A3 49                      	dec	ecx
  2495 000014A4 7403                    	jz	short lff32m2_2
  2496                                  	;mov	ax, [esi]
  2497 000014A6 668B1E                  	mov	bx, [esi]
  2498                                  lff32m2_2:
  2499                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2500                                  	;mov	ebp, eax	; [next_val]
  2501                                  	;add	ax, [previous_val]
  2502                                  	; ax = [previous_val]
  2503                                  	; bx = [next_val]
  2504 000014A9 6601D8                  	add	ax, bx
  2505 000014AC 66D1D8                  	rcr	ax, 1
  2506 000014AF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2507 000014B2 66AB                    	stosw		; this is interpolated sample (L)
  2508 000014B4 66AB                    	stosw		; this is interpolated sample (R)
  2509                                  
  2510                                  	; different than 8-16-24 kHZ !
  2511                                  	; 'original-interpolated-original' trio samples 
  2512 000014B6 E309                    	jecxz	lff32m2_3
  2513                                  
  2514 000014B8 66AD                    	lodsw
  2515 000014BA 66AB                    	stosw		; original sample (left channel)
  2516 000014BC 66AB                    	stosw		; original sample (right channel)
  2517                                  
  2518                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2519 000014BE 49                      	dec	ecx
  2520 000014BF 75D7                    	jnz	short lff32m2_1
  2521                                  lff32m2_3:
  2522 000014C1 E9B0F6FFFF              	jmp	lff32_3
  2523                                  
  2524                                  lff32m2_7:
  2525                                  lff32s2_7:
  2526 000014C6 E9C7F6FFFF              	jmp	lff32_5  ; error
  2527                                  
  2528                                  load_32khz_stereo_16_bit:
  2529                                  	; 16/11/2023
  2530                                  	; 15/11/2023
  2531 000014CB F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2532                                  					; last of the file?
  2533 000014D2 7402                    	jz	short lff32s2_0		; no
  2534 000014D4 F9                      	stc
  2535 000014D5 C3                      	retn
  2536                                  
  2537                                  lff32s2_0:
  2538 000014D6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2539                                          ;mov	edx, [loadsize]
  2540                                  
  2541                                  	; esi = buffer address
  2542                                  	;; edx = buffer size
  2543                                  
  2544                                  	; load file into memory
  2545                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000014DB 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000014E1 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000014E3 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000014E9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000014EE CD40                <1>  int 40h
  2546 000014F0 72D4                    	jc	short lff32s2_7 ; error !
  2547                                  
  2548 000014F2 BF[00300000]            	mov	edi, audio_buffer
  2549                                  	
  2550 000014F7 C1E802                  	shr	eax, 2
  2551 000014FA 7505                    	jnz	short lff32s2_8
  2552 000014FC E988F6FFFF              	jmp	lff32_eof
  2553                                  
  2554                                  lff32s2_8:
  2555 00001501 89C1                    	mov	ecx, eax ; dword count
  2556                                  lff32s2_1:
  2557 00001503 66AD                    	lodsw
  2558 00001505 66AB                    	stosw		; original sample (L)
  2559 00001507 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2560 0000150A 66A3[00210000]          	mov	[previous_val_l], ax
  2561 00001510 66AD                    	lodsw
  2562 00001512 66AB                    	stosw		; original sample (R)
  2563 00001514 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2564                                  	;mov	[previous_val_r], ax
  2565 00001517 89C3                    	mov	ebx, eax
  2566 00001519 31D2                    	xor	edx, edx
  2567 0000151B 31C0                    	xor	eax, eax
  2568                                  	; 16/11/2023
  2569 0000151D 49                      	dec	ecx
  2570 0000151E 7407                    	jz	short lff32s2_2
  2571 00001520 668B06                  	mov	ax, [esi]
  2572 00001523 668B5602                	mov	dx, [esi+2]
  2573                                  lff32s2_2:
  2574 00001527 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2575                                  	;;mov	[next_val_l], ax
  2576                                  	;mov	ebp, eax
  2577 0000152A 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2578                                  	;mov	[next_val_r], dx
  2579 0000152D 660305[00210000]        	add	ax, [previous_val_l]
  2580 00001534 66D1D8                  	rcr	ax, 1
  2581 00001537 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2582 0000153A 66AB                    	stosw		; this is interpolated sample (L)
  2583                                  	;mov	ax, [next_val_r]
  2584 0000153C 89D0                    	mov	eax, edx
  2585                                  	;add	ax, [previous_val_r]
  2586 0000153E 6601D8                  	add	ax, bx
  2587 00001541 66D1D8                  	rcr	ax, 1
  2588 00001544 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2589 00001547 66AB                    	stosw		; this is interpolated sample (R)
  2590                                  
  2591                                  	; different than 8-16-24 kHZ !
  2592                                  	; 'original-interpolated-original' trio samples 
  2593 00001549 E30B                    	jecxz	lff32s2_3
  2594                                  
  2595 0000154B 66AD                    	lodsw
  2596 0000154D 66AB                    	stosw	; original sample (L)
  2597 0000154F 66AD                    	lodsw
  2598 00001551 66AB                    	stosw	; original sample (R)
  2599                                  	
  2600                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2601 00001553 49                      	dec	ecx
  2602 00001554 75AD                    	jnz	short lff32s2_1
  2603                                  lff32s2_3:
  2604 00001556 E91BF6FFFF              	jmp	lff32_3
  2605                                  
  2606                                  ; .....................
  2607                                  
  2608                                  load_22khz_mono_8_bit:
  2609                                  	; 16/11/2023
  2610 0000155B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2611                                  					; last of the file?
  2612 00001562 7402                    	jz	short lff22m_0		; no
  2613 00001564 F9                      	stc
  2614 00001565 C3                      	retn
  2615                                  
  2616                                  lff22m_0:
  2617 00001566 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2618                                          ;mov	edx, [loadsize]
  2619                                  
  2620                                  	; esi = buffer address
  2621                                  	;; edx = buffer size
  2622                                  
  2623                                  	; load file into memory
  2624                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000156B 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001571 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001573 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001579 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000157E CD40                <1>  int 40h
  2625 00001580 725D                    	jc	short lff22m_7 ; error !
  2626                                  
  2627 00001582 BF[00300000]            	mov	edi, audio_buffer
  2628                                  	
  2629 00001587 21C0                    	and	eax, eax
  2630 00001589 7505                    	jnz	short lff22m_8
  2631 0000158B E9F9F5FFFF              	jmp	lff22_eof
  2632                                  
  2633                                  lff22m_8:
  2634 00001590 89C1                    	mov	ecx, eax	; byte count
  2635                                  lff22m_9:
  2636 00001592 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2637 00001597 C605[08210000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2638                                  lff22m_1:
  2639                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2640 0000159E AC                      	lodsb
  2641 0000159F B280                    	mov	dl, 80h
  2642 000015A1 49                      	dec	ecx
  2643 000015A2 7402                    	jz	short lff22m_2_1
  2644 000015A4 8A16                    	mov	dl, [esi]
  2645                                  lff22m_2_1:	
  2646                                  	; al = [previous_val]
  2647                                  	; dl = [next_val]
  2648 000015A6 E80F060000              	call	interpolating_3_8bit_mono ; 1 of 17
  2649 000015AB E32D                    	jecxz	lff22m_3
  2650                                  lff22m_2_2:
  2651 000015AD AC                      	lodsb
  2652 000015AE B280                    	mov	dl, 80h
  2653 000015B0 49                      	dec	ecx
  2654 000015B1 7402                    	jz	short lff22m_2_3
  2655 000015B3 8A16                    	mov	dl, [esi]
  2656                                  lff22m_2_3:
  2657 000015B5 E884060000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2658 000015BA E31E                    	jecxz	lff22m_3
  2659 000015BC 4D                      	dec	ebp
  2660 000015BD 75EE                    	jnz	short lff22m_2_2
  2661                                  
  2662 000015BF A0[08210000]            	mov	al, [faz]
  2663 000015C4 FEC8                    	dec	al
  2664 000015C6 74CA                    	jz	short lff22m_9
  2665 000015C8 FE0D[08210000]          	dec	byte [faz]
  2666 000015CE BD04000000              	mov	ebp, 4
  2667 000015D3 FEC8                    	dec	al
  2668 000015D5 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2669 000015D7 45                      	inc	ebp ; 5
  2670 000015D8 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2671                                  
  2672                                  lff22m_3:
  2673                                  lff22s_3:
  2674 000015DA E997F5FFFF              	jmp	lff22_3	; padfill
  2675                                  		; (put zeros in the remain words of the buffer)
  2676                                  lff22m_7:
  2677                                  lff22s_7:
  2678 000015DF E9AEF5FFFF              	jmp	lff22_5  ; error
  2679                                  
  2680                                  load_22khz_stereo_8_bit:
  2681                                  	; 16/11/2023
  2682 000015E4 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2683                                  					; last of the file?
  2684 000015EB 7402                    	jz	short lff22s_0		; no
  2685 000015ED F9                      	stc
  2686 000015EE C3                      	retn
  2687                                  
  2688                                  lff22s_0:
  2689 000015EF BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2690                                          ;mov	edx, [loadsize]
  2691                                  
  2692                                  	; esi = buffer address
  2693                                  	;; edx = buffer size
  2694                                  
  2695                                  	; load file into memory
  2696                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000015F4 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000015FA 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000015FC 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001602 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001607 CD40                <1>  int 40h
  2697 00001609 72D4                    	jc	short lff22s_7 ; error !
  2698                                  
  2699 0000160B BF[00300000]            	mov	edi, audio_buffer
  2700                                  	
  2701 00001610 D1E8                    	shr	eax, 1
  2702 00001612 7505                    	jnz	short lff22s_8
  2703 00001614 E970F5FFFF              	jmp	lff22_eof
  2704                                  
  2705                                  lff22s_8:
  2706 00001619 89C1                    	mov	ecx, eax	; word count
  2707                                  lff22s_9:
  2708 0000161B BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2709 00001620 C605[08210000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2710                                  lff22s_1:
  2711                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2712 00001627 66AD                    	lodsw
  2713 00001629 66BA8080                	mov	dx, 8080h
  2714 0000162D 49                      	dec	ecx
  2715 0000162E 7403                    	jz	short lff22s_2_1 
  2716 00001630 668B16                  	mov	dx, [esi]
  2717                                  lff22s_2_1:	
  2718                                  	; al = [previous_val_l]
  2719                                  	; ah = [previous_val_r]
  2720                                  	; dl = [next_val_l]
  2721                                  	; dh = [next_val_r]	
  2722 00001633 E8B3050000              	call	interpolating_3_8bit_stereo ; 1 of 17 
  2723 00001638 E3A0                    	jecxz	lff22s_3
  2724                                  lff22s_2_2:
  2725 0000163A 66AD                    	lodsw
  2726 0000163C 66BA8080                	mov	dx, 8080h
  2727 00001640 49                      	dec	ecx
  2728 00001641 7403                    	jz	short lff22s_2_3
  2729 00001643 668B16                  	mov	dx, [esi]
  2730                                  lff22s_2_3:
  2731 00001646 E810060000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2732 0000164B E38D                    	jecxz	lff22s_3
  2733 0000164D 4D                      	dec	ebp
  2734 0000164E 75EA                    	jnz	short lff22s_2_2
  2735                                  
  2736 00001650 A0[08210000]            	mov	al, [faz]
  2737 00001655 FEC8                    	dec	al
  2738 00001657 74C2                    	jz	short lff22s_9
  2739 00001659 FE0D[08210000]          	dec	byte [faz]
  2740 0000165F BD04000000              	mov	ebp, 4
  2741 00001664 FEC8                    	dec	al
  2742 00001666 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2743 00001668 45                      	inc	ebp ; 5
  2744 00001669 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2745                                  
  2746                                  load_22khz_mono_16_bit:
  2747                                  	; 16/11/2023
  2748 0000166B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2749                                  					; last of the file?
  2750 00001672 7402                    	jz	short lff22m2_0		; no
  2751 00001674 F9                      	stc
  2752 00001675 C3                      	retn
  2753                                  
  2754                                  lff22m2_0:
  2755 00001676 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2756                                          ;mov	edx, [loadsize]
  2757                                  
  2758                                  	; esi = buffer address
  2759                                  	;; edx = buffer size
  2760                                  
  2761                                  	; load file into memory
  2762                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 0000167B 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001681 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001683 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001689 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000168E CD40                <1>  int 40h
  2763 00001690 7261                    	jc	short lff22m2_7 ; error !
  2764                                  
  2765 00001692 BF[00300000]            	mov	edi, audio_buffer
  2766                                  	
  2767 00001697 D1E8                    	shr	eax, 1
  2768 00001699 7505                    	jnz	short lff22m2_8
  2769 0000169B E9E9F4FFFF              	jmp	lff22_eof
  2770                                  
  2771                                  lff22m2_8:
  2772 000016A0 89C1                    	mov	ecx, eax	; word count
  2773                                  lff22m2_9:
  2774 000016A2 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2775 000016A7 C605[08210000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2776                                  lff22m2_1:
  2777                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2778 000016AE 66AD                    	lodsw
  2779 000016B0 31D2                    	xor	edx, edx
  2780 000016B2 49                      	dec	ecx
  2781 000016B3 7403                    	jz	short lff22m2_2_1
  2782 000016B5 668B16                  	mov	dx, [esi]
  2783                                  lff22m2_2_1:	
  2784                                  	; ax = [previous_val]
  2785                                  	; dx = [next_val]
  2786 000016B8 E8CF050000              	call	interpolating_3_16bit_mono ; 1 of 17
  2787 000016BD E32F                    	jecxz	lff22m2_3
  2788                                  lff22m2_2_2:
  2789 000016BF 66AD                    	lodsw
  2790 000016C1 31D2                    	xor	edx, edx
  2791 000016C3 49                      	dec	ecx
  2792 000016C4 7403                    	jz	short lff22m2_2_3
  2793 000016C6 668B16                  	mov	dx, [esi]
  2794                                  lff22m2_2_3:
  2795 000016C9 E851060000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2796 000016CE E31E                    	jecxz	lff22m2_3
  2797 000016D0 4D                      	dec	ebp
  2798 000016D1 75EC                    	jnz	short lff22m2_2_2
  2799                                  
  2800 000016D3 A0[08210000]            	mov	al, [faz]
  2801 000016D8 FEC8                    	dec	al
  2802 000016DA 74C6                    	jz	short lff22m2_9
  2803 000016DC FE0D[08210000]          	dec	byte [faz]
  2804 000016E2 BD04000000              	mov	ebp, 4
  2805 000016E7 FEC8                    	dec	al
  2806 000016E9 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2807 000016EB 45                      	inc	ebp ; 5
  2808 000016EC EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2809                                  
  2810                                  lff22m2_3:
  2811                                  lff22s2_3:
  2812 000016EE E983F4FFFF              	jmp	lff22_3	; padfill
  2813                                  		; (put zeros in the remain words of the buffer)
  2814                                  lff22m2_7:
  2815                                  lff22s2_7:
  2816 000016F3 E99AF4FFFF              	jmp	lff22_5  ; error
  2817                                  
  2818                                  load_22khz_stereo_16_bit:
  2819                                  	; 16/11/2023
  2820 000016F8 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2821                                  					; last of the file?
  2822 000016FF 7402                    	jz	short lff22s2_0		; no
  2823 00001701 F9                      	stc
  2824 00001702 C3                      	retn
  2825                                  
  2826                                  lff22s2_0:
  2827 00001703 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2828                                          ;mov	edx, [loadsize]
  2829                                  
  2830                                  	; esi = buffer address
  2831                                  	;; edx = buffer size
  2832                                  
  2833                                  	; load file into memory
  2834                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001708 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000170E 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001710 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001716 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 0000171B CD40                <1>  int 40h
  2835 0000171D 72D4                    	jc	short lff22s2_7 ; error !
  2836                                  
  2837 0000171F BF[00300000]            	mov	edi, audio_buffer
  2838                                  	
  2839 00001724 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  2840 00001727 7505                    	jnz	short lff22s2_8
  2841 00001729 E95BF4FFFF              	jmp	lff22_eof
  2842                                  
  2843                                  lff22s2_8:
  2844 0000172E 89C1                    	mov	ecx, eax	; dword count
  2845                                  lff22s2_9:
  2846 00001730 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2847 00001735 C605[08210000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2848                                  lff22s2_1:
  2849                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2850 0000173C 66AD                    	lodsw
  2851 0000173E 89C3                    	mov	ebx, eax
  2852 00001740 66AD                    	lodsw
  2853 00001742 8B16                    	mov	edx, [esi]
  2854 00001744 668915[04210000]        	mov	[next_val_l], dx
  2855                                  	; 26/11/2023
  2856 0000174B C1EA10                  	shr	edx, 16
  2857 0000174E 49                      	dec	ecx
  2858 0000174F 7509                    	jnz	short lff22s2_2_1
  2859 00001751 31D2                    	xor	edx, edx ; 0
  2860 00001753 668915[04210000]        	mov	[next_val_l], dx
  2861                                  lff22s2_2_1:
  2862                                  	; bx = [previous_val_l]
  2863                                  	; ax = [previous_val_r]
  2864                                  	; [next_val_l]
  2865                                  	; dx = [next_val_r]
  2866 0000175A E85D050000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  2867 0000175F E38D                    	jecxz	lff22s2_3
  2868                                  lff22s2_2_2:
  2869 00001761 66AD                    	lodsw
  2870 00001763 89C3                    	mov	ebx, eax
  2871 00001765 66AD                    	lodsw
  2872 00001767 8B16                    	mov	edx, [esi]
  2873 00001769 668915[04210000]        	mov	[next_val_l], dx
  2874                                  	; 26/11/2023
  2875 00001770 C1EA10                  	shr	edx, 16
  2876 00001773 49                      	dec	ecx
  2877 00001774 7509                    	jnz	short lff22s2_2_3
  2878 00001776 31D2                    	xor	edx, edx ; 0
  2879 00001778 668915[04210000]        	mov	[next_val_l], dx
  2880                                  lff22s2_2_3:
  2881 0000177F E8B3050000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  2882 00001784 E31E                    	jecxz	lff22s2_2_4
  2883                                  
  2884 00001786 4D                      	dec	ebp
  2885 00001787 75D8                    	jnz	short lff22s2_2_2
  2886                                  
  2887 00001789 A0[08210000]            	mov	al, [faz]
  2888 0000178E FEC8                    	dec	al
  2889 00001790 749E                    	jz	short lff22s2_9
  2890 00001792 FE0D[08210000]          	dec	byte [faz]
  2891 00001798 BD04000000              	mov	ebp, 4
  2892 0000179D FEC8                    	dec	al
  2893 0000179F 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2894 000017A1 45                      	inc	ebp ; 5
  2895 000017A2 EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2896                                  
  2897                                  lff22s2_2_4:
  2898                                  	; 26/11/2023
  2899 000017A4 E9CDF3FFFF              	jmp	lff22_3	; padfill
  2900                                  
  2901                                  ; .....................
  2902                                  
  2903                                  load_11khz_mono_8_bit:
  2904                                  	; 18/11/2023
  2905 000017A9 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2906                                  					; last of the file?
  2907 000017B0 7402                    	jz	short lff11m_0		; no
  2908 000017B2 F9                      	stc
  2909 000017B3 C3                      	retn
  2910                                  
  2911                                  lff11m_0:
  2912 000017B4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2913                                          ;mov	edx, [loadsize]
  2914                                  
  2915                                  	; esi = buffer address
  2916                                  	;; edx = buffer size
  2917                                  
  2918                                  	; load file into memory
  2919                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000017B9 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000017BF 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000017C1 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000017C7 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000017CC CD40                <1>  int 40h
  2920 000017CE 7247                    	jc	short lff11m_7 ; error !
  2921                                  
  2922 000017D0 BF[00300000]            	mov	edi, audio_buffer
  2923                                  	
  2924 000017D5 21C0                    	and	eax, eax
  2925 000017D7 7505                    	jnz	short lff11m_8
  2926 000017D9 E9ABF3FFFF              	jmp	lff11_eof
  2927                                  
  2928                                  lff11m_8:
  2929 000017DE 89C1                    	mov	ecx, eax		; byte count
  2930                                  lff11m_9:
  2931 000017E0 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  2932                                  lff11m_1:
  2933                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2934 000017E5 AC                      	lodsb
  2935 000017E6 B280                    	mov	dl, 80h
  2936 000017E8 49                      	dec	ecx
  2937 000017E9 7402                    	jz	short lff11m_2_1
  2938 000017EB 8A16                    	mov	dl, [esi]
  2939                                  lff11m_2_1:	
  2940                                  	; al = [previous_val]
  2941                                  	; dl = [next_val]
  2942 000017ED E876050000              	call	interpolating_5_8bit_mono
  2943 000017F2 E328                    	jecxz	lff11m_3
  2944                                  lff11m_2_2:
  2945 000017F4 AC                      	lodsb
  2946 000017F5 B280                    	mov	dl, 80h
  2947 000017F7 49                      	dec	ecx
  2948 000017F8 7402                    	jz	short lff11m_2_3
  2949 000017FA 8A16                    	mov	dl, [esi]
  2950                                  lff11m_2_3:
  2951 000017FC E873060000               	call	interpolating_4_8bit_mono
  2952 00001801 E319                    	jecxz	lff11m_3
  2953                                  
  2954 00001803 4D                      	dec	ebp
  2955 00001804 74DA                    	jz	short lff11m_9
  2956                                  
  2957 00001806 AC                      	lodsb
  2958 00001807 B280                    	mov	dl, 80h
  2959 00001809 49                      	dec	ecx
  2960 0000180A 7402                    	jz	short lff11m_2_4
  2961 0000180C 8A16                    	mov	dl, [esi]
  2962                                  lff11m_2_4:
  2963 0000180E E861060000              	call	interpolating_4_8bit_mono
  2964 00001813 E307                    	jecxz	lff11m_3
  2965 00001815 EBCE                    	jmp	short lff11m_1
  2966                                  
  2967                                  lff11m_7:
  2968                                  lff11s_7:
  2969 00001817 E976F3FFFF              	jmp	lff11_5  ; error
  2970                                  
  2971                                  lff11m_3:
  2972                                  lff11s_3:
  2973 0000181C E955F3FFFF              	jmp	lff11_3	; padfill
  2974                                  		; (put zeros in the remain words of the buffer)
  2975                                  
  2976                                  load_11khz_stereo_8_bit:
  2977                                  	; 18/11/2023
  2978 00001821 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2979                                  					; last of the file?
  2980 00001828 7402                    	jz	short lff11s_0		; no
  2981 0000182A F9                      	stc
  2982 0000182B C3                      	retn
  2983                                  
  2984                                  lff11s_0:
  2985 0000182C BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2986                                          ;mov	edx, [loadsize]
  2987                                  
  2988                                  	; esi = buffer address
  2989                                  	;; edx = buffer size
  2990                                  
  2991                                  	; load file into memory
  2992                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001831 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001837 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001839 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 0000183F B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001844 CD40                <1>  int 40h
  2993 00001846 72CF                    	jc	short lff11s_7 ; error !
  2994                                  
  2995 00001848 BF[00300000]            	mov	edi, audio_buffer
  2996                                  	
  2997 0000184D D1E8                    	shr	eax, 1
  2998 0000184F 7505                    	jnz	short lff11s_8
  2999 00001851 E933F3FFFF              	jmp	lff11_eof
  3000                                  
  3001                                  lff11s_8:
  3002 00001856 89C1                    	mov	ecx, eax	; word count
  3003                                  lff11s_9:
  3004 00001858 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3005                                  lff11s_1:
  3006                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3007 0000185D 66AD                    	lodsw
  3008 0000185F 66BA8080                	mov	dx, 8080h
  3009 00001863 49                      	dec	ecx
  3010 00001864 7403                    	jz	short lff11s_2_1 
  3011 00001866 668B16                  	mov	dx, [esi]
  3012                                  lff11s_2_1:	
  3013                                  	; al = [previous_val_l]
  3014                                  	; ah = [previous_val_r]
  3015                                  	; dl = [next_val_l]
  3016                                  	; dh = [next_val_r]	
  3017 00001869 E859050000              	call	interpolating_5_8bit_stereo
  3018 0000186E E3AC                    	jecxz	lff11s_3
  3019                                  lff11s_2_2:
  3020 00001870 66AD                    	lodsw
  3021 00001872 66BA8080                	mov	dx, 8080h
  3022 00001876 49                      	dec	ecx
  3023 00001877 7403                    	jz	short lff11s_2_3
  3024 00001879 668B16                  	mov	dx, [esi]
  3025                                  lff11s_2_3:
  3026 0000187C E832060000               	call	interpolating_4_8bit_stereo
  3027 00001881 E399                    	jecxz	lff11s_3
  3028                                  	
  3029 00001883 4D                      	dec	ebp
  3030 00001884 74D2                    	jz	short lff11s_9
  3031                                  
  3032 00001886 66AD                    	lodsw
  3033 00001888 66BA8080                	mov	dx, 8080h
  3034 0000188C 49                      	dec	ecx
  3035 0000188D 7403                    	jz	short lff11s_2_4
  3036 0000188F 668B16                  	mov	dx, [esi]
  3037                                  lff11s_2_4:
  3038 00001892 E81C060000              	call	interpolating_4_8bit_stereo
  3039 00001897 E383                    	jecxz	lff11s_3
  3040 00001899 EBC2                    	jmp	short lff11s_1
  3041                                  
  3042                                  load_11khz_mono_16_bit:
  3043                                  	; 18/11/2023
  3044 0000189B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3045                                  					; last of the file?
  3046 000018A2 7402                    	jz	short lff11m2_0		; no
  3047 000018A4 F9                      	stc
  3048 000018A5 C3                      	retn
  3049                                  
  3050                                  lff11m2_0:
  3051 000018A6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3052                                          ;mov	edx, [loadsize]
  3053                                  
  3054                                  	; esi = buffer address
  3055                                  	;; edx = buffer size
  3056                                  
  3057                                  	; load file into memory
  3058                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000018AB 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000018B1 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000018B3 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000018B9 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000018BE CD40                <1>  int 40h
  3059 000018C0 724D                    	jc	short lff11m2_7 ; error !
  3060                                  
  3061 000018C2 BF[00300000]            	mov	edi, audio_buffer
  3062                                  	
  3063 000018C7 D1E8                    	shr	eax, 1
  3064 000018C9 7505                    	jnz	short lff11m2_8
  3065 000018CB E9B9F2FFFF              	jmp	lff11_eof
  3066                                  
  3067                                  lff11m2_8:
  3068 000018D0 89C1                    	mov	ecx, eax	; word count
  3069                                  lff11m2_9:
  3070 000018D2 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3071                                  lff11m2_1:
  3072                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3073 000018D7 66AD                    	lodsw
  3074 000018D9 31D2                    	xor	edx, edx
  3075 000018DB 49                      	dec	ecx
  3076 000018DC 7403                    	jz	short lff11m2_2_1
  3077 000018DE 668B16                  	mov	dx, [esi]
  3078                                  lff11m2_2_1:	
  3079                                  	; ax = [previous_val]
  3080                                  	; dx = [next_val]
  3081 000018E1 E83A060000              	call	interpolating_5_16bit_mono
  3082 000018E6 E362                    	jecxz	lff11m2_3
  3083                                  lff11m2_2_2:
  3084 000018E8 66AD                    	lodsw
  3085 000018EA 31D2                    	xor	edx, edx
  3086 000018EC 49                      	dec	ecx
  3087 000018ED 7403                    	jz	short lff11m2_2_3
  3088 000018EF 668B16                  	mov	dx, [esi]
  3089                                  lff11m2_2_3:
  3090 000018F2 E853070000               	call	interpolating_4_16bit_mono
  3091 000018F7 E351                    	jecxz	lff11m2_3
  3092                                  
  3093 000018F9 4D                      	dec	ebp
  3094 000018FA 74D6                    	jz	short lff11m2_9
  3095                                  
  3096 000018FC 66AD                    	lodsw
  3097 000018FE 31D2                    	xor	edx, edx
  3098 00001900 49                      	dec	ecx
  3099 00001901 7403                    	jz	short lff11m2_2_4
  3100 00001903 668B16                  	mov	dx, [esi]
  3101                                  lff11m2_2_4:
  3102 00001906 E83F070000               	call	interpolating_4_16bit_mono
  3103 0000190B E33D                    	jecxz	lff11m2_3
  3104 0000190D EBC8                    	jmp	short lff11m2_1
  3105                                  
  3106                                  lff11m2_7:
  3107                                  lff11s2_7:
  3108 0000190F E97EF2FFFF              	jmp	lff11_5  ; error
  3109                                  
  3110                                  load_11khz_stereo_16_bit:
  3111                                  	; 18/11/2023
  3112 00001914 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3113                                  					; last of the file?
  3114 0000191B 7402                    	jz	short lff11s2_0		; no
  3115 0000191D F9                      	stc
  3116 0000191E C3                      	retn
  3117                                  
  3118                                  lff11s2_0:
  3119 0000191F BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3120                                          ;mov	edx, [loadsize]
  3121                                  
  3122                                  	; esi = buffer address
  3123                                  	;; edx = buffer size
  3124                                  
  3125                                  	; load file into memory
  3126                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001924 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 0000192A 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 0000192C 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001932 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001937 CD40                <1>  int 40h
  3127 00001939 72D4                    	jc	short lff11s2_7 ; error !
  3128                                  
  3129 0000193B BF[00300000]            	mov	edi, audio_buffer
  3130                                  	
  3131 00001940 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3132 00001943 750A                    	jnz	short lff11s2_8
  3133 00001945 E93FF2FFFF              	jmp	lff11_eof
  3134                                  
  3135                                  lff11m2_3:
  3136                                  lff11s2_3:
  3137 0000194A E927F2FFFF              	jmp	lff11_3	; padfill
  3138                                  		; (put zeros in the remain words of the buffer)
  3139                                  
  3140                                  lff11s2_8:
  3141 0000194F 89C1                    	mov	ecx, eax	; dword count
  3142                                  lff11s2_9:
  3143 00001951 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3144                                  lff11s2_1:
  3145                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3146 00001956 66AD                    	lodsw
  3147 00001958 89C3                    	mov	ebx, eax
  3148 0000195A 66AD                    	lodsw
  3149 0000195C 8B16                    	mov	edx, [esi]
  3150 0000195E 8915[04210000]          	mov	[next_val_l], edx
  3151                                  	; 26/11/2023
  3152 00001964 C1EA10                  	shr	edx, 16
  3153                                  	;mov	[next_val_r], dx
  3154 00001967 49                      	dec	ecx
  3155 00001968 7509                    	jnz	short lff11s2_2_1
  3156 0000196A 31D2                    	xor	edx, edx ; 0
  3157 0000196C 668915[04210000]        	mov	[next_val_l], dx
  3158                                  	;mov	[next_val_r], dx
  3159                                  lff11s2_2_1:
  3160                                  	; bx = [previous_val_l]
  3161                                  	; ax = [previous_val_r]
  3162                                  	; [next_val_l]
  3163                                  	; dx = [next_val_r]
  3164 00001973 E803060000              	call	interpolating_5_16bit_stereo
  3165 00001978 E3D0                    	jecxz	lff11s2_3
  3166                                  lff11s2_2_2:
  3167 0000197A 66AD                    	lodsw
  3168 0000197C 89C3                    	mov	ebx, eax
  3169 0000197E 66AD                    	lodsw
  3170 00001980 8B16                    	mov	edx, [esi]
  3171 00001982 668915[04210000]        	mov	[next_val_l], dx
  3172                                  	; 26/11/2023
  3173 00001989 C1EA10                  	shr	edx, 16
  3174                                  	;mov	[next_val_r], dx
  3175 0000198C 49                      	dec	ecx
  3176 0000198D 7509                    	jnz	short lff11s2_2_3
  3177 0000198F 31D2                    	xor	edx, edx ; 0
  3178 00001991 668915[04210000]        	mov	[next_val_l], dx
  3179                                  	;mov	[next_val_r], dx
  3180                                  lff11s2_2_3:
  3181 00001998 E8E6060000               	call	interpolating_4_16bit_stereo
  3182 0000199D E3AB                    	jecxz	lff11s2_3
  3183                                  	
  3184 0000199F 4D                      	dec	ebp
  3185 000019A0 74AF                    	jz	short lff11s2_9
  3186                                  
  3187 000019A2 66AD                    	lodsw
  3188 000019A4 89C3                    	mov	ebx, eax
  3189 000019A6 66AD                    	lodsw
  3190 000019A8 8B16                    	mov	edx, [esi]
  3191 000019AA 668915[04210000]        	mov	[next_val_l], dx
  3192                                  	; 26/11/2023
  3193 000019B1 C1EA10                  	shr	edx, 16
  3194                                  	;mov	[next_val_r], dx
  3195 000019B4 49                      	dec	ecx
  3196 000019B5 7509                    	jnz	short lff11s2_2_4
  3197 000019B7 31D2                    	xor	edx, edx ; 0
  3198 000019B9 668915[04210000]        	mov	[next_val_l], dx
  3199                                  	;mov	[next_val_r], dx
  3200                                  lff11s2_2_4:
  3201 000019C0 E8BE060000               	call	interpolating_4_16bit_stereo
  3202 000019C5 E383                    	jecxz	lff11s2_3
  3203 000019C7 EB8D                    	jmp	short lff11s2_1
  3204                                  
  3205                                  ; .....................
  3206                                  
  3207                                  load_44khz_mono_8_bit:
  3208                                  	; 18/11/2023
  3209 000019C9 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3210                                  					; last of the file?
  3211 000019D0 7402                    	jz	short lff44m_0		; no
  3212 000019D2 F9                      	stc
  3213 000019D3 C3                      	retn
  3214                                  
  3215                                  lff44m_0:
  3216 000019D4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3217                                          ;mov	edx, [loadsize]
  3218                                  
  3219                                  	; esi = buffer address
  3220                                  	;; edx = buffer size
  3221                                  
  3222                                  	; load file into memory
  3223                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 000019D9 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 000019DF 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 000019E1 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 000019E7 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 000019EC CD40                <1>  int 40h
  3224 000019EE 7250                    	jc	short lff44m_7 ; error !
  3225                                  
  3226 000019F0 BF[00300000]            	mov	edi, audio_buffer
  3227                                  	
  3228 000019F5 21C0                    	and	eax, eax
  3229 000019F7 7505                    	jnz	short lff44m_8
  3230 000019F9 E98BF1FFFF              	jmp	lff44_eof
  3231                                  
  3232                                  lff44m_8:
  3233 000019FE 89C1                    	mov	ecx, eax	; byte count
  3234                                  lff44m_9:
  3235 00001A00 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3236 00001A05 C605[08210000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3237                                  lff44m_1:
  3238                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3239                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3240 00001A0C AC                      	lodsb
  3241 00001A0D B280                    	mov	dl, 80h
  3242 00001A0F 49                      	dec	ecx
  3243 00001A10 7402                    	jz	short lff44m_2_1
  3244 00001A12 8A16                    	mov	dl, [esi]
  3245                                  lff44m_2_1:	
  3246                                  	; al = [previous_val]
  3247                                  	; dl = [next_val]
  3248 00001A14 E825020000              	call	interpolating_2_8bit_mono
  3249 00001A19 E320                    	jecxz	lff44m_3
  3250                                  lff44m_2_2:
  3251 00001A1B AC                      	lodsb
  3252 00001A1C 2C80                    	sub	al, 80h
  3253 00001A1E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3254 00001A22 66AB                    	stosw		; (L)
  3255 00001A24 66AB                    	stosw		; (R)	
  3256                                  
  3257 00001A26 49                      	dec	ecx
  3258 00001A27 7412                    	jz	short lff44m_3	
  3259 00001A29 4D                      	dec	ebp
  3260 00001A2A 75EF                    	jnz	short lff44m_2_2
  3261                                  	
  3262 00001A2C FE0D[08210000]          	dec	byte [faz]
  3263 00001A32 74CC                    	jz	short lff44m_9 
  3264 00001A34 BD0B000000              	mov	ebp, 11
  3265 00001A39 EBD1                    	jmp	short lff44m_1
  3266                                  
  3267                                  lff44m_3:
  3268                                  lff44s_3:
  3269 00001A3B E936F1FFFF              	jmp	lff44_3	; padfill
  3270                                  		; (put zeros in the remain words of the buffer)
  3271                                  lff44m_7:
  3272                                  lff44s_7:
  3273 00001A40 E94DF1FFFF              	jmp	lff44_5  ; error
  3274                                  
  3275                                  load_44khz_stereo_8_bit:
  3276                                  	; 16/11/2023
  3277 00001A45 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3278                                  					; last of the file?
  3279 00001A4C 7402                    	jz	short lff44s_0		; no
  3280 00001A4E F9                      	stc
  3281 00001A4F C3                      	retn
  3282                                  
  3283                                  lff44s_0:
  3284 00001A50 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3285                                          ;mov	edx, [loadsize]
  3286                                  
  3287                                  	; esi = buffer address
  3288                                  	;; edx = buffer size
  3289                                  
  3290                                  	; load file into memory
  3291                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001A55 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001A5B 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001A5D 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001A63 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001A68 CD40                <1>  int 40h
  3292 00001A6A 72D4                    	jc	short lff44s_7 ; error !
  3293                                  
  3294 00001A6C BF[00300000]            	mov	edi, audio_buffer
  3295                                  	
  3296 00001A71 D1E8                    	shr	eax, 1
  3297 00001A73 7505                    	jnz	short lff44s_8
  3298 00001A75 E90FF1FFFF              	jmp	lff44_eof
  3299                                  
  3300                                  lff44s_8:
  3301 00001A7A 89C1                    	mov	ecx, eax	; word count
  3302                                  lff44s_9:
  3303 00001A7C BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3304 00001A81 C605[08210000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3305                                  lff44s_1:
  3306                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3307                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3308 00001A88 66AD                    	lodsw
  3309 00001A8A 66BA8080                	mov	dx, 8080h
  3310 00001A8E 49                      	dec	ecx
  3311 00001A8F 7403                    	jz	short lff44s_2_1 
  3312 00001A91 668B16                  	mov	dx, [esi]
  3313                                  lff44s_2_1:	
  3314                                  	; al = [previous_val_l]
  3315                                  	; ah = [previous_val_r]
  3316                                  	; dl = [next_val_l]
  3317                                  	; dh = [next_val_r]	
  3318 00001A94 E8C2010000              	call	interpolating_2_8bit_stereo
  3319 00001A99 E3A0                    	jecxz	lff44s_3
  3320                                  lff44s_2_2:
  3321 00001A9B AC                      	lodsb
  3322 00001A9C 2C80                    	sub	al, 80h
  3323 00001A9E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3324 00001AA2 66AB                    	stosw		; (L)
  3325 00001AA4 AC                      	lodsb
  3326 00001AA5 2C80                    	sub	al, 80h
  3327 00001AA7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3328 00001AAB 66AB                    	stosw		; (R)
  3329                                  
  3330 00001AAD 49                      	dec	ecx
  3331 00001AAE 748B                    	jz	short lff44s_3	
  3332 00001AB0 4D                      	dec	ebp
  3333 00001AB1 75E8                    	jnz	short lff44s_2_2
  3334                                  	
  3335 00001AB3 FE0D[08210000]          	dec	byte [faz]
  3336 00001AB9 74C1                    	jz	short lff44s_9 
  3337 00001ABB BD0B000000              	mov	ebp, 11
  3338 00001AC0 EBC6                    	jmp	short lff44s_1
  3339                                  
  3340                                  load_44khz_mono_16_bit:
  3341                                  	; 18/11/2023
  3342 00001AC2 F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3343                                  					; last of the file?
  3344 00001AC9 7402                    	jz	short lff44m2_0		; no
  3345 00001ACB F9                      	stc
  3346 00001ACC C3                      	retn
  3347                                  
  3348                                  lff44m2_0:
  3349 00001ACD BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3350                                          ;mov	edx, [loadsize]
  3351                                  
  3352                                  	; esi = buffer address
  3353                                  	;; edx = buffer size
  3354                                  
  3355                                  	; load file into memory
  3356                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001AD2 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001AD8 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001ADA 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001AE0 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001AE5 CD40                <1>  int 40h
  3357 00001AE7 724D                    	jc	short lff44m2_7 ; error !
  3358                                  
  3359 00001AE9 BF[00300000]            	mov	edi, audio_buffer
  3360                                  	
  3361 00001AEE D1E8                    	shr	eax, 1
  3362 00001AF0 7505                    	jnz	short lff44m2_8
  3363 00001AF2 E992F0FFFF              	jmp	lff44_eof
  3364                                  
  3365                                  lff44m2_8:
  3366 00001AF7 89C1                    	mov	ecx, eax	; word count
  3367                                  lff44m2_9:
  3368 00001AF9 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3369 00001AFE C605[08210000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3370                                  lff44m2_1:
  3371                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3372                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3373 00001B05 66AD                    	lodsw
  3374 00001B07 31D2                    	xor	edx, edx
  3375 00001B09 49                      	dec	ecx
  3376 00001B0A 7403                    	jz	short lff44m2_2_1
  3377 00001B0C 668B16                  	mov	dx, [esi]
  3378                                  lff44m2_2_1:	
  3379                                  	; ax = [previous_val]
  3380                                  	; dx = [next_val]
  3381 00001B0F E80B020000              	call	interpolating_2_16bit_mono
  3382 00001B14 E31B                    	jecxz	lff44m2_3
  3383                                  lff44m2_2_2:
  3384 00001B16 66AD                    	lodsw
  3385 00001B18 66AB                    	stosw		; (L)eft Channel
  3386 00001B1A 66AB                    	stosw		; (R)ight Channel
  3387                                  
  3388 00001B1C 49                      	dec	ecx
  3389 00001B1D 7412                    	jz	short lff44m2_3	
  3390 00001B1F 4D                      	dec	ebp
  3391 00001B20 75F4                    	jnz	short lff44m2_2_2
  3392                                  	
  3393 00001B22 FE0D[08210000]          	dec	byte [faz]
  3394 00001B28 74CF                    	jz	short lff44m2_9 
  3395 00001B2A BD0B000000              	mov	ebp, 11
  3396 00001B2F EBD4                    	jmp	short lff44m2_1
  3397                                  
  3398                                  lff44m2_3:
  3399                                  lff44s2_3:
  3400 00001B31 E940F0FFFF              	jmp	lff44_3	; padfill
  3401                                  		; (put zeros in the remain words of the buffer)
  3402                                  lff44m2_7:
  3403                                  lff44s2_7:
  3404 00001B36 E957F0FFFF              	jmp	lff44_5  ; error
  3405                                  
  3406                                  load_44khz_stereo_16_bit:
  3407                                  	; 18/11/2023
  3408 00001B3B F605[18240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3409                                  					; last of the file?
  3410 00001B42 7402                    	jz	short lff44s2_0		; no
  3411 00001B44 F9                      	stc
  3412 00001B45 C3                      	retn
  3413                                  
  3414                                  lff44s2_0:
  3415 00001B46 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3416                                          ;mov	edx, [loadsize]
  3417                                  
  3418                                  	; esi = buffer address
  3419                                  	;; edx = buffer size
  3420                                  
  3421                                  	; load file into memory
  3422                                  	sys 	_read, [FileHandle], esi, [loadsize]
    72                              <1> 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1>  %if %0 >= 2
    77 00001B4B 8B1D[09210000]      <1>  mov ebx, %2
    78                              <1>  %if %0 >= 3
    79 00001B51 89F1                <1>  mov ecx, %3
    80                              <1>  %if %0 = 4
    81 00001B53 8B15[D6030000]      <1>  mov edx, %4
    82                              <1>  %endif
    83                              <1>  %endif
    84                              <1>  %endif
    85 00001B59 B803000000          <1>  mov eax, %1
    86                              <1> 
    87 00001B5E CD40                <1>  int 40h
  3423 00001B60 72D4                    	jc	short lff44s2_7 ; error !
  3424                                  
  3425 00001B62 BF[00300000]            	mov	edi, audio_buffer
  3426                                  	
  3427 00001B67 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3428 00001B6A 7505                    	jnz	short lff44s2_8
  3429 00001B6C E918F0FFFF              	jmp	lff44_eof
  3430                                  
  3431                                  lff44s2_8:
  3432 00001B71 89C1                    	mov	ecx, eax	; dword count
  3433                                  lff44s2_9:
  3434 00001B73 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3435 00001B78 C605[08210000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3436                                  lff44s2_1:
  3437                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3438                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3439 00001B7F 66AD                    	lodsw
  3440 00001B81 89C3                    	mov	ebx, eax
  3441 00001B83 66AD                    	lodsw
  3442                                  	;mov	dx, [esi]
  3443                                  	;mov	[next_val_l], dx
  3444                                  	;mov	dx, [esi+2]
  3445                                  	; 26/11/2023
  3446 00001B85 8B16                    	mov	edx, [esi]
  3447 00001B87 668915[04210000]        	mov	[next_val_l], dx
  3448 00001B8E C1EA10                  	shr	edx, 16
  3449 00001B91 49                      	dec	ecx
  3450 00001B92 7509                    	jnz	short lff44s2_2_1
  3451 00001B94 31D2                    	xor	edx, edx ; 0
  3452 00001B96 668915[04210000]        	mov	[next_val_l], dx
  3453                                  lff44s2_2_1:
  3454                                  	; bx = [previous_val_l]
  3455                                  	; ax = [previous_val_r]
  3456                                  	; [next_val_l]
  3457                                  	; dx = [next_val_r]
  3458 00001B9D E895010000              	call	interpolating_2_16bit_stereo
  3459 00001BA2 E38D                    	jecxz	lff44s2_3
  3460                                  lff44s2_2_2:
  3461                                  	;movsw		; (L)eft Channel
  3462                                  	;movsw		; (R)ight Channel
  3463 00001BA4 A5                      	movsd
  3464                                  
  3465 00001BA5 49                      	dec	ecx
  3466 00001BA6 7489                    	jz	short lff44s2_3	
  3467 00001BA8 4D                      	dec	ebp
  3468 00001BA9 75F9                    	jnz	short lff44s2_2_2
  3469                                  	
  3470 00001BAB FE0D[08210000]          	dec	byte [faz]
  3471 00001BB1 74C0                    	jz	short lff44s2_9 
  3472 00001BB3 BD0B000000              	mov	ebp, 11
  3473 00001BB8 EBC5                    	jmp	short lff44s2_1
  3474                                  
  3475                                  ; .....................
  3476                                  
  3477                                  interpolating_3_8bit_mono:
  3478                                  	; 16/11/2023
  3479                                  	; al = [previous_val]
  3480                                  	; dl = [next_val]
  3481                                  	; original-interpolated-interpolated
  3482 00001BBA 88C3                    	mov	bl, al
  3483 00001BBC 2C80                    	sub	al, 80h
  3484 00001BBE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3485 00001BC2 66AB                    	stosw		; original sample (L)
  3486 00001BC4 66AB                    	stosw		; original sample (R)
  3487 00001BC6 88D8                    	mov	al, bl
  3488 00001BC8 00D0                    	add	al, dl	
  3489 00001BCA D0D8                    	rcr	al, 1
  3490 00001BCC 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3491 00001BCE 00D8                    	add	al, bl
  3492 00001BD0 D0D8                    	rcr	al, 1
  3493 00001BD2 2C80                    	sub	al, 80h
  3494 00001BD4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3495 00001BD8 66AB                    	stosw		; interpolated sample 1 (L)
  3496 00001BDA 66AB                    	stosw		; interpolated sample 1 (R)
  3497 00001BDC 88F8                    	mov	al, bh
  3498 00001BDE 00D0                    	add	al, dl	; [next_val]
  3499 00001BE0 D0D8                    	rcr	al, 1
  3500 00001BE2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3501 00001BE6 66AB                    	stosw		; interpolated sample 2 (L)
  3502 00001BE8 66AB                    	stosw		; interpolated sample 2 (R)
  3503 00001BEA C3                      	retn
  3504                                  
  3505                                  interpolating_3_8bit_stereo:
  3506                                  	; 16/11/2023
  3507                                  	; al = [previous_val_l]
  3508                                  	; ah = [previous_val_r]
  3509                                  	; dl = [next_val_l]
  3510                                  	; dh = [next_val_r]	
  3511                                  	; original-interpolated-interpolated
  3512 00001BEB 89C3                    	mov	ebx, eax
  3513 00001BED 2C80                    	sub	al, 80h
  3514 00001BEF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3515 00001BF3 66AB                    	stosw		; original sample (L)
  3516 00001BF5 88F8                    	mov	al, bh
  3517 00001BF7 2C80                    	sub	al, 80h
  3518 00001BF9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3519 00001BFD 66AB                    	stosw		; original sample (R)
  3520 00001BFF 88D8                    	mov	al, bl
  3521 00001C01 00D0                    	add	al, dl	; [next_val_l]	
  3522 00001C03 D0D8                    	rcr	al, 1
  3523 00001C05 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3524 00001C06 00D8                    	add	al, bl	; [previous_val_l]
  3525 00001C08 D0D8                    	rcr	al, 1
  3526 00001C0A 2C80                    	sub	al, 80h
  3527 00001C0C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3528 00001C10 66AB                    	stosw		; interpolated sample 1 (L)
  3529 00001C12 88F8                    	mov	al, bh
  3530 00001C14 00F0                    	add	al, dh	; [next_val_r]
  3531 00001C16 D0D8                    	rcr	al, 1
  3532 00001C18 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3533 00001C19 00F8                    	add	al, bh	; [previous_val_r]
  3534 00001C1B D0D8                    	rcr	al, 1
  3535 00001C1D 2C80                    	sub	al, 80h
  3536 00001C1F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3537 00001C23 66AB                    	stosw		; interpolated sample 1 (R)
  3538 00001C25 5B                      	pop	ebx ; **
  3539 00001C26 58                      	pop	eax ; *
  3540 00001C27 00D0                    	add	al, dl	; [next_val_l]
  3541 00001C29 D0D8                    	rcr	al, 1
  3542 00001C2B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3543 00001C2F 66AB                    	stosw		; interpolated sample 2 (L)
  3544 00001C31 88D8                    	mov	al, bl
  3545 00001C33 00F0                    	add	al, dh	; [next_val_r]
  3546 00001C35 D0D8                    	rcr	al, 1
  3547 00001C37 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3548 00001C3B 66AB                    	stosw		; interpolated sample 2 (R)
  3549 00001C3D C3                      	retn
  3550                                  
  3551                                  interpolating_2_8bit_mono:
  3552                                  	; 16/11/2023
  3553                                  	; al = [previous_val]
  3554                                  	; dl = [next_val]
  3555                                  	; original-interpolated
  3556 00001C3E 88C3                    	mov	bl, al
  3557 00001C40 2C80                    	sub	al, 80h
  3558 00001C42 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3559 00001C46 66AB                    	stosw		; original sample (L)
  3560 00001C48 66AB                    	stosw		; original sample (R)
  3561 00001C4A 88D8                    	mov	al, bl
  3562 00001C4C 00D0                    	add	al, dl	
  3563 00001C4E D0D8                    	rcr	al, 1
  3564 00001C50 2C80                    	sub	al, 80h
  3565 00001C52 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3566 00001C56 66AB                    	stosw		; interpolated sample (L)
  3567 00001C58 66AB                    	stosw		; interpolated sample (R)
  3568 00001C5A C3                      	retn
  3569                                  
  3570                                  interpolating_2_8bit_stereo:
  3571                                  	; 16/11/2023
  3572                                  	; al = [previous_val_l]
  3573                                  	; ah = [previous_val_r]
  3574                                  	; dl = [next_val_l]
  3575                                  	; dh = [next_val_r]	
  3576                                  	; original-interpolated
  3577 00001C5B 89C3                    	mov	ebx, eax
  3578 00001C5D 2C80                    	sub	al, 80h
  3579 00001C5F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3580 00001C63 66AB                    	stosw		; original sample (L)
  3581 00001C65 88F8                    	mov	al, bh
  3582 00001C67 2C80                    	sub	al, 80h
  3583 00001C69 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3584 00001C6D 66AB                    	stosw		; original sample (R)
  3585 00001C6F 88D8                    	mov	al, bl	; [previous_val_l]
  3586 00001C71 00D0                    	add	al, dl	; [next_val_l]	
  3587 00001C73 D0D8                    	rcr	al, 1
  3588 00001C75 2C80                    	sub	al, 80h
  3589 00001C77 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3590 00001C7B 66AB                    	stosw		; interpolated sample (L)
  3591 00001C7D 88F8                    	mov	al, bh
  3592 00001C7F 00F0                    	add	al, dh	; [next_val_r]
  3593 00001C81 D0D8                    	rcr	al, 1
  3594 00001C83 2C80                    	sub	al, 80h
  3595 00001C85 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3596 00001C89 66AB                    	stosw		; interpolated sample (R)
  3597 00001C8B C3                      	retn
  3598                                  
  3599                                  interpolating_3_16bit_mono:
  3600                                  	; 16/11/2023
  3601                                  	; ax = [previous_val]
  3602                                  	; dx = [next_val]
  3603                                  	; original-interpolated-interpolated
  3604                                  
  3605 00001C8C 66AB                    	stosw		; original sample (L)
  3606 00001C8E 66AB                    	stosw		; original sample (R)
  3607 00001C90 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3608 00001C93 50                      	push	eax ; *	; [previous_val]
  3609 00001C94 80C680                  	add	dh, 80h
  3610 00001C97 6601D0                  	add	ax, dx
  3611 00001C9A 66D1D8                  	rcr	ax, 1
  3612 00001C9D 5B                      	pop	ebx ; *		
  3613 00001C9E 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3614 00001C9F 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3615 00001CA2 66D1D8                  	rcr	ax, 1
  3616 00001CA5 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3617 00001CA8 66AB                    	stosw 		; interpolated sample 1 (L)
  3618 00001CAA 66AB                    	stosw		; interpolated sample 1 (R)
  3619 00001CAC 89D8                    	mov	eax, ebx
  3620 00001CAE 6601D0                  	add	ax, dx	 ;interpolated middle + [next_val]
  3621 00001CB1 66D1D8                  	rcr	ax, 1
  3622 00001CB4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3623 00001CB7 66AB                    	stosw		; interpolated sample 2 (L)
  3624 00001CB9 66AB                    	stosw		; interpolated sample 2 (R)
  3625 00001CBB C3                      	retn
  3626                                  
  3627                                  interpolating_3_16bit_stereo:
  3628                                  	; 16/11/2023
  3629                                  	; bx = [previous_val_l]
  3630                                  	; ax = [previous_val_r]
  3631                                  	; [next_val_l]
  3632                                  	; dx = [next_val_r]
  3633                                  	; original-interpolated-interpolated
  3634                                  
  3635 00001CBC 93                      	xchg	eax, ebx
  3636 00001CBD 66AB                    	stosw		; original sample (L)
  3637 00001CBF 93                      	xchg	eax, ebx
  3638 00001CC0 66AB                    	stosw		; original sample (R)
  3639 00001CC2 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3640 00001CC5 50                      	push	eax ; *	; [previous_val_r]
  3641 00001CC6 80C780                  	add	bh, 80h
  3642 00001CC9 8005[05210000]80        	add	byte [next_val_l+1], 80h
  3643 00001CD0 66A1[04210000]          	mov	ax, [next_val_l]
  3644 00001CD6 6601D8                  	add	ax, bx	; [previous_val_l]
  3645 00001CD9 66D1D8                  	rcr	ax, 1
  3646 00001CDC 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  3647 00001CDD 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3648 00001CE0 66D1D8                  	rcr	ax, 1
  3649 00001CE3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3650 00001CE6 66AB                    	stosw 		; interpolated sample 1 (L)
  3651 00001CE8 58                      	pop	eax  ; *
  3652 00001CE9 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  3653 00001CEC 52                      	push	edx  ; * ; [next_val_r]
  3654 00001CED 92                      	xchg	eax, edx
  3655 00001CEE 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  3656 00001CF1 66D1D8                  	rcr	ax, 1	; / 2
  3657 00001CF4 50                      	push	eax ; ** ; interpolated middle (R)
  3658 00001CF5 6601D0                  	add	ax, dx	; + [previous_val_r]
  3659 00001CF8 66D1D8                  	rcr	ax, 1
  3660 00001CFB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3661 00001CFE 66AB                    	stosw 		; interpolated sample 1 (R)
  3662 00001D00 66A1[04210000]          	mov	ax, [next_val_l]
  3663 00001D06 6601D8                  	add	ax, bx	; + interpolated middle (L)
  3664 00001D09 66D1D8                  	rcr	ax, 1
  3665 00001D0C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3666 00001D0F 66AB                    	stosw 		; interpolated sample 2 (L)
  3667 00001D11 58                      	pop	eax ; **
  3668 00001D12 5A                      	pop	edx ; *	
  3669 00001D13 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  3670 00001D16 66D1D8                  	rcr	ax, 1	; / 2
  3671 00001D19 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3672 00001D1C 66AB                    	stosw 		; interpolated sample 2 (L)
  3673 00001D1E C3                      	retn
  3674                                  
  3675                                  interpolating_2_16bit_mono:
  3676                                  	; 16/11/2023
  3677                                  	; ax = [previous_val]
  3678                                  	; dx = [next_val]
  3679                                  	; original-interpolated
  3680                                  
  3681 00001D1F 66AB                    	stosw		; original sample (L)
  3682 00001D21 66AB                    	stosw		; original sample (R)
  3683 00001D23 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3684 00001D26 80C680                  	add	dh, 80h
  3685 00001D29 6601D0                  	add	ax, dx
  3686 00001D2C 66D1D8                  	rcr	ax, 1
  3687 00001D2F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3688 00001D32 66AB                    	stosw		; interpolated sample (L)
  3689 00001D34 66AB                    	stosw		; interpolated sample (R)
  3690 00001D36 C3                      	retn
  3691                                  
  3692                                  interpolating_2_16bit_stereo:
  3693                                  	; 16/11/2023
  3694                                  	; bx = [previous_val_l]
  3695                                  	; ax = [previous_val_r]
  3696                                  	; [next_val_l]
  3697                                  	; dx = [next_val_r]
  3698                                  	; original-interpolated
  3699                                  
  3700 00001D37 93                      	xchg	eax, ebx
  3701 00001D38 66AB                    	stosw		; original sample (L)
  3702 00001D3A 93                      	xchg	eax, ebx
  3703 00001D3B 66AB                    	stosw		; original sample (R)
  3704 00001D3D 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3705 00001D40 80C680                  	add	dh, 80h
  3706 00001D43 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  3707 00001D46 66D1D8                  	rcr	ax, 1	; / 2
  3708 00001D49 50                      	push	eax ; *	; interpolated sample (R)
  3709 00001D4A 66A1[04210000]          	mov	ax, [next_val_l]
  3710 00001D50 80C480                  	add	ah, 80h
  3711 00001D53 80C780                  	add	bh, 80h
  3712 00001D56 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  3713 00001D59 66D1D8                  	rcr	ax, 1	; / 2		
  3714 00001D5C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3715 00001D5F 66AB                    	stosw 		; interpolated sample (L)
  3716 00001D61 58                      	pop	eax ; *	
  3717 00001D62 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3718 00001D65 66AB                    	stosw 		; interpolated sample (R)
  3719 00001D67 C3                      	retn
  3720                                  
  3721                                  interpolating_5_8bit_mono:
  3722                                  	; 17/11/2023
  3723                                  	; al = [previous_val]
  3724                                  	; dl = [next_val]
  3725                                  	; original-interpltd-interpltd-interpltd-interpltd
  3726 00001D68 88C3                    	mov	bl, al
  3727 00001D6A 2C80                    	sub	al, 80h
  3728 00001D6C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3729 00001D70 66AB                    	stosw		; original sample (L)
  3730 00001D72 66AB                    	stosw		; original sample (R)
  3731 00001D74 88D8                    	mov	al, bl
  3732 00001D76 00D0                    	add	al, dl	
  3733 00001D78 D0D8                    	rcr	al, 1
  3734 00001D7A 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3735 00001D7C 00D8                    	add	al, bl  ; [previous_val]
  3736 00001D7E D0D8                    	rcr	al, 1 	
  3737 00001D80 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  3738 00001D82 00D8                    	add	al, bl
  3739 00001D84 D0D8                    	rcr	al, 1
  3740 00001D86 2C80                    	sub	al, 80h
  3741 00001D88 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3742 00001D8C 66AB                    	stosw		; interpolated sample 1 (L)
  3743 00001D8E 66AB                    	stosw		; interpolated sample 1 (R)
  3744 00001D90 88F8                    	mov	al, bh
  3745 00001D92 00F0                    	add	al, dh
  3746 00001D94 D0D8                    	rcr	al, 1
  3747 00001D96 2C80                    	sub	al, 80h
  3748 00001D98 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3749 00001D9C 66AB                    	stosw		; interpolated sample 2 (L)
  3750 00001D9E 66AB                    	stosw		; interpolated sample 2 (R)
  3751 00001DA0 88F8                    	mov	al, bh
  3752 00001DA2 00D0                    	add	al, dl	; [next_val]
  3753 00001DA4 D0D8                    	rcr	al, 1
  3754 00001DA6 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  3755 00001DA8 00F8                    	add	al, bh
  3756 00001DAA D0D8                    	rcr	al, 1
  3757 00001DAC 2C80                    	sub	al, 80h
  3758 00001DAE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3759 00001DB2 66AB                    	stosw		; interpolated sample 3 (L)
  3760 00001DB4 66AB                    	stosw		; interpolated sample 3 (R)
  3761 00001DB6 88F0                    	mov	al, dh
  3762 00001DB8 00D0                    	add	al, dl
  3763 00001DBA D0D8                    	rcr	al, 1
  3764 00001DBC 2C80                    	sub	al, 80h
  3765 00001DBE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3766 00001DC2 66AB                    	stosw		; interpolated sample 4 (L)
  3767 00001DC4 66AB                    	stosw		; interpolated sample 4 (R)
  3768 00001DC6 C3                      	retn
  3769                                  
  3770                                  interpolating_5_8bit_stereo:
  3771                                  	; 17/11/2023
  3772                                  	; al = [previous_val_l]
  3773                                  	; ah = [previous_val_r]
  3774                                  	; dl = [next_val_l]
  3775                                  	; dh = [next_val_r]	
  3776                                  	; original-interpltd-interpltd-interpltd-interpltd
  3777 00001DC7 89C3                    	mov	ebx, eax
  3778 00001DC9 2C80                    	sub	al, 80h
  3779 00001DCB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3780 00001DCF 66AB                    	stosw		; original sample (L)
  3781 00001DD1 88F8                    	mov	al, bh
  3782 00001DD3 2C80                    	sub	al, 80h
  3783 00001DD5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3784 00001DD9 66AB                    	stosw		; original sample (R)
  3785 00001DDB 52                      	push	edx ; *
  3786 00001DDC 88D8                    	mov	al, bl
  3787 00001DDE 00D0                    	add	al, dl	; [next_val_l]
  3788 00001DE0 D0D8                    	rcr	al, 1
  3789 00001DE2 50                      	push	eax ; **	; al = interpolated middle (L) (temporary)
  3790 00001DE3 00D8                    	add	al, bl	; [previous_val_l]
  3791 00001DE5 D0D8                    	rcr	al, 1
  3792 00001DE7 86C3                    	xchg	al, bl	
  3793 00001DE9 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  3794 00001DEB D0D8                    	rcr	al, 1
  3795 00001DED 2C80                    	sub	al, 80h
  3796 00001DEF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3797 00001DF3 66AB                    	stosw		; interpolated sample 1 (L)
  3798 00001DF5 88F8                    	mov	al, bh
  3799 00001DF7 00F0                    	add	al, dh	; [next_val_r]
  3800 00001DF9 D0D8                    	rcr	al, 1
  3801 00001DFB 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  3802 00001DFC 00F8                    	add	al, bh	; [previous_val_r]
  3803 00001DFE D0D8                    	rcr	al, 1
  3804 00001E00 86C7                    	xchg	al, bh	
  3805 00001E02 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  3806 00001E04 D0D8                    	rcr	al, 1
  3807 00001E06 2C80                    	sub	al, 80h
  3808 00001E08 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3809 00001E0C 66AB                    	stosw		; interpolated sample 1 (R)
  3810 00001E0E 5A                      	pop	edx ; ***
  3811 00001E0F 58                      	pop	eax ; **	; al = interpolated middle (L) (temporary)
  3812 00001E10 86C3                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  3813 00001E12 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  3814 00001E14 D0D8                    	rcr	al, 1
  3815 00001E16 2C80                    	sub	al, 80h
  3816 00001E18 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3817 00001E1C 66AB                    	stosw		; interpolated sample 2 (L)	
  3818 00001E1E 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  3819 00001E20 86C7                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  3820 00001E22 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  3821 00001E24 D0D8                    	rcr	al, 1
  3822 00001E26 2C80                    	sub	al, 80h
  3823 00001E28 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3824 00001E2C 66AB                    	stosw		; interpolated sample 2 (R)
  3825 00001E2E 5A                      	pop	edx ; *
  3826 00001E2F 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  3827 00001E31 00D0                    	add	al, dl	; [next_val_l]
  3828 00001E33 D0D8                    	rcr	al, 1
  3829 00001E35 86C3                    	xchg	al, bl	; al = interpolated middle (R) (temporary)	
  3830 00001E37 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp) 
  3831 00001E39 D0D8                    	rcr	al, 1
  3832 00001E3B 2C80                    	sub	al, 80h
  3833 00001E3D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3834 00001E41 66AB                    	stosw		; interpolated sample 3 (L)
  3835 00001E43 88F8                    	mov	al, bh	
  3836 00001E45 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  3837 00001E47 D0D8                    	rcr	al, 1
  3838 00001E49 86C7                    	xchg	al, bh	; al = interpolated middle (R)
  3839 00001E4B 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  3840 00001E4D D0D8                    	rcr	al, 1
  3841 00001E4F 2C80                    	sub	al, 80h
  3842 00001E51 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3843 00001E55 66AB                    	stosw		; interpolated sample 3 (R)
  3844 00001E57 88D8                    	mov	al, bl
  3845 00001E59 00D0                    	add	al, dl	; [next_val_l]
  3846 00001E5B D0D8                    	rcr	al, 1
  3847 00001E5D 2C80                    	sub	al, 80h
  3848 00001E5F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3849 00001E63 66AB                    	stosw		; interpolated sample 4 (L)
  3850 00001E65 88F8                    	mov	al, bh
  3851 00001E67 00F0                    	add	al, dh	; [next_val_r]
  3852 00001E69 D0D8                    	rcr	al, 1
  3853 00001E6B 2C80                    	sub	al, 80h
  3854 00001E6D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3855 00001E71 66AB                    	stosw		; interpolated sample 4 (R)
  3856 00001E73 C3                      	retn
  3857                                  
  3858                                  interpolating_4_8bit_mono:
  3859                                  	; 17/11/2023
  3860                                  	; al = [previous_val]
  3861                                  	; dl = [next_val]
  3862                                  	; original-interpolated-interpolated-interpolated
  3863 00001E74 88C3                    	mov	bl, al
  3864 00001E76 2C80                    	sub	al, 80h
  3865 00001E78 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3866 00001E7C 66AB                    	stosw		; original sample (L)
  3867 00001E7E 66AB                    	stosw		; original sample (R)
  3868 00001E80 88D8                    	mov	al, bl
  3869 00001E82 00D0                    	add	al, dl	
  3870 00001E84 D0D8                    	rcr	al, 1
  3871 00001E86 86C3                    	xchg	al, bl  ; al = [previous_val]
  3872 00001E88 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  3873 00001E8A D0D8                    	rcr	al, 1 	
  3874 00001E8C 2C80                    	sub	al, 80h
  3875 00001E8E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3876 00001E92 66AB                    	stosw		; interpolated sample 1 (L)
  3877 00001E94 66AB                    	stosw		; interpolated sample 1 (R)
  3878 00001E96 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  3879 00001E98 2C80                    	sub	al, 80h
  3880 00001E9A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3881 00001E9E 66AB                    	stosw		; interpolated sample 2 (L)
  3882 00001EA0 66AB                    	stosw		; interpolated sample 2 (R)
  3883 00001EA2 88D8                    	mov	al, bl
  3884 00001EA4 00D0                    	add	al, dl	; [next_val]
  3885 00001EA6 D0D8                    	rcr	al, 1
  3886 00001EA8 2C80                    	sub	al, 80h
  3887 00001EAA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3888 00001EAE 66AB                    	stosw		; interpolated sample 3 (L)
  3889 00001EB0 66AB                    	stosw		; interpolated sample 3 (R)
  3890 00001EB2 C3                      	retn
  3891                                  
  3892                                  interpolating_4_8bit_stereo:
  3893                                  	; 17/11/2023
  3894                                  	; al = [previous_val_l]
  3895                                  	; ah = [previous_val_r]
  3896                                  	; dl = [next_val_l]
  3897                                  	; dh = [next_val_r]	
  3898                                  	; original-interpolated-interpolated-interpolated
  3899 00001EB3 89C3                    	mov	ebx, eax
  3900 00001EB5 2C80                    	sub	al, 80h
  3901 00001EB7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3902 00001EBB 66AB                    	stosw		; original sample (L)
  3903 00001EBD 88F8                    	mov	al, bh
  3904 00001EBF 2C80                    	sub	al, 80h
  3905 00001EC1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3906 00001EC5 66AB                    	stosw		; original sample (R)
  3907 00001EC7 88D8                    	mov	al, bl
  3908 00001EC9 00D0                    	add	al, dl	; [next_val_l]
  3909 00001ECB D0D8                    	rcr	al, 1
  3910 00001ECD 86C3                    	xchg	al, bl	; al = [previous_val_l]
  3911 00001ECF 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  3912 00001ED1 D0D8                    	rcr	al, 1
  3913 00001ED3 2C80                    	sub	al, 80h
  3914 00001ED5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3915 00001ED9 66AB                    	stosw		; interpolated sample 1 (L)
  3916 00001EDB 88F8                    	mov	al, bh
  3917 00001EDD 00F0                    	add	al, dh	; [next_val_r]
  3918 00001EDF D0D8                    	rcr	al, 1
  3919 00001EE1 86C7                    	xchg	al, bh	; al = [previous_val_h]
  3920 00001EE3 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  3921 00001EE5 D0D8                    	rcr	al, 1
  3922 00001EE7 2C80                    	sub	al, 80h
  3923 00001EE9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3924 00001EED 66AB                    	stosw		; interpolated sample 1 (R)
  3925 00001EEF 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  3926 00001EF1 2C80                    	sub	al, 80h
  3927 00001EF3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3928 00001EF7 66AB                    	stosw		; interpolated sample 2 (L)
  3929 00001EF9 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  3930 00001EFB 2C80                    	sub	al, 80h
  3931 00001EFD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3932 00001F01 66AB                    	stosw		; interpolated sample 2 (L)
  3933 00001F03 88D8                    	mov	al, bl
  3934 00001F05 00D0                    	add	al, dl	; [next_val_l]
  3935 00001F07 D0D8                    	rcr	al, 1
  3936 00001F09 2C80                    	sub	al, 80h
  3937 00001F0B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3938 00001F0F 66AB                    	stosw		; interpolated sample 3 (L)
  3939 00001F11 88F8                    	mov	al, bh
  3940 00001F13 00F0                    	add	al, dh	; [next_val_r]
  3941 00001F15 D0D8                    	rcr	al, 1
  3942 00001F17 2C80                    	sub	al, 80h
  3943 00001F19 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3944 00001F1D 66AB                    	stosw		; interpolated sample 3 (R)
  3945 00001F1F C3                      	retn
  3946                                  
  3947                                  interpolating_5_16bit_mono:
  3948                                  	; 18/11/2023
  3949                                  	; ax = [previous_val]
  3950                                  	; dx = [next_val]
  3951                                  	; original-interpltd-interpltd-interpltd-interpltd
  3952 00001F20 66AB                    	stosw		; original sample (L)
  3953 00001F22 66AB                    	stosw		; original sample (R)
  3954 00001F24 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3955 00001F27 89C3                    	mov	ebx, eax ; [previous_val]
  3956 00001F29 80C680                  	add	dh, 80h
  3957 00001F2C 6601D0                  	add	ax, dx
  3958 00001F2F 66D1D8                  	rcr	ax, 1
  3959 00001F32 50                      	push	eax ; *	; interpolated middle (temporary)
  3960 00001F33 6601D8                  	add	ax, bx	; interpolated middle + [previous_val] 
  3961 00001F36 66D1D8                  	rcr	ax, 1
  3962 00001F39 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  3963 00001F3A 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  3964 00001F3D 66D1D8                  	rcr	ax, 1	
  3965 00001F40 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3966 00001F43 66AB                    	stosw 		; interpolated sample 1 (L)
  3967 00001F45 66AB                    	stosw		; interpolated sample 1 (R)
  3968 00001F47 58                      	pop	eax ; **	
  3969 00001F48 5B                      	pop	ebx ; *
  3970 00001F49 6601D8                  	add	ax, bx	; 1st quarter + middle
  3971 00001F4C 66D1D8                  	rcr	ax, 1	; / 2
  3972 00001F4F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  3973 00001F52 66AB                    	stosw		; interpolated sample 2 (L)
  3974 00001F54 66AB                    	stosw		; interpolated sample 2 (R)		
  3975 00001F56 89D8                    	mov	eax, ebx
  3976 00001F58 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  3977 00001F5B 66D1D8                  	rcr	ax, 1
  3978 00001F5E 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  3979 00001F5F 6601D8                  	add	ax, bx	; + interpolated middle
  3980 00001F62 66D1D8                  	rcr	ax, 1
  3981 00001F65 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3982 00001F68 66AB                    	stosw		; interpolated sample 3 (L)
  3983 00001F6A 66AB                    	stosw		; interpolated sample 3 (R)
  3984 00001F6C 58                      	pop	eax ; *	
  3985 00001F6D 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  3986 00001F70 66D1D8                  	rcr	ax, 1	; / 2
  3987 00001F73 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3988 00001F76 66AB                    	stosw		; interpolated sample 4 (L)
  3989 00001F78 66AB                    	stosw		; interpolated sample 4 (R)
  3990 00001F7A C3                      	retn
  3991                                  
  3992                                  interpolating_5_16bit_stereo:
  3993                                  	; 18/11/2023
  3994                                  	; bx = [previous_val_l]
  3995                                  	; ax = [previous_val_r]
  3996                                  	; [next_val_l]
  3997                                  	; [next_val_r]
  3998                                  	; original-interpltd-interpltd-interpltd-interpltd
  3999 00001F7B 51                      	push	ecx ; !
  4000 00001F7C 93                      	xchg	eax, ebx
  4001 00001F7D 66AB                    	stosw		; original sample (L)
  4002 00001F7F 93                      	xchg	eax, ebx
  4003 00001F80 66AB                    	stosw		; original sample (R)
  4004 00001F82 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4005 00001F85 50                      	push	eax ; *	; [previous_val_r]
  4006 00001F86 80C780                  	add	bh, 80h
  4007 00001F89 8005[05210000]80        	add	byte [next_val_l+1], 80h
  4008 00001F90 66A1[04210000]          	mov	ax, [next_val_l]
  4009 00001F96 6601D8                  	add	ax, bx	; [previous_val_l]
  4010 00001F99 66D1D8                  	rcr	ax, 1
  4011 00001F9C 89C1                    	mov	ecx, eax ; interpolated middle (L)
  4012 00001F9E 6601D8                  	add	ax, bx	
  4013 00001FA1 66D1D8                  	rcr	ax, 1
  4014 00001FA4 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)	
  4015 00001FA6 6601D8                  	add	ax, bx	; [previous_val_l]
  4016 00001FA9 66D1D8                  	rcr	ax, 1
  4017 00001FAC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4018 00001FAF 66AB                    	stosw 		; interpolated sample 1 (L)
  4019 00001FB1 89C8                    	mov	eax, ecx
  4020 00001FB3 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L) 
  4021 00001FB6 66D1D8                  	rcr	ax, 1	; / 2
  4022 00001FB9 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  4023 00001FBB 5A                      	pop	edx ; *	; [previous_val_r]
  4024 00001FBC 89D0                    	mov	eax, edx
  4025 00001FBE 8005[07210000]80        	add	byte [next_val_r+1], 80h
  4026 00001FC5 660305[06210000]        	add	ax, [next_val_r]
  4027 00001FCC 66D1D8                  	rcr	ax, 1
  4028 00001FCF 50                      	push	eax ; *	; interpolated middle (R)
  4029 00001FD0 6601D0                  	add	ax, dx
  4030 00001FD3 66D1D8                  	rcr	ax, 1
  4031 00001FD6 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  4032 00001FD7 6601D0                  	add	ax, dx	; [previous_val_r]
  4033 00001FDA 66D1D8                  	rcr	ax, 1
  4034 00001FDD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4035 00001FE0 66AB                    	stosw 		; interpolated sample 1 (R)
  4036 00001FE2 89D8                    	mov	eax, ebx
  4037 00001FE4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4038 00001FE7 66AB                    	stosw 		; interpolated sample 2 (L)
  4039 00001FE9 58                      	pop	eax ; **
  4040 00001FEA 5A                      	pop	edx ; *
  4041 00001FEB 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  4042 00001FEE 66D1D8                  	rcr	ax, 1	; / 2
  4043 00001FF1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4044 00001FF4 66AB                    	stosw 		; interpolated sample 2 (R)
  4045 00001FF6 89C8                    	mov	eax, ecx
  4046 00001FF8 660305[04210000]        	add	ax, [next_val_l]
  4047 00001FFF 66D1D8                  	rcr	ax, 1
  4048 00002002 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  4049 00002003 6601C8                  	add	ax, cx	; interpolated middle (L)
  4050 00002006 66D1D8                  	rcr	ax, 1
  4051 00002009 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4052 0000200C 66AB                    	stosw 		; interpolated sample 3 (L)
  4053 0000200E 89D0                    	mov	eax, edx
  4054 00002010 660305[06210000]        	add	ax, [next_val_r]
  4055 00002017 66D1D8                  	rcr	ax, 1
  4056 0000201A 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4057 0000201B 6601D0                  	add	ax, dx	; interpolated middle (R)
  4058 0000201E 66D1D8                  	rcr	ax, 1
  4059 00002021 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4060 00002024 66AB                    	stosw 		; interpolated sample 3 (R)
  4061 00002026 5B                      	pop	ebx ; **
  4062 00002027 58                      	pop	eax ; *
  4063 00002028 660305[04210000]        	add	ax, [next_val_l]
  4064 0000202F 66D1D8                  	rcr	ax, 1
  4065 00002032 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4066 00002035 66AB                    	stosw 		; interpolated sample 4 (L)
  4067 00002037 89D8                    	mov	eax, ebx	
  4068 00002039 660305[06210000]        	add	ax, [next_val_r]
  4069 00002040 66D1D8                  	rcr	ax, 1
  4070 00002043 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4071 00002046 66AB                    	stosw 		; interpolated sample 4 (R)
  4072 00002048 59                      	pop	ecx ; !
  4073 00002049 C3                      	retn
  4074                                  
  4075                                  interpolating_4_16bit_mono:
  4076                                  	; 18/11/2023
  4077                                  	; ax = [previous_val]
  4078                                  	; dx = [next_val]
  4079                                  	; original-interpolated
  4080                                  
  4081 0000204A 66AB                    	stosw		; original sample (L)
  4082 0000204C 66AB                    	stosw		; original sample (R)
  4083 0000204E 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4084 00002051 89C3                    	mov	ebx, eax ; [previous_val]
  4085 00002053 80C680                  	add	dh, 80h
  4086 00002056 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4087 00002059 66D1D8                  	rcr	ax, 1
  4088 0000205C 93                      	xchg	eax, ebx	
  4089 0000205D 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4090 00002060 66D1D8                  	rcr	ax, 1
  4091 00002063 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4092 00002066 66AB                    	stosw 		; interpolated sample 1 (L)
  4093 00002068 66AB                    	stosw		; interpolated sample 1 (R)
  4094 0000206A 89D8                    	mov	eax, ebx ; interpolated middle
  4095 0000206C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4096 0000206F 66AB                    	stosw 		; interpolated sample 2 (L)
  4097 00002071 66AB                    	stosw		; interpolated sample 2 (R)
  4098 00002073 89D8                    	mov	eax, ebx
  4099 00002075 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4100 00002078 66D1D8                  	rcr	ax, 1
  4101 0000207B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4102 0000207E 66AB                    	stosw		; interpolated sample 3 (L)
  4103 00002080 66AB                    	stosw		; interpolated sample 3 (R)
  4104 00002082 C3                      	retn
  4105                                  
  4106                                  interpolating_4_16bit_stereo:
  4107                                  	; 18/11/2023
  4108                                  	; bx = [previous_val_l]
  4109                                  	; ax = [previous_val_r]
  4110                                  	; [next_val_l]
  4111                                  	; [next_val_r]
  4112                                  	; original-interpolated-interpolated-interpolated
  4113 00002083 93                      	xchg	eax, ebx
  4114 00002084 66AB                    	stosw		; original sample (L)
  4115 00002086 93                      	xchg	eax, ebx
  4116 00002087 66AB                    	stosw		; original sample (R)
  4117 00002089 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4118 0000208C 89C2                    	mov	edx, eax ; [previous_val_r]
  4119 0000208E 80C780                  	add	bh, 80h
  4120 00002091 8005[05210000]80        	add	byte [next_val_l+1], 80h
  4121 00002098 66A1[04210000]          	mov	ax, [next_val_l]
  4122 0000209E 6601D8                  	add	ax, bx	; [previous_val_l]
  4123 000020A1 66D1D8                  	rcr	ax, 1
  4124 000020A4 93                      	xchg	eax, ebx	
  4125 000020A5 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4126 000020A8 66D1D8                  	rcr	ax, 1
  4127 000020AB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4128 000020AE 66AB                    	stosw 		; interpolated sample 1 (L)
  4129 000020B0 8005[07210000]80        	add	byte [next_val_r+1], 80h
  4130 000020B7 89D0                    	mov	eax, edx ; [previous_val_r]
  4131 000020B9 660305[06210000]        	add	ax, [next_val_r]
  4132 000020C0 66D1D8                  	rcr	ax, 1
  4133 000020C3 92                      	xchg	eax, edx	
  4134 000020C4 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4135 000020C7 66D1D8                  	rcr	ax, 1
  4136 000020CA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4137 000020CD 66AB                    	stosw 		; interpolated sample 1 (R)
  4138 000020CF 89D8                    	mov	eax, ebx
  4139 000020D1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4140 000020D4 66AB                    	stosw 		; interpolated sample 2 (L)
  4141 000020D6 89D0                    	mov	eax, edx
  4142 000020D8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4143 000020DB 66AB                    	stosw 		; interpolated sample 2 (R)
  4144 000020DD 89D8                    	mov	eax, ebx
  4145 000020DF 660305[04210000]        	add	ax, [next_val_l]
  4146 000020E6 66D1D8                  	rcr	ax, 1
  4147 000020E9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4148 000020EC 66AB                    	stosw 		; interpolated sample 3 (L)
  4149 000020EE 89D0                    	mov	eax, edx
  4150 000020F0 660305[06210000]        	add	ax, [next_val_r]
  4151 000020F7 66D1D8                  	rcr	ax, 1
  4152 000020FA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4153 000020FD 66AB                    	stosw 		; interpolated sample 3 (R)
  4154 000020FF C3                      	retn
  4155                                  
  4156                                  ; 13/11/2023
  4157                                  previous_val:
  4158 00002100 0000                    previous_val_l: dw 0
  4159 00002102 0000                    previous_val_r: dw 0
  4160                                  next_val:
  4161 00002104 0000                    next_val_l: dw 0
  4162 00002106 0000                    next_val_r: dw 0
  4163                                  
  4164                                  ; 16/11/2023
  4165 00002108 00                      faz:	db 0	
  4166                                  	
  4167                                  ; --------------------------------------------------------
  4168                                  
  4169                                  ; DATA
  4170                                  
  4171                                  FileHandle:	
  4172 00002109 FFFFFFFF                	dd	-1
  4173                                  
  4174                                  Credits:
  4175 0000210D 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  4175 00002116 506C6179657220666F-
  4175 0000211F 72205452444F532033-
  4175 00002128 383620627920457264-
  4175 00002131 6F67616E2054616E2E-
  4175 0000213A 20                 
  4176                                  	;;db	'August 2020.',10,13,0
  4177                                  	;db	'November 2023.',10,13,0
  4178 0000213B 4A756E652032303234-     	db	'June 2024.', 10,13,0
  4178 00002144 2E0A0D00           
  4179 00002148 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  4179 00002151 370A0D00           
  4180 00002155 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  4180 0000215E 300A0D00           
  4181 00002162 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  4181 0000216B 330A0D00           
  4182 0000216F 30312F30362F323032-     	db	'01/06/2024', 10,13,0
  4182 00002178 340A0D00           
  4183 0000217C 30362F30362F323032-     	db	'06/06/2024', 10,13,0
  4183 00002185 340A0D00           
  4184                                  
  4185                                  msgAudioCardInfo:
  4186 00002189 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  4186 00002192 204143393720284943-
  4186 0000219B 482920417564696F20-
  4186 000021A4 436F6E74726F6C6C65-
  4186 000021AD 722E0A0D00         
  4187                                  
  4188                                  msg_usage:
  4189 000021B2 75736167653A20706C-     	db	'usage: playwav6 filename.wav',10,13,0
  4189 000021BB 617977617636206669-
  4189 000021C4 6C656E616D652E7761-
  4189 000021CD 760A0D00           
  4190                                  
  4191                                  noDevMsg:
  4192 000021D1 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  4192 000021DA 61626C6520746F2066-
  4192 000021E3 696E64204143393720-
  4192 000021EC 617564696F20646576-
  4192 000021F5 69636521           
  4193 000021F9 0A0D00                  	db	10,13,0
  4194                                  
  4195                                  noFileErrMsg:
  4196 000021FC 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  4196 00002205 6C65206E6F7420666F-
  4196 0000220E 756E642E0A0D00     
  4197                                  
  4198                                  trdos386_err_msg:
  4199 00002215 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  4199 0000221E 2053797374656D2063-
  4199 00002227 616C6C206572726F72-
  4199 00002230 20210A0D00         
  4200                                  
  4201                                  ; 01/06/2024
  4202                                  msg_init_err:
  4203 00002235 0A0D                    	db	10,13
  4204 00002237 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  4204 00002240 726F6C6C65722F436F-
  4204 00002249 64656320696E697469-
  4204 00002252 616C697A6174696F6E-
  4204 0000225B 206572726F722021   
  4205 00002263 0A0D00                  	db	10,13,0
  4206                                  
  4207                                  ; 25/11/2023
  4208                                  msg_no_vra:
  4209 00002266 0A0D                    	db	10,13
  4210 00002268 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  4210 00002271 70706F72742021204F-
  4210 0000227A 6E6C79203438206B48-
  4210 00002283 5A2073616D706C6520-
  4210 0000228C 726174652073757070-
  4210 00002295 6F727465642021     
  4211 0000229C 0A0D00                  	db	10,13,0
  4212                                  
  4213 0000229F 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  4213 000022A8 65204E616D653A2000 
  4214 000022B1 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  4214 000022BA 526174653A20       
  4215 000022C0 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  4215 000022C9 2000               
  4216 000022CB 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  4217 000022D4 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  4218 000022DB 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  4218 000022E4 00                 
  4219 000022E5 53746572656F            msgStereo:	db "Stereo"
  4220 000022EB 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  4221                                  
  4222                                  ; 03/06/2017
  4223 000022EE 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  4223 000022F7 3941424344454600   
  4224 000022FF 0D0A                    msgAC97Info	db 0Dh, 0Ah
  4225 00002301 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  4225 0000230A 6F20436F6E74726F6C-
  4225 00002313 6C6572202620436F64-
  4225 0000231C 656320496E666F0D0A 
  4226 00002325 56656E646F72204944-     		db "Vendor ID: "
  4226 0000232E 3A20               
  4227 00002330 303030306820446576-     msgVendorId	db "0000h Device ID: "
  4227 00002339 6963652049443A20   
  4228 00002341 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  4229 00002348 4275733A20              		db "Bus: "
  4230 0000234D 303068204465766963-     msgBusNo	db "00h Device: "
  4230 00002356 653A20             
  4231 00002359 3030682046756E6374-     msgDevNo	db "00h Function: "
  4231 00002362 696F6E3A20         
  4232 00002367 303068                  msgFncNo	db "00h"
  4233 0000236A 0D0A                    		db 0Dh, 0Ah
  4234 0000236C 4E414D4241523A20        		db "NAMBAR: "
  4235 00002374 30303030682020          msgNamBar	db "0000h  "
  4236 0000237B 4E41424D4241523A20      		db "NABMBAR: "
  4237 00002384 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  4237 0000238D 513A20             
  4238 00002390 3030                    msgIRQ		dw 3030h
  4239 00002392 0D0A00                  		db 0Dh, 0Ah, 0
  4240                                  ; 06/06/2024
  4241 00002395 0D0A                    msgCodec	db 0Dh, 0Ah
  4242 00002397 434F44454320            		db "CODEC "
  4243 0000239D 0D0A                    		db 0Dh, 0Ah
  4244 0000239F 56656E646F72204944-     		db "Vendor ID1: "
  4244 000023A8 313A20             
  4245 000023AB 30303030682020          msgCodecId1	db "0000h  "
  4246 000023B2 56656E646F72204944-     		db "Vendor ID2: "
  4246 000023BB 323A20             
  4247 000023BE 30303030682020          msgCodecId2	db "0000h  "  
  4248                                  ; 25/11/2023
  4249 000023C5 0D0A00                  		db 0Dh, 0Ah, 0
  4250 000023C8 56524120737570706F-     msgVRAheader:	db "VRA support: "
  4250 000023D1 72743A20           
  4251 000023D5 00                      		db 0	
  4252 000023D6 5945530D0A00            msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  4253 000023DC 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  4254 000023E1 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  4254 000023EA 617465642073616D70-
  4254 000023F3 6C6520726174652070-
  4254 000023FC 6C6179696E67206D65-
  4254 00002405 74686F6429         
  4255 0000240A 0D0A00                  		db 0Dh, 0Ah, 0	
  4256                                  EOF: 
  4257                                  
  4258                                  ; BSS
  4259                                  
  4260                                  bss_start:
  4261                                  
  4262                                  ABSOLUTE bss_start
  4263                                  
  4264 0000240D ??????                  alignb 4
  4265                                  
  4266 00002410 ??                      stmo:		resb 1 ; stereo or mono (1=stereo) 
  4267 00002411 ??                      bps:		resb 1 ; bits per sample (8,16)
  4268 00002412 ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  4269                                  
  4270                                  ; 25/11/2023
  4271 00002414 ????????                bufferSize:	resd 1
  4272                                  
  4273 00002418 ??                      flags:		resb 1
  4274                                  ;cbs_busy:	resb 1 
  4275 00002419 ??                      half_buff:	resb 1
  4276 0000241A ??                      srb:		resb 1
  4277                                  ; 18/08/2020
  4278 0000241B ??                      volume_level:	resb 1
  4279                                  ; 25/11/2023
  4280 0000241C ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  4281                                  
  4282 0000241D <res 1Ch>               smpRBuff:	resw 14 
  4283                                  
  4284                                  wav_file_name:
  4285 00002439 <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  4286                                  
  4287 00002489 ????                    		resw 1
  4288 0000248B ??                      ac97_int_ln_reg: resb 1
  4289 0000248C ??                      fbs_shift:	resb 1 ; 26/11/2023
  4290 0000248D ????????                dev_vendor:	resd 1
  4291 00002491 ????????                bus_dev_fn:	resd 1
  4292 00002495 ????                    ac97_NamBar:	resw 1
  4293 00002497 ????                    ac97_NabmBar:	resw 1
  4294                                  
  4295                                  bss_end:
  4296 00002499 <res B67h>              alignb 4096
  4297                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  4298                                  ; 26/11/2023
  4299 00003000 <res 10000h>            audio_buffer:	resb 65536
  4300                                  ; 13/06/2017
  4301                                  ;temp_buffer:	resb BUFFERSIZE
  4302                                  ; 26/11/2023
  4303 00013000 <res 10000h>            temp_buffer:	resb 65536
