     1                                  ; ****************************************************************************
     2                                  ; playwav8.s (for TRDOS 386)
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; PLAYWAV8.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 playwav8.s -l playwav8.txt -o PLAYWAV8.PRG	
    14                                  ; ----------------------------------------------------------------------------
    15                                  ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
    16                                  
    17                                  ; playwav6.s (04/06/2024)
    18                                  ; playwav3.s (17/06/2017)
    19                                  
    20                                  ; 04/06/2024 (non-VRA simuation)
    21                                  ; Interpolated sampling rate version (48 kHz - VRA disabled) - playwav8.s-
    22                                  
    23                                  ; CODE
    24                                  
    25                                  ; 20/10/2024
    26                                  ; 20/08/2024 ; TRDOS 386 v2.0.9
    27                                  ; TRDOS 386 system calls
    28                                  _ver 	equ 0
    29                                  _exit 	equ 1
    30                                  _fork 	equ 2
    31                                  _read 	equ 3
    32                                  _write	equ 4
    33                                  _open	equ 5
    34                                  _close 	equ 6
    35                                  _wait 	equ 7
    36                                  _creat 	equ 8
    37                                  _rename equ 9
    38                                  _delete equ 10
    39                                  _exec	equ 11
    40                                  _chdir	equ 12
    41                                  _time 	equ 13
    42                                  _mkdir 	equ 14
    43                                  _chmod	equ 15
    44                                  _rmdir	equ 16
    45                                  _break	equ 17
    46                                  _drive	equ 18
    47                                  _seek	equ 19
    48                                  _tell 	equ 20
    49                                  _mem	equ 21
    50                                  _prompt	equ 22
    51                                  _path	equ 23
    52                                  _env	equ 24
    53                                  _stime	equ 25
    54                                  _quit	equ 26
    55                                  _intr	equ 27
    56                                  _dir	equ 28
    57                                  _emt 	equ 29
    58                                  _ldvrt 	equ 30
    59                                  _video 	equ 31
    60                                  _audio	equ 32
    61                                  _timer	equ 33
    62                                  _sleep	equ 34
    63                                  _msg    equ 35
    64                                  _geterr	equ 36
    65                                  _fpsave	equ 37
    66                                  _pri	equ 38
    67                                  _rele	equ 39
    68                                  _fff	equ 40
    69                                  _fnf	equ 41
    70                                  _alloc	equ 42
    71                                  _dalloc equ 43
    72                                  _calbac equ 44
    73                                  _dma	equ 45
    74                                  _stdio  equ 46	;  TRDOS 386 v2.0.9
    75                                  
    76                                  %macro sys 1-4
    77                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    78                                      ; 03/09/2015	
    79                                      ; 13/04/2015
    80                                      ; Retro UNIX 386 v1 system call.
    81                                      %if %0 >= 2
    82                                          mov ebx, %2
    83                                          %if %0 >= 3
    84                                              mov ecx, %3
    85                                              %if %0 = 4
    86                                                 mov edx, %4
    87                                              %endif
    88                                          %endif
    89                                      %endif
    90                                      mov eax, %1
    91                                      ;int 30h
    92                                      int 40h ; TRDOS 386 (TRDOS v2.0)
    93                                  %endmacro
    94                                  
    95                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    96                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    97                                  
    98                                  BUFFERSIZE	equ	32768	; audio buffer size 
    99                                  ENDOFFILE       equ     1	; flag for knowing end of file
   100                                  
   101                                  [BITS 32]
   102                                  
   103                                  [ORG 0] 
   104                                  
   105                                  _STARTUP:
   106                                  	; Prints the Credits Text.
   107                                  	sys	_msg, Credits, 255, 0Bh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000000 BB[9B210000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000005 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000000A BA0B000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000000F B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000014 CD40                <1>  int 40h
   108                                  
   109                                  	; clear bss
   110 00000016 B9[19250000]            	mov	ecx, bss_end
   111 0000001B BF[8D240000]            	mov	edi, bss_start
   112 00000020 29F9                    	sub	ecx, edi
   113 00000022 D1E9                    	shr	ecx, 1
   114 00000024 31C0                    	xor	eax, eax
   115 00000026 F366AB                  	rep	stosw
   116                                  
   117                                  	; Detect (& Enable) AC'97 Audio Device
   118 00000029 E8C8040000              	call	DetectAC97
   119 0000002E 731B                    	jnc     short GetFileName
   120                                  
   121                                  _dev_not_ready:
   122                                  ; couldn't find the audio device!
   123                                  	sys	_msg, noDevMsg, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000030 BB[8A220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000035 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000003A BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000003F B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000044 CD40                <1>  int 40h
   124 00000046 E985040000                      jmp     Exit
   125                                  
   126                                  GetFileName:  
   127 0000004B 89E6                    	mov	esi, esp
   128 0000004D AD                      	lodsd
   129 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   130                                  	       ; (program file name & mod file name)
   131 00000051 0F8287040000            	jb	pmsg_usage ; nothing to do
   132                                  
   133 00000057 AD                      	lodsd ; program file name address 
   134 00000058 AD                      	lodsd ; mod file name address (file to be read)
   135 00000059 89C6                    	mov	esi, eax
   136 0000005B BF[B9240000]            	mov	edi, wav_file_name
   137                                  ScanName:       
   138 00000060 AC                      	lodsb
   139 00000061 84C0                    	test	al, al
   140 00000063 0F8475040000            	je	pmsg_usage
   141 00000069 3C20                    	cmp	al, 20h
   142 0000006B 74F3                    	je	short ScanName	; scan start of name.
   143 0000006D AA                      	stosb
   144 0000006E B4FF                    	mov	ah, 0FFh
   145                                  a_0:	
   146 00000070 FEC4                    	inc	ah
   147                                  a_1:
   148 00000072 AC                      	lodsb
   149 00000073 AA                      	stosb
   150 00000074 3C2E                    	cmp	al, '.'
   151 00000076 74F8                    	je	short a_0	
   152 00000078 20C0                    	and	al, al
   153 0000007A 75F6                    	jnz	short a_1
   154                                  
   155 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   156 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   157                                  SetExt:
   158 00000080 4F                      	dec	edi
   159 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   160 00000087 C6470400                	mov	byte [edi+4], 0
   161                                  
   162                                  _1:
   163                                  
   164                                  ; 26/11/2023
   165                                  %if 0
   166                                  	; Allocate Audio Buffer (for user)
   167                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   168                                  	; 26/11/2023
   169                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   170                                  	jnc	short _2
   171                                  error_exit:
   172                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   173                                  	jmp	Exit
   174                                  _2:
   175                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   176                                  	; bl = 0, bh = 4
   177                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   178                                  
   179                                  	sys	_video, 0400h
   180                                  	cmp	eax, 0B8000h
   181                                  	jne	short error_exit
   182                                  
   183                                  	; Initialize Audio Device (bh = 3)
   184                                  	sys	_audio, 0301h, 0, audio_int_handler 
   185                                  ;	jc	short error_exit
   186                                  _3:
   187                                  
   188                                  %endif
   189 0000008B E8AF060000              	call	write_audio_dev_info 
   190                                  
   191                                  ; open the file
   192                                          ; open existing file
   193 00000090 E86E040000                      call    openFile ; no error? ok.
   194 00000095 731B                            jnc     short _gsr
   195                                  
   196                                  ; file not found!
   197                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000097 BB[B5220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000009C B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000000A1 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000000A6 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000000AB CD40                <1>  int 40h
   198                                  _exit_:
   199 000000AD E91E040000                      jmp     Exit
   200                                  
   201                                  _gsr:  
   202 000000B2 E886040000                     	call    getSampleRate		; read the sample rate
   203                                                                          ; pass it onto codec.
   204                                  	;jc	Exit
   205                                  	; 25/11/2023
   206 000000B7 72F4                    	jc	short _exit_
   207                                  
   208 000000B9 66A3[92240000]          	mov	[sample_rate], ax
   209 000000BF 880D[90240000]          	mov	[stmo], cl
   210 000000C5 8815[91240000]          	mov	[bps], dl
   211                                  
   212                                  	; 26/11/2023
   213 000000CB C605[0C250000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   214 000000D2 FEC9                    	dec	cl
   215 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   216 000000D6 FE05[0C250000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   217                                  _gsr_1:	
   218 000000DC 80FA08                  	cmp	dl, 8 
   219 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   220 000000E1 FE05[0C250000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   221                                  _gsr_2:	
   222                                  	; 06/06/2017
   223                                  	sys	_audio, 0E00h ; get audio controller info
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000000E7 BB000E0000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000000EC B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000000F1 CD40                <1>  int 40h
   224 000000F3 0F822B030000            	jc	error_exit ; 25/11/2023
   225                                  
   226                                  	;cmp	ah, 2 ; ICH ? (Intel AC'97 Audio Controller)
   227                                  	;jne	_dev_not_ready	
   228                                  
   229                                  	; EAX = IRQ Number in AL
   230                                  	;	Audio Device Number in AH 
   231                                  	; EBX = DEV/VENDOR ID
   232                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   233                                  	; ECX = BUS/DEV/FN 
   234                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   235                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   236                                  	;      (Low word, DX = NAMBAR address)
   237                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   238                                  
   239 000000F9 A2[0B250000]            	mov	[ac97_int_ln_reg], al
   240 000000FE 891D[0D250000]          	mov	[dev_vendor], ebx
   241 00000104 890D[11250000]          	mov	[bus_dev_fn], ecx
   242                                  	;mov	[ac97_NamBar], dx
   243                                  	;shr	dx, 16
   244                                  	;mov	[ac97_NabmBar], dx
   245 0000010A 8915[15250000]          	mov	[ac97_NamBar], edx	
   246                                    
   247                                  	; 01/06/2024
   248                                  	; Reset Audio Device (bh = 8)
   249                                  	sys	_audio, 0800h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000110 BB00080000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000115 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 0000011A CD40                <1>  int 40h
   250                                  	;jc	error_exit	
   251 0000011C 7216                    	jc	short init_err
   252                                  
   253 0000011E E8FE060000              	call	write_ac97_pci_dev_info
   254                                  
   255                                  ; 04/06/2024
   256                                  %if 0
   257                                  	; 01/06/2024
   258                                  	; 25/11/2023
   259                                  	; Get AC'97 Codec info
   260                                  	; (Function 14, sub function 1)
   261                                  	sys	_audio, 0E01h
   262                                  	; Save Variable Rate Audio support bit
   263                                  	and	al, 1
   264                                  	mov	[VRA], al
   265                                  %endif
   266                                  
   267                                  	; 25/11/2023
   268 00000123 E8C0080000              	call	write_VRA_info
   269                                  
   270                                  	; 01/05/2017
   271 00000128 E829060000              	call	write_wav_file_info
   272                                  
   273                                  	; 25/11/2023
   274                                  	; ------------------------------------------
   275                                  
   276                                  ; 04/06/2024
   277                                  %if 0
   278                                  	cmp	byte [VRA], 1
   279                                  	jb	short chk_sample_rate
   280                                  %else
   281                                  	; 04/06/2024
   282                                  	; (non-VRA simulation)
   283 0000012D EB20                    	jmp	short chk_sample_rate
   284                                  %endif
   285                                  
   286                                  playwav_48_khz:	
   287                                  	;mov	dword [loadfromwavfile], loadFromFile
   288                                  	;mov	dword [buffersize], 65536
   289 0000012F E9D7020000              	jmp	PlayNow
   290                                  
   291                                  	; 01/06/2024
   292                                  init_err:
   293                                  	sys	_msg, msg_init_err, 255, 0Eh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000134 BB[EE220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000139 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000013E BA0E000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000143 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000148 CD40                <1>  int 40h
   294 0000014A E981030000              	jmp	Exit
   295                                  
   296                                  	; 02/02/2025
   297                                  chk_sample_rate:
   298                                  	; set conversion parameters
   299                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   300 0000014F 66A1[92240000]          	mov	ax, [sample_rate]
   301 00000155 663D80BB                	cmp	ax, 48000
   302 00000159 74D4                    	je	short playwav_48_khz
   303                                  chk_22khz:
   304 0000015B 663D2256                	cmp	ax, 22050
   305 0000015F 7545                    	jne	short chk_11khz
   306 00000161 803D[91240000]08        	cmp	byte [bps], 8
   307 00000168 7615                    	jna	short chk_22khz_1
   308 0000016A BB[5C160000]            	mov	ebx, load_22khz_stereo_16_bit
   309 0000016F 803D[90240000]01        	cmp	byte [stmo], 1 
   310 00000176 751A                    	jne	short chk_22khz_2
   311 00000178 BB[CF150000]            	mov	ebx, load_22khz_mono_16_bit
   312 0000017D EB13                    	jmp	short chk_22khz_2
   313                                  chk_22khz_1:
   314 0000017F BB[48150000]            	mov	ebx, load_22khz_stereo_8_bit
   315 00000184 803D[90240000]01        	cmp	byte [stmo], 1 
   316 0000018B 7505                    	jne	short chk_22khz_2
   317 0000018D BB[BF140000]            	mov	ebx, load_22khz_mono_8_bit
   318                                  chk_22khz_2:
   319 00000192 B85A1D0000              	mov	eax, 7514  ; (442*17)
   320 00000197 BA25000000              	mov	edx, 37
   321 0000019C B911000000              	mov	ecx, 17 
   322 000001A1 E9BA010000              	jmp	set_sizes	
   323                                  chk_11khz:
   324 000001A6 663D112B                	cmp	ax, 11025
   325 000001AA 7545                    	jne	short chk_44khz
   326 000001AC 803D[91240000]08        	cmp	byte [bps], 8
   327 000001B3 7615                    	jna	short chk_11khz_1
   328 000001B5 BB[78180000]            	mov	ebx, load_11khz_stereo_16_bit
   329 000001BA 803D[90240000]01        	cmp	byte [stmo], 1 
   330 000001C1 751A                    	jne	short chk_11khz_2
   331 000001C3 BB[FF170000]            	mov	ebx, load_11khz_mono_16_bit
   332 000001C8 EB13                    	jmp	short chk_11khz_2
   333                                  chk_11khz_1:
   334 000001CA BB[85170000]            	mov	ebx, load_11khz_stereo_8_bit
   335 000001CF 803D[90240000]01        	cmp	byte [stmo], 1 
   336 000001D6 7505                    	jne	short chk_11khz_2
   337 000001D8 BB[0D170000]            	mov	ebx, load_11khz_mono_8_bit
   338                                  chk_11khz_2:
   339 000001DD B8AD0E0000              	mov	eax, 3757  ; (221*17)
   340 000001E2 BA4A000000              	mov	edx, 74
   341 000001E7 B911000000              	mov	ecx, 17
   342 000001EC E96F010000              	jmp	set_sizes 
   343                                  chk_44khz:
   344 000001F1 663D44AC                	cmp	ax, 44100
   345 000001F5 7545                    	jne	short chk_16khz
   346 000001F7 803D[91240000]08        	cmp	byte [bps], 8
   347 000001FE 7615                    	jna	short chk_44khz_1
   348 00000200 BB[7F1A0000]            	mov	ebx, load_44khz_stereo_16_bit
   349 00000205 803D[90240000]01        	cmp	byte [stmo], 1 
   350 0000020C 751A                    	jne	short chk_44khz_2
   351 0000020E BB[061A0000]            	mov	ebx, load_44khz_mono_16_bit
   352 00000213 EB13                    	jmp	short chk_44khz_2
   353                                  chk_44khz_1:
   354 00000215 BB[89190000]            	mov	ebx, load_44khz_stereo_8_bit
   355 0000021A 803D[90240000]01        	cmp	byte [stmo], 1 
   356 00000221 7505                    	jne	short chk_44khz_2
   357 00000223 BB[0D190000]            	mov	ebx, load_44khz_mono_8_bit
   358                                  chk_44khz_2:
   359 00000228 B8D93A0000              	mov	eax, 15065 ; (655*23)
   360 0000022D BA19000000              	mov	edx, 25
   361 00000232 B917000000              	mov	ecx, 23
   362 00000237 E924010000              	jmp	set_sizes 
   363                                  chk_16khz:
   364 0000023C 663D803E                	cmp	ax, 16000
   365 00000240 7545                    	jne	short chk_8khz
   366 00000242 803D[91240000]08        	cmp	byte [bps], 8
   367 00000249 7615                    	jna	short chk_16khz_1
   368 0000024B BB[FE0F0000]            	mov	ebx, load_16khz_stereo_16_bit
   369 00000250 803D[90240000]01        	cmp	byte [stmo], 1 
   370 00000257 751A                    	jne	short chk_16khz_2
   371 00000259 BB[7D0F0000]            	mov	ebx, load_16khz_mono_16_bit
   372 0000025E EB13                    	jmp	short chk_16khz_2
   373                                  chk_16khz_1:
   374 00000260 BB[C30E0000]            	mov	ebx, load_16khz_stereo_8_bit
   375 00000265 803D[90240000]01        	cmp	byte [stmo], 1 
   376 0000026C 7505                    	jne	short chk_16khz_2
   377 0000026E BB[440E0000]            	mov	ebx, load_16khz_mono_8_bit
   378                                  chk_16khz_2:
   379 00000273 B855150000              	mov	eax, 5461
   380 00000278 BA03000000              	mov	edx, 3
   381 0000027D B901000000              	mov	ecx, 1
   382 00000282 E9D9000000              	jmp	set_sizes 
   383                                  chk_8khz:
   384 00000287 663D401F                	cmp	ax, 8000
   385 0000028B 7545                    	jne	short chk_24khz
   386 0000028D 803D[91240000]08        	cmp	byte [bps], 8
   387 00000294 7615                    	jna	short chk_8khz_1
   388 00000296 BB[F90C0000]            	mov	ebx, load_8khz_stereo_16_bit
   389 0000029B 803D[90240000]01        	cmp	byte [stmo], 1 
   390 000002A2 751A                    	jne	short chk_8khz_2
   391 000002A4 BB[290C0000]            	mov	ebx, load_8khz_mono_16_bit
   392 000002A9 EB13                    	jmp	short chk_8khz_2
   393                                  chk_8khz_1:
   394 000002AB BB[F90A0000]            	mov	ebx, load_8khz_stereo_8_bit
   395 000002B0 803D[90240000]01        	cmp	byte [stmo], 1 
   396 000002B7 7505                    	jne	short chk_8khz_2
   397 000002B9 BB[150A0000]            	mov	ebx, load_8khz_mono_8_bit
   398                                  chk_8khz_2:
   399 000002BE B8AA0A0000              	mov	eax, 2730
   400 000002C3 BA06000000              	mov	edx, 6
   401 000002C8 B901000000              	mov	ecx, 1
   402 000002CD E98E000000              	jmp	set_sizes 
   403                                  chk_24khz:
   404 000002D2 663DC05D                	cmp	ax, 24000
   405 000002D6 7542                    	jne	short chk_32khz
   406 000002D8 803D[91240000]08        	cmp	byte [bps], 8
   407 000002DF 7615                    	jna	short chk_24khz_1
   408 000002E1 BB[2B120000]            	mov	ebx, load_24khz_stereo_16_bit
   409 000002E6 803D[90240000]01        	cmp	byte [stmo], 1 
   410 000002ED 751A                    	jne	short chk_24khz_2
   411 000002EF BB[C5110000]            	mov	ebx, load_24khz_mono_16_bit
   412 000002F4 EB13                    	jmp	short chk_24khz_2
   413                                  chk_24khz_1:
   414 000002F6 BB[3B110000]            	mov	ebx, load_24khz_stereo_8_bit
   415 000002FB 803D[90240000]01        	cmp	byte [stmo], 1 
   416 00000302 7505                    	jne	short chk_24khz_2
   417 00000304 BB[D4100000]            	mov	ebx, load_24khz_mono_8_bit
   418                                  chk_24khz_2:
   419 00000309 B800200000              	mov	eax, 8192
   420 0000030E BA02000000              	mov	edx, 2
   421 00000313 B901000000              	mov	ecx, 1
   422 00000318 EB46                    	jmp	short set_sizes 
   423                                  chk_32khz:
   424 0000031A 663D007D                	cmp	ax, 32000
   425                                  	;jne	short vra_needed
   426                                  	; 02/02/2025
   427 0000031E 7579                    	jne	short chk_12khz
   428 00000320 803D[91240000]08        	cmp	byte [bps], 8
   429 00000327 7615                    	jna	short chk_32khz_1
   430 00000329 BB[2F140000]            	mov	ebx, load_32khz_stereo_16_bit
   431 0000032E 803D[90240000]01        	cmp	byte [stmo], 1 
   432 00000335 751A                    	jne	short chk_32khz_2
   433 00000337 BB[C2130000]            	mov	ebx, load_32khz_mono_16_bit
   434 0000033C EB13                    	jmp	short chk_32khz_2
   435                                  chk_32khz_1:
   436 0000033E BB[25130000]            	mov	ebx, load_32khz_stereo_8_bit
   437 00000343 803D[90240000]01        	cmp	byte [stmo], 1 
   438 0000034A 7505                    	jne	short chk_32khz_2
   439 0000034C BB[B2120000]            	mov	ebx, load_32khz_mono_8_bit
   440                                  chk_32khz_2:
   441 00000351 B8AA2A0000              	mov	eax, 10922
   442 00000356 BA03000000              	mov	edx, 3
   443 0000035B B902000000              	mov	ecx, 2
   444                                  	;jmp	short set_sizes 
   445                                  set_sizes:
   446 00000360 803D[90240000]01        	cmp	byte [stmo], 1
   447 00000367 7402                    	je	short ss_1
   448 00000369 D1E0                    	shl	eax, 1
   449                                  ss_1:
   450 0000036B 803D[91240000]08        	cmp	byte [bps], 8
   451 00000372 7602                    	jna	short ss_2
   452                                  	; 16 bit samples
   453 00000374 D1E0                    	shl	eax, 1
   454                                  ss_2:
   455 00000376 A3[03040000]            	mov	[loadsize], eax
   456 0000037B F7E2                    	mul	edx
   457                                  	;cmp	ecx, 1
   458                                  	;je	short ss_3
   459                                  ;ss_3:
   460 0000037D F7F1                    	div	ecx
   461 0000037F 8A0D[0C250000]          	mov	cl, [fbs_shift]
   462 00000385 D3E0                    	shl	eax, cl
   463                                  	; 26/11/2023
   464                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   465                                  
   466                                  	;;;
   467                                  	; 04/06/2024 (8 byte alignment for BDL)
   468 00000387 83C007                  	add	eax, 7
   469 0000038A 24F8                    	and	al, ~7
   470                                  	;;;
   471                                  
   472 0000038C A3[07040000]            	mov	[buffersize], eax ; buffer size in bytes 
   473 00000391 891D[FF030000]          	mov	[loadfromwavfile], ebx
   474 00000397 EB72                    	jmp	short PlayNow
   475                                  
   476                                  	;;;;
   477                                  	; 02/02/2025
   478                                  chk_12khz:
   479 00000399 663DE02E                	cmp	ax, 12000
   480 0000039D 7545                    	jne	short vra_needed
   481 0000039F 803D[91240000]08        	cmp	byte [bps], 8
   482 000003A6 7615                    	jna	short chk_12khz_1
   483 000003A8 BB[EB1B0000]            	mov	ebx, load_12khz_stereo_16_bit
   484 000003AD 803D[90240000]01        	cmp	byte [stmo], 1 
   485 000003B4 751A                    	jne	short chk_12khz_2
   486 000003B6 BB[9C1B0000]            	mov	ebx, load_12khz_mono_16_bit
   487 000003BB EB13                    	jmp	short chk_12khz_2
   488                                  chk_12khz_1:
   489 000003BD BB[461B0000]            	mov	ebx, load_12khz_stereo_8_bit
   490 000003C2 803D[90240000]01        	cmp	byte [stmo], 1 
   491 000003C9 7505                    	jne	short chk_12khz_2
   492 000003CB BB[FE1A0000]            	mov	ebx, load_12khz_mono_8_bit
   493                                  chk_12khz_2:
   494 000003D0 B800100000              	mov	eax, 4096
   495 000003D5 BA04000000              	mov	edx, 4
   496 000003DA B901000000              	mov	ecx, 1
   497 000003DF E97CFFFFFF              	jmp	set_sizes 
   498                                  	;;;;
   499                                  
   500                                  vra_needed:
   501                                  	sys	_msg, msg_no_vra, 255, 07h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000003E4 BB[1F230000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000003E9 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000003EE BA07000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000003F3 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000003F8 CD40                <1>  int 40h
   502 000003FA E9D1000000              	jmp	Exit
   503                                  
   504                                  	; 26/11/2023
   505                                  	; 13/11/2023
   506                                  loadfromwavfile:
   507 000003FF [AF050000]              	dd	loadFromFile
   508                                  loadsize:	; read from wav file
   509 00000403 00000000                	dd	0
   510                                  buffersize:	; write to DMA buffer
   511 00000407 00000100                	dd	65536 ; bytes
   512                                  
   513                                  PlayNow: 
   514                                  
   515                                  ; 26/11/2023
   516                                  %if 1
   517                                  	; Allocate Audio Buffer (for user)
   518                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   519                                  	; 26/11/2023
   520                                  	sys	_audio, 0200h, [buffersize], audio_buffer
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000040B BB00020000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000410 8B0D[07040000]      <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000416 BA[00300000]        <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000041B B820000000          <1>  mov eax, %1
    91                              <1> 
    92 00000420 CD40                <1>  int 40h
   521 00000422 731B                    	jnc	short _2
   522                                  
   523                                  	; 26/11/2023 - temporary
   524                                  	;sys	_msg, test_1, 255, 0Ch
   525                                  
   526                                  error_exit:
   527                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000424 BB[CE220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000429 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000042E BA0E000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000433 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000438 CD40                <1>  int 40h
   528 0000043A E991000000              	jmp	Exit
   529                                  _2:
   530                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   531                                  	; bl = 0, bh = 4
   532                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   533                                  
   534                                  	sys	_video, 0400h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000043F BB00040000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000444 B81F000000          <1>  mov eax, %1
    91                              <1> 
    92 00000449 CD40                <1>  int 40h
   535 0000044B 3D00800B00              	cmp	eax, 0B8000h
   536 00000450 75D2                    	jne	short error_exit
   537                                  
   538                                  	; 01/06/2024
   539                                  	; Initialize Audio Device (bh = 3)
   540                                  	sys	_audio, 0301h, 0, audio_int_handler 
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000452 BB01030000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000457 B900000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000045C BA[9B050000]        <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000461 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 00000466 CD40                <1>  int 40h
   541                                  	;jc	short error_exit
   542 00000468 0F82C6FCFFFF            	jc	init_err
   543                                  _3:
   544                                  
   545                                  %endif
   546                                  
   547                                  ;
   548                                  ; position file pointer to start in actual wav data
   549                                  ; MUCH improvement should really be done here to check if sample size is
   550                                  ; supported, make sure there are 2 channels, etc.  
   551                                  ;
   552                                          ;mov     ah, 42h
   553                                          ;mov     al, 0	; from start of file
   554                                          ;mov     bx, [FileHandle]
   555                                          ;xor     cx, cx
   556                                          ;mov     dx, 44	; jump past .wav/riff header
   557                                          ;int     21h
   558                                  
   559                                  	sys	_seek, [FileHandle], 44, 0
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000046E 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000474 B92C000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000479 BA00000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000047E B813000000          <1>  mov eax, %1
    91                              <1> 
    92 00000483 CD40                <1>  int 40h
   560                                  
   561                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000485 BB[A4230000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000048A B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000048F BA07000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000494 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000499 CD40                <1>  int 40h
   562                                  
   563                                  ; play the .wav file. Most of the good stuff is in here.
   564                                  
   565 0000049B E8C2010000                      call    PlayWav
   566                                  
   567                                  ; close the .wav file and exit.
   568                                  
   569                                  StopPlaying:
   570                                  	; Stop Playing
   571                                  	sys	_audio, 0700h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004A0 BB00070000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004A5 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000004AA CD40                <1>  int 40h
   572                                  	; Cancel callback service (for user)
   573                                  	sys	_audio, 0900h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004AC BB00090000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004B1 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000004B6 CD40                <1>  int 40h
   574                                  	; Deallocate Audio Buffer (for user)
   575                                  	sys	_audio, 0A00h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004B8 BB000A0000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004BD B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000004C2 CD40                <1>  int 40h
   576                                  	; Disable Audio Device
   577                                  	sys	_audio, 0C00h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004C4 BB000C0000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004C9 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000004CE CD40                <1>  int 40h
   578                                  Exit:  
   579 000004D0 E847000000                      call    closeFile
   580                                           
   581                                  	sys	_exit	; Bye!
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82                              <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004D5 B801000000          <1>  mov eax, %1
    91                              <1> 
    92 000004DA CD40                <1>  int 40h
   582                                  here:
   583 000004DC EBFE                    	jmp	short here
   584                                  
   585                                  pmsg_usage:
   586                                  	sys	_msg, msg_usage, 255, 0Bh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004DE BB[6B220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000004E3 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000004E8 BA0B000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004ED B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000004F2 CD40                <1>  int 40h
   587 000004F4 EBDA                    	jmp	short Exit
   588                                  
   589                                  	; 25/11/2023
   590                                  DetectAC97:
   591                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   592                                          sys	_audio, 0102h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000004F6 BB02010000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000004FB B820000000          <1>  mov eax, %1
    91                              <1> 
    92 00000500 CD40                <1>  int 40h
   593                                  
   594                                  ; 01/06/2024
   595                                  %if 0
   596                                  	jc	short DetectAC97_retn
   597                                  
   598                                  	; 25/11/2023
   599                                  	; Get AC'97 Codec info
   600                                  	; (Function 14, sub function 1)
   601                                  	sys	_audio, 0E01h
   602                                  	; Save Variable Rate Audio support bit
   603                                  	and	al, 1
   604                                  	mov	[VRA], al
   605                                  %endif
   606                                  
   607                                  DetectAC97_retn:
   608 00000502 C3                      	retn
   609                                  
   610                                  ;open or create file
   611                                  ;
   612                                  ;input: ds:dx-->filename (asciiz)
   613                                  ;       al=file Mode (create or open)
   614                                  ;output: none  cs:[FileHandle] filled
   615                                  ;
   616                                  openFile:
   617                                  	;mov	ah, 3Bh	; start with a mode
   618                                  	;add	ah, al	; add in create or open mode
   619                                  	;xor	ecx, ecx
   620                                  	;int	21h
   621                                  	;jc	short _of1
   622                                  	;;mov	[cs:FileHandle], ax
   623                                  
   624                                  	sys	_open, wav_file_name, 0
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000503 BB[B9240000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000508 B900000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000050D B805000000          <1>  mov eax, %1
    91                              <1> 
    92 00000512 CD40                <1>  int 40h
   625 00000514 7205                    	jc	short _of1
   626                                  
   627 00000516 A3[97210000]            	mov	[FileHandle], eax
   628                                  _of1:
   629 0000051B C3                      	retn
   630                                  
   631                                  ; close the currently open file
   632                                  ; input: none, uses cs:[FileHandle]
   633                                  closeFile:
   634 0000051C 833D[97210000]FF        	cmp	dword [FileHandle], -1
   635 00000523 7417                    	je	short _cf1
   636                                  	;mov    bx, [FileHandle]  
   637                                  	;mov    ax, 3E00h
   638                                          ;int    21h              ;close file
   639                                  
   640                                  	sys	_close, [FileHandle]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000525 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000052B B806000000          <1>  mov eax, %1
    91                              <1> 
    92 00000530 CD40                <1>  int 40h
   641 00000532 C705[97210000]FFFF-     	mov 	dword [FileHandle], -1
   641 0000053A FFFF               
   642                                  _cf1:
   643 0000053C C3                      	retn
   644                                  
   645                                  getSampleRate:
   646                                  	
   647                                  ; reads the sample rate from the .wav file.
   648                                  ; entry: none - assumes file is already open
   649                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   650                                  ;	cx = number of channels (mono=1, stereo=2)
   651                                  ;	dx = bits per sample (8, 16)
   652                                  
   653 0000053D 53                      	push    ebx
   654                                  
   655                                          ;mov	ah, 42h
   656                                          ;mov	al, 0	; from start of file
   657                                          ;mov	bx, [FileHandle]
   658                                          ;xor	ecx, ecx
   659                                          ;mov	dx, 08h	; "WAVE"
   660                                          ;int	21h
   661                                  	
   662                                  	sys	_seek, [FileHandle], 8, 0
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000053E 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000544 B908000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000549 BA00000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000054E B813000000          <1>  mov eax, %1
    91                              <1> 
    92 00000553 CD40                <1>  int 40h
   663                                  
   664                                          ;mov	dx, smpRBuff
   665                                          ;mov	cx, 28	; 28 bytes
   666                                  	;mov	ah, 3fh
   667                                          ;int	21h
   668                                  
   669                                  	sys	_read, [FileHandle], smpRBuff, 28
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000555 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000055B B9[9D240000]        <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000560 BA1C000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000565 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000056A CD40                <1>  int 40h
   670                                  
   671 0000056C 813D[9D240000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   671 00000574 5645               
   672 00000576 7520                    	jne	short gsr_stc
   673                                  
   674 00000578 66833D[A9240000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   675 00000580 7516                    	jne	short gsr_stc
   676                                  
   677 00000582 668B0D[AB240000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   678 00000589 66A1[AD240000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   679 0000058F 668B15[B7240000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   680                                  gsr_retn:
   681 00000596 5B                              pop     ebx
   682 00000597 C3                              retn
   683                                  gsr_stc:
   684 00000598 F9                      	stc
   685 00000599 EBFB                    	jmp	short gsr_retn
   686                                  
   687                                  audio_int_handler:
   688                                  	; 13/12/2024
   689                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   690                                  
   691                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   692                                  	
   693                                  	;cmp	byte [cbs_busy], 1
   694                                  	;jnb	short _callback_bsy_retn
   695                                  	
   696                                  	;mov	byte [cbs_busy], 1
   697                                  
   698                                  	; 13/12/2024
   699                                  	;mov	al, [half_buff]
   700                                  	;
   701                                  	;cmp	al, 1
   702                                  	;jb	short _callback_retn
   703                                  
   704                                  	; 18/08/2020
   705                                  	;mov	byte [srb], 1
   706                                  	; 13/12/2024
   707 0000059B FE05[9A240000]          	inc	byte [srb]
   708                                  
   709                                  	; 13/12/2024
   710                                  	;xor	byte [half_buff], 3 ; 2->1, 1->2
   711                                  
   712                                  	; 13/12/2024
   713                                  	;add	al, '0'
   714                                  ;tL0:	; 26/11/2023
   715                                  	;mov	ah, 4Eh
   716                                  	;mov	ebx, 0B8000h ; video display page address
   717                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   718                                  ;_callback_retn:
   719                                  	;;mov	byte [cbs_busy], 0
   720                                  ;_callback_bsy_retn:
   721                                  	sys	_rele ; return from callback service 
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82                              <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000005A1 B827000000          <1>  mov eax, %1
    91                              <1> 
    92 000005A6 CD40                <1>  int 40h
   722                                  	; we must not come here !
   723                                  	sys	_exit
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82                              <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000005A8 B801000000          <1>  mov eax, %1
    91                              <1> 
    92 000005AD CD40                <1>  int 40h
   724                                  	
   725                                  loadFromFile:
   726                                  	; 26/11/2023
   727 000005AF F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
   728                                  					; last of the file?
   729 000005B6 7402                    	jz	short lff_0		; no
   730 000005B8 F9                      	stc
   731 000005B9 C3                      	retn
   732                                  lff_0:
   733                                  	; 13/06/2017
   734                                  	;mov	edx, BUFFERSIZE
   735                                  	; 26/11/2023
   736 000005BA BF[00300000]            	mov	edi, audio_buffer
   737 000005BF 8B15[07040000]          	mov	edx, [buffersize]	; bytes
   738 000005C5 8A0D[0C250000]          	mov	cl, [fbs_shift]   
   739 000005CB 20C9                    	and	cl, cl
   740 000005CD 7409                    	jz	short lff_1 ; stereo, 16 bit
   741                                  
   742                                  	; fbs_shift =
   743                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   744                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   745 000005CF D3EA                    	shr	edx, cl
   746                                  	;inc	edx
   747                                  
   748 000005D1 BE[00300100]            	mov     esi, temp_buffer
   749 000005D6 EB02                    	jmp	short lff_2
   750                                  lff_1:
   751                                  	;mov	esi, audio_buffer
   752 000005D8 89FE                    	mov	esi, edi ; audio_buffer
   753                                  lff_2:
   754                                  	; 17/03/2017
   755                                  	; esi = buffer address
   756                                  	; edx = buffer size
   757                                   
   758                                  	; 26/11/2023
   759                                  	; load file into memory
   760                                  	sys 	_read, [FileHandle], esi
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000005DA 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000005E0 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000005E2 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000005E7 CD40                <1>  int 40h
   761                                  	; 14/12/2024
   762 000005E9 8B0D[07040000]          	mov	ecx, [buffersize]
   763                                  	;jc	short padfill ; error !
   764                                  	; 14/12/2024
   765 000005EF 7255                    	jc	short lff_10
   766                                  
   767 000005F1 21C0                    	and	eax, eax
   768 000005F3 7453                    	jz	short padfill
   769                                  lff_3:
   770                                  	; 26/11/2023
   771 000005F5 8A1D[0C250000]          	mov	bl, [fbs_shift]
   772 000005FB 20DB                    	and	bl, bl
   773 000005FD 7456                    	jz	short lff_11
   774                                  
   775                                  	; 14/12/2024
   776                                  	;sub	ecx, eax
   777                                  	;mov	ebp, ecx
   778                                  	; 14/12/2024
   779 000005FF 29C2                    	sub	edx, eax
   780                                  
   781                                  	;mov	esi, temp_buffer
   782                                  	;mov	edi, audio_buffer
   783 00000601 89C1                    	mov	ecx, eax   ; byte count
   784                                  
   785 00000603 803D[91240000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   786 0000060A 751E                    	jne	short lff_6 ; 16 bit samples
   787                                  	; 8 bit samples
   788 0000060C FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   789 0000060E 740E                    	jz	short lff_5 ; 8 bit, stereo
   790                                  lff_4:
   791                                  	; mono & 8 bit
   792 00000610 AC                      	lodsb
   793 00000611 2C80                    	sub	al, 80h ; 08/11/2023
   794 00000613 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   795 00000616 66AB                    	stosw	; left channel
   796 00000618 66AB                    	stosw	; right channel
   797 0000061A E2F4                    	loop	lff_4
   798 0000061C EB16                    	jmp	short lff_8
   799                                  lff_5:
   800                                  	; stereo & 8 bit
   801 0000061E AC                      	lodsb
   802 0000061F 2C80                    	sub	al, 80h ; 08/11/2023
   803 00000621 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   804 00000624 66AB                    	stosw
   805 00000626 E2F6                    	loop	lff_5
   806 00000628 EB0A                    	jmp	short lff_8
   807                                  lff_6:
   808 0000062A D1E9                    	shr	ecx, 1 ; word count
   809                                  lff_7:
   810 0000062C 66AD                    	lodsw
   811 0000062E 66AB                    	stosw	; left channel
   812 00000630 66AB                    	stosw	; right channel
   813 00000632 E2F8                    	loop	lff_7
   814                                  lff_8:
   815                                  	; 27/11/2023
   816 00000634 F8                      	clc
   817                                  	; 14/12/2024
   818                                  	;mov	ecx, ebp
   819                                  	;jecxz	endLFF_retn
   820 00000635 09D2                    	or	edx, edx
   821 00000637 741B                    	jz	short endLFF_retn
   822                                  	
   823                                  	; 14/12/2024
   824 00000639 B9[00300000]            	mov	ecx, audio_buffer
   825 0000063E 030D[07040000]          	add	ecx, [buffersize]
   826 00000644 29F9                    	sub	ecx, edi
   827                                  
   828                                  	; 14/12/2024
   829                                  lff_10:
   830 00000646 31C0                    	xor	eax, eax ; silence
   831                                  padfill:
   832 00000648 D1E9                    	shr	ecx, 1
   833 0000064A F366AB                  	rep	stosw
   834                                  lff_9:
   835 0000064D 800D[98240000]01                or	byte [flags], ENDOFFILE	; end of file flag
   836                                  endLFF_retn:
   837 00000654 C3                              retn
   838                                  
   839                                  lff_11:
   840                                  	; 16 bit stereo
   841                                  	; ecx = buffer size
   842                                  	; eax = read count
   843 00000655 29C1                    	sub	ecx, eax
   844 00000657 76FB                    	jna	short endLFF_retn
   845 00000659 01C7                    	add	edi, eax  ; audio_buffer + eax
   846 0000065B EBE9                    	jmp	short lff_10 ; padfill
   847                                  
   848                                  error_exit_2:
   849                                  	; 26/11/2023 - temporary
   850                                  	;sys	_msg, test_2, 255, 0Ch
   851                                  
   852 0000065D E9C2FDFFFF              	jmp	error_exit
   853                                  	
   854                                  	; 26/11/2023 - temporary
   855                                  ;test_1:
   856                                  ;	db 13, 10, 'Test 1', 13,10, 0
   857                                  ;test_2:
   858                                  ;	db 13, 10, 'Test 2', 13,10, 0
   859                                  	
   860                                  PlayWav:
   861                                  	; 26/11/2023
   862                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   863                                  	; 13/06/2017
   864                                  	; Convert 8 bit samples to 16 bit samples
   865                                  	; and convert mono samples to stereo samples
   866                                  
   867                                  	; 26/11/2023
   868                                  	; load 32768 bytes into audio buffer
   869                                  	;mov	edi, audio_buffer
   870                                  	;;mov	edx, BUFFERSIZE
   871                                  	; 26/11/2023
   872                                  	;mov	edx, [buffersize]
   873                                  	;call	loadFromFile
   874                                  	; 26/11/2023
   875 00000662 FF15[FF030000]          	call	dword [loadfromwavfile]
   876 00000668 72F3                    	jc	short error_exit_2
   877 0000066A C605[99240000]01        	mov	byte [half_buff], 1 ; (DMA) Buffer 1
   878                                  
   879                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   880 00000671 F605[98240000]01        	test    byte [flags], ENDOFFILE  ; end of file
   881 00000678 7512                    	jnz	short _6 ; yes
   882                                  			 ; bypass filling dma half buffer 2
   883                                  
   884                                  	; bh = 16 : update (current, first) dma half buffer
   885                                  	; bl = 0  : then switch to the next (second) half buffer
   886                                  	sys	_audio, 1000h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000067A BB00100000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000067F B820000000          <1>  mov eax, %1
    91                              <1> 
    92 00000684 CD40                <1>  int 40h
   887                                  
   888                                  	; 18/08/2020
   889                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
   890                                  
   891                                  	; audio_buffer must be filled again after above system call 
   892                                  	; (Because audio interrupt will be generated by AC97 hardware
   893                                  	; at the end of the first half of dma buffer.. so, 
   894                                  	; the second half must be ready. 'sound_play' will use it.)
   895                                  
   896                                  	; 26/11/2023
   897                                  	;mov	edi, audio_buffer
   898                                  	;;mov	edx, BUFFERSIZE
   899                                  	; 26/11/2023
   900                                  	;mov	edx, [buffersize]
   901                                  	;call	loadFromFile
   902                                  	; 26/11/2023
   903 00000686 FF15[FF030000]          	call	dword [loadfromwavfile]
   904                                  	;jc	short p_return
   905                                  _6:
   906                                  	; Set Master Volume Level (BL=0 or 80h)
   907                                  	; 	for next playing (BL>=80h)
   908                                  	;sys	_audio, 0B80h, 1D1Dh
   909                                  	sys	_audio, 0B00h, 1D1Dh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000068C BB000B0000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000691 B91D1D0000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000696 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 0000069B CD40                <1>  int 40h
   910                                  
   911                                  	; 18/08/2020
   912                                  	;mov	byte [volume_level], 1Dh
   913 0000069D 880D[9B240000]          	mov	[volume_level], cl
   914                                  
   915                                  	; Start	to play
   916                                  	;mov	al, [bps]
   917                                  	;shr	al, 4 ; 8 -> 0, 16 -> 1
   918                                  	;shl	al, 1 ; 16 -> 2, 8 -> 0
   919                                  	;mov	bl, [stmo]
   920                                  	;dec	bl
   921                                  	;or	bl, al
   922                                  	;mov	cx, [sample_rate]
   923                                  	; 04/06/2024
   924                                  	; (non-VRA simulation)
   925 000006A3 66B980BB                 	mov	cx, 48000 ; 48 kHz
   926 000006A7 B303                    	mov	bl, 3  ; 16 bit, stereo
   927                                  	
   928 000006A9 B704                    	mov	bh, 4 ; start to play
   929                                  	sys	_audio
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82                              <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000006AB B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000006B0 CD40                <1>  int 40h
   930                                  
   931                                  	;mov	ebx, 0B8000h ; video display page address
   932                                  	;mov	ah, 4Eh
   933                                  	;mov	al, [half_buffer]
   934                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
   935                                  
   936                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
   937                                  	; Here..
   938                                  	; If byte [flags] <> ENDOFFILE ...
   939                                  	; user's audio_buffer has been copied to dma half buffer 2
   940                                  
   941                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
   942                                  
   943                                  	; audio_buffer must be filled again after above system call 
   944                                  	; (Because, audio interrupt will be generated by VT8237R
   945                                  	; at the end of the first half of dma buffer.. so, 
   946                                  	; the 2nd half of dma buffer is ready but the 1st half
   947                                  	; must be filled again.)
   948                                  
   949                                  ; 14/12/2024
   950                                  %if 0
   951                                  	; 18/08/2020
   952                                  	test    byte [flags], ENDOFFILE  ; end of file
   953                                  	jnz	short p_loop ; yes
   954                                  
   955                                  	; 18/08/2020
   956                                  	; load 32768 bytes into audio buffer
   957                                  	;; (for the second half of DMA buffer)
   958                                  	; 27/11/2023
   959                                  	; 20/05/2017
   960                                  	;mov	edi, audio_buffer
   961                                  	;mov	edx, BUFFERSIZE
   962                                  	; 26/11/2023
   963                                  	;mov	edx, [buffersize]
   964                                  	;call	loadFromFile
   965                                  	; 26/11/2023
   966                                  	call	dword [loadfromwavfile]
   967                                  	;jc	short p_return
   968                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
   969                                  %endif
   970                                  
   971                                  	; we need to wait for 'SRB' (audio interrupt)
   972                                  	; (we can not return from 'PlayWav' here 
   973                                  	;  even if we have got an error from file reading)
   974                                  	; ((!!current audio data must be played!!))
   975                                  
   976                                  	; 18/08/2020
   977                                  	;mov	byte [srb], 1
   978                                  
   979                                  p_loop:
   980                                  	;mov	ah, 1		; any key pressed?
   981                                  	;int	32h		; no, Loop.
   982                                  	;jz	short q_loop
   983                                  	;
   984                                  	;mov	ah, 0		; flush key buffer...
   985                                  	;int	32h
   986                                  
   987                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
   988 000006B2 803D[9A240000]00        	cmp	byte [srb], 0
   989 000006B9 7627                    	jna	short q_loop
   990 000006BB C605[9A240000]00        	mov	byte [srb], 0
   991                                  	; 13/12/2024
   992 000006C2 8035[99240000]03        	xor	byte [half_buff], 3 ; 2->1, 1->2
   993                                  
   994                                  	; 27/11/2023
   995                                  	;mov	edi, audio_buffer
   996                                  	;mov	edx, BUFFERSIZE
   997                                  	; 26/11/2023
   998                                  	;mov	edx, [buffersize]
   999                                  	;call	loadFromFile
  1000                                  	; 26/11/2023
  1001 000006C9 FF15[FF030000]          	call	dword [loadfromwavfile]
  1002 000006CF 7223                    	jc	short p_return
  1003                                  
  1004                                  	; 14/12/2024
  1005                                  	;;;
  1006                                  	; bh = 16 : update (current, first) dma half buffer
  1007                                  	; bl = 0  : then switch to the other half buffer
  1008                                  	sys	_audio, 1000h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000006D1 BB00100000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000006D6 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 000006DB CD40                <1>  int 40h
  1009                                  	;;;
  1010                                  
  1011                                  	; 13/12/2024
  1012 000006DD E819000000              	call	tL0
  1013                                  q_loop:
  1014 000006E2 B401                    	mov     ah, 1		; any key pressed?
  1015 000006E4 CD32                    	int     32h		; no, Loop.
  1016 000006E6 74CA                    	jz	short p_loop
  1017                                  
  1018 000006E8 B400                    	mov     ah, 0		; flush key buffer...
  1019 000006EA CD32                    	int     32h
  1020                                  	
  1021 000006EC 3C2B                    	cmp	al, '+' ; increase sound volume
  1022 000006EE 741D                    	je	short inc_volume_level
  1023 000006F0 3C2D                    	cmp	al, '-'
  1024 000006F2 743C                    	je	short dec_volume_level
  1025                                  
  1026                                  p_return:
  1027 000006F4 C605[99240000]00        	mov	byte [half_buff], 0
  1028                                  	; 13/12/2024
  1029                                  	;call	tL0
  1030                                  	;retn
  1031                                  
  1032                                  	; 13/12/2024
  1033                                  tL0:
  1034 000006FB A0[99240000]            	mov	al, [half_buff]
  1035 00000700 0430                    	add	al, '0'
  1036 00000702 B44E                    	mov	ah, 4Eh
  1037 00000704 BB00800B00              	mov	ebx, 0B8000h	; video display page address
  1038 00000709 668903                  	mov	[ebx], ax	; show playing buffer (1, 2)
  1039 0000070C C3                      	retn
  1040                                  
  1041                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
  1042                                  inc_volume_level:
  1043 0000070D 8A0D[9B240000]          	mov	cl, [volume_level]
  1044 00000713 80F91F                  	cmp	cl, 1Fh ; 31
  1045 00000716 73CA                    	jnb	short q_loop
  1046 00000718 FEC1                    	inc	cl
  1047                                  change_volume_level:
  1048 0000071A 880D[9B240000]          	mov	[volume_level], cl
  1049 00000720 88CD                    	mov	ch, cl
  1050                                  	; Set Master Volume Level
  1051                                  	sys	_audio, 0B00h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000722 BB000B0000          <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84                              <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86                              <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000727 B820000000          <1>  mov eax, %1
    91                              <1> 
    92 0000072C CD40                <1>  int 40h
  1052 0000072E EB82                    	jmp	short p_loop
  1053                                  dec_volume_level:
  1054 00000730 8A0D[9B240000]          	mov	cl, [volume_level]
  1055 00000736 80F901                  	cmp	cl, 1 ; 1
  1056                                  	;jna	short p_loop
  1057                                  	; 14/12/2024
  1058 00000739 76A7                    	jna	short q_loop
  1059 0000073B FEC9                    	dec	cl
  1060 0000073D EBDB                    	jmp	short change_volume_level
  1061                                  
  1062                                  write_audio_dev_info:
  1063                                  	; EBX = Message address
  1064                                  	; ECX = Max. message length (or stop on ZERO character)
  1065                                  	;	(1 to 255)
  1066                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
  1067                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000073F BB[42220000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000744 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000749 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000074E B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000753 CD40                <1>  int 40h
  1068 00000755 C3                      	retn
  1069                                  
  1070                                  write_wav_file_info:
  1071                                  	; 01/05/2017
  1072                                  	sys	_msg, msgWavFileName, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000756 BB[58230000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000075B B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000760 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000765 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 0000076A CD40                <1>  int 40h
  1073                                  	sys	_msg, wav_file_name, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000076C BB[B9240000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000771 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000776 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000077B B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000780 CD40                <1>  int 40h
  1074                                  
  1075                                  write_sample_rate:
  1076                                  	; 01/05/2017
  1077 00000782 66A1[92240000]          	mov	ax, [sample_rate]
  1078                                  	; ax = sample rate (hertz)
  1079 00000788 31D2                    	xor	edx, edx
  1080 0000078A 66B90A00                	mov	cx, 10
  1081 0000078E 66F7F1                  	div	cx
  1082 00000791 0015[7D230000]          	add	[msgHertz+4], dl
  1083 00000797 29D2                    	sub	edx, edx
  1084 00000799 66F7F1                  	div	cx
  1085 0000079C 0015[7C230000]          	add	[msgHertz+3], dl
  1086 000007A2 29D2                    	sub	edx, edx
  1087 000007A4 66F7F1                  	div	cx
  1088 000007A7 0015[7B230000]          	add	[msgHertz+2], dl
  1089 000007AD 29D2                    	sub	edx, edx
  1090 000007AF 66F7F1                  	div	cx
  1091 000007B2 0015[7A230000]          	add	[msgHertz+1], dl
  1092 000007B8 0005[79230000]          	add	[msgHertz], al
  1093                                  	
  1094                                  	sys	_msg, msgSampleRate, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000007BE BB[6A230000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000007C3 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000007C8 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000007CD B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000007D2 CD40                <1>  int 40h
  1095                                  
  1096 000007D4 BE[94230000]            	mov	esi, msg16Bits
  1097 000007D9 803D[91240000]10        	cmp	byte [bps], 16
  1098 000007E0 7405                    	je	short wsr_1
  1099 000007E2 BE[84230000]            	mov	esi, msg8Bits
  1100                                  wsr_1:
  1101                                  	sys	_msg, esi, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000007E7 89F3                <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000007E9 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000007EE BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000007F3 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000007F8 CD40                <1>  int 40h
  1102                                  
  1103 000007FA BE[8D230000]            	mov	esi, msgMono
  1104 000007FF 803D[90240000]01        	cmp	byte [stmo], 1
  1105 00000806 7405                    	je	short wsr_2
  1106 00000808 BE[9E230000]            	mov	esi, msgStereo		
  1107                                  wsr_2:
  1108                                  	sys	_msg, esi, 255, 0Fh
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000080D 89F3                <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000080F B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000814 BA0F000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000819 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 0000081E CD40                <1>  int 40h
  1109 00000820 C3                              retn
  1110                                  
  1111                                  write_ac97_pci_dev_info:
  1112                                  	; 06/06/2017
  1113                                  	; 03/06/2017
  1114                                  	; BUS/DEV/FN
  1115                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1116                                  	; DEV/VENDOR
  1117                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1118                                  
  1119 00000821 8B35[0D250000]          	mov	esi, [dev_vendor]
  1120 00000827 89F0                    	mov	eax, esi
  1121 00000829 0FB6D8                  	movzx	ebx, al
  1122 0000082C 88DA                    	mov	dl, bl
  1123 0000082E 80E30F                  	and	bl, 0Fh
  1124 00000831 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1125 00000837 A2[EC230000]            	mov	[msgVendorId+3], al
  1126 0000083C 88D3                    	mov	bl, dl
  1127 0000083E C0EB04                  	shr	bl, 4
  1128 00000841 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1129 00000847 A2[EB230000]            	mov	[msgVendorId+2], al
  1130 0000084C 88E3                    	mov	bl, ah
  1131 0000084E 88DA                    	mov	dl, bl
  1132 00000850 80E30F                  	and	bl, 0Fh
  1133 00000853 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1134 00000859 A2[EA230000]            	mov	[msgVendorId+1], al
  1135 0000085E 88D3                    	mov	bl, dl
  1136 00000860 C0EB04                  	shr	bl, 4
  1137 00000863 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1138 00000869 A2[E9230000]            	mov	[msgVendorId], al
  1139 0000086E C1E810                  	shr	eax, 16
  1140 00000871 88C3                    	mov	bl, al
  1141 00000873 88DA                    	mov	dl, bl
  1142 00000875 80E30F                  	and	bl, 0Fh
  1143 00000878 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1144 0000087E A2[FD230000]            	mov	[msgDevId+3], al
  1145 00000883 88D3                    	mov	bl, dl
  1146 00000885 C0EB04                  	shr	bl, 4
  1147 00000888 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1148 0000088E A2[FC230000]            	mov	[msgDevId+2], al
  1149 00000893 88E3                    	mov	bl, ah
  1150 00000895 88DA                    	mov	dl, bl
  1151 00000897 80E30F                  	and	bl, 0Fh
  1152 0000089A 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1153 000008A0 A2[FB230000]            	mov	[msgDevId+1], al
  1154 000008A5 88D3                    	mov	bl, dl
  1155 000008A7 C0EB04                  	shr	bl, 4
  1156 000008AA 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1157 000008B0 A2[FA230000]            	mov	[msgDevId], al
  1158                                  
  1159 000008B5 8B35[11250000]          	mov	esi, [bus_dev_fn]
  1160 000008BB C1EE08                  	shr	esi, 8
  1161 000008BE 6689F0                  	mov	ax, si
  1162 000008C1 88C3                    	mov	bl, al
  1163 000008C3 88DA                    	mov	dl, bl
  1164 000008C5 80E307                  	and	bl, 7 ; bit 0,1,2
  1165 000008C8 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1166 000008CE A2[21240000]            	mov	[msgFncNo+1], al
  1167 000008D3 88D3                    	mov	bl, dl
  1168 000008D5 C0EB03                  	shr	bl, 3
  1169 000008D8 88DA                    	mov	dl, bl
  1170 000008DA 80E30F                  	and	bl, 0Fh
  1171 000008DD 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1172 000008E3 A2[13240000]            	mov	[msgDevNo+1], al
  1173 000008E8 88D3                    	mov	bl, dl
  1174 000008EA C0EB04                  	shr	bl, 4
  1175 000008ED 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1176 000008F3 A2[12240000]            	mov	[msgDevNo], al
  1177 000008F8 88E3                    	mov	bl, ah
  1178 000008FA 88DA                    	mov	dl, bl
  1179 000008FC 80E30F                  	and	bl, 0Fh
  1180 000008FF 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1181 00000905 A2[07240000]            	mov	[msgBusNo+1], al
  1182 0000090A 88D3                    	mov	bl, dl
  1183 0000090C C0EB04                  	shr	bl, 4
  1184 0000090F 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1185 00000915 A2[06240000]            	mov	[msgBusNo], al
  1186                                  
  1187 0000091A 66A1[15250000]          	mov	ax, [ac97_NamBar]
  1188 00000920 88C3                    	mov	bl, al
  1189 00000922 88DA                    	mov	dl, bl
  1190 00000924 80E30F                  	and	bl, 0Fh
  1191 00000927 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1192 0000092D A2[30240000]            	mov	[msgNamBar+3], al
  1193 00000932 88D3                    	mov	bl, dl
  1194 00000934 C0EB04                  	shr	bl, 4
  1195 00000937 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1196 0000093D A2[2F240000]            	mov	[msgNamBar+2], al
  1197 00000942 88E3                    	mov	bl, ah
  1198 00000944 88DA                    	mov	dl, bl
  1199 00000946 80E30F                  	and	bl, 0Fh
  1200 00000949 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1201 0000094F A2[2E240000]            	mov	[msgNamBar+1], al
  1202 00000954 88D3                    	mov	bl, dl
  1203 00000956 C0EB04                  	shr	bl, 4
  1204 00000959 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1205 0000095F A2[2D240000]            	mov	[msgNamBar], al
  1206                                  
  1207 00000964 66A1[17250000]          	mov	ax, [ac97_NabmBar]
  1208 0000096A 88C3                    	mov	bl, al
  1209 0000096C 88DA                    	mov	dl, bl
  1210 0000096E 80E30F                  	and	bl, 0Fh
  1211 00000971 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1212 00000977 A2[40240000]            	mov	[msgNabmBar+3], al
  1213 0000097C 88D3                    	mov	bl, dl
  1214 0000097E C0EB04                  	shr	bl, 4
  1215 00000981 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1216 00000987 A2[3F240000]            	mov	[msgNabmBar+2], al
  1217 0000098C 88E3                    	mov	bl, ah
  1218 0000098E 88DA                    	mov	dl, bl
  1219 00000990 80E30F                  	and	bl, 0Fh
  1220 00000993 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1221 00000999 A2[3E240000]            	mov	[msgNabmBar+1], al
  1222 0000099E 88D3                    	mov	bl, dl
  1223 000009A0 C0EB04                  	shr	bl, 4
  1224 000009A3 8A83[A7230000]          	mov	al, [ebx+hex_chars]
  1225 000009A9 A2[3D240000]            	mov	[msgNabmBar], al
  1226                                  
  1227 000009AE 30E4                    	xor	ah, ah
  1228 000009B0 A0[0B250000]            	mov	al, [ac97_int_ln_reg]
  1229 000009B5 B10A                    	mov	cl, 10
  1230 000009B7 F6F1                    	div	cl
  1231 000009B9 660105[49240000]        	add	[msgIRQ], ax
  1232 000009C0 20C0                    	and	al, al
  1233 000009C2 750D                    	jnz	short _w_ac97imsg_
  1234 000009C4 A0[4A240000]            	mov	al, [msgIRQ+1]
  1235 000009C9 B420                    	mov	ah, ' '
  1236 000009CB 66A3[49240000]          	mov	[msgIRQ], ax
  1237                                  _w_ac97imsg_:
  1238                                  	sys	_msg, msgAC97Info, 255, 07h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000009D1 BB[B8230000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000009D6 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000009DB BA07000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000009E0 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000009E5 CD40                <1>  int 40h
  1239                                  
  1240 000009E7 C3                              retn
  1241                                  
  1242                                  write_VRA_info:
  1243                                  	; 25/11/2023
  1244                                  	sys	_msg, msgVRAheader, 255, 07h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000009E8 BB[4E240000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000009ED B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000009F2 BA07000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000009F7 B823000000          <1>  mov eax, %1
    91                              <1> 
    92 000009FC CD40                <1>  int 40h
  1245                                  ; 08/12/2024
  1246                                  %if 0
  1247                                  	cmp	byte [VRA], 0
  1248                                  	jna	short _w_VRAi_no
  1249                                  _w_VRAi_yes:
  1250                                  	sys	_msg, msgVRAyes, 255, 07h
  1251                                  	retn
  1252                                  %endif
  1253                                  _w_VRAi_no:
  1254                                  	sys	_msg, msgVRAno, 255, 07h
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000009FE BB[5C240000]        <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000A03 B9FF000000          <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000A08 BA07000000          <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000A0D B823000000          <1>  mov eax, %1
    91                              <1> 
    92 00000A12 CD40                <1>  int 40h
  1255 00000A14 C3                      	retn
  1256                                  
  1257                                  ; 02/02/2025
  1258                                  ;
  1259                                  ; 26/11/2023
  1260                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1261                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1262                                  ; 14/11/2023
  1263                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1264                                  ; --------------------------------------------------------
  1265                                  
  1266                                  ;;Note:	At the end of every buffer load,
  1267                                  ;;	during buffer switch/swap, there will be discontinuity
  1268                                  ;;	between the last converted sample and the 1st sample
  1269                                  ;;	of the next buffer.
  1270                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1271                                  ;;	-To avoid this defect, the 1st sample of
  1272                                  ;;	the next buffer may be read from the wav file but
  1273                                  ;;	the file pointer would need to be set to 1 sample back
  1274                                  ;;	again via seek system call. Time comsumption problem! -
  1275                                  ;;
  1276                                  ;;	Erdogan Tan - 15/11/2023
  1277                                  ;;
  1278                                  ;;	((If entire wav data would be loaded at once.. conversion
  1279                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1280                                  ;;	64KB buffer limit is important also it is important
  1281                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1282                                  ;;	I have tested this program by using 2-30MB wav files.))
  1283                                  ;;
  1284                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1285                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1286                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1287                                  ;;			Realtek ALC850 codec.
  1288                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1289                                  
  1290                                  load_8khz_mono_8_bit:
  1291                                  	; 02/02/2025
  1292                                  	; 15/11/2023
  1293                                  	; 14/11/2023
  1294                                  	; 13/11/2023
  1295 00000A15 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1296                                  					; last of the file?
  1297 00000A1C 7402                    	jz	short lff8m_0		; no
  1298 00000A1E F9                      	stc
  1299 00000A1F C3                      	retn
  1300                                  
  1301                                  lff8m_0:
  1302 00000A20 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1303                                          ;mov	edx, [loadsize]
  1304                                  
  1305                                  	; esi = buffer address
  1306                                  	;; edx = buffer size
  1307                                  
  1308                                  	; load file into memory
  1309                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000A25 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000A2B 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000A2D 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000A33 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000A38 CD40                <1>  int 40h
  1310 00000A3A 7305                    	jnc	short lff8m_6
  1311 00000A3C E9AF000000              	jmp	lff8m_5  ; error !
  1312                                  
  1313                                  lff8m_6:
  1314 00000A41 BF[00300000]            	mov	edi, audio_buffer
  1315 00000A46 21C0                    	and	eax, eax
  1316 00000A48 0F8499000000            	jz	lff8_eof
  1317                                  
  1318 00000A4E 89C1                    	mov	ecx, eax	; byte count
  1319                                  lff8m_1:
  1320 00000A50 AC                      	lodsb
  1321 00000A51 A2[8E210000]            	mov	[previous_val], al
  1322 00000A56 2C80                    	sub	al, 80h
  1323 00000A58 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1324 00000A5C 66AB                    	stosw		; original sample (left channel)
  1325 00000A5E 66AB                    	stosw		; original sample (right channel)
  1326                                  	; 02/02/2025
  1327                                  	;xor	eax, eax
  1328 00000A60 8A06                    	mov	al, [esi]
  1329 00000A62 49                      	dec	ecx
  1330 00000A63 7502                    	jnz	short lff8m_2
  1331 00000A65 B080                    	mov	al, 80h
  1332                                  lff8m_2:
  1333                                  	;mov	[next_val], ax
  1334 00000A67 88C7                    	mov	bh, al	; [next_val]
  1335 00000A69 8A25[8E210000]          	mov	ah, [previous_val]
  1336 00000A6F 00E0                    	add	al, ah	; [previous_val]
  1337 00000A71 D0D8                    	rcr	al, 1
  1338 00000A73 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1339 00000A75 00E0                    	add	al, ah	; [previous_val]
  1340 00000A77 D0D8                    	rcr	al, 1	
  1341 00000A79 88C3                    	mov	bl, al 	; this is temporary interpolation value
  1342 00000A7B 00E0                    	add	al, ah	; [previous_val]
  1343 00000A7D D0D8                    	rcr	al, 1
  1344 00000A7F 2C80                    	sub	al, 80h
  1345 00000A81 66C1E008                	shl	ax, 8
  1346 00000A85 66AB                    	stosw		; this is 1st interpolated sample (L)
  1347 00000A87 66AB                    	stosw		; this is 1st interpolated sample (R)
  1348 00000A89 88D8                    	mov	al, bl
  1349 00000A8B 00D0                    	add	al, dl
  1350 00000A8D D0D8                    	rcr	al, 1
  1351 00000A8F 2C80                    	sub	al, 80h
  1352 00000A91 66C1E008                	shl	ax, 8
  1353 00000A95 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1354 00000A97 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1355 00000A99 88D0                    	mov	al, dl
  1356 00000A9B 2C80                    	sub	al, 80h
  1357 00000A9D 66C1E008                	shl	ax, 8
  1358 00000AA1 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1359 00000AA3 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1360                                  	;mov	al, [next_val]
  1361 00000AA5 88F8                    	mov	al, bh
  1362 00000AA7 00D0                    	add	al, dl
  1363 00000AA9 D0D8                    	rcr	al, 1
  1364 00000AAB 88C3                    	mov	bl, al	; this is temporary interpolation value
  1365 00000AAD 00D0                    	add	al, dl
  1366 00000AAF D0D8                    	rcr	al, 1
  1367 00000AB1 2C80                    	sub	al, 80h
  1368 00000AB3 66C1E008                	shl	ax, 8
  1369 00000AB7 66AB                    	stosw		; this is 4th interpolated sample (L)
  1370 00000AB9 66AB                    	stosw		; this is 4th interpolated sample (R)
  1371                                  	;mov	al, [next_val]
  1372 00000ABB 88F8                    	mov	al, bh
  1373 00000ABD 00D8                    	add	al, bl
  1374 00000ABF D0D8                    	rcr	al, 1
  1375 00000AC1 2C80                    	sub	al, 80h
  1376 00000AC3 66C1E008                	shl	ax, 8
  1377 00000AC7 66AB                    	stosw		; this is 5th interpolated sample (L)
  1378 00000AC9 66AB                    	stosw		; this is 5th interpolated sample (R)
  1379                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1380 00000ACB 09C9                    	or	ecx, ecx
  1381 00000ACD 7581                    	jnz	short lff8m_1
  1382                                  
  1383                                  	; --------------
  1384                                  
  1385                                  lff8s_3:
  1386                                  lff8m_3:
  1387                                  lff8s2_3:
  1388                                  lff8m2_3:
  1389                                  lff16s_3:
  1390                                  lff16m_3:
  1391                                  lff16s2_3:
  1392                                  lff16m2_3:
  1393                                  lff24_3:
  1394                                  lff32_3:
  1395                                  lff44_3:
  1396                                  lff22_3:
  1397                                  lff11_3:
  1398                                  lff12_3:	; 02/02/2025
  1399                                  	; 08/12/2024 (BugFix)
  1400                                  	; 01/06/2024 (BugFix)
  1401 00000ACF 8B0D[07040000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1402                                  	;shl	ecx, 1	; byte count ; Bug !
  1403                                  	; 08/12/2024
  1404 00000AD5 81C1[00300000]          	add	ecx, audio_buffer
  1405 00000ADB 29F9                    	sub	ecx, edi
  1406 00000ADD 7607                    	jna	short lff8m_4
  1407                                  	;inc	ecx
  1408 00000ADF C1E902                  	shr	ecx, 2
  1409 00000AE2 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros
  1410 00000AE4 F3AB                    	rep	stosd
  1411                                  lff8m_4:
  1412                                  	; 01/06/2024 (BugFix)
  1413                                  	; cf=1 ; Bug !
  1414                                  	; 08/12/2024
  1415                                  	;clc
  1416 00000AE6 C3                      	retn
  1417                                  
  1418                                  lff8_eof:
  1419                                  lff16_eof:
  1420                                  lff24_eof:
  1421                                  lff32_eof:
  1422                                  lff44_eof:
  1423                                  lff22_eof:
  1424                                  lff11_eof:
  1425                                  lff12_eof:	; 02/02/2025
  1426                                  	; 15/11/2023
  1427 00000AE7 C605[98240000]01        	mov	byte [flags], ENDOFFILE
  1428 00000AEE EBDF                    	jmp	short lff8m_3
  1429                                  
  1430                                  lff8s_5:
  1431                                  lff8m_5:
  1432                                  lff8s2_5:
  1433                                  lff8m2_5:
  1434                                  lff16s_5:
  1435                                  lff16m_5:
  1436                                  lff16s2_5:
  1437                                  lff16m2_5:
  1438                                  lff24_5:
  1439                                  lff32_5:
  1440                                  lff44_5:
  1441                                  lff22_5:
  1442                                  lff11_5:
  1443                                  lff12_5:	; 02/02/2025
  1444 00000AF0 B021                    	mov	al, '!'  ; error
  1445 00000AF2 E804FCFFFF              	call	tL0
  1446                                  	
  1447                                  	;jmp	short lff8m_3
  1448                                  	; 15/11/2023
  1449 00000AF7 EBEE                    	jmp	lff8_eof
  1450                                  
  1451                                  	; --------------
  1452                                  
  1453                                  load_8khz_stereo_8_bit:
  1454                                  	; 02/02/2025
  1455                                  	; 15/11/2023
  1456                                  	; 14/11/2023
  1457                                  	; 13/11/2023
  1458 00000AF9 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1459                                  					; last of the file?
  1460 00000B00 7402                    	jz	short lff8s_0		; no
  1461 00000B02 F9                      	stc
  1462 00000B03 C3                      	retn
  1463                                  
  1464                                  lff8s_0:
  1465 00000B04 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1466                                          ;mov	edx, [loadsize]
  1467                                  
  1468                                  	; esi = buffer address
  1469                                  	;; edx = buffer size
  1470                                  
  1471                                  	; load file into memory
  1472                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000B09 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000B0F 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000B11 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000B17 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000B1C CD40                <1>  int 40h
  1473 00000B1E 72D0                    	jc	short lff8s_5 ; error !
  1474                                  
  1475 00000B20 BF[00300000]            	mov	edi, audio_buffer
  1476                                  	
  1477 00000B25 D1E8                    	shr	eax, 1
  1478 00000B27 74BE                    	jz	short lff8_eof
  1479                                  
  1480 00000B29 89C1                    	mov	ecx, eax	; word count
  1481                                  lff8s_1:
  1482 00000B2B AC                      	lodsb
  1483 00000B2C A2[8E210000]            	mov	[previous_val_l], al
  1484 00000B31 2C80                    	sub	al, 80h
  1485 00000B33 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1486 00000B37 66AB                    	stosw		; original sample (L)
  1487 00000B39 AC                      	lodsb
  1488 00000B3A A2[90210000]            	mov	[previous_val_r], al
  1489 00000B3F 2C80                    	sub	al, 80h
  1490 00000B41 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1491 00000B45 66AB                    	stosw		; original sample (R)
  1492                                  
  1493                                  	;xor	eax, eax
  1494                                  	; 02/02/2025
  1495 00000B47 668B06                  	mov	ax, [esi]
  1496 00000B4A 49                      	dec	ecx
  1497 00000B4B 7504                    	jnz	short lff8s_2
  1498                                  		; convert 8 bit sample to 16 bit sample
  1499 00000B4D 66B88080                	mov	ax, 8080h
  1500                                  lff8s_2:
  1501 00000B51 A2[92210000]            	mov	[next_val_l], al
  1502 00000B56 8825[94210000]          	mov	[next_val_r], ah
  1503 00000B5C 8A25[8E210000]          	mov	ah, [previous_val_l]
  1504 00000B62 00E0                    	add	al, ah
  1505 00000B64 D0D8                    	rcr	al, 1
  1506 00000B66 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1507 00000B68 00E0                    	add	al, ah
  1508 00000B6A D0D8                    	rcr	al, 1	
  1509 00000B6C 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1510 00000B6E 00E0                    	add	al, ah
  1511 00000B70 D0D8                    	rcr	al, 1
  1512 00000B72 2C80                    	sub	al, 80h
  1513 00000B74 66C1E008                	shl	ax, 8
  1514 00000B78 66AB                    	stosw		; this is 1st interpolated sample (L)
  1515 00000B7A A0[94210000]            	mov	al, [next_val_r]
  1516 00000B7F 8A25[90210000]          	mov	ah, [previous_val_r]
  1517 00000B85 00E0                    	add	al, ah
  1518 00000B87 D0D8                    	rcr	al, 1
  1519 00000B89 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1520 00000B8B 00E0                    	add	al, ah
  1521 00000B8D D0D8                    	rcr	al, 1
  1522 00000B8F 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1523 00000B91 00E0                    	add	al, ah
  1524 00000B93 D0D8                    	rcr	al, 1
  1525 00000B95 2C80                    	sub	al, 80h
  1526 00000B97 66C1E008                	shl	ax, 8
  1527 00000B9B 66AB                    	stosw		; this is 1st interpolated sample (R)
  1528 00000B9D 88D8                    	mov	al, bl
  1529 00000B9F 00D0                    	add	al, dl
  1530 00000BA1 D0D8                    	rcr	al, 1
  1531 00000BA3 2C80                    	sub	al, 80h
  1532 00000BA5 66C1E008                	shl	ax, 8
  1533 00000BA9 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1534 00000BAB 88F8                    	mov	al, bh
  1535 00000BAD 00F0                    	add	al, dh
  1536 00000BAF D0D8                    	rcr	al, 1
  1537 00000BB1 2C80                    	sub	al, 80h
  1538 00000BB3 66C1E008                	shl	ax, 8
  1539 00000BB7 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1540 00000BB9 88D0                    	mov	al, dl
  1541 00000BBB 2C80                    	sub	al, 80h
  1542 00000BBD 66C1E008                	shl	ax, 8
  1543 00000BC1 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1544 00000BC3 88F0                    	mov	al, dh
  1545 00000BC5 2C80                    	sub	al, 80h
  1546 00000BC7 66C1E008                	shl	ax, 8
  1547 00000BCB 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1548 00000BCD A0[92210000]            	mov	al, [next_val_l]
  1549 00000BD2 00D0                    	add	al, dl
  1550 00000BD4 D0D8                    	rcr	al, 1
  1551 00000BD6 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1552 00000BD8 00D0                    	add	al, dl
  1553 00000BDA D0D8                    	rcr	al, 1
  1554 00000BDC 2C80                    	sub	al, 80h
  1555 00000BDE 66C1E008                	shl	ax, 8
  1556 00000BE2 66AB                    	stosw		; this is 4th interpolated sample (L)
  1557 00000BE4 A0[94210000]            	mov	al, [next_val_r]
  1558 00000BE9 00F0                    	add	al, dh
  1559 00000BEB D0D8                    	rcr	al, 1
  1560 00000BED 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1561 00000BEF 00F0                    	add	al, dh
  1562 00000BF1 D0D8                    	rcr	al, 1
  1563 00000BF3 2C80                    	sub	al, 80h
  1564 00000BF5 66C1E008                	shl	ax, 8
  1565 00000BF9 66AB                    	stosw		; this is 4th interpolated sample (R)
  1566 00000BFB A0[92210000]            	mov	al, [next_val_l]
  1567 00000C00 00D8                    	add	al, bl
  1568 00000C02 D0D8                    	rcr	al, 1
  1569 00000C04 2C80                    	sub	al, 80h
  1570 00000C06 66C1E008                	shl	ax, 8
  1571 00000C0A 66AB                    	stosw		; this is 5th interpolated sample (L)
  1572 00000C0C A0[94210000]            	mov	al, [next_val_r]
  1573 00000C11 00F8                    	add	al, bh
  1574 00000C13 D0D8                    	rcr	al, 1
  1575 00000C15 2C80                    	sub	al, 80h
  1576 00000C17 66C1E008                	shl	ax, 8
  1577 00000C1B 66AB                    	stosw		; this is 5th interpolated sample (R)
  1578                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1579 00000C1D E305                    	jecxz	lff8s_6
  1580 00000C1F E907FFFFFF              	jmp	lff8s_1
  1581                                  lff8s_6:
  1582 00000C24 E9A6FEFFFF              	jmp	lff8s_3
  1583                                  
  1584                                  load_8khz_mono_16_bit:
  1585                                  	; 02/02/2025
  1586                                  	; 13/11/2023
  1587 00000C29 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1588                                  					; last of the file?
  1589 00000C30 7402                    	jz	short lff8m2_0		; no
  1590 00000C32 F9                      	stc
  1591 00000C33 C3                      	retn
  1592                                  
  1593                                  lff8m2_0:
  1594 00000C34 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1595                                          ;mov	edx, [loadsize]
  1596                                  
  1597                                  	; esi = buffer address
  1598                                  	;; edx = buffer size
  1599                                  
  1600                                  	; load file into memory
  1601                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000C39 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000C3F 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000C41 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000C47 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000C4C CD40                <1>  int 40h
  1602 00000C4E 0F82A0000000            	jc	lff8m2_7 ; error !
  1603                                  
  1604 00000C54 BF[00300000]            	mov	edi, audio_buffer
  1605                                  	
  1606 00000C59 D1E8                    	shr	eax, 1
  1607 00000C5B 7505                    	jnz	short lff8m2_8
  1608 00000C5D E985FEFFFF              	jmp	lff8_eof
  1609                                  
  1610                                  lff8m2_8:
  1611 00000C62 89C1                    	mov	ecx, eax	; word count
  1612                                  lff8m2_1:
  1613 00000C64 66AD                    	lodsw
  1614 00000C66 66AB                    	stosw		; original sample (left channel)
  1615 00000C68 66AB                    	stosw		; original sample (right channel)
  1616 00000C6A 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1617 00000C6D 66A3[8E210000]          	mov	[previous_val], ax
  1618                                  	; 02/02/2025
  1619 00000C73 668B06                  	mov	ax, [esi]
  1620 00000C76 49                      	dec	ecx
  1621 00000C77 7502                    	jnz	short lff8m2_2
  1622 00000C79 31C0                    	xor	eax, eax
  1623                                  lff8m2_2:
  1624 00000C7B 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1625 00000C7E 89C5                    	mov	ebp, eax ; [next_val]
  1626 00000C80 660305[8E210000]        	add	ax, [previous_val]
  1627 00000C87 66D1D8                  	rcr	ax, 1
  1628 00000C8A 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1629 00000C8C 660305[8E210000]        	add	ax, [previous_val]
  1630 00000C93 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1631 00000C96 89C3                    	mov	ebx, eax 		
  1632 00000C98 660305[8E210000]        	add	ax, [previous_val]
  1633 00000C9F 66D1D8                  	rcr	ax, 1
  1634 00000CA2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1635 00000CA5 66AB                    	stosw		; this is 1st interpolated sample (L)
  1636 00000CA7 66AB                    	stosw		; this is 1st interpolated sample (R)
  1637 00000CA9 89D8                    	mov	eax, ebx
  1638 00000CAB 6601D0                  	add	ax, dx
  1639 00000CAE 66D1D8                  	rcr	ax, 1
  1640 00000CB1 80EC80                  	sub	ah, 80h
  1641 00000CB4 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1642 00000CB6 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1643 00000CB8 89D0                    	mov	eax, edx
  1644 00000CBA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1645 00000CBD 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1646 00000CBF 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1647 00000CC1 89E8                    	mov	eax, ebp
  1648 00000CC3 6601D0                  	add	ax, dx
  1649 00000CC6 66D1D8                  	rcr	ax, 1
  1650 00000CC9 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1651 00000CCB 6601D0                  	add	ax, dx
  1652 00000CCE 66D1D8                  	rcr	ax, 1
  1653 00000CD1 80EC80                  	sub	ah, 80h
  1654 00000CD4 66AB                    	stosw		; this is 4th interpolated sample (L)
  1655 00000CD6 66AB                    	stosw		; this is 4th interpolated sample (R)
  1656 00000CD8 89E8                    	mov	eax, ebp
  1657 00000CDA 6601D8                  	add	ax, bx
  1658 00000CDD 66D1D8                  	rcr	ax, 1
  1659 00000CE0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1660 00000CE3 66AB                    	stosw		; this is 5th interpolated sample (L)
  1661 00000CE5 66AB                    	stosw		; this is 5th interpolated sample (R)
  1662                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1663 00000CE7 09C9                    	or	ecx, ecx
  1664 00000CE9 0F8575FFFFFF            	jnz	lff8m2_1
  1665 00000CEF E9DBFDFFFF              	jmp	lff8m2_3
  1666                                  
  1667                                  lff8m2_7:
  1668                                  lff8s2_7:
  1669 00000CF4 E9F7FDFFFF              	jmp	lff8m2_5  ; error
  1670                                  
  1671                                  load_8khz_stereo_16_bit:
  1672                                  	; 02/02/2025
  1673                                  	; 16/11/2023
  1674                                  	; 15/11/2023
  1675                                  	; 13/11/2023
  1676 00000CF9 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1677                                  					; last of the file?
  1678 00000D00 7402                    	jz	short lff8s2_0		; no
  1679 00000D02 F9                      	stc
  1680 00000D03 C3                      	retn
  1681                                  
  1682                                  lff8s2_0:
  1683 00000D04 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1684                                          ;mov	edx, [loadsize]
  1685                                  
  1686                                  	; esi = buffer address
  1687                                  	;; edx = buffer size
  1688                                  
  1689                                  	; load file into memory
  1690                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000D09 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000D0F 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000D11 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000D17 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000D1C CD40                <1>  int 40h
  1691 00000D1E 72D4                    	jc	short lff8s2_7 ; error !
  1692                                  
  1693 00000D20 BF[00300000]            	mov	edi, audio_buffer
  1694                                  	
  1695 00000D25 C1E802                  	shr	eax, 2
  1696 00000D28 7505                    	jnz	short lff8s2_8
  1697 00000D2A E9B8FDFFFF              	jmp	lff8_eof
  1698                                  
  1699                                  lff8s2_8:
  1700 00000D2F 89C1                    	mov	ecx, eax ; dword count
  1701                                  lff8s2_1:
  1702 00000D31 66AD                    	lodsw
  1703 00000D33 66AB                    	stosw		; original sample (L)
  1704                                  	; 15/11/2023
  1705 00000D35 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1706 00000D38 66A3[8E210000]          	mov	[previous_val_l], ax
  1707 00000D3E 66AD                    	lodsw
  1708 00000D40 66AB                    	stosw		; original sample (R)
  1709 00000D42 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1710 00000D45 66A3[90210000]          	mov	[previous_val_r], ax
  1711                                  	; 02/02/2025
  1712 00000D4B 668B06                  	mov	ax, [esi]
  1713 00000D4E 668B5602                	mov	dx, [esi+2]
  1714                                  	; 16/11/2023
  1715 00000D52 49                      	dec	ecx
  1716 00000D53 7504                    	jnz	short lff8s2_2
  1717 00000D55 31D2                    	xor	edx, edx
  1718 00000D57 31C0                    	xor	eax, eax
  1719                                  lff8s2_2:
  1720 00000D59 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1721 00000D5C 66A3[92210000]          	mov	[next_val_l], ax
  1722 00000D62 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1723 00000D65 668915[94210000]        	mov	[next_val_r], dx
  1724 00000D6C 660305[8E210000]        	add	ax, [previous_val_l]
  1725 00000D73 66D1D8                  	rcr	ax, 1
  1726 00000D76 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1727 00000D78 660305[8E210000]        	add	ax, [previous_val_l]
  1728 00000D7F 66D1D8                  	rcr	ax, 1	
  1729 00000D82 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1730 00000D84 660305[8E210000]        	add	ax, [previous_val_l]
  1731 00000D8B 66D1D8                  	rcr	ax, 1
  1732 00000D8E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1733 00000D91 66AB                    	stosw		; this is 1st interpolated sample (L)
  1734 00000D93 66A1[94210000]          	mov	ax, [next_val_r]
  1735 00000D99 660305[90210000]        	add	ax, [previous_val_r]
  1736 00000DA0 66D1D8                  	rcr	ax, 1
  1737 00000DA3 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1738 00000DA5 660305[90210000]        	add	ax, [previous_val_r]
  1739 00000DAC 66D1D8                  	rcr	ax, 1
  1740 00000DAF 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1741 00000DB0 660305[90210000]        	add	ax, [previous_val_r]
  1742 00000DB7 66D1D8                  	rcr	ax, 1
  1743 00000DBA 80EC80                  	sub	ah, 80h
  1744 00000DBD 66AB                    	stosw		; this is 1st interpolated sample (R)
  1745 00000DBF 89D8                    	mov	eax, ebx
  1746 00000DC1 6601D0                  	add	ax, dx
  1747 00000DC4 66D1D8                  	rcr	ax, 1
  1748 00000DC7 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1749 00000DCA 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1750 00000DCC 58                      	pop	eax ; *
  1751 00000DCD 6601E8                  	add	ax, bp
  1752 00000DD0 66D1D8                  	rcr	ax, 1
  1753 00000DD3 80EC80                  	sub	ah, 80h
  1754 00000DD6 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1755 00000DD8 89D0                    	mov	eax, edx
  1756 00000DDA 80EC80                  	sub	ah, 80h
  1757 00000DDD 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1758 00000DDF 89E8                    	mov	eax, ebp
  1759 00000DE1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1760 00000DE4 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1761 00000DE6 66A1[92210000]          	mov	ax, [next_val_l]
  1762 00000DEC 6601D0                  	add	ax, dx
  1763 00000DEF 66D1D8                  	rcr	ax, 1
  1764 00000DF2 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1765 00000DF4 6601D0                  	add	ax, dx
  1766 00000DF7 66D1D8                  	rcr	ax, 1
  1767 00000DFA 80EC80                  	sub	ah, 80h
  1768 00000DFD 66AB                    	stosw		; this is 4th interpolated sample (L)
  1769 00000DFF 66A1[94210000]          	mov	ax, [next_val_r]
  1770 00000E05 6601E8                  	add	ax, bp
  1771 00000E08 66D1D8                  	rcr	ax, 1
  1772 00000E0B 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1773 00000E0C 6601E8                  	add	ax, bp
  1774 00000E0F 66D1D8                  	rcr	ax, 1
  1775 00000E12 80EC80                  	sub	ah, 80h
  1776 00000E15 66AB                    	stosw		; this is 4th interpolated sample (R)
  1777 00000E17 66A1[92210000]          	mov	ax, [next_val_l]
  1778 00000E1D 6601D8                  	add	ax, bx
  1779 00000E20 66D1D8                  	rcr	ax, 1
  1780 00000E23 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1781 00000E26 66AB                    	stosw		; this is 5th interpolated sample (L)
  1782 00000E28 58                      	pop	eax ; **
  1783 00000E29 660305[94210000]        	add	ax, [next_val_r]
  1784 00000E30 66D1D8                  	rcr	ax, 1
  1785 00000E33 80EC80                  	sub	ah, 80h
  1786 00000E36 66AB                    	stosw		; this is 5th interpolated sample (R)
  1787                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1788 00000E38 E305                    	jecxz	lff8_s2_9
  1789 00000E3A E9F2FEFFFF              	jmp	lff8s2_1
  1790                                  lff8_s2_9:
  1791 00000E3F E98BFCFFFF              	jmp	lff8s2_3
  1792                                  
  1793                                  ; .....................
  1794                                  
  1795                                  load_16khz_mono_8_bit:
  1796                                  	; 02/02/2025
  1797                                  	; 14/11/2023
  1798                                  	; 13/11/2023
  1799 00000E44 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1800                                  					; last of the file?
  1801 00000E4B 7402                    	jz	short lff16m_0		; no
  1802 00000E4D F9                      	stc
  1803 00000E4E C3                      	retn
  1804                                  
  1805                                  lff16m_0:
  1806 00000E4F BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1807                                          ;mov	edx, [loadsize]
  1808                                  
  1809                                  	; esi = buffer address
  1810                                  	;; edx = buffer size
  1811                                  
  1812                                  	; load file into memory
  1813                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000E54 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000E5A 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000E5C 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000E62 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000E67 CD40                <1>  int 40h
  1814 00000E69 7253                    	jc	short lff16m_7 ; error !
  1815                                  
  1816 00000E6B BF[00300000]            	mov	edi, audio_buffer
  1817                                  	
  1818 00000E70 21C0                    	and	eax, eax
  1819 00000E72 7505                    	jnz	short lff16m_8
  1820 00000E74 E96EFCFFFF              	jmp	lff16_eof
  1821                                  
  1822                                  lff16m_8:
  1823 00000E79 89C1                    	mov	ecx, eax		; byte count
  1824                                  lff16m_1:
  1825 00000E7B AC                      	lodsb
  1826                                  	;mov	[previous_val], al
  1827 00000E7C 88C3                    	mov	bl, al
  1828 00000E7E 2C80                    	sub	al, 80h
  1829 00000E80 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1830 00000E84 66AB                    	stosw		; original sample (left channel)
  1831 00000E86 66AB                    	stosw		; original sample (right channel)
  1832                                  	;xor	eax, eax
  1833                                  	; 02/02/2025
  1834 00000E88 8A06                    	mov	al, [esi]
  1835 00000E8A 49                      	dec	ecx
  1836 00000E8B 7502                    	jnz	short lff16m_2
  1837                                  	; 14/11/2023
  1838 00000E8D B080                    	mov	al, 80h
  1839                                  lff16m_2:
  1840                                  	;mov	[next_val], al
  1841 00000E8F 88C7                    	mov	bh, al
  1842                                  	;add	al, [previous_val]
  1843 00000E91 00D8                    	add	al, bl
  1844 00000E93 D0D8                    	rcr	al, 1
  1845 00000E95 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1846                                  	;add	al, [previous_val]
  1847 00000E97 00D8                    	add	al, bl
  1848 00000E99 D0D8                    	rcr	al, 1
  1849 00000E9B 2C80                    	sub	al, 80h
  1850 00000E9D 66C1E008                	shl	ax, 8
  1851 00000EA1 66AB                    	stosw		; this is 1st interpolated sample (L)
  1852 00000EA3 66AB                    	stosw		; this is 1st interpolated sample (R)
  1853                                  	;mov	al, [next_val]
  1854 00000EA5 88F8                    	mov	al, bh
  1855 00000EA7 00D0                    	add	al, dl
  1856 00000EA9 D0D8                    	rcr	al, 1
  1857 00000EAB 2C80                    	sub	al, 80h
  1858 00000EAD 66C1E008                	shl	ax, 8
  1859 00000EB1 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1860 00000EB3 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1861                                  	
  1862                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1863 00000EB5 09C9                    	or	ecx, ecx
  1864 00000EB7 75C2                    	jnz	short lff16m_1
  1865 00000EB9 E911FCFFFF              	jmp	lff16m_3
  1866                                  
  1867                                  lff16m_7:
  1868                                  lff16s_7:
  1869 00000EBE E92DFCFFFF              	jmp	lff16m_5  ; error
  1870                                  
  1871                                  load_16khz_stereo_8_bit:
  1872                                  	; 02/02/2025
  1873                                  	; 14/11/2023
  1874                                  	; 13/11/2023
  1875 00000EC3 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1876                                  					; last of the file?
  1877 00000ECA 7402                    	jz	short lff16s_0		; no
  1878 00000ECC F9                      	stc
  1879 00000ECD C3                      	retn
  1880                                  
  1881                                  lff16s_0:
  1882 00000ECE BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1883                                          ;mov	edx, [loadsize]
  1884                                  
  1885                                  	; esi = buffer address
  1886                                  	;; edx = buffer size
  1887                                  
  1888                                  	; load file into memory
  1889                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000ED3 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000ED9 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000EDB 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000EE1 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000EE6 CD40                <1>  int 40h
  1890 00000EE8 72D4                    	jc	short lff16s_7 ; error !
  1891                                  
  1892 00000EEA BF[00300000]            	mov	edi, audio_buffer
  1893                                  	
  1894 00000EEF D1E8                    	shr	eax, 1
  1895 00000EF1 7505                    	jnz	short lff16s_8
  1896 00000EF3 E9EFFBFFFF              	jmp	lff16_eof
  1897                                  
  1898                                  lff16s_8:
  1899 00000EF8 89C1                    	mov	ecx, eax	; word count
  1900                                  lff16s_1:
  1901 00000EFA AC                      	lodsb
  1902 00000EFB A2[8E210000]            	mov	[previous_val_l], al
  1903 00000F00 2C80                    	sub	al, 80h
  1904 00000F02 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1905 00000F06 66AB                    	stosw		; original sample (L)
  1906 00000F08 AC                      	lodsb
  1907 00000F09 A2[90210000]            	mov	[previous_val_r], al
  1908 00000F0E 2C80                    	sub	al, 80h
  1909 00000F10 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1910 00000F14 66AB                    	stosw		; original sample (R)
  1911                                  
  1912                                  	;xor	eax, eax
  1913                                  	; 02/02/2025
  1914 00000F16 668B06                  	mov	ax, [esi]
  1915 00000F19 49                      	dec	ecx
  1916 00000F1A 7504                    	jnz	short lff16s_2
  1917                                  		; convert 8 bit sample to 16 bit sample
  1918                                  	; 14/11/2023
  1919 00000F1C 66B88080                	mov	ax, 8080h
  1920                                  lff16s_2:
  1921                                  	;mov	[next_val_l], al
  1922                                  	;mov	[next_val_r], ah
  1923 00000F20 89C3                    	mov	ebx, eax
  1924 00000F22 0205[8E210000]          	add	al, [previous_val_l]
  1925 00000F28 D0D8                    	rcr	al, 1
  1926 00000F2A 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  1927 00000F2C 0205[8E210000]          	add	al, [previous_val_l]
  1928 00000F32 D0D8                    	rcr	al, 1
  1929 00000F34 2C80                    	sub	al, 80h
  1930 00000F36 66C1E008                	shl	ax, 8
  1931 00000F3A 66AB                    	stosw		; this is 1st interpolated sample (L)
  1932 00000F3C 88F8                    	mov	al, bh	; [next_val_r]
  1933 00000F3E 0205[90210000]          	add	al, [previous_val_r]
  1934 00000F44 D0D8                    	rcr	al, 1
  1935 00000F46 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  1936 00000F48 0205[90210000]          	add	al, [previous_val_r]
  1937 00000F4E D0D8                    	rcr	al, 1
  1938 00000F50 2C80                    	sub	al, 80h
  1939 00000F52 66C1E008                	shl	ax, 8
  1940 00000F56 66AB                    	stosw		; this is 1st interpolated sample (R)
  1941 00000F58 88D0                    	mov	al, dl
  1942 00000F5A 00D8                    	add	al, bl	; [next_val_l]
  1943 00000F5C D0D8                    	rcr	al, 1
  1944 00000F5E 2C80                    	sub	al, 80h
  1945 00000F60 66C1E008                	shl	ax, 8
  1946 00000F64 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1947 00000F66 88F0                    	mov	al, dh
  1948 00000F68 00F8                    	add	al, bh	; [next_val_r]
  1949 00000F6A D0D8                    	rcr	al, 1
  1950 00000F6C 2C80                    	sub	al, 80h
  1951 00000F6E 66C1E008                	shl	ax, 8
  1952 00000F72 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1953                                  	
  1954                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1955 00000F74 09C9                    	or	ecx, ecx
  1956 00000F76 7582                    	jnz	short lff16s_1
  1957 00000F78 E952FBFFFF              	jmp	lff16s_3
  1958                                  
  1959                                  load_16khz_mono_16_bit:
  1960                                  	; 02/02/2025
  1961                                  	; 15/11/2023
  1962                                  	; 13/11/2023
  1963 00000F7D F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1964                                  					; last of the file?
  1965 00000F84 7402                    	jz	short lff16m2_0		; no
  1966 00000F86 F9                      	stc
  1967 00000F87 C3                      	retn
  1968                                  
  1969                                  lff16m2_0:
  1970 00000F88 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1971                                          ;mov	edx, [loadsize]
  1972                                  
  1973                                  	; esi = buffer address
  1974                                  	;; edx = buffer size
  1975                                  
  1976                                  	; load file into memory
  1977                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00000F8D 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00000F93 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00000F95 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00000F9B B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00000FA0 CD40                <1>  int 40h
  1978 00000FA2 7255                    	jc	short lff16m2_7 ; error !
  1979                                  
  1980 00000FA4 BF[00300000]            	mov	edi, audio_buffer
  1981                                  	
  1982 00000FA9 D1E8                    	shr	eax, 1
  1983 00000FAB 7505                    	jnz	short lff16m2_8
  1984 00000FAD E935FBFFFF              	jmp	lff16_eof
  1985                                  
  1986                                  lff16m2_8:
  1987 00000FB2 89C1                    	mov	ecx, eax  ; word count
  1988                                  lff16m2_1:
  1989 00000FB4 66AD                    	lodsw
  1990 00000FB6 66AB                    	stosw		; original sample (left channel)
  1991 00000FB8 66AB                    	stosw		; original sample (right channel)
  1992 00000FBA 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  1993                                  	;mov	[previous_val], ax
  1994 00000FBD 89C3                    	mov	ebx, eax
  1995                                  	; 02/02/2025
  1996 00000FBF 668B06                  	mov	ax, [esi]
  1997 00000FC2 49                      	dec	ecx
  1998 00000FC3 7502                    	jnz	short lff16m2_2
  1999 00000FC5 31C0                    	xor	eax, eax
  2000                                  lff16m2_2:
  2001 00000FC7 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2002 00000FCA 89C5                    	mov	ebp, eax ; [next_val]
  2003                                  	;add	ax, [previous_val]
  2004 00000FCC 6601D8                  	add	ax, bx
  2005 00000FCF 66D1D8                  	rcr	ax, 1
  2006 00000FD2 89C2                    	mov	edx, eax ; this is temporary interpolation value
  2007                                  	;add	ax, [previous_val]
  2008 00000FD4 6601D8                  	add	ax, bx
  2009 00000FD7 66D1D8                  	rcr	ax, 1
  2010 00000FDA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2011 00000FDD 66AB                    	stosw		; this is 1st interpolated sample (L)
  2012 00000FDF 66AB                    	stosw		; this is 1st interpolated sample (R)
  2013 00000FE1 89E8                    	mov	eax, ebp 
  2014 00000FE3 6601D0                  	add	ax, dx
  2015 00000FE6 66D1D8                  	rcr	ax, 1
  2016 00000FE9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2017 00000FEC 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2018 00000FEE 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2019                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2020 00000FF0 09C9                    	or	ecx, ecx
  2021 00000FF2 75C0                    	jnz	short lff16m2_1
  2022 00000FF4 E9D6FAFFFF              	jmp	lff16m2_3
  2023                                  
  2024                                  lff16m2_7:
  2025                                  lff16s2_7:
  2026 00000FF9 E9F2FAFFFF              	jmp	lff16m2_5  ; error
  2027                                  
  2028                                  load_16khz_stereo_16_bit:
  2029                                  	; 02/02/2025
  2030                                  	; 16/11/2023
  2031                                  	; 15/11/2023
  2032                                  	; 13/11/2023
  2033 00000FFE F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2034                                  					; last of the file?
  2035 00001005 7402                    	jz	short lff16s2_0		; no
  2036 00001007 F9                      	stc
  2037 00001008 C3                      	retn
  2038                                  
  2039                                  lff16s2_0:
  2040 00001009 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2041                                          ;mov	edx, [loadsize]
  2042                                  
  2043                                  	; esi = buffer address
  2044                                  	;; edx = buffer size
  2045                                  
  2046                                  	; load file into memory
  2047                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000100E 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001014 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001016 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000101C B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001021 CD40                <1>  int 40h
  2048 00001023 72D4                    	jc	short lff16s2_7 ; error !
  2049                                  
  2050 00001025 BF[00300000]            	mov	edi, audio_buffer
  2051                                  	
  2052 0000102A C1E802                  	shr	eax, 2
  2053 0000102D 7505                    	jnz	short lff16s2_8
  2054 0000102F E9B3FAFFFF              	jmp	lff16_eof
  2055                                  
  2056                                  lff16s2_8:
  2057 00001034 89C1                    	mov	ecx, eax  ; dword count
  2058                                  lff16s2_1:
  2059 00001036 66AD                    	lodsw
  2060 00001038 66AB                    	stosw		; original sample (L)
  2061 0000103A 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2062 0000103D 66A3[8E210000]          	mov	[previous_val_l], ax
  2063 00001043 66AD                    	lodsw
  2064 00001045 66AB                    	stosw		; original sample (R)
  2065 00001047 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2066 0000104A 66A3[90210000]          	mov	[previous_val_r], ax
  2067                                  	; 02/02/2025
  2068 00001050 668B06                  	mov	ax, [esi]
  2069 00001053 668B5602                	mov	dx, [esi+2]
  2070                                  	; 16/11/2023
  2071 00001057 49                      	dec	ecx
  2072 00001058 7504                    	jnz	short lff16s2_2
  2073 0000105A 31D2                    	xor	edx, edx
  2074 0000105C 31C0                    	xor	eax, eax
  2075                                  lff16s2_2:
  2076 0000105E 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2077                                  	;mov	[next_val_l], ax
  2078 00001061 89C5                    	mov	ebp, eax
  2079 00001063 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2080 00001066 668915[94210000]        	mov	[next_val_r], dx
  2081 0000106D 660305[8E210000]        	add	ax, [previous_val_l]
  2082 00001074 66D1D8                  	rcr	ax, 1
  2083 00001077 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  2084 00001079 660305[8E210000]        	add	ax, [previous_val_l]
  2085 00001080 66D1D8                  	rcr	ax, 1
  2086 00001083 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2087 00001086 66AB                    	stosw		; this is 1st interpolated sample (L)
  2088 00001088 66A1[94210000]          	mov	ax, [next_val_r]
  2089 0000108E 660305[90210000]        	add	ax, [previous_val_r]
  2090 00001095 66D1D8                  	rcr	ax, 1
  2091 00001098 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  2092 0000109A 660305[90210000]        	add	ax, [previous_val_r]
  2093 000010A1 66D1D8                  	rcr	ax, 1
  2094 000010A4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2095 000010A7 66AB                    	stosw		; this is 1st interpolated sample (R)
  2096                                  	;mov	ax, [next_val_l]
  2097 000010A9 89E8                    	mov	eax, ebp
  2098 000010AB 6601D0                  	add	ax, dx
  2099 000010AE 66D1D8                  	rcr	ax, 1
  2100 000010B1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2101 000010B4 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2102 000010B6 66A1[94210000]          	mov	ax, [next_val_r]
  2103 000010BC 6601D8                  	add	ax, bx
  2104 000010BF 66D1D8                  	rcr	ax, 1
  2105 000010C2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2106 000010C5 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2107                                  	
  2108                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2109 000010C7 09C9                    	or	ecx, ecx
  2110 000010C9 0F8567FFFFFF            	jnz	lff16s2_1
  2111 000010CF E9FBF9FFFF              	jmp	lff16s2_3
  2112                                  
  2113                                  ; .....................
  2114                                  
  2115                                  load_24khz_mono_8_bit:
  2116                                  	; 02/02/2025
  2117                                  	; 15/11/2023
  2118 000010D4 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2119                                  					; last of the file?
  2120 000010DB 7402                    	jz	short lff24m_0		; no
  2121 000010DD F9                      	stc
  2122 000010DE C3                      	retn
  2123                                  
  2124                                  lff24m_0:
  2125 000010DF BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2126                                          ;mov	edx, [loadsize]
  2127                                  
  2128                                  	; esi = buffer address
  2129                                  	;; edx = buffer size
  2130                                  
  2131                                  	; load file into memory
  2132                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000010E4 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000010EA 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000010EC 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000010F2 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000010F7 CD40                <1>  int 40h
  2133 000010F9 723B                    	jc	short lff24m_7 ; error !
  2134                                  
  2135 000010FB BF[00300000]            	mov	edi, audio_buffer
  2136                                  	
  2137 00001100 21C0                    	and	eax, eax
  2138 00001102 7505                    	jnz	short lff24m_8
  2139 00001104 E9DEF9FFFF              	jmp	lff24_eof
  2140                                  
  2141                                  lff24m_8:
  2142 00001109 89C1                    	mov	ecx, eax	; byte count
  2143                                  lff24m_1:
  2144 0000110B AC                      	lodsb
  2145                                  	;mov	[previous_val], al
  2146 0000110C 88C3                    	mov	bl, al
  2147 0000110E 2C80                    	sub	al, 80h
  2148 00001110 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2149 00001114 66AB                    	stosw		; original sample (left channel)
  2150 00001116 66AB                    	stosw		; original sample (right channel)
  2151                                  	;xor	eax, eax
  2152                                  	; 02/02/2025
  2153 00001118 8A06                    	mov	al, [esi]
  2154 0000111A 49                      	dec	ecx
  2155 0000111B 7502                    	jnz	short lff24m_2
  2156 0000111D B080                    	mov	al, 80h
  2157                                  lff24m_2:
  2158                                  	;;mov	[next_val], al
  2159                                  	;mov	bh, al
  2160                                  	;add	al, [previous_val]
  2161 0000111F 00D8                    	add	al, bl
  2162 00001121 D0D8                    	rcr	al, 1
  2163 00001123 2C80                    	sub	al, 80h
  2164 00001125 66C1E008                	shl	ax, 8
  2165 00001129 66AB                    	stosw		; this is interpolated sample (L)
  2166 0000112B 66AB                    	stosw		; this is interpolated sample (R)
  2167                                  	
  2168                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2169 0000112D 09C9                    	or	ecx, ecx
  2170 0000112F 75DA                    	jnz	short lff24m_1
  2171 00001131 E999F9FFFF              	jmp	lff24_3
  2172                                  
  2173                                  lff24m_7:
  2174                                  lff24s_7:
  2175 00001136 E9B5F9FFFF              	jmp	lff24_5  ; error
  2176                                  
  2177                                  load_24khz_stereo_8_bit:
  2178                                  	; 02/02/2025
  2179                                  	; 15/11/2023
  2180 0000113B F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2181                                  					; last of the file?
  2182 00001142 7402                    	jz	short lff24s_0		; no
  2183 00001144 F9                      	stc
  2184 00001145 C3                      	retn
  2185                                  
  2186                                  lff24s_0:
  2187 00001146 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2188                                          ;mov	edx, [loadsize]
  2189                                  
  2190                                  	; esi = buffer address
  2191                                  	;; edx = buffer size
  2192                                  
  2193                                  	; load file into memory
  2194                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000114B 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001151 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001153 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001159 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000115E CD40                <1>  int 40h
  2195 00001160 72D4                    	jc	short lff24s_7 ; error !
  2196                                  
  2197 00001162 BF[00300000]            	mov	edi, audio_buffer
  2198                                  
  2199 00001167 D1E8                    	shr	eax, 1
  2200 00001169 7505                    	jnz	short lff24s_8
  2201 0000116B E977F9FFFF              	jmp	lff24_eof
  2202                                  
  2203                                  lff24s_8:
  2204 00001170 89C1                    	mov	ecx, eax  ; word count
  2205                                  lff24s_1:
  2206 00001172 AC                      	lodsb
  2207 00001173 A2[8E210000]            	mov	[previous_val_l], al
  2208 00001178 2C80                    	sub	al, 80h
  2209 0000117A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2210 0000117E 66AB                    	stosw		; original sample (L)
  2211 00001180 AC                      	lodsb
  2212 00001181 A2[90210000]            	mov	[previous_val_r], al
  2213 00001186 2C80                    	sub	al, 80h
  2214 00001188 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2215 0000118C 66AB                    	stosw		; original sample (R)
  2216                                  
  2217                                  	;xor	eax, eax
  2218                                  	; 02/02/2025
  2219 0000118E 668B06                  	mov	ax, [esi]
  2220 00001191 49                      	dec	ecx
  2221 00001192 7504                    	jnz	short lff24s_2
  2222                                  		; convert 8 bit sample to 16 bit sample
  2223 00001194 66B88080                	mov	ax, 8080h
  2224                                  lff24s_2:
  2225                                  	;;mov	[next_val_l], al
  2226                                  	;;mov	[next_val_r], ah
  2227                                  	;mov	bx, ax
  2228 00001198 88E7                    	mov	bh, ah
  2229 0000119A 0205[8E210000]          	add	al, [previous_val_l]
  2230 000011A0 D0D8                    	rcr	al, 1
  2231                                  	;mov	dl, al
  2232 000011A2 2C80                    	sub	al, 80h
  2233 000011A4 66C1E008                	shl	ax, 8
  2234 000011A8 66AB                    	stosw		; this is interpolated sample (L)
  2235 000011AA 88F8                    	mov	al, bh	; [next_val_r]
  2236 000011AC 0205[90210000]          	add	al, [previous_val_r]
  2237 000011B2 D0D8                    	rcr	al, 1
  2238                                  	;mov	dh, al
  2239 000011B4 2C80                    	sub	al, 80h
  2240 000011B6 66C1E008                	shl	ax, 8
  2241 000011BA 66AB                    	stosw		; this is interpolated sample (R)
  2242                                  		
  2243                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2244 000011BC 09C9                    	or	ecx, ecx
  2245 000011BE 75B2                    	jnz	short lff24s_1
  2246 000011C0 E90AF9FFFF              	jmp	lff24_3
  2247                                  
  2248                                  load_24khz_mono_16_bit:
  2249                                  	; 02/02/2025
  2250                                  	; 15/11/2023
  2251 000011C5 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2252                                  					; last of the file?
  2253 000011CC 7402                    	jz	short lff24m2_0		; no
  2254 000011CE F9                      	stc
  2255 000011CF C3                      	retn
  2256                                  
  2257                                  lff24m2_0:
  2258 000011D0 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2259                                          ;mov	edx, [loadsize]
  2260                                  
  2261                                  	; esi = buffer address
  2262                                  	;; edx = buffer size
  2263                                  
  2264                                  	; load file into memory
  2265                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000011D5 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000011DB 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000011DD 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000011E3 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000011E8 CD40                <1>  int 40h
  2266 000011EA 723A                    	jc	short lff24m2_7 ; error !
  2267                                  
  2268 000011EC BF[00300000]            	mov	edi, audio_buffer
  2269                                  	
  2270 000011F1 D1E8                    	shr	eax, 1
  2271 000011F3 7505                    	jnz	short lff24m2_8
  2272 000011F5 E9EDF8FFFF              	jmp	lff24_eof
  2273                                  
  2274                                  lff24m2_8:
  2275 000011FA 89C1                    	mov	ecx, eax  ; word count
  2276                                  lff24m2_1:
  2277 000011FC 66AD                    	lodsw
  2278 000011FE 66AB                    	stosw		; original sample (left channel)
  2279 00001200 66AB                    	stosw		; original sample (right channel)
  2280 00001202 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2281                                  	;mov	[previous_val], ax
  2282                                  	;mov	ebx, eax
  2283                                  	; 02/02/2025
  2284 00001205 668B1E                  	mov	bx, [esi]
  2285 00001208 49                      	dec	ecx
  2286 00001209 7502                    	jnz	short lff24m2_2
  2287                                  	;xor	eax, eax
  2288 0000120B 31DB                    	xor	ebx, ebx
  2289                                  lff24m2_2:
  2290                                  	; 02/02/2025
  2291 0000120D 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  2292                                  	;add	ah, 80h
  2293                                  	;mov	ebp, eax	; [next_val]
  2294                                  	;add	ax, [previous_val]
  2295                                  	; ax = [previous_val]
  2296                                  	; bx = [next_val]
  2297 00001210 6601D8                  	add	ax, bx
  2298 00001213 66D1D8                  	rcr	ax, 1
  2299 00001216 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2300 00001219 66AB                    	stosw		; this is interpolated sample (L)
  2301 0000121B 66AB                    	stosw		; this is interpolated sample (R)
  2302                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2303 0000121D 09C9                    	or	ecx, ecx
  2304 0000121F 75DB                    	jnz	short lff24m2_1
  2305 00001221 E9A9F8FFFF              	jmp	lff24_3
  2306                                  
  2307                                  lff24m2_7:
  2308                                  lff24s2_7:
  2309 00001226 E9C5F8FFFF              	jmp	lff24_5  ; error
  2310                                  
  2311                                  load_24khz_stereo_16_bit:
  2312                                  	; 02/02/2025
  2313                                  	; 16/11/2023
  2314                                  	; 15/11/2023
  2315 0000122B F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2316                                  					; last of the file?
  2317 00001232 7402                    	jz	short lff24s2_0		; no
  2318 00001234 F9                      	stc
  2319 00001235 C3                      	retn
  2320                                  
  2321                                  lff24s2_0:
  2322 00001236 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2323                                          ;mov	edx, [loadsize]
  2324                                  
  2325                                  	; esi = buffer address
  2326                                  	;; edx = buffer size
  2327                                  
  2328                                  	; load file into memory
  2329                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000123B 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001241 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001243 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001249 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000124E CD40                <1>  int 40h
  2330 00001250 72D4                    	jc	short lff24s2_7 ; error !
  2331                                  
  2332 00001252 BF[00300000]            	mov	edi, audio_buffer
  2333                                  	
  2334 00001257 C1E802                  	shr	eax, 2
  2335 0000125A 7505                    	jnz	short lff24s2_8
  2336 0000125C E986F8FFFF              	jmp	lff24_eof
  2337                                  
  2338                                  lff24s2_8:
  2339 00001261 89C1                    	mov	ecx, eax  ; dword count
  2340                                  lff24s2_1:
  2341 00001263 66AD                    	lodsw
  2342 00001265 66AB                    	stosw		; original sample (L)
  2343 00001267 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2344 0000126A 66A3[8E210000]          	mov	[previous_val_l], ax
  2345 00001270 66AD                    	lodsw
  2346 00001272 66AB                    	stosw		; original sample (R)
  2347 00001274 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2348                                  	;mov	[previous_val_r], ax
  2349 00001277 89C3                    	mov	ebx, eax
  2350                                  	; 02/02/2025
  2351 00001279 668B06                  	mov	ax, [esi]
  2352 0000127C 668B5602                	mov	dx, [esi+2]
  2353                                  	; 16/11/2023
  2354 00001280 49                      	dec	ecx
  2355 00001281 7504                    	jnz	short lff24s2_2
  2356 00001283 31D2                    	xor	edx, edx
  2357 00001285 31C0                    	xor	eax, eax
  2358                                  lff24s2_2:
  2359 00001287 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2360                                  	;;mov	[next_val_l], ax
  2361                                  	;mov	ebp, eax
  2362 0000128A 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  2363                                  	;mov	[next_val_r], dx
  2364 0000128D 660305[8E210000]        	add	ax, [previous_val_l]
  2365 00001294 66D1D8                  	rcr	ax, 1
  2366 00001297 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2367 0000129A 66AB                    	stosw		; this is interpolated sample (L)
  2368                                  	;mov	ax, [next_val_r]
  2369 0000129C 89D0                    	mov	eax, edx
  2370                                  	;add	ax, [previous_val_r]
  2371 0000129E 6601D8                  	add	ax, bx
  2372 000012A1 66D1D8                  	rcr	ax, 1
  2373 000012A4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2374 000012A7 66AB                    	stosw		; this is interpolated sample (R)
  2375                                  
  2376                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2377 000012A9 09C9                    	or	ecx, ecx
  2378 000012AB 75B6                    	jnz	short lff24s2_1
  2379 000012AD E91DF8FFFF              	jmp	lff24_3
  2380                                  
  2381                                  ; .....................
  2382                                  
  2383                                  load_32khz_mono_8_bit:
  2384                                  	; 02/02/2025
  2385                                  	; 15/11/2023
  2386 000012B2 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2387                                  					; last of the file?
  2388 000012B9 7402                    	jz	short lff32m_0		; no
  2389 000012BB F9                      	stc
  2390 000012BC C3                      	retn
  2391                                  
  2392                                  lff32m_0:
  2393 000012BD BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2394                                          ;mov	edx, [loadsize]
  2395                                  
  2396                                  	; esi = buffer address
  2397                                  	;; edx = buffer size
  2398                                  
  2399                                  	; load file into memory
  2400                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000012C2 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000012C8 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000012CA 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000012D0 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000012D5 CD40                <1>  int 40h
  2401 000012D7 7247                    	jc	short lff32m_7 ; error !
  2402                                  
  2403 000012D9 BF[00300000]            	mov	edi, audio_buffer
  2404                                  
  2405 000012DE 21C0                    	and	eax, eax
  2406 000012E0 7505                    	jnz	short lff32m_8
  2407 000012E2 E900F8FFFF              	jmp	lff32_eof
  2408                                  
  2409                                  lff32m_8:
  2410 000012E7 89C1                    	mov	ecx, eax	; byte count
  2411                                  lff32m_1:
  2412 000012E9 AC                      	lodsb
  2413                                  	;mov	[previous_val], al
  2414 000012EA 88C3                    	mov	bl, al
  2415 000012EC 2C80                    	sub	al, 80h
  2416 000012EE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2417 000012F2 66AB                    	stosw		; original sample (left channel)
  2418 000012F4 66AB                    	stosw		; original sample (right channel)
  2419                                  	;xor	eax, eax
  2420                                  	; 02/02/2025
  2421 000012F6 8A06                    	mov	al, [esi]
  2422 000012F8 49                      	dec	ecx
  2423 000012F9 7502                    	jnz	short lff32m_2
  2424 000012FB B080                    	mov	al, 80h
  2425                                  lff32m_2:
  2426                                  	;;mov	[next_val], al
  2427                                  	;mov	bh, al
  2428                                  	;add	al, [previous_val]
  2429 000012FD 00D8                    	add	al, bl
  2430 000012FF D0D8                    	rcr	al, 1
  2431 00001301 2C80                    	sub	al, 80h
  2432 00001303 66C1E008                	shl	ax, 8
  2433 00001307 66AB                    	stosw		; this is interpolated sample (L)
  2434 00001309 66AB                    	stosw		; this is interpolated sample (R)
  2435                                  	
  2436                                  	; different than 8-16-24 kHZ !
  2437                                  	; 'original-interpolated-original' trio samples
  2438 0000130B E30E                    	jecxz	lff32m_3
  2439                                  
  2440 0000130D AC                      	lodsb
  2441 0000130E 2C80                    	sub	al, 80h
  2442 00001310 66C1E008                	shl	ax, 8
  2443 00001314 66AB                    	stosw		; original sample (left channel)
  2444 00001316 66AB                    	stosw		; original sample (right channel)
  2445                                  
  2446                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2447 00001318 49                      	dec	ecx
  2448 00001319 75CE                    	jnz	short lff32m_1
  2449                                  lff32m_3:
  2450 0000131B E9AFF7FFFF              	jmp	lff32_3
  2451                                  
  2452                                  lff32m_7:
  2453                                  lff32s_7:
  2454 00001320 E9CBF7FFFF              	jmp	lff32_5  ; error
  2455                                  
  2456                                  load_32khz_stereo_8_bit:
  2457                                  	; 02/02/2025
  2458                                  	; 15/11/2023
  2459 00001325 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2460                                  					; last of the file?
  2461 0000132C 7402                    	jz	short lff32s_0		; no
  2462 0000132E F9                      	stc
  2463 0000132F C3                      	retn
  2464                                  
  2465                                  lff32s_0:
  2466 00001330 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2467                                          ;mov	edx, [loadsize]
  2468                                  
  2469                                  	; esi = buffer address
  2470                                  	;; edx = buffer size
  2471                                  
  2472                                  	; load file into memory
  2473                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001335 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000133B 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000133D 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001343 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001348 CD40                <1>  int 40h
  2474 0000134A 72D4                    	jc	short lff32s_7 ; error !
  2475                                  
  2476 0000134C BF[00300000]            	mov	edi, audio_buffer
  2477                                  	
  2478 00001351 D1E8                    	shr	eax, 1
  2479 00001353 7505                    	jnz	short lff32s_8
  2480 00001355 E98DF7FFFF              	jmp	lff32_eof
  2481                                  
  2482                                  lff32s_8:
  2483 0000135A 89C1                    	mov	ecx, eax  ; word count
  2484                                  lff32s_1:
  2485 0000135C AC                      	lodsb
  2486 0000135D A2[8E210000]            	mov	[previous_val_l], al
  2487 00001362 2C80                    	sub	al, 80h
  2488 00001364 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2489 00001368 66AB                    	stosw		; original sample (L)
  2490 0000136A AC                      	lodsb
  2491 0000136B A2[90210000]            	mov	[previous_val_r], al
  2492 00001370 2C80                    	sub	al, 80h
  2493 00001372 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2494 00001376 66AB                    	stosw		; original sample (R)
  2495                                  
  2496                                  	;xor	eax, eax
  2497                                  	; 02/02/2025
  2498 00001378 668B06                  	mov	ax, [esi]
  2499 0000137B 49                      	dec	ecx
  2500 0000137C 7504                    	jnz	short lff32s_2
  2501                                  		; convert 8 bit sample to 16 bit sample
  2502 0000137E 66B88080                	mov	ax, 8080h
  2503                                  lff32s_2:
  2504                                  	;;mov	[next_val_l], al
  2505                                  	;;mov	[next_val_r], ah
  2506                                  	;mov	bx, ax
  2507 00001382 88E7                    	mov	bh, ah
  2508 00001384 0205[8E210000]          	add	al, [previous_val_l]
  2509 0000138A D0D8                    	rcr	al, 1
  2510                                  	;mov	dl, al
  2511 0000138C 2C80                    	sub	al, 80h
  2512 0000138E 66C1E008                	shl	ax, 8
  2513 00001392 66AB                    	stosw		; this is interpolated sample (L)
  2514 00001394 88F8                    	mov	al, bh	; [next_val_r]
  2515 00001396 0205[90210000]          	add	al, [previous_val_r]
  2516 0000139C D0D8                    	rcr	al, 1
  2517                                  	;mov	dh, al
  2518 0000139E 2C80                    	sub	al, 80h
  2519 000013A0 66C1E008                	shl	ax, 8
  2520 000013A4 66AB                    	stosw		; this is interpolated sample (R)
  2521                                  
  2522                                  	; different than 8-16-24 kHZ !
  2523                                  	; 'original-interpolated-original' trio samples
  2524 000013A6 E315                    	jecxz	lff32s_3
  2525                                  
  2526 000013A8 AC                      	lodsb
  2527 000013A9 2C80                    	sub	al, 80h
  2528 000013AB 66C1E008                	shl	ax, 8
  2529 000013AF 66AB                    	stosw		; original sample (left channel)
  2530                                  
  2531 000013B1 AC                      	lodsb
  2532 000013B2 2C80                    	sub	al, 80h
  2533 000013B4 66C1E008                	shl	ax, 8
  2534 000013B8 66AB                    	stosw		; original sample (right channel)
  2535                                  
  2536                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2537 000013BA 49                      	dec	ecx
  2538 000013BB 759F                    	jnz	short lff32s_1
  2539                                  lff32s_3:
  2540 000013BD E90DF7FFFF              	jmp	lff32_3
  2541                                  
  2542                                  load_32khz_mono_16_bit:
  2543                                  	; 02/02/2025
  2544                                  	; 15/11/2023
  2545 000013C2 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2546                                  					; last of the file?
  2547 000013C9 7402                    	jz	short lff32m2_0		; no
  2548 000013CB F9                      	stc
  2549 000013CC C3                      	retn
  2550                                  
  2551                                  lff32m2_0:
  2552 000013CD BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2553                                          ;mov	edx, [loadsize]
  2554                                  
  2555                                  	; esi = buffer address
  2556                                  	;; edx = buffer size
  2557                                  
  2558                                  	; load file into memory
  2559                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000013D2 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000013D8 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000013DA 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000013E0 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000013E5 CD40                <1>  int 40h
  2560 000013E7 7241                    	jc	short lff32m2_7 ; error !
  2561                                  
  2562 000013E9 BF[00300000]            	mov	edi, audio_buffer
  2563                                  	
  2564 000013EE D1E8                    	shr	eax, 1
  2565 000013F0 7505                    	jnz	short lff32m2_8
  2566 000013F2 E9F0F6FFFF              	jmp	lff32_eof
  2567                                  
  2568                                  lff32m2_8:
  2569 000013F7 89C1                    	mov	ecx, eax  ; word count
  2570                                  lff32m2_1:
  2571 000013F9 66AD                    	lodsw
  2572 000013FB 66AB                    	stosw		; original sample (left channel)
  2573 000013FD 66AB                    	stosw		; original sample (right channel)
  2574 000013FF 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2575                                  	;mov	[previous_val], ax
  2576                                  	;mov	ebx, eax
  2577                                  	;xor	eax, eax
  2578                                  	; 02/02/2025
  2579                                  	;mov	ax, [esi]
  2580 00001402 668B1E                  	mov	bx, [esi]
  2581 00001405 49                      	dec	ecx
  2582 00001406 7502                    	jnz	short lff32m2_2
  2583 00001408 31DB                    	xor	ebx, ebx
  2584                                  lff32m2_2:
  2585                                  	; 02/02/2025
  2586 0000140A 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  2587                                  	;add	ah, 80h
  2588                                  	;mov	ebp, eax ; [next_val]
  2589                                  	;add	ax, [previous_val]
  2590                                  	; ax = [previous_val]
  2591                                  	; bx = [next_val]
  2592 0000140D 6601D8                  	add	ax, bx
  2593 00001410 66D1D8                  	rcr	ax, 1
  2594 00001413 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2595 00001416 66AB                    	stosw		; this is interpolated sample (L)
  2596 00001418 66AB                    	stosw		; this is interpolated sample (R)
  2597                                  
  2598                                  	; different than 8-16-24 kHZ !
  2599                                  	; 'original-interpolated-original' trio samples
  2600 0000141A E309                    	jecxz	lff32m2_3
  2601                                  
  2602 0000141C 66AD                    	lodsw
  2603 0000141E 66AB                    	stosw		; original sample (left channel)
  2604 00001420 66AB                    	stosw		; original sample (right channel)
  2605                                  
  2606                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2607 00001422 49                      	dec	ecx
  2608 00001423 75D4                    	jnz	short lff32m2_1
  2609                                  lff32m2_3:
  2610 00001425 E9A5F6FFFF              	jmp	lff32_3
  2611                                  
  2612                                  lff32m2_7:
  2613                                  lff32s2_7:
  2614 0000142A E9C1F6FFFF              	jmp	lff32_5  ; error
  2615                                  
  2616                                  load_32khz_stereo_16_bit:
  2617                                  	; 02/02/2025
  2618                                  	; 16/11/2023
  2619                                  	; 15/11/2023
  2620 0000142F F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2621                                  					; last of the file?
  2622 00001436 7402                    	jz	short lff32s2_0		; no
  2623 00001438 F9                      	stc
  2624 00001439 C3                      	retn
  2625                                  
  2626                                  lff32s2_0:
  2627 0000143A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2628                                          ;mov	edx, [loadsize]
  2629                                  
  2630                                  	; esi = buffer address
  2631                                  	;; edx = buffer size
  2632                                  
  2633                                  	; load file into memory
  2634                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000143F 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001445 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001447 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000144D B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001452 CD40                <1>  int 40h
  2635 00001454 72D4                    	jc	short lff32s2_7 ; error !
  2636                                  
  2637 00001456 BF[00300000]            	mov	edi, audio_buffer
  2638                                  	
  2639 0000145B C1E802                  	shr	eax, 2
  2640 0000145E 7505                    	jnz	short lff32s2_8
  2641 00001460 E982F6FFFF              	jmp	lff32_eof
  2642                                  
  2643                                  lff32s2_8:
  2644 00001465 89C1                    	mov	ecx, eax ; dword count
  2645                                  lff32s2_1:
  2646 00001467 66AD                    	lodsw
  2647 00001469 66AB                    	stosw		; original sample (L)
  2648 0000146B 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2649 0000146E 66A3[8E210000]          	mov	[previous_val_l], ax
  2650 00001474 66AD                    	lodsw
  2651 00001476 66AB                    	stosw		; original sample (R)
  2652 00001478 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2653                                  	;mov	[previous_val_r], ax
  2654 0000147B 89C3                    	mov	ebx, eax
  2655                                  	; 02/02/2025
  2656 0000147D 668B06                  	mov	ax, [esi]
  2657 00001480 668B5602                	mov	dx, [esi+2]
  2658                                  	; 16/11/2023
  2659 00001484 49                      	dec	ecx
  2660 00001485 7504                    	jnz	short lff32s2_2
  2661 00001487 31D2                    	xor	edx, edx
  2662 00001489 31C0                    	xor	eax, eax
  2663                                  lff32s2_2:
  2664 0000148B 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  2665                                  	;;mov	[next_val_l], ax
  2666                                  	;mov	ebp, eax
  2667 0000148E 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  2668                                  	;mov	[next_val_r], dx
  2669 00001491 660305[8E210000]        	add	ax, [previous_val_l]
  2670 00001498 66D1D8                  	rcr	ax, 1
  2671 0000149B 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2672 0000149E 66AB                    	stosw		; this is interpolated sample (L)
  2673                                  	;mov	ax, [next_val_r]
  2674 000014A0 89D0                    	mov	eax, edx
  2675                                  	;add	ax, [previous_val_r]
  2676 000014A2 6601D8                  	add	ax, bx
  2677 000014A5 66D1D8                  	rcr	ax, 1
  2678 000014A8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2679 000014AB 66AB                    	stosw		; this is interpolated sample (R)
  2680                                  
  2681                                  	; different than 8-16-24 kHZ !
  2682                                  	; 'original-interpolated-original' trio samples 
  2683 000014AD E30B                    	jecxz	lff32s2_3
  2684                                  
  2685 000014AF 66AD                    	lodsw
  2686 000014B1 66AB                    	stosw	; original sample (L)
  2687 000014B3 66AD                    	lodsw
  2688 000014B5 66AB                    	stosw	; original sample (R)
  2689                                  
  2690                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2691 000014B7 49                      	dec	ecx
  2692 000014B8 75AD                    	jnz	short lff32s2_1
  2693                                  lff32s2_3:
  2694 000014BA E910F6FFFF              	jmp	lff32_3
  2695                                  
  2696                                  ; .....................
  2697                                  
  2698                                  load_22khz_mono_8_bit:
  2699                                  	; 02/02/2025
  2700                                  	; 16/11/2023
  2701 000014BF F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2702                                  					; last of the file?
  2703 000014C6 7402                    	jz	short lff22m_0		; no
  2704 000014C8 F9                      	stc
  2705 000014C9 C3                      	retn
  2706                                  
  2707                                  lff22m_0:
  2708 000014CA BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2709                                          ;mov	edx, [loadsize]
  2710                                  
  2711                                  	; esi = buffer address
  2712                                  	;; edx = buffer size
  2713                                  
  2714                                  	; load file into memory
  2715                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000014CF 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000014D5 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000014D7 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000014DD B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000014E2 CD40                <1>  int 40h
  2716 000014E4 725D                    	jc	short lff22m_7 ; error !
  2717                                  
  2718 000014E6 BF[00300000]            	mov	edi, audio_buffer
  2719                                  	
  2720 000014EB 21C0                    	and	eax, eax
  2721 000014ED 7505                    	jnz	short lff22m_8
  2722 000014EF E9F3F5FFFF              	jmp	lff22_eof
  2723                                  
  2724                                  lff22m_8:
  2725 000014F4 89C1                    	mov	ecx, eax	; byte count
  2726                                  lff22m_9:
  2727 000014F6 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2728 000014FB C605[96210000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2729                                  lff22m_1:
  2730                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2731 00001502 AC                      	lodsb
  2732                                  	; 02/02/2025
  2733 00001503 8A16                    	mov	dl, [esi]
  2734 00001505 49                      	dec	ecx
  2735 00001506 7502                    	jnz	short lff22m_2_1
  2736 00001508 B280                    	mov	dl, 80h
  2737                                  lff22m_2_1:
  2738                                  	; al = [previous_val]
  2739                                  	; dl = [next_val]
  2740 0000150A E835070000              	call	interpolating_3_8bit_mono ; 1 of 17
  2741 0000150F E32D                    	jecxz	lff22m_3
  2742                                  lff22m_2_2:
  2743 00001511 AC                      	lodsb
  2744                                  	; 02/02/2025
  2745 00001512 8A16                    	mov	dl, [esi]
  2746 00001514 49                      	dec	ecx
  2747 00001515 7502                    	jnz	short lff22m_2_3
  2748 00001517 B280                    	mov	dl, 80h
  2749                                  lff22m_2_3:
  2750 00001519 E8B0070000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2751 0000151E E31E                    	jecxz	lff22m_3
  2752 00001520 4D                      	dec	ebp
  2753 00001521 75EE                    	jnz	short lff22m_2_2
  2754                                  
  2755 00001523 A0[96210000]            	mov	al, [faz]
  2756 00001528 FEC8                    	dec	al
  2757 0000152A 74CA                    	jz	short lff22m_9
  2758 0000152C FE0D[96210000]          	dec	byte [faz]
  2759 00001532 BD04000000              	mov	ebp, 4
  2760 00001537 FEC8                    	dec	al
  2761 00001539 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2762 0000153B 45                      	inc	ebp ; 5
  2763 0000153C EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2764                                  
  2765                                  lff22m_3:
  2766                                  lff22s_3:
  2767 0000153E E98CF5FFFF              	jmp	lff22_3	; padfill
  2768                                  		; (put zeros in the remain words of the buffer)
  2769                                  lff22m_7:
  2770                                  lff22s_7:
  2771 00001543 E9A8F5FFFF              	jmp	lff22_5  ; error
  2772                                  
  2773                                  load_22khz_stereo_8_bit:
  2774                                  	; 02/02/2025
  2775                                  	; 16/11/2023
  2776 00001548 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2777                                  					; last of the file?
  2778 0000154F 7402                    	jz	short lff22s_0		; no
  2779 00001551 F9                      	stc
  2780 00001552 C3                      	retn
  2781                                  
  2782                                  lff22s_0:
  2783 00001553 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2784                                          ;mov	edx, [loadsize]
  2785                                  
  2786                                  	; esi = buffer address
  2787                                  	;; edx = buffer size
  2788                                  
  2789                                  	; load file into memory
  2790                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001558 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000155E 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001560 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001566 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000156B CD40                <1>  int 40h
  2791 0000156D 72D4                    	jc	short lff22s_7 ; error !
  2792                                  
  2793 0000156F BF[00300000]            	mov	edi, audio_buffer
  2794                                  
  2795 00001574 D1E8                    	shr	eax, 1
  2796 00001576 7505                    	jnz	short lff22s_8
  2797 00001578 E96AF5FFFF              	jmp	lff22_eof
  2798                                  
  2799                                  lff22s_8:
  2800 0000157D 89C1                    	mov	ecx, eax	; word count
  2801                                  lff22s_9:
  2802 0000157F BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2803 00001584 C605[96210000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2804                                  lff22s_1:
  2805                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2806 0000158B 66AD                    	lodsw
  2807                                  	; 02/02/2025
  2808 0000158D 668B16                  	mov	dx, [esi]
  2809 00001590 49                      	dec	ecx
  2810 00001591 7504                    	jnz	short lff22s_2_1
  2811 00001593 66BA8080                	mov	dx, 8080h
  2812                                  lff22s_2_1:
  2813                                  	; al = [previous_val_l]
  2814                                  	; ah = [previous_val_r]
  2815                                  	; dl = [next_val_l]
  2816                                  	; dh = [next_val_r]
  2817 00001597 E8DB060000              	call	interpolating_3_8bit_stereo ; 1 of 17
  2818 0000159C E3A0                    	jecxz	lff22s_3
  2819                                  lff22s_2_2:
  2820 0000159E 66AD                    	lodsw
  2821                                  	; 02/02/2025
  2822 000015A0 668B16                  	mov	dx, [esi]
  2823 000015A3 49                      	dec	ecx
  2824 000015A4 7504                    	jnz	short lff22s_2_3
  2825 000015A6 66BA8080                	mov	dx, 8080h
  2826                                  lff22s_2_3:
  2827 000015AA E83C070000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2828 000015AF E38D                    	jecxz	lff22s_3
  2829 000015B1 4D                      	dec	ebp
  2830 000015B2 75EA                    	jnz	short lff22s_2_2
  2831                                  
  2832 000015B4 A0[96210000]            	mov	al, [faz]
  2833 000015B9 FEC8                    	dec	al
  2834 000015BB 74C2                    	jz	short lff22s_9
  2835 000015BD FE0D[96210000]          	dec	byte [faz]
  2836 000015C3 BD04000000              	mov	ebp, 4
  2837 000015C8 FEC8                    	dec	al
  2838 000015CA 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2839 000015CC 45                      	inc	ebp ; 5
  2840 000015CD EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2841                                  
  2842                                  load_22khz_mono_16_bit:
  2843                                  	; 02/02/2025
  2844                                  	; 16/11/2023
  2845 000015CF F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2846                                  					; last of the file?
  2847 000015D6 7402                    	jz	short lff22m2_0		; no
  2848 000015D8 F9                      	stc
  2849 000015D9 C3                      	retn
  2850                                  
  2851                                  lff22m2_0:
  2852 000015DA BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2853                                          ;mov	edx, [loadsize]
  2854                                  
  2855                                  	; esi = buffer address
  2856                                  	;; edx = buffer size
  2857                                  
  2858                                  	; load file into memory
  2859                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 000015DF 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 000015E5 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000015E7 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000015ED B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000015F2 CD40                <1>  int 40h
  2860 000015F4 7261                    	jc	short lff22m2_7 ; error !
  2861                                  
  2862 000015F6 BF[00300000]            	mov	edi, audio_buffer
  2863                                  	
  2864 000015FB D1E8                    	shr	eax, 1
  2865 000015FD 7505                    	jnz	short lff22m2_8
  2866 000015FF E9E3F4FFFF              	jmp	lff22_eof
  2867                                  
  2868                                  lff22m2_8:
  2869 00001604 89C1                    	mov	ecx, eax	; word count
  2870                                  lff22m2_9:
  2871 00001606 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2872 0000160B C605[96210000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2873                                  lff22m2_1:
  2874                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2875 00001612 66AD                    	lodsw
  2876                                  	; 02/02/2025
  2877 00001614 668B16                  	mov	dx, [esi]
  2878 00001617 49                      	dec	ecx
  2879 00001618 7502                    	jnz	short lff22m2_2_1
  2880 0000161A 31D2                    	xor	edx, edx
  2881                                  lff22m2_2_1:	
  2882                                  	; ax = [previous_val]
  2883                                  	; dx = [next_val]
  2884 0000161C E8FB060000              	call	interpolating_3_16bit_mono ; 1 of 17
  2885 00001621 E32F                    	jecxz	lff22m2_3
  2886                                  lff22m2_2_2:
  2887 00001623 66AD                    	lodsw
  2888                                  	; 02/02/2025
  2889 00001625 668B16                  	mov	dx, [esi]
  2890 00001628 49                      	dec	ecx
  2891 00001629 7502                    	jnz	short lff22m2_2_3
  2892 0000162B 31D2                    	xor	edx, edx
  2893                                  lff22m2_2_3:
  2894 0000162D E87D070000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2895 00001632 E31E                    	jecxz	lff22m2_3
  2896 00001634 4D                      	dec	ebp
  2897 00001635 75EC                    	jnz	short lff22m2_2_2
  2898                                  
  2899 00001637 A0[96210000]            	mov	al, [faz]
  2900 0000163C FEC8                    	dec	al
  2901 0000163E 74C6                    	jz	short lff22m2_9
  2902 00001640 FE0D[96210000]          	dec	byte [faz]
  2903 00001646 BD04000000              	mov	ebp, 4
  2904 0000164B FEC8                    	dec	al
  2905 0000164D 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2906 0000164F 45                      	inc	ebp ; 5
  2907 00001650 EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2908                                  
  2909                                  lff22m2_3:
  2910                                  lff22s2_3:
  2911 00001652 E978F4FFFF              	jmp	lff22_3	; padfill
  2912                                  		; (put zeros in the remain words of the buffer)
  2913                                  lff22m2_7:
  2914                                  lff22s2_7:
  2915 00001657 E994F4FFFF              	jmp	lff22_5  ; error
  2916                                  
  2917                                  load_22khz_stereo_16_bit:
  2918                                  	; 16/11/2023
  2919 0000165C F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2920                                  					; last of the file?
  2921 00001663 7402                    	jz	short lff22s2_0		; no
  2922 00001665 F9                      	stc
  2923 00001666 C3                      	retn
  2924                                  
  2925                                  lff22s2_0:
  2926 00001667 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2927                                          ;mov	edx, [loadsize]
  2928                                  
  2929                                  	; esi = buffer address
  2930                                  	;; edx = buffer size
  2931                                  
  2932                                  	; load file into memory
  2933                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000166C 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001672 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001674 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000167A B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000167F CD40                <1>  int 40h
  2934 00001681 72D4                    	jc	short lff22s2_7 ; error !
  2935                                  
  2936 00001683 BF[00300000]            	mov	edi, audio_buffer
  2937                                  	
  2938 00001688 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  2939 0000168B 7505                    	jnz	short lff22s2_8
  2940 0000168D E955F4FFFF              	jmp	lff22_eof
  2941                                  
  2942                                  lff22s2_8:
  2943 00001692 89C1                    	mov	ecx, eax	; dword count
  2944                                  lff22s2_9:
  2945 00001694 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2946 00001699 C605[96210000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2947                                  lff22s2_1:
  2948                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2949 000016A0 66AD                    	lodsw
  2950 000016A2 89C3                    	mov	ebx, eax
  2951 000016A4 66AD                    	lodsw
  2952 000016A6 8B16                    	mov	edx, [esi]
  2953 000016A8 668915[92210000]        	mov	[next_val_l], dx
  2954                                  	; 26/11/2023
  2955 000016AF C1EA10                  	shr	edx, 16
  2956 000016B2 49                      	dec	ecx
  2957 000016B3 7509                    	jnz	short lff22s2_2_1
  2958 000016B5 31D2                    	xor	edx, edx ; 0
  2959 000016B7 668915[92210000]        	mov	[next_val_l], dx
  2960                                  lff22s2_2_1:
  2961                                  	; bx = [previous_val_l]
  2962                                  	; ax = [previous_val_r]
  2963                                  	; [next_val_l]
  2964                                  	; dx = [next_val_r]
  2965 000016BE E889060000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  2966 000016C3 E38D                    	jecxz	lff22s2_3
  2967                                  lff22s2_2_2:
  2968 000016C5 66AD                    	lodsw
  2969 000016C7 89C3                    	mov	ebx, eax
  2970 000016C9 66AD                    	lodsw
  2971 000016CB 8B16                    	mov	edx, [esi]
  2972 000016CD 668915[92210000]        	mov	[next_val_l], dx
  2973                                  	; 26/11/2023
  2974 000016D4 C1EA10                  	shr	edx, 16
  2975 000016D7 49                      	dec	ecx
  2976 000016D8 7509                    	jnz	short lff22s2_2_3
  2977 000016DA 31D2                    	xor	edx, edx ; 0
  2978 000016DC 668915[92210000]        	mov	[next_val_l], dx
  2979                                  lff22s2_2_3:
  2980 000016E3 E8DF060000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  2981 000016E8 E31E                    	jecxz	lff22s2_2_4
  2982                                  
  2983 000016EA 4D                      	dec	ebp
  2984 000016EB 75D8                    	jnz	short lff22s2_2_2
  2985                                  
  2986 000016ED A0[96210000]            	mov	al, [faz]
  2987 000016F2 FEC8                    	dec	al
  2988 000016F4 749E                    	jz	short lff22s2_9
  2989 000016F6 FE0D[96210000]          	dec	byte [faz]
  2990 000016FC BD04000000              	mov	ebp, 4
  2991 00001701 FEC8                    	dec	al
  2992 00001703 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2993 00001705 45                      	inc	ebp ; 5
  2994 00001706 EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2995                                  
  2996                                  lff22s2_2_4:
  2997                                  	; 26/11/2023
  2998 00001708 E9C2F3FFFF              	jmp	lff22_3	; padfill
  2999                                  
  3000                                  ; .....................
  3001                                  
  3002                                  load_11khz_mono_8_bit:
  3003                                  	; 02/02/2025
  3004                                  	; 18/11/2023
  3005 0000170D F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3006                                  					; last of the file?
  3007 00001714 7402                    	jz	short lff11m_0		; no
  3008 00001716 F9                      	stc
  3009 00001717 C3                      	retn
  3010                                  
  3011                                  lff11m_0:
  3012 00001718 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3013                                          ;mov	edx, [loadsize]
  3014                                  
  3015                                  	; esi = buffer address
  3016                                  	;; edx = buffer size
  3017                                  
  3018                                  	; load file into memory
  3019                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000171D 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001723 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001725 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000172B B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001730 CD40                <1>  int 40h
  3020 00001732 7247                    	jc	short lff11m_7 ; error !
  3021                                  
  3022 00001734 BF[00300000]            	mov	edi, audio_buffer
  3023                                  	
  3024 00001739 21C0                    	and	eax, eax
  3025 0000173B 7505                    	jnz	short lff11m_8
  3026 0000173D E9A5F3FFFF              	jmp	lff11_eof
  3027                                  
  3028                                  lff11m_8:
  3029 00001742 89C1                    	mov	ecx, eax	; byte count
  3030                                  lff11m_9:
  3031 00001744 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3032                                  lff11m_1:
  3033                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3034 00001749 AC                      	lodsb
  3035                                  	; 02/02/2025
  3036 0000174A 8A16                    	mov	dl, [esi]
  3037 0000174C 49                      	dec	ecx
  3038 0000174D 7502                    	jnz	short lff11m_2_1
  3039 0000174F B280                    	mov	dl, 80h
  3040                                  lff11m_2_1:	
  3041                                  	; al = [previous_val]
  3042                                  	; dl = [next_val]
  3043 00001751 E8A0060000              	call	interpolating_5_8bit_mono
  3044 00001756 E328                    	jecxz	lff11m_3
  3045                                  lff11m_2_2:
  3046 00001758 AC                      	lodsb
  3047                                  	; 02/02/2025
  3048 00001759 8A16                    	mov	dl, [esi]
  3049 0000175B 49                      	dec	ecx
  3050 0000175C 7502                    	jnz	short lff11m_2_3
  3051 0000175E B280                    	mov	dl, 80h
  3052                                  lff11m_2_3:
  3053 00001760 E89D070000               	call	interpolating_4_8bit_mono
  3054 00001765 E319                    	jecxz	lff11m_3
  3055                                  
  3056 00001767 4D                      	dec	ebp
  3057 00001768 74DA                    	jz	short lff11m_9
  3058                                  
  3059 0000176A AC                      	lodsb
  3060                                  	; 02/02/2025
  3061 0000176B 8A16                    	mov	dl, [esi]
  3062 0000176D 49                      	dec	ecx
  3063 0000176E 7502                    	jnz	short lff11m_2_4
  3064 00001770 B280                    	mov	dl, 80h
  3065                                  lff11m_2_4:
  3066 00001772 E88B070000              	call	interpolating_4_8bit_mono
  3067 00001777 E307                    	jecxz	lff11m_3
  3068 00001779 EBCE                    	jmp	short lff11m_1
  3069                                  
  3070                                  lff11m_7:
  3071                                  lff11s_7:
  3072 0000177B E970F3FFFF              	jmp	lff11_5  ; error
  3073                                  
  3074                                  lff11m_3:
  3075                                  lff11s_3:
  3076 00001780 E94AF3FFFF              	jmp	lff11_3	; padfill
  3077                                  		; (put zeros in the remain words of the buffer)
  3078                                  
  3079                                  load_11khz_stereo_8_bit:
  3080                                  	; 02/02/2025
  3081                                  	; 18/11/2023
  3082 00001785 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3083                                  					; last of the file?
  3084 0000178C 7402                    	jz	short lff11s_0		; no
  3085 0000178E F9                      	stc
  3086 0000178F C3                      	retn
  3087                                  
  3088                                  lff11s_0:
  3089 00001790 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3090                                          ;mov	edx, [loadsize]
  3091                                  
  3092                                  	; esi = buffer address
  3093                                  	;; edx = buffer size
  3094                                  
  3095                                  	; load file into memory
  3096                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001795 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000179B 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 0000179D 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000017A3 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000017A8 CD40                <1>  int 40h
  3097 000017AA 72CF                    	jc	short lff11s_7 ; error !
  3098                                  
  3099 000017AC BF[00300000]            	mov	edi, audio_buffer
  3100                                  
  3101 000017B1 D1E8                    	shr	eax, 1
  3102 000017B3 7505                    	jnz	short lff11s_8
  3103 000017B5 E92DF3FFFF              	jmp	lff11_eof
  3104                                  
  3105                                  lff11s_8:
  3106 000017BA 89C1                    	mov	ecx, eax	; word count
  3107                                  lff11s_9:
  3108 000017BC BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3109                                  lff11s_1:
  3110                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3111 000017C1 66AD                    	lodsw
  3112                                  	; 02/02/2025
  3113 000017C3 668B16                  	mov	dx, [esi]
  3114 000017C6 49                      	dec	ecx
  3115 000017C7 7504                    	jnz	short lff11s_2_1
  3116 000017C9 66BA8080                	mov	dx, 8080h
  3117                                  lff11s_2_1:
  3118                                  	; al = [previous_val_l]
  3119                                  	; ah = [previous_val_r]
  3120                                  	; dl = [next_val_l]
  3121                                  	; dh = [next_val_r]
  3122 000017CD E883060000              	call	interpolating_5_8bit_stereo
  3123 000017D2 E3AC                    	jecxz	lff11s_3
  3124                                  lff11s_2_2:
  3125 000017D4 66AD                    	lodsw
  3126                                  	; 02/02/2025
  3127 000017D6 668B16                  	mov	dx, [esi]
  3128 000017D9 49                      	dec	ecx
  3129 000017DA 7504                    	jnz	short lff11s_2_3
  3130 000017DC 66BA8080                	mov	dx, 8080h
  3131                                  lff11s_2_3:
  3132 000017E0 E85C070000               	call	interpolating_4_8bit_stereo
  3133 000017E5 E399                    	jecxz	lff11s_3
  3134                                  	
  3135 000017E7 4D                      	dec	ebp
  3136 000017E8 74D2                    	jz	short lff11s_9
  3137                                  
  3138 000017EA 66AD                    	lodsw
  3139                                  	; 02/02/2025
  3140 000017EC 668B16                  	mov	dx, [esi]
  3141 000017EF 49                      	dec	ecx
  3142 000017F0 7504                    	jnz	short lff11s_2_4
  3143 000017F2 66BA8080                	mov	dx, 8080h
  3144                                  lff11s_2_4:
  3145 000017F6 E846070000              	call	interpolating_4_8bit_stereo
  3146 000017FB E383                    	jecxz	lff11s_3
  3147 000017FD EBC2                    	jmp	short lff11s_1
  3148                                  
  3149                                  load_11khz_mono_16_bit:
  3150                                  	; 02/02/2025
  3151                                  	; 18/11/2023
  3152 000017FF F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3153                                  					; last of the file?
  3154 00001806 7402                    	jz	short lff11m2_0		; no
  3155 00001808 F9                      	stc
  3156 00001809 C3                      	retn
  3157                                  
  3158                                  lff11m2_0:
  3159 0000180A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3160                                          ;mov	edx, [loadsize]
  3161                                  
  3162                                  	; esi = buffer address
  3163                                  	;; edx = buffer size
  3164                                  
  3165                                  	; load file into memory
  3166                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000180F 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001815 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001817 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000181D B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001822 CD40                <1>  int 40h
  3167 00001824 724D                    	jc	short lff11m2_7 ; error !
  3168                                  
  3169 00001826 BF[00300000]            	mov	edi, audio_buffer
  3170                                  	
  3171 0000182B D1E8                    	shr	eax, 1
  3172 0000182D 7505                    	jnz	short lff11m2_8
  3173 0000182F E9B3F2FFFF              	jmp	lff11_eof
  3174                                  
  3175                                  lff11m2_8:
  3176 00001834 89C1                    	mov	ecx, eax	; word count
  3177                                  lff11m2_9:
  3178 00001836 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3179                                  lff11m2_1:
  3180                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3181 0000183B 66AD                    	lodsw
  3182                                  	; 02/02/2025
  3183 0000183D 668B16                  	mov	dx, [esi]
  3184 00001840 49                      	dec	ecx
  3185 00001841 7502                    	jnz	short lff11m2_2_1
  3186 00001843 31D2                    	xor	edx, edx
  3187                                  lff11m2_2_1:	
  3188                                  	; ax = [previous_val]
  3189                                  	; dx = [next_val]
  3190 00001845 E864070000              	call	interpolating_5_16bit_mono
  3191 0000184A E362                    	jecxz	lff11m2_3
  3192                                  lff11m2_2_2:
  3193 0000184C 66AD                    	lodsw
  3194                                  	; 02/02/2025
  3195 0000184E 668B16                  	mov	dx, [esi]
  3196 00001851 49                      	dec	ecx
  3197 00001852 7502                    	jnz	short lff11m2_2_3
  3198 00001854 31D2                    	xor	edx, edx
  3199                                  lff11m2_2_3:
  3200 00001856 E87D080000               	call	interpolating_4_16bit_mono
  3201 0000185B E351                    	jecxz	lff11m2_3
  3202                                  
  3203 0000185D 4D                      	dec	ebp
  3204 0000185E 74D6                    	jz	short lff11m2_9
  3205                                  
  3206 00001860 66AD                    	lodsw
  3207                                  	; 02/02/2025
  3208 00001862 668B16                  	mov	dx, [esi]
  3209 00001865 49                      	dec	ecx
  3210 00001866 7502                    	jnz	short lff11m2_2_4
  3211 00001868 31D2                    	xor	edx, edx
  3212                                  lff11m2_2_4:
  3213 0000186A E869080000               	call	interpolating_4_16bit_mono
  3214 0000186F E33D                    	jecxz	lff11m2_3
  3215 00001871 EBC8                    	jmp	short lff11m2_1
  3216                                  
  3217                                  lff11m2_7:
  3218                                  lff11s2_7:
  3219 00001873 E978F2FFFF              	jmp	lff11_5  ; error
  3220                                  
  3221                                  load_11khz_stereo_16_bit:
  3222                                  	; 17/01/2025
  3223                                  	; 18/11/2023
  3224 00001878 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3225                                  					; last of the file?
  3226 0000187F 7402                    	jz	short lff11s2_0		; no
  3227 00001881 F9                      	stc
  3228 00001882 C3                      	retn
  3229                                  
  3230                                  lff11s2_0:
  3231 00001883 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3232                                          ;mov	edx, [loadsize]
  3233                                  
  3234                                  	; esi = buffer address
  3235                                  	;; edx = buffer size
  3236                                  
  3237                                  	; load file into memory
  3238                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001888 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000188E 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001890 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001896 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 0000189B CD40                <1>  int 40h
  3239 0000189D 72D4                    	jc	short lff11s2_7 ; error !
  3240                                  
  3241 0000189F BF[00300000]            	mov	edi, audio_buffer
  3242                                  	
  3243 000018A4 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3244 000018A7 750A                    	jnz	short lff11s2_8
  3245 000018A9 E939F2FFFF              	jmp	lff11_eof
  3246                                  
  3247                                  lff11m2_3:
  3248                                  lff11s2_3:
  3249 000018AE E91CF2FFFF              	jmp	lff11_3	; padfill
  3250                                  		; (put zeros in the remain words of the buffer)
  3251                                  
  3252                                  lff11s2_8:
  3253 000018B3 89C1                    	mov	ecx, eax	; dword count
  3254                                  lff11s2_9:
  3255 000018B5 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3256                                  lff11s2_1:
  3257                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3258 000018BA 66AD                    	lodsw
  3259 000018BC 89C3                    	mov	ebx, eax
  3260 000018BE 66AD                    	lodsw
  3261 000018C0 8B16                    	mov	edx, [esi]
  3262                                  	; 17/01/2025
  3263                                  	;mov	[next_val_l], edx
  3264                                  	; 26/11/2023
  3265                                  	;shr	edx, 16
  3266                                  	;mov	[next_val_r], dx
  3267 000018C2 49                      	dec	ecx
  3268 000018C3 7502                    	jnz	short lff11s2_2_1
  3269 000018C5 31D2                    	xor	edx, edx ; 0
  3270                                  	;mov	[next_val_l], dx
  3271                                  	;mov	[next_val_r], dx
  3272                                  lff11s2_2_1:
  3273                                  	; bx = [previous_val_l]
  3274                                  	; ax = [previous_val_r]
  3275                                  	; [next_val_l]
  3276                                  	; dx = [next_val_r]
  3277                                  	;;;
  3278                                  	; 17/01/2025 (BugFix)
  3279 000018C7 8915[92210000]          	mov	[next_val_l], edx
  3280                                  	;;;
  3281 000018CD E837070000              	call	interpolating_5_16bit_stereo
  3282 000018D2 E3DA                    	jecxz	lff11s2_3
  3283                                  lff11s2_2_2:
  3284 000018D4 66AD                    	lodsw
  3285 000018D6 89C3                    	mov	ebx, eax
  3286 000018D8 66AD                    	lodsw
  3287 000018DA 8B16                    	mov	edx, [esi]
  3288                                  	; 17/01/2025
  3289                                  	;mov	[next_val_l], dx
  3290                                  	; 26/11/2023
  3291                                  	;shr	edx, 16
  3292                                  	;mov	[next_val_r], dx
  3293 000018DC 49                      	dec	ecx
  3294 000018DD 7502                    	jnz	short lff11s2_2_3
  3295 000018DF 31D2                    	xor	edx, edx ; 0
  3296                                  	;mov	[next_val_l], dx
  3297                                  	;mov	[next_val_r], dx
  3298                                  lff11s2_2_3:
  3299                                  	;;;
  3300                                  	; 17/01/2025 (BugFix)
  3301 000018E1 8915[92210000]          	mov	[next_val_l], edx
  3302                                  	;;;
  3303 000018E7 E825080000              	call	interpolating_4_16bit_stereo
  3304 000018EC E3C0                    	jecxz	lff11s2_3
  3305                                  	
  3306 000018EE 4D                      	dec	ebp
  3307 000018EF 74C4                    	jz	short lff11s2_9
  3308                                  
  3309 000018F1 66AD                    	lodsw
  3310 000018F3 89C3                    	mov	ebx, eax
  3311 000018F5 66AD                    	lodsw
  3312 000018F7 8B16                    	mov	edx, [esi]
  3313                                  	; 17/01/2025
  3314                                  	;mov	[next_val_l], dx
  3315                                  	; 26/11/2023
  3316                                  	;shr	edx, 16
  3317                                  	;mov	[next_val_r], dx
  3318 000018F9 49                      	dec	ecx
  3319 000018FA 7502                    	jnz	short lff11s2_2_4
  3320 000018FC 31D2                    	xor	edx, edx ; 0
  3321                                  	;mov	[next_val_l], dx
  3322                                  	;mov	[next_val_r], dx
  3323                                  lff11s2_2_4:
  3324                                  	;;;
  3325                                  	; 17/01/2025 (BugFix)
  3326 000018FE 8915[92210000]          	mov	[next_val_l], edx
  3327                                  	;;;
  3328 00001904 E808080000               	call	interpolating_4_16bit_stereo
  3329 00001909 E3A3                    	jecxz	lff11s2_3
  3330 0000190B EBAD                    	jmp	short lff11s2_1
  3331                                  
  3332                                  ; .....................
  3333                                  
  3334                                  load_44khz_mono_8_bit:
  3335                                  	; 02/02/2025
  3336                                  	; 18/11/2023
  3337 0000190D F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3338                                  					; last of the file?
  3339 00001914 7402                    	jz	short lff44m_0		; no
  3340 00001916 F9                      	stc
  3341 00001917 C3                      	retn
  3342                                  
  3343                                  lff44m_0:
  3344 00001918 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3345                                          ;mov	edx, [loadsize]
  3346                                  
  3347                                  	; esi = buffer address
  3348                                  	;; edx = buffer size
  3349                                  
  3350                                  	; load file into memory
  3351                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 0000191D 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001923 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001925 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 0000192B B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001930 CD40                <1>  int 40h
  3352 00001932 7250                    	jc	short lff44m_7 ; error !
  3353                                  
  3354 00001934 BF[00300000]            	mov	edi, audio_buffer
  3355                                  
  3356 00001939 21C0                    	and	eax, eax
  3357 0000193B 7505                    	jnz	short lff44m_8
  3358 0000193D E9A5F1FFFF              	jmp	lff44_eof
  3359                                  
  3360                                  lff44m_8:
  3361 00001942 89C1                    	mov	ecx, eax	; byte count
  3362                                  lff44m_9:
  3363 00001944 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3364 00001949 C605[96210000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3365                                  lff44m_1:
  3366                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3367                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3368 00001950 AC                      	lodsb
  3369                                  	; 02/02/2025
  3370 00001951 8A16                    	mov	dl, [esi]
  3371 00001953 49                      	dec	ecx
  3372 00001954 7502                    	jnz	short lff44m_2_1
  3373 00001956 B280                    	mov	dl, 80h
  3374                                  lff44m_2_1:
  3375                                  	; al = [previous_val]
  3376                                  	; dl = [next_val]
  3377 00001958 E871030000              	call	interpolating_2_8bit_mono
  3378 0000195D E320                    	jecxz	lff44m_3
  3379                                  lff44m_2_2:
  3380 0000195F AC                      	lodsb
  3381 00001960 2C80                    	sub	al, 80h
  3382 00001962 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3383 00001966 66AB                    	stosw		; (L)
  3384 00001968 66AB                    	stosw		; (R)
  3385                                  
  3386 0000196A 49                      	dec	ecx
  3387 0000196B 7412                    	jz	short lff44m_3
  3388 0000196D 4D                      	dec	ebp
  3389 0000196E 75EF                    	jnz	short lff44m_2_2
  3390                                  	
  3391 00001970 FE0D[96210000]          	dec	byte [faz]
  3392 00001976 74CC                    	jz	short lff44m_9
  3393 00001978 BD0B000000              	mov	ebp, 11
  3394 0000197D EBD1                    	jmp	short lff44m_1
  3395                                  
  3396                                  lff44m_3:
  3397                                  lff44s_3:
  3398 0000197F E94BF1FFFF              	jmp	lff44_3	; padfill
  3399                                  		; (put zeros in the remain words of the buffer)
  3400                                  lff44m_7:
  3401                                  lff44s_7:
  3402 00001984 E967F1FFFF              	jmp	lff44_5  ; error
  3403                                  
  3404                                  load_44khz_stereo_8_bit:
  3405                                  	; 02/02/2025
  3406                                  	; 16/11/2023
  3407 00001989 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3408                                  					; last of the file?
  3409 00001990 7402                    	jz	short lff44s_0		; no
  3410 00001992 F9                      	stc
  3411 00001993 C3                      	retn
  3412                                  
  3413                                  lff44s_0:
  3414 00001994 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3415                                          ;mov	edx, [loadsize]
  3416                                  
  3417                                  	; esi = buffer address
  3418                                  	;; edx = buffer size
  3419                                  
  3420                                  	; load file into memory
  3421                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001999 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 0000199F 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 000019A1 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 000019A7 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 000019AC CD40                <1>  int 40h
  3422 000019AE 72D4                    	jc	short lff44s_7 ; error !
  3423                                  
  3424 000019B0 BF[00300000]            	mov	edi, audio_buffer
  3425                                  
  3426 000019B5 D1E8                    	shr	eax, 1
  3427 000019B7 7505                    	jnz	short lff44s_8
  3428 000019B9 E929F1FFFF              	jmp	lff44_eof
  3429                                  
  3430                                  lff44s_8:
  3431 000019BE 89C1                    	mov	ecx, eax	; word count
  3432                                  lff44s_9:
  3433 000019C0 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3434 000019C5 C605[96210000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3435                                  lff44s_1:
  3436                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3437                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3438 000019CC 66AD                    	lodsw
  3439                                  	; 02/02/2025
  3440 000019CE 668B16                  	mov	dx, [esi]
  3441 000019D1 49                      	dec	ecx
  3442 000019D2 7504                    	jnz	short lff44s_2_1
  3443 000019D4 66BA8080                	mov	dx, 8080h
  3444                                  lff44s_2_1:	
  3445                                  	; al = [previous_val_l]
  3446                                  	; ah = [previous_val_r]
  3447                                  	; dl = [next_val_l]
  3448                                  	; dh = [next_val_r]
  3449 000019D8 E80E030000              	call	interpolating_2_8bit_stereo
  3450 000019DD E3A0                    	jecxz	lff44s_3
  3451                                  lff44s_2_2:
  3452 000019DF AC                      	lodsb
  3453 000019E0 2C80                    	sub	al, 80h
  3454 000019E2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3455 000019E6 66AB                    	stosw		; (L)
  3456 000019E8 AC                      	lodsb
  3457 000019E9 2C80                    	sub	al, 80h
  3458 000019EB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3459 000019EF 66AB                    	stosw		; (R)
  3460                                  
  3461 000019F1 49                      	dec	ecx
  3462 000019F2 748B                    	jz	short lff44s_3
  3463 000019F4 4D                      	dec	ebp
  3464 000019F5 75E8                    	jnz	short lff44s_2_2
  3465                                  	
  3466 000019F7 FE0D[96210000]          	dec	byte [faz]
  3467 000019FD 74C1                    	jz	short lff44s_9
  3468 000019FF BD0B000000              	mov	ebp, 11
  3469 00001A04 EBC6                    	jmp	short lff44s_1
  3470                                  
  3471                                  load_44khz_mono_16_bit:
  3472                                  	; 02/02/2025
  3473                                  	; 18/11/2023
  3474 00001A06 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3475                                  					; last of the file?
  3476 00001A0D 7402                    	jz	short lff44m2_0		; no
  3477 00001A0F F9                      	stc
  3478 00001A10 C3                      	retn
  3479                                  
  3480                                  lff44m2_0:
  3481 00001A11 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3482                                          ;mov	edx, [loadsize]
  3483                                  
  3484                                  	; esi = buffer address
  3485                                  	;; edx = buffer size
  3486                                  
  3487                                  	; load file into memory
  3488                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001A16 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001A1C 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001A1E 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001A24 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001A29 CD40                <1>  int 40h
  3489 00001A2B 724D                    	jc	short lff44m2_7 ; error !
  3490                                  
  3491 00001A2D BF[00300000]            	mov	edi, audio_buffer
  3492                                  	
  3493 00001A32 D1E8                    	shr	eax, 1
  3494 00001A34 7505                    	jnz	short lff44m2_8
  3495 00001A36 E9ACF0FFFF              	jmp	lff44_eof
  3496                                  
  3497                                  lff44m2_8:
  3498 00001A3B 89C1                    	mov	ecx, eax	; word count
  3499                                  lff44m2_9:
  3500 00001A3D BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3501 00001A42 C605[96210000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3502                                  lff44m2_1:
  3503                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3504                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3505 00001A49 66AD                    	lodsw
  3506                                  	; 02/02/2025
  3507 00001A4B 668B16                  	mov	dx, [esi]
  3508 00001A4E 49                      	dec	ecx
  3509 00001A4F 7502                    	jnz	short lff44m2_2_1
  3510 00001A51 31D2                    	xor	edx, edx
  3511                                  lff44m2_2_1:	
  3512                                  	; ax = [previous_val]
  3513                                  	; dx = [next_val]
  3514 00001A53 E857030000              	call	interpolating_2_16bit_mono
  3515 00001A58 E31B                    	jecxz	lff44m2_3
  3516                                  lff44m2_2_2:
  3517 00001A5A 66AD                    	lodsw
  3518 00001A5C 66AB                    	stosw		; (L)eft Channel
  3519 00001A5E 66AB                    	stosw		; (R)ight Channel
  3520                                  
  3521 00001A60 49                      	dec	ecx
  3522 00001A61 7412                    	jz	short lff44m2_3	
  3523 00001A63 4D                      	dec	ebp
  3524 00001A64 75F4                    	jnz	short lff44m2_2_2
  3525                                  
  3526 00001A66 FE0D[96210000]          	dec	byte [faz]
  3527 00001A6C 74CF                    	jz	short lff44m2_9 
  3528 00001A6E BD0B000000              	mov	ebp, 11
  3529 00001A73 EBD4                    	jmp	short lff44m2_1
  3530                                  
  3531                                  lff44m2_3:
  3532                                  lff44s2_3:
  3533 00001A75 E955F0FFFF              	jmp	lff44_3	; padfill
  3534                                  		; (put zeros in the remain words of the buffer)
  3535                                  lff44m2_7:
  3536                                  lff44s2_7:
  3537 00001A7A E971F0FFFF              	jmp	lff44_5  ; error
  3538                                  
  3539                                  load_44khz_stereo_16_bit:
  3540                                  	; 18/11/2023
  3541 00001A7F F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3542                                  					; last of the file?
  3543 00001A86 7402                    	jz	short lff44s2_0		; no
  3544 00001A88 F9                      	stc
  3545 00001A89 C3                      	retn
  3546                                  
  3547                                  lff44s2_0:
  3548 00001A8A BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3549                                          ;mov	edx, [loadsize]
  3550                                  
  3551                                  	; esi = buffer address
  3552                                  	;; edx = buffer size
  3553                                  
  3554                                  	; load file into memory
  3555                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001A8F 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001A95 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001A97 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001A9D B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001AA2 CD40                <1>  int 40h
  3556 00001AA4 72D4                    	jc	short lff44s2_7 ; error !
  3557                                  
  3558 00001AA6 BF[00300000]            	mov	edi, audio_buffer
  3559                                  
  3560 00001AAB C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3561 00001AAE 7505                    	jnz	short lff44s2_8
  3562 00001AB0 E932F0FFFF              	jmp	lff44_eof
  3563                                  
  3564                                  lff44s2_8:
  3565 00001AB5 89C1                    	mov	ecx, eax	; dword count
  3566                                  lff44s2_9:
  3567 00001AB7 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3568 00001ABC C605[96210000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3569                                  lff44s2_1:
  3570                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3571                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3572 00001AC3 66AD                    	lodsw
  3573 00001AC5 89C3                    	mov	ebx, eax
  3574 00001AC7 66AD                    	lodsw
  3575                                  	;mov	dx, [esi]
  3576                                  	;mov	[next_val_l], dx
  3577                                  	;mov	dx, [esi+2]
  3578                                  	; 26/11/2023
  3579 00001AC9 8B16                    	mov	edx, [esi]
  3580 00001ACB 668915[92210000]        	mov	[next_val_l], dx
  3581 00001AD2 C1EA10                  	shr	edx, 16
  3582 00001AD5 49                      	dec	ecx
  3583 00001AD6 7509                    	jnz	short lff44s2_2_1
  3584 00001AD8 31D2                    	xor	edx, edx ; 0
  3585 00001ADA 668915[92210000]        	mov	[next_val_l], dx
  3586                                  lff44s2_2_1:
  3587                                  	; bx = [previous_val_l]
  3588                                  	; ax = [previous_val_r]
  3589                                  	; [next_val_l]
  3590                                  	; dx = [next_val_r]
  3591 00001AE1 E8E1020000              	call	interpolating_2_16bit_stereo
  3592 00001AE6 E38D                    	jecxz	lff44s2_3
  3593                                  lff44s2_2_2:
  3594                                  	;movsw		; (L)eft Channel
  3595                                  	;movsw		; (R)ight Channel
  3596 00001AE8 A5                      	movsd
  3597                                  
  3598 00001AE9 49                      	dec	ecx
  3599 00001AEA 7489                    	jz	short lff44s2_3	
  3600 00001AEC 4D                      	dec	ebp
  3601 00001AED 75F9                    	jnz	short lff44s2_2_2
  3602                                  	
  3603 00001AEF FE0D[96210000]          	dec	byte [faz]
  3604 00001AF5 74C0                    	jz	short lff44s2_9 
  3605 00001AF7 BD0B000000              	mov	ebp, 11
  3606 00001AFC EBC5                    	jmp	short lff44s2_1
  3607                                  
  3608                                  ; .....................
  3609                                  
  3610                                  	; 02/02/2025
  3611                                  load_12khz_mono_8_bit:
  3612 00001AFE F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3613                                  					; last of the file?
  3614 00001B05 7402                    	jz	short lff12m_0		; no
  3615 00001B07 F9                      	stc
  3616 00001B08 C3                      	retn
  3617                                  
  3618                                  lff12m_0:
  3619 00001B09 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3620                                  
  3621                                  	; load file into memory
  3622                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001B0E 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001B14 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001B16 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001B1C B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001B21 CD40                <1>  int 40h
  3623 00001B23 7256                    	jc	short lff12m_7 ; error !
  3624                                  
  3625 00001B25 BF[00300000]            	mov	edi, audio_buffer
  3626                                  	
  3627 00001B2A 21C0                    	and	eax, eax
  3628 00001B2C 7505                    	jnz	short lff12m_8
  3629 00001B2E E9B4EFFFFF              	jmp	lff12_eof
  3630                                  
  3631                                  lff12m_8:
  3632 00001B33 89C1                    	mov	ecx, eax	; byte count
  3633                                  lff12m_1:
  3634                                  	; original-interpolated-interpolated-interpolated
  3635 00001B35 AC                      	lodsb
  3636                                  	; 02/02/2025
  3637 00001B36 8A16                    	mov	dl, [esi]
  3638 00001B38 49                      	dec	ecx
  3639 00001B39 7502                    	jnz	short lff12m_2
  3640 00001B3B B280                    	mov	dl, 80h
  3641                                  lff12m_2:	
  3642                                  	; al = [previous_val]
  3643                                  	; dl = [next_val]
  3644 00001B3D E8C0030000               	call	interpolating_4_8bit_mono
  3645 00001B42 E353                    	jecxz	lff12m_3
  3646 00001B44 EBEF                    	jmp	short lff12m_1
  3647                                  
  3648                                  	; 02/02/2025
  3649                                  load_12khz_stereo_8_bit:
  3650 00001B46 F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3651                                  					; last of the file?
  3652 00001B4D 7402                    	jz	short lff12s_0		; no
  3653 00001B4F F9                      	stc
  3654 00001B50 C3                      	retn
  3655                                  
  3656                                  lff12s_0:
  3657 00001B51 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3658                                  
  3659                                  	; load file into memory
  3660                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001B56 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001B5C 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001B5E 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001B64 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001B69 CD40                <1>  int 40h
  3661 00001B6B 720E                    	jc	short lff12s_7 ; error !
  3662                                  
  3663 00001B6D BF[00300000]            	mov	edi, audio_buffer
  3664                                  	
  3665 00001B72 D1E8                    	shr	eax, 1
  3666 00001B74 750A                    	jnz	short lff12s_8
  3667 00001B76 E96CEFFFFF              	jmp	lff12_eof
  3668                                  
  3669                                  lff12m_7:
  3670                                  lff12s_7:
  3671 00001B7B E970EFFFFF              	jmp	lff12_5  ; error
  3672                                  
  3673                                  lff12s_8:
  3674 00001B80 89C1                    	mov	ecx, eax	; word count
  3675                                  lff12s_1:
  3676                                  	; original-interpolated-interpolated-interpolated
  3677 00001B82 66AD                    	lodsw
  3678                                  	; 02/02/2025
  3679 00001B84 668B16                  	mov	dx, [esi]
  3680 00001B87 49                      	dec	ecx
  3681 00001B88 7504                    	jnz	short lff12s_2
  3682 00001B8A 66BA8080                	mov	dx, 8080h
  3683                                  lff12s_2:	
  3684                                  	; al = [previous_val_l]
  3685                                  	; ah = [previous_val_r]
  3686                                  	; dl = [next_val_l]
  3687                                  	; dh = [next_val_r]
  3688 00001B8E E8AE030000              	call	interpolating_4_8bit_stereo
  3689 00001B93 E302                    	jecxz	lff12s_3
  3690 00001B95 EBEB                    	jmp	short lff12s_1
  3691                                  
  3692                                  lff12m_3:
  3693                                  lff12s_3:
  3694 00001B97 E933EFFFFF              	jmp	lff12_3	; padfill
  3695                                  		; (put zeros in the remain words of the buffer)
  3696                                  
  3697                                  	; 02/02/2025
  3698                                  load_12khz_mono_16_bit:
  3699 00001B9C F605[98240000]01        	test    byte [flags], ENDOFFILE	; have we already read the
  3700                                  					; last of the file?
  3701 00001BA3 7402                    	jz	short lff12m2_0		; no
  3702 00001BA5 F9                      	stc
  3703 00001BA6 C3                      	retn
  3704                                  
  3705                                  lff12m2_0:
  3706 00001BA7 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3707                                  
  3708                                  	; load file into memory
  3709                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001BAC 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001BB2 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001BB4 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001BBA B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001BBF CD40                <1>  int 40h
  3710 00001BC1 7223                    	jc	short lff12m2_7 ; error !
  3711                                  
  3712 00001BC3 BF[00300000]            	mov	edi, audio_buffer
  3713                                  	
  3714 00001BC8 D1E8                    	shr	eax, 1
  3715 00001BCA 7505                    	jnz	short lff12m2_8
  3716 00001BCC E916EFFFFF              	jmp	lff12_eof
  3717                                  
  3718                                  lff12m2_8:
  3719 00001BD1 89C1                    	mov	ecx, eax	; word count
  3720                                  lff12m2_1:
  3721                                  	; original-interpolated-interpolated-interpolated
  3722 00001BD3 66AD                    	lodsw
  3723                                  	; 02/02/2025
  3724 00001BD5 668B16                  	mov	dx, [esi]
  3725 00001BD8 49                      	dec	ecx
  3726 00001BD9 7502                    	jnz	short lff12m2_2
  3727 00001BDB 31D2                    	xor	edx, edx
  3728                                  lff12m2_2:	
  3729                                  	; ax = [previous_val]
  3730                                  	; dx = [next_val]
  3731 00001BDD E8F6040000               	call	interpolating_4_16bit_mono
  3732 00001BE2 E3B3                    	jecxz	lff12m_3
  3733 00001BE4 EBED                    	jmp	short lff12m2_1
  3734                                  
  3735                                  lff12m2_7:
  3736                                  lff12s2_7:
  3737 00001BE6 E905EFFFFF              	jmp	lff12_5  ; error
  3738                                  
  3739                                  	; 02/02/2025
  3740                                  load_12khz_stereo_16_bit:
  3741 00001BEB F605[98240000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3742                                  					; last of the file?
  3743 00001BF2 7402                    	jz	short lff12s2_0		; no
  3744 00001BF4 F9                      	stc
  3745 00001BF5 C3                      	retn
  3746                                  
  3747                                  lff12s2_0:
  3748 00001BF6 BE[00300100]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3749                                  
  3750                                  	; load file into memory
  3751                                  	sys 	_read, [FileHandle], esi, [loadsize]
    77                              <1> 
    78                              <1> 
    79                              <1> 
    80                              <1> 
    81                              <1>  %if %0 >= 2
    82 00001BFB 8B1D[97210000]      <1>  mov ebx, %2
    83                              <1>  %if %0 >= 3
    84 00001C01 89F1                <1>  mov ecx, %3
    85                              <1>  %if %0 = 4
    86 00001C03 8B15[03040000]      <1>  mov edx, %4
    87                              <1>  %endif
    88                              <1>  %endif
    89                              <1>  %endif
    90 00001C09 B803000000          <1>  mov eax, %1
    91                              <1> 
    92 00001C0E CD40                <1>  int 40h
  3752 00001C10 72D4                    	jc	short lff12s2_7 ; error !
  3753                                  
  3754 00001C12 BF[00300000]            	mov	edi, audio_buffer
  3755                                  	
  3756 00001C17 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3757 00001C1A 750A                    	jnz	short lff12s2_8
  3758 00001C1C E9C6EEFFFF              	jmp	lff12_eof
  3759                                  
  3760                                  lff12m2_3:
  3761                                  lff12s2_3:
  3762 00001C21 E9A9EEFFFF              	jmp	lff12_3	; padfill
  3763                                  		; (put zeros in the remain words of the buffer)
  3764                                  
  3765                                  lff12s2_8:
  3766 00001C26 89C1                    	mov	ecx, eax	; dword count
  3767                                  lff12s2_1:
  3768                                  	; original-interpolated-interpolated-interpolated
  3769 00001C28 66AD                    	lodsw
  3770 00001C2A 89C3                    	mov	ebx, eax
  3771 00001C2C 66AD                    	lodsw
  3772 00001C2E 8B16                    	mov	edx, [esi]
  3773 00001C30 49                      	dec	ecx
  3774 00001C31 7502                    	jnz	short lff12s2_2
  3775 00001C33 31D2                    	xor	edx, edx ; 0
  3776                                  lff12s2_2:
  3777                                  	;mov	[next_val_l], dx
  3778                                  	;shr	edx, 16
  3779                                  	;mov	[next_val_r], dx
  3780                                  	; 02/02/2025
  3781 00001C35 8915[92210000]          	mov	[next_val_l], edx
  3782                                  
  3783                                  	; bx = [previous_val_l]
  3784                                  	; ax = [previous_val_r]
  3785                                  	; [next_val_l]
  3786                                  	; [next_val_r]
  3787 00001C3B E8D1040000              	call	interpolating_4_16bit_stereo
  3788 00001C40 E3DF                    	jecxz	lff12s2_3
  3789 00001C42 EBE4                    	jmp	short lff12s2_1
  3790                                  
  3791                                  ; .....................
  3792                                  
  3793                                  interpolating_3_8bit_mono:
  3794                                  	; 02/02/2025
  3795                                  	; 16/11/2023
  3796                                  	; al = [previous_val]
  3797                                  	; dl = [next_val]
  3798                                  	; original-interpolated-interpolated
  3799 00001C44 88C3                    	mov	bl, al
  3800 00001C46 2C80                    	sub	al, 80h
  3801 00001C48 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3802 00001C4C 66AB                    	stosw		; original sample (L)
  3803 00001C4E 66AB                    	stosw		; original sample (R)
  3804 00001C50 88D8                    	mov	al, bl
  3805 00001C52 00D0                    	add	al, dl
  3806 00001C54 D0D8                    	rcr	al, 1
  3807 00001C56 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3808 00001C58 00D8                    	add	al, bl
  3809 00001C5A D0D8                    	rcr	al, 1
  3810 00001C5C 2C80                    	sub	al, 80h
  3811 00001C5E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3812 00001C62 66AB                    	stosw		; interpolated sample 1 (L)
  3813 00001C64 66AB                    	stosw		; interpolated sample 1 (R)
  3814 00001C66 88F8                    	mov	al, bh
  3815 00001C68 00D0                    	add	al, dl	; [next_val]
  3816 00001C6A D0D8                    	rcr	al, 1
  3817                                  	; 02/02/2025
  3818 00001C6C 2C80                    	sub	al, 80h
  3819 00001C6E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3820 00001C72 66AB                    	stosw		; interpolated sample 2 (L)
  3821 00001C74 66AB                    	stosw		; interpolated sample 2 (R)
  3822 00001C76 C3                      	retn
  3823                                  
  3824                                  interpolating_3_8bit_stereo:
  3825                                  	; 02/02/2025
  3826                                  	; 16/11/2023
  3827                                  	; al = [previous_val_l]
  3828                                  	; ah = [previous_val_r]
  3829                                  	; dl = [next_val_l]
  3830                                  	; dh = [next_val_r]	
  3831                                  	; original-interpolated-interpolated
  3832 00001C77 89C3                    	mov	ebx, eax
  3833 00001C79 2C80                    	sub	al, 80h
  3834 00001C7B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3835 00001C7F 66AB                    	stosw		; original sample (L)
  3836 00001C81 88F8                    	mov	al, bh
  3837 00001C83 2C80                    	sub	al, 80h
  3838 00001C85 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3839 00001C89 66AB                    	stosw		; original sample (R)
  3840 00001C8B 88D8                    	mov	al, bl
  3841 00001C8D 00D0                    	add	al, dl	; [next_val_l]
  3842 00001C8F D0D8                    	rcr	al, 1
  3843 00001C91 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3844 00001C92 00D8                    	add	al, bl	; [previous_val_l]
  3845 00001C94 D0D8                    	rcr	al, 1
  3846 00001C96 2C80                    	sub	al, 80h
  3847 00001C98 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3848 00001C9C 66AB                    	stosw		; interpolated sample 1 (L)
  3849 00001C9E 88F8                    	mov	al, bh
  3850 00001CA0 00F0                    	add	al, dh	; [next_val_r]
  3851 00001CA2 D0D8                    	rcr	al, 1
  3852 00001CA4 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3853 00001CA5 00F8                    	add	al, bh	; [previous_val_r]
  3854 00001CA7 D0D8                    	rcr	al, 1
  3855 00001CA9 2C80                    	sub	al, 80h
  3856 00001CAB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3857 00001CAF 66AB                    	stosw		; interpolated sample 1 (R)
  3858 00001CB1 5B                      	pop	ebx ; **
  3859 00001CB2 58                      	pop	eax ; *
  3860 00001CB3 00D0                    	add	al, dl	; [next_val_l]
  3861 00001CB5 D0D8                    	rcr	al, 1
  3862                                  	; 02/02/2025
  3863 00001CB7 2C80                    	sub	al, 80h
  3864 00001CB9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3865 00001CBD 66AB                    	stosw		; interpolated sample 2 (L)
  3866 00001CBF 88D8                    	mov	al, bl
  3867 00001CC1 00F0                    	add	al, dh	; [next_val_r]
  3868 00001CC3 D0D8                    	rcr	al, 1
  3869                                  	; 02/02/2025
  3870 00001CC5 2C80                    	sub	al, 80h
  3871 00001CC7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3872 00001CCB 66AB                    	stosw		; interpolated sample 2 (R)
  3873 00001CCD C3                      	retn
  3874                                  
  3875                                  interpolating_2_8bit_mono:
  3876                                  	; 16/11/2023
  3877                                  	; al = [previous_val]
  3878                                  	; dl = [next_val]
  3879                                  	; original-interpolated
  3880 00001CCE 88C3                    	mov	bl, al
  3881 00001CD0 2C80                    	sub	al, 80h
  3882 00001CD2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3883 00001CD6 66AB                    	stosw		; original sample (L)
  3884 00001CD8 66AB                    	stosw		; original sample (R)
  3885 00001CDA 88D8                    	mov	al, bl
  3886 00001CDC 00D0                    	add	al, dl
  3887 00001CDE D0D8                    	rcr	al, 1
  3888 00001CE0 2C80                    	sub	al, 80h
  3889 00001CE2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3890 00001CE6 66AB                    	stosw		; interpolated sample (L)
  3891 00001CE8 66AB                    	stosw		; interpolated sample (R)
  3892 00001CEA C3                      	retn
  3893                                  
  3894                                  interpolating_2_8bit_stereo:
  3895                                  	; 16/11/2023
  3896                                  	; al = [previous_val_l]
  3897                                  	; ah = [previous_val_r]
  3898                                  	; dl = [next_val_l]
  3899                                  	; dh = [next_val_r]
  3900                                  	; original-interpolated
  3901 00001CEB 89C3                    	mov	ebx, eax
  3902 00001CED 2C80                    	sub	al, 80h
  3903 00001CEF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3904 00001CF3 66AB                    	stosw		; original sample (L)
  3905 00001CF5 88F8                    	mov	al, bh
  3906 00001CF7 2C80                    	sub	al, 80h
  3907 00001CF9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3908 00001CFD 66AB                    	stosw		; original sample (R)
  3909 00001CFF 88D8                    	mov	al, bl	; [previous_val_l]
  3910 00001D01 00D0                    	add	al, dl	; [next_val_l]
  3911 00001D03 D0D8                    	rcr	al, 1
  3912 00001D05 2C80                    	sub	al, 80h
  3913 00001D07 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3914 00001D0B 66AB                    	stosw		; interpolated sample (L)
  3915 00001D0D 88F8                    	mov	al, bh
  3916 00001D0F 00F0                    	add	al, dh	; [next_val_r]
  3917 00001D11 D0D8                    	rcr	al, 1
  3918 00001D13 2C80                    	sub	al, 80h
  3919 00001D15 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3920 00001D19 66AB                    	stosw		; interpolated sample (R)
  3921 00001D1B C3                      	retn
  3922                                  
  3923                                  interpolating_3_16bit_mono:
  3924                                  	; 16/11/2023
  3925                                  	; ax = [previous_val]
  3926                                  	; dx = [next_val]
  3927                                  	; original-interpolated-interpolated
  3928                                  
  3929 00001D1C 66AB                    	stosw		; original sample (L)
  3930 00001D1E 66AB                    	stosw		; original sample (R)
  3931 00001D20 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3932 00001D23 50                      	push	eax ; *	; [previous_val]
  3933 00001D24 80C680                  	add	dh, 80h
  3934 00001D27 6601D0                  	add	ax, dx
  3935 00001D2A 66D1D8                  	rcr	ax, 1
  3936 00001D2D 5B                      	pop	ebx ; *
  3937 00001D2E 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3938 00001D2F 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3939 00001D32 66D1D8                  	rcr	ax, 1
  3940 00001D35 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3941 00001D38 66AB                    	stosw 		; interpolated sample 1 (L)
  3942 00001D3A 66AB                    	stosw		; interpolated sample 1 (R)
  3943 00001D3C 89D8                    	mov	eax, ebx
  3944 00001D3E 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  3945 00001D41 66D1D8                  	rcr	ax, 1
  3946 00001D44 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3947 00001D47 66AB                    	stosw		; interpolated sample 2 (L)
  3948 00001D49 66AB                    	stosw		; interpolated sample 2 (R)
  3949 00001D4B C3                      	retn
  3950                                  
  3951                                  interpolating_3_16bit_stereo:
  3952                                  	; 16/11/2023
  3953                                  	; bx = [previous_val_l]
  3954                                  	; ax = [previous_val_r]
  3955                                  	; [next_val_l]
  3956                                  	; dx = [next_val_r]
  3957                                  	; original-interpolated-interpolated
  3958                                  
  3959 00001D4C 93                      	xchg	eax, ebx
  3960 00001D4D 66AB                    	stosw		; original sample (L)
  3961 00001D4F 93                      	xchg	eax, ebx
  3962 00001D50 66AB                    	stosw		; original sample (R)
  3963 00001D52 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3964 00001D55 50                      	push	eax ; *	; [previous_val_r]
  3965 00001D56 80C780                  	add	bh, 80h
  3966 00001D59 8005[93210000]80        	add	byte [next_val_l+1], 80h
  3967 00001D60 66A1[92210000]          	mov	ax, [next_val_l]
  3968 00001D66 6601D8                  	add	ax, bx	; [previous_val_l]
  3969 00001D69 66D1D8                  	rcr	ax, 1
  3970 00001D6C 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  3971 00001D6D 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3972 00001D70 66D1D8                  	rcr	ax, 1
  3973 00001D73 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3974 00001D76 66AB                    	stosw 		; interpolated sample 1 (L)
  3975 00001D78 58                      	pop	eax  ; *
  3976 00001D79 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  3977 00001D7C 52                      	push	edx  ; * ; [next_val_r]
  3978 00001D7D 92                      	xchg	eax, edx
  3979 00001D7E 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  3980 00001D81 66D1D8                  	rcr	ax, 1	; / 2
  3981 00001D84 50                      	push	eax ; ** ; interpolated middle (R)
  3982 00001D85 6601D0                  	add	ax, dx	; + [previous_val_r]
  3983 00001D88 66D1D8                  	rcr	ax, 1
  3984 00001D8B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3985 00001D8E 66AB                    	stosw 		; interpolated sample 1 (R)
  3986 00001D90 66A1[92210000]          	mov	ax, [next_val_l]
  3987 00001D96 6601D8                  	add	ax, bx	; + interpolated middle (L)
  3988 00001D99 66D1D8                  	rcr	ax, 1
  3989 00001D9C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3990 00001D9F 66AB                    	stosw 		; interpolated sample 2 (L)
  3991 00001DA1 58                      	pop	eax ; **
  3992 00001DA2 5A                      	pop	edx ; *
  3993 00001DA3 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  3994 00001DA6 66D1D8                  	rcr	ax, 1	; / 2
  3995 00001DA9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3996 00001DAC 66AB                    	stosw 		; interpolated sample 2 (L)
  3997 00001DAE C3                      	retn
  3998                                  
  3999                                  interpolating_2_16bit_mono:
  4000                                  	; 16/11/2023
  4001                                  	; ax = [previous_val]
  4002                                  	; dx = [next_val]
  4003                                  	; original-interpolated
  4004                                  
  4005 00001DAF 66AB                    	stosw		; original sample (L)
  4006 00001DB1 66AB                    	stosw		; original sample (R)
  4007 00001DB3 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4008 00001DB6 80C680                  	add	dh, 80h
  4009 00001DB9 6601D0                  	add	ax, dx
  4010 00001DBC 66D1D8                  	rcr	ax, 1
  4011 00001DBF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4012 00001DC2 66AB                    	stosw		; interpolated sample (L)
  4013 00001DC4 66AB                    	stosw		; interpolated sample (R)
  4014 00001DC6 C3                      	retn
  4015                                  
  4016                                  interpolating_2_16bit_stereo:
  4017                                  	; 17/01/2025
  4018                                  	; 16/11/2023
  4019                                  	; bx = [previous_val_l]
  4020                                  	; ax = [previous_val_r]
  4021                                  	; [next_val_l]
  4022                                  	; dx = [next_val_r]
  4023                                  	; original-interpolated
  4024                                  
  4025 00001DC7 93                      	xchg	eax, ebx
  4026 00001DC8 66AB                    	stosw		; original sample (L)
  4027 00001DCA 93                      	xchg	eax, ebx
  4028 00001DCB 66AB                    	stosw		; original sample (R)
  4029 00001DCD 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4030 00001DD0 80C680                  	add	dh, 80h
  4031 00001DD3 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  4032 00001DD6 66D1D8                  	rcr	ax, 1	; / 2
  4033                                  	; 17/01/2025
  4034 00001DD9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4035                                  	;push	eax ; *	; interpolated sample (R)
  4036                                  	; 17/01/2025
  4037 00001DDC C1E010                  	shl	eax, 16
  4038 00001DDF 66A1[92210000]          	mov	ax, [next_val_l]
  4039 00001DE5 80C480                  	add	ah, 80h
  4040 00001DE8 80C780                  	add	bh, 80h
  4041 00001DEB 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  4042 00001DEE 66D1D8                  	rcr	ax, 1	; / 2
  4043 00001DF1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4044                                  	; 17/01/2025
  4045                                  	;stosw 		; interpolated sample (L)
  4046                                  	;pop	eax ; *
  4047                                  	;sub	ah, 80h	; -32768 to +32767 format again
  4048                                  	;stosw 		; interpolated sample (R)
  4049                                  	; 17/01/2025
  4050 00001DF4 AB                      	stosd
  4051 00001DF5 C3                      	retn
  4052                                  
  4053                                  interpolating_5_8bit_mono:
  4054                                  	; 17/11/2023
  4055                                  	; al = [previous_val]
  4056                                  	; dl = [next_val]
  4057                                  	; original-interpltd-interpltd-interpltd-interpltd
  4058 00001DF6 88C3                    	mov	bl, al
  4059 00001DF8 2C80                    	sub	al, 80h
  4060 00001DFA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4061 00001DFE 66AB                    	stosw		; original sample (L)
  4062 00001E00 66AB                    	stosw		; original sample (R)
  4063 00001E02 88D8                    	mov	al, bl
  4064 00001E04 00D0                    	add	al, dl
  4065 00001E06 D0D8                    	rcr	al, 1
  4066 00001E08 88C7                    	mov	bh, al	; interpolated middle (temporary)
  4067 00001E0A 00D8                    	add	al, bl  ; [previous_val]
  4068 00001E0C D0D8                    	rcr	al, 1 	
  4069 00001E0E 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  4070 00001E10 00D8                    	add	al, bl
  4071 00001E12 D0D8                    	rcr	al, 1
  4072 00001E14 2C80                    	sub	al, 80h
  4073 00001E16 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4074 00001E1A 66AB                    	stosw		; interpolated sample 1 (L)
  4075 00001E1C 66AB                    	stosw		; interpolated sample 1 (R)
  4076 00001E1E 88F8                    	mov	al, bh
  4077 00001E20 00F0                    	add	al, dh
  4078 00001E22 D0D8                    	rcr	al, 1
  4079 00001E24 2C80                    	sub	al, 80h
  4080 00001E26 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4081 00001E2A 66AB                    	stosw		; interpolated sample 2 (L)
  4082 00001E2C 66AB                    	stosw		; interpolated sample 2 (R)
  4083 00001E2E 88F8                    	mov	al, bh
  4084 00001E30 00D0                    	add	al, dl	; [next_val]
  4085 00001E32 D0D8                    	rcr	al, 1
  4086 00001E34 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  4087 00001E36 00F8                    	add	al, bh
  4088 00001E38 D0D8                    	rcr	al, 1
  4089 00001E3A 2C80                    	sub	al, 80h
  4090 00001E3C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4091 00001E40 66AB                    	stosw		; interpolated sample 3 (L)
  4092 00001E42 66AB                    	stosw		; interpolated sample 3 (R)
  4093 00001E44 88F0                    	mov	al, dh
  4094 00001E46 00D0                    	add	al, dl
  4095 00001E48 D0D8                    	rcr	al, 1
  4096 00001E4A 2C80                    	sub	al, 80h
  4097 00001E4C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4098 00001E50 66AB                    	stosw		; interpolated sample 4 (L)
  4099 00001E52 66AB                    	stosw		; interpolated sample 4 (R)
  4100 00001E54 C3                      	retn
  4101                                  
  4102                                  interpolating_5_8bit_stereo:
  4103                                  	; 17/11/2023
  4104                                  	; al = [previous_val_l]
  4105                                  	; ah = [previous_val_r]
  4106                                  	; dl = [next_val_l]
  4107                                  	; dh = [next_val_r]
  4108                                  	; original-interpltd-interpltd-interpltd-interpltd
  4109 00001E55 89C3                    	mov	ebx, eax
  4110 00001E57 2C80                    	sub	al, 80h
  4111 00001E59 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4112 00001E5D 66AB                    	stosw		; original sample (L)
  4113 00001E5F 88F8                    	mov	al, bh
  4114 00001E61 2C80                    	sub	al, 80h
  4115 00001E63 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4116 00001E67 66AB                    	stosw		; original sample (R)
  4117 00001E69 52                      	push	edx ; *
  4118 00001E6A 88D8                    	mov	al, bl
  4119 00001E6C 00D0                    	add	al, dl	; [next_val_l]
  4120 00001E6E D0D8                    	rcr	al, 1
  4121 00001E70 50                      	push	eax ; ** ; al = interpolated middle (L) (temporary)
  4122 00001E71 00D8                    	add	al, bl	; [previous_val_l]
  4123 00001E73 D0D8                    	rcr	al, 1
  4124 00001E75 86D8                    	xchg	al, bl
  4125 00001E77 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  4126 00001E79 D0D8                    	rcr	al, 1
  4127 00001E7B 2C80                    	sub	al, 80h
  4128 00001E7D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4129 00001E81 66AB                    	stosw		; interpolated sample 1 (L)
  4130 00001E83 88F8                    	mov	al, bh
  4131 00001E85 00F0                    	add	al, dh	; [next_val_r]
  4132 00001E87 D0D8                    	rcr	al, 1
  4133 00001E89 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  4134 00001E8A 00F8                    	add	al, bh	; [previous_val_r]
  4135 00001E8C D0D8                    	rcr	al, 1
  4136 00001E8E 86F8                    	xchg	al, bh
  4137 00001E90 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  4138 00001E92 D0D8                    	rcr	al, 1
  4139 00001E94 2C80                    	sub	al, 80h
  4140 00001E96 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4141 00001E9A 66AB                    	stosw		; interpolated sample 1 (R)
  4142 00001E9C 5A                      	pop	edx ; ***
  4143 00001E9D 58                      	pop	eax ; ** ; al = interpolated middle (L) (temporary)
  4144 00001E9E 86D8                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  4145 00001EA0 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  4146 00001EA2 D0D8                    	rcr	al, 1
  4147 00001EA4 2C80                    	sub	al, 80h
  4148 00001EA6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4149 00001EAA 66AB                    	stosw		; interpolated sample 2 (L)	
  4150 00001EAC 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  4151 00001EAE 86F8                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  4152 00001EB0 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  4153 00001EB2 D0D8                    	rcr	al, 1
  4154 00001EB4 2C80                    	sub	al, 80h
  4155 00001EB6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4156 00001EBA 66AB                    	stosw		; interpolated sample 2 (R)
  4157 00001EBC 5A                      	pop	edx ; *
  4158 00001EBD 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  4159 00001EBF 00D0                    	add	al, dl	; [next_val_l]
  4160 00001EC1 D0D8                    	rcr	al, 1
  4161 00001EC3 86D8                    	xchg	al, bl	; al = interpolated middle (R) (temporary)
  4162 00001EC5 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  4163 00001EC7 D0D8                    	rcr	al, 1
  4164 00001EC9 2C80                    	sub	al, 80h
  4165 00001ECB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4166 00001ECF 66AB                    	stosw		; interpolated sample 3 (L)
  4167 00001ED1 88F8                    	mov	al, bh	
  4168 00001ED3 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  4169 00001ED5 D0D8                    	rcr	al, 1
  4170 00001ED7 86F8                    	xchg	al, bh	; al = interpolated middle (R)
  4171 00001ED9 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  4172 00001EDB D0D8                    	rcr	al, 1
  4173 00001EDD 2C80                    	sub	al, 80h
  4174 00001EDF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4175 00001EE3 66AB                    	stosw		; interpolated sample 3 (R)
  4176 00001EE5 88D8                    	mov	al, bl
  4177 00001EE7 00D0                    	add	al, dl	; [next_val_l]
  4178 00001EE9 D0D8                    	rcr	al, 1
  4179 00001EEB 2C80                    	sub	al, 80h
  4180 00001EED 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4181 00001EF1 66AB                    	stosw		; interpolated sample 4 (L)
  4182 00001EF3 88F8                    	mov	al, bh
  4183 00001EF5 00F0                    	add	al, dh	; [next_val_r]
  4184 00001EF7 D0D8                    	rcr	al, 1
  4185 00001EF9 2C80                    	sub	al, 80h
  4186 00001EFB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4187 00001EFF 66AB                    	stosw		; interpolated sample 4 (R)
  4188 00001F01 C3                      	retn
  4189                                  
  4190                                  interpolating_4_8bit_mono:
  4191                                  	; 17/11/2023
  4192                                  	; al = [previous_val]
  4193                                  	; dl = [next_val]
  4194                                  	; original-interpolated-interpolated-interpolated
  4195 00001F02 88C3                    	mov	bl, al
  4196 00001F04 2C80                    	sub	al, 80h
  4197 00001F06 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4198 00001F0A 66AB                    	stosw		; original sample (L)
  4199 00001F0C 66AB                    	stosw		; original sample (R)
  4200 00001F0E 88D8                    	mov	al, bl
  4201 00001F10 00D0                    	add	al, dl
  4202 00001F12 D0D8                    	rcr	al, 1
  4203 00001F14 86D8                    	xchg	al, bl  ; al = [previous_val]
  4204 00001F16 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  4205 00001F18 D0D8                    	rcr	al, 1
  4206 00001F1A 2C80                    	sub	al, 80h
  4207 00001F1C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4208 00001F20 66AB                    	stosw		; interpolated sample 1 (L)
  4209 00001F22 66AB                    	stosw		; interpolated sample 1 (R)
  4210 00001F24 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  4211 00001F26 2C80                    	sub	al, 80h
  4212 00001F28 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4213 00001F2C 66AB                    	stosw		; interpolated sample 2 (L)
  4214 00001F2E 66AB                    	stosw		; interpolated sample 2 (R)
  4215 00001F30 88D8                    	mov	al, bl
  4216 00001F32 00D0                    	add	al, dl	; [next_val]
  4217 00001F34 D0D8                    	rcr	al, 1
  4218 00001F36 2C80                    	sub	al, 80h
  4219 00001F38 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4220 00001F3C 66AB                    	stosw		; interpolated sample 3 (L)
  4221 00001F3E 66AB                    	stosw		; interpolated sample 3 (R)
  4222 00001F40 C3                      	retn
  4223                                  
  4224                                  interpolating_4_8bit_stereo:
  4225                                  	; 17/11/2023
  4226                                  	; al = [previous_val_l]
  4227                                  	; ah = [previous_val_r]
  4228                                  	; dl = [next_val_l]
  4229                                  	; dh = [next_val_r]
  4230                                  	; original-interpolated-interpolated-interpolated
  4231 00001F41 89C3                    	mov	ebx, eax
  4232 00001F43 2C80                    	sub	al, 80h
  4233 00001F45 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4234 00001F49 66AB                    	stosw		; original sample (L)
  4235 00001F4B 88F8                    	mov	al, bh
  4236 00001F4D 2C80                    	sub	al, 80h
  4237 00001F4F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4238 00001F53 66AB                    	stosw		; original sample (R)
  4239 00001F55 88D8                    	mov	al, bl
  4240 00001F57 00D0                    	add	al, dl	; [next_val_l]
  4241 00001F59 D0D8                    	rcr	al, 1
  4242 00001F5B 86D8                    	xchg	al, bl	; al = [previous_val_l]
  4243 00001F5D 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  4244 00001F5F D0D8                    	rcr	al, 1
  4245 00001F61 2C80                    	sub	al, 80h
  4246 00001F63 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4247 00001F67 66AB                    	stosw		; interpolated sample 1 (L)
  4248 00001F69 88F8                    	mov	al, bh
  4249 00001F6B 00F0                    	add	al, dh	; [next_val_r]
  4250 00001F6D D0D8                    	rcr	al, 1
  4251 00001F6F 86F8                    	xchg	al, bh	; al = [previous_val_h]
  4252 00001F71 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  4253 00001F73 D0D8                    	rcr	al, 1
  4254 00001F75 2C80                    	sub	al, 80h
  4255 00001F77 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4256 00001F7B 66AB                    	stosw		; interpolated sample 1 (R)
  4257 00001F7D 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  4258 00001F7F 2C80                    	sub	al, 80h
  4259 00001F81 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4260 00001F85 66AB                    	stosw		; interpolated sample 2 (L)
  4261 00001F87 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  4262 00001F89 2C80                    	sub	al, 80h
  4263 00001F8B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4264 00001F8F 66AB                    	stosw		; interpolated sample 2 (L)
  4265 00001F91 88D8                    	mov	al, bl
  4266 00001F93 00D0                    	add	al, dl	; [next_val_l]
  4267 00001F95 D0D8                    	rcr	al, 1
  4268 00001F97 2C80                    	sub	al, 80h
  4269 00001F99 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4270 00001F9D 66AB                    	stosw		; interpolated sample 3 (L)
  4271 00001F9F 88F8                    	mov	al, bh
  4272 00001FA1 00F0                    	add	al, dh	; [next_val_r]
  4273 00001FA3 D0D8                    	rcr	al, 1
  4274 00001FA5 2C80                    	sub	al, 80h
  4275 00001FA7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4276 00001FAB 66AB                    	stosw		; interpolated sample 3 (R)
  4277 00001FAD C3                      	retn
  4278                                  
  4279                                  interpolating_5_16bit_mono:
  4280                                  	; 18/11/2023
  4281                                  	; ax = [previous_val]
  4282                                  	; dx = [next_val]
  4283                                  	; original-interpltd-interpltd-interpltd-interpltd
  4284 00001FAE 66AB                    	stosw		; original sample (L)
  4285 00001FB0 66AB                    	stosw		; original sample (R)
  4286 00001FB2 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4287 00001FB5 89C3                    	mov	ebx, eax ; [previous_val]
  4288 00001FB7 80C680                  	add	dh, 80h
  4289 00001FBA 6601D0                  	add	ax, dx
  4290 00001FBD 66D1D8                  	rcr	ax, 1
  4291 00001FC0 50                      	push	eax ; *	; interpolated middle (temporary)
  4292 00001FC1 6601D8                  	add	ax, bx	; interpolated middle + [previous_val]
  4293 00001FC4 66D1D8                  	rcr	ax, 1
  4294 00001FC7 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  4295 00001FC8 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  4296 00001FCB 66D1D8                  	rcr	ax, 1	
  4297 00001FCE 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4298 00001FD1 66AB                    	stosw 		; interpolated sample 1 (L)
  4299 00001FD3 66AB                    	stosw		; interpolated sample 1 (R)
  4300 00001FD5 58                      	pop	eax ; **
  4301 00001FD6 5B                      	pop	ebx ; *
  4302 00001FD7 6601D8                  	add	ax, bx	; 1st quarter + middle
  4303 00001FDA 66D1D8                  	rcr	ax, 1	; / 2
  4304 00001FDD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  4305 00001FE0 66AB                    	stosw		; interpolated sample 2 (L)
  4306 00001FE2 66AB                    	stosw		; interpolated sample 2 (R)
  4307 00001FE4 89D8                    	mov	eax, ebx
  4308 00001FE6 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4309 00001FE9 66D1D8                  	rcr	ax, 1
  4310 00001FEC 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  4311 00001FED 6601D8                  	add	ax, bx	; + interpolated middle
  4312 00001FF0 66D1D8                  	rcr	ax, 1
  4313 00001FF3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4314 00001FF6 66AB                    	stosw		; interpolated sample 3 (L)
  4315 00001FF8 66AB                    	stosw		; interpolated sample 3 (R)
  4316 00001FFA 58                      	pop	eax ; *	
  4317 00001FFB 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  4318 00001FFE 66D1D8                  	rcr	ax, 1	; / 2
  4319 00002001 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4320 00002004 66AB                    	stosw		; interpolated sample 4 (L)
  4321 00002006 66AB                    	stosw		; interpolated sample 4 (R)
  4322 00002008 C3                      	retn
  4323                                  
  4324                                  interpolating_5_16bit_stereo:
  4325                                  	; 18/11/2023
  4326                                  	; bx = [previous_val_l]
  4327                                  	; ax = [previous_val_r]
  4328                                  	; [next_val_l]
  4329                                  	; [next_val_r]
  4330                                  	; original-interpltd-interpltd-interpltd-interpltd
  4331 00002009 51                      	push	ecx ; !
  4332 0000200A 93                      	xchg	eax, ebx
  4333 0000200B 66AB                    	stosw		; original sample (L)
  4334 0000200D 93                      	xchg	eax, ebx
  4335 0000200E 66AB                    	stosw		; original sample (R)
  4336 00002010 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4337 00002013 50                      	push	eax ; *	; [previous_val_r]
  4338 00002014 80C780                  	add	bh, 80h
  4339 00002017 8005[93210000]80        	add	byte [next_val_l+1], 80h
  4340 0000201E 66A1[92210000]          	mov	ax, [next_val_l]
  4341 00002024 6601D8                  	add	ax, bx	; [previous_val_l]
  4342 00002027 66D1D8                  	rcr	ax, 1
  4343 0000202A 89C1                    	mov	ecx, eax ; interpolated middle (L)
  4344 0000202C 6601D8                  	add	ax, bx	
  4345 0000202F 66D1D8                  	rcr	ax, 1
  4346 00002032 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)
  4347 00002034 6601D8                  	add	ax, bx	; [previous_val_l]
  4348 00002037 66D1D8                  	rcr	ax, 1
  4349 0000203A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4350 0000203D 66AB                    	stosw 		; interpolated sample 1 (L)
  4351 0000203F 89C8                    	mov	eax, ecx
  4352 00002041 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L)
  4353 00002044 66D1D8                  	rcr	ax, 1	; / 2
  4354 00002047 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  4355 00002049 5A                      	pop	edx ; *	; [previous_val_r]
  4356 0000204A 89D0                    	mov	eax, edx
  4357 0000204C 8005[95210000]80        	add	byte [next_val_r+1], 80h
  4358 00002053 660305[94210000]        	add	ax, [next_val_r]
  4359 0000205A 66D1D8                  	rcr	ax, 1
  4360 0000205D 50                      	push	eax ; *	; interpolated middle (R)
  4361 0000205E 6601D0                  	add	ax, dx
  4362 00002061 66D1D8                  	rcr	ax, 1
  4363 00002064 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  4364 00002065 6601D0                  	add	ax, dx	; [previous_val_r]
  4365 00002068 66D1D8                  	rcr	ax, 1
  4366 0000206B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4367 0000206E 66AB                    	stosw 		; interpolated sample 1 (R)
  4368 00002070 89D8                    	mov	eax, ebx
  4369 00002072 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4370 00002075 66AB                    	stosw 		; interpolated sample 2 (L)
  4371 00002077 58                      	pop	eax ; **
  4372 00002078 5A                      	pop	edx ; *
  4373 00002079 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  4374 0000207C 66D1D8                  	rcr	ax, 1	; / 2
  4375 0000207F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4376 00002082 66AB                    	stosw 		; interpolated sample 2 (R)
  4377 00002084 89C8                    	mov	eax, ecx
  4378 00002086 660305[92210000]        	add	ax, [next_val_l]
  4379 0000208D 66D1D8                  	rcr	ax, 1
  4380 00002090 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  4381 00002091 6601C8                  	add	ax, cx	; interpolated middle (L)
  4382 00002094 66D1D8                  	rcr	ax, 1
  4383 00002097 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4384 0000209A 66AB                    	stosw 		; interpolated sample 3 (L)
  4385 0000209C 89D0                    	mov	eax, edx
  4386 0000209E 660305[94210000]        	add	ax, [next_val_r]
  4387 000020A5 66D1D8                  	rcr	ax, 1
  4388 000020A8 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4389 000020A9 6601D0                  	add	ax, dx	; interpolated middle (R)
  4390 000020AC 66D1D8                  	rcr	ax, 1
  4391 000020AF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4392 000020B2 66AB                    	stosw 		; interpolated sample 3 (R)
  4393 000020B4 5B                      	pop	ebx ; **
  4394 000020B5 58                      	pop	eax ; *
  4395 000020B6 660305[92210000]        	add	ax, [next_val_l]
  4396 000020BD 66D1D8                  	rcr	ax, 1
  4397 000020C0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4398 000020C3 66AB                    	stosw 		; interpolated sample 4 (L)
  4399 000020C5 89D8                    	mov	eax, ebx	
  4400 000020C7 660305[94210000]        	add	ax, [next_val_r]
  4401 000020CE 66D1D8                  	rcr	ax, 1
  4402 000020D1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4403 000020D4 66AB                    	stosw 		; interpolated sample 4 (R)
  4404 000020D6 59                      	pop	ecx ; !
  4405 000020D7 C3                      	retn
  4406                                  
  4407                                  interpolating_4_16bit_mono:
  4408                                  	; 18/11/2023
  4409                                  	; ax = [previous_val]
  4410                                  	; dx = [next_val]
  4411                                  	; 02/02/2025
  4412                                  	; original-interpolated-interpolated-interpolated
  4413                                  
  4414 000020D8 66AB                    	stosw		; original sample (L)
  4415 000020DA 66AB                    	stosw		; original sample (R)
  4416 000020DC 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4417 000020DF 89C3                    	mov	ebx, eax ; [previous_val]
  4418 000020E1 80C680                  	add	dh, 80h
  4419 000020E4 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4420 000020E7 66D1D8                  	rcr	ax, 1
  4421 000020EA 93                      	xchg	eax, ebx
  4422 000020EB 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4423 000020EE 66D1D8                  	rcr	ax, 1
  4424 000020F1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4425 000020F4 66AB                    	stosw 		; interpolated sample 1 (L)
  4426 000020F6 66AB                    	stosw		; interpolated sample 1 (R)
  4427 000020F8 89D8                    	mov	eax, ebx ; interpolated middle
  4428 000020FA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4429 000020FD 66AB                    	stosw 		; interpolated sample 2 (L)
  4430 000020FF 66AB                    	stosw		; interpolated sample 2 (R)
  4431 00002101 89D8                    	mov	eax, ebx
  4432 00002103 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4433 00002106 66D1D8                  	rcr	ax, 1
  4434 00002109 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4435 0000210C 66AB                    	stosw		; interpolated sample 3 (L)
  4436 0000210E 66AB                    	stosw		; interpolated sample 3 (R)
  4437 00002110 C3                      	retn
  4438                                  
  4439                                  interpolating_4_16bit_stereo:
  4440                                  	; 18/11/2023
  4441                                  	; bx = [previous_val_l]
  4442                                  	; ax = [previous_val_r]
  4443                                  	; [next_val_l]
  4444                                  	; [next_val_r]
  4445                                  	; original-interpolated-interpolated-interpolated
  4446 00002111 93                      	xchg	eax, ebx
  4447 00002112 66AB                    	stosw		; original sample (L)
  4448 00002114 93                      	xchg	eax, ebx
  4449 00002115 66AB                    	stosw		; original sample (R)
  4450 00002117 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4451 0000211A 89C2                    	mov	edx, eax ; [previous_val_r]
  4452 0000211C 80C780                  	add	bh, 80h
  4453 0000211F 8005[93210000]80        	add	byte [next_val_l+1], 80h
  4454 00002126 66A1[92210000]          	mov	ax, [next_val_l]
  4455 0000212C 6601D8                  	add	ax, bx	; [previous_val_l]
  4456 0000212F 66D1D8                  	rcr	ax, 1
  4457 00002132 93                      	xchg	eax, ebx	
  4458 00002133 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4459 00002136 66D1D8                  	rcr	ax, 1
  4460 00002139 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4461 0000213C 66AB                    	stosw 		; interpolated sample 1 (L)
  4462 0000213E 8005[95210000]80        	add	byte [next_val_r+1], 80h
  4463 00002145 89D0                    	mov	eax, edx ; [previous_val_r]
  4464 00002147 660305[94210000]        	add	ax, [next_val_r]
  4465 0000214E 66D1D8                  	rcr	ax, 1
  4466 00002151 92                      	xchg	eax, edx	
  4467 00002152 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4468 00002155 66D1D8                  	rcr	ax, 1
  4469 00002158 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4470 0000215B 66AB                    	stosw 		; interpolated sample 1 (R)
  4471 0000215D 89D8                    	mov	eax, ebx
  4472 0000215F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4473 00002162 66AB                    	stosw 		; interpolated sample 2 (L)
  4474 00002164 89D0                    	mov	eax, edx
  4475 00002166 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4476 00002169 66AB                    	stosw 		; interpolated sample 2 (R)
  4477 0000216B 89D8                    	mov	eax, ebx
  4478 0000216D 660305[92210000]        	add	ax, [next_val_l]
  4479 00002174 66D1D8                  	rcr	ax, 1
  4480 00002177 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4481 0000217A 66AB                    	stosw 		; interpolated sample 3 (L)
  4482 0000217C 89D0                    	mov	eax, edx
  4483 0000217E 660305[94210000]        	add	ax, [next_val_r]
  4484 00002185 66D1D8                  	rcr	ax, 1
  4485 00002188 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4486 0000218B 66AB                    	stosw 		; interpolated sample 3 (R)
  4487 0000218D C3                      	retn
  4488                                  
  4489                                  ; 13/11/2023
  4490                                  previous_val:
  4491 0000218E 0000                    previous_val_l: dw 0
  4492 00002190 0000                    previous_val_r: dw 0
  4493                                  next_val:
  4494 00002192 0000                    next_val_l: dw 0
  4495 00002194 0000                    next_val_r: dw 0
  4496                                  
  4497                                  ; 16/11/2023
  4498 00002196 00                      faz:	db 0
  4499                                  
  4500                                  ; --------------------------------------------------------
  4501                                  
  4502                                  ; DATA
  4503                                  
  4504                                  FileHandle:	
  4505 00002197 FFFFFFFF                	dd	-1
  4506                                  
  4507                                  Credits:
  4508 0000219B 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  4508 000021A4 506C6179657220666F-
  4508 000021AD 72205452444F532033-
  4508 000021B6 383620627920457264-
  4508 000021BF 6F67616E2054616E2E-
  4508 000021C8 20                 
  4509                                  	;;;;;db	'August 2020.',10,13,0
  4510                                  	;;;;db	'November 2023.',10,13,0
  4511                                  	;;;db	'June 2024.', 10,13,0
  4512                                  	;;db	'December 2024.', 10,13,0
  4513                                  	;db	'January 2025.', 10,13,0
  4514 000021C9 466562727561727920-     	db	'February 2025.', 10,13,0
  4514 000021D2 323032352E0A0D00   
  4515 000021DA 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  4515 000021E3 370A0D00           
  4516 000021E7 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  4516 000021F0 300A0D00           
  4517 000021F4 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  4517 000021FD 330A0D00           
  4518 00002201 30312F30362F323032-     	db	'01/06/2024', 10,13,0
  4518 0000220A 340A0D00           
  4519 0000220E 30342F30362F323032-     	db	'04/06/2024', 10,13,0
  4519 00002217 340A0D00           
  4520 0000221B 31342F31322F323032-     	db	'14/12/2024', 10,13,0
  4520 00002224 340A0D00           
  4521 00002228 31372F30312F323032-     	db	'17/01/2025', 10,13,0
  4521 00002231 350A0D00           
  4522 00002235 30322F30322F323032-     	db	'02/02/2025', 10,13,0
  4522 0000223E 350A0D00           
  4523                                  
  4524                                  msgAudioCardInfo:
  4525 00002242 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  4525 0000224B 204143393720284943-
  4525 00002254 482920417564696F20-
  4525 0000225D 436F6E74726F6C6C65-
  4525 00002266 722E0A0D00         
  4526                                  
  4527                                  msg_usage:
  4528 0000226B 75736167653A20706C-     	db	'usage: playwav8 filename.wav',10,13,0
  4528 00002274 617977617638206669-
  4528 0000227D 6C656E616D652E7761-
  4528 00002286 760A0D00           
  4529                                  
  4530                                  noDevMsg:
  4531 0000228A 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  4531 00002293 61626C6520746F2066-
  4531 0000229C 696E64204143393720-
  4531 000022A5 617564696F20646576-
  4531 000022AE 69636521           
  4532 000022B2 0A0D00                  	db	10,13,0
  4533                                  
  4534                                  noFileErrMsg:
  4535 000022B5 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  4535 000022BE 6C65206E6F7420666F-
  4535 000022C7 756E642E0A0D00     
  4536                                  
  4537                                  trdos386_err_msg:
  4538 000022CE 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  4538 000022D7 2053797374656D2063-
  4538 000022E0 616C6C206572726F72-
  4538 000022E9 20210A0D00         
  4539                                  
  4540                                  ; 01/06/2024
  4541                                  msg_init_err:
  4542 000022EE 0A0D                    	db	10,13
  4543 000022F0 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  4543 000022F9 726F6C6C65722F436F-
  4543 00002302 64656320696E697469-
  4543 0000230B 616C697A6174696F6E-
  4543 00002314 206572726F722021   
  4544 0000231C 0A0D00                  	db	10,13,0
  4545                                  
  4546                                  ; 25/11/2023
  4547                                  msg_no_vra:
  4548 0000231F 0A0D                    	db	10,13
  4549 00002321 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  4549 0000232A 70706F72742021204F-
  4549 00002333 6E6C79203438206B48-
  4549 0000233C 5A2073616D706C6520-
  4549 00002345 726174652073757070-
  4549 0000234E 6F727465642021     
  4550 00002355 0A0D00                  	db	10,13,0
  4551                                  
  4552 00002358 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  4552 00002361 65204E616D653A2000 
  4553 0000236A 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  4553 00002373 526174653A20       
  4554 00002379 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  4554 00002382 2000               
  4555 00002384 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  4556 0000238D 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  4557 00002394 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  4557 0000239D 00                 
  4558 0000239E 53746572656F            msgStereo:	db "Stereo"
  4559 000023A4 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  4560                                  
  4561                                  ; 03/06/2017
  4562 000023A7 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  4562 000023B0 3941424344454600   
  4563 000023B8 0D0A                    msgAC97Info	db 0Dh, 0Ah
  4564 000023BA 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  4564 000023C3 6F20436F6E74726F6C-
  4564 000023CC 6C6572202620436F64-
  4564 000023D5 656320496E666F0D0A 
  4565 000023DE 56656E646F72204944-     		db "Vendor ID: "
  4565 000023E7 3A20               
  4566 000023E9 303030306820446576-     msgVendorId	db "0000h Device ID: "
  4566 000023F2 6963652049443A20   
  4567 000023FA 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  4568 00002401 4275733A20              		db "Bus: "
  4569 00002406 303068204465766963-     msgBusNo	db "00h Device: "
  4569 0000240F 653A20             
  4570 00002412 3030682046756E6374-     msgDevNo	db "00h Function: "
  4570 0000241B 696F6E3A20         
  4571 00002420 303068                  msgFncNo	db "00h"
  4572 00002423 0D0A                    		db 0Dh, 0Ah
  4573 00002425 4E414D4241523A20        		db "NAMBAR: "
  4574 0000242D 30303030682020          msgNamBar	db "0000h  "
  4575 00002434 4E41424D4241523A20      		db "NABMBAR: "
  4576 0000243D 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  4576 00002446 513A20             
  4577 00002449 3030                    msgIRQ		dw 3030h
  4578 0000244B 0D0A00                  		db 0Dh, 0Ah, 0
  4579                                  ; 25/11/2023
  4580 0000244E 56524120737570706F-     msgVRAheader:	db "VRA support: "
  4580 00002457 72743A20           
  4581 0000245B 00                      		db 0
  4582                                  ; 08/12/2024
  4583                                  ;msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  4584 0000245C 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  4585 00002461 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  4585 0000246A 617465642073616D70-
  4585 00002473 6C6520726174652070-
  4585 0000247C 6C6179696E67206D65-
  4585 00002485 74686F6429         
  4586 0000248A 0D0A00                  		db 0Dh, 0Ah, 0	
  4587                                  EOF:
  4588                                  
  4589                                  ; BSS
  4590                                  
  4591                                  bss_start:
  4592                                  
  4593                                  ABSOLUTE bss_start
  4594                                  
  4595 0000248D ??????                  alignb 4
  4596                                  
  4597 00002490 ??                      stmo:		resb 1 ; stereo or mono (1=stereo)
  4598 00002491 ??                      bps:		resb 1 ; bits per sample (8,16)
  4599 00002492 ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  4600                                  
  4601                                  ; 25/11/2023
  4602 00002494 ????????                bufferSize:	resd 1
  4603                                  
  4604 00002498 ??                      flags:		resb 1
  4605                                  ;cbs_busy:	resb 1
  4606 00002499 ??                      half_buff:	resb 1
  4607 0000249A ??                      srb:		resb 1
  4608                                  ; 18/08/2020
  4609 0000249B ??                      volume_level:	resb 1
  4610                                  ; 25/11/2023
  4611 0000249C ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  4612                                  
  4613 0000249D <res 1Ch>               smpRBuff:	resw 14
  4614                                  
  4615                                  wav_file_name:
  4616 000024B9 <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  4617                                  
  4618 00002509 ????                    		resw 1
  4619 0000250B ??                      ac97_int_ln_reg: resb 1
  4620 0000250C ??                      fbs_shift:	resb 1 ; 26/11/2023
  4621 0000250D ????????                dev_vendor:	resd 1
  4622 00002511 ????????                bus_dev_fn:	resd 1
  4623 00002515 ????                    ac97_NamBar:	resw 1
  4624 00002517 ????                    ac97_NabmBar:	resw 1
  4625                                  
  4626                                  bss_end:
  4627 00002519 <res AE7h>              alignb 4096
  4628                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  4629                                  ; 26/11/2023
  4630 00003000 <res 10000h>            audio_buffer:	resb 65536
  4631                                  ; 13/06/2017
  4632                                  ;temp_buffer:	resb BUFFERSIZE
  4633                                  ; 26/11/2023
  4634 00013000 <res 10000h>            temp_buffer:	resb 65536
