     1                                  ; ****************************************************************************
     2                                  ; cgaplay.s - TRDOS 386 (TRDOS v2.0.9) WAV PLAYER - Video Mode 13h
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; CGAPLAY.PRG ! AC'97 (ICH) .WAV PLAYER program by Erdogan TAN
     5                                  ;
     6                                  ; 27/12/2024				- play music from multiple wav files -
     7                                  ;
     8                                  ; [ Last Modification: 30/12/2024 ]
     9                                  ;
    10                                  ; Modified from VGAPLAY3.PRG .wav player program by Erdogan Tan, 30/12/2024
    11                                  ;
    12                                  ; ****************************************************************************
    13                                  ; nasm cgaplay.s -l cgaplay.txt -o CGAPLAY.PRG -Z error.txt
    14                                  
    15                                  ; 30/12/2024
    16                                  ; vgaplay3.s
    17                                  ; 27/12/2024
    18                                  ; vgaplay2.s : DMA buffer tracking (instead of user's audio buffer)
    19                                  ; 18/12/2024
    20                                  ; ac97play.s : TUNELOOP version (playing without AC97 interrupt)
    21                                  
    22                                  ; vgaplay.s (26/12/2024) - play music from multiple wav files -
    23                                  ; dplayvga.s (25/12/2024) - play music from single wav file -
    24                                  ; ac97play.s (18/12/2024) - play music from multiple wav files -
    25                                  
    26                                  ; 07/12/2024 - playwav9.s - interrupt (srb) + tuneloop version
    27                                  ; ------------------------------------------------------------
    28                                  ; INTERRUPT (SRB) + TUNELOOP version ; 24/11/2024 (PLAYWAV9.ASM)
    29                                  ;	(running in DOSBOX, VIRTUALBOX, QEMU is ok)
    30                                  ; Signal Response Byte = message/signal to user about an event/interrupt
    31                                  ;	    as requested (TuneLoop procedure continuously checks this SRB)
    32                                  ; (TRDOS 386 v2 feature is used here as very simple interrupt handler output)
    33                                  
    34                                  ; ------------------------------------------------------------
    35                                  
    36                                  ; 30/11/2024
    37                                  ; 20/08/2024 ; TRDOS 386 v2.0.9
    38                                  ; 29/04/2016
    39                                  _ver 	equ 0
    40                                  _exit 	equ 1
    41                                  _fork 	equ 2
    42                                  _read 	equ 3
    43                                  _write	equ 4
    44                                  _open	equ 5
    45                                  _close 	equ 6
    46                                  _wait 	equ 7
    47                                  _creat 	equ 8
    48                                  _link 	equ 9
    49                                  _unlink	equ 10
    50                                  _exec	equ 11
    51                                  _chdir	equ 12
    52                                  _time 	equ 13
    53                                  _mkdir 	equ 14
    54                                  _chmod	equ 15
    55                                  _chown	equ 16
    56                                  _break	equ 17
    57                                  _stat	equ 18
    58                                  _seek	equ 19
    59                                  _tell 	equ 20
    60                                  _mount	equ 21
    61                                  _umount	equ 22
    62                                  _setuid	equ 23
    63                                  _getuid	equ 24
    64                                  _stime	equ 25
    65                                  _quit	equ 26
    66                                  _intr	equ 27
    67                                  _fstat	equ 28
    68                                  _emt 	equ 29
    69                                  _mdate 	equ 30
    70                                  _video 	equ 31
    71                                  _audio	equ 32
    72                                  _timer	equ 33
    73                                  _sleep	equ 34
    74                                  _msg    equ 35
    75                                  _geterr	equ 36
    76                                  _fpsave	equ 37
    77                                  _pri	equ 38
    78                                  _rele	equ 39
    79                                  _fff	equ 40
    80                                  _fnf	equ 41
    81                                  _alloc	equ 42
    82                                  _dalloc equ 43
    83                                  _calbac equ 44
    84                                  _dma	equ 45
    85                                  _stdio  equ 46
    86                                  
    87                                  ; ------------------------------------------------------------
    88                                  
    89                                  %macro sys 1-4
    90                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    91                                      ; 03/09/2015
    92                                      ; 13/04/2015
    93                                      ; Retro UNIX 386 v1 system call.
    94                                      %if %0 >= 2
    95                                          mov ebx, %2
    96                                          %if %0 >= 3
    97                                              mov ecx, %3
    98                                              %if %0 = 4
    99                                                 mov edx, %4
   100                                              %endif
   101                                          %endif
   102                                      %endif
   103                                      mov eax, %1
   104                                      ;int 30h
   105                                      int 40h ; TRDOS 386 (TRDOS v2.0)
   106                                  %endmacro
   107                                  
   108                                  ; Retro UNIX 386 v1 system call format:
   109                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   110                                  
   111                                  ; ------------------------------------------------------------
   112                                  
   113                                  ; player internal variables and other equates.
   114                                  BUFFERSIZE	equ 65536
   115                                  ENDOFFILE	equ 1		; flag for knowing end of file
   116                                  
   117                                  ; ------------------------------------------------------------
   118                                  
   119                                  [BITS 32] ; 32-bit intructions
   120                                  
   121                                  [ORG 0]
   122                                  
   123                                  START_CODE:
   124                                  	; Prints the Credits Text.
   125                                  	sys	_msg, Credits, 255, 0Bh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000000 BB[AC2C0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000005 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000000A BA0B000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000000F B823000000          <1>  mov eax, %1
   104                              <1> 
   105 00000014 CD40                <1>  int 40h
   126                                  
   127                                  	; clear bss
   128 00000016 BF[F4320000]            	mov	edi, bss_start
   129 0000001B B976010000              	mov	ecx, (bss_end - bss_start)/4
   130 00000020 31C0                    	xor	eax, eax
   131 00000022 F3AB                    	rep	stosd
   132                                  
   133                                  ; -------------------------------------------------------------
   134                                  
   135                                  	; 21/12/2024
   136                                  	; Detect (& Enable) AC'97 Audio Device
   137 00000024 E88C070000              	call	DetectAC97
   138 00000029 731B                    	jnc	short ac97_hardware_ready
   139                                  
   140                                  	; 30/11/2024
   141                                  	; 30/05/2024
   142                                  _dev_not_ready:
   143                                  	; couldn't find the audio device!
   144                                  	sys	_msg, noDevMsg, 255, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000002B BB[4F2D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000030 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00000035 BA0F000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000003A B823000000          <1>  mov eax, %1
   104                              <1> 
   105 0000003F CD40                <1>  int 40h
   145 00000041 E973040000                      jmp     Exit
   146                                  
   147                                  ac97_hardware_ready:
   148 00000046 E8A10D0000              	call	write_audio_dev_info
   149                                  
   150                                  ; -------------------------------------------------------------
   151                                  
   152                                  	; 30/12/2024
   153                                  	;;;
   154                                  	; DIRECT VGA MEMORY ACCESS
   155                                  	; bl = 0, bh = 5
   156                                  	; Direct access/map to VGA memory (0A0000h)
   157                                  
   158                                  	sys	_video, 0500h
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000004B BB00050000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97                              <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000050 B81F000000          <1>  mov eax, %1
   104                              <1> 
   105 00000055 CD40                <1>  int 40h
   159 00000057 3D00000A00              	cmp	eax, 0A0000h
   160 0000005C 7405                    	je	short _a
   161                                  
   162                                  	; 30/12/2024
   163 0000005E E99E040000              	jmp	trdos386_error
   164                                  
   165                                  _a:
   166                                  	;; Set Video Mode to 13h
   167                                  	;sys	_video, 0813h
   168                                  	;cmp	eax, 14h 
   169                                  	;je	short mode_13h_set_ok
   170                                  
   171                                  	; set VGA mode by using int 31h
   172 00000063 66B81300                	mov	ax, 13h	; mode 13h ; 
   173 00000067 CD31                    	int	31h	; real mode: int 10h
   174                                  
   175                                  ; -------------------------------------------------------------
   176                                  
   177                                  mode_13h_set_ok:
   178                                  	; 30/12/2024
   179                                  	; 24/12/2024 (setting for wave lighting points)
   180                                  	;mov	eax, 0A0000h
   181                                  	;;add	eax, 12*8*320
   182                                  	;add	eax, (13*8*320)+(2*320)
   183                                  			; wave graphics start (top) line/row
   184                                  			; 64 volume levels
   185                                  	;mov	[graphstart], eax
   186                                  	; 30/12/2024
   187 00000069 C705[E4320000]0087-     	mov	dword [graphstart], 0A0000h+(13*8*320)+(4*320)
   187 00000071 0A00               
   188                                  
   189                                  ; -------------------------------------------------------------
   190                                  
   191                                  	; 25/12/2024
   192                                  	; 28/11/2024
   193                                  Player_InitalizePSP:
   194                                  	; 30/11/2024
   195                                  	; (TRDOS 386 -Retro UNIX 386- argument transfer method)
   196                                  	; (stack: argc,argv0addr,argv1addr,argv2addr ..
   197                                  	;			.. argv0text, argv1text ..) 
   198                                  	; ---- argc, argv[] ----
   199 00000073 89E6                    	mov	esi, esp
   200 00000075 AD                      	lodsd
   201 00000076 83F802                  	cmp	eax, 2 ; two arguments 
   202                                  		; (program file name & mod file name)
   203 00000079 0F8243040000            	jb	pmsg_usage ; nothing to do
   204                                  	;mov	[argc], al
   205 0000007F C1E002                  	shl	eax, 2 ; *4
   206 00000082 01E0                    	add	eax, esp
   207                                  	; eax = last argument's address pointer
   208 00000084 A3[44380000]            	mov	[argvl], eax ; last wav file (argument)
   209 00000089 8935[3C380000]          	mov	[argv], esi ; current argument (PRG file name)
   210 0000008F AD                      	lodsd	; skip program (PRG) file name
   211 00000090 8935[40380000]          	mov	[argvf], esi ; 1st wav file (argument)
   212                                  
   213                                  	; 30/12/2024
   214                                  Player_ParseParameters:
   215 00000096 EB2A                    	jmp	short Player_ParseNextParameter
   216                                  	; 25/12/2024
   217                                  check_p_command:
   218                                  	; 07/12/2024
   219 00000098 8B35[3C380000]          	mov	esi, [argv]
   220                                  	;
   221 0000009E 803D[06380000]50          	cmp	byte [command], 'P'
   222 000000A5 7410                    	je	short Player_ParsePreviousParameter
   223                                      
   224                                  	; 07/12/2024
   225                                  	; 30/11/2024
   226                                  	;mov	esi, [argv] ; current argument (wav file) ptr
   227 000000A7 83C604                  	add	esi, 4
   228 000000AA 3B35[44380000]          	cmp	esi, [argvl] ; last argument (wav file) ptr
   229 000000B0 7610                    	jna	short Player_ParseNextParameter
   230                                  jmp_Player_Quit:
   231 000000B2 E9CE040000              	jmp	Player_Quit
   232                                  
   233                                  Player_ParsePreviousParameter:
   234                                  	; 29/11/2024
   235                                  	;mov	byte [command], 0
   236                                  	; 30/11/2024
   237                                  	;mov	esi, [argv] ; 07/12/2024	
   238 000000B7 3B35[40380000]          	cmp	esi, [argvf] ; first argument (wav file) ptr
   239 000000BD 7603                    	jna	short Player_ParseNextParameter
   240 000000BF 83EE04                  	sub	esi, 4
   241                                  Player_ParseNextParameter:
   242                                  	; 30/11/2024
   243 000000C2 8935[3C380000]          	mov	[argv], esi  ; set as current argument
   244                                  
   245                                  	; 01/12/2024
   246 000000C8 8B36                    	mov	esi, [esi]
   247                                  
   248                                  	; 30/12/2024
   249                                  	; 29/11/2024
   250 000000CA E83C000000              	call	GetFileName
   251                                  	;jcxz	jmp_Player_Quit
   252 000000CF E3E1                    	jecxz	jmp_Player_Quit ; 30/11/2024
   253                                  
   254                                  	; 30/12/2024
   255                                          ; open existing file
   256                                  	; 28/11/2024
   257 000000D1 BA[48380000]            	mov	edx, wav_file_name
   258 000000D6 E82A070000                      call	openFile ; no error? ok.
   259 000000DB 7376                            jnc	getwavparms	; 14/11/2024
   260                                  
   261                                  	; 29/11/2024
   262 000000DD 803D[07380000]00        	cmp	byte [filecount], 0
   263 000000E4 77B2                    	ja	short check_p_command
   264                                  
   265                                  	; 25/12/2024
   266                                  	; 21/12/2024
   267 000000E6 E892040000              	call	set_text_mode
   268                                  	; file not found!
   269                                  	; 30/11/2024
   270                                  	sys	_msg, noFileErrMsg, 255, 0Ch
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000000EB BB[7A2D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000000F0 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000000F5 BA0C000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000000FA B823000000          <1>  mov eax, %1
   104                              <1> 
   105 000000FF CD40                <1>  int 40h
   271 00000101 E9B3030000                      jmp     Exit
   272                                  
   273                                  _exit_:
   274 00000106 E9A9030000              	jmp	terminate
   275                                  
   276                                  ; -------------------------------------------------------------
   277                                  
   278                                  	; 26/12/2024
   279                                  	; 25/12/2024
   280                                  	; 30/11/2024 (32bit)
   281                                  	; 29/11/2024
   282                                  	; 30/05/2024
   283                                  GetFileName:
   284 0000010B BF[48380000]            	mov	edi, wav_file_name 
   285                                  	; 30/11/2024
   286                                  	;mov	esi, [argv]
   287 00000110 31C9                    	xor	ecx, ecx ; 0
   288                                  ScanName:
   289 00000112 AC                      	lodsb
   290                                  	;test	al, al
   291                                  	;jz	short a_4
   292                                  	; 29/11/2024
   293 00000113 3C0D                    	cmp	al, 0Dh
   294 00000115 7638                    	jna	short a_4
   295 00000117 3C20                    	cmp	al, 20h
   296 00000119 74F7                    	je	short ScanName	; scan start of name.
   297 0000011B AA                      	stosb
   298 0000011C B4FF                    	mov	ah, 0FFh
   299                                  	;;;
   300                                  	; 14/11/2024
   301                                  	; (max. path length = 64 bytes for MSDOS ?) (*)
   302                                  	;xor	ecx, ecx ; 0
   303                                  	;;;
   304                                  a_0:	
   305 0000011E FEC4                    	inc	ah
   306                                  a_1:
   307                                  	;;;
   308                                  	; 14/11/2024
   309 00000120 41                      	inc	ecx
   310                                  	;;;
   311 00000121 AC                      	lodsb
   312 00000122 AA                      	stosb
   313 00000123 3C2E                    	cmp	al, '.'
   314 00000125 74F7                    	je	short a_0
   315                                  	; 29/11/2024
   316 00000127 3C20                    	cmp	al, 20h
   317                                  	;and	al, al
   318                                  	;jnz	short a_1
   319                                  	;;;
   320                                  	; 14/11/2024
   321 00000129 7613                    	jna	short a_3
   322 0000012B 20E4                    	and	ah, ah
   323 0000012D 7406                    	jz	short a_2
   324 0000012F 3C2F                    	cmp	al, '/'	; 14/12/2024
   325 00000131 7502                    	jne	short a_2
   326 00000133 B400                    	mov	ah, 0
   327                                  a_2:
   328 00000135 80F94B                  	cmp	cl, 75	; 64+8+'.'+3 -> offset 75 is the last chr
   329 00000138 72E6                    	jb	short a_1
   330                                  	; 29/11/2024
   331 0000013A 29C9                    	sub	ecx, ecx
   332 0000013C EB11                    	jmp	short a_4
   333                                  a_3:
   334                                  	; 29/11/2024
   335 0000013E 4F                      	dec	edi
   336                                  	;;;
   337 0000013F 08E4                    	or	ah, ah		; if period NOT found,
   338 00000141 750C                    	jnz	short a_4 	; then add a .WAV extension.
   339                                  SetExt:
   340                                  	; 29/11/2024
   341                                  	;dec	edi
   342 00000143 C7072E574156            	mov	dword [edi], '.WAV'
   343                                  				; ! 64+12 is DOS limit
   344                                  				; but writing +4 must not
   345                                  				; destroy the following data	 
   346                                  	;mov	byte [edi+4], 0	; so, 80 bytes path + 0 is possible here
   347                                  	; 29/11/2024
   348 00000149 83C104                  	add	ecx, 4
   349 0000014C 83C704                  	add	edi, 4
   350                                  a_4:	
   351 0000014F C60700                  	mov	byte [edi], 0
   352                                  	; 30/11/2024
   353 00000152 C3                      	retn
   354                                  
   355                                  ; -------------------------------------------------------------
   356                                  
   357                                  getwavparms:
   358                                  	; 14/11/2024
   359 00000153 E8DF060000                     	call    getWAVParameters
   360 00000158 72AC                    	jc	short _exit_		; nothing to do
   361                                  
   362                                  	; 17/11/2024
   363 0000015A B304                    	mov	bl, 4
   364 0000015C 2A1D[28380000]          	sub	bl, byte [WAVE_BlockAlign]
   365                                  			; = 0 for 16 bit stereo
   366                                  			; = 2 for 8 bit stereo or 16 bit mono
   367                                  			; = 3 for 8 bit mono	
   368                                  
   369 00000162 D0EB                    	shr	bl, 1	;  0 -->  0,  2 -->  1,  3 -->  1
   370                                  	; 15/11/2024
   371 00000164 80D300                  	adc	bl, 0	; 3 --> 1 --> 2
   372 00000167 881D[9A380000]          	mov	byte [fbs_shift], bl	; = 2 mono and 8 bit
   373                                  					; = 0 stereo and 16 bit
   374                                  					; = 1 mono or 8 bit
   375                                  	; 29/12/2024
   376                                  	; 30/05/2024
   377 0000016D E826080000              	call	codecConfig		; unmute codec, set rates.
   378 00000172 0F8267030000            	jc	init_err
   379                                  
   380                                  ; -------------------------------------------------------------
   381                                  
   382                                  StartPlay:
   383                                  	; 30/12/2024
   384 00000178 C605[FB370000]01        	mov	byte [wpoints], 1
   385                                  
   386                                  	;;;
   387                                  	; 09/12/2024
   388 0000017F B834290000              	mov	eax, 10548 ; (48000*10/182)*4
   389 00000184 803D[05380000]00        	cmp	byte [VRA], 0
   390 0000018B 7614                    	jna	short _w ; 48kHZ (interpolation)
   391                                  	;
   392 0000018D 66A1[20380000]          	mov	ax, [WAVE_SampleRate]
   393 00000193 B90A000000              	mov	ecx, 10
   394 00000198 F7E1                    	mul	ecx
   395 0000019A B1B6                    	mov	cl, 182
   396 0000019C F7F1                    	div	ecx
   397                                  	; ax = samples per 1/18.2 second
   398                                  	;mov	cl, byte [WAVE_BlockAlign]
   399                                  	; 09/12/2024 
   400                                  	;mov	cl, 4 ; 16 bit, stereo
   401                                  	;mul	ecx
   402 0000019E C1E002                  	shl	eax, 2 ; * 4
   403                                  _w:
   404 000001A1 A3[E0320000]            	mov	[wpoints_dif], eax ; buffer read differential (distance)
   405                                  				; for wave volume leds update
   406                                  				; (byte stream per 1/18.2 second)
   407                                  
   408                                  ; -------------------------------------------------------------
   409                                  
   410                                  	; 25/12/2024
   411 000001A6 FE05[07380000]          	inc	byte [filecount]
   412 000001AC C605[06380000]00        	mov	byte [command], 0
   413                                  	; 30/12/2024
   414 000001B3 C605[F1320000]FF        	mov	byte [pbprev], -1
   415                                  
   416                                  ; -------------------------------------------------------------
   417                                  
   418                                  	; 07/12/2024 (playwav9.s)
   419                                  
   420                                  	; 18/11/2023 (ich_wav4.asm)
   421                                  	; 13/11/2023 (ich_wav3.asm)
   422                                  
   423 000001BA 803D[05380000]01        	cmp	byte [VRA], 1
   424 000001C1 7226                    	jb	short chk_sample_rate
   425                                  
   426                                  playwav_48_khz:
   427 000001C3 C705[A8380000]-         	mov	dword [loadfromwavfile], loadFromFile
   427 000001C9 [1E0D0000]         
   428                                  	;mov	dword [loadsize], 0 ; 65536
   429                                  	;;;
   430                                  	; 17/11/2024
   431                                  	;mov	word [buffersize], 32768
   432                                  	;mov	ax, BUFFERSIZE/2 ; 32760
   433                                  	; 30/11/2024
   434                                  	;mov	eax, BUFFERSIZE/2 ; 32768
   435                                  	; 07/12/2024
   436 000001CD B800000100              	mov	eax, BUFFERSIZE ; 65536
   437 000001D2 A3[B0380000]            	mov	[buffersize], eax	; 16 bit samples
   438                                  	; 07/12/2024
   439                                  	;shl	eax, 1			; bytes
   440 000001D7 8A0D[9A380000]          	mov	cl, [fbs_shift]
   441 000001DD D3E8                    	shr	eax, cl 
   442                                  	;mov	[loadsize], ax ; 16380 or 32760 or 65520
   443 000001DF A3[AC380000]            	mov	[loadsize], eax ; 16384 or 32768 or 65536
   444                                  	;;;
   445                                  	;jmp	PlayNow ; 30/05/2024
   446                                  	; 07/12/2024
   447 000001E4 E95D020000              	jmp	Player_Template
   448                                  
   449                                  chk_sample_rate:
   450                                  	; set conversion parameters
   451                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   452 000001E9 66A1[20380000]          	mov	ax, [WAVE_SampleRate]
   453 000001EF 663D80BB                	cmp	ax, 48000
   454 000001F3 74CE                    	je	short playwav_48_khz
   455                                  chk_22khz:
   456 000001F5 663D2256                	cmp	ax, 22050
   457 000001F9 7545                    	jne	short chk_11khz
   458 000001FB 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   459 00000202 7615                    	jna	short chk_22khz_1
   460 00000204 BB[FE1C0000]            	mov	ebx, load_22khz_stereo_16_bit
   461 00000209 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   462 00000210 751A                    	jne	short chk_22khz_2
   463 00000212 BB[6B1C0000]            	mov	ebx, load_22khz_mono_16_bit
   464 00000217 EB13                    	jmp	short chk_22khz_2
   465                                  chk_22khz_1:
   466 00000219 BB[DE1B0000]            	mov	ebx, load_22khz_stereo_8_bit
   467 0000021E 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   468 00000225 7505                    	jne	short chk_22khz_2
   469 00000227 BB[4F1B0000]            	mov	ebx, load_22khz_mono_8_bit
   470                                  chk_22khz_2:
   471 0000022C B85A1D0000              	mov	eax, 7514  ; (442*17)
   472 00000231 BA25000000              	mov	edx, 37
   473 00000236 B911000000              	mov	ecx, 17
   474 0000023B E9D9010000              	jmp	set_sizes
   475                                  chk_11khz:
   476 00000240 663D112B                	cmp	ax, 11025
   477 00000244 7545                    	jne	short chk_44khz
   478 00000246 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   479 0000024D 7615                    	jna	short chk_11khz_1
   480 0000024F BB[321F0000]            	mov	ebx, load_11khz_stereo_16_bit
   481 00000254 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   482 0000025B 751A                    	jne	short chk_11khz_2
   483 0000025D BB[B31E0000]            	mov	ebx, load_11khz_mono_16_bit
   484 00000262 EB13                    	jmp	short chk_11khz_2
   485                                  chk_11khz_1:
   486 00000264 BB[2E1E0000]            	mov	ebx, load_11khz_stereo_8_bit
   487 00000269 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1 
   488 00000270 7505                    	jne	short chk_11khz_2
   489 00000272 BB[B51D0000]            	mov	ebx, load_11khz_mono_8_bit
   490                                  chk_11khz_2:
   491 00000277 B8AD0E0000              	mov	eax, 3757  ; (221*17)
   492 0000027C BA4A000000              	mov	edx, 74
   493 00000281 B911000000              	mov	ecx, 17
   494 00000286 E98E010000              	jmp	set_sizes
   495                                  chk_44khz:
   496 0000028B 663D44AC                	cmp	ax, 44100
   497 0000028F 7545                    	jne	short chk_16khz
   498 00000291 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   499 00000298 7615                    	jna	short chk_44khz_1
   500 0000029A BB[71210000]            	mov	ebx, load_44khz_stereo_16_bit
   501 0000029F 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   502 000002A6 751A                    	jne	short chk_44khz_2
   503 000002A8 BB[F2200000]            	mov	ebx, load_44khz_mono_16_bit
   504 000002AD EB13                    	jmp	short chk_44khz_2
   505                                  chk_44khz_1:
   506 000002AF BB[6F200000]            	mov	ebx, load_44khz_stereo_8_bit
   507 000002B4 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   508 000002BB 7505                    	jne	short chk_44khz_2
   509 000002BD BB[ED1F0000]            	mov	ebx, load_44khz_mono_8_bit
   510                                  chk_44khz_2:
   511                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   512 000002C2 B8D93A0000              	mov	eax, 15065 ; (655*23)
   513                                  	; 18/11/2023 ((file size + bss + stack) <= 64KB)
   514                                  	;mov	ax, 14076 ; (612*23)
   515                                  	; 17/11/2024
   516                                  	;mov	ax, 12650 ; (550*23)
   517 000002C7 BA19000000              	mov	edx, 25
   518 000002CC B917000000              	mov	ecx, 23
   519 000002D1 E943010000              	jmp	set_sizes
   520                                  chk_16khz:
   521 000002D6 663D803E                	cmp	ax, 16000
   522 000002DA 7545                    	jne	short chk_8khz
   523 000002DC 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   524 000002E3 7615                    	jna	short chk_16khz_1
   525 000002E5 BB[5E160000]            	mov	ebx, load_16khz_stereo_16_bit
   526 000002EA 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1 
   527 000002F1 751A                    	jne	short chk_16khz_2
   528 000002F3 BB[D7150000]            	mov	ebx, load_16khz_mono_16_bit
   529 000002F8 EB13                    	jmp	short chk_16khz_2
   530                                  chk_16khz_1:
   531 000002FA BB[17150000]            	mov	ebx, load_16khz_stereo_8_bit
   532 000002FF 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   533 00000306 7505                    	jne	short chk_16khz_2
   534 00000308 BB[92140000]            	mov	ebx, load_16khz_mono_8_bit
   535                                  chk_16khz_2:
   536                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   537 0000030D B855150000              	mov	eax, 5461
   538                                  	; 17/11/2024
   539                                  	;mov	ax, 5460
   540 00000312 BA03000000              	mov	edx, 3
   541 00000317 B901000000              	mov	ecx, 1
   542 0000031C E9F8000000              	jmp	set_sizes
   543                                  chk_8khz:
   544 00000321 663D401F                	cmp	ax, 8000
   545 00000325 7545                    	jne	short chk_24khz
   546 00000327 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   547 0000032E 7615                    	jna	short chk_8khz_1
   548 00000330 BB[41130000]            	mov	ebx, load_8khz_stereo_16_bit
   549 00000335 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   550 0000033C 751A                    	jne	short chk_8khz_2
   551 0000033E BB[6B120000]            	mov	ebx, load_8khz_mono_16_bit
   552 00000343 EB13                    	jmp	short chk_8khz_2
   553                                  chk_8khz_1:
   554 00000345 BB[35110000]            	mov	ebx, load_8khz_stereo_8_bit
   555 0000034A 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1 
   556 00000351 7505                    	jne	short chk_8khz_2
   557 00000353 BB[47100000]            	mov	ebx, load_8khz_mono_8_bit
   558                                  chk_8khz_2:
   559 00000358 B8AA0A0000              	mov	eax, 2730
   560 0000035D BA06000000              	mov	edx, 6
   561 00000362 B901000000              	mov	ecx, 1
   562 00000367 E9AD000000              	jmp	set_sizes
   563                                  chk_24khz:
   564 0000036C 663DC05D                	cmp	ax, 24000
   565 00000370 7561                    	jne	short chk_32khz
   566 00000372 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   567 00000379 7613                    	jna	short chk_24khz_1
   568 0000037B 66BB[A018]              	mov	bx, load_24khz_stereo_16_bit
   569 0000037F 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1 
   570 00000386 7519                    	jne	short chk_24khz_2
   571 00000388 66BB[3718]              	mov	bx, load_24khz_mono_16_bit
   572 0000038C EB13                    	jmp	short chk_24khz_2
   573                                  chk_24khz_1:
   574 0000038E BB[A7170000]            	mov	ebx, load_24khz_stereo_8_bit
   575 00000393 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1 
   576 0000039A 7505                    	jne	short chk_24khz_2
   577 0000039C BB[3A170000]            	mov	ebx, load_24khz_mono_8_bit
   578                                  chk_24khz_2:
   579                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   580 000003A1 B800200000              	mov	eax, 8192
   581                                  	; 17/11/2024
   582                                  	;mov	ax, 8190
   583 000003A6 BA02000000              	mov	edx, 2
   584 000003AB B901000000              	mov	ecx, 1
   585 000003B0 EB67                    	jmp	short set_sizes
   586                                  
   587                                  	; 07/12/2024
   588                                  vra_needed:
   589                                  	; 30/11/2024 (TRDOS 386, ax -> eax)
   590                                  	; 13/11/2023
   591 000003B2 58                      	pop	eax ; discard return address to the caller
   592                                  	; 30/05/2024
   593                                  vra_err:
   594                                  	; 21/12/2024
   595 000003B3 E8C5010000              	call	set_text_mode
   596                                  	; 30/11/2024
   597                                  	sys	_msg, msg_no_vra, 255, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000003B8 BB[E42D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000003BD B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000003C2 BA0F000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000003C7 B823000000          <1>  mov eax, %1
   104                              <1> 
   105 000003CC CD40                <1>  int 40h
   598 000003CE E9E6000000              	jmp	Exit
   599                                  
   600                                  chk_32khz:
   601 000003D3 663D007D                	cmp	ax, 32000
   602 000003D7 75D9                    	jne	short vra_needed
   603 000003D9 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   604 000003E0 7615                    	jna	short chk_32khz_1
   605 000003E2 BB[B91A0000]            	mov	ebx, load_32khz_stereo_16_bit
   606 000003E7 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   607 000003EE 751A                    	jne	short chk_32khz_2
   608 000003F0 BB[491A0000]            	mov	ebx, load_32khz_mono_16_bit
   609 000003F5 EB13                    	jmp	short chk_32khz_2
   610                                  chk_32khz_1:
   611 000003F7 BB[A6190000]            	mov	ebx, load_32khz_stereo_8_bit
   612 000003FC 803D[1E380000]01        	cmp	byte [WAVE_NumChannels], 1
   613 00000403 7505                    	jne	short chk_32khz_2
   614 00000405 BB[2D190000]            	mov	ebx, load_32khz_mono_8_bit
   615                                  chk_32khz_2:
   616                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   617 0000040A B8AA2A0000              	mov	eax, 10922
   618                                  	; 17/11/2024
   619                                  	;mov	ax, 10920
   620 0000040F BA03000000              	mov	edx, 3
   621 00000414 B902000000              	mov	ecx, 2
   622                                  	;jmp	short set_sizes
   623                                  set_sizes:
   624                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   625                                  	;;;
   626                                  	; 17/11/2024
   627 00000419 51                      	push	ecx
   628 0000041A B102                    	mov	cl, 2
   629 0000041C 2A0D[9A380000]          	sub	cl, [fbs_shift]
   630                                  		; = 2 for 16 bit stereo
   631                                  		; = 1 for 16 bit mono or 8 bit stereo
   632                                  		; = 0 for 8 bit mono
   633 00000422 D3E0                    	shl	eax, cl
   634 00000424 59                      	pop	ecx	
   635 00000425 A3[AC380000]            	mov	[loadsize], eax	; (one) read count in bytes
   636                                  	;;;
   637 0000042A F7E2                    	mul	edx
   638 0000042C 83F901                  	cmp	ecx, 1
   639 0000042F 7402                    	je	short s_2
   640                                  s_1:
   641 00000431 F7F1                    	div	ecx
   642                                  s_2:
   643                                  	;;;
   644                                  	; eax = byte count of (to be) converted samples 
   645                                  	
   646                                  	; 17/11/2024
   647                                  	;;;
   648 00000433 8A0D[9A380000]          	mov	cl, [fbs_shift]
   649                                  
   650 00000439 D3E0                    	shl	eax, cl
   651                                  		; *1 for 16 bit stereo
   652                                  		; *2 for 16 bit mono or 8 bit stereo
   653                                  		; *4 for for 8 bit mono
   654                                  	;;;
   655                                  
   656                                  	; eax = 16 bit stereo byte count (target buffer size)
   657                                  	
   658                                  	; 07/12/2024
   659                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   660 0000043B A3[B0380000]            	mov	[buffersize], eax ; buffer size in bytes
   661 00000440 891D[A8380000]          	mov	[loadfromwavfile], ebx
   662                                  
   663                                  ; -------------------------------------------------------------
   664                                  
   665                                  	; 30/12/2024
   666                                  Player_Template:
   667                                  	; 21/12/2024
   668 00000446 E8DF000000              	call	clearscreen
   669 0000044B E8E9000000              	call	drawplayingscreen
   670                                  
   671                                  	; 14/11/2024
   672 00000450 E82C250000              	call	SetTotalTime
   673 00000455 E8F9250000              	call	UpdateFileInfo
   674                                  
   675                                  ; -------------------------------------------------------------
   676                                  
   677                                  	; 30/12/2024 (cgaplay.s)
   678                                  	; 29/12/2024 (vgaplay3.s)
   679                                  	; 18/12/2024 (ac97play.s)
   680                                  PlayNow:
   681                                  	; 01/12/2024 (32bit)
   682                                  	; 14/11/2024
   683                                  	;mov	al, 3	; 0 = max, 31 = min
   684                                  	; 14/12/2024
   685 0000045A A0[64290000]            	mov	al, [volume]
   686 0000045F E83D030000              	call	SetPCMOutVolume@
   687                                  	; 15/11/2024
   688                                  	;;call	SetMasterVolume
   689                                  	;call	SetPCMOutVolume
   690                                  
   691                                  	;;;
   692                                  	; 14/11/2024
   693 00000464 E8F0260000              	call	UpdateProgressBar
   694                                  	;;;
   695                                  
   696                                   	; 30/05/2024
   697                                  	; playwav4.asm
   698                                  _2:	
   699 00000469 E893240000              	call	check4keyboardstop	; flush keyboard buffer
   700 0000046E 72F9                    	jc	short _2		; 07/11/2023
   701                                  
   702                                  ; play the .wav file. Most of the good stuff is in here.
   703                                  
   704                                  	; 05/12/2024
   705                                  	; 02/12/2024
   706                                  	;mov	eax, [_bdl_buffer]	; BDL_BUFFER physical address
   707                                  ;_3:
   708 00000470 E815010000              	call    PlayWav
   709                                  
   710                                  	; 30/12/2024
   711                                  	; 29/12/2024 (vgaplay3.s)
   712                                  	; 27/12/2024 (vgaplay.s)
   713                                  _3:
   714                                  
   715                                  ; close the .wav file and exit.
   716                                  
   717                                  	; 25/12/2024
   718 00000475 E8A6030000              	call	closeFile
   719                                  
   720                                  	; 25/12/2024
   721                                  	;;;
   722                                  	; reset file loading and EOF parameters
   723                                  	; 18/12/2024
   724 0000047A C705[BC380000]0000-     	mov	dword [count], 0
   724 00000482 0000               
   725 00000484 C705[C0380000]0000-     	mov	dword [LoadedDataBytes], 0
   725 0000048C 0000               
   726 0000048E C605[36380000]00        	mov	byte [flags], 0
   727 00000495 C605[F8370000]00        	mov	byte [stopped], 0
   728                                  	; 29/12/2024
   729 0000049C C705[00380000]0000-     	mov	dword [pbuf_s], 0
   729 000004A4 0000               
   730                                  	;;;
   731                                  
   732 000004A6 803D[06380000]51        	cmp	byte [command], 'Q'
   733 000004AD 7405                    	je	short terminate
   734 000004AF E9E4FBFFFF              	jmp	check_p_command
   735                                  
   736                                  terminate:
   737 000004B4 E8C4000000              	call	set_text_mode
   738                                  Exit:
   739                                  	sys	_exit
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95                              <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97                              <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000004B9 B801000000          <1>  mov eax, %1
   104                              <1> 
   105 000004BE CD40                <1>  int 40h
   740                                  halt:
   741 000004C0 EBFE                    	jmp	short halt
   742                                  
   743                                  ; -------------------------------------------------------------
   744                                  
   745                                  	; 30/05/2024
   746                                  pmsg_usage:
   747                                  	; 21/12/2024
   748 000004C2 E8B6000000              	call	set_text_mode
   749                                  	; 01/12/2024
   750                                  	sys	_msg, msg_usage, 255, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000004C7 BB[202D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000004CC B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000004D1 BA0F000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000004D6 B823000000          <1>  mov eax, %1
   104                              <1> 
   105 000004DB CD40                <1>  int 40h
   751 000004DD EBDA                    	jmp	short Exit
   752                                  
   753                                  ; -------------------------------------------------------------
   754                                  
   755                                  	; 30/05/2024
   756                                  init_err:
   757                                  	; 21/12/2024
   758 000004DF E899000000              	call	set_text_mode
   759                                  	; 01/12/2024
   760                                  	sys	_msg, msg_init_err, 255, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000004E4 BB[B32D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000004E9 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000004EE BA0F000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000004F3 B823000000          <1>  mov eax, %1
   104                              <1> 
   105 000004F8 CD40                <1>  int 40h
   761 000004FA EBBD                    	jmp	short Exit
   762                                  
   763                                  ; -------------------------------------------------------------
   764                                  
   765                                  	; 07/12/2024
   766                                  error_exit:
   767                                  	; 21/12/2024
   768 000004FC E87C000000              	call	set_text_mode
   769                                  trdos386_error:
   770                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000501 BB[932D0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000506 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000050B BA0E000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000510 B823000000          <1>  mov eax, %1
   104                              <1> 
   105 00000515 CD40                <1>  int 40h
   771 00000517 EBA0                    	jmp	short Exit
   772                                  
   773                                  ; -------------------------------------------------------------
   774                                  
   775                                  	; 21/12/2024
   776                                  print_msg:
   777 00000519 B40E                    	mov	ah, 0Eh
   778 0000051B BB07000000              	mov	ebx, 7
   779                                  	;mov	bl, 7 ; char attribute & color
   780                                  p_next_chr:
   781 00000520 AC                      	lodsb
   782 00000521 08C0                    	or	al, al
   783 00000523 7404                    	jz	short p_retn ; retn
   784 00000525 CD31                    	int	31h
   785 00000527 EBF7                    	jmp	short p_next_chr
   786                                  p_retn:
   787 00000529 C3                      	retn
   788                                  
   789                                  ; -------------------------------------------------------------
   790                                  
   791                                  	; 30/12/2024
   792                                  clearscreen:
   793                                  	; fast clear
   794                                  	; 320*200, 256 colors
   795 0000052A BF00000A00              	mov	edi, 0A0000h
   796 0000052F B9803E0000              	mov	ecx, (320*200*1)/4
   797 00000534 31C0                    	xor	eax, eax
   798 00000536 F3AB                    	rep	stosd
   799 00000538 C3                      	retn
   800                                  
   801                                  ; -------------------------------------------------------------
   802                                  
   803                                  	; 30/12/2024 (VGA Mode 13h, 320*200 pixels, 256 colors)
   804                                  	; 26/12/2024
   805                                  	; 21/12/2024
   806                                  drawplayingscreen:
   807 00000539 BD[0C2F0000]            	mov	ebp, PlayingScreen
   808                                  	;mov	esi, 0 ; row 0, column 0
   809 0000053E BE00000200              	mov	esi, 00020000h ; row 2, column 0 ; top margin = 2
   810                                  p_d_x:
   811 00000543 C605[F0320000]28        	mov	byte [columns], 40
   812 0000054A B601                    	mov	dh, 01h ; 8x8 system font
   813                                  p_d_x_n:
   814 0000054C 8A5500                  	mov	dl, [ebp]
   815 0000054F 20D2                    	and	dl, dl
   816 00000551 7429                    	jz	short p_d_x_ok
   817                                  
   818                                  	; sysvideo system call
   819                                  	; BH = 01h = VGA graphics (0A0000h) data transfers
   820                                  	; BL = 0Fh = write character/font
   821                                  	; DH = 01h = 8*8 system font 
   822                                  	; CL = 0Fh = color (white)
   823                                  	; ESI = cursor/writing position (pixels)
   824                                  	;	HW = row, SI = column
   825                                  
   826                                  	sys	_video, 010Fh, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000553 BB0F010000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000558 B90F000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000055D B81F000000          <1>  mov eax, %1
   104                              <1> 
   105 00000562 CD40                <1>  int 40h
   827                                  
   828 00000564 45                      	inc	ebp
   829 00000565 6683C608                	add	si, 8 ; next char pos
   830 00000569 FE0D[F0320000]          	dec	byte [columns]
   831 0000056F 75DB                    	jnz	short p_d_x_n	; next column
   832 00000571 6631F6                  	xor	si, si
   833 00000574 81C600000800            	add	esi, 00080000h	; next row ; 8*8
   834 0000057A EBC7                    	jmp	short p_d_x
   835                                  p_d_x_ok:
   836 0000057C C3                      	retn
   837                                  
   838                                  ; -------------------------------------------------------------
   839                                  
   840                                  	; 21/12/2024
   841                                  set_text_mode:
   842 0000057D 30E4                    	xor    ah, ah
   843 0000057F B003                    	mov    al, 3                        
   844                                   	;int   10h ; al = 03h text mode, int 10 video
   845 00000581 CD31                    	int    31h ; TRDOS 386 - Video interrupt
   846 00000583 C3                      	retn
   847                                  
   848                                  ; -------------------------------------------------------------
   849                                  
   850                                  	; 02/12/2024
   851                                  Player_Quit@:
   852 00000584 58                      	pop	eax ; return addr (call PlayWav@)
   853                                  	
   854                                  	; 29/11/2024
   855                                  Player_Quit:
   856 00000585 E92AFFFFFF              	jmp	 terminate
   857                                  
   858                                  ; -------------------------------------------------------------
   859                                  
   860                                  	; 30/12/2024 (cgaplay.s)
   861                                  	; 29/12/2024 (vgaplay3.s)
   862                                  	; 02/12/2024 (ac97play.s)
   863                                  PlayWav:
   864                                  	; 30/12/2024
   865 0000058A A1[C8380000]            	mov	eax, [_bdl_buffer] ; BDL_BUFFER physical address
   866 0000058F 09C0                    	or	eax, eax
   867 00000591 751D                    	jnz	short PlayWav@
   868                                  
   869                                  	; 29/05/2024
   870                                  	; Allocate memory block (33 pages)
   871                                  	sys	_alloc, BDL_BUFFER, 33*4096, 0	; no upper limit
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000593 BB[00400000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000598 B900100200          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000059D BA00000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000005A2 B82A000000          <1>  mov eax, %1
   104                              <1> 
   105 000005A7 CD40                <1>  int 40h
   872                                  	;jc	short Player_Quit ; 01/12/2024
   873 000005A9 72D9                    	jc	short Player_Quit@ ; 02/12/2024
   874                                  
   875 000005AB A3[C8380000]            	mov	[_bdl_buffer], eax ; BDL_BUFFER physical address
   876                                  
   877                                  PlayWav@:
   878                                  	; create Buffer Descriptor List
   879                                  
   880                                  	;  Generic Form of Buffer Descriptor
   881                                  	;  ---------------------------------
   882                                  	;  63   62    61-48    47-32   31-0
   883                                  	;  ---  ---  --------  ------- -----
   884                                  	;  IOC  BUP -reserved- Buffer  Buffer
   885                                  	;		      Length   Pointer
   886                                  	;		      [15:0]   [31:0]
   887                                  
   888                                  	; 30/12/2024	
   889                                  
   890 000005B0 0500100000              	add	eax, 4096	; WAVBUFFER_1 physical address
   891 000005B5 89C3                    	mov	ebx, eax
   892                                  	;mov	[wav_buffer1], eax
   893                                  	;add	eax, 65536	; WAVBUFFER_2 physical address
   894                                  	;mov	[wav_buffer2], eax
   895                                  
   896 000005B7 BF[00400000]            	mov	edi, BDL_BUFFER
   897 000005BC B910000000              	mov	ecx, 16
   898                                  _pw0:
   899                                  	;mov	eax, WAVBUFFER_1
   900 000005C1 89D8                    	mov	eax, ebx	; WAVBUFFER_1 physical address
   901 000005C3 AB                      	stosd
   902                                  
   903 000005C4 A1[B0380000]            	mov	eax, [buffersize]
   904                                  	; 02/12/2024
   905 000005C9 D1E8                    	shr	eax, 1 ; buffer size in word
   906 000005CB 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
   907 000005D0 AB                      	stosd
   908                                  
   909                                  	;mov	eax, WAVBUFFER_2
   910 000005D1 89D8                    	mov	eax, ebx
   911 000005D3 0500000100              	add	eax, 65536	; WAVBUFFER_2 physical address
   912 000005D8 AB                      	stosd
   913                                  
   914 000005D9 A1[B0380000]            	mov	eax, [buffersize]
   915                                  	; 02/12/2024
   916 000005DE D1E8                    	shr	eax, 1 ; buffer size in word
   917 000005E0 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
   918 000005E5 AB                      	stosd
   919                                  
   920 000005E6 E2D9                    	loop	_pw0
   921                                  
   922                                  	; 14/11/2024
   923                                  	;mov	dword [count], ecx ; 0
   924                                  	;mov	dword [LoadedDataBytes], 0
   925                                  
   926                                  RePlayWav:
   927                                  	; 01/12/2024
   928                                  	; load 64k into buffer 1
   929 000005E8 BF[00500000]            	mov	edi, WAVBUFFER_1
   930 000005ED FF15[A8380000]          	call	dword [loadfromwavfile]
   931                                  	; 01/12/2024
   932                                  	; 14/11/2024
   933 000005F3 A1[BC380000]            	mov	eax, [count]
   934 000005F8 0105[C0380000]          	add	[LoadedDataBytes], eax
   935                                  
   936                                  	; 18/12/2024
   937 000005FE C705[BC380000]0000-     	mov	dword [count], 0
   937 00000606 0000               
   938                                  
   939                                  	; and 64k into buffer 2
   940 00000608 BF[00500100]            	mov	edi, WAVBUFFER_2
   941 0000060D FF15[A8380000]          	call	dword [loadfromwavfile]
   942                                  	; 01/12/2024
   943                                  	; 14/11/2024
   944 00000613 A1[BC380000]            	mov	eax, [count]
   945 00000618 0105[C0380000]          	add	[LoadedDataBytes], eax
   946                                  	
   947                                  	; write NABMBAR+10h with offset of buffer descriptor list
   948                                  
   949                                         	;;mov	eax, BDL_BUFFER
   950                                          ;mov	eax, esi	; BDL_BUFFER physical address
   951                                  
   952                                  	;mov	eax, [_bdl_buffer] ; BDL_BUFFER physical address
   953                                  	; 02/12/2024
   954 0000061E 8B1D[C8380000]          	mov	ebx, [_bdl_buffer]
   955                                  
   956 00000624 668B15[A6380000]        	mov	dx, [NABMBAR]
   957 0000062B 6683C210                        add     dx, PO_BDBAR_REG	; set pointer to BDL
   958                                  	;out	dx, eax 		; write to AC97 controller
   959                                  	; 29/05/2024
   960                                  	;mov	ebx, eax ; data, dword
   961                                  	; 02/12/2024
   962                                  	; ebx = [_bdl_buffer] ; data, dword
   963 0000062F B405                    	mov	ah, 5	; write port dword
   964 00000631 CD34                    	int	34h
   965                                  
   966                                  	; 31/05/2024
   967                                  	; 19/05/2024
   968                                  	;call	delay1_4ms
   969                                  
   970 00000633 B01F                            mov	al, 31
   971 00000635 E8D4060000              	call	setLastValidIndex
   972                                  
   973                                  	; 31/05/2024
   974                                  	; 19/05/2024
   975                                  	;call	delay1_4ms
   976                                  
   977                                  	; 17/02/2017
   978 0000063A 668B15[A6380000]                mov	dx, [NABMBAR]
   979 00000641 6683C21B                        add	dx, PO_CR_REG		; PCM out Control Register
   980                                          ;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
   981                                  	;			; (LVBI interrupt will not be enabled)
   982                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
   983 00000645 B001                    	mov	al, RPBM
   984                                  	;out	dx, al			; Start bus master operation.
   985                                  	; 29/05/2024
   986                                  	; al = data, byte
   987 00000647 B401                    	mov	ah, 1 ; write port, byte
   988 00000649 CD34                    	int	34h
   989                                  
   990                                  	; 30/12/2024
   991                                  
   992                                  ; -------------------------------------------
   993                                  
   994                                  	; 30/12/2024 (cgaplay.s)
   995                                  	; 29/12/2024 (vgaplay3.s)
   996                                  	; 18/12/2024 (ac97play.s)
   997                                  	; 01/12/2024 (32bit)
   998                                  	; 29/11/2024
   999                                  tuneLoop:
  1000                                  	; 30/05/2024
  1001                                  	; 18/11/2023 (ich_wav4.asm)
  1002                                  	; 08/11/2023
  1003                                  	; 06/11/2023
  1004                                  tLWait:
  1005                                  	; 18/11/2024
  1006 0000064B 803D[F8370000]00        	cmp	byte [stopped], 0
  1007                                  	;jna	short tL@
  1008                                  	; 21/11/2024
  1009 00000652 7718                    	ja	short tLWait@
  1010 00000654 A0[FA370000]            	mov	al, [tLP]
  1011 00000659 3C31                    	cmp	al, '1'
  1012 0000065B 7458                    	je	short tL1@
  1013 0000065D 0F87A3000000            	ja	tL2@
  1014 00000663 B031                    	mov	al, '1'
  1015 00000665 A2[FA370000]            	mov	[tLP], al
  1016 0000066A EB49                    	jmp	short tL1@ 
  1017                                  tLWait@:	; 21/11/2024
  1018                                  	;;;
  1019                                  	; 09/12/2024
  1020 0000066C 803D[F8370000]03        	cmp	byte [stopped], 3
  1021 00000673 0F83DF000000            	jnb	_exitt_
  1022                                  	;;;
  1023 00000679 E8C7200000              	call	checkUpdateEvents
  1024 0000067E 0F82D4000000            	jc	_exitt_
  1025                                  	;;;
  1026                                  	; 29/11/2024
  1027 00000684 803D[06380000]4E        	cmp	byte [command], 'N'
  1028 0000068B 0F84C7000000            	je	_exitt_
  1029 00000691 803D[06380000]50        	cmp	byte [command], 'P'
  1030 00000698 0F84BA000000            	je	_exitt_
  1031                                  	;;;
  1032 0000069E 803D[F9370000]30        	cmp	byte [tLO], '0'
  1033 000006A5 74A4                    	je	short tLWait
  1034 000006A7 E8B6000000              	call	tLZ
  1035 000006AC C605[F9370000]30        	mov	byte [tLO], '0'
  1036 000006B3 EB96                    	jmp	short tLWait
  1037                                  
  1038                                  ;tLO:	db 0
  1039                                  	
  1040                                  tL1@:
  1041                                  	;mov	al, '1'
  1042                                  	; 19/11/2024
  1043 000006B5 A2[F9370000]            	mov	[tLO], al
  1044 000006BA E8A5000000              	call	tL0
  1045                                  tL1:
  1046 000006BF E80D060000              	call	updateLVI	; /set LVI != CIV/
  1047 000006C4 0F848E000000            	jz	_exitt_		; 08/11/2023
  1048                                  	;;;
  1049                                  	;call	check4keyboardstop
  1050                                  	; 14/11/2024
  1051 000006CA E876200000              	call	checkUpdateEvents
  1052 000006CF 0F8283000000            	jc	_exitt_
  1053                                  	; 18/11/2024
  1054 000006D5 803D[F8370000]00        	cmp	byte [stopped], 0
  1055 000006DC 778E                    	ja	short tLWait@	; 21/11/2024
  1056                                  	;;;
  1057 000006DE E8DE050000              	call	getCurrentIndex
  1058 000006E3 A801                    	test	al, BIT0
  1059 000006E5 74D8                    	jz	short tL1	; loop if buffer 2 is not playing
  1060                                  
  1061                                  	; load buffer 1
  1062                                  	;mov	ax, [WAV_BUFFER1]
  1063                                  	; 01/12/2024
  1064 000006E7 BF[00500000]            	mov	edi, WAVBUFFER_1	
  1065                                  
  1066                                  	;call	loadFromFile
  1067                                  	; 18/11/2023
  1068                                  	;call	word [loadfromwavfile]
  1069                                  	; 01/12/2024
  1070 000006EC FF15[A8380000]          	call	dword [loadfromwavfile]
  1071 000006F2 7264                    	jc	short _exitt_	; end of file
  1072                                  
  1073                                  	; 14/11/2024
  1074                                  	;mov	ax, [count]
  1075                                  	;add	[LoadedDataBytes], ax
  1076                                  	;adc	word [LoadedDataBytes+2], 0
  1077                                  	; 01/12/2024
  1078 000006F4 A1[BC380000]            	mov	eax, [count]
  1079 000006F9 0105[C0380000]          	add	[LoadedDataBytes], eax
  1080                                  
  1081 000006FF B032                    	mov	al, '2'
  1082                                  	; 21/11/2024
  1083 00000701 A2[FA370000]            	mov	[tLP], al
  1084                                  tL2@:
  1085                                  	; 19/11/2024
  1086 00000706 A2[F9370000]            	mov	[tLO], al
  1087 0000070B E854000000              	call	tL0
  1088                                  tL2:
  1089 00000710 E8BC050000              	call    updateLVI
  1090 00000715 7441                    	jz	short _exitt_	; 08/11/2023
  1091                                  	;;;
  1092                                  	;call	check4keyboardstop
  1093                                  	; 14/11/2024
  1094 00000717 E829200000              	call	checkUpdateEvents
  1095 0000071C 723A                    	jc	short _exitt_
  1096                                  	; 18/11/2024
  1097 0000071E 803D[F8370000]00        	cmp	byte [stopped], 0
  1098 00000725 0F8741FFFFFF            	ja	tLWait@		; 21/11/2024 
  1099                                  	;;;
  1100 0000072B E891050000              	call    getCurrentIndex
  1101 00000730 A801                    	test	al, BIT0
  1102 00000732 75DC                    	jnz	short tL2	; loop if buffer 1 is not playing
  1103                                  
  1104                                  	; load buffer 2
  1105                                  	;mov	ax, [WAV_BUFFER2]
  1106                                  	; 01/12/2024
  1107 00000734 BF[00500100]            	mov	edi, WAVBUFFER_2
  1108                                  	;call	loadFromFile
  1109                                  	; 18/11/2023
  1110                                  	;call	word [loadfromwavfile]
  1111                                  	; 01/12/2024
  1112 00000739 FF15[A8380000]          	call	dword [loadfromwavfile]
  1113                                  	;jnc	short tuneLoop
  1114 0000073F 7217                    	jc	short _exitt_
  1115                                  
  1116                                  	; 14/11/2024
  1117                                  	;mov	ax, [count]
  1118                                  	;add	[LoadedDataBytes], ax
  1119                                  	;adc	word [LoadedDataBytes+2], 0
  1120                                  	; 01/12/2024
  1121 00000741 A1[BC380000]            	mov	eax, [count]
  1122 00000746 0105[C0380000]          	add	[LoadedDataBytes], eax	
  1123                                  
  1124                                  	; 21/11/2024
  1125 0000074C C605[FA370000]31        	mov	byte [tLP], '1'
  1126 00000753 E9F3FEFFFF              	jmp	tuneLoop
  1127                                  
  1128                                  	; 29/12/2024 (vgaplay3.s)
  1129                                  _exitt_:
  1130                                  	; 07/12/2024
  1131                                  	; Stop Playing
  1132                                  	;mov	byte [stopped], 2
  1133                                  	;sys	_audio, 0700h
  1134 00000758 E8F6040000              	call	ac97_stop
  1135                                  
  1136                                  	;;;
  1137                                  	; 14/11/2024
  1138 0000075D E8F7230000              	call	UpdateProgressBar
  1139                                  	;;;
  1140                                  
  1141                                  	; 18/11/2024
  1142                                  tLZ:
  1143                                  	; 30/05/2024
  1144 00000762 B030                    	mov	al, '0'
  1145                                  
  1146                                  	;add	al, '0'
  1147                                  	;call	tL0
  1148                                  	;
  1149                                  	;retn
  1150                                  	; 06/11/2023
  1151                                  	;jmp	short tL0
  1152                                  	;retn
  1153                                  
  1154                                  tL0:
  1155                                  	; 30/12/2024 (cgaplay.s)
  1156                                  	; 29/05/2024 (TRDOS 386)
  1157                                  	; 08/11/2023
  1158                                  	; 05/11/2023
  1159                                  	; 17/02/2017 - Buffer switch test (temporary)
  1160                                  	; 06/11/2023
  1161                                  	; al = buffer indicator ('1', '2' or '0' -stop- )
  1162                                  
  1163                                  	; 30/12/2024 (video mode 13h modification)
  1164                                  	; (320*200, 256 colors)
  1165                                  	;;;
  1166 00000764 88C2                    	mov	dl, al ; character
  1167 00000766 BF00000A00              	mov	edi, 0A0000h
  1168                                  
  1169 0000076B BB08000000              	mov	ebx, 8 ; 8 pixels (8*8 pixels font)
  1170                                  
  1171 00000770 B00C                    	mov	al, 0Ch ; red
  1172                                  tL0_1:
  1173                                  	;mov	ecx, 8 ; 8 pixels (8*8 pixels font)
  1174 00000772 B907000000              	mov	ecx, 7
  1175                                  tL0_2:
  1176 00000777 AA                      	stosb
  1177 00000778 49                      	dec	ecx
  1178 00000779 75FC                    	jnz	short tL0_2
  1179 0000077B 4B                      	dec	ebx
  1180 0000077C 7408                    	jz	short tL0_3
  1181                                  	;add	edi, 320-8 ; next line
  1182 0000077E 81C739010000            	add	edi, 320-7
  1183 00000784 EBEC                    	jmp	short tL0_1
  1184                                  tL0_3:
  1185                                  	; write system font
  1186 00000786 B601                    	mov	dh, 01h
  1187                                  	;mov	dl, al ; character
  1188 00000788 31F6                    	xor	esi, esi ; = row 0, column 0
  1189                                  	sys	_video, 010Fh, 0Eh ; yellow
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000078A BB0F010000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000078F B90E000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000794 B81F000000          <1>  mov eax, %1
   104                              <1> 
   105 00000799 CD40                <1>  int 40h
  1190                                  	;;;
  1191                                  
  1192 0000079B C3                      	retn
  1193                                  
  1194                                  ; -------------------------------------------
  1195                                  
  1196                                  	; 29/12/2024 (vgaplay3.s)
  1197                                  	; 18/12/2024 (ac97play.s)
  1198                                  	; 14/11/2024
  1199                                  ;SetMasterVolume:
  1200                                  	; 15/11/2024
  1201                                  SetPCMOutVolume:
  1202                                  	;cmp	al, 31
  1203                                  	;ja	short setvolume_ok
  1204 0000079C A2[64290000]            	mov	[volume], al  ; max = 0, min = 31
  1205                                  SetPCMOutVolume@:	; 19/11/2024
  1206 000007A1 88C4                    	mov	ah, al
  1207 000007A3 668B15[A4380000]        	mov	dx, [NAMBAR]
  1208                                  	; 15/11/2024 (QEMU)
  1209                                    	;add	dx, CODEC_MASTER_VOL_REG
  1210 000007AA 6683C218                	add	dx, CODEC_PCM_OUT_REG
  1211                                  	;out	dx, ax
  1212                                  	; 01/12/2024
  1213                                  	; bx = data, word
  1214                                  	; 03/12/2024
  1215 000007AE 89C3                    	mov	ebx, eax
  1216 000007B0 B403                    	mov	ah, 3  ; write port, word
  1217 000007B2 CD34                    	int	34h
  1218                                  ;setvolume_ok:
  1219 000007B4 C3                      	retn
  1220                                  
  1221                                  ; -------------------------------------------
  1222                                  
  1223                                  	; 29/12/2024 (vgaplay3.s)
  1224                                  	; 18/12/2024 (ac97play.s)
  1225                                  	; 30/05/2024
  1226                                  DetectAC97:
  1227                                  DetectICH:
  1228                                  	; 22/11/2023
  1229                                  	; 19/11/2023
  1230                                  	; 01/11/2023 - TRDOS 386 Kernel v2.0.7
  1231                                  	;; 10/06/2017
  1232                                  	;; 05/06/2017
  1233                                  	;; 29/05/2017
  1234                                  	;; 28/05/2017
  1235                                  
  1236                                  	; 01/12/2024
  1237                                  	; 19/11/2023
  1238 000007B5 BE[542C0000]            	mov	esi, valid_ids	; address of Valid ICH (AC97) Device IDs
  1239 000007BA B915000000              	mov	ecx, valid_id_count
  1240                                  pfd_1:
  1241 000007BF AD                      	lodsd
  1242 000007C0 E8A8000000              	call	pciFindDevice
  1243 000007C5 7303                    	jnc	short d_ac97_1
  1244 000007C7 E2F6                    	loop	pfd_1
  1245                                  
  1246                                  	;stc
  1247 000007C9 C3                      	retn
  1248                                  
  1249                                  d_ac97_1:
  1250                                  	; eax = BUS/DEV/FN
  1251                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1252                                  	; edx = DEV/VENDOR
  1253                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1254                                  
  1255                                  	; playwav4.asm - 19/05/2024
  1256                                  
  1257 000007CA A3[9C380000]            	mov	[bus_dev_fn], eax
  1258 000007CF 8915[A0380000]          	mov	[dev_vendor], edx
  1259                                  
  1260                                  	; get ICH base address regs for mixer and bus master
  1261                                  
  1262 000007D5 B010                            mov     al, NAMBAR_REG
  1263 000007D7 E81F010000                      call    pciRegRead16			; read PCI registers 10-11
  1264                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
  1265                                  	; 19/05/2024
  1266 000007DC 80E2FE                  	and	dl, 0FEh
  1267                                  
  1268 000007DF 668915[A4380000]                mov     [NAMBAR], dx			; save audio mixer base addr
  1269                                  
  1270 000007E6 B014                    	mov     al, NABMBAR_REG
  1271 000007E8 E80E010000                      call    pciRegRead16
  1272                                          ;and    dx, IO_ADDR_MASK
  1273                                  	; 19/05/2024
  1274 000007ED 80E2C0                  	and	dl, 0C0h
  1275                                  
  1276 000007F0 668915[A6380000]                mov     [NABMBAR], dx			; save bus master base addr
  1277                                  
  1278 000007F7 B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
  1279 000007F9 E8F6000000              	call	pciRegRead8 ; 17/02/2017
  1280                                  	
  1281 000007FE 8815[37380000]          	mov	[ac97_int_ln_reg], dl
  1282                                  
  1283                                  	;clc
  1284                                  
  1285 00000804 C3                      	retn
  1286                                  
  1287                                  ; ----------------------------------
  1288                                  	
  1289                                  	; 26/12/2024
  1290                                  	; 07/12/2024
  1291                                  	; 01/12/2024
  1292                                  	; 14/11/2024
  1293                                  	; INPUT: ds:dx = file name address
  1294                                  	; OUTPUT: [filehandle] = ; -1 = not open
  1295                                  openFile:
  1296                                  	; 26/12/2024
  1297                                  	; 01/12/2024
  1298                                  	sys	_open, edx, 0
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000805 89D3                <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000807 B900000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000080C B805000000          <1>  mov eax, %1
   104                              <1> 
   105 00000811 CD40                <1>  int 40h
  1299                                  	; 07/12/2024
  1300                                  	;sys	_open, wav_file_name, 0
  1301 00000813 7305                    	jnc	short _of1
  1302                                  
  1303 00000815 B8FFFFFFFF              	mov	eax, -1
  1304                                  	; cf = 1 -> not found or access error
  1305                                  _of1:
  1306 0000081A A3[38380000]            	mov	[filehandle], eax
  1307 0000081F C3                      	retn
  1308                                  
  1309                                  ; ----------------------------------
  1310                                  
  1311                                  ; close the currently open file
  1312                                  
  1313                                  	; 01/12/2024
  1314                                  	; 14/11/2024
  1315                                  	; INPUT: [filehandle] ; -1 = not open
  1316                                  	; OUTPUT: none
  1317                                  closeFile:
  1318 00000820 833D[38380000]FF        	cmp	dword [filehandle], -1
  1319 00000827 740D                    	jz	short _cf1
  1320                                  	; 01/12/2024
  1321                                  	sys	_close, [filehandle]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000829 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97                              <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000082F B806000000          <1>  mov eax, %1
   104                              <1> 
   105 00000834 CD40                <1>  int 40h
  1322                                  	;mov 	dword [filehandle], -1
  1323                                  _cf1:
  1324 00000836 C3                      	retn
  1325                                  
  1326                                  ; ----------------------------------
  1327                                  
  1328                                  	; 01/12/2024
  1329                                  	; 14/11/2024 - Erdogan Tan
  1330                                  getWAVParameters:
  1331                                  ; reads WAV file header(s) (44 bytes) from the .wav file.
  1332                                  ; entry: none - assumes file is already open
  1333                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
  1334                                  ;	cx = number of channels (mono=1, stereo=2)
  1335                                  ;	dx = bits per sample (8, 16)
  1336                                  ;	bx = number of bytes per sample (1 to 4)
  1337                                  
  1338                                          ;mov	dx, WAVFILEHEADERbuff
  1339                                  	;mov	bx, [filehandle]
  1340                                          ;mov	cx, 44			; 44 bytes
  1341                                  	;mov	ah, 3Fh
  1342                                          ;int	21h
  1343                                  	;jc	short gwavp_retn
  1344                                  	; 01/12/2024 (TRDOS 386)
  1345                                  	sys	_read, [filehandle], WAVFILEHEADERbuff, 44
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000837 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000083D B9[08380000]        <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00000842 BA2C000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000847 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 0000084C CD40                <1>  int 40h
  1346 0000084E 721C                    	jc	short gwavp_retn
  1347                                  
  1348 00000850 83F82C                  	cmp	eax, 44
  1349 00000853 7217                    	jb	short gwavp_retn
  1350                                  
  1351 00000855 813D[10380000]5741-     	cmp	dword [RIFF_Format], 'WAVE'
  1351 0000085D 5645               
  1352 0000085F 750A                    	jne	short gwavp_stc_retn
  1353                                  
  1354 00000861 66833D[1C380000]01      	cmp	word [WAVE_AudioFormat], 1 ; Offset 20, must be 1 (= PCM)
  1355                                  	;jne	short gwavp_stc_retn
  1356 00000869 7401                    	je	short gwavp_retn ; 15/11/2024
  1357                                  
  1358                                  	; 15/11/2024
  1359                                  	;mov	cx, [WAVE_NumChannels]	; return num of channels in CX
  1360                                          ;mov    ax, [WAVE_SampleRate]	; return sample rate in AX
  1361                                  	;mov	dx, [WAVE_BitsPerSample] 
  1362                                  					; return bits per sample value in DX
  1363                                  	;mov	bx, [WAVE_BlockAlign]	; return bytes per sample in BX
  1364                                  ;gwavp_retn:
  1365                                          ;retn
  1366                                  
  1367                                  gwavp_stc_retn:
  1368 0000086B F9                      	stc
  1369                                  gwavp_retn:
  1370 0000086C C3                      	retn
  1371                                  
  1372                                  
  1373                                  ; 29/12/2024 (vgaplay3.s)
  1374                                  ; 18/12/2024 (ac97play.s)
  1375                                  ; --------------------------------------------------------
  1376                                  ; 27/05/2024 - (TRDOS 386 Kernel) audio.s
  1377                                  ; --------------------------------------------------------
  1378                                  
  1379                                  NOT_PCI32_PCI16	EQU 03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
  1380                                  NOT_BIT31 EQU 7FFFFFFFh
  1381                                  
  1382                                  pciFindDevice:
  1383                                  	; 19/11/2023
  1384                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1385                                  	;
  1386                                  	; scan through PCI space looking for a device+vendor ID
  1387                                  	;
  1388                                  	; Entry: EAX=Device+Vendor ID
  1389                                  	;
  1390                                  	; Exit: EAX=PCI address if device found
  1391                                  	;	EDX=Device+Vendor ID
  1392                                  	;       CY clear if found, set if not found. EAX invalid if CY set.
  1393                                  	;
  1394                                  	; Destroys: ebx, edi ; 19/11/2023
  1395                                  
  1396                                          ; 19/11/2023
  1397 0000086D 89C3                    	mov	ebx, eax
  1398 0000086F BF00000080              	mov	edi, 80000000h
  1399                                  nextPCIdevice:
  1400 00000874 89F8                    	mov 	eax, edi		; read PCI registers
  1401 00000876 E88C000000              	call	pciRegRead32
  1402                                  	; 19/11/2023
  1403 0000087B 39DA                    	cmp	edx, ebx
  1404 0000087D 7412                    	je	short PCIScanExit	; found
  1405                                  	; 19/11/2023
  1406 0000087F 81FF00F8FF80            	cmp	edi, 80FFF800h
  1407 00000885 7308                    	jnb	short pfd_nf		; not found
  1408 00000887 81C700010000            	add	edi, 100h
  1409 0000088D EBE5                    	jmp	short nextPCIdevice
  1410                                  pfd_nf:
  1411 0000088F F9                      	stc
  1412 00000890 C3                      	retn
  1413                                  PCIScanExit:
  1414                                  	;pushf
  1415 00000891 B8FFFFFF7F              	mov	eax, NOT_BIT31 	; 19/03/2017
  1416 00000896 21F8                    	and	eax, edi	; return only bus/dev/fn #
  1417 00000898 C3                      	retn
  1418                                  
  1419                                  pciRegRead:
  1420                                  	; 01/12/2024
  1421                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1422                                  	;
  1423                                  	; 8/16/32bit PCI reader
  1424                                  	;
  1425                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1426                                  	;           BIT30 set if 32 bit access requested
  1427                                  	;           BIT29 set if 16 bit access requested
  1428                                  	;           otherwise defaults to 8 bit read
  1429                                  	;
  1430                                  	; Exit:  DL,DX,EDX register data depending on requested read size
  1431                                  	;
  1432                                  	; Note1: this routine is meant to be called via pciRegRead8,
  1433                                  	;	 pciRegread16 or pciRegRead32, listed below.
  1434                                  	;
  1435                                  	; Note2: don't attempt to read 32 bits of data from a non dword
  1436                                  	;	 aligned reg number. Likewise, don't do 16 bit reads from
  1437                                  	;	 non word aligned reg #
  1438                                  
  1439 00000899 53                      	push	ebx
  1440 0000089A 51                      	push	ecx
  1441 0000089B 89C3                            mov     ebx, eax		; save eax, dh
  1442 0000089D 88F1                            mov     cl, dh
  1443                                  
  1444 0000089F 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1445 000008A4 0D00000080                      or      eax, BIT31		; make a PCI access request
  1446 000008A9 24FC                            and     al, ~3 ; NOT 3 ; 0FCh	; force index to be dword
  1447                                  
  1448 000008AB 66BAF80C                        mov     dx, PCI_INDEX_PORT
  1449                                          ;out	dx, eax			; write PCI selector
  1450                                  	; 29/05/2024
  1451 000008AF 53                      	push	ebx
  1452 000008B0 89C3                    	mov	ebx, eax ; data, dword
  1453 000008B2 B405                    	mov	ah, 5 ; write port, dword
  1454                                  	; dx = port number
  1455 000008B4 CD34                    	int	34h
  1456 000008B6 5B                      	pop	ebx
  1457                                  	
  1458 000008B7 66BAFC0C                        mov     dx, PCI_DATA_PORT
  1459 000008BB 88D8                            mov     al, bl
  1460 000008BD 2403                            and     al, 3			; figure out which port to
  1461 000008BF 00C2                            add     dl, al			; read to
  1462                                  
  1463 000008C1 F7C3000000C0            	test    ebx, PCI32+PCI16
  1464 000008C7 750A                            jnz     short _pregr0
  1465                                  
  1466                                  	;in	al, dx			; return 8 bits of data
  1467                                  	; 29/05/2024
  1468 000008C9 B400                    	mov	ah, 0 ; read port, byte
  1469                                  	; dx = port number
  1470 000008CB CD34                    	int	34h
  1471                                          
  1472 000008CD 88C2                    	mov	dl, al
  1473 000008CF 88CE                    	mov     dh, cl			; restore dh for 8 bit read
  1474 000008D1 EB17                    	jmp	short _pregr2
  1475                                  _pregr0:	
  1476 000008D3 F7C300000080            	test    ebx, PCI32
  1477 000008D9 7509                            jnz	short _pregr1
  1478                                  
  1479                                  	;in	ax, dx
  1480                                  	; 29/05/2024
  1481 000008DB B402                    	mov	ah, 2 ; read port, word
  1482                                  	; dx = port number
  1483 000008DD CD34                    	int	34h
  1484                                  
  1485 000008DF 6689C2                  	mov     dx, ax			; return 16 bits of data
  1486 000008E2 EB06                    	jmp	short _pregr2
  1487                                  _pregr1:
  1488                                  	;in	eax, dx			; return 32 bits of data
  1489                                  	; 29/05/2024
  1490 000008E4 B404                    	mov	ah, 4 ; read port, dword
  1491                                  	; dx = port number
  1492 000008E6 CD34                    	int	34h
  1493                                  
  1494 000008E8 89C2                    	mov	edx, eax
  1495                                  _pregr2:
  1496 000008EA 89D8                    	mov     eax, ebx		; restore eax
  1497 000008EC 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1498 000008F1 59                      	pop	ecx
  1499 000008F2 5B                      	pop	ebx
  1500 000008F3 C3                      	retn
  1501                                  
  1502                                  pciRegRead8:
  1503 000008F4 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
  1504 000008F9 EB9E                            jmp     short pciRegRead	; call generic PCI access
  1505                                  
  1506                                  pciRegRead16:
  1507 000008FB 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
  1508 00000900 0D00000040                      or      eax, PCI16		; call generic PCI access
  1509 00000905 EB92                            jmp     short pciRegRead
  1510                                  
  1511                                  pciRegRead32:
  1512 00000907 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
  1513 0000090C 0D00000080                      or      eax, PCI32		; call generic PCI access
  1514 00000911 EB86                            jmp     pciRegRead
  1515                                  
  1516                                  pciRegWrite:
  1517                                  	; 01/12/2024
  1518                                  	; 03/04/2017 ('pci.asm', 29/11/2016)
  1519                                  	;
  1520                                  	; 8/16/32bit PCI writer
  1521                                  	;
  1522                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1523                                  	;           BIT31 set if 32 bit access requested
  1524                                  	;           BIT30 set if 16 bit access requested
  1525                                  	;           otherwise defaults to 8bit read
  1526                                  	;        DL/DX/EDX data to write depending on size
  1527                                  	;
  1528                                  	; Note1: this routine is meant to be called via pciRegWrite8,
  1529                                  	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
  1530                                  	;
  1531                                  	; Note2: don't attempt to write 32bits of data from a non dword
  1532                                  	;	 aligned reg number. Likewise, don't do 16 bit writes from
  1533                                  	;	 non word aligned reg #
  1534                                  
  1535 00000913 53                      	push	ebx
  1536 00000914 51                      	push	ecx
  1537 00000915 89C3                            mov     ebx, eax		; save eax, edx
  1538 00000917 89D1                            mov     ecx, edx
  1539 00000919 25FFFFFF3F              	and     eax, NOT_PCI32_PCI16	; clear out data size request
  1540 0000091E 0D00000080                      or      eax, BIT31		; make a PCI access request
  1541 00000923 24FC                            and     al, ~3 ; NOT 3 ; 0FCh	; force index to be dword
  1542                                  
  1543 00000925 66BAF80C                        mov     dx, PCI_INDEX_PORT
  1544                                  	;out	dx, eax			; write PCI selector
  1545                                  	; 29/05/2024
  1546 00000929 53                      	push	ebx
  1547 0000092A 89C3                    	mov	ebx, eax ; data, dword
  1548 0000092C B405                    	mov	ah, 5 ; write port, dword
  1549                                  	; dx = port number
  1550 0000092E CD34                    	int	34h
  1551 00000930 5B                      	pop	ebx
  1552                                  	
  1553 00000931 66BAFC0C                        mov     dx, PCI_DATA_PORT
  1554 00000935 88D8                            mov     al, bl
  1555 00000937 2403                            and     al, 3			; figure out which port to
  1556 00000939 00C2                            add     dl, al			; write to
  1557                                  
  1558 0000093B F7C3000000C0            	test    ebx, PCI32+PCI16
  1559 00000941 7508                            jnz     short _pregw0
  1560 00000943 88C8                    	mov	al, cl 			; put data into al
  1561                                  	;out	dx, al
  1562                                  	; 29/05/2024
  1563                                  	; al = data, byte
  1564 00000945 B401                    	mov	ah, 1 ; write port, byte
  1565                                  	; dx = port number
  1566 00000947 CD34                    	int	34h
  1567                                  
  1568 00000949 EB1F                    	jmp	short _pregw2
  1569                                  _pregw0:
  1570 0000094B F7C300000080            	test    ebx, PCI32
  1571 00000951 750D                            jnz     short _pregw1
  1572 00000953 6689C8                  	mov	ax, cx			; put data into ax
  1573                                  	;out	dx, ax
  1574                                  	; 29/05/2024
  1575 00000956 53                      	push	ebx
  1576 00000957 89C3                    	mov	ebx, eax ; data, word
  1577 00000959 B403                    	mov	ah, 3 ; write port, word
  1578                                  	; dx = port number
  1579 0000095B CD34                    	int	34h
  1580 0000095D 5B                      	pop	ebx
  1581                                  
  1582 0000095E EB0A                    	jmp	short _pregw2
  1583                                  _pregw1:
  1584 00000960 89C8                    	mov	eax, ecx		; put data into eax
  1585                                  	;out	dx, eax
  1586                                  	; 29/05/2024
  1587 00000962 53                      	push	ebx
  1588 00000963 89C3                    	mov	ebx, eax ; data, dword
  1589 00000965 B405                    	mov	ah, 5 ; write port, dword
  1590                                  	; dx = port number
  1591 00000967 CD34                    	int	34h
  1592 00000969 5B                      	pop	ebx
  1593                                  _pregw2:
  1594 0000096A 89D8                            mov     eax, ebx		; restore eax
  1595 0000096C 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1596 00000971 89CA                            mov     edx, ecx		; restore dx
  1597 00000973 59                      	pop	ecx
  1598 00000974 5B                      	pop	ebx
  1599 00000975 C3                      	retn
  1600                                  
  1601                                  pciRegWrite8:
  1602 00000976 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
  1603 0000097B EB96                            jmp	short pciRegWrite	; call generic PCI access
  1604                                  
  1605                                  pciRegWrite16:
  1606 0000097D 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
  1607 00000982 0D00000040                      or      eax, PCI16		; call generic PCI access
  1608 00000987 EB8A                            jmp	short pciRegWrite
  1609                                  
  1610                                  pciRegWrite32:
  1611 00000989 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
  1612 0000098E 0D00000080                      or      eax, PCI32		; call generic PCI access
  1613 00000993 E97BFFFFFF                      jmp	pciRegWrite
  1614                                  
  1615                                  ; --------------------------------------------------------
  1616                                  ; 19/05/2024 - (playwav4.asm) ac97_vra.asm
  1617                                  ; --------------------------------------------------------
  1618                                  
  1619                                  	; 13/11/2023
  1620                                  
  1621                                  ;VRA:	db 1
  1622                                  
  1623                                  codecConfig:
  1624                                  	; 01/12/2024 (ac97play.s)
  1625                                  	; 29/05/2024 (playwav7.s modification)
  1626                                  	; 19/05/2024
  1627                                  	; 19/11/2023
  1628                                  	; 15/11/2023
  1629                                  	; 04/11/2023
  1630                                  	; 17/02/2017 
  1631                                  	; 07/11/2016 (Erdogan Tan)
  1632                                  
  1633                                  	;AC97_EA_VRA equ 1
  1634                                  	AC97_EA_VRA equ BIT0
  1635                                  
  1636                                  	; 04/11/2023
  1637                                  init_ac97_controller:
  1638 00000998 A1[9C380000]            	mov	eax, [bus_dev_fn]
  1639 0000099D B004                    	mov	al, PCI_CMD_REG
  1640 0000099F E857FFFFFF              	call	pciRegRead16		; read PCI command register
  1641 000009A4 80CA05                  	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
  1642 000009A7 E8D1FFFFFF              	call	pciRegWrite16
  1643                                  
  1644                                  	;call	delay_100ms
  1645                                  
  1646                                  	; 19/05/2024
  1647                                  	; ('PLAYMOD3.ASM', Erdogan Tan, 18/05/2024)
  1648                                  
  1649                                  init_ac97_codec:
  1650                                  	; 18/11/2023
  1651 000009AC BD28000000              	mov	ebp, 40
  1652                                  	; 29/05/2024
  1653                                  	;mov	ebp, 1000
  1654                                  _initc_1:
  1655                                  	; 29/05/2024
  1656 000009B1 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  1657 000009B5 660315[A6380000]        	add	dx, [NABMBAR]
  1658                                  	;in	eax, dx
  1659 000009BC B404                    	mov	ah, 4	; read port, dword
  1660 000009BE CD34                    	int	34h
  1661                                  
  1662                                  	; 19/05/2024
  1663                                  	;call	delay1_4ms
  1664                                  
  1665 000009C0 83F8FF                  	cmp	eax, 0FFFFFFFFh ; -1
  1666 000009C3 750A                    	jne	short _initc_3
  1667                                  _initc_2:
  1668 000009C5 4D                      	dec	ebp
  1669 000009C6 7425                    	jz	short _ac97_codec_ready
  1670                                  
  1671                                  	; 31/05/2024
  1672 000009C8 E8B3020000              	call	delay_100ms
  1673 000009CD EBE2                    	jmp	short _initc_1
  1674                                  _initc_3:
  1675 000009CF A900030010              	test	eax, CTRL_ST_CREADY
  1676 000009D4 7517                    	jnz	short _ac97_codec_ready
  1677                                  
  1678                                  	; 30/05/2024
  1679 000009D6 803D[F62C0000]01        	cmp	byte [reset], 1
  1680 000009DD 73E6                    	jnb	short _initc_2
  1681                                  
  1682 000009DF E893010000              	call	reset_ac97_codec
  1683                                  	; 30/05/2024
  1684 000009E4 C605[F62C0000]01        	mov	byte [reset], 1
  1685                                  	; 19/05/2024
  1686 000009EB EBD8                    	jmp	short _initc_2
  1687                                  
  1688                                  _ac97_codec_ready:
  1689 000009ED 668B15[A4380000]        	mov	dx, [NAMBAR]
  1690                                  	;add	dx, 0 ; ac_reg_0 ; reset register
  1691                                  	;out	dx, ax
  1692                                  	; 29/05/2024
  1693 000009F4 53                      	push	ebx
  1694 000009F5 89C3                    	mov	ebx, eax ; bx = data, word
  1695 000009F7 B403                    	mov	ah, 3	; write port, word
  1696 000009F9 CD34                    	int	34h
  1697 000009FB 5B                      	pop	ebx
  1698                                  
  1699                                  	; 31/05/2024
  1700                                  	; 29/05/2024
  1701                                  	;call	delay_100ms
  1702                                  
  1703                                  	; 19/11/2023
  1704 000009FC 09ED                    	or	ebp, ebp
  1705 000009FE 7539                    	jnz	short _ac97_codec_init_ok
  1706                                  
  1707 00000A00 31C0                    	xor	eax, eax ; 0
  1708 00000A02 668B15[A4380000]        	mov	dx, [NAMBAR]
  1709 00000A09 6683C226                	add	dx, CODEC_REG_POWERDOWN
  1710                                  	;out	dx, ax
  1711                                  	; 29/05/2024
  1712 00000A0D 53                      	push	ebx
  1713 00000A0E 89C3                    	mov	ebx, eax
  1714 00000A10 B403                    	mov	ah, 3	; write port, word
  1715 00000A12 CD34                    	int	34h
  1716 00000A14 5B                      	pop	ebx
  1717                                  
  1718                                  	; 19/11/2023
  1719                                  	; wait for 1 second
  1720                                  	; 19/05/2024
  1721 00000A15 B9E8030000              	mov	ecx, 1000 ; 1000*4*0.25ms = 1s
  1722                                  	;;mov	ecx, 10
  1723                                  	; 30/05/2024
  1724                                  	;mov	ecx, 40
  1725                                  _ac97_codec_rloop:
  1726                                  	;call	delay_100ms
  1727                                  	; 31/05/2024
  1728 00000A1A E870020000              	call	delay1_4ms
  1729                                  
  1730                                  	;mov	dx, [NAMBAR]
  1731                                  	;add	dx, CODEC_REG_POWERDOWN
  1732                                  	;in	ax, dx
  1733                                  	; 29/05/2024
  1734 00000A1F 668B15[A4380000]        	mov	dx, [NAMBAR]
  1735 00000A26 6683C226                	add	dx, CODEC_REG_POWERDOWN
  1736                                  	; 31/05/2024
  1737 00000A2A B402                    	mov	ah, 2	; read port, word
  1738 00000A2C CD34                    	int	34h
  1739                                  
  1740                                  	; 31/05/2024
  1741                                  	;call	delay1_4ms
  1742                                  	
  1743 00000A2E 6683E00F                	and	ax, 0Fh
  1744 00000A32 3C0F                    	cmp	al, 0Fh
  1745 00000A34 7403                    	je	short _ac97_codec_init_ok
  1746 00000A36 E2E2                    	loop	_ac97_codec_rloop 
  1747                                  
  1748                                  init_ac97_codec_err1:
  1749                                  	;stc	; cf = 1 ; 19/05/2024
  1750                                  init_ac97_codec_err2:
  1751 00000A38 C3                      	retn
  1752                                  
  1753                                  _ac97_codec_init_ok:
  1754 00000A39 E8DA000000              	call 	reset_ac97_controller
  1755                                  
  1756                                  	; 31/05/2024
  1757                                  	; 30/05/2024
  1758                                  	; 19/05/2024
  1759                                  	;call	delay_100ms
  1760                                  
  1761                                  	; 30/05/2024
  1762                                  	;call	delay1_4ms
  1763                                  	;call	delay1_4ms
  1764                                  	;call	delay1_4ms
  1765                                  	;call	delay1_4ms
  1766                                  
  1767                                  	; 01/12/2024
  1768                                  setup_ac97_codec:
  1769                                  	; 12/11/2023
  1770 00000A3E 66813D[20380000]80-     	cmp	word [WAVE_SampleRate], 48000
  1770 00000A46 BB                 
  1771 00000A47 0F849C000000            	je	skip_rate
  1772                                  	
  1773                                  	; 31/05/2024
  1774                                  	; 30/05/2024
  1775                                  	; 29/05/2024
  1776                                  	;cmp	byte [VRA], 0
  1777                                  	;jna	short skip_rate
  1778                                  
  1779                                  	; 11/11/2023
  1780 00000A4D 668B15[A4380000]        	mov	dx, [NAMBAR]
  1781 00000A54 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1782                                  	;in	ax, dx
  1783                                  	; 29/05/2024
  1784 00000A58 B402                    	mov	ah, 2 ; read port, word
  1785 00000A5A CD34                    	int	34h
  1786                                  
  1787                                  	; 30/05/2024
  1788                                  	; 19/05/2024
  1789 00000A5C E82E020000              	call	delay1_4ms
  1790                                  
  1791                                  	;and	al, ~BIT1 ; Clear DRA
  1792                                  	;;;
  1793                                  	; 30/05/2024
  1794 00000A61 24FC                    	and	al, ~(BIT1+BIT0) ; Clear DRA+VRA
  1795                                  	; 01/12/2024 (FASM)
  1796                                  	;and	al, NOT (BIT1+BIT0) ; 0FCh
  1797                                  	;out	dx, ax
  1798                                  	; 31/05/2024
  1799 00000A63 53                      	push	ebx
  1800 00000A64 89C3                    	mov	ebx, eax
  1801 00000A66 668B15[A4380000]        	mov	dx, [NAMBAR]
  1802 00000A6D 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1803 00000A71 B403                    	mov	ah, 3 ; write port, word
  1804 00000A73 CD34                    	int	34h
  1805 00000A75 5B                      	pop	ebx
  1806                                  
  1807                                  	; 31/05/2024
  1808 00000A76 E8B1010000              	call	check_vra
  1809                                  
  1810                                  	; 31/05/2024 - temporary (interpolated sample rate test)
  1811                                  	;mov	byte [VRA], 0
  1812                                  
  1813                                  	; 31/05/2024
  1814 00000A7B 803D[05380000]00        	cmp	byte [VRA], 0
  1815 00000A82 7665                    	jna	short skip_rate
  1816                                  
  1817 00000A84 668B15[A4380000]        	mov	dx, [NAMBAR]
  1818 00000A8B 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1819                                  	;in	ax, dx
  1820                                  	; 31/05/2024
  1821 00000A8F B402                    	mov	ah, 2 ; read port, word
  1822 00000A91 CD34                    	int	34h
  1823                                  
  1824                                  	;and	al, ~BIT1 ; Clear DRA
  1825                                  	;;;
  1826                                  
  1827 00000A93 0C01                    	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
  1828                                  	;out	dx, ax	; Enable variable rate audio
  1829                                  	; 29/05/2024
  1830 00000A95 53                      	push	ebx
  1831 00000A96 89C3                    	mov	ebx, eax
  1832                                  	;
  1833                                  	; 30/05/2024
  1834 00000A98 668B15[A4380000]        	mov	dx, [NAMBAR]
  1835 00000A9F 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1836                                  	;
  1837 00000AA3 B403                    	mov	ah, 3 ; write port, word
  1838 00000AA5 CD34                    	int	34h
  1839 00000AA7 5B                      	pop	ebx
  1840                                  
  1841                                  	;mov	cx, 10
  1842 00000AA8 B90A000000              	mov	ecx, 10 ; 30/05/2024
  1843                                  check_vra_loop:
  1844                                  	; 31/05/2024
  1845                                  	;call	delay_100ms
  1846                                  	; 30/05/2024
  1847 00000AAD E8DD010000              	call	delay1_4ms
  1848                                  
  1849                                  	; 11/11/2023
  1850                                  	;in	ax, dx
  1851                                  	; 29/05/2024
  1852 00000AB2 668B15[A4380000]        	mov	dx, [NAMBAR]
  1853 00000AB9 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1854 00000ABD B402                    	mov	ah, 2 ; read port, word
  1855 00000ABF CD34                    	int	34h
  1856                                  
  1857 00000AC1 A801                    	test	al, AC97_EA_VRA ; 1
  1858 00000AC3 750B                    	jnz	short set_rate
  1859                                  
  1860                                  	; 11/11/2023
  1861 00000AC5 E2E6                    	loop	check_vra_loop
  1862                                  
  1863                                  ;vra_not_supported:	; 19/05/2024
  1864 00000AC7 C605[05380000]00        	mov	byte [VRA], 0
  1865 00000ACE EB19                    	jmp	short skip_rate
  1866                                  
  1867                                  set_rate:
  1868                                  	;mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
  1869                                  	; 01/12/2024
  1870 00000AD0 66A1[20380000]          	mov	ax, [WAVE_SampleRate]
  1871                                  
  1872 00000AD6 668B15[A4380000]        	mov    	dx, [NAMBAR]
  1873 00000ADD 6683C22C                	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch
  1874                                  	;out	dx, ax 	; PCM Front/Center Output Sample Rate
  1875                                  	; 29/05/2024
  1876 00000AE1 53                      	push	ebx
  1877 00000AE2 89C3                    	mov	ebx, eax  ; bx = data, word
  1878 00000AE4 B403                    	mov	ah, 3 ; write port, word
  1879 00000AE6 CD34                    	int	34h
  1880 00000AE8 5B                      	pop	ebx
  1881                                  
  1882                                  	; 29/05/2024
  1883                                  	;call	delay_100ms
  1884                                  	; 30/05/2024
  1885                                  	;call	delay1_4ms
  1886                                  
  1887                                  	; 12/11/2023
  1888                                  skip_rate:
  1889 00000AE9 66B80202                	mov	ax, 0202h
  1890 00000AED 668B15[A4380000]          	mov	dx, [NAMBAR]
  1891 00000AF4 6683C202                  	add	dx, CODEC_MASTER_VOL_REG ;02h
  1892                                  	;out	dx, ax
  1893                                  	; 29/05/2024
  1894 00000AF8 53                      	push	ebx
  1895 00000AF9 89C3                    	mov	ebx, eax  ; bx = data, word
  1896 00000AFB B403                    	mov	ah, 3 ; write port, word
  1897 00000AFD CD34                    	int	34h
  1898 00000AFF 5B                      	pop	ebx
  1899                                  
  1900                                  	; 29/05/2024
  1901                                  	;call	delay1_4ms
  1902                                  	;call	delay1_4ms
  1903                                  	;call	delay1_4ms
  1904                                  	;call	delay1_4ms
  1905                                  
  1906 00000B00 66B80202                	mov	ax, 0202h
  1907 00000B04 668B15[A4380000]          	mov	dx, [NAMBAR]
  1908 00000B0B 6683C218                  	add	dx, CODEC_PCM_OUT_REG		;18h
  1909                                    	;out	dx, ax
  1910                                  	; 29/05/2024
  1911 00000B0F 53                      	push	ebx
  1912 00000B10 89C3                    	mov	ebx, eax  ; bx = data, word
  1913 00000B12 B403                    	mov	ah, 3 ; write port, word
  1914 00000B14 CD34                    	int	34h
  1915 00000B16 5B                      	pop	ebx
  1916                                  
  1917                                   	; 29/05/2024
  1918                                  	;call	delay1_4ms
  1919                                  	;call	delay1_4ms
  1920                                  	;call	delay1_4ms
  1921                                  	;call	delay1_4ms
  1922                                  
  1923                                  	; 19/05/2024
  1924                                  	;clc
  1925                                  
  1926 00000B17 C3                              retn
  1927                                  
  1928                                  reset_ac97_controller:
  1929                                  	; 29/05/2024 (TRDOS 386)
  1930                                  	; 19/05/2024
  1931                                  	; 11/11/2023
  1932                                  	; 10/06/2017
  1933                                  	; 29/05/2017
  1934                                  	; 28/05/2017
  1935                                  	; reset AC97 audio controller registers
  1936 00000B18 31C0                    	xor	eax, eax
  1937 00000B1A 66BA0B00                        mov	dx, PI_CR_REG
  1938 00000B1E 660315[A6380000]        	add	dx, [NABMBAR]
  1939                                  	;out	dx, al
  1940                                  	; 29/05/2024
  1941                                  	; al = data, byte
  1942 00000B25 B401                    	mov	ah, 1 ; write port, byte
  1943 00000B27 CD34                    	int	34h
  1944                                  
  1945                                  	; 19/05/2024
  1946                                  	;call	delay1_4ms
  1947                                  
  1948 00000B29 66BA1B00                        mov     dx, PO_CR_REG
  1949 00000B2D 660315[A6380000]        	add	dx, [NABMBAR]
  1950                                  	;out	dx, al
  1951                                  	; 29/05/2024
  1952                                  	; al = data, byte
  1953 00000B34 B401                    	mov	ah, 1 ; write port, byte
  1954 00000B36 CD34                    	int	34h
  1955                                  
  1956                                  	; 19/05/2024
  1957                                  	;call	delay1_4ms
  1958                                  
  1959 00000B38 66BA2B00                        mov     dx, MC_CR_REG
  1960 00000B3C 660315[A6380000]        	add	dx, [NABMBAR]
  1961                                  	;out	dx, al
  1962                                  	; 29/05/2024
  1963                                  	; al = data, byte
  1964 00000B43 B401                    	mov	ah, 1 ; write port, byte
  1965 00000B45 CD34                    	int	34h
  1966                                  
  1967                                  	; 19/05/2024
  1968                                  	;call	delay1_4ms
  1969                                  
  1970 00000B47 B002                            mov	al, RR
  1971 00000B49 66BA0B00                        mov	dx, PI_CR_REG
  1972 00000B4D 660315[A6380000]        	add	dx, [NABMBAR]
  1973                                  	;out	dx, al
  1974                                  	; 29/05/2024
  1975                                  	; al = data, byte
  1976 00000B54 B401                    	mov	ah, 1 ; write port, byte
  1977 00000B56 CD34                    	int	34h
  1978                                  
  1979                                  	; 19/05/2024
  1980                                  	;call	delay1_4ms
  1981                                  
  1982 00000B58 66BA1B00                        mov	dx, PO_CR_REG
  1983 00000B5C 660315[A6380000]        	add	dx, [NABMBAR]
  1984                                  	;out	dx, al
  1985                                  	; 29/05/2024
  1986                                  	; al = data, byte
  1987 00000B63 B401                    	mov	ah, 1 ; write port, byte
  1988 00000B65 CD34                    	int	34h
  1989                                  
  1990                                  	; 19/05/2024
  1991                                  	;call	delay1_4ms
  1992                                  
  1993 00000B67 66BA2B00                        mov	dx, MC_CR_REG
  1994 00000B6B 660315[A6380000]        	add	dx, [NABMBAR]
  1995                                  	;out	dx, al
  1996                                  	; 29/05/2024
  1997                                  	; al = data, byte
  1998 00000B72 B401                    	mov	ah, 1 ; write port, byte
  1999 00000B74 CD34                    	int	34h
  2000                                  
  2001                                  	; 19/05/2024
  2002                                  	;call	delay1_4ms
  2003                                  
  2004 00000B76 C3                      	retn
  2005                                  
  2006                                  reset_ac97_codec:
  2007                                  	; 29/05/2024 (TRDOS 386)
  2008                                  	; 11/11/2023
  2009                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2010 00000B77 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2011 00000B7B 660315[A6380000]        	add	dx, [NABMBAR]
  2012                                  	;in	eax, dx
  2013                                  	; 29/05/2024
  2014 00000B82 B404                    	mov	ah, 4 ; read port, dword
  2015 00000B84 CD34                    	int	34h
  2016                                  
  2017                                  	;test	eax, 2
  2018                                  	; 06/08/2022
  2019 00000B86 A802                    	test	al, 2
  2020 00000B88 7407                    	jz	short _r_ac97codec_cold
  2021                                  
  2022 00000B8A E80F000000              	call	warm_ac97codec_reset
  2023 00000B8F 7308                    	jnc	short _r_ac97codec_ok
  2024                                  _r_ac97codec_cold:
  2025 00000B91 E845000000                      call	cold_ac97codec_reset
  2026 00000B96 7301                            jnc	short _r_ac97codec_ok
  2027                                  	
  2028                                  	; 16/04/2017
  2029                                          ;xor	eax, eax	; timeout error
  2030                                         	;stc
  2031 00000B98 C3                      	retn
  2032                                  
  2033                                  _r_ac97codec_ok:
  2034 00000B99 31C0                            xor     eax, eax
  2035                                          ;mov	al, VIA_ACLINK_C00_READY ; 1
  2036 00000B9B FEC0                            inc	al
  2037 00000B9D C3                      	retn
  2038                                  
  2039                                  warm_ac97codec_reset:
  2040                                  	; 29/05/2024 (TRDOS 386)
  2041                                  	; 11/11/2023
  2042                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  2043                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2044 00000B9E B806000000              	mov	eax, 6
  2045 00000BA3 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2046 00000BA7 660315[A6380000]        	add	dx, [NABMBAR]
  2047                                  	;out	dx, eax
  2048                                  	; 29/05/2024
  2049 00000BAE 53                      	push	ebx
  2050 00000BAF 89C3                    	mov	ebx, eax  ; ebx = data, dword
  2051 00000BB1 B405                    	mov	ah, 5 ; write port, dword
  2052 00000BB3 CD34                    	int	34h
  2053 00000BB5 5B                      	pop	ebx
  2054                                  
  2055                                  	; 30/05/2024
  2056 00000BB6 B90A000000              	mov	ecx, 10	; total 1s
  2057                                  	; 29/05/2024
  2058                                  	;mov	ecx, 4000
  2059                                  _warm_ac97c_rst_wait:
  2060                                  	; 30/05/2024
  2061 00000BBB E8C0000000              	call	delay_100ms
  2062                                  
  2063 00000BC0 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  2064 00000BC4 660315[A6380000]        	add	dx, [NABMBAR]
  2065                                  	;in	eax, dx
  2066                                  	; 29/05/2024
  2067 00000BCB B404                    	mov	ah, 4 ; read port, dword
  2068 00000BCD CD34                    	int	34h
  2069                                  
  2070 00000BCF A900030010              	test	eax, CTRL_ST_CREADY
  2071 00000BD4 7504                    	jnz	short _warm_ac97c_rst_ok
  2072                                  
  2073 00000BD6 49                      	dec	ecx
  2074 00000BD7 75E2                    	jnz	short _warm_ac97c_rst_wait
  2075                                  
  2076                                  _warm_ac97c_rst_fail:
  2077 00000BD9 F9                              stc
  2078                                  _warm_ac97c_rst_ok:
  2079 00000BDA C3                      	retn
  2080                                  
  2081                                  cold_ac97codec_reset:
  2082                                  	; 11/11/2023
  2083                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  2084                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2085 00000BDB B802000000                      mov	eax, 2
  2086 00000BE0 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2087 00000BE4 660315[A6380000]        	add	dx, [NABMBAR]
  2088                                  	;out	dx, eax
  2089                                  	; 29/05/2024
  2090 00000BEB 53                      	push	ebx
  2091 00000BEC 89C3                    	mov	ebx, eax  ; ebx = data, dword
  2092 00000BEE B405                    	mov	ah, 5 ; write port, dword
  2093 00000BF0 CD34                    	int	34h
  2094 00000BF2 5B                      	pop	ebx
  2095                                  
  2096                                  	; 30/05/2024
  2097 00000BF3 E888000000              	call	delay_100ms 	; wait 100 ms
  2098 00000BF8 E883000000              	call	delay_100ms 	; wait 100 ms
  2099 00000BFD E87E000000              	call	delay_100ms 	; wait 100 ms
  2100 00000C02 E879000000              	call	delay_100ms 	; wait 100 ms
  2101                                  
  2102                                  	; 30/05/2024
  2103 00000C07 B910000000              	mov	ecx, 16	; total 20*100 ms = 2s
  2104                                  	; 29/05/2024
  2105                                  	;mov	ecx, 16000
  2106                                  _cold_ac97c_rst_wait:
  2107 00000C0C 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  2108 00000C10 660315[A6380000]        	add	dx, [NABMBAR]
  2109                                  	;in	eax, dx
  2110                                  	; 29/05/2024
  2111 00000C17 B404                    	mov	ah, 4 ; read port, dword
  2112 00000C19 CD34                    	int	34h
  2113                                  
  2114 00000C1B A900030010              	test	eax, CTRL_ST_CREADY
  2115 00000C20 7509                    	jnz	short _cold_ac97c_rst_ok
  2116                                  
  2117                                  	; 30/05/2024
  2118                                  	; 29/05/2024
  2119 00000C22 E859000000              	call	delay_100ms
  2120                                  
  2121 00000C27 49                      	dec	ecx
  2122 00000C28 75E2                    	jnz	short _cold_ac97c_rst_wait
  2123                                  
  2124                                  _cold_ac97c_rst_fail:
  2125 00000C2A F9                              stc
  2126                                  _cold_ac97c_rst_ok:
  2127 00000C2B C3                      	retn
  2128                                  
  2129                                  ; 29/12/2024 (vgaplay3.s, NASM)
  2130                                  ; 18/12/2024 (ac97play.s, FASM)
  2131                                  ; 13/11/2024
  2132                                  ; 30/05/2024
  2133                                  %if 1
  2134                                  ;if 1
  2135                                  check_vra:
  2136                                  	; 29/05/2024
  2137 00000C2C C605[05380000]01        	mov	byte [VRA], 1
  2138                                  
  2139                                  	; 29/05/2024 - audio.s (TRDOS 386 Kernel) - 27/05/2024
  2140                                  	; 24/05/2024
  2141                                  	; 23/05/2024
  2142 00000C33 668B15[A4380000]        	mov	dx, [NAMBAR]
  2143 00000C3A 6683C228                	add	dx, CODEC_EXT_AUDIO_REG	; 28h
  2144                                  	;in	ax, dx
  2145                                  	; 29/05/2024
  2146 00000C3E B402                    	mov	ah, 2 ; read port, word
  2147 00000C40 CD34                    	int	34h
  2148                                  
  2149                                  	; 30/05/2024
  2150                                  	; 23/05/2024
  2151 00000C42 E848000000              	call	delay1_4ms
  2152                                  
  2153                                  	; 29/05/2024
  2154 00000C47 A801                    	test	al, BIT0
  2155                                  	;test	al, 1 ; BIT0 ; Variable Rate Audio bit
  2156 00000C49 7507                    	jnz	short check_vra_ok
  2157                                  
  2158                                  vra_not_supported:
  2159                                  	; 13/11/2023
  2160 00000C4B C605[05380000]00        	mov	byte [VRA], 0
  2161                                  check_vra_ok:
  2162 00000C52 C3                      	retn
  2163                                  ;end if
  2164                                  %endif
  2165                                  
  2166                                  ; --------------------------------------------------------
  2167                                  ; --------------------------------------------------------
  2168                                  
  2169                                  ; 29/12/2024 (vgaplay3.s)
  2170                                  ; 18/12/2024 (ac97play.s)
  2171                                  ;
  2172                                  ; 18/11/2024
  2173                                  ; Ref: TRDOS 386 v2.0.9, audio.s, Erdogan Tan, 06/06/2024
  2174                                  
  2175                                  ac97_stop: 
  2176                                  	; 18/11/2024
  2177 00000C53 C605[F8370000]02        	mov	byte [stopped], 2
  2178                                  
  2179                                  ac97_po_cmd@:
  2180 00000C5A 30C0                    	xor	al, al ; 0
  2181                                  ac97_po_cmd:
  2182 00000C5C 668B15[A6380000]        	mov     dx, [NABMBAR]
  2183 00000C63 6683C21B                        add     dx, PO_CR_REG	; PCM out control register
  2184                                  	;out	dx, al
  2185                                  	; 01/12/2024
  2186 00000C67 B401                    	mov	ah, 1 ; write port, byte
  2187 00000C69 CD34                    	int	34h
  2188 00000C6B C3                      	retn
  2189                                  
  2190                                  ac97_pause:
  2191 00000C6C C605[F8370000]01        	mov	byte [stopped], 1 ; paused
  2192                                  	;mov	al, 0
  2193                                  	;jmp	short ac97_po_cmd
  2194 00000C73 EBE5                    	jmp	short ac97_po_cmd@
  2195                                  
  2196                                  ac97_play: ; continue to play (after pause)
  2197 00000C75 C605[F8370000]00        	mov	byte [stopped], 0
  2198 00000C7C B001                    	mov	al, RPBM
  2199 00000C7E EBDC                    	jmp	short ac97_po_cmd
  2200                                  
  2201                                  ; --------------------------------------------------------
  2202                                  
  2203                                  PORTB		EQU 061h
  2204                                  REFRESH_STATUS	EQU 010h	; Refresh signal status
  2205                                  
  2206                                  	; 29/12/2024 (vgaplay3.s)
  2207                                  	; 18/12/2024
  2208                                  	; 01/12/2024 (ac97play.s)
  2209                                  delay_100ms:
  2210                                  	; 30/05/2024 (playwav7.s)
  2211 00000C80 51                      	push	ecx
  2212 00000C81 B990010000              	mov	ecx, 400  ; 400*0.25ms
  2213                                  _delay_x_ms:
  2214 00000C86 E804000000              	call	delay1_4ms
  2215 00000C8B E2F9                            loop	_delay_x_ms
  2216 00000C8D 59                      	pop	ecx
  2217 00000C8E C3                      	retn
  2218                                  
  2219                                  delay1_4ms:
  2220                                  	; 30/05/2024 (TRDOS 386)
  2221 00000C8F 50                              push    eax 
  2222 00000C90 51                              push    ecx
  2223 00000C91 53                      	push	ebx
  2224 00000C92 52                      	push	edx
  2225 00000C93 B910000000                      mov     ecx, 16			; close enough.
  2226                                  	;in	al, PORTB
  2227                                  	; 30/05/2024
  2228 00000C98 66BA6100                	mov	dx, PORTB
  2229 00000C9C B400                    	mov	ah, 0  ; read port, byte
  2230 00000C9E CD34                    	int	34h
  2231                                  
  2232 00000CA0 2410                    	and	al, REFRESH_STATUS
  2233                                  	;mov	ah, al			; Start toggle state
  2234 00000CA2 88C3                    	mov	bl, al
  2235 00000CA4 09C9                    	or	ecx, ecx
  2236 00000CA6 7401                    	jz	short _d4ms1
  2237 00000CA8 41                      	inc	ecx			; Throwaway first toggle
  2238                                  _d4ms1:	
  2239                                  	;in	al, PORTB		; Read system control port
  2240                                  	; 30/05/2024
  2241 00000CA9 66BA6100                	mov	dx, PORTB
  2242 00000CAD B400                    	mov	ah, 0  ; read port, byte
  2243 00000CAF CD34                    	int	34h
  2244                                  
  2245 00000CB1 2410                    	and	al, REFRESH_STATUS	; Refresh toggles 15.085 microseconds
  2246                                  	;cmp	ah, al
  2247 00000CB3 38C3                    	cmp	bl, al
  2248 00000CB5 74F2                    	je	short _d4ms1		; Wait for state change
  2249                                  
  2250                                  	;mov	ah, al			; Update with new state
  2251 00000CB7 88C3                    	mov	bl, al
  2252 00000CB9 49                      	dec	ecx
  2253 00000CBA 75ED                    	jnz	short _d4ms1
  2254                                  
  2255 00000CBC 5A                      	pop	edx
  2256 00000CBD 5B                              pop	ebx
  2257 00000CBE 59                      	pop	ecx
  2258 00000CBF 58                              pop	eax
  2259                                  c4ue_okk:
  2260 00000CC0 C3                              retn
  2261                                  
  2262                                  ; --------------------------------------------------------
  2263                                  
  2264                                  getCurrentIndex:
  2265                                  	; returns AL = current index value
  2266                                  	; 01/12/2024
  2267                                  	; 29/05/2024 (TRDOS 386)
  2268                                  	; 08/11/2023
  2269 00000CC1 668B15[A6380000]        	mov	dx, [NABMBAR]
  2270 00000CC8 6683C214                	add	dx, PO_CIV_REG
  2271                                  	;in	al, dx
  2272                                  	; 29/05/2024
  2273 00000CCC B400                    	mov	ah, 0 ; read port, byte
  2274 00000CCE CD34                    	int	34h
  2275                                  uLVI2:	;	06/11/2023
  2276 00000CD0 C3                      	retn
  2277                                  
  2278                                  ; --------------------------------------------------------
  2279                                  
  2280                                  updateLVI:
  2281                                  	; 01/12/2024
  2282                                  	; 29/05/2024 (TRDOS 386)
  2283                                  	; 08/11/2023
  2284                                  	; 07/11/2023
  2285                                  	; 06/11/2023
  2286 00000CD1 668B15[A6380000]        	mov	dx, [NABMBAR]
  2287 00000CD8 6683C214                	add	dx, PO_CIV_REG
  2288                                  	; (Current Index Value and Last Valid Index value)
  2289                                  	;in	ax, dx
  2290                                  	; 29/05/2024
  2291 00000CDC B402                    	mov	ah, 2 ; read port, word
  2292 00000CDE CD34                    	int	34h
  2293                                  
  2294 00000CE0 38E0                    	cmp	al, ah ; is current index = last index ?
  2295 00000CE2 75EC                    	jne	short uLVI2
  2296                                  
  2297                                  	; 08/11/2023	
  2298 00000CE4 E8D8FFFFFF              	call	getCurrentIndex
  2299                                   
  2300 00000CE9 F605[36380000]01        	test	byte [flags], ENDOFFILE
  2301                                  	;jnz	short uLVI1
  2302 00000CF0 7418                    	jz	short uLVI0  ; 08/11/2023
  2303                                  
  2304                                  	; 08/11/2023
  2305 00000CF2 50                      	push	eax	; 29/05/2024 (32 bit)
  2306 00000CF3 668B15[A6380000]        	mov	dx, [NABMBAR]
  2307 00000CFA 6683C216                	add	dx, PO_SR_REG  ; PCM out status register
  2308                                  	;in	ax, dx
  2309                                  	; 29/05/2024
  2310 00000CFE B402                    	mov	ah, 2 ; read port, word
  2311 00000D00 CD34                    	int	34h
  2312                                  
  2313 00000D02 A803                    	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
  2314                                  		      ; (has been processed)
  2315                                  		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
  2316 00000D04 58                      	pop	eax
  2317 00000D05 7407                    	jz	short uLVI1
  2318                                  uLVI3:
  2319 00000D07 31C0                    	xor	eax, eax
  2320                                  	; zf = 1
  2321 00000D09 C3                      	retn
  2322                                  uLVI0:
  2323                                          ; not at the end of the file yet.
  2324 00000D0A FEC8                    	dec	al
  2325 00000D0C 241F                    	and	al, 1Fh
  2326                                  uLVI1:
  2327                                  	;call	setLastValidIndex
  2328                                  ;uLVI2:
  2329                                  	;retn
  2330                                  
  2331                                  ;input AL = index # to stop on
  2332                                  setLastValidIndex:
  2333                                  	; 01/12/2024
  2334                                  	; 29/05/2024 (TRDOS 386)
  2335                                  	; 08/11/2023
  2336 00000D0E 668B15[A6380000]        	mov	dx, [NABMBAR]
  2337 00000D15 6683C215                	add	dx, PO_LVI_REG
  2338                                          ;out	dx, al
  2339                                  	; 29/05/2024
  2340                                  	; al = data, byte
  2341 00000D19 B401                    	mov	ah, 1 ; write port, byte
  2342 00000D1B CD34                    	int	34h
  2343 00000D1D C3                      	retn
  2344                                  
  2345                                  ; --------------------------------------------------------
  2346                                  ; 07/12/2024
  2347                                  ; --------------------------------------------------------
  2348                                  
  2349                                  ; /////
  2350                                  	; 14/12/2024
  2351                                  	; 07/12/2024
  2352                                  	; 01/12/2024
  2353                                  	; 30/05/2024 (ich_wav4.asm, 19/05/2024)
  2354                                  loadFromFile:
  2355                                  	; 07/11/2023
  2356                                  
  2357 00000D1E F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2358                                  					; last of the file?
  2359 00000D25 7402                    	jz	short lff_0		; no
  2360 00000D27 F9                      	stc
  2361 00000D28 C3                      	retn
  2362                                  
  2363                                  lff_0:
  2364                                  	; 07/12/2024
  2365                                  	; 26/11/2023 (playwav8.s)
  2366                                  	;mov	edi, audio_buffer
  2367                                  
  2368                                  	; 01/12/2024 (TRDOS 386)
  2369                                  	; edi = audio buffer address
  2370                                  
  2371                                  	; 14/12/2024
  2372                                  	; 01/12/2024
  2373                                  	; 17/11/2024
  2374                                  	;mov	ebx, [filehandle]
  2375                                  	; 02/12/2024
  2376                                  	;mov	edx, [loadsize] 
  2377                                  
  2378                                  	; 17/11/2024
  2379 00000D29 803D[9A380000]00        	cmp	byte [fbs_shift], 0
  2380 00000D30 7677                    	jna	short lff_1 ; stereo, 16 bit
  2381                                  
  2382                                  lff_2:
  2383                                  	; 01/12/2024
  2384 00000D32 BE[00500200]            	mov	esi, temp_buffer 
  2385                                  	; 14/12/2024
  2386                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000D37 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000D3D 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00000D3F 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000D45 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00000D4A CD40                <1>  int 40h
  2387 00000D4C 0F8289000000            	jc	lff_4 ; error !
  2388                                  
  2389                                  	; 01/12/2024
  2390                                  	; 14/11/2024
  2391 00000D52 A3[BC380000]            	mov	[count], eax
  2392                                  
  2393                                  	; 01/12/2024
  2394 00000D57 21C0                    	and	eax, eax
  2395                                  	;jz	short lff_3
  2396                                  	; 14/12/2024
  2397 00000D59 0F8485000000            	jz	lff_10
  2398                                  
  2399 00000D5F 8A1D[9A380000]          	mov	bl, [fbs_shift]
  2400                                  
  2401                                  	; 14/12/2024
  2402 00000D65 89FA                    	mov	edx, edi ; audio buffer start address
  2403                                  
  2404                                  	; 01/12/2024
  2405 00000D67 89C1                    	mov	ecx, eax
  2406 00000D69 803D[2A380000]08        	cmp	byte [WAVE_BitsPerSample], 8 ; bits per sample (8 or 16)
  2407 00000D70 751E                    	jne	short lff_7 ; 16 bit samples
  2408                                  	; 8 bit samples
  2409 00000D72 FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
  2410 00000D74 740E                    	jz	short lff_6 ; 8 bit, stereo
  2411                                  	; 01/12/2024 (32bit registers)
  2412                                  lff_5:
  2413                                  	; mono & 8 bit
  2414 00000D76 AC                      	lodsb
  2415 00000D77 2C80                    	sub	al, 80h ; 08/11/2023
  2416 00000D79 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
  2417 00000D7C 66AB                    	stosw	; left channel
  2418 00000D7E 66AB                    	stosw	; right channel
  2419 00000D80 E2F4                    	loop	lff_5
  2420 00000D82 EB16                    	jmp	short lff_9
  2421                                  lff_6:
  2422                                  	; stereo & 8 bit
  2423 00000D84 AC                      	lodsb
  2424 00000D85 2C80                    	sub	al, 80h ; 08/11/2023
  2425 00000D87 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
  2426 00000D8A 66AB                    	stosw
  2427 00000D8C E2F6                    	loop	lff_6
  2428 00000D8E EB0A                    	jmp	short lff_9
  2429                                  lff_7:
  2430 00000D90 D1E9                    	shr	ecx, 1 ; word count
  2431                                  lff_8:
  2432 00000D92 66AD                    	lodsw
  2433 00000D94 66AB                    	stosw	; left channel
  2434 00000D96 66AB                    	stosw	; right channel
  2435 00000D98 E2F8                    	loop	lff_8
  2436                                  lff_9:
  2437                                  	; 14/12/2024
  2438 00000D9A 89F8                    	mov	eax, edi
  2439 00000D9C 8B0D[B0380000]          	mov	ecx, [buffersize] 
  2440 00000DA2 01D1                    	add	ecx, edx ; + buffer start address
  2441 00000DA4 39C8                    	cmp	eax, ecx	
  2442 00000DA6 7225                    	jb	short lff_3
  2443 00000DA8 C3                      	retn
  2444                                  	
  2445                                  lff_1:  
  2446                                  	; 07/12/2024
  2447                                  	; 01/12/2024
  2448                                  	;sys 	_read, [filehandle], esi, [loadsize] ; edx
  2449                                  	; 14/12/2024
  2450                                  	sys 	_read, [filehandle], edi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000DA9 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000DAF 89F9                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00000DB1 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000DB7 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00000DBC CD40                <1>  int 40h
  2451                                  	; 07/11/2023
  2452 00000DBE 721B                    	jc	short lff_4 ; error !
  2453                                  
  2454                                  	; 01/12/2024
  2455                                  	; 14/11/2024
  2456 00000DC0 A3[BC380000]            	mov	[count], eax
  2457                                  
  2458                                  	; 02/12/2024
  2459 00000DC5 39D0                    	cmp	eax, edx ; cmp eax, [loadsize]	
  2460 00000DC7 7411                    	je	short endLFF
  2461                                  	; edi = buffer (start) address
  2462 00000DC9 01C7                    	add	edi, eax
  2463 00000DCB 89D1                    	mov	ecx, edx
  2464                                  lff_3:
  2465                                  	;call	padfill			; blank pad the remainder
  2466                                  	; 21/12/2024
  2467                                  padfill:
  2468                                  	; 14/12/2024
  2469                                  	; 01/12/2024 (TRDOS 386, 32bit registers)
  2470                                  	; 17/11/2024
  2471                                  	;   di = offset (to be filled with ZEROs)
  2472                                  	;   bp = buffer segment
  2473                                  	;   ax = di = number of bytes loaded
  2474                                  	;   cx = buffer size (> loaded bytes)	
  2475                                  	; 07/11/2023
  2476                                  	; 06/11/2023
  2477                                  	; 17/02/2017
  2478                                  	; 01/12/2024
  2479 00000DCD 29C1                    	sub	ecx, eax
  2480                                  	; 01/12/2024
  2481                                  	; 25/11/2024
  2482 00000DCF 31C0                    	xor	eax, eax
  2483                                  	; 14/12/2024
  2484 00000DD1 F3AA                    	rep	stosb
  2485                                  	; 21/12/2024
  2486                                  	;retn
  2487                                  	; ----------
  2488                                          ;clc				; don't exit with CY yet.
  2489 00000DD3 800D[36380000]01                or	byte [flags], ENDOFFILE	; end of file flag
  2490                                  endLFF:
  2491 00000DDA C3                              retn
  2492                                  lff_4:
  2493                                  	; 08/11/2023
  2494 00000DDB B021                    	mov	al, '!'  ; error
  2495 00000DDD E882F9FFFF              	call	tL0
  2496                                  
  2497                                  	; 01/12/2024
  2498 00000DE2 31C0                    	xor	eax, eax
  2499                                  lff_10:
  2500                                  	; 14/12/2024
  2501 00000DE4 8B0D[B0380000]          	mov	ecx, [buffersize]
  2502 00000DEA EBE1                    	jmp	short lff_3
  2503                                  
  2504                                  ; /////
  2505                                  
  2506                                  ; --------------------------------------------------------
  2507                                  ; --------------------------------------------------------
  2508                                  	
  2509                                  write_audio_dev_info:
  2510                                  	; 30/05/2024
  2511                                       	;sys_msg msgAudioCardInfo, 0Fh
  2512                                  	; 01/12/2024
  2513                                  	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00000DEC BB[F72C0000]        <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00000DF1 B9FF000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00000DF6 BA0F000000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00000DFB B823000000          <1>  mov eax, %1
   104                              <1> 
   105 00000E00 CD40                <1>  int 40h
  2514 00000E02 C3                      	retn
  2515                                  
  2516                                  ; --------------------------------------------------------
  2517                                  
  2518                                  write_ac97_pci_dev_info:
  2519                                  	; 19/11/2024
  2520                                  	; 30/05/2024
  2521                                  	; 06/06/2017
  2522                                  	; 03/06/2017
  2523                                  	; BUS/DEV/FN
  2524                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  2525                                  	; DEV/VENDOR
  2526                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  2527                                  
  2528 00000E03 A1[A0380000]            	mov	eax, [dev_vendor]
  2529 00000E08 31DB                    	xor	ebx, ebx
  2530 00000E0A 88C3                    	mov	bl, al
  2531 00000E0C 88DA                    	mov	dl, bl
  2532 00000E0E 80E30F                  	and	bl, 0Fh
  2533 00000E11 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2534 00000E17 A2[642E0000]            	mov	[msgVendorId+3], al
  2535 00000E1C 88D3                    	mov	bl, dl
  2536 00000E1E C0EB04                  	shr	bl, 4
  2537 00000E21 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2538 00000E27 A2[632E0000]            	mov	[msgVendorId+2], al
  2539 00000E2C 88E3                    	mov	bl, ah
  2540 00000E2E 88DA                    	mov	dl, bl
  2541 00000E30 80E30F                  	and	bl, 0Fh
  2542 00000E33 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2543 00000E39 A2[622E0000]            	mov	[msgVendorId+1], al
  2544 00000E3E 88D3                    	mov	bl, dl
  2545 00000E40 C0EB04                  	shr	bl, 4
  2546 00000E43 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2547 00000E49 A2[612E0000]            	mov	[msgVendorId], al
  2548 00000E4E C1E810                  	shr	eax, 16
  2549 00000E51 88C3                    	mov	bl, al
  2550 00000E53 88DA                    	mov	dl, bl
  2551 00000E55 80E30F                  	and	bl, 0Fh
  2552 00000E58 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2553 00000E5E A2[752E0000]            	mov	[msgDevId+3], al
  2554 00000E63 88D3                    	mov	bl, dl
  2555 00000E65 C0EB04                  	shr	bl, 4
  2556 00000E68 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2557 00000E6E A2[742E0000]            	mov	[msgDevId+2], al
  2558 00000E73 88E3                    	mov	bl, ah
  2559 00000E75 88DA                    	mov	dl, bl
  2560 00000E77 80E30F                  	and	bl, 0Fh
  2561 00000E7A 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2562 00000E80 A2[732E0000]            	mov	[msgDevId+1], al
  2563 00000E85 88D3                    	mov	bl, dl
  2564 00000E87 C0EB04                  	shr	bl, 4
  2565 00000E8A 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2566 00000E90 A2[722E0000]            	mov	[msgDevId], al
  2567                                  
  2568 00000E95 A1[9C380000]            	mov	eax, [bus_dev_fn]
  2569 00000E9A C1E808                  	shr	eax, 8
  2570 00000E9D 88C3                    	mov	bl, al
  2571 00000E9F 88DA                    	mov	dl, bl
  2572 00000EA1 80E307                  	and	bl, 7 ; bit 0,1,2
  2573 00000EA4 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2574 00000EAA A2[9A2E0000]            	mov	[msgFncNo+1], al
  2575 00000EAF 88D3                    	mov	bl, dl
  2576 00000EB1 C0EB03                  	shr	bl, 3
  2577 00000EB4 88DA                    	mov	dl, bl
  2578 00000EB6 80E30F                  	and	bl, 0Fh
  2579 00000EB9 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2580 00000EBF A2[8C2E0000]            	mov	[msgDevNo+1], al
  2581 00000EC4 88D3                    	mov	bl, dl
  2582 00000EC6 C0EB04                  	shr	bl, 4
  2583 00000EC9 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2584 00000ECF A2[8B2E0000]            	mov	[msgDevNo], al
  2585 00000ED4 88E3                    	mov	bl, ah
  2586 00000ED6 88DA                    	mov	dl, bl
  2587 00000ED8 80E30F                  	and	bl, 0Fh
  2588 00000EDB 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2589 00000EE1 A2[802E0000]            	mov	[msgBusNo+1], al
  2590 00000EE6 88D3                    	mov	bl, dl
  2591 00000EE8 C0EB04                  	shr	bl, 4
  2592 00000EEB 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2593 00000EF1 A2[7F2E0000]            	mov	[msgBusNo], al
  2594                                  
  2595                                  	;mov	ax, [ac97_NamBar]
  2596 00000EF6 66A1[A4380000]          	mov	ax, [NAMBAR]
  2597 00000EFC 88C3                    	mov	bl, al
  2598 00000EFE 88DA                    	mov	dl, bl
  2599 00000F00 80E30F                  	and	bl, 0Fh
  2600 00000F03 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2601 00000F09 A2[AA2E0000]            	mov	[msgNamBar+3], al
  2602 00000F0E 88D3                    	mov	bl, dl
  2603 00000F10 C0EB04                  	shr	bl, 4
  2604 00000F13 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2605 00000F19 A2[A92E0000]            	mov	[msgNamBar+2], al
  2606 00000F1E 88E3                    	mov	bl, ah
  2607 00000F20 88DA                    	mov	dl, bl
  2608 00000F22 80E30F                  	and	bl, 0Fh
  2609 00000F25 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2610 00000F2B A2[A82E0000]            	mov	[msgNamBar+1], al
  2611 00000F30 88D3                    	mov	bl, dl
  2612 00000F32 C0EB04                  	shr	bl, 4
  2613 00000F35 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2614 00000F3B A2[A72E0000]            	mov	[msgNamBar], al
  2615                                  
  2616                                  	;mov	ax, [ac97_NabmBar]
  2617 00000F40 66A1[A6380000]          	mov	ax, [NABMBAR]
  2618 00000F46 88C3                    	mov	bl, al
  2619 00000F48 88DA                    	mov	dl, bl
  2620 00000F4A 80E30F                  	and	bl, 0Fh
  2621 00000F4D 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2622 00000F53 A2[BA2E0000]            	mov	[msgNabmBar+3], al
  2623 00000F58 88D3                    	mov	bl, dl
  2624 00000F5A C0EB04                  	shr	bl, 4
  2625 00000F5D 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2626 00000F63 A2[B92E0000]            	mov	[msgNabmBar+2], al
  2627 00000F68 88E3                    	mov	bl, ah
  2628 00000F6A 88DA                    	mov	dl, bl
  2629 00000F6C 80E30F                  	and	bl, 0Fh
  2630 00000F6F 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2631 00000F75 A2[B82E0000]            	mov	[msgNabmBar+1], al
  2632 00000F7A 88D3                    	mov	bl, dl
  2633 00000F7C C0EB04                  	shr	bl, 4
  2634 00000F7F 8A83[1D2E0000]          	mov	al, [hex_chars+ebx]
  2635 00000F85 A2[B72E0000]            	mov	[msgNabmBar], al
  2636                                  
  2637 00000F8A 31C0                    	xor	eax, eax
  2638 00000F8C A0[37380000]            	mov	al, [ac97_int_ln_reg]
  2639 00000F91 B10A                    	mov	cl, 10
  2640 00000F93 F6F1                    	div	cl
  2641                                  	; 23/11/2024
  2642                                  	;add	[msgIRQ], ax
  2643 00000F95 66053030                	add	ax, 3030h
  2644 00000F99 66A3[C32E0000]          	mov	[msgIRQ], ax
  2645                                  	;and	al, al
  2646 00000F9F 3C30                    	cmp	al, 30h
  2647 00000FA1 750D                    	jnz	short _w_ac97imsg_
  2648 00000FA3 A0[C42E0000]            	mov	al, byte [msgIRQ+1]
  2649 00000FA8 B420                    	mov	ah, ' '
  2650 00000FAA 66A3[C32E0000]          	mov	[msgIRQ], ax
  2651                                  _w_ac97imsg_:
  2652                                  	; 19/11/2024
  2653 00000FB0 E88B1C0000              	call 	clear_window
  2654                                  	;mov	dh, 13
  2655                                  	; 30/12/2024 (video mode 13h)
  2656 00000FB5 B60B                    	mov	dh, 11
  2657 00000FB7 B200                    	mov	dl, 0
  2658 00000FB9 E8A7190000              	call	setCursorPosition
  2659                                  	;;;
  2660                                  	; 21/12/2024
  2661 00000FBE BD[2E2E0000]            	mov	ebp, msgAC97Info ; message
  2662                                  	; 22/12/2024
  2663                                  	;mov	cl, 07h ; color 
  2664 00000FC3 E81F000000              	call	sys_gmsg
  2665                                  	;
  2666                                  	; 30/05/2024
  2667                                  write_VRA_info:
  2668                                  	; 21/12/2024
  2669 00000FC8 BD[C82E0000]            	mov	ebp, msgVRAheader ; message
  2670                                  	;mov	cl, 07h ; color 
  2671 00000FCD E815000000              	call	sys_gmsg
  2672                                  	;
  2673 00000FD2 803D[05380000]00        	cmp	byte [VRA], 0
  2674 00000FD9 7607                    	jna	short _w_VRAi_no
  2675                                  _w_VRAi_yes:
  2676 00000FDB BD[D72E0000]            	mov	ebp, msgVRAyes
  2677 00000FE0 EB05                    	jmp	short _w_VRAi_yn_msg
  2678                                  _w_VRAi_no:
  2679 00000FE2 BD[DD2E0000]            	mov	ebp, msgVRAno
  2680                                  _w_VRAi_yn_msg:
  2681                                  	;mov	cl, 07h ; color 
  2682                                  	;call	sys_msg
  2683                                  	;retn
  2684                                  	;jmp	short sys_gmsg
  2685                                  	;;;
  2686                                  ; --------------------------------------------------------
  2687                                  
  2688                                  	; 30/12/2024 (Video Mode 13h)
  2689                                  	; (write message in VGA/CGA mode)
  2690                                  	; 22/12/2024
  2691                                  	; 21/12/2024
  2692                                  	; (write message in VGA/VESA-VBE mode)
  2693                                  sys_gmsg:
  2694 00000FE7 8A4500                  	mov	al, [ebp]
  2695 00000FEA 20C0                    	and	al, al
  2696 00000FEC 7458                    	jz	short sys_gmsg_ok
  2697 00000FEE 3C20                    	cmp	al, 20h
  2698 00000FF0 731E                    	jnb	short sys_gmsg_3
  2699 00000FF2 3C0D                    	cmp	al, CR ; 13
  2700 00000FF4 750C                    	jne	short sys_gmsg_2
  2701                                  	; carriege return, move cursor to column 0
  2702 00000FF6 66C705[E8320000]00-     	mov	word [screenpos], 0
  2702 00000FFE 00                 
  2703                                  sys_gmsg_1:
  2704 00000FFF 45                      	inc	ebp
  2705 00001000 EBE5                    	jmp	short sys_gmsg
  2706                                  sys_gmsg_2:
  2707 00001002 3C0A                    	cmp	al, LF ; 10
  2708 00001004 7540                    	jne	short sys_gmsg_ok ; 22/12/2024
  2709                                  	; line feed, move cursor to next row
  2710                                  	;add	word [screenpos+2], 16
  2711                                  	; 30/12/2024
  2712 00001006 668305[EA320000]08      	add	word [screenpos+2], 8
  2713 0000100E EBEF                    	jmp	short sys_gmsg_1
  2714                                  sys_gmsg_3:
  2715 00001010 8B35[E8320000]          	mov	esi, [screenpos]
  2716                                  		; hw = (cursor) row
  2717                                  		; si = (cursor) column
  2718 00001016 B907000000              	mov	ecx, 07h ; gray (light)
  2719 0000101B E8FF1A0000              	call	write_character
  2720 00001020 83C608                  	add	esi, 8
  2721                                  	;;;
  2722                                  	;cmp	si, 640
  2723                                  	; 30/12/2024 (cgaplay.s)
  2724 00001023 6681FE4001              	cmp	si, 320
  2725 00001028 7213                    	jb	short sys_gmsg_5
  2726 0000102A C1EE10                  	shr	esi, 16
  2727                                  	;add	si, 16
  2728                                  	;cmp	si, 480
  2729                                  	; 30/12/2024
  2730 0000102D 6683C608                	add	si, 8
  2731 00001031 6681FEC800              	cmp	si, 200
  2732 00001036 7202                    	jb	short sys_gmsg_4
  2733 00001038 31F6                    	xor	esi, esi
  2734                                  sys_gmsg_4:
  2735 0000103A C1E610                  	shl	esi, 16
  2736                                  	;;;
  2737                                  sys_gmsg_5:
  2738 0000103D 8935[E8320000]          	mov	[screenpos], esi
  2739 00001043 45                      	inc	ebp
  2740 00001044 EBA1                    	jmp	short sys_gmsg
  2741                                  sys_gmsg_ok:
  2742 00001046 C3                      	retn
  2743                                  	;;;
  2744                                  
  2745                                  ; --------------------------------------------------------
  2746                                  
  2747                                  ; 29/12/2024 - vgaplay3.s
  2748                                  ; 18/12/2024
  2749                                  ; 01/12/2024 - ac97play.s
  2750                                  ; 29/05/2024
  2751                                  ; 26/11/2023
  2752                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  2753                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  2754                                  ; 14/11/2023
  2755                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  2756                                  ; --------------------------------------------------------
  2757                                  
  2758                                  ;;Note:	At the end of every buffer load,
  2759                                  ;;	during buffer switch/swap, there will be discontinuity
  2760                                  ;;	between the last converted sample and the 1st sample
  2761                                  ;;	of the next buffer.
  2762                                  ;;	(like as a dot noises vaguely between normal sound samples)
  2763                                  ;;	-To avoid this defect, the 1st sample of
  2764                                  ;;	the next buffer may be read from the wav file but
  2765                                  ;;	the file pointer would need to be set to 1 sample back
  2766                                  ;;	again via seek system call. Time comsumption problem! -
  2767                                  ;;
  2768                                  ;;	Erdogan Tan - 15/11/2023
  2769                                  ;;
  2770                                  ;;	((If entire wav data would be loaded at once.. conversion
  2771                                  ;;	defect/noise would disappear.. but for DOS, to keep
  2772                                  ;;	64KB buffer limit is important also it is important
  2773                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  2774                                  ;;	I have tested this program by using 2-30MB wav files.))
  2775                                  ;;
  2776                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  2777                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  2778                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  2779                                  ;;			Realtek ALC850 codec.
  2780                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  2781                                  
  2782                                  load_8khz_mono_8_bit:
  2783                                  	; 15/11/2023
  2784                                  	; 14/11/2023
  2785                                  	; 13/11/2023
  2786 00001047 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2787                                  					; last of the file?
  2788 0000104E 7402                    	jz	short lff8m_0		; no
  2789 00001050 F9                      	stc
  2790 00001051 C3                      	retn
  2791                                  
  2792                                  lff8m_0:
  2793                                  	; 01/12/2024
  2794                                  	; edi = audio buffer address
  2795                                  	; 13/12/2024
  2796 00001052 893D[F4320000]          	mov	[audio_buffer], edi
  2797 00001058 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2798                                          ;mov	edx, [loadsize]
  2799                                  
  2800                                  	; esi = buffer address
  2801                                  	;; edx = buffer size
  2802                                  
  2803                                  	; load file into memory
  2804                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000105D 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001063 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001065 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000106B B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001070 CD40                <1>  int 40h
  2805 00001072 7305                    	jnc	short lff8m_6
  2806 00001074 E9B3000000              	jmp	lff8m_5  ; error !
  2807                                  
  2808                                  lff8m_6:
  2809                                  	; 01/12/2024
  2810 00001079 A3[BC380000]            	mov	[count], eax
  2811                                  	;mov	edi, audio_buffer
  2812                                  	; 29/05/2024
  2813 0000107E 8B3D[F4320000]          	mov	edi, [audio_buffer]
  2814                                  	;and	eax, eax
  2815 00001084 0F8499000000            	jz	lff8_eof
  2816                                  
  2817 0000108A 89C1                    	mov	ecx, eax		; byte count
  2818                                  lff8m_1:
  2819 0000108C AC                      	lodsb
  2820 0000108D A2[3C270000]            	mov	[previous_val], al
  2821 00001092 2C80                    	sub	al, 80h
  2822 00001094 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2823 00001098 66AB                    	stosw		; original sample (left channel)
  2824 0000109A 66AB                    	stosw		; original sample (right channel)
  2825                                  	;xor	eax, eax
  2826 0000109C B080                    	mov	al, 80h
  2827 0000109E 49                      	dec	ecx
  2828 0000109F 7402                    	jz	short lff8m_2
  2829 000010A1 8A06                    	mov	al, [esi]
  2830                                  lff8m_2:
  2831                                  	;mov	[next_val], ax
  2832 000010A3 88C7                    	mov	bh, al	; [next_val]
  2833 000010A5 8A25[3C270000]          	mov	ah, [previous_val]
  2834 000010AB 00E0                    	add	al, ah	; [previous_val]
  2835 000010AD D0D8                    	rcr	al, 1
  2836 000010AF 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  2837 000010B1 00E0                    	add	al, ah	; [previous_val]
  2838 000010B3 D0D8                    	rcr	al, 1	
  2839 000010B5 88C3                    	mov	bl, al 	; this is temporary interpolation value
  2840 000010B7 00E0                    	add	al, ah	; [previous_val]
  2841 000010B9 D0D8                    	rcr	al, 1
  2842 000010BB 2C80                    	sub	al, 80h
  2843 000010BD 66C1E008                	shl	ax, 8	
  2844 000010C1 66AB                    	stosw		; this is 1st interpolated sample (L)
  2845 000010C3 66AB                    	stosw		; this is 1st interpolated sample (R)
  2846 000010C5 88D8                    	mov	al, bl
  2847 000010C7 00D0                    	add	al, dl
  2848 000010C9 D0D8                    	rcr	al, 1
  2849 000010CB 2C80                    	sub	al, 80h
  2850 000010CD 66C1E008                	shl	ax, 8
  2851 000010D1 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2852 000010D3 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2853 000010D5 88D0                    	mov	al, dl
  2854 000010D7 2C80                    	sub	al, 80h
  2855 000010D9 66C1E008                	shl	ax, 8
  2856 000010DD 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  2857 000010DF 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  2858                                  	;mov	al, [next_val]
  2859 000010E1 88F8                    	mov	al, bh
  2860 000010E3 00D0                    	add	al, dl
  2861 000010E5 D0D8                    	rcr	al, 1
  2862 000010E7 88C3                    	mov	bl, al	; this is temporary interpolation value
  2863 000010E9 00D0                    	add	al, dl
  2864 000010EB D0D8                    	rcr	al, 1
  2865 000010ED 2C80                    	sub	al, 80h
  2866 000010EF 66C1E008                	shl	ax, 8
  2867 000010F3 66AB                    	stosw		; this is 4th interpolated sample (L)
  2868 000010F5 66AB                    	stosw		; this is 4th interpolated sample (R)
  2869                                  	;mov	al, [next_val]
  2870 000010F7 88F8                    	mov	al, bh
  2871 000010F9 00D8                    	add	al, bl
  2872 000010FB D0D8                    	rcr	al, 1
  2873 000010FD 2C80                    	sub	al, 80h
  2874 000010FF 66C1E008                	shl	ax, 8
  2875 00001103 66AB                    	stosw		; this is 5th interpolated sample (L)
  2876 00001105 66AB                    	stosw		; this is 5th interpolated sample (R)
  2877                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2878 00001107 09C9                    	or	ecx, ecx
  2879 00001109 7581                    	jnz	short lff8m_1
  2880                                  
  2881                                  	; --------------
  2882                                  
  2883                                  lff8s_3:
  2884                                  lff8m_3:
  2885                                  lff8s2_3:
  2886                                  lff8m2_3:
  2887                                  lff16s_3:
  2888                                  lff16m_3:
  2889                                  lff16s2_3:
  2890                                  lff16m2_3:
  2891                                  lff24_3:
  2892                                  lff32_3:
  2893                                  lff44_3:
  2894                                  lff22_3:
  2895                                  lff11_3:
  2896                                  	; 08/12/2024 (BugFix)
  2897                                  	; 31/05/2024
  2898 0000110B 8B0D[B0380000]          	mov	ecx, [buffersize] ; buffer size in words
  2899                                  	; 29/12/2024
  2900                                  	; 08/12/2024
  2901                                  	;shl	ecx, 1 ; buffer size in bytes
  2902                                  	; 13/12/2024
  2903 00001111 030D[F4320000]          	add	ecx, [audio_buffer] ; + start address of the buffer
  2904 00001117 29F9                    	sub	ecx, edi
  2905 00001119 7607                    	jna	short lff8m_4
  2906                                  	;inc	ecx
  2907 0000111B C1E902                  	shr	ecx, 2
  2908 0000111E 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros
  2909 00001120 F3AB                    	rep	stosd
  2910                                  lff8m_4:
  2911                                  	; 31/05/2024
  2912                                  	; cf=1
  2913                                  	; 08/12/2024
  2914                                  	;clc
  2915 00001122 C3                      	retn
  2916                                  
  2917                                  lff8_eof:
  2918                                  lff16_eof:
  2919                                  lff24_eof:
  2920                                  lff32_eof:
  2921                                  lff44_eof:
  2922                                  lff22_eof:
  2923                                  lff11_eof:
  2924                                  	; 15/11/2023
  2925 00001123 C605[36380000]01        	mov	byte [flags], ENDOFFILE
  2926 0000112A EBDF                    	jmp	short lff8m_3
  2927                                  
  2928                                  lff8s_5:
  2929                                  lff8m_5:
  2930                                  lff8s2_5:
  2931                                  lff8m2_5:
  2932                                  lff16s_5:
  2933                                  lff16m_5:
  2934                                  lff16s2_5:
  2935                                  lff16m2_5:
  2936                                  lff24_5:
  2937                                  lff32_5:
  2938                                  lff44_5:
  2939                                  lff22_5:
  2940                                  lff11_5:
  2941 0000112C B021                    	mov	al, '!'  ; error
  2942 0000112E E831F6FFFF              	call	tL0
  2943                                  	
  2944                                  	;jmp	short lff8m_3
  2945                                  	; 15/11/2023
  2946 00001133 EBEE                    	jmp	lff8_eof
  2947                                  
  2948                                  	; --------------
  2949                                  
  2950                                  load_8khz_stereo_8_bit:
  2951                                  	; 15/11/2023
  2952                                  	; 14/11/2023
  2953                                  	; 13/11/2023
  2954 00001135 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2955                                  					; last of the file?
  2956 0000113C 7402                    	jz	short lff8s_0		; no
  2957 0000113E F9                      	stc
  2958 0000113F C3                      	retn
  2959                                  
  2960                                  lff8s_0:
  2961                                  	; 01/12/2024
  2962                                  	; edi = audio buffer address
  2963                                  	; 13/12/2024
  2964 00001140 893D[F4320000]          	mov	[audio_buffer], edi
  2965 00001146 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2966                                          ;mov	edx, [loadsize]
  2967                                  
  2968                                  	; esi = buffer address
  2969                                  	;; edx = buffer size
  2970                                  
  2971                                  	; load file into memory
  2972                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000114B 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001151 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001153 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001159 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 0000115E CD40                <1>  int 40h
  2973 00001160 72CA                    	jc	short lff8s_5 ; error !
  2974                                  
  2975                                  	; 01/12/2024
  2976 00001162 A3[BC380000]            	mov	[count], eax
  2977                                  
  2978                                  	;mov	edi, audio_buffer
  2979                                  	; 29/05/2024
  2980                                  	;mov	edi, [audio_buffer]
  2981                                  	
  2982 00001167 D1E8                    	shr	eax, 1
  2983 00001169 74B8                    	jz	short lff8_eof
  2984                                  
  2985 0000116B 89C1                    	mov	ecx, eax	; word count
  2986                                  lff8s_1:
  2987 0000116D AC                      	lodsb
  2988 0000116E A2[3C270000]            	mov	[previous_val_l], al
  2989 00001173 2C80                    	sub	al, 80h
  2990 00001175 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2991 00001179 66AB                    	stosw		; original sample (L)
  2992 0000117B AC                      	lodsb
  2993 0000117C A2[3E270000]            	mov	[previous_val_r], al
  2994 00001181 2C80                    	sub	al, 80h
  2995 00001183 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2996 00001187 66AB                    	stosw		; original sample (R)
  2997                                  
  2998                                  	;xor	eax, eax
  2999 00001189 66B88080                	mov	ax, 8080h
  3000 0000118D 49                      	dec	ecx
  3001 0000118E 7403                    	jz	short lff8s_2
  3002                                  		; convert 8 bit sample to 16 bit sample
  3003 00001190 668B06                  	mov	ax, [esi]
  3004                                  lff8s_2:
  3005 00001193 A2[40270000]            	mov	[next_val_l], al
  3006 00001198 8825[42270000]          	mov	[next_val_r], ah
  3007 0000119E 8A25[3C270000]          	mov	ah, [previous_val_l]
  3008 000011A4 00E0                    	add	al, ah
  3009 000011A6 D0D8                    	rcr	al, 1
  3010 000011A8 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  3011 000011AA 00E0                    	add	al, ah
  3012 000011AC D0D8                    	rcr	al, 1
  3013 000011AE 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  3014 000011B0 00E0                    	add	al, ah
  3015 000011B2 D0D8                    	rcr	al, 1
  3016 000011B4 2C80                    	sub	al, 80h
  3017 000011B6 66C1E008                	shl	ax, 8
  3018 000011BA 66AB                    	stosw		; this is 1st interpolated sample (L)
  3019 000011BC A0[42270000]            	mov	al, [next_val_r]
  3020 000011C1 8A25[3E270000]          	mov	ah, [previous_val_r]
  3021 000011C7 00E0                    	add	al, ah
  3022 000011C9 D0D8                    	rcr	al, 1
  3023 000011CB 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  3024 000011CD 00E0                    	add	al, ah
  3025 000011CF D0D8                    	rcr	al, 1
  3026 000011D1 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  3027 000011D3 00E0                    	add	al, ah
  3028 000011D5 D0D8                    	rcr	al, 1
  3029 000011D7 2C80                    	sub	al, 80h
  3030 000011D9 66C1E008                	shl	ax, 8
  3031 000011DD 66AB                    	stosw		; this is 1st interpolated sample (R)
  3032 000011DF 88D8                    	mov	al, bl
  3033 000011E1 00D0                    	add	al, dl
  3034 000011E3 D0D8                    	rcr	al, 1
  3035 000011E5 2C80                    	sub	al, 80h
  3036 000011E7 66C1E008                	shl	ax, 8
  3037 000011EB 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3038 000011ED 88F8                    	mov	al, bh
  3039 000011EF 00F0                    	add	al, dh
  3040 000011F1 D0D8                    	rcr	al, 1
  3041 000011F3 2C80                    	sub	al, 80h
  3042 000011F5 66C1E008                	shl	ax, 8
  3043 000011F9 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3044 000011FB 88D0                    	mov	al, dl
  3045 000011FD 2C80                    	sub	al, 80h
  3046 000011FF 66C1E008                	shl	ax, 8
  3047 00001203 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3048 00001205 88F0                    	mov	al, dh
  3049 00001207 2C80                    	sub	al, 80h
  3050 00001209 66C1E008                	shl	ax, 8
  3051 0000120D 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3052 0000120F A0[40270000]            	mov	al, [next_val_l]
  3053 00001214 00D0                    	add	al, dl
  3054 00001216 D0D8                    	rcr	al, 1
  3055 00001218 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  3056 0000121A 00D0                    	add	al, dl
  3057 0000121C D0D8                    	rcr	al, 1
  3058 0000121E 2C80                    	sub	al, 80h
  3059 00001220 66C1E008                	shl	ax, 8
  3060 00001224 66AB                    	stosw		; this is 4th interpolated sample (L)
  3061 00001226 A0[42270000]            	mov	al, [next_val_r]
  3062 0000122B 00F0                    	add	al, dh
  3063 0000122D D0D8                    	rcr	al, 1
  3064 0000122F 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  3065 00001231 00F0                    	add	al, dh
  3066 00001233 D0D8                    	rcr	al, 1
  3067 00001235 2C80                    	sub	al, 80h
  3068 00001237 66C1E008                	shl	ax, 8
  3069 0000123B 66AB                    	stosw		; this is 4th interpolated sample (R)
  3070 0000123D A0[40270000]            	mov	al, [next_val_l]
  3071 00001242 00D8                    	add	al, bl
  3072 00001244 D0D8                    	rcr	al, 1
  3073 00001246 2C80                    	sub	al, 80h
  3074 00001248 66C1E008                	shl	ax, 8
  3075 0000124C 66AB                    	stosw		; this is 5th interpolated sample (L)
  3076 0000124E A0[42270000]            	mov	al, [next_val_r]
  3077 00001253 00F8                    	add	al, bh
  3078 00001255 D0D8                    	rcr	al, 1
  3079 00001257 2C80                    	sub	al, 80h
  3080 00001259 66C1E008                	shl	ax, 8
  3081 0000125D 66AB                    	stosw		; this is 5th interpolated sample (R)
  3082                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3083 0000125F E305                    	jecxz	lff8s_6
  3084 00001261 E907FFFFFF              	jmp	lff8s_1
  3085                                  lff8s_6:
  3086 00001266 E9A0FEFFFF              	jmp	lff8s_3
  3087                                  
  3088                                  load_8khz_mono_16_bit:
  3089                                  	; 13/11/2023
  3090 0000126B F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3091                                  					; last of the file?
  3092 00001272 7402                    	jz	short lff8m2_0		; no
  3093 00001274 F9                      	stc
  3094 00001275 C3                      	retn
  3095                                  
  3096                                  lff8m2_0:
  3097                                  	; 01/12/2024
  3098                                  	; edi = audio buffer address
  3099                                  	; 13/12/2024
  3100 00001276 893D[F4320000]          	mov	[audio_buffer], edi
  3101 0000127C BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3102                                          ;mov	edx, [loadsize]
  3103                                  
  3104                                  	; esi = buffer address
  3105                                  	;; edx = buffer size
  3106                                  
  3107                                  	; load file into memory
  3108                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001281 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001287 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001289 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000128F B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001294 CD40                <1>  int 40h
  3109 00001296 0F82A0000000            	jc	lff8m2_7 ; error !
  3110                                  
  3111                                  	; 01/12/2024
  3112 0000129C A3[BC380000]            	mov	[count], eax
  3113                                  
  3114                                  	;mov	edi, audio_buffer
  3115                                  	; 29/05/2024
  3116                                  	;mov	edi, [audio_buffer]
  3117                                  	
  3118 000012A1 D1E8                    	shr	eax, 1
  3119 000012A3 7505                    	jnz	short lff8m2_8
  3120 000012A5 E979FEFFFF              	jmp	lff8_eof
  3121                                  
  3122                                  lff8m2_8:
  3123 000012AA 89C1                    	mov	ecx, eax	; word count
  3124                                  lff8m2_1:
  3125 000012AC 66AD                    	lodsw
  3126 000012AE 66AB                    	stosw		; original sample (left channel)
  3127 000012B0 66AB                    	stosw		; original sample (right channel)
  3128 000012B2 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3129 000012B5 66A3[3C270000]          	mov	[previous_val], ax
  3130 000012BB 31C0                    	xor	eax, eax
  3131 000012BD 49                      	dec	ecx
  3132 000012BE 7403                    	jz	short lff8m2_2
  3133 000012C0 668B06                  	mov	ax, [esi]
  3134                                  lff8m2_2:
  3135 000012C3 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  3136 000012C6 89C5                    	mov	ebp, eax	; [next_val]
  3137 000012C8 660305[3C270000]        	add	ax, [previous_val]
  3138 000012CF 66D1D8                  	rcr	ax, 1
  3139 000012D2 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  3140 000012D4 660305[3C270000]        	add	ax, [previous_val]
  3141 000012DB 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  3142 000012DE 89C3                    	mov	ebx, eax 		
  3143 000012E0 660305[3C270000]        	add	ax, [previous_val]
  3144 000012E7 66D1D8                  	rcr	ax, 1
  3145 000012EA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3146 000012ED 66AB                    	stosw		; this is 1st interpolated sample (L)
  3147 000012EF 66AB                    	stosw		; this is 1st interpolated sample (R)
  3148 000012F1 89D8                    	mov	eax, ebx
  3149 000012F3 6601D0                  	add	ax, dx
  3150 000012F6 66D1D8                  	rcr	ax, 1
  3151 000012F9 80EC80                  	sub	ah, 80h
  3152 000012FC 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3153 000012FE 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3154 00001300 89D0                    	mov	eax, edx
  3155 00001302 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3156 00001305 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3157 00001307 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3158 00001309 89E8                    	mov	eax, ebp
  3159 0000130B 6601D0                  	add	ax, dx
  3160 0000130E 66D1D8                  	rcr	ax, 1
  3161 00001311 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  3162 00001313 6601D0                  	add	ax, dx
  3163 00001316 66D1D8                  	rcr	ax, 1
  3164 00001319 80EC80                  	sub	ah, 80h
  3165 0000131C 66AB                    	stosw		; this is 4th interpolated sample (L)
  3166 0000131E 66AB                    	stosw		; this is 4th interpolated sample (R)
  3167 00001320 89E8                    	mov	eax, ebp
  3168 00001322 6601D8                  	add	ax, bx
  3169 00001325 66D1D8                  	rcr	ax, 1
  3170 00001328 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3171 0000132B 66AB                    	stosw		; this is 5th interpolated sample (L)
  3172 0000132D 66AB                    	stosw		; this is 5th interpolated sample (R)
  3173                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3174 0000132F 09C9                    	or	ecx, ecx
  3175 00001331 0F8575FFFFFF            	jnz	lff8m2_1
  3176 00001337 E9CFFDFFFF              	jmp	lff8m2_3
  3177                                  
  3178                                  lff8m2_7:
  3179                                  lff8s2_7:
  3180 0000133C E9EBFDFFFF              	jmp	lff8m2_5  ; error
  3181                                  
  3182                                  load_8khz_stereo_16_bit:
  3183                                  	; 16/11/2023
  3184                                  	; 15/11/2023
  3185                                  	; 13/11/2023
  3186 00001341 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3187                                  					; last of the file?
  3188 00001348 7402                    	jz	short lff8s2_0		; no
  3189 0000134A F9                      	stc
  3190 0000134B C3                      	retn
  3191                                  
  3192                                  lff8s2_0:
  3193                                  	; 01/12/2024
  3194                                  	; edi = audio buffer address
  3195                                  	; 13/12/2024
  3196 0000134C 893D[F4320000]          	mov	[audio_buffer], edi
  3197 00001352 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3198                                          ;mov	edx, [loadsize]
  3199                                  
  3200                                  	; esi = buffer address
  3201                                  	;; edx = buffer size
  3202                                  
  3203                                  	; load file into memory
  3204                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001357 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000135D 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000135F 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001365 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 0000136A CD40                <1>  int 40h
  3205 0000136C 72CE                    	jc	short lff8s2_7 ; error !
  3206                                  
  3207                                  	; 01/12/2024
  3208 0000136E A3[BC380000]            	mov	[count], eax
  3209                                  
  3210                                  	;mov	edi, audio_buffer
  3211                                  	; 29/05/2024
  3212                                  	;mov	edi, [audio_buffer]
  3213                                  	
  3214 00001373 C1E802                  	shr	eax, 2
  3215 00001376 7505                    	jnz	short lff8s2_8
  3216 00001378 E9A6FDFFFF              	jmp	lff8_eof
  3217                                  
  3218                                  lff8s2_8:
  3219 0000137D 89C1                    	mov	ecx, eax ; dword count
  3220                                  lff8s2_1:
  3221 0000137F 66AD                    	lodsw
  3222 00001381 66AB                    	stosw		; original sample (L)
  3223                                  	; 15/11/2023
  3224 00001383 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3225 00001386 66A3[3C270000]          	mov	[previous_val_l], ax
  3226 0000138C 66AD                    	lodsw
  3227 0000138E 66AB                    	stosw		; original sample (R)
  3228 00001390 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3229 00001393 66A3[3E270000]          	mov	[previous_val_r], ax
  3230 00001399 31D2                    	xor	edx, edx
  3231 0000139B 31C0                    	xor	eax, eax
  3232                                  	; 16/11/2023
  3233 0000139D 49                      	dec	ecx
  3234 0000139E 7407                    	jz	short lff8s2_2
  3235 000013A0 668B06                  	mov	ax, [esi]
  3236 000013A3 668B5602                	mov	dx, [esi+2]
  3237                                  lff8s2_2:
  3238 000013A7 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3239 000013AA 66A3[40270000]          	mov	[next_val_l], ax
  3240 000013B0 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  3241 000013B3 668915[42270000]        	mov	[next_val_r], dx
  3242 000013BA 660305[3C270000]        	add	ax, [previous_val_l]
  3243 000013C1 66D1D8                  	rcr	ax, 1
  3244 000013C4 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  3245 000013C6 660305[3C270000]        	add	ax, [previous_val_l]
  3246 000013CD 66D1D8                  	rcr	ax, 1	
  3247 000013D0 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  3248 000013D2 660305[3C270000]        	add	ax, [previous_val_l]
  3249 000013D9 66D1D8                  	rcr	ax, 1
  3250 000013DC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3251 000013DF 66AB                    	stosw		; this is 1st interpolated sample (L)
  3252 000013E1 66A1[42270000]          	mov	ax, [next_val_r]
  3253 000013E7 660305[3E270000]        	add	ax, [previous_val_r]
  3254 000013EE 66D1D8                  	rcr	ax, 1
  3255 000013F1 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  3256 000013F3 660305[3E270000]        	add	ax, [previous_val_r]
  3257 000013FA 66D1D8                  	rcr	ax, 1
  3258 000013FD 50                      	push	eax ; *	; this is temporary interpolation value (R)
  3259 000013FE 660305[3E270000]        	add	ax, [previous_val_r]
  3260 00001405 66D1D8                  	rcr	ax, 1
  3261 00001408 80EC80                  	sub	ah, 80h
  3262 0000140B 66AB                    	stosw		; this is 1st interpolated sample (R)
  3263 0000140D 89D8                    	mov	eax, ebx
  3264 0000140F 6601D0                  	add	ax, dx
  3265 00001412 66D1D8                  	rcr	ax, 1
  3266 00001415 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3267 00001418 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3268 0000141A 58                      	pop	eax ; *
  3269 0000141B 6601E8                  	add	ax, bp
  3270 0000141E 66D1D8                  	rcr	ax, 1
  3271 00001421 80EC80                  	sub	ah, 80h
  3272 00001424 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3273 00001426 89D0                    	mov	eax, edx
  3274 00001428 80EC80                  	sub	ah, 80h
  3275 0000142B 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3276 0000142D 89E8                    	mov	eax, ebp
  3277 0000142F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3278 00001432 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3279 00001434 66A1[40270000]          	mov	ax, [next_val_l]
  3280 0000143A 6601D0                  	add	ax, dx
  3281 0000143D 66D1D8                  	rcr	ax, 1
  3282 00001440 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  3283 00001442 6601D0                  	add	ax, dx
  3284 00001445 66D1D8                  	rcr	ax, 1
  3285 00001448 80EC80                  	sub	ah, 80h
  3286 0000144B 66AB                    	stosw		; this is 4th interpolated sample (L)
  3287 0000144D 66A1[42270000]          	mov	ax, [next_val_r]
  3288 00001453 6601E8                  	add	ax, bp
  3289 00001456 66D1D8                  	rcr	ax, 1
  3290 00001459 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  3291 0000145A 6601E8                  	add	ax, bp
  3292 0000145D 66D1D8                  	rcr	ax, 1
  3293 00001460 80EC80                  	sub	ah, 80h
  3294 00001463 66AB                    	stosw		; this is 4th interpolated sample (R)
  3295 00001465 66A1[40270000]          	mov	ax, [next_val_l]
  3296 0000146B 6601D8                  	add	ax, bx
  3297 0000146E 66D1D8                  	rcr	ax, 1
  3298 00001471 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3299 00001474 66AB                    	stosw		; this is 5th interpolated sample (L)
  3300 00001476 58                      	pop	eax ; **
  3301 00001477 660305[42270000]        	add	ax, [next_val_r]
  3302 0000147E 66D1D8                  	rcr	ax, 1
  3303 00001481 80EC80                  	sub	ah, 80h
  3304 00001484 66AB                    	stosw		; this is 5th interpolated sample (R)
  3305                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3306 00001486 E305                    	jecxz	lff8_s2_9
  3307 00001488 E9F2FEFFFF              	jmp	lff8s2_1
  3308                                  lff8_s2_9:
  3309 0000148D E979FCFFFF              	jmp	lff8s2_3
  3310                                  
  3311                                  ; .....................
  3312                                  
  3313                                  load_16khz_mono_8_bit:
  3314                                  	; 14/11/2023
  3315                                  	; 13/11/2023
  3316 00001492 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3317                                  					; last of the file?
  3318 00001499 7402                    	jz	short lff16m_0		; no
  3319 0000149B F9                      	stc
  3320 0000149C C3                      	retn
  3321                                  
  3322                                  lff16m_0:
  3323                                  	; 01/12/2024
  3324                                  	; edi = audio buffer address
  3325                                  	; 13/12/2024
  3326 0000149D 893D[F4320000]          	mov	[audio_buffer], edi
  3327 000014A3 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3328                                          ;mov	edx, [loadsize]
  3329                                  
  3330                                  	; esi = buffer address
  3331                                  	;; edx = buffer size
  3332                                  
  3333                                  	; load file into memory
  3334                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000014A8 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000014AE 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000014B0 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000014B6 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 000014BB CD40                <1>  int 40h
  3335 000014BD 7253                    	jc	short lff16m_7 ; error !
  3336                                  
  3337                                  	; 01/12/2024
  3338 000014BF A3[BC380000]            	mov	[count], eax
  3339                                  
  3340                                  	;mov	edi, audio_buffer
  3341                                  	; 29/05/2024
  3342                                  	;mov	edi, [audio_buffer]
  3343                                  	
  3344 000014C4 21C0                    	and	eax, eax
  3345 000014C6 7505                    	jnz	short lff16m_8
  3346 000014C8 E956FCFFFF              	jmp	lff16_eof
  3347                                  
  3348                                  lff16m_8:
  3349 000014CD 89C1                    	mov	ecx, eax		; byte count
  3350                                  lff16m_1:
  3351 000014CF AC                      	lodsb
  3352                                  	;mov	[previous_val], al
  3353 000014D0 88C3                    	mov	bl, al
  3354 000014D2 2C80                    	sub	al, 80h
  3355 000014D4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3356 000014D8 66AB                    	stosw		; original sample (left channel)
  3357 000014DA 66AB                    	stosw		; original sample (right channel)
  3358                                  	;xor	ax, ax
  3359                                  	; 14/11/22023
  3360 000014DC B080                    	mov	al, 80h
  3361 000014DE 49                      	dec	ecx
  3362 000014DF 7402                    	jz	short lff16m_2
  3363 000014E1 8A06                    	mov	al, [esi]
  3364                                  lff16m_2:
  3365                                  	;mov	[next_val], al
  3366 000014E3 88C7                    	mov	bh, al
  3367                                  	;add	al, [previous_val]
  3368 000014E5 00D8                    	add	al, bl
  3369 000014E7 D0D8                    	rcr	al, 1
  3370 000014E9 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  3371                                  	;add	al, [previous_val]
  3372 000014EB 00D8                    	add	al, bl
  3373 000014ED D0D8                    	rcr	al, 1
  3374 000014EF 2C80                    	sub	al, 80h
  3375 000014F1 66C1E008                	shl	ax, 8
  3376 000014F5 66AB                    	stosw		; this is 1st interpolated sample (L)
  3377 000014F7 66AB                    	stosw		; this is 1st interpolated sample (R)
  3378                                  	;mov	al, [next_val]
  3379 000014F9 88F8                    	mov	al, bh
  3380 000014FB 00D0                    	add	al, dl
  3381 000014FD D0D8                    	rcr	al, 1
  3382 000014FF 2C80                    	sub	al, 80h
  3383 00001501 66C1E008                	shl	ax, 8
  3384 00001505 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3385 00001507 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3386                                  	
  3387                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3388 00001509 09C9                    	or	ecx, ecx
  3389 0000150B 75C2                    	jnz	short lff16m_1
  3390 0000150D E9F9FBFFFF              	jmp	lff16m_3
  3391                                  
  3392                                  lff16m_7:
  3393                                  lff16s_7:
  3394 00001512 E915FCFFFF              	jmp	lff16m_5  ; error
  3395                                  
  3396                                  load_16khz_stereo_8_bit:
  3397                                  	; 14/11/2023
  3398                                  	; 13/11/2023
  3399 00001517 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3400                                  					; last of the file?
  3401 0000151E 7402                    	jz	short lff16s_0		; no
  3402 00001520 F9                      	stc
  3403 00001521 C3                      	retn
  3404                                  
  3405                                  lff16s_0:
  3406                                  	; 01/12/2024
  3407                                  	; edi = audio buffer address
  3408                                  	; 13/12/2024
  3409 00001522 893D[F4320000]          	mov	[audio_buffer], edi
  3410 00001528 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3411                                          ;mov	edx, [loadsize]
  3412                                  
  3413                                  	; esi = buffer address
  3414                                  	;; edx = buffer size
  3415                                  
  3416                                  	; load file into memory
  3417                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000152D 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001533 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001535 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000153B B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001540 CD40                <1>  int 40h
  3418 00001542 72CE                    	jc	short lff16s_7 ; error !
  3419                                  
  3420                                  	; 01/12/2024
  3421 00001544 A3[BC380000]            	mov	[count], eax
  3422                                  
  3423                                  	;mov	edi, audio_buffer
  3424                                  	; 29/05/2024
  3425                                  	;mov	edi, [audio_buffer]
  3426                                  	
  3427 00001549 D1E8                    	shr	eax, 1
  3428 0000154B 7505                    	jnz	short lff16s_8
  3429 0000154D E9D1FBFFFF              	jmp	lff16_eof
  3430                                  
  3431                                  lff16s_8:
  3432 00001552 89C1                    	mov	ecx, eax	; word count
  3433                                  lff16s_1:
  3434 00001554 AC                      	lodsb
  3435 00001555 A2[3C270000]            	mov	[previous_val_l], al
  3436 0000155A 2C80                    	sub	al, 80h
  3437 0000155C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3438 00001560 66AB                    	stosw		; original sample (L)
  3439 00001562 AC                      	lodsb
  3440 00001563 A2[3E270000]            	mov	[previous_val_r], al
  3441 00001568 2C80                    	sub	al, 80h
  3442 0000156A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3443 0000156E 66AB                    	stosw		; original sample (R)
  3444                                  
  3445                                  	;xor	eax, eax
  3446 00001570 66B88080                	mov	ax, 8080h
  3447 00001574 49                      	dec	ecx
  3448 00001575 7403                    	jz	short lff16s_2
  3449                                  		; convert 8 bit sample to 16 bit sample
  3450 00001577 668B06                  	mov	ax, [esi]
  3451                                  lff16s_2:
  3452                                  	;mov	[next_val_l], al
  3453                                  	;mov	[next_val_r], ah
  3454 0000157A 89C3                    	mov	ebx, eax
  3455 0000157C 0205[3C270000]          	add	al, [previous_val_l]
  3456 00001582 D0D8                    	rcr	al, 1
  3457 00001584 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  3458 00001586 0205[3C270000]          	add	al, [previous_val_l]
  3459 0000158C D0D8                    	rcr	al, 1
  3460 0000158E 2C80                    	sub	al, 80h
  3461 00001590 66C1E008                	shl	ax, 8
  3462 00001594 66AB                    	stosw		; this is 1st interpolated sample (L)
  3463 00001596 88F8                    	mov	al, bh	; [next_val_r]
  3464 00001598 0205[3E270000]          	add	al, [previous_val_r]
  3465 0000159E D0D8                    	rcr	al, 1
  3466 000015A0 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  3467 000015A2 0205[3E270000]          	add	al, [previous_val_r]
  3468 000015A8 D0D8                    	rcr	al, 1
  3469 000015AA 2C80                    	sub	al, 80h
  3470 000015AC 66C1E008                	shl	ax, 8
  3471 000015B0 66AB                    	stosw		; this is 1st interpolated sample (R)
  3472 000015B2 88D0                    	mov	al, dl
  3473 000015B4 00D8                    	add	al, bl	; [next_val_l]
  3474 000015B6 D0D8                    	rcr	al, 1
  3475 000015B8 2C80                    	sub	al, 80h
  3476 000015BA 66C1E008                	shl	ax, 8
  3477 000015BE 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3478 000015C0 88F0                    	mov	al, dh
  3479 000015C2 00F8                    	add	al, bh	; [next_val_r]
  3480 000015C4 D0D8                    	rcr	al, 1
  3481 000015C6 2C80                    	sub	al, 80h
  3482 000015C8 66C1E008                	shl	ax, 8
  3483 000015CC 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3484                                  	
  3485                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3486 000015CE 09C9                    	or	ecx, ecx
  3487 000015D0 7582                    	jnz	short lff16s_1
  3488 000015D2 E934FBFFFF              	jmp	lff16s_3
  3489                                  
  3490                                  load_16khz_mono_16_bit:
  3491                                  	; 15/11/2023
  3492                                  	; 13/11/2023
  3493 000015D7 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3494                                  					; last of the file?
  3495 000015DE 7402                    	jz	short lff16m2_0		; no
  3496 000015E0 F9                      	stc
  3497 000015E1 C3                      	retn
  3498                                  
  3499                                  lff16m2_0:
  3500                                  	; 01/12/2024
  3501                                  	; edi = audio buffer address
  3502                                  	; 13/12/2024
  3503 000015E2 893D[F4320000]          	mov	[audio_buffer], edi
  3504 000015E8 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3505                                          ;mov	edx, [loadsize]
  3506                                  
  3507                                  	; esi = buffer address
  3508                                  	;; edx = buffer size
  3509                                  
  3510                                  	; load file into memory
  3511                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000015ED 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000015F3 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000015F5 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000015FB B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001600 CD40                <1>  int 40h
  3512 00001602 7255                    	jc	short lff16m2_7 ; error !
  3513                                  
  3514                                  	; 01/12/2024
  3515 00001604 A3[BC380000]            	mov	[count], eax
  3516                                  
  3517                                  	;mov	edi, audio_buffer
  3518                                  	; 29/05/2024
  3519                                  	;mov	edi, [audio_buffer]
  3520                                  	
  3521 00001609 D1E8                    	shr	eax, 1
  3522 0000160B 7505                    	jnz	short lff16m2_8
  3523 0000160D E911FBFFFF              	jmp	lff16_eof
  3524                                  
  3525                                  lff16m2_8:
  3526 00001612 89C1                    	mov	ecx, eax  ; word count
  3527                                  lff16m2_1:
  3528 00001614 66AD                    	lodsw
  3529 00001616 66AB                    	stosw		; original sample (left channel)
  3530 00001618 66AB                    	stosw		; original sample (right channel)
  3531 0000161A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3532                                  	;mov	[previous_val], ax
  3533 0000161D 89C3                    	mov	ebx, eax
  3534 0000161F 31C0                    	xor	eax, eax
  3535 00001621 49                      	dec	ecx
  3536 00001622 7403                    	jz	short lff16m2_2
  3537 00001624 668B06                  	mov	ax, [esi]
  3538                                  lff16m2_2:
  3539 00001627 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3540 0000162A 89C5                    	mov	ebp, eax	; [next_val]
  3541                                  	;add	ax, [previous_val]
  3542 0000162C 6601D8                  	add	ax, bx
  3543 0000162F 66D1D8                  	rcr	ax, 1
  3544 00001632 89C2                    	mov	edx, eax ; this is temporary interpolation value
  3545                                  	;add	ax, [previous_val]
  3546 00001634 6601D8                  	add	ax, bx
  3547 00001637 66D1D8                  	rcr	ax, 1
  3548 0000163A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3549 0000163D 66AB                    	stosw		; this is 1st interpolated sample (L)
  3550 0000163F 66AB                    	stosw		; this is 1st interpolated sample (R)
  3551 00001641 89E8                    	mov	eax, ebp
  3552 00001643 6601D0                  	add	ax, dx
  3553 00001646 66D1D8                  	rcr	ax, 1
  3554 00001649 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3555 0000164C 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3556 0000164E 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3557                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3558 00001650 09C9                    	or	ecx, ecx
  3559 00001652 75C0                    	jnz	short lff16m2_1
  3560 00001654 E9B2FAFFFF              	jmp	lff16m2_3
  3561                                  
  3562                                  lff16m2_7:
  3563                                  lff16s2_7:
  3564 00001659 E9CEFAFFFF              	jmp	lff16m2_5  ; error
  3565                                  
  3566                                  load_16khz_stereo_16_bit:
  3567                                  	; 16/11/2023
  3568                                  	; 15/11/2023
  3569                                  	; 13/11/2023
  3570 0000165E F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3571                                  					; last of the file?
  3572 00001665 7402                    	jz	short lff16s2_0		; no
  3573 00001667 F9                      	stc
  3574 00001668 C3                      	retn
  3575                                  
  3576                                  lff16s2_0:
  3577                                  	; 01/12/2024
  3578                                  	; edi = audio buffer address
  3579                                  	; 13/12/2024
  3580 00001669 893D[F4320000]          	mov	[audio_buffer], edi
  3581 0000166F BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3582                                          ;mov	edx, [loadsize]
  3583                                  
  3584                                  	; esi = buffer address
  3585                                  	;; edx = buffer size
  3586                                  
  3587                                  	; load file into memory
  3588                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001674 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000167A 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000167C 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001682 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001687 CD40                <1>  int 40h
  3589 00001689 72CE                    	jc	short lff16s2_7 ; error !
  3590                                  
  3591                                  	; 01/12/2024
  3592 0000168B A3[BC380000]            	mov	[count], eax
  3593                                  
  3594                                  	;mov	edi, audio_buffer
  3595                                  	; 29/05/2024
  3596                                  	;mov	edi, [audio_buffer]
  3597                                  	
  3598 00001690 C1E802                  	shr	eax, 2
  3599 00001693 7505                    	jnz	short lff16s2_8
  3600 00001695 E989FAFFFF              	jmp	lff16_eof
  3601                                  
  3602                                  lff16s2_8:
  3603 0000169A 89C1                    	mov	ecx, eax  ; dword count
  3604                                  lff16s2_1:
  3605 0000169C 66AD                    	lodsw
  3606 0000169E 66AB                    	stosw		; original sample (L)
  3607 000016A0 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3608 000016A3 66A3[3C270000]          	mov	[previous_val_l], ax
  3609 000016A9 66AD                    	lodsw
  3610 000016AB 66AB                    	stosw		; original sample (R)
  3611 000016AD 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3612 000016B0 66A3[3E270000]          	mov	[previous_val_r], ax
  3613 000016B6 31D2                    	xor	edx, edx
  3614 000016B8 31C0                    	xor	eax, eax
  3615                                  	; 16/11/2023
  3616 000016BA 49                      	dec	ecx
  3617 000016BB 7407                    	jz	short lff16s2_2
  3618 000016BD 668B06                  	mov	ax, [esi]
  3619 000016C0 668B5602                	mov	dx, [esi+2]
  3620                                  lff16s2_2:
  3621 000016C4 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3622                                  	;mov	[next_val_l], ax
  3623 000016C7 89C5                    	mov	ebp, eax
  3624 000016C9 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  3625 000016CC 668915[42270000]        	mov	[next_val_r], dx
  3626 000016D3 660305[3C270000]        	add	ax, [previous_val_l]
  3627 000016DA 66D1D8                  	rcr	ax, 1
  3628 000016DD 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  3629 000016DF 660305[3C270000]        	add	ax, [previous_val_l]
  3630 000016E6 66D1D8                  	rcr	ax, 1
  3631 000016E9 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3632 000016EC 66AB                    	stosw		; this is 1st interpolated sample (L)
  3633 000016EE 66A1[42270000]          	mov	ax, [next_val_r]
  3634 000016F4 660305[3E270000]        	add	ax, [previous_val_r]
  3635 000016FB 66D1D8                  	rcr	ax, 1
  3636 000016FE 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  3637 00001700 660305[3E270000]        	add	ax, [previous_val_r]
  3638 00001707 66D1D8                  	rcr	ax, 1
  3639 0000170A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3640 0000170D 66AB                    	stosw		; this is 1st interpolated sample (R)
  3641                                  	;mov	ax, [next_val_l]
  3642 0000170F 89E8                    	mov	eax, ebp
  3643 00001711 6601D0                  	add	ax, dx
  3644 00001714 66D1D8                  	rcr	ax, 1
  3645 00001717 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3646 0000171A 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3647 0000171C 66A1[42270000]          	mov	ax, [next_val_r]
  3648 00001722 6601D8                  	add	ax, bx
  3649 00001725 66D1D8                  	rcr	ax, 1
  3650 00001728 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3651 0000172B 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3652                                  	
  3653                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3654 0000172D 09C9                    	or	ecx, ecx
  3655 0000172F 0F8567FFFFFF            	jnz	lff16s2_1
  3656 00001735 E9D1F9FFFF              	jmp	lff16s2_3
  3657                                  
  3658                                  ; .....................
  3659                                  
  3660                                  load_24khz_mono_8_bit:
  3661                                  	; 15/11/2023
  3662 0000173A F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3663                                  					; last of the file?
  3664 00001741 7402                    	jz	short lff24m_0		; no
  3665 00001743 F9                      	stc
  3666 00001744 C3                      	retn
  3667                                  
  3668                                  lff24m_0:
  3669                                  	; 01/12/2024
  3670                                  	; edi = audio buffer address
  3671                                  	; 13/12/2024
  3672 00001745 893D[F4320000]          	mov	[audio_buffer], edi
  3673 0000174B BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3674                                          ;mov	edx, [loadsize]
  3675                                  
  3676                                  	; esi = buffer address
  3677                                  	;; edx = buffer size
  3678                                  
  3679                                  	; load file into memory
  3680                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001750 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001756 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001758 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000175E B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001763 CD40                <1>  int 40h
  3681 00001765 723B                    	jc	short lff24m_7 ; error !
  3682                                  
  3683                                  	; 01/12/2024
  3684 00001767 A3[BC380000]            	mov	[count], eax
  3685                                  
  3686                                  	;mov	edi, audio_buffer
  3687                                  	; 29/05/2024
  3688                                  	;mov	edi, [audio_buffer]
  3689                                  	
  3690 0000176C 21C0                    	and	eax, eax
  3691 0000176E 7505                    	jnz	short lff24m_8
  3692 00001770 E9AEF9FFFF              	jmp	lff24_eof
  3693                                  
  3694                                  lff24m_8:
  3695 00001775 89C1                    	mov	ecx, eax	; byte count
  3696                                  lff24m_1:
  3697 00001777 AC                      	lodsb
  3698                                  	;mov	[previous_val], al
  3699 00001778 88C3                    	mov	bl, al
  3700 0000177A 2C80                    	sub	al, 80h
  3701 0000177C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3702 00001780 66AB                    	stosw		; original sample (left channel)
  3703 00001782 66AB                    	stosw		; original sample (right channel)
  3704                                  	;xor	eax, eax
  3705 00001784 B080                    	mov	al, 80h
  3706 00001786 49                      	dec	ecx
  3707 00001787 7402                    	jz	short lff24m_2
  3708 00001789 8A06                    	mov	al, [esi]
  3709                                  lff24m_2:
  3710                                  	;;mov	[next_val], al
  3711                                  	;mov	bh, al
  3712                                  	;add	al, [previous_val]
  3713 0000178B 00D8                    	add	al, bl
  3714 0000178D D0D8                    	rcr	al, 1
  3715 0000178F 2C80                    	sub	al, 80h
  3716 00001791 66C1E008                	shl	ax, 8
  3717 00001795 66AB                    	stosw		; this is interpolated sample (L)
  3718 00001797 66AB                    	stosw		; this is interpolated sample (R)
  3719                                  	
  3720                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3721 00001799 09C9                    	or	ecx, ecx
  3722 0000179B 75DA                    	jnz	short lff24m_1
  3723 0000179D E969F9FFFF              	jmp	lff24_3
  3724                                  
  3725                                  lff24m_7:
  3726                                  lff24s_7:
  3727 000017A2 E985F9FFFF              	jmp	lff24_5  ; error
  3728                                  
  3729                                  load_24khz_stereo_8_bit:
  3730                                  	; 15/11/2023
  3731 000017A7 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3732                                  					; last of the file?
  3733 000017AE 7402                    	jz	short lff24s_0		; no
  3734 000017B0 F9                      	stc
  3735 000017B1 C3                      	retn
  3736                                  
  3737                                  lff24s_0:
  3738                                  	; 01/12/2024
  3739                                  	; edi = audio buffer address
  3740                                  	; 13/12/2024
  3741 000017B2 893D[F4320000]          	mov	[audio_buffer], edi
  3742 000017B8 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3743                                          ;mov	edx, [loadsize]
  3744                                  
  3745                                  	; esi = buffer address
  3746                                  	;; edx = buffer size
  3747                                  
  3748                                  	; load file into memory
  3749                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000017BD 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000017C3 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000017C5 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000017CB B803000000          <1>  mov eax, %1
   104                              <1> 
   105 000017D0 CD40                <1>  int 40h
  3750 000017D2 72CE                    	jc	short lff24s_7 ; error !
  3751                                  
  3752                                  	; 01/12/2024
  3753 000017D4 A3[BC380000]            	mov	[count], eax
  3754                                  
  3755                                  	;mov	edi, audio_buffer
  3756                                  	; 29/05/2024
  3757                                  	;mov	edi, [audio_buffer]
  3758                                  	
  3759 000017D9 D1E8                    	shr	eax, 1
  3760 000017DB 7505                    	jnz	short lff24s_8
  3761 000017DD E941F9FFFF              	jmp	lff24_eof
  3762                                  
  3763                                  lff24s_8:
  3764 000017E2 89C1                    	mov	ecx, eax  ; word count
  3765                                  lff24s_1:
  3766 000017E4 AC                      	lodsb
  3767 000017E5 A2[3C270000]            	mov	[previous_val_l], al
  3768 000017EA 2C80                    	sub	al, 80h
  3769 000017EC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3770 000017F0 66AB                    	stosw		; original sample (L)
  3771 000017F2 AC                      	lodsb
  3772 000017F3 A2[3E270000]            	mov	[previous_val_r], al
  3773 000017F8 2C80                    	sub	al, 80h
  3774 000017FA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3775 000017FE 66AB                    	stosw		; original sample (R)
  3776                                  
  3777                                  	;xor	eax, eax
  3778 00001800 66B88080                	mov	ax, 8080h
  3779 00001804 49                      	dec	ecx
  3780 00001805 7403                    	jz	short lff24s_2
  3781                                  		; convert 8 bit sample to 16 bit sample
  3782 00001807 668B06                  	mov	ax, [esi]
  3783                                  lff24s_2:
  3784                                  	;;mov	[next_val_l], al
  3785                                  	;;mov	[next_val_r], ah
  3786                                  	;mov	bx, ax
  3787 0000180A 88E7                    	mov	bh, ah
  3788 0000180C 0205[3C270000]          	add	al, [previous_val_l]
  3789 00001812 D0D8                    	rcr	al, 1
  3790                                  	;mov	dl, al
  3791 00001814 2C80                    	sub	al, 80h
  3792 00001816 66C1E008                	shl	ax, 8
  3793 0000181A 66AB                    	stosw		; this is interpolated sample (L)
  3794 0000181C 88F8                    	mov	al, bh	; [next_val_r]
  3795 0000181E 0205[3E270000]          	add	al, [previous_val_r]
  3796 00001824 D0D8                    	rcr	al, 1
  3797                                  	;mov	dh, al
  3798 00001826 2C80                    	sub	al, 80h
  3799 00001828 66C1E008                	shl	ax, 8
  3800 0000182C 66AB                    	stosw		; this is interpolated sample (R)
  3801                                  		
  3802                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3803 0000182E 09C9                    	or	ecx, ecx
  3804 00001830 75B2                    	jnz	short lff24s_1
  3805 00001832 E9D4F8FFFF              	jmp	lff24_3
  3806                                  
  3807                                  load_24khz_mono_16_bit:
  3808                                  	; 15/11/2023
  3809 00001837 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3810                                  					; last of the file?
  3811 0000183E 7402                    	jz	short lff24m2_0		; no
  3812 00001840 F9                      	stc
  3813 00001841 C3                      	retn
  3814                                  
  3815                                  lff24m2_0:
  3816                                  	; 01/12/2024
  3817                                  	; edi = audio buffer address
  3818                                  	; 13/12/2024
  3819 00001842 893D[F4320000]          	mov	[audio_buffer], edi
  3820 00001848 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3821                                          ;mov	edx, [loadsize]
  3822                                  
  3823                                  	; esi = buffer address
  3824                                  	;; edx = buffer size
  3825                                  
  3826                                  	; load file into memory
  3827                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 0000184D 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001853 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001855 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000185B B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001860 CD40                <1>  int 40h
  3828 00001862 7237                    	jc	short lff24m2_7 ; error !
  3829                                  
  3830                                  	; 01/12/2024
  3831 00001864 A3[BC380000]            	mov	[count], eax
  3832                                  
  3833                                  	;mov	edi, audio_buffer
  3834                                  	; 29/05/2024
  3835                                  	;mov	edi, [audio_buffer]
  3836                                  	
  3837 00001869 D1E8                    	shr	eax, 1
  3838 0000186B 7505                    	jnz	short lff24m2_8
  3839 0000186D E9B1F8FFFF              	jmp	lff24_eof
  3840                                  
  3841                                  lff24m2_8:
  3842 00001872 89C1                    	mov	ecx, eax  ; word count
  3843                                  lff24m2_1:
  3844 00001874 66AD                    	lodsw
  3845 00001876 66AB                    	stosw		; original sample (left channel)
  3846 00001878 66AB                    	stosw		; original sample (right channel)
  3847 0000187A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3848                                  	;mov	[previous_val], ax
  3849                                  	;mov	ebx, eax
  3850                                  	;xor	eax, eax
  3851 0000187D 31DB                    	xor	ebx, ebx
  3852 0000187F 49                      	dec	ecx
  3853 00001880 7403                    	jz	short lff24m2_2
  3854                                  	;mov	ax, [esi]
  3855 00001882 668B1E                  	mov	bx, [esi]
  3856                                  lff24m2_2:
  3857                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  3858                                  	;mov	ebp, eax	; [next_val]
  3859                                  	;add	ax, [previous_val]
  3860                                  	; ax = [previous_val]
  3861                                  	; bx = [next_val]
  3862 00001885 6601D8                  	add	ax, bx
  3863 00001888 66D1D8                  	rcr	ax, 1
  3864 0000188B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3865 0000188E 66AB                    	stosw		; this is interpolated sample (L)
  3866 00001890 66AB                    	stosw		; this is interpolated sample (R)
  3867                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3868 00001892 09C9                    	or	ecx, ecx
  3869 00001894 75DE                    	jnz	short lff24m2_1
  3870 00001896 E970F8FFFF              	jmp	lff24_3
  3871                                  
  3872                                  lff24m2_7:
  3873                                  lff24s2_7:
  3874 0000189B E98CF8FFFF              	jmp	lff24_5  ; error
  3875                                  
  3876                                  load_24khz_stereo_16_bit:
  3877                                  	; 16/11/2023
  3878                                  	; 15/11/2023
  3879 000018A0 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3880                                  					; last of the file?
  3881 000018A7 7402                    	jz	short lff24s2_0		; no
  3882 000018A9 F9                      	stc
  3883 000018AA C3                      	retn
  3884                                  
  3885                                  lff24s2_0:
  3886                                  	; 01/12/2024
  3887                                  	; edi = audio buffer address
  3888                                  	; 13/12/2024
  3889 000018AB 893D[F4320000]          	mov	[audio_buffer], edi
  3890 000018B1 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3891                                          ;mov	edx, [loadsize]
  3892                                  
  3893                                  	; esi = buffer address
  3894                                  	;; edx = buffer size
  3895                                  
  3896                                  	; load file into memory
  3897                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000018B6 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000018BC 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000018BE 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000018C4 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 000018C9 CD40                <1>  int 40h
  3898 000018CB 72CE                    	jc	short lff24s2_7 ; error !
  3899                                  
  3900                                  	; 01/12/2024
  3901 000018CD A3[BC380000]            	mov	[count], eax
  3902                                  
  3903                                  	;mov	edi, audio_buffer
  3904                                  	; 29/05/2024
  3905                                  	;mov	edi, [audio_buffer]
  3906                                  	
  3907 000018D2 C1E802                  	shr	eax, 2
  3908 000018D5 7505                    	jnz	short lff24s2_8
  3909 000018D7 E947F8FFFF              	jmp	lff24_eof
  3910                                  
  3911                                  lff24s2_8:
  3912 000018DC 89C1                    	mov	ecx, eax  ; dword count
  3913                                  lff24s2_1:
  3914 000018DE 66AD                    	lodsw
  3915 000018E0 66AB                    	stosw		; original sample (L)
  3916 000018E2 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3917 000018E5 66A3[3C270000]          	mov	[previous_val_l], ax
  3918 000018EB 66AD                    	lodsw
  3919 000018ED 66AB                    	stosw		; original sample (R)
  3920 000018EF 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3921                                  	;mov	[previous_val_r], ax
  3922 000018F2 89C3                    	mov	ebx, eax
  3923 000018F4 31D2                    	xor	edx, edx
  3924 000018F6 31C0                    	xor	eax, eax
  3925                                  	; 16/11/2023
  3926 000018F8 49                      	dec	ecx
  3927 000018F9 7407                    	jz	short lff24s2_2
  3928 000018FB 668B06                  	mov	ax, [esi]
  3929 000018FE 668B5602                	mov	dx, [esi+2]
  3930                                  lff24s2_2:
  3931 00001902 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3932                                  	;;mov	[next_val_l], ax
  3933                                  	;mov	ebp, eax
  3934 00001905 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  3935                                  	;mov	[next_val_r], dx
  3936 00001908 660305[3C270000]        	add	ax, [previous_val_l]
  3937 0000190F 66D1D8                  	rcr	ax, 1
  3938 00001912 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3939 00001915 66AB                    	stosw		; this is interpolated sample (L)
  3940                                  	;mov	ax, [next_val_r]
  3941 00001917 89D0                    	mov	eax, edx
  3942                                  	;add	ax, [previous_val_r]
  3943 00001919 6601D8                  	add	ax, bx
  3944 0000191C 66D1D8                  	rcr	ax, 1
  3945 0000191F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3946 00001922 66AB                    	stosw		; this is interpolated sample (R)
  3947                                  	
  3948                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3949 00001924 09C9                    	or	ecx, ecx
  3950 00001926 75B6                    	jnz	short lff24s2_1
  3951 00001928 E9DEF7FFFF              	jmp	lff24_3
  3952                                  
  3953                                  ; .....................
  3954                                  
  3955                                  load_32khz_mono_8_bit:
  3956                                  	; 15/11/2023
  3957 0000192D F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3958                                  					; last of the file?
  3959 00001934 7402                    	jz	short lff32m_0		; no
  3960 00001936 F9                      	stc
  3961 00001937 C3                      	retn
  3962                                  
  3963                                  lff32m_0:
  3964                                  	; 01/12/2024
  3965                                  	; edi = audio buffer address
  3966                                  	; 13/12/2024
  3967 00001938 893D[F4320000]          	mov	[audio_buffer], edi
  3968 0000193E BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3969                                          ;mov	edx, [loadsize]
  3970                                  
  3971                                  	; esi = buffer address
  3972                                  	;; edx = buffer size
  3973                                  
  3974                                  	; load file into memory
  3975                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001943 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001949 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000194B 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001951 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001956 CD40                <1>  int 40h
  3976 00001958 7247                    	jc	short lff32m_7 ; error !
  3977                                  
  3978                                  	; 01/12/2024
  3979 0000195A A3[BC380000]            	mov	[count], eax
  3980                                  
  3981                                  	;mov	edi, audio_buffer
  3982                                  	; 29/05/2024
  3983                                  	;mov	edi, [audio_buffer]
  3984                                  	
  3985 0000195F 21C0                    	and	eax, eax
  3986 00001961 7505                    	jnz	short lff32m_8
  3987 00001963 E9BBF7FFFF              	jmp	lff32_eof
  3988                                  
  3989                                  lff32m_8:
  3990 00001968 89C1                    	mov	ecx, eax	; byte count
  3991                                  lff32m_1:
  3992 0000196A AC                      	lodsb
  3993                                  	;mov	[previous_val], al
  3994 0000196B 88C3                    	mov	bl, al
  3995 0000196D 2C80                    	sub	al, 80h
  3996 0000196F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3997 00001973 66AB                    	stosw		; original sample (left channel)
  3998 00001975 66AB                    	stosw		; original sample (right channel)
  3999                                  	;xor	eax, eax
  4000 00001977 B080                    	mov	al, 80h
  4001 00001979 49                      	dec	ecx
  4002 0000197A 7402                    	jz	short lff32m_2
  4003 0000197C 8A06                    	mov	al, [esi]
  4004                                  lff32m_2:
  4005                                  	;;mov	[next_val], al
  4006                                  	;mov	bh, al
  4007                                  	;add	al, [previous_val]
  4008 0000197E 00D8                    	add	al, bl
  4009 00001980 D0D8                    	rcr	al, 1
  4010 00001982 2C80                    	sub	al, 80h
  4011 00001984 66C1E008                	shl	ax, 8
  4012 00001988 66AB                    	stosw		; this is interpolated sample (L)
  4013 0000198A 66AB                    	stosw		; this is interpolated sample (R)
  4014                                  	
  4015                                  	; different than 8-16-24 kHZ !
  4016                                  	; 'original-interpolated-original' trio samples
  4017 0000198C E30E                    	jecxz	lff32m_3
  4018                                  
  4019 0000198E AC                      	lodsb
  4020 0000198F 2C80                    	sub	al, 80h
  4021 00001991 66C1E008                	shl	ax, 8
  4022 00001995 66AB                    	stosw		; original sample (left channel)
  4023 00001997 66AB                    	stosw		; original sample (right channel)
  4024                                  
  4025                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  4026 00001999 49                      	dec	ecx
  4027 0000199A 75CE                    	jnz	short lff32m_1
  4028                                  lff32m_3:
  4029 0000199C E96AF7FFFF              	jmp	lff32_3
  4030                                  
  4031                                  lff32m_7:
  4032                                  lff32s_7:
  4033 000019A1 E986F7FFFF              	jmp	lff32_5  ; error
  4034                                  
  4035                                  load_32khz_stereo_8_bit:
  4036                                  	; 15/11/2023
  4037 000019A6 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4038                                  					; last of the file?
  4039 000019AD 7402                    	jz	short lff32s_0		; no
  4040 000019AF F9                      	stc
  4041 000019B0 C3                      	retn
  4042                                  
  4043                                  lff32s_0:
  4044                                  	; 01/12/2024
  4045                                  	; edi = audio buffer address
  4046                                  	; 13/12/2024
  4047 000019B1 893D[F4320000]          	mov	[audio_buffer], edi
  4048 000019B7 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4049                                          ;mov	edx, [loadsize]
  4050                                  
  4051                                  	; esi = buffer address
  4052                                  	;; edx = buffer size
  4053                                  
  4054                                  	; load file into memory
  4055                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 000019BC 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 000019C2 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 000019C4 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 000019CA B803000000          <1>  mov eax, %1
   104                              <1> 
   105 000019CF CD40                <1>  int 40h
  4056 000019D1 72CE                    	jc	short lff32s_7 ; error !
  4057                                  
  4058                                  	; 01/12/2024
  4059 000019D3 A3[BC380000]            	mov	[count], eax
  4060                                  
  4061                                  	;mov	edi, audio_buffer
  4062                                  	; 29/05/2024
  4063                                  	;mov	edi, [audio_buffer]
  4064                                  	
  4065 000019D8 D1E8                    	shr	eax, 1
  4066 000019DA 7505                    	jnz	short lff32s_8
  4067 000019DC E942F7FFFF              	jmp	lff32_eof
  4068                                  
  4069                                  lff32s_8:
  4070 000019E1 89C1                    	mov	ecx, eax  ; word count
  4071                                  lff32s_1:
  4072 000019E3 AC                      	lodsb
  4073 000019E4 A2[3C270000]            	mov	[previous_val_l], al
  4074 000019E9 2C80                    	sub	al, 80h
  4075 000019EB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4076 000019EF 66AB                    	stosw		; original sample (L)
  4077 000019F1 AC                      	lodsb
  4078 000019F2 A2[3E270000]            	mov	[previous_val_r], al
  4079 000019F7 2C80                    	sub	al, 80h
  4080 000019F9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4081 000019FD 66AB                    	stosw		; original sample (R)
  4082                                  
  4083                                  	;xor	eax, eax
  4084 000019FF 66B88080                	mov	ax, 8080h
  4085 00001A03 49                      	dec	ecx
  4086 00001A04 7403                    	jz	short lff32s_2
  4087                                  		; convert 8 bit sample to 16 bit sample
  4088 00001A06 668B06                  	mov	ax, [esi]
  4089                                  lff32s_2:
  4090                                  	;;mov	[next_val_l], al
  4091                                  	;;mov	[next_val_r], ah
  4092                                  	;mov	bx, ax
  4093 00001A09 88E7                    	mov	bh, ah
  4094 00001A0B 0205[3C270000]          	add	al, [previous_val_l]
  4095 00001A11 D0D8                    	rcr	al, 1
  4096                                  	;mov	dl, al
  4097 00001A13 2C80                    	sub	al, 80h
  4098 00001A15 66C1E008                	shl	ax, 8
  4099 00001A19 66AB                    	stosw		; this is interpolated sample (L)
  4100 00001A1B 88F8                    	mov	al, bh	; [next_val_r]
  4101 00001A1D 0205[3E270000]          	add	al, [previous_val_r]
  4102 00001A23 D0D8                    	rcr	al, 1
  4103                                  	;mov	dh, al
  4104 00001A25 2C80                    	sub	al, 80h
  4105 00001A27 66C1E008                	shl	ax, 8
  4106 00001A2B 66AB                    	stosw		; this is interpolated sample (R)
  4107                                  
  4108                                  	; different than 8-16-24 kHZ !
  4109                                  	; 'original-interpolated-original' trio samples
  4110 00001A2D E315                    	jecxz	lff32s_3
  4111                                  
  4112 00001A2F AC                      	lodsb
  4113 00001A30 2C80                    	sub	al, 80h
  4114 00001A32 66C1E008                	shl	ax, 8
  4115 00001A36 66AB                    	stosw		; original sample (left channel)
  4116                                  
  4117 00001A38 AC                      	lodsb
  4118 00001A39 2C80                    	sub	al, 80h
  4119 00001A3B 66C1E008                	shl	ax, 8
  4120 00001A3F 66AB                    	stosw		; original sample (right channel)
  4121                                  		
  4122                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  4123 00001A41 49                      	dec	ecx
  4124 00001A42 759F                    	jnz	short lff32s_1
  4125                                  lff32s_3:
  4126 00001A44 E9C2F6FFFF              	jmp	lff32_3
  4127                                  
  4128                                  load_32khz_mono_16_bit:
  4129                                  	; 15/11/2023
  4130 00001A49 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4131                                  					; last of the file?
  4132 00001A50 7402                    	jz	short lff32m2_0		; no
  4133 00001A52 F9                      	stc
  4134 00001A53 C3                      	retn
  4135                                  
  4136                                  lff32m2_0:
  4137                                  	; 01/12/2024
  4138                                  	; edi = audio buffer address
  4139                                  	; 13/12/2024
  4140 00001A54 893D[F4320000]          	mov	[audio_buffer], edi
  4141 00001A5A BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4142                                          ;mov	edx, [loadsize]
  4143                                  
  4144                                  	; esi = buffer address
  4145                                  	;; edx = buffer size
  4146                                  
  4147                                  	; load file into memory
  4148                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001A5F 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001A65 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001A67 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001A6D B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001A72 CD40                <1>  int 40h
  4149 00001A74 723E                    	jc	short lff32m2_7 ; error !
  4150                                  
  4151                                  	; 01/12/2024
  4152 00001A76 A3[BC380000]            	mov	[count], eax
  4153                                  
  4154                                  	;mov	edi, audio_buffer
  4155                                  	; 29/05/2024
  4156                                  	;mov	edi, [audio_buffer]
  4157                                  	
  4158 00001A7B D1E8                    	shr	eax, 1
  4159 00001A7D 7505                    	jnz	short lff32m2_8
  4160 00001A7F E99FF6FFFF              	jmp	lff32_eof
  4161                                  
  4162                                  lff32m2_8:
  4163 00001A84 89C1                    	mov	ecx, eax  ; word count
  4164                                  lff32m2_1:
  4165 00001A86 66AD                    	lodsw
  4166 00001A88 66AB                    	stosw		; original sample (left channel)
  4167 00001A8A 66AB                    	stosw		; original sample (right channel)
  4168 00001A8C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4169                                  	;mov	[previous_val], ax
  4170                                  	;mov	ebx, eax
  4171                                  	;xor	eax, eax
  4172 00001A8F 31DB                    	xor	ebx, ebx
  4173 00001A91 49                      	dec	ecx
  4174 00001A92 7403                    	jz	short lff32m2_2
  4175                                  	;mov	ax, [esi]
  4176 00001A94 668B1E                  	mov	bx, [esi]
  4177                                  lff32m2_2:
  4178                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  4179                                  	;mov	ebp, eax	; [next_val]
  4180                                  	;add	ax, [previous_val]
  4181                                  	; ax = [previous_val]
  4182                                  	; bx = [next_val]
  4183 00001A97 6601D8                  	add	ax, bx
  4184 00001A9A 66D1D8                  	rcr	ax, 1
  4185 00001A9D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4186 00001AA0 66AB                    	stosw		; this is interpolated sample (L)
  4187 00001AA2 66AB                    	stosw		; this is interpolated sample (R)
  4188                                  
  4189                                  	; different than 8-16-24 kHZ !
  4190                                  	; 'original-interpolated-original' trio samples 
  4191 00001AA4 E309                    	jecxz	lff32m2_3
  4192                                  
  4193 00001AA6 66AD                    	lodsw
  4194 00001AA8 66AB                    	stosw		; original sample (left channel)
  4195 00001AAA 66AB                    	stosw		; original sample (right channel)
  4196                                  
  4197                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  4198 00001AAC 49                      	dec	ecx
  4199 00001AAD 75D7                    	jnz	short lff32m2_1
  4200                                  lff32m2_3:
  4201 00001AAF E957F6FFFF              	jmp	lff32_3
  4202                                  
  4203                                  lff32m2_7:
  4204                                  lff32s2_7:
  4205 00001AB4 E973F6FFFF              	jmp	lff32_5  ; error
  4206                                  
  4207                                  load_32khz_stereo_16_bit:
  4208                                  	; 16/11/2023
  4209                                  	; 15/11/2023
  4210 00001AB9 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4211                                  					; last of the file?
  4212 00001AC0 7402                    	jz	short lff32s2_0		; no
  4213 00001AC2 F9                      	stc
  4214 00001AC3 C3                      	retn
  4215                                  
  4216                                  lff32s2_0:
  4217                                  	; 01/12/2024
  4218                                  	; edi = audio buffer address
  4219                                  	; 13/12/2024
  4220 00001AC4 893D[F4320000]          	mov	[audio_buffer], edi
  4221 00001ACA BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4222                                          ;mov	edx, [loadsize]
  4223                                  
  4224                                  	; esi = buffer address
  4225                                  	;; edx = buffer size
  4226                                  
  4227                                  	; load file into memory
  4228                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001ACF 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001AD5 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001AD7 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001ADD B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001AE2 CD40                <1>  int 40h
  4229 00001AE4 72CE                    	jc	short lff32s2_7 ; error !
  4230                                  
  4231                                  	; 01/12/2024
  4232 00001AE6 A3[BC380000]            	mov	[count], eax
  4233                                  
  4234                                  	;mov	edi, audio_buffer
  4235                                  	; 29/05/2024
  4236                                  	;mov	edi, [audio_buffer]
  4237                                  	
  4238 00001AEB C1E802                  	shr	eax, 2
  4239 00001AEE 7505                    	jnz	short lff32s2_8
  4240 00001AF0 E92EF6FFFF              	jmp	lff32_eof
  4241                                  
  4242                                  lff32s2_8:
  4243 00001AF5 89C1                    	mov	ecx, eax ; dword count
  4244                                  lff32s2_1:
  4245 00001AF7 66AD                    	lodsw
  4246 00001AF9 66AB                    	stosw		; original sample (L)
  4247 00001AFB 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  4248 00001AFE 66A3[3C270000]          	mov	[previous_val_l], ax
  4249 00001B04 66AD                    	lodsw
  4250 00001B06 66AB                    	stosw		; original sample (R)
  4251 00001B08 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  4252                                  	;mov	[previous_val_r], ax
  4253 00001B0B 89C3                    	mov	ebx, eax
  4254 00001B0D 31D2                    	xor	edx, edx
  4255 00001B0F 31C0                    	xor	eax, eax
  4256                                  	; 16/11/2023
  4257 00001B11 49                      	dec	ecx
  4258 00001B12 7407                    	jz	short lff32s2_2
  4259 00001B14 668B06                  	mov	ax, [esi]
  4260 00001B17 668B5602                	mov	dx, [esi+2]
  4261                                  lff32s2_2:
  4262 00001B1B 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  4263                                  	;;mov	[next_val_l], ax
  4264                                  	;mov	ebp, eax
  4265 00001B1E 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  4266                                  	;mov	[next_val_r], dx
  4267 00001B21 660305[3C270000]        	add	ax, [previous_val_l]
  4268 00001B28 66D1D8                  	rcr	ax, 1
  4269 00001B2B 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  4270 00001B2E 66AB                    	stosw		; this is interpolated sample (L)
  4271                                  	;mov	ax, [next_val_r]
  4272 00001B30 89D0                    	mov	eax, edx
  4273                                  	;add	ax, [previous_val_r]
  4274 00001B32 6601D8                  	add	ax, bx
  4275 00001B35 66D1D8                  	rcr	ax, 1
  4276 00001B38 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4277 00001B3B 66AB                    	stosw		; this is interpolated sample (R)
  4278                                  
  4279                                  	; different than 8-16-24 kHZ !
  4280                                  	; 'original-interpolated-original' trio samples
  4281 00001B3D E30B                    	jecxz	lff32s2_3
  4282                                  
  4283 00001B3F 66AD                    	lodsw
  4284 00001B41 66AB                    	stosw	; original sample (L)
  4285 00001B43 66AD                    	lodsw
  4286 00001B45 66AB                    	stosw	; original sample (R)
  4287                                  	
  4288                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  4289 00001B47 49                      	dec	ecx
  4290 00001B48 75AD                    	jnz	short lff32s2_1
  4291                                  lff32s2_3:
  4292 00001B4A E9BCF5FFFF              	jmp	lff32_3
  4293                                  
  4294                                  ; .....................
  4295                                  
  4296                                  load_22khz_mono_8_bit:
  4297                                  	; 16/11/2023
  4298 00001B4F F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4299                                  					; last of the file?
  4300 00001B56 7402                    	jz	short lff22m_0		; no
  4301 00001B58 F9                      	stc
  4302 00001B59 C3                      	retn
  4303                                  
  4304                                  lff22m_0:
  4305                                  	; 01/12/2024
  4306                                  	; edi = audio buffer address
  4307                                  	; 13/12/2024
  4308 00001B5A 893D[F4320000]          	mov	[audio_buffer], edi
  4309 00001B60 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4310                                          ;mov	edx, [loadsize]
  4311                                  
  4312                                  	; esi = buffer address
  4313                                  	;; edx = buffer size
  4314                                  
  4315                                  	; load file into memory
  4316                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001B65 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001B6B 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001B6D 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001B73 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001B78 CD40                <1>  int 40h
  4317 00001B7A 725D                    	jc	short lff22m_7 ; error !
  4318                                  
  4319                                  	; 01/12/2024
  4320 00001B7C A3[BC380000]            	mov	[count], eax
  4321                                  
  4322                                  	;mov	edi, audio_buffer
  4323                                  	; 29/05/2024
  4324                                  	;mov	edi, [audio_buffer]
  4325                                  	
  4326 00001B81 21C0                    	and	eax, eax
  4327 00001B83 7505                    	jnz	short lff22m_8
  4328 00001B85 E999F5FFFF              	jmp	lff22_eof
  4329                                  
  4330                                  lff22m_8:
  4331 00001B8A 89C1                    	mov	ecx, eax	; byte count
  4332                                  lff22m_9:
  4333 00001B8C BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4334 00001B91 C605[44270000]03        	mov	byte [faz], 3  ; 3 steps/phases
  4335                                  lff22m_1:
  4336                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4337 00001B98 AC                      	lodsb
  4338 00001B99 B280                    	mov	dl, 80h
  4339 00001B9B 49                      	dec	ecx
  4340 00001B9C 7402                    	jz	short lff22m_2_1
  4341 00001B9E 8A16                    	mov	dl, [esi]
  4342                                  lff22m_2_1:	
  4343                                  	; al = [previous_val]
  4344                                  	; dl = [next_val]
  4345 00001BA0 E851060000              	call	interpolating_3_8bit_mono ; 1 of 17
  4346 00001BA5 E32D                    	jecxz	lff22m_3
  4347                                  lff22m_2_2:
  4348 00001BA7 AC                      	lodsb
  4349 00001BA8 B280                    	mov	dl, 80h
  4350 00001BAA 49                      	dec	ecx
  4351 00001BAB 7402                    	jz	short lff22m_2_3
  4352 00001BAD 8A16                    	mov	dl, [esi]
  4353                                  lff22m_2_3:
  4354 00001BAF E8C6060000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  4355 00001BB4 E31E                    	jecxz	lff22m_3
  4356 00001BB6 4D                      	dec	ebp
  4357 00001BB7 75EE                    	jnz	short lff22m_2_2
  4358                                  
  4359 00001BB9 A0[44270000]            	mov	al, [faz]
  4360 00001BBE FEC8                    	dec	al
  4361 00001BC0 74CA                    	jz	short lff22m_9
  4362 00001BC2 FE0D[44270000]          	dec	byte [faz]
  4363 00001BC8 BD04000000              	mov	ebp, 4
  4364 00001BCD FEC8                    	dec	al
  4365 00001BCF 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  4366 00001BD1 45                      	inc	ebp ; 5
  4367 00001BD2 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4368                                  
  4369                                  lff22m_3:
  4370                                  lff22s_3:
  4371 00001BD4 E932F5FFFF              	jmp	lff22_3	; padfill
  4372                                  		; (put zeros in the remain words of the buffer)
  4373                                  lff22m_7:
  4374                                  lff22s_7:
  4375 00001BD9 E94EF5FFFF              	jmp	lff22_5  ; error
  4376                                  
  4377                                  load_22khz_stereo_8_bit:
  4378                                  	; 16/11/2023
  4379 00001BDE F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4380                                  					; last of the file?
  4381 00001BE5 7402                    	jz	short lff22s_0		; no
  4382 00001BE7 F9                      	stc
  4383 00001BE8 C3                      	retn
  4384                                  
  4385                                  lff22s_0:
  4386                                  	; 01/12/2024
  4387                                  	; edi = audio buffer address
  4388                                  	; 13/12/2024
  4389 00001BE9 893D[F4320000]          	mov	[audio_buffer], edi
  4390 00001BEF BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4391                                          ;mov	edx, [loadsize]
  4392                                  
  4393                                  	; esi = buffer address
  4394                                  	;; edx = buffer size
  4395                                  
  4396                                  	; load file into memory
  4397                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001BF4 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001BFA 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001BFC 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001C02 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001C07 CD40                <1>  int 40h
  4398 00001C09 72CE                    	jc	short lff22s_7 ; error !
  4399                                  
  4400                                  	; 01/12/2024
  4401 00001C0B A3[BC380000]            	mov	[count], eax
  4402                                  
  4403                                  	;mov	edi, audio_buffer
  4404                                  	; 29/05/2024
  4405                                  	;mov	edi, [audio_buffer]
  4406                                  	
  4407 00001C10 D1E8                    	shr	eax, 1
  4408 00001C12 7505                    	jnz	short lff22s_8
  4409 00001C14 E90AF5FFFF              	jmp	lff22_eof
  4410                                  
  4411                                  lff22s_8:
  4412 00001C19 89C1                    	mov	ecx, eax	; word count
  4413                                  lff22s_9:
  4414 00001C1B BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4415 00001C20 C605[44270000]03        	mov	byte [faz], 3  ; 3 steps/phase
  4416                                  lff22s_1:
  4417                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4418 00001C27 66AD                    	lodsw
  4419 00001C29 66BA8080                	mov	dx, 8080h
  4420 00001C2D 49                      	dec	ecx
  4421 00001C2E 7403                    	jz	short lff22s_2_1
  4422 00001C30 668B16                  	mov	dx, [esi]
  4423                                  lff22s_2_1:	
  4424                                  	; al = [previous_val_l]
  4425                                  	; ah = [previous_val_r]
  4426                                  	; dl = [next_val_l]
  4427                                  	; dh = [next_val_r]
  4428 00001C33 E8EF050000              	call	interpolating_3_8bit_stereo ; 1 of 17
  4429 00001C38 E39A                    	jecxz	lff22s_3
  4430                                  lff22s_2_2:
  4431 00001C3A 66AD                    	lodsw
  4432 00001C3C 66BA8080                	mov	dx, 8080h
  4433 00001C40 49                      	dec	ecx
  4434 00001C41 7403                    	jz	short lff22s_2_3
  4435 00001C43 668B16                  	mov	dx, [esi]
  4436                                  lff22s_2_3:
  4437 00001C46 E84C060000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  4438 00001C4B E387                    	jecxz	lff22s_3
  4439 00001C4D 4D                      	dec	ebp
  4440 00001C4E 75EA                    	jnz	short lff22s_2_2
  4441                                  
  4442 00001C50 A0[44270000]            	mov	al, [faz]
  4443 00001C55 FEC8                    	dec	al
  4444 00001C57 74C2                    	jz	short lff22s_9
  4445 00001C59 FE0D[44270000]          	dec	byte [faz]
  4446 00001C5F BD04000000              	mov	ebp, 4
  4447 00001C64 FEC8                    	dec	al
  4448 00001C66 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  4449 00001C68 45                      	inc	ebp ; 5
  4450 00001C69 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4451                                  
  4452                                  load_22khz_mono_16_bit:
  4453                                  	; 16/11/2023
  4454 00001C6B F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4455                                  					; last of the file?
  4456 00001C72 7402                    	jz	short lff22m2_0		; no
  4457 00001C74 F9                      	stc
  4458 00001C75 C3                      	retn
  4459                                  
  4460                                  lff22m2_0:
  4461                                  	; 01/12/2024
  4462                                  	; edi = audio buffer address
  4463                                  	; 13/12/2024
  4464 00001C76 893D[F4320000]          	mov	[audio_buffer], edi
  4465 00001C7C BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4466                                          ;mov	edx, [loadsize]
  4467                                  
  4468                                  	; esi = buffer address
  4469                                  	;; edx = buffer size
  4470                                  
  4471                                  	; load file into memory
  4472                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001C81 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001C87 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001C89 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001C8F B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001C94 CD40                <1>  int 40h
  4473 00001C96 7261                    	jc	short lff22m2_7 ; error !
  4474                                  
  4475                                  	; 01/12/2024
  4476 00001C98 A3[BC380000]            	mov	[count], eax
  4477                                  
  4478                                  	;mov	edi, audio_buffer
  4479                                  	; 29/05/2024
  4480                                  	;mov	edi, [audio_buffer]
  4481                                  	
  4482 00001C9D D1E8                    	shr	eax, 1
  4483 00001C9F 7505                    	jnz	short lff22m2_8
  4484 00001CA1 E97DF4FFFF              	jmp	lff22_eof
  4485                                  
  4486                                  lff22m2_8:
  4487 00001CA6 89C1                    	mov	ecx, eax	; word count
  4488                                  lff22m2_9:
  4489 00001CA8 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4490 00001CAD C605[44270000]03        	mov	byte [faz], 3  ; 3 steps/phases
  4491                                  lff22m2_1:
  4492                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4493 00001CB4 66AD                    	lodsw
  4494 00001CB6 31D2                    	xor	edx, edx
  4495 00001CB8 49                      	dec	ecx
  4496 00001CB9 7403                    	jz	short lff22m2_2_1
  4497 00001CBB 668B16                  	mov	dx, [esi]
  4498                                  lff22m2_2_1:	
  4499                                  	; ax = [previous_val]
  4500                                  	; dx = [next_val]
  4501 00001CBE E805060000              	call	interpolating_3_16bit_mono ; 1 of 17
  4502 00001CC3 E32F                    	jecxz	lff22m2_3
  4503                                  lff22m2_2_2:
  4504 00001CC5 66AD                    	lodsw
  4505 00001CC7 31D2                    	xor	edx, edx
  4506 00001CC9 49                      	dec	ecx
  4507 00001CCA 7403                    	jz	short lff22m2_2_3
  4508 00001CCC 668B16                  	mov	dx, [esi]
  4509                                  lff22m2_2_3:
  4510 00001CCF E887060000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  4511 00001CD4 E31E                    	jecxz	lff22m2_3
  4512 00001CD6 4D                      	dec	ebp
  4513 00001CD7 75EC                    	jnz	short lff22m2_2_2
  4514                                  
  4515 00001CD9 A0[44270000]            	mov	al, [faz]
  4516 00001CDE FEC8                    	dec	al
  4517 00001CE0 74C6                    	jz	short lff22m2_9
  4518 00001CE2 FE0D[44270000]          	dec	byte [faz]
  4519 00001CE8 BD04000000              	mov	ebp, 4
  4520 00001CED FEC8                    	dec	al
  4521 00001CEF 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4522 00001CF1 45                      	inc	ebp ; 5
  4523 00001CF2 EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4524                                  
  4525                                  lff22m2_3:
  4526                                  lff22s2_3:
  4527 00001CF4 E912F4FFFF              	jmp	lff22_3	; padfill
  4528                                  		; (put zeros in the remain words of the buffer)
  4529                                  lff22m2_7:
  4530                                  lff22s2_7:
  4531 00001CF9 E92EF4FFFF              	jmp	lff22_5  ; error
  4532                                  
  4533                                  load_22khz_stereo_16_bit:
  4534                                  	; 16/11/2023
  4535 00001CFE F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4536                                  					; last of the file?
  4537 00001D05 7402                    	jz	short lff22s2_0		; no
  4538 00001D07 F9                      	stc
  4539 00001D08 C3                      	retn
  4540                                  
  4541                                  lff22s2_0:
  4542                                  	; 01/12/2024
  4543                                  	; edi = audio buffer address
  4544                                  	; 13/12/2024
  4545 00001D09 893D[F4320000]          	mov	[audio_buffer], edi
  4546 00001D0F BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4547                                          ;mov	edx, [loadsize]
  4548                                  
  4549                                  	; esi = buffer address
  4550                                  	;; edx = buffer size
  4551                                  
  4552                                  	; load file into memory
  4553                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001D14 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001D1A 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001D1C 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001D22 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001D27 CD40                <1>  int 40h
  4554 00001D29 72CE                    	jc	short lff22s2_7 ; error !
  4555                                  
  4556                                  	; 01/12/2024
  4557 00001D2B A3[BC380000]            	mov	[count], eax
  4558                                  
  4559                                  	;mov	edi, audio_buffer
  4560                                  	; 29/05/2024
  4561                                  	;mov	edi, [audio_buffer]
  4562                                  	
  4563 00001D30 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  4564 00001D33 7505                    	jnz	short lff22s2_8
  4565 00001D35 E9E9F3FFFF              	jmp	lff22_eof
  4566                                  
  4567                                  lff22s2_8:
  4568 00001D3A 89C1                    	mov	ecx, eax	; dword count
  4569                                  lff22s2_9:
  4570 00001D3C BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4571 00001D41 C605[44270000]03        	mov	byte [faz], 3  ; 3 steps/phase
  4572                                  lff22s2_1:
  4573                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4574 00001D48 66AD                    	lodsw
  4575 00001D4A 89C3                    	mov	ebx, eax
  4576 00001D4C 66AD                    	lodsw
  4577 00001D4E 8B16                    	mov	edx, [esi]
  4578 00001D50 668915[40270000]        	mov	[next_val_l], dx
  4579                                  	; 26/11/2023
  4580 00001D57 C1EA10                  	shr	edx, 16
  4581 00001D5A 49                      	dec	ecx
  4582 00001D5B 7509                    	jnz	short lff22s2_2_1
  4583 00001D5D 31D2                    	xor	edx, edx ; 0
  4584 00001D5F 668915[40270000]        	mov	[next_val_l], dx
  4585                                  lff22s2_2_1:
  4586                                  	; bx = [previous_val_l]
  4587                                  	; ax = [previous_val_r]
  4588                                  	; [next_val_l]
  4589                                  	; dx = [next_val_r]
  4590 00001D66 E88D050000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  4591 00001D6B E387                    	jecxz	lff22s2_3
  4592                                  lff22s2_2_2:
  4593 00001D6D 66AD                    	lodsw
  4594 00001D6F 89C3                    	mov	ebx, eax
  4595 00001D71 66AD                    	lodsw
  4596 00001D73 8B16                    	mov	edx, [esi]
  4597 00001D75 668915[40270000]        	mov	[next_val_l], dx
  4598                                  	; 26/11/2023
  4599 00001D7C C1EA10                  	shr	edx, 16
  4600 00001D7F 49                      	dec	ecx
  4601 00001D80 7509                    	jnz	short lff22s2_2_3
  4602 00001D82 31D2                    	xor	edx, edx ; 0
  4603 00001D84 668915[40270000]        	mov	[next_val_l], dx
  4604                                  lff22s2_2_3:
  4605 00001D8B E8E3050000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  4606 00001D90 E31E                    	jecxz	lff22s2_2_4
  4607                                  
  4608 00001D92 4D                      	dec	ebp
  4609 00001D93 75D8                    	jnz	short lff22s2_2_2
  4610                                  
  4611 00001D95 A0[44270000]            	mov	al, [faz]
  4612 00001D9A FEC8                    	dec	al
  4613 00001D9C 749E                    	jz	short lff22s2_9
  4614 00001D9E FE0D[44270000]          	dec	byte [faz]
  4615 00001DA4 BD04000000              	mov	ebp, 4
  4616 00001DA9 FEC8                    	dec	al
  4617 00001DAB 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4618 00001DAD 45                      	inc	ebp ; 5
  4619 00001DAE EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4620                                  
  4621                                  lff22s2_2_4:
  4622                                  	; 26/11/2023
  4623 00001DB0 E956F3FFFF              	jmp	lff22_3	; padfill
  4624                                  
  4625                                  ; .....................
  4626                                  
  4627                                  load_11khz_mono_8_bit:
  4628                                  	; 18/11/2023
  4629 00001DB5 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4630                                  					; last of the file?
  4631 00001DBC 7402                    	jz	short lff11m_0		; no
  4632 00001DBE F9                      	stc
  4633 00001DBF C3                      	retn
  4634                                  
  4635                                  lff11m_0:
  4636                                  	; 01/12/2024
  4637                                  	; edi = audio buffer address
  4638                                  	; 13/12/2024
  4639 00001DC0 893D[F4320000]          	mov	[audio_buffer], edi
  4640 00001DC6 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4641                                          ;mov	edx, [loadsize]
  4642                                  
  4643                                  	; esi = buffer address
  4644                                  	;; edx = buffer size
  4645                                  
  4646                                  	; load file into memory
  4647                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001DCB 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001DD1 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001DD3 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001DD9 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001DDE CD40                <1>  int 40h
  4648 00001DE0 7247                    	jc	short lff11m_7 ; error !
  4649                                  
  4650                                  	; 01/12/2024
  4651 00001DE2 A3[BC380000]            	mov	[count], eax
  4652                                  
  4653                                  	;mov	edi, audio_buffer
  4654                                  	; 29/05/2024
  4655                                  	;mov	edi, [audio_buffer]
  4656                                  	
  4657 00001DE7 21C0                    	and	eax, eax
  4658 00001DE9 7505                    	jnz	short lff11m_8
  4659 00001DEB E933F3FFFF              	jmp	lff11_eof
  4660                                  
  4661                                  lff11m_8:
  4662 00001DF0 89C1                    	mov	ecx, eax		; byte count
  4663                                  lff11m_9:
  4664 00001DF2 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4665                                  lff11m_1:
  4666                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4667 00001DF7 AC                      	lodsb
  4668 00001DF8 B280                    	mov	dl, 80h
  4669 00001DFA 49                      	dec	ecx
  4670 00001DFB 7402                    	jz	short lff11m_2_1
  4671 00001DFD 8A16                    	mov	dl, [esi]
  4672                                  lff11m_2_1:	
  4673                                  	; al = [previous_val]
  4674                                  	; dl = [next_val]
  4675 00001DFF E8A0050000              	call	interpolating_5_8bit_mono
  4676 00001E04 E333                    	jecxz	lff11m_3
  4677                                  lff11m_2_2:
  4678 00001E06 AC                      	lodsb
  4679 00001E07 B280                    	mov	dl, 80h
  4680 00001E09 49                      	dec	ecx
  4681 00001E0A 7402                    	jz	short lff11m_2_3
  4682 00001E0C 8A16                    	mov	dl, [esi]
  4683                                  lff11m_2_3:
  4684 00001E0E E89D060000               	call	interpolating_4_8bit_mono
  4685 00001E13 E324                    	jecxz	lff11m_3
  4686                                  
  4687 00001E15 4D                      	dec	ebp
  4688 00001E16 74DA                    	jz	short lff11m_9
  4689                                  
  4690 00001E18 AC                      	lodsb
  4691 00001E19 B280                    	mov	dl, 80h
  4692 00001E1B 49                      	dec	ecx
  4693 00001E1C 7402                    	jz	short lff11m_2_4
  4694 00001E1E 8A16                    	mov	dl, [esi]
  4695                                  lff11m_2_4:
  4696 00001E20 E88B060000              	call	interpolating_4_8bit_mono
  4697 00001E25 E312                    	jecxz	lff11m_3
  4698 00001E27 EBCE                    	jmp	short lff11m_1
  4699                                  
  4700                                  lff11m_7:
  4701                                  lff11s_7:
  4702 00001E29 E9FEF2FFFF              	jmp	lff11_5  ; error
  4703                                  
  4704                                  load_11khz_stereo_8_bit:
  4705                                  	; 18/11/2023
  4706 00001E2E F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4707                                  					; last of the file?
  4708 00001E35 7407                    	jz	short lff11s_0		; no
  4709 00001E37 F9                      	stc
  4710 00001E38 C3                      	retn
  4711                                  
  4712                                  lff11m_3:
  4713                                  lff11s_3:
  4714 00001E39 E9CDF2FFFF              	jmp	lff11_3	; padfill
  4715                                  		; (put zeros in the remain words of the buffer)
  4716                                  
  4717                                  lff11s_0:
  4718                                  	; 01/12/2024
  4719                                  	; edi = audio buffer address
  4720                                  	; 13/12/2024
  4721 00001E3E 893D[F4320000]          	mov	[audio_buffer], edi
  4722 00001E44 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4723                                          ;mov	edx, [loadsize]
  4724                                  
  4725                                  	; esi = buffer address
  4726                                  	;; edx = buffer size
  4727                                  
  4728                                  	; load file into memory
  4729                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001E49 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001E4F 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001E51 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001E57 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001E5C CD40                <1>  int 40h
  4730 00001E5E 72C9                    	jc	short lff11s_7 ; error !
  4731                                  
  4732                                  	; 01/12/2024
  4733 00001E60 A3[BC380000]            	mov	[count], eax
  4734                                  
  4735                                  	;mov	edi, audio_buffer
  4736                                  	; 29/05/2024
  4737                                  	;mov	edi, [audio_buffer]
  4738                                  	
  4739 00001E65 D1E8                    	shr	eax, 1
  4740 00001E67 7505                    	jnz	short lff11s_8
  4741 00001E69 E9B5F2FFFF              	jmp	lff11_eof
  4742                                  
  4743                                  lff11s_8:
  4744 00001E6E 89C1                    	mov	ecx, eax	; word count
  4745                                  lff11s_9:
  4746 00001E70 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4747                                  lff11s_1:
  4748                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4749 00001E75 66AD                    	lodsw
  4750 00001E77 66BA8080                	mov	dx, 8080h
  4751 00001E7B 49                      	dec	ecx
  4752 00001E7C 7403                    	jz	short lff11s_2_1
  4753 00001E7E 668B16                  	mov	dx, [esi]
  4754                                  lff11s_2_1:	
  4755                                  	; al = [previous_val_l]
  4756                                  	; ah = [previous_val_r]
  4757                                  	; dl = [next_val_l]
  4758                                  	; dh = [next_val_r]
  4759 00001E81 E87D050000              	call	interpolating_5_8bit_stereo
  4760 00001E86 E3B1                    	jecxz	lff11s_3
  4761                                  lff11s_2_2:
  4762 00001E88 66AD                    	lodsw
  4763 00001E8A 66BA8080                	mov	dx, 8080h
  4764 00001E8E 49                      	dec	ecx
  4765 00001E8F 7403                    	jz	short lff11s_2_3
  4766 00001E91 668B16                  	mov	dx, [esi]
  4767                                  lff11s_2_3:
  4768 00001E94 E856060000               	call	interpolating_4_8bit_stereo
  4769 00001E99 E39E                    	jecxz	lff11s_3
  4770                                  	
  4771 00001E9B 4D                      	dec	ebp
  4772 00001E9C 74D2                    	jz	short lff11s_9
  4773                                  
  4774 00001E9E 66AD                    	lodsw
  4775 00001EA0 66BA8080                	mov	dx, 8080h
  4776 00001EA4 49                      	dec	ecx
  4777 00001EA5 7403                    	jz	short lff11s_2_4
  4778 00001EA7 668B16                  	mov	dx, [esi]
  4779                                  lff11s_2_4:
  4780 00001EAA E840060000              	call	interpolating_4_8bit_stereo
  4781 00001EAF E388                    	jecxz	lff11s_3
  4782 00001EB1 EBC2                    	jmp	short lff11s_1
  4783                                  
  4784                                  load_11khz_mono_16_bit:
  4785                                  	; 18/11/2023
  4786 00001EB3 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4787                                  					; last of the file?
  4788 00001EBA 7402                    	jz	short lff11m2_0		; no
  4789 00001EBC F9                      	stc
  4790 00001EBD C3                      	retn
  4791                                  
  4792                                  lff11m2_0:
  4793                                  	; 01/12/2024
  4794                                  	; edi = audio buffer address
  4795                                  	; 13/12/2024
  4796 00001EBE 893D[F4320000]          	mov	[audio_buffer], edi
  4797 00001EC4 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4798                                          ;mov	edx, [loadsize]
  4799                                  
  4800                                  	; esi = buffer address
  4801                                  	;; edx = buffer size
  4802                                  
  4803                                  	; load file into memory
  4804                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001EC9 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001ECF 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001ED1 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001ED7 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001EDC CD40                <1>  int 40h
  4805 00001EDE 724D                    	jc	short lff11m2_7 ; error !
  4806                                  
  4807                                  	; 01/12/2024
  4808 00001EE0 A3[BC380000]            	mov	[count], eax
  4809                                  
  4810                                  	;mov	edi, audio_buffer
  4811                                  	; 29/05/2024
  4812                                  	;mov	edi, [audio_buffer]
  4813                                  	
  4814 00001EE5 D1E8                    	shr	eax, 1
  4815 00001EE7 7505                    	jnz	short lff11m2_8
  4816 00001EE9 E935F2FFFF              	jmp	lff11_eof
  4817                                  
  4818                                  lff11m2_8:
  4819 00001EEE 89C1                    	mov	ecx, eax	; word count
  4820                                  lff11m2_9:
  4821 00001EF0 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4822                                  lff11m2_1:
  4823                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4824 00001EF5 66AD                    	lodsw
  4825 00001EF7 31D2                    	xor	edx, edx
  4826 00001EF9 49                      	dec	ecx
  4827 00001EFA 7403                    	jz	short lff11m2_2_1
  4828 00001EFC 668B16                  	mov	dx, [esi]
  4829                                  lff11m2_2_1:	
  4830                                  	; ax = [previous_val]
  4831                                  	; dx = [next_val]
  4832 00001EFF E858060000              	call	interpolating_5_16bit_mono
  4833 00001F04 E368                    	jecxz	lff11m2_3
  4834                                  lff11m2_2_2:
  4835 00001F06 66AD                    	lodsw
  4836 00001F08 31D2                    	xor	edx, edx
  4837 00001F0A 49                      	dec	ecx
  4838 00001F0B 7403                    	jz	short lff11m2_2_3
  4839 00001F0D 668B16                  	mov	dx, [esi]
  4840                                  lff11m2_2_3:
  4841 00001F10 E871070000               	call	interpolating_4_16bit_mono
  4842 00001F15 E357                    	jecxz	lff11m2_3
  4843                                  
  4844 00001F17 4D                      	dec	ebp
  4845 00001F18 74D6                    	jz	short lff11m2_9
  4846                                  
  4847 00001F1A 66AD                    	lodsw
  4848 00001F1C 31D2                    	xor	edx, edx
  4849 00001F1E 49                      	dec	ecx
  4850 00001F1F 7403                    	jz	short lff11m2_2_4
  4851 00001F21 668B16                  	mov	dx, [esi]
  4852                                  lff11m2_2_4:
  4853 00001F24 E85D070000               	call	interpolating_4_16bit_mono
  4854 00001F29 E343                    	jecxz	lff11m2_3
  4855 00001F2B EBC8                    	jmp	short lff11m2_1
  4856                                  
  4857                                  lff11m2_7:
  4858                                  lff11s2_7:
  4859 00001F2D E9FAF1FFFF              	jmp	lff11_5  ; error
  4860                                  
  4861                                  load_11khz_stereo_16_bit:
  4862                                  	; 18/11/2023
  4863 00001F32 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4864                                  					; last of the file?
  4865 00001F39 7402                    	jz	short lff11s2_0		; no
  4866 00001F3B F9                      	stc
  4867 00001F3C C3                      	retn
  4868                                  
  4869                                  lff11s2_0:
  4870                                  	; 01/12/2024
  4871                                  	; edi = audio buffer address
  4872                                  	; 13/12/2024
  4873 00001F3D 893D[F4320000]          	mov	[audio_buffer], edi
  4874 00001F43 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4875                                          ;mov	edx, [loadsize]
  4876                                  
  4877                                  	; esi = buffer address
  4878                                  	;; edx = buffer size
  4879                                  
  4880                                  	; load file into memory
  4881                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00001F48 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00001F4E 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00001F50 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00001F56 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00001F5B CD40                <1>  int 40h
  4882 00001F5D 72CE                    	jc	short lff11s2_7 ; error !
  4883                                  
  4884                                  	; 01/12/2024
  4885 00001F5F A3[BC380000]            	mov	[count], eax
  4886                                  
  4887                                  	;mov	edi, audio_buffer
  4888                                  	; 29/05/2024
  4889                                  	;mov	edi, [audio_buffer]
  4890                                  	
  4891 00001F64 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  4892 00001F67 750A                    	jnz	short lff11s2_8
  4893 00001F69 E9B5F1FFFF              	jmp	lff11_eof
  4894                                  
  4895                                  lff11m2_3:
  4896                                  lff11s2_3:
  4897 00001F6E E998F1FFFF              	jmp	lff11_3	; padfill
  4898                                  		; (put zeros in the remain words of the buffer)
  4899                                  
  4900                                  lff11s2_8:
  4901 00001F73 89C1                    	mov	ecx, eax	; dword count
  4902                                  lff11s2_9:
  4903 00001F75 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4904                                  lff11s2_1:
  4905                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4906 00001F7A 66AD                    	lodsw
  4907 00001F7C 89C3                    	mov	ebx, eax
  4908 00001F7E 66AD                    	lodsw
  4909 00001F80 8B16                    	mov	edx, [esi]
  4910 00001F82 8915[40270000]          	mov	[next_val_l], edx
  4911                                  	; 26/11/2023
  4912 00001F88 C1EA10                  	shr	edx, 16
  4913                                  	;mov	[next_val_r], dx
  4914 00001F8B 49                      	dec	ecx
  4915 00001F8C 7509                    	jnz	short lff11s2_2_1
  4916 00001F8E 31D2                    	xor	edx, edx ; 0
  4917 00001F90 668915[40270000]        	mov	[next_val_l], dx
  4918                                  	;mov	[next_val_r], dx
  4919                                  lff11s2_2_1:
  4920                                  	; bx = [previous_val_l]
  4921                                  	; ax = [previous_val_r]
  4922                                  	; [next_val_l]
  4923                                  	; dx = [next_val_r]
  4924 00001F97 E81B060000              	call	interpolating_5_16bit_stereo
  4925 00001F9C E3D0                    	jecxz	lff11s2_3
  4926                                  lff11s2_2_2:
  4927 00001F9E 66AD                    	lodsw
  4928 00001FA0 89C3                    	mov	ebx, eax
  4929 00001FA2 66AD                    	lodsw
  4930 00001FA4 8B16                    	mov	edx, [esi]
  4931 00001FA6 668915[40270000]        	mov	[next_val_l], dx
  4932                                  	; 26/11/2023
  4933 00001FAD C1EA10                  	shr	edx, 16
  4934                                  	;mov	[next_val_r], dx
  4935 00001FB0 49                      	dec	ecx
  4936 00001FB1 7509                    	jnz	short lff11s2_2_3
  4937 00001FB3 31D2                    	xor	edx, edx ; 0
  4938 00001FB5 668915[40270000]        	mov	[next_val_l], dx
  4939                                  	;mov	[next_val_r], dx
  4940                                  lff11s2_2_3:
  4941 00001FBC E8FE060000               	call	interpolating_4_16bit_stereo
  4942 00001FC1 E3AB                    	jecxz	lff11s2_3
  4943                                  	
  4944 00001FC3 4D                      	dec	ebp
  4945 00001FC4 74AF                    	jz	short lff11s2_9
  4946                                  
  4947 00001FC6 66AD                    	lodsw
  4948 00001FC8 89C3                    	mov	ebx, eax
  4949 00001FCA 66AD                    	lodsw
  4950 00001FCC 8B16                    	mov	edx, [esi]
  4951 00001FCE 668915[40270000]        	mov	[next_val_l], dx
  4952                                  	; 26/11/2023
  4953 00001FD5 C1EA10                  	shr	edx, 16
  4954                                  	;mov	[next_val_r], dx
  4955 00001FD8 49                      	dec	ecx
  4956 00001FD9 7509                    	jnz	short lff11s2_2_4
  4957 00001FDB 31D2                    	xor	edx, edx ; 0
  4958 00001FDD 668915[40270000]        	mov	[next_val_l], dx
  4959                                  	;mov	[next_val_r], dx
  4960                                  lff11s2_2_4:
  4961 00001FE4 E8D6060000               	call	interpolating_4_16bit_stereo
  4962 00001FE9 E383                    	jecxz	lff11s2_3
  4963 00001FEB EB8D                    	jmp	short lff11s2_1
  4964                                  
  4965                                  ; .....................
  4966                                  
  4967                                  load_44khz_mono_8_bit:
  4968                                  	; 18/11/2023
  4969 00001FED F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4970                                  					; last of the file?
  4971 00001FF4 7402                    	jz	short lff44m_0		; no
  4972 00001FF6 F9                      	stc
  4973 00001FF7 C3                      	retn
  4974                                  
  4975                                  lff44m_0:
  4976                                  	; 01/12/2024
  4977                                  	; edi = audio buffer address
  4978                                  	; 13/12/2024
  4979 00001FF8 893D[F4320000]          	mov	[audio_buffer], edi
  4980 00001FFE BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4981                                          ;mov	edx, [loadsize]
  4982                                  
  4983                                  	; esi = buffer address
  4984                                  	;; edx = buffer size
  4985                                  
  4986                                  	; load file into memory
  4987                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002003 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00002009 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000200B 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002011 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00002016 CD40                <1>  int 40h
  4988 00002018 7250                    	jc	short lff44m_7 ; error !
  4989                                  
  4990                                  	; 01/12/2024
  4991 0000201A A3[BC380000]            	mov	[count], eax
  4992                                  
  4993                                  	;mov	edi, audio_buffer
  4994                                  	; 29/05/2024
  4995                                  	;mov	edi, [audio_buffer]
  4996                                  	
  4997 0000201F 21C0                    	and	eax, eax
  4998 00002021 7505                    	jnz	short lff44m_8
  4999 00002023 E9FBF0FFFF              	jmp	lff44_eof
  5000                                  
  5001                                  lff44m_8:
  5002 00002028 89C1                    	mov	ecx, eax	; byte count
  5003                                  lff44m_9:
  5004 0000202A BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5005 0000202F C605[44270000]02        	mov	byte [faz], 2  ; 2 steps/phases
  5006                                  lff44m_1:
  5007                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5008                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5009 00002036 AC                      	lodsb
  5010 00002037 B280                    	mov	dl, 80h
  5011 00002039 49                      	dec	ecx
  5012 0000203A 7402                    	jz	short lff44m_2_1
  5013 0000203C 8A16                    	mov	dl, [esi]
  5014                                  lff44m_2_1:	
  5015                                  	; al = [previous_val]
  5016                                  	; dl = [next_val]
  5017 0000203E E837020000              	call	interpolating_2_8bit_mono
  5018 00002043 E320                    	jecxz	lff44m_3
  5019                                  lff44m_2_2:
  5020 00002045 AC                      	lodsb
  5021 00002046 2C80                    	sub	al, 80h
  5022 00002048 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5023 0000204C 66AB                    	stosw		; (L)
  5024 0000204E 66AB                    	stosw		; (R)
  5025                                  
  5026 00002050 49                      	dec	ecx
  5027 00002051 7412                    	jz	short lff44m_3
  5028 00002053 4D                      	dec	ebp
  5029 00002054 75EF                    	jnz	short lff44m_2_2
  5030                                  	
  5031 00002056 FE0D[44270000]          	dec	byte [faz]
  5032 0000205C 74CC                    	jz	short lff44m_9 
  5033 0000205E BD0B000000              	mov	ebp, 11
  5034 00002063 EBD1                    	jmp	short lff44m_1
  5035                                  
  5036                                  lff44m_3:
  5037                                  lff44s_3:
  5038 00002065 E9A1F0FFFF              	jmp	lff44_3	; padfill
  5039                                  		; (put zeros in the remain words of the buffer)
  5040                                  lff44m_7:
  5041                                  lff44s_7:
  5042 0000206A E9BDF0FFFF              	jmp	lff44_5  ; error
  5043                                  
  5044                                  load_44khz_stereo_8_bit:
  5045                                  	; 16/11/2023
  5046 0000206F F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5047                                  					; last of the file?
  5048 00002076 7402                    	jz	short lff44s_0		; no
  5049 00002078 F9                      	stc
  5050 00002079 C3                      	retn
  5051                                  
  5052                                  lff44s_0:
  5053                                  	; 01/12/2024
  5054                                  	; edi = audio buffer address
  5055                                  	; 13/12/2024
  5056 0000207A 893D[F4320000]          	mov	[audio_buffer], edi
  5057 00002080 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5058                                          ;mov	edx, [loadsize]
  5059                                  
  5060                                  	; esi = buffer address
  5061                                  	;; edx = buffer size
  5062                                  
  5063                                  	; load file into memory
  5064                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002085 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000208B 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000208D 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002093 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 00002098 CD40                <1>  int 40h
  5065 0000209A 72CE                    	jc	short lff44s_7 ; error !
  5066                                  
  5067                                  	; 01/12/2024
  5068 0000209C A3[BC380000]            	mov	[count], eax
  5069                                  
  5070                                  	;mov	edi, audio_buffer
  5071                                  	; 29/05/2024
  5072                                  	;mov	edi, [audio_buffer]
  5073                                  	
  5074 000020A1 D1E8                    	shr	eax, 1
  5075 000020A3 7505                    	jnz	short lff44s_8
  5076 000020A5 E979F0FFFF              	jmp	lff44_eof
  5077                                  
  5078                                  lff44s_8:
  5079 000020AA 89C1                    	mov	ecx, eax	; word count
  5080                                  lff44s_9:
  5081 000020AC BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5082 000020B1 C605[44270000]02        	mov	byte [faz], 2  ; 2 steps/phase
  5083                                  lff44s_1:
  5084                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5085                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5086 000020B8 66AD                    	lodsw
  5087 000020BA 66BA8080                	mov	dx, 8080h
  5088 000020BE 49                      	dec	ecx
  5089 000020BF 7403                    	jz	short lff44s_2_1
  5090 000020C1 668B16                  	mov	dx, [esi]
  5091                                  lff44s_2_1:	
  5092                                  	; al = [previous_val_l]
  5093                                  	; ah = [previous_val_r]
  5094                                  	; dl = [next_val_l]
  5095                                  	; dh = [next_val_r]
  5096 000020C4 E8CE010000              	call	interpolating_2_8bit_stereo
  5097 000020C9 E39A                    	jecxz	lff44s_3
  5098                                  lff44s_2_2:
  5099 000020CB AC                      	lodsb
  5100 000020CC 2C80                    	sub	al, 80h
  5101 000020CE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5102 000020D2 66AB                    	stosw		; (L)
  5103 000020D4 AC                      	lodsb
  5104 000020D5 2C80                    	sub	al, 80h
  5105 000020D7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5106 000020DB 66AB                    	stosw		; (R)
  5107                                  
  5108 000020DD 49                      	dec	ecx
  5109 000020DE 7485                    	jz	short lff44s_3	
  5110 000020E0 4D                      	dec	ebp
  5111 000020E1 75E8                    	jnz	short lff44s_2_2
  5112                                  	
  5113 000020E3 FE0D[44270000]          	dec	byte [faz]
  5114 000020E9 74C1                    	jz	short lff44s_9 
  5115 000020EB BD0B000000              	mov	ebp, 11
  5116 000020F0 EBC6                    	jmp	short lff44s_1
  5117                                  
  5118                                  load_44khz_mono_16_bit:
  5119                                  	; 18/11/2023
  5120 000020F2 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5121                                  					; last of the file?
  5122 000020F9 7402                    	jz	short lff44m2_0		; no
  5123 000020FB F9                      	stc
  5124 000020FC C3                      	retn
  5125                                  
  5126                                  lff44m2_0:
  5127                                  	; 01/12/2024
  5128                                  	; edi = audio buffer address
  5129                                  	; 13/12/2024
  5130 000020FD 893D[F4320000]          	mov	[audio_buffer], edi
  5131 00002103 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5132                                          ;mov	edx, [loadsize]
  5133                                  
  5134                                  	; esi = buffer address
  5135                                  	;; edx = buffer size
  5136                                  
  5137                                  	; load file into memory
  5138                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002108 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000210E 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00002110 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002116 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 0000211B CD40                <1>  int 40h
  5139 0000211D 724D                    	jc	short lff44m2_7 ; error !
  5140                                  
  5141                                  	; 01/12/2024
  5142 0000211F A3[BC380000]            	mov	[count], eax
  5143                                  
  5144                                  	;mov	edi, audio_buffer
  5145                                  	; 29/05/2024
  5146                                  	;mov	edi, [audio_buffer]
  5147                                  	
  5148 00002124 D1E8                    	shr	eax, 1
  5149 00002126 7505                    	jnz	short lff44m2_8
  5150 00002128 E9F6EFFFFF              	jmp	lff44_eof
  5151                                  
  5152                                  lff44m2_8:
  5153 0000212D 89C1                    	mov	ecx, eax	; word count
  5154                                  lff44m2_9:
  5155 0000212F BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5156 00002134 C605[44270000]02        	mov	byte [faz], 2  ; 2 steps/phases
  5157                                  lff44m2_1:
  5158                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5159                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5160 0000213B 66AD                    	lodsw
  5161 0000213D 31D2                    	xor	edx, edx
  5162 0000213F 49                      	dec	ecx
  5163 00002140 7403                    	jz	short lff44m2_2_1
  5164 00002142 668B16                  	mov	dx, [esi]
  5165                                  lff44m2_2_1:	
  5166                                  	; ax = [previous_val]
  5167                                  	; dx = [next_val]
  5168 00002145 E811020000              	call	interpolating_2_16bit_mono
  5169 0000214A E31B                    	jecxz	lff44m2_3
  5170                                  lff44m2_2_2:
  5171 0000214C 66AD                    	lodsw
  5172 0000214E 66AB                    	stosw		; (L)eft Channel
  5173 00002150 66AB                    	stosw		; (R)ight Channel
  5174                                  
  5175 00002152 49                      	dec	ecx
  5176 00002153 7412                    	jz	short lff44m2_3	
  5177 00002155 4D                      	dec	ebp
  5178 00002156 75F4                    	jnz	short lff44m2_2_2
  5179                                  	
  5180 00002158 FE0D[44270000]          	dec	byte [faz]
  5181 0000215E 74CF                    	jz	short lff44m2_9 
  5182 00002160 BD0B000000              	mov	ebp, 11
  5183 00002165 EBD4                    	jmp	short lff44m2_1
  5184                                  
  5185                                  lff44m2_3:
  5186                                  lff44s2_3:
  5187 00002167 E99FEFFFFF              	jmp	lff44_3	; padfill
  5188                                  		; (put zeros in the remain words of the buffer)
  5189                                  lff44m2_7:
  5190                                  lff44s2_7:
  5191 0000216C E9BBEFFFFF              	jmp	lff44_5  ; error
  5192                                  
  5193                                  load_44khz_stereo_16_bit:
  5194                                  	; 18/11/2023
  5195 00002171 F605[36380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5196                                  					; last of the file?
  5197 00002178 7402                    	jz	short lff44s2_0		; no
  5198 0000217A F9                      	stc
  5199 0000217B C3                      	retn
  5200                                  
  5201                                  lff44s2_0:
  5202                                  	; 01/12/2024
  5203                                  	; edi = audio buffer address
  5204                                  	; 13/12/2024
  5205 0000217C 893D[F4320000]          	mov	[audio_buffer], edi
  5206 00002182 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5207                                          ;mov	edx, [loadsize]
  5208                                  
  5209                                  	; esi = buffer address
  5210                                  	;; edx = buffer size
  5211                                  
  5212                                  	; load file into memory
  5213                                  	sys 	_read, [filehandle], esi, [loadsize]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002187 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 0000218D 89F1                <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 0000218F 8B15[AC380000]      <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002195 B803000000          <1>  mov eax, %1
   104                              <1> 
   105 0000219A CD40                <1>  int 40h
  5214 0000219C 72CE                    	jc	short lff44s2_7 ; error !
  5215                                  
  5216                                  	; 01/12/2024
  5217 0000219E A3[BC380000]            	mov	[count], eax
  5218                                  
  5219                                  	;mov	edi, audio_buffer
  5220                                  	; 29/05/2024
  5221                                  	;mov	edi, [audio_buffer]
  5222                                  	
  5223 000021A3 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  5224 000021A6 7505                    	jnz	short lff44s2_8
  5225 000021A8 E976EFFFFF              	jmp	lff44_eof
  5226                                  
  5227                                  lff44s2_8:
  5228 000021AD 89C1                    	mov	ecx, eax	; dword count
  5229                                  lff44s2_9:
  5230 000021AF BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5231 000021B4 C605[44270000]02        	mov	byte [faz], 2  ; 2 steps/phase
  5232                                  lff44s2_1:
  5233                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5234                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5235 000021BB 66AD                    	lodsw
  5236 000021BD 89C3                    	mov	ebx, eax
  5237 000021BF 66AD                    	lodsw
  5238                                  	;mov	dx, [esi]
  5239                                  	;mov	[next_val_l], dx
  5240                                  	;mov	dx, [esi+2]
  5241                                  	; 26/11/2023
  5242 000021C1 8B16                    	mov	edx, [esi]
  5243 000021C3 668915[40270000]        	mov	[next_val_l], dx
  5244 000021CA C1EA10                  	shr	edx, 16
  5245 000021CD 49                      	dec	ecx
  5246 000021CE 7509                    	jnz	short lff44s2_2_1
  5247 000021D0 31D2                    	xor	edx, edx ; 0
  5248 000021D2 668915[40270000]        	mov	[next_val_l], dx
  5249                                  lff44s2_2_1:
  5250                                  	; bx = [previous_val_l]
  5251                                  	; ax = [previous_val_r]
  5252                                  	; [next_val_l]
  5253                                  	; dx = [next_val_r]
  5254 000021D9 E895010000              	call	interpolating_2_16bit_stereo
  5255 000021DE E387                    	jecxz	lff44s2_3
  5256                                  lff44s2_2_2:
  5257                                  	;movsw		; (L)eft Channel
  5258                                  	;movsw		; (R)ight Channel
  5259 000021E0 A5                      	movsd
  5260                                  
  5261 000021E1 49                      	dec	ecx
  5262 000021E2 7483                    	jz	short lff44s2_3	
  5263 000021E4 4D                      	dec	ebp
  5264 000021E5 75F9                    	jnz	short lff44s2_2_2
  5265                                  	
  5266 000021E7 FE0D[44270000]          	dec	byte [faz]
  5267 000021ED 74C0                    	jz	short lff44s2_9 
  5268 000021EF BD0B000000              	mov	ebp, 11
  5269 000021F4 EBC5                    	jmp	short lff44s2_1
  5270                                  
  5271                                  ; .....................
  5272                                  
  5273                                  interpolating_3_8bit_mono:
  5274                                  	; 16/11/2023
  5275                                  	; al = [previous_val]
  5276                                  	; dl = [next_val]
  5277                                  	; original-interpolated-interpolated
  5278 000021F6 88C3                    	mov	bl, al
  5279 000021F8 2C80                    	sub	al, 80h
  5280 000021FA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5281 000021FE 66AB                    	stosw		; original sample (L)
  5282 00002200 66AB                    	stosw		; original sample (R)
  5283 00002202 88D8                    	mov	al, bl
  5284 00002204 00D0                    	add	al, dl
  5285 00002206 D0D8                    	rcr	al, 1
  5286 00002208 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5287 0000220A 00D8                    	add	al, bl
  5288 0000220C D0D8                    	rcr	al, 1
  5289 0000220E 2C80                    	sub	al, 80h
  5290 00002210 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5291 00002214 66AB                    	stosw		; interpolated sample 1 (L)
  5292 00002216 66AB                    	stosw		; interpolated sample 1 (R)
  5293 00002218 88F8                    	mov	al, bh
  5294 0000221A 00D0                    	add	al, dl	; [next_val]
  5295 0000221C D0D8                    	rcr	al, 1
  5296 0000221E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5297 00002222 66AB                    	stosw		; interpolated sample 2 (L)
  5298 00002224 66AB                    	stosw		; interpolated sample 2 (R)
  5299 00002226 C3                      	retn
  5300                                  
  5301                                  interpolating_3_8bit_stereo:
  5302                                  	; 16/11/2023
  5303                                  	; al = [previous_val_l]
  5304                                  	; ah = [previous_val_r]
  5305                                  	; dl = [next_val_l]
  5306                                  	; dh = [next_val_r]
  5307                                  	; original-interpolated-interpolated
  5308 00002227 89C3                    	mov	ebx, eax
  5309 00002229 2C80                    	sub	al, 80h
  5310 0000222B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5311 0000222F 66AB                    	stosw		; original sample (L)
  5312 00002231 88F8                    	mov	al, bh
  5313 00002233 2C80                    	sub	al, 80h
  5314 00002235 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5315 00002239 66AB                    	stosw		; original sample (R)
  5316 0000223B 88D8                    	mov	al, bl
  5317 0000223D 00D0                    	add	al, dl	; [next_val_l]
  5318 0000223F D0D8                    	rcr	al, 1
  5319 00002241 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  5320 00002242 00D8                    	add	al, bl	; [previous_val_l]
  5321 00002244 D0D8                    	rcr	al, 1
  5322 00002246 2C80                    	sub	al, 80h
  5323 00002248 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5324 0000224C 66AB                    	stosw		; interpolated sample 1 (L)
  5325 0000224E 88F8                    	mov	al, bh
  5326 00002250 00F0                    	add	al, dh	; [next_val_r]
  5327 00002252 D0D8                    	rcr	al, 1
  5328 00002254 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  5329 00002255 00F8                    	add	al, bh	; [previous_val_r]
  5330 00002257 D0D8                    	rcr	al, 1
  5331 00002259 2C80                    	sub	al, 80h
  5332 0000225B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5333 0000225F 66AB                    	stosw		; interpolated sample 1 (R)
  5334 00002261 5B                      	pop	ebx ; **
  5335 00002262 58                      	pop	eax ; *
  5336 00002263 00D0                    	add	al, dl	; [next_val_l]
  5337 00002265 D0D8                    	rcr	al, 1
  5338 00002267 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5339 0000226B 66AB                    	stosw		; interpolated sample 2 (L)
  5340 0000226D 88D8                    	mov	al, bl
  5341 0000226F 00F0                    	add	al, dh	; [next_val_r]
  5342 00002271 D0D8                    	rcr	al, 1
  5343 00002273 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5344 00002277 66AB                    	stosw		; interpolated sample 2 (R)
  5345 00002279 C3                      	retn
  5346                                  
  5347                                  interpolating_2_8bit_mono:
  5348                                  	; 16/11/2023
  5349                                  	; al = [previous_val]
  5350                                  	; dl = [next_val]
  5351                                  	; original-interpolated
  5352 0000227A 88C3                    	mov	bl, al
  5353 0000227C 2C80                    	sub	al, 80h
  5354 0000227E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5355 00002282 66AB                    	stosw		; original sample (L)
  5356 00002284 66AB                    	stosw		; original sample (R)
  5357 00002286 88D8                    	mov	al, bl
  5358 00002288 00D0                    	add	al, dl
  5359 0000228A D0D8                    	rcr	al, 1
  5360 0000228C 2C80                    	sub	al, 80h
  5361 0000228E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5362 00002292 66AB                    	stosw		; interpolated sample (L)
  5363 00002294 66AB                    	stosw		; interpolated sample (R)
  5364 00002296 C3                      	retn
  5365                                  
  5366                                  interpolating_2_8bit_stereo:
  5367                                  	; 16/11/2023
  5368                                  	; al = [previous_val_l]
  5369                                  	; ah = [previous_val_r]
  5370                                  	; dl = [next_val_l]
  5371                                  	; dh = [next_val_r]
  5372                                  	; original-interpolated
  5373 00002297 89C3                    	mov	ebx, eax
  5374 00002299 2C80                    	sub	al, 80h
  5375 0000229B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5376 0000229F 66AB                    	stosw		; original sample (L)
  5377 000022A1 88F8                    	mov	al, bh
  5378 000022A3 2C80                    	sub	al, 80h
  5379 000022A5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5380 000022A9 66AB                    	stosw		; original sample (R)
  5381 000022AB 88D8                    	mov	al, bl	; [previous_val_l]
  5382 000022AD 00D0                    	add	al, dl	; [next_val_l]
  5383 000022AF D0D8                    	rcr	al, 1
  5384 000022B1 2C80                    	sub	al, 80h
  5385 000022B3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5386 000022B7 66AB                    	stosw		; interpolated sample (L)
  5387 000022B9 88F8                    	mov	al, bh
  5388 000022BB 00F0                    	add	al, dh	; [next_val_r]
  5389 000022BD D0D8                    	rcr	al, 1
  5390 000022BF 2C80                    	sub	al, 80h
  5391 000022C1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5392 000022C5 66AB                    	stosw		; interpolated sample (R)
  5393 000022C7 C3                      	retn
  5394                                  
  5395                                  interpolating_3_16bit_mono:
  5396                                  	; 16/11/2023
  5397                                  	; ax = [previous_val]
  5398                                  	; dx = [next_val]
  5399                                  	; original-interpolated-interpolated
  5400                                  
  5401 000022C8 66AB                    	stosw		; original sample (L)
  5402 000022CA 66AB                    	stosw		; original sample (R)
  5403 000022CC 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5404 000022CF 50                      	push	eax ; *	; [previous_val]
  5405 000022D0 80C680                  	add	dh, 80h
  5406 000022D3 6601D0                  	add	ax, dx
  5407 000022D6 66D1D8                  	rcr	ax, 1
  5408 000022D9 5B                      	pop	ebx ; *
  5409 000022DA 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  5410 000022DB 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  5411 000022DE 66D1D8                  	rcr	ax, 1
  5412 000022E1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5413 000022E4 66AB                    	stosw 		; interpolated sample 1 (L)
  5414 000022E6 66AB                    	stosw		; interpolated sample 1 (R)
  5415 000022E8 89D8                    	mov	eax, ebx
  5416 000022EA 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  5417 000022ED 66D1D8                  	rcr	ax, 1
  5418 000022F0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5419 000022F3 66AB                    	stosw		; interpolated sample 2 (L)
  5420 000022F5 66AB                    	stosw		; interpolated sample 2 (R)
  5421 000022F7 C3                      	retn
  5422                                  
  5423                                  interpolating_3_16bit_stereo:
  5424                                  	; 16/11/2023
  5425                                  	; bx = [previous_val_l]
  5426                                  	; ax = [previous_val_r]
  5427                                  	; [next_val_l]
  5428                                  	; dx = [next_val_r]
  5429                                  	; original-interpolated-interpolated
  5430                                  
  5431 000022F8 93                      	xchg	eax, ebx
  5432 000022F9 66AB                    	stosw		; original sample (L)
  5433 000022FB 93                      	xchg	eax, ebx
  5434 000022FC 66AB                    	stosw		; original sample (R)
  5435 000022FE 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5436 00002301 50                      	push	eax ; *	; [previous_val_r]
  5437 00002302 80C780                  	add	bh, 80h
  5438 00002305 8005[41270000]80        	add	byte [next_val_l+1], 80h
  5439 0000230C 66A1[40270000]          	mov	ax, [next_val_l]
  5440 00002312 6601D8                  	add	ax, bx	; [previous_val_l]
  5441 00002315 66D1D8                  	rcr	ax, 1
  5442 00002318 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  5443 00002319 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  5444 0000231C 66D1D8                  	rcr	ax, 1
  5445 0000231F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5446 00002322 66AB                    	stosw 		; interpolated sample 1 (L)
  5447 00002324 58                      	pop	eax  ; *
  5448 00002325 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  5449 00002328 52                      	push	edx  ; * ; [next_val_r]
  5450 00002329 92                      	xchg	eax, edx
  5451 0000232A 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  5452 0000232D 66D1D8                  	rcr	ax, 1	; / 2
  5453 00002330 50                      	push	eax ; ** ; interpolated middle (R)
  5454 00002331 6601D0                  	add	ax, dx	; + [previous_val_r]
  5455 00002334 66D1D8                  	rcr	ax, 1
  5456 00002337 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5457 0000233A 66AB                    	stosw 		; interpolated sample 1 (R)
  5458 0000233C 66A1[40270000]          	mov	ax, [next_val_l]
  5459 00002342 6601D8                  	add	ax, bx	; + interpolated middle (L)
  5460 00002345 66D1D8                  	rcr	ax, 1
  5461 00002348 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5462 0000234B 66AB                    	stosw 		; interpolated sample 2 (L)
  5463 0000234D 58                      	pop	eax ; **
  5464 0000234E 5A                      	pop	edx ; *
  5465 0000234F 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  5466 00002352 66D1D8                  	rcr	ax, 1	; / 2
  5467 00002355 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5468 00002358 66AB                    	stosw 		; interpolated sample 2 (L)
  5469 0000235A C3                      	retn
  5470                                  
  5471                                  interpolating_2_16bit_mono:
  5472                                  	; 16/11/2023
  5473                                  	; ax = [previous_val]
  5474                                  	; dx = [next_val]
  5475                                  	; original-interpolated
  5476                                  
  5477 0000235B 66AB                    	stosw		; original sample (L)
  5478 0000235D 66AB                    	stosw		; original sample (R)
  5479 0000235F 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5480 00002362 80C680                  	add	dh, 80h
  5481 00002365 6601D0                  	add	ax, dx
  5482 00002368 66D1D8                  	rcr	ax, 1
  5483 0000236B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5484 0000236E 66AB                    	stosw		; interpolated sample (L)
  5485 00002370 66AB                    	stosw		; interpolated sample (R)
  5486 00002372 C3                      	retn
  5487                                  
  5488                                  interpolating_2_16bit_stereo:
  5489                                  	; 16/11/2023
  5490                                  	; bx = [previous_val_l]
  5491                                  	; ax = [previous_val_r]
  5492                                  	; [next_val_l]
  5493                                  	; dx = [next_val_r]
  5494                                  	; original-interpolated
  5495                                  
  5496 00002373 93                      	xchg	eax, ebx
  5497 00002374 66AB                    	stosw		; original sample (L)
  5498 00002376 93                      	xchg	eax, ebx
  5499 00002377 66AB                    	stosw		; original sample (R)
  5500 00002379 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5501 0000237C 80C680                  	add	dh, 80h
  5502 0000237F 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  5503 00002382 66D1D8                  	rcr	ax, 1	; / 2
  5504 00002385 50                      	push	eax ; *	; interpolated sample (R)
  5505 00002386 66A1[40270000]          	mov	ax, [next_val_l]
  5506 0000238C 80C480                  	add	ah, 80h
  5507 0000238F 80C780                  	add	bh, 80h
  5508 00002392 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  5509 00002395 66D1D8                  	rcr	ax, 1	; / 2
  5510 00002398 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5511 0000239B 66AB                    	stosw 		; interpolated sample (L)
  5512 0000239D 58                      	pop	eax ; *	
  5513 0000239E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5514 000023A1 66AB                    	stosw 		; interpolated sample (R)
  5515 000023A3 C3                      	retn
  5516                                  
  5517                                  interpolating_5_8bit_mono:
  5518                                  	; 17/11/2023
  5519                                  	; al = [previous_val]
  5520                                  	; dl = [next_val]
  5521                                  	; original-interpltd-interpltd-interpltd-interpltd
  5522 000023A4 88C3                    	mov	bl, al
  5523 000023A6 2C80                    	sub	al, 80h
  5524 000023A8 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5525 000023AC 66AB                    	stosw		; original sample (L)
  5526 000023AE 66AB                    	stosw		; original sample (R)
  5527 000023B0 88D8                    	mov	al, bl
  5528 000023B2 00D0                    	add	al, dl
  5529 000023B4 D0D8                    	rcr	al, 1
  5530 000023B6 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5531 000023B8 00D8                    	add	al, bl  ; [previous_val]
  5532 000023BA D0D8                    	rcr	al, 1 	
  5533 000023BC 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  5534 000023BE 00D8                    	add	al, bl
  5535 000023C0 D0D8                    	rcr	al, 1
  5536 000023C2 2C80                    	sub	al, 80h
  5537 000023C4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5538 000023C8 66AB                    	stosw		; interpolated sample 1 (L)
  5539 000023CA 66AB                    	stosw		; interpolated sample 1 (R)
  5540 000023CC 88F8                    	mov	al, bh
  5541 000023CE 00F0                    	add	al, dh
  5542 000023D0 D0D8                    	rcr	al, 1
  5543 000023D2 2C80                    	sub	al, 80h
  5544 000023D4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5545 000023D8 66AB                    	stosw		; interpolated sample 2 (L)
  5546 000023DA 66AB                    	stosw		; interpolated sample 2 (R)
  5547 000023DC 88F8                    	mov	al, bh
  5548 000023DE 00D0                    	add	al, dl	; [next_val]
  5549 000023E0 D0D8                    	rcr	al, 1
  5550 000023E2 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  5551 000023E4 00F8                    	add	al, bh
  5552 000023E6 D0D8                    	rcr	al, 1
  5553 000023E8 2C80                    	sub	al, 80h
  5554 000023EA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5555 000023EE 66AB                    	stosw		; interpolated sample 3 (L)
  5556 000023F0 66AB                    	stosw		; interpolated sample 3 (R)
  5557 000023F2 88F0                    	mov	al, dh
  5558 000023F4 00D0                    	add	al, dl
  5559 000023F6 D0D8                    	rcr	al, 1
  5560 000023F8 2C80                    	sub	al, 80h
  5561 000023FA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5562 000023FE 66AB                    	stosw		; interpolated sample 4 (L)
  5563 00002400 66AB                    	stosw		; interpolated sample 4 (R)
  5564 00002402 C3                      	retn
  5565                                  
  5566                                  interpolating_5_8bit_stereo:
  5567                                  	; 17/11/2023
  5568                                  	; al = [previous_val_l]
  5569                                  	; ah = [previous_val_r]
  5570                                  	; dl = [next_val_l]
  5571                                  	; dh = [next_val_r]
  5572                                  	; original-interpltd-interpltd-interpltd-interpltd
  5573 00002403 89C3                    	mov	ebx, eax
  5574 00002405 2C80                    	sub	al, 80h
  5575 00002407 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5576 0000240B 66AB                    	stosw		; original sample (L)
  5577 0000240D 88F8                    	mov	al, bh
  5578 0000240F 2C80                    	sub	al, 80h
  5579 00002411 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5580 00002415 66AB                    	stosw		; original sample (R)
  5581 00002417 52                      	push	edx ; *
  5582 00002418 88D8                    	mov	al, bl
  5583 0000241A 00D0                    	add	al, dl	; [next_val_l]
  5584 0000241C D0D8                    	rcr	al, 1
  5585 0000241E 50                      	push	eax ; **	; al = interpolated middle (L) (temporary)
  5586 0000241F 00D8                    	add	al, bl	; [previous_val_l]
  5587 00002421 D0D8                    	rcr	al, 1
  5588 00002423 86D8                    	xchg	al, bl
  5589 00002425 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  5590 00002427 D0D8                    	rcr	al, 1
  5591 00002429 2C80                    	sub	al, 80h
  5592 0000242B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5593 0000242F 66AB                    	stosw		; interpolated sample 1 (L)
  5594 00002431 88F8                    	mov	al, bh
  5595 00002433 00F0                    	add	al, dh	; [next_val_r]
  5596 00002435 D0D8                    	rcr	al, 1
  5597 00002437 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  5598 00002438 00F8                    	add	al, bh	; [previous_val_r]
  5599 0000243A D0D8                    	rcr	al, 1
  5600 0000243C 86F8                    	xchg	al, bh
  5601 0000243E 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  5602 00002440 D0D8                    	rcr	al, 1
  5603 00002442 2C80                    	sub	al, 80h
  5604 00002444 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5605 00002448 66AB                    	stosw		; interpolated sample 1 (R)
  5606 0000244A 5A                      	pop	edx ; ***
  5607 0000244B 58                      	pop	eax ; **	; al = interpolated middle (L) (temporary)
  5608 0000244C 86D8                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  5609 0000244E 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  5610 00002450 D0D8                    	rcr	al, 1
  5611 00002452 2C80                    	sub	al, 80h
  5612 00002454 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5613 00002458 66AB                    	stosw		; interpolated sample 2 (L)
  5614 0000245A 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  5615 0000245C 86F8                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  5616 0000245E 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  5617 00002460 D0D8                    	rcr	al, 1
  5618 00002462 2C80                    	sub	al, 80h
  5619 00002464 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5620 00002468 66AB                    	stosw		; interpolated sample 2 (R)
  5621 0000246A 5A                      	pop	edx ; *
  5622 0000246B 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  5623 0000246D 00D0                    	add	al, dl	; [next_val_l]
  5624 0000246F D0D8                    	rcr	al, 1
  5625 00002471 86D8                    	xchg	al, bl	; al = interpolated middle (R) (temporary)
  5626 00002473 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  5627 00002475 D0D8                    	rcr	al, 1
  5628 00002477 2C80                    	sub	al, 80h
  5629 00002479 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5630 0000247D 66AB                    	stosw		; interpolated sample 3 (L)
  5631 0000247F 88F8                    	mov	al, bh	
  5632 00002481 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  5633 00002483 D0D8                    	rcr	al, 1
  5634 00002485 86F8                    	xchg	al, bh	; al = interpolated middle (R)
  5635 00002487 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  5636 00002489 D0D8                    	rcr	al, 1
  5637 0000248B 2C80                    	sub	al, 80h
  5638 0000248D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5639 00002491 66AB                    	stosw		; interpolated sample 3 (R)
  5640 00002493 88D8                    	mov	al, bl
  5641 00002495 00D0                    	add	al, dl	; [next_val_l]
  5642 00002497 D0D8                    	rcr	al, 1
  5643 00002499 2C80                    	sub	al, 80h
  5644 0000249B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5645 0000249F 66AB                    	stosw		; interpolated sample 4 (L)
  5646 000024A1 88F8                    	mov	al, bh
  5647 000024A3 00F0                    	add	al, dh	; [next_val_r]
  5648 000024A5 D0D8                    	rcr	al, 1
  5649 000024A7 2C80                    	sub	al, 80h
  5650 000024A9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5651 000024AD 66AB                    	stosw		; interpolated sample 4 (R)
  5652 000024AF C3                      	retn
  5653                                  
  5654                                  interpolating_4_8bit_mono:
  5655                                  	; 17/11/2023
  5656                                  	; al = [previous_val]
  5657                                  	; dl = [next_val]
  5658                                  	; original-interpolated-interpolated-interpolated
  5659 000024B0 88C3                    	mov	bl, al
  5660 000024B2 2C80                    	sub	al, 80h
  5661 000024B4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5662 000024B8 66AB                    	stosw		; original sample (L)
  5663 000024BA 66AB                    	stosw		; original sample (R)
  5664 000024BC 88D8                    	mov	al, bl
  5665 000024BE 00D0                    	add	al, dl	
  5666 000024C0 D0D8                    	rcr	al, 1
  5667 000024C2 86D8                    	xchg	al, bl  ; al = [previous_val]
  5668 000024C4 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  5669 000024C6 D0D8                    	rcr	al, 1 	
  5670 000024C8 2C80                    	sub	al, 80h
  5671 000024CA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5672 000024CE 66AB                    	stosw		; interpolated sample 1 (L)
  5673 000024D0 66AB                    	stosw		; interpolated sample 1 (R)
  5674 000024D2 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  5675 000024D4 2C80                    	sub	al, 80h
  5676 000024D6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5677 000024DA 66AB                    	stosw		; interpolated sample 2 (L)
  5678 000024DC 66AB                    	stosw		; interpolated sample 2 (R)
  5679 000024DE 88D8                    	mov	al, bl
  5680 000024E0 00D0                    	add	al, dl	; [next_val]
  5681 000024E2 D0D8                    	rcr	al, 1
  5682 000024E4 2C80                    	sub	al, 80h
  5683 000024E6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5684 000024EA 66AB                    	stosw		; interpolated sample 3 (L)
  5685 000024EC 66AB                    	stosw		; interpolated sample 3 (R)
  5686 000024EE C3                      	retn
  5687                                  
  5688                                  interpolating_4_8bit_stereo:
  5689                                  	; 17/11/2023
  5690                                  	; al = [previous_val_l]
  5691                                  	; ah = [previous_val_r]
  5692                                  	; dl = [next_val_l]
  5693                                  	; dh = [next_val_r]	
  5694                                  	; original-interpolated-interpolated-interpolated
  5695 000024EF 89C3                    	mov	ebx, eax
  5696 000024F1 2C80                    	sub	al, 80h
  5697 000024F3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5698 000024F7 66AB                    	stosw		; original sample (L)
  5699 000024F9 88F8                    	mov	al, bh
  5700 000024FB 2C80                    	sub	al, 80h
  5701 000024FD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5702 00002501 66AB                    	stosw		; original sample (R)
  5703 00002503 88D8                    	mov	al, bl
  5704 00002505 00D0                    	add	al, dl	; [next_val_l]
  5705 00002507 D0D8                    	rcr	al, 1
  5706 00002509 86D8                    	xchg	al, bl	; al = [previous_val_l]
  5707 0000250B 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  5708 0000250D D0D8                    	rcr	al, 1
  5709 0000250F 2C80                    	sub	al, 80h
  5710 00002511 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5711 00002515 66AB                    	stosw		; interpolated sample 1 (L)
  5712 00002517 88F8                    	mov	al, bh
  5713 00002519 00F0                    	add	al, dh	; [next_val_r]
  5714 0000251B D0D8                    	rcr	al, 1
  5715 0000251D 86F8                    	xchg	al, bh	; al = [previous_val_h]
  5716 0000251F 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  5717 00002521 D0D8                    	rcr	al, 1
  5718 00002523 2C80                    	sub	al, 80h
  5719 00002525 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5720 00002529 66AB                    	stosw		; interpolated sample 1 (R)
  5721 0000252B 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  5722 0000252D 2C80                    	sub	al, 80h
  5723 0000252F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5724 00002533 66AB                    	stosw		; interpolated sample 2 (L)
  5725 00002535 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  5726 00002537 2C80                    	sub	al, 80h
  5727 00002539 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5728 0000253D 66AB                    	stosw		; interpolated sample 2 (L)
  5729 0000253F 88D8                    	mov	al, bl
  5730 00002541 00D0                    	add	al, dl	; [next_val_l]
  5731 00002543 D0D8                    	rcr	al, 1
  5732 00002545 2C80                    	sub	al, 80h
  5733 00002547 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5734 0000254B 66AB                    	stosw		; interpolated sample 3 (L)
  5735 0000254D 88F8                    	mov	al, bh
  5736 0000254F 00F0                    	add	al, dh	; [next_val_r]
  5737 00002551 D0D8                    	rcr	al, 1
  5738 00002553 2C80                    	sub	al, 80h
  5739 00002555 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5740 00002559 66AB                    	stosw		; interpolated sample 3 (R)
  5741 0000255B C3                      	retn
  5742                                  
  5743                                  interpolating_5_16bit_mono:
  5744                                  	; 18/11/2023
  5745                                  	; ax = [previous_val]
  5746                                  	; dx = [next_val]
  5747                                  	; original-interpltd-interpltd-interpltd-interpltd
  5748 0000255C 66AB                    	stosw		; original sample (L)
  5749 0000255E 66AB                    	stosw		; original sample (R)
  5750 00002560 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5751 00002563 89C3                    	mov	ebx, eax ; [previous_val]
  5752 00002565 80C680                  	add	dh, 80h
  5753 00002568 6601D0                  	add	ax, dx
  5754 0000256B 66D1D8                  	rcr	ax, 1
  5755 0000256E 50                      	push	eax ; *	; interpolated middle (temporary)
  5756 0000256F 6601D8                  	add	ax, bx	; interpolated middle + [previous_val] 
  5757 00002572 66D1D8                  	rcr	ax, 1
  5758 00002575 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  5759 00002576 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  5760 00002579 66D1D8                  	rcr	ax, 1	
  5761 0000257C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5762 0000257F 66AB                    	stosw 		; interpolated sample 1 (L)
  5763 00002581 66AB                    	stosw		; interpolated sample 1 (R)
  5764 00002583 58                      	pop	eax ; **
  5765 00002584 5B                      	pop	ebx ; *
  5766 00002585 6601D8                  	add	ax, bx	; 1st quarter + middle
  5767 00002588 66D1D8                  	rcr	ax, 1	; / 2
  5768 0000258B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  5769 0000258E 66AB                    	stosw		; interpolated sample 2 (L)
  5770 00002590 66AB                    	stosw		; interpolated sample 2 (R)
  5771 00002592 89D8                    	mov	eax, ebx
  5772 00002594 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  5773 00002597 66D1D8                  	rcr	ax, 1
  5774 0000259A 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  5775 0000259B 6601D8                  	add	ax, bx	; + interpolated middle
  5776 0000259E 66D1D8                  	rcr	ax, 1
  5777 000025A1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5778 000025A4 66AB                    	stosw		; interpolated sample 3 (L)
  5779 000025A6 66AB                    	stosw		; interpolated sample 3 (R)
  5780 000025A8 58                      	pop	eax ; *	
  5781 000025A9 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  5782 000025AC 66D1D8                  	rcr	ax, 1	; / 2
  5783 000025AF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5784 000025B2 66AB                    	stosw		; interpolated sample 4 (L)
  5785 000025B4 66AB                    	stosw		; interpolated sample 4 (R)
  5786 000025B6 C3                      	retn
  5787                                  
  5788                                  interpolating_5_16bit_stereo:
  5789                                  	; 18/11/2023
  5790                                  	; bx = [previous_val_l]
  5791                                  	; ax = [previous_val_r]
  5792                                  	; [next_val_l]
  5793                                  	; [next_val_r]
  5794                                  	; original-interpltd-interpltd-interpltd-interpltd
  5795 000025B7 51                      	push	ecx ; !
  5796 000025B8 93                      	xchg	eax, ebx
  5797 000025B9 66AB                    	stosw		; original sample (L)
  5798 000025BB 93                      	xchg	eax, ebx
  5799 000025BC 66AB                    	stosw		; original sample (R)
  5800 000025BE 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5801 000025C1 50                      	push	eax ; *	; [previous_val_r]
  5802 000025C2 80C780                  	add	bh, 80h
  5803 000025C5 8005[41270000]80        	add	byte [next_val_l+1], 80h
  5804 000025CC 66A1[40270000]          	mov	ax, [next_val_l]
  5805 000025D2 6601D8                  	add	ax, bx	; [previous_val_l]
  5806 000025D5 66D1D8                  	rcr	ax, 1
  5807 000025D8 89C1                    	mov	ecx, eax ; interpolated middle (L)
  5808 000025DA 6601D8                  	add	ax, bx	
  5809 000025DD 66D1D8                  	rcr	ax, 1
  5810 000025E0 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)
  5811 000025E2 6601D8                  	add	ax, bx	; [previous_val_l]
  5812 000025E5 66D1D8                  	rcr	ax, 1
  5813 000025E8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5814 000025EB 66AB                    	stosw 		; interpolated sample 1 (L)
  5815 000025ED 89C8                    	mov	eax, ecx
  5816 000025EF 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L)
  5817 000025F2 66D1D8                  	rcr	ax, 1	; / 2
  5818 000025F5 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  5819 000025F7 5A                      	pop	edx ; *	; [previous_val_r]
  5820 000025F8 89D0                    	mov	eax, edx
  5821 000025FA 8005[43270000]80        	add	byte [next_val_r+1], 80h
  5822 00002601 660305[42270000]        	add	ax, [next_val_r]
  5823 00002608 66D1D8                  	rcr	ax, 1
  5824 0000260B 50                      	push	eax ; *	; interpolated middle (R)
  5825 0000260C 6601D0                  	add	ax, dx
  5826 0000260F 66D1D8                  	rcr	ax, 1
  5827 00002612 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  5828 00002613 6601D0                  	add	ax, dx	; [previous_val_r]
  5829 00002616 66D1D8                  	rcr	ax, 1
  5830 00002619 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5831 0000261C 66AB                    	stosw 		; interpolated sample 1 (R)
  5832 0000261E 89D8                    	mov	eax, ebx
  5833 00002620 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5834 00002623 66AB                    	stosw 		; interpolated sample 2 (L)
  5835 00002625 58                      	pop	eax ; **
  5836 00002626 5A                      	pop	edx ; *
  5837 00002627 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  5838 0000262A 66D1D8                  	rcr	ax, 1	; / 2
  5839 0000262D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5840 00002630 66AB                    	stosw 		; interpolated sample 2 (R)
  5841 00002632 89C8                    	mov	eax, ecx
  5842 00002634 660305[40270000]        	add	ax, [next_val_l]
  5843 0000263B 66D1D8                  	rcr	ax, 1
  5844 0000263E 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  5845 0000263F 6601C8                  	add	ax, cx	; interpolated middle (L)
  5846 00002642 66D1D8                  	rcr	ax, 1
  5847 00002645 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5848 00002648 66AB                    	stosw 		; interpolated sample 3 (L)
  5849 0000264A 89D0                    	mov	eax, edx
  5850 0000264C 660305[42270000]        	add	ax, [next_val_r]
  5851 00002653 66D1D8                  	rcr	ax, 1
  5852 00002656 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  5853 00002657 6601D0                  	add	ax, dx	; interpolated middle (R)
  5854 0000265A 66D1D8                  	rcr	ax, 1
  5855 0000265D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5856 00002660 66AB                    	stosw 		; interpolated sample 3 (R)
  5857 00002662 5B                      	pop	ebx ; **
  5858 00002663 58                      	pop	eax ; *
  5859 00002664 660305[40270000]        	add	ax, [next_val_l]
  5860 0000266B 66D1D8                  	rcr	ax, 1
  5861 0000266E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5862 00002671 66AB                    	stosw 		; interpolated sample 4 (L)
  5863 00002673 89D8                    	mov	eax, ebx
  5864 00002675 660305[42270000]        	add	ax, [next_val_r]
  5865 0000267C 66D1D8                  	rcr	ax, 1
  5866 0000267F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5867 00002682 66AB                    	stosw 		; interpolated sample 4 (R)
  5868 00002684 59                      	pop	ecx ; !
  5869 00002685 C3                      	retn
  5870                                  
  5871                                  interpolating_4_16bit_mono:
  5872                                  	; 18/11/2023
  5873                                  	; ax = [previous_val]
  5874                                  	; dx = [next_val]
  5875                                  	; original-interpolated
  5876                                  
  5877 00002686 66AB                    	stosw		; original sample (L)
  5878 00002688 66AB                    	stosw		; original sample (R)
  5879 0000268A 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5880 0000268D 89C3                    	mov	ebx, eax ; [previous_val]
  5881 0000268F 80C680                  	add	dh, 80h
  5882 00002692 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  5883 00002695 66D1D8                  	rcr	ax, 1
  5884 00002698 93                      	xchg	eax, ebx
  5885 00002699 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  5886 0000269C 66D1D8                  	rcr	ax, 1
  5887 0000269F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5888 000026A2 66AB                    	stosw 		; interpolated sample 1 (L)
  5889 000026A4 66AB                    	stosw		; interpolated sample 1 (R)
  5890 000026A6 89D8                    	mov	eax, ebx ; interpolated middle
  5891 000026A8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5892 000026AB 66AB                    	stosw 		; interpolated sample 2 (L)
  5893 000026AD 66AB                    	stosw		; interpolated sample 2 (R)
  5894 000026AF 89D8                    	mov	eax, ebx
  5895 000026B1 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  5896 000026B4 66D1D8                  	rcr	ax, 1
  5897 000026B7 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5898 000026BA 66AB                    	stosw		; interpolated sample 3 (L)
  5899 000026BC 66AB                    	stosw		; interpolated sample 3 (R)
  5900 000026BE C3                      	retn
  5901                                  
  5902                                  interpolating_4_16bit_stereo:
  5903                                  	; 18/11/2023
  5904                                  	; bx = [previous_val_l]
  5905                                  	; ax = [previous_val_r]
  5906                                  	; [next_val_l]
  5907                                  	; [next_val_r]
  5908                                  	; original-interpolated-interpolated-interpolated
  5909 000026BF 93                      	xchg	eax, ebx
  5910 000026C0 66AB                    	stosw		; original sample (L)
  5911 000026C2 93                      	xchg	eax, ebx
  5912 000026C3 66AB                    	stosw		; original sample (R)
  5913 000026C5 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5914 000026C8 89C2                    	mov	edx, eax ; [previous_val_r]
  5915 000026CA 80C780                  	add	bh, 80h
  5916 000026CD 8005[41270000]80        	add	byte [next_val_l+1], 80h
  5917 000026D4 66A1[40270000]          	mov	ax, [next_val_l]
  5918 000026DA 6601D8                  	add	ax, bx	; [previous_val_l]
  5919 000026DD 66D1D8                  	rcr	ax, 1
  5920 000026E0 93                      	xchg	eax, ebx
  5921 000026E1 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  5922 000026E4 66D1D8                  	rcr	ax, 1
  5923 000026E7 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5924 000026EA 66AB                    	stosw 		; interpolated sample 1 (L)
  5925 000026EC 8005[43270000]80        	add	byte [next_val_r+1], 80h
  5926 000026F3 89D0                    	mov	eax, edx ; [previous_val_r]
  5927 000026F5 660305[42270000]        	add	ax, [next_val_r]
  5928 000026FC 66D1D8                  	rcr	ax, 1
  5929 000026FF 92                      	xchg	eax, edx
  5930 00002700 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  5931 00002703 66D1D8                  	rcr	ax, 1
  5932 00002706 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5933 00002709 66AB                    	stosw 		; interpolated sample 1 (R)
  5934 0000270B 89D8                    	mov	eax, ebx
  5935 0000270D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5936 00002710 66AB                    	stosw 		; interpolated sample 2 (L)
  5937 00002712 89D0                    	mov	eax, edx
  5938 00002714 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5939 00002717 66AB                    	stosw 		; interpolated sample 2 (R)
  5940 00002719 89D8                    	mov	eax, ebx
  5941 0000271B 660305[40270000]        	add	ax, [next_val_l]
  5942 00002722 66D1D8                  	rcr	ax, 1
  5943 00002725 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5944 00002728 66AB                    	stosw 		; interpolated sample 3 (L)
  5945 0000272A 89D0                    	mov	eax, edx
  5946 0000272C 660305[42270000]        	add	ax, [next_val_r]
  5947 00002733 66D1D8                  	rcr	ax, 1
  5948 00002736 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5949 00002739 66AB                    	stosw 		; interpolated sample 3 (R)
  5950 0000273B C3                      	retn
  5951                                  
  5952                                  ; 13/11/2023
  5953                                  previous_val:
  5954 0000273C 0000                    previous_val_l: dw 0
  5955 0000273E 0000                    previous_val_r: dw 0
  5956                                  next_val:
  5957 00002740 0000                    next_val_l: dw 0
  5958 00002742 0000                    next_val_r: dw 0
  5959                                  
  5960                                  ; 16/11/2023
  5961 00002744 00                      faz:	db 0
  5962                                  
  5963                                  ; --------------------------------------------------------
  5964                                  ; 14/11/2024 - Erdogan Tan
  5965                                  ; --------------------------------------------------------
  5966                                  
  5967                                  	; 07/12/2024
  5968                                  	; 01/12/2024 (32bit registers)
  5969                                  	; 29/11/2024
  5970                                  checkUpdateEvents:
  5971 00002745 E8B7010000              	call	check4keyboardstop
  5972 0000274A 7272                    	jc	short c4ue_ok
  5973                                  
  5974                                  	; 18/11/2024
  5975 0000274C 50                      	push	eax ; *
  5976 0000274D 09C0                    	or	eax, eax
  5977 0000274F 0F84D1000000            	jz	c4ue_cpt
  5978                                  
  5979                                  	; 18/11/2024
  5980 00002755 3C20                    	cmp	al, 20h ; SPACE (spacebar) ; pause/play
  5981 00002757 7543                    	jne	short c4ue_chk_s
  5982 00002759 803D[F8370000]00        	cmp	byte [stopped], 0
  5983 00002760 7714                    	ja	short c4ue_chk_ps
  5984                                  	; pause
  5985 00002762 E805E5FFFF              	call	ac97_pause
  5986                                  	; 21/11/2024
  5987 00002767 A0[F9370000]            	mov	al, [tLO]
  5988 0000276C A2[FA370000]            	mov	byte [tLP], al
  5989 00002771 E9B0000000              	jmp	c4ue_cpt
  5990                                  c4ue_chk_ps:
  5991 00002776 803D[F8370000]01        	cmp	byte [stopped], 1
  5992 0000277D 770A                    	ja	short c4ue_replay
  5993                                  	; continue to play (after a pause)
  5994 0000277F E8F1E4FFFF              	call	ac97_play 
  5995 00002784 E99D000000              	jmp	c4ue_cpt
  5996                                  c4ue_replay:
  5997                                  	; 19/11/2024
  5998 00002789 58                      	pop	eax ; *
  5999 0000278A 58                      	pop	eax ; return address
  6000                                  	; 07/02/2024
  6001                                  	;mov	al, [volume]
  6002                                  	;call	SetmasterVolume
  6003 0000278B C605[F8370000]00        	mov	byte [stopped], 0
  6004 00002792 E87A040000              	call	move_to_beginning
  6005                                  	;jmp	PlayWav
  6006                                  	; 07/12/2024
  6007 00002797 E94CDEFFFF              	jmp	RePlayWav
  6008                                  
  6009                                  c4ue_chk_s:
  6010 0000279C 3C53                    	cmp	al, 'S'	; stop
  6011 0000279E 751F                    	jne	short c4ue_chk_fb
  6012 000027A0 803D[F8370000]00        	cmp	byte [stopped], 0
  6013 000027A7 777D                    	ja	c4ue_cpt ; Already stopped/paused
  6014 000027A9 E8A5E4FFFF              	call	ac97_stop
  6015                                  	; 19/11/2024
  6016 000027AE C605[F9370000]00        	mov	byte [tLO], 0
  6017                                  	; 21/11/2024
  6018 000027B5 C605[FA370000]30        	mov	byte [tLP], '0'
  6019 000027BC EB68                    	jmp	c4ue_cpt
  6020                                  
  6021                                  	; 01/12/2024
  6022                                  	; 18/11/2024
  6023                                  c4ue_ok:
  6024 000027BE C3                      	retn
  6025                                  
  6026                                  c4ue_chk_fb:
  6027                                  	; 17/11/2024
  6028 000027BF 3C46                    	cmp	al, 'F'
  6029 000027C1 7507                    	jne	short c4ue_chk_b
  6030 000027C3 E821040000              	call 	Player_ProcessKey_Forwards
  6031 000027C8 EB5C                    	jmp	c4ue_cpt
  6032                                  
  6033                                  c4ue_chk_b:
  6034 000027CA 3C42                    	cmp	al, 'B'
  6035                                  	;;jne	short c4ue_cpt
  6036                                  	; 19/11/2024
  6037                                  	;jne	short c4ue_chk_h
  6038                                  	; 25/12/2024
  6039                                  	; 29/11/2024
  6040 000027CC 7507                    	jne	short c4ue_chk_n
  6041 000027CE E812040000              	call 	Player_ProcessKey_Backwards
  6042 000027D3 EB51                    	jmp	short c4ue_cpt
  6043                                  
  6044                                  	;;;
  6045                                  	; 25/12/2024
  6046                                  	; 29/11/2024
  6047                                  c4ue_chk_n:
  6048 000027D5 3C4E                    	cmp	al, 'N'
  6049 000027D7 7404                    	je	short c4ue_nps
  6050                                  c4ue_chk_p:
  6051 000027D9 3C50                    	cmp	al, 'P'
  6052 000027DB 7509                    	jne	short c4ue_chk_h
  6053                                  c4ue_nps:
  6054 000027DD C605[F8370000]03        	mov	byte [stopped], 3
  6055 000027E4 EB40                    	jmp	short c4ue_cpt
  6056                                  	;;;
  6057                                  
  6058                                  c4ue_chk_h:
  6059                                  	; 19/11/2024
  6060 000027E6 3C48                    	cmp	al, 'H'
  6061 000027E8 750E                    	jne	short c4ue_chk_cr
  6062 000027EA C605[FB370000]00        	mov	byte [wpoints], 0
  6063 000027F1 E80DE6FFFF              	call 	write_ac97_pci_dev_info
  6064                                  	; 30/12/2024
  6065 000027F6 EB2E                    	jmp	short c4ue_cpt
  6066                                  c4ue_chk_cr:
  6067                                  	;;;
  6068                                  	; 24/12/2024 (wave lighting points option)
  6069                                  	;mov	ah, [wpoints]
  6070                                  	; 30/12/2024
  6071 000027F8 31DB                    	xor	ebx, ebx
  6072 000027FA 8A1D[FB370000]          	mov	bl, [wpoints]
  6073 00002800 3C47                    	cmp	al, 'G'
  6074 00002802 7406                    	je	short c4ue_g
  6075                                  	; 19/11/2024
  6076 00002804 3C0D                    	cmp	al, 0Dh ; ENTER/CR key
  6077 00002806 751E                    	jne	short c4ue_cpt
  6078                                  	; 23/11/2024
  6079                                  	;xor	ebx, ebx
  6080                                  	; 30/12/2024
  6081                                  	;mov	bl, ah ; 24/12/2024
  6082 00002808 FEC3                    	inc	bl
  6083                                  c4ue_g:	; 30/12/2024
  6084 0000280A 80E307                  	and	bl, 07h
  6085 0000280D 7501                    	jnz	short c4ue_sc
  6086 0000280F 43                      	inc	ebx
  6087                                  c4ue_sc:
  6088 00002810 881D[FB370000]          	mov	[wpoints], bl
  6089                                  	; 30/12/2024
  6090 00002816 8A83[D5320000]          	mov	al, [ebx+colors-1] ; 1 to 7
  6091                                  	; 24/12/2024
  6092 0000281C A2[DD320000]            	mov	[ccolor], al
  6093                                  	; 30/12/2024
  6094 00002821 E81A040000              	call	clear_window
  6095                                  	;;;
  6096                                  c4ue_cpt:
  6097                                  	; 24/12/2024
  6098                                  	; 18/11/2024
  6099 00002826 59                      	pop	ecx ; *
  6100                                  	;;;
  6101                                  	; 29/12/2024
  6102                                  	; 24/12/2024 (skip wave lighting if data is not loaded yet)
  6103                                  	;cmp	byte [SRB], 0
  6104                                  	;ja	short c4ue_vb_ok
  6105                                  	;;;
  6106                                  	; 01/12/2024 (TRDOS 386)
  6107                                  	sys	_time, 4 ; get timer ticks (18.2 ticks/second),
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002827 BB04000000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97                              <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 0000282C B80D000000          <1>  mov eax, %1
   104                              <1> 
   105 00002831 CD40                <1>  int 40h
  6108                                  	; 24/12/2024
  6109                                  	; 18/11/2024
  6110                                  	;pop	ecx ; *
  6111                                  	; 01/12/2024
  6112 00002833 3B05[C4380000]          	cmp	eax, [timerticks]
  6113                                  	;je	short c4ue_ok
  6114                                  	; 18/11/2024
  6115 00002839 7408                    	je	short c4ue_skip_utt
  6116                                  c4ue_utt:	
  6117                                  	; 01/12/2024
  6118 0000283B A3[C4380000]            	mov	[timerticks], eax
  6119 00002840 EB05                    	jmp	short c4ue_cpt_@
  6120                                  
  6121                                  	; 30/12/2024
  6122                                  c4ue_vb_ok:
  6123 00002842 C3                      	retn
  6124                                  
  6125                                  c4ue_skip_utt:
  6126                                  	; 18/11/2024
  6127 00002843 21C9                    	and	ecx, ecx
  6128 00002845 74FB                    	jz	short c4ue_vb_ok
  6129                                  c4ue_cpt_@:
  6130                                  	; 18/11/2024
  6131 00002847 803D[F8370000]00        	cmp	byte [stopped], 0
  6132 0000284E 77F2                    	ja	short c4ue_vb_ok
  6133                                  	
  6134 00002850 E8DE010000              	call	CalcProgressTime
  6135                                  
  6136                                  	;cmp	ax, [ProgressTime]
  6137                                  	; 01/12/2024
  6138 00002855 3B05[B8380000]          	cmp	eax, [ProgressTime]
  6139                                  	;je	short c4ue_vb_ok
  6140                                  			; same second, no need to update
  6141                                  	; 23/11/2024
  6142 0000285B 7405                    	je	short c4ue_uvb
  6143                                  
  6144                                  	;call	UpdateProgressTime
  6145                                  	;call	UpdateProgressBar@
  6146 0000285D E8F7020000              	call	UpdateProgressBar
  6147                                  
  6148                                  	; 23/11/2024
  6149                                  c4ue_uvb:
  6150 00002862 803D[FB370000]00        	cmp	byte [wpoints], 0
  6151 00002869 76D7                    	jna	short c4ue_vb_ok
  6152                                  
  6153                                  	; 30/12/2024
  6154                                  	;call	UpdateWavePoints
  6155                                  	;retn
  6156                                  
  6157                                  ; --------------------------------------------------------
  6158                                  ; 27/12/2024 - Erdogan Tan
  6159                                  ; --------------------------------------------------------
  6160                                  
  6161                                  	; 30/12/2024 (cgaplay.s)
  6162                                  	;  * 320*200 pixels, 256 colors
  6163                                  	;  * 64 volume levels
  6164                                  	; 29/12/2024
  6165                                  	; 27/12/2024 (DMA Buffer Tracking)
  6166                                  	; 26/12/2024
  6167                                  	; 24/12/2024
  6168                                  UpdateWavePoints:
  6169 0000286B BE[F8320000]            	mov	esi, prev_points
  6170 00002870 833E00                  	cmp	dword [esi], 0
  6171 00002873 740B                    	jz	short lights_off_ok
  6172                                  	;mov	ecx, 640
  6173                                  	; 30/12/2024
  6174 00002875 B940010000              	mov	ecx, 320
  6175                                  light_off:
  6176 0000287A AD                      	lodsd
  6177                                  	; eax = wave point (lighting point) address
  6178 0000287B C60000                  	mov	byte [eax], 0 ; black point (light off)
  6179 0000287E E2FA                    	loop	light_off	
  6180                                  
  6181                                  lights_off_ok:
  6182                                  	; 29/12/2024
  6183 00002880 803D[F9370000]32        	cmp	byte [tLO],'2'
  6184 00002887 7507                    	jne	short lights_on_buff_1
  6185                                  lights_on_buff_2:
  6186 00002889 BA[00500100]            	mov	edx, WAVBUFFER_2
  6187 0000288E EB05                    	jmp	short lights_on
  6188                                  lights_on_buff_1:
  6189 00002890 BA[00500000]            	mov	edx, WAVBUFFER_1
  6190                                  lights_on:
  6191 00002895 3915[00380000]          	cmp	[pbuf_s], edx
  6192 0000289B 7520                    	jne	short lights_on_2
  6193 0000289D 8B1D[E0320000]          	mov	ebx, [wpoints_dif]
  6194 000028A3 8B35[FC370000]          	mov	esi, [pbuf_o]
  6195 000028A9 8B0D[B0380000]          	mov	ecx, [buffersize] ; bytes
  6196 000028AF 29D9                    	sub	ecx, ebx ; sub ecx, [wpoints_dif]
  6197 000028B1 01DE                    	add	esi, ebx
  6198 000028B3 7204                    	jc	short lights_on_1
  6199 000028B5 39CE                    	cmp	esi, ecx
  6200 000028B7 760C                    	jna	short lights_on_3
  6201                                  lights_on_1:
  6202 000028B9 89CE                    	mov	esi, ecx
  6203 000028BB EB08                    	jmp	short lights_on_3
  6204                                  
  6205                                  lights_on_2:
  6206                                  	; 29/12/2024
  6207 000028BD 8915[00380000]          	mov	[pbuf_s], edx
  6208 000028C3 31F6                    	xor	esi, esi ; 0
  6209                                  lights_on_3:
  6210 000028C5 8935[FC370000]          	mov	[pbuf_o], esi
  6211                                  	; 29/12/2024
  6212                                  	;add	esi, [pbuf_s]
  6213 000028CB 01D6                    	add	esi, edx
  6214                                  	;mov	ecx, 640
  6215                                  	; 30/12/2024
  6216 000028CD B940010000              	mov	ecx, 320
  6217 000028D2 89CD                    	mov	ebp, ecx
  6218                                  	; 26/12/2024
  6219 000028D4 BF[F8320000]            	mov	edi, prev_points
  6220 000028D9 8B1D[E4320000]          	mov	ebx, [graphstart] ; start (top) line
  6221                                  lights_on_4:
  6222 000028DF 31C0                    	xor	eax, eax ; 0
  6223 000028E1 66AD                    	lodsw	; left
  6224 000028E3 80C480                  	add	ah, 80h
  6225 000028E6 89C2                    	mov	edx, eax
  6226 000028E8 66AD                    	lodsw	; right
  6227                                  	;add	ax, dx
  6228 000028EA 80C480                  	add	ah, 80h
  6229                                  	;;shr	eax, 9	; 128 volume levels
  6230                                  	;add	eax, edx
  6231                                  	;;shr	eax, 10	; (L+R/2) & 128 volume levels
  6232                                  	;shr	eax, 9	; (L+R/2) & 256 volume levels
  6233                                  	; 30/12/2024
  6234 000028ED C1E80B                  	shr	eax, 11	; (L+R/2) & 64 volume levels
  6235                                  	; * 320 row  ; 30/12/2024
  6236 000028F0 F7E5                    	mul	ebp	; * 640 (row) 
  6237 000028F2 01D8                    	add	eax, ebx ; + column
  6238 000028F4 8A15[DD320000]          	mov	dl, [ccolor]
  6239 000028FA 8810                    	mov	[eax], dl ; pixel (light on) color
  6240 000028FC AB                      	stosd		; save light on addr in prev_points
  6241 000028FD 43                      	inc	ebx
  6242 000028FE E2DF                    	loop	lights_on_4
  6243 00002900 C3                      	retn
  6244                                  
  6245                                  ; --------------------------------------------------------
  6246                                  ; 19/05/2024 - (playwav4.asm) ich_wav4.asm
  6247                                  ; --------------------------------------------------------
  6248                                  
  6249                                  	; 29/12/2024
  6250                                  	; 25/12/2024
  6251                                  	; 07/12/2024
  6252                                  	; 01/12/2024 (TRDOS 386)
  6253                                  	; 29/11/2024
  6254                                  check4keyboardstop:
  6255                                  	; 19/05/2024
  6256                                  	; 08/11/2023
  6257                                  	; 04/11/2023
  6258 00002901 B401                    	mov	ah, 1
  6259                                  	;int	16h
  6260                                  	; 01/12/2024 (TRDOS 386 keyboard interrupt)
  6261 00002903 CD32                    	int	32h
  6262                                  	;clc
  6263 00002905 7433                    	jz	short _cksr
  6264                                  
  6265 00002907 30E4                    	xor	ah, ah
  6266                                  	;int	16h
  6267                                  	; 01/12/2024 (TRDOS 386 keyboard interrupt)
  6268 00002909 CD32                    	int	32h
  6269                                  
  6270                                  	; 25/12/2024
  6271                                  	; 29/11/2024
  6272                                  	;mov	[command], al
  6273                                  
  6274                                  	;;;
  6275                                  	; 19/05/2024 (change PCM out volume)
  6276 0000290B 3C2B                    	cmp	al, '+'
  6277 0000290D 750D                    	jne	short p_1
  6278                                  	
  6279 0000290F A0[64290000]            	mov	al, [volume]
  6280 00002914 3C00                    	cmp	al, 0
  6281 00002916 7624                    	jna	short p_3
  6282 00002918 FEC8                    	dec	al
  6283 0000291A EB0F                    	jmp	short p_2
  6284                                  p_1:
  6285 0000291C 3C2D                    	cmp	al, '-'
  6286 0000291E 751D                    	jne	short p_4
  6287                                  
  6288 00002920 A0[64290000]            	mov	al, [volume]
  6289 00002925 3C1F                    	cmp	al, 31
  6290 00002927 7313                    	jnb	short p_3
  6291 00002929 FEC0                    	inc	al
  6292                                  p_2:
  6293 0000292B A2[64290000]            	mov	[volume], al
  6294                                  	; 29/12/2024
  6295                                  	; 14/11/2024
  6296 00002930 E867DEFFFF              	call	SetPCMOutVolume
  6297                                  	; 15/11/2024 (QEMU)
  6298                                  	; 07/12/2024
  6299                                  	;call	SetMasterVolume
  6300                                  	;call	UpdateVolume
  6301                                  	;;clc
  6302                                  	;retn
  6303 00002935 E99A010000              	jmp	UpdateVolume
  6304                                  	;mov	ah, al
  6305                                  	;mov    dx, [NAMBAR]
  6306                                    	;;add   dx, CODEC_MASTER_VOL_REG
  6307                                  	;add	dx, CODEC_PCM_OUT_REG
  6308                                  	;out    dx, ax
  6309                                  	;
  6310                                  	;call   delay1_4ms
  6311                                          ;call   delay1_4ms
  6312                                          ;call   delay1_4ms
  6313                                          ;call   delay1_4ms
  6314                                  _cksr:		; 19/05/2024
  6315                                  	; 18/12/2024
  6316 0000293A 31C0                    	xor	eax, eax
  6317                                  	;clc
  6318                                  p_3:
  6319 0000293C C3                      	retn
  6320                                  p_4:
  6321                                  	; 17/11/2024
  6322 0000293D 80FC01                  	cmp	ah, 01h  ; ESC
  6323 00002940 7419                        	je	short p_q
  6324                                  	;cmp	ax, 2E03h ; 21/12/2024 
  6325 00002942 3C03                    	cmp	al, 03h  ; CTRL+C
  6326 00002944 7415                    	je	short p_q
  6327                                  
  6328                                  	; 18/11/2024
  6329 00002946 3C20                    	cmp	al, 20h
  6330 00002948 7419                    	je	short p_r
  6331                                  
  6332                                  	; 19/11/2024
  6333 0000294A 3C0D                    	cmp	al, 0Dh ; CR/ENTER
  6334 0000294C 7415                    	je	short p_r
  6335                                  
  6336 0000294E 24DF                    	and	al, 0DFh
  6337                                  
  6338                                  	; 25/12/2024
  6339                                  	; 29/11/2024
  6340 00002950 A2[06380000]            	mov	[command], al
  6341                                  
  6342                                  	;cmp	al, 'B'
  6343                                  	;je	short p_r
  6344                                  	;cmp	al, 'F'
  6345                                  	;je	short p_r
  6346                                  
  6347                                  	; 29/11/2024
  6348                                  	;cmp	al, 'N'
  6349                                  	;je	short p_r
  6350                                  	;cmp	al, 'P'
  6351                                  	;je	short p_r
  6352                                  
  6353 00002955 3C51                    	cmp	al, 'Q'
  6354                                  	;je	short p_q
  6355 00002957 7409                    	je	short p_quit ; 29/11/2024
  6356                                  
  6357 00002959 F8                      	clc
  6358 0000295A C3                      	retn
  6359                                  
  6360                                  	;;;
  6361                                  ;_cskr:	
  6362                                  p_q:
  6363                                  	; 27/12/2024
  6364 0000295B C605[06380000]51        	mov	byte [command], 'Q'
  6365                                  p_quit:
  6366 00002962 F9                      	stc
  6367                                  p_r:
  6368 00002963 C3                      	retn
  6369                                  
  6370                                  ; 29/05/2024
  6371                                  ; 19/05/2024
  6372                                  volume: 
  6373                                  	;db	02h
  6374                                  ; 26/12/2024
  6375 00002964 03                      	db	03h
  6376                                  
  6377                                  ; --------------------------------------------------------
  6378                                  
  6379                                  	; 30/12/2024
  6380                                  	; simulate cursor position in VGA mode 13h
  6381                                  	; ! for 320*200, 256 colors (1 byte/pixel) !
  6382                                  setCursorPosition:
  6383                                  	; dh = Row
  6384                                  	; dl = Column
  6385                                  	
  6386 00002965 31C0                    	xor	eax, eax
  6387                                  	; row height is 8 pixels (8*8)
  6388 00002967 88F0                    	mov	al, dh
  6389 00002969 C1E003                  	shl	eax, 3
  6390 0000296C 6683C002                	add	ax, 2	; top margin
  6391 00002970 C1E010                  	shl	eax, 16
  6392 00002973 88D0                    	mov	al, dl	; * 8 ; character width = 8 pixels
  6393 00002975 66C1E003                	shl	ax, 3
  6394                                  			; hw = row, ax = column
  6395 00002979 A3[E8320000]            	mov	[screenpos], eax
  6396                                  	; 22/12/2024
  6397 0000297E 31C0                    	xor	eax, eax
  6398 00002980 C3                      	retn
  6399                                  	
  6400                                  ; --------------------------------------------------------
  6401                                  ; 14/11/2024
  6402                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6403                                  
  6404                                  ;; NAME:	SetTotalTime
  6405                                  ;; DESCRIPTION: Calculates the total time in seconds in file
  6406                                  ;; INPUT:	DATA_SubchunkSize, WAVE_SampleRate, WAVE_BlockAlign
  6407                                  ;; OUTPUT:	CurrentTotalTime=Total time in seconds in file,
  6408                                  ;; 		Output on the screen of the total time in seconds
  6409                                  
  6410                                  	; 01/12/2024 (32 bit registers)
  6411                                  SetTotalTime:
  6412                                  	;; Calculate total seconds in file
  6413                                  	;mov	ax, [DATA_SubchunkSize]
  6414                                  	;mov	dx, [DATA_SubchunkSize + 2]
  6415                                  	;mov	bx, [WAVE_SampleRate]
  6416                                  	;div	bx
  6417                                  	;xor	dx, dx
  6418                                  	; 01/12/2024
  6419 00002981 A1[30380000]            	mov	eax, [DATA_SubchunkSize]
  6420 00002986 0FB71D[20380000]        	movzx	ebx, word [WAVE_SampleRate]
  6421 0000298D 31D2                    	xor	edx, edx
  6422 0000298F F7F3                    	div	ebx
  6423                                  
  6424                                  	;mov	bx, [WAVE_BlockAlign]
  6425                                  	;div	bx
  6426                                  	; 01/12/2024
  6427 00002991 668B1D[28380000]        	mov	bx, [WAVE_BlockAlign]
  6428 00002998 31D2                    	xor	edx, edx
  6429 0000299A F7F3                    	div	ebx
  6430                                  
  6431                                  	;mov	[TotalTime], ax
  6432 0000299C A3[B4380000]            	mov	[TotalTime], eax
  6433                                  
  6434 000029A1 B33C                    	mov	bl, 60
  6435 000029A3 F6F3                    	div	bl
  6436                                  
  6437                                  	;; al = minutes, ah = seconds
  6438 000029A5 50                      	push	eax ; **
  6439 000029A6 50                      	push	eax ; *
  6440                                  
  6441                                  	;mov	dh, 24
  6442                                  	; 21/12/2024 (640*480)
  6443                                  	;mov	dh, 32
  6444                                  	;mov	dl, 42
  6445                                  	; 30/12/2024 (320*200)
  6446 000029A7 B617                    	mov	dh, 23
  6447 000029A9 B216                    	mov	dl, 22
  6448 000029AB E8B5FFFFFF              	call	setCursorPosition
  6449                                  
  6450 000029B0 58                      	pop	eax ; *
  6451 000029B1 30E4                    	xor	ah, ah
  6452 000029B3 BD02000000              	mov	ebp, 2
  6453 000029B8 E812000000              	call	PrintNumber
  6454                                  	
  6455                                  	;mov	dh, 24
  6456                                  	; 21/12/2024 (640*480)
  6457                                  	;mov	dh, 32
  6458                                  	;mov	dl, 45
  6459                                  	; 30/12/2024 (320*200)
  6460 000029BD B617                    	mov	dh, 23
  6461 000029BF B219                    	mov	dl, 25
  6462 000029C1 E89FFFFFFF              	call	setCursorPosition
  6463                                  
  6464 000029C6 58                      	pop	eax ; **
  6465 000029C7 88E0                    	mov	al, ah
  6466 000029C9 30E4                    	xor	ah, ah
  6467                                  	; 21/12/2024
  6468 000029CB 66BD0200                	mov	bp, 2
  6469                                  	;jmp	short PrintNumber
  6470                                  
  6471                                  ; --------------------------------------------------------
  6472                                  
  6473                                  	; 21/12/2024 (write numbers in VESA VBE graphics mode)
  6474                                  	; 01/12/2024 (32bit registers)
  6475                                  PrintNumber:
  6476                                  	; eax = binary number
  6477                                  	; ebp = digits
  6478 000029CF 8B35[E8320000]          	mov	esi, [screenpos]
  6479                                  		; hw = row, si = column
  6480 000029D5 BB0A000000              	mov	ebx, 10
  6481 000029DA 31C9                    	xor	ecx, ecx
  6482                                  printNumber_CutNumber:
  6483 000029DC 41                      	inc	ecx
  6484 000029DD 31D2                    	xor	edx, edx
  6485 000029DF F7F3                    	div	ebx
  6486 000029E1 52                      	push	edx
  6487 000029E2 39E9                    	cmp	ecx, ebp
  6488 000029E4 7402                    	je	short printNumber_printloop
  6489 000029E6 EBF4                    	jmp	printNumber_CutNumber
  6490                                  
  6491                                  printNumber_printloop:
  6492 000029E8 58                      	pop	eax
  6493                                  	; 21/12/2024
  6494                                  	; ebp = count of digits
  6495                                  	; eax <= 9
  6496                                  
  6497 000029E9 0430                    	add	al, '0'
  6498                                  	
  6499                                  	; esi = pixel position (hw = row, si = column)
  6500                                  	; eax = al = character
  6501                                  	;call	write_character
  6502                                  	; 22/12/2024
  6503 000029EB E82A010000              	call	write_character_white
  6504                                  
  6505 000029F0 4D                      	dec	ebp
  6506 000029F1 7405                     	jz	short printNumber_ok
  6507 000029F3 83C608                  	add	esi, 8	; next column
  6508 000029F6 EBF0                    	jmp	short printNumber_printloop
  6509                                  printNumber_ok:
  6510 000029F8 C3                      	retn
  6511                                  
  6512                                  ; --------------------------------------------------------
  6513                                  
  6514                                  	; 14/11/2024 - Erdogan Tan
  6515                                  SetProgressTime:
  6516                                  	;; Calculate playing/progress seconds in file
  6517 000029F9 E835000000              	call	CalcProgressTime
  6518                                  
  6519                                  	; 01/12/2024 (32bit registers)
  6520                                  UpdateProgressTime:
  6521                                  	; eax = (new) progress time 
  6522                                  
  6523 000029FE A3[B8380000]            	mov	[ProgressTime], eax
  6524                                  
  6525 00002A03 B33C                    	mov	bl, 60
  6526 00002A05 F6F3                    	div	bl
  6527                                  
  6528                                  	;; al = minutes, ah = seconds
  6529 00002A07 50                      	push	eax ; **
  6530 00002A08 50                      	push	eax ; *
  6531                                  
  6532                                  	;mov	dh, 24
  6533                                  	; 21/12/2024 (640*480)
  6534                                  	;mov	dh, 32
  6535                                  	;mov	dl, 33
  6536                                  	; 30/12/2024 (320*200)
  6537 00002A09 B617                    	mov	dh, 23
  6538 00002A0B B20D                    	mov	dl, 13
  6539 00002A0D E853FFFFFF              	call	setCursorPosition
  6540                                  
  6541 00002A12 58                      	pop	eax ; *
  6542 00002A13 30E4                    	xor	ah, ah
  6543 00002A15 BD02000000              	mov	ebp, 2
  6544 00002A1A E8B0FFFFFF              	call	PrintNumber
  6545                                  	
  6546                                  	;mov	dh, 24
  6547                                  	; 21/12/2024 (640*480)
  6548                                  	;mov	dh, 32
  6549                                  	;mov	dl, 36
  6550                                  	; 30/12/2024 (320*200)
  6551 00002A1F B617                    	mov	dh, 23
  6552 00002A21 B210                    	mov	dl, 16
  6553 00002A23 E83DFFFFFF              	call	setCursorPosition
  6554                                  
  6555 00002A28 58                      	pop	eax ; **
  6556 00002A29 88E0                    	mov	al, ah
  6557 00002A2B 30E4                    	xor	ah, ah
  6558                                  	; 21/12/2024
  6559 00002A2D 66BD0200                	mov	bp, 2
  6560 00002A31 EB9C                    	jmp	short PrintNumber
  6561                                  
  6562                                  ; --------------------------------------------------------
  6563                                  
  6564                                  	; 01/12/2024 (32bit registers)
  6565                                  	; 17/11/2024
  6566                                  	; 14/11/2024
  6567                                  CalcProgressTime:
  6568                                  	;mov	ax, [LoadedDataBytes]
  6569                                  	;mov	dx, [LoadedDataBytes+2]
  6570                                  	;mov	bx, ax
  6571                                  	;or	bx, dx
  6572                                  	;jz	short cpt_ok
  6573                                  	; 01/12/2024
  6574 00002A33 A1[C0380000]            	mov	eax, [LoadedDataBytes]
  6575 00002A38 09C0                    	or	eax, eax
  6576 00002A3A 7416                    	jz	short cpt_ok
  6577                                  
  6578                                  	;mov	bx, [WAVE_SampleRate]
  6579                                  	;div	bx
  6580                                  	;xor	dx, dx
  6581                                  	;mov	bx, [WAVE_BlockAlign]
  6582                                  	;div	bx
  6583                                  	; 01/12/2024
  6584 00002A3C 0FB71D[20380000]        	movzx	ebx, word [WAVE_SampleRate]
  6585 00002A43 31D2                    	xor	edx, edx
  6586 00002A45 F7F3                    	div	ebx
  6587 00002A47 31D2                    	xor	edx, edx
  6588 00002A49 668B1D[28380000]        	mov	bx, [WAVE_BlockAlign]
  6589 00002A50 F7F3                    	div	ebx
  6590                                  cpt_ok:
  6591                                  	; eax = (new) progress time
  6592 00002A52 C3                      	retn
  6593                                  
  6594                                  ; --------------------------------------------------------
  6595                                  ; 14/11/2024
  6596                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6597                                  
  6598                                  ;; DESCRIPTION: Update file information on template
  6599                                  ;; PARAMS:	WAVE parameters and other variables
  6600                                  ;; REGS:	AX(RW)
  6601                                  ;; VARS:	CurrentFileName, WAVE_SampleRate, 
  6602                                  ;; RETURNS:	On-screen file info is updated.
  6603                                  
  6604                                  	; 01/12/2024 (32bit registers)
  6605                                  UpdateFileInfo:
  6606                                  	;; Print File Name
  6607                                  	;mov	dh, 9
  6608                                  	; 21/12/2024 (640*480 graphics display)
  6609                                  	;mov	dh, 8
  6610                                  	;mov	dl, 23
  6611                                  	; 30/12/2024 (320*200, video mode 13h)
  6612 00002A53 B607                    	mov	dh, 7
  6613 00002A55 B208                    	mov	dl, 8
  6614 00002A57 E809FFFFFF              	call	setCursorPosition
  6615                                  	
  6616 00002A5C BE[48380000]            	mov	esi, wav_file_name
  6617                                  	
  6618                                  	;;;
  6619                                  	; 14/11/2024
  6620                                  	; skip directory separators
  6621                                  	; (note: asciiz string, max. 79 bytes except zero tail)
  6622 00002A61 89F3                    	mov	ebx, esi
  6623                                  chk4_nxt_sep:
  6624 00002A63 AC                      	lodsb
  6625 00002A64 3C2F                    	cmp	al, '/'	; 14/12/2024
  6626 00002A66 7406                    	je	short chg_fpos
  6627 00002A68 20C0                    	and	al, al
  6628 00002A6A 7406                    	jz	short chg_fpos_ok
  6629 00002A6C EBF5                    	jmp	short chk4_nxt_sep
  6630                                  chg_fpos:
  6631 00002A6E 89F3                    	mov	ebx, esi
  6632 00002A70 EBF1                    	jmp	short chk4_nxt_sep
  6633                                  chg_fpos_ok:
  6634 00002A72 89DE                    	mov	esi, ebx ; file name (without its path/directory)
  6635                                  	;;;
  6636                                  _fnl_chk:
  6637                                  	; 30/12/2024 (cgaplay.s)
  6638                                  	; ????????.wav
  6639                                  	; 26/12/2024 (file name length limit -display-)
  6640 00002A74 BB0C000000              	mov	ebx, 12
  6641                                  	;mov	ebx, 17 ; ????????.wav?????
  6642 00002A79 56                      	push	esi
  6643                                  _fnl_chk_loop:
  6644 00002A7A AC                      	lodsb
  6645 00002A7B 20C0                    	and	al, al
  6646 00002A7D 7406                    	jz	short _fnl_ok
  6647 00002A7F 4B                       	dec	ebx
  6648 00002A80 75F8                    	jnz	short _fnl_chk_loop
  6649 00002A82 C60600                  	mov	byte [esi], 0
  6650                                  _fnl_ok:
  6651 00002A85 5E                      	pop	esi
  6652                                  	;;;
  6653                                  
  6654 00002A86 E870000000              	call	PrintString
  6655                                  	
  6656                                  	;; Print Frequency
  6657                                  	;mov	dh, 10
  6658                                  	; 21/12/2024 (640*480 graphics display)
  6659                                  	;mov	dh, 9
  6660                                  	;mov	dl, 23
  6661                                  	; 30/12/2024 (320*200, video mode 13h)
  6662 00002A8B B608                    	mov	dh, 8
  6663 00002A8D B208                    	mov	dl, 8
  6664 00002A8F E8D1FEFFFF              	call	setCursorPosition
  6665                                  	;movzx	eax, word [WAVE_SampleRate]
  6666                                  	; 22/12/2024
  6667                                  	; eax = 0
  6668 00002A94 66A1[20380000]          	mov	ax, [WAVE_SampleRate]
  6669 00002A9A BD05000000              	mov	ebp, 5
  6670 00002A9F E82BFFFFFF              	call	PrintNumber
  6671                                  
  6672                                  	;; Print BitRate
  6673                                  	;mov	dh, 9
  6674                                  	; 21/12/2024 (640*480 graphics display)
  6675                                  	;mov	dh, 8
  6676                                  	;mov	dl, 57
  6677                                  	; 30/12/2024 (320*200, video mode 13h)
  6678 00002AA4 B607                    	mov	dh, 7
  6679 00002AA6 B21F                    	mov	dl, 31
  6680 00002AA8 E8B8FEFFFF              	call	setCursorPosition
  6681 00002AAD 66A1[2A380000]          	mov	ax, [WAVE_BitsPerSample]
  6682 00002AB3 66BD0200                	mov	bp, 2
  6683 00002AB7 E813FFFFFF              	call	PrintNumber
  6684                                  
  6685                                  	;; Print Channel Number
  6686                                  	;mov	dh, 10
  6687                                  	; 21/12/2024 (640*480 graphics display)
  6688                                  	;mov	dh, 9
  6689                                  	;mov	dl, 57
  6690                                  	; 30/12/2024 (320*200, video mode 13h)
  6691 00002ABC B608                    	mov	dh, 8
  6692 00002ABE B21F                    	mov	dl, 31
  6693 00002AC0 E8A0FEFFFF              	call	setCursorPosition
  6694 00002AC5 66A1[1E380000]          	mov	ax, [WAVE_NumChannels]
  6695 00002ACB 66BD0100                	mov	bp, 1
  6696 00002ACF E8FBFEFFFF              	call	PrintNumber
  6697                                  
  6698                                  	;call	UpdateVolume
  6699                                  	;retn
  6700                                  
  6701                                  ; --------------------------------------------------------
  6702                                  
  6703                                  	; 14/11/2024
  6704                                  UpdateVolume:
  6705                                  	;; Print Volume
  6706                                  	;mov	dh, 24
  6707                                  	; 21/12/2024 (640*480)
  6708                                  	;mov	dh, 32
  6709                                  	;mov	dl, 75
  6710                                  	; 30/12/2024 (320*200, video mode 13h)
  6711 00002AD4 B617                    	mov	dh, 23
  6712 00002AD6 B223                    	mov	dl, 35
  6713 00002AD8 E888FEFFFF              	call	setCursorPosition
  6714                                  	; 22/12/2024
  6715                                  	; eax = 0
  6716                                  
  6717 00002ADD A0[64290000]            	mov	al, [volume]
  6718                                  
  6719 00002AE2 B364                    	mov	bl, 100
  6720 00002AE4 F6E3                    	mul	bl
  6721                                  
  6722 00002AE6 B31F                    	mov	bl, 31
  6723 00002AE8 F6F3                    	div	bl
  6724                                  
  6725                                  	;neg	ax
  6726                                  	;add	ax, 100	
  6727                                  	; 01/12/2024
  6728 00002AEA B464                    	mov	ah, 100
  6729 00002AEC 28C4                    	sub	ah, al
  6730 00002AEE 0FB6C4                  	movzx	eax, ah
  6731                                  	;xor	ah, ah
  6732                                  	;mov	bp, 3
  6733 00002AF1 BD03000000              	mov	ebp, 3
  6734                                  	;call	PrintNumber
  6735                                  	;retn
  6736 00002AF6 E9D4FEFFFF              	jmp	PrintNumber	
  6737                                  
  6738                                  ; --------------------------------------------------------
  6739                                  
  6740                                  	; 21/12/2024
  6741                                  	; write text in VESA VBE graphics mode
  6742                                  PrintString:
  6743                                  	; esi = string address
  6744                                  printstr_loop:
  6745 00002AFB 31C0                    	xor	eax, eax
  6746 00002AFD AC                      	lodsb
  6747 00002AFE 08C0                    	or	al, al
  6748 00002B00 7417                    	jz	short printstr_ok
  6749                                  
  6750 00002B02 56                      	push	esi
  6751                                  
  6752 00002B03 8B35[E8320000]          	mov	esi, [screenpos]
  6753                                  
  6754                                  	; esi = pixel position (hw = row, si = column)
  6755                                  	; eax = al = character
  6756                                  	;call	write_character
  6757                                  	; 22/12/2024
  6758 00002B09 E80C000000              	call	write_character_white
  6759                                  
  6760 00002B0E 668305[E8320000]08      	add	word [screenpos], 8 ; update column (only, not row)
  6761                                  
  6762 00002B16 5E                      	pop	esi
  6763 00002B17 EBE2                    	jmp	short printstr_loop
  6764                                  
  6765                                  printstr_ok:
  6766 00002B19 C3                      	retn
  6767                                  
  6768                                  ; --------------------------------------------------------
  6769                                  
  6770                                  	; 30/12/2024
  6771                                  	; write character (at cursor position)
  6772                                  	; in video mode 13h (320*200, 256 colors)
  6773                                  	; 21/12/2024
  6774                                  	; write character (at cursor position)
  6775                                  	; in graphics mode (640*480, 256 colors)
  6776                                  	; 22/12/2024
  6777                                  write_character_white:
  6778 00002B1A B90F000000              	mov	ecx, 0Fh
  6779                                  	; 26/12/2024
  6780                                  	;movzx	ecx, byte [tcolor]
  6781                                  write_character:
  6782                                  	; esi = pixel position (hw = row, si = column)
  6783                                  	; eax = al = character
  6784                                  	; cl = color
  6785 00002B1F 890D[EC320000]          	mov	[wcolor], ecx ; 22/12/2024
  6786                                  
  6787                                  	; 30/12/2024
  6788                                  	; 22/12/2024
  6789 00002B25 50                      	push	eax
  6790                                  	; clear previous character pixels
  6791 00002B26 BF[CC320000]            	mov	edi, fillblock
  6792                                  	;;sys	_video, 020Fh, 0, 8001h
  6793                                  	; 30/12/2024
  6794                                  	sys	_video, 010Fh, 0, 8000h ; 8*8 userfont
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002B2B BB0F010000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00002B30 B900000000          <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00002B35 BA00800000          <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002B3A B81F000000          <1>  mov eax, %1
   104                              <1> 
   105 00002B3F CD40                <1>  int 40h
  6795 00002B41 58                      	pop	eax
  6796                                  
  6797                                  	; 30/12/2024
  6798                                  	;shl	eax, 4 ; 8*16 pixel user font
  6799                                  	;mov	edi, fontbuff2 ; start of user font data
  6800                                  	;add	edi, eax
  6801                                  
  6802                                  	; 21/12/2024
  6803                                  	; NOTE:
  6804                                  	; TRDOS 386 does not use 8*14 pixel fonts in sysvideo
  6805                                  	; system calls -in graphics mode-
  6806                                  	; because 8*16 pixel operations are faster
  6807                                  	;			than 8*14 pixel operations.
  6808                                  	; ((so, 8*14 fonts can be converted to 8*16 fonts by
  6809                                  	; adding 2 empty lines))
  6810                                  	; (8*14 characters can be written via pixel operations)
  6811                                    	
  6812                                  	; 21/12/2024 (TRDOS 386 v2.0.9, trdosk6.s, 27/09/2024)
  6813                                  	;;;;;;;;;;;;;;;;; ; sysvideo system call
  6814                                  	;sysvideo:
  6815                                  	;   function in BH
  6816                                  	;	02h: Super VGA, LINEAR FRAME BUFFER data transfers
  6817                                  	;   sub function in BL
  6818                                  	;	0Fh: WRITE CHARACTER (FONT)
  6819                                  	;          CL = char's color (8 bit, 256 colors)
  6820                                  	;	If DH bit 7 = 1
  6821                                  	;	   USER FONT (from user buffer)
  6822                                  	;	         DL = 1 -> 8x16 pixel font
  6823                                   	;	   EDI = user's font buffer address
  6824                                  	;		(NOTE: byte order is as row0,row1,row2..)
  6825                                  	;	   ESI = start position (row, column)
  6826                                  	;		(HW = row, SI = column)
  6827                                  	;;;;;;;;;;;;;;;;;
  6828                                  
  6829                                  	;sys	_video, 020Fh, [wcolor], 8001h
  6830                                  
  6831                                  	; 30/12/2024
  6832                                  	; sysvideo system call
  6833                                  	; BH = 01h = VGA graphics (0A0000h) data transfers
  6834                                  	; BL = 0Fh = write character/font
  6835                                  	; DH = 01h = 8*8 system font 
  6836                                  	; CL = [wcolor] = color
  6837                                  	; ESI = cursor/writing position (pixels)
  6838                                  	;	HW = row, SI = column
  6839                                  	; DL = character (ASCII code)
  6840                                  
  6841 00002B42 B401                    	mov	ah, 01h ; 8*8 pixels
  6842                                  
  6843                                  	sys	_video, 010Fh, [wcolor], eax
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002B44 BB0F010000          <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97 00002B49 8B0D[EC320000]      <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99 00002B4F 89C2                <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002B51 B81F000000          <1>  mov eax, %1
   104                              <1> 
   105 00002B56 CD40                <1>  int 40h
  6844                                  
  6845 00002B58 C3                      	retn
  6846                                  
  6847                                  ; --------------------------------------------------------
  6848                                  
  6849                                  	; 30/12/2024
  6850                                  	; write characters in video mode 13h
  6851                                  	; (320*200 pixels, 256 colors)
  6852                                  	; 22/12/2024
  6853                                  	; 21/12/2024
  6854                                  	; (write chars in VESA VBE graphics mode)
  6855                                  	; 14/11/2024
  6856                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  6857                                  	; (Modification: Erdogan Tan, 14/11/2024)
  6858                                  
  6859                                  	;PROGRESSBAR_ROW equ 23
  6860                                  	; 21/12/2024 (640*480)
  6861                                  	;PROGRESSBAR_ROW equ 31
  6862                                  	; 30/12/2024 (320*200)
  6863                                  	PROGRESSBAR_ROW equ 22
  6864                                  
  6865                                  UpdateProgressBar:
  6866 00002B59 E89BFEFFFF              	call	SetProgressTime	; 14/11/2024
  6867                                  
  6868                                  	; 01/12/2024 (32bit registers)
  6869 00002B5E A1[B8380000]            	mov	eax, [ProgressTime]
  6870                                  UpdateProgressBar@:
  6871                                  	;mov	edx, 80
  6872                                  	; 30/12/2024
  6873 00002B63 BA28000000              	mov	edx, 40 ; 320*200 pixels, 40 columns 
  6874 00002B68 F7E2                    	mul	edx
  6875 00002B6A 8B1D[B4380000]          	mov	ebx, [TotalTime]
  6876 00002B70 F7F3                    	div	ebx
  6877                                  
  6878                                  	; 22/12/2024
  6879                                  	; check progress bar indicator position if it is same 
  6880 00002B72 3A05[F1320000]          	cmp	al, [pbprev]
  6881 00002B78 7430                    	je	short UpdateProgressBar_ok
  6882 00002B7A A2[F1320000]            	mov	[pbprev], al
  6883                                  
  6884                                  UpdateProgressBar@@:
  6885                                  	;; Push for the 'Clean' part
  6886 00002B7F 50                      	push	eax ; **
  6887 00002B80 50                      	push	eax ; *
  6888                                  
  6889                                  	;; Set cursor position
  6890 00002B81 B616                    	mov	dh, PROGRESSBAR_ROW
  6891 00002B83 B200                    	mov	dl, 0
  6892 00002B85 E8DBFDFFFF              	call	setCursorPosition
  6893                                  
  6894 00002B8A 58                      	pop	eax ; *
  6895 00002B8B 09C0                    	or	eax, eax
  6896 00002B8D 742D                    	jz	short UpdateProgressBar_Clean
  6897                                  
  6898                                  UpdateProgressBar_DrawProgress:
  6899                                  	; 22/12/2024
  6900                                  	; 21/12/2024
  6901                                  	; (write progress bar chars in graphics mode)
  6902                                  	;;;;
  6903 00002B8F 89C5                    	mov	ebp, eax
  6904 00002B91 50                      	push	eax ; ***
  6905 00002B92 8B35[E8320000]          	mov	esi, [screenpos]
  6906                                  UpdateProgressBar_DrawProgress_@:
  6907 00002B98 B8DF000000              	mov	eax, 223
  6908                                  	
  6909                                  	; esi = pixel position (hw = row, si = column)
  6910                                  	; eax = al = character
  6911                                  	;call	write_character
  6912                                  	; 22/12/2024
  6913 00002B9D E878FFFFFF              	call	write_character_white
  6914                                  
  6915 00002BA2 4D                      	dec	ebp
  6916 00002BA3 7406                    	jz	short UpdateProgressBar_DrawCursor
  6917                                  
  6918 00002BA5 83C608                  	add	esi, 8 ; next column
  6919 00002BA8 EBEE                    	jmp	short UpdateProgressBar_DrawProgress_@
  6920                                  	;;;
  6921                                  
  6922                                  UpdateProgressBar_ok:
  6923 00002BAA C3                      	retn
  6924                                  
  6925                                  UpdateProgressBar_DrawCursor:
  6926                                  	; 22/12/2024
  6927 00002BAB 5A                      	pop	edx ; ***
  6928 00002BAC B616                    	mov	dh, PROGRESSBAR_ROW
  6929 00002BAE E8B2FDFFFF              	call	setCursorPosition
  6930                                  
  6931                                  	; 21/12/2024
  6932                                  	; (write progress bar character in graphics mode)
  6933                                  	;;;;
  6934                                  	;;;mov	eax, 223
  6935                                  	;;;shl	eax, 4 ; 8*16 pixel user font
  6936                                  	;;mov	eax, 223*16
  6937                                  	;;mov	edi, fontbuff2 ; start of user font data
  6938                                  	;;add	edi, eax
  6939                                  	;mov	edi, fontbuff2+(223*16)
  6940                                  	;
  6941                                  	;sys	_video, 020Fh, 0Ch, 8001h
  6942                                  	; 22/12/2024
  6943                                  	;mov	eax, 223
  6944                                  	; eax = 0
  6945 00002BB3 B0DF                    	mov	al, 223
  6946 00002BB5 B10C                    	mov	cl, 0Ch ; red
  6947 00002BB7 E863FFFFFF              	call	write_character
  6948                                  	;;;;
  6949                                  
  6950                                  UpdateProgressBar_Clean:
  6951                                  	;pop	eax  ; **
  6952                                  	; 22/12/2024
  6953 00002BBC 5A                      	pop	edx  ; **
  6954                                  	; 30/12/2024
  6955                                  	; 21/12/2024
  6956                                  	;mov	ebp, 80
  6957                                  	; 30/12/2024
  6958 00002BBD BD28000000              	mov	ebp, 40 ; 40 columns (320*200 pixels)
  6959                                  	;sub	bp, ax
  6960 00002BC2 6629D5                  	sub	bp, dx ; 22/12/2024
  6961 00002BC5 74E3                    	jz	short UpdateProgressBar_ok
  6962                                  
  6963 00002BC7 B616                    	mov	dh, PROGRESSBAR_ROW
  6964                                  	;mov	dl, al ; 22/12/2024
  6965 00002BC9 E897FDFFFF              	call	setCursorPosition
  6966                                  
  6967                                  	; 21/12/2024
  6968                                  	; (write progress bar chars in graphics mode)
  6969                                  	;;;;
  6970 00002BCE 8B35[E8320000]          	mov	esi, [screenpos]
  6971                                  UpdateProgressBar_Clean_@:
  6972                                  	;;;mov	eax, 223
  6973                                  	;;;shl	eax, 4 ; 8*16 pixel user font
  6974                                  	;;mov	eax, 223*16
  6975                                  	;mov	edi, fontbuff2 ; start of user font data
  6976                                  	;add	edi, eax
  6977                                  	;mov	edi, fontbuff2+(223*16)
  6978                                  	;
  6979                                  	;sys	_video, 020Fh, 08h, 8001h
  6980                                  	; 22/12/2024
  6981                                  	;mov	eax, 223
  6982                                  	; eax = 0
  6983 00002BD4 B0DF                    	mov	al, 223
  6984 00002BD6 B108                    	mov	cl, 08h ; gray (dark)
  6985 00002BD8 E842FFFFFF              	call	write_character
  6986                                  	;;;;
  6987                                  
  6988 00002BDD 4D                      	dec	ebp
  6989 00002BDE 74CA                    	jz	short UpdateProgressBar_ok
  6990                                  
  6991 00002BE0 83C608                  	add	esi, 8 ; next column
  6992 00002BE3 EBEF                    	jmp	short UpdateProgressBar_Clean_@
  6993                                  	;;;;
  6994                                  
  6995                                  ; --------------------------------------------------------
  6996                                  ; 17/11/2024
  6997                                  
  6998                                  Player_ProcessKey_Backwards:
  6999                                  	;; In order to go backwards 5 seconds:
  7000                                  	;; Update file pointer to the beginning, skip headers
  7001 00002BE5 B142                    	mov	cl, 'B'
  7002 00002BE7 EB02                    	jmp	short Player_ProcessKey_B_or_F
  7003                                  
  7004                                  Player_ProcessKey_Forwards:
  7005                                  	;; In order to fast-forward 5 seconds, set the file pointer
  7006                                  	;; to CUR_SEEK + 5 * Freq
  7007                                  
  7008 00002BE9 B146                    	mov	cl, 'F'
  7009                                  	;jmp	short Player_ProcessKey_B_or_F
  7010                                  
  7011                                  	; 01/12/2024 (32bit regsisters)
  7012                                  Player_ProcessKey_B_or_F:
  7013                                  	; 17/11/2024
  7014                                  	; 04/11/2024
  7015                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  7016                                    
  7017                                  	; 04/11/2024
  7018 00002BEB B805000000              	mov	eax, 5
  7019 00002BF0 0FB71D[28380000]        	movzx	ebx, word [WAVE_BlockAlign]
  7020 00002BF7 F7E3                    	mul	ebx
  7021 00002BF9 668B1D[20380000]        	mov	bx, [WAVE_SampleRate]
  7022 00002C00 F7E3                    	mul	ebx
  7023                                  	; eax = transfer byte count for 5 seconds
  7024                                  	
  7025                                  	; 17/11/2024
  7026 00002C02 80F942                  	cmp	cl, 'B'
  7027                                  	;mov	bx, [LoadedDataBytes]
  7028                                  	;mov	cx, [LoadedDataBytes+2]
  7029                                  	; 01/12/2024
  7030 00002C05 8B0D[C0380000]          	mov	ecx, [LoadedDataBytes]
  7031 00002C0B 7508                    	jne	short move_forward ; cl = 'F'
  7032                                  move_backward:
  7033                                  	;sub	bx, ax
  7034                                  	;sbb	cx, dx
  7035 00002C0D 29C1                    	sub	ecx, eax
  7036 00002C0F 7316                    	jnc	short move_file_pointer
  7037                                  move_to_beginning:
  7038                                  	;xor	cx, cx ; 0
  7039                                  	;xor	bx, bx ; 0
  7040 00002C11 31C9                    	xor	ecx, ecx
  7041 00002C13 EB12                    	jmp	short move_file_pointer
  7042                                  move_forward: 
  7043                                  	;add	bx, ax
  7044                                  	;adc	cx, dx
  7045 00002C15 01C1                    	add	ecx, eax
  7046 00002C17 7208                    	jc	short move_to_end
  7047                                  	;cmp	cx, [DATA_SubchunkSize+2]
  7048                                  	;ja	short move_to_end
  7049                                  	;jb	short move_file_pointer
  7050                                  	;cmp	bx, [DATA_SubchunkSize]
  7051                                  	;jna	short move_file_pointer
  7052 00002C19 3B0D[30380000]          	cmp	ecx, [DATA_SubchunkSize]
  7053 00002C1F 7606                    	jna	short move_file_pointer
  7054                                  move_to_end:
  7055                                  	;mov	bx, [DATA_SubchunkSize]
  7056                                  	;mov	cx, [DATA_SubchunkSize+2]
  7057 00002C21 8B0D[30380000]          	mov	ecx, [DATA_SubchunkSize]
  7058                                  move_file_pointer:
  7059                                  	;mov	dx, bx    
  7060                                  	;mov	[LoadedDataBytes], dx
  7061                                  	;mov	[LoadedDataBytes+2], cx
  7062 00002C27 890D[C0380000]          	mov	[LoadedDataBytes], ecx
  7063                                  	;add	dx, 44 ; + header
  7064                                  	;adc	cx, 0
  7065 00002C2D 83C12C                  	add	ecx, 44 
  7066                                  
  7067                                  	; seek
  7068                                  	;mov	bx, [filehandle]
  7069                                  	;mov	ax, 4200h
  7070                                  	;int	21h
  7071                                  	; 01/12/2024
  7072 00002C30 31D2                    	xor	edx, edx ; offset from beginning of the file
  7073                                  	; ecx = offset	
  7074                                  	; ebx = file handle
  7075                                  	; edx = 0
  7076                                  	sys	_seek, [filehandle]
    90                              <1> 
    91                              <1> 
    92                              <1> 
    93                              <1> 
    94                              <1>  %if %0 >= 2
    95 00002C32 8B1D[38380000]      <1>  mov ebx, %2
    96                              <1>  %if %0 >= 3
    97                              <1>  mov ecx, %3
    98                              <1>  %if %0 = 4
    99                              <1>  mov edx, %4
   100                              <1>  %endif
   101                              <1>  %endif
   102                              <1>  %endif
   103 00002C38 B813000000          <1>  mov eax, %1
   104                              <1> 
   105 00002C3D CD40                <1>  int 40h
  7077 00002C3F C3                      	retn
  7078                                  
  7079                                  ; --------------------------------------------------------
  7080                                  
  7081                                  	; 30/12/2024 (video mode 13h)
  7082                                  	; (320*200, 256 colors)
  7083                                  	; 25/12/2024
  7084                                  	; 22/12/2024 (VESA VBE mode graphics) 
  7085                                  	; (640*480, 256 colors)
  7086                                  clear_window:
  7087                                  	;mov	edi, [LFB_ADDR]
  7088                                  	; 30/12/2024
  7089                                  	;mov	edi, 0A0000h
  7090                                  	;;add	edi, (13*80*8*14)
  7091                                  	; 25/12/2024
  7092                                  	;;add	edi, 164*640
  7093                                  	;add	edi, 12*8*320
  7094                                  	; 30/12/2024
  7095                                  	;mov	edi, [graphstart] ; 12*8*320
  7096 00002C40 BF80700A00              	mov	edi, 0A0000h+(11*8*320)+(2*320) ; *
  7097                                  				; AC97 info start 
  7098 00002C45 29C0                    	sub	eax, eax
  7099                                  	;;mov	ecx, (16*640*14)/4 ; 16 rows
  7100                                  	;mov	ecx, 64*640 ; 256 volume level points
  7101                                  	; 30/12/2024
  7102                                  	;mov	ecx, (8*8*320)/4 ; 8 rows 
  7103 00002C47 B900190000              	mov	ecx, (10*8*320)/4 ; *
  7104 00002C4C F3AB                    	rep	stosd
  7105                                  	; 24/12/2024
  7106 00002C4E A3[F8320000]            	mov	[prev_points], eax ; 0
  7107                                  	;
  7108 00002C53 C3                      	retn
  7109                                  
  7110                                  ; -------------------------------------------------------------
  7111                                  ; ac97.inc (11/11/2023)
  7112                                  ; -------------------------------------------------------------
  7113                                  
  7114                                  ; special characters
  7115                                  LF      EQU 10
  7116                                  CR      EQU 13
  7117                                  
  7118                                  ; PCI stuff
  7119                                  
  7120                                  BIT0  EQU 1
  7121                                  BIT1  EQU 2
  7122                                  BIT2  EQU 4
  7123                                  BIT8  EQU 100h
  7124                                  BIT9  EQU 200h
  7125                                  BIT28 EQU 10000000h
  7126                                  BIT30 EQU 40000000h
  7127                                  BIT31 EQU 80000000h
  7128                                  
  7129                                  BUP		equ	BIT30		; Buffer Underrun Policy.
  7130                                  					; if this buffer is the last buffer
  7131                                  					; in a playback, fill the remaining
  7132                                  					; samples with 0 (silence) or not.
  7133                                  					; It's a good idea to set this to 1
  7134                                  					; for the last buffer in playback,
  7135                                  					; otherwise you're likely to get a lot
  7136                                  					; of noise at the end of the sound.
  7137                                  
  7138                                  RR		equ	BIT1		; reset registers. Nukes all regs
  7139                                                                          ; except bits 4:2 of this register.
  7140                                                                          ; Only set this bit if BIT 0 is 0
  7141                                  RPBM		equ	BIT0		; Run/Pause
  7142                                  					; set this bit to start the codec!
  7143                                  IO_ENA		EQU	BIT0		; i/o decode enable
  7144                                  BM_ENA		EQU	BIT2		; bus master enable
  7145                                  
  7146                                  PCI_INDEX_PORT  EQU     0CF8h
  7147                                  PCI_DATA_PORT   EQU     0CFCh
  7148                                  PCI32           EQU     BIT31           ; bitflag to signal 32bit access
  7149                                  PCI16           EQU     BIT30           ; bitflag for 16bit access
  7150                                  
  7151                                  AC97_INT_LINE	equ	3Ch		; AC97 Interrupt Line register offset
  7152                                  
  7153                                  ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
  7154                                  
  7155                                  INTEL_VID       equ     8086h           ; Intel's PCI vendor ID
  7156                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  7157                                  SIS_VID		equ	1039h
  7158                                  NVIDIA_VID	equ	10DEh	 ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
  7159                                  AMD_VID		equ	1022h
  7160                                  
  7161                                  ICH_DID         equ     2415h           ; ICH device ID
  7162                                  ICH0_DID        equ     2425h           ; ICH0
  7163                                  ICH2_DID        equ     2445h           ; ICH2 I think there are more ICHes.
  7164                                                                          ; they all should be compatible.
  7165                                  
  7166                                  ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
  7167                                  ICH3_DID	equ     2485h           ; ICH3
  7168                                  ICH4_DID        equ     24C5h           ; ICH4
  7169                                  ICH5_DID	equ     24D5h           ; ICH5
  7170                                  ICH6_DID	equ     266Eh           ; ICH6
  7171                                  ESB6300_DID	equ     25A6h           ; 6300ESB
  7172                                  ESB631X_DID	equ     2698h           ; 631XESB
  7173                                  ICH7_DID	equ	27DEh		; ICH7
  7174                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  7175                                  MX82440_DID	equ	7195h
  7176                                  SI7012_DID	equ	7012h
  7177                                  NFORCE_DID	equ	01B1h
  7178                                  NFORCE2_DID	equ	006Ah
  7179                                  AMD8111_DID	equ	746Dh
  7180                                  AMD768_DID	equ	7445h
  7181                                  ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
  7182                                  CK804_DID	equ	0059h
  7183                                  MCP04_DID	equ	003Ah
  7184                                  CK8_DID		equ	008Ah
  7185                                  NFORCE3_DID	equ	00DAh
  7186                                  CK8S_DID	equ	00EAh
  7187                                  
  7188                                  NAMBAR_REG	equ	10h		; native audio mixer BAR
  7189                                  NABMBAR_REG	equ	14h		; native audio bus mastering BAR
  7190                                  
  7191                                  CODEC_MASTER_VOL_REG	equ	02h	; master volume
  7192                                  CODEC_MASTER_TONE_REG	equ	08h	; master tone (R+L)
  7193                                  CODEC_PCM_OUT_REG 	equ	18h     ; PCM output volume
  7194                                  CODEC_EXT_AUDIO_REG	equ	28h	; extended audio
  7195                                  CODEC_EXT_AUDIO_CTRL_REG equ	2Ah	; extended audio control
  7196                                  CODEC_PCM_FRONT_DACRATE_REG equ	2Ch	; PCM out sample rate
  7197                                  
  7198                                  ; ICH supports 3 different types of register sets for three types of things
  7199                                  ; it can do, thus:
  7200                                  ;
  7201                                  ; PCM in (for recording) aka PI
  7202                                  ; PCM out (for playback) aka PO
  7203                                  ; MIC in (for recording) aka MC
  7204                                  
  7205                                  PI_BDBAR_REG	equ	0		; PCM in buffer descriptor BAR
  7206                                  PO_BDBAR_REG	equ	10h		; PCM out buffer descriptor BAR
  7207                                  
  7208                                  GLOB_CNT_REG	equ	2Ch		; Global control register
  7209                                  GLOB_STS_REG 	equ	30h		; Global Status register (RO)
  7210                                  
  7211                                  PI_CR_REG 	equ	0Bh		; PCM in Control Register
  7212                                  PO_CR_REG	equ	1Bh		; PCM out Control Register
  7213                                  MC_CR_REG	equ	2Bh		; MIC in Control Register
  7214                                  
  7215                                  PCI_CMD_REG	EQU	04h		; reg 04h, command register
  7216                                  
  7217                                  CTRL_ST_CREADY		equ	BIT8+BIT9+BIT28 ; Primary Codec Ready
  7218                                  CODEC_REG_POWERDOWN	equ	26h
  7219                                  
  7220                                  PO_CIV_REG	equ	14h		; PCM out current Index value (RO)
  7221                                  PO_LVI_REG	equ	15h		; PCM out Last Valid Index
  7222                                  PO_SR_REG	equ	16h		; PCM out Status register
  7223                                  
  7224                                  ; -------------------------------------------------------------
  7225                                  
  7226                                  ; 22/12/2024
  7227                                  align 4
  7228                                  
  7229                                  ; 13/11/2024
  7230                                  ; ('<<' to 'shl' conversion for FASM)
  7231                                  ;
  7232                                  ; 29/05/2024 (TRDOS 386)
  7233                                  ; 17/02/2017
  7234                                  ; Valid ICH device IDs
  7235                                  
  7236                                  valid_ids:
  7237                                  	;dd (ICH_DID shl 16) + INTEL_VID	; 8086h:2415h
  7238 00002C54 86801524                	dd (ICH_DID << 16) + INTEL_VID		; 8086h:2415h
  7239 00002C58 86802524                	dd (ICH0_DID << 16) + INTEL_VID		; 8086h:2425h
  7240 00002C5C 86804524                	dd (ICH2_DID << 16) + INTEL_VID		; 8086h:2445h
  7241 00002C60 86808524                	dd (ICH3_DID << 16) + INTEL_VID		; 8086h:2485h
  7242 00002C64 8680C524                	dd (ICH4_DID << 16) + INTEL_VID		; 8086h:24C5h
  7243 00002C68 8680D524                	dd (ICH5_DID << 16) + INTEL_VID		; 8086h:24D5h
  7244 00002C6C 86806E26                	dd (ICH6_DID << 16) + INTEL_VID		; 8086h:266Eh
  7245 00002C70 8680A625                	dd (ESB6300_DID << 16) + INTEL_VID	; 8086h:25A6h
  7246 00002C74 86809826                	dd (ESB631X_DID << 16) + INTEL_VID	; 8086h:2698h
  7247 00002C78 8680DE27                	dd (ICH7_DID << 16) + INTEL_VID		; 8086h:27DEh
  7248                                  	; 03/11/2023 - Erdogan Tan
  7249 00002C7C 86809571                	dd (MX82440_DID << 16) + INTEL_VID	; 8086h:7195h
  7250 00002C80 39101270                	dd (SI7012_DID << 16)  + SIS_VID	; 1039h:7012h
  7251 00002C84 DE10B101                	dd (NFORCE_DID << 16)  + NVIDIA_VID	; 10DEh:01B1h
  7252 00002C88 DE106A00                	dd (NFORCE2_DID << 16) + NVIDIA_VID	; 10DEh:006Ah
  7253 00002C8C 22106D74                	dd (AMD8111_DID << 16) + AMD_VID	; 1022h:746Dh
  7254 00002C90 22104574                	dd (AMD768_DID << 16)  + AMD_VID	; 1022h:7445h
  7255 00002C94 DE105900                	dd (CK804_DID << 16) + NVIDIA_VID	; 10DEh:0059h
  7256 00002C98 DE103A00                	dd (MCP04_DID << 16) + NVIDIA_VID	; 10DEh:003Ah
  7257 00002C9C DE108A00                	dd (CK8_DID << 16) + NVIDIA_VID		; 1022h:008Ah
  7258 00002CA0 DE10DA00                	dd (NFORCE3_DID << 16) + NVIDIA_VID	; 10DEh:00DAh
  7259 00002CA4 DE10EA00                	dd (CK8S_DID << 16) + NVIDIA_VID	; 10DEh:00EAh
  7260                                  
  7261                                  valid_id_count equ (($ - valid_ids)>>2)	; 05/11/2023
  7262                                  ; 13/11/2024
  7263                                  ;valid_id_count = ($ - valid_ids) shr 2	; 05/11/2023
  7264                                  
  7265 00002CA8 00000000                	dd 0
  7266                                  
  7267                                  Credits:
  7268 00002CAC 564741205741562050-     	db 'VGA WAV Player for TRDOS 386 by Erdogan Tan. '
  7268 00002CB5 6C6179657220666F72-
  7268 00002CBE 205452444F53203338-
  7268 00002CC7 36206279204572646F-
  7268 00002CD0 67616E2054616E2E20 
  7269 00002CD9 446563656D62657220-     	db 'December 2024.',10,13,0
  7269 00002CE2 323032342E0A0D00   
  7270 00002CEA 33302F31322F323032-     	db '30/12/2024', 10,13
  7270 00002CF3 340A0D             
  7271                                  ; 15/11/2024
  7272                                  reset:
  7273 00002CF6 00                      	db 0
  7274                                  
  7275                                  msgAudioCardInfo:
  7276 00002CF7 666F7220496E74656C-     	db 'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  7276 00002D00 204143393720284943-
  7276 00002D09 482920417564696F20-
  7276 00002D12 436F6E74726F6C6C65-
  7276 00002D1B 722E0A0D00         
  7277                                  
  7278                                  	; 30/12/2024
  7279                                  msg_usage:
  7280 00002D20 75736167653A204347-     	db 'usage: CGAPLAY <FileName1> <FileName2> <...>',10,13,0
  7280 00002D29 41504C4159203C4669-
  7280 00002D32 6C654E616D65313E20-
  7280 00002D3B 3C46696C654E616D65-
  7280 00002D44 323E203C2E2E2E3E0A-
  7280 00002D4D 0D00               
  7281                                  
  7282                                  noDevMsg:
  7283 00002D4F 4572726F723A20556E-     	db 'Error: Unable to find AC97 audio device!'
  7283 00002D58 61626C6520746F2066-
  7283 00002D61 696E64204143393720-
  7283 00002D6A 617564696F20646576-
  7283 00002D73 69636521           
  7284 00002D77 0A0D00                  	db 10,13,0
  7285                                  
  7286                                  noFileErrMsg:
  7287 00002D7A 4572726F723A206669-     	db 'Error: file not found.',10,13,0
  7287 00002D83 6C65206E6F7420666F-
  7287 00002D8C 756E642E0A0D00     
  7288                                  
  7289                                  ; 07/12/2024
  7290                                  trdos386_err_msg:
  7291 00002D93 5452444F5320333836-     	db 'TRDOS 386 System call error !',10,13,0
  7291 00002D9C 2053797374656D2063-
  7291 00002DA5 616C6C206572726F72-
  7291 00002DAE 20210A0D00         
  7292                                  
  7293                                  ; 29/05/2024
  7294                                  ; 11/11/2023
  7295                                  msg_init_err:
  7296 00002DB3 0D0A                    	db CR, LF
  7297 00002DB5 4143393720436F6E74-     	db 'AC97 Controller/Codec initialization error !'
  7297 00002DBE 726F6C6C65722F436F-
  7297 00002DC7 64656320696E697469-
  7297 00002DD0 616C697A6174696F6E-
  7297 00002DD9 206572726F722021   
  7298 00002DE1 0D0A00                  	db CR, LF, 0 ; 07/12/2024
  7299                                  
  7300                                  ; 25/11/2023
  7301                                  msg_no_vra:
  7302 00002DE4 0A0D                    	db 10,13
  7303 00002DE6 4E6F20565241207375-     	db 'No VRA support ! Only 48 kHZ sample rate supported !'
  7303 00002DEF 70706F72742021204F-
  7303 00002DF8 6E6C79203438206B48-
  7303 00002E01 5A2073616D706C6520-
  7303 00002E0A 726174652073757070-
  7303 00002E13 6F727465642021     
  7304 00002E1A 0A0D00                  	db 10,13,0
  7305                                  
  7306                                  ; 19/11/2024
  7307                                  ; 03/06/2017
  7308                                  hex_chars:
  7309 00002E1D 303132333435363738-     	db '0123456789ABCDEF', 0
  7309 00002E26 3941424344454600   
  7310                                  msgAC97Info:
  7311 00002E2E 0D0A                    	db 0Dh, 0Ah
  7312 00002E30 204143393720417564-     	db ' AC97 Audio Controller & Codec Info', 0Dh, 0Ah 
  7312 00002E39 696F20436F6E74726F-
  7312 00002E42 6C6C6572202620436F-
  7312 00002E4B 64656320496E666F0D-
  7312 00002E54 0A                 
  7313 00002E55 2056656E646F722049-     	db ' Vendor ID: '
  7313 00002E5E 443A20             
  7314                                  msgVendorId:
  7315 00002E61 303030306820446576-     	db '0000h Device ID: '
  7315 00002E6A 6963652049443A20   
  7316                                  msgDevId:
  7317 00002E72 30303030680D0A          	db '0000h', 0Dh, 0Ah
  7318 00002E79 204275733A20            	db ' Bus: '
  7319                                  msgBusNo:
  7320 00002E7F 303068204465766963-     	db '00h Device: '
  7320 00002E88 653A20             
  7321                                  msgDevNo:
  7322 00002E8B 3030682046756E6374-     	db '00h Function: '
  7322 00002E94 696F6E3A20         
  7323                                  msgFncNo:
  7324 00002E99 303068                  	db '00h'
  7325 00002E9C 0D0A                    	db 0Dh, 0Ah
  7326 00002E9E 204E414D4241523A20      	db ' NAMBAR: '
  7327                                  msgNamBar:
  7328 00002EA7 30303030682020          	db '0000h  '
  7329 00002EAE 4E41424D4241523A20      	db 'NABMBAR: '
  7330                                  msgNabmBar:
  7331 00002EB7 303030306820204952-     	db '0000h  IRQ: '
  7331 00002EC0 513A20             
  7332                                  msgIRQ:
  7333 00002EC3 3030                    	dw 3030h
  7334 00002EC5 0D0A00                  	db 0Dh, 0Ah, 0
  7335                                  ; 25/11/2023
  7336                                  msgVRAheader:
  7337 00002EC8 205652412073757070-     	db ' VRA support: '
  7337 00002ED1 6F72743A20         
  7338 00002ED6 00                      	db 0	
  7339                                  msgVRAyes:
  7340 00002ED7 5945530D0A00            	db 'YES', 0Dh, 0Ah, 0
  7341                                  msgVRAno:
  7342 00002EDD 4E4F200D0A              	db 'NO ', 0Dh, 0Ah
  7343                                  	;db ' (Interpolated sample rate playing method)'
  7344                                  	; 30/12/2024
  7345 00002EE2 2028496E746572706F-     	db ' (Interpolated samplerate play method)'
  7345 00002EEB 6C617465642073616D-
  7345 00002EF4 706C65726174652070-
  7345 00002EFD 6C6179206D6574686F-
  7345 00002F06 6429               
  7346 00002F08 0D0A00                  	db 0Dh, 0Ah, 0
  7347                                  
  7348 00002F0B 90                      align 4
  7349                                  
  7350                                  ; -------------------------------------------------------------
  7351                                  
  7352                                  	; 30/12/2024
  7353                                  PlayingScreen:
  7354 00002F0C DBDBDBDBDBDBDBDBDB-     	db  14 dup(219), " DOS Player ", 14 dup(219)
  7354 00002F15 DBDBDBDBDB20444F53-
  7354 00002F1E 20506C6179657220DB-
  7354 00002F27 DBDBDBDBDBDBDBDBDB-
  7354 00002F30 DBDBDBDB           
  7355 00002F34 C9CDCDCDCDCDCDCDCD-     	db  201, 38 dup(205), 187
  7355 00002F3D CDCDCDCDCDCDCDCDCD-
  7355 00002F46 CDCDCDCDCDCDCDCDCD-
  7355 00002F4F CDCDCDCDCDCDCDCDCD-
  7355 00002F58 CDCDCDBB           
  7356 00002F5C BA203C53706163653E-     	db  186, " <Space> Play/Pause <N>/<P> Next/Prev ", 186
  7356 00002F65 20506C61792F506175-
  7356 00002F6E 7365203C4E3E2F3C50-
  7356 00002F77 3E204E6578742F5072-
  7356 00002F80 657620BA           
  7357 00002F84 BA203C533E20202020-     	db  186, " <S>     Stop       <Enter> Color     ", 186
  7357 00002F8D 2053746F7020202020-
  7357 00002F96 2020203C456E746572-
  7357 00002F9F 3E20436F6C6F722020-
  7357 00002FA8 202020BA           
  7358 00002FAC BA203C463E20202020-     	db  186, " <F>     Forwards   <+>/<-> Volume    ", 186
  7358 00002FB5 20466F727761726473-
  7358 00002FBE 2020203C2B3E2F3C2D-
  7358 00002FC7 3E20566F6C756D6520-
  7358 00002FD0 202020BA           
  7359 00002FD4 BA203C423E20202020-     	db  186, " <B>     Backwards  <Q>     Quit Prg  ", 186
  7359 00002FDD 204261636B77617264-
  7359 00002FE6 7320203C513E202020-
  7359 00002FEF 202051756974205072-
  7359 00002FF8 672020BA           
  7360 00002FFC CCCDCDCDCDCDCDCDCD-     	db  204, 38 dup(205), 185
  7360 00003005 CDCDCDCDCDCDCDCDCD-
  7360 0000300E CDCDCDCDCDCDCDCDCD-
  7360 00003017 CDCDCDCDCDCDCDCDCD-
  7360 00003020 CDCDCDB9           
  7361 00003024 BA2046696C653A2020-     	db  186, " File:              Bits:     0       ", 186
  7361 0000302D 202020202020202020-
  7361 00003036 202020426974733A20-
  7361 0000303F 202020203020202020-
  7361 00003048 202020BA           
  7362 0000304C BA20467265713A2030-     	db  186, " Freq: 0     Hz     Channels: 0       ", 186
  7362 00003055 2020202020487A2020-
  7362 0000305E 2020204368616E6E65-
  7362 00003067 6C733A203020202020-
  7362 00003070 202020BA           
  7363 00003074 C8CDCDCDCDCDCDCDCD-     	db  200, 38 dup(205), 188
  7363 0000307D CDCDCDCDCDCDCDCDCD-
  7363 00003086 CDCDCDCDCDCDCDCDCD-
  7363 0000308F CDCDCDCDCDCDCDCDCD-
  7363 00003098 CDCDCDBC           
  7364 0000309C 202020202020202020-     	db  40 dup(32)
  7364 000030A5 202020202020202020-
  7364 000030AE 202020202020202020-
  7364 000030B7 202020202020202020-
  7364 000030C0 20202020           
  7365                                  improper_samplerate_txt:
  7366                                  read_error_txt:
  7367 000030C4 202020202020202020-     	db  40 dup(32)
  7367 000030CD 202020202020202020-
  7367 000030D6 202020202020202020-
  7367 000030DF 202020202020202020-
  7367 000030E8 20202020           
  7368 000030EC 202020202020202020-     	db  40 dup(32)
  7368 000030F5 202020202020202020-
  7368 000030FE 202020202020202020-
  7368 00003107 202020202020202020-
  7368 00003110 20202020           
  7369 00003114 202020202020202020-     	db  40 dup(32)
  7369 0000311D 202020202020202020-
  7369 00003126 202020202020202020-
  7369 0000312F 202020202020202020-
  7369 00003138 20202020           
  7370 0000313C 202020202020202020-     	db  40 dup(32)
  7370 00003145 202020202020202020-
  7370 0000314E 202020202020202020-
  7370 00003157 202020202020202020-
  7370 00003160 20202020           
  7371 00003164 202020202020202020-     	db  40 dup(32)
  7371 0000316D 202020202020202020-
  7371 00003176 202020202020202020-
  7371 0000317F 202020202020202020-
  7371 00003188 20202020           
  7372 0000318C 202020202020202020-     	db  40 dup(32)
  7372 00003195 202020202020202020-
  7372 0000319E 202020202020202020-
  7372 000031A7 202020202020202020-
  7372 000031B0 20202020           
  7373 000031B4 202020202020202020-     	db  40 dup(32)
  7373 000031BD 202020202020202020-
  7373 000031C6 202020202020202020-
  7373 000031CF 202020202020202020-
  7373 000031D8 20202020           
  7374 000031DC 202020202020202020-     	db  40 dup(32)
  7374 000031E5 202020202020202020-
  7374 000031EE 202020202020202020-
  7374 000031F7 202020202020202020-
  7374 00003200 20202020           
  7375 00003204 202020202020202020-     	db  40 dup(32)
  7375 0000320D 202020202020202020-
  7375 00003216 202020202020202020-
  7375 0000321F 202020202020202020-
  7375 00003228 20202020           
  7376 0000322C 202020202020202020-     	db  40 dup(32)
  7376 00003235 202020202020202020-
  7376 0000323E 202020202020202020-
  7376 00003247 202020202020202020-
  7376 00003250 20202020           
  7377 00003254 CDCDCDCDCDCDCDCDCD-     	db  40 dup(205)
  7377 0000325D CDCDCDCDCDCDCDCDCD-
  7377 00003266 CDCDCDCDCDCDCDCDCD-
  7377 0000326F CDCDCDCDCDCDCDCDCD-
  7377 00003278 CDCDCDCD           
  7378 0000327C 202020202020202020-     	db  40 dup(32)
  7378 00003285 202020202020202020-
  7378 0000328E 202020202020202020-
  7378 00003297 202020202020202020-
  7378 000032A0 20202020           
  7379 000032A4 202020202020202020-     	db  13 dup(32), "00:00 ", 174, 175, " 00:00", 4 dup(32), "VOL 000%"
  7379 000032AD 2020202030303A3030-
  7379 000032B6 20AEAF2030303A3030-
  7379 000032BF 20202020564F4C2030-
  7379 000032C8 303025             
  7380                                  	;db  40 dup(32) ; not necessary
  7381 000032CB 00                      	db 0
  7382                                  
  7383                                  ; -------------------------------------------------------------
  7384                                  
  7385                                  	; 30/12/2024
  7386                                  fillblock:
  7387 000032CC FF<rep 8h>              	times 8 db 0FFh
  7388 000032D4 0000                    	dw 0
  7389                                  
  7390                                  ; -------------------------------------------------------------
  7391                                  
  7392                                  ; 30/12/2024
  7393                                  ; 23/11/2024
  7394                                  colors:
  7395 000032D6 0F0B0A0C0E090D          	db 0Fh, 0Bh, 0Ah, 0Ch, 0Eh, 09h, 0Dh
  7396                                  	; white, cyan, green, red, yellow, blue, magenta
  7397 000032DD 0B                      ccolor:	db 0Bh	; cyan
  7398                                  
  7399                                  EOF: 
  7400                                  
  7401                                  ; -------------------------------------------------------------
  7402                                  
  7403                                  bss:
  7404                                  
  7405                                  ABSOLUTE bss
  7406                                  
  7407 000032DE ????                    alignb 4
  7408                                  
  7409                                  ; 24/12/2024
  7410                                  wpoints_dif:	; wave lighting points factor (differential) 
  7411 000032E0 ????????                	resd 1	; required bytes for 1/18 second wave lighting
  7412                                  graphstart:
  7413 000032E4 ????????                	resd 1	; start (top) line/row for wave lighting points 	 
  7414                                  
  7415                                  ; 30/12/2024
  7416                                  ;LFB_ADDR:
  7417                                  ;	resd 1
  7418                                  
  7419                                  ;nextrow:
  7420                                  	;resd 1
  7421                                  screenpos: ; hw = (cursor) row, lw = (cursor) column
  7422 000032E8 ????????                	resd 1
  7423 000032EC ????????                wcolor:	resd 1
  7424                                  ; 26/12/2024
  7425                                  ;tcolor: resb 1 ; text color
  7426                                  columns:
  7427 000032F0 ??                      	resb 1
  7428 000032F1 ??                      pbprev:	resb 1 ; previous progress bar indicator position
  7429                                  
  7430 000032F2 ????                    alignb 4
  7431                                  
  7432                                  bss_start:
  7433                                  
  7434                                  ; 29/12/2024
  7435                                  audio_buffer:
  7436 000032F4 ????????                	resd 1
  7437                                  
  7438                                  ; 30/12/2024
  7439                                  prev_points:
  7440 000032F8 <res 500h>              	resd 320 ; previous wave points (which are lighting)	
  7441                                  
  7442                                  ; 18/11/2024
  7443                                  stopped:
  7444 000037F8 ??                      	resb 1
  7445 000037F9 ??                      tLO:	resb 1
  7446                                  ; 21/11/2024
  7447 000037FA ??                      tLP:	resb 1
  7448                                  ; 30/12/2024
  7449                                  wpoints:
  7450 000037FB ??                      	resb 1
  7451 000037FC ????????                pbuf_o:	resd 1
  7452                                  ; 29/12/2024
  7453 00003800 ????????                pbuf_s:	resd 1
  7454                                  
  7455                                  ; 07/12/2024
  7456                                  ; 24/11/2024
  7457                                  half_buffer:
  7458 00003804 ??                      	resb 1	; dma half buffer 1 or 2 (0 or 1)
  7459                                  
  7460                                  ; 30/05/2024
  7461 00003805 ??                      VRA:	resb 1	; Variable Rate Audio Support Status
  7462                                  
  7463                                  ; 25/12/2024
  7464                                  ; 29/11/2024
  7465                                  command:
  7466 00003806 ??                      	resb 1
  7467                                  filecount:
  7468 00003807 ??                      	resb 1
  7469                                  
  7470                                  ; 30/11/2024
  7471                                  alignb 4
  7472                                  
  7473                                  ;;;;;;;;;;;;;;
  7474                                  ; 14/11/2024
  7475                                  ; (Ref: player.asm, Matan Alfasi, 2017)  
  7476                                  WAVFILEHEADERbuff:
  7477                                  RIFF_ChunkID:
  7478 00003808 ????????                	resd 1	; Must be equal to "RIFF" - big-endian
  7479                                  		; 0x52494646
  7480                                  RIFF_ChunkSize:
  7481 0000380C ????????                	resd 1	; Represents total file size, not 
  7482                                          	; including the first 2 fields 
  7483                                  		; (Total_File_Size - 8), little-endian
  7484                                  RIFF_Format:
  7485 00003810 ????????                	resd 1	; Must be equal to "WAVE" - big-endian
  7486                                  		; 0x57415645
  7487                                  
  7488                                  ;; WAVE header parameters ("Sub-chunk")
  7489                                  WAVE_SubchunkID:
  7490 00003814 ????????                	resd 1	; Must be equal to "fmt " - big-endian
  7491                                  		; 0x666d7420
  7492                                  WAVE_SubchunkSize:
  7493 00003818 ????????                	resd 1	; Represents total chunk size
  7494                                  WAVE_AudioFormat:
  7495 0000381C ????                    	resw 1	; PCM (Raw) - is 1, other - is a form 
  7496                                  		; of compression, not supported.
  7497                                  WAVE_NumChannels:
  7498 0000381E ????                    	resw 1	; Number of channels, Mono-1, Stereo-2
  7499                                  WAVE_SampleRate:
  7500 00003820 ????????                	resd 1	; Frequency rate, in Hz (8000, 44100 ...)
  7501                                  WAVE_ByteRate:
  7502 00003824 ????????                	resd 1	; SampleRate * NumChannels * BytesPerSample
  7503                                  WAVE_BlockAlign:
  7504 00003828 ????                    	resw 1	; NumChannels * BytesPerSample
  7505                                  		; Number of bytes for one sample.
  7506                                  WAVE_BitsPerSample:
  7507 0000382A ????                    	resw 1	; 8 = 8 bits, 16 = 16 bits, etc.
  7508                                  
  7509                                  ;; DATA header parameters
  7510                                  DATA_SubchunkID:
  7511 0000382C ????????                	resd 1	; Must be equal to "data" - big-endian
  7512                                          	; 0x64617461
  7513                                  DATA_SubchunkSize:
  7514 00003830 ????????                	resd 1	; NumSamples * NumChannels * BytesPerSample
  7515                                          	; Number of bytes in the data.
  7516                                  ;;;;;;;;;;;;;;
  7517                                  
  7518                                  ; 28/12/2024
  7519                                  ; 15/11/2024
  7520                                  ;cursortype:
  7521 00003834 ????                    	resw 1
  7522 00003836 ??                      flags:	resb 1
  7523                                  ; 06/11/2023
  7524                                  ac97_int_ln_reg:
  7525 00003837 ??                      	resb 1
  7526                                  filehandle:
  7527 00003838 ????????                	resd 1
  7528                                  
  7529                                  ; 25/12/2024
  7530                                  ; 30/11/2024
  7531                                  ;argc:	resb 1	; argument count
  7532 0000383C ????????                argv:	resd 1	; current argument (wav file) ptr
  7533 00003840 ????????                argvf:	resd 1	; 1st argument (wav file) ptr
  7534 00003844 ????????                argvl:	resd 1	; last argument (wav file) ptr
  7535                                  
  7536                                  ; 30/05/2024
  7537                                  wav_file_name:
  7538 00003848 <res 50h>               	resb 80	; wave file, path name (<= 80 bytes)
  7539 00003898 ????                    	resw 1	; 30/11/2024
  7540                                  
  7541                                  ; 08/11/2023
  7542                                  ; 07/11/2023
  7543                                  fbs_shift:
  7544 0000389A ??                      	resb 1
  7545                                  ; 07/12/2024
  7546 0000389B ??                      SRB:	resb 1
  7547                                  
  7548                                  ; 12/11/2016 - Erdogan Tan
  7549                                  bus_dev_fn:
  7550 0000389C ????????                	resd 1
  7551                                  dev_vendor:
  7552 000038A0 ????????                	resd 1
  7553                                  
  7554                                  ; 17/02/2017
  7555                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  7556                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  7557                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  7558                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  7559 000038A4 ????                    NAMBAR:	resw 1	; BAR for mixer
  7560                                  NABMBAR:
  7561 000038A6 ????                    	resw 1	; BAR for bus master regs
  7562                                  
  7563                                  ; 15/11/2024
  7564                                  loadfromwavfile:
  7565 000038A8 ????????                	resd 1	; 'loadfromfile' or load+conversion proc address
  7566                                  loadsize:
  7567 000038AC ????????                	resd 1	; (.wav file) read count (bytes) per one time
  7568                                  buffersize:
  7569 000038B0 ????????                	resd 1	; 16 bit samples (not bytes)
  7570                                  		
  7571                                  ; 14/11/2024
  7572                                  TotalTime:
  7573 000038B4 ????????                	resd 1	; Total (WAV File) Playing Time in seconds
  7574                                  ProgressTime:
  7575 000038B8 ????????                	resd 1
  7576 000038BC ????????                count:	resd 1	; byte count of one (wav file) read
  7577                                  LoadedDataBytes:
  7578 000038C0 ????????                	resd 1	; total read/load count
  7579                                  
  7580                                  timerticks:
  7581 000038C4 ????????                	resd 1	; (to eliminate excessive lookup of events in tuneloop)
  7582                                  		; (in order to get the emulator/qemu to run correctly)
  7583                                  ; 01/12/2024
  7584                                  _bdl_buffer:
  7585 000038C8 ????????                	resd 1
  7586                                  
  7587                                  ; 14/11/2024
  7588                                  bss_end:
  7589                                  
  7590                                  ; 29/12/2024
  7591 000038CC <res 734h>              alignb 4096
  7592                                  
  7593                                  ; 01/12/2024
  7594                                  BDL_BUFFER:
  7595 00004000 <res 100h>              	resb 256
  7596                                  	; 02/12/2024
  7597 00004100 <res F00h>              	resb 4096-256
  7598                                  
  7599                                  ;alignb 4096
  7600                                  
  7601                                  ; 29/05/2024
  7602                                  WAVBUFFER_1:
  7603 00005000 <res 10000h>            	resb 65536
  7604                                  WAVBUFFER_2:
  7605 00015000 <res 10000h>            	resb 65536
  7606                                  
  7607                                  ; 01/12/2024
  7608                                  ; 26/11/2023
  7609                                  temp_buffer:
  7610 00025000 <res 10000h>            	resb 65536  ;  resb BUFFERSIZE
