     1                                  ; ****************************************************************************
     2                                  ; cgaplay.asm - Retro DOS (MSDOS/PCDOS) WAV PLAYER - Video Mode 13h
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; CGAPLAY.COM ! AC'97 (ICH) .WAV PLAYER program by Erdogan TAN
     5                                  ;
     6                                  ; 01/01/2025				- play music from multiple wav files -
     7                                  ;
     8                                  ; [ Last Modification: 04/02/2025 ]
     9                                  ;
    10                                  ; Modified from CGAPLAY1.PRG .wav player program by Erdogan Tan, 31/12/2024
    11                                  ;	        AC97PLAY.COM, 18/12/2024
    12                                  ;
    13                                  ; ****************************************************************************
    14                                  ; nasm cgaplay.asm -l cgaplay.lst -o CGAPLAY.COM -Z error.txt
    15                                  
    16                                  ; 31/12/2024
    17                                  ; cgaplay1.s (int 31h modifications on cgaplay.s) -TRDOS386-PRG-
    18                                  ; 18/12/2024
    19                                  ; ac97play.asm : TUNELOOP version (playing without AC97 interrupt) -DOS-COM-
    20                                  
    21                                  ; vgaplay.s (26/12/2024) - play music from multiple wav files -
    22                                  ; dplayvga.s (25/12/2024) - play music from single wav file -
    23                                  ; ac97play.s (18/12/2024) - play music from multiple wav files -
    24                                  
    25                                  ; 07/12/2024 - playwav9.s - interrupt (srb) + tuneloop version
    26                                  ; ------------------------------------------------------------
    27                                  ; INTERRUPT (SRB) + TUNELOOP version ; 24/11/2024 (PLAYWAV9.ASM)
    28                                  ;	(running in DOSBOX, VIRTUALBOX, QEMU is ok)
    29                                  ; Signal Response Byte = message/signal to user about an event/interrupt
    30                                  ;	    as requested (TuneLoop procedure continuously checks this SRB)
    31                                  ; (TRDOS 386 v2 feature is used here as very simple interrupt handler output)
    32                                  
    33                                  ; ------------------------------------------------------------
    34                                  
    35                                  ; 01/01/2025	
    36                                  %macro	sys_msg	2
    37                                  	mov	si, %1	; message
    38                                  	mov	bl, %2	; text color
    39                                  	xor	bh, bh	; video page 0
    40                                  	mov	ah, 0Eh
    41                                  	call	p_msg	
    42                                  %endmacro
    43                                  
    44                                  ; ------------------------------------------------------------
    45                                  ; player internal variables and other equates.
    46                                  ;BUFFERSIZE	equ 64 * 1024	; 64k file buffer size.
    47                                  ; 17/11/2024
    48                                  BUFFERSIZE	equ 65520
    49                                  ENDOFFILE	equ 1		; flag for knowing end of file
    50                                  ; ------------------------------------------------------------
    51                                  
    52                                  [BITS 16] ; 16-bit intructions
    53                                  
    54                                  [ORG 100h]
    55                                  
    56                                  	; 01/01/2025
    57                                  START_CODE:
    58                                  	; 30/05/2024
    59                                  	; Prints the Credits Text.
    60                                  	sys_msg Credits, 0Bh
    37 00000000 BE[A822]            <1>  mov si, %1
    38 00000003 B30B                <1>  mov bl, %2
    39 00000005 30FF                <1>  xor bh, bh
    40 00000007 B40E                <1>  mov ah, 0Eh
    41 00000009 E8C003              <1>  call p_msg
    61                                  
    62                                  	; 01/01/2025
    63                                  	; (setFree is required before memAlloc)
    64                                  	; 30/05/2024
    65 0000000C E8FE05                          call    setFree		; deallocate unused DOS mem
    66                                  
    67                                  	; 17/02/2017
    68                                  	; Clear BSS (uninitialized data) area
    69 0000000F 31C0                    	xor	ax, ax ; 0
    70 00000011 B99D01                  	mov	cx, (bss_end - bss_start)/2
    71 00000014 BF[B428]                	mov	di, bss_start
    72 00000017 F3AB                    	rep	stosw
    73                                  
    74                                  ; -------------------------------------------------------------
    75                                  
    76                                  	; 21/12/2024
    77                                  	; Detect (& Enable) AC'97 Audio Device
    78 00000019 E86305                  	call	DetectAC97
    79 0000001C 730F                    	jnc	short ac97_hardware_ready
    80                                  
    81                                  	; 30/11/2024
    82                                  	; 30/05/2024
    83                                  _dev_not_ready:
    84                                  	; couldn't find the audio device!
    85                                  	sys_msg noDevMsg, 0Fh
    37 0000001E BE[4B23]            <1>  mov si, %1
    38 00000021 B30F                <1>  mov bl, %2
    39 00000023 30FF                <1>  xor bh, bh
    40 00000025 B40E                <1>  mov ah, 0Eh
    41 00000027 E8A203              <1>  call p_msg
    86 0000002A E97103                          jmp     Exit
    87                                  
    88                                  ac97_hardware_ready:
    89 0000002D E82B0A                  	call	write_audio_dev_info
    90                                  
    91                                  ; -------------------------------------------------------------
    92                                  	; 30/05/2024
    93                                  allocate_memory:
    94                                  
    95                                  ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
    96                                  
    97 00000030 B81000                          mov     ax, BDL_SIZE / 16
    98 00000033 E8DF05                          call    memAlloc
    99 00000036 A3[D22B]                        mov     [BDL_BUFFER], ax	; segment 
   100                                  
   101                                  ; allocate 2 buffers, 64k each for now.
   102                                  
   103 00000039 B8FF0F                          mov     ax, BUFFERSIZE / 16	; 64k for .WAV file
   104 0000003C E8D605                          call    memAlloc
   105 0000003F A3[D42B]                        mov     [WAV_BUFFER1], ax	; segment
   106                                  
   107 00000042 B8FF0F                  	mov	ax, BUFFERSIZE / 16
   108 00000045 E8CD05                  	call	memAlloc
   109 00000048 A3[D62B]                	mov	[WAV_BUFFER2], ax
   110                                  
   111                                  ; -------------------------------------------------------------
   112                                  
   113                                  	; 01/01/2025
   114                                  	; set VGA/CGA mode (320*200 pixels, 256 colors)
   115 0000004B B81300                  	mov	ax, 13h
   116 0000004E CD10                    	int	10h
   117                                  
   118                                  ; -------------------------------------------------------------
   119                                  
   120                                  mode_13h_set_ok:
   121                                  	; 01/01/2025
   122                                  	;mov	word [graphstart], (11*8*320)+(4*320)
   123                                  
   124                                  ; -------------------------------------------------------------
   125                                  
   126                                  	; 01/01/2025
   127                                  Player_ParseParameters:
   128                                  	; 28/11/2024
   129 00000050 BE8100                  	mov	si, 81h
   130 00000053 8936[702B]              	mov	[PSP_CurrentOffset], si
   131 00000057 803C0D                  	cmp	byte [si], 0Dh		; "CR": No command line parameters
   132 0000005A 7737                    	ja	short Player_ParseNextParameter ; 01/01/2025
   133 0000005C E94603                  	jmp	pmsg_usage
   134                                  
   135                                  	; 30/12/2024
   136                                  	; 29/11/2024
   137                                  check_p_command:
   138 0000005F 803E[3D2B]50              	cmp	byte [command], 'P'
   139 00000064 740C                    	je	short Player_ParsePreviousParameter
   140                                      
   141 00000066 8B36[702B]              	mov	si, [PSP_CurrentOffset]
   142 0000006A 803C0D                  	cmp	byte [si], 0Dh
   143 0000006D 7724                    	ja	short Player_ParseNextParameter
   144                                  jmp_Player_Quit:
   145 0000006F E99B03                  	jmp	Player_Quit
   146                                  
   147                                  Player_ParsePreviousParameter:
   148                                  	; 29/11/2024
   149                                  	;mov	byte [command], 0
   150                                  
   151 00000072 8B36[702B]              	mov	si, [PSP_CurrentOffset]
   152                                  
   153 00000076 81FE8100                	cmp	si, 81h
   154 0000007A 7417                    	je	short Player_ParseNextParameter
   155                                  
   156                                  	;; Search for previous space character
   157 0000007C 4E                      	dec	si
   158 0000007D B90200                  	mov	cx, 2
   159                                  PSPParsePrev_Search:
   160 00000080 4E                      	dec	si
   161 00000081 8A04                    	mov	al, [si]
   162 00000083 3C20                    	cmp	al, 20h
   163 00000085 75F9                    	jne	short PSPParsePrev_Search
   164                                  
   165 00000087 81FE8100                	cmp	si, 81h
   166 0000008B 7602                    	jna	PSPParsePrev_Copy
   167 0000008D E2F1                    	loop	PSPParsePrev_Search
   168                                  
   169                                  PSPParsePrev_Copy:
   170 0000008F 8936[702B]              	mov	[PSP_CurrentOffset], si
   171                                  	
   172                                  Player_ParseNextParameter:
   173                                  	; 29/11/2024
   174 00000093 E82600                  	call	GetFileName
   175 00000096 E3D7                    	jcxz	jmp_Player_Quit
   176                                  
   177                                  	; 01/01/2025
   178                                  	; 28/11/2024
   179 00000098 BA[722B]                	mov	dx, wav_file_name
   180                                  
   181                                  	; 30/12/2024
   182                                          ; open existing file
   183 0000009B E81C05                          call	openFile ; no error? ok.
   184 0000009E 736C                            jnc	getwavparms	; 14/11/2024
   185                                  
   186                                  	; 29/11/2024
   187 000000A0 803E[3E2B]00            	cmp	byte [filecount], 0
   188 000000A5 77B8                    	ja	short check_p_command
   189                                  
   190                                  	; 25/12/2024
   191                                  	; 21/12/2024
   192 000000A7 E84E03                  	call	set_text_mode
   193                                  	; file not found!
   194                                  	; 01/01/2025
   195                                  	; 30/11/2024
   196                                  	sys_msg	noFileErrMsg, 0Ch
    37 000000AA BE[7623]            <1>  mov si, %1
    38 000000AD B30C                <1>  mov bl, %2
    39 000000AF 30FF                <1>  xor bh, bh
    40 000000B1 B40E                <1>  mov ah, 0Eh
    41 000000B3 E81603              <1>  call p_msg
   197 000000B6 E9E502                          jmp     Exit
   198                                  
   199                                  _exit_:
   200 000000B9 E9DF02                  	jmp	terminate
   201                                  
   202                                  ; -------------------------------------------------------------
   203                                  
   204                                  	; 29/11/2024
   205                                  	; 30/05/2024
   206                                  GetFileName:
   207 000000BC BF[722B]                	mov	di, wav_file_name 
   208 000000BF 8B36[702B]              	mov	si, [PSP_CurrentOffset]
   209 000000C3 31C9                    	xor	cx, cx ; 0
   210                                  ScanName:
   211 000000C5 AC                      	lodsb
   212                                  	;test	al, al
   213                                  	;jz	short a_4
   214                                  	; 29/11/2024
   215 000000C6 3C0D                    	cmp	al, 0Dh
   216 000000C8 7639                    	jna	short a_4
   217 000000CA 3C20                    	cmp	al, 20h
   218 000000CC 74F7                    	je	short ScanName	; scan start of name.
   219 000000CE AA                      	stosb
   220 000000CF B4FF                    	mov	ah, 0FFh
   221                                  	;;;
   222                                  	; 14/11/2024
   223                                  	; (max. path length = 64 bytes for MSDOS ?) (*)
   224                                  	;xor	cx, cx ; 0
   225                                  	;;;
   226                                  a_0:	
   227 000000D1 FEC4                    	inc	ah
   228                                  a_1:
   229                                  	;;;
   230                                  	; 14/11/2024
   231 000000D3 41                      	inc	cx
   232                                  	;;;
   233 000000D4 AC                      	lodsb
   234 000000D5 AA                      	stosb
   235 000000D6 3C2E                    	cmp	al, '.'
   236 000000D8 74F7                    	je	short a_0
   237                                  	; 29/11/2024
   238 000000DA 3C20                    	cmp	al, 20h
   239                                  	;and	al, al
   240                                  	;jnz	short a_1
   241                                  	;;;
   242                                  	; 14/11/2024
   243 000000DC 7613                    	jna	short a_3
   244 000000DE 20E4                    	and	ah, ah
   245 000000E0 7406                    	jz	short a_2
   246 000000E2 3C5C                    	cmp	al, '\'
   247 000000E4 7502                    	jne	short a_2
   248 000000E6 B400                    	mov	ah, 0
   249                                  a_2:
   250 000000E8 80F94B                  	cmp	cl, 75	; 64+8+'.'+3 -> offset 75 is the last chr
   251 000000EB 72E6                    	jb	short a_1
   252                                  	; 29/11/2024
   253 000000ED 29C9                    	sub	cx, cx
   254 000000EF EB12                    	jmp	short a_4
   255                                  a_3:
   256                                  	; 29/11/2024
   257 000000F1 4F                      	dec	di
   258                                  	;;;
   259 000000F2 08E4                    	or	ah, ah		; if period NOT found,
   260 000000F4 750D                    	jnz	short a_4 	; then add a .WAV extension.
   261                                  SetExt:
   262                                  	; 29/11/2024
   263                                  	;dec	di
   264 000000F6 66C7052E574156          	mov	dword [di], '.WAV' ; ! 64+12 is DOS limit
   265                                  				   ;   but writing +4 must not
   266                                  				   ;   destroy the following data	 
   267                                  	;mov	byte [di+4], 0	   ; so, 80 bytes path + 0 is possible here
   268                                  	; 29/11/2024
   269 000000FD 83C104                  	add	cx, 4
   270 00000100 83C704                  	add	di, 4
   271                                  a_4:	
   272 00000103 C60500                  	mov	byte [di], 0
   273 00000106 4E                      	dec	si
   274 00000107 8936[702B]              	mov	[PSP_CurrentOffset], si
   275 0000010B C3                      	retn
   276                                  
   277                                  ; -------------------------------------------------------------
   278                                  
   279                                  getwavparms:
   280                                  	; 14/11/2024
   281 0000010C E8CA04                         	call    getWAVParameters
   282 0000010F 72A8                    	jc	short _exit_		; nothing to do
   283                                  
   284                                  	; 17/11/2024
   285 00000111 B304                    	mov	bl, 4
   286 00000113 2A1E[602B]              	sub	bl, byte [WAVE_BlockAlign]
   287                                  			; = 0 for 16 bit stereo
   288                                  			; = 2 for 8 bit stereo or 16 bit mono
   289                                  			; = 3 for 8 bit mono	
   290                                  
   291 00000117 D0EB                    	shr	bl, 1	;  0 -->  0,  2 -->  1,  3 -->  1
   292                                  	; 15/11/2024
   293 00000119 80D300                  	adc	bl, 0	; 3 --> 1 --> 2
   294 0000011C 881E[C42B]              	mov	byte [fbs_shift], bl	; = 2 mono and 8 bit
   295                                  					; = 0 stereo and 16 bit
   296                                  					; = 1 mono or 8 bit
   297                                  	; 29/12/2024
   298                                  	; 30/05/2024
   299 00000120 E82106                  	call	codecConfig		; unmute codec, set rates.
   300 00000123 0F828F02                	jc	init_err
   301                                  
   302                                  ; -------------------------------------------------------------
   303                                  
   304                                  	; 01/01/2025
   305                                  StartPlay:
   306                                  	; 30/12/2024
   307 00000127 C606[372B]01            	mov	byte [wpoints], 1
   308                                  
   309                                  	; 01/01/2025 (RetroDOS, 16bit)
   310                                  	; 09/12/2024 (TRDOS386, 32bit)
   311 0000012C B83429                  	mov	ax, 10548 ; (48000*10/182)*4
   312 0000012F 803E[3C2B]00            	cmp	byte [VRA], 0
   313 00000134 760F                    	jna	short _w ; 48kHZ (interpolation)
   314                                  	;
   315 00000136 A1[582B]                	mov	ax, [WAVE_SampleRate]
   316 00000139 B90A00                  	mov	cx, 10
   317 0000013C F7E1                    	mul	cx
   318 0000013E B1B6                    	mov	cl, 182
   319 00000140 F7F1                    	div	cx
   320                                  	; ax = samples per 1/18.2 second
   321                                  	;mov	cl, byte [WAVE_BlockAlign]
   322                                  	; 09/12/2024 
   323                                  	;mov	cl, 4 ; 16 bit, stereo
   324                                  	;mul	cx
   325 00000142 C1E002                  	shl	ax, 2 ; * 4
   326                                  _w:
   327 00000145 A3[B028]                	mov	[wpoints_dif], ax ; buffer read differential (distance)
   328                                  				; for wave volume leds update
   329                                  				; (byte stream per 1/18.2 second)
   330                                  
   331                                  ; -------------------------------------------------------------
   332                                  
   333                                  	; 25/12/2024
   334 00000148 FE06[3E2B]              	inc	byte [filecount]
   335 0000014C C606[3D2B]00            	mov	byte [command], 0
   336                                  	; 30/12/2024
   337 00000151 C606[B328]FF            	mov	byte [pbprev], -1
   338                                  
   339                                  ; -------------------------------------------------------------
   340                                  
   341                                  	; 01/01/2025 (cgaplay.asm)
   342                                  	; 28/11/2024 (ac97play.asm)
   343                                  	; 25/11/2023
   344                                  	; 18/11/2023 (ich_wav4.asm)
   345                                  	; 13/11/2023 (ich_wav3.asm)
   346                                  
   347 00000156 803E[3C2B]01            	cmp	byte [VRA], 1
   348 0000015B 721A                    	jb	short chk_sample_rate
   349                                  
   350                                  playwav_48_khz:
   351 0000015D C706[D82B][BD09]        	mov	word [loadfromwavfile], loadFromFile
   352                                  	;mov	word [loadsize], 0 ; 65536
   353                                  	;;;
   354                                  	; 17/11/2024
   355                                  	;mov	word [buffersize], 32768
   356 00000163 B8F87F                  	mov	ax, BUFFERSIZE/2 ; 32760
   357 00000166 A3[DC2B]                	mov	[buffersize], ax	; 16 bit samples
   358 00000169 D1E0                    	shl	ax, 1			; bytes
   359 0000016B 8A0E[C42B]              	mov	cl, [fbs_shift]
   360 0000016F D3E8                    	shr	ax, cl
   361 00000171 A3[DA2B]                	mov	[loadsize], ax ; 16380 or 32760 or 65520
   362                                  	;;;
   363                                  	;jmp	PlayNow ; 30/05/2024
   364                                  	; 01/01/2025
   365 00000174 E9D801                  	jmp	Player_Template
   366                                  
   367                                  chk_sample_rate:
   368                                  	; set conversion parameters
   369                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   370 00000177 A1[582B]                	mov	ax, [WAVE_SampleRate]
   371 0000017A 3D80BB                  	cmp	ax, 48000
   372 0000017D 74DE                    	je	short playwav_48_khz
   373                                  chk_22khz:
   374 0000017F 3D2256                  	cmp	ax, 22050
   375 00000182 752F                    	jne	short chk_11khz
   376 00000184 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   377 00000189 760F                    	jna	short chk_22khz_1
   378 0000018B BB[5915]                	mov	bx, load_22khz_stereo_16_bit
   379 0000018E 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   380 00000193 7512                    	jne	short chk_22khz_2
   381 00000195 BB[ED14]                	mov	bx, load_22khz_mono_16_bit
   382 00000198 EB0D                    	jmp	short chk_22khz_2
   383                                  chk_22khz_1:
   384 0000019A BB[8514]                	mov	bx, load_22khz_stereo_8_bit
   385 0000019D 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   386 000001A2 7503                    	jne	short chk_22khz_2
   387 000001A4 BB[1914]                	mov	bx, load_22khz_mono_8_bit
   388                                  chk_22khz_2:
   389 000001A7 B85A1D                  	mov	ax, 7514  ; (442*17)
   390 000001AA BA2500                  	mov	dx, 37
   391 000001AD B91100                  	mov	cx, 17
   392 000001B0 E97701                  	jmp	set_sizes
   393                                  chk_11khz:
   394 000001B3 3D112B                  	cmp	ax, 11025
   395 000001B6 752F                    	jne	short chk_44khz
   396 000001B8 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   397 000001BD 760F                    	jna	short chk_11khz_1
   398 000001BF BB[F916]                	mov	bx, load_11khz_stereo_16_bit
   399 000001C2 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   400 000001C7 7512                    	jne	short chk_11khz_2
   401 000001C9 BB[9B16]                	mov	bx, load_11khz_mono_16_bit
   402 000001CC EB0D                    	jmp	short chk_11khz_2
   403                                  chk_11khz_1:
   404 000001CE BB[3D16]                	mov	bx, load_11khz_stereo_8_bit
   405 000001D1 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   406 000001D6 7503                    	jne	short chk_11khz_2
   407 000001D8 BB[DC15]                	mov	bx, load_11khz_mono_8_bit
   408                                  chk_11khz_2:
   409 000001DB B8AD0E                  	mov	ax, 3757  ; (221*17)
   410 000001DE BA4A00                  	mov	dx, 74
   411 000001E1 B91100                  	mov	cx, 17
   412 000001E4 E94301                  	jmp	set_sizes
   413                                  chk_44khz:
   414 000001E7 3D44AC                  	cmp	ax, 44100
   415 000001EA 752F                    	jne	short chk_16khz
   416 000001EC 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   417 000001F1 760F                    	jna	short chk_44khz_1
   418 000001F3 BB[B618]                	mov	bx, load_44khz_stereo_16_bit
   419 000001F6 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   420 000001FB 7512                    	jne	short chk_44khz_2
   421 000001FD BB[5B18]                	mov	bx, load_44khz_mono_16_bit
   422 00000200 EB0D                    	jmp	short chk_44khz_2
   423                                  chk_44khz_1:
   424 00000202 BB[FA17]                	mov	bx, load_44khz_stereo_8_bit
   425 00000205 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   426 0000020A 7503                    	jne	short chk_44khz_2
   427 0000020C BB[9A17]                	mov	bx, load_44khz_mono_8_bit
   428                                  chk_44khz_2:
   429                                  	;mov	ax, 15065 ; (655*23)
   430                                  	; 18/11/2023 ((file size + bss + stack) <= 64KB)
   431                                  	;mov	ax, 14076 ; (612*23)
   432                                  	; 17/11/2024
   433 0000020F B86A31                  	mov	ax, 12650 ; (550*23)
   434 00000212 BA1900                  	mov	dx, 25
   435 00000215 B91700                  	mov	cx, 23
   436 00000218 E90F01                  	jmp	set_sizes
   437                                  chk_16khz:
   438 0000021B 3D803E                  	cmp	ax, 16000
   439 0000021E 752F                    	jne	short chk_8khz
   440 00000220 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   441 00000225 760F                    	jna	short chk_16khz_1
   442 00000227 BB[7910]                	mov	bx, load_16khz_stereo_16_bit
   443 0000022A 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   444 0000022F 7512                    	jne	short chk_16khz_2
   445 00000231 BB[1510]                	mov	bx, load_16khz_mono_16_bit
   446 00000234 EB0D                    	jmp	short chk_16khz_2
   447                                  chk_16khz_1:
   448 00000236 BB[820F]                	mov	bx, load_16khz_stereo_8_bit
   449 00000239 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   450 0000023E 7503                    	jne	short chk_16khz_2
   451 00000240 BB[1B0F]                	mov	bx, load_16khz_mono_8_bit
   452                                  chk_16khz_2:
   453                                  	;mov	ax, 5461
   454                                  	; 17/11/2024
   455 00000243 B85415                  	mov	ax, 5460
   456 00000246 BA0300                  	mov	dx, 3
   457 00000249 B90100                  	mov	cx, 1
   458 0000024C E9DB00                  	jmp	set_sizes
   459                                  chk_8khz:
   460 0000024F 3D401F                  	cmp	ax, 8000
   461 00000252 752F                    	jne	short chk_24khz
   462 00000254 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   463 00000259 760F                    	jna	short chk_8khz_1
   464 0000025B BB[310E]                	mov	bx, load_8khz_stereo_16_bit
   465 0000025E 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   466 00000263 7512                    	jne	short chk_8khz_2
   467 00000265 BB[9D0D]                	mov	bx, load_8khz_mono_16_bit
   468 00000268 EB0D                    	jmp	short chk_8khz_2
   469                                  chk_8khz_1:
   470 0000026A BB[AA0C]                	mov	bx, load_8khz_stereo_8_bit
   471 0000026D 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   472 00000272 7503                    	jne	short chk_8khz_2
   473 00000274 BB[F40B]                	mov	bx, load_8khz_mono_8_bit
   474                                  chk_8khz_2:
   475 00000277 B8AA0A                  	mov	ax, 2730
   476 0000027A BA0600                  	mov	dx, 6
   477 0000027D B90100                  	mov	cx, 1
   478 00000280 E9A700                  	jmp	set_sizes  ; 02/02/2025
   479                                  chk_24khz:
   480 00000283 3DC05D                  	cmp	ax, 24000
   481 00000286 752E                    	jne	short chk_32khz
   482 00000288 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   483 0000028D 760F                    	jna	short chk_24khz_1
   484 0000028F BB[1D12]                	mov	bx, load_24khz_stereo_16_bit
   485 00000292 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   486 00000297 7512                    	jne	short chk_24khz_2
   487 00000299 BB[CE11]                	mov	bx, load_24khz_mono_16_bit
   488 0000029C EB0D                    	jmp	short chk_24khz_2
   489                                  chk_24khz_1:
   490 0000029E BB[6311]                	mov	bx, load_24khz_stereo_8_bit
   491 000002A1 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   492 000002A6 7503                    	jne	short chk_24khz_2
   493 000002A8 BB[1111]                	mov	bx, load_24khz_mono_8_bit
   494                                  chk_24khz_2:
   495                                  	;mov	ax, 8192
   496                                  	; 17/11/2024
   497 000002AB B8FE1F                  	mov	ax, 8190
   498 000002AE BA0200                  	mov	dx, 2
   499 000002B1 B90100                  	mov	cx, 1
   500 000002B4 EB74                    	jmp	short set_sizes
   501                                  
   502                                  chk_32khz:
   503 000002B6 3D007D                  	cmp	ax, 32000
   504                                  	;jne	short vra_needed
   505                                  	; 02/02/2025
   506 000002B9 753E                    	jne	short chk_12khz
   507 000002BB 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   508 000002C0 760F                    	jna	short chk_32khz_1
   509 000002C2 BB[AE13]                	mov	bx, load_32khz_stereo_16_bit
   510 000002C5 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   511 000002CA 7512                    	jne	short chk_32khz_2
   512 000002CC BB[5B13]                	mov	bx, load_32khz_mono_16_bit
   513 000002CF EB0D                    	jmp	short chk_32khz_2
   514                                  chk_32khz_1:
   515 000002D1 BB[E112]                	mov	bx, load_32khz_stereo_8_bit
   516 000002D4 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   517 000002D9 7503                    	jne	short chk_32khz_2
   518 000002DB BB[8612]                	mov	bx, load_32khz_mono_8_bit
   519                                  chk_32khz_2:
   520                                  	;mov	ax, 10922
   521                                  	; 17/11/2024
   522 000002DE B8A82A                  	mov	ax, 10920
   523 000002E1 BA0300                  	mov	dx, 3
   524 000002E4 B90200                  	mov	cx, 2
   525                                  	; 02/02/2025
   526 000002E7 EB41                    	jmp	short set_sizes
   527                                  
   528                                  	; 01/01/2025 (cgaplay.asm)
   529                                  vra_needed:
   530                                  	; 13/11/2023
   531 000002E9 58                      	pop	ax ; discard return address to the caller
   532                                  	; 30/05/2024
   533                                  vra_err:
   534                                  	sys_msg msg_no_vra, 0Fh
    37 000002EA BE[C023]            <1>  mov si, %1
    38 000002ED B30F                <1>  mov bl, %2
    39 000002EF 30FF                <1>  xor bh, bh
    40 000002F1 B40E                <1>  mov ah, 0Eh
    41 000002F3 E8D600              <1>  call p_msg
   535 000002F6 E9A500                  	jmp	Exit
   536                                  
   537                                  	;;;;
   538                                  	; 02/02/2025
   539                                  chk_12khz:
   540 000002F9 3DE02E                  	cmp	ax, 12000
   541 000002FC 75EB                    	jne	short vra_needed
   542 000002FE 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8
   543 00000303 760F                    	jna	short chk_12khz_1
   544 00000305 BB[D619]                	mov	bx, load_12khz_stereo_16_bit
   545 00000308 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   546 0000030D 7512                    	jne	short chk_12khz_2
   547 0000030F BB[9719]                	mov	bx, load_12khz_mono_16_bit
   548 00000312 EB0D                    	jmp	short chk_12khz_2
   549                                  chk_12khz_1:
   550 00000314 BB[5419]                	mov	bx, load_12khz_stereo_8_bit
   551 00000317 803E[562B]01            	cmp	byte [WAVE_NumChannels], 1
   552 0000031C 7503                    	jne	short chk_12khz_2
   553 0000031E BB[1919]                	mov	bx, load_12khz_mono_8_bit
   554                                  chk_12khz_2:
   555                                  	;mov	ax, 4096
   556 00000321 B8FF0F                  	mov	ax, 4095 ; playwav8.asm
   557 00000324 BA0400                  	mov	dx, 4
   558 00000327 B90100                  	mov	cx, 1
   559                                  	; 02/02/2025
   560                                  	;jmp	short set_sizes
   561                                  	;;;;
   562                                  
   563                                  set_sizes:
   564                                  	;;;
   565                                  	; 17/11/2024
   566 0000032A 51                      	push	cx
   567 0000032B B102                    	mov	cl, 2
   568 0000032D 2A0E[C42B]              	sub	cl, [fbs_shift]
   569                                  		; = 2 for 16 bit stereo
   570                                  		; = 1 for 16 bit mono or 8 bit stereo
   571                                  		; = 0 for 8 bit mono
   572 00000331 D3E0                    	shl	ax, cl
   573 00000333 59                      	pop	cx
   574 00000334 A3[DA2B]                	mov	[loadsize], ax	; (one) read count in bytes
   575                                  	;;;
   576 00000337 F7E2                    	mul	dx
   577 00000339 83F901                  	cmp	cx, 1
   578 0000033C 7402                    	je	short s_2
   579                                  s_1:
   580 0000033E F7F1                    	div	cx
   581                                  s_2:	
   582                                  	;;;
   583                                  	; ax = byte count of (to be) converted samples 
   584                                  	
   585                                  	; 17/11/2024
   586                                  	;;;
   587 00000340 8A0E[C42B]              	mov	cl, [fbs_shift]
   588                                  
   589 00000344 D3E0                    	shl	ax, cl
   590                                  		; *1 for 16 bit stereo
   591                                  		; *2 for 16 bit mono or 8 bit stereo
   592                                  		; *4 for for 8 bit mono
   593                                  	;;;
   594                                  
   595                                  	; ax = 16 bit stereo byte count (target buffer size)
   596                                  	
   597 00000346 D1E8                    	shr	ax, 1	; buffer size is 16 bit sample count
   598 00000348 A3[DC2B]                	mov	[buffersize], ax 
   599 0000034B 891E[D82B]              	mov	[loadfromwavfile], bx
   600                                  	
   601                                  	; 01/01/2025 (cgaplay.asm)
   602                                  ; -------------------------------------------------------------
   603                                  	; 30/12/2024
   604                                  Player_Template:
   605                                  	; 21/12/2024
   606 0000034F E88400                  	call	clearscreen
   607 00000352 E89200                  	call	drawplayingscreen
   608                                  	; 14/11/2024
   609 00000355 E8F31C                  	call	SetTotalTime
   610 00000358 E8931D                  	call	UpdateFileInfo
   611                                  
   612                                  ; -------------------------------------------------------------
   613                                  
   614                                  	; 30/12/2024 (cgaplay.s)
   615                                  	; 29/12/2024 (vgaplay3.s)
   616                                  	; 18/12/2024 (ac97play.s)
   617                                  PlayNow:
   618                                  	; 01/12/2024 (32bit)
   619                                  	; 14/11/2024
   620                                  	;mov	al, 3	; 0 = max, 31 = min
   621                                  	; 14/12/2024
   622 0000035B A0[4320]                	mov	al, [volume]
   623 0000035E E81302                  	call	SetPCMOutVolume@
   624                                  	; 15/11/2024
   625                                  	;;call	SetMasterVolume
   626                                  	;call	SetPCMOutVolume
   627                                  
   628                                  	;;;
   629                                  	; 14/11/2024
   630 00000361 E8121E                  	call	UpdateProgressBar
   631                                  	;;;
   632                                  
   633                                   	; 30/05/2024
   634                                  	; playwav4.asm
   635                                  _2:	
   636 00000364 E8841C                  	call	check4keyboardstop	; flush keyboard buffer
   637 00000367 72FB                    	jc	short _2		; 07/11/2023
   638                                  
   639                                  	; 01/01/2025 (cgaplay.asm)
   640                                  
   641                                  ; play the .wav file. Most of the good stuff is in here.
   642                                  
   643 00000369 E8A300                  	call    PlayWav
   644                                  
   645                                  	; 30/12/2024
   646                                  	; 29/12/2024 (vgaplay3.s)
   647                                  	; 27/12/2024 (vgaplay.s)
   648                                  _3:
   649                                  
   650                                  ; close the .wav file and exit.
   651                                  
   652                                  	; 25/12/2024
   653 0000036C E85902                  	call	closeFile
   654                                  
   655                                  	; 01/01/2025 (16bit modifications)
   656                                  	; 25/12/2024
   657                                  	;;;
   658                                  	; reset file loading and EOF parameters
   659                                  	; 18/12/2024
   660 0000036F C706[E42B]0000          	mov	word [count], 0
   661                                  	;mov	dword [LoadedDataBytes], 0
   662 00000375 C706[E62B]0000          	mov	word [LoadedDataBytes], 0
   663 0000037B C706[E82B]0000          	mov	word [LoadedDataBytes+2], 0
   664 00000381 C606[6C2B]00            	mov	byte [flags], 0
   665 00000386 C606[342B]00            	mov	byte [stopped], 0
   666                                  	; 29/12/2024
   667 0000038B C706[3A2B]0000          	mov	word [pbuf_s], 0
   668                                  	;;;
   669                                  
   670 00000391 803E[3D2B]51            	cmp	byte [command], 'Q'
   671 00000396 7403                    	je	short terminate
   672 00000398 E9C4FC                  	jmp	check_p_command
   673                                  
   674                                  terminate:
   675 0000039B E85A00                  	call	set_text_mode
   676                                  	
   677                                  Exit:	; 01/01/2025
   678 0000039E B8004C                  	mov	ax, 4C00h	; bye !
   679 000003A1 CD21                    	int	21h
   680                                  halt:
   681 000003A3 EBFE                    	jmp	short halt
   682                                  
   683                                  ; -------------------------------------------------------------
   684                                  
   685                                  	; 30/05/2024
   686                                  pmsg_usage:
   687                                  	; 21/12/2024
   688 000003A5 E85000                  	call	set_text_mode
   689                                  	; 01/01/2025
   690                                  	; 01/12/2024
   691                                  	sys_msg msg_usage, 0Fh
    37 000003A8 BE[1C23]            <1>  mov si, %1
    38 000003AB B30F                <1>  mov bl, %2
    39 000003AD 30FF                <1>  xor bh, bh
    40 000003AF B40E                <1>  mov ah, 0Eh
    41 000003B1 E81800              <1>  call p_msg
   692 000003B4 EBE8                    	jmp	short Exit
   693                                  
   694                                  ; -------------------------------------------------------------
   695                                  
   696                                  	; 30/05/2024
   697                                  init_err:
   698                                  	; 21/12/2024
   699 000003B6 E83F00                  	call	set_text_mode
   700                                  	; 01/01/2025
   701                                  	; 01/12/2024
   702                                  	sys_msg msg_init_err, 0Fh
    37 000003B9 BE[8F23]            <1>  mov si, %1
    38 000003BC B30F                <1>  mov bl, %2
    39 000003BE 30FF                <1>  xor bh, bh
    40 000003C0 B40E                <1>  mov ah, 0Eh
    41 000003C2 E80700              <1>  call p_msg
   703 000003C5 EBD7                    	jmp	short Exit
   704                                  
   705                                  ; -------------------------------------------------------------
   706                                  
   707                                  	; 01/01/2025 (cgaplay.asm)
   708                                  	; 21/12/2024
   709                                  	; 14/11/2024
   710                                  PrintString:
   711 000003C7 B40E                    	mov	ah, 0Eh
   712 000003C9 BB0F00                  	mov	bx, 0Fh ; char attribute & color (white)
   713                                  p_msg:
   714                                  	; ah = 0Eh
   715                                  	; bh = 0
   716                                  	; bl = color
   717                                  	; ds:si = msg address
   718                                  p_next_chr:
   719 000003CC AC                      	lodsb
   720 000003CD 08C0                    	or	al, al
   721 000003CF 7404                    	jz	short p_retn ; retn
   722 000003D1 CD10                    	int	10h
   723 000003D3 EBF7                    	jmp	short p_next_chr
   724                                  p_retn:
   725 000003D5 C3                      	retn
   726                                  
   727                                  ; -------------------------------------------------------------
   728                                  
   729                                  	; 01/01/2025 (cgaplay.asm)
   730                                  clearscreen:
   731                                  	; fast clear
   732                                  	; 320*200, 256 colors
   733 000003D6 06                      	push	es
   734 000003D7 BF00A0                  	mov	di, 0A000h
   735 000003DA 8EC7                    	mov	es, di
   736 000003DC 31FF                    	xor	di, di
   737 000003DE B9007D                  	mov	cx, 320*200*1/2
   738 000003E1 31C0                    	xor	ax, ax
   739 000003E3 F3AB                    	rep	stosw
   740 000003E5 07                      	pop	es
   741 000003E6 C3                      	retn
   742                                  
   743                                  ; -------------------------------------------------------------
   744                                  
   745                                  	; 01/01/2025v (cgaplay.asm)
   746                                  drawplayingscreen:
   747                                  	;push	es
   748                                  	;push	bp
   749                                  	;push	ds
   750                                  	;pop	es
   751                                  	; es = ds
   752 000003E7 BD[E824]                	mov	bp, PlayingScreen
   753 000003EA B80013                  	mov	ax, 1300h ; write character string
   754 000003ED BB0F00                  	mov	bx, 0Fh
   755 000003F0 B9C003                  	mov	cx, 24*40
   756 000003F3 31D2                    	xor	dx, dx ; row 0, columns 0
   757 000003F5 CD10                    	int	10h
   758                                  	;pop	bp
   759                                  	;pop	es
   760 000003F7 C3                      	retn
   761                                  
   762                                  ; -------------------------------------------------------------
   763                                  
   764                                  	; 01/01/2025
   765                                  set_text_mode:
   766 000003F8 B80300                  	mov	ax, 03h
   767 000003FB CD10                    	int	10h
   768                                  	;retn
   769                                  
   770                                  	sys_msg Credits, 0Bh
    37 000003FD BE[A822]            <1>  mov si, %1
    38 00000400 B30B                <1>  mov bl, %2
    39 00000402 30FF                <1>  xor bh, bh
    40 00000404 B40E                <1>  mov ah, 0Eh
    41 00000406 E8C3FF              <1>  call p_msg
   771                                  	;call	write_audio_dev_info
   772                                  	;retn
   773 00000409 E94F06                  	jmp	write_audio_dev_info
   774                                  
   775                                  ; -------------------------------------------------------------
   776                                  
   777                                  	; 01/01/2025 (16bit pop)
   778                                  	; 02/12/2024
   779                                  Player_Quit@:
   780 0000040C 58                      	pop	ax ; return addr (call PlayWav@)
   781                                  	
   782                                  	; 29/11/2024
   783                                  Player_Quit:
   784 0000040D EB8C                    	jmp	 terminate
   785                                  
   786                                  ; -------------------------------------------------------------
   787                                  
   788                                  	; 01/01/2025 (cgaplay.asm)
   789                                  	; 18/12/2024 (ac97play.asm)
   790                                  	; 30/12/2024 (cgaplay.s)
   791                                  	; 29/12/2024 (vgaplay3.s)
   792                                  	; 02/12/2024 (ac97play.s)
   793                                  PlayWav:
   794                                  	; 29/05/2024 (TRDOS 386, playwav7.s)
   795                                  	; ((Modified from playwav4.asm, ich_wav4.asm))
   796                                  	; ------------------
   797                                  
   798                                  	; create Buffer Descriptor List
   799                                  
   800                                  	;  Generic Form of Buffer Descriptor
   801                                  	;  ---------------------------------
   802                                  	;  63   62    61-48    47-32   31-0
   803                                  	;  ---  ---  --------  ------- -----
   804                                  	;  IOC  BUP -reserved- Buffer  Buffer
   805                                  	;		      Length   Pointer
   806                                  	;		      [15:0]   [31:0]
   807                                  
   808 0000040F 06                              push    es
   809 00000410 A1[D22B]                        mov     ax, [BDL_BUFFER]		; get segment # for BDL
   810 00000413 8EC0                            mov     es, ax
   811                                  
   812 00000415 B91000                          mov     cx, 32 / 2                      ; make 32 entries in BDL
   813 00000418 31FF                            xor     di, di
   814                                  _pw0:
   815 0000041A 660FB706[D42B]                  movzx   eax, word [WAV_BUFFER1]
   816 00000420 66C1E004                        shl     eax, 4                          ; convert seg:off ->0:offset
   817 00000424 66AB                            stosd		       ; store pointer to wavbuffer1
   818                                  
   819                                  	;mov	eax, BUFFERSIZE / 2 ; size of buffer (32K) in (16bit) words
   820                                  	; 13/11/2023 (ich_wav3.asm) - 18/11/2023 (ich_wav4.asm)
   821 00000426 66A1[DC2B]              	mov	eax, [buffersize]
   822                                  
   823                                  	;or	eax, IOC + BUP
   824                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
   825 0000042A 660D00000040            	or	eax, BUP
   826 00000430 66AB                    	stosd
   827                                  
   828 00000432 660FB706[D62B]                  movzx   eax, word [WAV_BUFFER2]
   829 00000438 66C1E004                        shl     eax, 4                          ; convert seg:off ->0:offset
   830 0000043C 66AB                            stosd		       ; store pointer to wavbuffer2
   831                                  
   832                                  	;mov	eax, BUFFERSIZE / 2 ; size of half buffer (32K)
   833                                  	; 13/11/2023 (ich_wav3.asm) - 18/11/2023 (ich_wav4.asm)
   834 0000043E 66A1[DC2B]              	mov	eax, [buffersize]
   835                                  
   836                                  	;or	eax, IOC + BUP
   837                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
   838 00000442 660D00000040            	or	eax, BUP
   839 00000448 66AB                    	stosd
   840                                  
   841 0000044A E2CE                            loop    _pw0
   842 0000044C 07                              pop     es
   843                                  
   844                                  	; 18/12/2024
   845                                  	;mov	word [count], cx ; 0
   846                                  	; 14/11/2024
   847                                  	;mov	dword [LoadedDataBytes], 0
   848                                  
   849                                  	; 19/11/2024
   850                                  RePlayWav:
   851                                  	; load 64k into buffer 1
   852 0000044D A1[D42B]                        mov     ax, [WAV_BUFFER1]
   853                                          ;call	loadFromFile
   854                                  	; 13/11/2023
   855 00000450 FF16[D82B]              	call	word [loadfromwavfile]
   856                                  	; 14/11/2024
   857 00000454 A1[E42B]                	mov	ax, [count]
   858 00000457 0106[E62B]              	add	[LoadedDataBytes], ax
   859 0000045B 8316[E82B]00            	adc	word [LoadedDataBytes+2], 0
   860                                  
   861                                  	; and 64k into buffer 2
   862 00000460 A1[D62B]                	mov     ax, [WAV_BUFFER2]
   863                                         	;call	loadFromFile
   864                                  	; 13/11/2023
   865 00000463 FF16[D82B]              	call	word [loadfromwavfile]
   866                                  	; 14/11/2024
   867 00000467 A1[E42B]                	mov	ax, [count]
   868 0000046A 0106[E62B]              	add	[LoadedDataBytes], ax
   869 0000046E 8316[E82B]00            	adc	word [LoadedDataBytes+2], 0
   870                                  
   871                                  	; write NABMBAR+10h with offset of buffer descriptor list
   872                                  
   873 00000473 660FB706[D22B]                  movzx   eax, word [BDL_BUFFER]
   874 00000479 66C1E004                	shl     eax, 4                          ; convert seg:off to 0:off
   875 0000047D 8B16[D02B]                      mov     dx, [NABMBAR]
   876 00000481 83C210                          add     dx, PO_BDBAR_REG                ; set pointer to BDL
   877 00000484 66EF                            out     dx, eax                         ; write to AC97 controller
   878                                  
   879                                  	; 19/05/2024
   880 00000486 E8D604                  	call	delay1_4ms
   881                                  
   882 00000489 B01F                            mov	al, 31
   883 0000048B E82605                  	call	setLastValidIndex
   884                                  
   885                                  	; 19/05/2024
   886                                  	;call	delay1_4ms
   887                                  
   888                                  	; 17/02/2017
   889 0000048E 8B16[D02B]                      mov	dx, [NABMBAR]
   890 00000492 83C21B                          add	dx, PO_CR_REG		; PCM out Control Register
   891                                          ;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
   892                                  	;			; (LVBI interrupt will not be enabled)
   893                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
   894 00000495 B001                    	mov	al, RPBM
   895 00000497 EE                      	out	dx, al			; Start bus master operation.
   896                                  
   897                                  	; 19/05/2024
   898                                  	; 06/11/2023
   899 00000498 E8C404                  	call	delay1_4ms	; 30/05/2024
   900                                  	;call	delay1_4ms
   901                                  	;call	delay1_4ms
   902                                  	;call	delay1_4ms
   903                                  
   904                                  	; 30/12/2024
   905                                  
   906                                  ; -------------------------------------------
   907                                  
   908                                  	; 01/01/2025 (cgaplay.asm)
   909                                  	; 18/12/2024 (ac97play.asm)
   910                                  	; 30/12/2024 (cgaplay.s)
   911                                  	; 29/12/2024 (vgaplay3.s)
   912                                  	; 18/12/2024 (ac97play.s)
   913                                  	; 01/12/2024 (32bit)
   914                                  	; 29/11/2024
   915                                  tuneLoop:
   916                                  	; 30/05/2024
   917                                  	; 18/11/2023 (ich_wav4.asm)
   918                                  	; 08/11/2023
   919                                  	; 06/11/2023
   920                                  tLWait:
   921                                  	; 18/11/2024
   922 0000049B 803E[342B]00            	cmp	byte [stopped], 0
   923                                  	;jna	short tL@
   924                                  	; 21/11/2024
   925 000004A0 7710                    	ja	short tLWait@
   926 000004A2 A0[362B]                	mov	al, [tLP]
   927 000004A5 3C31                    	cmp	al, '1'
   928 000004A7 743C                    	je	short tL1@
   929 000004A9 7772                    	ja	short tL2@
   930 000004AB B031                    	mov	al, '1'
   931 000004AD A2[362B]                	mov	[tLP], al
   932 000004B0 EB33                    	jmp	short tL1@ 
   933                                  tLWait@:	; 21/11/2024
   934                                  	;;;
   935                                  	; 09/12/2024
   936 000004B2 803E[342B]03            	cmp	byte [stopped], 3
   937 000004B7 0F839F00                	jnb	_exitt_
   938                                  	;;;
   939 000004BB E8AC19                  	call	checkUpdateEvents
   940 000004BE 0F829800                	jc	_exitt_
   941                                  	;;;
   942                                  	; 29/11/2024
   943 000004C2 803E[3D2B]4E            	cmp	byte [command], 'N'
   944 000004C7 0F848F00                	je	_exitt_
   945 000004CB 803E[3D2B]50            	cmp	byte [command], 'P'
   946 000004D0 0F848600                	je	_exitt_
   947                                  	;;;
   948 000004D4 803E[352B]30            	cmp	byte [tLO], '0'
   949 000004D9 74C0                    	je	short tLWait
   950 000004DB E88200                  	call	tLZ
   951 000004DE C606[352B]30            	mov	byte [tLO], '0'
   952 000004E3 EBB6                    	jmp	short tLWait
   953                                  
   954                                  ;tLO:	db 0
   955                                  	
   956                                  tL1@:
   957                                  	;mov	al, '1'
   958                                  	; 19/11/2024
   959 000004E5 A2[352B]                	mov	[tLO], al
   960 000004E8 E87700                  	call	tL0
   961                                  tL1:
   962 000004EB E89B04                  	call	updateLVI	; /set LVI != CIV/
   963 000004EE 746A                    	jz	_exitt_		; 08/11/2023
   964                                  	;;;
   965                                  	;call	check4keyboardstop
   966                                  	; 14/11/2024
   967 000004F0 E87719                  	call	checkUpdateEvents
   968 000004F3 7265                    	jc	_exitt_
   969                                  	; 18/11/2024
   970 000004F5 803E[342B]00            	cmp	byte [stopped], 0
   971 000004FA 77B6                    	ja	short tLWait@	; 21/11/2024
   972                                  	;;;
   973 000004FC E88104                  	call	getCurrentIndex
   974 000004FF A801                    	test	al, BIT0
   975 00000501 74E8                    	jz	short tL1	; loop if buffer 2 is not playing
   976                                  
   977                                  	; load buffer 1
   978 00000503 A1[D42B]                	mov     ax, [WAV_BUFFER1]
   979                                  	;call	loadFromFile
   980                                  	; 18/11/2023
   981 00000506 FF16[D82B]              	call	word [loadfromwavfile]
   982 0000050A 724E                    	jc	short _exitt_	; end of file
   983                                  
   984                                  	; 14/11/2024
   985 0000050C A1[E42B]                	mov	ax, [count]
   986 0000050F 0106[E62B]              	add	[LoadedDataBytes], ax
   987 00000513 8316[E82B]00            	adc	word [LoadedDataBytes+2], 0
   988                                  
   989 00000518 B032                    	mov	al, '2'
   990                                  	; 21/11/2024
   991 0000051A A2[362B]                	mov	[tLP], al
   992                                  tL2@:
   993                                  	; 19/11/2024
   994 0000051D A2[352B]                	mov	[tLO], al
   995 00000520 E83F00                  	call	tL0
   996                                  tL2:
   997 00000523 E86304                  	call    updateLVI
   998 00000526 7432                    	jz	short _exitt_	; 08/11/2023
   999                                  	;;;
  1000                                  	;call	check4keyboardstop
  1001                                  	; 14/11/2024
  1002 00000528 E83F19                  	call	checkUpdateEvents
  1003 0000052B 722D                    	jc	short _exitt_
  1004                                  	; 18/11/2024
  1005 0000052D 803E[342B]00            	cmp	byte [stopped], 0
  1006 00000532 0F877CFF                	ja	tLWait@		; 21/11/2024 
  1007                                  	;;;
  1008 00000536 E84704                  	call    getCurrentIndex
  1009 00000539 A801                    	test	al, BIT0
  1010 0000053B 75E6                    	jnz	short tL2	; loop if buffer 1 is not playing
  1011                                  
  1012                                  	; load buffer 2
  1013 0000053D A1[D62B]                	mov     ax, [WAV_BUFFER2]
  1014                                  	;call	loadFromFile
  1015                                  	; 18/11/2023
  1016 00000540 FF16[D82B]              	call	word [loadfromwavfile]
  1017                                  	;jnc	short tuneLoop
  1018 00000544 7214                    	jc	short _exitt_
  1019                                  
  1020                                  	; 14/11/2024
  1021 00000546 A1[E42B]                	mov	ax, [count]
  1022 00000549 0106[E62B]              	add	[LoadedDataBytes], ax
  1023 0000054D 8316[E82B]00            	adc	word [LoadedDataBytes+2], 0
  1024                                  
  1025                                  	; 21/11/2024
  1026 00000552 C606[362B]31            	mov	byte [tLP], '1'
  1027 00000557 E941FF                  	jmp	tuneLoop
  1028                                  
  1029                                  	; 29/12/2024 (vgaplay3.s)
  1030                                  _exitt_:
  1031                                  	; 07/12/2024
  1032                                  	; Stop Playing
  1033 0000055A E8D703                  	call	ac97_stop
  1034                                  
  1035                                  	;;;
  1036                                  	; 14/11/2024
  1037 0000055D E8161C                  	call	UpdateProgressBar
  1038                                  	;;;
  1039                                  
  1040                                  	; 18/11/2024
  1041                                  tLZ:
  1042                                  	; 30/05/2024
  1043 00000560 B030                    	mov	al, '0'
  1044                                  tL0:
  1045                                  	; 01/01/2025 (cgaplay.asm)
  1046                                  	; 31/12/2024
  1047 00000562 50                      	push	ax
  1048 00000563 31D2                    	xor	dx, dx ; row 0, column 0
  1049 00000565 E8DC1A                  	call	setCursorPosition
  1050 00000568 58                      	pop	ax
  1051                                  	;
  1052 00000569 B40E                    	mov	ah, 0Eh
  1053 0000056B BB0E00                  	mov	bx, 0Eh
  1054 0000056E CD10                    	int	10h
  1055                                  	
  1056 00000570 C3                      	retn
  1057                                  
  1058                                  ; -------------------------------------------
  1059                                  
  1060                                  	; 14/11/2024
  1061                                  ;SetMasterVolume:
  1062                                  	; 15/11/2024
  1063                                  SetPCMOutVolume:
  1064                                  	;cmp	al, 31
  1065                                  	;ja	short setvolume_ok
  1066 00000571 A2[4320]                	mov	[volume], al  ; max = 0, min = 31
  1067                                  SetPCMOutVolume@:	; 19/11/2024
  1068 00000574 88C4                    	mov	ah, al
  1069 00000576 8B16[CE2B]              	mov	dx, [NAMBAR]
  1070                                  	; 15/11/2024 (QEMU)
  1071                                    	;add	dx, CODEC_MASTER_VOL_REG
  1072 0000057A 83C218                  	add	dx, CODEC_PCM_OUT_REG
  1073 0000057D EF                      	out	dx, ax
  1074                                  ;setvolume_ok:
  1075 0000057E C3                      	retn
  1076                                  
  1077                                  ; -------------------------------------------
  1078                                  
  1079                                  	; 30/05/2024
  1080                                  DetectAC97:
  1081                                  DetectICH:
  1082                                  	; 22/11/2023
  1083                                  	; 19/11/2023
  1084                                  	; 01/11/2023 - TRDOS 386 Kernel v2.0.7
  1085                                  	;; 10/06/2017
  1086                                  	;; 05/06/2017
  1087                                  	;; 29/05/2017
  1088                                  	;; 28/05/2017
  1089                                  
  1090                                  	; 19/11/2023
  1091 0000057F BE[5022]                	mov	si, valid_ids	; address of Valid ICH (AC97) Device IDs
  1092 00000582 B91500                  	mov	cx, valid_id_count
  1093                                  pfd_1:
  1094 00000585 66AD                    	lodsd
  1095 00000587 E89400                  	call	pciFindDevice
  1096 0000058A 7303                    	jnc	short d_ac97_1
  1097 0000058C E2F7                    	loop	pfd_1
  1098                                  
  1099                                  	;stc
  1100 0000058E C3                      	retn
  1101                                  
  1102                                  d_ac97_1:
  1103                                  	; eax = BUS/DEV/FN
  1104                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1105                                  	; edx = DEV/VENDOR
  1106                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1107                                  
  1108                                  	; playwav4.asm - 19/05/2024
  1109                                  
  1110 0000058F 66A3[C62B]              	mov	[bus_dev_fn], eax
  1111 00000593 668916[CA2B]            	mov	[dev_vendor], edx
  1112                                  
  1113                                  	; get ICH base address regs for mixer and bus master
  1114                                  
  1115 00000598 B010                            mov     al, NAMBAR_REG
  1116 0000059A E80F01                          call    pciRegRead16			; read PCI registers 10-11
  1117                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
  1118                                  	; 19/05/2024
  1119 0000059D 80E2FE                  	and	dl, 0FEh
  1120                                  
  1121 000005A0 8916[CE2B]                      mov     [NAMBAR], dx			; save audio mixer base addr
  1122                                  
  1123 000005A4 B014                    	mov     al, NABMBAR_REG
  1124 000005A6 E80301                          call    pciRegRead16
  1125                                          ;and    dx, IO_ADDR_MASK
  1126                                  	; 19/05/2024
  1127 000005A9 80E2C0                  	and	dl, 0C0h
  1128                                  
  1129 000005AC 8916[D02B]                      mov     [NABMBAR], dx			; save bus master base addr
  1130                                  
  1131 000005B0 B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
  1132 000005B2 E8EF00                  	call	pciRegRead8 ; 17/02/2017
  1133                                  
  1134 000005B5 8816[6D2B]              	mov	[ac97_int_ln_reg], dl
  1135                                  
  1136                                  	;clc
  1137                                  
  1138 000005B9 C3                      	retn
  1139                                  
  1140                                  ; ----------------------------------
  1141                                  
  1142                                  	; 14/11/2024
  1143                                  	; INPUT: ds:dx = file name address
  1144                                  	; OUTPUT: [filehandle] = ; -1 = not open
  1145                                  openFile:
  1146 000005BA B8003D                  	mov	ax, 3D00h	; open File for read
  1147 000005BD CD21                    	int	21h
  1148 000005BF 7303                    	jnc	short _of1
  1149 000005C1 B8FFFF                  	mov	ax, -1
  1150                                  	; cf = 1 -> not found or access error
  1151                                  _of1:
  1152 000005C4 A3[6E2B]                	mov	[filehandle], ax
  1153 000005C7 C3                      	retn
  1154                                  
  1155                                  ; ----------------------------------
  1156                                  
  1157                                  ; close the currently open file
  1158                                  
  1159                                  	; 14/11/2024
  1160                                  	; INPUT: [filehandle] ; -1 = not open
  1161                                  	; OUTPUT: none
  1162                                  closeFile:
  1163 000005C8 833E[6E2B]FF            	cmp	word [filehandle], -1
  1164 000005CD 7409                    	jz	short _cf1
  1165 000005CF 8B1E[6E2B]              	mov     bx, [filehandle]
  1166 000005D3 B8003E                  	mov     ax, 3E00h
  1167 000005D6 CD21                            int     21h              ; close file
  1168                                  _cf1:
  1169 000005D8 C3                      	retn
  1170                                  
  1171                                  ; ----------------------------------
  1172                                  
  1173                                  	; 04/02/2025
  1174                                  	; 14/11/2024 - Erdogan Tan
  1175                                  getWAVParameters:
  1176                                  ; reads WAV file header(s) (44 bytes) from the .wav file.
  1177                                  ; entry: none - assumes file is already open
  1178                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
  1179                                  ;	cx = number of channels (mono=1, stereo=2)
  1180                                  ;	dx = bits per sample (8, 16)
  1181                                  ;	bx = number of bytes per sample (1 to 4)
  1182                                  
  1183 000005D9 BA[402B]                        mov     dx, WAVFILEHEADERbuff
  1184 000005DC 8B1E[6E2B]              	mov	bx, [filehandle]
  1185 000005E0 B92C00                          mov     cx, 44			; 44 bytes
  1186 000005E3 B43F                    	mov	ah, 3Fh
  1187 000005E5 CD21                            int     21h
  1188 000005E7 7223                    	jc	short gwavp_retn
  1189                                  
  1190 000005E9 83F82C                  	cmp	ax, 44
  1191 000005EC 721E                    	jb	short gwavp_retn
  1192                                  
  1193 000005EE 66813E[482B]574156-     	cmp	dword [RIFF_Format], 'WAVE'
  1193 000005F6 45                 
  1194 000005F7 7512                    	jne	short gwavp_stc_retn
  1195                                  
  1196 000005F9 833E[542B]01            	cmp	word [WAVE_AudioFormat], 1 ; Offset 20, must be 1 (= PCM)
  1197                                  	; 04/02/2025
  1198 000005FE 750B                    	jne	short gwavp_stc_retn
  1199                                  	;je	short gwavp_retn ; 15/11/2024
  1200                                  
  1201                                  	; 04/02/2025
  1202                                  	; (Open MPT creates wav files with a new type header,
  1203                                  	;  this program can not use the new type
  1204                                  	;  because of 'data' offset is not at DATA_SubchunkID.)
  1205                                  	; ((GoldWave creates common type wav file.))
  1206 00000600 66813E[642B]646174-     	cmp	dword [DATA_SubchunkID], 'data'
  1206 00000608 61                 
  1207 00000609 7401                    	je	short gwavp_retn
  1208                                  
  1209                                  	; 15/11/2024
  1210                                  	;mov	cx, [WAVE_NumChannels]	; return num of channels in CX
  1211                                          ;mov    ax, [WAVE_SampleRate]	; return sample rate in AX
  1212                                  	;mov	dx, [WAVE_BitsPerSample] 
  1213                                  					; return bits per sample value in DX
  1214                                  	;mov	bx, [WAVE_BlockAlign]	; return bytes per sample in BX
  1215                                  ;gwavp_retn:
  1216                                          ;retn
  1217                                  
  1218                                  gwavp_stc_retn:
  1219 0000060B F9                      	stc
  1220                                  gwavp_retn:
  1221 0000060C C3                      	retn
  1222                                  
  1223                                  ; --------------------------------------------------------
  1224                                  ; ----	30/05/2024 (playwav4.asm, 19/05/2024)
  1225                                  ; --------------------------------------------------------
  1226                                  
  1227                                  ; MEMALLOC.ASM
  1228                                  ;-- SETFREE: Release memory not used  --------------------
  1229                                  ;-- Input    : ES = address of PSP
  1230                                  ;-- Output   : none
  1231                                  ;-- Register : AX, BX, CL and FLAGS are changed 
  1232                                  ;-- Info     : Since the stack-segment is always the last segment in an 
  1233                                  ;              EXE-file, ES:0000 points to the beginning and SS:SP
  1234                                  ;              to the end of the program in memory. Through this the
  1235                                  ;              length of the program can be calculated 
  1236                                  ; call this routine once at the beginning of the program to free up memory
  1237                                  ; assigned to it by DOS.
  1238                                  
  1239                                  setFree:
  1240 0000060D BB0010                  	mov	bx, 65536/16	; 4K paragraphs ; 17/02/2017 (Erdogan Tan)		
  1241                                  
  1242 00000610 B44A                    	mov	ah, 4Ah		; pass new length to DOS
  1243 00000612 CD21                    	int	21h
  1244                                  
  1245 00000614 C3                      	retn			; back to caller 
  1246                                  				; new size (allocated memory) = 64KB
  1247                                  
  1248                                  ; --------------------------------------------------------
  1249                                  
  1250                                  memAlloc:
  1251                                  ; input: AX = # of paragraphs required
  1252                                  ; output: AX = segment of block to use
  1253                                  
  1254 00000615 53                      	push	bx
  1255 00000616 89C3                    	mov	bx, ax
  1256 00000618 B448                    	mov	ah, 48h
  1257 0000061A CD21                    	int	21h
  1258 0000061C 5B                      	pop	bx
  1259 0000061D C3                      	retn
  1260                                  
  1261                                  ; --------------------------------------------------------
  1262                                  
  1263                                  ; 29/12/2024 (vgaplay3.s)
  1264                                  ; 18/12/2024 (ac97play.s)
  1265                                  ; --------------------------------------------------------
  1266                                  ; 27/05/2024 - (TRDOS 386 Kernel) audio.s
  1267                                  ; --------------------------------------------------------
  1268                                  
  1269                                  NOT_PCI32_PCI16	EQU 03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
  1270                                  NOT_BIT31 EQU 7FFFFFFFh
  1271                                  
  1272                                  pciFindDevice:
  1273                                  	; 19/11/2023
  1274                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1275                                  	;
  1276                                  	; scan through PCI space looking for a device+vendor ID
  1277                                  	;
  1278                                  	; Entry: EAX=Device+Vendor ID
  1279                                  	;
  1280                                  	; Exit: EAX=PCI address if device found
  1281                                  	;	EDX=Device+Vendor ID
  1282                                  	;       CY clear if found, set if not found. EAX invalid if CY set.
  1283                                  	;
  1284                                  	; Destroys: ebx, edi ; 19/11/2023
  1285                                  
  1286                                          ; 19/11/2023
  1287 0000061E 6689C3                  	mov	ebx, eax
  1288 00000621 66BF00000080            	mov	edi, 80000000h
  1289                                  nextPCIdevice:
  1290 00000627 6689F8                  	mov 	eax, edi		; read PCI registers
  1291 0000062A E88D00                  	call	pciRegRead32
  1292                                  	; 19/11/2023
  1293 0000062D 6639DA                  	cmp	edx, ebx
  1294 00000630 7414                    	je	short PCIScanExit	; found
  1295                                  	; 19/11/2023
  1296 00000632 6681FF00F8FF80          	cmp	edi, 80FFF800h
  1297 00000639 7309                    	jnb	short pfd_nf		; not found
  1298 0000063B 6681C700010000          	add	edi, 100h
  1299 00000642 EBE3                    	jmp	short nextPCIdevice
  1300                                  pfd_nf:
  1301 00000644 F9                      	stc
  1302 00000645 C3                      	retn
  1303                                  PCIScanExit:
  1304                                  	;pushf
  1305 00000646 66B8FFFFFF7F            	mov	eax, NOT_BIT31 	; 19/03/2017
  1306 0000064C 6621F8                  	and	eax, edi	; return only bus/dev/fn #
  1307 0000064F C3                      	retn
  1308                                  
  1309                                  pciRegRead:
  1310                                  	; 30/05/2024
  1311                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1312                                  	;
  1313                                  	; 8/16/32bit PCI reader
  1314                                  	;
  1315                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1316                                  	;           BIT30 set if 32 bit access requested
  1317                                  	;           BIT29 set if 16 bit access requested
  1318                                  	;           otherwise defaults to 8 bit read
  1319                                  	;
  1320                                  	; Exit:  DL,DX,EDX register data depending on requested read size
  1321                                  	;
  1322                                  	; Note1: this routine is meant to be called via pciRegRead8,
  1323                                  	;	 pciRegread16 or pciRegRead32, listed below.
  1324                                  	;
  1325                                  	; Note2: don't attempt to read 32 bits of data from a non dword
  1326                                  	;	 aligned reg number. Likewise, don't do 16 bit reads from
  1327                                  	;	 non word aligned reg #
  1328                                  	
  1329 00000650 6653                    	push	ebx
  1330 00000652 51                      	push	cx
  1331 00000653 6689C3                          mov     ebx, eax		; save eax, dh
  1332 00000656 88F1                            mov     cl, dh
  1333                                  
  1334 00000658 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; clear out data size request
  1335 0000065E 660D00000080                    or      eax, BIT31		; make a PCI access request
  1336                                  	; 01/01/2025 (NASM)
  1337 00000664 24FC                            and     al, ~3 ; NOT 3		; force index to be dword
  1338                                  
  1339 00000666 BAF80C                          mov     dx, PCI_INDEX_PORT
  1340 00000669 66EF                    	out	dx, eax			; write PCI selector
  1341                                  		
  1342 0000066B BAFC0C                          mov     dx, PCI_DATA_PORT
  1343 0000066E 88D8                            mov     al, bl
  1344 00000670 2403                            and     al, 3			; figure out which port to
  1345 00000672 00C2                            add     dl, al			; read to
  1346                                  
  1347 00000674 66F7C3000000C0          	test    ebx, PCI32+PCI16
  1348 0000067B 7507                            jnz     short _pregr0
  1349                                  
  1350 0000067D EC                      	in	al, dx			; return 8 bits of data
  1351                                  
  1352 0000067E 88C2                    	mov	dl, al
  1353 00000680 88CE                    	mov     dh, cl			; restore dh for 8 bit read
  1354 00000682 EB13                    	jmp	short _pregr2
  1355                                  _pregr0:	
  1356 00000684 66F7C300000080          	test    ebx, PCI32
  1357 0000068B 7505                            jnz	short _pregr1
  1358                                  
  1359 0000068D ED                      	in	ax, dx
  1360                                  
  1361 0000068E 89C2                    	mov     dx, ax			; return 16 bits of data
  1362 00000690 EB05                    	jmp	short _pregr2
  1363                                  _pregr1:
  1364 00000692 66ED                    	in	eax, dx			; return 32 bits of data
  1365                                  
  1366 00000694 6689C2                  	mov	edx, eax
  1367                                  _pregr2:
  1368 00000697 6689D8                  	mov     eax, ebx		; restore eax
  1369 0000069A 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; clear out data size request
  1370 000006A0 59                      	pop	cx
  1371 000006A1 665B                    	pop	ebx
  1372 000006A3 C3                      	retn
  1373                                  
  1374                                  pciRegRead8:
  1375 000006A4 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
  1376 000006AA EBA4                            jmp     short pciRegRead	; call generic PCI access
  1377                                  
  1378                                  pciRegRead16:
  1379 000006AC 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
  1380 000006B2 660D00000040                    or      eax, PCI16		; call generic PCI access
  1381 000006B8 EB96                            jmp     short pciRegRead
  1382                                  
  1383                                  pciRegRead32:
  1384 000006BA 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
  1385 000006C0 660D00000080                    or      eax, PCI32		; call generic PCI access
  1386 000006C6 EB88                            jmp     pciRegRead
  1387                                  
  1388                                  pciRegWrite:
  1389                                  	; 30/05/2024
  1390                                  	; 03/04/2017 ('pci.asm', 29/11/2016)
  1391                                  	;
  1392                                  	; 8/16/32bit PCI writer
  1393                                  	;
  1394                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1395                                  	;           BIT31 set if 32 bit access requested
  1396                                  	;           BIT30 set if 16 bit access requested
  1397                                  	;           otherwise defaults to 8bit read
  1398                                  	;        DL/DX/EDX data to write depending on size
  1399                                  	;
  1400                                  	; Note1: this routine is meant to be called via pciRegWrite8,
  1401                                  	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
  1402                                  	;
  1403                                  	; Note2: don't attempt to write 32bits of data from a non dword
  1404                                  	;	 aligned reg number. Likewise, don't do 16 bit writes from
  1405                                  	;	 non word aligned reg #
  1406                                  
  1407 000006C8 6653                    	push	ebx
  1408 000006CA 6651                    	push	ecx
  1409 000006CC 6689C3                          mov     ebx, eax		; save eax, edx
  1410 000006CF 6689D1                          mov     ecx, edx
  1411 000006D2 6625FFFFFF3F            	and     eax, NOT_PCI32_PCI16	; clear out data size request
  1412 000006D8 660D00000080                    or      eax, BIT31		; make a PCI access request
  1413                                  	; 01/01/2025 (NASM)
  1414 000006DE 24FC                            and     al, ~3 ; NOT 3		; force index to be dword
  1415                                  
  1416 000006E0 BAF80C                          mov     dx, PCI_INDEX_PORT
  1417 000006E3 66EF                    	out	dx, eax			; write PCI selector
  1418                                  		
  1419 000006E5 BAFC0C                          mov     dx, PCI_DATA_PORT
  1420 000006E8 88D8                            mov     al, bl
  1421 000006EA 2403                            and     al, 3			; figure out which port to
  1422 000006EC 00C2                            add     dl, al			; write to
  1423                                  
  1424 000006EE 66F7C3000000C0          	test    ebx, PCI32+PCI16
  1425 000006F5 7505                            jnz     short _pregw0
  1426                                  	
  1427 000006F7 88C8                    	mov	al, cl 			; put data into al
  1428 000006F9 EE                      	out	dx, al
  1429                                  	
  1430 000006FA EB13                    	jmp	short _pregw2
  1431                                  _pregw0:
  1432 000006FC 66F7C300000080          	test    ebx, PCI32
  1433 00000703 7505                            jnz     short _pregw1
  1434                                  	
  1435 00000705 89C8                    	mov	ax, cx			; put data into ax
  1436 00000707 EF                      	out	dx, ax
  1437                                  
  1438 00000708 EB05                    	jmp	short _pregw2
  1439                                  _pregw1:
  1440 0000070A 6689C8                  	mov	eax, ecx		; put data into eax
  1441 0000070D 66EF                    	out	dx, eax
  1442                                  _pregw2:
  1443 0000070F 6689D8                          mov     eax, ebx		; restore eax
  1444 00000712 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; clear out data size request
  1445 00000718 6689CA                          mov     edx, ecx		; restore dx
  1446 0000071B 6659                    	pop	ecx
  1447 0000071D 665B                    	pop	ebx
  1448 0000071F C3                      	retn
  1449                                  
  1450                                  pciRegWrite8:
  1451 00000720 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
  1452 00000726 EBA0                            jmp	short pciRegWrite	; call generic PCI access
  1453                                  
  1454                                  pciRegWrite16:
  1455 00000728 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
  1456 0000072E 660D00000040                    or      eax, PCI16		; call generic PCI access
  1457 00000734 EB92                            jmp	short pciRegWrite
  1458                                  
  1459                                  pciRegWrite32:
  1460 00000736 6625FFFFFF3F                    and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
  1461 0000073C 660D00000080                    or      eax, PCI32		; call generic PCI access
  1462 00000742 EB84                            jmp	pciRegWrite
  1463                                  
  1464                                  ; --------------------------------------------------------
  1465                                  ; 19/05/2024 - (playwav4.asm) ac97_vra.asm
  1466                                  ; --------------------------------------------------------
  1467                                  
  1468                                  	; 13/11/2023
  1469                                  
  1470                                  ;VRA:	db 1
  1471                                  
  1472                                  codecConfig:
  1473                                  	; 30/05/2024
  1474                                  	; 19/05/2024
  1475                                  	; 19/11/2023
  1476                                  	; 15/11/2023
  1477                                  	; 04/11/2023
  1478                                  	; 17/02/2017 
  1479                                  	; 07/11/2016 (Erdogan Tan)
  1480                                  
  1481                                  	;AC97_EA_VRA equ 1
  1482                                  	AC97_EA_VRA equ BIT0
  1483                                  
  1484                                  	; 04/11/2023
  1485                                  init_ac97_controller:
  1486 00000744 66A1[C62B]              	mov	eax, [bus_dev_fn]
  1487 00000748 B004                    	mov	al, PCI_CMD_REG
  1488 0000074A E85FFF                  	call	pciRegRead16		; read PCI command register
  1489 0000074D 80CA05                  	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
  1490 00000750 E8D5FF                  	call	pciRegWrite16
  1491                                  
  1492                                  	;call	delay_100ms
  1493                                  
  1494                                  	; 19/05/2024
  1495                                  	; ('PLAYMOD3.ASM', Erdogan Tan, 18/05/2024)
  1496                                  
  1497                                  init_ac97_codec:
  1498                                  	; 18/11/2023
  1499 00000753 BD2800                  	mov	bp, 40
  1500                                  	; 29/05/2024
  1501                                  	;mov	bp, 1000
  1502                                  _initc_1:
  1503                                  	; 30/05/2024
  1504 00000756 BA3000                  	mov	dx, GLOB_STS_REG ; 30h
  1505 00000759 0316[D02B]              	add	dx, [NABMBAR]
  1506 0000075D 66ED                    	in	eax, dx
  1507                                  
  1508                                  	; 19/05/2024
  1509 0000075F E8FD01                  	call	delay1_4ms
  1510                                  
  1511 00000762 6683F8FF                	cmp	eax, 0FFFFFFFFh ; -1
  1512 00000766 7508                    	jne	short _initc_3
  1513                                  _initc_2:
  1514 00000768 4D                      	dec	bp
  1515 00000769 741E                    	jz	short _ac97_codec_ready
  1516                                  
  1517 0000076B E8E601                  	call	delay_100ms
  1518 0000076E EBE6                    	jmp	short _initc_1
  1519                                  _initc_3:
  1520 00000770 66A900030010            	test	eax, CTRL_ST_CREADY
  1521 00000776 7511                    	jnz	short _ac97_codec_ready
  1522                                  
  1523                                  	; 30/05/2024
  1524 00000778 803E[F222]01            	cmp	byte [reset], 1
  1525 0000077D 73E9                    	jnb	short _initc_2
  1526                                  
  1527 0000077F E81801                  	call	reset_ac97_codec
  1528                                  	; 30/05/2024
  1529 00000782 C606[F222]01            	mov	byte [reset], 1
  1530                                  	; 19/05/2024
  1531 00000787 EBDF                    	jmp	short _initc_2
  1532                                  
  1533                                  _ac97_codec_ready:
  1534 00000789 8B16[CE2B]              	mov	dx, [NAMBAR]
  1535                                  	;add	dx, 0 ; ac_reg_0 ; reset register
  1536 0000078D EF                      	out	dx, ax
  1537                                  	
  1538 0000078E E8C301                  	call	delay_100ms
  1539                                  
  1540                                  	; 19/11/2023
  1541 00000791 09ED                    	or	bp, bp
  1542 00000793 7525                    	jnz	short _ac97_codec_init_ok
  1543                                  
  1544 00000795 31C0                    	xor	ax, ax ; 0
  1545 00000797 8B16[CE2B]              	mov	dx, [NAMBAR]
  1546 0000079B 83C226                  	add	dx, CODEC_REG_POWERDOWN
  1547 0000079E EF                      	out	dx, ax
  1548                                  
  1549                                  	; 30/05/2024
  1550 0000079F E8BD01                  	call	delay1_4ms
  1551                                  
  1552                                  	; 19/11/2023
  1553                                  	; wait for 1 second
  1554                                  	; 19/05/2024
  1555 000007A2 B9E803                  	mov	cx, 1000 ; 1000*4*0.25ms = 1s
  1556                                  	;;mov	cx, 10
  1557                                  	; 30/05/2024
  1558                                  	;mov	cx, 40
  1559                                  _ac97_codec_rloop:
  1560                                  	;call	delay_100ms
  1561                                  
  1562                                  	; 30/05/2024
  1563 000007A5 8B16[CE2B]              	mov	dx, [NAMBAR]
  1564 000007A9 83C226                  	add	dx, CODEC_REG_POWERDOWN
  1565 000007AC ED                      	in	ax, dx
  1566                                  
  1567 000007AD E8AF01                  	call	delay1_4ms
  1568                                  	
  1569 000007B0 83E00F                  	and	ax, 0Fh
  1570 000007B3 3C0F                    	cmp	al, 0Fh
  1571 000007B5 7403                    	je	short _ac97_codec_init_ok
  1572 000007B7 E2EC                    	loop	_ac97_codec_rloop 
  1573                                  
  1574                                  init_ac97_codec_err1:
  1575                                  	;stc	; cf = 1 ; 19/05/2024
  1576                                  init_ac97_codec_err2:
  1577 000007B9 C3                      	retn
  1578                                  
  1579                                  _ac97_codec_init_ok:
  1580 000007BA E89600                  	call 	reset_ac97_controller
  1581                                  
  1582                                  	; 30/05/2024
  1583                                  	; 19/05/2024
  1584                                  	;call	delay_100ms
  1585                                  
  1586                                  	; 30/05/2024
  1587 000007BD E89F01                  	call	delay1_4ms
  1588 000007C0 E89C01                  	call	delay1_4ms
  1589 000007C3 E89901                  	call	delay1_4ms
  1590 000007C6 E89601                  	call	delay1_4ms
  1591                                  
  1592                                  setup_ac97_codec:
  1593                                  	; 12/11/2023
  1594 000007C9 813E[582B]80BB          	cmp	word [WAVE_SampleRate], 48000
  1595 000007CF 7453                    	je	short skip_rate
  1596                                  	
  1597                                  	; 30/05/2024
  1598                                  	; 19/05/2024
  1599                                  	;call	delay1_4ms
  1600                                  
  1601                                  	; 30/05/2024
  1602                                  	;cmp	byte [VRA], 0
  1603                                  	;jna	short skip_rate
  1604                                  
  1605                                  	; 11/11/2023
  1606 000007D1 8B16[CE2B]              	mov	dx, [NAMBAR]
  1607 000007D5 83C22A                  	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1608 000007D8 ED                      	in	ax, dx
  1609                                  
  1610                                  	; 30/05/2024
  1611                                  	; 19/05/2024
  1612 000007D9 E88301                  	call	delay1_4ms
  1613                                  	
  1614                                  	; 13/11/2024
  1615                                  	;and	al, NOT BIT1 ; Clear DRA
  1616                                  	;;;
  1617                                  	; 30/05/2024
  1618                                  	;and	al, NOT (BIT1+BIT0) ; Clear DRA+VRA
  1619                                  	; 01/01/2025 (NASM)
  1620 000007DC 24FC                    	and	al, ~(BIT1+BIT0)
  1621 000007DE EF                      	out	dx, ax
  1622                                  
  1623 000007DF E83801                  	call	check_vra
  1624                                  
  1625 000007E2 803E[3C2B]00            	cmp	byte [VRA], 0
  1626 000007E7 763B                    	jna	short skip_rate
  1627                                  
  1628 000007E9 8B16[CE2B]              	mov	dx, [NAMBAR]
  1629 000007ED 83C22A                  	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1630 000007F0 ED                      	in	ax, dx
  1631                                  	;and	al, ~BIT1 ; Clear DRA
  1632                                  	;;;
  1633                                  
  1634 000007F1 0C01                    	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
  1635                                  	; 30/05/2024
  1636 000007F3 8B16[CE2B]              	mov	dx, [NAMBAR]
  1637 000007F7 83C22A                  	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1638                                  
  1639 000007FA EF                      	out	dx, ax			; Enable variable rate audio
  1640                                  
  1641 000007FB B90A00                  	mov	cx, 10
  1642                                  check_vra_loop:
  1643 000007FE E85301                  	call	delay_100ms
  1644                                  	; 30/05/2024
  1645                                  	;call	delay1_4ms
  1646                                  
  1647                                  	; 30/05/2024
  1648 00000801 8B16[CE2B]              	mov	dx, [NAMBAR]
  1649 00000805 83C22A                  	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1650                                  	; 11/11/2023
  1651 00000808 ED                      	in	ax, dx
  1652                                  	
  1653 00000809 A801                    	test	al, AC97_EA_VRA ; 1
  1654 0000080B 7509                    	jnz	short set_rate
  1655                                  
  1656                                  	; 11/11/2023
  1657 0000080D E2EF                    	loop	check_vra_loop
  1658                                  
  1659                                  ;vra_not_supported:	; 19/05/2024
  1660 0000080F C606[3C2B]00            	mov	byte [VRA], 0
  1661 00000814 EB0E                    	jmp	short skip_rate
  1662                                  
  1663                                  set_rate:
  1664 00000816 A1[582B]                	mov	ax, [WAVE_SampleRate] ; 17/02/2017 (Erdogan Tan)
  1665                                  
  1666 00000819 8B16[CE2B]              	mov    	dx, [NAMBAR]               	
  1667 0000081D 83C22C                  	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch
  1668 00000820 EF                      	out	dx, ax 			; PCM Front/Center Output Sample Rate
  1669                                  
  1670                                  	;call	delay_100ms
  1671                                  	; 30/05/2024
  1672 00000821 E83B01                  	call	delay1_4ms
  1673                                  
  1674                                  	; 12/11/2023
  1675                                  skip_rate:
  1676 00000824 B80202                  	mov	ax, 0202h
  1677 00000827 8B16[CE2B]                	mov	dx, [NAMBAR]
  1678 0000082B 83C202                    	add	dx, CODEC_MASTER_VOL_REG	; 02h
  1679 0000082E EF                      	out	dx, ax
  1680                                  
  1681                                  	; 11/11/2023
  1682 0000082F E82D01                  	call	delay1_4ms
  1683 00000832 E82A01                  	call	delay1_4ms
  1684 00000835 E82701                  	call	delay1_4ms
  1685 00000838 E82401                  	call	delay1_4ms
  1686                                  
  1687 0000083B B80202                  	mov	ax, 0202h
  1688 0000083E 8B16[CE2B]                	mov	dx, [NAMBAR]
  1689 00000842 83C218                    	add	dx, CODEC_PCM_OUT_REG		; 18h
  1690 00000845 EF                        	out	dx, ax
  1691                                  	
  1692                                  	; 11/11/2023
  1693 00000846 E81601                  	call	delay1_4ms
  1694 00000849 E81301                  	call	delay1_4ms
  1695 0000084C E81001                  	call	delay1_4ms
  1696 0000084F E80D01                  	call	delay1_4ms
  1697                                  
  1698                                  	; 30/05/2024
  1699                                  	; 19/05/2024
  1700                                  	;clc
  1701                                  
  1702 00000852 C3                              retn
  1703                                  
  1704                                  reset_ac97_controller:
  1705                                  	; 19/05/2024
  1706                                  	; 11/11/2023
  1707                                  	; 10/06/2017
  1708                                  	; 29/05/2017
  1709                                  	; 28/05/2017
  1710                                  	; reset AC97 audio controller registers
  1711 00000853 31C0                    	xor     ax, ax
  1712 00000855 BA0B00                          mov	dx, PI_CR_REG
  1713 00000858 0316[D02B]              	add	dx, [NABMBAR]
  1714 0000085C EE                      	out     dx, al
  1715                                  
  1716                                  	; 19/05/2024
  1717 0000085D E8FF00                  	call	delay1_4ms
  1718                                  
  1719 00000860 BA1B00                          mov     dx, PO_CR_REG
  1720 00000863 0316[D02B]              	add	dx, [NABMBAR]
  1721 00000867 EE                      	out     dx, al
  1722                                  
  1723                                  	; 19/05/2024
  1724 00000868 E8F400                  	call	delay1_4ms
  1725                                  
  1726 0000086B BA2B00                          mov     dx, MC_CR_REG
  1727 0000086E 0316[D02B]              	add	dx, [NABMBAR]
  1728 00000872 EE                      	out     dx, al
  1729                                  
  1730                                  	; 19/05/2024
  1731 00000873 E8E900                  	call	delay1_4ms
  1732                                  
  1733 00000876 B002                            mov     al, RR
  1734 00000878 BA0B00                          mov     dx, PI_CR_REG
  1735 0000087B 0316[D02B]              	add	dx, [NABMBAR]
  1736 0000087F EE                      	out     dx, al
  1737                                  
  1738                                  	; 19/05/2024
  1739 00000880 E8DC00                  	call	delay1_4ms
  1740                                  
  1741 00000883 BA1B00                          mov     dx, PO_CR_REG
  1742 00000886 0316[D02B]              	add	dx, [NABMBAR]
  1743 0000088A EE                      	out     dx, al
  1744                                  
  1745                                  	; 19/05/2024
  1746 0000088B E8D100                  	call	delay1_4ms
  1747                                  
  1748 0000088E BA2B00                          mov     dx, MC_CR_REG
  1749 00000891 0316[D02B]              	add	dx, [NABMBAR]
  1750 00000895 EE                      	out     dx, al
  1751                                  
  1752                                  	; 19/05/2024
  1753 00000896 E8C600                  	call	delay1_4ms
  1754                                  
  1755 00000899 C3                      	retn
  1756                                  
  1757                                  reset_ac97_codec:
  1758                                  	; 11/11/2023
  1759                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  1760 0000089A BA2C00                  	mov	dx, GLOB_CNT_REG ; 2Ch
  1761 0000089D 0316[D02B]              	add	dx, [NABMBAR]
  1762 000008A1 66ED                    	in	eax, dx
  1763                                  
  1764                                  	;test	eax, 2
  1765                                  	; 06/08/2022
  1766 000008A3 A802                    	test	al, 2
  1767 000008A5 7405                    	jz	short _r_ac97codec_cold
  1768                                  
  1769 000008A7 E80E00                  	call	warm_ac97codec_reset
  1770 000008AA 7306                    	jnc	short _r_ac97codec_ok
  1771                                  _r_ac97codec_cold:
  1772 000008AC E83400                          call    cold_ac97codec_reset
  1773 000008AF 7301                            jnc     short _r_ac97codec_ok
  1774                                  	
  1775                                  	; 16/04/2017
  1776                                          ;xor	eax, eax	; timeout error
  1777                                         	;stc
  1778 000008B1 C3                      	retn
  1779                                  
  1780                                  _r_ac97codec_ok:
  1781 000008B2 6631C0                          xor     eax, eax
  1782                                          ;mov	al, VIA_ACLINK_C00_READY ; 1
  1783 000008B5 FEC0                            inc	al
  1784 000008B7 C3                      	retn
  1785                                  
  1786                                  warm_ac97codec_reset:
  1787                                  	; 11/11/2023
  1788                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  1789                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  1790 000008B8 66B806000000            	mov	eax, 6
  1791 000008BE BA2C00                  	mov	dx, GLOB_CNT_REG ; 2Ch
  1792 000008C1 0316[D02B]              	add	dx, [NABMBAR]
  1793 000008C5 66EF                    	out	dx, eax
  1794                                  
  1795 000008C7 B90A00                  	mov	cx, 10	; total 1s
  1796                                  _warm_ac97c_rst_wait:
  1797 000008CA E88700                  	call	delay_100ms
  1798                                  
  1799 000008CD BA3000                  	mov	dx, GLOB_STS_REG ; 30h
  1800 000008D0 0316[D02B]              	add	dx, [NABMBAR]
  1801 000008D4 66ED                    	in	eax, dx
  1802                                  
  1803 000008D6 66A900030010            	test	eax, CTRL_ST_CREADY
  1804 000008DC 7504                    	jnz	short _warm_ac97c_rst_ok
  1805                                  
  1806 000008DE 49                              dec     cx
  1807 000008DF 75E9                            jnz     short _warm_ac97c_rst_wait
  1808                                  
  1809                                  _warm_ac97c_rst_fail:
  1810 000008E1 F9                              stc
  1811                                  _warm_ac97c_rst_ok:
  1812 000008E2 C3                      	retn
  1813                                  
  1814                                  cold_ac97codec_reset:
  1815                                  	; 11/11/2023
  1816                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  1817                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  1818 000008E3 66B802000000                    mov	eax, 2
  1819 000008E9 BA2C00                  	mov	dx, GLOB_CNT_REG ; 2Ch
  1820 000008EC 0316[D02B]              	add	dx, [NABMBAR]
  1821 000008F0 66EF                    	out	dx, eax
  1822                                  
  1823 000008F2 E85F00                  	call	delay_100ms 	; wait 100 ms
  1824 000008F5 E85C00                  	call	delay_100ms 	; wait 100 ms
  1825 000008F8 E85900                  	call	delay_100ms 	; wait 100 ms
  1826 000008FB E85600                  	call	delay_100ms 	; wait 100 ms
  1827                                  
  1828 000008FE B91000                  	mov	cx, 16	; total 20*100 ms = 2s
  1829                                  
  1830                                  _cold_ac97c_rst_wait:
  1831 00000901 BA3000                  	mov	dx, GLOB_STS_REG ; 30h
  1832 00000904 0316[D02B]              	add	dx, [NABMBAR]
  1833 00000908 66ED                    	in	eax, dx
  1834                                  
  1835 0000090A 66A900030010            	test	eax, CTRL_ST_CREADY
  1836 00000910 7507                    	jnz	short _cold_ac97c_rst_ok
  1837                                  
  1838 00000912 E83F00                  	call	delay_100ms
  1839                                  
  1840 00000915 49                              dec     cx
  1841 00000916 75E9                            jnz     short _cold_ac97c_rst_wait
  1842                                  
  1843                                  _cold_ac97c_rst_fail:
  1844 00000918 F9                              stc
  1845                                  _cold_ac97c_rst_ok:
  1846 00000919 C3                      	retn
  1847                                  
  1848                                  ; 13/11/2024
  1849                                  ; 30/05/2024
  1850                                  %if 1
  1851                                  check_vra:
  1852                                  	; 30/05/2024
  1853 0000091A C606[3C2B]01            	mov	byte [VRA], 1
  1854                                  
  1855                                  	; 29/05/2024 - audio.s (TRDOS 386 Kernel) - 27/05/2024
  1856                                  	; 24/05/2024
  1857                                  	; 23/05/2024
  1858 0000091F 8B16[CE2B]              	mov	dx, [NAMBAR]
  1859 00000923 83C228                  	add	dx, CODEC_EXT_AUDIO_REG	; 28h
  1860 00000926 ED                      	in	ax, dx
  1861                                  
  1862                                  	; 30/05/2024
  1863                                  	; 23/05/2024
  1864 00000927 E83500                  	call	delay1_4ms
  1865                                  
  1866                                  	; 30/05/2024
  1867 0000092A A801                    	test	al, BIT0
  1868                                  	;test	al, 1 ; BIT0 ; Variable Rate Audio bit
  1869 0000092C 7505                    	jnz	short check_vra_ok
  1870                                  
  1871                                  vra_not_supported:
  1872                                  	; 13/11/2023
  1873 0000092E C606[3C2B]00            	mov	byte [VRA], 0
  1874                                  check_vra_ok:
  1875 00000933 C3                      	retn
  1876                                  %endif
  1877                                  
  1878                                  ; --------------------------------------------------------
  1879                                  ; --------------------------------------------------------
  1880                                  
  1881                                  ; 01/01/2025 (cgaplay.asm)
  1882                                  ; 29/12/2024 (vgaplay3.s)
  1883                                  ; 18/12/2024 (ac97play.s)
  1884                                  ;
  1885                                  ; 18/11/2024
  1886                                  ; Ref: TRDOS 386 v2.0.9, audio.s, Erdogan Tan, 06/06/2024
  1887                                  
  1888                                  ac97_stop:
  1889                                  	; 18/11/2024
  1890 00000934 C606[342B]02            	mov	byte [stopped], 2
  1891                                  
  1892                                  ac97_po_cmd@:
  1893 00000939 30C0                    	xor	al, al ; 0
  1894                                  ac97_po_cmd:
  1895 0000093B 8B16[D02B]              	mov     dx, [NABMBAR]
  1896 0000093F 83C21B                          add     dx, PO_CR_REG	; PCM out control register
  1897 00000942 EE                      	out	dx, al
  1898 00000943 C3                      	retn
  1899                                  
  1900                                  ac97_pause:
  1901 00000944 C606[342B]01            	mov	byte [stopped], 1 ; paused
  1902                                  	;mov	al, 0
  1903                                  	;jmp	short ac97_po_cmd
  1904 00000949 EBEE                    	jmp	short ac97_po_cmd@
  1905                                  
  1906                                  ac97_play: ; continue to play (after pause)
  1907 0000094B C606[342B]00            	mov	byte [stopped], 0
  1908 00000950 B001                    	mov	al, RPBM
  1909 00000952 EBE7                    	jmp	short ac97_po_cmd
  1910                                  
  1911                                  ; --------------------------------------------------------
  1912                                  
  1913                                  PORTB		EQU 061h
  1914                                  REFRESH_STATUS	EQU 010h	; Refresh signal status
  1915                                  
  1916                                  delay_100ms:
  1917                                  	; 11/11/2023
  1918                                  	; 29/05/2017
  1919                                  	; 24/03/2017 ('codec.asm')
  1920                                  	; wait 100 ms
  1921 00000954 51                      	push	cx
  1922 00000955 B99001                  	mov	cx, 400  ; 400*0.25ms
  1923                                  _delay_x_ms:
  1924 00000958 E80400                  	call	delay1_4ms
  1925 0000095B E2FB                            loop	_delay_x_ms
  1926 0000095D 59                      	pop	cx
  1927 0000095E C3                      	retn
  1928                                  
  1929                                  delay1_4ms:
  1930 0000095F 50                              push    ax
  1931 00000960 51                              push    cx
  1932 00000961 B91000                          mov     cx, 16			; close enough.
  1933 00000964 E461                    	in	al, PORTB
  1934 00000966 2410                    	and	al, REFRESH_STATUS
  1935 00000968 88C4                    	mov	ah, al			; Start toggle state
  1936 0000096A 09C9                    	or	cx, cx
  1937 0000096C 7401                    	jz	short _d4ms1
  1938 0000096E 41                      	inc	cx			; Throwaway first toggle
  1939                                  _d4ms1:
  1940 0000096F E461                    	in	al, PORTB		; Read system control port
  1941 00000971 2410                    	and	al, REFRESH_STATUS	; Refresh toggles 15.085 microseconds
  1942 00000973 38C4                    	cmp	ah, al
  1943 00000975 74F8                    	je	short _d4ms1		; Wait for state change
  1944                                  
  1945 00000977 88C4                    	mov	ah, al			; Update with new state
  1946 00000979 49                      	dec	cx
  1947 0000097A 75F3                    	jnz	short _d4ms1
  1948                                  
  1949                                  	; 30/05/2024
  1950 0000097C F8                      	clc
  1951                                  
  1952 0000097D 59                              pop     cx
  1953 0000097E 58                              pop     ax
  1954 0000097F C3                              retn
  1955                                  
  1956                                  ; --------------------------------------------------------
  1957                                  
  1958                                  ; returns AL = current index value
  1959                                  getCurrentIndex:
  1960                                  	; 08/11/2023
  1961                                  	;push	dx
  1962 00000980 8B16[D02B]              	mov	dx, [NABMBAR]
  1963 00000984 83C214                  	add	dx, PO_CIV_REG
  1964 00000987 EC                      	in	al, dx
  1965                                  	;pop	dx
  1966                                  uLVI2:	;	06/11/2023
  1967 00000988 C3                      	retn
  1968                                  
  1969                                  ; --------------------------------------------------------
  1970                                  
  1971                                  updateLVI:
  1972                                  	; 06/11/2023
  1973 00000989 8B16[D02B]              	mov	dx, [NABMBAR]
  1974 0000098D 83C214                  	add	dx, PO_CIV_REG
  1975                                  	; (Current Index Value and Last Valid Index value)
  1976 00000990 ED                      	in	ax, dx
  1977                                  
  1978 00000991 38E0                    	cmp	al, ah ; is current index = last index ?
  1979 00000993 75F3                    	jne	short uLVI2
  1980                                  
  1981                                  	; 08/11/2023
  1982 00000995 E8E8FF                  	call	getCurrentIndex
  1983                                   
  1984 00000998 F606[6C2B]01            	test	byte [flags], ENDOFFILE
  1985                                  	;jnz	short uLVI1
  1986 0000099D 7411                    	jz	short uLVI0  ; 08/11/2023
  1987                                  
  1988                                  	; 08/11/2023
  1989 0000099F 50                      	push	ax
  1990 000009A0 8B16[D02B]              	mov	dx, [NABMBAR]
  1991 000009A4 83C216                  	add	dx, PO_SR_REG  ; PCM out status register
  1992 000009A7 ED                      	in	ax, dx
  1993                                  
  1994 000009A8 A803                    	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
  1995                                  		      ; (has been processed)
  1996                                  		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
  1997 000009AA 58                      	pop	ax
  1998 000009AB 7407                    	jz	short uLVI1
  1999                                  uLVI3:
  2000 000009AD 31C0                    	xor	ax, ax
  2001                                  	; zf = 1
  2002 000009AF C3                      	retn
  2003                                  uLVI0:
  2004                                          ; not at the end of the file yet.
  2005 000009B0 FEC8                    	dec	al
  2006 000009B2 241F                    	and	al, 1Fh
  2007                                  uLVI1:
  2008                                  	;call	setLastValidIndex
  2009                                  ;uLVI2:
  2010                                  	;retn
  2011                                  
  2012                                  ;input AL = index # to stop on
  2013                                  setLastValidIndex:
  2014                                  	; 08/11/2023
  2015                                  	;push	dx
  2016 000009B4 8B16[D02B]              	mov	dx, [NABMBAR]
  2017 000009B8 83C215                  	add	dx, PO_LVI_REG
  2018 000009BB EE                              out     dx, al
  2019                                  	;pop	dx
  2020 000009BC C3                      	retn
  2021                                  
  2022                                  ; --------------------------------------------------------
  2023                                  ; 07/12/2024
  2024                                  ; --------------------------------------------------------
  2025                                  
  2026                                  ; /////
  2027                                  	; 30/05/2024 (ich_wav4.asm, 19/05/2024)
  2028                                  loadFromFile:
  2029                                  	; 07/11/2023
  2030 000009BD F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  2031                                  					; last of the file?
  2032 000009C2 7402                    	jz	short lff_0		; no
  2033 000009C4 F9                      	stc
  2034 000009C5 C3                      	retn
  2035                                  
  2036                                  lff_0:
  2037                                  	; 08/11/2023
  2038 000009C6 89C5                    	mov	bp, ax ; save buffer segment
  2039                                  
  2040                                  	; 17/11/2024
  2041 000009C8 8B1E[6E2B]              	mov	bx, [filehandle]
  2042                                  
  2043                                  	; 17/11/2024
  2044 000009CC 8B0E[DA2B]              	mov	cx, [loadsize]
  2045 000009D0 31FF                    	xor	di, di ; 0
  2046                                  
  2047                                  	;mov	cl, [fbs_shift]
  2048                                  	;and	cl, cl
  2049                                  	;jz	short lff_1 ; stereo, 16 bit
  2050                                  	; 17/11/2024
  2051 000009D2 803E[C42B]00            	cmp	byte [fbs_shift], 0
  2052 000009D7 7650                    	jna	short lff_1 ; stereo, 16 bit
  2053                                  
  2054                                  	;mov	di, BUFFERSIZE - 1 ; 65535
  2055                                  
  2056                                  	;; fbs_shift =
  2057                                  	;;	2 for mono and 8 bit sample (multiplier = 4)
  2058                                  	;;	1 for mono or 8 bit sample (multiplier = 2)
  2059                                  	;shr	di, cl
  2060                                  	;inc	di ; 16384 for 8 bit and mono
  2061                                  	;	   ; 32768 for 8 bit or mono
  2062                                  	
  2063                                  	; 17/11/2024
  2064                                  	;mov	cx, [loadsize] ; 16380 or 32760
  2065                                  
  2066                                  	;mov	ax, cs
  2067 000009D9 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  2068                                  
  2069                                  	; 17/02/2017 (stereo/mono, 8bit/16bit corrections)
  2070                                  	; load file into memory
  2071                                  	;mov	cx, di ; 17/11/2024
  2072                                  	;mov	bx, [filehandle] ; 17/11/2024
  2073                                  	;mov    ds, ax
  2074 000009DC B43F                           	mov	ah, 3Fh
  2075 000009DE CD21                    	int	21h
  2076                                  
  2077                                  	;mov	bx, cs
  2078                                  	;mov	ds, bx
  2079                                  	; 17/11/2024
  2080                                  	;push	cs
  2081                                  	;pop	ds
  2082                                  
  2083 000009E0 7265                    	jc	lff_4 ; error !
  2084                                  
  2085                                  	; 14/11/2024
  2086 000009E2 A3[E42B]                	mov	[count], ax
  2087                                  
  2088                                  	; 17/11/2024
  2089                                  	; 08/11/2023
  2090                                  	;xor	dx, dx ; 0
  2091                                  
  2092 000009E5 21C0                    	and	ax, ax
  2093 000009E7 7455                    	jz	short lff_3
  2094                                  
  2095 000009E9 8A1E[C42B]              	mov	bl, [fbs_shift]
  2096                                  
  2097 000009ED 06                      	push	es
  2098                                  	;mov	di, dx ; 0 ; [fbs_off]
  2099                                  	; 17/11/2024
  2100                                  	; di = 0
  2101                                  	;mov	bp, [fbs_seg] ; buffer segment
  2102 000009EE 8EC5                    	mov	es, bp
  2103 000009F0 BE[EE2B]                	mov	si, temp_buffer ; temporary buffer address
  2104 000009F3 89C1                    	mov	cx, ax ; byte count
  2105 000009F5 803E[622B]08            	cmp	byte [WAVE_BitsPerSample], 8 ; bits per sample (8 or 16)
  2106 000009FA 751B                    	jne	short lff_7 ; 16 bit samples
  2107                                  	; 8 bit samples
  2108 000009FC FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
  2109 000009FE 740C                    	jz	short lff_6 ; 8 bit, stereo
  2110                                  lff_5:
  2111                                  	; mono & 8 bit
  2112 00000A00 AC                      	lodsb
  2113 00000A01 2C80                    	sub	al, 80h ; 08/11/2023
  2114 00000A03 C1E008                  	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
  2115 00000A06 AB                      	stosw	; left channel
  2116 00000A07 AB                      	stosw	; right channel
  2117 00000A08 E2F6                    	loop	lff_5
  2118 00000A0A EB12                    	jmp	short lff_9
  2119                                  lff_6:
  2120                                  	; stereo & 8 bit
  2121 00000A0C AC                      	lodsb
  2122 00000A0D 2C80                    	sub	al, 80h ; 08/11/2023
  2123 00000A0F C1E008                  	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
  2124 00000A12 AB                      	stosw
  2125 00000A13 E2F7                    	loop	lff_6
  2126 00000A15 EB07                    	jmp	short lff_9
  2127                                  lff_7:
  2128 00000A17 D1E9                    	shr	cx, 1 ; word count
  2129                                  lff_8:
  2130 00000A19 AD                      	lodsw
  2131 00000A1A AB                      	stosw	; left channel
  2132 00000A1B AB                      	stosw	; right channel
  2133 00000A1C E2FB                    	loop	lff_8
  2134                                  lff_9:
  2135 00000A1E 07                      	pop	es
  2136                                  	
  2137                                  	;or	di, di
  2138                                  	;jz	short endLFF ; 64KB ok 
  2139                                  	;mov	ax, di ; [fbs_off]
  2140                                  	;dec	ax
  2141                                  	; 17/11/2024
  2142 00000A1F 89F8                    	mov	ax, di 
  2143                                  	;cmp	ax, BUFFERSIZE ; 65520
  2144                                  	;jnb	short endLFF
  2145                                  
  2146                                  	;mov	cx, BUFFERSIZE - 1 ; 65535
  2147                                  	; 17/11/2024
  2148 00000A21 B9F0FF                  	mov	cx, BUFFERSIZE
  2149                                  	; 17/11/2024
  2150                                  	; ax = di
  2151 00000A24 39C8                    	cmp	ax, cx
  2152                                  	;jnb	short endLFF
  2153                                  	;jmp	short lff_3
  2154 00000A26 7216                    	jb	short lff_3
  2155 00000A28 C3                      	retn
  2156                                  	
  2157                                  lff_1:  
  2158                                  	;mov	bp, ax ; save buffer segment
  2159 00000A29 31D2                    	xor	dx, dx
  2160                                  	; load file into memory
  2161                                          ;mov	cx, (BUFFERSIZE / 2)	; 32k chunk
  2162                                  	
  2163                                  	; 17/11/2024
  2164                                  	;mov	cx, [buffersize] ; BUFFERSIZE / 2
  2165                                  	; 17/11/2024 (*)
  2166                                  	; cx = [loadsize] = 2*[buffersize]
  2167                                  
  2168                                  	;mov	bx, [filehandle] ; 17/11/2024
  2169 00000A2B 8ED8                    	mov     ds, ax ; mov ds, bp
  2170 00000A2D B43F                           	mov	ah, 3Fh
  2171 00000A2F CD21                    	int	21h
  2172                                  
  2173                                  	;mov	di, cs
  2174                                  	;mov	ds, di
  2175                                  	; 17/11/2024
  2176 00000A31 0E                      	push	cs
  2177 00000A32 1F                      	pop	ds
  2178                                  
  2179                                  	; 07/11/2023
  2180 00000A33 7212                    	jc	short lff_4 ; error !
  2181                                  
  2182                                  	; 14/11/2024
  2183 00000A35 A3[E42B]                	mov	[count], ax
  2184                                  	; 17/11/2024
  2185                                  	; di = 0
  2186                                  
  2187                                  ; 17/11/2024 (*)
  2188                                  %if 0	
  2189                                  	cmp	ax, cx
  2190                                  	jne	short lff_3
  2191                                  lff_2:
  2192                                  	; 08/11/2023
  2193                                  	add	dx, ax
  2194                                  	;;mov	cx, (BUFFERSIZE / 2)	; 32k chunk
  2195                                  	;mov	cx, [buffersize] ; BUFFERSIZE / 2
  2196                                  	;mov	bx, [filehandle]
  2197                                  	mov     ds, bp
  2198                                         	mov	ah, 3Fh
  2199                                  	int	21h
  2200                                  
  2201                                  	;;mov	di, cs
  2202                                  	;mov	ds, di
  2203                                  	; 17/11/2024
  2204                                  	push	cs
  2205                                  	pop	ds
  2206                                  
  2207                                  	jc	short lff_4 ; error !
  2208                                  
  2209                                  	; 17/11/2024
  2210                                  	; 14/11/2024
  2211                                  	add	[count], ax
  2212                                  %endif
  2213                                  
  2214 00000A38 39C8                    	cmp	ax, cx
  2215 00000A3A 740A                    	je	short endLFF
  2216                                  	; 17/11/2024
  2217                                  	; di = 0
  2218 00000A3C 89C7                    	mov	di, ax
  2219                                  lff_3:
  2220 00000A3E E80F00                  	call    padfill			; blank pad the remainder
  2221                                          ;clc				; don't exit with CY yet.
  2222 00000A41 800E[6C2B]01                    or	byte [flags], ENDOFFILE	; end of file flag
  2223                                  endLFF:
  2224 00000A46 C3                              retn
  2225                                  lff_4:
  2226                                  	; 08/11/2023
  2227 00000A47 B021                    	mov	al, '!'  ; error
  2228 00000A49 E816FB                  	call	tL0
  2229                                  
  2230 00000A4C 31C0                    	xor	ax, ax
  2231 00000A4E EBEE                    	jmp	short lff_3
  2232                                  
  2233                                  ; entry ds:ax points to last byte in file
  2234                                  ; cx = target size
  2235                                  ; note: must do byte size fill
  2236                                  ; destroys bx, cx
  2237                                  
  2238                                  padfill:
  2239                                  	; 14/12/2024
  2240                                  	; 17/11/2024
  2241                                  	;   di = offset (to be filled with ZEROs)
  2242                                  	;   bp = buffer segment
  2243                                  	;   ax = di = number of bytes loaded
  2244                                  	;   cx = buffer size (> loaded bytes)
  2245                                  	; 07/11/2023
  2246                                  	; 06/11/2023
  2247                                  	; 17/02/2017
  2248 00000A50 06                      	push	es
  2249                                          ;push	di
  2250                                  	;mov	di, [fbs_seg]
  2251                                  	;mov	es, di
  2252 00000A51 8EC5                            mov	es, bp
  2253 00000A53 29C1                    	sub	cx, ax
  2254                                  	; 08/11/2023
  2255                                  	;mov	di, ax ; (wrong)
  2256                                  	; 17/11/2024
  2257                                  	;mov	di, dx ; buffer offset
  2258                                  	;add	di, ax
  2259                                  	; 07/11/2023
  2260                                  	;add	di, [fbs_off]
  2261                                   	; 25/11/2024
  2262 00000A55 31C0                    	xor	ax, ax
  2263                                  	; 14/12/2024
  2264 00000A57 F3AA                    	rep	stosb
  2265                                  	;mov	[fbs_off], di
  2266                                  	;pop	di
  2267 00000A59 07                              pop	es
  2268 00000A5A C3                      	retn
  2269                                  
  2270                                  ; /////
  2271                                  
  2272                                  ; --------------------------------------------------------
  2273                                  ; --------------------------------------------------------
  2274                                  	
  2275                                  write_audio_dev_info:
  2276                                  	; 30/05/2024
  2277                                       	sys_msg msgAudioCardInfo, 0Fh
    37 00000A5B BE[F322]            <1>  mov si, %1
    38 00000A5E B30F                <1>  mov bl, %2
    39 00000A60 30FF                <1>  xor bh, bh
    40 00000A62 B40E                <1>  mov ah, 0Eh
    41 00000A64 E865F9              <1>  call p_msg
  2278 00000A67 C3                      	retn
  2279                                  
  2280                                  ; --------------------------------------------------------
  2281                                  
  2282                                  write_ac97_pci_dev_info:
  2283                                  	; 01/01/2025 (cgaplay.asm)
  2284                                  	; 19/11/2024
  2285                                  	; 30/05/2024
  2286                                  	; 06/06/2017
  2287                                  	; 03/06/2017
  2288                                  	; BUS/DEV/FN
  2289                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  2290                                  	; DEV/VENDOR
  2291                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  2292                                  
  2293 00000A68 66A1[CA2B]              	mov	eax, [dev_vendor]
  2294 00000A6C 30FF                    	xor	bh, bh
  2295 00000A6E 88C3                    	mov	bl, al
  2296 00000A70 88DA                    	mov	dl, bl
  2297 00000A72 80E30F                  	and	bl, 0Fh
  2298 00000A75 8A87[F923]              	mov	al, [bx+hex_chars]
  2299 00000A79 A2[4024]                	mov	[msgVendorId+3], al
  2300 00000A7C 88D3                    	mov	bl, dl
  2301 00000A7E C0EB04                  	shr	bl, 4
  2302 00000A81 8A87[F923]              	mov	al, [bx+hex_chars]
  2303 00000A85 A2[3F24]                	mov	[msgVendorId+2], al
  2304 00000A88 88E3                    	mov	bl, ah
  2305 00000A8A 88DA                    	mov	dl, bl
  2306 00000A8C 80E30F                  	and	bl, 0Fh
  2307 00000A8F 8A87[F923]              	mov	al, [bx+hex_chars]
  2308 00000A93 A2[3E24]                	mov	[msgVendorId+1], al
  2309 00000A96 88D3                    	mov	bl, dl
  2310 00000A98 C0EB04                  	shr	bl, 4
  2311 00000A9B 8A87[F923]              	mov	al, [bx+hex_chars]
  2312 00000A9F A2[3D24]                	mov	[msgVendorId], al
  2313 00000AA2 66C1E810                	shr	eax, 16
  2314 00000AA6 88C3                    	mov	bl, al
  2315 00000AA8 88DA                    	mov	dl, bl
  2316 00000AAA 80E30F                  	and	bl, 0Fh
  2317 00000AAD 8A87[F923]              	mov	al, [bx+hex_chars]
  2318 00000AB1 A2[5124]                	mov	[msgDevId+3], al
  2319 00000AB4 88D3                    	mov	bl, dl
  2320 00000AB6 C0EB04                  	shr	bl, 4
  2321 00000AB9 8A87[F923]              	mov	al, [bx+hex_chars]
  2322 00000ABD A2[5024]                	mov	[msgDevId+2], al
  2323 00000AC0 88E3                    	mov	bl, ah
  2324 00000AC2 88DA                    	mov	dl, bl
  2325 00000AC4 80E30F                  	and	bl, 0Fh
  2326 00000AC7 8A87[F923]              	mov	al, [bx+hex_chars]
  2327 00000ACB A2[4F24]                	mov	[msgDevId+1], al
  2328 00000ACE 88D3                    	mov	bl, dl
  2329 00000AD0 C0EB04                  	shr	bl, 4
  2330 00000AD3 8A87[F923]              	mov	al, [bx+hex_chars]
  2331 00000AD7 A2[4E24]                	mov	[msgDevId], al
  2332                                  
  2333 00000ADA 66A1[C62B]              	mov	eax, [bus_dev_fn]
  2334 00000ADE 66C1E808                	shr	eax, 8
  2335 00000AE2 88C3                    	mov	bl, al
  2336 00000AE4 88DA                    	mov	dl, bl
  2337 00000AE6 80E307                  	and	bl, 7 ; bit 0,1,2
  2338 00000AE9 8A87[F923]              	mov	al, [bx+hex_chars]
  2339 00000AED A2[7624]                	mov	[msgFncNo+1], al
  2340 00000AF0 88D3                    	mov	bl, dl
  2341 00000AF2 C0EB03                  	shr	bl, 3
  2342 00000AF5 88DA                    	mov	dl, bl
  2343 00000AF7 80E30F                  	and	bl, 0Fh
  2344 00000AFA 8A87[F923]              	mov	al, [bx+hex_chars]
  2345 00000AFE A2[6824]                	mov	[msgDevNo+1], al
  2346 00000B01 88D3                    	mov	bl, dl
  2347 00000B03 C0EB04                  	shr	bl, 4
  2348 00000B06 8A87[F923]              	mov	al, [bx+hex_chars]
  2349 00000B0A A2[6724]                	mov	[msgDevNo], al
  2350 00000B0D 88E3                    	mov	bl, ah
  2351 00000B0F 88DA                    	mov	dl, bl
  2352 00000B11 80E30F                  	and	bl, 0Fh
  2353 00000B14 8A87[F923]              	mov	al, [bx+hex_chars]
  2354 00000B18 A2[5C24]                	mov	[msgBusNo+1], al
  2355 00000B1B 88D3                    	mov	bl, dl
  2356 00000B1D C0EB04                  	shr	bl, 4
  2357 00000B20 8A87[F923]              	mov	al, [bx+hex_chars]
  2358 00000B24 A2[5B24]                	mov	[msgBusNo], al
  2359                                  
  2360                                  	;mov	ax, [ac97_NamBar]
  2361 00000B27 A1[CE2B]                	mov	ax, [NAMBAR]
  2362 00000B2A 88C3                    	mov	bl, al
  2363 00000B2C 88DA                    	mov	dl, bl
  2364 00000B2E 80E30F                  	and	bl, 0Fh
  2365 00000B31 8A87[F923]              	mov	al, [bx+hex_chars]
  2366 00000B35 A2[8624]                	mov	[msgNamBar+3], al
  2367 00000B38 88D3                    	mov	bl, dl
  2368 00000B3A C0EB04                  	shr	bl, 4
  2369 00000B3D 8A87[F923]              	mov	al, [bx+hex_chars]
  2370 00000B41 A2[8524]                	mov	[msgNamBar+2], al
  2371 00000B44 88E3                    	mov	bl, ah
  2372 00000B46 88DA                    	mov	dl, bl
  2373 00000B48 80E30F                  	and	bl, 0Fh
  2374 00000B4B 8A87[F923]              	mov	al, [bx+hex_chars]
  2375 00000B4F A2[8424]                	mov	[msgNamBar+1], al
  2376 00000B52 88D3                    	mov	bl, dl
  2377 00000B54 C0EB04                  	shr	bl, 4
  2378 00000B57 8A87[F923]              	mov	al, [bx+hex_chars]
  2379 00000B5B A2[8324]                	mov	[msgNamBar], al
  2380                                  
  2381                                  	;mov	ax, [ac97_NabmBar]
  2382 00000B5E A1[D02B]                	mov	ax, [NABMBAR]
  2383 00000B61 88C3                    	mov	bl, al
  2384 00000B63 88DA                    	mov	dl, bl
  2385 00000B65 80E30F                  	and	bl, 0Fh
  2386 00000B68 8A87[F923]              	mov	al, [bx+hex_chars]
  2387 00000B6C A2[9624]                	mov	[msgNabmBar+3], al
  2388 00000B6F 88D3                    	mov	bl, dl
  2389 00000B71 C0EB04                  	shr	bl, 4
  2390 00000B74 8A87[F923]              	mov	al, [bx+hex_chars]
  2391 00000B78 A2[9524]                	mov	[msgNabmBar+2], al
  2392 00000B7B 88E3                    	mov	bl, ah
  2393 00000B7D 88DA                    	mov	dl, bl
  2394 00000B7F 80E30F                  	and	bl, 0Fh
  2395 00000B82 8A87[F923]              	mov	al, [bx+hex_chars]
  2396 00000B86 A2[9424]                	mov	[msgNabmBar+1], al
  2397 00000B89 88D3                    	mov	bl, dl
  2398 00000B8B C0EB04                  	shr	bl, 4
  2399 00000B8E 8A87[F923]              	mov	al, [bx+hex_chars]
  2400 00000B92 A2[9324]                	mov	[msgNabmBar], al
  2401                                  
  2402 00000B95 6631C0                  	xor	eax, eax
  2403 00000B98 A0[6D2B]                	mov	al, [ac97_int_ln_reg]
  2404 00000B9B B10A                    	mov	cl, 10
  2405 00000B9D F6F1                    	div	cl
  2406                                  	; 23/11/2024
  2407                                  	;add	[msgIRQ], ax
  2408 00000B9F 053030                  	add	ax, 3030h
  2409 00000BA2 A3[9F24]                	mov	[msgIRQ], ax
  2410                                  	;and	al, al
  2411 00000BA5 3C30                    	cmp	al, 30h
  2412 00000BA7 7508                    	jnz	short _w_ac97imsg_
  2413 00000BA9 A0[A024]                	mov	al, byte [msgIRQ+1]
  2414 00000BAC B420                    	mov	ah, ' '
  2415 00000BAE A3[9F24]                	mov	[msgIRQ], ax
  2416                                  _w_ac97imsg_:
  2417                                  	; 19/11/2024
  2418 00000BB1 E88416                  	call 	clear_window
  2419                                  	;mov	dh, 13
  2420                                  	; 01/01/2025 (video mode 13h)
  2421 00000BB4 B60B                    	mov	dh, 11
  2422 00000BB6 B200                    	mov	dl, 0
  2423 00000BB8 E88914                  	call	setCursorPosition
  2424                                  	;;;
  2425                                  	; 30/05/2024
  2426                                  	sys_msg msgAC97Info, 07h
    37 00000BBB BE[0A24]            <1>  mov si, %1
    38 00000BBE B307                <1>  mov bl, %2
    39 00000BC0 30FF                <1>  xor bh, bh
    40 00000BC2 B40E                <1>  mov ah, 0Eh
    41 00000BC4 E805F8              <1>  call p_msg
  2427                                  
  2428                                  	; 19/11/2024
  2429                                          ;retn
  2430                                  
  2431                                  	; 30/05/2024
  2432                                  write_VRA_info:
  2433                                  	sys_msg	msgVRAheader, 07h
    37 00000BC7 BE[A424]            <1>  mov si, %1
    38 00000BCA B307                <1>  mov bl, %2
    39 00000BCC 30FF                <1>  xor bh, bh
    40 00000BCE B40E                <1>  mov ah, 0Eh
    41 00000BD0 E8F9F7              <1>  call p_msg
  2434 00000BD3 803E[3C2B]00            	cmp	byte [VRA], 0
  2435 00000BD8 760D                    	jna	short _w_VRAi_no
  2436                                  _w_VRAi_yes:
  2437                                  	sys_msg msgVRAyes, 07h
    37 00000BDA BE[B324]            <1>  mov si, %1
    38 00000BDD B307                <1>  mov bl, %2
    39 00000BDF 30FF                <1>  xor bh, bh
    40 00000BE1 B40E                <1>  mov ah, 0Eh
    41 00000BE3 E8E6F7              <1>  call p_msg
  2438 00000BE6 C3                      	retn
  2439                                  _w_VRAi_no:
  2440                                  	sys_msg msgVRAno, 07h
    37 00000BE7 BE[B924]            <1>  mov si, %1
    38 00000BEA B307                <1>  mov bl, %2
    39 00000BEC 30FF                <1>  xor bh, bh
    40 00000BEE B40E                <1>  mov ah, 0Eh
    41 00000BF0 E8D9F7              <1>  call p_msg
  2441 00000BF3 C3                      	retn
  2442                                  
  2443                                  ; --------------------------------------------------------
  2444                                  ; 02/02/2025 - playwav8.asm - ac97play.asm - cgaplay.asm 
  2445                                  ; 01/01/2025 - cgaplay.asm
  2446                                  ; 18/12/2024 - ac97play.asm
  2447                                  ; ----------
  2448                                  ; 30/05/2024 - playwav6.asm
  2449                                  ; 18/11/2023 - ich_wav3.asm & ich_wav4.asm
  2450                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  2451                                  ; 14/11/2023
  2452                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  2453                                  ; --------------------------------------------------------
  2454                                  
  2455                                  ;;Note:	At the end of every buffer load,
  2456                                  ;;	during buffer switch/swap, there will be discontinuity
  2457                                  ;;	between the last converted sample and the 1st sample
  2458                                  ;;	of the next buffer.
  2459                                  ;;	(like as a dot noises vaguely between normal sound samples)
  2460                                  ;;	-To avoid this defect, the 1st sample of
  2461                                  ;;	the next buffer may be read from the wav file but
  2462                                  ;;	the file pointer would need to be set to 1 sample back
  2463                                  ;;	again via seek system call. Time comsumption problem! -
  2464                                  ;;
  2465                                  ;;	Erdogan Tan - 15/11/2023
  2466                                  ;;
  2467                                  ;;	((If entire wav data would be loaded at once.. conversion
  2468                                  ;;	defect/noise would disappear.. but for DOS, to keep
  2469                                  ;;	64KB buffer limit is important also it is important
  2470                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  2471                                  ;;	I have tested this program by using 2-30MB wav files.))
  2472                                  ;;
  2473                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  2474                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  2475                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  2476                                  ;;			Realtek ALC850 codec.
  2477                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  2478                                  
  2479                                  load_8khz_mono_8_bit:
  2480                                  	; 02/02/2025
  2481                                  	; 15/11/2023
  2482                                  	; 14/11/2023
  2483                                  	; 13/11/2023
  2484 00000BF4 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  2485                                  					; last of the file?
  2486 00000BF9 7402                    	jz	short lff8m_0		; no
  2487 00000BFB F9                      	stc
  2488 00000BFC C3                      	retn
  2489                                  
  2490                                  lff8m_0:
  2491 00000BFD 8EC0                    	mov	es, ax ; buffer segment
  2492 00000BFF 31FF                    	xor	di, di
  2493 00000C01 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  2494                                  	; ds = cs
  2495                                  
  2496                                  	; load file into memory
  2497 00000C04 8B0E[DA2B]                      mov	cx, [loadsize]
  2498 00000C08 8B1E[6E2B]              	mov	bx, [filehandle]
  2499 00000C0C B43F                           	mov	ah, 3Fh
  2500 00000C0E CD21                    	int	21h
  2501                                  	;jc	short lff8m_5 ; error !
  2502                                  	; 14/11/2023
  2503 00000C10 7303                    	jnc	short lff8m_6
  2504 00000C12 E98E00                  	jmp	lff8m_5
  2505                                  
  2506                                  lff8m_6:
  2507                                  	; 14/11/2024
  2508 00000C15 A3[E42B]                	mov	[count], ax
  2509                                  
  2510 00000C18 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  2511 00000C1A 21C0                    	and	ax, ax
  2512                                  	;jz	short lff8m_3
  2513                                  	; 15/11/2023
  2514 00000C1C 747E                    	jz	short lff8_eof
  2515                                  
  2516 00000C1E 89C1                    	mov	cx, ax	; byte count
  2517                                  lff8m_1:
  2518 00000C20 AC                      	lodsb
  2519 00000C21 A2[611E]                	mov	[previous_val], al
  2520 00000C24 2C80                    	sub	al, 80h
  2521 00000C26 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2522 00000C29 AB                      	stosw		; original sample (left channel)
  2523 00000C2A AB                      	stosw		; original sample (right channel)
  2524                                  	;xor	ax, ax
  2525                                  	; 02/02/2025
  2526 00000C2B 8A04                    	mov	al, [si]
  2527 00000C2D 49                      	dec	cx
  2528 00000C2E 7502                    	jnz	short lff8m_2
  2529                                  	; 14/11/2023
  2530 00000C30 B080                    	mov	al, 80h
  2531                                  lff8m_2:
  2532                                  	;mov	[next_val], ax
  2533 00000C32 88C7                    	mov	bh, al	; [next_val]
  2534 00000C34 8A26[611E]              	mov	ah, [previous_val]
  2535 00000C38 00E0                    	add	al, ah	; [previous_val]
  2536 00000C3A D0D8                    	rcr	al, 1
  2537 00000C3C 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  2538 00000C3E 00E0                    	add	al, ah	; [previous_val]
  2539 00000C40 D0D8                    	rcr	al, 1	
  2540 00000C42 88C3                    	mov	bl, al 	; this is temporary interpolation value
  2541 00000C44 00E0                    	add	al, ah	; [previous_val]
  2542 00000C46 D0D8                    	rcr	al, 1
  2543 00000C48 2C80                    	sub	al, 80h
  2544 00000C4A C1E008                  	shl	ax, 8
  2545 00000C4D AB                      	stosw		; this is 1st interpolated sample (L)
  2546 00000C4E AB                      	stosw		; this is 1st interpolated sample (R)
  2547 00000C4F 88D8                    	mov	al, bl
  2548 00000C51 00D0                    	add	al, dl
  2549 00000C53 D0D8                    	rcr	al, 1
  2550 00000C55 2C80                    	sub	al, 80h
  2551 00000C57 C1E008                  	shl	ax, 8
  2552 00000C5A AB                      	stosw		; this is 2nd interpolated sample (L)
  2553 00000C5B AB                      	stosw		; this is 2nd interpolated sample (R)
  2554 00000C5C 88D0                    	mov	al, dl
  2555 00000C5E 2C80                    	sub	al, 80h
  2556 00000C60 C1E008                  	shl	ax, 8
  2557 00000C63 AB                      	stosw		; this is middle (3th) interpolated sample (L)
  2558 00000C64 AB                      	stosw		; this is middle (3th) interpolated sample (R)
  2559                                  	;mov	al, [next_val]
  2560 00000C65 88F8                    	mov	al, bh
  2561 00000C67 00D0                    	add	al, dl
  2562 00000C69 D0D8                    	rcr	al, 1
  2563 00000C6B 88C3                    	mov	bl, al	; this is temporary interpolation value
  2564 00000C6D 00D0                    	add	al, dl
  2565 00000C6F D0D8                    	rcr	al, 1
  2566 00000C71 2C80                    	sub	al, 80h
  2567 00000C73 C1E008                  	shl	ax, 8
  2568 00000C76 AB                      	stosw		; this is 4th interpolated sample (L)
  2569 00000C77 AB                      	stosw		; this is 4th interpolated sample (R)
  2570                                  	;mov	al, [next_val]
  2571 00000C78 88F8                    	mov	al, bh
  2572 00000C7A 00D8                    	add	al, bl
  2573 00000C7C D0D8                    	rcr	al, 1
  2574 00000C7E 2C80                    	sub	al, 80h
  2575 00000C80 C1E008                  	shl	ax, 8
  2576 00000C83 AB                      	stosw		; this is 5th interpolated sample (L)
  2577 00000C84 AB                      	stosw		; this is 5th interpolated sample (R)
  2578                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2579 00000C85 09C9                    	or	cx, cx
  2580 00000C87 7597                    	jnz	short lff8m_1
  2581                                  
  2582                                  	; --------------
  2583                                  
  2584                                  lff8s_3:
  2585                                  lff8m_3:
  2586                                  lff8s2_3:
  2587                                  lff8m2_3:
  2588                                  lff16s_3:
  2589                                  lff16m_3:
  2590                                  lff16s2_3:
  2591                                  lff16m2_3:
  2592                                  lff24_3:
  2593                                  lff32_3:
  2594                                  lff44_3:
  2595                                  lff22_3:
  2596                                  lff11_3:
  2597                                  lff12_3:	; 02/02/2025
  2598 00000C89 8B0E[DC2B]              	mov	cx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  2599 00000C8D D1E1                    	shl	cx, 1	; byte count
  2600 00000C8F 29F9                    	sub	cx, di
  2601 00000C91 7606                    	jna	short lff8m_4
  2602                                  	;inc	cx
  2603 00000C93 D1E9                    	shr	cx, 1
  2604 00000C95 31C0                    	xor	ax, ax	; fill (remain part of) buffer with zeros
  2605 00000C97 F3AB                    	rep	stosw
  2606                                  lff8m_4:
  2607 00000C99 0E                      	push	cs
  2608 00000C9A 07                      	pop	es
  2609 00000C9B C3                      	retn
  2610                                  
  2611                                  lff8_eof:
  2612                                  lff16_eof:
  2613                                  lff24_eof:
  2614                                  lff32_eof:
  2615                                  lff44_eof:
  2616                                  lff22_eof:
  2617                                  lff11_eof:
  2618                                  lff12_eof:	; 02/02/2025
  2619                                  	; 15/11/2023
  2620 00000C9C C606[6C2B]01            	mov	byte [flags], ENDOFFILE
  2621 00000CA1 EBE6                    	jmp	short lff8m_3
  2622                                  
  2623                                  lff8s_5:
  2624                                  lff8m_5:
  2625                                  lff8s2_5:
  2626                                  lff8m2_5:
  2627                                  lff16s_5:
  2628                                  lff16m_5:
  2629                                  lff16s2_5:
  2630                                  lff16m2_5:
  2631                                  lff24_5:
  2632                                  lff32_5:
  2633                                  lff44_5:
  2634                                  lff22_5:
  2635                                  lff11_5:
  2636                                  lff12_5:	; 02/02/2025
  2637 00000CA3 B021                    	mov	al, '!'  ; error
  2638 00000CA5 E8BAF8                  	call	tL0
  2639                                  	
  2640                                  	;jmp	short lff8m_3
  2641                                  	; 15/11/2023
  2642 00000CA8 EBF2                    	jmp	lff8_eof
  2643                                  
  2644                                  	; --------------
  2645                                  
  2646                                  load_8khz_stereo_8_bit:
  2647                                  	; 02/02/2025
  2648                                  	; 15/11/2023
  2649                                  	; 14/11/2023
  2650                                  	; 13/11/2023
  2651 00000CAA F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  2652                                  					; last of the file?
  2653 00000CAF 7402                    	jz	short lff8s_0		; no
  2654 00000CB1 F9                      	stc
  2655 00000CB2 C3                      	retn
  2656                                  
  2657                                  lff8s_0:
  2658 00000CB3 8EC0                    	mov	es, ax ; buffer segment
  2659 00000CB5 31FF                    	xor	di, di
  2660 00000CB7 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  2661                                  	; ds = cs
  2662                                  
  2663                                  	; load file into memory
  2664 00000CBA 8B0E[DA2B]                      mov	cx, [loadsize]
  2665 00000CBE 8B1E[6E2B]              	mov	bx, [filehandle]
  2666 00000CC2 B43F                           	mov	ah, 3Fh
  2667 00000CC4 CD21                    	int	21h
  2668 00000CC6 72DB                    	jc	short lff8s_5 ; error !
  2669                                  
  2670                                  	; 14/11/2024
  2671 00000CC8 A3[E42B]                	mov	[count], ax
  2672                                  
  2673 00000CCB 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  2674                                  	
  2675 00000CCD D1E8                    	shr	ax, 1
  2676                                  	;;and	ax, ax
  2677                                  	;jz	short lff8s_3
  2678                                  	; 15/11/2023
  2679 00000CCF 74CB                    	jz	short lff8_eof
  2680                                  
  2681 00000CD1 89C1                    	mov	cx, ax	; word count
  2682                                  lff8s_1:
  2683 00000CD3 AC                      	lodsb
  2684 00000CD4 A2[611E]                	mov	[previous_val_l], al
  2685 00000CD7 2C80                    	sub	al, 80h
  2686 00000CD9 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2687 00000CDC AB                      	stosw		; original sample (L)
  2688 00000CDD AC                      	lodsb
  2689 00000CDE A2[631E]                	mov	[previous_val_r], al
  2690 00000CE1 2C80                    	sub	al, 80h
  2691 00000CE3 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2692 00000CE6 AB                      	stosw		; original sample (R)
  2693                                  
  2694                                  	;xor	ax, ax
  2695                                  	; 02/02/2025
  2696 00000CE7 8B04                    	mov	ax, [si]
  2697 00000CE9 49                      	dec	cx
  2698 00000CEA 7503                    	jnz	short lff8s_2
  2699                                  		; convert 8 bit sample to 16 bit sample
  2700                                  	; 14/11/2023
  2701 00000CEC B88080                  	mov	ax, 8080h
  2702                                  lff8s_2:
  2703 00000CEF A2[651E]                	mov	[next_val_l], al
  2704 00000CF2 8826[671E]              	mov	[next_val_r], ah
  2705 00000CF6 8A26[611E]              	mov	ah, [previous_val_l]
  2706 00000CFA 00E0                    	add	al, ah
  2707 00000CFC D0D8                    	rcr	al, 1
  2708 00000CFE 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  2709 00000D00 00E0                    	add	al, ah
  2710 00000D02 D0D8                    	rcr	al, 1	
  2711 00000D04 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  2712 00000D06 00E0                    	add	al, ah
  2713 00000D08 D0D8                    	rcr	al, 1
  2714 00000D0A 2C80                    	sub	al, 80h
  2715 00000D0C C1E008                  	shl	ax, 8
  2716 00000D0F AB                      	stosw		; this is 1st interpolated sample (L)
  2717 00000D10 A0[671E]                	mov	al, [next_val_r]
  2718 00000D13 8A26[631E]              	mov	ah, [previous_val_r]
  2719 00000D17 00E0                    	add	al, ah
  2720 00000D19 D0D8                    	rcr	al, 1
  2721 00000D1B 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  2722 00000D1D 00E0                    	add	al, ah
  2723 00000D1F D0D8                    	rcr	al, 1
  2724 00000D21 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  2725 00000D23 00E0                    	add	al, ah
  2726 00000D25 D0D8                    	rcr	al, 1
  2727 00000D27 2C80                    	sub	al, 80h
  2728 00000D29 C1E008                  	shl	ax, 8
  2729 00000D2C AB                      	stosw		; this is 1st interpolated sample (R)
  2730 00000D2D 88D8                    	mov	al, bl
  2731 00000D2F 00D0                    	add	al, dl
  2732 00000D31 D0D8                    	rcr	al, 1
  2733 00000D33 2C80                    	sub	al, 80h
  2734 00000D35 C1E008                  	shl	ax, 8
  2735 00000D38 AB                      	stosw		; this is 2nd interpolated sample (L)
  2736 00000D39 88F8                    	mov	al, bh
  2737 00000D3B 00F0                    	add	al, dh
  2738 00000D3D D0D8                    	rcr	al, 1
  2739 00000D3F 2C80                    	sub	al, 80h
  2740 00000D41 C1E008                  	shl	ax, 8
  2741 00000D44 AB                      	stosw 		; this is 2nd interpolated sample (R)
  2742 00000D45 88D0                    	mov	al, dl
  2743 00000D47 2C80                    	sub	al, 80h
  2744 00000D49 C1E008                  	shl	ax, 8
  2745 00000D4C AB                      	stosw		; this is middle (3th) interpolated sample (L)
  2746 00000D4D 88F0                    	mov	al, dh
  2747 00000D4F 2C80                    	sub	al, 80h
  2748 00000D51 C1E008                  	shl	ax, 8
  2749 00000D54 AB                      	stosw		; this is middle (3th) interpolated sample (R)
  2750 00000D55 A0[651E]                	mov	al, [next_val_l]
  2751 00000D58 00D0                    	add	al, dl
  2752 00000D5A D0D8                    	rcr	al, 1
  2753 00000D5C 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  2754 00000D5E 00D0                    	add	al, dl
  2755 00000D60 D0D8                    	rcr	al, 1
  2756 00000D62 2C80                    	sub	al, 80h
  2757 00000D64 C1E008                  	shl	ax, 8
  2758 00000D67 AB                      	stosw		; this is 4th interpolated sample (L)
  2759 00000D68 A0[671E]                	mov	al, [next_val_r]
  2760 00000D6B 00F0                    	add	al, dh
  2761 00000D6D D0D8                    	rcr	al, 1
  2762 00000D6F 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  2763 00000D71 00F0                    	add	al, dh
  2764 00000D73 D0D8                    	rcr	al, 1
  2765 00000D75 2C80                    	sub	al, 80h
  2766 00000D77 C1E008                  	shl	ax, 8
  2767 00000D7A AB                      	stosw		; this is 4th interpolated sample (R)
  2768 00000D7B A0[651E]                	mov	al, [next_val_l]
  2769 00000D7E 00D8                    	add	al, bl
  2770 00000D80 D0D8                    	rcr	al, 1
  2771 00000D82 2C80                    	sub	al, 80h
  2772 00000D84 C1E008                  	shl	ax, 8
  2773 00000D87 AB                      	stosw		; this is 5th interpolated sample (L)
  2774 00000D88 A0[671E]                	mov	al, [next_val_r]
  2775 00000D8B 00F8                    	add	al, bh
  2776 00000D8D D0D8                    	rcr	al, 1
  2777 00000D8F 2C80                    	sub	al, 80h
  2778 00000D91 C1E008                  	shl	ax, 8
  2779 00000D94 AB                      	stosw		; this is 5th interpolated sample (R)
  2780                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2781 00000D95 E303                    	jcxz	lff8s_6
  2782 00000D97 E939FF                  	jmp	lff8s_1
  2783                                  lff8s_6:
  2784 00000D9A E9ECFE                  	jmp	lff8s_3
  2785                                  
  2786                                  load_8khz_mono_16_bit:
  2787                                  	; 02/02/2025
  2788                                  	; 13/11/2023
  2789 00000D9D F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  2790                                  					; last of the file?
  2791 00000DA2 7402                    	jz	short lff8m2_0		; no
  2792 00000DA4 F9                      	stc
  2793 00000DA5 C3                      	retn
  2794                                  
  2795                                  lff8m2_0:
  2796 00000DA6 8EC0                    	mov	es, ax ; buffer segment
  2797 00000DA8 31FF                    	xor	di, di
  2798 00000DAA BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  2799                                  	; ds = cs
  2800                                  
  2801                                  	; load file into memory
  2802 00000DAD 8B0E[DA2B]                      mov	cx, [loadsize]
  2803 00000DB1 8B1E[6E2B]              	mov	bx, [filehandle]
  2804 00000DB5 B43F                           	mov	ah, 3Fh
  2805 00000DB7 CD21                    	int	21h
  2806 00000DB9 7273                    	jc	short lff8m2_7 ; error !
  2807                                  
  2808                                  	; 14/11/2024
  2809 00000DBB A3[E42B]                	mov	[count], ax
  2810                                  
  2811 00000DBE 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  2812                                  	
  2813 00000DC0 D1E8                    	shr	ax, 1
  2814                                  	;and	ax, ax
  2815 00000DC2 7503                    	jnz	short lff8m2_8
  2816                                  	;jmp	lff8m2_3
  2817                                  	; 15/11/2023
  2818 00000DC4 E9D5FE                  	jmp	lff8_eof
  2819                                  
  2820                                  lff8m2_8:
  2821 00000DC7 89C1                    	mov	cx, ax	; word count
  2822                                  lff8m2_1:
  2823 00000DC9 AD                      	lodsw
  2824 00000DCA AB                      	stosw		; original sample (left channel)
  2825 00000DCB AB                      	stosw		; original sample (right channel)
  2826 00000DCC 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  2827 00000DCF A3[611E]                	mov	[previous_val], ax
  2828                                  	; 02/02/2025
  2829 00000DD2 8B04                    	mov	ax, [si]
  2830 00000DD4 49                      	dec	cx
  2831 00000DD5 7502                    	jnz	short lff8m2_2
  2832 00000DD7 31C0                    	xor	ax, ax
  2833                                  lff8m2_2:
  2834 00000DD9 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  2835 00000DDC 89C5                    	mov	bp, ax	; [next_val]
  2836 00000DDE 0306[611E]              	add	ax, [previous_val]
  2837 00000DE2 D1D8                    	rcr	ax, 1
  2838 00000DE4 89C2                    	mov	dx, ax	; this is interpolated middle (3th) sample
  2839 00000DE6 0306[611E]              	add	ax, [previous_val]
  2840 00000DEA D1D8                    	rcr	ax, 1	; this is temporary interpolation value
  2841 00000DEC 89C3                    	mov	bx, ax 		
  2842 00000DEE 0306[611E]              	add	ax, [previous_val]
  2843 00000DF2 D1D8                    	rcr	ax, 1
  2844 00000DF4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2845 00000DF7 AB                      	stosw		; this is 1st interpolated sample (L)
  2846 00000DF8 AB                      	stosw		; this is 1st interpolated sample (R)
  2847 00000DF9 89D8                    	mov	ax, bx
  2848 00000DFB 01D0                    	add	ax, dx
  2849 00000DFD D1D8                    	rcr	ax, 1
  2850 00000DFF 80EC80                  	sub	ah, 80h
  2851 00000E02 AB                      	stosw		; this is 2nd interpolated sample (L)
  2852 00000E03 AB                      	stosw		; this is 2nd interpolated sample (R)
  2853 00000E04 89D0                    	mov	ax, dx
  2854 00000E06 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2855 00000E09 AB                      	stosw		; this is middle (3th) interpolated sample (L)
  2856 00000E0A AB                      	stosw		; this is middle (3th) interpolated sample (R)
  2857 00000E0B 89E8                    	mov	ax, bp
  2858 00000E0D 01D0                    	add	ax, dx
  2859 00000E0F D1D8                    	rcr	ax, 1
  2860 00000E11 89C3                    	mov	bx, ax	; this is temporary interpolation value
  2861 00000E13 01D0                    	add	ax, dx
  2862 00000E15 D1D8                    	rcr	ax, 1
  2863 00000E17 80EC80                  	sub	ah, 80h
  2864 00000E1A AB                      	stosw		; this is 4th interpolated sample (L)
  2865 00000E1B AB                      	stosw		; this is 4th interpolated sample (R)
  2866 00000E1C 89E8                    	mov	ax, bp
  2867 00000E1E 01D8                    	add	ax, bx
  2868 00000E20 D1D8                    	rcr	ax, 1
  2869 00000E22 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2870 00000E25 AB                      	stosw		; this is 5th interpolated sample (L)
  2871 00000E26 AB                      	stosw		; this is 5th interpolated sample (R)
  2872                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2873 00000E27 09C9                    	or	cx, cx
  2874 00000E29 759E                    	jnz	short lff8m2_1
  2875 00000E2B E95BFE                  	jmp	lff8m2_3
  2876                                  
  2877                                  lff8m2_7:
  2878                                  lff8s2_7:
  2879 00000E2E E972FE                  	jmp	lff8m2_5  ; error
  2880                                  
  2881                                  load_8khz_stereo_16_bit:
  2882                                  	; 02/02/2025
  2883                                  	; 16/11/2023
  2884                                  	; 15/11/2023
  2885                                  	; 13/11/2023
  2886 00000E31 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  2887                                  					; last of the file?
  2888 00000E36 7402                    	jz	short lff8s2_0		; no
  2889 00000E38 F9                      	stc
  2890 00000E39 C3                      	retn
  2891                                  
  2892                                  lff8s2_0:
  2893 00000E3A 8EC0                    	mov	es, ax ; buffer segment
  2894 00000E3C 31FF                    	xor	di, di
  2895 00000E3E BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  2896                                  	; ds = cs
  2897                                  
  2898                                  	; load file into memory
  2899 00000E41 8B0E[DA2B]                      mov	cx, [loadsize]
  2900 00000E45 8B1E[6E2B]              	mov	bx, [filehandle]
  2901 00000E49 B43F                           	mov	ah, 3Fh
  2902 00000E4B CD21                    	int	21h
  2903 00000E4D 72DF                    	jc	short lff8s2_7 ; error !
  2904                                  
  2905                                  	; 14/11/2024
  2906 00000E4F A3[E42B]                	mov	[count], ax
  2907                                  
  2908 00000E52 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  2909                                  	
  2910 00000E54 C1E802                  	shr	ax, 2	; 16/11/2023
  2911                                  	;and	ax, ax
  2912 00000E57 7503                    	jnz	short lff8s2_8
  2913                                  	;jmp	lff8s2_3
  2914                                  	; 15/11/2023
  2915 00000E59 E940FE                  	jmp	lff8_eof
  2916                                  
  2917                                  lff8s2_8:
  2918 00000E5C 89C1                    	mov	cx, ax	; dword count
  2919                                  lff8s2_1:
  2920 00000E5E AD                      	lodsw
  2921 00000E5F AB                      	stosw		; original sample (L)
  2922                                  	; 15/11/2023
  2923 00000E60 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  2924 00000E63 A3[611E]                	mov	[previous_val_l], ax
  2925 00000E66 AD                      	lodsw
  2926 00000E67 AB                      	stosw		; original sample (R)
  2927 00000E68 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  2928 00000E6B A3[631E]                	mov	[previous_val_r], ax
  2929                                  	; 02/02/2025
  2930 00000E6E 8B04                    	mov	ax, [si]
  2931 00000E70 8B5402                  	mov	dx, [si+2]
  2932                                  	; 16/11/2023
  2933 00000E73 49                      	dec	cx
  2934 00000E74 7504                    	jnz	short lff8s2_2
  2935 00000E76 31D2                    	xor	dx, dx
  2936 00000E78 31C0                    	xor	ax, ax
  2937                                  lff8s2_2:
  2938 00000E7A 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  2939 00000E7D A3[651E]                	mov	[next_val_l], ax
  2940 00000E80 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  2941 00000E83 8916[671E]              	mov	[next_val_r], dx
  2942 00000E87 0306[611E]              	add	ax, [previous_val_l]
  2943 00000E8B D1D8                    	rcr	ax, 1
  2944 00000E8D 89C2                    	mov	dx, ax	; this is interpolated middle (3th) sample (L)
  2945 00000E8F 0306[611E]              	add	ax, [previous_val_l]
  2946 00000E93 D1D8                    	rcr	ax, 1	
  2947 00000E95 89C3                    	mov	bx, ax 	; this is temporary interpolation value (L)
  2948 00000E97 0306[611E]              	add	ax, [previous_val_l]
  2949 00000E9B D1D8                    	rcr	ax, 1
  2950 00000E9D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2951 00000EA0 AB                      	stosw		; this is 1st interpolated sample (L)
  2952 00000EA1 A1[671E]                	mov	ax, [next_val_r]
  2953 00000EA4 0306[631E]              	add	ax, [previous_val_r]
  2954 00000EA8 D1D8                    	rcr	ax, 1
  2955 00000EAA 89C5                    	mov	bp, ax	; this is interpolated middle (3th) sample (R)
  2956 00000EAC 0306[631E]              	add	ax, [previous_val_r]
  2957 00000EB0 D1D8                    	rcr	ax, 1
  2958 00000EB2 50                      	push	ax ; *	; this is temporary interpolation value (R)
  2959 00000EB3 0306[631E]              	add	ax, [previous_val_r]
  2960 00000EB7 D1D8                    	rcr	ax, 1
  2961 00000EB9 80EC80                  	sub	ah, 80h
  2962 00000EBC AB                      	stosw		; this is 1st interpolated sample (R)
  2963 00000EBD 89D8                    	mov	ax, bx
  2964 00000EBF 01D0                    	add	ax, dx
  2965 00000EC1 D1D8                    	rcr	ax, 1
  2966 00000EC3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2967 00000EC6 AB                      	stosw		; this is 2nd interpolated sample (L)
  2968 00000EC7 58                      	pop	ax ; *
  2969 00000EC8 01E8                    	add	ax, bp
  2970 00000ECA D1D8                    	rcr	ax, 1
  2971 00000ECC 80EC80                  	sub	ah, 80h
  2972 00000ECF AB                      	stosw 		; this is 2nd interpolated sample (R)
  2973 00000ED0 89D0                    	mov	ax, dx
  2974 00000ED2 80EC80                  	sub	ah, 80h
  2975 00000ED5 AB                      	stosw		; this is middle (3th) interpolated sample (L)
  2976 00000ED6 89E8                    	mov	ax, bp
  2977 00000ED8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2978 00000EDB AB                      	stosw		; this is middle (3th) interpolated sample (R)
  2979 00000EDC A1[651E]                	mov	ax, [next_val_l]
  2980 00000EDF 01D0                    	add	ax, dx
  2981 00000EE1 D1D8                    	rcr	ax, 1
  2982 00000EE3 89C3                    	mov	bx, ax	; this is temporary interpolation value (L)
  2983 00000EE5 01D0                    	add	ax, dx
  2984 00000EE7 D1D8                    	rcr	ax, 1
  2985 00000EE9 80EC80                  	sub	ah, 80h
  2986 00000EEC AB                      	stosw		; this is 4th interpolated sample (L)
  2987 00000EED A1[671E]                	mov	ax, [next_val_r]
  2988 00000EF0 01E8                    	add	ax, bp
  2989 00000EF2 D1D8                    	rcr	ax, 1
  2990 00000EF4 50                      	push	ax ; ** ; this is temporary interpolation value (R)
  2991 00000EF5 01E8                    	add	ax, bp
  2992 00000EF7 D1D8                    	rcr	ax, 1
  2993 00000EF9 80EC80                  	sub	ah, 80h
  2994 00000EFC AB                      	stosw		; this is 4th interpolated sample (R)
  2995 00000EFD A1[651E]                	mov	ax, [next_val_l]
  2996 00000F00 01D8                    	add	ax, bx
  2997 00000F02 D1D8                    	rcr	ax, 1
  2998 00000F04 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2999 00000F07 AB                      	stosw		; this is 5th interpolated sample (L)
  3000 00000F08 58                      	pop	ax ; **
  3001 00000F09 0306[671E]              	add	ax, [next_val_r]
  3002 00000F0D D1D8                    	rcr	ax, 1
  3003 00000F0F 80EC80                  	sub	ah, 80h
  3004 00000F12 AB                      	stosw		; this is 5th interpolated sample (R)
  3005                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3006 00000F13 E303                    	jcxz	lff8_s2_9
  3007 00000F15 E946FF                  	jmp	lff8s2_1
  3008                                  lff8_s2_9:
  3009 00000F18 E96EFD                  	jmp	lff8s2_3
  3010                                  
  3011                                  ; .....................
  3012                                  
  3013                                  load_16khz_mono_8_bit:
  3014                                  	; 02/02/2025
  3015                                  	; 14/11/2023
  3016                                  	; 13/11/2023
  3017 00000F1B F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3018                                  					; last of the file?
  3019 00000F20 7402                    	jz	short lff16m_0		; no
  3020 00000F22 F9                      	stc
  3021 00000F23 C3                      	retn
  3022                                  
  3023                                  lff16m_0:
  3024 00000F24 8EC0                    	mov	es, ax ; buffer segment
  3025 00000F26 31FF                    	xor	di, di
  3026 00000F28 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3027                                  	; ds = cs
  3028                                  
  3029                                  	; load file into memory
  3030 00000F2B 8B0E[DA2B]                      mov	cx, [loadsize]
  3031 00000F2F 8B1E[6E2B]              	mov	bx, [filehandle]
  3032 00000F33 B43F                           	mov	ah, 3Fh
  3033 00000F35 CD21                    	int	21h
  3034 00000F37 7246                    	jc	short lff16m_7 ; error !
  3035                                  
  3036                                  	; 14/11/2024
  3037 00000F39 A3[E42B]                	mov	[count], ax
  3038                                  
  3039 00000F3C 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3040                                  	
  3041 00000F3E 21C0                    	and	ax, ax
  3042 00000F40 7503                    	jnz	short lff16m_8
  3043                                  	;jmp	lff16m_3
  3044                                  	; 15/11/2023
  3045 00000F42 E957FD                  	jmp	lff16_eof
  3046                                  
  3047                                  lff16m_8:
  3048 00000F45 89C1                    	mov	cx, ax	; byte count
  3049                                  lff16m_1:
  3050 00000F47 AC                      	lodsb
  3051                                  	;mov	[previous_val], al
  3052 00000F48 88C3                    	mov	bl, al
  3053 00000F4A 2C80                    	sub	al, 80h
  3054 00000F4C C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3055 00000F4F AB                      	stosw		; original sample (left channel)
  3056 00000F50 AB                      	stosw		; original sample (right channel)
  3057                                  	;xor	ax, ax
  3058                                  	; 02/02/2025
  3059 00000F51 8A04                    	mov	al, [si]
  3060 00000F53 49                      	dec	cx
  3061 00000F54 7502                    	jnz	short lff16m_2
  3062                                  	; 14/11/2023
  3063 00000F56 B080                    	mov	al, 80h
  3064                                  lff16m_2:
  3065                                  	;mov	[next_val], al
  3066 00000F58 88C7                    	mov	bh, al
  3067                                  	;add	al, [previous_val]
  3068 00000F5A 00D8                    	add	al, bl
  3069 00000F5C D0D8                    	rcr	al, 1
  3070 00000F5E 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  3071                                  	;add	al, [previous_val]
  3072 00000F60 00D8                    	add	al, bl
  3073 00000F62 D0D8                    	rcr	al, 1
  3074 00000F64 2C80                    	sub	al, 80h
  3075 00000F66 C1E008                  	shl	ax, 8
  3076 00000F69 AB                      	stosw		; this is 1st interpolated sample (L)
  3077 00000F6A AB                      	stosw		; this is 1st interpolated sample (R)
  3078                                  	;mov	al, [next_val]
  3079 00000F6B 88F8                    	mov	al, bh
  3080 00000F6D 00D0                    	add	al, dl
  3081 00000F6F D0D8                    	rcr	al, 1
  3082 00000F71 2C80                    	sub	al, 80h
  3083 00000F73 C1E008                  	shl	ax, 8
  3084 00000F76 AB                      	stosw		; this is 2nd interpolated sample (L)
  3085 00000F77 AB                      	stosw		; this is 2nd interpolated sample (R)
  3086                                  	
  3087                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3088 00000F78 09C9                    	or	cx, cx
  3089 00000F7A 75CB                    	jnz	short lff16m_1
  3090 00000F7C E90AFD                  	jmp	lff16m_3
  3091                                  
  3092                                  lff16m_7:
  3093                                  lff16s_7:
  3094 00000F7F E921FD                  	jmp	lff16m_5  ; error
  3095                                  
  3096                                  load_16khz_stereo_8_bit:
  3097                                  	; 02/02/2025
  3098                                  	; 14/11/2023
  3099                                  	; 13/11/2023
  3100 00000F82 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3101                                  					; last of the file?
  3102 00000F87 7402                    	jz	short lff16s_0		; no
  3103 00000F89 F9                      	stc
  3104 00000F8A C3                      	retn
  3105                                  
  3106                                  lff16s_0:
  3107 00000F8B 8EC0                    	mov	es, ax ; buffer segment
  3108 00000F8D 31FF                    	xor	di, di
  3109 00000F8F BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3110                                  	; ds = cs
  3111                                  
  3112                                  	; load file into memory
  3113 00000F92 8B0E[DA2B]                      mov	cx, [loadsize]
  3114 00000F96 8B1E[6E2B]              	mov	bx, [filehandle]
  3115 00000F9A B43F                           	mov	ah, 3Fh
  3116 00000F9C CD21                    	int	21h
  3117 00000F9E 72DF                    	jc	short lff16s_7 ; error !
  3118                                  
  3119                                  	; 14/11/2024
  3120 00000FA0 A3[E42B]                	mov	[count], ax
  3121                                  
  3122 00000FA3 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3123                                  	
  3124 00000FA5 D1E8                    	shr	ax, 1
  3125                                  	;and	ax, ax
  3126 00000FA7 7503                    	jnz	short lff16s_8
  3127                                  	;jmp	lff16s_3
  3128                                  	; 15/11/2023
  3129 00000FA9 E9F0FC                  	jmp	lff16_eof
  3130                                  
  3131                                  lff16s_8:
  3132 00000FAC 89C1                    	mov	cx, ax	; word count
  3133                                  lff16s_1:
  3134 00000FAE AC                      	lodsb
  3135 00000FAF A2[611E]                	mov	[previous_val_l], al
  3136 00000FB2 2C80                    	sub	al, 80h
  3137 00000FB4 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3138 00000FB7 AB                      	stosw		; original sample (L)
  3139 00000FB8 AC                      	lodsb
  3140 00000FB9 A2[631E]                	mov	[previous_val_r], al
  3141 00000FBC 2C80                    	sub	al, 80h
  3142 00000FBE C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3143 00000FC1 AB                      	stosw		; original sample (R)
  3144                                  
  3145                                  	;xor	ax, ax
  3146                                  	; 02/02/2025
  3147 00000FC2 8B04                    	mov	ax, [si]
  3148 00000FC4 49                      	dec	cx
  3149 00000FC5 7503                    	jnz	short lff16s_2
  3150                                  		; convert 8 bit sample to 16 bit sample
  3151                                  	; 14/11/2023
  3152 00000FC7 B88080                  	mov	ax, 8080h
  3153                                  lff16s_2:
  3154                                  	;mov	[next_val_l], al
  3155                                  	;mov	[next_val_r], ah
  3156 00000FCA 89C3                    	mov	bx, ax
  3157 00000FCC 0206[611E]              	add	al, [previous_val_l]
  3158 00000FD0 D0D8                    	rcr	al, 1
  3159 00000FD2 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  3160 00000FD4 0206[611E]              	add	al, [previous_val_l]
  3161 00000FD8 D0D8                    	rcr	al, 1
  3162 00000FDA 2C80                    	sub	al, 80h
  3163 00000FDC C1E008                  	shl	ax, 8
  3164 00000FDF AB                      	stosw		; this is 1st interpolated sample (L)
  3165 00000FE0 88F8                    	mov	al, bh	; [next_val_r]
  3166 00000FE2 0206[631E]              	add	al, [previous_val_r]
  3167 00000FE6 D0D8                    	rcr	al, 1
  3168 00000FE8 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  3169 00000FEA 0206[631E]              	add	al, [previous_val_r]
  3170 00000FEE D0D8                    	rcr	al, 1
  3171 00000FF0 2C80                    	sub	al, 80h
  3172 00000FF2 C1E008                  	shl	ax, 8
  3173 00000FF5 AB                      	stosw		; this is 1st interpolated sample (R)
  3174 00000FF6 88D0                    	mov	al, dl
  3175 00000FF8 00D8                    	add	al, bl	; [next_val_l]
  3176 00000FFA D0D8                    	rcr	al, 1
  3177 00000FFC 2C80                    	sub	al, 80h
  3178 00000FFE C1E008                  	shl	ax, 8
  3179 00001001 AB                      	stosw		; this is 2nd interpolated sample (L)
  3180 00001002 88F0                    	mov	al, dh
  3181 00001004 00F8                    	add	al, bh	; [next_val_r]
  3182 00001006 D0D8                    	rcr	al, 1
  3183 00001008 2C80                    	sub	al, 80h
  3184 0000100A C1E008                  	shl	ax, 8
  3185 0000100D AB                      	stosw 		; this is 2nd interpolated sample (R)
  3186                                  	
  3187                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3188 0000100E 09C9                    	or	cx, cx
  3189 00001010 759C                    	jnz	short lff16s_1
  3190 00001012 E974FC                  	jmp	lff16s_3
  3191                                  
  3192                                  load_16khz_mono_16_bit:
  3193                                  	; 02/02/2025
  3194                                  	; 15/11/2023
  3195                                  	; 13/11/2023
  3196 00001015 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3197                                  					; last of the file?
  3198 0000101A 7402                    	jz	short lff16m2_0		; no
  3199 0000101C F9                      	stc
  3200 0000101D C3                      	retn
  3201                                  
  3202                                  lff16m2_0:
  3203 0000101E 8EC0                    	mov	es, ax ; buffer segment
  3204 00001020 31FF                    	xor	di, di
  3205 00001022 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3206                                  	; ds = cs
  3207                                  
  3208                                  	; load file into memory
  3209 00001025 8B0E[DA2B]                      mov	cx, [loadsize]
  3210 00001029 8B1E[6E2B]              	mov	bx, [filehandle]
  3211 0000102D B43F                           	mov	ah, 3Fh
  3212 0000102F CD21                    	int	21h
  3213 00001031 7243                    	jc	short lff16m2_7 ; error !
  3214                                  
  3215                                  	; 14/11/2024
  3216 00001033 A3[E42B]                	mov	[count], ax
  3217                                  
  3218 00001036 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3219                                  	
  3220 00001038 D1E8                    	shr	ax, 1
  3221                                  	;and	ax, ax
  3222 0000103A 7503                    	jnz	short lff16m2_8
  3223                                  	;jmp	lff16m2_3
  3224                                  	; 15/11/2023
  3225 0000103C E95DFC                  	jmp	lff16_eof
  3226                                  
  3227                                  lff16m2_8:
  3228 0000103F 89C1                    	mov	cx, ax	; word count
  3229                                  lff16m2_1:
  3230 00001041 AD                      	lodsw
  3231 00001042 AB                      	stosw		; original sample (left channel)
  3232 00001043 AB                      	stosw		; original sample (right channel)
  3233 00001044 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3234                                  	;mov	[previous_val], ax
  3235 00001047 89C3                    	mov	bx, ax	
  3236                                  	; 02/02/2025
  3237 00001049 8B04                    	mov	ax, [si]
  3238 0000104B 49                      	dec	cx
  3239 0000104C 7502                    	jnz	short lff16m2_2
  3240 0000104E 31C0                    	xor	ax, ax
  3241                                  lff16m2_2:
  3242 00001050 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3243 00001053 89C5                    	mov	bp, ax	; [next_val]
  3244                                  	;add	ax, [previous_val]
  3245 00001055 01D8                    	add	ax, bx
  3246 00001057 D1D8                    	rcr	ax, 1
  3247 00001059 89C2                    	mov	dx, ax	; this is temporary interpolation value
  3248                                  	;add	ax, [previous_val]
  3249 0000105B 01D8                    	add	ax, bx
  3250 0000105D D1D8                    	rcr	ax, 1
  3251 0000105F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3252 00001062 AB                      	stosw		; this is 1st interpolated sample (L)
  3253 00001063 AB                      	stosw		; this is 1st interpolated sample (R)
  3254 00001064 89E8                    	mov	ax, bp 
  3255 00001066 01D0                    	add	ax, dx
  3256 00001068 D1D8                    	rcr	ax, 1
  3257 0000106A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3258 0000106D AB                      	stosw		; this is 2nd interpolated sample (L)
  3259 0000106E AB                      	stosw		; this is 2nd interpolated sample (R)
  3260                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3261 0000106F 09C9                    	or	cx, cx
  3262 00001071 75CE                    	jnz	short lff16m2_1
  3263 00001073 E913FC                  	jmp	lff16m2_3
  3264                                  
  3265                                  lff16m2_7:
  3266                                  lff16s2_7:
  3267 00001076 E92AFC                  	jmp	lff16m2_5  ; error
  3268                                  
  3269                                  load_16khz_stereo_16_bit:
  3270                                  	; 02/02/2025
  3271                                  	; 16/11/2023
  3272                                  	; 15/11/2023
  3273                                  	; 13/11/2023
  3274 00001079 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3275                                  					; last of the file?
  3276 0000107E 7402                    	jz	short lff16s2_0		; no
  3277 00001080 F9                      	stc
  3278 00001081 C3                      	retn
  3279                                  
  3280                                  lff16s2_0:
  3281 00001082 8EC0                    	mov	es, ax ; buffer segment
  3282 00001084 31FF                    	xor	di, di
  3283 00001086 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3284                                  	; ds = cs
  3285                                  
  3286                                  	; load file into memory
  3287 00001089 8B0E[DA2B]                      mov	cx, [loadsize]
  3288 0000108D 8B1E[6E2B]              	mov	bx, [filehandle]
  3289 00001091 B43F                           	mov	ah, 3Fh
  3290 00001093 CD21                    	int	21h
  3291 00001095 72DF                    	jc	short lff16s2_7 ; error !
  3292                                  
  3293                                  	; 14/11/2024
  3294 00001097 A3[E42B]                	mov	[count], ax
  3295                                  
  3296 0000109A 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3297                                  	
  3298                                  	;shr	ax, 1
  3299 0000109C C1E802                  	shr	ax, 2	; 16/11/2023
  3300                                  	;and	ax, ax
  3301 0000109F 7503                    	jnz	short lff16s2_8
  3302                                  	;jmp	lff16s2_3
  3303                                  	; 15/11/2023
  3304 000010A1 E9F8FB                  	jmp	lff16_eof
  3305                                  
  3306                                  lff16s2_8:
  3307 000010A4 89C1                    	mov	cx, ax	; dword count
  3308                                  lff16s2_1:
  3309 000010A6 AD                      	lodsw
  3310 000010A7 AB                      	stosw		; original sample (L)
  3311 000010A8 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3312 000010AB A3[611E]                	mov	[previous_val_l], ax
  3313 000010AE AD                      	lodsw
  3314 000010AF AB                      	stosw		; original sample (R)
  3315 000010B0 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3316 000010B3 A3[631E]                	mov	[previous_val_r], ax
  3317                                  	; 02/02/2025
  3318 000010B6 8B04                    	mov	ax, [si]
  3319 000010B8 8B5402                  	mov	dx, [si+2]
  3320                                  	; 16/11/2023
  3321 000010BB 49                      	dec	cx
  3322 000010BC 7504                    	jnz	short lff16s2_2
  3323 000010BE 31D2                    	xor	dx, dx
  3324 000010C0 31C0                    	xor	ax, ax
  3325                                  lff16s2_2:
  3326 000010C2 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3327                                  	;mov	[next_val_l], ax
  3328 000010C5 89C5                    	mov	bp, ax
  3329 000010C7 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  3330 000010CA 8916[671E]              	mov	[next_val_r], dx
  3331 000010CE 0306[611E]              	add	ax, [previous_val_l]
  3332 000010D2 D1D8                    	rcr	ax, 1
  3333 000010D4 89C2                    	mov	dx, ax	; this is temporary interpolation value (L)
  3334 000010D6 0306[611E]              	add	ax, [previous_val_l]
  3335 000010DA D1D8                    	rcr	ax, 1
  3336 000010DC 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3337 000010DF AB                      	stosw		; this is 1st interpolated sample (L)
  3338 000010E0 A1[671E]                	mov	ax, [next_val_r]
  3339 000010E3 0306[631E]              	add	ax, [previous_val_r]
  3340 000010E7 D1D8                    	rcr	ax, 1
  3341 000010E9 89C3                    	mov	bx, ax	; this is temporary interpolation value (R)
  3342 000010EB 0306[631E]              	add	ax, [previous_val_r]
  3343 000010EF D1D8                    	rcr	ax, 1
  3344 000010F1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3345 000010F4 AB                      	stosw		; this is 1st interpolated sample (R)
  3346                                  	;mov	ax, [next_val_l]
  3347 000010F5 89E8                    	mov	ax, bp
  3348 000010F7 01D0                    	add	ax, dx
  3349 000010F9 D1D8                    	rcr	ax, 1
  3350 000010FB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3351 000010FE AB                      	stosw		; this is 2nd interpolated sample (L)
  3352 000010FF A1[671E]                	mov	ax, [next_val_r]
  3353 00001102 01D8                    	add	ax, bx
  3354 00001104 D1D8                    	rcr	ax, 1
  3355 00001106 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3356 00001109 AB                      	stosw 		; this is 2nd interpolated sample (R)
  3357                                  	
  3358                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3359 0000110A 09C9                    	or	cx, cx
  3360 0000110C 7598                    	jnz	short lff16s2_1
  3361 0000110E E978FB                  	jmp	lff16s2_3
  3362                                  
  3363                                  ; .....................
  3364                                  
  3365                                  load_24khz_mono_8_bit:
  3366                                  	; 02/02/2025
  3367                                  	; 15/11/2023
  3368 00001111 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3369                                  					; last of the file?
  3370 00001116 7402                    	jz	short lff24m_0		; no
  3371 00001118 F9                      	stc
  3372 00001119 C3                      	retn
  3373                                  
  3374                                  lff24m_0:
  3375 0000111A 8EC0                    	mov	es, ax ; buffer segment
  3376 0000111C 31FF                    	xor	di, di
  3377 0000111E BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3378                                  	; ds = cs
  3379                                  
  3380                                  	; load file into memory
  3381 00001121 8B0E[DA2B]                      mov	cx, [loadsize]
  3382 00001125 8B1E[6E2B]              	mov	bx, [filehandle]
  3383 00001129 B43F                           	mov	ah, 3Fh
  3384 0000112B CD21                    	int	21h
  3385 0000112D 7231                    	jc	short lff24m_7 ; error !
  3386                                  
  3387                                  	; 14/11/2024
  3388 0000112F A3[E42B]                	mov	[count], ax
  3389                                  
  3390 00001132 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3391                                  	
  3392 00001134 21C0                    	and	ax, ax
  3393 00001136 7503                    	jnz	short lff24m_8
  3394 00001138 E961FB                  	jmp	lff24_eof
  3395                                  
  3396                                  lff24m_8:
  3397 0000113B 89C1                    	mov	cx, ax	; byte count
  3398                                  lff24m_1:
  3399 0000113D AC                      	lodsb
  3400                                  	;mov	[previous_val], al
  3401 0000113E 88C3                    	mov	bl, al
  3402 00001140 2C80                    	sub	al, 80h
  3403 00001142 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3404 00001145 AB                      	stosw		; original sample (left channel)
  3405 00001146 AB                      	stosw		; original sample (right channel)
  3406                                  	;xor	ax, ax
  3407                                  	; 02/02/2025
  3408 00001147 8A04                    	mov	al, [si]
  3409 00001149 49                      	dec	cx
  3410 0000114A 7502                    	jnz	short lff24m_2
  3411 0000114C B080                    	mov	al, 80h
  3412                                  lff24m_2:
  3413                                  	;;mov	[next_val], al
  3414                                  	;mov	bh, al
  3415                                  	;add	al, [previous_val]
  3416 0000114E 00D8                    	add	al, bl
  3417 00001150 D0D8                    	rcr	al, 1
  3418 00001152 2C80                    	sub	al, 80h
  3419 00001154 C1E008                  	shl	ax, 8
  3420 00001157 AB                      	stosw		; this is interpolated sample (L)
  3421 00001158 AB                      	stosw		; this is interpolated sample (R)
  3422                                  	
  3423                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3424 00001159 09C9                    	or	cx, cx
  3425 0000115B 75E0                    	jnz	short lff24m_1
  3426 0000115D E929FB                  	jmp	lff24_3
  3427                                  
  3428                                  lff24m_7:
  3429                                  lff24s_7:
  3430 00001160 E940FB                  	jmp	lff24_5  ; error
  3431                                  
  3432                                  load_24khz_stereo_8_bit:
  3433                                  	; 02/02/2025
  3434                                  	; 15/11/2023
  3435 00001163 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3436                                  					; last of the file?
  3437 00001168 7402                    	jz	short lff24s_0		; no
  3438 0000116A F9                      	stc
  3439 0000116B C3                      	retn
  3440                                  
  3441                                  lff24s_0:
  3442 0000116C 8EC0                    	mov	es, ax ; buffer segment
  3443 0000116E 31FF                    	xor	di, di
  3444 00001170 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3445                                  	; ds = cs
  3446                                  
  3447                                  	; load file into memory
  3448 00001173 8B0E[DA2B]                      mov	cx, [loadsize]
  3449 00001177 8B1E[6E2B]              	mov	bx, [filehandle]
  3450 0000117B B43F                           	mov	ah, 3Fh
  3451 0000117D CD21                    	int	21h
  3452 0000117F 72DF                    	jc	short lff24s_7 ; error !
  3453                                  
  3454                                  	; 14/11/2024
  3455 00001181 A3[E42B]                	mov	[count], ax
  3456                                  
  3457 00001184 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3458                                  	
  3459 00001186 D1E8                    	shr	ax, 1
  3460                                  	;and	ax, ax
  3461 00001188 7503                    	jnz	short lff24s_8
  3462 0000118A E90FFB                  	jmp	lff24_eof
  3463                                  
  3464                                  lff24s_8:
  3465 0000118D 89C1                    	mov	cx, ax	; word count
  3466                                  lff24s_1:
  3467 0000118F AC                      	lodsb
  3468 00001190 A2[611E]                	mov	[previous_val_l], al
  3469 00001193 2C80                    	sub	al, 80h
  3470 00001195 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3471 00001198 AB                      	stosw		; original sample (L)
  3472 00001199 AC                      	lodsb
  3473 0000119A A2[631E]                	mov	[previous_val_r], al
  3474 0000119D 2C80                    	sub	al, 80h
  3475 0000119F C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3476 000011A2 AB                      	stosw		; original sample (R)
  3477                                  	;xor	ax, ax
  3478                                  	; 02/02/2025
  3479 000011A3 8B04                    	mov	ax, [si]
  3480 000011A5 49                      	dec	cx
  3481 000011A6 7503                    	jnz	short lff24s_2
  3482                                  		; convert 8 bit sample to 16 bit sample
  3483 000011A8 B88080                  	mov	ax, 8080h
  3484                                  lff24s_2:
  3485                                  	;;mov	[next_val_l], al
  3486                                  	;;mov	[next_val_r], ah
  3487                                  	;mov	bx, ax
  3488 000011AB 88E7                    	mov	bh, ah
  3489 000011AD 0206[611E]              	add	al, [previous_val_l]
  3490 000011B1 D0D8                    	rcr	al, 1
  3491                                  	;mov	dl, al
  3492 000011B3 2C80                    	sub	al, 80h
  3493 000011B5 C1E008                  	shl	ax, 8
  3494 000011B8 AB                      	stosw		; this is interpolated sample (L)
  3495 000011B9 88F8                    	mov	al, bh	; [next_val_r]
  3496 000011BB 0206[631E]              	add	al, [previous_val_r]
  3497 000011BF D0D8                    	rcr	al, 1
  3498                                  	;mov	dh, al
  3499 000011C1 2C80                    	sub	al, 80h
  3500 000011C3 C1E008                  	shl	ax, 8
  3501 000011C6 AB                      	stosw		; this is interpolated sample (R)
  3502                                  		
  3503                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3504 000011C7 09C9                    	or	cx, cx
  3505 000011C9 75C4                    	jnz	short lff24s_1
  3506 000011CB E9BBFA                  	jmp	lff24_3
  3507                                  
  3508                                  load_24khz_mono_16_bit:
  3509                                  	; 02/02/2025
  3510                                  	; 15/11/2023
  3511 000011CE F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3512                                  					; last of the file?
  3513 000011D3 7402                    	jz	short lff24m2_0		; no
  3514 000011D5 F9                      	stc
  3515 000011D6 C3                      	retn
  3516                                  
  3517                                  lff24m2_0:
  3518 000011D7 8EC0                    	mov	es, ax ; buffer segment
  3519 000011D9 31FF                    	xor	di, di
  3520 000011DB BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3521                                  	; ds = cs
  3522                                  
  3523                                  	; load file into memory
  3524 000011DE 8B0E[DA2B]                      mov	cx, [loadsize]
  3525 000011E2 8B1E[6E2B]              	mov	bx, [filehandle]
  3526 000011E6 B43F                           	mov	ah, 3Fh
  3527 000011E8 CD21                    	int	21h
  3528 000011EA 722E                    	jc	short lff24m2_7 ; error !
  3529                                  
  3530                                  	; 14/11/2024
  3531 000011EC A3[E42B]                	mov	[count], ax
  3532                                  
  3533 000011EF 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3534                                  	
  3535 000011F1 D1E8                    	shr	ax, 1
  3536                                  	;and	ax, ax
  3537 000011F3 7503                    	jnz	short lff24m2_8
  3538 000011F5 E9A4FA                  	jmp	lff24_eof
  3539                                  
  3540                                  lff24m2_8:
  3541 000011F8 89C1                    	mov	cx, ax	; word count
  3542                                  lff24m2_1:
  3543 000011FA AD                      	lodsw
  3544 000011FB AB                      	stosw		; original sample (left channel)
  3545 000011FC AB                      	stosw		; original sample (right channel)
  3546 000011FD 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3547                                  	;mov	[previous_val], ax
  3548                                  	;mov	bx, ax	
  3549                                  	;mov	ax, [si
  3550                                  	; 02/02/2025
  3551 00001200 8B1C                    	mov	bx, [si]
  3552 00001202 49                      	dec	cx
  3553 00001203 7502                    	jnz	short lff24m2_2
  3554                                  	;xor	ax, ax
  3555 00001205 31DB                    	xor	bx, bx
  3556                                  lff24m2_2:
  3557                                  	; 02/02/2025
  3558 00001207 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  3559                                  	;add	ah, 80h
  3560                                  	;mov	bp, ax	; [next_val]
  3561                                  	;add	ax, [previous_val]
  3562                                  	; ax = [previous_val]
  3563                                  	; bx = [next_val]
  3564 0000120A 01D8                    	add	ax, bx
  3565 0000120C D1D8                    	rcr	ax, 1
  3566 0000120E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3567 00001211 AB                      	stosw		; this is interpolated sample (L)
  3568 00001212 AB                      	stosw		; this is interpolated sample (R)
  3569                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3570 00001213 09C9                    	or	cx, cx
  3571 00001215 75E3                    	jnz	short lff24m2_1
  3572 00001217 E96FFA                  	jmp	lff24_3
  3573                                  
  3574                                  lff24m2_7:
  3575                                  lff24s2_7:
  3576 0000121A E986FA                  	jmp	lff24_5  ; error
  3577                                  
  3578                                  load_24khz_stereo_16_bit:
  3579                                  	; 02/02/2025
  3580                                  	; 16/11/2023
  3581                                  	; 15/11/2023
  3582 0000121D F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3583                                  					; last of the file?
  3584 00001222 7402                    	jz	short lff24s2_0		; no
  3585 00001224 F9                      	stc
  3586 00001225 C3                      	retn
  3587                                  
  3588                                  lff24s2_0:
  3589 00001226 8EC0                    	mov	es, ax ; buffer segment
  3590 00001228 31FF                    	xor	di, di
  3591 0000122A BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3592                                  	; ds = cs
  3593                                  
  3594                                  	; load file into memory
  3595 0000122D 8B0E[DA2B]                      mov	cx, [loadsize]
  3596 00001231 8B1E[6E2B]              	mov	bx, [filehandle]
  3597 00001235 B43F                           	mov	ah, 3Fh
  3598 00001237 CD21                    	int	21h
  3599 00001239 72DF                    	jc	short lff24s2_7 ; error !
  3600                                  
  3601                                  	; 14/11/2024
  3602 0000123B A3[E42B]                	mov	[count], ax
  3603                                  
  3604 0000123E 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3605                                  	
  3606                                  	;shr	ax, 1
  3607 00001240 C1E802                  	shr	ax, 2	; 16/11/2023
  3608                                  	;and	ax, ax
  3609 00001243 7503                    	jnz	short lff24s2_8
  3610 00001245 E954FA                  	jmp	lff24_eof
  3611                                  
  3612                                  lff24s2_8:
  3613 00001248 89C1                    	mov	cx, ax	; dword count
  3614                                  lff24s2_1:
  3615 0000124A AD                      	lodsw
  3616 0000124B AB                      	stosw		; original sample (L)
  3617 0000124C 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  3618 0000124F A3[611E]                	mov	[previous_val_l], ax
  3619 00001252 AD                      	lodsw
  3620 00001253 AB                      	stosw		; original sample (R)
  3621 00001254 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  3622                                  	;mov	[previous_val_r], ax
  3623 00001257 89C3                    	mov	bx, ax
  3624                                  	; 02/02/2025
  3625 00001259 8B04                    	mov	ax, [si]
  3626 0000125B 8B5402                  	mov	dx, [si+2]
  3627                                  	; 16/11/2023
  3628 0000125E 49                      	dec	cx
  3629 0000125F 7504                    	jnz	short lff24s2_2
  3630 00001261 31D2                    	xor	dx, dx
  3631 00001263 31C0                    	xor	ax, ax
  3632                                  lff24s2_2:
  3633 00001265 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  3634                                  	;;mov	[next_val_l], ax
  3635                                  	;mov	bp, ax
  3636 00001268 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  3637                                  	;mov	[next_val_r], dx
  3638 0000126B 0306[611E]              	add	ax, [previous_val_l]
  3639 0000126F D1D8                    	rcr	ax, 1
  3640 00001271 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3641 00001274 AB                      	stosw		; this is interpolated sample (L)
  3642                                  	;mov	ax, [next_val_r]
  3643 00001275 89D0                    	mov	ax, dx
  3644                                  	;add	ax, [previous_val_r]
  3645 00001277 01D8                    	add	ax, bx
  3646 00001279 D1D8                    	rcr	ax, 1
  3647 0000127B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3648 0000127E AB                      	stosw		; this is interpolated sample (R)
  3649                                  	
  3650                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3651 0000127F 09C9                    	or	cx, cx
  3652 00001281 75C7                    	jnz	short lff24s2_1
  3653 00001283 E903FA                  	jmp	lff24_3
  3654                                  
  3655                                  ; .....................
  3656                                  
  3657                                  load_32khz_mono_8_bit:
  3658                                  	; 02/02/2025
  3659                                  	; 15/11/2023
  3660 00001286 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3661                                  					; last of the file?
  3662 0000128B 7402                    	jz	short lff32m_0		; no
  3663 0000128D F9                      	stc
  3664 0000128E C3                      	retn
  3665                                  
  3666                                  lff32m_0:
  3667 0000128F 8EC0                    	mov	es, ax ; buffer segment
  3668 00001291 31FF                    	xor	di, di
  3669 00001293 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3670                                  	; ds = cs
  3671                                  
  3672                                  	; load file into memory
  3673 00001296 8B0E[DA2B]                      mov	cx, [loadsize]
  3674 0000129A 8B1E[6E2B]              	mov	bx, [filehandle]
  3675 0000129E B43F                           	mov	ah, 3Fh
  3676 000012A0 CD21                    	int	21h
  3677 000012A2 723A                    	jc	short lff32m_7 ; error !
  3678                                  
  3679                                  	; 14/11/2024
  3680 000012A4 A3[E42B]                	mov	[count], ax
  3681                                  
  3682 000012A7 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3683                                  	
  3684 000012A9 21C0                    	and	ax, ax
  3685 000012AB 7503                    	jnz	short lff32m_8
  3686 000012AD E9ECF9                  	jmp	lff32_eof
  3687                                  
  3688                                  lff32m_8:
  3689 000012B0 89C1                    	mov	cx, ax	; byte count
  3690                                  lff32m_1:
  3691 000012B2 AC                      	lodsb
  3692                                  	;mov	[previous_val], al
  3693 000012B3 88C3                    	mov	bl, al
  3694 000012B5 2C80                    	sub	al, 80h
  3695 000012B7 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3696 000012BA AB                      	stosw		; original sample (left channel)
  3697 000012BB AB                      	stosw		; original sample (right channel)
  3698                                  	;xor	ax, ax
  3699                                  	; 02/02/2025
  3700 000012BC 8A04                    	mov	al, [si]
  3701 000012BE 49                      	dec	cx
  3702 000012BF 7502                    	jnz	short lff32m_2
  3703 000012C1 B080                    	mov	al, 80h
  3704                                  lff32m_2:
  3705                                  	;;mov	[next_val], al
  3706                                  	;mov	bh, al
  3707                                  	;add	al, [previous_val]
  3708 000012C3 00D8                    	add	al, bl
  3709 000012C5 D0D8                    	rcr	al, 1
  3710 000012C7 2C80                    	sub	al, 80h
  3711 000012C9 C1E008                  	shl	ax, 8
  3712 000012CC AB                      	stosw		; this is interpolated sample (L)
  3713 000012CD AB                      	stosw		; this is interpolated sample (R)
  3714                                  	
  3715                                  	; different than 8-16-24 kHZ !
  3716                                  	; 'original-interpolated-original' trio samples
  3717 000012CE E30B                    	jcxz	lff32m_3
  3718                                  
  3719 000012D0 AC                      	lodsb
  3720 000012D1 2C80                    	sub	al, 80h
  3721 000012D3 C1E008                  	shl	ax, 8
  3722 000012D6 AB                      	stosw		; original sample (left channel)
  3723 000012D7 AB                      	stosw		; original sample (right channel)
  3724                                  
  3725                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3726 000012D8 49                      	dec	cx
  3727 000012D9 75D7                    	jnz	short lff32m_1
  3728                                  lff32m_3:
  3729 000012DB E9ABF9                  	jmp	lff32_3
  3730                                  
  3731                                  lff32m_7:
  3732                                  lff32s_7:
  3733 000012DE E9C2F9                  	jmp	lff32_5  ; error
  3734                                  
  3735                                  load_32khz_stereo_8_bit:
  3736                                  	; 02/02/2025
  3737                                  	; 15/11/2023
  3738 000012E1 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3739                                  					; last of the file?
  3740 000012E6 7402                    	jz	short lff32s_0		; no
  3741 000012E8 F9                      	stc
  3742 000012E9 C3                      	retn
  3743                                  
  3744                                  lff32s_0:
  3745 000012EA 8EC0                    	mov	es, ax ; buffer segment
  3746 000012EC 31FF                    	xor	di, di
  3747 000012EE BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3748                                  	; ds = cs
  3749                                  
  3750                                  	; load file into memory
  3751 000012F1 8B0E[DA2B]                      mov	cx, [loadsize]
  3752 000012F5 8B1E[6E2B]              	mov	bx, [filehandle]
  3753 000012F9 B43F                           	mov	ah, 3Fh
  3754 000012FB CD21                    	int	21h
  3755 000012FD 72DF                    	jc	short lff32s_7 ; error !
  3756                                  
  3757                                  	; 14/11/2024
  3758 000012FF A3[E42B]                	mov	[count], ax
  3759                                  
  3760 00001302 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3761                                  	
  3762 00001304 D1E8                    	shr	ax, 1
  3763                                  	;and	ax, ax
  3764 00001306 7503                    	jnz	short lff32s_8
  3765 00001308 E991F9                  	jmp	lff32_eof
  3766                                  
  3767                                  lff32s_8:
  3768 0000130B 89C1                    	mov	cx, ax	; word count
  3769                                  lff32s_1:
  3770 0000130D AC                      	lodsb
  3771 0000130E A2[611E]                	mov	[previous_val_l], al
  3772 00001311 2C80                    	sub	al, 80h
  3773 00001313 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3774 00001316 AB                      	stosw		; original sample (L)
  3775 00001317 AC                      	lodsb
  3776 00001318 A2[631E]                	mov	[previous_val_r], al
  3777 0000131B 2C80                    	sub	al, 80h
  3778 0000131D C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3779 00001320 AB                      	stosw		; original sample (R)
  3780                                  	; 02/02/2025
  3781 00001321 8B04                    	mov	ax, [si]
  3782 00001323 49                      	dec	cx
  3783 00001324 7503                    	jnz	short lff32s_2
  3784                                  		; convert 8 bit sample to 16 bit sample
  3785                                  	;xor	ax, ax
  3786 00001326 B88080                  	mov	ax, 8080h
  3787                                  lff32s_2:
  3788                                  	;;mov	[next_val_l], al
  3789                                  	;;mov	[next_val_r], ah
  3790                                  	;mov	bx, ax
  3791 00001329 88E7                    	mov	bh, ah
  3792 0000132B 0206[611E]              	add	al, [previous_val_l]
  3793 0000132F D0D8                    	rcr	al, 1
  3794                                  	;mov	dl, al
  3795 00001331 2C80                    	sub	al, 80h
  3796 00001333 C1E008                  	shl	ax, 8
  3797 00001336 AB                      	stosw		; this is interpolated sample (L)
  3798 00001337 88F8                    	mov	al, bh	; [next_val_r]
  3799 00001339 0206[631E]              	add	al, [previous_val_r]
  3800 0000133D D0D8                    	rcr	al, 1
  3801                                  	;mov	dh, al
  3802 0000133F 2C80                    	sub	al, 80h
  3803 00001341 C1E008                  	shl	ax, 8
  3804 00001344 AB                      	stosw		; this is interpolated sample (R)
  3805                                  
  3806                                  	; different than 8-16-24 kHZ !
  3807                                  	; 'original-interpolated-original' trio samples
  3808 00001345 E311                    	jcxz	lff32s_3
  3809                                  
  3810 00001347 AC                      	lodsb
  3811 00001348 2C80                    	sub	al, 80h
  3812 0000134A C1E008                  	shl	ax, 8
  3813 0000134D AB                      	stosw		; original sample (left channel)
  3814                                  
  3815 0000134E AC                      	lodsb
  3816 0000134F 2C80                    	sub	al, 80h
  3817 00001351 C1E008                  	shl	ax, 8
  3818 00001354 AB                      	stosw		; original sample (right channel)
  3819                                  		
  3820                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3821 00001355 49                      	dec	cx
  3822 00001356 75B5                    	jnz	short lff32s_1
  3823                                  lff32s_3:
  3824 00001358 E92EF9                  	jmp	lff32_3
  3825                                  
  3826                                  load_32khz_mono_16_bit:
  3827                                  	; 02/02/2025
  3828                                  	; 15/11/2023
  3829 0000135B F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3830                                  					; last of the file?
  3831 00001360 7402                    	jz	short lff32m2_0		; no
  3832 00001362 F9                      	stc
  3833 00001363 C3                      	retn
  3834                                  
  3835                                  lff32m2_0:
  3836 00001364 8EC0                    	mov	es, ax ; buffer segment
  3837 00001366 31FF                    	xor	di, di
  3838 00001368 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3839                                  	; ds = cs
  3840                                  
  3841                                  	; load file into memory
  3842 0000136B 8B0E[DA2B]                      mov	cx, [loadsize]
  3843 0000136F 8B1E[6E2B]              	mov	bx, [filehandle]
  3844 00001373 B43F                           	mov	ah, 3Fh
  3845 00001375 CD21                    	int	21h
  3846 00001377 7232                    	jc	short lff32m2_7 ; error !
  3847                                  
  3848                                  	; 14/11/2024
  3849 00001379 A3[E42B]                	mov	[count], ax
  3850                                  
  3851 0000137C 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3852                                  	
  3853 0000137E D1E8                    	shr	ax, 1
  3854                                  	;and	ax, ax
  3855 00001380 7503                    	jnz	short lff32m2_8
  3856 00001382 E917F9                  	jmp	lff32_eof
  3857                                  
  3858                                  lff32m2_8:
  3859 00001385 89C1                    	mov	cx, ax	; word count
  3860                                  lff32m2_1:
  3861 00001387 AD                      	lodsw
  3862 00001388 AB                      	stosw		; original sample (left channel)
  3863 00001389 AB                      	stosw		; original sample (right channel)
  3864 0000138A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3865                                  	;mov	[previous_val], ax
  3866                                  	;mov	bx, ax	
  3867                                  	; 02/02/2025
  3868                                  	;mov	ax, [si]
  3869 0000138D 8B1C                    	mov	bx, [si]
  3870 0000138F 49                      	dec	cx
  3871 00001390 7502                    	jnz	short lff32m2_2
  3872                                  	;xor	ax, ax
  3873 00001392 31DB                    	xor	bx, bx
  3874                                  lff32m2_2:
  3875                                  	; 02/02/2025
  3876 00001394 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  3877                                  	;add	ah, 80h
  3878                                  	;mov	bp, ax	; [next_val]
  3879                                  	;add	ax, [previous_val]
  3880                                  	; ax = [previous_val]
  3881                                  	; bx = [next_val]
  3882 00001397 01D8                    	add	ax, bx
  3883 00001399 D1D8                    	rcr	ax, 1
  3884 0000139B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3885 0000139E AB                      	stosw		; this is interpolated sample (L)
  3886 0000139F AB                      	stosw		; this is interpolated sample (R)
  3887                                  
  3888                                  	; different than 8-16-24 kHZ !
  3889                                  	; 'original-interpolated-original' trio samples
  3890 000013A0 E306                    	jcxz	lff32m2_3
  3891                                  
  3892 000013A2 AD                      	lodsw
  3893 000013A3 AB                      	stosw		; original sample (left channel)
  3894 000013A4 AB                      	stosw		; original sample (right channel)
  3895                                  
  3896                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3897 000013A5 49                      	dec	cx
  3898 000013A6 75DF                    	jnz	short lff32m2_1
  3899                                  lff32m2_3:
  3900 000013A8 E9DEF8                  	jmp	lff32_3
  3901                                  
  3902                                  lff32m2_7:
  3903                                  lff32s2_7:
  3904 000013AB E9F5F8                  	jmp	lff32_5  ; error
  3905                                  
  3906                                  load_32khz_stereo_16_bit:
  3907                                  	; 02/02/2025
  3908                                  	; 16/11/2023
  3909                                  	; 15/11/2023
  3910 000013AE F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3911                                  					; last of the file?
  3912 000013B3 7402                    	jz	short lff32s2_0		; no
  3913 000013B5 F9                      	stc
  3914 000013B6 C3                      	retn
  3915                                  
  3916                                  lff32s2_0:
  3917 000013B7 8EC0                    	mov	es, ax ; buffer segment
  3918 000013B9 31FF                    	xor	di, di
  3919 000013BB BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  3920                                  	; ds = cs
  3921                                  
  3922                                  	; load file into memory
  3923 000013BE 8B0E[DA2B]                      mov	cx, [loadsize]
  3924 000013C2 8B1E[6E2B]              	mov	bx, [filehandle]
  3925 000013C6 B43F                           	mov	ah, 3Fh
  3926 000013C8 CD21                    	int	21h
  3927 000013CA 72DF                    	jc	short lff32s2_7 ; error !
  3928                                  
  3929 000013CC 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  3930                                  	
  3931 000013CE C1E802                  	shr	ax, 2	; 16/11/2023 (word left ch + word right ch)
  3932                                  	;and	ax, ax
  3933 000013D1 7503                    	jnz	short lff32s2_8
  3934 000013D3 E9C6F8                  	jmp	lff32_eof
  3935                                  
  3936                                  lff32s2_8:
  3937 000013D6 89C1                    	mov	cx, ax	; dword count
  3938                                  lff32s2_1:
  3939 000013D8 AD                      	lodsw
  3940 000013D9 AB                      	stosw		; original sample (L)
  3941 000013DA 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3942 000013DD A3[611E]                	mov	[previous_val_l], ax
  3943 000013E0 AD                      	lodsw
  3944 000013E1 AB                      	stosw		; original sample (R)
  3945 000013E2 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3946                                  	;mov	[previous_val_r], ax
  3947 000013E5 89C3                    	mov	bx, ax
  3948                                  	; 02/02/2025
  3949 000013E7 8B04                    	mov	ax, [si]
  3950 000013E9 8B5402                  	mov	dx, [si+2]
  3951                                  	; 16/11/2023
  3952 000013EC 49                      	dec	cx
  3953 000013ED 7504                    	jnz	short lff32s2_2
  3954 000013EF 31D2                    	xor	dx, dx
  3955 000013F1 31C0                    	xor	ax, ax
  3956                                  lff32s2_2:
  3957 000013F3 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3958                                  	;;mov	[next_val_l], ax
  3959                                  	;mov	bp, ax
  3960 000013F6 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  3961                                  	;mov	[next_val_r], dx
  3962 000013F9 0306[611E]              	add	ax, [previous_val_l]
  3963 000013FD D1D8                    	rcr	ax, 1
  3964 000013FF 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3965 00001402 AB                      	stosw		; this is interpolated sample (L)
  3966                                  	;mov	ax, [next_val_r]
  3967 00001403 89D0                    	mov	ax, dx
  3968                                  	;add	ax, [previous_val_r]
  3969 00001405 01D8                    	add	ax, bx
  3970 00001407 D1D8                    	rcr	ax, 1
  3971 00001409 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3972 0000140C AB                      	stosw		; this is interpolated sample (R)
  3973                                  
  3974                                  	; different than 8-16-24 kHZ !
  3975                                  	; 'original-interpolated-original' trio samples
  3976 0000140D E307                    	jcxz	lff32s2_3
  3977                                  
  3978 0000140F AD                      	lodsw
  3979 00001410 AB                      	stosw	; original sample (L)
  3980 00001411 AD                      	lodsw
  3981 00001412 AB                      	stosw	; original sample (R)
  3982                                  	
  3983                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3984 00001413 49                      	dec	cx
  3985 00001414 75C2                    	jnz	short lff32s2_1
  3986                                  lff32s2_3:
  3987 00001416 E970F8                  	jmp	lff32_3
  3988                                  
  3989                                  ; .....................
  3990                                  
  3991                                  load_22khz_mono_8_bit:
  3992                                  	; 02/02/2025
  3993                                  	; 16/11/2023
  3994 00001419 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  3995                                  					; last of the file?
  3996 0000141E 7402                    	jz	short lff22m_0		; no
  3997 00001420 F9                      	stc
  3998 00001421 C3                      	retn
  3999                                  
  4000                                  lff22m_0:
  4001 00001422 8EC0                    	mov	es, ax ; buffer segment
  4002 00001424 31FF                    	xor	di, di
  4003 00001426 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4004                                  	; ds = cs
  4005                                  
  4006                                  	; load file into memory
  4007 00001429 8B0E[DA2B]                      mov	cx, [loadsize]
  4008 0000142D 8B1E[6E2B]              	mov	bx, [filehandle]
  4009 00001431 B43F                           	mov	ah, 3Fh
  4010 00001433 CD21                    	int	21h
  4011 00001435 724B                    	jc	short lff22m_7 ; error !
  4012                                  
  4013                                  	; 14/11/2024
  4014 00001437 A3[E42B]                	mov	[count], ax
  4015                                  
  4016 0000143A 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4017                                  	
  4018 0000143C 21C0                    	and	ax, ax
  4019 0000143E 7503                    	jnz	short lff22m_8
  4020 00001440 E959F8                  	jmp	lff22_eof
  4021                                  
  4022                                  lff22m_8:
  4023 00001443 89C1                    	mov	cx, ax	; byte count
  4024                                  lff22m_9:
  4025 00001445 BD0500                  	mov	bp, 5	; interpolation (one step) loop count
  4026 00001448 C606[691E]03            	mov	byte [faz], 3  ; 3 steps/phases
  4027                                  lff22m_1:
  4028                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4029 0000144D AC                      	lodsb
  4030                                  	; 02/02/2025
  4031 0000144E 8A14                    	mov	dl, [si]
  4032 00001450 49                      	dec	cx
  4033 00001451 7502                    	jnz	short lff22m_2_1
  4034 00001453 B280                    	mov	dl, 80h
  4035                                  lff22m_2_1:	
  4036                                  	; al = [previous_val]
  4037                                  	; dl = [next_val]
  4038 00001455 E8D405                  	call	interpolating_3_8bit_mono ; 1 of 17
  4039 00001458 E325                    	jcxz	lff22m_3
  4040                                  lff22m_2_2:
  4041 0000145A AC                      	lodsb
  4042                                  	; 02/02/2025
  4043 0000145B 8A14                    	mov	dl, [si]
  4044 0000145D 49                      	dec	cx
  4045 0000145E 7502                    	jnz	short lff22m_2_3
  4046 00001460 B280                    	mov	dl, 80h
  4047                                  lff22m_2_3:
  4048 00001462 E83C06                   	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  4049 00001465 E318                    	jcxz	lff22m_3
  4050 00001467 4D                      	dec	bp
  4051 00001468 75F0                    	jnz	short lff22m_2_2
  4052                                  
  4053 0000146A A0[691E]                	mov	al, [faz]
  4054 0000146D FEC8                    	dec	al
  4055 0000146F 74D4                    	jz	short lff22m_9
  4056 00001471 FE0E[691E]              	dec	byte [faz]
  4057 00001475 BD0400                  	mov	bp, 4
  4058 00001478 FEC8                    	dec	al
  4059 0000147A 75D1                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  4060 0000147C 45                      	inc	bp ; 5
  4061 0000147D EBCE                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4062                                  
  4063                                  lff22m_3:
  4064                                  lff22s_3:
  4065 0000147F E907F8                  	jmp	lff22_3	; padfill
  4066                                  		; (put zeros in the remain words of the buffer)
  4067                                  lff22m_7:
  4068                                  lff22s_7:
  4069 00001482 E91EF8                  	jmp	lff22_5  ; error
  4070                                  
  4071                                  load_22khz_stereo_8_bit:
  4072                                  	; 02/02/2025
  4073                                  	; 16/11/2023
  4074 00001485 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4075                                  					; last of the file?
  4076 0000148A 7402                    	jz	short lff22s_0		; no
  4077 0000148C F9                      	stc
  4078 0000148D C3                      	retn
  4079                                  
  4080                                  lff22s_0:
  4081 0000148E 8EC0                    	mov	es, ax ; buffer segment
  4082 00001490 31FF                    	xor	di, di
  4083 00001492 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4084                                  	; ds = cs
  4085                                  
  4086                                  	; load file into memory
  4087 00001495 8B0E[DA2B]                      mov	cx, [loadsize]
  4088 00001499 8B1E[6E2B]              	mov	bx, [filehandle]
  4089 0000149D B43F                           	mov	ah, 3Fh
  4090 0000149F CD21                    	int	21h
  4091 000014A1 72DF                    	jc	short lff22s_7 ; error !
  4092                                  
  4093                                  	; 14/11/2024
  4094 000014A3 A3[E42B]                	mov	[count], ax
  4095                                  
  4096 000014A6 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4097                                  	
  4098 000014A8 D1E8                    	shr	ax, 1
  4099                                  	;and	ax, ax
  4100 000014AA 7503                    	jnz	short lff22s_8
  4101 000014AC E9EDF7                  	jmp	lff22_eof
  4102                                  
  4103                                  lff22s_8:
  4104 000014AF 89C1                    	mov	cx, ax	; word count
  4105                                  lff22s_9:
  4106 000014B1 BD0500                  	mov	bp, 5	; interpolation (one step) loop count
  4107 000014B4 C606[691E]03            	mov	byte [faz], 3  ; 3 steps/phase
  4108                                  lff22s_1:
  4109                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4110 000014B9 AD                      	lodsw
  4111                                  	; 02/02/2025
  4112 000014BA 8B14                    	mov	dx, [si]
  4113 000014BC 49                      	dec	cx
  4114 000014BD 7503                    	jnz	short lff22s_2_1
  4115 000014BF BA8080                  	mov	dx, 8080h
  4116                                  lff22s_2_1:	
  4117                                  	; al = [previous_val_l]
  4118                                  	; ah = [previous_val_r]
  4119                                  	; dl = [next_val_l]
  4120                                  	; dl = [next_val_r]	
  4121 000014C2 E89105                  	call	interpolating_3_8bit_stereo ; 1 of 17
  4122 000014C5 E3B8                    	jcxz	lff22s_3
  4123                                  lff22s_2_2:
  4124 000014C7 AD                      	lodsw
  4125                                  	; 02/02/2025
  4126 000014C8 8B14                    	mov	dx, [si]
  4127 000014CA 49                      	dec	cx
  4128 000014CB 7503                    	jnz	short lff22s_2_3
  4129 000014CD BA8080                  	mov	dx, 8080h
  4130                                  lff22s_2_3:
  4131 000014D0 E8E505                   	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  4132 000014D3 E3AA                    	jcxz	lff22s_3
  4133 000014D5 4D                      	dec	bp
  4134 000014D6 75EF                    	jnz	short lff22s_2_2
  4135                                  
  4136 000014D8 A0[691E]                	mov	al, [faz]
  4137 000014DB FEC8                    	dec	al
  4138 000014DD 74D2                    	jz	short lff22s_9
  4139 000014DF FE0E[691E]              	dec	byte [faz]
  4140 000014E3 BD0400                  	mov	bp, 4
  4141 000014E6 FEC8                    	dec	al
  4142 000014E8 75CF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  4143 000014EA 45                      	inc	bp ; 5
  4144 000014EB EBCC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4145                                  
  4146                                  load_22khz_mono_16_bit:
  4147                                  	; 02/02/2025
  4148                                  	; 16/11/2023
  4149 000014ED F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4150                                  					; last of the file?
  4151 000014F2 7402                    	jz	short lff22m2_0		; no
  4152 000014F4 F9                      	stc
  4153 000014F5 C3                      	retn
  4154                                  
  4155                                  lff22m2_0:
  4156 000014F6 8EC0                    	mov	es, ax ; buffer segment
  4157 000014F8 31FF                    	xor	di, di
  4158 000014FA BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4159                                  	; ds = cs
  4160                                  
  4161                                  	; load file into memory
  4162 000014FD 8B0E[DA2B]                      mov	cx, [loadsize]
  4163 00001501 8B1E[6E2B]              	mov	bx, [filehandle]
  4164 00001505 B43F                           	mov	ah, 3Fh
  4165 00001507 CD21                    	int	21h
  4166 00001509 724B                    	jc	short lff22m2_7 ; error !
  4167                                  
  4168                                  	; 14/11/2024
  4169 0000150B A3[E42B]                	mov	[count], ax
  4170                                  
  4171 0000150E 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4172                                  	
  4173 00001510 D1E8                    	shr	ax, 1
  4174                                  	;and	ax, ax
  4175 00001512 7503                    	jnz	short lff22m2_8
  4176 00001514 E985F7                  	jmp	lff22_eof
  4177                                  
  4178                                  lff22m2_8:
  4179 00001517 89C1                    	mov	cx, ax	; word count
  4180                                  lff22m2_9:
  4181 00001519 BD0500                  	mov	bp, 5	; interpolation (one step) loop count
  4182 0000151C C606[691E]03            	mov	byte [faz], 3  ; 3 steps/phases
  4183                                  lff22m2_1:
  4184                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4185 00001521 AD                      	lodsw
  4186                                  	; 02/02/2025
  4187 00001522 8B14                    	mov	dx, [si]
  4188 00001524 49                      	dec	cx
  4189 00001525 7502                    	jnz	short lff22m2_2_1
  4190 00001527 31D2                    	xor	dx, dx
  4191                                  lff22m2_2_1:	
  4192                                  	; ax = [previous_val]
  4193                                  	; dx = [next_val]
  4194 00001529 E8B505                  	call	interpolating_3_16bit_mono ; 1 of 17
  4195 0000152C E325                    	jcxz	lff22m2_3
  4196                                  lff22m2_2_2:
  4197 0000152E AD                      	lodsw
  4198                                  	; 02/02/2025
  4199 0000152F 8B14                    	mov	dx, [si]
  4200 00001531 49                      	dec	cx
  4201 00001532 7502                    	jnz	short lff22m2_2_3
  4202 00001534 31D2                    	xor	dx, dx
  4203                                  lff22m2_2_3:
  4204 00001536 E81506                   	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  4205 00001539 E318                    	jcxz	lff22m2_3
  4206 0000153B 4D                      	dec	bp
  4207 0000153C 75F0                    	jnz	short lff22m2_2_2
  4208                                  
  4209 0000153E A0[691E]                	mov	al, [faz]
  4210 00001541 FEC8                    	dec	al
  4211 00001543 74D4                    	jz	short lff22m2_9
  4212 00001545 FE0E[691E]              	dec	byte [faz]
  4213 00001549 BD0400                  	mov	bp, 4
  4214 0000154C FEC8                    	dec	al
  4215 0000154E 75D1                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4216 00001550 45                      	inc	bp ; 5
  4217 00001551 EBCE                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4218                                  
  4219                                  lff22m2_3:
  4220                                  lff22s2_3:
  4221 00001553 E933F7                  	jmp	lff22_3	; padfill
  4222                                  		; (put zeros in the remain words of the buffer)
  4223                                  lff22m2_7:
  4224                                  lff22s2_7:
  4225 00001556 E94AF7                  	jmp	lff22_5  ; error
  4226                                  
  4227                                  load_22khz_stereo_16_bit:
  4228                                  	; 16/11/2023
  4229 00001559 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4230                                  					; last of the file?
  4231 0000155E 7402                    	jz	short lff22s2_0		; no
  4232 00001560 F9                      	stc
  4233 00001561 C3                      	retn
  4234                                  
  4235                                  lff22s2_0:
  4236 00001562 8EC0                    	mov	es, ax ; buffer segment
  4237 00001564 31FF                    	xor	di, di
  4238 00001566 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4239                                  	; ds = cs
  4240                                  
  4241                                  	; load file into memory
  4242 00001569 8B0E[DA2B]                      mov	cx, [loadsize]
  4243 0000156D 8B1E[6E2B]              	mov	bx, [filehandle]
  4244 00001571 B43F                           	mov	ah, 3Fh
  4245 00001573 CD21                    	int	21h
  4246 00001575 72DF                    	jc	short lff22s2_7 ; error !
  4247                                  
  4248                                  	; 14/11/2024
  4249 00001577 A3[E42B]                	mov	[count], ax
  4250                                  
  4251 0000157A 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4252                                  	
  4253 0000157C C1E802                  	shr	ax, 2	; dword (left chan word + right chan word)
  4254                                  	;and	ax, ax
  4255 0000157F 7503                    	jnz	short lff22s2_8
  4256 00001581 E918F7                  	jmp	lff22_eof
  4257                                  
  4258                                  lff22s2_8:
  4259 00001584 89C1                    	mov	cx, ax	; dword count
  4260                                  lff22s2_9:
  4261 00001586 BD0500                  	mov	bp, 5	; interpolation (one step) loop count
  4262 00001589 C606[691E]03            	mov	byte [faz], 3  ; 3 steps/phase
  4263                                  lff22s2_1:
  4264                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4265 0000158E AD                      	lodsw
  4266 0000158F 89C3                    	mov	bx, ax
  4267 00001591 AD                      	lodsw
  4268 00001592 8B14                    	mov	dx, [si]
  4269 00001594 8916[651E]              	mov	[next_val_l], dx
  4270 00001598 8B5402                  	mov	dx, [si+2]
  4271 0000159B 49                      	dec	cx
  4272 0000159C 7506                    	jnz	short lff22s2_2_1
  4273 0000159E 31D2                    	xor	dx, dx ; 0
  4274 000015A0 8916[651E]              	mov	[next_val_l], dx
  4275                                  lff22s2_2_1:
  4276                                  	; bx = [previous_val_l]
  4277                                  	; ax = [previous_val_r]
  4278                                  	; [next_val_l]
  4279                                  	; dx = [next_val_r]
  4280 000015A4 E85E05                  	call	interpolating_3_16bit_stereo ; 1 of 17 
  4281 000015A7 E3AA                    	jcxz	lff22s2_3
  4282                                  lff22s2_2_2:
  4283 000015A9 AD                      	lodsw
  4284 000015AA 89C3                    	mov	bx, ax
  4285 000015AC AD                      	lodsw
  4286 000015AD 8B14                    	mov	dx, [si]
  4287 000015AF 8916[651E]              	mov	[next_val_l], dx
  4288 000015B3 8B5402                  	mov	dx, [si+2]
  4289 000015B6 49                      	dec	cx
  4290 000015B7 7506                    	jnz	short lff22s2_2_3
  4291 000015B9 31D2                    	xor	dx, dx ; 0
  4292 000015BB 8916[651E]              	mov	[next_val_l], dx
  4293                                  lff22s2_2_3:
  4294 000015BF E89E05                   	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  4295 000015C2 E38F                    	jcxz	lff22s2_3
  4296 000015C4 4D                      	dec	bp
  4297 000015C5 75E2                    	jnz	short lff22s2_2_2
  4298                                  
  4299 000015C7 A0[691E]                	mov	al, [faz]
  4300 000015CA FEC8                    	dec	al
  4301 000015CC 74B8                    	jz	short lff22s2_9
  4302 000015CE FE0E[691E]              	dec	byte [faz]
  4303 000015D2 BD0400                  	mov	bp, 4
  4304 000015D5 FEC8                    	dec	al
  4305 000015D7 75B5                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4306 000015D9 45                      	inc	bp ; 5
  4307 000015DA EBB2                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4308                                  
  4309                                  ; .....................
  4310                                  
  4311                                  load_11khz_mono_8_bit:
  4312                                  	; 18/11/2023
  4313 000015DC F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4314                                  					; last of the file?
  4315 000015E1 7402                    	jz	short lff11m_0		; no
  4316 000015E3 F9                      	stc
  4317 000015E4 C3                      	retn
  4318                                  
  4319                                  lff11m_0:
  4320 000015E5 8EC0                    	mov	es, ax ; buffer segment
  4321 000015E7 31FF                    	xor	di, di
  4322 000015E9 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4323                                  	; ds = cs
  4324                                  
  4325                                  	; load file into memory
  4326 000015EC 8B0E[DA2B]                      mov	cx, [loadsize]
  4327 000015F0 8B1E[6E2B]              	mov	bx, [filehandle]
  4328 000015F4 B43F                           	mov	ah, 3Fh
  4329 000015F6 CD21                    	int	21h
  4330 000015F8 7240                    	jc	short lff11m_7 ; error !
  4331                                  
  4332                                  	; 14/11/2024
  4333 000015FA A3[E42B]                	mov	[count], ax
  4334                                  
  4335 000015FD 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4336                                  	
  4337 000015FF 21C0                    	and	ax, ax
  4338 00001601 7503                    	jnz	short lff11m_8
  4339 00001603 E996F6                  	jmp	lff11_eof
  4340                                  
  4341                                  lff11m_8:
  4342 00001606 89C1                    	mov	cx, ax	; byte count
  4343                                  lff11m_9:
  4344 00001608 BD0600                  	mov	bp, 6	; interpolation (one step) loop count
  4345                                  lff11m_1:
  4346                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4347 0000160B AC                      	lodsb
  4348                                  	; 02/02/2025
  4349 0000160C 8A14                    	mov	dl, [si]
  4350 0000160E 49                      	dec	cx
  4351 0000160F 7502                    	jnz	short lff11m_2_1
  4352 00001611 B280                    	mov	dl, 80h
  4353                                  lff11m_2_1:	
  4354                                  	; al = [previous_val]
  4355                                  	; dl = [next_val]
  4356 00001613 E87005                  	call	interpolating_5_8bit_mono
  4357 00001616 E31F                    	jcxz	lff11m_3
  4358                                  lff11m_2_2:
  4359 00001618 AC                      	lodsb
  4360                                  	; 02/02/2025
  4361 00001619 8A14                    	mov	dl, [si]
  4362 0000161B 49                      	dec	cx
  4363 0000161C 7502                    	jnz	short lff11m_2_3
  4364 0000161E B280                    	mov	dl, 80h
  4365                                  lff11m_2_3:
  4366 00001620 E84C06                   	call	interpolating_4_8bit_mono
  4367 00001623 E312                    	jcxz	lff11m_3
  4368                                  
  4369 00001625 4D                      	dec	bp
  4370 00001626 74E0                    	jz	short lff11m_9
  4371                                  
  4372 00001628 AC                      	lodsb
  4373                                  	; 02/02/2025
  4374 00001629 8A14                    	mov	dl, [si]
  4375 0000162B 49                      	dec	cx
  4376 0000162C 7502                    	jnz	short lff11m_2_4
  4377 0000162E B280                    	mov	dl, 80h
  4378                                  lff11m_2_4:
  4379 00001630 E83C06                  	call	interpolating_4_8bit_mono
  4380 00001633 E302                    	jcxz	lff11m_3
  4381 00001635 EBD4                    	jmp	short lff11m_1
  4382                                  
  4383                                  lff11m_3:
  4384                                  lff11s_3:
  4385 00001637 E94FF6                  	jmp	lff11_3	; padfill
  4386                                  		; (put zeros in the remain words of the buffer)
  4387                                  lff11m_7:
  4388                                  lff11s_7:
  4389 0000163A E966F6                  	jmp	lff11_5  ; error
  4390                                  
  4391                                  load_11khz_stereo_8_bit:
  4392                                  	; 02/02/2025
  4393                                  	; 18/11/2023
  4394 0000163D F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4395                                  					; last of the file?
  4396 00001642 7402                    	jz	short lff11s_0		; no
  4397 00001644 F9                      	stc
  4398 00001645 C3                      	retn
  4399                                  
  4400                                  lff11s_0:
  4401 00001646 8EC0                    	mov	es, ax ; buffer segment
  4402 00001648 31FF                    	xor	di, di
  4403 0000164A BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4404                                  	; ds = cs
  4405                                  
  4406                                  	; load file into memory
  4407 0000164D 8B0E[DA2B]                      mov	cx, [loadsize]
  4408 00001651 8B1E[6E2B]              	mov	bx, [filehandle]
  4409 00001655 B43F                           	mov	ah, 3Fh
  4410 00001657 CD21                    	int	21h
  4411 00001659 72DF                    	jc	short lff11s_7 ; error !
  4412                                  
  4413                                  	; 14/11/2024
  4414 0000165B A3[E42B]                	mov	[count], ax
  4415                                  
  4416 0000165E 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4417                                  	
  4418 00001660 D1E8                    	shr	ax, 1
  4419                                  	;and	ax, ax
  4420 00001662 7503                    	jnz	short lff11s_8
  4421 00001664 E935F6                  	jmp	lff11_eof
  4422                                  
  4423                                  lff11s_8:
  4424 00001667 89C1                    	mov	cx, ax	; word count
  4425                                  lff11s_9:
  4426 00001669 BD0600                  	mov	bp, 6	; interpolation (one step) loop count
  4427                                  lff11s_1:
  4428                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4429 0000166C AD                      	lodsw
  4430                                  	; 02/02/2025
  4431 0000166D 8B14                    	mov	dx, [si]
  4432 0000166F 49                      	dec	cx
  4433 00001670 7503                    	jnz	short lff11s_2_1
  4434 00001672 BA8080                  	mov	dx, 8080h
  4435                                  lff11s_2_1:	
  4436                                  	; al = [previous_val_l]
  4437                                  	; ah = [previous_val_r]
  4438                                  	; dl = [next_val_l]
  4439                                  	; dl = [next_val_r]	
  4440 00001675 E85E05                  	call	interpolating_5_8bit_stereo
  4441 00001678 E3BD                    	jcxz	lff11s_3
  4442                                  lff11s_2_2:
  4443 0000167A AD                      	lodsw
  4444                                  	; 02/02/2025
  4445 0000167B 8B14                    	mov	dx, [si]
  4446 0000167D 49                      	dec	cx
  4447 0000167E 7503                    	jnz	short lff11s_2_3
  4448 00001680 BA8080                  	mov	dx, 8080h
  4449                                  lff11s_2_3:
  4450 00001683 E81C06                   	call	interpolating_4_8bit_stereo
  4451 00001686 E3AF                    	jcxz	lff11s_3
  4452                                  	
  4453 00001688 4D                      	dec	bp
  4454 00001689 74DE                    	jz	short lff11s_9
  4455                                  
  4456 0000168B AD                      	lodsw
  4457                                  	; 02/02/2025
  4458 0000168C 8B14                    	mov	dx, [si]
  4459 0000168E 49                      	dec	cx
  4460 0000168F 7503                    	jnz	short lff11s_2_4
  4461 00001691 BA8080                  	mov	dx, 8080h
  4462                                  lff11s_2_4:
  4463 00001694 E80B06                  	call	interpolating_4_8bit_stereo
  4464 00001697 E39E                    	jcxz	lff11s_3
  4465 00001699 EBD1                    	jmp	short lff11s_1
  4466                                  
  4467                                  load_11khz_mono_16_bit:
  4468                                  	; 02/02/2025
  4469                                  	; 18/11/2023
  4470 0000169B F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4471                                  					; last of the file?
  4472 000016A0 7402                    	jz	short lff11m2_0		; no
  4473 000016A2 F9                      	stc
  4474 000016A3 C3                      	retn
  4475                                  
  4476                                  lff11m2_0:
  4477 000016A4 8EC0                    	mov	es, ax ; buffer segment
  4478 000016A6 31FF                    	xor	di, di
  4479 000016A8 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4480                                  	; ds = cs
  4481                                  
  4482                                  	; load file into memory
  4483 000016AB 8B0E[DA2B]                      mov	cx, [loadsize]
  4484 000016AF 8B1E[6E2B]              	mov	bx, [filehandle]
  4485 000016B3 B43F                           	mov	ah, 3Fh
  4486 000016B5 CD21                    	int	21h
  4487 000016B7 723D                    	jc	short lff11m2_7 ; error !
  4488                                  
  4489                                  	; 14/11/2024
  4490 000016B9 A3[E42B]                	mov	[count], ax
  4491                                  
  4492 000016BC 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4493                                  	
  4494 000016BE D1E8                    	shr	ax, 1
  4495                                  	;and	ax, ax
  4496 000016C0 7503                    	jnz	short lff11m2_8
  4497 000016C2 E9D7F5                  	jmp	lff11_eof
  4498                                  
  4499                                  lff11m2_8:
  4500 000016C5 89C1                    	mov	cx, ax	; word count
  4501                                  lff11m2_9:
  4502 000016C7 BD0600                  	mov	bp, 6	; interpolation (one step) loop count
  4503                                  lff11m2_1:
  4504                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4505 000016CA AD                      	lodsw
  4506                                  	; 02/02/2025
  4507 000016CB 8B14                    	mov	dx, [si]
  4508 000016CD 49                      	dec	cx
  4509 000016CE 7502                    	jnz	short lff11m2_2_1
  4510 000016D0 31D2                    	xor	dx, dx
  4511                                  lff11m2_2_1:	
  4512                                  	; ax = [previous_val]
  4513                                  	; dx = [next_val]
  4514 000016D2 E82A06                  	call	interpolating_5_16bit_mono
  4515 000016D5 E34D                    	jcxz	lff11m2_3
  4516                                  lff11m2_2_2:
  4517 000016D7 AD                      	lodsw
  4518                                  	; 02/02/2025
  4519 000016D8 8B14                    	mov	dx, [si]
  4520 000016DA 49                      	dec	cx
  4521 000016DB 7502                    	jnz	short lff11m2_2_3
  4522 000016DD 31D2                    	xor	dx, dx
  4523                                  lff11m2_2_3:
  4524 000016DF E8F806                   	call	interpolating_4_16bit_mono
  4525 000016E2 E340                    	jcxz	lff11m2_3
  4526                                  
  4527 000016E4 4D                      	dec	bp
  4528 000016E5 74E0                    	jz	short lff11m2_9
  4529                                  
  4530 000016E7 AD                      	lodsw
  4531                                  	; 02/02/2025
  4532 000016E8 8B14                    	mov	dx, [si]
  4533 000016EA 49                      	dec	cx
  4534 000016EB 7502                    	jnz	short lff11m2_2_4
  4535 000016ED 31D2                    	xor	dx, dx
  4536                                  lff11m2_2_4:
  4537 000016EF E8E806                   	call	interpolating_4_16bit_mono
  4538 000016F2 E330                    	jcxz	lff11m2_3
  4539 000016F4 EBD4                    	jmp	short lff11m2_1
  4540                                  
  4541                                  lff11m2_7:
  4542                                  lff11s2_7:
  4543 000016F6 E9AAF5                  	jmp	lff11_5  ; error
  4544                                  
  4545                                  load_11khz_stereo_16_bit:
  4546                                  	; 18/11/2023
  4547 000016F9 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4548                                  					; last of the file?
  4549 000016FE 7402                    	jz	short lff11s2_0		; no
  4550 00001700 F9                      	stc
  4551 00001701 C3                      	retn
  4552                                  
  4553                                  lff11s2_0:
  4554 00001702 8EC0                    	mov	es, ax ; buffer segment
  4555 00001704 31FF                    	xor	di, di
  4556 00001706 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4557                                  	; ds = cs
  4558                                  
  4559                                  	; load file into memory
  4560 00001709 8B0E[DA2B]                      mov	cx, [loadsize]
  4561 0000170D 8B1E[6E2B]              	mov	bx, [filehandle]
  4562 00001711 B43F                           	mov	ah, 3Fh
  4563 00001713 CD21                    	int	21h
  4564 00001715 72DF                    	jc	short lff11s2_7 ; error !
  4565                                  
  4566                                  	; 14/11/2024
  4567 00001717 A3[E42B]                	mov	[count], ax
  4568                                  
  4569 0000171A 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4570                                  	
  4571 0000171C C1E802                  	shr	ax, 2	; dword (left chan word + right chan word)
  4572                                  	;and	ax, ax
  4573 0000171F 7506                    	jnz	short lff11s2_8
  4574 00001721 E978F5                  	jmp	lff11_eof
  4575                                  
  4576                                  lff11m2_3:
  4577                                  lff11s2_3:
  4578 00001724 E962F5                  	jmp	lff11_3	; padfill
  4579                                  		; (put zeros in the remain words of the buffer)
  4580                                  
  4581                                  lff11s2_8:
  4582 00001727 89C1                    	mov	cx, ax	; dword count
  4583                                  lff11s2_9:
  4584 00001729 BD0600                  	mov	bp, 6	; interpolation (one step) loop count
  4585                                  lff11s2_1:
  4586                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4587 0000172C AD                      	lodsw
  4588 0000172D 89C3                    	mov	bx, ax
  4589 0000172F AD                      	lodsw
  4590 00001730 8B14                    	mov	dx, [si]
  4591 00001732 8916[651E]              	mov	[next_val_l], dx
  4592 00001736 8B5402                  	mov	dx, [si+2]
  4593 00001739 8916[671E]              	mov	[next_val_r], dx
  4594 0000173D 49                      	dec	cx
  4595 0000173E 750A                    	jnz	short lff11s2_2_1
  4596 00001740 31D2                    	xor	dx, dx ; 0
  4597 00001742 8916[651E]              	mov	[next_val_l], dx
  4598 00001746 8916[671E]              	mov	[next_val_r], dx
  4599                                  lff11s2_2_1:
  4600                                  	; bx = [previous_val_l]
  4601                                  	; ax = [previous_val_r]
  4602                                  	; [next_val_l]
  4603                                  	; dx = [next_val_r]
  4604 0000174A E8F505                  	call	interpolating_5_16bit_stereo
  4605 0000174D E3D5                    	jcxz	lff11s2_3
  4606                                  lff11s2_2_2:
  4607 0000174F AD                      	lodsw
  4608 00001750 89C3                    	mov	bx, ax
  4609 00001752 AD                      	lodsw
  4610 00001753 8B14                    	mov	dx, [si]
  4611 00001755 8916[651E]              	mov	[next_val_l], dx
  4612 00001759 8B5402                  	mov	dx, [si+2]
  4613 0000175C 8916[671E]              	mov	[next_val_r], dx
  4614 00001760 49                      	dec	cx
  4615 00001761 750A                    	jnz	short lff11s2_2_3
  4616 00001763 31D2                    	xor	dx, dx ; 0
  4617 00001765 8916[651E]              	mov	[next_val_l], dx
  4618 00001769 8916[671E]              	mov	[next_val_r], dx
  4619                                  lff11s2_2_3:
  4620 0000176D E89506                   	call	interpolating_4_16bit_stereo
  4621 00001770 E3B2                    	jcxz	lff11s2_3
  4622                                  	
  4623 00001772 4D                      	dec	bp
  4624 00001773 74B4                    	jz	short lff11s2_9
  4625                                  
  4626 00001775 AD                      	lodsw
  4627 00001776 89C3                    	mov	bx, ax
  4628 00001778 AD                      	lodsw
  4629 00001779 8B14                    	mov	dx, [si]
  4630 0000177B 8916[651E]              	mov	[next_val_l], dx
  4631 0000177F 8B5402                  	mov	dx, [si+2]
  4632 00001782 8916[671E]              	mov	[next_val_r], dx
  4633 00001786 49                      	dec	cx
  4634 00001787 750A                    	jnz	short lff11s2_2_4
  4635 00001789 31D2                    	xor	dx, dx ; 0
  4636 0000178B 8916[651E]              	mov	[next_val_l], dx
  4637 0000178F 8916[671E]              	mov	[next_val_r], dx
  4638                                  lff11s2_2_4:
  4639 00001793 E86F06                   	call	interpolating_4_16bit_stereo
  4640 00001796 E38C                    	jcxz	lff11s2_3
  4641 00001798 EB92                    	jmp	short lff11s2_1
  4642                                  
  4643                                  ; .....................
  4644                                  
  4645                                  load_44khz_mono_8_bit:
  4646                                  	; 02/02/2025
  4647                                  	; 18/11/2023
  4648 0000179A F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4649                                  					; last of the file?
  4650 0000179F 7402                    	jz	short lff44m_0		; no
  4651 000017A1 F9                      	stc
  4652 000017A2 C3                      	retn
  4653                                  
  4654                                  lff44m_0:
  4655 000017A3 8EC0                    	mov	es, ax ; buffer segment
  4656 000017A5 31FF                    	xor	di, di
  4657 000017A7 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4658                                  	; ds = cs
  4659                                  
  4660                                  	; load file into memory
  4661 000017AA 8B0E[DA2B]                      mov	cx, [loadsize]
  4662 000017AE 8B1E[6E2B]              	mov	bx, [filehandle]
  4663 000017B2 B43F                           	mov	ah, 3Fh
  4664 000017B4 CD21                    	int	21h
  4665 000017B6 723F                    	jc	short lff44m_7 ; error !
  4666                                  
  4667                                  	; 14/11/2024
  4668 000017B8 A3[E42B]                	mov	[count], ax
  4669                                  
  4670 000017BB 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4671                                  	
  4672 000017BD 21C0                    	and	ax, ax
  4673 000017BF 7503                    	jnz	short lff44m_8
  4674 000017C1 E9D8F4                  	jmp	lff44_eof
  4675                                  
  4676                                  lff44m_8:
  4677 000017C4 89C1                    	mov	cx, ax	; byte count
  4678                                  lff44m_9:
  4679 000017C6 BD0A00                  	mov	bp, 10	; interpolation (one step) loop count
  4680 000017C9 C606[691E]02            	mov	byte [faz], 2  ; 2 steps/phases
  4681                                  lff44m_1:
  4682                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  4683                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  4684 000017CE AC                      	lodsb
  4685                                  	; 02/02/2025
  4686 000017CF 8A14                    	mov	dl, [si]
  4687 000017D1 49                      	dec	cx
  4688 000017D2 7502                    	jnz	short lff44m_2_1
  4689 000017D4 B280                    	mov	dl, 80h
  4690                                  lff44m_2_1:	
  4691                                  	; al = [previous_val]
  4692                                  	; dl = [next_val]
  4693 000017D6 E8C802                  	call	interpolating_2_8bit_mono
  4694 000017D9 E319                    	jcxz	lff44m_3
  4695                                  lff44m_2_2:
  4696 000017DB AC                      	lodsb
  4697 000017DC 2C80                    	sub	al, 80h
  4698 000017DE C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4699 000017E1 AB                      	stosw		; (L)
  4700 000017E2 AB                      	stosw		; (R)	
  4701                                  
  4702 000017E3 49                      	dec	cx
  4703 000017E4 740E                    	jz	short lff44m_3	
  4704 000017E6 4D                      	dec	bp
  4705 000017E7 75F2                    	jnz	short lff44m_2_2
  4706                                  	
  4707 000017E9 FE0E[691E]              	dec	byte [faz]
  4708 000017ED 74D7                    	jz	short lff44m_9 
  4709 000017EF BD0B00                  	mov	bp, 11
  4710 000017F2 EBDA                    	jmp	short lff44m_1
  4711                                  
  4712                                  lff44m_3:
  4713                                  lff44s_3:
  4714 000017F4 E992F4                  	jmp	lff44_3	; padfill
  4715                                  		; (put zeros in the remain words of the buffer)
  4716                                  lff44m_7:
  4717                                  lff44s_7:
  4718 000017F7 E9A9F4                  	jmp	lff44_5  ; error
  4719                                  
  4720                                  load_44khz_stereo_8_bit:
  4721                                  	; 02/02/2025
  4722                                  	; 16/11/2023
  4723 000017FA F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4724                                  					; last of the file?
  4725 000017FF 7402                    	jz	short lff44s_0		; no
  4726 00001801 F9                      	stc
  4727 00001802 C3                      	retn
  4728                                  
  4729                                  lff44s_0:
  4730 00001803 8EC0                    	mov	es, ax ; buffer segment
  4731 00001805 31FF                    	xor	di, di
  4732 00001807 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4733                                  	; ds = cs
  4734                                  
  4735                                  	; load file into memory
  4736 0000180A 8B0E[DA2B]                      mov	cx, [loadsize]
  4737 0000180E 8B1E[6E2B]              	mov	bx, [filehandle]
  4738 00001812 B43F                           	mov	ah, 3Fh
  4739 00001814 CD21                    	int	21h
  4740 00001816 72DF                    	jc	short lff44s_7 ; error !
  4741                                  
  4742                                  	; 14/11/2024
  4743 00001818 A3[E42B]                	mov	[count], ax
  4744                                  
  4745 0000181B 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4746                                  	
  4747 0000181D D1E8                    	shr	ax, 1
  4748                                  	;and	ax, ax
  4749 0000181F 7503                    	jnz	short lff44s_8
  4750 00001821 E978F4                  	jmp	lff44_eof
  4751                                  
  4752                                  lff44s_8:
  4753 00001824 89C1                    	mov	cx, ax	; word count
  4754                                  lff44s_9:
  4755 00001826 BD0A00                  	mov	bp, 10	; interpolation (one step) loop count
  4756 00001829 C606[691E]02            	mov	byte [faz], 2  ; 2 steps/phase
  4757                                  lff44s_1:
  4758                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  4759                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  4760 0000182E AD                      	lodsw
  4761                                  	; 02/02/2025
  4762 0000182F 8B14                    	mov	dx, [si]
  4763 00001831 49                      	dec	cx
  4764 00001832 7503                    	jnz	short lff44s_2_1
  4765 00001834 BA8080                  	mov	dx, 8080h
  4766                                  lff44s_2_1:	
  4767                                  	; al = [previous_val_l]
  4768                                  	; ah = [previous_val_r]
  4769                                  	; dl = [next_val_l]
  4770                                  	; dl = [next_val_r]	
  4771 00001837 E87E02                  	call	interpolating_2_8bit_stereo
  4772 0000183A E3B8                    	jcxz	lff44s_3
  4773                                  lff44s_2_2:
  4774 0000183C AC                      	lodsb
  4775 0000183D 2C80                    	sub	al, 80h
  4776 0000183F C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4777 00001842 AB                      	stosw		; (L)
  4778 00001843 AC                      	lodsb
  4779 00001844 2C80                    	sub	al, 80h
  4780 00001846 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4781 00001849 AB                      	stosw		; (R)
  4782                                  
  4783 0000184A 49                      	dec	cx
  4784 0000184B 74A7                    	jz	short lff44s_3	
  4785 0000184D 4D                      	dec	bp
  4786 0000184E 75EC                    	jnz	short lff44s_2_2
  4787                                  	
  4788 00001850 FE0E[691E]              	dec	byte [faz]
  4789 00001854 74D0                    	jz	short lff44s_9 
  4790 00001856 BD0B00                  	mov	bp, 11
  4791 00001859 EBD3                    	jmp	short lff44s_1
  4792                                  
  4793                                  load_44khz_mono_16_bit:
  4794                                  	; 02/02/2025
  4795                                  	; 18/11/2023
  4796 0000185B F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4797                                  					; last of the file?
  4798 00001860 7402                    	jz	short lff44m2_0		; no
  4799 00001862 F9                      	stc
  4800 00001863 C3                      	retn
  4801                                  
  4802                                  lff44m2_0:
  4803 00001864 8EC0                    	mov	es, ax ; buffer segment
  4804 00001866 31FF                    	xor	di, di
  4805 00001868 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4806                                  	; ds = cs
  4807                                  
  4808                                  	; load file into memory
  4809 0000186B 8B0E[DA2B]                      mov	cx, [loadsize]
  4810 0000186F 8B1E[6E2B]              	mov	bx, [filehandle]
  4811 00001873 B43F                           	mov	ah, 3Fh
  4812 00001875 CD21                    	int	21h
  4813 00001877 723A                    	jc	short lff44m2_7 ; error !
  4814                                  
  4815                                  	; 14/11/2024
  4816 00001879 A3[E42B]                	mov	[count], ax
  4817                                  
  4818 0000187C 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4819                                  	
  4820 0000187E D1E8                    	shr	ax, 1
  4821                                  	;and	ax, ax
  4822 00001880 7503                    	jnz	short lff44m2_8
  4823 00001882 E917F4                  	jmp	lff44_eof
  4824                                  
  4825                                  lff44m2_8:
  4826 00001885 89C1                    	mov	cx, ax	; word count
  4827                                  lff44m2_9:
  4828 00001887 BD0A00                  	mov	bp, 10	; interpolation (one step) loop count
  4829 0000188A C606[691E]02            	mov	byte [faz], 2  ; 2 steps/phases
  4830                                  lff44m2_1:
  4831                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  4832                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  4833 0000188F AD                      	lodsw
  4834                                  	; 02/02/2025
  4835 00001890 8B14                    	mov	dx, [si]
  4836 00001892 49                      	dec	cx
  4837 00001893 7502                    	jnz	short lff44m2_2_1
  4838 00001895 31D2                    	xor	dx, dx
  4839                                  lff44m2_2_1:	
  4840                                  	; ax = [previous_val]
  4841                                  	; dx = [next_val]
  4842 00001897 E8B402                  	call	interpolating_2_16bit_mono
  4843 0000189A E314                    	jcxz	lff44m2_3
  4844                                  lff44m2_2_2:
  4845 0000189C AD                      	lodsw
  4846 0000189D AB                      	stosw		; (L)eft Channel
  4847 0000189E AB                      	stosw		; (R)ight Channel
  4848                                  
  4849 0000189F 49                      	dec	cx
  4850 000018A0 740E                    	jz	short lff44m2_3	
  4851 000018A2 4D                      	dec	bp
  4852 000018A3 75F7                    	jnz	short lff44m2_2_2
  4853                                  	
  4854 000018A5 FE0E[691E]              	dec	byte [faz]
  4855 000018A9 74DC                    	jz	short lff44m2_9 
  4856 000018AB BD0B00                  	mov	bp, 11
  4857 000018AE EBDF                    	jmp	short lff44m2_1
  4858                                  
  4859                                  lff44m2_3:
  4860                                  lff44s2_3:
  4861 000018B0 E9D6F3                  	jmp	lff44_3	; padfill
  4862                                  		; (put zeros in the remain words of the buffer)
  4863                                  lff44m2_7:
  4864                                  lff44s2_7:
  4865 000018B3 E9EDF3                  	jmp	lff44_5  ; error
  4866                                  
  4867                                  load_44khz_stereo_16_bit:
  4868                                  	; 18/11/2023
  4869 000018B6 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4870                                  					; last of the file?
  4871 000018BB 7402                    	jz	short lff44s2_0		; no
  4872 000018BD F9                      	stc
  4873 000018BE C3                      	retn
  4874                                  
  4875                                  lff44s2_0:
  4876 000018BF 8EC0                    	mov	es, ax ; buffer segment
  4877 000018C1 31FF                    	xor	di, di
  4878 000018C3 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4879                                  	; ds = cs
  4880                                  
  4881                                  	; load file into memory
  4882 000018C6 8B0E[DA2B]                      mov	cx, [loadsize]
  4883 000018CA 8B1E[6E2B]              	mov	bx, [filehandle]
  4884 000018CE B43F                           	mov	ah, 3Fh
  4885 000018D0 CD21                    	int	21h
  4886 000018D2 72DF                    	jc	short lff44s2_7 ; error !
  4887                                  
  4888                                  	; 14/11/2024
  4889 000018D4 A3[E42B]                	mov	[count], ax
  4890                                  
  4891 000018D7 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4892                                  	
  4893 000018D9 C1E802                  	shr	ax, 2	; dword (left chan word + right chan word)
  4894                                  	;and	ax, ax
  4895 000018DC 7503                    	jnz	short lff44s2_8
  4896 000018DE E9BBF3                  	jmp	lff44_eof
  4897                                  
  4898                                  lff44s2_8:
  4899 000018E1 89C1                    	mov	cx, ax	; dword count
  4900                                  lff44s2_9:
  4901 000018E3 BD0A00                  	mov	bp, 10	; interpolation (one step) loop count
  4902 000018E6 C606[691E]02            	mov	byte [faz], 2  ; 2 steps/phase
  4903                                  lff44s2_1:
  4904                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  4905                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  4906 000018EB AD                      	lodsw
  4907 000018EC 89C3                    	mov	bx, ax
  4908 000018EE AD                      	lodsw
  4909 000018EF 8B14                    	mov	dx, [si]
  4910 000018F1 8916[651E]              	mov	[next_val_l], dx
  4911 000018F5 8B5402                  	mov	dx, [si+2]
  4912 000018F8 49                      	dec	cx
  4913 000018F9 7506                    	jnz	short lff44s2_2_1
  4914 000018FB 31D2                    	xor	dx, dx ; 0
  4915 000018FD 8916[651E]              	mov	[next_val_l], dx
  4916                                  lff44s2_2_1:
  4917                                  	; bx = [previous_val_l]
  4918                                  	; ax = [previous_val_r]
  4919                                  	; [next_val_l]
  4920                                  	; dx = [next_val_r]
  4921 00001901 E85C02                  	call	interpolating_2_16bit_stereo
  4922 00001904 E3AA                    	jcxz	lff44s2_3
  4923                                  lff44s2_2_2:
  4924                                  	;lodsw
  4925                                  	;stosw		; (L)
  4926                                  	;lodsw
  4927                                  	;stosw		; (R)
  4928 00001906 A5                      	movsw		; (L)eft Channel
  4929 00001907 A5                      	movsw		; (R)ight Channel
  4930                                  
  4931 00001908 49                      	dec	cx
  4932 00001909 74A5                    	jz	short lff44s2_3	
  4933 0000190B 4D                      	dec	bp
  4934 0000190C 75F8                    	jnz	short lff44s2_2_2
  4935                                  	
  4936 0000190E FE0E[691E]              	dec	byte [faz]
  4937 00001912 74CF                    	jz	short lff44s2_9 
  4938 00001914 BD0B00                  	mov	bp, 11
  4939 00001917 EBD2                    	jmp	short lff44s2_1
  4940                                  
  4941                                  ; .....................
  4942                                  
  4943                                  	; 02/02/2025
  4944                                  load_12khz_mono_8_bit:
  4945 00001919 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4946                                  					; last of the file?
  4947 0000191E 7402                    	jz	short lff12m_0		; no
  4948 00001920 F9                      	stc
  4949 00001921 C3                      	retn
  4950                                  
  4951                                  lff12m_0:
  4952 00001922 8EC0                    	mov	es, ax ; buffer segment
  4953 00001924 31FF                    	xor	di, di
  4954 00001926 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  4955                                  	; ds = cs
  4956                                  
  4957                                  	; load file into memory
  4958 00001929 8B0E[DA2B]                      mov	cx, [loadsize]
  4959 0000192D 8B1E[6E2B]              	mov	bx, [filehandle]
  4960 00001931 B43F                           	mov	ah, 3Fh
  4961 00001933 CD21                    	int	21h
  4962 00001935 7247                    	jc	short lff12m_7 ; error !
  4963                                  
  4964                                  	; 02/02/2025
  4965 00001937 A3[E42B]                	mov	[count], ax
  4966                                  
  4967 0000193A 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  4968                                  
  4969 0000193C 21C0                    	and	ax, ax
  4970 0000193E 7503                    	jnz	short lff12m_8
  4971 00001940 E959F3                  	jmp	lff12_eof
  4972                                  
  4973                                  lff12m_8:
  4974 00001943 89C1                    	mov	cx, ax	; byte count
  4975                                  lff12m_1:
  4976                                  	; original-interpolated-interpolated-interpolated
  4977 00001945 AC                      	lodsb
  4978                                  	; 02/02/2025
  4979 00001946 8A14                    	mov	dl, [si]
  4980 00001948 49                      	dec	cx
  4981 00001949 7502                    	jnz	short lff12m_2
  4982 0000194B B280                    	mov	dl, 80h
  4983                                  lff12m_2:	
  4984                                  	; al = [previous_val]
  4985                                  	; dl = [next_val]
  4986 0000194D E81F03                   	call	interpolating_4_8bit_mono
  4987 00001950 E342                    	jcxz	lff12m_3
  4988 00001952 EBF1                    	jmp	short lff12m_1
  4989                                  
  4990                                  	; 02/02/2025
  4991                                  load_12khz_stereo_8_bit:
  4992 00001954 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  4993                                  					; last of the file?
  4994 00001959 7402                    	jz	short lff12s_0		; no
  4995 0000195B F9                      	stc
  4996 0000195C C3                      	retn
  4997                                  
  4998                                  lff12s_0:
  4999 0000195D 8EC0                    	mov	es, ax ; buffer segment
  5000 0000195F 31FF                    	xor	di, di
  5001 00001961 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  5002                                  	; ds = cs
  5003                                  
  5004                                  	; load file into memory
  5005 00001964 8B0E[DA2B]                      mov	cx, [loadsize]
  5006 00001968 8B1E[6E2B]              	mov	bx, [filehandle]
  5007 0000196C B43F                           	mov	ah, 3Fh
  5008 0000196E CD21                    	int	21h
  5009 00001970 720C                    	jc	short lff12s_7 ; error !
  5010                                  
  5011                                  	; 02/02/2025
  5012 00001972 A3[E42B]                	mov	[count], ax
  5013                                  
  5014 00001975 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  5015                                  	
  5016 00001977 D1E8                    	shr	ax, 1
  5017                                  	;and	ax, ax
  5018 00001979 7506                    	jnz	short lff12s_8
  5019 0000197B E91EF3                  	jmp	lff12_eof
  5020                                  
  5021                                  lff12m_7:
  5022                                  lff12s_7:
  5023 0000197E E922F3                  	jmp	lff12_5  ; error
  5024                                  
  5025                                  lff12s_8:
  5026 00001981 89C1                    	mov	cx, ax	; word count
  5027                                  lff12s_1:
  5028                                  	; original-interpolated-interpolated-interpolated
  5029 00001983 AD                      	lodsw
  5030                                  	; 02/02/2025
  5031 00001984 8B14                    	mov	dx, [si]
  5032 00001986 49                      	dec	cx
  5033 00001987 7503                    	jnz	short lff12s_2
  5034 00001989 BA8080                  	mov	dx, 8080h
  5035                                  lff12s_2:	
  5036                                  	; al = [previous_val_l]
  5037                                  	; ah = [previous_val_r]
  5038                                  	; dl = [next_val_l]
  5039                                  	; dh = [next_val_r]
  5040 0000198C E81303                  	call	interpolating_4_8bit_stereo
  5041 0000198F 67E302                  	jecxz	lff12s_3
  5042 00001992 EBEF                    	jmp	short lff12s_1
  5043                                  
  5044                                  lff12m_3:
  5045                                  lff12s_3:
  5046 00001994 E9F2F2                  	jmp	lff12_3	; padfill
  5047                                  		; (put zeros in the remain words of the buffer)
  5048                                  
  5049                                  	; 02/02/2025
  5050                                  load_12khz_mono_16_bit:
  5051 00001997 F606[6C2B]01            	test    byte [flags], ENDOFFILE	; have we already read the
  5052                                  					; last of the file?
  5053 0000199C 7402                    	jz	short lff12m2_0		; no
  5054 0000199E F9                      	stc
  5055 0000199F C3                      	retn
  5056                                  
  5057                                  lff12m2_0:
  5058 000019A0 8EC0                    	mov	es, ax ; buffer segment
  5059 000019A2 31FF                    	xor	di, di
  5060 000019A4 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  5061                                  	; ds = cs
  5062                                  
  5063                                  	; load file into memory
  5064 000019A7 8B0E[DA2B]                      mov	cx, [loadsize]
  5065 000019AB 8B1E[6E2B]              	mov	bx, [filehandle]
  5066 000019AF B43F                           	mov	ah, 3Fh
  5067 000019B1 CD21                    	int	21h
  5068 000019B3 721E                    	jc	short lff12m2_7 ; error !
  5069                                  
  5070                                  	; 02/02/2025
  5071 000019B5 A3[E42B]                	mov	[count], ax
  5072                                  
  5073 000019B8 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  5074                                  	
  5075 000019BA D1E8                    	shr	ax, 1
  5076                                  	;and	ax, ax
  5077 000019BC 7503                    	jnz	short lff12m2_8
  5078 000019BE E9DBF2                  	jmp	lff12_eof
  5079                                  
  5080                                  lff12m2_8:
  5081 000019C1 89C1                    	mov	cx, ax	; word count
  5082                                  lff12m2_1:
  5083                                  	; original-interpolated-interpolated-interpolated
  5084 000019C3 AD                      	lodsw
  5085                                  	; 02/02/2025
  5086 000019C4 8B14                    	mov	dx, [si]
  5087 000019C6 49                      	dec	cx
  5088 000019C7 7502                    	jnz	short lff12m2_2
  5089 000019C9 31D2                    	xor	dx, dx
  5090                                  lff12m2_2:	
  5091                                  	; ax = [previous_val]
  5092                                  	; dx = [next_val]
  5093 000019CB E80C04                   	call	interpolating_4_16bit_mono
  5094 000019CE 67E3C3                  	jecxz	lff12m_3
  5095 000019D1 EBF0                    	jmp	short lff12m2_1
  5096                                  
  5097                                  lff12m2_7:
  5098                                  lff12s2_7:
  5099 000019D3 E9CDF2                  	jmp	lff12_5  ; error
  5100                                  
  5101                                  	; 02/02/2025
  5102                                  load_12khz_stereo_16_bit:
  5103 000019D6 F606[6C2B]01                    test    byte [flags], ENDOFFILE	; have we already read the
  5104                                  					; last of the file?
  5105 000019DB 7402                    	jz	short lff12s2_0		; no
  5106 000019DD F9                      	stc
  5107 000019DE C3                      	retn
  5108                                  
  5109                                  lff12s2_0:
  5110 000019DF 8EC0                    	mov	es, ax ; buffer segment
  5111 000019E1 31FF                    	xor	di, di
  5112 000019E3 BA[EE2B]                	mov	dx, temp_buffer ; temporary buffer for wav data
  5113                                  	; ds = cs
  5114                                  
  5115                                  	; load file into memory
  5116 000019E6 8B0E[DA2B]                      mov	cx, [loadsize]
  5117 000019EA 8B1E[6E2B]              	mov	bx, [filehandle]
  5118 000019EE B43F                           	mov	ah, 3Fh
  5119 000019F0 CD21                    	int	21h
  5120 000019F2 72DF                    	jc	short lff12s2_7 ; error !
  5121                                  
  5122                                  	; 02/02/2025
  5123 000019F4 A3[E42B]                	mov	[count], ax
  5124                                  
  5125 000019F7 89D6                    	mov	si, dx ; temp_buffer ; temporary buffer address
  5126                                  	
  5127 000019F9 C1E802                  	shr	ax, 2	; dword (left chan word + right chan word)
  5128                                  	;and	ax, ax
  5129 000019FC 7506                    	jnz	short lff12s2_8
  5130 000019FE E99BF2                  	jmp	lff12_eof
  5131                                  
  5132                                  lff12m2_3:
  5133                                  lff12s2_3:
  5134 00001A01 E985F2                  	jmp	lff12_3	; padfill
  5135                                  		; (put zeros in the remain words of the buffer)
  5136                                  
  5137                                  lff12s2_8:
  5138 00001A04 89C1                    	mov	cx, ax	; dword count
  5139                                  lff12s2_1:
  5140                                  	; original-interpolated-interpolated-interpolated
  5141 00001A06 AD                      	lodsw
  5142 00001A07 89C3                    	mov	bx, ax
  5143 00001A09 AD                      	lodsw
  5144                                  	; 02/02/2025
  5145 00001A0A 8B14                    	mov	dx, [si]
  5146 00001A0C 8916[651E]              	mov	[next_val_l], dx
  5147 00001A10 8B5402                  	mov	dx, [si+2]
  5148 00001A13 8916[671E]              	mov	[next_val_r], dx
  5149 00001A17 49                      	dec	cx
  5150 00001A18 750A                    	jnz	short lff12s2_2
  5151 00001A1A 31D2                    	xor	dx, dx ; 0
  5152 00001A1C 8916[651E]              	mov	[next_val_l], dx
  5153 00001A20 8916[671E]              	mov	[next_val_r], dx
  5154                                  lff12s2_2:
  5155                                  	; bx = [previous_val_l]
  5156                                  	; ax = [previous_val_r]
  5157                                  	; [next_val_l]
  5158                                  	; [next_val_r]
  5159 00001A24 E8DE03                  	call	interpolating_4_16bit_stereo
  5160 00001A27 67E3D7                  	jecxz	lff12s2_3
  5161 00001A2A EBDA                    	jmp	short lff12s2_1
  5162                                  
  5163                                  ; .....................
  5164                                  
  5165                                  interpolating_3_8bit_mono:
  5166                                  	; 02/02/2025
  5167                                  	; 16/11/2023
  5168                                  	; al = [previous_val]
  5169                                  	; dl = [next_val]
  5170                                  	; original-interpolated-interpolated
  5171 00001A2C 88C3                    	mov	bl, al
  5172 00001A2E 2C80                    	sub	al, 80h
  5173 00001A30 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5174 00001A33 AB                      	stosw		; original sample (L)
  5175 00001A34 AB                      	stosw		; original sample (R)
  5176 00001A35 88D8                    	mov	al, bl
  5177 00001A37 00D0                    	add	al, dl
  5178 00001A39 D0D8                    	rcr	al, 1
  5179 00001A3B 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5180 00001A3D 00D8                    	add	al, bl
  5181 00001A3F D0D8                    	rcr	al, 1
  5182 00001A41 2C80                    	sub	al, 80h
  5183 00001A43 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5184 00001A46 AB                      	stosw		; interpolated sample 1 (L)
  5185 00001A47 AB                      	stosw		; interpolated sample 1 (R)
  5186 00001A48 88F8                    	mov	al, bh
  5187 00001A4A 00D0                    	add	al, dl	; [next_val]
  5188 00001A4C D0D8                    	rcr	al, 1
  5189                                  	; 02/02/2025
  5190 00001A4E 2C80                    	sub	al, 80h
  5191 00001A50 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5192 00001A53 AB                      	stosw		; interpolated sample 2 (L)
  5193 00001A54 AB                      	stosw		; interpolated sample 2 (R)
  5194 00001A55 C3                      	retn
  5195                                  
  5196                                  interpolating_3_8bit_stereo:
  5197                                  	; 02/02/2025
  5198                                  	; 16/11/2023
  5199                                  	; al = [previous_val_l]
  5200                                  	; ah = [previous_val_r]
  5201                                  	; dl = [next_val_l]
  5202                                  	; dh = [next_val_r]
  5203                                  	; original-interpolated-interpolated
  5204 00001A56 89C3                    	mov	bx, ax
  5205 00001A58 2C80                    	sub	al, 80h
  5206 00001A5A C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5207 00001A5D AB                      	stosw		; original sample (L)
  5208 00001A5E 88F8                    	mov	al, bh
  5209 00001A60 2C80                    	sub	al, 80h
  5210 00001A62 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5211 00001A65 AB                      	stosw		; original sample (R)
  5212 00001A66 88D8                    	mov	al, bl
  5213 00001A68 00D0                    	add	al, dl	; [next_val_l]
  5214 00001A6A D0D8                    	rcr	al, 1
  5215 00001A6C 50                      	push	ax ; *	; al = interpolated middle (L) (temporary)
  5216 00001A6D 00D8                    	add	al, bl	; [previous_val_l]
  5217 00001A6F D0D8                    	rcr	al, 1
  5218 00001A71 2C80                    	sub	al, 80h
  5219 00001A73 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5220 00001A76 AB                      	stosw		; interpolated sample 1 (L)
  5221 00001A77 88F8                    	mov	al, bh
  5222 00001A79 00F0                    	add	al, dh	; [next_val_r]
  5223 00001A7B D0D8                    	rcr	al, 1
  5224 00001A7D 50                      	push	ax ; ** ; al = interpolated middle (R) (temporary)
  5225 00001A7E 00F8                    	add	al, bh	; [previous_val_r]
  5226 00001A80 D0D8                    	rcr	al, 1
  5227 00001A82 2C80                    	sub	al, 80h
  5228 00001A84 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5229 00001A87 AB                      	stosw		; interpolated sample 1 (R)
  5230 00001A88 5B                      	pop	bx ; **
  5231 00001A89 58                      	pop	ax ; *
  5232 00001A8A 00D0                    	add	al, dl	; [next_val_l]
  5233 00001A8C D0D8                    	rcr	al, 1
  5234                                  	; 02/02/2025
  5235 00001A8E 2C80                    	sub	al, 80h
  5236 00001A90 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5237 00001A93 AB                      	stosw		; interpolated sample 2 (L)
  5238 00001A94 88D8                    	mov	al, bl
  5239 00001A96 00F0                    	add	al, dh	; [next_val_r]
  5240 00001A98 D0D8                    	rcr	al, 1
  5241                                  	; 02/02/2025
  5242 00001A9A 2C80                    	sub	al, 80h
  5243 00001A9C C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5244 00001A9F AB                      	stosw		; interpolated sample 2 (R)
  5245 00001AA0 C3                      	retn
  5246                                  
  5247                                  interpolating_2_8bit_mono:
  5248                                  	; 16/11/2023
  5249                                  	; al = [previous_val]
  5250                                  	; dl = [next_val]
  5251                                  	; original-interpolated
  5252 00001AA1 88C3                    	mov	bl, al
  5253 00001AA3 2C80                    	sub	al, 80h
  5254 00001AA5 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5255 00001AA8 AB                      	stosw		; original sample (L)
  5256 00001AA9 AB                      	stosw		; original sample (R)
  5257 00001AAA 88D8                    	mov	al, bl
  5258 00001AAC 00D0                    	add	al, dl
  5259 00001AAE D0D8                    	rcr	al, 1
  5260 00001AB0 2C80                    	sub	al, 80h
  5261 00001AB2 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5262 00001AB5 AB                      	stosw		; interpolated sample (L)
  5263 00001AB6 AB                      	stosw		; interpolated sample (R)
  5264 00001AB7 C3                      	retn
  5265                                  
  5266                                  interpolating_2_8bit_stereo:
  5267                                  	; 16/11/2023
  5268                                  	; al = [previous_val_l]
  5269                                  	; ah = [previous_val_r]
  5270                                  	; dl = [next_val_l]
  5271                                  	; dh = [next_val_r]
  5272                                  	; original-interpolated
  5273 00001AB8 89C3                    	mov	bx, ax
  5274 00001ABA 2C80                    	sub	al, 80h
  5275 00001ABC C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5276 00001ABF AB                      	stosw		; original sample (L)
  5277 00001AC0 88F8                    	mov	al, bh
  5278 00001AC2 2C80                    	sub	al, 80h
  5279 00001AC4 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5280 00001AC7 AB                      	stosw		; original sample (R)
  5281 00001AC8 88D8                    	mov	al, bl	; [previous_val_l]
  5282 00001ACA 00D0                    	add	al, dl	; [next_val_l]	
  5283 00001ACC D0D8                    	rcr	al, 1
  5284 00001ACE 2C80                    	sub	al, 80h
  5285 00001AD0 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5286 00001AD3 AB                      	stosw		; interpolated sample (L)
  5287 00001AD4 88F8                    	mov	al, bh
  5288 00001AD6 00F0                    	add	al, dh	; [next_val_r]
  5289 00001AD8 D0D8                    	rcr	al, 1
  5290 00001ADA 2C80                    	sub	al, 80h
  5291 00001ADC C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5292 00001ADF AB                      	stosw		; interpolated sample (R)
  5293 00001AE0 C3                      	retn
  5294                                  
  5295                                  interpolating_3_16bit_mono:
  5296                                  	; 16/11/2023
  5297                                  	; ax = [previous_val]
  5298                                  	; dx = [next_val]
  5299                                  	; original-interpolated-interpolated
  5300                                  
  5301 00001AE1 AB                      	stosw		; original sample (L)
  5302 00001AE2 AB                      	stosw		; original sample (R)
  5303 00001AE3 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5304 00001AE6 50                      	push	ax ; *	; [previous_val]
  5305 00001AE7 80C680                  	add	dh, 80h
  5306 00001AEA 01D0                    	add	ax, dx
  5307 00001AEC D1D8                    	rcr	ax, 1
  5308 00001AEE 5B                      	pop	bx ; *
  5309 00001AEF 93                      	xchg	bx, ax	; bx  = interpolated middle (temporary)
  5310 00001AF0 01D8                    	add	ax, bx	; [previous_val] + interpolated middle
  5311 00001AF2 D1D8                    	rcr	ax, 1
  5312 00001AF4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5313 00001AF7 AB                      	stosw 		; interpolated sample 1 (L)
  5314 00001AF8 AB                      	stosw		; interpolated sample 1 (R)
  5315 00001AF9 89D8                    	mov	ax, bx
  5316 00001AFB 01D0                    	add	ax, dx	 ;interpolated middle + [next_val]
  5317 00001AFD D1D8                    	rcr	ax, 1
  5318 00001AFF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5319 00001B02 AB                      	stosw		; interpolated sample 2 (L)
  5320 00001B03 AB                      	stosw		; interpolated sample 2 (R)
  5321 00001B04 C3                      	retn
  5322                                  
  5323                                  interpolating_3_16bit_stereo:
  5324                                  	; 16/11/2023
  5325                                  	; bx = [previous_val_l]
  5326                                  	; ax = [previous_val_r]
  5327                                  	; [next_val_l]
  5328                                  	; dx = [next_val_r]
  5329                                  	; original-interpolated-interpolated
  5330                                  
  5331 00001B05 93                      	xchg	ax, bx
  5332 00001B06 AB                      	stosw		; original sample (L)
  5333 00001B07 93                      	xchg	ax, bx
  5334 00001B08 AB                      	stosw		; original sample (R)
  5335 00001B09 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5336 00001B0C 50                      	push	ax ; *	; [previous_val_r]
  5337 00001B0D 80C780                  	add	bh, 80h
  5338 00001B10 8006[661E]80            	add	byte [next_val_l+1], 80h
  5339 00001B15 A1[651E]                	mov	ax, [next_val_l]
  5340 00001B18 01D8                    	add	ax, bx	; [previous_val_l]
  5341 00001B1A D1D8                    	rcr	ax, 1
  5342 00001B1C 93                      	xchg	ax, bx	; ax = [previous_val_l]	
  5343 00001B1D 01D8                    	add	ax, bx	; bx = interpolated middle (L)
  5344 00001B1F D1D8                    	rcr	ax, 1
  5345 00001B21 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5346 00001B24 AB                      	stosw 		; interpolated sample 1 (L)
  5347 00001B25 58                      	pop	ax  ; *
  5348 00001B26 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  5349 00001B29 52                      	push	dx  ; * ; [next_val_r]
  5350 00001B2A 92                      	xchg	ax, dx
  5351 00001B2B 01D0                    	add	ax, dx	; [next_val_r] + [previous_val_r]
  5352 00001B2D D1D8                    	rcr	ax, 1	; / 2
  5353 00001B2F 50                      	push	ax ; ** ; interpolated middle (R)
  5354 00001B30 01D0                    	add	ax, dx	; + [previous_val_r]
  5355 00001B32 D1D8                    	rcr	ax, 1
  5356 00001B34 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5357 00001B37 AB                      	stosw 		; interpolated sample 1 (R)
  5358 00001B38 A1[651E]                	mov	ax, [next_val_l]
  5359 00001B3B 01D8                    	add	ax, bx	; + interpolated middle (L)
  5360 00001B3D D1D8                    	rcr	ax, 1
  5361 00001B3F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5362 00001B42 AB                      	stosw 		; interpolated sample 2 (L)
  5363 00001B43 58                      	pop	ax ; **
  5364 00001B44 5A                      	pop	dx ; *
  5365 00001B45 01D0                    	add	ax, dx	; interpolated middle + [next_val_r]
  5366 00001B47 D1D8                    	rcr	ax, 1	; / 2
  5367 00001B49 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5368 00001B4C AB                      	stosw 		; interpolated sample 2 (L)
  5369 00001B4D C3                      	retn
  5370                                  
  5371                                  
  5372                                  interpolating_2_16bit_mono:
  5373                                  	; 16/11/2023
  5374                                  	; ax = [previous_val]
  5375                                  	; dx = [next_val]
  5376                                  	; original-interpolated
  5377                                  
  5378 00001B4E AB                      	stosw		; original sample (L)
  5379 00001B4F AB                      	stosw		; original sample (R)
  5380 00001B50 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5381 00001B53 80C680                  	add	dh, 80h
  5382 00001B56 01D0                    	add	ax, dx
  5383 00001B58 D1D8                    	rcr	ax, 1
  5384 00001B5A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5385 00001B5D AB                      	stosw		; interpolated sample (L)
  5386 00001B5E AB                      	stosw		; interpolated sample (R)
  5387 00001B5F C3                      	retn
  5388                                  
  5389                                  interpolating_2_16bit_stereo:
  5390                                  	; 16/11/2023
  5391                                  	; bx = [previous_val_l]
  5392                                  	; ax = [previous_val_r]
  5393                                  	; [next_val_l]
  5394                                  	; dx = [next_val_r]
  5395                                  	; original-interpolated
  5396                                  
  5397 00001B60 93                      	xchg	ax, bx
  5398 00001B61 AB                      	stosw		; original sample (L)
  5399 00001B62 93                      	xchg	ax, bx
  5400 00001B63 AB                      	stosw		; original sample (R)
  5401 00001B64 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5402 00001B67 80C680                  	add	dh, 80h
  5403 00001B6A 01D0                    	add	ax, dx	; [previous_val_r] + [next_val_r]
  5404 00001B6C D1D8                    	rcr	ax, 1	; / 2
  5405 00001B6E 50                      	push	ax ; *	; interpolated sample (R)
  5406 00001B6F A1[651E]                	mov	ax, [next_val_l]
  5407 00001B72 80C480                  	add	ah, 80h
  5408 00001B75 80C780                  	add	bh, 80h
  5409 00001B78 01D8                    	add	ax, bx	; [next_val_l] + [previous_val_l]
  5410 00001B7A D1D8                    	rcr	ax, 1	; / 2		
  5411 00001B7C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5412 00001B7F AB                      	stosw 		; interpolated sample (L)
  5413 00001B80 58                      	pop	ax ; *	
  5414 00001B81 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5415 00001B84 AB                      	stosw 		; interpolated sample (R)
  5416 00001B85 C3                      	retn
  5417                                  
  5418                                  interpolating_5_8bit_mono:
  5419                                  	; 17/11/2023
  5420                                  	; al = [previous_val]
  5421                                  	; dl = [next_val]
  5422                                  	; original-interpltd-interpltd-interpltd-interpltd
  5423 00001B86 88C3                    	mov	bl, al
  5424 00001B88 2C80                    	sub	al, 80h
  5425 00001B8A C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5426 00001B8D AB                      	stosw		; original sample (L)
  5427 00001B8E AB                      	stosw		; original sample (R)
  5428 00001B8F 88D8                    	mov	al, bl
  5429 00001B91 00D0                    	add	al, dl
  5430 00001B93 D0D8                    	rcr	al, 1
  5431 00001B95 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5432 00001B97 00D8                    	add	al, bl  ; [previous_val]
  5433 00001B99 D0D8                    	rcr	al, 1 	
  5434 00001B9B 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  5435 00001B9D 00D8                    	add	al, bl
  5436 00001B9F D0D8                    	rcr	al, 1
  5437 00001BA1 2C80                    	sub	al, 80h
  5438 00001BA3 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5439 00001BA6 AB                      	stosw		; interpolated sample 1 (L)
  5440 00001BA7 AB                      	stosw		; interpolated sample 1 (R)
  5441 00001BA8 88F8                    	mov	al, bh
  5442 00001BAA 00F0                    	add	al, dh
  5443 00001BAC D0D8                    	rcr	al, 1
  5444 00001BAE 2C80                    	sub	al, 80h
  5445 00001BB0 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5446 00001BB3 AB                      	stosw		; interpolated sample 2 (L)
  5447 00001BB4 AB                      	stosw		; interpolated sample 2 (R)
  5448 00001BB5 88F8                    	mov	al, bh
  5449 00001BB7 00D0                    	add	al, dl	; [next_val]
  5450 00001BB9 D0D8                    	rcr	al, 1
  5451 00001BBB 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  5452 00001BBD 00F8                    	add	al, bh
  5453 00001BBF D0D8                    	rcr	al, 1
  5454 00001BC1 2C80                    	sub	al, 80h
  5455 00001BC3 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5456 00001BC6 AB                      	stosw		; interpolated sample 3 (L)
  5457 00001BC7 AB                      	stosw		; interpolated sample 3 (R)
  5458 00001BC8 88F0                    	mov	al, dh
  5459 00001BCA 00D0                    	add	al, dl
  5460 00001BCC D0D8                    	rcr	al, 1
  5461 00001BCE 2C80                    	sub	al, 80h
  5462 00001BD0 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5463 00001BD3 AB                      	stosw		; interpolated sample 4 (L)
  5464 00001BD4 AB                      	stosw		; interpolated sample 4 (R)
  5465 00001BD5 C3                      	retn
  5466                                  
  5467                                  interpolating_5_8bit_stereo:
  5468                                  	; 17/11/2023
  5469                                  	; al = [previous_val_l]
  5470                                  	; ah = [previous_val_r]
  5471                                  	; dl = [next_val_l]
  5472                                  	; dh = [next_val_r]
  5473                                  	; original-interpltd-interpltd-interpltd-interpltd
  5474 00001BD6 89C3                    	mov	bx, ax
  5475 00001BD8 2C80                    	sub	al, 80h
  5476 00001BDA C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5477 00001BDD AB                      	stosw		; original sample (L)
  5478 00001BDE 88F8                    	mov	al, bh
  5479 00001BE0 2C80                    	sub	al, 80h
  5480 00001BE2 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5481 00001BE5 AB                      	stosw		; original sample (R)
  5482 00001BE6 52                      	push	dx ; *
  5483 00001BE7 88D8                    	mov	al, bl
  5484 00001BE9 00D0                    	add	al, dl	; [next_val_l]
  5485 00001BEB D0D8                    	rcr	al, 1
  5486 00001BED 50                      	push	ax ; **	; al = interpolated middle (L) (temporary)
  5487 00001BEE 00D8                    	add	al, bl	; [previous_val_l]
  5488 00001BF0 D0D8                    	rcr	al, 1
  5489 00001BF2 86D8                    	xchg	al, bl
  5490 00001BF4 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  5491 00001BF6 D0D8                    	rcr	al, 1
  5492 00001BF8 2C80                    	sub	al, 80h
  5493 00001BFA C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5494 00001BFD AB                      	stosw		; interpolated sample 1 (L)
  5495 00001BFE 88F8                    	mov	al, bh
  5496 00001C00 00F0                    	add	al, dh	; [next_val_r]
  5497 00001C02 D0D8                    	rcr	al, 1
  5498 00001C04 50                      	push	ax ; *** ; al = interpolated middle (R) (temporary)
  5499 00001C05 00F8                    	add	al, bh	; [previous_val_r]
  5500 00001C07 D0D8                    	rcr	al, 1
  5501 00001C09 86F8                    	xchg	al, bh
  5502 00001C0B 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  5503 00001C0D D0D8                    	rcr	al, 1
  5504 00001C0F 2C80                    	sub	al, 80h
  5505 00001C11 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5506 00001C14 AB                      	stosw		; interpolated sample 1 (R)
  5507 00001C15 5A                      	pop	dx ; ***
  5508 00001C16 58                      	pop	ax ; **	; al = interpolated middle (L) (temporary)
  5509 00001C17 86D8                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  5510 00001C19 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  5511 00001C1B D0D8                    	rcr	al, 1
  5512 00001C1D 2C80                    	sub	al, 80h
  5513 00001C1F C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5514 00001C22 AB                      	stosw		; interpolated sample 2 (L)	
  5515 00001C23 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  5516 00001C25 86F8                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  5517 00001C27 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  5518 00001C29 D0D8                    	rcr	al, 1
  5519 00001C2B 2C80                    	sub	al, 80h
  5520 00001C2D C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5521 00001C30 AB                      	stosw		; interpolated sample 2 (R)
  5522 00001C31 5A                      	pop	dx ; *
  5523 00001C32 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  5524 00001C34 00D0                    	add	al, dl	; [next_val_l]
  5525 00001C36 D0D8                    	rcr	al, 1
  5526 00001C38 86D8                    	xchg	al, bl	; al = interpolated middle (R) (temporary)
  5527 00001C3A 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  5528 00001C3C D0D8                    	rcr	al, 1
  5529 00001C3E 2C80                    	sub	al, 80h
  5530 00001C40 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5531 00001C43 AB                      	stosw		; interpolated sample 3 (L)
  5532 00001C44 88F8                    	mov	al, bh	
  5533 00001C46 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  5534 00001C48 D0D8                    	rcr	al, 1
  5535 00001C4A 86F8                    	xchg	al, bh	; al = interpolated middle (R)
  5536 00001C4C 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  5537 00001C4E D0D8                    	rcr	al, 1
  5538 00001C50 2C80                    	sub	al, 80h
  5539 00001C52 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5540 00001C55 AB                      	stosw		; interpolated sample 3 (R)
  5541 00001C56 88D8                    	mov	al, bl
  5542 00001C58 00D0                    	add	al, dl	; [next_val_l]
  5543 00001C5A D0D8                    	rcr	al, 1
  5544 00001C5C 2C80                    	sub	al, 80h
  5545 00001C5E C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5546 00001C61 AB                      	stosw		; interpolated sample 4 (L)
  5547 00001C62 88F8                    	mov	al, bh
  5548 00001C64 00F0                    	add	al, dh	; [next_val_r]
  5549 00001C66 D0D8                    	rcr	al, 1
  5550 00001C68 2C80                    	sub	al, 80h
  5551 00001C6A C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5552 00001C6D AB                      	stosw		; interpolated sample 4 (R)
  5553 00001C6E C3                      	retn
  5554                                  
  5555                                  interpolating_4_8bit_mono:
  5556                                  	; 17/11/2023
  5557                                  	; al = [previous_val]
  5558                                  	; dl = [next_val]
  5559                                  	; original-interpolated-interpolated-interpolated
  5560 00001C6F 88C3                    	mov	bl, al
  5561 00001C71 2C80                    	sub	al, 80h
  5562 00001C73 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5563 00001C76 AB                      	stosw		; original sample (L)
  5564 00001C77 AB                      	stosw		; original sample (R)
  5565 00001C78 88D8                    	mov	al, bl
  5566 00001C7A 00D0                    	add	al, dl
  5567 00001C7C D0D8                    	rcr	al, 1
  5568 00001C7E 86D8                    	xchg	al, bl  ; al = [previous_val]
  5569 00001C80 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  5570 00001C82 D0D8                    	rcr	al, 1
  5571 00001C84 2C80                    	sub	al, 80h
  5572 00001C86 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5573 00001C89 AB                      	stosw		; interpolated sample 1 (L)
  5574 00001C8A AB                      	stosw		; interpolated sample 1 (R)
  5575 00001C8B 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  5576 00001C8D 2C80                    	sub	al, 80h
  5577 00001C8F C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5578 00001C92 AB                      	stosw		; interpolated sample 2 (L)
  5579 00001C93 AB                      	stosw		; interpolated sample 2 (R)
  5580 00001C94 88D8                    	mov	al, bl
  5581 00001C96 00D0                    	add	al, dl	; [next_val]
  5582 00001C98 D0D8                    	rcr	al, 1
  5583 00001C9A 2C80                    	sub	al, 80h
  5584 00001C9C C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5585 00001C9F AB                      	stosw		; interpolated sample 3 (L)
  5586 00001CA0 AB                      	stosw		; interpolated sample 3 (R)
  5587 00001CA1 C3                      	retn
  5588                                  
  5589                                  interpolating_4_8bit_stereo:
  5590                                  	; 17/11/2023
  5591                                  	; al = [previous_val_l]
  5592                                  	; ah = [previous_val_r]
  5593                                  	; dl = [next_val_l]
  5594                                  	; dh = [next_val_r]
  5595                                  	; original-interpolated-interpolated-interpolated
  5596 00001CA2 89C3                    	mov	bx, ax
  5597 00001CA4 2C80                    	sub	al, 80h
  5598 00001CA6 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5599 00001CA9 AB                      	stosw		; original sample (L)
  5600 00001CAA 88F8                    	mov	al, bh
  5601 00001CAC 2C80                    	sub	al, 80h
  5602 00001CAE C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5603 00001CB1 AB                      	stosw		; original sample (R)
  5604 00001CB2 88D8                    	mov	al, bl
  5605 00001CB4 00D0                    	add	al, dl	; [next_val_l]
  5606 00001CB6 D0D8                    	rcr	al, 1
  5607 00001CB8 86D8                    	xchg	al, bl	; al = [previous_val_l]
  5608 00001CBA 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  5609 00001CBC D0D8                    	rcr	al, 1
  5610 00001CBE 2C80                    	sub	al, 80h
  5611 00001CC0 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5612 00001CC3 AB                      	stosw		; interpolated sample 1 (L)
  5613 00001CC4 88F8                    	mov	al, bh
  5614 00001CC6 00F0                    	add	al, dh	; [next_val_r]
  5615 00001CC8 D0D8                    	rcr	al, 1
  5616 00001CCA 86F8                    	xchg	al, bh	; al = [previous_val_h]
  5617 00001CCC 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  5618 00001CCE D0D8                    	rcr	al, 1
  5619 00001CD0 2C80                    	sub	al, 80h
  5620 00001CD2 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5621 00001CD5 AB                      	stosw		; interpolated sample 1 (R)
  5622 00001CD6 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  5623 00001CD8 2C80                    	sub	al, 80h
  5624 00001CDA C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5625 00001CDD AB                      	stosw		; interpolated sample 2 (L)
  5626 00001CDE 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  5627 00001CE0 2C80                    	sub	al, 80h
  5628 00001CE2 C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5629 00001CE5 AB                      	stosw		; interpolated sample 2 (L)
  5630 00001CE6 88D8                    	mov	al, bl
  5631 00001CE8 00D0                    	add	al, dl	; [next_val_l]
  5632 00001CEA D0D8                    	rcr	al, 1
  5633 00001CEC 2C80                    	sub	al, 80h
  5634 00001CEE C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5635 00001CF1 AB                      	stosw		; interpolated sample 3 (L)
  5636 00001CF2 88F8                    	mov	al, bh
  5637 00001CF4 00F0                    	add	al, dh	; [next_val_r]
  5638 00001CF6 D0D8                    	rcr	al, 1
  5639 00001CF8 2C80                    	sub	al, 80h
  5640 00001CFA C1E008                  	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5641 00001CFD AB                      	stosw		; interpolated sample 3 (R)
  5642 00001CFE C3                      	retn
  5643                                  
  5644                                  interpolating_5_16bit_mono:
  5645                                  	; 18/11/2023
  5646                                  	; ax = [previous_val]
  5647                                  	; dx = [next_val]
  5648                                  	; original-interpltd-interpltd-interpltd-interpltd
  5649 00001CFF AB                      	stosw		; original sample (L)
  5650 00001D00 AB                      	stosw		; original sample (R)
  5651 00001D01 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5652 00001D04 89C3                    	mov	bx, ax	; [previous_val]
  5653 00001D06 80C680                  	add	dh, 80h
  5654 00001D09 01D0                    	add	ax, dx
  5655 00001D0B D1D8                    	rcr	ax, 1
  5656 00001D0D 50                      	push	ax ; *	; interpolated middle (temporary)
  5657 00001D0E 01D8                    	add	ax, bx	; interpolated middle + [previous_val]
  5658 00001D10 D1D8                    	rcr	ax, 1
  5659 00001D12 50                      	push	ax ; **	; interpolated 1st quarter (temporary)
  5660 00001D13 01D8                    	add	ax, bx	; 1st quarter + [previous_val]
  5661 00001D15 D1D8                    	rcr	ax, 1	
  5662 00001D17 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5663 00001D1A AB                      	stosw 		; interpolated sample 1 (L)
  5664 00001D1B AB                      	stosw		; interpolated sample 1 (R)
  5665 00001D1C 58                      	pop	ax ; **	
  5666 00001D1D 5B                      	pop	bx ; *
  5667 00001D1E 01D8                    	add	ax, bx	; 1st quarter + middle
  5668 00001D20 D1D8                    	rcr	ax, 1	; / 2
  5669 00001D22 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  5670 00001D25 AB                      	stosw		; interpolated sample 2 (L)
  5671 00001D26 AB                      	stosw		; interpolated sample 2 (R)
  5672 00001D27 89D8                    	mov	ax, bx
  5673 00001D29 01D0                    	add	ax, dx	; interpolated middle + [next_val]
  5674 00001D2B D1D8                    	rcr	ax, 1
  5675 00001D2D 50                      	push	ax ; *	; interpolated 3rd quarter (temporary)
  5676 00001D2E 01D8                    	add	ax, bx	; + interpolated middle
  5677 00001D30 D1D8                    	rcr	ax, 1
  5678 00001D32 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5679 00001D35 AB                      	stosw		; interpolated sample 3 (L)
  5680 00001D36 AB                      	stosw		; interpolated sample 3 (R)
  5681 00001D37 58                      	pop	ax ; *	
  5682 00001D38 01D0                    	add	ax, dx	; 3rd quarter + [next_val]
  5683 00001D3A D1D8                    	rcr	ax, 1	; / 2
  5684 00001D3C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5685 00001D3F AB                      	stosw		; interpolated sample 4 (L)
  5686 00001D40 AB                      	stosw		; interpolated sample 4 (R)
  5687 00001D41 C3                      	retn
  5688                                  
  5689                                  interpolating_5_16bit_stereo:
  5690                                  	; 18/11/2023
  5691                                  	; bx = [previous_val_l]
  5692                                  	; ax = [previous_val_r]
  5693                                  	; [next_val_l]
  5694                                  	; [next_val_r]
  5695                                  	; original-interpltd-interpltd-interpltd-interpltd
  5696 00001D42 51                      	push	cx ; !
  5697 00001D43 93                      	xchg	ax, bx
  5698 00001D44 AB                      	stosw		; original sample (L)
  5699 00001D45 93                      	xchg	ax, bx
  5700 00001D46 AB                      	stosw		; original sample (R)
  5701 00001D47 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5702 00001D4A 50                      	push	ax ; *	; [previous_val_r]
  5703 00001D4B 80C780                  	add	bh, 80h
  5704 00001D4E 8006[661E]80            	add	byte [next_val_l+1], 80h
  5705 00001D53 A1[651E]                	mov	ax, [next_val_l]
  5706 00001D56 01D8                    	add	ax, bx	; [previous_val_l]
  5707 00001D58 D1D8                    	rcr	ax, 1
  5708 00001D5A 89C1                    	mov	cx, ax	; interpolated middle (L)
  5709 00001D5C 01D8                    	add	ax, bx	
  5710 00001D5E D1D8                    	rcr	ax, 1
  5711 00001D60 89C2                    	mov	dx, ax	; interpolated 1st quarter (L)
  5712 00001D62 01D8                    	add	ax, bx	; [previous_val_l]
  5713 00001D64 D1D8                    	rcr	ax, 1
  5714 00001D66 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5715 00001D69 AB                      	stosw 		; interpolated sample 1 (L)
  5716 00001D6A 89C8                    	mov	ax, cx
  5717 00001D6C 01D0                    	add	ax, dx	; middle (L) + 1st quarter (L)
  5718 00001D6E D1D8                    	rcr	ax, 1	; / 2
  5719 00001D70 89C3                    	mov	bx, ax  ; interpolated sample 2 (L)
  5720 00001D72 5A                      	pop	dx ; *	; [previous_val_r]
  5721 00001D73 89D0                    	mov	ax, dx
  5722 00001D75 8006[681E]80            	add	byte [next_val_r+1], 80h
  5723 00001D7A 0306[671E]              	add	ax, [next_val_r]
  5724 00001D7E D1D8                    	rcr	ax, 1
  5725 00001D80 50                      	push	ax ; *	; interpolated middle (R)
  5726 00001D81 01D0                    	add	ax, dx
  5727 00001D83 D1D8                    	rcr	ax, 1
  5728 00001D85 50                      	push	ax ; **	; interpolated 1st quarter (R)
  5729 00001D86 01D0                    	add	ax, dx	; [previous_val_r]
  5730 00001D88 D1D8                    	rcr	ax, 1
  5731 00001D8A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5732 00001D8D AB                      	stosw 		; interpolated sample 1 (R)
  5733 00001D8E 89D8                    	mov	ax, bx
  5734 00001D90 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5735 00001D93 AB                      	stosw 		; interpolated sample 2 (L)
  5736 00001D94 58                      	pop	ax ; **
  5737 00001D95 5A                      	pop	dx ; *
  5738 00001D96 01D0                    	add	ax, dx	; 1st quarter (R) + middle (R)
  5739 00001D98 D1D8                    	rcr	ax, 1	; / 2
  5740 00001D9A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5741 00001D9D AB                      	stosw 		; interpolated sample 2 (R)
  5742 00001D9E 89C8                    	mov	ax, cx
  5743 00001DA0 0306[651E]              	add	ax, [next_val_l]
  5744 00001DA4 D1D8                    	rcr	ax, 1
  5745 00001DA6 50                      	push	ax ; * 	; interpolated 3rd quarter (L)
  5746 00001DA7 01C8                    	add	ax, cx	; interpolated middle (L)
  5747 00001DA9 D1D8                    	rcr	ax, 1
  5748 00001DAB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5749 00001DAE AB                      	stosw 		; interpolated sample 3 (L)
  5750 00001DAF 89D0                    	mov	ax, dx
  5751 00001DB1 0306[671E]              	add	ax, [next_val_r]
  5752 00001DB5 D1D8                    	rcr	ax, 1
  5753 00001DB7 50                      	push	ax ; ** ; interpolated 3rd quarter (R)
  5754 00001DB8 01D0                    	add	ax, dx	; interpolated middle (R)
  5755 00001DBA D1D8                    	rcr	ax, 1
  5756 00001DBC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5757 00001DBF AB                      	stosw 		; interpolated sample 3 (R)
  5758 00001DC0 5B                      	pop	bx ; **
  5759 00001DC1 58                      	pop	ax ; *
  5760 00001DC2 0306[651E]              	add	ax, [next_val_l]
  5761 00001DC6 D1D8                    	rcr	ax, 1
  5762 00001DC8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5763 00001DCB AB                      	stosw 		; interpolated sample 4 (L)
  5764 00001DCC 89D8                    	mov	ax, bx	
  5765 00001DCE 0306[671E]              	add	ax, [next_val_r]
  5766 00001DD2 D1D8                    	rcr	ax, 1
  5767 00001DD4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5768 00001DD7 AB                      	stosw 		; interpolated sample 4 (R)
  5769 00001DD8 59                      	pop	cx ; !
  5770 00001DD9 C3                      	retn
  5771                                  
  5772                                  interpolating_4_16bit_mono:
  5773                                  	; 18/11/2023
  5774                                  	; ax = [previous_val]
  5775                                  	; dx = [next_val]
  5776                                  	; 02/02/2025
  5777                                  	; original-interpolated-interpolated-interpolated
  5778                                  
  5779 00001DDA AB                      	stosw		; original sample (L)
  5780 00001DDB AB                      	stosw		; original sample (R)
  5781 00001DDC 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5782 00001DDF 89C3                    	mov	bx, ax	; [previous_val]
  5783 00001DE1 80C680                  	add	dh, 80h
  5784 00001DE4 01D0                    	add	ax, dx	; [previous_val] + [next_val]
  5785 00001DE6 D1D8                    	rcr	ax, 1
  5786 00001DE8 93                      	xchg	ax, bx	
  5787 00001DE9 01D8                    	add	ax, bx	; [previous_val] + interpolated middle
  5788 00001DEB D1D8                    	rcr	ax, 1
  5789 00001DED 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5790 00001DF0 AB                      	stosw 		; interpolated sample 1 (L)
  5791 00001DF1 AB                      	stosw		; interpolated sample 1 (R)
  5792 00001DF2 89D8                    	mov	ax, bx	; interpolated middle
  5793 00001DF4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5794 00001DF7 AB                      	stosw 		; interpolated sample 2 (L)
  5795 00001DF8 AB                      	stosw		; interpolated sample 2 (R)
  5796 00001DF9 89D8                    	mov	ax, bx
  5797 00001DFB 01D0                    	add	ax, dx	; interpolated middle + [next_val]
  5798 00001DFD D1D8                    	rcr	ax, 1
  5799 00001DFF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5800 00001E02 AB                      	stosw		; interpolated sample 3 (L)
  5801 00001E03 AB                      	stosw		; interpolated sample 3 (R)
  5802 00001E04 C3                      	retn
  5803                                  
  5804                                  interpolating_4_16bit_stereo:
  5805                                  	; 18/11/2023
  5806                                  	; bx = [previous_val_l]
  5807                                  	; ax = [previous_val_r]
  5808                                  	; [next_val_l]
  5809                                  	; [next_val_r]
  5810                                  	; original-interpolated-interpolated-interpolated
  5811 00001E05 93                      	xchg	ax, bx
  5812 00001E06 AB                      	stosw		; original sample (L)
  5813 00001E07 93                      	xchg	ax, bx
  5814 00001E08 AB                      	stosw		; original sample (R)
  5815 00001E09 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5816 00001E0C 89C2                    	mov	dx, ax	; [previous_val_r]
  5817 00001E0E 80C780                  	add	bh, 80h
  5818 00001E11 8006[661E]80            	add	byte [next_val_l+1], 80h
  5819 00001E16 A1[651E]                	mov	ax, [next_val_l]
  5820 00001E19 01D8                    	add	ax, bx	; [previous_val_l]
  5821 00001E1B D1D8                    	rcr	ax, 1
  5822 00001E1D 93                      	xchg	ax, bx	
  5823 00001E1E 01D8                    	add	ax, bx	; bx = interpolated middle (L)
  5824 00001E20 D1D8                    	rcr	ax, 1
  5825 00001E22 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5826 00001E25 AB                      	stosw 		; interpolated sample 1 (L)
  5827 00001E26 8006[681E]80            	add	byte [next_val_r+1], 80h
  5828 00001E2B 89D0                    	mov	ax, dx	; [previous_val_r]
  5829 00001E2D 0306[671E]              	add	ax, [next_val_r]
  5830 00001E31 D1D8                    	rcr	ax, 1
  5831 00001E33 92                      	xchg	ax, dx	
  5832 00001E34 01D0                    	add	ax, dx	; dx = interpolated middle (R)
  5833 00001E36 D1D8                    	rcr	ax, 1
  5834 00001E38 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5835 00001E3B AB                      	stosw 		; interpolated sample 1 (R)
  5836 00001E3C 89D8                    	mov	ax, bx
  5837 00001E3E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5838 00001E41 AB                      	stosw 		; interpolated sample 2 (L)
  5839 00001E42 89D0                    	mov	ax, dx
  5840 00001E44 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5841 00001E47 AB                      	stosw 		; interpolated sample 2 (R)
  5842 00001E48 89D8                    	mov	ax, bx
  5843 00001E4A 0306[651E]              	add	ax, [next_val_l]
  5844 00001E4E D1D8                    	rcr	ax, 1
  5845 00001E50 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5846 00001E53 AB                      	stosw 		; interpolated sample 3 (L)
  5847 00001E54 89D0                    	mov	ax, dx
  5848 00001E56 0306[671E]              	add	ax, [next_val_r]
  5849 00001E5A D1D8                    	rcr	ax, 1
  5850 00001E5C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5851 00001E5F AB                      	stosw 		; interpolated sample 3 (R)
  5852 00001E60 C3                      	retn
  5853                                  
  5854                                  ; 13/11/2023
  5855                                  previous_val:
  5856 00001E61 0000                    previous_val_l: dw 0
  5857 00001E63 0000                    previous_val_r: dw 0
  5858                                  next_val:
  5859 00001E65 0000                    next_val_l: dw 0
  5860 00001E67 0000                    next_val_r: dw 0
  5861                                  
  5862                                  ; 16/11/2023
  5863 00001E69 00                      faz:	db 0
  5864                                  
  5865                                  ; --------------------------------------------------------
  5866                                  ; 14/11/2024 - Erdogan Tan
  5867                                  ; --------------------------------------------------------
  5868                                  
  5869                                  	; 01/01/2025 (cgaplay.asm, 16bit registers)
  5870                                  	; 07/12/2024
  5871                                  	; 01/12/2024 (32bit registers)
  5872                                  	; 29/11/2024
  5873                                  checkUpdateEvents:
  5874 00001E6A E87E01                  	call	check4keyboardstop
  5875 00001E6D 7251                    	jc	short c4ue_ok
  5876                                  
  5877                                  	; 01/01/2025
  5878                                  	; 18/11/2024
  5879 00001E6F 50                      	push	ax ; *
  5880 00001E70 09C0                    	or	ax, ax
  5881 00001E72 0F849E00                	jz	c4ue_cpt
  5882                                  
  5883                                  	; 18/11/2024
  5884 00001E76 3C20                    	cmp	al, 20h ; SPACE (spacebar) ; pause/play
  5885 00001E78 752C                    	jne	short c4ue_chk_s
  5886 00001E7A 803E[342B]00            	cmp	byte [stopped], 0
  5887 00001E7F 770C                    	ja	short c4ue_chk_ps
  5888                                  	; pause
  5889 00001E81 E8C0EA                  	call	ac97_pause
  5890                                  	; 21/11/2024
  5891 00001E84 A0[352B]                	mov	al, [tLO]
  5892 00001E87 A2[362B]                	mov	byte [tLP], al
  5893 00001E8A E98700                  	jmp	c4ue_cpt
  5894                                  c4ue_chk_ps:
  5895 00001E8D 803E[342B]01            	cmp	byte [stopped], 1
  5896 00001E92 7705                    	ja	short c4ue_replay
  5897                                  	; continue to play (after a pause)
  5898 00001E94 E8B4EA                  	call	ac97_play 
  5899 00001E97 EB7B                    	jmp	c4ue_cpt
  5900                                  c4ue_replay:
  5901                                  	; 19/11/2024
  5902 00001E99 58                      	pop	ax ; *
  5903 00001E9A 58                      	pop	ax ; return address
  5904                                  	; 07/02/2024
  5905                                  	;mov	al, [volume]
  5906                                  	;call	SetmasterVolume
  5907 00001E9B C606[342B]00            	mov	byte [stopped], 0
  5908 00001EA0 E85903                  	call	move_to_beginning
  5909                                  	;jmp	PlayWav
  5910                                  	; 07/12/2024
  5911 00001EA3 E9A7E5                  	jmp	RePlayWav
  5912                                  
  5913                                  c4ue_chk_s:
  5914 00001EA6 3C53                    	cmp	al, 'S'	; stop
  5915 00001EA8 7517                    	jne	short c4ue_chk_fb
  5916 00001EAA 803E[342B]00            	cmp	byte [stopped], 0
  5917 00001EAF 7763                    	ja	c4ue_cpt ; Already stopped/paused
  5918 00001EB1 E880EA                  	call	ac97_stop
  5919                                  	; 19/11/2024
  5920 00001EB4 C606[352B]00            	mov	byte [tLO], 0
  5921                                  	; 21/11/2024
  5922 00001EB9 C606[362B]30            	mov	byte [tLP], '0'
  5923 00001EBE EB54                    	jmp	c4ue_cpt
  5924                                  
  5925                                  	; 01/12/2024
  5926                                  	; 18/11/2024
  5927                                  c4ue_ok:
  5928 00001EC0 C3                      	retn
  5929                                  
  5930                                  c4ue_chk_fb:
  5931                                  	; 17/11/2024
  5932 00001EC1 3C46                    	cmp	al, 'F'
  5933 00001EC3 7505                    	jne	short c4ue_chk_b
  5934 00001EC5 E81003                  	call 	Player_ProcessKey_Forwards
  5935 00001EC8 EB4A                    	jmp	c4ue_cpt
  5936                                  
  5937                                  c4ue_chk_b:
  5938 00001ECA 3C42                    	cmp	al, 'B'
  5939                                  	;;jne	short c4ue_cpt
  5940                                  	; 19/11/2024
  5941                                  	;jne	short c4ue_chk_h
  5942                                  	; 25/12/2024
  5943                                  	; 29/11/2024
  5944 00001ECC 7505                    	jne	short c4ue_chk_n
  5945 00001ECE E80303                  	call 	Player_ProcessKey_Backwards
  5946 00001ED1 EB41                    	jmp	short c4ue_cpt
  5947                                  
  5948                                  	;;;
  5949                                  	; 25/12/2024
  5950                                  	; 29/11/2024
  5951                                  c4ue_chk_n:
  5952 00001ED3 3C4E                    	cmp	al, 'N'
  5953 00001ED5 7404                    	je	short c4ue_nps
  5954                                  c4ue_chk_p:
  5955 00001ED7 3C50                    	cmp	al, 'P'
  5956 00001ED9 7507                    	jne	short c4ue_chk_h
  5957                                  c4ue_nps:
  5958 00001EDB C606[342B]03            	mov	byte [stopped], 3
  5959 00001EE0 EB32                    	jmp	short c4ue_cpt
  5960                                  	;;;
  5961                                  
  5962                                  c4ue_chk_h:
  5963                                  	; 19/11/2024
  5964 00001EE2 3C48                    	cmp	al, 'H'
  5965 00001EE4 750A                    	jne	short c4ue_chk_cr
  5966 00001EE6 C606[372B]00            	mov	byte [wpoints], 0
  5967 00001EEB E87AEB                  	call 	write_ac97_pci_dev_info
  5968                                  	; 30/12/2024
  5969 00001EEE EB24                    	jmp	short c4ue_cpt
  5970                                  c4ue_chk_cr:
  5971                                  	;;;
  5972                                  	; 24/12/2024 (wave lighting points option)
  5973                                  	;mov	ah, [wpoints]
  5974                                  	; 01/01/2025
  5975 00001EF0 31DB                    	xor	bx, bx
  5976 00001EF2 8A1E[372B]              	mov	bl, [wpoints]
  5977 00001EF6 3C47                    	cmp	al, 'G'
  5978 00001EF8 7406                    	je	short c4ue_g
  5979                                  	; 19/11/2024
  5980 00001EFA 3C0D                    	cmp	al, 0Dh ; ENTER/CR key
  5981 00001EFC 7516                    	jne	short c4ue_cpt
  5982                                  	; 23/11/2024
  5983                                  	;xor	bx, bx
  5984                                  	; 30/12/2024
  5985                                  	;mov	bl, ah ; 24/12/2024
  5986 00001EFE FEC3                    	inc	bl
  5987                                  c4ue_g:	; 30/12/2024
  5988 00001F00 80E307                  	and	bl, 07h
  5989 00001F03 7501                    	jnz	short c4ue_sc
  5990                                  	; 01/01/2025
  5991 00001F05 43                      	inc	bx
  5992                                  c4ue_sc:
  5993 00001F06 881E[372B]              	mov	[wpoints], bl
  5994                                  	; 01/01/2025
  5995 00001F0A 8A87[A728]              	mov	al, [bx+colors-1] ; 1 to 7
  5996                                  	; 24/12/2024
  5997 00001F0E A2[AF28]                	mov	[ccolor], al
  5998                                  	; 30/12/2024
  5999 00001F11 E82403                  	call	clear_window
  6000                                  	;;;
  6001                                  c4ue_cpt:
  6002 00001F14 1E                      	push	ds
  6003 00001F15 BB4000                  	mov	bx, 40h
  6004 00001F18 8EDB                    	mov	ds, bx
  6005 00001F1A BB6C00                  	mov	bx, 6Ch  ; counter (INT 08h, 18.2 ticks per sec)
  6006                                  	;cli
  6007 00001F1D 8B07                    	mov	ax, [bx]
  6008 00001F1F 8B5702                  	mov	dx, [bx+2]
  6009                                  	;sti
  6010 00001F22 1F                      	pop	ds
  6011                                  	; 18/11/2024
  6012 00001F23 59                      	pop	cx ; *
  6013 00001F24 3B16[EC2B]              	cmp	dx, [timerticks+2]
  6014 00001F28 7506                    	jne	short c4ue_utt
  6015 00001F2A 3B06[EA2B]              	cmp	ax, [timerticks]
  6016                                  	;je	short c4ue_ok
  6017                                  	; 18/11/2024
  6018 00001F2E 740A                    	je	short c4ue_skip_utt
  6019                                  c4ue_utt:
  6020                                  	; 01/01/2025
  6021 00001F30 A3[EA2B]                	mov	[timerticks], ax
  6022 00001F33 8916[EC2B]              	mov	[timerticks+2], dx
  6023 00001F37 EB05                    	jmp	short c4ue_cpt_@
  6024                                  
  6025                                  	; 30/12/2024
  6026                                  c4ue_vb_ok:
  6027 00001F39 C3                      	retn
  6028                                  
  6029                                  c4ue_skip_utt:
  6030                                  	; 01/01/2025
  6031                                  	; 18/11/2024
  6032 00001F3A 21C9                    	and	cx, cx
  6033 00001F3C 74FB                    	jz	short c4ue_vb_ok
  6034                                  c4ue_cpt_@:
  6035                                  	; 18/11/2024
  6036 00001F3E 803E[342B]00            	cmp	byte [stopped], 0
  6037 00001F43 77F4                    	ja	short c4ue_vb_ok
  6038                                  	
  6039 00001F45 E88A01                  	call	CalcProgressTime
  6040                                  
  6041 00001F48 3B06[E22B]              	cmp	ax, [ProgressTime]
  6042                                  	;je	short c4ue_vb_ok
  6043                                  			; same second, no need to update
  6044                                  	; 23/11/2024
  6045 00001F4C 7403                    	je	short c4ue_uvb
  6046                                  
  6047                                  	;call	UpdateProgressTime
  6048                                  	;call	UpdateProgressBar@
  6049 00001F4E E82502                  	call	UpdateProgressBar
  6050                                  
  6051                                  	; 23/11/2024
  6052                                  c4ue_uvb:
  6053 00001F51 803E[372B]00            	cmp	byte [wpoints], 0
  6054 00001F56 76E1                    	jna	short c4ue_vb_ok
  6055                                  
  6056                                  	; 30/12/2024
  6057                                  	;call	UpdateWavePoints
  6058                                  	;retn
  6059                                  
  6060                                  ; --------------------------------------------------------
  6061                                  ; 27/12/2024 - Erdogan Tan
  6062                                  ; --------------------------------------------------------
  6063                                  
  6064                                  	; 01/01/2025 (cgaplay.asm, 16bit registers)
  6065                                  	; 30/12/2024 (cgaplay.s)
  6066                                  	;  * 320*200 pixels, 256 colors
  6067                                  	;  * 64 volume levels
  6068                                  	; 29/12/2024
  6069                                  	; 27/12/2024 (DMA Buffer Tracking)
  6070                                  	; 26/12/2024
  6071                                  	; 24/12/2024
  6072                                  UpdateWavePoints:
  6073                                  	; 01/01/2024
  6074 00001F58 06                      	push	es ; **
  6075 00001F59 BB00A0                  	mov	bx, 0A000h
  6076 00001F5C 8EC3                    	mov	es, bx
  6077                                  	;
  6078 00001F5E BE[B428]                	mov	si, prev_points
  6079 00001F61 833C00                  	cmp	word [si], 0
  6080 00001F64 740C                    	jz	short lights_off_ok
  6081                                  
  6082                                  	;mov	cx, 640
  6083                                  	; 30/12/2024
  6084 00001F66 B94001                  	mov	cx, 320
  6085                                  light_off:
  6086 00001F69 AD                      	lodsw
  6087                                  	; ax = wave point (lighting point) address
  6088                                  	;mov	byte [ax], 0 ; black point (light off)
  6089                                  	; 01/01/2025 (16bit mode modification)
  6090 00001F6A 89C3                    	mov	bx, ax
  6091 00001F6C 26C60700                	mov	byte [es:bx], 0
  6092 00001F70 E2F7                    	loop	light_off
  6093                                  
  6094                                  lights_off_ok:
  6095                                  	; 29/12/2024
  6096 00001F72 803E[352B]32            	cmp	byte [tLO],'2'
  6097 00001F77 7506                    	jne	short lights_on_buff_1
  6098                                  lights_on_buff_2:
  6099                                  	; 01/01/2025
  6100 00001F79 8B16[D62B]              	mov	dx, [WAV_BUFFER2]
  6101 00001F7D EB04                    	jmp	short lights_on
  6102                                  lights_on_buff_1:
  6103                                  	; 01/01/2025
  6104 00001F7F 8B16[D42B]              	mov	dx, [WAV_BUFFER1]
  6105                                  lights_on:
  6106 00001F83 3916[3A2B]              	cmp	[pbuf_s], dx
  6107 00001F87 751C                    	jne	short lights_on_2
  6108 00001F89 8B1E[B028]              	mov	bx, [wpoints_dif]
  6109 00001F8D 8B36[382B]              	mov	si, [pbuf_o]
  6110 00001F91 8B0E[DC2B]              	mov	cx, [buffersize] ; samples
  6111                                  	; 01/01/2025
  6112 00001F95 D1E1                    	shl	cx, 1  ; bytes
  6113 00001F97 29D9                    	sub	cx, bx ; sub cx, [wpoints_dif]
  6114 00001F99 01DE                    	add	si, bx
  6115 00001F9B 7204                    	jc	short lights_on_1
  6116 00001F9D 39CE                    	cmp	si, cx
  6117 00001F9F 760A                    	jna	short lights_on_3
  6118                                  lights_on_1:
  6119 00001FA1 89CE                    	mov	si, cx
  6120 00001FA3 EB06                    	jmp	short lights_on_3
  6121                                  
  6122                                  lights_on_2:
  6123                                  	; 29/12/2024
  6124 00001FA5 8916[3A2B]              	mov	[pbuf_s], dx
  6125 00001FA9 31F6                    	xor	si, si ; 0
  6126                                  lights_on_3:
  6127 00001FAB 8936[382B]              	mov	[pbuf_o], si
  6128                                  	; 01/01/2025
  6129 00001FAF 1E                      	push	ds ; **
  6130                                  	;
  6131                                  	;mov	cx, 640
  6132                                  	; 30/12/2024
  6133 00001FB0 B94001                  	mov	cx, 320
  6134 00001FB3 89CD                    	mov	bp, cx
  6135                                  	; 26/12/2024
  6136 00001FB5 BF[B428]                	mov	di, prev_points
  6137                                  	;mov	bx, [graphstart] ; start (top) line
  6138                                  	; 01/01/2025
  6139 00001FB8 8EDA                    	mov	ds, dx
  6140 00001FBA BB0073                  	mov	bx, (11*8*320)+(4*320)
  6141                                  lights_on_4:
  6142                                  	; 01/01/2025
  6143 00001FBD 6631C0                  	xor	eax, eax ; 0
  6144 00001FC0 AD                      	lodsw	; left
  6145 00001FC1 80C480                  	add	ah, 80h
  6146 00001FC4 6689C2                  	mov	edx, eax
  6147 00001FC7 AD                      	lodsw	; right
  6148                                  	;add	ax, dx
  6149 00001FC8 80C480                  	add	ah, 80h
  6150                                  	;;shr	eax, 9	; 128 volume levels
  6151 00001FCB 6601D0                  	add	eax, edx
  6152                                  	;;shr	eax, 10	; (L+R/2) & 128 volume levels
  6153                                  	;shr	eax, 9	; (L+R/2) & 256 volume levels
  6154                                  	; 30/12/2024
  6155 00001FCE 66C1E80B                	shr	eax, 11	; (L+R/2) & 64 volume levels
  6156                                  	; * 320 row  ; 30/12/2024
  6157 00001FD2 F7E5                    	mul	bp	; * 640 (row) 
  6158 00001FD4 01D8                    	add	ax, bx ; + column
  6159                                  	;mov	dl, [ccolor]
  6160                                  	; 01/01/2025
  6161 00001FD6 2E8A16[AF28]            	mov	dl, [cs:ccolor]
  6162 00001FDB 93                      	xchg	ax, bx
  6163 00001FDC 268817                  	mov	[es:bx], dl ; pixel (light on) color
  6164 00001FDF 93                      	xchg	ax, bx
  6165 00001FE0 2E8905                  	mov	[cs:di], ax ; save light on addr in prev_points
  6166 00001FE3 47                      	inc	di
  6167 00001FE4 47                      	inc	di
  6168 00001FE5 43                      	inc	bx
  6169 00001FE6 E2D5                    	loop	lights_on_4
  6170 00001FE8 1F                      	pop	ds ; **
  6171 00001FE9 07                      	pop	es ; *
  6172 00001FEA C3                      	retn
  6173                                  
  6174                                  ; --------------------------------------------------------
  6175                                  ; 19/05/2024 - (playwav4.asm) ich_wav4.asm
  6176                                  ; --------------------------------------------------------
  6177                                  
  6178                                  	; 29/11/2024
  6179                                  check4keyboardstop:
  6180                                  	; 19/05/2024
  6181                                  	; 08/11/2023
  6182                                  	; 04/11/2023
  6183 00001FEB B401                    	mov	ah, 1
  6184 00001FED CD16                    	int	16h
  6185                                  	;clc
  6186 00001FEF 742C                    	jz	short _cksr
  6187                                  
  6188 00001FF1 30E4                    	xor	ah, ah
  6189 00001FF3 CD16                    	int	16h
  6190                                  
  6191                                  	; 29/11/2024
  6192 00001FF5 A2[3D2B]                	mov	[command], al
  6193                                  
  6194                                  	;;;
  6195                                  	; 19/05/2024 (change PCM out volume)
  6196 00001FF8 3C2B                    	cmp	al, '+'
  6197 00001FFA 750B                    	jne	short p_1
  6198                                  	
  6199 00001FFC A0[4320]                	mov	al, [volume]
  6200 00001FFF 3C00                    	cmp	al, 0
  6201 00002001 761C                    	jna	short p_3
  6202 00002003 FEC8                    	dec	al
  6203 00002005 EB0D                    	jmp	short p_2
  6204                                  p_1:
  6205 00002007 3C2D                    	cmp	al, '-'
  6206 00002009 7515                    	jne	short p_4
  6207                                  
  6208 0000200B A0[4320]                	mov	al, [volume]
  6209 0000200E 3C1F                    	cmp	al, 31
  6210 00002010 730D                    	jnb	short p_3
  6211 00002012 FEC0                    	inc	al
  6212                                  p_2:
  6213 00002014 A2[4320]                	mov	[volume], al
  6214                                  	; 14/11/2024
  6215 00002017 E857E5                  	call	SetPCMOutVolume
  6216                                  	; 15/11/2024 (QEMU)
  6217                                  	;call	SetMasterVolume
  6218                                  	;call	UpdateVolume
  6219                                  	;;clc
  6220                                  	;retn
  6221 0000201A E93101                  	jmp	UpdateVolume
  6222                                  	;mov	ah, al
  6223                                  	;mov    dx, [NAMBAR]
  6224                                    	;;add   dx, CODEC_MASTER_VOL_REG
  6225                                  	;add	dx, CODEC_PCM_OUT_REG
  6226                                  	;out    dx, ax
  6227                                  	;
  6228                                  	;call   delay1_4ms
  6229                                          ;call   delay1_4ms
  6230                                          ;call   delay1_4ms
  6231                                          ;call   delay1_4ms
  6232                                  _cksr:		; 19/05/2024
  6233                                  	; 18/11/2024
  6234 0000201D 31C0                    	xor	ax, ax
  6235                                  	;clc
  6236                                  p_3:
  6237 0000201F C3                      	retn
  6238                                  p_4:
  6239                                  	; 17/11/2024
  6240 00002020 80FC01                  	cmp	ah, 01h  ; ESC
  6241 00002023 7417                        	je	short p_q
  6242 00002025 3C03                    	cmp	al, 03h  ; CTRL+C
  6243 00002027 7413                    	je	short p_q
  6244                                  
  6245                                  	; 18/11/2024
  6246 00002029 3C20                    	cmp	al, 20h
  6247 0000202B 7415                    	je	short p_r
  6248                                  
  6249                                  	; 19/11/2024
  6250 0000202D 3C0D                    	cmp	al, 0Dh ; CR/ENTER
  6251 0000202F 7411                    	je	short p_r
  6252                                  
  6253 00002031 24DF                    	and	al, 0DFh
  6254                                  
  6255                                  	; 29/11/2024
  6256 00002033 A2[3D2B]                	mov	[command], al
  6257                                  
  6258                                  	;cmp	al, 'B'
  6259                                  	;je	short p_r
  6260                                  	;cmp	al, 'F'
  6261                                  	;je	short p_r
  6262                                  
  6263                                  	; 29/11/2024
  6264                                  	;cmp	al, 'N'
  6265                                  	;je	short p_r
  6266                                  	;cmp	al, 'P'
  6267                                  	;je	short p_r
  6268                                  
  6269 00002036 3C51                    	cmp	al, 'Q'
  6270                                  	;je	short p_q
  6271 00002038 7407                    	je	short p_quit ; 29/11/2024
  6272                                  
  6273 0000203A F8                      	clc
  6274 0000203B C3                      	retn
  6275                                  
  6276                                  	;;;
  6277                                  ;_cskr:	
  6278                                  p_q:
  6279                                  	; 29/11/2024
  6280 0000203C C606[3D2B]51            	mov	byte [command], 'Q'
  6281                                  p_quit:
  6282 00002041 F9                      	stc
  6283                                  p_r:
  6284 00002042 C3                      	retn
  6285                                  
  6286                                  ; 29/05/2024
  6287                                  ; 19/05/2024
  6288                                  volume: 
  6289                                  	;db	02h
  6290                                  ; 26/12/2024
  6291 00002043 03                      	db	03h
  6292                                  
  6293                                  ; --------------------------------------------------------
  6294                                  
  6295                                  	; 01/01/2025 /cgaplay.asm)
  6296                                  setCursorPosition:
  6297                                  	; dh = Row
  6298                                  	; dl = Column
  6299                                  
  6300                                  	; 31/12/2024
  6301 00002044 B700                    	mov	bh, 0
  6302 00002046 B402                    	mov	ah, 02h
  6303 00002048 CD10                    	int	10h
  6304 0000204A C3                      	retn
  6305                                  	
  6306                                  ; --------------------------------------------------------
  6307                                  ; 14/11/2024
  6308                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6309                                  
  6310                                  ;; NAME:	SetTotalTime
  6311                                  ;; DESCRIPTION: Calculates the total time in seconds in file
  6312                                  ;; INPUT:	DATA_SubchunkSize, WAVE_SampleRate, WAVE_BlockAlign
  6313                                  ;; OUTPUT:	CurrentTotalTime=Total time in seconds in file,
  6314                                  ;; 		Output on the screen of the total time in seconds
  6315                                  
  6316                                  	; 01/01/2025
  6317                                  SetTotalTime:
  6318                                  	;; Calculate total seconds in file
  6319 0000204B A1[682B]                	mov	ax, [DATA_SubchunkSize]
  6320 0000204E 8B16[6A2B]              	mov	dx, [DATA_SubchunkSize+2]
  6321 00002052 8B1E[582B]              	mov	bx, [WAVE_SampleRate]
  6322 00002056 F7F3                    	div	bx
  6323 00002058 31D2                    	xor	dx, dx
  6324                                  
  6325 0000205A 8B1E[602B]              	mov	bx, [WAVE_BlockAlign]
  6326                                  
  6327 0000205E F7F3                    	div	bx
  6328                                  
  6329 00002060 A3[E02B]                	mov	[TotalTime], ax
  6330                                  
  6331 00002063 B33C                    	mov	bl, 60
  6332 00002065 F6F3                    	div	bl
  6333                                  
  6334                                  	;; al = minutes, ah = seconds
  6335 00002067 50                      	push	ax ; **
  6336 00002068 50                      	push	ax ; *
  6337                                  
  6338                                  	;mov	dh, 24
  6339                                  	;mov	dl, 42
  6340                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6341 00002069 B617                    	mov	dh, 23
  6342 0000206B B216                    	mov	dl, 22
  6343 0000206D E8D4FF                  	call	setCursorPosition
  6344                                  
  6345 00002070 58                      	pop	ax ; *
  6346 00002071 30E4                    	xor	ah, ah
  6347 00002073 BD0200                  	mov	bp, 2
  6348 00002076 E80F00                  	call	PrintNumber
  6349                                  	
  6350                                  	;mov	dh, 24
  6351                                  	;mov	dl, 45
  6352                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6353 00002079 B617                    	mov	dh, 23
  6354 0000207B B219                    	mov	dl, 25
  6355 0000207D E8C4FF                  	call	setCursorPosition
  6356                                  
  6357 00002080 58                      	pop	ax ; **
  6358 00002081 88E0                    	mov	al, ah
  6359 00002083 30E4                    	xor	ah, ah
  6360 00002085 BD0200                  	mov	bp, 2
  6361                                  	;jmp	short PrintNumber
  6362                                  
  6363                                  ; --------------------------------------------------------
  6364                                  
  6365                                  	; 01/01/2025 (cgaplay.asm)
  6366                                  PrintNumber:
  6367                                  	; bp = digits
  6368                                  	; ax = binary number
  6369 00002088 BB0A00                  	mov	bx, 10
  6370 0000208B 31C9                    	xor	cx, cx
  6371                                  printNumber_CutNumber:
  6372 0000208D 41                      	inc	cx
  6373 0000208E 31D2                    	xor	dx, dx
  6374 00002090 F7F3                    	div	bx
  6375 00002092 52                      	push	dx
  6376 00002093 39E9                    	cmp	cx, bp
  6377 00002095 7402                    	je	short printNumber_printloop
  6378 00002097 EBF4                    	jmp	printNumber_CutNumber
  6379                                  
  6380                                  printNumber_printloop:
  6381 00002099 58                      	pop	ax
  6382                                  	; bp = count of digits
  6383                                  	; ax <= 9
  6384                                  
  6385 0000209A 0430                    	add	al, '0'
  6386                                  	
  6387                                  	; al = character
  6388 0000209C E8CE00                  	call	write_character_white
  6389                                  
  6390 0000209F 4D                      	dec	bp
  6391 000020A0 7402                     	jz	short printNumber_ok
  6392 000020A2 EBF5                    	jmp	short printNumber_printloop
  6393                                  printNumber_ok:
  6394 000020A4 C3                      	retn
  6395                                  
  6396                                  ; --------------------------------------------------------
  6397                                  
  6398                                  	; 01/01/2025
  6399                                  	; 14/11/2024 - Erdogan Tan
  6400                                  SetProgressTime:
  6401                                  	;; Calculate playing/progress seconds in file
  6402 000020A5 E82A00                  	call	CalcProgressTime
  6403                                  
  6404                                  UpdateProgressTime:
  6405                                  	; ax = (new) progress time 
  6406                                  
  6407 000020A8 A3[E22B]                	mov	[ProgressTime], ax
  6408                                  
  6409 000020AB B33C                    	mov	bl, 60
  6410 000020AD F6F3                    	div	bl
  6411                                  
  6412                                  	;; al = minutes, ah = seconds
  6413 000020AF 50                      	push	ax ; **
  6414 000020B0 50                      	push	ax ; *
  6415                                  
  6416                                  	;mov	dh, 24
  6417                                  	;mov	dl, 33
  6418                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6419 000020B1 B617                    	mov	dh, 23
  6420 000020B3 B20D                    	mov	dl, 13
  6421 000020B5 E88CFF                  	call	setCursorPosition
  6422                                  
  6423 000020B8 58                      	pop	ax ; *
  6424 000020B9 30E4                    	xor	ah, ah
  6425 000020BB BD0200                  	mov	bp, 2
  6426 000020BE E8C7FF                  	call	PrintNumber
  6427                                  	
  6428                                  	;mov	dh, 24
  6429                                  	;mov	dl, 36
  6430                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6431 000020C1 B617                    	mov	dh, 23
  6432 000020C3 B210                    	mov	dl, 16
  6433 000020C5 E87CFF                  	call	setCursorPosition
  6434                                  
  6435 000020C8 58                      	pop	ax ; **
  6436 000020C9 88E0                    	mov	al, ah
  6437 000020CB 30E4                    	xor	ah, ah
  6438                                  	; 21/12/2024
  6439 000020CD BD0200                  	mov	bp, 2
  6440 000020D0 EBB6                    	jmp	short PrintNumber
  6441                                  
  6442                                  ; --------------------------------------------------------
  6443                                  
  6444                                  	; 17/11/2024
  6445                                  	; 14/11/2024
  6446                                  CalcProgressTime:
  6447 000020D2 A1[E62B]                	mov	ax, [LoadedDataBytes]
  6448 000020D5 8B16[E82B]              	mov	dx, [LoadedDataBytes+2]
  6449 000020D9 89C3                    	mov	bx, ax
  6450 000020DB 09D3                    	or	bx, dx
  6451 000020DD 740E                    	jz	short cpt_ok
  6452                                  
  6453 000020DF 8B1E[582B]              	mov	bx, [WAVE_SampleRate]
  6454 000020E3 F7F3                    	div	bx
  6455 000020E5 31D2                    	xor	dx, dx
  6456 000020E7 8B1E[602B]              	mov	bx, [WAVE_BlockAlign]
  6457 000020EB F7F3                    	div	bx
  6458                                  cpt_ok:
  6459                                  	; ax = (new) progress time
  6460 000020ED C3                      	retn
  6461                                  
  6462                                  ; --------------------------------------------------------
  6463                                  ; 14/11/2024
  6464                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6465                                  
  6466                                  ;; DESCRIPTION: Update file information on template
  6467                                  ;; PARAMS:	WAVE parameters and other variables
  6468                                  ;; REGS:	AX(RW)
  6469                                  ;; VARS:	CurrentFileName, WAVE_SampleRate, 
  6470                                  ;; RETURNS:	On-screen file info is updated.
  6471                                  
  6472                                  	; 01/01/2025 (cgaplay.asm)
  6473                                  UpdateFileInfo:
  6474                                  	;; Print File Name
  6475                                  	;mov	dh, 9
  6476                                  	;mov	dl, 23
  6477                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6478 000020EE B607                    	mov	dh, 7
  6479 000020F0 B208                    	mov	dl, 8
  6480 000020F2 E84FFF                  	call	setCursorPosition
  6481                                  	
  6482 000020F5 BE[722B]                	mov	si, wav_file_name
  6483                                  	
  6484                                  	;;;
  6485                                  	; 14/11/2024
  6486                                  	; skip directory separators
  6487                                  	; (note: asciiz string, max. 79 bytes except zero tail)
  6488 000020F8 89F3                    	mov	bx, si
  6489                                  chk4_nxt_sep:
  6490 000020FA AC                      	lodsb
  6491 000020FB 3C5C                    	cmp	al, '\'
  6492 000020FD 7406                    	je	short chg_fpos
  6493 000020FF 20C0                    	and	al, al
  6494 00002101 7406                    	jz	short chg_fpos_ok
  6495 00002103 EBF5                    	jmp	short chk4_nxt_sep
  6496                                  chg_fpos:
  6497 00002105 89F3                    	mov	bx, si
  6498 00002107 EBF1                    	jmp	short chk4_nxt_sep
  6499                                  chg_fpos_ok:
  6500 00002109 89DE                    	mov	si, bx	; file name (without its path/directory)
  6501                                  	;;;
  6502                                  _fnl_chk:
  6503                                  	; 01/01/2025 (cplay.asm)
  6504                                  	; 30/12/2024 (cgaplay.s)
  6505                                  	; ????????.wav
  6506                                  	; 26/12/2024 (file name length limit -display-)
  6507 0000210B BB0C00                  	mov	bx, 12
  6508                                  	;mov	bx, 17	; ????????.wav?????
  6509 0000210E 56                      	push	si
  6510                                  _fnl_chk_loop:
  6511 0000210F AC                      	lodsb
  6512 00002110 20C0                    	and	al, al
  6513 00002112 7406                    	jz	short _fnl_ok
  6514 00002114 4B                       	dec	bx
  6515 00002115 75F8                    	jnz	short _fnl_chk_loop
  6516 00002117 C60400                  	mov	byte [si], 0
  6517                                  _fnl_ok:
  6518 0000211A 5E                      	pop	si
  6519                                  	;;;
  6520                                  
  6521 0000211B E8A9E2                  	call	PrintString
  6522                                  	
  6523                                  	;; Print Frequency
  6524                                  	;mov	dh, 10
  6525                                  	;mov	dl, 23
  6526                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6527 0000211E B608                    	mov	dh, 8
  6528 00002120 B208                    	mov	dl, 8
  6529 00002122 E81FFF                  	call	setCursorPosition
  6530                                  	 
  6531 00002125 A1[582B]                	mov	ax, [WAVE_SampleRate]
  6532 00002128 BD0500                  	mov	bp, 5
  6533 0000212B E85AFF                  	call	PrintNumber
  6534                                  
  6535                                  	;; Print BitRate
  6536                                  	;mov	dh, 9
  6537                                  	;mov	dl, 57
  6538                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6539 0000212E B607                    	mov	dh, 7
  6540 00002130 B21F                    	mov	dl, 31
  6541 00002132 E80FFF                  	call	setCursorPosition
  6542                                  
  6543 00002135 A1[622B]                	mov	ax, [WAVE_BitsPerSample]
  6544 00002138 BD0200                  	mov	bp, 2
  6545 0000213B E84AFF                  	call	PrintNumber
  6546                                  
  6547                                  	;; Print Channel Number
  6548                                  	;mov	dh, 10
  6549                                  	;mov	dl, 57
  6550                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6551 0000213E B608                    	mov	dh, 8
  6552 00002140 B21F                    	mov	dl, 31
  6553 00002142 E8FFFE                  	call	setCursorPosition
  6554                                  
  6555 00002145 A1[562B]                	mov	ax, [WAVE_NumChannels]
  6556 00002148 BD0100                  	mov	bp, 1
  6557 0000214B E83AFF                  	call	PrintNumber
  6558                                  
  6559                                  	;call	UpdateVolume
  6560                                  	;retn
  6561                                  
  6562                                  ; --------------------------------------------------------
  6563                                  
  6564                                  	; 01/01/2025
  6565                                  	; 14/11/2024
  6566                                  UpdateVolume:
  6567                                  	;; Print Volume
  6568                                  	;mov	dh, 24
  6569                                  	;mov	dl, 75
  6570                                  	; 01/01/2025 (cgaplay.asm, video mode 13h)
  6571 0000214E B617                    	mov	dh, 23
  6572 00002150 B223                    	mov	dl, 35
  6573 00002152 E8EFFE                  	call	setCursorPosition
  6574                                  	
  6575 00002155 A0[4320]                	mov	al, [volume]
  6576                                  
  6577 00002158 B364                    	mov	bl, 100
  6578 0000215A F6E3                    	mul	bl
  6579                                  
  6580 0000215C B31F                    	mov	bl, 31
  6581 0000215E F6F3                    	div	bl
  6582                                  
  6583 00002160 F7D8                    	neg	ax
  6584 00002162 83C064                  	add	ax, 100
  6585                                  
  6586 00002165 30E4                    	xor	ah, ah
  6587 00002167 BD0300                  	mov	bp, 3
  6588                                  	;call	PrintNumber
  6589                                  	;retn
  6590 0000216A E91BFF                  	jmp	PrintNumber
  6591                                  
  6592                                  ; --------------------------------------------------------
  6593                                  
  6594                                  	; 01/01/2025 (cgaplay.asm)
  6595                                  write_character_white:
  6596                                  	;mov	cx, 0Fh
  6597 0000216D B30F                    	mov	bl, 0Fh
  6598                                  write_character:
  6599                                  	; 01/12/2024
  6600 0000216F 30FF                    	xor	bh, bh
  6601                                  	; bl = foreground color
  6602                                  	; al = character (ASCII code)
  6603 00002171 B40E                    	mov	ah, 0Eh
  6604 00002173 CD10                    	int	10h
  6605 00002175 C3                      	retn
  6606                                  
  6607                                  ; --------------------------------------------------------
  6608                                  
  6609                                  	; 01/01/2025 (cgaplay.asm)
  6610                                  	; 30/12/2024
  6611                                  	; write characters in video mode 13h
  6612                                  	; (320*200 pixels, 256 colors)
  6613                                  	; 22/12/2024
  6614                                  	; 21/12/2024
  6615                                  	; (write chars in VESA VBE graphics mode)
  6616                                  	; 14/11/2024
  6617                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  6618                                  	; (Modification: Erdogan Tan, 14/11/2024)
  6619                                  
  6620                                  	;PROGRESSBAR_ROW equ 23
  6621                                  	; 21/12/2024 (640*480)
  6622                                  	;PROGRESSBAR_ROW equ 31
  6623                                  	; 30/12/2024 (320*200)
  6624                                  	PROGRESSBAR_ROW equ 22
  6625                                  
  6626                                  UpdateProgressBar:
  6627 00002176 E82CFF                  	call	SetProgressTime	; 14/11/2024
  6628                                  
  6629                                  	; 01/01/2025
  6630 00002179 A1[E22B]                	mov	ax, [ProgressTime]
  6631                                  UpdateProgressBar@:
  6632                                  	;mov	dx, 80
  6633                                  	; 30/12/2024
  6634 0000217C BA2800                  	mov	dx, 40 ; 320*200 pixels, 40 columns 
  6635 0000217F F7E2                    	mul	dx
  6636 00002181 8B1E[E02B]              	mov	bx, [TotalTime]
  6637 00002185 F7F3                    	div	bx
  6638                                  
  6639                                  	; 22/12/2024
  6640                                  	; check progress bar indicator position if it is same 
  6641 00002187 3A06[B328]              	cmp	al, [pbprev]
  6642 0000218B 741E                    	je	short UpdateProgressBar_ok
  6643 0000218D A2[B328]                	mov	[pbprev], al
  6644                                  
  6645                                  	; 01/01/2025
  6646                                  UpdateProgressBar@@:
  6647                                  	;; Push for the 'Clean' part
  6648 00002190 50                      	push	ax ; **
  6649 00002191 50                      	push	ax ; *
  6650                                  
  6651                                  	;; Set cursor position
  6652 00002192 B616                    	mov	dh, PROGRESSBAR_ROW
  6653 00002194 B200                    	mov	dl, 0
  6654 00002196 E8ABFE                  	call	setCursorPosition
  6655                                  
  6656 00002199 58                      	pop	ax ; *
  6657 0000219A 09C0                    	or	ax, ax
  6658 0000219C 741D                    	jz	short UpdateProgressBar_Clean
  6659                                  
  6660                                  	; 01/01/2025
  6661                                  UpdateProgressBar_DrawProgress:
  6662                                  	; 31/12/2024 (int 31h)
  6663                                  	; 22/12/2024
  6664                                  	; 21/12/2024
  6665                                  	; (write progress bar chars in graphics mode)
  6666                                  	;;;;
  6667 0000219E 89C5                    	mov	bp, ax
  6668 000021A0 50                      	push	ax ; ***
  6669                                  UpdateProgressBar_DrawProgress_@:
  6670                                  	; 01/01/2025
  6671 000021A1 B0DF                    	mov	al, 223
  6672                                  
  6673                                  	; al = character
  6674                                  	;call	write_character
  6675                                  	; 22/12/2024
  6676 000021A3 E8C7FF                  	call	write_character_white
  6677                                  
  6678 000021A6 4D                      	dec	bp
  6679 000021A7 7403                    	jz	short UpdateProgressBar_DrawCursor
  6680 000021A9 EBF6                    	jmp	short UpdateProgressBar_DrawProgress_@
  6681                                  
  6682                                  UpdateProgressBar_ok:
  6683 000021AB C3                      	retn
  6684                                  
  6685                                  	; 01/01/2025
  6686                                  UpdateProgressBar_DrawCursor:
  6687                                  	; 22/12/2024
  6688 000021AC 5A                      	pop	dx ; ***
  6689 000021AD B616                    	mov	dh, PROGRESSBAR_ROW
  6690                                  	; 31/12/2024
  6691 000021AF FECA                    	dec	dl ; last written position again
  6692 000021B1 E890FE                  	call	setCursorPosition
  6693                                  
  6694                                  	; 01/01/2025	
  6695 000021B4 B0DF                    	mov	al, 223
  6696                                  	;mov	cl, 0Ch ; red
  6697                                  	; 01/01/2025
  6698 000021B6 B30C                    	mov	bl, 0Ch
  6699 000021B8 E8B4FF                  	call	write_character
  6700                                  
  6701                                  	; 01/01/2025
  6702                                  UpdateProgressBar_Clean:
  6703                                  	;pop	ax  ; **
  6704                                  	; 22/12/2024
  6705 000021BB 5A                      	pop	dx  ; **
  6706                                  	; 30/12/2024
  6707                                  	; 21/12/2024
  6708                                  	;mov	bp, 80
  6709                                  	; 30/12/2024
  6710 000021BC BD2800                  	mov	bp, 40 ; 40 columns (320*200 pixels)
  6711                                  	;sub	bp, ax
  6712 000021BF 29D5                    	sub	bp, dx ; 22/12/2024
  6713                                  	;jz	short UpdateProgressBar_ok
  6714                                  	; 31/12/2024
  6715 000021C1 76E8                    	jna	short UpdateProgressBar_ok
  6716                                  
  6717 000021C3 B616                    	mov	dh, PROGRESSBAR_ROW
  6718                                  	;mov	dl, al ; 22/12/2024
  6719 000021C5 E87CFE                  	call	setCursorPosition
  6720                                  
  6721                                  	; 21/12/2024
  6722                                  	; (write progress bar chars in graphics mode)
  6723                                  UpdateProgressBar_Clean_@:
  6724                                  	; 01/01/2025	
  6725 000021C8 B0DF                    	mov	al, 223
  6726                                  	;mov	cl, 08h ; gray (dark)
  6727 000021CA B308                    	mov	bl, 08h
  6728 000021CC E8A0FF                  	call	write_character
  6729                                  	
  6730 000021CF 4D                      	dec	bp
  6731 000021D0 74D9                    	jz	short UpdateProgressBar_ok
  6732 000021D2 EBF4                    	jmp	short UpdateProgressBar_Clean_@
  6733                                  
  6734                                  ; --------------------------------------------------------
  6735                                  ; 17/11/2024
  6736                                  
  6737                                  Player_ProcessKey_Backwards:
  6738                                  	;; In order to go backwards 5 seconds:
  6739                                  	;; Update file pointer to the beginning, skip headers
  6740 000021D4 B142                    	mov	cl, 'B'
  6741 000021D6 EB02                    	jmp	short Player_ProcessKey_B_or_F
  6742                                  
  6743                                  Player_ProcessKey_Forwards:
  6744                                  	;; In order to fast-forward 5 seconds, set the file pointer
  6745                                  	;; to CUR_SEEK + 5 * Freq
  6746                                  
  6747 000021D8 B146                    	mov	cl, 'F'
  6748                                  	;jmp	short Player_ProcessKey_B_or_F
  6749                                  
  6750                                  	; 01/01/2025 (cgaplay.asm, 16bit registers)
  6751                                  	; 01/12/2024 (32bit registers)
  6752                                  Player_ProcessKey_B_or_F:
  6753                                  	; 17/11/2024
  6754                                  	; 04/11/2024
  6755                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  6756                                    
  6757                                  	; 04/11/2024
  6758 000021DA B80500                  	mov	ax, 5
  6759 000021DD 8B1E[602B]              	mov	bx, [WAVE_BlockAlign]
  6760 000021E1 F7E3                    	mul	bx
  6761 000021E3 8B1E[582B]              	mov	bx, [WAVE_SampleRate]
  6762 000021E7 F7E3                    	mul	bx
  6763                                  	; dx:ax = transfer byte count for 5 seconds
  6764                                  	
  6765                                  	; 17/11/2024
  6766 000021E9 80F942                  	cmp	cl, 'B'
  6767 000021EC 8B1E[E62B]              	mov	bx, [LoadedDataBytes]
  6768 000021F0 8B0E[E82B]              	mov	cx, [LoadedDataBytes+2]
  6769 000021F4 750C                    	jne	short move_forward ; cl = 'F'
  6770                                  move_backward:
  6771 000021F6 29C3                    	sub	bx, ax
  6772 000021F8 19D1                    	sbb	cx, dx
  6773 000021FA 7322                    	jnc	short move_file_pointer
  6774                                  move_to_beginning:
  6775 000021FC 31C9                    	xor	cx, cx ; 0
  6776 000021FE 31DB                    	xor	bx, bx ; 0
  6777 00002200 EB1C                    	jmp	short move_file_pointer
  6778                                  move_forward: 
  6779 00002202 01C3                    	add	bx, ax
  6780 00002204 11D1                    	adc	cx, dx
  6781 00002206 720E                    	jc	short move_to_end
  6782 00002208 3B0E[6A2B]              	cmp	cx, [DATA_SubchunkSize+2]
  6783 0000220C 7708                    	ja	short move_to_end
  6784 0000220E 720E                    	jb	short move_file_pointer
  6785 00002210 3B1E[682B]              	cmp	bx, [DATA_SubchunkSize]
  6786 00002214 7608                    	jna	short move_file_pointer
  6787                                  move_to_end:
  6788 00002216 8B1E[682B]              	mov	bx, [DATA_SubchunkSize]
  6789 0000221A 8B0E[6A2B]              	mov	cx, [DATA_SubchunkSize+2]
  6790                                  move_file_pointer:
  6791 0000221E 89DA                    	mov	dx, bx    
  6792 00002220 8916[E62B]              	mov	[LoadedDataBytes], dx
  6793 00002224 890E[E82B]              	mov	[LoadedDataBytes+2], cx
  6794 00002228 83C22C                  	add	dx, 44 ; + header
  6795 0000222B 83D100                  	adc	cx, 0
  6796                                  
  6797                                  	; seek
  6798 0000222E 8B1E[6E2B]              	mov	bx, [filehandle]
  6799 00002232 B80042                  	mov	ax, 4200h
  6800 00002235 CD21                    	int	21h
  6801                                  	
  6802 00002237 C3                      	retn
  6803                                  
  6804                                  ; --------------------------------------------------------
  6805                                  
  6806                                  	; 01/01/2025 (cgaplay.asm)
  6807                                  	; (video mode 13h, 320*200, 256 colors)
  6808                                  clear_window:
  6809 00002238 06                      	push	es
  6810 00002239 BF00A0                  	mov	di, 0A000h
  6811 0000223C 8EC7                    	mov	es, di
  6812 0000223E BF8070                  	mov	di, (11*8*320)+(2*320) ; AC97 info start 
  6813 00002241 29C0                    	sub	ax, ax
  6814 00002243 B90032                  	mov	cx, (10*8*320)/2
  6815 00002246 F3AB                    	rep	stosw
  6816 00002248 A3[B428]                	mov	[prev_points], ax ; 0
  6817 0000224B 07                      	pop	es
  6818 0000224C C3                      	retn
  6819                                  
  6820                                  ; -------------------------------------------------------------
  6821                                  ; ac97.inc (11/11/2023)
  6822                                  ; -------------------------------------------------------------
  6823                                  
  6824                                  ; special characters
  6825                                  LF      EQU 10
  6826                                  CR      EQU 13
  6827                                  
  6828                                  ; PCI stuff
  6829                                  
  6830                                  BIT0  EQU 1
  6831                                  BIT1  EQU 2
  6832                                  BIT2  EQU 4
  6833                                  BIT8  EQU 100h
  6834                                  BIT9  EQU 200h
  6835                                  BIT28 EQU 10000000h
  6836                                  BIT30 EQU 40000000h
  6837                                  BIT31 EQU 80000000h
  6838                                  
  6839                                  BUP		equ	BIT30		; Buffer Underrun Policy.
  6840                                  					; if this buffer is the last buffer
  6841                                  					; in a playback, fill the remaining
  6842                                  					; samples with 0 (silence) or not.
  6843                                  					; It's a good idea to set this to 1
  6844                                  					; for the last buffer in playback,
  6845                                  					; otherwise you're likely to get a lot
  6846                                  					; of noise at the end of the sound.
  6847                                  
  6848                                  RR		equ	BIT1		; reset registers. Nukes all regs
  6849                                                                          ; except bits 4:2 of this register.
  6850                                                                          ; Only set this bit if BIT 0 is 0
  6851                                  RPBM		equ	BIT0		; Run/Pause
  6852                                  					; set this bit to start the codec!
  6853                                  IO_ENA		EQU	BIT0		; i/o decode enable
  6854                                  BM_ENA		EQU	BIT2		; bus master enable
  6855                                  
  6856                                  PCI_INDEX_PORT  EQU     0CF8h
  6857                                  PCI_DATA_PORT   EQU     0CFCh
  6858                                  PCI32           EQU     BIT31           ; bitflag to signal 32bit access
  6859                                  PCI16           EQU     BIT30           ; bitflag for 16bit access
  6860                                  
  6861                                  AC97_INT_LINE	equ	3Ch		; AC97 Interrupt Line register offset
  6862                                  
  6863                                  ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
  6864                                  
  6865                                  INTEL_VID       equ     8086h           ; Intel's PCI vendor ID
  6866                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  6867                                  SIS_VID		equ	1039h
  6868                                  NVIDIA_VID	equ	10DEh	 ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
  6869                                  AMD_VID		equ	1022h
  6870                                  
  6871                                  ICH_DID         equ     2415h           ; ICH device ID
  6872                                  ICH0_DID        equ     2425h           ; ICH0
  6873                                  ICH2_DID        equ     2445h           ; ICH2 I think there are more ICHes.
  6874                                                                          ; they all should be compatible.
  6875                                  
  6876                                  ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
  6877                                  ICH3_DID	equ     2485h           ; ICH3
  6878                                  ICH4_DID        equ     24C5h           ; ICH4
  6879                                  ICH5_DID	equ     24D5h           ; ICH5
  6880                                  ICH6_DID	equ     266Eh           ; ICH6
  6881                                  ESB6300_DID	equ     25A6h           ; 6300ESB
  6882                                  ESB631X_DID	equ     2698h           ; 631XESB
  6883                                  ICH7_DID	equ	27DEh		; ICH7
  6884                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  6885                                  MX82440_DID	equ	7195h
  6886                                  SI7012_DID	equ	7012h
  6887                                  NFORCE_DID	equ	01B1h
  6888                                  NFORCE2_DID	equ	006Ah
  6889                                  AMD8111_DID	equ	746Dh
  6890                                  AMD768_DID	equ	7445h
  6891                                  ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
  6892                                  CK804_DID	equ	0059h
  6893                                  MCP04_DID	equ	003Ah
  6894                                  CK8_DID		equ	008Ah
  6895                                  NFORCE3_DID	equ	00DAh
  6896                                  CK8S_DID	equ	00EAh
  6897                                  
  6898                                  NAMBAR_REG	equ	10h		; native audio mixer BAR
  6899                                  NABMBAR_REG	equ	14h		; native audio bus mastering BAR
  6900                                  
  6901                                  CODEC_MASTER_VOL_REG	equ	02h	; master volume
  6902                                  CODEC_MASTER_TONE_REG	equ	08h	; master tone (R+L)
  6903                                  CODEC_PCM_OUT_REG 	equ	18h     ; PCM output volume
  6904                                  CODEC_EXT_AUDIO_REG	equ	28h	; extended audio
  6905                                  CODEC_EXT_AUDIO_CTRL_REG equ	2Ah	; extended audio control
  6906                                  CODEC_PCM_FRONT_DACRATE_REG equ	2Ch	; PCM out sample rate
  6907                                  
  6908                                  ; ICH supports 3 different types of register sets for three types of things
  6909                                  ; it can do, thus:
  6910                                  ;
  6911                                  ; PCM in (for recording) aka PI
  6912                                  ; PCM out (for playback) aka PO
  6913                                  ; MIC in (for recording) aka MC
  6914                                  
  6915                                  PI_BDBAR_REG	equ	0		; PCM in buffer descriptor BAR
  6916                                  PO_BDBAR_REG	equ	10h		; PCM out buffer descriptor BAR
  6917                                  
  6918                                  GLOB_CNT_REG	equ	2Ch		; Global control register
  6919                                  GLOB_STS_REG 	equ	30h		; Global Status register (RO)
  6920                                  
  6921                                  PI_CR_REG 	equ	0Bh		; PCM in Control Register
  6922                                  PO_CR_REG	equ	1Bh		; PCM out Control Register
  6923                                  MC_CR_REG	equ	2Bh		; MIC in Control Register
  6924                                  
  6925                                  PCI_CMD_REG	EQU	04h		; reg 04h, command register
  6926                                  
  6927                                  CTRL_ST_CREADY		equ	BIT8+BIT9+BIT28 ; Primary Codec Ready
  6928                                  CODEC_REG_POWERDOWN	equ	26h
  6929                                  
  6930                                  PO_CIV_REG	equ	14h		; PCM out current Index value (RO)
  6931                                  PO_LVI_REG	equ	15h		; PCM out Last Valid Index
  6932                                  PO_SR_REG	equ	16h		; PCM out Status register
  6933                                  
  6934                                  BDL_SIZE	equ	32*8		; Buffer Descriptor List size
  6935                                  
  6936                                  ; -------------------------------------------------------------
  6937                                  
  6938                                  ; 22/12/2024
  6939 0000224D 90<rep 3h>              align 4
  6940                                  
  6941                                  ; 13/11/2024
  6942                                  ; ('<<' to 'shl' conversion for FASM)
  6943                                  ;
  6944                                  ; 29/05/2024 (TRDOS 386)
  6945                                  ; 17/02/2017
  6946                                  ; Valid ICH device IDs
  6947                                  
  6948                                  valid_ids:
  6949                                  	;dd (ICH_DID shl 16) + INTEL_VID	; 8086h:2415h
  6950 00002250 86801524                	dd (ICH_DID << 16) + INTEL_VID		; 8086h:2415h
  6951 00002254 86802524                	dd (ICH0_DID << 16) + INTEL_VID		; 8086h:2425h
  6952 00002258 86804524                	dd (ICH2_DID << 16) + INTEL_VID		; 8086h:2445h
  6953 0000225C 86808524                	dd (ICH3_DID << 16) + INTEL_VID		; 8086h:2485h
  6954 00002260 8680C524                	dd (ICH4_DID << 16) + INTEL_VID		; 8086h:24C5h
  6955 00002264 8680D524                	dd (ICH5_DID << 16) + INTEL_VID		; 8086h:24D5h
  6956 00002268 86806E26                	dd (ICH6_DID << 16) + INTEL_VID		; 8086h:266Eh
  6957 0000226C 8680A625                	dd (ESB6300_DID << 16) + INTEL_VID	; 8086h:25A6h
  6958 00002270 86809826                	dd (ESB631X_DID << 16) + INTEL_VID	; 8086h:2698h
  6959 00002274 8680DE27                	dd (ICH7_DID << 16) + INTEL_VID		; 8086h:27DEh
  6960                                  	; 03/11/2023 - Erdogan Tan
  6961 00002278 86809571                	dd (MX82440_DID << 16) + INTEL_VID	; 8086h:7195h
  6962 0000227C 39101270                	dd (SI7012_DID << 16)  + SIS_VID	; 1039h:7012h
  6963 00002280 DE10B101                	dd (NFORCE_DID << 16)  + NVIDIA_VID	; 10DEh:01B1h
  6964 00002284 DE106A00                	dd (NFORCE2_DID << 16) + NVIDIA_VID	; 10DEh:006Ah
  6965 00002288 22106D74                	dd (AMD8111_DID << 16) + AMD_VID	; 1022h:746Dh
  6966 0000228C 22104574                	dd (AMD768_DID << 16)  + AMD_VID	; 1022h:7445h
  6967 00002290 DE105900                	dd (CK804_DID << 16) + NVIDIA_VID	; 10DEh:0059h
  6968 00002294 DE103A00                	dd (MCP04_DID << 16) + NVIDIA_VID	; 10DEh:003Ah
  6969 00002298 DE108A00                	dd (CK8_DID << 16) + NVIDIA_VID		; 1022h:008Ah
  6970 0000229C DE10DA00                	dd (NFORCE3_DID << 16) + NVIDIA_VID	; 10DEh:00DAh
  6971 000022A0 DE10EA00                	dd (CK8S_DID << 16) + NVIDIA_VID	; 10DEh:00EAh
  6972                                  
  6973                                  valid_id_count equ (($ - valid_ids)>>2)	; 05/11/2023
  6974                                  ; 13/11/2024
  6975                                  ;valid_id_count = ($ - valid_ids) shr 2	; 05/11/2023
  6976                                  
  6977 000022A4 00000000                	dd 0
  6978                                  
  6979                                  ; 01/01/2025
  6980                                  
  6981                                  Credits:
  6982 000022A8 564741205741562050-     	db 'VGA WAV Player for Retro DOS by Erdogan Tan. '
  6982 000022B1 6C6179657220666F72-
  6982 000022BA 20526574726F20444F-
  6982 000022C3 53206279204572646F-
  6982 000022CC 67616E2054616E2E20 
  6983                                  	;db 'January 2025.',10,13,0
  6984                                  	;db '01/01/2025', 10,13
  6985 000022D5 466562727561727920-     	db 'February 2025.',10,13,0
  6985 000022DE 323032352E0A0D00   
  6986 000022E6 30342F30322F323032-     	db '04/02/2025', 10,13
  6986 000022EF 350A0D             
  6987                                  ; 15/11/2024
  6988                                  reset:
  6989 000022F2 00                      	db 0
  6990                                  
  6991                                  msgAudioCardInfo:
  6992 000022F3 666F7220496E74656C-     	db 'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  6992 000022FC 204143393720284943-
  6992 00002305 482920417564696F20-
  6992 0000230E 436F6E74726F6C6C65-
  6992 00002317 722E0A0D00         
  6993                                  
  6994                                  	; 01/01/2025
  6995                                  msg_usage:
  6996 0000231C 75736167653A204347-     	db 'usage: CGAPLAY <FileName1> <FileName2> <...>',10,13,0
  6996 00002325 41504C4159203C4669-
  6996 0000232E 6C654E616D65313E20-
  6996 00002337 3C46696C654E616D65-
  6996 00002340 323E203C2E2E2E3E0A-
  6996 00002349 0D00               
  6997                                  
  6998                                  noDevMsg:
  6999 0000234B 4572726F723A20556E-     	db 'Error: Unable to find AC97 audio device!'
  6999 00002354 61626C6520746F2066-
  6999 0000235D 696E64204143393720-
  6999 00002366 617564696F20646576-
  6999 0000236F 69636521           
  7000 00002373 0A0D00                  	db 10,13,0
  7001                                  
  7002                                  noFileErrMsg:
  7003 00002376 4572726F723A206669-     	db 'Error: file not found.',10,13,0
  7003 0000237F 6C65206E6F7420666F-
  7003 00002388 756E642E0A0D00     
  7004                                  
  7005                                  ; 29/05/2024
  7006                                  ; 11/11/2023
  7007                                  msg_init_err:
  7008 0000238F 0D0A                    	db CR, LF
  7009 00002391 4143393720436F6E74-     	db 'AC97 Controller/Codec initialization error !'
  7009 0000239A 726F6C6C65722F436F-
  7009 000023A3 64656320696E697469-
  7009 000023AC 616C697A6174696F6E-
  7009 000023B5 206572726F722021   
  7010 000023BD 0D0A00                  	db CR, LF, 0 ; 07/12/2024
  7011                                  
  7012                                  ; 25/11/2023
  7013                                  msg_no_vra:
  7014 000023C0 0A0D                    	db 10,13
  7015 000023C2 4E6F20565241207375-     	db 'No VRA support ! Only 48 kHZ sample rate supported !'
  7015 000023CB 70706F72742021204F-
  7015 000023D4 6E6C79203438206B48-
  7015 000023DD 5A2073616D706C6520-
  7015 000023E6 726174652073757070-
  7015 000023EF 6F727465642021     
  7016 000023F6 0A0D00                  	db 10,13,0
  7017                                  
  7018                                  ; 19/11/2024
  7019                                  ; 03/06/2017
  7020                                  hex_chars:
  7021 000023F9 303132333435363738-     	db '0123456789ABCDEF', 0
  7021 00002402 3941424344454600   
  7022                                  msgAC97Info:
  7023 0000240A 0D0A                    	db 0Dh, 0Ah
  7024 0000240C 204143393720417564-     	db ' AC97 Audio Controller & Codec Info', 0Dh, 0Ah 
  7024 00002415 696F20436F6E74726F-
  7024 0000241E 6C6C6572202620436F-
  7024 00002427 64656320496E666F0D-
  7024 00002430 0A                 
  7025 00002431 2056656E646F722049-     	db ' Vendor ID: '
  7025 0000243A 443A20             
  7026                                  msgVendorId:
  7027 0000243D 303030306820446576-     	db '0000h Device ID: '
  7027 00002446 6963652049443A20   
  7028                                  msgDevId:
  7029 0000244E 30303030680D0A          	db '0000h', 0Dh, 0Ah
  7030 00002455 204275733A20            	db ' Bus: '
  7031                                  msgBusNo:
  7032 0000245B 303068204465766963-     	db '00h Device: '
  7032 00002464 653A20             
  7033                                  msgDevNo:
  7034 00002467 3030682046756E6374-     	db '00h Function: '
  7034 00002470 696F6E3A20         
  7035                                  msgFncNo:
  7036 00002475 303068                  	db '00h'
  7037 00002478 0D0A                    	db 0Dh, 0Ah
  7038 0000247A 204E414D4241523A20      	db ' NAMBAR: '
  7039                                  msgNamBar:
  7040 00002483 30303030682020          	db '0000h  '
  7041 0000248A 4E41424D4241523A20      	db 'NABMBAR: '
  7042                                  msgNabmBar:
  7043 00002493 303030306820204952-     	db '0000h  IRQ: '
  7043 0000249C 513A20             
  7044                                  msgIRQ:
  7045 0000249F 3030                    	dw 3030h
  7046 000024A1 0D0A00                  	db 0Dh, 0Ah, 0
  7047                                  ; 25/11/2023
  7048                                  msgVRAheader:
  7049 000024A4 205652412073757070-     	db ' VRA support: '
  7049 000024AD 6F72743A20         
  7050 000024B2 00                      	db 0	
  7051                                  msgVRAyes:
  7052 000024B3 5945530D0A00            	db 'YES', 0Dh, 0Ah, 0
  7053                                  msgVRAno:
  7054 000024B9 4E4F200D0A              	db 'NO ', 0Dh, 0Ah
  7055                                  	;db ' (Interpolated sample rate playing method)'
  7056                                  	; 30/12/2024
  7057 000024BE 2028496E746572706F-     	db ' (Interpolated samplerate play method)'
  7057 000024C7 6C617465642073616D-
  7057 000024D0 706C65726174652070-
  7057 000024D9 6C6179206D6574686F-
  7057 000024E2 6429               
  7058 000024E4 0D0A00                  	db 0Dh, 0Ah, 0
  7059                                  
  7060 000024E7 90                      align 4
  7061                                  
  7062                                  ; -------------------------------------------------------------
  7063                                  
  7064                                  	; 30/12/2024
  7065                                  PlayingScreen:
  7066 000024E8 DBDBDBDBDBDBDBDBDB-     	db  14 dup(219), " DOS Player ", 14 dup(219)
  7066 000024F1 DBDBDBDBDB20444F53-
  7066 000024FA 20506C6179657220DB-
  7066 00002503 DBDBDBDBDBDBDBDBDB-
  7066 0000250C DBDBDBDB           
  7067 00002510 C9CDCDCDCDCDCDCDCD-     	db  201, 38 dup(205), 187
  7067 00002519 CDCDCDCDCDCDCDCDCD-
  7067 00002522 CDCDCDCDCDCDCDCDCD-
  7067 0000252B CDCDCDCDCDCDCDCDCD-
  7067 00002534 CDCDCDBB           
  7068 00002538 BA203C53706163653E-     	db  186, " <Space> Play/Pause <N>/<P> Next/Prev ", 186
  7068 00002541 20506C61792F506175-
  7068 0000254A 7365203C4E3E2F3C50-
  7068 00002553 3E204E6578742F5072-
  7068 0000255C 657620BA           
  7069 00002560 BA203C533E20202020-     	db  186, " <S>     Stop       <Enter> Color     ", 186
  7069 00002569 2053746F7020202020-
  7069 00002572 2020203C456E746572-
  7069 0000257B 3E20436F6C6F722020-
  7069 00002584 202020BA           
  7070 00002588 BA203C463E20202020-     	db  186, " <F>     Forwards   <+>/<-> Volume    ", 186
  7070 00002591 20466F727761726473-
  7070 0000259A 2020203C2B3E2F3C2D-
  7070 000025A3 3E20566F6C756D6520-
  7070 000025AC 202020BA           
  7071 000025B0 BA203C423E20202020-     	db  186, " <B>     Backwards  <Q>     Quit Prg  ", 186
  7071 000025B9 204261636B77617264-
  7071 000025C2 7320203C513E202020-
  7071 000025CB 202051756974205072-
  7071 000025D4 672020BA           
  7072 000025D8 CCCDCDCDCDCDCDCDCD-     	db  204, 38 dup(205), 185
  7072 000025E1 CDCDCDCDCDCDCDCDCD-
  7072 000025EA CDCDCDCDCDCDCDCDCD-
  7072 000025F3 CDCDCDCDCDCDCDCDCD-
  7072 000025FC CDCDCDB9           
  7073 00002600 BA2046696C653A2020-     	db  186, " File:              Bits:     0       ", 186
  7073 00002609 202020202020202020-
  7073 00002612 202020426974733A20-
  7073 0000261B 202020203020202020-
  7073 00002624 202020BA           
  7074 00002628 BA20467265713A2030-     	db  186, " Freq: 0     Hz     Channels: 0       ", 186
  7074 00002631 2020202020487A2020-
  7074 0000263A 2020204368616E6E65-
  7074 00002643 6C733A203020202020-
  7074 0000264C 202020BA           
  7075 00002650 C8CDCDCDCDCDCDCDCD-     	db  200, 38 dup(205), 188
  7075 00002659 CDCDCDCDCDCDCDCDCD-
  7075 00002662 CDCDCDCDCDCDCDCDCD-
  7075 0000266B CDCDCDCDCDCDCDCDCD-
  7075 00002674 CDCDCDBC           
  7076 00002678 202020202020202020-     	db  40 dup(32)
  7076 00002681 202020202020202020-
  7076 0000268A 202020202020202020-
  7076 00002693 202020202020202020-
  7076 0000269C 20202020           
  7077                                  improper_samplerate_txt:
  7078                                  read_error_txt:
  7079 000026A0 202020202020202020-     	db  40 dup(32)
  7079 000026A9 202020202020202020-
  7079 000026B2 202020202020202020-
  7079 000026BB 202020202020202020-
  7079 000026C4 20202020           
  7080 000026C8 202020202020202020-     	db  40 dup(32)
  7080 000026D1 202020202020202020-
  7080 000026DA 202020202020202020-
  7080 000026E3 202020202020202020-
  7080 000026EC 20202020           
  7081 000026F0 202020202020202020-     	db  40 dup(32)
  7081 000026F9 202020202020202020-
  7081 00002702 202020202020202020-
  7081 0000270B 202020202020202020-
  7081 00002714 20202020           
  7082 00002718 202020202020202020-     	db  40 dup(32)
  7082 00002721 202020202020202020-
  7082 0000272A 202020202020202020-
  7082 00002733 202020202020202020-
  7082 0000273C 20202020           
  7083 00002740 202020202020202020-     	db  40 dup(32)
  7083 00002749 202020202020202020-
  7083 00002752 202020202020202020-
  7083 0000275B 202020202020202020-
  7083 00002764 20202020           
  7084 00002768 202020202020202020-     	db  40 dup(32)
  7084 00002771 202020202020202020-
  7084 0000277A 202020202020202020-
  7084 00002783 202020202020202020-
  7084 0000278C 20202020           
  7085 00002790 202020202020202020-     	db  40 dup(32)
  7085 00002799 202020202020202020-
  7085 000027A2 202020202020202020-
  7085 000027AB 202020202020202020-
  7085 000027B4 20202020           
  7086 000027B8 202020202020202020-     	db  40 dup(32)
  7086 000027C1 202020202020202020-
  7086 000027CA 202020202020202020-
  7086 000027D3 202020202020202020-
  7086 000027DC 20202020           
  7087 000027E0 202020202020202020-     	db  40 dup(32)
  7087 000027E9 202020202020202020-
  7087 000027F2 202020202020202020-
  7087 000027FB 202020202020202020-
  7087 00002804 20202020           
  7088 00002808 202020202020202020-     	db  40 dup(32)
  7088 00002811 202020202020202020-
  7088 0000281A 202020202020202020-
  7088 00002823 202020202020202020-
  7088 0000282C 20202020           
  7089 00002830 CDCDCDCDCDCDCDCDCD-     	db  40 dup(205)
  7089 00002839 CDCDCDCDCDCDCDCDCD-
  7089 00002842 CDCDCDCDCDCDCDCDCD-
  7089 0000284B CDCDCDCDCDCDCDCDCD-
  7089 00002854 CDCDCDCD           
  7090 00002858 202020202020202020-     	db  40 dup(32)
  7090 00002861 202020202020202020-
  7090 0000286A 202020202020202020-
  7090 00002873 202020202020202020-
  7090 0000287C 20202020           
  7091 00002880 202020202020202020-     	db  13 dup(32), "00:00 ", 174, 175, " 00:00", 4 dup(32), "VOL 000%"
  7091 00002889 2020202030303A3030-
  7091 00002892 20AEAF2030303A3030-
  7091 0000289B 20202020564F4C2030-
  7091 000028A4 303025             
  7092                                  	;db  40 dup(32) ; not necessary
  7093 000028A7 00                      	db 0
  7094                                  
  7095                                  ; -------------------------------------------------------------
  7096                                  
  7097                                  ; 31/12/2024
  7098                                  	; 30/12/2024
  7099                                  ;fillblock:
  7100                                  ;	times 8 db 0FFh
  7101                                  ;	dw 0
  7102                                  
  7103                                  ; -------------------------------------------------------------
  7104                                  
  7105                                  ; 30/12/2024
  7106                                  ; 23/11/2024
  7107                                  colors:
  7108 000028A8 0F0B0A0C0E090D          	db 0Fh, 0Bh, 0Ah, 0Ch, 0Eh, 09h, 0Dh
  7109                                  	; white, cyan, green, red, yellow, blue, magenta
  7110 000028AF 0B                      ccolor:	db 0Bh	; cyan
  7111                                  
  7112                                  EOF: 
  7113                                  
  7114                                  ; -------------------------------------------------------------
  7115                                  
  7116                                  bss:
  7117                                  
  7118                                  ABSOLUTE bss
  7119                                  
  7120                                  ; 01/01/2025 (16bit modifications)
  7121                                  
  7122                                  alignb 2
  7123                                  
  7124                                  ; 24/12/2024
  7125                                  wpoints_dif:	; wave lighting points factor (differential) 
  7126 000028B0 ????                    	resw 1	; required bytes for 1/18 second wave lighting
  7127                                  ; 01/01/2025
  7128                                  ;graphstart:
  7129                                  ;	resw 1	; start (top) line/row for wave lighting points
  7130                                  
  7131                                  columns:
  7132 000028B2 ??                      	resb 1
  7133 000028B3 ??                      pbprev:	resb 1 ; previous progress bar indicator position
  7134                                  
  7135                                  ;alignb 2
  7136                                  
  7137                                  bss_start:
  7138                                  
  7139                                  ; 30/12/2024
  7140                                  prev_points:
  7141 000028B4 <res 280h>              	resw 320 ; previous wave points (which are lighting)
  7142                                  
  7143                                  ; 18/11/2024
  7144                                  stopped:
  7145 00002B34 ??                      	resb 1
  7146 00002B35 ??                      tLO:	resb 1
  7147                                  ; 21/11/2024
  7148 00002B36 ??                      tLP:	resb 1
  7149                                  ; 30/12/2024
  7150                                  wpoints:
  7151 00002B37 ??                      	resb 1
  7152 00002B38 ????                    pbuf_o:	resw 1
  7153                                  ; 29/12/2024
  7154 00002B3A ????                    pbuf_s:	resw 1
  7155                                  
  7156                                  ; 30/05/2024
  7157 00002B3C ??                      VRA:	resb 1	; Variable Rate Audio Support Status
  7158                                  
  7159                                  ; 25/12/2024
  7160                                  ; 29/11/2024
  7161                                  command:
  7162 00002B3D ??                      	resb 1
  7163                                  filecount:
  7164 00002B3E ??                      	resb 1
  7165                                  
  7166                                  ; 30/11/2024
  7167 00002B3F ??                      alignb 4
  7168                                  
  7169                                  ;;;;;;;;;;;;;;
  7170                                  ; 14/11/2024
  7171                                  ; (Ref: player.asm, Matan Alfasi, 2017)  
  7172                                  WAVFILEHEADERbuff:
  7173                                  RIFF_ChunkID:
  7174 00002B40 ????????                	resd 1	; Must be equal to "RIFF" - big-endian
  7175                                  		; 0x52494646
  7176                                  RIFF_ChunkSize:
  7177 00002B44 ????????                	resd 1	; Represents total file size, not 
  7178                                          	; including the first 2 fields 
  7179                                  		; (Total_File_Size - 8), little-endian
  7180                                  RIFF_Format:
  7181 00002B48 ????????                	resd 1	; Must be equal to "WAVE" - big-endian
  7182                                  		; 0x57415645
  7183                                  
  7184                                  ;; WAVE header parameters ("Sub-chunk")
  7185                                  WAVE_SubchunkID:
  7186 00002B4C ????????                	resd 1	; Must be equal to "fmt " - big-endian
  7187                                  		; 0x666d7420
  7188                                  WAVE_SubchunkSize:
  7189 00002B50 ????????                	resd 1	; Represents total chunk size
  7190                                  WAVE_AudioFormat:
  7191 00002B54 ????                    	resw 1	; PCM (Raw) - is 1, other - is a form
  7192                                  		; of compression, not supported.
  7193                                  WAVE_NumChannels:
  7194 00002B56 ????                    	resw 1	; Number of channels, Mono-1, Stereo-2
  7195                                  WAVE_SampleRate:
  7196 00002B58 ????????                	resd 1	; Frequency rate, in Hz (8000, 44100 ...)
  7197                                  WAVE_ByteRate:
  7198 00002B5C ????????                	resd 1	; SampleRate * NumChannels * BytesPerSample
  7199                                  WAVE_BlockAlign:
  7200 00002B60 ????                    	resw 1	; NumChannels * BytesPerSample
  7201                                  		; Number of bytes for one sample.
  7202                                  WAVE_BitsPerSample:
  7203 00002B62 ????                    	resw 1	; 8 = 8 bits, 16 = 16 bits, etc.
  7204                                  
  7205                                  ;; DATA header parameters
  7206                                  DATA_SubchunkID:
  7207 00002B64 ????????                	resd 1	; Must be equal to "data" - big-endian
  7208                                          	; 0x64617461
  7209                                  DATA_SubchunkSize:
  7210 00002B68 ????????                	resd 1	; NumSamples * NumChannels * BytesPerSample
  7211                                          	; Number of bytes in the data.
  7212                                  ;;;;;;;;;;;;;;
  7213                                  
  7214                                  ; 01/01/2025
  7215                                  
  7216 00002B6C ??                      flags:	resb 1
  7217                                  ; 06/11/2023
  7218                                  ac97_int_ln_reg:
  7219 00002B6D ??                      	resb 1
  7220                                  filehandle:
  7221 00002B6E ????                    	resw 1
  7222                                  
  7223                                  ; 01/01/2025
  7224                                  ; 28/11/2024
  7225                                  PSP_CurrentOffset:
  7226 00002B70 ????                    	resw 1
  7227                                  
  7228                                  ; 30/05/2024
  7229                                  wav_file_name:
  7230 00002B72 <res 50h>               	resb 80	; wave file, path name (<= 80 bytes)
  7231 00002BC2 ????                    	resw 1	; 30/11/2024
  7232                                  
  7233                                  ; 08/11/2023
  7234                                  ; 07/11/2023
  7235                                  fbs_shift:
  7236 00002BC4 ??                      	resb 1
  7237                                  ; 07/12/2024
  7238 00002BC5 ??                      SRB:	resb 1
  7239                                  
  7240                                  ; 12/11/2016 - Erdogan Tan
  7241                                  bus_dev_fn:
  7242 00002BC6 ????????                	resd 1
  7243                                  dev_vendor:
  7244 00002BCA ????????                	resd 1
  7245                                  
  7246                                  ; 17/02/2017
  7247                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  7248                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  7249                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  7250                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  7251 00002BCE ????                    NAMBAR:	resw 1	; BAR for mixer
  7252                                  NABMBAR:
  7253 00002BD0 ????                    	resw 1	; BAR for bus master regs
  7254                                  
  7255                                  ; 01/01/2024
  7256                                  ; 256 byte buffer for descriptor list
  7257                                  BDL_BUFFER:
  7258 00002BD2 ????                    	resw 1	; segment of our 256byte BDL buffer
  7259                                  WAV_BUFFER1:
  7260 00002BD4 ????                    	resw 1	; segment of our WAV storage
  7261                                  ; 64k buffers for wav file storage
  7262                                  WAV_BUFFER2:
  7263 00002BD6 ????                    	resw 1	; segment of 2nd wav buffer
  7264                                  
  7265                                  ; 01/01/2025
  7266                                  ; 15/11/2024
  7267                                  loadfromwavfile:
  7268 00002BD8 ????                    	resw 1	; 'loadfromfile' or load+conversion proc address
  7269                                  loadsize:
  7270 00002BDA ????                    	resw 1	; (.wav file) read count (bytes) per one time
  7271                                  buffersize:
  7272 00002BDC ????????                	resd 1	; 16 bit samples (not bytes)
  7273                                  		
  7274                                  ; 01/01/2025
  7275                                  ; 14/11/2024
  7276                                  TotalTime:
  7277 00002BE0 ????                    	resw 1	; Total (WAV File) Playing Time in seconds
  7278                                  ProgressTime:
  7279 00002BE2 ????                    	resw 1
  7280 00002BE4 ????                    count:	resw 1	; byte count of one (wav file) read
  7281                                  LoadedDataBytes:
  7282 00002BE6 ????????                	resd 1	; total read/load count
  7283                                  
  7284                                  timerticks:
  7285 00002BEA ????????                	resd 1	; (to eliminate excessive lookup of events in tuneloop)
  7286                                  		; (in order to get the emulator/qemu to run correctly)
  7287                                  ; 14/11/2024
  7288                                  bss_end:
  7289                                  
  7290                                  ; 01/01/2025
  7291                                  ; 17/11/2024
  7292                                  temp_buffer:
  7293 00002BEE <res C5A8h>             	resb 50600  ; (44.1 kHZ stereo 12650 samples)
