     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: 02/02/2025 ]
     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                                  ; 20/10/2024
    22                                  ; 20/08/2024 ; TRDOS 386 v2.0.9
    23                                  ; TRDOS 386 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                                  _creat 	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                                  _mem	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                                  _ldvrt 	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                                  _fpsave	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                                  _stdio  equ 46	;  TRDOS 386 v2.0.9
    71                                  
    72                                  %macro sys 1-4
    73                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    74                                      ; 03/09/2015
    75                                      ; 13/04/2015
    76                                      ; Retro UNIX 386 v1 system call.
    77                                      %if %0 >= 2
    78                                          mov ebx, %2
    79                                          %if %0 >= 3
    80                                              mov ecx, %3
    81                                              %if %0 = 4
    82                                                 mov edx, %4
    83                                              %endif
    84                                          %endif
    85                                      %endif
    86                                      mov eax, %1
    87                                      ;int 30h
    88                                      int 40h ; TRDOS 386 (TRDOS v2.0)
    89                                  %endmacro
    90                                  
    91                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    92                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    93                                  
    94                                  BUFFERSIZE	equ	32768	; audio buffer size 
    95                                  ENDOFFILE       equ     1	; flag for knowing end of file
    96                                  
    97                                  [BITS 32]
    98                                  
    99                                  [ORG 0] 
   100                                  
   101                                  _STARTUP:
   102                                  	; Prints the Credits Text.
   103                                  	sys	_msg, Credits, 255, 0Bh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000000 BB[85220000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000005 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000000A BA0B000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000000F B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000014 CD40                <1>  int 40h
   104                                  
   105                                  	; clear bss
   106 00000016 B9[49260000]            	mov	ecx, bss_end
   107 0000001B BF[BD250000]            	mov	edi, bss_start
   108 00000020 29F9                    	sub	ecx, edi
   109 00000022 D1E9                    	shr	ecx, 1
   110 00000024 31C0                    	xor	eax, eax
   111 00000026 F366AB                  	rep	stosw
   112                                  
   113                                  	; Detect (& Enable) AC'97 Audio Device
   114 00000029 E8E3040000              	call	DetectAC97
   115 0000002E 731B                    	jnc     short GetFileName
   116                                  
   117                                  _dev_not_ready:
   118                                  ; couldn't find the audio device!
   119                                  	sys	_msg, noDevMsg, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000030 BB[81230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000035 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000003A BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000003F B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000044 CD40                <1>  int 40h
   120 00000046 E9A0040000                      jmp     Exit
   121                                  
   122                                  GetFileName:  
   123 0000004B 89E6                    	mov	esi, esp
   124 0000004D AD                      	lodsd
   125 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   126                                  	       ; (program file name & mod file name)
   127 00000051 0F82A2040000            	jb	pmsg_usage ; nothing to do
   128                                  
   129 00000057 AD                      	lodsd ; program file name address 
   130 00000058 AD                      	lodsd ; mod file name address (file to be read)
   131 00000059 89C6                    	mov	esi, eax
   132 0000005B BF[E9250000]            	mov	edi, wav_file_name
   133                                  ScanName:       
   134 00000060 AC                      	lodsb
   135 00000061 84C0                    	test	al, al
   136 00000063 0F8490040000            	je	pmsg_usage
   137 00000069 3C20                    	cmp	al, 20h
   138 0000006B 74F3                    	je	short ScanName	; scan start of name.
   139 0000006D AA                      	stosb
   140 0000006E B4FF                    	mov	ah, 0FFh
   141                                  a_0:	
   142 00000070 FEC4                    	inc	ah
   143                                  a_1:
   144 00000072 AC                      	lodsb
   145 00000073 AA                      	stosb
   146 00000074 3C2E                    	cmp	al, '.'
   147 00000076 74F8                    	je	short a_0	
   148 00000078 20C0                    	and	al, al
   149 0000007A 75F6                    	jnz	short a_1
   150                                  
   151 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   152 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   153                                  SetExt:
   154 00000080 4F                      	dec	edi
   155 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   156 00000087 C6470400                	mov	byte [edi+4], 0
   157                                  
   158                                  _1:
   159                                  
   160                                  ; 26/11/2023
   161                                  %if 0
   162                                  	; Allocate Audio Buffer (for user)
   163                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   164                                  	; 26/11/2023
   165                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   166                                  	jnc	short _2
   167                                  error_exit:
   168                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   169                                  	jmp	Exit
   170                                  _2:
   171                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   172                                  	; bl = 0, bh = 4
   173                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   174                                  
   175                                  	sys	_video, 0400h
   176                                  	cmp	eax, 0B8000h
   177                                  	jne	short error_exit
   178                                  
   179                                  	; Initialize Audio Device (bh = 3)
   180                                  	sys	_audio, 0301h, 0, audio_int_handler 
   181                                  ;	jc	short error_exit
   182                                  _3:
   183                                  
   184                                  %endif
   185 0000008B E8DF060000              	call	write_audio_dev_info 
   186                                  
   187                                  ; open the file
   188                                          ; open existing file
   189 00000090 E889040000                      call    openFile ; no error? ok.
   190 00000095 731B                            jnc     short _gsr
   191                                  
   192                                  ; file not found!
   193                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000097 BB[AC230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000009C B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000000A1 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000000A6 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 000000AB CD40                <1>  int 40h
   194                                  _exit_:
   195 000000AD E939040000                      jmp     Exit
   196                                  
   197                                  _gsr:  
   198 000000B2 E8A1040000                     	call    getSampleRate		; read the sample rate
   199                                                                          ; pass it onto codec.
   200                                  	;jc	Exit
   201                                  	; 25/11/2023
   202 000000B7 72F4                    	jc	short _exit_
   203                                  
   204 000000B9 66A3[C2250000]          	mov	[sample_rate], ax
   205 000000BF 880D[C0250000]          	mov	[stmo], cl
   206 000000C5 8815[C1250000]          	mov	[bps], dl
   207                                  
   208                                  	; 26/11/2023
   209 000000CB C605[3C260000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   210 000000D2 FEC9                    	dec	cl
   211 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   212 000000D6 FE05[3C260000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   213                                  _gsr_1:	
   214 000000DC 80FA08                  	cmp	dl, 8 
   215 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   216 000000E1 FE05[3C260000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   217                                  _gsr_2:	
   218                                  	; 06/06/2017
   219                                  	sys	_audio, 0E00h ; get audio controller info
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000000E7 BB000E0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000000EC B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000000F1 CD40                <1>  int 40h
   220 000000F3 0F8246030000            	jc	error_exit ; 25/11/2023
   221                                  
   222                                  	;cmp	ah, 2 ; ICH ? (Intel AC'97 Audio Controller)
   223                                  	;jne	_dev_not_ready	
   224                                  
   225                                  	; EAX = IRQ Number in AL
   226                                  	;	Audio Device Number in AH 
   227                                  	; EBX = DEV/VENDOR ID
   228                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   229                                  	; ECX = BUS/DEV/FN 
   230                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   231                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   232                                  	;      (Low word, DX = NAMBAR address)
   233                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   234                                  
   235 000000F9 A2[3B260000]            	mov	[ac97_int_ln_reg], al
   236 000000FE 891D[3D260000]          	mov	[dev_vendor], ebx
   237 00000104 890D[41260000]          	mov	[bus_dev_fn], ecx
   238                                  	;mov	[ac97_NamBar], dx
   239                                  	;shr	dx, 16
   240                                  	;mov	[ac97_NabmBar], dx
   241 0000010A 8915[45260000]          	mov	[ac97_NamBar], edx	
   242                                    
   243                                  	; 06/06/2024
   244                                  	;; 01/06/2024
   245                                  	;; Reset Audio Device (bh = 8)
   246                                  	;sys	_audio, 0800h
   247                                  	;;jc	error_exit	
   248                                  	;jc	short init_err
   249                                  
   250 00000110 E83C070000              	call	write_ac97_pci_dev_info
   251                                  
   252                                  	; 01/06/2024
   253                                  	; 25/11/2023
   254                                  	; Get AC'97 Codec info
   255                                  	; (Function 14, sub function 1)
   256                                  	sys	_audio, 0E01h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000115 BB010E0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000011A B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000011F CD40                <1>  int 40h
   257                                  	; 06/06/2024
   258 00000121 7310                    	jnc	short _gsr_3
   259                                  
   260                                  	; 06/06/2024
   261                                  	; a 2nd attempt
   262                                  	sys	_audio, 0E01h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000123 BB010E0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000128 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000012D CD40                <1>  int 40h
   263 0000012F 7302                    	jnc	short _gsr_3
   264                                  
   265 00000131 D1E0                    	shl	eax, 1 ; clears AL BIT 0
   266                                  _gsr_3:
   267                                  	; Save Variable Rate Audio support bit
   268 00000133 2401                    	and	al, 1
   269 00000135 A2[CC250000]            	mov	[VRA], al
   270                                  
   271                                  	; 06/06/2024
   272                                  	; ebx = codec vendor id1 & id2 (bx)
   273 0000013A E826090000              	call	write_codec_info
   274                                  
   275                                  	; 25/11/2023
   276 0000013F E8D4080000              	call	write_VRA_info
   277                                  
   278                                  	; 01/05/2017
   279 00000144 E83D060000              	call	write_wav_file_info
   280                                  
   281                                  	; 25/11/2023
   282                                  	; ------------------------------------------
   283                                  
   284 00000149 803D[CC250000]01        	cmp	byte [VRA], 1
   285 00000150 7220                    	jb	short chk_sample_rate
   286                                  
   287                                  playwav_48_khz:	
   288                                  	;mov	dword [loadfromwavfile], loadFromFile
   289                                  	;mov	dword [buffersize], 65536
   290 00000152 E9CF020000              	jmp	PlayNow
   291                                  
   292                                  	; 01/06/2024
   293                                  init_err:
   294                                  	sys	_msg, msg_init_err, 255, 0Eh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000157 BB[E5230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000015C B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000161 BA0E000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000166 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 0000016B CD40                <1>  int 40h
   295 0000016D E979030000              	jmp	Exit
   296                                  
   297                                  	; 02/02/2025
   298                                  chk_sample_rate:
   299                                  	; set conversion parameters
   300                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   301 00000172 66A1[C2250000]          	mov	ax, [sample_rate]
   302 00000178 663D80BB                	cmp	ax, 48000
   303 0000017C 74D4                    	je	short playwav_48_khz
   304                                  chk_22khz:
   305 0000017E 663D2256                	cmp	ax, 22050
   306 00000182 7545                    	jne	short chk_11khz
   307 00000184 803D[C1250000]08        	cmp	byte [bps], 8
   308 0000018B 7615                    	jna	short chk_22khz_1
   309 0000018D BB[46170000]            	mov	ebx, load_22khz_stereo_16_bit
   310 00000192 803D[C0250000]01        	cmp	byte [stmo], 1 
   311 00000199 751A                    	jne	short chk_22khz_2
   312 0000019B BB[B9160000]            	mov	ebx, load_22khz_mono_16_bit
   313 000001A0 EB13                    	jmp	short chk_22khz_2
   314                                  chk_22khz_1:
   315 000001A2 BB[32160000]            	mov	ebx, load_22khz_stereo_8_bit
   316 000001A7 803D[C0250000]01        	cmp	byte [stmo], 1 
   317 000001AE 7505                    	jne	short chk_22khz_2
   318 000001B0 BB[A9150000]            	mov	ebx, load_22khz_mono_8_bit
   319                                  chk_22khz_2:
   320 000001B5 B85A1D0000              	mov	eax, 7514  ; (442*17)
   321 000001BA BA25000000              	mov	edx, 37
   322 000001BF B911000000              	mov	ecx, 17 
   323 000001C4 E9BA010000              	jmp	set_sizes	
   324                                  chk_11khz:
   325 000001C9 663D112B                	cmp	ax, 11025
   326 000001CD 7545                    	jne	short chk_44khz
   327 000001CF 803D[C1250000]08        	cmp	byte [bps], 8
   328 000001D6 7615                    	jna	short chk_11khz_1
   329 000001D8 BB[62190000]            	mov	ebx, load_11khz_stereo_16_bit
   330 000001DD 803D[C0250000]01        	cmp	byte [stmo], 1 
   331 000001E4 751A                    	jne	short chk_11khz_2
   332 000001E6 BB[E9180000]            	mov	ebx, load_11khz_mono_16_bit
   333 000001EB EB13                    	jmp	short chk_11khz_2
   334                                  chk_11khz_1:
   335 000001ED BB[6F180000]            	mov	ebx, load_11khz_stereo_8_bit
   336 000001F2 803D[C0250000]01        	cmp	byte [stmo], 1 
   337 000001F9 7505                    	jne	short chk_11khz_2
   338 000001FB BB[F7170000]            	mov	ebx, load_11khz_mono_8_bit
   339                                  chk_11khz_2:
   340 00000200 B8AD0E0000              	mov	eax, 3757  ; (221*17)
   341 00000205 BA4A000000              	mov	edx, 74
   342 0000020A B911000000              	mov	ecx, 17
   343 0000020F E96F010000              	jmp	set_sizes 
   344                                  chk_44khz:
   345 00000214 663D44AC                	cmp	ax, 44100
   346 00000218 7545                    	jne	short chk_16khz
   347 0000021A 803D[C1250000]08        	cmp	byte [bps], 8
   348 00000221 7615                    	jna	short chk_44khz_1
   349 00000223 BB[691B0000]            	mov	ebx, load_44khz_stereo_16_bit
   350 00000228 803D[C0250000]01        	cmp	byte [stmo], 1 
   351 0000022F 751A                    	jne	short chk_44khz_2
   352 00000231 BB[F01A0000]            	mov	ebx, load_44khz_mono_16_bit
   353 00000236 EB13                    	jmp	short chk_44khz_2
   354                                  chk_44khz_1:
   355 00000238 BB[731A0000]            	mov	ebx, load_44khz_stereo_8_bit
   356 0000023D 803D[C0250000]01        	cmp	byte [stmo], 1 
   357 00000244 7505                    	jne	short chk_44khz_2
   358 00000246 BB[F7190000]            	mov	ebx, load_44khz_mono_8_bit
   359                                  chk_44khz_2:
   360 0000024B B8D93A0000              	mov	eax, 15065 ; (655*23)
   361 00000250 BA19000000              	mov	edx, 25
   362 00000255 B917000000              	mov	ecx, 23
   363 0000025A E924010000              	jmp	set_sizes 
   364                                  chk_16khz:
   365 0000025F 663D803E                	cmp	ax, 16000
   366 00000263 7545                    	jne	short chk_8khz
   367 00000265 803D[C1250000]08        	cmp	byte [bps], 8
   368 0000026C 7615                    	jna	short chk_16khz_1
   369 0000026E BB[E8100000]            	mov	ebx, load_16khz_stereo_16_bit
   370 00000273 803D[C0250000]01        	cmp	byte [stmo], 1 
   371 0000027A 751A                    	jne	short chk_16khz_2
   372 0000027C BB[67100000]            	mov	ebx, load_16khz_mono_16_bit
   373 00000281 EB13                    	jmp	short chk_16khz_2
   374                                  chk_16khz_1:
   375 00000283 BB[AD0F0000]            	mov	ebx, load_16khz_stereo_8_bit
   376 00000288 803D[C0250000]01        	cmp	byte [stmo], 1 
   377 0000028F 7505                    	jne	short chk_16khz_2
   378 00000291 BB[2E0F0000]            	mov	ebx, load_16khz_mono_8_bit
   379                                  chk_16khz_2:
   380 00000296 B855150000              	mov	eax, 5461
   381 0000029B BA03000000              	mov	edx, 3
   382 000002A0 B901000000              	mov	ecx, 1
   383 000002A5 E9D9000000              	jmp	set_sizes 
   384                                  chk_8khz:
   385 000002AA 663D401F                	cmp	ax, 8000
   386 000002AE 7545                    	jne	short chk_24khz
   387 000002B0 803D[C1250000]08        	cmp	byte [bps], 8
   388 000002B7 7615                    	jna	short chk_8khz_1
   389 000002B9 BB[E30D0000]            	mov	ebx, load_8khz_stereo_16_bit
   390 000002BE 803D[C0250000]01        	cmp	byte [stmo], 1 
   391 000002C5 751A                    	jne	short chk_8khz_2
   392 000002C7 BB[130D0000]            	mov	ebx, load_8khz_mono_16_bit
   393 000002CC EB13                    	jmp	short chk_8khz_2
   394                                  chk_8khz_1:
   395 000002CE BB[E30B0000]            	mov	ebx, load_8khz_stereo_8_bit
   396 000002D3 803D[C0250000]01        	cmp	byte [stmo], 1 
   397 000002DA 7505                    	jne	short chk_8khz_2
   398 000002DC BB[FF0A0000]            	mov	ebx, load_8khz_mono_8_bit
   399                                  chk_8khz_2:
   400 000002E1 B8AA0A0000              	mov	eax, 2730
   401 000002E6 BA06000000              	mov	edx, 6
   402 000002EB B901000000              	mov	ecx, 1
   403 000002F0 E98E000000              	jmp	set_sizes 
   404                                  chk_24khz:
   405 000002F5 663DC05D                	cmp	ax, 24000
   406 000002F9 7542                    	jne	short chk_32khz
   407 000002FB 803D[C1250000]08        	cmp	byte [bps], 8
   408 00000302 7615                    	jna	short chk_24khz_1
   409 00000304 BB[15130000]            	mov	ebx, load_24khz_stereo_16_bit
   410 00000309 803D[C0250000]01        	cmp	byte [stmo], 1 
   411 00000310 751A                    	jne	short chk_24khz_2
   412 00000312 BB[AF120000]            	mov	ebx, load_24khz_mono_16_bit
   413 00000317 EB13                    	jmp	short chk_24khz_2
   414                                  chk_24khz_1:
   415 00000319 BB[25120000]            	mov	ebx, load_24khz_stereo_8_bit
   416 0000031E 803D[C0250000]01        	cmp	byte [stmo], 1 
   417 00000325 7505                    	jne	short chk_24khz_2
   418 00000327 BB[BE110000]            	mov	ebx, load_24khz_mono_8_bit
   419                                  chk_24khz_2:
   420 0000032C B800200000              	mov	eax, 8192
   421 00000331 BA02000000              	mov	edx, 2
   422 00000336 B901000000              	mov	ecx, 1
   423 0000033B EB46                    	jmp	short set_sizes 
   424                                  chk_32khz:
   425 0000033D 663D007D                	cmp	ax, 32000
   426                                  	;jne	short vra_needed
   427                                  	; 02/02/2025
   428 00000341 7574                    	jne	short chk_12khz
   429 00000343 803D[C1250000]08        	cmp	byte [bps], 8
   430 0000034A 7615                    	jna	short chk_32khz_1
   431 0000034C BB[19150000]            	mov	ebx, load_32khz_stereo_16_bit
   432 00000351 803D[C0250000]01        	cmp	byte [stmo], 1 
   433 00000358 751A                    	jne	short chk_32khz_2
   434 0000035A BB[AC140000]            	mov	ebx, load_32khz_mono_16_bit
   435 0000035F EB13                    	jmp	short chk_32khz_2
   436                                  chk_32khz_1:
   437 00000361 BB[0F140000]            	mov	ebx, load_32khz_stereo_8_bit
   438 00000366 803D[C0250000]01        	cmp	byte [stmo], 1 
   439 0000036D 7505                    	jne	short chk_32khz_2
   440 0000036F BB[9C130000]            	mov	ebx, load_32khz_mono_8_bit
   441                                  chk_32khz_2:
   442 00000374 B8AA2A0000              	mov	eax, 10922
   443 00000379 BA03000000              	mov	edx, 3
   444 0000037E B902000000              	mov	ecx, 2
   445                                  	;jmp	short set_sizes
   446                                  
   447                                  set_sizes:
   448 00000383 803D[C0250000]01        	cmp	byte [stmo], 1
   449 0000038A 7402                    	je	short ss_1
   450 0000038C D1E0                    	shl	eax, 1
   451                                  ss_1:
   452 0000038E 803D[C1250000]08        	cmp	byte [bps], 8
   453 00000395 7602                    	jna	short ss_2
   454                                  	; 16 bit samples
   455 00000397 D1E0                    	shl	eax, 1
   456                                  ss_2:
   457 00000399 A3[1E040000]            	mov	[loadsize], eax
   458 0000039E F7E2                    	mul	edx
   459                                  	;cmp	ecx, 1
   460                                  	;je	short ss_3
   461                                  ;ss_3:
   462 000003A0 F7F1                    	div	ecx
   463 000003A2 8A0D[3C260000]          	mov	cl, [fbs_shift]
   464 000003A8 D3E0                    	shl	eax, cl
   465                                  	; 26/11/2023
   466                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   467 000003AA A3[22040000]            	mov	[buffersize], eax ; buffer size in bytes
   468 000003AF 891D[1A040000]          	mov	[loadfromwavfile], ebx
   469 000003B5 EB6F                    	jmp	short PlayNow
   470                                  
   471                                  	;;;;
   472                                  	; 02/02/2025
   473                                  chk_12khz:
   474 000003B7 663DE02E                	cmp	ax, 12000
   475 000003BB 7542                    	jne	short vra_needed
   476 000003BD 803D[C1250000]08        	cmp	byte [bps], 8
   477 000003C4 7615                    	jna	short chk_12khz_1
   478 000003C6 BB[D51C0000]            	mov	ebx, load_12khz_stereo_16_bit
   479 000003CB 803D[C0250000]01        	cmp	byte [stmo], 1 
   480 000003D2 751A                    	jne	short chk_12khz_2
   481 000003D4 BB[861C0000]            	mov	ebx, load_12khz_mono_16_bit
   482 000003D9 EB13                    	jmp	short chk_12khz_2
   483                                  chk_12khz_1:
   484 000003DB BB[301C0000]            	mov	ebx, load_12khz_stereo_8_bit
   485 000003E0 803D[C0250000]01        	cmp	byte [stmo], 1 
   486 000003E7 7505                    	jne	short chk_12khz_2
   487 000003E9 BB[E81B0000]            	mov	ebx, load_12khz_mono_8_bit
   488                                  chk_12khz_2:
   489 000003EE B800100000              	mov	eax, 4096
   490 000003F3 BA04000000              	mov	edx, 4
   491 000003F8 B901000000              	mov	ecx, 1
   492 000003FD EB84                    	jmp	set_sizes 
   493                                  	;;;;
   494                                  
   495                                  vra_needed:
   496                                  	sys	_msg, msg_no_vra, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000003FF BB[16240000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000404 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000409 BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000040E B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000413 CD40                <1>  int 40h
   497 00000415 E9D1000000              	jmp	Exit
   498                                  
   499                                  	; 26/11/2023
   500                                  	; 13/11/2023
   501                                  loadfromwavfile:
   502 0000041A [CA050000]              	dd	loadFromFile
   503                                  loadsize:	; read from wav file
   504 0000041E 00000000                	dd	0
   505                                  buffersize:	; write to DMA buffer
   506 00000422 00000100                	dd	65536 ; bytes
   507                                  
   508                                  PlayNow: 
   509                                  
   510                                  ; 26/11/2023
   511                                  %if 1
   512                                  	; Allocate Audio Buffer (for user)
   513                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   514                                  	; 26/11/2023
   515                                  	sys	_audio, 0200h, [buffersize], audio_buffer
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000426 BB00020000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000042B 8B0D[22040000]      <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000431 BA[00300000]        <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000436 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000043B CD40                <1>  int 40h
   516 0000043D 731B                    	jnc	short _2
   517                                  
   518                                  	; 26/11/2023 - temporary
   519                                  	;sys	_msg, test_1, 255, 0Ch
   520                                  
   521                                  error_exit:
   522                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000043F BB[C5230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000444 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000449 BA0E000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000044E B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000453 CD40                <1>  int 40h
   523 00000455 E991000000              	jmp	Exit
   524                                  _2:
   525                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   526                                  	; bl = 0, bh = 4
   527                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   528                                  
   529                                  	sys	_video, 0400h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000045A BB00040000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000045F B81F000000          <1>  mov eax, %1
    87                              <1> 
    88 00000464 CD40                <1>  int 40h
   530 00000466 3D00800B00              	cmp	eax, 0B8000h
   531 0000046B 75D2                    	jne	short error_exit
   532                                  
   533                                  	; 01/06/2024
   534                                  	; Initialize Audio Device (bh = 3)
   535                                  	sys	_audio, 0301h, 0, audio_int_handler 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000046D BB01030000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000472 B900000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000477 BA[B6050000]        <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000047C B820000000          <1>  mov eax, %1
    87                              <1> 
    88 00000481 CD40                <1>  int 40h
   536                                  	;jc	short error_exit
   537 00000483 0F82CEFCFFFF            	jc	init_err
   538                                  _3:
   539                                  
   540                                  %endif
   541                                  
   542                                  ;
   543                                  ; position file pointer to start in actual wav data
   544                                  ; MUCH improvement should really be done here to check if sample size is
   545                                  ; supported, make sure there are 2 channels, etc.  
   546                                  ;
   547                                          ;mov     ah, 42h
   548                                          ;mov     al, 0	; from start of file
   549                                          ;mov     bx, [FileHandle]
   550                                          ;xor     cx, cx
   551                                          ;mov     dx, 44	; jump past .wav/riff header
   552                                          ;int     21h
   553                                  
   554                                  	sys	_seek, [FileHandle], 44, 0
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000489 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000048F B92C000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000494 BA00000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000499 B813000000          <1>  mov eax, %1
    87                              <1> 
    88 0000049E CD40                <1>  int 40h
   555                                  
   556                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004A0 BB[9B240000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000004A5 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000004AA BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004AF B823000000          <1>  mov eax, %1
    87                              <1> 
    88 000004B4 CD40                <1>  int 40h
   557                                  
   558                                  ; play the .wav file. Most of the good stuff is in here.
   559                                  
   560 000004B6 E8C2010000                      call    PlayWav
   561                                  
   562                                  ; close the .wav file and exit.
   563                                  
   564                                  StopPlaying:
   565                                  	; Stop Playing
   566                                  	sys	_audio, 0700h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004BB BB00070000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004C0 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000004C5 CD40                <1>  int 40h
   567                                  	; Cancel callback service (for user)
   568                                  	sys	_audio, 0900h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004C7 BB00090000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004CC B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000004D1 CD40                <1>  int 40h
   569                                  	; Deallocate Audio Buffer (for user)
   570                                  	sys	_audio, 0A00h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004D3 BB000A0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004D8 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000004DD CD40                <1>  int 40h
   571                                  	; Disable Audio Device
   572                                  	sys	_audio, 0C00h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004DF BB000C0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004E4 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000004E9 CD40                <1>  int 40h
   573                                  Exit:  
   574 000004EB E847000000                      call    closeFile
   575                                           
   576                                  	sys	_exit	; Bye!
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78                              <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000004F0 B801000000          <1>  mov eax, %1
    87                              <1> 
    88 000004F5 CD40                <1>  int 40h
   577                                  here:
   578 000004F7 EBFE                    	jmp	short here
   579                                  
   580                                  pmsg_usage:
   581                                  	sys	_msg, msg_usage, 255, 0Bh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000004F9 BB[62230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000004FE B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000503 BA0B000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000508 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 0000050D CD40                <1>  int 40h
   582 0000050F EBDA                    	jmp	short Exit
   583                                  
   584                                  	; 25/11/2023
   585                                  DetectAC97:
   586                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   587                                          sys	_audio, 0102h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000511 BB02010000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000516 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000051B CD40                <1>  int 40h
   588                                  
   589                                  ; 01/06/2024
   590                                  %if 0
   591                                  	jc	short DetectAC97_retn
   592                                  
   593                                  	; 25/11/2023
   594                                  	; Get AC'97 Codec info
   595                                  	; (Function 14, sub function 1)
   596                                  	sys	_audio, 0E01h
   597                                  	; Save Variable Rate Audio support bit
   598                                  	and	al, 1
   599                                  	mov	[VRA], al
   600                                  %endif
   601                                  
   602                                  DetectAC97_retn:
   603 0000051D C3                      	retn
   604                                  
   605                                  ;open or create file
   606                                  ;
   607                                  ;input: ds:dx-->filename (asciiz)
   608                                  ;       al=file Mode (create or open)
   609                                  ;output: none  cs:[FileHandle] filled
   610                                  ;
   611                                  openFile:
   612                                  	;mov	ah, 3Bh	; start with a mode
   613                                  	;add	ah, al	; add in create or open mode
   614                                  	;xor	ecx, ecx
   615                                  	;int	21h
   616                                  	;jc	short _of1
   617                                  	;;mov	[cs:FileHandle], ax
   618                                  
   619                                  	sys	_open, wav_file_name, 0
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000051E BB[E9250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000523 B900000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000528 B805000000          <1>  mov eax, %1
    87                              <1> 
    88 0000052D CD40                <1>  int 40h
   620 0000052F 7205                    	jc	short _of1
   621                                  
   622 00000531 A3[81220000]            	mov	[FileHandle], eax
   623                                  _of1:
   624 00000536 C3                      	retn
   625                                  
   626                                  ; close the currently open file
   627                                  ; input: none, uses cs:[FileHandle]
   628                                  closeFile:
   629 00000537 833D[81220000]FF        	cmp	dword [FileHandle], -1
   630 0000053E 7417                    	je	short _cf1
   631                                  	;mov    bx, [FileHandle]  
   632                                  	;mov    ax, 3E00h
   633                                          ;int    21h              ;close file
   634                                  
   635                                  	sys	_close, [FileHandle]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000540 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000546 B806000000          <1>  mov eax, %1
    87                              <1> 
    88 0000054B CD40                <1>  int 40h
   636 0000054D C705[81220000]FFFF-     	mov 	dword [FileHandle], -1
   636 00000555 FFFF               
   637                                  _cf1:
   638 00000557 C3                      	retn
   639                                  
   640                                  getSampleRate:
   641                                  	
   642                                  ; reads the sample rate from the .wav file.
   643                                  ; entry: none - assumes file is already open
   644                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   645                                  ;	cx = number of channels (mono=1, stereo=2)
   646                                  ;	dx = bits per sample (8, 16)
   647                                  
   648 00000558 53                      	push    ebx
   649                                  
   650                                          ;mov	ah, 42h
   651                                          ;mov	al, 0	; from start of file
   652                                          ;mov	bx, [FileHandle]
   653                                          ;xor	ecx, ecx
   654                                          ;mov	dx, 08h	; "WAVE"
   655                                          ;int	21h
   656                                  	
   657                                  	sys	_seek, [FileHandle], 8, 0
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000559 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000055F B908000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000564 BA00000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000569 B813000000          <1>  mov eax, %1
    87                              <1> 
    88 0000056E CD40                <1>  int 40h
   658                                  
   659                                          ;mov	dx, smpRBuff
   660                                          ;mov	cx, 28	; 28 bytes
   661                                  	;mov	ah, 3fh
   662                                          ;int	21h
   663                                  
   664                                  	sys	_read, [FileHandle], smpRBuff, 28
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000570 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000576 B9[CD250000]        <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000057B BA1C000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000580 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000585 CD40                <1>  int 40h
   665                                  
   666 00000587 813D[CD250000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   666 0000058F 5645               
   667 00000591 7520                    	jne	short gsr_stc
   668                                  
   669 00000593 66833D[D9250000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   670 0000059B 7516                    	jne	short gsr_stc
   671                                  
   672 0000059D 668B0D[DB250000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   673 000005A4 66A1[DD250000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   674 000005AA 668B15[E7250000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   675                                  gsr_retn:
   676 000005B1 5B                              pop     ebx
   677 000005B2 C3                              retn
   678                                  gsr_stc:
   679 000005B3 F9                      	stc
   680 000005B4 EBFB                    	jmp	short gsr_retn
   681                                  
   682                                  audio_int_handler:
   683                                  	; 13/12/2024
   684                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   685                                  
   686                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   687                                  	
   688                                  	;cmp	byte [cbs_busy], 1
   689                                  	;jnb	short _callback_bsy_retn
   690                                  	
   691                                  	;mov	byte [cbs_busy], 1
   692                                  
   693                                  	; 13/12/2024
   694                                  	;mov	al, [half_buff]
   695                                  	;
   696                                  	;cmp	al, 1
   697                                  	;jb	short _callback_retn
   698                                  
   699                                  	; 18/08/2020
   700                                  	;mov	byte [srb], 1
   701                                  	; 13/12/2024
   702 000005B6 FE05[CA250000]          	inc	byte [srb]
   703                                  
   704                                  	; 13/12/2024
   705                                  	;xor	byte [half_buff], 3 ; 2->1, 1->2
   706                                  
   707                                  	; 13/12/2024
   708                                  	;add	al, '0'
   709                                  ;tL0:	; 26/11/2023
   710                                  	;mov	ah, 4Eh
   711                                  	;mov	ebx, 0B8000h ; video display page address
   712                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   713                                  ;_callback_retn:
   714                                  	;;mov	byte [cbs_busy], 0
   715                                  ;_callback_bsy_retn:
   716                                  	sys	_rele ; return from callback service 
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78                              <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000005BC B827000000          <1>  mov eax, %1
    87                              <1> 
    88 000005C1 CD40                <1>  int 40h
   717                                  	; we must not come here !
   718                                  	sys	_exit
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78                              <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000005C3 B801000000          <1>  mov eax, %1
    87                              <1> 
    88 000005C8 CD40                <1>  int 40h
   719                                  	
   720                                  loadFromFile:
   721                                  	; 26/11/2023
   722 000005CA F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
   723                                  					; last of the file?
   724 000005D1 7402                    	jz	short lff_0		; no
   725 000005D3 F9                      	stc
   726 000005D4 C3                      	retn
   727                                  lff_0:
   728                                  	; 13/06/2017
   729                                  	;mov	edx, BUFFERSIZE
   730                                  	; 26/11/2023
   731 000005D5 BF[00300000]            	mov	edi, audio_buffer
   732 000005DA 8B15[22040000]          	mov	edx, [buffersize]	; bytes
   733 000005E0 8A0D[3C260000]          	mov	cl, [fbs_shift]   
   734 000005E6 20C9                    	and	cl, cl
   735 000005E8 7409                    	jz	short lff_1 ; stereo, 16 bit
   736                                  
   737                                  	; fbs_shift =
   738                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   739                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   740 000005EA D3EA                    	shr	edx, cl
   741                                  	;inc	edx
   742                                  
   743 000005EC BE[00300100]            	mov     esi, temp_buffer
   744 000005F1 EB02                    	jmp	short lff_2
   745                                  lff_1:
   746                                  	;mov	esi, audio_buffer
   747 000005F3 89FE                    	mov	esi, edi ; audio_buffer
   748                                  lff_2:
   749                                  	; 17/03/2017
   750                                  	; esi = buffer address
   751                                  	; edx = buffer size
   752                                   
   753                                  	; 26/11/2023
   754                                  	; load file into memory
   755                                  	sys 	_read, [FileHandle], esi
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000005F5 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000005FB 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000005FD B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000602 CD40                <1>  int 40h
   756                                  	; 14/12/2024
   757 00000604 8B0D[22040000]          	mov	ecx, [buffersize]
   758                                  	;jc	short padfill ; error !
   759                                  	; 14/12/2024
   760 0000060A 7255                    	jc	short lff_10
   761                                  
   762 0000060C 21C0                    	and	eax, eax
   763 0000060E 7453                    	jz	short padfill
   764                                  lff_3:
   765                                  	; 26/11/2023
   766 00000610 8A1D[3C260000]          	mov	bl, [fbs_shift]
   767 00000616 20DB                    	and	bl, bl
   768 00000618 7456                    	jz	short lff_11
   769                                  
   770                                  	; 14/12/2024
   771                                  	;sub	ecx, eax
   772                                  	;mov	ebp, ecx
   773                                  	; 14/12/2024
   774 0000061A 29C2                    	sub	edx, eax
   775                                  
   776                                  	;mov	esi, temp_buffer
   777                                  	;mov	edi, audio_buffer
   778 0000061C 89C1                    	mov	ecx, eax   ; byte count
   779                                  
   780 0000061E 803D[C1250000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   781 00000625 751E                    	jne	short lff_6 ; 16 bit samples
   782                                  	; 8 bit samples
   783 00000627 FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   784 00000629 740E                    	jz	short lff_5 ; 8 bit, stereo
   785                                  lff_4:
   786                                  	; mono & 8 bit
   787 0000062B AC                      	lodsb
   788 0000062C 2C80                    	sub	al, 80h ; 08/11/2023
   789 0000062E C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   790 00000631 66AB                    	stosw	; left channel
   791 00000633 66AB                    	stosw	; right channel
   792 00000635 E2F4                    	loop	lff_4
   793 00000637 EB16                    	jmp	short lff_8
   794                                  lff_5:
   795                                  	; stereo & 8 bit
   796 00000639 AC                      	lodsb
   797 0000063A 2C80                    	sub	al, 80h ; 08/11/2023
   798 0000063C C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   799 0000063F 66AB                    	stosw
   800 00000641 E2F6                    	loop	lff_5			
   801 00000643 EB0A                    	jmp	short lff_8
   802                                  lff_6:
   803 00000645 D1E9                    	shr	ecx, 1 ; word count
   804                                  lff_7:
   805 00000647 66AD                    	lodsw
   806 00000649 66AB                    	stosw	; left channel
   807 0000064B 66AB                    	stosw	; right channel
   808 0000064D E2F8                    	loop	lff_7
   809                                  lff_8:
   810                                  	; 27/11/2023
   811 0000064F F8                      	clc
   812                                  	; 14/12/2024
   813                                  	;mov	ecx, ebp
   814                                  	;jecxz	endLFF_retn
   815 00000650 09D2                    	or	edx, edx
   816 00000652 741B                    	jz	short endLFF_retn
   817                                  	
   818                                  	; 14/12/2024
   819 00000654 B9[00300000]            	mov	ecx, audio_buffer
   820 00000659 030D[22040000]          	add	ecx, [buffersize]
   821 0000065F 29F9                    	sub	ecx, edi
   822                                  
   823                                  	; 14/12/2024
   824                                  lff_10:
   825 00000661 31C0                    	xor	eax, eax ; silence
   826                                  padfill:
   827 00000663 D1E9                    	shr	ecx, 1 
   828 00000665 F366AB                  	rep	stosw
   829                                  lff_9:
   830 00000668 800D[C8250000]01                or	byte [flags], ENDOFFILE	; end of file flag
   831                                  endLFF_retn:
   832 0000066F C3                              retn
   833                                  
   834                                  lff_11:
   835                                  	; 16 bit stereo
   836                                  	; ecx = buffer size
   837                                  	; eax = read count
   838 00000670 29C1                    	sub	ecx, eax
   839 00000672 76FB                    	jna	short endLFF_retn
   840 00000674 01C7                    	add	edi, eax  ; audio_buffer + eax
   841 00000676 EBE9                    	jmp	short lff_10 ; padfill
   842                                  
   843                                  error_exit_2:
   844                                  	; 26/11/2023 - temporary
   845                                  	;sys	_msg, test_2, 255, 0Ch
   846                                  
   847 00000678 E9C2FDFFFF              	jmp	error_exit
   848                                  	
   849                                  	; 26/11/2023 - temporary
   850                                  ;test_1:
   851                                  ;	db 13, 10, 'Test 1', 13,10, 0
   852                                  ;test_2:
   853                                  ;	db 13, 10, 'Test 2', 13,10, 0
   854                                  	
   855                                  PlayWav:
   856                                  	; 26/11/2023
   857                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   858                                  	; 13/06/2017
   859                                  	; Convert 8 bit samples to 16 bit samples
   860                                  	; and convert mono samples to stereo samples
   861                                  
   862                                  	; 26/11/2023
   863                                  	; load 32768 bytes into audio buffer
   864                                  	;mov	edi, audio_buffer
   865                                  	;;mov	edx, BUFFERSIZE
   866                                  	; 26/11/2023
   867                                  	;mov	edx, [buffersize]
   868                                  	;call	loadFromFile
   869                                  	; 26/11/2023
   870 0000067D FF15[1A040000]          	call	dword [loadfromwavfile]
   871 00000683 72F3                    	jc	short error_exit_2
   872 00000685 C605[C9250000]01        	mov	byte [half_buff], 1 ; (DMA) Buffer 1
   873                                  
   874                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   875 0000068C F605[C8250000]01        	test    byte [flags], ENDOFFILE  ; end of file
   876 00000693 7512                    	jnz	short _6 ; yes
   877                                  			 ; bypass filling dma half buffer 2
   878                                  
   879                                  	; bh = 16 : update (current, first) dma half buffer
   880                                  	; bl = 0  : then switch to the next (second) half buffer
   881                                  	sys	_audio, 1000h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000695 BB00100000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000069A B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000069F CD40                <1>  int 40h
   882                                  
   883                                  	; 18/08/2020
   884                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
   885                                  
   886                                  	; audio_buffer must be filled again after above system call 
   887                                  	; (Because audio interrupt will be generated by AC97 hardware
   888                                  	; at the end of the first half of dma buffer.. so, 
   889                                  	; the second half must be ready. 'sound_play' will use it.)
   890                                  
   891                                  	; 26/11/2023
   892                                  	;mov	edi, audio_buffer
   893                                  	;;mov	edx, BUFFERSIZE
   894                                  	; 26/11/2023
   895                                  	;mov	edx, [buffersize]
   896                                  	;call	loadFromFile
   897                                  	; 26/11/2023
   898 000006A1 FF15[1A040000]          	call	dword [loadfromwavfile]
   899                                  	;jc	short p_return
   900                                  _6:
   901                                  	; Set Master Volume Level (BL=0 or 80h)
   902                                  	; 	for next playing (BL>=80h)
   903                                  	;sys	_audio, 0B80h, 1D1Dh
   904                                  	sys	_audio, 0B00h, 1D1Dh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000006A7 BB000B0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000006AC B91D1D0000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000006B1 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000006B6 CD40                <1>  int 40h
   905                                  
   906                                  	; 18/08/2020
   907                                  	;mov	byte [volume_level], 1Dh
   908 000006B8 880D[CB250000]          	mov	[volume_level], cl
   909                                  
   910                                  	; Start	to play
   911 000006BE A0[C1250000]            	mov	al, [bps]
   912 000006C3 C0E804                  	shr	al, 4 ; 8 -> 0, 16 -> 1
   913 000006C6 D0E0                    	shl	al, 1 ; 16 -> 2, 8 -> 0
   914 000006C8 8A1D[C0250000]          	mov	bl, [stmo]
   915 000006CE FECB                    	dec	bl
   916 000006D0 08C3                    	or	bl, al
   917 000006D2 668B0D[C2250000]        	mov	cx, [sample_rate] 
   918 000006D9 B704                    	mov	bh, 4 ; start to play
   919                                  	sys	_audio
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78                              <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000006DB B820000000          <1>  mov eax, %1
    87                              <1> 
    88 000006E0 CD40                <1>  int 40h
   920                                  
   921                                  	;mov	ebx, 0B8000h ; video display page address
   922                                  	;mov	ah, 4Eh
   923                                  	;mov	al, [half_buffer]
   924                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   925                                  
   926                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   927                                  	; Here..
   928                                  	; If byte [flags] <> ENDOFFILE ...
   929                                  	; user's audio_buffer has been copied to dma half buffer 2
   930                                  
   931                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
   932                                  
   933                                  	; audio_buffer must be filled again after above system call 
   934                                  	; (Because, audio interrupt will be generated by VT8237R
   935                                  	; at the end of the first half of dma buffer.. so, 
   936                                  	; the 2nd half of dma buffer is ready but the 1st half
   937                                  	; must be filled again.)
   938                                  
   939                                  ; 14/12/2024
   940                                  %if 0
   941                                  	; 18/08/2020
   942                                  	test    byte [flags], ENDOFFILE  ; end of file
   943                                  	jnz	short p_loop ; yes
   944                                  
   945                                  	; 18/08/2020
   946                                  	; load 32768 bytes into audio buffer
   947                                  	;; (for the second half of DMA buffer)
   948                                  	; 27/11/2023
   949                                  	; 20/05/2017
   950                                  	;mov	edi, audio_buffer
   951                                  	;mov	edx, BUFFERSIZE
   952                                  	; 26/11/2023
   953                                  	;mov	edx, [buffersize]
   954                                  	;call	loadFromFile
   955                                  	; 26/11/2023
   956                                  	call	dword [loadfromwavfile]
   957                                  	;jc	short p_return
   958                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
   959                                  %endif
   960                                  
   961                                  	; we need to wait for 'SRB' (audio interrupt)
   962                                  	; (we can not return from 'PlayWav' here 
   963                                  	;  even if we have got an error from file reading)
   964                                  	; ((!!current audio data must be played!!))
   965                                  
   966                                  	; 18/08/2020
   967                                  	;mov	byte [srb], 1
   968                                  
   969                                  p_loop:
   970                                  	;mov	ah, 1		; any key pressed?
   971                                  	;int	32h		; no, Loop.
   972                                  	;jz	short q_loop
   973                                  	;
   974                                  	;mov	ah, 0		; flush key buffer...
   975                                  	;int	32h
   976                                  
   977                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   978 000006E2 803D[CA250000]00        	cmp	byte [srb], 0
   979 000006E9 7627                    	jna	short q_loop
   980 000006EB C605[CA250000]00        	mov	byte [srb], 0
   981                                  	; 13/12/2024
   982 000006F2 8035[C9250000]03        	xor	byte [half_buff], 3 ; 2->1, 1->2
   983                                  
   984                                  	; 27/11/2023
   985                                  	;mov	edi, audio_buffer
   986                                  	;mov	edx, BUFFERSIZE
   987                                  	; 26/11/2023
   988                                  	;mov	edx, [buffersize]
   989                                  	;call	loadFromFile
   990                                  	; 26/11/2023
   991 000006F9 FF15[1A040000]          	call	dword [loadfromwavfile]
   992 000006FF 7223                    	jc	short p_return
   993                                  
   994                                  	; 14/12/2024
   995                                  	;;;
   996                                  	; bh = 16 : update (current, first) dma half buffer
   997                                  	; bl = 0  : then switch to the other half buffer
   998                                  	sys	_audio, 1000h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000701 BB00100000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000706 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000070B CD40                <1>  int 40h
   999                                  	;;;;
  1000                                  
  1001                                  	; 13/12/2024
  1002 0000070D E819000000              	call	tL0
  1003                                  q_loop:
  1004 00000712 B401                    	mov     ah, 1		; any key pressed?
  1005 00000714 CD32                    	int     32h		; no, Loop.
  1006 00000716 74CA                    	jz	short p_loop
  1007                                  
  1008 00000718 B400                    	mov     ah, 0		; flush key buffer...
  1009 0000071A CD32                    	int     32h
  1010                                  	
  1011 0000071C 3C2B                    	cmp	al, '+' ; increase sound volume
  1012 0000071E 741D                    	je	short inc_volume_level
  1013 00000720 3C2D                    	cmp	al, '-'
  1014 00000722 743C                    	je	short dec_volume_level
  1015                                  
  1016                                  p_return:
  1017 00000724 C605[C9250000]00        	mov	byte [half_buff], 0
  1018                                  	; 13/12/2024
  1019                                  	;call	tL0
  1020                                  	;retn
  1021                                  
  1022                                  	; 13/12/2024
  1023                                  tL0:
  1024 0000072B A0[C9250000]            	mov	al, [half_buff]
  1025 00000730 0430                    	add	al, '0'
  1026 00000732 B44E                    	mov	ah, 4Eh
  1027 00000734 BB00800B00              	mov	ebx, 0B8000h	; video display page address
  1028 00000739 668903                  	mov	[ebx], ax	; show playing buffer (1, 2)
  1029 0000073C C3                      	retn
  1030                                  
  1031                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
  1032                                  inc_volume_level:
  1033 0000073D 8A0D[CB250000]          	mov	cl, [volume_level]
  1034 00000743 80F91F                  	cmp	cl, 1Fh ; 31
  1035 00000746 73CA                    	jnb	short q_loop
  1036 00000748 FEC1                    	inc	cl
  1037                                  change_volume_level:
  1038 0000074A 880D[CB250000]          	mov	[volume_level], cl
  1039 00000750 88CD                    	mov	ch, cl
  1040                                  	; Set Master Volume Level
  1041                                  	sys	_audio, 0B00h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000752 BB000B0000          <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80                              <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82                              <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000757 B820000000          <1>  mov eax, %1
    87                              <1> 
    88 0000075C CD40                <1>  int 40h
  1042 0000075E EB82                    	jmp	short p_loop
  1043                                  dec_volume_level:
  1044 00000760 8A0D[CB250000]          	mov	cl, [volume_level]
  1045 00000766 80F901                  	cmp	cl, 1 ; 1
  1046                                  	;jna	short p_loop
  1047                                  	; 14/12/2024
  1048 00000769 76A7                    	jna	short q_loop
  1049 0000076B FEC9                    	dec	cl
  1050 0000076D EBDB                    	jmp	short change_volume_level
  1051                                  
  1052                                  write_audio_dev_info:
  1053                                  	; EBX = Message address
  1054                                  	; ECX = Max. message length (or stop on ZERO character)
  1055                                  	;	(1 to 255)
  1056                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
  1057                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000076F BB[39230000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000774 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000779 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000077E B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000783 CD40                <1>  int 40h
  1058 00000785 C3                      	retn
  1059                                  
  1060                                  write_wav_file_info:
  1061                                  	; 01/05/2017
  1062                                  	sys	_msg, msgWavFileName, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000786 BB[4F240000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000078B B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000790 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000795 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 0000079A CD40                <1>  int 40h
  1063                                  	sys	_msg, wav_file_name, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000079C BB[E9250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000007A1 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000007A6 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000007AB B823000000          <1>  mov eax, %1
    87                              <1> 
    88 000007B0 CD40                <1>  int 40h
  1064                                  
  1065                                  write_sample_rate:
  1066                                  	; 01/05/2017
  1067 000007B2 66A1[C2250000]          	mov	ax, [sample_rate]
  1068                                  	; ax = sample rate (hertz)
  1069 000007B8 31D2                    	xor	edx, edx
  1070 000007BA 66B90A00                	mov	cx, 10
  1071 000007BE 66F7F1                  	div	cx
  1072 000007C1 0015[74240000]          	add	[msgHertz+4], dl
  1073 000007C7 29D2                    	sub	edx, edx
  1074 000007C9 66F7F1                  	div	cx
  1075 000007CC 0015[73240000]          	add	[msgHertz+3], dl
  1076 000007D2 29D2                    	sub	edx, edx
  1077 000007D4 66F7F1                  	div	cx
  1078 000007D7 0015[72240000]          	add	[msgHertz+2], dl
  1079 000007DD 29D2                    	sub	edx, edx
  1080 000007DF 66F7F1                  	div	cx
  1081 000007E2 0015[71240000]          	add	[msgHertz+1], dl
  1082 000007E8 0005[70240000]          	add	[msgHertz], al
  1083                                  	
  1084                                  	sys	_msg, msgSampleRate, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000007EE BB[61240000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000007F3 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000007F8 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000007FD B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000802 CD40                <1>  int 40h
  1085                                  
  1086 00000804 BE[8B240000]            	mov	esi, msg16Bits
  1087 00000809 803D[C1250000]10        	cmp	byte [bps], 16
  1088 00000810 7405                    	je	short wsr_1
  1089 00000812 BE[7B240000]            	mov	esi, msg8Bits
  1090                                  wsr_1:
  1091                                  	sys	_msg, esi, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000817 89F3                <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000819 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000081E BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000823 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000828 CD40                <1>  int 40h
  1092                                  
  1093 0000082A BE[84240000]            	mov	esi, msgMono
  1094 0000082F 803D[C0250000]01        	cmp	byte [stmo], 1
  1095 00000836 7405                    	je	short wsr_2
  1096 00000838 BE[95240000]            	mov	esi, msgStereo		
  1097                                  wsr_2:
  1098                                  	sys	_msg, esi, 255, 0Fh
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000083D 89F3                <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000083F B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000844 BA0F000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000849 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 0000084E CD40                <1>  int 40h
  1099 00000850 C3                              retn
  1100                                  
  1101                                  write_ac97_pci_dev_info:
  1102                                  	; 06/06/2017
  1103                                  	; 03/06/2017
  1104                                  	; BUS/DEV/FN
  1105                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1106                                  	; DEV/VENDOR
  1107                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1108                                  
  1109 00000851 8B35[3D260000]          	mov	esi, [dev_vendor]
  1110 00000857 89F0                    	mov	eax, esi
  1111 00000859 0FB6D8                  	movzx	ebx, al
  1112 0000085C 88DA                    	mov	dl, bl
  1113 0000085E 80E30F                  	and	bl, 0Fh
  1114 00000861 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1115 00000867 A2[E3240000]            	mov	[msgVendorId+3], al
  1116 0000086C 88D3                    	mov	bl, dl
  1117 0000086E C0EB04                  	shr	bl, 4
  1118 00000871 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1119 00000877 A2[E2240000]            	mov	[msgVendorId+2], al
  1120 0000087C 88E3                    	mov	bl, ah
  1121 0000087E 88DA                    	mov	dl, bl
  1122 00000880 80E30F                  	and	bl, 0Fh
  1123 00000883 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1124 00000889 A2[E1240000]            	mov	[msgVendorId+1], al
  1125 0000088E 88D3                    	mov	bl, dl
  1126 00000890 C0EB04                  	shr	bl, 4
  1127 00000893 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1128 00000899 A2[E0240000]            	mov	[msgVendorId], al
  1129 0000089E C1E810                  	shr	eax, 16
  1130 000008A1 88C3                    	mov	bl, al
  1131 000008A3 88DA                    	mov	dl, bl
  1132 000008A5 80E30F                  	and	bl, 0Fh
  1133 000008A8 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1134 000008AE A2[F4240000]            	mov	[msgDevId+3], al
  1135 000008B3 88D3                    	mov	bl, dl
  1136 000008B5 C0EB04                  	shr	bl, 4
  1137 000008B8 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1138 000008BE A2[F3240000]            	mov	[msgDevId+2], al
  1139 000008C3 88E3                    	mov	bl, ah
  1140 000008C5 88DA                    	mov	dl, bl
  1141 000008C7 80E30F                  	and	bl, 0Fh
  1142 000008CA 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1143 000008D0 A2[F2240000]            	mov	[msgDevId+1], al
  1144 000008D5 88D3                    	mov	bl, dl
  1145 000008D7 C0EB04                  	shr	bl, 4
  1146 000008DA 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1147 000008E0 A2[F1240000]            	mov	[msgDevId], al
  1148                                  
  1149 000008E5 8B35[41260000]          	mov	esi, [bus_dev_fn]
  1150 000008EB C1EE08                  	shr	esi, 8
  1151 000008EE 6689F0                  	mov	ax, si
  1152 000008F1 88C3                    	mov	bl, al
  1153 000008F3 88DA                    	mov	dl, bl
  1154 000008F5 80E307                  	and	bl, 7 ; bit 0,1,2
  1155 000008F8 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1156 000008FE A2[18250000]            	mov	[msgFncNo+1], al
  1157 00000903 88D3                    	mov	bl, dl
  1158 00000905 C0EB03                  	shr	bl, 3
  1159 00000908 88DA                    	mov	dl, bl
  1160 0000090A 80E30F                  	and	bl, 0Fh
  1161 0000090D 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1162 00000913 A2[0A250000]            	mov	[msgDevNo+1], al
  1163 00000918 88D3                    	mov	bl, dl
  1164 0000091A C0EB04                  	shr	bl, 4
  1165 0000091D 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1166 00000923 A2[09250000]            	mov	[msgDevNo], al
  1167 00000928 88E3                    	mov	bl, ah
  1168 0000092A 88DA                    	mov	dl, bl
  1169 0000092C 80E30F                  	and	bl, 0Fh
  1170 0000092F 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1171 00000935 A2[FE240000]            	mov	[msgBusNo+1], al
  1172 0000093A 88D3                    	mov	bl, dl
  1173 0000093C C0EB04                  	shr	bl, 4
  1174 0000093F 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1175 00000945 A2[FD240000]            	mov	[msgBusNo], al
  1176                                  
  1177 0000094A 66A1[45260000]          	mov	ax, [ac97_NamBar]
  1178 00000950 88C3                    	mov	bl, al
  1179 00000952 88DA                    	mov	dl, bl
  1180 00000954 80E30F                  	and	bl, 0Fh
  1181 00000957 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1182 0000095D A2[27250000]            	mov	[msgNamBar+3], al
  1183 00000962 88D3                    	mov	bl, dl
  1184 00000964 C0EB04                  	shr	bl, 4
  1185 00000967 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1186 0000096D A2[26250000]            	mov	[msgNamBar+2], al
  1187 00000972 88E3                    	mov	bl, ah
  1188 00000974 88DA                    	mov	dl, bl
  1189 00000976 80E30F                  	and	bl, 0Fh
  1190 00000979 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1191 0000097F A2[25250000]            	mov	[msgNamBar+1], al
  1192 00000984 88D3                    	mov	bl, dl
  1193 00000986 C0EB04                  	shr	bl, 4
  1194 00000989 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1195 0000098F A2[24250000]            	mov	[msgNamBar], al
  1196                                  
  1197 00000994 66A1[47260000]          	mov	ax, [ac97_NabmBar]
  1198 0000099A 88C3                    	mov	bl, al
  1199 0000099C 88DA                    	mov	dl, bl
  1200 0000099E 80E30F                  	and	bl, 0Fh
  1201 000009A1 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1202 000009A7 A2[37250000]            	mov	[msgNabmBar+3], al
  1203 000009AC 88D3                    	mov	bl, dl
  1204 000009AE C0EB04                  	shr	bl, 4
  1205 000009B1 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1206 000009B7 A2[36250000]            	mov	[msgNabmBar+2], al
  1207 000009BC 88E3                    	mov	bl, ah
  1208 000009BE 88DA                    	mov	dl, bl
  1209 000009C0 80E30F                  	and	bl, 0Fh
  1210 000009C3 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1211 000009C9 A2[35250000]            	mov	[msgNabmBar+1], al
  1212 000009CE 88D3                    	mov	bl, dl
  1213 000009D0 C0EB04                  	shr	bl, 4
  1214 000009D3 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1215 000009D9 A2[34250000]            	mov	[msgNabmBar], al
  1216                                  
  1217 000009DE 30E4                    	xor	ah, ah
  1218 000009E0 A0[3B260000]            	mov	al, [ac97_int_ln_reg]
  1219 000009E5 B10A                    	mov	cl, 10
  1220 000009E7 F6F1                    	div	cl
  1221 000009E9 660105[40250000]        	add	[msgIRQ], ax
  1222 000009F0 20C0                    	and	al, al
  1223 000009F2 750D                    	jnz	short _w_ac97imsg_
  1224 000009F4 A0[41250000]            	mov	al, [msgIRQ+1]
  1225 000009F9 B420                    	mov	ah, ' '
  1226 000009FB 66A3[40250000]          	mov	[msgIRQ], ax
  1227                                  _w_ac97imsg_:
  1228                                  	sys	_msg, msgAC97Info, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000A01 BB[AF240000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000A06 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000A0B BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000A10 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000A15 CD40                <1>  int 40h
  1229                                  
  1230 00000A17 C3                              retn
  1231                                  
  1232                                  write_VRA_info:
  1233                                  	; 25/11/2023
  1234                                  	sys	_msg, msgVRAheader, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000A18 BB[78250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000A1D B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000A22 BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000A27 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000A2C CD40                <1>  int 40h
  1235 00000A2E 803D[CC250000]00        	cmp	byte [VRA], 0
  1236 00000A35 7617                    	jna	short _w_VRAi_no
  1237                                  _w_VRAi_yes:
  1238                                  	sys	_msg, msgVRAyes, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000A37 BB[86250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000A3C B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000A41 BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000A46 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000A4B CD40                <1>  int 40h
  1239 00000A4D C3                      	retn
  1240                                  _w_VRAi_no:
  1241                                  	sys	_msg, msgVRAno, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000A4E BB[8C250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000A53 B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000A58 BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000A5D B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000A62 CD40                <1>  int 40h
  1242 00000A64 C3                      	retn
  1243                                  
  1244                                  	; 06/06/2024
  1245                                  write_codec_info:
  1246 00000A65 89DA                    	mov	edx, ebx
  1247 00000A67 83E30F                  	and	ebx, 0Fh
  1248 00000A6A 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1249 00000A70 A2[71250000]            	mov	[msgCodecId2+3], al
  1250 00000A75 88D3                    	mov	bl, dl
  1251 00000A77 C0EB04                  	shr	bl, 4
  1252 00000A7A 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1253 00000A80 A2[70250000]            	mov	[msgCodecId2+2], al
  1254 00000A85 88F3                    	mov	bl, dh
  1255 00000A87 80E30F                  	and	bl, 0Fh
  1256 00000A8A 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1257 00000A90 A2[6F250000]            	mov	[msgCodecId2+1], al
  1258 00000A95 88F3                    	mov	bl, dh
  1259 00000A97 C0EB04                  	shr	bl, 4
  1260 00000A9A 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1261 00000AA0 A2[6E250000]            	mov	[msgCodecId2], al
  1262 00000AA5 C1EA10                  	shr	edx, 16
  1263 00000AA8 88D3                    	mov	bl, dl
  1264 00000AAA 80E30F                  	and	bl, 0Fh
  1265 00000AAD 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1266 00000AB3 A2[5E250000]            	mov	[msgCodecId1+3], al
  1267 00000AB8 88D3                    	mov	bl, dl
  1268 00000ABA C0EB04                  	shr	bl, 4
  1269 00000ABD 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1270 00000AC3 A2[5D250000]            	mov	[msgCodecId1+2], al
  1271 00000AC8 88F3                    	mov	bl, dh
  1272 00000ACA 80E30F                  	and	bl, 0Fh
  1273 00000ACD 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1274 00000AD3 A2[5C250000]            	mov	[msgCodecId1+1], al
  1275 00000AD8 88F3                    	mov	bl, dh
  1276 00000ADA C0EB04                  	shr	bl, 4
  1277 00000ADD 8A83[9E240000]          	mov	al, [ebx+hex_chars]
  1278 00000AE3 A2[5B250000]            	mov	[msgCodecId1], al
  1279                                  	;
  1280                                  	sys	_msg, msgCodec, 255, 07h
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000AE8 BB[45250000]        <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000AED B9FF000000          <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000AF2 BA07000000          <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000AF7 B823000000          <1>  mov eax, %1
    87                              <1> 
    88 00000AFC CD40                <1>  int 40h
  1281 00000AFE C3                      	retn
  1282                                  
  1283                                  ; 02/02/2025
  1284                                  ;
  1285                                  ; 26/11/2023
  1286                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1287                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1288                                  ; 14/11/2023
  1289                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1290                                  ; --------------------------------------------------------
  1291                                  
  1292                                  ;;Note:	At the end of every buffer load,
  1293                                  ;;	during buffer switch/swap, there will be discontinuity
  1294                                  ;;	between the last converted sample and the 1st sample
  1295                                  ;;	of the next buffer.
  1296                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1297                                  ;;	-To avoid this defect, the 1st sample of
  1298                                  ;;	the next buffer may be read from the wav file but
  1299                                  ;;	the file pointer would need to be set to 1 sample back
  1300                                  ;;	again via seek system call. Time comsumption problem! -
  1301                                  ;;
  1302                                  ;;	Erdogan Tan - 15/11/2023
  1303                                  ;;
  1304                                  ;;	((If entire wav data would be loaded at once.. conversion
  1305                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1306                                  ;;	64KB buffer limit is important also it is important
  1307                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1308                                  ;;	I have tested this program by using 2-30MB wav files.))
  1309                                  ;;
  1310                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1311                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1312                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1313                                  ;;			Realtek ALC850 codec.
  1314                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1315                                  
  1316                                  load_8khz_mono_8_bit:
  1317                                  	; 02/02/2025
  1318                                  	; 15/11/2023
  1319                                  	; 14/11/2023
  1320                                  	; 13/11/2023
  1321 00000AFF F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1322                                  					; last of the file?
  1323 00000B06 7402                    	jz	short lff8m_0		; no
  1324 00000B08 F9                      	stc
  1325 00000B09 C3                      	retn
  1326                                  
  1327                                  lff8m_0:
  1328 00000B0A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1329                                          ;mov	edx, [loadsize]
  1330                                  
  1331                                  	; esi = buffer address
  1332                                  	;; edx = buffer size
  1333                                  
  1334                                  	; load file into memory
  1335                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000B0F 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000B15 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000B17 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000B1D B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000B22 CD40                <1>  int 40h
  1336 00000B24 7305                    	jnc	short lff8m_6
  1337 00000B26 E9AF000000              	jmp	lff8m_5  ; error !
  1338                                  
  1339                                  lff8m_6:
  1340 00000B2B BF[00300000]            	mov	edi, audio_buffer
  1341 00000B30 21C0                    	and	eax, eax
  1342 00000B32 0F8499000000            	jz	lff8_eof
  1343                                  
  1344 00000B38 89C1                    	mov	ecx, eax	; byte count
  1345                                  lff8m_1:
  1346 00000B3A AC                      	lodsb
  1347 00000B3B A2[78220000]            	mov	[previous_val], al
  1348 00000B40 2C80                    	sub	al, 80h
  1349 00000B42 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1350 00000B46 66AB                    	stosw		; original sample (left channel)
  1351 00000B48 66AB                    	stosw		; original sample (right channel)
  1352                                  	; 02/02/2025
  1353                                  	;xor	eax, eax
  1354 00000B4A 8A06                    	mov	al, [esi]
  1355 00000B4C 49                      	dec	ecx
  1356 00000B4D 7502                    	jnz	short lff8m_2
  1357 00000B4F B080                    	mov	al, 80h
  1358                                  lff8m_2:
  1359                                  	;mov	[next_val], ax
  1360 00000B51 88C7                    	mov	bh, al	; [next_val]
  1361 00000B53 8A25[78220000]          	mov	ah, [previous_val]
  1362 00000B59 00E0                    	add	al, ah	; [previous_val]
  1363 00000B5B D0D8                    	rcr	al, 1
  1364 00000B5D 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1365 00000B5F 00E0                    	add	al, ah	; [previous_val]
  1366 00000B61 D0D8                    	rcr	al, 1	
  1367 00000B63 88C3                    	mov	bl, al 	; this is temporary interpolation value
  1368 00000B65 00E0                    	add	al, ah	; [previous_val]
  1369 00000B67 D0D8                    	rcr	al, 1
  1370 00000B69 2C80                    	sub	al, 80h
  1371 00000B6B 66C1E008                	shl	ax, 8
  1372 00000B6F 66AB                    	stosw		; this is 1st interpolated sample (L)
  1373 00000B71 66AB                    	stosw		; this is 1st interpolated sample (R)
  1374 00000B73 88D8                    	mov	al, bl
  1375 00000B75 00D0                    	add	al, dl
  1376 00000B77 D0D8                    	rcr	al, 1
  1377 00000B79 2C80                    	sub	al, 80h
  1378 00000B7B 66C1E008                	shl	ax, 8
  1379 00000B7F 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1380 00000B81 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1381 00000B83 88D0                    	mov	al, dl
  1382 00000B85 2C80                    	sub	al, 80h
  1383 00000B87 66C1E008                	shl	ax, 8
  1384 00000B8B 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1385 00000B8D 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1386                                  	;mov	al, [next_val]
  1387 00000B8F 88F8                    	mov	al, bh
  1388 00000B91 00D0                    	add	al, dl
  1389 00000B93 D0D8                    	rcr	al, 1
  1390 00000B95 88C3                    	mov	bl, al	; this is temporary interpolation value
  1391 00000B97 00D0                    	add	al, dl
  1392 00000B99 D0D8                    	rcr	al, 1
  1393 00000B9B 2C80                    	sub	al, 80h
  1394 00000B9D 66C1E008                	shl	ax, 8
  1395 00000BA1 66AB                    	stosw		; this is 4th interpolated sample (L)
  1396 00000BA3 66AB                    	stosw		; this is 4th interpolated sample (R)
  1397                                  	;mov	al, [next_val]
  1398 00000BA5 88F8                    	mov	al, bh
  1399 00000BA7 00D8                    	add	al, bl
  1400 00000BA9 D0D8                    	rcr	al, 1
  1401 00000BAB 2C80                    	sub	al, 80h
  1402 00000BAD 66C1E008                	shl	ax, 8
  1403 00000BB1 66AB                    	stosw		; this is 5th interpolated sample (L)
  1404 00000BB3 66AB                    	stosw		; this is 5th interpolated sample (R)
  1405                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1406 00000BB5 09C9                    	or	ecx, ecx
  1407 00000BB7 7581                    	jnz	short lff8m_1
  1408                                  
  1409                                  	; --------------
  1410                                  
  1411                                  lff8s_3:
  1412                                  lff8m_3:
  1413                                  lff8s2_3:
  1414                                  lff8m2_3:
  1415                                  lff16s_3:
  1416                                  lff16m_3:
  1417                                  lff16s2_3:
  1418                                  lff16m2_3:
  1419                                  lff24_3:
  1420                                  lff32_3:
  1421                                  lff44_3:
  1422                                  lff22_3:
  1423                                  lff11_3:
  1424                                  lff12_3:	; 02/02/2025
  1425                                  	; 08/12/2024 (BugFix)
  1426                                  	; 01/06/2024 (BugFix)
  1427 00000BB9 8B0D[22040000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1428                                  	;shl	ecx, 1	; byte count ; Bug !
  1429                                  	; 08/12/2024
  1430 00000BBF 81C1[00300000]          	add	ecx, audio_buffer
  1431 00000BC5 29F9                    	sub	ecx, edi
  1432 00000BC7 7607                    	jna	short lff8m_4
  1433                                  	;inc	ecx
  1434 00000BC9 C1E902                  	shr	ecx, 2
  1435 00000BCC 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros
  1436 00000BCE F3AB                    	rep	stosd
  1437                                  lff8m_4:
  1438                                  	; 01/06/2024 (BugFix)
  1439                                  	; cf=1 ; Bug !
  1440                                  	; 08/12/2024
  1441                                  	;clc
  1442 00000BD0 C3                      	retn
  1443                                  
  1444                                  lff8_eof:
  1445                                  lff16_eof:
  1446                                  lff24_eof:
  1447                                  lff32_eof:
  1448                                  lff44_eof:
  1449                                  lff22_eof:
  1450                                  lff11_eof:
  1451                                  lff12_eof:	; 02/02/2025
  1452                                  	; 15/11/2023
  1453 00000BD1 C605[C8250000]01        	mov	byte [flags], ENDOFFILE
  1454 00000BD8 EBDF                    	jmp	short lff8m_3
  1455                                  
  1456                                  lff8s_5:
  1457                                  lff8m_5:
  1458                                  lff8s2_5:
  1459                                  lff8m2_5:
  1460                                  lff16s_5:
  1461                                  lff16m_5:
  1462                                  lff16s2_5:
  1463                                  lff16m2_5:
  1464                                  lff24_5:
  1465                                  lff32_5:
  1466                                  lff44_5:
  1467                                  lff22_5:
  1468                                  lff11_5:
  1469                                  lff12_5:	; 02/02/2025
  1470 00000BDA B021                    	mov	al, '!'  ; error
  1471 00000BDC E84AFBFFFF              	call	tL0
  1472                                  	
  1473                                  	;jmp	short lff8m_3
  1474                                  	; 15/11/2023
  1475 00000BE1 EBEE                    	jmp	lff8_eof
  1476                                  
  1477                                  	; --------------
  1478                                  
  1479                                  load_8khz_stereo_8_bit:
  1480                                  	; 02/02/2025
  1481                                  	; 15/11/2023
  1482                                  	; 14/11/2023
  1483                                  	; 13/11/2023
  1484 00000BE3 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1485                                  					; last of the file?
  1486 00000BEA 7402                    	jz	short lff8s_0		; no
  1487 00000BEC F9                      	stc
  1488 00000BED C3                      	retn
  1489                                  
  1490                                  lff8s_0:
  1491 00000BEE BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1492                                          ;mov	edx, [loadsize]
  1493                                  
  1494                                  	; esi = buffer address
  1495                                  	;; edx = buffer size
  1496                                  
  1497                                  	; load file into memory
  1498                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000BF3 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000BF9 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000BFB 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000C01 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000C06 CD40                <1>  int 40h
  1499 00000C08 72D0                    	jc	short lff8s_5 ; error !
  1500                                  
  1501 00000C0A BF[00300000]            	mov	edi, audio_buffer
  1502                                  	
  1503 00000C0F D1E8                    	shr	eax, 1
  1504 00000C11 74BE                    	jz	short lff8_eof
  1505                                  
  1506 00000C13 89C1                    	mov	ecx, eax	; word count
  1507                                  lff8s_1:
  1508 00000C15 AC                      	lodsb
  1509 00000C16 A2[78220000]            	mov	[previous_val_l], al
  1510 00000C1B 2C80                    	sub	al, 80h
  1511 00000C1D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1512 00000C21 66AB                    	stosw		; original sample (L)
  1513 00000C23 AC                      	lodsb
  1514 00000C24 A2[7A220000]            	mov	[previous_val_r], al
  1515 00000C29 2C80                    	sub	al, 80h
  1516 00000C2B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1517 00000C2F 66AB                    	stosw		; original sample (R)
  1518                                  
  1519                                  	;xor	eax, eax
  1520                                  	; 02/02/2025
  1521 00000C31 668B06                  	mov	ax, [esi]
  1522 00000C34 49                      	dec	ecx
  1523 00000C35 7504                    	jnz	short lff8s_2
  1524                                  		; convert 8 bit sample to 16 bit sample
  1525 00000C37 66B88080                	mov	ax, 8080h
  1526                                  lff8s_2:
  1527 00000C3B A2[7C220000]            	mov	[next_val_l], al
  1528 00000C40 8825[7E220000]          	mov	[next_val_r], ah
  1529 00000C46 8A25[78220000]          	mov	ah, [previous_val_l]
  1530 00000C4C 00E0                    	add	al, ah
  1531 00000C4E D0D8                    	rcr	al, 1
  1532 00000C50 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1533 00000C52 00E0                    	add	al, ah
  1534 00000C54 D0D8                    	rcr	al, 1	
  1535 00000C56 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1536 00000C58 00E0                    	add	al, ah
  1537 00000C5A D0D8                    	rcr	al, 1
  1538 00000C5C 2C80                    	sub	al, 80h
  1539 00000C5E 66C1E008                	shl	ax, 8
  1540 00000C62 66AB                    	stosw		; this is 1st interpolated sample (L)
  1541 00000C64 A0[7E220000]            	mov	al, [next_val_r]
  1542 00000C69 8A25[7A220000]          	mov	ah, [previous_val_r]
  1543 00000C6F 00E0                    	add	al, ah
  1544 00000C71 D0D8                    	rcr	al, 1
  1545 00000C73 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1546 00000C75 00E0                    	add	al, ah
  1547 00000C77 D0D8                    	rcr	al, 1
  1548 00000C79 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1549 00000C7B 00E0                    	add	al, ah
  1550 00000C7D D0D8                    	rcr	al, 1
  1551 00000C7F 2C80                    	sub	al, 80h
  1552 00000C81 66C1E008                	shl	ax, 8
  1553 00000C85 66AB                    	stosw		; this is 1st interpolated sample (R)
  1554 00000C87 88D8                    	mov	al, bl
  1555 00000C89 00D0                    	add	al, dl
  1556 00000C8B D0D8                    	rcr	al, 1
  1557 00000C8D 2C80                    	sub	al, 80h
  1558 00000C8F 66C1E008                	shl	ax, 8
  1559 00000C93 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1560 00000C95 88F8                    	mov	al, bh
  1561 00000C97 00F0                    	add	al, dh
  1562 00000C99 D0D8                    	rcr	al, 1
  1563 00000C9B 2C80                    	sub	al, 80h
  1564 00000C9D 66C1E008                	shl	ax, 8
  1565 00000CA1 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1566 00000CA3 88D0                    	mov	al, dl
  1567 00000CA5 2C80                    	sub	al, 80h
  1568 00000CA7 66C1E008                	shl	ax, 8
  1569 00000CAB 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1570 00000CAD 88F0                    	mov	al, dh
  1571 00000CAF 2C80                    	sub	al, 80h
  1572 00000CB1 66C1E008                	shl	ax, 8
  1573 00000CB5 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1574 00000CB7 A0[7C220000]            	mov	al, [next_val_l]
  1575 00000CBC 00D0                    	add	al, dl
  1576 00000CBE D0D8                    	rcr	al, 1
  1577 00000CC0 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1578 00000CC2 00D0                    	add	al, dl
  1579 00000CC4 D0D8                    	rcr	al, 1
  1580 00000CC6 2C80                    	sub	al, 80h
  1581 00000CC8 66C1E008                	shl	ax, 8
  1582 00000CCC 66AB                    	stosw		; this is 4th interpolated sample (L)
  1583 00000CCE A0[7E220000]            	mov	al, [next_val_r]
  1584 00000CD3 00F0                    	add	al, dh
  1585 00000CD5 D0D8                    	rcr	al, 1
  1586 00000CD7 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1587 00000CD9 00F0                    	add	al, dh
  1588 00000CDB D0D8                    	rcr	al, 1
  1589 00000CDD 2C80                    	sub	al, 80h
  1590 00000CDF 66C1E008                	shl	ax, 8
  1591 00000CE3 66AB                    	stosw		; this is 4th interpolated sample (R)
  1592 00000CE5 A0[7C220000]            	mov	al, [next_val_l]
  1593 00000CEA 00D8                    	add	al, bl
  1594 00000CEC D0D8                    	rcr	al, 1
  1595 00000CEE 2C80                    	sub	al, 80h
  1596 00000CF0 66C1E008                	shl	ax, 8
  1597 00000CF4 66AB                    	stosw		; this is 5th interpolated sample (L)
  1598 00000CF6 A0[7E220000]            	mov	al, [next_val_r]
  1599 00000CFB 00F8                    	add	al, bh
  1600 00000CFD D0D8                    	rcr	al, 1
  1601 00000CFF 2C80                    	sub	al, 80h
  1602 00000D01 66C1E008                	shl	ax, 8
  1603 00000D05 66AB                    	stosw		; this is 5th interpolated sample (R)
  1604                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1605 00000D07 E305                    	jecxz	lff8s_6
  1606 00000D09 E907FFFFFF              	jmp	lff8s_1
  1607                                  lff8s_6:
  1608 00000D0E E9A6FEFFFF              	jmp	lff8s_3
  1609                                  
  1610                                  load_8khz_mono_16_bit:
  1611                                  	; 02/02/2025
  1612                                  	; 13/11/2023
  1613 00000D13 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1614                                  					; last of the file?
  1615 00000D1A 7402                    	jz	short lff8m2_0		; no
  1616 00000D1C F9                      	stc
  1617 00000D1D C3                      	retn
  1618                                  
  1619                                  lff8m2_0:
  1620 00000D1E BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1621                                          ;mov	edx, [loadsize]
  1622                                  
  1623                                  	; esi = buffer address
  1624                                  	;; edx = buffer size
  1625                                  
  1626                                  	; load file into memory
  1627                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000D23 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000D29 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000D2B 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000D31 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000D36 CD40                <1>  int 40h
  1628 00000D38 0F82A0000000            	jc	lff8m2_7 ; error !
  1629                                  
  1630 00000D3E BF[00300000]            	mov	edi, audio_buffer
  1631                                  	
  1632 00000D43 D1E8                    	shr	eax, 1
  1633 00000D45 7505                    	jnz	short lff8m2_8
  1634 00000D47 E985FEFFFF              	jmp	lff8_eof
  1635                                  
  1636                                  lff8m2_8:
  1637 00000D4C 89C1                    	mov	ecx, eax	; word count
  1638                                  lff8m2_1:
  1639 00000D4E 66AD                    	lodsw
  1640 00000D50 66AB                    	stosw		; original sample (left channel)
  1641 00000D52 66AB                    	stosw		; original sample (right channel)
  1642 00000D54 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1643 00000D57 66A3[78220000]          	mov	[previous_val], ax
  1644                                  	; 02/02/2025
  1645 00000D5D 668B06                  	mov	ax, [esi]
  1646 00000D60 49                      	dec	ecx
  1647 00000D61 7502                    	jnz	short lff8m2_2
  1648 00000D63 31C0                    	xor	eax, eax
  1649                                  lff8m2_2:
  1650 00000D65 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1651 00000D68 89C5                    	mov	ebp, eax ; [next_val]
  1652 00000D6A 660305[78220000]        	add	ax, [previous_val]
  1653 00000D71 66D1D8                  	rcr	ax, 1
  1654 00000D74 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1655 00000D76 660305[78220000]        	add	ax, [previous_val]
  1656 00000D7D 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1657 00000D80 89C3                    	mov	ebx, eax 		
  1658 00000D82 660305[78220000]        	add	ax, [previous_val]
  1659 00000D89 66D1D8                  	rcr	ax, 1
  1660 00000D8C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1661 00000D8F 66AB                    	stosw		; this is 1st interpolated sample (L)
  1662 00000D91 66AB                    	stosw		; this is 1st interpolated sample (R)
  1663 00000D93 89D8                    	mov	eax, ebx
  1664 00000D95 6601D0                  	add	ax, dx
  1665 00000D98 66D1D8                  	rcr	ax, 1
  1666 00000D9B 80EC80                  	sub	ah, 80h
  1667 00000D9E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1668 00000DA0 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1669 00000DA2 89D0                    	mov	eax, edx
  1670 00000DA4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1671 00000DA7 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1672 00000DA9 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1673 00000DAB 89E8                    	mov	eax, ebp
  1674 00000DAD 6601D0                  	add	ax, dx
  1675 00000DB0 66D1D8                  	rcr	ax, 1
  1676 00000DB3 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1677 00000DB5 6601D0                  	add	ax, dx
  1678 00000DB8 66D1D8                  	rcr	ax, 1
  1679 00000DBB 80EC80                  	sub	ah, 80h
  1680 00000DBE 66AB                    	stosw		; this is 4th interpolated sample (L)
  1681 00000DC0 66AB                    	stosw		; this is 4th interpolated sample (R)
  1682 00000DC2 89E8                    	mov	eax, ebp
  1683 00000DC4 6601D8                  	add	ax, bx
  1684 00000DC7 66D1D8                  	rcr	ax, 1
  1685 00000DCA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1686 00000DCD 66AB                    	stosw		; this is 5th interpolated sample (L)
  1687 00000DCF 66AB                    	stosw		; this is 5th interpolated sample (R)
  1688                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1689 00000DD1 09C9                    	or	ecx, ecx
  1690 00000DD3 0F8575FFFFFF            	jnz	lff8m2_1
  1691 00000DD9 E9DBFDFFFF              	jmp	lff8m2_3
  1692                                  
  1693                                  lff8m2_7:
  1694                                  lff8s2_7:
  1695 00000DDE E9F7FDFFFF              	jmp	lff8m2_5  ; error
  1696                                  
  1697                                  load_8khz_stereo_16_bit:
  1698                                  	; 02/02/2025
  1699                                  	; 16/11/2023
  1700                                  	; 15/11/2023
  1701                                  	; 13/11/2023
  1702 00000DE3 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1703                                  					; last of the file?
  1704 00000DEA 7402                    	jz	short lff8s2_0		; no
  1705 00000DEC F9                      	stc
  1706 00000DED C3                      	retn
  1707                                  
  1708                                  lff8s2_0:
  1709 00000DEE BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1710                                          ;mov	edx, [loadsize]
  1711                                  
  1712                                  	; esi = buffer address
  1713                                  	;; edx = buffer size
  1714                                  
  1715                                  	; load file into memory
  1716                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000DF3 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000DF9 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000DFB 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000E01 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000E06 CD40                <1>  int 40h
  1717 00000E08 72D4                    	jc	short lff8s2_7 ; error !
  1718                                  
  1719 00000E0A BF[00300000]            	mov	edi, audio_buffer
  1720                                  	
  1721 00000E0F C1E802                  	shr	eax, 2
  1722 00000E12 7505                    	jnz	short lff8s2_8
  1723 00000E14 E9B8FDFFFF              	jmp	lff8_eof
  1724                                  
  1725                                  lff8s2_8:
  1726 00000E19 89C1                    	mov	ecx, eax ; dword count
  1727                                  lff8s2_1:
  1728 00000E1B 66AD                    	lodsw
  1729 00000E1D 66AB                    	stosw		; original sample (L)
  1730                                  	; 15/11/2023
  1731 00000E1F 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1732 00000E22 66A3[78220000]          	mov	[previous_val_l], ax
  1733 00000E28 66AD                    	lodsw
  1734 00000E2A 66AB                    	stosw		; original sample (R)
  1735 00000E2C 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1736 00000E2F 66A3[7A220000]          	mov	[previous_val_r], ax
  1737                                  	; 02/02/2025
  1738 00000E35 668B06                  	mov	ax, [esi]
  1739 00000E38 668B5602                	mov	dx, [esi+2]
  1740                                  	; 16/11/2023
  1741 00000E3C 49                      	dec	ecx
  1742 00000E3D 7504                    	jnz	short lff8s2_2
  1743 00000E3F 31D2                    	xor	edx, edx
  1744 00000E41 31C0                    	xor	eax, eax
  1745                                  lff8s2_2:
  1746 00000E43 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1747 00000E46 66A3[7C220000]          	mov	[next_val_l], ax
  1748 00000E4C 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1749 00000E4F 668915[7E220000]        	mov	[next_val_r], dx
  1750 00000E56 660305[78220000]        	add	ax, [previous_val_l]
  1751 00000E5D 66D1D8                  	rcr	ax, 1
  1752 00000E60 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1753 00000E62 660305[78220000]        	add	ax, [previous_val_l]
  1754 00000E69 66D1D8                  	rcr	ax, 1	
  1755 00000E6C 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1756 00000E6E 660305[78220000]        	add	ax, [previous_val_l]
  1757 00000E75 66D1D8                  	rcr	ax, 1
  1758 00000E78 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1759 00000E7B 66AB                    	stosw		; this is 1st interpolated sample (L)
  1760 00000E7D 66A1[7E220000]          	mov	ax, [next_val_r]
  1761 00000E83 660305[7A220000]        	add	ax, [previous_val_r]
  1762 00000E8A 66D1D8                  	rcr	ax, 1
  1763 00000E8D 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1764 00000E8F 660305[7A220000]        	add	ax, [previous_val_r]
  1765 00000E96 66D1D8                  	rcr	ax, 1
  1766 00000E99 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1767 00000E9A 660305[7A220000]        	add	ax, [previous_val_r]
  1768 00000EA1 66D1D8                  	rcr	ax, 1
  1769 00000EA4 80EC80                  	sub	ah, 80h
  1770 00000EA7 66AB                    	stosw		; this is 1st interpolated sample (R)
  1771 00000EA9 89D8                    	mov	eax, ebx
  1772 00000EAB 6601D0                  	add	ax, dx
  1773 00000EAE 66D1D8                  	rcr	ax, 1
  1774 00000EB1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1775 00000EB4 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1776 00000EB6 58                      	pop	eax ; *
  1777 00000EB7 6601E8                  	add	ax, bp
  1778 00000EBA 66D1D8                  	rcr	ax, 1
  1779 00000EBD 80EC80                  	sub	ah, 80h
  1780 00000EC0 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1781 00000EC2 89D0                    	mov	eax, edx
  1782 00000EC4 80EC80                  	sub	ah, 80h
  1783 00000EC7 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1784 00000EC9 89E8                    	mov	eax, ebp
  1785 00000ECB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1786 00000ECE 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1787 00000ED0 66A1[7C220000]          	mov	ax, [next_val_l]
  1788 00000ED6 6601D0                  	add	ax, dx
  1789 00000ED9 66D1D8                  	rcr	ax, 1
  1790 00000EDC 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1791 00000EDE 6601D0                  	add	ax, dx
  1792 00000EE1 66D1D8                  	rcr	ax, 1
  1793 00000EE4 80EC80                  	sub	ah, 80h
  1794 00000EE7 66AB                    	stosw		; this is 4th interpolated sample (L)
  1795 00000EE9 66A1[7E220000]          	mov	ax, [next_val_r]
  1796 00000EEF 6601E8                  	add	ax, bp
  1797 00000EF2 66D1D8                  	rcr	ax, 1
  1798 00000EF5 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1799 00000EF6 6601E8                  	add	ax, bp
  1800 00000EF9 66D1D8                  	rcr	ax, 1
  1801 00000EFC 80EC80                  	sub	ah, 80h
  1802 00000EFF 66AB                    	stosw		; this is 4th interpolated sample (R)
  1803 00000F01 66A1[7C220000]          	mov	ax, [next_val_l]
  1804 00000F07 6601D8                  	add	ax, bx
  1805 00000F0A 66D1D8                  	rcr	ax, 1
  1806 00000F0D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1807 00000F10 66AB                    	stosw		; this is 5th interpolated sample (L)
  1808 00000F12 58                      	pop	eax ; **
  1809 00000F13 660305[7E220000]        	add	ax, [next_val_r]
  1810 00000F1A 66D1D8                  	rcr	ax, 1
  1811 00000F1D 80EC80                  	sub	ah, 80h
  1812 00000F20 66AB                    	stosw		; this is 5th interpolated sample (R)
  1813                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1814 00000F22 E305                    	jecxz	lff8_s2_9
  1815 00000F24 E9F2FEFFFF              	jmp	lff8s2_1
  1816                                  lff8_s2_9:
  1817 00000F29 E98BFCFFFF              	jmp	lff8s2_3
  1818                                  
  1819                                  ; .....................
  1820                                  
  1821                                  load_16khz_mono_8_bit:
  1822                                  	; 02/02/2025
  1823                                  	; 14/11/2023
  1824                                  	; 13/11/2023
  1825 00000F2E F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1826                                  					; last of the file?
  1827 00000F35 7402                    	jz	short lff16m_0		; no
  1828 00000F37 F9                      	stc
  1829 00000F38 C3                      	retn
  1830                                  
  1831                                  lff16m_0:
  1832 00000F39 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1833                                          ;mov	edx, [loadsize]
  1834                                  
  1835                                  	; esi = buffer address
  1836                                  	;; edx = buffer size
  1837                                  
  1838                                  	; load file into memory
  1839                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000F3E 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000F44 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000F46 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000F4C B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000F51 CD40                <1>  int 40h
  1840 00000F53 7253                    	jc	short lff16m_7 ; error !
  1841                                  
  1842 00000F55 BF[00300000]            	mov	edi, audio_buffer
  1843                                  	
  1844 00000F5A 21C0                    	and	eax, eax
  1845 00000F5C 7505                    	jnz	short lff16m_8
  1846 00000F5E E96EFCFFFF              	jmp	lff16_eof
  1847                                  
  1848                                  lff16m_8:
  1849 00000F63 89C1                    	mov	ecx, eax		; byte count
  1850                                  lff16m_1:
  1851 00000F65 AC                      	lodsb
  1852                                  	;mov	[previous_val], al
  1853 00000F66 88C3                    	mov	bl, al
  1854 00000F68 2C80                    	sub	al, 80h
  1855 00000F6A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1856 00000F6E 66AB                    	stosw		; original sample (left channel)
  1857 00000F70 66AB                    	stosw		; original sample (right channel)
  1858                                  	;xor	eax, eax
  1859                                  	; 02/02/2025
  1860 00000F72 8A06                    	mov	al, [esi]
  1861 00000F74 49                      	dec	ecx
  1862 00000F75 7502                    	jnz	short lff16m_2
  1863                                  	; 14/11/2023
  1864 00000F77 B080                    	mov	al, 80h
  1865                                  lff16m_2:
  1866                                  	;mov	[next_val], al
  1867 00000F79 88C7                    	mov	bh, al
  1868                                  	;add	al, [previous_val]
  1869 00000F7B 00D8                    	add	al, bl
  1870 00000F7D D0D8                    	rcr	al, 1
  1871 00000F7F 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1872                                  	;add	al, [previous_val]
  1873 00000F81 00D8                    	add	al, bl
  1874 00000F83 D0D8                    	rcr	al, 1
  1875 00000F85 2C80                    	sub	al, 80h
  1876 00000F87 66C1E008                	shl	ax, 8
  1877 00000F8B 66AB                    	stosw		; this is 1st interpolated sample (L)
  1878 00000F8D 66AB                    	stosw		; this is 1st interpolated sample (R)
  1879                                  	;mov	al, [next_val]
  1880 00000F8F 88F8                    	mov	al, bh
  1881 00000F91 00D0                    	add	al, dl
  1882 00000F93 D0D8                    	rcr	al, 1
  1883 00000F95 2C80                    	sub	al, 80h
  1884 00000F97 66C1E008                	shl	ax, 8
  1885 00000F9B 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1886 00000F9D 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1887                                  	
  1888                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1889 00000F9F 09C9                    	or	ecx, ecx
  1890 00000FA1 75C2                    	jnz	short lff16m_1
  1891 00000FA3 E911FCFFFF              	jmp	lff16m_3
  1892                                  
  1893                                  lff16m_7:
  1894                                  lff16s_7:
  1895 00000FA8 E92DFCFFFF              	jmp	lff16m_5  ; error
  1896                                  
  1897                                  load_16khz_stereo_8_bit:
  1898                                  	; 02/02/2025
  1899                                  	; 14/11/2023
  1900                                  	; 13/11/2023
  1901 00000FAD F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1902                                  					; last of the file?
  1903 00000FB4 7402                    	jz	short lff16s_0		; no
  1904 00000FB6 F9                      	stc
  1905 00000FB7 C3                      	retn
  1906                                  
  1907                                  lff16s_0:
  1908 00000FB8 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1909                                          ;mov	edx, [loadsize]
  1910                                  
  1911                                  	; esi = buffer address
  1912                                  	;; edx = buffer size
  1913                                  
  1914                                  	; load file into memory
  1915                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00000FBD 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00000FC3 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00000FC5 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00000FCB B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00000FD0 CD40                <1>  int 40h
  1916 00000FD2 72D4                    	jc	short lff16s_7 ; error !
  1917                                  
  1918 00000FD4 BF[00300000]            	mov	edi, audio_buffer
  1919                                  	
  1920 00000FD9 D1E8                    	shr	eax, 1
  1921 00000FDB 7505                    	jnz	short lff16s_8
  1922 00000FDD E9EFFBFFFF              	jmp	lff16_eof
  1923                                  
  1924                                  lff16s_8:
  1925 00000FE2 89C1                    	mov	ecx, eax	; word count
  1926                                  lff16s_1:
  1927 00000FE4 AC                      	lodsb
  1928 00000FE5 A2[78220000]            	mov	[previous_val_l], al
  1929 00000FEA 2C80                    	sub	al, 80h
  1930 00000FEC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1931 00000FF0 66AB                    	stosw		; original sample (L)
  1932 00000FF2 AC                      	lodsb
  1933 00000FF3 A2[7A220000]            	mov	[previous_val_r], al
  1934 00000FF8 2C80                    	sub	al, 80h
  1935 00000FFA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1936 00000FFE 66AB                    	stosw		; original sample (R)
  1937                                  
  1938                                  	;xor	eax, eax
  1939                                  	; 02/02/2025
  1940 00001000 668B06                  	mov	ax, [esi]
  1941 00001003 49                      	dec	ecx
  1942 00001004 7504                    	jnz	short lff16s_2
  1943                                  		; convert 8 bit sample to 16 bit sample
  1944                                  	; 14/11/2023
  1945 00001006 66B88080                	mov	ax, 8080h
  1946                                  lff16s_2:
  1947                                  	;mov	[next_val_l], al
  1948                                  	;mov	[next_val_r], ah
  1949 0000100A 89C3                    	mov	ebx, eax
  1950 0000100C 0205[78220000]          	add	al, [previous_val_l]
  1951 00001012 D0D8                    	rcr	al, 1
  1952 00001014 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  1953 00001016 0205[78220000]          	add	al, [previous_val_l]
  1954 0000101C D0D8                    	rcr	al, 1
  1955 0000101E 2C80                    	sub	al, 80h
  1956 00001020 66C1E008                	shl	ax, 8
  1957 00001024 66AB                    	stosw		; this is 1st interpolated sample (L)
  1958 00001026 88F8                    	mov	al, bh	; [next_val_r]
  1959 00001028 0205[7A220000]          	add	al, [previous_val_r]
  1960 0000102E D0D8                    	rcr	al, 1
  1961 00001030 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  1962 00001032 0205[7A220000]          	add	al, [previous_val_r]
  1963 00001038 D0D8                    	rcr	al, 1
  1964 0000103A 2C80                    	sub	al, 80h
  1965 0000103C 66C1E008                	shl	ax, 8
  1966 00001040 66AB                    	stosw		; this is 1st interpolated sample (R)
  1967 00001042 88D0                    	mov	al, dl
  1968 00001044 00D8                    	add	al, bl	; [next_val_l]
  1969 00001046 D0D8                    	rcr	al, 1
  1970 00001048 2C80                    	sub	al, 80h
  1971 0000104A 66C1E008                	shl	ax, 8
  1972 0000104E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1973 00001050 88F0                    	mov	al, dh
  1974 00001052 00F8                    	add	al, bh	; [next_val_r]
  1975 00001054 D0D8                    	rcr	al, 1
  1976 00001056 2C80                    	sub	al, 80h
  1977 00001058 66C1E008                	shl	ax, 8
  1978 0000105C 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1979                                  	
  1980                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1981 0000105E 09C9                    	or	ecx, ecx
  1982 00001060 7582                    	jnz	short lff16s_1
  1983 00001062 E952FBFFFF              	jmp	lff16s_3
  1984                                  
  1985                                  load_16khz_mono_16_bit:
  1986                                  	; 02/02/2025
  1987                                  	; 15/11/2023
  1988                                  	; 13/11/2023
  1989 00001067 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1990                                  					; last of the file?
  1991 0000106E 7402                    	jz	short lff16m2_0		; no
  1992 00001070 F9                      	stc
  1993 00001071 C3                      	retn
  1994                                  
  1995                                  lff16m2_0:
  1996 00001072 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1997                                          ;mov	edx, [loadsize]
  1998                                  
  1999                                  	; esi = buffer address
  2000                                  	;; edx = buffer size
  2001                                  
  2002                                  	; load file into memory
  2003                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001077 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000107D 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000107F 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001085 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 0000108A CD40                <1>  int 40h
  2004 0000108C 7255                    	jc	short lff16m2_7 ; error !
  2005                                  
  2006 0000108E BF[00300000]            	mov	edi, audio_buffer
  2007                                  	
  2008 00001093 D1E8                    	shr	eax, 1
  2009 00001095 7505                    	jnz	short lff16m2_8
  2010 00001097 E935FBFFFF              	jmp	lff16_eof
  2011                                  
  2012                                  lff16m2_8:
  2013 0000109C 89C1                    	mov	ecx, eax  ; word count
  2014                                  lff16m2_1:
  2015 0000109E 66AD                    	lodsw
  2016 000010A0 66AB                    	stosw		; original sample (left channel)
  2017 000010A2 66AB                    	stosw		; original sample (right channel)
  2018 000010A4 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2019                                  	;mov	[previous_val], ax
  2020 000010A7 89C3                    	mov	ebx, eax
  2021                                  	; 02/02/2025
  2022 000010A9 668B06                  	mov	ax, [esi]
  2023 000010AC 49                      	dec	ecx
  2024 000010AD 7502                    	jnz	short lff16m2_2
  2025 000010AF 31C0                    	xor	eax, eax
  2026                                  lff16m2_2:
  2027 000010B1 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2028 000010B4 89C5                    	mov	ebp, eax ; [next_val]
  2029                                  	;add	ax, [previous_val]
  2030 000010B6 6601D8                  	add	ax, bx
  2031 000010B9 66D1D8                  	rcr	ax, 1
  2032 000010BC 89C2                    	mov	edx, eax ; this is temporary interpolation value
  2033                                  	;add	ax, [previous_val]
  2034 000010BE 6601D8                  	add	ax, bx
  2035 000010C1 66D1D8                  	rcr	ax, 1
  2036 000010C4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2037 000010C7 66AB                    	stosw		; this is 1st interpolated sample (L)
  2038 000010C9 66AB                    	stosw		; this is 1st interpolated sample (R)
  2039 000010CB 89E8                    	mov	eax, ebp 
  2040 000010CD 6601D0                  	add	ax, dx
  2041 000010D0 66D1D8                  	rcr	ax, 1
  2042 000010D3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2043 000010D6 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2044 000010D8 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2045                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2046 000010DA 09C9                    	or	ecx, ecx
  2047 000010DC 75C0                    	jnz	short lff16m2_1
  2048 000010DE E9D6FAFFFF              	jmp	lff16m2_3
  2049                                  
  2050                                  lff16m2_7:
  2051                                  lff16s2_7:
  2052 000010E3 E9F2FAFFFF              	jmp	lff16m2_5  ; error
  2053                                  
  2054                                  load_16khz_stereo_16_bit:
  2055                                  	; 02/02/2025
  2056                                  	; 16/11/2023
  2057                                  	; 15/11/2023
  2058                                  	; 13/11/2023
  2059 000010E8 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2060                                  					; last of the file?
  2061 000010EF 7402                    	jz	short lff16s2_0		; no
  2062 000010F1 F9                      	stc
  2063 000010F2 C3                      	retn
  2064                                  
  2065                                  lff16s2_0:
  2066 000010F3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2067                                          ;mov	edx, [loadsize]
  2068                                  
  2069                                  	; esi = buffer address
  2070                                  	;; edx = buffer size
  2071                                  
  2072                                  	; load file into memory
  2073                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000010F8 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000010FE 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001100 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001106 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 0000110B CD40                <1>  int 40h
  2074 0000110D 72D4                    	jc	short lff16s2_7 ; error !
  2075                                  
  2076 0000110F BF[00300000]            	mov	edi, audio_buffer
  2077                                  	
  2078 00001114 C1E802                  	shr	eax, 2
  2079 00001117 7505                    	jnz	short lff16s2_8
  2080 00001119 E9B3FAFFFF              	jmp	lff16_eof
  2081                                  
  2082                                  lff16s2_8:
  2083 0000111E 89C1                    	mov	ecx, eax  ; dword count
  2084                                  lff16s2_1:
  2085 00001120 66AD                    	lodsw
  2086 00001122 66AB                    	stosw		; original sample (L)
  2087 00001124 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2088 00001127 66A3[78220000]          	mov	[previous_val_l], ax
  2089 0000112D 66AD                    	lodsw
  2090 0000112F 66AB                    	stosw		; original sample (R)
  2091 00001131 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2092 00001134 66A3[7A220000]          	mov	[previous_val_r], ax
  2093                                  	; 02/02/2025
  2094 0000113A 668B06                  	mov	ax, [esi]
  2095 0000113D 668B5602                	mov	dx, [esi+2]
  2096                                  	; 16/11/2023
  2097 00001141 49                      	dec	ecx
  2098 00001142 7504                    	jnz	short lff16s2_2
  2099 00001144 31D2                    	xor	edx, edx
  2100 00001146 31C0                    	xor	eax, eax
  2101                                  lff16s2_2:
  2102 00001148 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2103                                  	;mov	[next_val_l], ax
  2104 0000114B 89C5                    	mov	ebp, eax
  2105 0000114D 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2106 00001150 668915[7E220000]        	mov	[next_val_r], dx
  2107 00001157 660305[78220000]        	add	ax, [previous_val_l]
  2108 0000115E 66D1D8                  	rcr	ax, 1
  2109 00001161 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  2110 00001163 660305[78220000]        	add	ax, [previous_val_l]
  2111 0000116A 66D1D8                  	rcr	ax, 1
  2112 0000116D 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2113 00001170 66AB                    	stosw		; this is 1st interpolated sample (L)
  2114 00001172 66A1[7E220000]          	mov	ax, [next_val_r]
  2115 00001178 660305[7A220000]        	add	ax, [previous_val_r]
  2116 0000117F 66D1D8                  	rcr	ax, 1
  2117 00001182 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  2118 00001184 660305[7A220000]        	add	ax, [previous_val_r]
  2119 0000118B 66D1D8                  	rcr	ax, 1
  2120 0000118E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2121 00001191 66AB                    	stosw		; this is 1st interpolated sample (R)
  2122                                  	;mov	ax, [next_val_l]
  2123 00001193 89E8                    	mov	eax, ebp
  2124 00001195 6601D0                  	add	ax, dx
  2125 00001198 66D1D8                  	rcr	ax, 1
  2126 0000119B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2127 0000119E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2128 000011A0 66A1[7E220000]          	mov	ax, [next_val_r]
  2129 000011A6 6601D8                  	add	ax, bx
  2130 000011A9 66D1D8                  	rcr	ax, 1
  2131 000011AC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2132 000011AF 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2133                                  	
  2134                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2135 000011B1 09C9                    	or	ecx, ecx
  2136 000011B3 0F8567FFFFFF            	jnz	lff16s2_1
  2137 000011B9 E9FBF9FFFF              	jmp	lff16s2_3
  2138                                  
  2139                                  ; .....................
  2140                                  
  2141                                  load_24khz_mono_8_bit:
  2142                                  	; 02/02/2025
  2143                                  	; 15/11/2023
  2144 000011BE F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2145                                  					; last of the file?
  2146 000011C5 7402                    	jz	short lff24m_0		; no
  2147 000011C7 F9                      	stc
  2148 000011C8 C3                      	retn
  2149                                  
  2150                                  lff24m_0:
  2151 000011C9 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2152                                          ;mov	edx, [loadsize]
  2153                                  
  2154                                  	; esi = buffer address
  2155                                  	;; edx = buffer size
  2156                                  
  2157                                  	; load file into memory
  2158                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000011CE 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000011D4 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000011D6 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000011DC B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000011E1 CD40                <1>  int 40h
  2159 000011E3 723B                    	jc	short lff24m_7 ; error !
  2160                                  
  2161 000011E5 BF[00300000]            	mov	edi, audio_buffer
  2162                                  	
  2163 000011EA 21C0                    	and	eax, eax
  2164 000011EC 7505                    	jnz	short lff24m_8
  2165 000011EE E9DEF9FFFF              	jmp	lff24_eof
  2166                                  
  2167                                  lff24m_8:
  2168 000011F3 89C1                    	mov	ecx, eax	; byte count
  2169                                  lff24m_1:
  2170 000011F5 AC                      	lodsb
  2171                                  	;mov	[previous_val], al
  2172 000011F6 88C3                    	mov	bl, al
  2173 000011F8 2C80                    	sub	al, 80h
  2174 000011FA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2175 000011FE 66AB                    	stosw		; original sample (left channel)
  2176 00001200 66AB                    	stosw		; original sample (right channel)
  2177                                  	;xor	eax, eax
  2178                                  	; 02/02/2025
  2179 00001202 8A06                    	mov	al, [esi]
  2180 00001204 49                      	dec	ecx
  2181 00001205 7502                    	jnz	short lff24m_2
  2182 00001207 B080                    	mov	al, 80h
  2183                                  lff24m_2:
  2184                                  	;;mov	[next_val], al
  2185                                  	;mov	bh, al
  2186                                  	;add	al, [previous_val]
  2187 00001209 00D8                    	add	al, bl
  2188 0000120B D0D8                    	rcr	al, 1
  2189 0000120D 2C80                    	sub	al, 80h
  2190 0000120F 66C1E008                	shl	ax, 8
  2191 00001213 66AB                    	stosw		; this is interpolated sample (L)
  2192 00001215 66AB                    	stosw		; this is interpolated sample (R)
  2193                                  	
  2194                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2195 00001217 09C9                    	or	ecx, ecx
  2196 00001219 75DA                    	jnz	short lff24m_1
  2197 0000121B E999F9FFFF              	jmp	lff24_3
  2198                                  
  2199                                  lff24m_7:
  2200                                  lff24s_7:
  2201 00001220 E9B5F9FFFF              	jmp	lff24_5  ; error
  2202                                  
  2203                                  load_24khz_stereo_8_bit:
  2204                                  	; 02/02/2025
  2205                                  	; 15/11/2023
  2206 00001225 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2207                                  					; last of the file?
  2208 0000122C 7402                    	jz	short lff24s_0		; no
  2209 0000122E F9                      	stc
  2210 0000122F C3                      	retn
  2211                                  
  2212                                  lff24s_0:
  2213 00001230 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2214                                          ;mov	edx, [loadsize]
  2215                                  
  2216                                  	; esi = buffer address
  2217                                  	;; edx = buffer size
  2218                                  
  2219                                  	; load file into memory
  2220                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001235 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000123B 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000123D 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001243 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001248 CD40                <1>  int 40h
  2221 0000124A 72D4                    	jc	short lff24s_7 ; error !
  2222                                  
  2223 0000124C BF[00300000]            	mov	edi, audio_buffer
  2224                                  
  2225 00001251 D1E8                    	shr	eax, 1
  2226 00001253 7505                    	jnz	short lff24s_8
  2227 00001255 E977F9FFFF              	jmp	lff24_eof
  2228                                  
  2229                                  lff24s_8:
  2230 0000125A 89C1                    	mov	ecx, eax  ; word count
  2231                                  lff24s_1:
  2232 0000125C AC                      	lodsb
  2233 0000125D A2[78220000]            	mov	[previous_val_l], al
  2234 00001262 2C80                    	sub	al, 80h
  2235 00001264 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2236 00001268 66AB                    	stosw		; original sample (L)
  2237 0000126A AC                      	lodsb
  2238 0000126B A2[7A220000]            	mov	[previous_val_r], al
  2239 00001270 2C80                    	sub	al, 80h
  2240 00001272 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2241 00001276 66AB                    	stosw		; original sample (R)
  2242                                  
  2243                                  	;xor	eax, eax
  2244                                  	; 02/02/2025
  2245 00001278 668B06                  	mov	ax, [esi]
  2246 0000127B 49                      	dec	ecx
  2247 0000127C 7504                    	jnz	short lff24s_2
  2248                                  		; convert 8 bit sample to 16 bit sample
  2249 0000127E 66B88080                	mov	ax, 8080h
  2250                                  lff24s_2:
  2251                                  	;;mov	[next_val_l], al
  2252                                  	;;mov	[next_val_r], ah
  2253                                  	;mov	bx, ax
  2254 00001282 88E7                    	mov	bh, ah
  2255 00001284 0205[78220000]          	add	al, [previous_val_l]
  2256 0000128A D0D8                    	rcr	al, 1
  2257                                  	;mov	dl, al
  2258 0000128C 2C80                    	sub	al, 80h
  2259 0000128E 66C1E008                	shl	ax, 8
  2260 00001292 66AB                    	stosw		; this is interpolated sample (L)
  2261 00001294 88F8                    	mov	al, bh	; [next_val_r]
  2262 00001296 0205[7A220000]          	add	al, [previous_val_r]
  2263 0000129C D0D8                    	rcr	al, 1
  2264                                  	;mov	dh, al
  2265 0000129E 2C80                    	sub	al, 80h
  2266 000012A0 66C1E008                	shl	ax, 8
  2267 000012A4 66AB                    	stosw		; this is interpolated sample (R)
  2268                                  		
  2269                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2270 000012A6 09C9                    	or	ecx, ecx
  2271 000012A8 75B2                    	jnz	short lff24s_1
  2272 000012AA E90AF9FFFF              	jmp	lff24_3
  2273                                  
  2274                                  load_24khz_mono_16_bit:
  2275                                  	; 02/02/2025
  2276                                  	; 15/11/2023
  2277 000012AF F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2278                                  					; last of the file?
  2279 000012B6 7402                    	jz	short lff24m2_0		; no
  2280 000012B8 F9                      	stc
  2281 000012B9 C3                      	retn
  2282                                  
  2283                                  lff24m2_0:
  2284 000012BA BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2285                                          ;mov	edx, [loadsize]
  2286                                  
  2287                                  	; esi = buffer address
  2288                                  	;; edx = buffer size
  2289                                  
  2290                                  	; load file into memory
  2291                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000012BF 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000012C5 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000012C7 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000012CD B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000012D2 CD40                <1>  int 40h
  2292 000012D4 723A                    	jc	short lff24m2_7 ; error !
  2293                                  
  2294 000012D6 BF[00300000]            	mov	edi, audio_buffer
  2295                                  	
  2296 000012DB D1E8                    	shr	eax, 1
  2297 000012DD 7505                    	jnz	short lff24m2_8
  2298 000012DF E9EDF8FFFF              	jmp	lff24_eof
  2299                                  
  2300                                  lff24m2_8:
  2301 000012E4 89C1                    	mov	ecx, eax  ; word count
  2302                                  lff24m2_1:
  2303 000012E6 66AD                    	lodsw
  2304 000012E8 66AB                    	stosw		; original sample (left channel)
  2305 000012EA 66AB                    	stosw		; original sample (right channel)
  2306 000012EC 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2307                                  	;mov	[previous_val], ax
  2308                                  	;mov	ebx, eax
  2309                                  	; 02/02/2025
  2310 000012EF 668B1E                  	mov	bx, [esi]
  2311 000012F2 49                      	dec	ecx
  2312 000012F3 7502                    	jnz	short lff24m2_2
  2313                                  	;xor	eax, eax
  2314 000012F5 31DB                    	xor	ebx, ebx
  2315                                  lff24m2_2:
  2316                                  	; 02/02/2025
  2317 000012F7 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  2318                                  	;add	ah, 80h
  2319                                  	;mov	ebp, eax	; [next_val]
  2320                                  	;add	ax, [previous_val]
  2321                                  	; ax = [previous_val]
  2322                                  	; bx = [next_val]
  2323 000012FA 6601D8                  	add	ax, bx
  2324 000012FD 66D1D8                  	rcr	ax, 1
  2325 00001300 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2326 00001303 66AB                    	stosw		; this is interpolated sample (L)
  2327 00001305 66AB                    	stosw		; this is interpolated sample (R)
  2328                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2329 00001307 09C9                    	or	ecx, ecx
  2330 00001309 75DB                    	jnz	short lff24m2_1
  2331 0000130B E9A9F8FFFF              	jmp	lff24_3
  2332                                  
  2333                                  lff24m2_7:
  2334                                  lff24s2_7:
  2335 00001310 E9C5F8FFFF              	jmp	lff24_5  ; error
  2336                                  
  2337                                  load_24khz_stereo_16_bit:
  2338                                  	; 02/02/2025
  2339                                  	; 16/11/2023
  2340                                  	; 15/11/2023
  2341 00001315 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2342                                  					; last of the file?
  2343 0000131C 7402                    	jz	short lff24s2_0		; no
  2344 0000131E F9                      	stc
  2345 0000131F C3                      	retn
  2346                                  
  2347                                  lff24s2_0:
  2348 00001320 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2349                                          ;mov	edx, [loadsize]
  2350                                  
  2351                                  	; esi = buffer address
  2352                                  	;; edx = buffer size
  2353                                  
  2354                                  	; load file into memory
  2355                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001325 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000132B 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000132D 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001333 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001338 CD40                <1>  int 40h
  2356 0000133A 72D4                    	jc	short lff24s2_7 ; error !
  2357                                  
  2358 0000133C BF[00300000]            	mov	edi, audio_buffer
  2359                                  	
  2360 00001341 C1E802                  	shr	eax, 2
  2361 00001344 7505                    	jnz	short lff24s2_8
  2362 00001346 E986F8FFFF              	jmp	lff24_eof
  2363                                  
  2364                                  lff24s2_8:
  2365 0000134B 89C1                    	mov	ecx, eax  ; dword count
  2366                                  lff24s2_1:
  2367 0000134D 66AD                    	lodsw
  2368 0000134F 66AB                    	stosw		; original sample (L)
  2369 00001351 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2370 00001354 66A3[78220000]          	mov	[previous_val_l], ax
  2371 0000135A 66AD                    	lodsw
  2372 0000135C 66AB                    	stosw		; original sample (R)
  2373 0000135E 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2374                                  	;mov	[previous_val_r], ax
  2375 00001361 89C3                    	mov	ebx, eax
  2376                                  	; 02/02/2025
  2377 00001363 668B06                  	mov	ax, [esi]
  2378 00001366 668B5602                	mov	dx, [esi+2]
  2379                                  	; 16/11/2023
  2380 0000136A 49                      	dec	ecx
  2381 0000136B 7504                    	jnz	short lff24s2_2
  2382 0000136D 31D2                    	xor	edx, edx
  2383 0000136F 31C0                    	xor	eax, eax
  2384                                  lff24s2_2:
  2385 00001371 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2386                                  	;;mov	[next_val_l], ax
  2387                                  	;mov	ebp, eax
  2388 00001374 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  2389                                  	;mov	[next_val_r], dx
  2390 00001377 660305[78220000]        	add	ax, [previous_val_l]
  2391 0000137E 66D1D8                  	rcr	ax, 1
  2392 00001381 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2393 00001384 66AB                    	stosw		; this is interpolated sample (L)
  2394                                  	;mov	ax, [next_val_r]
  2395 00001386 89D0                    	mov	eax, edx
  2396                                  	;add	ax, [previous_val_r]
  2397 00001388 6601D8                  	add	ax, bx
  2398 0000138B 66D1D8                  	rcr	ax, 1
  2399 0000138E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2400 00001391 66AB                    	stosw		; this is interpolated sample (R)
  2401                                  
  2402                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2403 00001393 09C9                    	or	ecx, ecx
  2404 00001395 75B6                    	jnz	short lff24s2_1
  2405 00001397 E91DF8FFFF              	jmp	lff24_3
  2406                                  
  2407                                  ; .....................
  2408                                  
  2409                                  load_32khz_mono_8_bit:
  2410                                  	; 02/02/2025
  2411                                  	; 15/11/2023
  2412 0000139C F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2413                                  					; last of the file?
  2414 000013A3 7402                    	jz	short lff32m_0		; no
  2415 000013A5 F9                      	stc
  2416 000013A6 C3                      	retn
  2417                                  
  2418                                  lff32m_0:
  2419 000013A7 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2420                                          ;mov	edx, [loadsize]
  2421                                  
  2422                                  	; esi = buffer address
  2423                                  	;; edx = buffer size
  2424                                  
  2425                                  	; load file into memory
  2426                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000013AC 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000013B2 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000013B4 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000013BA B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000013BF CD40                <1>  int 40h
  2427 000013C1 7247                    	jc	short lff32m_7 ; error !
  2428                                  
  2429 000013C3 BF[00300000]            	mov	edi, audio_buffer
  2430                                  
  2431 000013C8 21C0                    	and	eax, eax
  2432 000013CA 7505                    	jnz	short lff32m_8
  2433 000013CC E900F8FFFF              	jmp	lff32_eof
  2434                                  
  2435                                  lff32m_8:
  2436 000013D1 89C1                    	mov	ecx, eax	; byte count
  2437                                  lff32m_1:
  2438 000013D3 AC                      	lodsb
  2439                                  	;mov	[previous_val], al
  2440 000013D4 88C3                    	mov	bl, al
  2441 000013D6 2C80                    	sub	al, 80h
  2442 000013D8 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2443 000013DC 66AB                    	stosw		; original sample (left channel)
  2444 000013DE 66AB                    	stosw		; original sample (right channel)
  2445                                  	;xor	eax, eax
  2446                                  	; 02/02/2025
  2447 000013E0 8A06                    	mov	al, [esi]
  2448 000013E2 49                      	dec	ecx
  2449 000013E3 7502                    	jnz	short lff32m_2
  2450 000013E5 B080                    	mov	al, 80h
  2451                                  lff32m_2:
  2452                                  	;;mov	[next_val], al
  2453                                  	;mov	bh, al
  2454                                  	;add	al, [previous_val]
  2455 000013E7 00D8                    	add	al, bl
  2456 000013E9 D0D8                    	rcr	al, 1
  2457 000013EB 2C80                    	sub	al, 80h
  2458 000013ED 66C1E008                	shl	ax, 8
  2459 000013F1 66AB                    	stosw		; this is interpolated sample (L)
  2460 000013F3 66AB                    	stosw		; this is interpolated sample (R)
  2461                                  	
  2462                                  	; different than 8-16-24 kHZ !
  2463                                  	; 'original-interpolated-original' trio samples
  2464 000013F5 E30E                    	jecxz	lff32m_3
  2465                                  
  2466 000013F7 AC                      	lodsb
  2467 000013F8 2C80                    	sub	al, 80h
  2468 000013FA 66C1E008                	shl	ax, 8
  2469 000013FE 66AB                    	stosw		; original sample (left channel)
  2470 00001400 66AB                    	stosw		; original sample (right channel)
  2471                                  
  2472                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2473 00001402 49                      	dec	ecx
  2474 00001403 75CE                    	jnz	short lff32m_1
  2475                                  lff32m_3:
  2476 00001405 E9AFF7FFFF              	jmp	lff32_3
  2477                                  
  2478                                  lff32m_7:
  2479                                  lff32s_7:
  2480 0000140A E9CBF7FFFF              	jmp	lff32_5  ; error
  2481                                  
  2482                                  load_32khz_stereo_8_bit:
  2483                                  	; 02/02/2025
  2484                                  	; 15/11/2023
  2485 0000140F F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2486                                  					; last of the file?
  2487 00001416 7402                    	jz	short lff32s_0		; no
  2488 00001418 F9                      	stc
  2489 00001419 C3                      	retn
  2490                                  
  2491                                  lff32s_0:
  2492 0000141A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2493                                          ;mov	edx, [loadsize]
  2494                                  
  2495                                  	; esi = buffer address
  2496                                  	;; edx = buffer size
  2497                                  
  2498                                  	; load file into memory
  2499                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000141F 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001425 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001427 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000142D B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001432 CD40                <1>  int 40h
  2500 00001434 72D4                    	jc	short lff32s_7 ; error !
  2501                                  
  2502 00001436 BF[00300000]            	mov	edi, audio_buffer
  2503                                  	
  2504 0000143B D1E8                    	shr	eax, 1
  2505 0000143D 7505                    	jnz	short lff32s_8
  2506 0000143F E98DF7FFFF              	jmp	lff32_eof
  2507                                  
  2508                                  lff32s_8:
  2509 00001444 89C1                    	mov	ecx, eax  ; word count
  2510                                  lff32s_1:
  2511 00001446 AC                      	lodsb
  2512 00001447 A2[78220000]            	mov	[previous_val_l], al
  2513 0000144C 2C80                    	sub	al, 80h
  2514 0000144E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2515 00001452 66AB                    	stosw		; original sample (L)
  2516 00001454 AC                      	lodsb
  2517 00001455 A2[7A220000]            	mov	[previous_val_r], al
  2518 0000145A 2C80                    	sub	al, 80h
  2519 0000145C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2520 00001460 66AB                    	stosw		; original sample (R)
  2521                                  
  2522                                  	;xor	eax, eax
  2523                                  	; 02/02/2025
  2524 00001462 668B06                  	mov	ax, [esi]
  2525 00001465 49                      	dec	ecx
  2526 00001466 7504                    	jnz	short lff32s_2
  2527                                  		; convert 8 bit sample to 16 bit sample
  2528 00001468 66B88080                	mov	ax, 8080h
  2529                                  lff32s_2:
  2530                                  	;;mov	[next_val_l], al
  2531                                  	;;mov	[next_val_r], ah
  2532                                  	;mov	bx, ax
  2533 0000146C 88E7                    	mov	bh, ah
  2534 0000146E 0205[78220000]          	add	al, [previous_val_l]
  2535 00001474 D0D8                    	rcr	al, 1
  2536                                  	;mov	dl, al
  2537 00001476 2C80                    	sub	al, 80h
  2538 00001478 66C1E008                	shl	ax, 8
  2539 0000147C 66AB                    	stosw		; this is interpolated sample (L)
  2540 0000147E 88F8                    	mov	al, bh	; [next_val_r]
  2541 00001480 0205[7A220000]          	add	al, [previous_val_r]
  2542 00001486 D0D8                    	rcr	al, 1
  2543                                  	;mov	dh, al
  2544 00001488 2C80                    	sub	al, 80h
  2545 0000148A 66C1E008                	shl	ax, 8
  2546 0000148E 66AB                    	stosw		; this is interpolated sample (R)
  2547                                  
  2548                                  	; different than 8-16-24 kHZ !
  2549                                  	; 'original-interpolated-original' trio samples
  2550 00001490 E315                    	jecxz	lff32s_3
  2551                                  
  2552 00001492 AC                      	lodsb
  2553 00001493 2C80                    	sub	al, 80h
  2554 00001495 66C1E008                	shl	ax, 8
  2555 00001499 66AB                    	stosw		; original sample (left channel)
  2556                                  
  2557 0000149B AC                      	lodsb
  2558 0000149C 2C80                    	sub	al, 80h
  2559 0000149E 66C1E008                	shl	ax, 8
  2560 000014A2 66AB                    	stosw		; original sample (right channel)
  2561                                  
  2562                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2563 000014A4 49                      	dec	ecx
  2564 000014A5 759F                    	jnz	short lff32s_1
  2565                                  lff32s_3:
  2566 000014A7 E90DF7FFFF              	jmp	lff32_3
  2567                                  
  2568                                  load_32khz_mono_16_bit:
  2569                                  	; 02/02/2025
  2570                                  	; 15/11/2023
  2571 000014AC F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2572                                  					; last of the file?
  2573 000014B3 7402                    	jz	short lff32m2_0		; no
  2574 000014B5 F9                      	stc
  2575 000014B6 C3                      	retn
  2576                                  
  2577                                  lff32m2_0:
  2578 000014B7 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2579                                          ;mov	edx, [loadsize]
  2580                                  
  2581                                  	; esi = buffer address
  2582                                  	;; edx = buffer size
  2583                                  
  2584                                  	; load file into memory
  2585                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000014BC 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000014C2 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000014C4 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000014CA B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000014CF CD40                <1>  int 40h
  2586 000014D1 7241                    	jc	short lff32m2_7 ; error !
  2587                                  
  2588 000014D3 BF[00300000]            	mov	edi, audio_buffer
  2589                                  	
  2590 000014D8 D1E8                    	shr	eax, 1
  2591 000014DA 7505                    	jnz	short lff32m2_8
  2592 000014DC E9F0F6FFFF              	jmp	lff32_eof
  2593                                  
  2594                                  lff32m2_8:
  2595 000014E1 89C1                    	mov	ecx, eax  ; word count
  2596                                  lff32m2_1:
  2597 000014E3 66AD                    	lodsw
  2598 000014E5 66AB                    	stosw		; original sample (left channel)
  2599 000014E7 66AB                    	stosw		; original sample (right channel)
  2600 000014E9 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2601                                  	;mov	[previous_val], ax
  2602                                  	;mov	ebx, eax
  2603                                  	;xor	eax, eax
  2604                                  	; 02/02/2025
  2605                                  	;mov	ax, [esi]
  2606 000014EC 668B1E                  	mov	bx, [esi]
  2607 000014EF 49                      	dec	ecx
  2608 000014F0 7502                    	jnz	short lff32m2_2
  2609 000014F2 31DB                    	xor	ebx, ebx
  2610                                  lff32m2_2:
  2611                                  	; 02/02/2025
  2612 000014F4 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  2613                                  	;add	ah, 80h
  2614                                  	;mov	ebp, eax ; [next_val]
  2615                                  	;add	ax, [previous_val]
  2616                                  	; ax = [previous_val]
  2617                                  	; bx = [next_val]
  2618 000014F7 6601D8                  	add	ax, bx
  2619 000014FA 66D1D8                  	rcr	ax, 1
  2620 000014FD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2621 00001500 66AB                    	stosw		; this is interpolated sample (L)
  2622 00001502 66AB                    	stosw		; this is interpolated sample (R)
  2623                                  
  2624                                  	; different than 8-16-24 kHZ !
  2625                                  	; 'original-interpolated-original' trio samples
  2626 00001504 E309                    	jecxz	lff32m2_3
  2627                                  
  2628 00001506 66AD                    	lodsw
  2629 00001508 66AB                    	stosw		; original sample (left channel)
  2630 0000150A 66AB                    	stosw		; original sample (right channel)
  2631                                  
  2632                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2633 0000150C 49                      	dec	ecx
  2634 0000150D 75D4                    	jnz	short lff32m2_1
  2635                                  lff32m2_3:
  2636 0000150F E9A5F6FFFF              	jmp	lff32_3
  2637                                  
  2638                                  lff32m2_7:
  2639                                  lff32s2_7:
  2640 00001514 E9C1F6FFFF              	jmp	lff32_5  ; error
  2641                                  
  2642                                  load_32khz_stereo_16_bit:
  2643                                  	; 02/02/2025
  2644                                  	; 16/11/2023
  2645                                  	; 15/11/2023
  2646 00001519 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2647                                  					; last of the file?
  2648 00001520 7402                    	jz	short lff32s2_0		; no
  2649 00001522 F9                      	stc
  2650 00001523 C3                      	retn
  2651                                  
  2652                                  lff32s2_0:
  2653 00001524 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2654                                          ;mov	edx, [loadsize]
  2655                                  
  2656                                  	; esi = buffer address
  2657                                  	;; edx = buffer size
  2658                                  
  2659                                  	; load file into memory
  2660                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001529 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000152F 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001531 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001537 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 0000153C CD40                <1>  int 40h
  2661 0000153E 72D4                    	jc	short lff32s2_7 ; error !
  2662                                  
  2663 00001540 BF[00300000]            	mov	edi, audio_buffer
  2664                                  	
  2665 00001545 C1E802                  	shr	eax, 2
  2666 00001548 7505                    	jnz	short lff32s2_8
  2667 0000154A E982F6FFFF              	jmp	lff32_eof
  2668                                  
  2669                                  lff32s2_8:
  2670 0000154F 89C1                    	mov	ecx, eax ; dword count
  2671                                  lff32s2_1:
  2672 00001551 66AD                    	lodsw
  2673 00001553 66AB                    	stosw		; original sample (L)
  2674 00001555 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2675 00001558 66A3[78220000]          	mov	[previous_val_l], ax
  2676 0000155E 66AD                    	lodsw
  2677 00001560 66AB                    	stosw		; original sample (R)
  2678 00001562 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2679                                  	;mov	[previous_val_r], ax
  2680 00001565 89C3                    	mov	ebx, eax
  2681                                  	; 02/02/2025
  2682 00001567 668B06                  	mov	ax, [esi]
  2683 0000156A 668B5602                	mov	dx, [esi+2]
  2684                                  	; 16/11/2023
  2685 0000156E 49                      	dec	ecx
  2686 0000156F 7504                    	jnz	short lff32s2_2
  2687 00001571 31D2                    	xor	edx, edx
  2688 00001573 31C0                    	xor	eax, eax
  2689                                  lff32s2_2:
  2690 00001575 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2691                                  	;;mov	[next_val_l], ax
  2692                                  	;mov	ebp, eax
  2693 00001578 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  2694                                  	;mov	[next_val_r], dx
  2695 0000157B 660305[78220000]        	add	ax, [previous_val_l]
  2696 00001582 66D1D8                  	rcr	ax, 1
  2697 00001585 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2698 00001588 66AB                    	stosw		; this is interpolated sample (L)
  2699                                  	;mov	ax, [next_val_r]
  2700 0000158A 89D0                    	mov	eax, edx
  2701                                  	;add	ax, [previous_val_r]
  2702 0000158C 6601D8                  	add	ax, bx
  2703 0000158F 66D1D8                  	rcr	ax, 1
  2704 00001592 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2705 00001595 66AB                    	stosw		; this is interpolated sample (R)
  2706                                  
  2707                                  	; different than 8-16-24 kHZ !
  2708                                  	; 'original-interpolated-original' trio samples 
  2709 00001597 E30B                    	jecxz	lff32s2_3
  2710                                  
  2711 00001599 66AD                    	lodsw
  2712 0000159B 66AB                    	stosw	; original sample (L)
  2713 0000159D 66AD                    	lodsw
  2714 0000159F 66AB                    	stosw	; original sample (R)
  2715                                  
  2716                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2717 000015A1 49                      	dec	ecx
  2718 000015A2 75AD                    	jnz	short lff32s2_1
  2719                                  lff32s2_3:
  2720 000015A4 E910F6FFFF              	jmp	lff32_3
  2721                                  
  2722                                  ; .....................
  2723                                  
  2724                                  load_22khz_mono_8_bit:
  2725                                  	; 02/02/2025
  2726                                  	; 16/11/2023
  2727 000015A9 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2728                                  					; last of the file?
  2729 000015B0 7402                    	jz	short lff22m_0		; no
  2730 000015B2 F9                      	stc
  2731 000015B3 C3                      	retn
  2732                                  
  2733                                  lff22m_0:
  2734 000015B4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2735                                          ;mov	edx, [loadsize]
  2736                                  
  2737                                  	; esi = buffer address
  2738                                  	;; edx = buffer size
  2739                                  
  2740                                  	; load file into memory
  2741                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000015B9 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000015BF 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000015C1 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000015C7 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000015CC CD40                <1>  int 40h
  2742 000015CE 725D                    	jc	short lff22m_7 ; error !
  2743                                  
  2744 000015D0 BF[00300000]            	mov	edi, audio_buffer
  2745                                  	
  2746 000015D5 21C0                    	and	eax, eax
  2747 000015D7 7505                    	jnz	short lff22m_8
  2748 000015D9 E9F3F5FFFF              	jmp	lff22_eof
  2749                                  
  2750                                  lff22m_8:
  2751 000015DE 89C1                    	mov	ecx, eax	; byte count
  2752                                  lff22m_9:
  2753 000015E0 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2754 000015E5 C605[80220000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2755                                  lff22m_1:
  2756                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2757 000015EC AC                      	lodsb
  2758                                  	; 02/02/2025
  2759 000015ED 8A16                    	mov	dl, [esi]
  2760 000015EF 49                      	dec	ecx
  2761 000015F0 7502                    	jnz	short lff22m_2_1
  2762 000015F2 B280                    	mov	dl, 80h
  2763                                  lff22m_2_1:
  2764                                  	; al = [previous_val]
  2765                                  	; dl = [next_val]
  2766 000015F4 E835070000              	call	interpolating_3_8bit_mono ; 1 of 17
  2767 000015F9 E32D                    	jecxz	lff22m_3
  2768                                  lff22m_2_2:
  2769 000015FB AC                      	lodsb
  2770                                  	; 02/02/2025
  2771 000015FC 8A16                    	mov	dl, [esi]
  2772 000015FE 49                      	dec	ecx
  2773 000015FF 7502                    	jnz	short lff22m_2_3
  2774 00001601 B280                    	mov	dl, 80h
  2775                                  lff22m_2_3:
  2776 00001603 E8B0070000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2777 00001608 E31E                    	jecxz	lff22m_3
  2778 0000160A 4D                      	dec	ebp
  2779 0000160B 75EE                    	jnz	short lff22m_2_2
  2780                                  
  2781 0000160D A0[80220000]            	mov	al, [faz]
  2782 00001612 FEC8                    	dec	al
  2783 00001614 74CA                    	jz	short lff22m_9
  2784 00001616 FE0D[80220000]          	dec	byte [faz]
  2785 0000161C BD04000000              	mov	ebp, 4
  2786 00001621 FEC8                    	dec	al
  2787 00001623 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2788 00001625 45                      	inc	ebp ; 5
  2789 00001626 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2790                                  
  2791                                  lff22m_3:
  2792                                  lff22s_3:
  2793 00001628 E98CF5FFFF              	jmp	lff22_3	; padfill
  2794                                  		; (put zeros in the remain words of the buffer)
  2795                                  lff22m_7:
  2796                                  lff22s_7:
  2797 0000162D E9A8F5FFFF              	jmp	lff22_5  ; error
  2798                                  
  2799                                  load_22khz_stereo_8_bit:
  2800                                  	; 02/02/2025
  2801                                  	; 16/11/2023
  2802 00001632 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2803                                  					; last of the file?
  2804 00001639 7402                    	jz	short lff22s_0		; no
  2805 0000163B F9                      	stc
  2806 0000163C C3                      	retn
  2807                                  
  2808                                  lff22s_0:
  2809 0000163D BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2810                                          ;mov	edx, [loadsize]
  2811                                  
  2812                                  	; esi = buffer address
  2813                                  	;; edx = buffer size
  2814                                  
  2815                                  	; load file into memory
  2816                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001642 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001648 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000164A 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001650 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001655 CD40                <1>  int 40h
  2817 00001657 72D4                    	jc	short lff22s_7 ; error !
  2818                                  
  2819 00001659 BF[00300000]            	mov	edi, audio_buffer
  2820                                  
  2821 0000165E D1E8                    	shr	eax, 1
  2822 00001660 7505                    	jnz	short lff22s_8
  2823 00001662 E96AF5FFFF              	jmp	lff22_eof
  2824                                  
  2825                                  lff22s_8:
  2826 00001667 89C1                    	mov	ecx, eax	; word count
  2827                                  lff22s_9:
  2828 00001669 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2829 0000166E C605[80220000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2830                                  lff22s_1:
  2831                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2832 00001675 66AD                    	lodsw
  2833                                  	; 02/02/2025
  2834 00001677 668B16                  	mov	dx, [esi]
  2835 0000167A 49                      	dec	ecx
  2836 0000167B 7504                    	jnz	short lff22s_2_1
  2837 0000167D 66BA8080                	mov	dx, 8080h
  2838                                  lff22s_2_1:
  2839                                  	; al = [previous_val_l]
  2840                                  	; ah = [previous_val_r]
  2841                                  	; dl = [next_val_l]
  2842                                  	; dh = [next_val_r]
  2843 00001681 E8DB060000              	call	interpolating_3_8bit_stereo ; 1 of 17
  2844 00001686 E3A0                    	jecxz	lff22s_3
  2845                                  lff22s_2_2:
  2846 00001688 66AD                    	lodsw
  2847                                  	; 02/02/2025
  2848 0000168A 668B16                  	mov	dx, [esi]
  2849 0000168D 49                      	dec	ecx
  2850 0000168E 7504                    	jnz	short lff22s_2_3
  2851 00001690 66BA8080                	mov	dx, 8080h
  2852                                  lff22s_2_3:
  2853 00001694 E83C070000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2854 00001699 E38D                    	jecxz	lff22s_3
  2855 0000169B 4D                      	dec	ebp
  2856 0000169C 75EA                    	jnz	short lff22s_2_2
  2857                                  
  2858 0000169E A0[80220000]            	mov	al, [faz]
  2859 000016A3 FEC8                    	dec	al
  2860 000016A5 74C2                    	jz	short lff22s_9
  2861 000016A7 FE0D[80220000]          	dec	byte [faz]
  2862 000016AD BD04000000              	mov	ebp, 4
  2863 000016B2 FEC8                    	dec	al
  2864 000016B4 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2865 000016B6 45                      	inc	ebp ; 5
  2866 000016B7 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2867                                  
  2868                                  load_22khz_mono_16_bit:
  2869                                  	; 02/02/2025
  2870                                  	; 16/11/2023
  2871 000016B9 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2872                                  					; last of the file?
  2873 000016C0 7402                    	jz	short lff22m2_0		; no
  2874 000016C2 F9                      	stc
  2875 000016C3 C3                      	retn
  2876                                  
  2877                                  lff22m2_0:
  2878 000016C4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2879                                          ;mov	edx, [loadsize]
  2880                                  
  2881                                  	; esi = buffer address
  2882                                  	;; edx = buffer size
  2883                                  
  2884                                  	; load file into memory
  2885                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000016C9 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000016CF 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 000016D1 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 000016D7 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 000016DC CD40                <1>  int 40h
  2886 000016DE 7261                    	jc	short lff22m2_7 ; error !
  2887                                  
  2888 000016E0 BF[00300000]            	mov	edi, audio_buffer
  2889                                  	
  2890 000016E5 D1E8                    	shr	eax, 1
  2891 000016E7 7505                    	jnz	short lff22m2_8
  2892 000016E9 E9E3F4FFFF              	jmp	lff22_eof
  2893                                  
  2894                                  lff22m2_8:
  2895 000016EE 89C1                    	mov	ecx, eax	; word count
  2896                                  lff22m2_9:
  2897 000016F0 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2898 000016F5 C605[80220000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2899                                  lff22m2_1:
  2900                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2901 000016FC 66AD                    	lodsw
  2902                                  	; 02/02/2025
  2903 000016FE 668B16                  	mov	dx, [esi]
  2904 00001701 49                      	dec	ecx
  2905 00001702 7502                    	jnz	short lff22m2_2_1
  2906 00001704 31D2                    	xor	edx, edx
  2907                                  lff22m2_2_1:	
  2908                                  	; ax = [previous_val]
  2909                                  	; dx = [next_val]
  2910 00001706 E8FB060000              	call	interpolating_3_16bit_mono ; 1 of 17
  2911 0000170B E32F                    	jecxz	lff22m2_3
  2912                                  lff22m2_2_2:
  2913 0000170D 66AD                    	lodsw
  2914                                  	; 02/02/2025
  2915 0000170F 668B16                  	mov	dx, [esi]
  2916 00001712 49                      	dec	ecx
  2917 00001713 7502                    	jnz	short lff22m2_2_3
  2918 00001715 31D2                    	xor	edx, edx
  2919                                  lff22m2_2_3:
  2920 00001717 E87D070000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2921 0000171C E31E                    	jecxz	lff22m2_3
  2922 0000171E 4D                      	dec	ebp
  2923 0000171F 75EC                    	jnz	short lff22m2_2_2
  2924                                  
  2925 00001721 A0[80220000]            	mov	al, [faz]
  2926 00001726 FEC8                    	dec	al
  2927 00001728 74C6                    	jz	short lff22m2_9
  2928 0000172A FE0D[80220000]          	dec	byte [faz]
  2929 00001730 BD04000000              	mov	ebp, 4
  2930 00001735 FEC8                    	dec	al
  2931 00001737 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2932 00001739 45                      	inc	ebp ; 5
  2933 0000173A EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2934                                  
  2935                                  lff22m2_3:
  2936                                  lff22s2_3:
  2937 0000173C E978F4FFFF              	jmp	lff22_3	; padfill
  2938                                  		; (put zeros in the remain words of the buffer)
  2939                                  lff22m2_7:
  2940                                  lff22s2_7:
  2941 00001741 E994F4FFFF              	jmp	lff22_5  ; error
  2942                                  
  2943                                  load_22khz_stereo_16_bit:
  2944                                  	; 16/11/2023
  2945 00001746 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2946                                  					; last of the file?
  2947 0000174D 7402                    	jz	short lff22s2_0		; no
  2948 0000174F F9                      	stc
  2949 00001750 C3                      	retn
  2950                                  
  2951                                  lff22s2_0:
  2952 00001751 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2953                                          ;mov	edx, [loadsize]
  2954                                  
  2955                                  	; esi = buffer address
  2956                                  	;; edx = buffer size
  2957                                  
  2958                                  	; load file into memory
  2959                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001756 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000175C 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000175E 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001764 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001769 CD40                <1>  int 40h
  2960 0000176B 72D4                    	jc	short lff22s2_7 ; error !
  2961                                  
  2962 0000176D BF[00300000]            	mov	edi, audio_buffer
  2963                                  	
  2964 00001772 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  2965 00001775 7505                    	jnz	short lff22s2_8
  2966 00001777 E955F4FFFF              	jmp	lff22_eof
  2967                                  
  2968                                  lff22s2_8:
  2969 0000177C 89C1                    	mov	ecx, eax	; dword count
  2970                                  lff22s2_9:
  2971 0000177E BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2972 00001783 C605[80220000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2973                                  lff22s2_1:
  2974                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2975 0000178A 66AD                    	lodsw
  2976 0000178C 89C3                    	mov	ebx, eax
  2977 0000178E 66AD                    	lodsw
  2978 00001790 8B16                    	mov	edx, [esi]
  2979 00001792 668915[7C220000]        	mov	[next_val_l], dx
  2980                                  	; 26/11/2023
  2981 00001799 C1EA10                  	shr	edx, 16
  2982 0000179C 49                      	dec	ecx
  2983 0000179D 7509                    	jnz	short lff22s2_2_1
  2984 0000179F 31D2                    	xor	edx, edx ; 0
  2985 000017A1 668915[7C220000]        	mov	[next_val_l], dx
  2986                                  lff22s2_2_1:
  2987                                  	; bx = [previous_val_l]
  2988                                  	; ax = [previous_val_r]
  2989                                  	; [next_val_l]
  2990                                  	; dx = [next_val_r]
  2991 000017A8 E889060000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  2992 000017AD E38D                    	jecxz	lff22s2_3
  2993                                  lff22s2_2_2:
  2994 000017AF 66AD                    	lodsw
  2995 000017B1 89C3                    	mov	ebx, eax
  2996 000017B3 66AD                    	lodsw
  2997 000017B5 8B16                    	mov	edx, [esi]
  2998 000017B7 668915[7C220000]        	mov	[next_val_l], dx
  2999                                  	; 26/11/2023
  3000 000017BE C1EA10                  	shr	edx, 16
  3001 000017C1 49                      	dec	ecx
  3002 000017C2 7509                    	jnz	short lff22s2_2_3
  3003 000017C4 31D2                    	xor	edx, edx ; 0
  3004 000017C6 668915[7C220000]        	mov	[next_val_l], dx
  3005                                  lff22s2_2_3:
  3006 000017CD E8DF060000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  3007 000017D2 E31E                    	jecxz	lff22s2_2_4
  3008                                  
  3009 000017D4 4D                      	dec	ebp
  3010 000017D5 75D8                    	jnz	short lff22s2_2_2
  3011                                  
  3012 000017D7 A0[80220000]            	mov	al, [faz]
  3013 000017DC FEC8                    	dec	al
  3014 000017DE 749E                    	jz	short lff22s2_9
  3015 000017E0 FE0D[80220000]          	dec	byte [faz]
  3016 000017E6 BD04000000              	mov	ebp, 4
  3017 000017EB FEC8                    	dec	al
  3018 000017ED 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  3019 000017EF 45                      	inc	ebp ; 5
  3020 000017F0 EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  3021                                  
  3022                                  lff22s2_2_4:
  3023                                  	; 26/11/2023
  3024 000017F2 E9C2F3FFFF              	jmp	lff22_3	; padfill
  3025                                  
  3026                                  ; .....................
  3027                                  
  3028                                  load_11khz_mono_8_bit:
  3029                                  	; 02/02/2025
  3030                                  	; 18/11/2023
  3031 000017F7 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3032                                  					; last of the file?
  3033 000017FE 7402                    	jz	short lff11m_0		; no
  3034 00001800 F9                      	stc
  3035 00001801 C3                      	retn
  3036                                  
  3037                                  lff11m_0:
  3038 00001802 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3039                                          ;mov	edx, [loadsize]
  3040                                  
  3041                                  	; esi = buffer address
  3042                                  	;; edx = buffer size
  3043                                  
  3044                                  	; load file into memory
  3045                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001807 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 0000180D 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000180F 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001815 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 0000181A CD40                <1>  int 40h
  3046 0000181C 7247                    	jc	short lff11m_7 ; error !
  3047                                  
  3048 0000181E BF[00300000]            	mov	edi, audio_buffer
  3049                                  	
  3050 00001823 21C0                    	and	eax, eax
  3051 00001825 7505                    	jnz	short lff11m_8
  3052 00001827 E9A5F3FFFF              	jmp	lff11_eof
  3053                                  
  3054                                  lff11m_8:
  3055 0000182C 89C1                    	mov	ecx, eax	; byte count
  3056                                  lff11m_9:
  3057 0000182E BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3058                                  lff11m_1:
  3059                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3060 00001833 AC                      	lodsb
  3061                                  	; 02/02/2025
  3062 00001834 8A16                    	mov	dl, [esi]
  3063 00001836 49                      	dec	ecx
  3064 00001837 7502                    	jnz	short lff11m_2_1
  3065 00001839 B280                    	mov	dl, 80h
  3066                                  lff11m_2_1:	
  3067                                  	; al = [previous_val]
  3068                                  	; dl = [next_val]
  3069 0000183B E8A0060000              	call	interpolating_5_8bit_mono
  3070 00001840 E328                    	jecxz	lff11m_3
  3071                                  lff11m_2_2:
  3072 00001842 AC                      	lodsb
  3073                                  	; 02/02/2025
  3074 00001843 8A16                    	mov	dl, [esi]
  3075 00001845 49                      	dec	ecx
  3076 00001846 7502                    	jnz	short lff11m_2_3
  3077 00001848 B280                    	mov	dl, 80h
  3078                                  lff11m_2_3:
  3079 0000184A E89D070000               	call	interpolating_4_8bit_mono
  3080 0000184F E319                    	jecxz	lff11m_3
  3081                                  
  3082 00001851 4D                      	dec	ebp
  3083 00001852 74DA                    	jz	short lff11m_9
  3084                                  
  3085 00001854 AC                      	lodsb
  3086                                  	; 02/02/2025
  3087 00001855 8A16                    	mov	dl, [esi]
  3088 00001857 49                      	dec	ecx
  3089 00001858 7502                    	jnz	short lff11m_2_4
  3090 0000185A B280                    	mov	dl, 80h
  3091                                  lff11m_2_4:
  3092 0000185C E88B070000              	call	interpolating_4_8bit_mono
  3093 00001861 E307                    	jecxz	lff11m_3
  3094 00001863 EBCE                    	jmp	short lff11m_1
  3095                                  
  3096                                  lff11m_7:
  3097                                  lff11s_7:
  3098 00001865 E970F3FFFF              	jmp	lff11_5  ; error
  3099                                  
  3100                                  lff11m_3:
  3101                                  lff11s_3:
  3102 0000186A E94AF3FFFF              	jmp	lff11_3	; padfill
  3103                                  		; (put zeros in the remain words of the buffer)
  3104                                  
  3105                                  load_11khz_stereo_8_bit:
  3106                                  	; 02/02/2025
  3107                                  	; 18/11/2023
  3108 0000186F F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3109                                  					; last of the file?
  3110 00001876 7402                    	jz	short lff11s_0		; no
  3111 00001878 F9                      	stc
  3112 00001879 C3                      	retn
  3113                                  
  3114                                  lff11s_0:
  3115 0000187A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3116                                          ;mov	edx, [loadsize]
  3117                                  
  3118                                  	; esi = buffer address
  3119                                  	;; edx = buffer size
  3120                                  
  3121                                  	; load file into memory
  3122                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 0000187F 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001885 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001887 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 0000188D B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001892 CD40                <1>  int 40h
  3123 00001894 72CF                    	jc	short lff11s_7 ; error !
  3124                                  
  3125 00001896 BF[00300000]            	mov	edi, audio_buffer
  3126                                  
  3127 0000189B D1E8                    	shr	eax, 1
  3128 0000189D 7505                    	jnz	short lff11s_8
  3129 0000189F E92DF3FFFF              	jmp	lff11_eof
  3130                                  
  3131                                  lff11s_8:
  3132 000018A4 89C1                    	mov	ecx, eax	; word count
  3133                                  lff11s_9:
  3134 000018A6 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3135                                  lff11s_1:
  3136                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3137 000018AB 66AD                    	lodsw
  3138                                  	; 02/02/2025
  3139 000018AD 668B16                  	mov	dx, [esi]
  3140 000018B0 49                      	dec	ecx
  3141 000018B1 7504                    	jnz	short lff11s_2_1
  3142 000018B3 66BA8080                	mov	dx, 8080h
  3143                                  lff11s_2_1:
  3144                                  	; al = [previous_val_l]
  3145                                  	; ah = [previous_val_r]
  3146                                  	; dl = [next_val_l]
  3147                                  	; dh = [next_val_r]
  3148 000018B7 E883060000              	call	interpolating_5_8bit_stereo
  3149 000018BC E3AC                    	jecxz	lff11s_3
  3150                                  lff11s_2_2:
  3151 000018BE 66AD                    	lodsw
  3152                                  	; 02/02/2025
  3153 000018C0 668B16                  	mov	dx, [esi]
  3154 000018C3 49                      	dec	ecx
  3155 000018C4 7504                    	jnz	short lff11s_2_3
  3156 000018C6 66BA8080                	mov	dx, 8080h
  3157                                  lff11s_2_3:
  3158 000018CA E85C070000               	call	interpolating_4_8bit_stereo
  3159 000018CF E399                    	jecxz	lff11s_3
  3160                                  	
  3161 000018D1 4D                      	dec	ebp
  3162 000018D2 74D2                    	jz	short lff11s_9
  3163                                  
  3164 000018D4 66AD                    	lodsw
  3165                                  	; 02/02/2025
  3166 000018D6 668B16                  	mov	dx, [esi]
  3167 000018D9 49                      	dec	ecx
  3168 000018DA 7504                    	jnz	short lff11s_2_4
  3169 000018DC 66BA8080                	mov	dx, 8080h
  3170                                  lff11s_2_4:
  3171 000018E0 E846070000              	call	interpolating_4_8bit_stereo
  3172 000018E5 E383                    	jecxz	lff11s_3
  3173 000018E7 EBC2                    	jmp	short lff11s_1
  3174                                  
  3175                                  load_11khz_mono_16_bit:
  3176                                  	; 02/02/2025
  3177                                  	; 18/11/2023
  3178 000018E9 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3179                                  					; last of the file?
  3180 000018F0 7402                    	jz	short lff11m2_0		; no
  3181 000018F2 F9                      	stc
  3182 000018F3 C3                      	retn
  3183                                  
  3184                                  lff11m2_0:
  3185 000018F4 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3186                                          ;mov	edx, [loadsize]
  3187                                  
  3188                                  	; esi = buffer address
  3189                                  	;; edx = buffer size
  3190                                  
  3191                                  	; load file into memory
  3192                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 000018F9 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 000018FF 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001901 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001907 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 0000190C CD40                <1>  int 40h
  3193 0000190E 724D                    	jc	short lff11m2_7 ; error !
  3194                                  
  3195 00001910 BF[00300000]            	mov	edi, audio_buffer
  3196                                  	
  3197 00001915 D1E8                    	shr	eax, 1
  3198 00001917 7505                    	jnz	short lff11m2_8
  3199 00001919 E9B3F2FFFF              	jmp	lff11_eof
  3200                                  
  3201                                  lff11m2_8:
  3202 0000191E 89C1                    	mov	ecx, eax	; word count
  3203                                  lff11m2_9:
  3204 00001920 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3205                                  lff11m2_1:
  3206                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3207 00001925 66AD                    	lodsw
  3208                                  	; 02/02/2025
  3209 00001927 668B16                  	mov	dx, [esi]
  3210 0000192A 49                      	dec	ecx
  3211 0000192B 7502                    	jnz	short lff11m2_2_1
  3212 0000192D 31D2                    	xor	edx, edx
  3213                                  lff11m2_2_1:	
  3214                                  	; ax = [previous_val]
  3215                                  	; dx = [next_val]
  3216 0000192F E864070000              	call	interpolating_5_16bit_mono
  3217 00001934 E362                    	jecxz	lff11m2_3
  3218                                  lff11m2_2_2:
  3219 00001936 66AD                    	lodsw
  3220                                  	; 02/02/2025
  3221 00001938 668B16                  	mov	dx, [esi]
  3222 0000193B 49                      	dec	ecx
  3223 0000193C 7502                    	jnz	short lff11m2_2_3
  3224 0000193E 31D2                    	xor	edx, edx
  3225                                  lff11m2_2_3:
  3226 00001940 E87D080000               	call	interpolating_4_16bit_mono
  3227 00001945 E351                    	jecxz	lff11m2_3
  3228                                  
  3229 00001947 4D                      	dec	ebp
  3230 00001948 74D6                    	jz	short lff11m2_9
  3231                                  
  3232 0000194A 66AD                    	lodsw
  3233                                  	; 02/02/2025
  3234 0000194C 668B16                  	mov	dx, [esi]
  3235 0000194F 49                      	dec	ecx
  3236 00001950 7502                    	jnz	short lff11m2_2_4
  3237 00001952 31D2                    	xor	edx, edx
  3238                                  lff11m2_2_4:
  3239 00001954 E869080000               	call	interpolating_4_16bit_mono
  3240 00001959 E33D                    	jecxz	lff11m2_3
  3241 0000195B EBC8                    	jmp	short lff11m2_1
  3242                                  
  3243                                  lff11m2_7:
  3244                                  lff11s2_7:
  3245 0000195D E978F2FFFF              	jmp	lff11_5  ; error
  3246                                  
  3247                                  load_11khz_stereo_16_bit:
  3248                                  	; 17/01/2025
  3249                                  	; 18/11/2023
  3250 00001962 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3251                                  					; last of the file?
  3252 00001969 7402                    	jz	short lff11s2_0		; no
  3253 0000196B F9                      	stc
  3254 0000196C C3                      	retn
  3255                                  
  3256                                  lff11s2_0:
  3257 0000196D BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3258                                          ;mov	edx, [loadsize]
  3259                                  
  3260                                  	; esi = buffer address
  3261                                  	;; edx = buffer size
  3262                                  
  3263                                  	; load file into memory
  3264                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001972 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001978 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 0000197A 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001980 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001985 CD40                <1>  int 40h
  3265 00001987 72D4                    	jc	short lff11s2_7 ; error !
  3266                                  
  3267 00001989 BF[00300000]            	mov	edi, audio_buffer
  3268                                  	
  3269 0000198E C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3270 00001991 750A                    	jnz	short lff11s2_8
  3271 00001993 E939F2FFFF              	jmp	lff11_eof
  3272                                  
  3273                                  lff11m2_3:
  3274                                  lff11s2_3:
  3275 00001998 E91CF2FFFF              	jmp	lff11_3	; padfill
  3276                                  		; (put zeros in the remain words of the buffer)
  3277                                  
  3278                                  lff11s2_8:
  3279 0000199D 89C1                    	mov	ecx, eax	; dword count
  3280                                  lff11s2_9:
  3281 0000199F BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3282                                  lff11s2_1:
  3283                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3284 000019A4 66AD                    	lodsw
  3285 000019A6 89C3                    	mov	ebx, eax
  3286 000019A8 66AD                    	lodsw
  3287 000019AA 8B16                    	mov	edx, [esi]
  3288                                  	; 17/01/2025
  3289                                  	;mov	[next_val_l], edx
  3290                                  	; 26/11/2023
  3291                                  	;shr	edx, 16
  3292                                  	;mov	[next_val_r], dx
  3293 000019AC 49                      	dec	ecx
  3294 000019AD 7502                    	jnz	short lff11s2_2_1
  3295 000019AF 31D2                    	xor	edx, edx ; 0
  3296                                  	;mov	[next_val_l], dx
  3297                                  	;mov	[next_val_r], dx
  3298                                  lff11s2_2_1:
  3299                                  	; bx = [previous_val_l]
  3300                                  	; ax = [previous_val_r]
  3301                                  	; [next_val_l]
  3302                                  	; dx = [next_val_r]
  3303                                  	;;;
  3304                                  	; 17/01/2025 (BugFix)
  3305 000019B1 8915[7C220000]          	mov	[next_val_l], edx
  3306                                  	;;;
  3307 000019B7 E837070000              	call	interpolating_5_16bit_stereo
  3308 000019BC E3DA                    	jecxz	lff11s2_3
  3309                                  lff11s2_2_2:
  3310 000019BE 66AD                    	lodsw
  3311 000019C0 89C3                    	mov	ebx, eax
  3312 000019C2 66AD                    	lodsw
  3313 000019C4 8B16                    	mov	edx, [esi]
  3314                                  	; 17/01/2025
  3315                                  	;mov	[next_val_l], dx
  3316                                  	; 26/11/2023
  3317                                  	;shr	edx, 16
  3318                                  	;mov	[next_val_r], dx
  3319 000019C6 49                      	dec	ecx
  3320 000019C7 7502                    	jnz	short lff11s2_2_3
  3321 000019C9 31D2                    	xor	edx, edx ; 0
  3322                                  	;mov	[next_val_l], dx
  3323                                  	;mov	[next_val_r], dx
  3324                                  lff11s2_2_3:
  3325                                  	;;;
  3326                                  	; 17/01/2025 (BugFix)
  3327 000019CB 8915[7C220000]          	mov	[next_val_l], edx
  3328                                  	;;;
  3329 000019D1 E825080000              	call	interpolating_4_16bit_stereo
  3330 000019D6 E3C0                    	jecxz	lff11s2_3
  3331                                  	
  3332 000019D8 4D                      	dec	ebp
  3333 000019D9 74C4                    	jz	short lff11s2_9
  3334                                  
  3335 000019DB 66AD                    	lodsw
  3336 000019DD 89C3                    	mov	ebx, eax
  3337 000019DF 66AD                    	lodsw
  3338 000019E1 8B16                    	mov	edx, [esi]
  3339                                  	; 17/01/2025
  3340                                  	;mov	[next_val_l], dx
  3341                                  	; 26/11/2023
  3342                                  	;shr	edx, 16
  3343                                  	;mov	[next_val_r], dx
  3344 000019E3 49                      	dec	ecx
  3345 000019E4 7502                    	jnz	short lff11s2_2_4
  3346 000019E6 31D2                    	xor	edx, edx ; 0
  3347                                  	;mov	[next_val_l], dx
  3348                                  	;mov	[next_val_r], dx
  3349                                  lff11s2_2_4:
  3350                                  	;;;
  3351                                  	; 17/01/2025 (BugFix)
  3352 000019E8 8915[7C220000]          	mov	[next_val_l], edx
  3353                                  	;;;
  3354 000019EE E808080000               	call	interpolating_4_16bit_stereo
  3355 000019F3 E3A3                    	jecxz	lff11s2_3
  3356 000019F5 EBAD                    	jmp	short lff11s2_1
  3357                                  
  3358                                  ; .....................
  3359                                  
  3360                                  load_44khz_mono_8_bit:
  3361                                  	; 02/02/2025
  3362                                  	; 18/11/2023
  3363 000019F7 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3364                                  					; last of the file?
  3365 000019FE 7402                    	jz	short lff44m_0		; no
  3366 00001A00 F9                      	stc
  3367 00001A01 C3                      	retn
  3368                                  
  3369                                  lff44m_0:
  3370 00001A02 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3371                                          ;mov	edx, [loadsize]
  3372                                  
  3373                                  	; esi = buffer address
  3374                                  	;; edx = buffer size
  3375                                  
  3376                                  	; load file into memory
  3377                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001A07 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001A0D 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001A0F 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001A15 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001A1A CD40                <1>  int 40h
  3378 00001A1C 7250                    	jc	short lff44m_7 ; error !
  3379                                  
  3380 00001A1E BF[00300000]            	mov	edi, audio_buffer
  3381                                  
  3382 00001A23 21C0                    	and	eax, eax
  3383 00001A25 7505                    	jnz	short lff44m_8
  3384 00001A27 E9A5F1FFFF              	jmp	lff44_eof
  3385                                  
  3386                                  lff44m_8:
  3387 00001A2C 89C1                    	mov	ecx, eax	; byte count
  3388                                  lff44m_9:
  3389 00001A2E BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3390 00001A33 C605[80220000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3391                                  lff44m_1:
  3392                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3393                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3394 00001A3A AC                      	lodsb
  3395                                  	; 02/02/2025
  3396 00001A3B 8A16                    	mov	dl, [esi]
  3397 00001A3D 49                      	dec	ecx
  3398 00001A3E 7502                    	jnz	short lff44m_2_1
  3399 00001A40 B280                    	mov	dl, 80h
  3400                                  lff44m_2_1:
  3401                                  	; al = [previous_val]
  3402                                  	; dl = [next_val]
  3403 00001A42 E871030000              	call	interpolating_2_8bit_mono
  3404 00001A47 E320                    	jecxz	lff44m_3
  3405                                  lff44m_2_2:
  3406 00001A49 AC                      	lodsb
  3407 00001A4A 2C80                    	sub	al, 80h
  3408 00001A4C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3409 00001A50 66AB                    	stosw		; (L)
  3410 00001A52 66AB                    	stosw		; (R)
  3411                                  
  3412 00001A54 49                      	dec	ecx
  3413 00001A55 7412                    	jz	short lff44m_3
  3414 00001A57 4D                      	dec	ebp
  3415 00001A58 75EF                    	jnz	short lff44m_2_2
  3416                                  	
  3417 00001A5A FE0D[80220000]          	dec	byte [faz]
  3418 00001A60 74CC                    	jz	short lff44m_9
  3419 00001A62 BD0B000000              	mov	ebp, 11
  3420 00001A67 EBD1                    	jmp	short lff44m_1
  3421                                  
  3422                                  lff44m_3:
  3423                                  lff44s_3:
  3424 00001A69 E94BF1FFFF              	jmp	lff44_3	; padfill
  3425                                  		; (put zeros in the remain words of the buffer)
  3426                                  lff44m_7:
  3427                                  lff44s_7:
  3428 00001A6E E967F1FFFF              	jmp	lff44_5  ; error
  3429                                  
  3430                                  load_44khz_stereo_8_bit:
  3431                                  	; 02/02/2025
  3432                                  	; 16/11/2023
  3433 00001A73 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3434                                  					; last of the file?
  3435 00001A7A 7402                    	jz	short lff44s_0		; no
  3436 00001A7C F9                      	stc
  3437 00001A7D C3                      	retn
  3438                                  
  3439                                  lff44s_0:
  3440 00001A7E BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3441                                          ;mov	edx, [loadsize]
  3442                                  
  3443                                  	; esi = buffer address
  3444                                  	;; edx = buffer size
  3445                                  
  3446                                  	; load file into memory
  3447                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001A83 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001A89 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001A8B 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001A91 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001A96 CD40                <1>  int 40h
  3448 00001A98 72D4                    	jc	short lff44s_7 ; error !
  3449                                  
  3450 00001A9A BF[00300000]            	mov	edi, audio_buffer
  3451                                  
  3452 00001A9F D1E8                    	shr	eax, 1
  3453 00001AA1 7505                    	jnz	short lff44s_8
  3454 00001AA3 E929F1FFFF              	jmp	lff44_eof
  3455                                  
  3456                                  lff44s_8:
  3457 00001AA8 89C1                    	mov	ecx, eax	; word count
  3458                                  lff44s_9:
  3459 00001AAA BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3460 00001AAF C605[80220000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3461                                  lff44s_1:
  3462                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3463                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3464 00001AB6 66AD                    	lodsw
  3465                                  	; 02/02/2025
  3466 00001AB8 668B16                  	mov	dx, [esi]
  3467 00001ABB 49                      	dec	ecx
  3468 00001ABC 7504                    	jnz	short lff44s_2_1
  3469 00001ABE 66BA8080                	mov	dx, 8080h
  3470                                  lff44s_2_1:	
  3471                                  	; al = [previous_val_l]
  3472                                  	; ah = [previous_val_r]
  3473                                  	; dl = [next_val_l]
  3474                                  	; dh = [next_val_r]
  3475 00001AC2 E80E030000              	call	interpolating_2_8bit_stereo
  3476 00001AC7 E3A0                    	jecxz	lff44s_3
  3477                                  lff44s_2_2:
  3478 00001AC9 AC                      	lodsb
  3479 00001ACA 2C80                    	sub	al, 80h
  3480 00001ACC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3481 00001AD0 66AB                    	stosw		; (L)
  3482 00001AD2 AC                      	lodsb
  3483 00001AD3 2C80                    	sub	al, 80h
  3484 00001AD5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3485 00001AD9 66AB                    	stosw		; (R)
  3486                                  
  3487 00001ADB 49                      	dec	ecx
  3488 00001ADC 748B                    	jz	short lff44s_3
  3489 00001ADE 4D                      	dec	ebp
  3490 00001ADF 75E8                    	jnz	short lff44s_2_2
  3491                                  	
  3492 00001AE1 FE0D[80220000]          	dec	byte [faz]
  3493 00001AE7 74C1                    	jz	short lff44s_9
  3494 00001AE9 BD0B000000              	mov	ebp, 11
  3495 00001AEE EBC6                    	jmp	short lff44s_1
  3496                                  
  3497                                  load_44khz_mono_16_bit:
  3498                                  	; 02/02/2025
  3499                                  	; 18/11/2023
  3500 00001AF0 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3501                                  					; last of the file?
  3502 00001AF7 7402                    	jz	short lff44m2_0		; no
  3503 00001AF9 F9                      	stc
  3504 00001AFA C3                      	retn
  3505                                  
  3506                                  lff44m2_0:
  3507 00001AFB BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3508                                          ;mov	edx, [loadsize]
  3509                                  
  3510                                  	; esi = buffer address
  3511                                  	;; edx = buffer size
  3512                                  
  3513                                  	; load file into memory
  3514                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001B00 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001B06 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001B08 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001B0E B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001B13 CD40                <1>  int 40h
  3515 00001B15 724D                    	jc	short lff44m2_7 ; error !
  3516                                  
  3517 00001B17 BF[00300000]            	mov	edi, audio_buffer
  3518                                  	
  3519 00001B1C D1E8                    	shr	eax, 1
  3520 00001B1E 7505                    	jnz	short lff44m2_8
  3521 00001B20 E9ACF0FFFF              	jmp	lff44_eof
  3522                                  
  3523                                  lff44m2_8:
  3524 00001B25 89C1                    	mov	ecx, eax	; word count
  3525                                  lff44m2_9:
  3526 00001B27 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3527 00001B2C C605[80220000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3528                                  lff44m2_1:
  3529                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3530                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3531 00001B33 66AD                    	lodsw
  3532                                  	; 02/02/2025
  3533 00001B35 668B16                  	mov	dx, [esi]
  3534 00001B38 49                      	dec	ecx
  3535 00001B39 7502                    	jnz	short lff44m2_2_1
  3536 00001B3B 31D2                    	xor	edx, edx
  3537                                  lff44m2_2_1:	
  3538                                  	; ax = [previous_val]
  3539                                  	; dx = [next_val]
  3540 00001B3D E857030000              	call	interpolating_2_16bit_mono
  3541 00001B42 E31B                    	jecxz	lff44m2_3
  3542                                  lff44m2_2_2:
  3543 00001B44 66AD                    	lodsw
  3544 00001B46 66AB                    	stosw		; (L)eft Channel
  3545 00001B48 66AB                    	stosw		; (R)ight Channel
  3546                                  
  3547 00001B4A 49                      	dec	ecx
  3548 00001B4B 7412                    	jz	short lff44m2_3	
  3549 00001B4D 4D                      	dec	ebp
  3550 00001B4E 75F4                    	jnz	short lff44m2_2_2
  3551                                  
  3552 00001B50 FE0D[80220000]          	dec	byte [faz]
  3553 00001B56 74CF                    	jz	short lff44m2_9 
  3554 00001B58 BD0B000000              	mov	ebp, 11
  3555 00001B5D EBD4                    	jmp	short lff44m2_1
  3556                                  
  3557                                  lff44m2_3:
  3558                                  lff44s2_3:
  3559 00001B5F E955F0FFFF              	jmp	lff44_3	; padfill
  3560                                  		; (put zeros in the remain words of the buffer)
  3561                                  lff44m2_7:
  3562                                  lff44s2_7:
  3563 00001B64 E971F0FFFF              	jmp	lff44_5  ; error
  3564                                  
  3565                                  load_44khz_stereo_16_bit:
  3566                                  	; 18/11/2023
  3567 00001B69 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3568                                  					; last of the file?
  3569 00001B70 7402                    	jz	short lff44s2_0		; no
  3570 00001B72 F9                      	stc
  3571 00001B73 C3                      	retn
  3572                                  
  3573                                  lff44s2_0:
  3574 00001B74 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3575                                          ;mov	edx, [loadsize]
  3576                                  
  3577                                  	; esi = buffer address
  3578                                  	;; edx = buffer size
  3579                                  
  3580                                  	; load file into memory
  3581                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001B79 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001B7F 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001B81 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001B87 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001B8C CD40                <1>  int 40h
  3582 00001B8E 72D4                    	jc	short lff44s2_7 ; error !
  3583                                  
  3584 00001B90 BF[00300000]            	mov	edi, audio_buffer
  3585                                  
  3586 00001B95 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3587 00001B98 7505                    	jnz	short lff44s2_8
  3588 00001B9A E932F0FFFF              	jmp	lff44_eof
  3589                                  
  3590                                  lff44s2_8:
  3591 00001B9F 89C1                    	mov	ecx, eax	; dword count
  3592                                  lff44s2_9:
  3593 00001BA1 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3594 00001BA6 C605[80220000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3595                                  lff44s2_1:
  3596                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3597                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3598 00001BAD 66AD                    	lodsw
  3599 00001BAF 89C3                    	mov	ebx, eax
  3600 00001BB1 66AD                    	lodsw
  3601                                  	;mov	dx, [esi]
  3602                                  	;mov	[next_val_l], dx
  3603                                  	;mov	dx, [esi+2]
  3604                                  	; 26/11/2023
  3605 00001BB3 8B16                    	mov	edx, [esi]
  3606 00001BB5 668915[7C220000]        	mov	[next_val_l], dx
  3607 00001BBC C1EA10                  	shr	edx, 16
  3608 00001BBF 49                      	dec	ecx
  3609 00001BC0 7509                    	jnz	short lff44s2_2_1
  3610 00001BC2 31D2                    	xor	edx, edx ; 0
  3611 00001BC4 668915[7C220000]        	mov	[next_val_l], dx
  3612                                  lff44s2_2_1:
  3613                                  	; bx = [previous_val_l]
  3614                                  	; ax = [previous_val_r]
  3615                                  	; [next_val_l]
  3616                                  	; dx = [next_val_r]
  3617 00001BCB E8E1020000              	call	interpolating_2_16bit_stereo
  3618 00001BD0 E38D                    	jecxz	lff44s2_3
  3619                                  lff44s2_2_2:
  3620                                  	;movsw		; (L)eft Channel
  3621                                  	;movsw		; (R)ight Channel
  3622 00001BD2 A5                      	movsd
  3623                                  
  3624 00001BD3 49                      	dec	ecx
  3625 00001BD4 7489                    	jz	short lff44s2_3	
  3626 00001BD6 4D                      	dec	ebp
  3627 00001BD7 75F9                    	jnz	short lff44s2_2_2
  3628                                  	
  3629 00001BD9 FE0D[80220000]          	dec	byte [faz]
  3630 00001BDF 74C0                    	jz	short lff44s2_9 
  3631 00001BE1 BD0B000000              	mov	ebp, 11
  3632 00001BE6 EBC5                    	jmp	short lff44s2_1
  3633                                  
  3634                                  ; .....................
  3635                                  
  3636                                  	; 02/02/2025
  3637                                  load_12khz_mono_8_bit:
  3638 00001BE8 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3639                                  					; last of the file?
  3640 00001BEF 7402                    	jz	short lff12m_0		; no
  3641 00001BF1 F9                      	stc
  3642 00001BF2 C3                      	retn
  3643                                  
  3644                                  lff12m_0:
  3645 00001BF3 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3646                                  
  3647                                  	; load file into memory
  3648                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001BF8 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001BFE 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001C00 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001C06 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001C0B CD40                <1>  int 40h
  3649 00001C0D 7256                    	jc	short lff12m_7 ; error !
  3650                                  
  3651 00001C0F BF[00300000]            	mov	edi, audio_buffer
  3652                                  	
  3653 00001C14 21C0                    	and	eax, eax
  3654 00001C16 7505                    	jnz	short lff12m_8
  3655 00001C18 E9B4EFFFFF              	jmp	lff12_eof
  3656                                  
  3657                                  lff12m_8:
  3658 00001C1D 89C1                    	mov	ecx, eax	; byte count
  3659                                  lff12m_1:
  3660                                  	; original-interpolated-interpolated-interpolated
  3661 00001C1F AC                      	lodsb
  3662                                  	; 02/02/2025
  3663 00001C20 8A16                    	mov	dl, [esi]
  3664 00001C22 49                      	dec	ecx
  3665 00001C23 7502                    	jnz	short lff12m_2
  3666 00001C25 B280                    	mov	dl, 80h
  3667                                  lff12m_2:	
  3668                                  	; al = [previous_val]
  3669                                  	; dl = [next_val]
  3670 00001C27 E8C0030000               	call	interpolating_4_8bit_mono
  3671 00001C2C E353                    	jecxz	lff12m_3
  3672 00001C2E EBEF                    	jmp	short lff12m_1
  3673                                  
  3674                                  	; 02/02/2025
  3675                                  load_12khz_stereo_8_bit:
  3676 00001C30 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3677                                  					; last of the file?
  3678 00001C37 7402                    	jz	short lff12s_0		; no
  3679 00001C39 F9                      	stc
  3680 00001C3A C3                      	retn
  3681                                  
  3682                                  lff12s_0:
  3683 00001C3B BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3684                                  
  3685                                  	; load file into memory
  3686                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001C40 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001C46 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001C48 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001C4E B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001C53 CD40                <1>  int 40h
  3687 00001C55 720E                    	jc	short lff12s_7 ; error !
  3688                                  
  3689 00001C57 BF[00300000]            	mov	edi, audio_buffer
  3690                                  	
  3691 00001C5C D1E8                    	shr	eax, 1
  3692 00001C5E 750A                    	jnz	short lff12s_8
  3693 00001C60 E96CEFFFFF              	jmp	lff12_eof
  3694                                  
  3695                                  lff12m_7:
  3696                                  lff12s_7:
  3697 00001C65 E970EFFFFF              	jmp	lff12_5  ; error
  3698                                  
  3699                                  lff12s_8:
  3700 00001C6A 89C1                    	mov	ecx, eax	; word count
  3701                                  lff12s_1:
  3702                                  	; original-interpolated-interpolated-interpolated
  3703 00001C6C 66AD                    	lodsw
  3704                                  	; 02/02/2025
  3705 00001C6E 668B16                  	mov	dx, [esi]
  3706 00001C71 49                      	dec	ecx
  3707 00001C72 7504                    	jnz	short lff12s_2
  3708 00001C74 66BA8080                	mov	dx, 8080h
  3709                                  lff12s_2:	
  3710                                  	; al = [previous_val_l]
  3711                                  	; ah = [previous_val_r]
  3712                                  	; dl = [next_val_l]
  3713                                  	; dh = [next_val_r]
  3714 00001C78 E8AE030000              	call	interpolating_4_8bit_stereo
  3715 00001C7D E302                    	jecxz	lff12s_3
  3716 00001C7F EBEB                    	jmp	short lff12s_1
  3717                                  
  3718                                  lff12m_3:
  3719                                  lff12s_3:
  3720 00001C81 E933EFFFFF              	jmp	lff12_3	; padfill
  3721                                  		; (put zeros in the remain words of the buffer)
  3722                                  
  3723                                  	; 02/02/2025
  3724                                  load_12khz_mono_16_bit:
  3725 00001C86 F605[C8250000]01        	test    byte [flags], ENDOFFILE	; have we already read the
  3726                                  					; last of the file?
  3727 00001C8D 7402                    	jz	short lff12m2_0		; no
  3728 00001C8F F9                      	stc
  3729 00001C90 C3                      	retn
  3730                                  
  3731                                  lff12m2_0:
  3732 00001C91 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3733                                  
  3734                                  	; load file into memory
  3735                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001C96 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001C9C 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001C9E 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001CA4 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001CA9 CD40                <1>  int 40h
  3736 00001CAB 7223                    	jc	short lff12m2_7 ; error !
  3737                                  
  3738 00001CAD BF[00300000]            	mov	edi, audio_buffer
  3739                                  	
  3740 00001CB2 D1E8                    	shr	eax, 1
  3741 00001CB4 7505                    	jnz	short lff12m2_8
  3742 00001CB6 E916EFFFFF              	jmp	lff12_eof
  3743                                  
  3744                                  lff12m2_8:
  3745 00001CBB 89C1                    	mov	ecx, eax	; word count
  3746                                  lff12m2_1:
  3747                                  	; original-interpolated-interpolated-interpolated
  3748 00001CBD 66AD                    	lodsw
  3749                                  	; 02/02/2025
  3750 00001CBF 668B16                  	mov	dx, [esi]
  3751 00001CC2 49                      	dec	ecx
  3752 00001CC3 7502                    	jnz	short lff12m2_2
  3753 00001CC5 31D2                    	xor	edx, edx
  3754                                  lff12m2_2:	
  3755                                  	; ax = [previous_val]
  3756                                  	; dx = [next_val]
  3757 00001CC7 E8F6040000               	call	interpolating_4_16bit_mono
  3758 00001CCC E3B3                    	jecxz	lff12m_3
  3759 00001CCE EBED                    	jmp	short lff12m2_1
  3760                                  
  3761                                  lff12m2_7:
  3762                                  lff12s2_7:
  3763 00001CD0 E905EFFFFF              	jmp	lff12_5  ; error
  3764                                  
  3765                                  	; 02/02/2025
  3766                                  load_12khz_stereo_16_bit:
  3767 00001CD5 F605[C8250000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3768                                  					; last of the file?
  3769 00001CDC 7402                    	jz	short lff12s2_0		; no
  3770 00001CDE F9                      	stc
  3771 00001CDF C3                      	retn
  3772                                  
  3773                                  lff12s2_0:
  3774 00001CE0 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3775                                  
  3776                                  	; load file into memory
  3777                                  	sys 	_read, [FileHandle], esi, [loadsize]
    73                              <1> 
    74                              <1> 
    75                              <1> 
    76                              <1> 
    77                              <1>  %if %0 >= 2
    78 00001CE5 8B1D[81220000]      <1>  mov ebx, %2
    79                              <1>  %if %0 >= 3
    80 00001CEB 89F1                <1>  mov ecx, %3
    81                              <1>  %if %0 = 4
    82 00001CED 8B15[1E040000]      <1>  mov edx, %4
    83                              <1>  %endif
    84                              <1>  %endif
    85                              <1>  %endif
    86 00001CF3 B803000000          <1>  mov eax, %1
    87                              <1> 
    88 00001CF8 CD40                <1>  int 40h
  3778 00001CFA 72D4                    	jc	short lff12s2_7 ; error !
  3779                                  
  3780 00001CFC BF[00300000]            	mov	edi, audio_buffer
  3781                                  	
  3782 00001D01 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3783 00001D04 750A                    	jnz	short lff12s2_8
  3784 00001D06 E9C6EEFFFF              	jmp	lff12_eof
  3785                                  
  3786                                  lff12m2_3:
  3787                                  lff12s2_3:
  3788 00001D0B E9A9EEFFFF              	jmp	lff12_3	; padfill
  3789                                  		; (put zeros in the remain words of the buffer)
  3790                                  
  3791                                  lff12s2_8:
  3792 00001D10 89C1                    	mov	ecx, eax	; dword count
  3793                                  lff12s2_1:
  3794                                  	; original-interpolated-interpolated-interpolated
  3795 00001D12 66AD                    	lodsw
  3796 00001D14 89C3                    	mov	ebx, eax
  3797 00001D16 66AD                    	lodsw
  3798 00001D18 8B16                    	mov	edx, [esi]
  3799 00001D1A 49                      	dec	ecx
  3800 00001D1B 7502                    	jnz	short lff12s2_2
  3801 00001D1D 31D2                    	xor	edx, edx ; 0
  3802                                  lff12s2_2:
  3803                                  	;mov	[next_val_l], dx
  3804                                  	;shr	edx, 16
  3805                                  	;mov	[next_val_r], dx
  3806                                  	; 02/02/2025
  3807 00001D1F 8915[7C220000]          	mov	[next_val_l], edx
  3808                                  
  3809                                  	; bx = [previous_val_l]
  3810                                  	; ax = [previous_val_r]
  3811                                  	; [next_val_l]
  3812                                  	; [next_val_r]
  3813 00001D25 E8D1040000              	call	interpolating_4_16bit_stereo
  3814 00001D2A E3DF                    	jecxz	lff12s2_3
  3815 00001D2C EBE4                    	jmp	short lff12s2_1
  3816                                  
  3817                                  ; .....................
  3818                                  
  3819                                  interpolating_3_8bit_mono:
  3820                                  	; 02/02/2025
  3821                                  	; 16/11/2023
  3822                                  	; al = [previous_val]
  3823                                  	; dl = [next_val]
  3824                                  	; original-interpolated-interpolated
  3825 00001D2E 88C3                    	mov	bl, al
  3826 00001D30 2C80                    	sub	al, 80h
  3827 00001D32 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3828 00001D36 66AB                    	stosw		; original sample (L)
  3829 00001D38 66AB                    	stosw		; original sample (R)
  3830 00001D3A 88D8                    	mov	al, bl
  3831 00001D3C 00D0                    	add	al, dl
  3832 00001D3E D0D8                    	rcr	al, 1
  3833 00001D40 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3834 00001D42 00D8                    	add	al, bl
  3835 00001D44 D0D8                    	rcr	al, 1
  3836 00001D46 2C80                    	sub	al, 80h
  3837 00001D48 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3838 00001D4C 66AB                    	stosw		; interpolated sample 1 (L)
  3839 00001D4E 66AB                    	stosw		; interpolated sample 1 (R)
  3840 00001D50 88F8                    	mov	al, bh
  3841 00001D52 00D0                    	add	al, dl	; [next_val]
  3842 00001D54 D0D8                    	rcr	al, 1
  3843                                  	; 02/02/2025
  3844 00001D56 2C80                    	sub	al, 80h
  3845 00001D58 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3846 00001D5C 66AB                    	stosw		; interpolated sample 2 (L)
  3847 00001D5E 66AB                    	stosw		; interpolated sample 2 (R)
  3848 00001D60 C3                      	retn
  3849                                  
  3850                                  interpolating_3_8bit_stereo:
  3851                                  	; 02/02/2025
  3852                                  	; 16/11/2023
  3853                                  	; al = [previous_val_l]
  3854                                  	; ah = [previous_val_r]
  3855                                  	; dl = [next_val_l]
  3856                                  	; dh = [next_val_r]	
  3857                                  	; original-interpolated-interpolated
  3858 00001D61 89C3                    	mov	ebx, eax
  3859 00001D63 2C80                    	sub	al, 80h
  3860 00001D65 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3861 00001D69 66AB                    	stosw		; original sample (L)
  3862 00001D6B 88F8                    	mov	al, bh
  3863 00001D6D 2C80                    	sub	al, 80h
  3864 00001D6F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3865 00001D73 66AB                    	stosw		; original sample (R)
  3866 00001D75 88D8                    	mov	al, bl
  3867 00001D77 00D0                    	add	al, dl	; [next_val_l]
  3868 00001D79 D0D8                    	rcr	al, 1
  3869 00001D7B 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3870 00001D7C 00D8                    	add	al, bl	; [previous_val_l]
  3871 00001D7E D0D8                    	rcr	al, 1
  3872 00001D80 2C80                    	sub	al, 80h
  3873 00001D82 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3874 00001D86 66AB                    	stosw		; interpolated sample 1 (L)
  3875 00001D88 88F8                    	mov	al, bh
  3876 00001D8A 00F0                    	add	al, dh	; [next_val_r]
  3877 00001D8C D0D8                    	rcr	al, 1
  3878 00001D8E 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3879 00001D8F 00F8                    	add	al, bh	; [previous_val_r]
  3880 00001D91 D0D8                    	rcr	al, 1
  3881 00001D93 2C80                    	sub	al, 80h
  3882 00001D95 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3883 00001D99 66AB                    	stosw		; interpolated sample 1 (R)
  3884 00001D9B 5B                      	pop	ebx ; **
  3885 00001D9C 58                      	pop	eax ; *
  3886 00001D9D 00D0                    	add	al, dl	; [next_val_l]
  3887 00001D9F D0D8                    	rcr	al, 1
  3888                                  	; 02/02/2025
  3889 00001DA1 2C80                    	sub	al, 80h
  3890 00001DA3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3891 00001DA7 66AB                    	stosw		; interpolated sample 2 (L)
  3892 00001DA9 88D8                    	mov	al, bl
  3893 00001DAB 00F0                    	add	al, dh	; [next_val_r]
  3894 00001DAD D0D8                    	rcr	al, 1
  3895                                  	; 02/02/2025
  3896 00001DAF 2C80                    	sub	al, 80h
  3897 00001DB1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3898 00001DB5 66AB                    	stosw		; interpolated sample 2 (R)
  3899 00001DB7 C3                      	retn
  3900                                  
  3901                                  interpolating_2_8bit_mono:
  3902                                  	; 16/11/2023
  3903                                  	; al = [previous_val]
  3904                                  	; dl = [next_val]
  3905                                  	; original-interpolated
  3906 00001DB8 88C3                    	mov	bl, al
  3907 00001DBA 2C80                    	sub	al, 80h
  3908 00001DBC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3909 00001DC0 66AB                    	stosw		; original sample (L)
  3910 00001DC2 66AB                    	stosw		; original sample (R)
  3911 00001DC4 88D8                    	mov	al, bl
  3912 00001DC6 00D0                    	add	al, dl
  3913 00001DC8 D0D8                    	rcr	al, 1
  3914 00001DCA 2C80                    	sub	al, 80h
  3915 00001DCC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3916 00001DD0 66AB                    	stosw		; interpolated sample (L)
  3917 00001DD2 66AB                    	stosw		; interpolated sample (R)
  3918 00001DD4 C3                      	retn
  3919                                  
  3920                                  interpolating_2_8bit_stereo:
  3921                                  	; 16/11/2023
  3922                                  	; al = [previous_val_l]
  3923                                  	; ah = [previous_val_r]
  3924                                  	; dl = [next_val_l]
  3925                                  	; dh = [next_val_r]
  3926                                  	; original-interpolated
  3927 00001DD5 89C3                    	mov	ebx, eax
  3928 00001DD7 2C80                    	sub	al, 80h
  3929 00001DD9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3930 00001DDD 66AB                    	stosw		; original sample (L)
  3931 00001DDF 88F8                    	mov	al, bh
  3932 00001DE1 2C80                    	sub	al, 80h
  3933 00001DE3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3934 00001DE7 66AB                    	stosw		; original sample (R)
  3935 00001DE9 88D8                    	mov	al, bl	; [previous_val_l]
  3936 00001DEB 00D0                    	add	al, dl	; [next_val_l]
  3937 00001DED D0D8                    	rcr	al, 1
  3938 00001DEF 2C80                    	sub	al, 80h
  3939 00001DF1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3940 00001DF5 66AB                    	stosw		; interpolated sample (L)
  3941 00001DF7 88F8                    	mov	al, bh
  3942 00001DF9 00F0                    	add	al, dh	; [next_val_r]
  3943 00001DFB D0D8                    	rcr	al, 1
  3944 00001DFD 2C80                    	sub	al, 80h
  3945 00001DFF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3946 00001E03 66AB                    	stosw		; interpolated sample (R)
  3947 00001E05 C3                      	retn
  3948                                  
  3949                                  interpolating_3_16bit_mono:
  3950                                  	; 16/11/2023
  3951                                  	; ax = [previous_val]
  3952                                  	; dx = [next_val]
  3953                                  	; original-interpolated-interpolated
  3954                                  
  3955 00001E06 66AB                    	stosw		; original sample (L)
  3956 00001E08 66AB                    	stosw		; original sample (R)
  3957 00001E0A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3958 00001E0D 50                      	push	eax ; *	; [previous_val]
  3959 00001E0E 80C680                  	add	dh, 80h
  3960 00001E11 6601D0                  	add	ax, dx
  3961 00001E14 66D1D8                  	rcr	ax, 1
  3962 00001E17 5B                      	pop	ebx ; *
  3963 00001E18 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3964 00001E19 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3965 00001E1C 66D1D8                  	rcr	ax, 1
  3966 00001E1F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3967 00001E22 66AB                    	stosw 		; interpolated sample 1 (L)
  3968 00001E24 66AB                    	stosw		; interpolated sample 1 (R)
  3969 00001E26 89D8                    	mov	eax, ebx
  3970 00001E28 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  3971 00001E2B 66D1D8                  	rcr	ax, 1
  3972 00001E2E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3973 00001E31 66AB                    	stosw		; interpolated sample 2 (L)
  3974 00001E33 66AB                    	stosw		; interpolated sample 2 (R)
  3975 00001E35 C3                      	retn
  3976                                  
  3977                                  interpolating_3_16bit_stereo:
  3978                                  	; 16/11/2023
  3979                                  	; bx = [previous_val_l]
  3980                                  	; ax = [previous_val_r]
  3981                                  	; [next_val_l]
  3982                                  	; dx = [next_val_r]
  3983                                  	; original-interpolated-interpolated
  3984                                  
  3985 00001E36 93                      	xchg	eax, ebx
  3986 00001E37 66AB                    	stosw		; original sample (L)
  3987 00001E39 93                      	xchg	eax, ebx
  3988 00001E3A 66AB                    	stosw		; original sample (R)
  3989 00001E3C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3990 00001E3F 50                      	push	eax ; *	; [previous_val_r]
  3991 00001E40 80C780                  	add	bh, 80h
  3992 00001E43 8005[7D220000]80        	add	byte [next_val_l+1], 80h
  3993 00001E4A 66A1[7C220000]          	mov	ax, [next_val_l]
  3994 00001E50 6601D8                  	add	ax, bx	; [previous_val_l]
  3995 00001E53 66D1D8                  	rcr	ax, 1
  3996 00001E56 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  3997 00001E57 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3998 00001E5A 66D1D8                  	rcr	ax, 1
  3999 00001E5D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4000 00001E60 66AB                    	stosw 		; interpolated sample 1 (L)
  4001 00001E62 58                      	pop	eax  ; *
  4002 00001E63 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  4003 00001E66 52                      	push	edx  ; * ; [next_val_r]
  4004 00001E67 92                      	xchg	eax, edx
  4005 00001E68 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  4006 00001E6B 66D1D8                  	rcr	ax, 1	; / 2
  4007 00001E6E 50                      	push	eax ; ** ; interpolated middle (R)
  4008 00001E6F 6601D0                  	add	ax, dx	; + [previous_val_r]
  4009 00001E72 66D1D8                  	rcr	ax, 1
  4010 00001E75 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4011 00001E78 66AB                    	stosw 		; interpolated sample 1 (R)
  4012 00001E7A 66A1[7C220000]          	mov	ax, [next_val_l]
  4013 00001E80 6601D8                  	add	ax, bx	; + interpolated middle (L)
  4014 00001E83 66D1D8                  	rcr	ax, 1
  4015 00001E86 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4016 00001E89 66AB                    	stosw 		; interpolated sample 2 (L)
  4017 00001E8B 58                      	pop	eax ; **
  4018 00001E8C 5A                      	pop	edx ; *
  4019 00001E8D 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  4020 00001E90 66D1D8                  	rcr	ax, 1	; / 2
  4021 00001E93 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4022 00001E96 66AB                    	stosw 		; interpolated sample 2 (L)
  4023 00001E98 C3                      	retn
  4024                                  
  4025                                  interpolating_2_16bit_mono:
  4026                                  	; 16/11/2023
  4027                                  	; ax = [previous_val]
  4028                                  	; dx = [next_val]
  4029                                  	; original-interpolated
  4030                                  
  4031 00001E99 66AB                    	stosw		; original sample (L)
  4032 00001E9B 66AB                    	stosw		; original sample (R)
  4033 00001E9D 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4034 00001EA0 80C680                  	add	dh, 80h
  4035 00001EA3 6601D0                  	add	ax, dx
  4036 00001EA6 66D1D8                  	rcr	ax, 1
  4037 00001EA9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4038 00001EAC 66AB                    	stosw		; interpolated sample (L)
  4039 00001EAE 66AB                    	stosw		; interpolated sample (R)
  4040 00001EB0 C3                      	retn
  4041                                  
  4042                                  interpolating_2_16bit_stereo:
  4043                                  	; 17/01/2025
  4044                                  	; 16/11/2023
  4045                                  	; bx = [previous_val_l]
  4046                                  	; ax = [previous_val_r]
  4047                                  	; [next_val_l]
  4048                                  	; dx = [next_val_r]
  4049                                  	; original-interpolated
  4050                                  
  4051 00001EB1 93                      	xchg	eax, ebx
  4052 00001EB2 66AB                    	stosw		; original sample (L)
  4053 00001EB4 93                      	xchg	eax, ebx
  4054 00001EB5 66AB                    	stosw		; original sample (R)
  4055 00001EB7 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4056 00001EBA 80C680                  	add	dh, 80h
  4057 00001EBD 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  4058 00001EC0 66D1D8                  	rcr	ax, 1	; / 2
  4059                                  	; 17/01/2025
  4060 00001EC3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4061                                  	;push	eax ; *	; interpolated sample (R)
  4062                                  	; 17/01/2025
  4063 00001EC6 C1E010                  	shl	eax, 16
  4064 00001EC9 66A1[7C220000]          	mov	ax, [next_val_l]
  4065 00001ECF 80C480                  	add	ah, 80h
  4066 00001ED2 80C780                  	add	bh, 80h
  4067 00001ED5 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  4068 00001ED8 66D1D8                  	rcr	ax, 1	; / 2
  4069 00001EDB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4070                                  	; 17/01/2025
  4071                                  	;stosw 		; interpolated sample (L)
  4072                                  	;pop	eax ; *
  4073                                  	;sub	ah, 80h	; -32768 to +32767 format again
  4074                                  	;stosw 		; interpolated sample (R)
  4075                                  	; 17/01/2025
  4076 00001EDE AB                      	stosd
  4077 00001EDF C3                      	retn
  4078                                  
  4079                                  interpolating_5_8bit_mono:
  4080                                  	; 17/11/2023
  4081                                  	; al = [previous_val]
  4082                                  	; dl = [next_val]
  4083                                  	; original-interpltd-interpltd-interpltd-interpltd
  4084 00001EE0 88C3                    	mov	bl, al
  4085 00001EE2 2C80                    	sub	al, 80h
  4086 00001EE4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4087 00001EE8 66AB                    	stosw		; original sample (L)
  4088 00001EEA 66AB                    	stosw		; original sample (R)
  4089 00001EEC 88D8                    	mov	al, bl
  4090 00001EEE 00D0                    	add	al, dl
  4091 00001EF0 D0D8                    	rcr	al, 1
  4092 00001EF2 88C7                    	mov	bh, al	; interpolated middle (temporary)
  4093 00001EF4 00D8                    	add	al, bl  ; [previous_val]
  4094 00001EF6 D0D8                    	rcr	al, 1 	
  4095 00001EF8 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  4096 00001EFA 00D8                    	add	al, bl
  4097 00001EFC D0D8                    	rcr	al, 1
  4098 00001EFE 2C80                    	sub	al, 80h
  4099 00001F00 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4100 00001F04 66AB                    	stosw		; interpolated sample 1 (L)
  4101 00001F06 66AB                    	stosw		; interpolated sample 1 (R)
  4102 00001F08 88F8                    	mov	al, bh
  4103 00001F0A 00F0                    	add	al, dh
  4104 00001F0C D0D8                    	rcr	al, 1
  4105 00001F0E 2C80                    	sub	al, 80h
  4106 00001F10 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4107 00001F14 66AB                    	stosw		; interpolated sample 2 (L)
  4108 00001F16 66AB                    	stosw		; interpolated sample 2 (R)
  4109 00001F18 88F8                    	mov	al, bh
  4110 00001F1A 00D0                    	add	al, dl	; [next_val]
  4111 00001F1C D0D8                    	rcr	al, 1
  4112 00001F1E 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  4113 00001F20 00F8                    	add	al, bh
  4114 00001F22 D0D8                    	rcr	al, 1
  4115 00001F24 2C80                    	sub	al, 80h
  4116 00001F26 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4117 00001F2A 66AB                    	stosw		; interpolated sample 3 (L)
  4118 00001F2C 66AB                    	stosw		; interpolated sample 3 (R)
  4119 00001F2E 88F0                    	mov	al, dh
  4120 00001F30 00D0                    	add	al, dl
  4121 00001F32 D0D8                    	rcr	al, 1
  4122 00001F34 2C80                    	sub	al, 80h
  4123 00001F36 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4124 00001F3A 66AB                    	stosw		; interpolated sample 4 (L)
  4125 00001F3C 66AB                    	stosw		; interpolated sample 4 (R)
  4126 00001F3E C3                      	retn
  4127                                  
  4128                                  interpolating_5_8bit_stereo:
  4129                                  	; 17/11/2023
  4130                                  	; al = [previous_val_l]
  4131                                  	; ah = [previous_val_r]
  4132                                  	; dl = [next_val_l]
  4133                                  	; dh = [next_val_r]
  4134                                  	; original-interpltd-interpltd-interpltd-interpltd
  4135 00001F3F 89C3                    	mov	ebx, eax
  4136 00001F41 2C80                    	sub	al, 80h
  4137 00001F43 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4138 00001F47 66AB                    	stosw		; original sample (L)
  4139 00001F49 88F8                    	mov	al, bh
  4140 00001F4B 2C80                    	sub	al, 80h
  4141 00001F4D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4142 00001F51 66AB                    	stosw		; original sample (R)
  4143 00001F53 52                      	push	edx ; *
  4144 00001F54 88D8                    	mov	al, bl
  4145 00001F56 00D0                    	add	al, dl	; [next_val_l]
  4146 00001F58 D0D8                    	rcr	al, 1
  4147 00001F5A 50                      	push	eax ; ** ; al = interpolated middle (L) (temporary)
  4148 00001F5B 00D8                    	add	al, bl	; [previous_val_l]
  4149 00001F5D D0D8                    	rcr	al, 1
  4150 00001F5F 86D8                    	xchg	al, bl
  4151 00001F61 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  4152 00001F63 D0D8                    	rcr	al, 1
  4153 00001F65 2C80                    	sub	al, 80h
  4154 00001F67 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4155 00001F6B 66AB                    	stosw		; interpolated sample 1 (L)
  4156 00001F6D 88F8                    	mov	al, bh
  4157 00001F6F 00F0                    	add	al, dh	; [next_val_r]
  4158 00001F71 D0D8                    	rcr	al, 1
  4159 00001F73 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  4160 00001F74 00F8                    	add	al, bh	; [previous_val_r]
  4161 00001F76 D0D8                    	rcr	al, 1
  4162 00001F78 86F8                    	xchg	al, bh
  4163 00001F7A 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  4164 00001F7C D0D8                    	rcr	al, 1
  4165 00001F7E 2C80                    	sub	al, 80h
  4166 00001F80 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4167 00001F84 66AB                    	stosw		; interpolated sample 1 (R)
  4168 00001F86 5A                      	pop	edx ; ***
  4169 00001F87 58                      	pop	eax ; ** ; al = interpolated middle (L) (temporary)
  4170 00001F88 86D8                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  4171 00001F8A 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  4172 00001F8C D0D8                    	rcr	al, 1
  4173 00001F8E 2C80                    	sub	al, 80h
  4174 00001F90 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4175 00001F94 66AB                    	stosw		; interpolated sample 2 (L)	
  4176 00001F96 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  4177 00001F98 86F8                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  4178 00001F9A 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  4179 00001F9C D0D8                    	rcr	al, 1
  4180 00001F9E 2C80                    	sub	al, 80h
  4181 00001FA0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4182 00001FA4 66AB                    	stosw		; interpolated sample 2 (R)
  4183 00001FA6 5A                      	pop	edx ; *
  4184 00001FA7 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  4185 00001FA9 00D0                    	add	al, dl	; [next_val_l]
  4186 00001FAB D0D8                    	rcr	al, 1
  4187 00001FAD 86D8                    	xchg	al, bl	; al = interpolated middle (R) (temporary)
  4188 00001FAF 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  4189 00001FB1 D0D8                    	rcr	al, 1
  4190 00001FB3 2C80                    	sub	al, 80h
  4191 00001FB5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4192 00001FB9 66AB                    	stosw		; interpolated sample 3 (L)
  4193 00001FBB 88F8                    	mov	al, bh	
  4194 00001FBD 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  4195 00001FBF D0D8                    	rcr	al, 1
  4196 00001FC1 86F8                    	xchg	al, bh	; al = interpolated middle (R)
  4197 00001FC3 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  4198 00001FC5 D0D8                    	rcr	al, 1
  4199 00001FC7 2C80                    	sub	al, 80h
  4200 00001FC9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4201 00001FCD 66AB                    	stosw		; interpolated sample 3 (R)
  4202 00001FCF 88D8                    	mov	al, bl
  4203 00001FD1 00D0                    	add	al, dl	; [next_val_l]
  4204 00001FD3 D0D8                    	rcr	al, 1
  4205 00001FD5 2C80                    	sub	al, 80h
  4206 00001FD7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4207 00001FDB 66AB                    	stosw		; interpolated sample 4 (L)
  4208 00001FDD 88F8                    	mov	al, bh
  4209 00001FDF 00F0                    	add	al, dh	; [next_val_r]
  4210 00001FE1 D0D8                    	rcr	al, 1
  4211 00001FE3 2C80                    	sub	al, 80h
  4212 00001FE5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4213 00001FE9 66AB                    	stosw		; interpolated sample 4 (R)
  4214 00001FEB C3                      	retn
  4215                                  
  4216                                  interpolating_4_8bit_mono:
  4217                                  	; 17/11/2023
  4218                                  	; al = [previous_val]
  4219                                  	; dl = [next_val]
  4220                                  	; original-interpolated-interpolated-interpolated
  4221 00001FEC 88C3                    	mov	bl, al
  4222 00001FEE 2C80                    	sub	al, 80h
  4223 00001FF0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4224 00001FF4 66AB                    	stosw		; original sample (L)
  4225 00001FF6 66AB                    	stosw		; original sample (R)
  4226 00001FF8 88D8                    	mov	al, bl
  4227 00001FFA 00D0                    	add	al, dl
  4228 00001FFC D0D8                    	rcr	al, 1
  4229 00001FFE 86D8                    	xchg	al, bl  ; al = [previous_val]
  4230 00002000 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  4231 00002002 D0D8                    	rcr	al, 1
  4232 00002004 2C80                    	sub	al, 80h
  4233 00002006 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4234 0000200A 66AB                    	stosw		; interpolated sample 1 (L)
  4235 0000200C 66AB                    	stosw		; interpolated sample 1 (R)
  4236 0000200E 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  4237 00002010 2C80                    	sub	al, 80h
  4238 00002012 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4239 00002016 66AB                    	stosw		; interpolated sample 2 (L)
  4240 00002018 66AB                    	stosw		; interpolated sample 2 (R)
  4241 0000201A 88D8                    	mov	al, bl
  4242 0000201C 00D0                    	add	al, dl	; [next_val]
  4243 0000201E D0D8                    	rcr	al, 1
  4244 00002020 2C80                    	sub	al, 80h
  4245 00002022 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4246 00002026 66AB                    	stosw		; interpolated sample 3 (L)
  4247 00002028 66AB                    	stosw		; interpolated sample 3 (R)
  4248 0000202A C3                      	retn
  4249                                  
  4250                                  interpolating_4_8bit_stereo:
  4251                                  	; 17/11/2023
  4252                                  	; al = [previous_val_l]
  4253                                  	; ah = [previous_val_r]
  4254                                  	; dl = [next_val_l]
  4255                                  	; dh = [next_val_r]
  4256                                  	; original-interpolated-interpolated-interpolated
  4257 0000202B 89C3                    	mov	ebx, eax
  4258 0000202D 2C80                    	sub	al, 80h
  4259 0000202F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4260 00002033 66AB                    	stosw		; original sample (L)
  4261 00002035 88F8                    	mov	al, bh
  4262 00002037 2C80                    	sub	al, 80h
  4263 00002039 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4264 0000203D 66AB                    	stosw		; original sample (R)
  4265 0000203F 88D8                    	mov	al, bl
  4266 00002041 00D0                    	add	al, dl	; [next_val_l]
  4267 00002043 D0D8                    	rcr	al, 1
  4268 00002045 86D8                    	xchg	al, bl	; al = [previous_val_l]
  4269 00002047 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  4270 00002049 D0D8                    	rcr	al, 1
  4271 0000204B 2C80                    	sub	al, 80h
  4272 0000204D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4273 00002051 66AB                    	stosw		; interpolated sample 1 (L)
  4274 00002053 88F8                    	mov	al, bh
  4275 00002055 00F0                    	add	al, dh	; [next_val_r]
  4276 00002057 D0D8                    	rcr	al, 1
  4277 00002059 86F8                    	xchg	al, bh	; al = [previous_val_h]
  4278 0000205B 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  4279 0000205D D0D8                    	rcr	al, 1
  4280 0000205F 2C80                    	sub	al, 80h
  4281 00002061 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4282 00002065 66AB                    	stosw		; interpolated sample 1 (R)
  4283 00002067 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  4284 00002069 2C80                    	sub	al, 80h
  4285 0000206B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4286 0000206F 66AB                    	stosw		; interpolated sample 2 (L)
  4287 00002071 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  4288 00002073 2C80                    	sub	al, 80h
  4289 00002075 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4290 00002079 66AB                    	stosw		; interpolated sample 2 (L)
  4291 0000207B 88D8                    	mov	al, bl
  4292 0000207D 00D0                    	add	al, dl	; [next_val_l]
  4293 0000207F D0D8                    	rcr	al, 1
  4294 00002081 2C80                    	sub	al, 80h
  4295 00002083 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4296 00002087 66AB                    	stosw		; interpolated sample 3 (L)
  4297 00002089 88F8                    	mov	al, bh
  4298 0000208B 00F0                    	add	al, dh	; [next_val_r]
  4299 0000208D D0D8                    	rcr	al, 1
  4300 0000208F 2C80                    	sub	al, 80h
  4301 00002091 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4302 00002095 66AB                    	stosw		; interpolated sample 3 (R)
  4303 00002097 C3                      	retn
  4304                                  
  4305                                  interpolating_5_16bit_mono:
  4306                                  	; 18/11/2023
  4307                                  	; ax = [previous_val]
  4308                                  	; dx = [next_val]
  4309                                  	; original-interpltd-interpltd-interpltd-interpltd
  4310 00002098 66AB                    	stosw		; original sample (L)
  4311 0000209A 66AB                    	stosw		; original sample (R)
  4312 0000209C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4313 0000209F 89C3                    	mov	ebx, eax ; [previous_val]
  4314 000020A1 80C680                  	add	dh, 80h
  4315 000020A4 6601D0                  	add	ax, dx
  4316 000020A7 66D1D8                  	rcr	ax, 1
  4317 000020AA 50                      	push	eax ; *	; interpolated middle (temporary)
  4318 000020AB 6601D8                  	add	ax, bx	; interpolated middle + [previous_val]
  4319 000020AE 66D1D8                  	rcr	ax, 1
  4320 000020B1 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  4321 000020B2 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  4322 000020B5 66D1D8                  	rcr	ax, 1	
  4323 000020B8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4324 000020BB 66AB                    	stosw 		; interpolated sample 1 (L)
  4325 000020BD 66AB                    	stosw		; interpolated sample 1 (R)
  4326 000020BF 58                      	pop	eax ; **
  4327 000020C0 5B                      	pop	ebx ; *
  4328 000020C1 6601D8                  	add	ax, bx	; 1st quarter + middle
  4329 000020C4 66D1D8                  	rcr	ax, 1	; / 2
  4330 000020C7 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  4331 000020CA 66AB                    	stosw		; interpolated sample 2 (L)
  4332 000020CC 66AB                    	stosw		; interpolated sample 2 (R)
  4333 000020CE 89D8                    	mov	eax, ebx
  4334 000020D0 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4335 000020D3 66D1D8                  	rcr	ax, 1
  4336 000020D6 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  4337 000020D7 6601D8                  	add	ax, bx	; + interpolated middle
  4338 000020DA 66D1D8                  	rcr	ax, 1
  4339 000020DD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4340 000020E0 66AB                    	stosw		; interpolated sample 3 (L)
  4341 000020E2 66AB                    	stosw		; interpolated sample 3 (R)
  4342 000020E4 58                      	pop	eax ; *	
  4343 000020E5 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  4344 000020E8 66D1D8                  	rcr	ax, 1	; / 2
  4345 000020EB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4346 000020EE 66AB                    	stosw		; interpolated sample 4 (L)
  4347 000020F0 66AB                    	stosw		; interpolated sample 4 (R)
  4348 000020F2 C3                      	retn
  4349                                  
  4350                                  interpolating_5_16bit_stereo:
  4351                                  	; 18/11/2023
  4352                                  	; bx = [previous_val_l]
  4353                                  	; ax = [previous_val_r]
  4354                                  	; [next_val_l]
  4355                                  	; [next_val_r]
  4356                                  	; original-interpltd-interpltd-interpltd-interpltd
  4357 000020F3 51                      	push	ecx ; !
  4358 000020F4 93                      	xchg	eax, ebx
  4359 000020F5 66AB                    	stosw		; original sample (L)
  4360 000020F7 93                      	xchg	eax, ebx
  4361 000020F8 66AB                    	stosw		; original sample (R)
  4362 000020FA 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4363 000020FD 50                      	push	eax ; *	; [previous_val_r]
  4364 000020FE 80C780                  	add	bh, 80h
  4365 00002101 8005[7D220000]80        	add	byte [next_val_l+1], 80h
  4366 00002108 66A1[7C220000]          	mov	ax, [next_val_l]
  4367 0000210E 6601D8                  	add	ax, bx	; [previous_val_l]
  4368 00002111 66D1D8                  	rcr	ax, 1
  4369 00002114 89C1                    	mov	ecx, eax ; interpolated middle (L)
  4370 00002116 6601D8                  	add	ax, bx	
  4371 00002119 66D1D8                  	rcr	ax, 1
  4372 0000211C 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)
  4373 0000211E 6601D8                  	add	ax, bx	; [previous_val_l]
  4374 00002121 66D1D8                  	rcr	ax, 1
  4375 00002124 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4376 00002127 66AB                    	stosw 		; interpolated sample 1 (L)
  4377 00002129 89C8                    	mov	eax, ecx
  4378 0000212B 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L)
  4379 0000212E 66D1D8                  	rcr	ax, 1	; / 2
  4380 00002131 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  4381 00002133 5A                      	pop	edx ; *	; [previous_val_r]
  4382 00002134 89D0                    	mov	eax, edx
  4383 00002136 8005[7F220000]80        	add	byte [next_val_r+1], 80h
  4384 0000213D 660305[7E220000]        	add	ax, [next_val_r]
  4385 00002144 66D1D8                  	rcr	ax, 1
  4386 00002147 50                      	push	eax ; *	; interpolated middle (R)
  4387 00002148 6601D0                  	add	ax, dx
  4388 0000214B 66D1D8                  	rcr	ax, 1
  4389 0000214E 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  4390 0000214F 6601D0                  	add	ax, dx	; [previous_val_r]
  4391 00002152 66D1D8                  	rcr	ax, 1
  4392 00002155 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4393 00002158 66AB                    	stosw 		; interpolated sample 1 (R)
  4394 0000215A 89D8                    	mov	eax, ebx
  4395 0000215C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4396 0000215F 66AB                    	stosw 		; interpolated sample 2 (L)
  4397 00002161 58                      	pop	eax ; **
  4398 00002162 5A                      	pop	edx ; *
  4399 00002163 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  4400 00002166 66D1D8                  	rcr	ax, 1	; / 2
  4401 00002169 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4402 0000216C 66AB                    	stosw 		; interpolated sample 2 (R)
  4403 0000216E 89C8                    	mov	eax, ecx
  4404 00002170 660305[7C220000]        	add	ax, [next_val_l]
  4405 00002177 66D1D8                  	rcr	ax, 1
  4406 0000217A 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  4407 0000217B 6601C8                  	add	ax, cx	; interpolated middle (L)
  4408 0000217E 66D1D8                  	rcr	ax, 1
  4409 00002181 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4410 00002184 66AB                    	stosw 		; interpolated sample 3 (L)
  4411 00002186 89D0                    	mov	eax, edx
  4412 00002188 660305[7E220000]        	add	ax, [next_val_r]
  4413 0000218F 66D1D8                  	rcr	ax, 1
  4414 00002192 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4415 00002193 6601D0                  	add	ax, dx	; interpolated middle (R)
  4416 00002196 66D1D8                  	rcr	ax, 1
  4417 00002199 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4418 0000219C 66AB                    	stosw 		; interpolated sample 3 (R)
  4419 0000219E 5B                      	pop	ebx ; **
  4420 0000219F 58                      	pop	eax ; *
  4421 000021A0 660305[7C220000]        	add	ax, [next_val_l]
  4422 000021A7 66D1D8                  	rcr	ax, 1
  4423 000021AA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4424 000021AD 66AB                    	stosw 		; interpolated sample 4 (L)
  4425 000021AF 89D8                    	mov	eax, ebx	
  4426 000021B1 660305[7E220000]        	add	ax, [next_val_r]
  4427 000021B8 66D1D8                  	rcr	ax, 1
  4428 000021BB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4429 000021BE 66AB                    	stosw 		; interpolated sample 4 (R)
  4430 000021C0 59                      	pop	ecx ; !
  4431 000021C1 C3                      	retn
  4432                                  
  4433                                  interpolating_4_16bit_mono:
  4434                                  	; 18/11/2023
  4435                                  	; ax = [previous_val]
  4436                                  	; dx = [next_val]
  4437                                  	; 02/02/2025
  4438                                  	; original-interpolated-interpolated-interpolated
  4439                                  
  4440 000021C2 66AB                    	stosw		; original sample (L)
  4441 000021C4 66AB                    	stosw		; original sample (R)
  4442 000021C6 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4443 000021C9 89C3                    	mov	ebx, eax ; [previous_val]
  4444 000021CB 80C680                  	add	dh, 80h
  4445 000021CE 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4446 000021D1 66D1D8                  	rcr	ax, 1
  4447 000021D4 93                      	xchg	eax, ebx
  4448 000021D5 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4449 000021D8 66D1D8                  	rcr	ax, 1
  4450 000021DB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4451 000021DE 66AB                    	stosw 		; interpolated sample 1 (L)
  4452 000021E0 66AB                    	stosw		; interpolated sample 1 (R)
  4453 000021E2 89D8                    	mov	eax, ebx ; interpolated middle
  4454 000021E4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4455 000021E7 66AB                    	stosw 		; interpolated sample 2 (L)
  4456 000021E9 66AB                    	stosw		; interpolated sample 2 (R)
  4457 000021EB 89D8                    	mov	eax, ebx
  4458 000021ED 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4459 000021F0 66D1D8                  	rcr	ax, 1
  4460 000021F3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4461 000021F6 66AB                    	stosw		; interpolated sample 3 (L)
  4462 000021F8 66AB                    	stosw		; interpolated sample 3 (R)
  4463 000021FA C3                      	retn
  4464                                  
  4465                                  interpolating_4_16bit_stereo:
  4466                                  	; 18/11/2023
  4467                                  	; bx = [previous_val_l]
  4468                                  	; ax = [previous_val_r]
  4469                                  	; [next_val_l]
  4470                                  	; [next_val_r]
  4471                                  	; original-interpolated-interpolated-interpolated
  4472 000021FB 93                      	xchg	eax, ebx
  4473 000021FC 66AB                    	stosw		; original sample (L)
  4474 000021FE 93                      	xchg	eax, ebx
  4475 000021FF 66AB                    	stosw		; original sample (R)
  4476 00002201 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4477 00002204 89C2                    	mov	edx, eax ; [previous_val_r]
  4478 00002206 80C780                  	add	bh, 80h
  4479 00002209 8005[7D220000]80        	add	byte [next_val_l+1], 80h
  4480 00002210 66A1[7C220000]          	mov	ax, [next_val_l]
  4481 00002216 6601D8                  	add	ax, bx	; [previous_val_l]
  4482 00002219 66D1D8                  	rcr	ax, 1
  4483 0000221C 93                      	xchg	eax, ebx	
  4484 0000221D 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4485 00002220 66D1D8                  	rcr	ax, 1
  4486 00002223 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4487 00002226 66AB                    	stosw 		; interpolated sample 1 (L)
  4488 00002228 8005[7F220000]80        	add	byte [next_val_r+1], 80h
  4489 0000222F 89D0                    	mov	eax, edx ; [previous_val_r]
  4490 00002231 660305[7E220000]        	add	ax, [next_val_r]
  4491 00002238 66D1D8                  	rcr	ax, 1
  4492 0000223B 92                      	xchg	eax, edx	
  4493 0000223C 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4494 0000223F 66D1D8                  	rcr	ax, 1
  4495 00002242 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4496 00002245 66AB                    	stosw 		; interpolated sample 1 (R)
  4497 00002247 89D8                    	mov	eax, ebx
  4498 00002249 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4499 0000224C 66AB                    	stosw 		; interpolated sample 2 (L)
  4500 0000224E 89D0                    	mov	eax, edx
  4501 00002250 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4502 00002253 66AB                    	stosw 		; interpolated sample 2 (R)
  4503 00002255 89D8                    	mov	eax, ebx
  4504 00002257 660305[7C220000]        	add	ax, [next_val_l]
  4505 0000225E 66D1D8                  	rcr	ax, 1
  4506 00002261 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4507 00002264 66AB                    	stosw 		; interpolated sample 3 (L)
  4508 00002266 89D0                    	mov	eax, edx
  4509 00002268 660305[7E220000]        	add	ax, [next_val_r]
  4510 0000226F 66D1D8                  	rcr	ax, 1
  4511 00002272 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4512 00002275 66AB                    	stosw 		; interpolated sample 3 (R)
  4513 00002277 C3                      	retn
  4514                                  
  4515                                  ; 13/11/2023
  4516                                  previous_val:
  4517 00002278 0000                    previous_val_l: dw 0
  4518 0000227A 0000                    previous_val_r: dw 0
  4519                                  next_val:
  4520 0000227C 0000                    next_val_l: dw 0
  4521 0000227E 0000                    next_val_r: dw 0
  4522                                  
  4523                                  ; 16/11/2023
  4524 00002280 00                      faz:	db 0
  4525                                  	
  4526                                  ; --------------------------------------------------------
  4527                                  
  4528                                  ; DATA
  4529                                  
  4530                                  FileHandle:	
  4531 00002281 FFFFFFFF                	dd	-1
  4532                                  
  4533                                  Credits:
  4534 00002285 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  4534 0000228E 506C6179657220666F-
  4534 00002297 72205452444F532033-
  4534 000022A0 383620627920457264-
  4534 000022A9 6F67616E2054616E2E-
  4534 000022B2 20                 
  4535                                  	;;;;;db	'August 2020.',10,13,0
  4536                                  	;;;;db	'November 2023.',10,13,0
  4537                                  	;;;db	'June 2024.', 10,13,0
  4538                                  	;;db	'December 2024.', 10,13,0
  4539                                  	;db	'January 2025.', 10,13,0
  4540 000022B3 466562727561727920-     	db	'February 2025.', 10,13,0
  4540 000022BC 323032352E0A0D00   
  4541 000022C4 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  4541 000022CD 370A0D00           
  4542 000022D1 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  4542 000022DA 300A0D00           
  4543 000022DE 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  4543 000022E7 330A0D00           
  4544 000022EB 30312F30362F323032-     	db	'01/06/2024', 10,13,0
  4544 000022F4 340A0D00           
  4545 000022F8 30362F30362F323032-     	db	'06/06/2024', 10,13,0
  4545 00002301 340A0D00           
  4546 00002305 30382F31322F323032-     	db	'08/12/2024', 10,13,0
  4546 0000230E 340A0D00           
  4547 00002312 31342F31322F323032-     	db	'14/12/2024', 10,13,0
  4547 0000231B 340A0D00           
  4548 0000231F 31372F30312F323032-     	db	'17/01/2025', 10,13,0
  4548 00002328 350A0D00           
  4549 0000232C 30322F30322F323032-     	db	'02/02/2025', 10,13,0
  4549 00002335 350A0D00           
  4550                                  
  4551                                  msgAudioCardInfo:
  4552 00002339 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  4552 00002342 204143393720284943-
  4552 0000234B 482920417564696F20-
  4552 00002354 436F6E74726F6C6C65-
  4552 0000235D 722E0A0D00         
  4553                                  
  4554                                  msg_usage:
  4555 00002362 75736167653A20706C-     	db	'usage: playwav6 filename.wav',10,13,0
  4555 0000236B 617977617636206669-
  4555 00002374 6C656E616D652E7761-
  4555 0000237D 760A0D00           
  4556                                  
  4557                                  noDevMsg:
  4558 00002381 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  4558 0000238A 61626C6520746F2066-
  4558 00002393 696E64204143393720-
  4558 0000239C 617564696F20646576-
  4558 000023A5 69636521           
  4559 000023A9 0A0D00                  	db	10,13,0
  4560                                  
  4561                                  noFileErrMsg:
  4562 000023AC 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  4562 000023B5 6C65206E6F7420666F-
  4562 000023BE 756E642E0A0D00     
  4563                                  
  4564                                  trdos386_err_msg:
  4565 000023C5 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  4565 000023CE 2053797374656D2063-
  4565 000023D7 616C6C206572726F72-
  4565 000023E0 20210A0D00         
  4566                                  
  4567                                  ; 01/06/2024
  4568                                  msg_init_err:
  4569 000023E5 0A0D                    	db	10,13
  4570 000023E7 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  4570 000023F0 726F6C6C65722F436F-
  4570 000023F9 64656320696E697469-
  4570 00002402 616C697A6174696F6E-
  4570 0000240B 206572726F722021   
  4571 00002413 0A0D00                  	db	10,13,0
  4572                                  
  4573                                  ; 25/11/2023
  4574                                  msg_no_vra:
  4575 00002416 0A0D                    	db	10,13
  4576 00002418 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  4576 00002421 70706F72742021204F-
  4576 0000242A 6E6C79203438206B48-
  4576 00002433 5A2073616D706C6520-
  4576 0000243C 726174652073757070-
  4576 00002445 6F727465642021     
  4577 0000244C 0A0D00                  	db	10,13,0
  4578                                  
  4579 0000244F 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  4579 00002458 65204E616D653A2000 
  4580 00002461 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  4580 0000246A 526174653A20       
  4581 00002470 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  4581 00002479 2000               
  4582 0000247B 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  4583 00002484 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  4584 0000248B 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  4584 00002494 00                 
  4585 00002495 53746572656F            msgStereo:	db "Stereo"
  4586 0000249B 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  4587                                  
  4588                                  ; 03/06/2017
  4589 0000249E 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  4589 000024A7 3941424344454600   
  4590 000024AF 0D0A                    msgAC97Info	db 0Dh, 0Ah
  4591 000024B1 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  4591 000024BA 6F20436F6E74726F6C-
  4591 000024C3 6C6572202620436F64-
  4591 000024CC 656320496E666F0D0A 
  4592 000024D5 56656E646F72204944-     		db "Vendor ID: "
  4592 000024DE 3A20               
  4593 000024E0 303030306820446576-     msgVendorId	db "0000h Device ID: "
  4593 000024E9 6963652049443A20   
  4594 000024F1 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  4595 000024F8 4275733A20              		db "Bus: "
  4596 000024FD 303068204465766963-     msgBusNo	db "00h Device: "
  4596 00002506 653A20             
  4597 00002509 3030682046756E6374-     msgDevNo	db "00h Function: "
  4597 00002512 696F6E3A20         
  4598 00002517 303068                  msgFncNo	db "00h"
  4599 0000251A 0D0A                    		db 0Dh, 0Ah
  4600 0000251C 4E414D4241523A20        		db "NAMBAR: "
  4601 00002524 30303030682020          msgNamBar	db "0000h  "
  4602 0000252B 4E41424D4241523A20      		db "NABMBAR: "
  4603 00002534 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  4603 0000253D 513A20             
  4604 00002540 3030                    msgIRQ		dw 3030h
  4605 00002542 0D0A00                  		db 0Dh, 0Ah, 0
  4606                                  ; 06/06/2024
  4607 00002545 0D0A                    msgCodec	db 0Dh, 0Ah
  4608 00002547 434F44454320            		db "CODEC "
  4609 0000254D 0D0A                    		db 0Dh, 0Ah
  4610 0000254F 56656E646F72204944-     		db "Vendor ID1: "
  4610 00002558 313A20             
  4611 0000255B 30303030682020          msgCodecId1	db "0000h  "
  4612 00002562 56656E646F72204944-     		db "Vendor ID2: "
  4612 0000256B 323A20             
  4613 0000256E 30303030682020          msgCodecId2	db "0000h  "  
  4614                                  ; 25/11/2023
  4615 00002575 0D0A00                  		db 0Dh, 0Ah, 0
  4616 00002578 56524120737570706F-     msgVRAheader:	db "VRA support: "
  4616 00002581 72743A20           
  4617 00002585 00                      		db 0	
  4618 00002586 5945530D0A00            msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  4619 0000258C 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  4620 00002591 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  4620 0000259A 617465642073616D70-
  4620 000025A3 6C6520726174652070-
  4620 000025AC 6C6179696E67206D65-
  4620 000025B5 74686F6429         
  4621 000025BA 0D0A00                  		db 0Dh, 0Ah, 0	
  4622                                  EOF: 
  4623                                  
  4624                                  ; BSS
  4625                                  
  4626                                  bss_start:
  4627                                  
  4628                                  ABSOLUTE bss_start
  4629                                  
  4630 000025BD ??????                  alignb 4
  4631                                  
  4632 000025C0 ??                      stmo:		resb 1 ; stereo or mono (1=stereo) 
  4633 000025C1 ??                      bps:		resb 1 ; bits per sample (8,16)
  4634 000025C2 ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  4635                                  
  4636                                  ; 25/11/2023
  4637 000025C4 ????????                bufferSize:	resd 1
  4638                                  
  4639 000025C8 ??                      flags:		resb 1
  4640                                  ;cbs_busy:	resb 1 
  4641 000025C9 ??                      half_buff:	resb 1
  4642 000025CA ??                      srb:		resb 1
  4643                                  ; 18/08/2020
  4644 000025CB ??                      volume_level:	resb 1
  4645                                  ; 25/11/2023
  4646 000025CC ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  4647                                  
  4648 000025CD <res 1Ch>               smpRBuff:	resw 14 
  4649                                  
  4650                                  wav_file_name:
  4651 000025E9 <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  4652                                  
  4653 00002639 ????                    		resw 1
  4654 0000263B ??                      ac97_int_ln_reg: resb 1
  4655 0000263C ??                      fbs_shift:	resb 1 ; 26/11/2023
  4656 0000263D ????????                dev_vendor:	resd 1
  4657 00002641 ????????                bus_dev_fn:	resd 1
  4658 00002645 ????                    ac97_NamBar:	resw 1
  4659 00002647 ????                    ac97_NabmBar:	resw 1
  4660                                  
  4661                                  bss_end:
  4662 00002649 <res 9B7h>              alignb 4096
  4663                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  4664                                  ; 26/11/2023
  4665 00003000 <res 10000h>            audio_buffer:	resb 65536
  4666                                  ; 13/06/2017
  4667                                  ;temp_buffer:	resb BUFFERSIZE
  4668                                  ; 26/11/2023
  4669 00013000 <res 10000h>            temp_buffer:	resb 65536
