     1                                  ; ****************************************************************************
     2                                  ; cgaplay1.s - TRDOS 386 (TRDOS v2.0.9) WAV PLAYER - Video Mode 13h
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; CGAPLAY0.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: 06/02/2025 ]
     9                                  ;
    10                                  ; Modified from VGAPLAY3.PRG .wav player program by Erdogan Tan, 30/12/2024
    11                                  ;
    12                                  ; ****************************************************************************
    13                                  ; nasm cgaplay1.s -l cgaplay1.txt -o CGAPLAY1.PRG -Z error.txt
    14                                  
    15                                  ; 31/12/2024
    16                                  ; cgaplay1.s (int 31h modifications on cgaplay.s)
    17                                  ; 30/12/2024 (cgaplay.s)
    18                                  ; vgaplay3.s
    19                                  ; 27/12/2024
    20                                  ; vgaplay2.s : DMA buffer tracking (instead of user's audio buffer)
    21                                  ; 18/12/2024
    22                                  ; ac97play.s : TUNELOOP version (playing without AC97 interrupt)
    23                                  
    24                                  ; vgaplay.s (26/12/2024) - play music from multiple wav files -
    25                                  ; dplayvga.s (25/12/2024) - play music from single wav file -
    26                                  ; ac97play.s (18/12/2024) - play music from multiple wav files -
    27                                  
    28                                  ; 07/12/2024 - playwav9.s - interrupt (srb) + tuneloop version
    29                                  ; ------------------------------------------------------------
    30                                  ; INTERRUPT (SRB) + TUNELOOP version ; 24/11/2024 (PLAYWAV9.ASM)
    31                                  ;	(running in DOSBOX, VIRTUALBOX, QEMU is ok)
    32                                  ; Signal Response Byte = message/signal to user about an event/interrupt
    33                                  ;	    as requested (TuneLoop procedure continuously checks this SRB)
    34                                  ; (TRDOS 386 v2 feature is used here as very simple interrupt handler output)
    35                                  
    36                                  ; ------------------------------------------------------------
    37                                  
    38                                  ; !!!!!!!!!!!!!!!!!!!!!!!!!
    39                                  ;
    40                                  ; CGAPLAY1.PRG 
    41                                  ; (PMI32=enabled status fix for TRDOS 386 v2.0.9)
    42                                  ;
    43                                  ; *****
    44                                  ;
    45                                  ; When the video mode 13h is -has been- set by using VESA VBE32 PMI 
    46                                  ;
    47                                  ; (TRDOS 386 kernel uses it if PMI32=1. PMI32 can be set by using 
    48                                  ; a program, "PMI32.PRG" for example. 'sys _video, 0901h' or '0900h'), 
    49                                  ;
    50                                  ; character height and columns are not set for INT 31h 'write string' function.
    51                                  ; Writing characters while these parameters have not contain correct values,
    52                                  ; playing screen will not be shown as normal/correct.
    53                                  ;
    54                                  ; As result of this defect:
    55                                  ; 
    56                                  ; CGAPLAY0.PRG (this file) is modified to check PMI32 value at fist
    57                                  ; then select string writing method accorind to the PMI32 status.
    58                                  ; (If PMI32=0, write string by using INT 31h, otherwise write string as pixels.)
    59                                  ;
    60                                  ; !!!!!!!!!!!!!!!!!!!!!!!!!
    61                                  
    62                                  ; 30/11/2024
    63                                  ; 20/08/2024 ; TRDOS 386 v2.0.9
    64                                  ; 29/04/2016
    65                                  _ver 	equ 0
    66                                  _exit 	equ 1
    67                                  _fork 	equ 2
    68                                  _read 	equ 3
    69                                  _write	equ 4
    70                                  _open	equ 5
    71                                  _close 	equ 6
    72                                  _wait 	equ 7
    73                                  _creat 	equ 8
    74                                  _link 	equ 9
    75                                  _unlink	equ 10
    76                                  _exec	equ 11
    77                                  _chdir	equ 12
    78                                  _time 	equ 13
    79                                  _mkdir 	equ 14
    80                                  _chmod	equ 15
    81                                  _chown	equ 16
    82                                  _break	equ 17
    83                                  _stat	equ 18
    84                                  _seek	equ 19
    85                                  _tell 	equ 20
    86                                  _mount	equ 21
    87                                  _umount	equ 22
    88                                  _setuid	equ 23
    89                                  _getuid	equ 24
    90                                  _stime	equ 25
    91                                  _quit	equ 26
    92                                  _intr	equ 27
    93                                  _fstat	equ 28
    94                                  _emt 	equ 29
    95                                  _mdate 	equ 30
    96                                  _video 	equ 31
    97                                  _audio	equ 32
    98                                  _timer	equ 33
    99                                  _sleep	equ 34
   100                                  _msg    equ 35
   101                                  _geterr	equ 36
   102                                  _fpsave	equ 37
   103                                  _pri	equ 38
   104                                  _rele	equ 39
   105                                  _fff	equ 40
   106                                  _fnf	equ 41
   107                                  _alloc	equ 42
   108                                  _dalloc equ 43
   109                                  _calbac equ 44
   110                                  _dma	equ 45
   111                                  _stdio  equ 46
   112                                  
   113                                  ; ------------------------------------------------------------
   114                                  
   115                                  %macro sys 1-4
   116                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   117                                      ; 03/09/2015
   118                                      ; 13/04/2015
   119                                      ; Retro UNIX 386 v1 system call.
   120                                      %if %0 >= 2
   121                                          mov ebx, %2
   122                                          %if %0 >= 3
   123                                              mov ecx, %3
   124                                              %if %0 = 4
   125                                                 mov edx, %4
   126                                              %endif
   127                                          %endif
   128                                      %endif
   129                                      mov eax, %1
   130                                      ;int 30h
   131                                      int 40h ; TRDOS 386 (TRDOS v2.0)
   132                                  %endmacro
   133                                  
   134                                  ; Retro UNIX 386 v1 system call format:
   135                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   136                                  
   137                                  ; ------------------------------------------------------------
   138                                  
   139                                  ; player internal variables and other equates.
   140                                  BUFFERSIZE	equ 65536
   141                                  ENDOFFILE	equ 1		; flag for knowing end of file
   142                                  
   143                                  ; ------------------------------------------------------------
   144                                  
   145                                  [BITS 32] ; 32-bit intructions
   146                                  
   147                                  [ORG 0]
   148                                  
   149                                  START_CODE:
   150                                  	; Prints the Credits Text.
   151                                  	sys	_msg, Credits, 255, 0Bh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000000 BB[102D0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000005 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000000A BA0B000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000000F B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000014 CD40                <1>  int 40h
   152                                  
   153                                  	; clear bss
   154 00000016 BF[58330000]            	mov	edi, bss_start
   155 0000001B B976010000              	mov	ecx, (bss_end - bss_start)/4
   156 00000020 31C0                    	xor	eax, eax
   157 00000022 F3AB                    	rep	stosd
   158                                  
   159                                  ; -------------------------------------------------------------
   160                                  
   161                                  	; 21/12/2024
   162                                  	; Detect (& Enable) AC'97 Audio Device
   163 00000024 E812080000              	call	DetectAC97
   164 00000029 731B                    	jnc	short ac97_hardware_ready
   165                                  
   166                                  	; 30/11/2024
   167                                  	; 30/05/2024
   168                                  _dev_not_ready:
   169                                  	; couldn't find the audio device!
   170                                  	sys	_msg, noDevMsg, 255, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000002B BB[C12D0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000030 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00000035 BA0F000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000003A B823000000          <1>  mov eax, %1
   130                              <1> 
   131 0000003F CD40                <1>  int 40h
   171 00000041 E9C0040000                      jmp     Exit
   172                                  
   173                                  ac97_hardware_ready:
   174 00000046 E8330E0000              	call	write_audio_dev_info
   175                                  
   176                                  ; -------------------------------------------------------------
   177                                  
   178                                  	; 30/12/2024
   179                                  	;;;
   180                                  	; DIRECT VGA MEMORY ACCESS
   181                                  	; bl = 0, bh = 5
   182                                  	; Direct access/map to VGA memory (0A0000h)
   183                                  
   184                                  	sys	_video, 0500h
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000004B BB00050000          <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000050 B81F000000          <1>  mov eax, %1
   130                              <1> 
   131 00000055 CD40                <1>  int 40h
   185 00000057 3D00000A00              	cmp	eax, 0A0000h
   186 0000005C 7405                    	je	short _a
   187                                  
   188                                  	; 30/12/2024
   189 0000005E E9EB040000              	jmp	trdos386_error
   190                                  
   191                                  _a:
   192                                  	;; Set Video Mode to 13h
   193                                  	;sys	_video, 0813h
   194                                  	;cmp	eax, 14h 
   195                                  	;je	short mode_13h_set_ok
   196                                  
   197                                  	; set VGA mode by using int 31h
   198 00000063 66B81300                	mov	ax, 13h	; mode 13h ; 
   199 00000067 CD31                    	int	31h	; real mode: int 10h
   200                                  
   201                                  ; -------------------------------------------------------------
   202                                  
   203                                  mode_13h_set_ok:
   204                                  	; 30/12/2024
   205                                  	; 24/12/2024 (setting for wave lighting points)
   206                                  	;mov	eax, 0A0000h
   207                                  	;;add	eax, 12*8*320
   208                                  	;add	eax, (13*8*320)+(2*320)
   209                                  			; wave graphics start (top) line/row
   210                                  			; 64 volume levels
   211                                  	;mov	[graphstart], eax
   212                                  	; 30/12/2024
   213                                  	;mov	dword [graphstart], 0A0000h+(13*8*320)+(4*320)
   214                                  	; 01/01/2025
   215 00000069 C705[4C330000]0073-     	mov	dword [graphstart], 0A0000h+(11*8*320)+(4*320)
   215 00000071 0A00               
   216                                  
   217                                  ; -------------------------------------------------------------
   218                                  
   219                                  	; 25/12/2024
   220                                  	; 28/11/2024
   221                                  Player_InitalizePSP:
   222                                  	; 30/11/2024
   223                                  	; (TRDOS 386 -Retro UNIX 386- argument transfer method)
   224                                  	; (stack: argc,argv0addr,argv1addr,argv2addr ..
   225                                  	;			.. argv0text, argv1text ..) 
   226                                  	; ---- argc, argv[] ----
   227 00000073 89E6                    	mov	esi, esp
   228 00000075 AD                      	lodsd
   229 00000076 83F802                  	cmp	eax, 2 ; two arguments 
   230                                  		; (program file name & mod file name)
   231 00000079 0F8290040000            	jb	pmsg_usage ; nothing to do
   232                                  	;mov	[argc], al
   233 0000007F C1E002                  	shl	eax, 2 ; *4
   234 00000082 01E0                    	add	eax, esp
   235                                  	; eax = last argument's address pointer
   236 00000084 A3[A8380000]            	mov	[argvl], eax ; last wav file (argument)
   237 00000089 8935[A0380000]          	mov	[argv], esi ; current argument (PRG file name)
   238 0000008F AD                      	lodsd	; skip program (PRG) file name
   239 00000090 8935[A4380000]          	mov	[argvf], esi ; 1st wav file (argument)
   240                                  
   241                                  	; 30/12/2024
   242                                  Player_ParseParameters:
   243 00000096 EB2A                    	jmp	short Player_ParseNextParameter
   244                                  	; 25/12/2024
   245                                  check_p_command:
   246                                  	; 07/12/2024
   247 00000098 8B35[A0380000]          	mov	esi, [argv]
   248                                  	;
   249 0000009E 803D[6A380000]50          	cmp	byte [command], 'P'
   250 000000A5 7410                    	je	short Player_ParsePreviousParameter
   251                                      
   252                                  	; 07/12/2024
   253                                  	; 30/11/2024
   254                                  	;mov	esi, [argv] ; current argument (wav file) ptr
   255 000000A7 83C604                  	add	esi, 4
   256 000000AA 3B35[A8380000]          	cmp	esi, [argvl] ; last argument (wav file) ptr
   257 000000B0 7610                    	jna	short Player_ParseNextParameter
   258                                  jmp_Player_Quit:
   259 000000B2 E93F050000              	jmp	Player_Quit
   260                                  
   261                                  Player_ParsePreviousParameter:
   262                                  	; 29/11/2024
   263                                  	;mov	byte [command], 0
   264                                  	; 30/11/2024
   265                                  	;mov	esi, [argv] ; 07/12/2024	
   266 000000B7 3B35[A4380000]          	cmp	esi, [argvf] ; first argument (wav file) ptr
   267 000000BD 7603                    	jna	short Player_ParseNextParameter
   268 000000BF 83EE04                  	sub	esi, 4
   269                                  Player_ParseNextParameter:
   270                                  	; 30/11/2024
   271 000000C2 8935[A0380000]          	mov	[argv], esi  ; set as current argument
   272                                  
   273                                  	; 01/12/2024
   274 000000C8 8B36                    	mov	esi, [esi]
   275                                  
   276                                  	; 30/12/2024
   277                                  	; 29/11/2024
   278 000000CA E83C000000              	call	GetFileName
   279                                  	;jcxz	jmp_Player_Quit
   280 000000CF E3E1                    	jecxz	jmp_Player_Quit ; 30/11/2024
   281                                  
   282                                  	; 30/12/2024
   283                                          ; open existing file
   284                                  	; 28/11/2024
   285 000000D1 BA[AC380000]            	mov	edx, wav_file_name
   286 000000D6 E8B0070000                      call	openFile ; no error? ok.
   287 000000DB 7376                            jnc	getwavparms	; 14/11/2024
   288                                  
   289                                  	; 29/11/2024
   290 000000DD 803D[6B380000]00        	cmp	byte [filecount], 0
   291 000000E4 77B2                    	ja	short check_p_command
   292                                  
   293                                  	; 25/12/2024
   294                                  	; 21/12/2024
   295 000000E6 E803050000              	call	set_text_mode
   296                                  	; file not found!
   297                                  	; 30/11/2024
   298                                  	sys	_msg, noFileErrMsg, 255, 0Ch
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000000EB BB[EC2D0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000000F0 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000000F5 BA0C000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000000FA B823000000          <1>  mov eax, %1
   130                              <1> 
   131 000000FF CD40                <1>  int 40h
   299 00000101 E900040000                      jmp     Exit
   300                                  
   301                                  _exit_:
   302 00000106 E9F6030000              	jmp	terminate
   303                                  
   304                                  ; -------------------------------------------------------------
   305                                  
   306                                  	; 26/12/2024
   307                                  	; 25/12/2024
   308                                  	; 30/11/2024 (32bit)
   309                                  	; 29/11/2024
   310                                  	; 30/05/2024
   311                                  GetFileName:
   312 0000010B BF[AC380000]            	mov	edi, wav_file_name 
   313                                  	; 30/11/2024
   314                                  	;mov	esi, [argv]
   315 00000110 31C9                    	xor	ecx, ecx ; 0
   316                                  ScanName:
   317 00000112 AC                      	lodsb
   318                                  	;test	al, al
   319                                  	;jz	short a_4
   320                                  	; 29/11/2024
   321 00000113 3C0D                    	cmp	al, 0Dh
   322 00000115 7638                    	jna	short a_4
   323 00000117 3C20                    	cmp	al, 20h
   324 00000119 74F7                    	je	short ScanName	; scan start of name.
   325 0000011B AA                      	stosb
   326 0000011C B4FF                    	mov	ah, 0FFh
   327                                  	;;;
   328                                  	; 14/11/2024
   329                                  	; (max. path length = 64 bytes for MSDOS ?) (*)
   330                                  	;xor	ecx, ecx ; 0
   331                                  	;;;
   332                                  a_0:	
   333 0000011E FEC4                    	inc	ah
   334                                  a_1:
   335                                  	;;;
   336                                  	; 14/11/2024
   337 00000120 41                      	inc	ecx
   338                                  	;;;
   339 00000121 AC                      	lodsb
   340 00000122 AA                      	stosb
   341 00000123 3C2E                    	cmp	al, '.'
   342 00000125 74F7                    	je	short a_0
   343                                  	; 29/11/2024
   344 00000127 3C20                    	cmp	al, 20h
   345                                  	;and	al, al
   346                                  	;jnz	short a_1
   347                                  	;;;
   348                                  	; 14/11/2024
   349 00000129 7613                    	jna	short a_3
   350 0000012B 20E4                    	and	ah, ah
   351 0000012D 7406                    	jz	short a_2
   352 0000012F 3C2F                    	cmp	al, '/'	; 14/12/2024
   353 00000131 7502                    	jne	short a_2
   354 00000133 B400                    	mov	ah, 0
   355                                  a_2:
   356 00000135 80F94B                  	cmp	cl, 75	; 64+8+'.'+3 -> offset 75 is the last chr
   357 00000138 72E6                    	jb	short a_1
   358                                  	; 29/11/2024
   359 0000013A 29C9                    	sub	ecx, ecx
   360 0000013C EB11                    	jmp	short a_4
   361                                  a_3:
   362                                  	; 29/11/2024
   363 0000013E 4F                      	dec	edi
   364                                  	;;;
   365 0000013F 08E4                    	or	ah, ah		; if period NOT found,
   366 00000141 750C                    	jnz	short a_4 	; then add a .WAV extension.
   367                                  SetExt:
   368                                  	; 29/11/2024
   369                                  	;dec	edi
   370 00000143 C7072E574156            	mov	dword [edi], '.WAV'
   371                                  				; ! 64+12 is DOS limit
   372                                  				; but writing +4 must not
   373                                  				; destroy the following data	 
   374                                  	;mov	byte [edi+4], 0	; so, 80 bytes path + 0 is possible here
   375                                  	; 29/11/2024
   376 00000149 83C104                  	add	ecx, 4
   377 0000014C 83C704                  	add	edi, 4
   378                                  a_4:	
   379 0000014F C60700                  	mov	byte [edi], 0
   380                                  	; 30/11/2024
   381 00000152 C3                      	retn
   382                                  
   383                                  ; -------------------------------------------------------------
   384                                  
   385                                  getwavparms:
   386                                  	; 14/11/2024
   387 00000153 E865070000                     	call    getWAVParameters
   388 00000158 72AC                    	jc	short _exit_		; nothing to do
   389                                  
   390                                  	; 17/11/2024
   391 0000015A B304                    	mov	bl, 4
   392 0000015C 2A1D[8C380000]          	sub	bl, byte [WAVE_BlockAlign]
   393                                  			; = 0 for 16 bit stereo
   394                                  			; = 2 for 8 bit stereo or 16 bit mono
   395                                  			; = 3 for 8 bit mono	
   396                                  
   397 00000162 D0EB                    	shr	bl, 1	;  0 -->  0,  2 -->  1,  3 -->  1
   398                                  	; 15/11/2024
   399 00000164 80D300                  	adc	bl, 0	; 3 --> 1 --> 2
   400 00000167 881D[FE380000]          	mov	byte [fbs_shift], bl	; = 2 mono and 8 bit
   401                                  					; = 0 stereo and 16 bit
   402                                  					; = 1 mono or 8 bit
   403                                  	; 29/12/2024
   404                                  	; 30/05/2024
   405 0000016D E8B8080000              	call	codecConfig		; unmute codec, set rates.
   406 00000172 0F82B4030000            	jc	init_err
   407                                  
   408                                  ; -------------------------------------------------------------
   409                                  
   410                                  StartPlay:
   411                                  	; 30/12/2024
   412 00000178 C605[5F380000]01        	mov	byte [wpoints], 1
   413                                  
   414                                  	;;;
   415                                  	; 09/12/2024
   416 0000017F B834290000              	mov	eax, 10548 ; (48000*10/182)*4
   417 00000184 803D[69380000]00        	cmp	byte [VRA], 0
   418 0000018B 7614                    	jna	short _w ; 48kHZ (interpolation)
   419                                  	;
   420 0000018D 66A1[84380000]          	mov	ax, [WAVE_SampleRate]
   421 00000193 B90A000000              	mov	ecx, 10
   422 00000198 F7E1                    	mul	ecx
   423 0000019A B1B6                    	mov	cl, 182
   424 0000019C F7F1                    	div	ecx
   425                                  	; ax = samples per 1/18.2 second
   426                                  	;mov	cl, byte [WAVE_BlockAlign]
   427                                  	; 09/12/2024 
   428                                  	;mov	cl, 4 ; 16 bit, stereo
   429                                  	;mul	ecx
   430 0000019E C1E002                  	shl	eax, 2 ; * 4
   431                                  _w:
   432 000001A1 A3[48330000]            	mov	[wpoints_dif], eax ; buffer read differential (distance)
   433                                  				; for wave volume leds update
   434                                  				; (byte stream per 1/18.2 second)
   435                                  
   436                                  ; -------------------------------------------------------------
   437                                  
   438                                  	; 25/12/2024
   439 000001A6 FE05[6B380000]          	inc	byte [filecount]
   440 000001AC C605[6A380000]00        	mov	byte [command], 0
   441                                  	; 30/12/2024
   442 000001B3 C605[55330000]FF        	mov	byte [pbprev], -1
   443                                  
   444                                  ; -------------------------------------------------------------
   445                                  
   446                                  	; 07/12/2024 (playwav9.s)
   447                                  
   448                                  	; 18/11/2023 (ich_wav4.asm)
   449                                  	; 13/11/2023 (ich_wav3.asm)
   450                                  
   451 000001BA 803D[69380000]01        	cmp	byte [VRA], 1
   452 000001C1 7226                    	jb	short chk_sample_rate
   453                                  
   454                                  playwav_48_khz:
   455 000001C3 C705[0C390000]-         	mov	dword [loadfromwavfile], loadFromFile
   455 000001C9 [B00D0000]         
   456                                  	;mov	dword [loadsize], 0 ; 65536
   457                                  	;;;
   458                                  	; 17/11/2024
   459                                  	;mov	word [buffersize], 32768
   460                                  	;mov	ax, BUFFERSIZE/2 ; 32760
   461                                  	; 30/11/2024
   462                                  	;mov	eax, BUFFERSIZE/2 ; 32768
   463                                  	; 07/12/2024
   464 000001CD B800000100              	mov	eax, BUFFERSIZE ; 65536
   465 000001D2 A3[14390000]            	mov	[buffersize], eax	; 16 bit samples
   466                                  	; 07/12/2024
   467                                  	;shl	eax, 1			; bytes
   468 000001D7 8A0D[FE380000]          	mov	cl, [fbs_shift]
   469 000001DD D3E8                    	shr	eax, cl 
   470                                  	;mov	[loadsize], ax ; 16380 or 32760 or 65520
   471 000001DF A3[10390000]            	mov	[loadsize], eax ; 16384 or 32768 or 65536
   472                                  	;;;
   473                                  	;jmp	PlayNow ; 30/05/2024
   474                                  	; 07/12/2024
   475 000001E4 E9AA020000              	jmp	Player_Template
   476                                  
   477                                  
   478                                  	; 05/02/2025
   479                                  chk_sample_rate:
   480                                  	; set conversion parameters
   481                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   482 000001E9 66A1[84380000]          	mov	ax, [WAVE_SampleRate]
   483 000001EF 663D80BB                	cmp	ax, 48000
   484 000001F3 74CE                    	je	short playwav_48_khz
   485                                  chk_22khz:
   486 000001F5 663D2256                	cmp	ax, 22050
   487 000001F9 7545                    	jne	short chk_11khz
   488 000001FB 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   489 00000202 7615                    	jna	short chk_22khz_1
   490 00000204 BB[D51C0000]            	mov	ebx, load_22khz_stereo_16_bit
   491 00000209 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   492 00000210 751A                    	jne	short chk_22khz_2
   493 00000212 BB[481C0000]            	mov	ebx, load_22khz_mono_16_bit
   494 00000217 EB13                    	jmp	short chk_22khz_2
   495                                  chk_22khz_1:
   496 00000219 BB[C11B0000]            	mov	ebx, load_22khz_stereo_8_bit
   497 0000021E 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   498 00000225 7505                    	jne	short chk_22khz_2
   499 00000227 BB[381B0000]            	mov	ebx, load_22khz_mono_8_bit
   500                                  chk_22khz_2:
   501 0000022C B85A1D0000              	mov	eax, 7514  ; (442*17)
   502 00000231 BA25000000              	mov	edx, 37
   503 00000236 B911000000              	mov	ecx, 17
   504 0000023B E926020000              	jmp	set_sizes
   505                                  chk_11khz:
   506 00000240 663D112B                	cmp	ax, 11025
   507 00000244 7545                    	jne	short chk_44khz
   508 00000246 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   509 0000024D 7615                    	jna	short chk_11khz_1
   510 0000024F BB[F11E0000]            	mov	ebx, load_11khz_stereo_16_bit
   511 00000254 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   512 0000025B 751A                    	jne	short chk_11khz_2
   513 0000025D BB[781E0000]            	mov	ebx, load_11khz_mono_16_bit
   514 00000262 EB13                    	jmp	short chk_11khz_2
   515                                  chk_11khz_1:
   516 00000264 BB[FE1D0000]            	mov	ebx, load_11khz_stereo_8_bit
   517 00000269 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1 
   518 00000270 7505                    	jne	short chk_11khz_2
   519 00000272 BB[861D0000]            	mov	ebx, load_11khz_mono_8_bit
   520                                  chk_11khz_2:
   521 00000277 B8AD0E0000              	mov	eax, 3757  ; (221*17)
   522 0000027C BA4A000000              	mov	edx, 74
   523 00000281 B911000000              	mov	ecx, 17
   524 00000286 E9DB010000              	jmp	set_sizes
   525                                  chk_44khz:
   526 0000028B 663D44AC                	cmp	ax, 44100
   527 0000028F 7545                    	jne	short chk_16khz
   528 00000291 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   529 00000298 7615                    	jna	short chk_44khz_1
   530 0000029A BB[F8200000]            	mov	ebx, load_44khz_stereo_16_bit
   531 0000029F 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   532 000002A6 751A                    	jne	short chk_44khz_2
   533 000002A8 BB[7F200000]            	mov	ebx, load_44khz_mono_16_bit
   534 000002AD EB13                    	jmp	short chk_44khz_2
   535                                  chk_44khz_1:
   536 000002AF BB[02200000]            	mov	ebx, load_44khz_stereo_8_bit
   537 000002B4 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   538 000002BB 7505                    	jne	short chk_44khz_2
   539 000002BD BB[861F0000]            	mov	ebx, load_44khz_mono_8_bit
   540                                  chk_44khz_2:
   541                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   542 000002C2 B8D93A0000              	mov	eax, 15065 ; (655*23)
   543                                  	; 18/11/2023 ((file size + bss + stack) <= 64KB)
   544                                  	;mov	ax, 14076 ; (612*23)
   545                                  	; 17/11/2024
   546                                  	;mov	ax, 12650 ; (550*23)
   547 000002C7 BA19000000              	mov	edx, 25
   548 000002CC B917000000              	mov	ecx, 23
   549 000002D1 E990010000              	jmp	set_sizes
   550                                  chk_16khz:
   551 000002D6 663D803E                	cmp	ax, 16000
   552 000002DA 7545                    	jne	short chk_8khz
   553 000002DC 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   554 000002E3 7615                    	jna	short chk_16khz_1
   555 000002E5 BB[77160000]            	mov	ebx, load_16khz_stereo_16_bit
   556 000002EA 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1 
   557 000002F1 751A                    	jne	short chk_16khz_2
   558 000002F3 BB[F6150000]            	mov	ebx, load_16khz_mono_16_bit
   559 000002F8 EB13                    	jmp	short chk_16khz_2
   560                                  chk_16khz_1:
   561 000002FA BB[3C150000]            	mov	ebx, load_16khz_stereo_8_bit
   562 000002FF 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   563 00000306 7505                    	jne	short chk_16khz_2
   564 00000308 BB[BD140000]            	mov	ebx, load_16khz_mono_8_bit
   565                                  chk_16khz_2:
   566                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   567 0000030D B855150000              	mov	eax, 5461
   568                                  	; 17/11/2024
   569                                  	;mov	ax, 5460
   570 00000312 BA03000000              	mov	edx, 3
   571 00000317 B901000000              	mov	ecx, 1
   572 0000031C E945010000              	jmp	set_sizes
   573                                  chk_8khz:
   574 00000321 663D401F                	cmp	ax, 8000
   575 00000325 7545                    	jne	short chk_24khz
   576 00000327 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   577 0000032E 7615                    	jna	short chk_8khz_1
   578 00000330 BB[72130000]            	mov	ebx, load_8khz_stereo_16_bit
   579 00000335 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   580 0000033C 751A                    	jne	short chk_8khz_2
   581 0000033E BB[A2120000]            	mov	ebx, load_8khz_mono_16_bit
   582 00000343 EB13                    	jmp	short chk_8khz_2
   583                                  chk_8khz_1:
   584 00000345 BB[72110000]            	mov	ebx, load_8khz_stereo_8_bit
   585 0000034A 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1 
   586 00000351 7505                    	jne	short chk_8khz_2
   587 00000353 BB[8E100000]            	mov	ebx, load_8khz_mono_8_bit
   588                                  chk_8khz_2:
   589 00000358 B8AA0A0000              	mov	eax, 2730
   590 0000035D BA06000000              	mov	edx, 6
   591 00000362 B901000000              	mov	ecx, 1
   592 00000367 E9FA000000              	jmp	set_sizes
   593                                  chk_24khz:
   594 0000036C 663DC05D                	cmp	ax, 24000
   595 00000370 7545                    	jne	short chk_32khz
   596 00000372 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   597 00000379 7615                    	jna	short chk_24khz_1
   598                                  	; 18/01/2025 (BugFix)
   599                                  	; bx -> ebx
   600 0000037B BB[A4180000]            	mov	ebx, load_24khz_stereo_16_bit
   601 00000380 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   602 00000387 751A                    	jne	short chk_24khz_2
   603 00000389 BB[3E180000]            	mov	ebx, load_24khz_mono_16_bit
   604 0000038E EB13                    	jmp	short chk_24khz_2
   605                                  chk_24khz_1:
   606 00000390 BB[B4170000]            	mov	ebx, load_24khz_stereo_8_bit
   607 00000395 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1 
   608 0000039C 7505                    	jne	short chk_24khz_2
   609 0000039E BB[4D170000]            	mov	ebx, load_24khz_mono_8_bit
   610                                  chk_24khz_2:
   611                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   612 000003A3 B800200000              	mov	eax, 8192
   613                                  	; 17/11/2024
   614                                  	;mov	ax, 8190
   615 000003A8 BA02000000              	mov	edx, 2
   616 000003AD B901000000              	mov	ecx, 1
   617 000003B2 E9AF000000              	jmp	set_sizes ; 02/02/2025	
   618                                  
   619                                  chk_32khz:
   620 000003B7 663D007D                	cmp	ax, 32000
   621                                  	;jne	short vra_needed
   622                                  	; 05/02/2025
   623 000003BB 7563                    	jne	short chk_12khz
   624 000003BD 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   625 000003C4 7615                    	jna	short chk_32khz_1
   626 000003C6 BB[A81A0000]            	mov	ebx, load_32khz_stereo_16_bit
   627 000003CB 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   628 000003D2 751A                    	jne	short chk_32khz_2
   629 000003D4 BB[3B1A0000]            	mov	ebx, load_32khz_mono_16_bit
   630 000003D9 EB13                    	jmp	short chk_32khz_2
   631                                  chk_32khz_1:
   632 000003DB BB[9E190000]            	mov	ebx, load_32khz_stereo_8_bit
   633 000003E0 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   634 000003E7 7505                    	jne	short chk_32khz_2
   635 000003E9 BB[2B190000]            	mov	ebx, load_32khz_mono_8_bit
   636                                  chk_32khz_2:
   637                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   638 000003EE B8AA2A0000              	mov	eax, 10922
   639                                  	; 17/11/2024
   640                                  	;mov	ax, 10920
   641 000003F3 BA03000000              	mov	edx, 3
   642 000003F8 B902000000              	mov	ecx, 2
   643                                  	; 05/02/2025
   644 000003FD EB67                    	jmp	short set_sizes
   645                                  
   646                                  	; 07/12/2024
   647                                  vra_needed:
   648                                  	; 30/11/2024 (TRDOS 386, ax -> eax)
   649                                  	; 13/11/2023
   650 000003FF 58                      	pop	eax ; discard return address to the caller
   651                                  	; 30/05/2024
   652                                  vra_err:
   653                                  	; 21/12/2024
   654 00000400 E8E9010000              	call	set_text_mode
   655                                  	; 30/11/2024
   656                                  	sys	_msg, msg_no_vra, 255, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000405 BB[562E0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000040A B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000040F BA0F000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000414 B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000419 CD40                <1>  int 40h
   657 0000041B E9E6000000              	jmp	Exit
   658                                  
   659                                  	;;;;
   660                                  	; 05/02/2025
   661                                  chk_12khz:
   662 00000420 663DE02E                	cmp	ax, 12000
   663 00000424 75D9                    	jne	short vra_needed
   664 00000426 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8
   665 0000042D 7615                    	jna	short chk_12khz_1
   666 0000042F BB[64220000]            	mov	ebx, load_12khz_stereo_16_bit
   667 00000434 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   668 0000043B 751A                    	jne	short chk_12khz_2
   669 0000043D BB[15220000]            	mov	ebx, load_12khz_mono_16_bit
   670 00000442 EB13                    	jmp	short chk_12khz_2
   671                                  chk_12khz_1:
   672 00000444 BB[BF210000]            	mov	ebx, load_12khz_stereo_8_bit
   673 00000449 803D[82380000]01        	cmp	byte [WAVE_NumChannels], 1
   674 00000450 7505                    	jne	short chk_12khz_2
   675 00000452 BB[77210000]            	mov	ebx, load_12khz_mono_8_bit
   676                                  chk_12khz_2:
   677 00000457 B800100000              	mov	eax, 4096
   678 0000045C BA04000000              	mov	edx, 4
   679 00000461 B901000000              	mov	ecx, 1
   680                                  	; 05/02/2025
   681                                  	;jmp	short set_sizes
   682                                  	;;;;
   683                                  
   684                                  set_sizes:
   685                                  	; 30/11/2024 (TRDOS 386, 32bit DOS)
   686                                  	;;;
   687                                  	; 17/11/2024
   688 00000466 51                      	push	ecx
   689 00000467 B102                    	mov	cl, 2
   690 00000469 2A0D[FE380000]          	sub	cl, [fbs_shift]
   691                                  		; = 2 for 16 bit stereo
   692                                  		; = 1 for 16 bit mono or 8 bit stereo
   693                                  		; = 0 for 8 bit mono
   694 0000046F D3E0                    	shl	eax, cl
   695 00000471 59                      	pop	ecx	
   696 00000472 A3[10390000]            	mov	[loadsize], eax	; (one) read count in bytes
   697                                  	;;;
   698 00000477 F7E2                    	mul	edx
   699 00000479 83F901                  	cmp	ecx, 1
   700 0000047C 7402                    	je	short s_2
   701                                  s_1:
   702 0000047E F7F1                    	div	ecx
   703                                  s_2:
   704                                  	;;;
   705                                  	; eax = byte count of (to be) converted samples 
   706                                  	
   707                                  	; 17/11/2024
   708                                  	;;;
   709 00000480 8A0D[FE380000]          	mov	cl, [fbs_shift]
   710                                  
   711 00000486 D3E0                    	shl	eax, cl
   712                                  		; *1 for 16 bit stereo
   713                                  		; *2 for 16 bit mono or 8 bit stereo
   714                                  		; *4 for for 8 bit mono
   715                                  	;;;
   716                                  
   717                                  	; eax = 16 bit stereo byte count (target buffer size)
   718                                  	
   719                                  	; 07/12/2024
   720                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   721 00000488 A3[14390000]            	mov	[buffersize], eax ; buffer size in bytes
   722 0000048D 891D[0C390000]          	mov	[loadfromwavfile], ebx
   723                                  
   724                                  ; -------------------------------------------------------------
   725                                  
   726                                  	; 30/12/2024
   727                                  Player_Template:
   728                                  	; 21/12/2024
   729 00000493 E8DF000000              	call	clearscreen
   730 00000498 E8E9000000              	call	drawplayingscreen
   731                                  
   732                                  	; 14/11/2024
   733 0000049D E897250000              	call	SetTotalTime
   734 000004A2 E85B260000              	call	UpdateFileInfo
   735                                  
   736                                  ; -------------------------------------------------------------
   737                                  
   738                                  	; 30/12/2024 (cgaplay.s)
   739                                  	; 29/12/2024 (vgaplay3.s)
   740                                  	; 18/12/2024 (ac97play.s)
   741                                  PlayNow:
   742                                  	; 01/12/2024 (32bit)
   743                                  	; 14/11/2024
   744                                  	;mov	al, 3	; 0 = max, 31 = min
   745                                  	; 14/12/2024
   746 000004A7 A0[312A0000]            	mov	al, [volume]
   747 000004AC E876030000              	call	SetPCMOutVolume@
   748                                  	; 15/11/2024
   749                                  	;;call	SetMasterVolume
   750                                  	;call	SetPCMOutVolume
   751                                  
   752                                  	;;;
   753                                  	; 14/11/2024
   754 000004B1 E816270000              	call	UpdateProgressBar
   755                                  	;;;
   756                                  
   757                                   	; 30/05/2024
   758                                  	; playwav4.asm
   759                                  _2:	
   760 000004B6 E813250000              	call	check4keyboardstop	; flush keyboard buffer
   761 000004BB 72F9                    	jc	short _2		; 07/11/2023
   762                                  
   763                                  ; play the .wav file. Most of the good stuff is in here.
   764                                  
   765                                  	; 05/12/2024
   766                                  	; 02/12/2024
   767                                  	;mov	eax, [_bdl_buffer]	; BDL_BUFFER physical address
   768                                  ;_3:
   769 000004BD E839010000              	call    PlayWav
   770                                  
   771                                  	; 30/12/2024
   772                                  	; 29/12/2024 (vgaplay3.s)
   773                                  	; 27/12/2024 (vgaplay.s)
   774                                  _3:
   775                                  
   776                                  ; close the .wav file and exit.
   777                                  
   778                                  	; 25/12/2024
   779 000004C2 E8DF030000              	call	closeFile
   780                                  
   781                                  	; 25/12/2024
   782                                  	;;;
   783                                  	; reset file loading and EOF parameters
   784                                  	; 18/12/2024
   785 000004C7 C705[20390000]0000-     	mov	dword [count], 0
   785 000004CF 0000               
   786 000004D1 C705[24390000]0000-     	mov	dword [LoadedDataBytes], 0
   786 000004D9 0000               
   787 000004DB C605[9A380000]00        	mov	byte [flags], 0
   788 000004E2 C605[5C380000]00        	mov	byte [stopped], 0
   789                                  	; 29/12/2024
   790 000004E9 C705[64380000]0000-     	mov	dword [pbuf_s], 0
   790 000004F1 0000               
   791                                  	;;;
   792                                  
   793 000004F3 803D[6A380000]51        	cmp	byte [command], 'Q'
   794 000004FA 7405                    	je	short terminate
   795 000004FC E997FBFFFF              	jmp	check_p_command
   796                                  
   797                                  terminate:
   798 00000501 E8E8000000              	call	set_text_mode
   799                                  Exit:
   800                                  	sys	_exit
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121                              <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000506 B801000000          <1>  mov eax, %1
   130                              <1> 
   131 0000050B CD40                <1>  int 40h
   801                                  halt:
   802 0000050D EBFE                    	jmp	short halt
   803                                  
   804                                  ; -------------------------------------------------------------
   805                                  
   806                                  	; 30/05/2024
   807                                  pmsg_usage:
   808                                  	; 21/12/2024
   809 0000050F E8DA000000              	call	set_text_mode
   810                                  	; 01/12/2024
   811                                  	sys	_msg, msg_usage, 255, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000514 BB[912D0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000519 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000051E BA0F000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000523 B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000528 CD40                <1>  int 40h
   812 0000052A EBDA                    	jmp	short Exit
   813                                  
   814                                  ; -------------------------------------------------------------
   815                                  
   816                                  	; 30/05/2024
   817                                  init_err:
   818                                  	; 21/12/2024
   819 0000052C E8BD000000              	call	set_text_mode
   820                                  	; 01/12/2024
   821                                  	sys	_msg, msg_init_err, 255, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000531 BB[252E0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000536 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000053B BA0F000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000540 B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000545 CD40                <1>  int 40h
   822 00000547 EBBD                    	jmp	short Exit
   823                                  
   824                                  ; -------------------------------------------------------------
   825                                  
   826                                  	; 07/12/2024
   827                                  error_exit:
   828                                  	; 21/12/2024
   829 00000549 E8A0000000              	call	set_text_mode
   830                                  trdos386_error:
   831                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000054E BB[052E0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000553 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00000558 BA0E000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000055D B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000562 CD40                <1>  int 40h
   832 00000564 EBA0                    	jmp	short Exit
   833                                  
   834                                  ; -------------------------------------------------------------
   835                                  
   836                                  	; 21/12/2024
   837                                  print_msg:
   838 00000566 B40E                    	mov	ah, 0Eh
   839 00000568 BB07000000              	mov	ebx, 7
   840                                  	;mov	bl, 7 ; char attribute & color
   841                                  p_next_chr:
   842 0000056D AC                      	lodsb
   843 0000056E 08C0                    	or	al, al
   844 00000570 7404                    	jz	short p_retn ; retn
   845 00000572 CD31                    	int	31h
   846 00000574 EBF7                    	jmp	short p_next_chr
   847                                  p_retn:
   848 00000576 C3                      	retn
   849                                  
   850                                  ; -------------------------------------------------------------
   851                                  
   852                                  	; 30/12/2024
   853                                  clearscreen:
   854                                  	; fast clear
   855                                  	; 320*200, 256 colors
   856 00000577 BF00000A00              	mov	edi, 0A0000h
   857 0000057C B9803E0000              	mov	ecx, (320*200*1)/4
   858 00000581 31C0                    	xor	eax, eax
   859 00000583 F3AB                    	rep	stosd
   860 00000585 C3                      	retn
   861                                  
   862                                  ; -------------------------------------------------------------
   863                                  
   864                                  	; 06/02/2025
   865                                  	; 31/12/2024 (int 31h)
   866                                  	; 30/12/2024 (VGA Mode 13h, 320*200 pixels, 256 colors)
   867                                  	; 26/12/2024
   868                                  	; 21/12/2024
   869                                  drawplayingscreen:
   870 00000586 BD[802F0000]            	mov	ebp, PlayingScreen
   871                                  
   872                                  	; 06/02/2025
   873                                  	; Get VESA VBE3 Protected Mode Interface status
   874                                  	sys	_video, 0902h
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000058B BB02090000          <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000590 B81F000000          <1>  mov eax, %1
   130                              <1> 
   131 00000595 CD40                <1>  int 40h
   875 00000597 3C02                    	cmp	al, 2	; 0 = not VBE3, 1 = PMI32 is disabled
   876                                  			; 2 = PMI32 is enabled 
   877 00000599 723F                    	jb	short use_int31h
   878                                  
   879                                  ; 06/02/2025
   880                                  %if 1
   881                                  ; 31/12/2024
   882                                  ;%if 0
   883                                  	; 06/02/2025
   884 0000059B BE00000000              	mov	esi, 0 ; row 0, column 0
   885                                  	;mov	esi, 00020000h ; row 2, column 0 ; top margin = 2
   886                                  p_d_x:
   887 000005A0 C605[54330000]28        	mov	byte [columns], 40
   888 000005A7 B601                    	mov	dh, 01h ; 8x8 system font
   889                                  p_d_x_n:
   890 000005A9 8A5500                  	mov	dl, [ebp]
   891 000005AC 20D2                    	and	dl, dl
   892 000005AE 7429                    	jz	short p_d_x_ok
   893                                  
   894                                  	; sysvideo system call
   895                                  	; BH = 01h = VGA graphics (0A0000h) data transfers
   896                                  	; BL = 0Fh = write character/font
   897                                  	; DH = 01h = 8*8 system font 
   898                                  	; CL = 0Fh = color (white)
   899                                  	; ESI = cursor/writing position (pixels)
   900                                  	;	HW = row, SI = column
   901                                  
   902                                  	sys	_video, 010Fh, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000005B0 BB0F010000          <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000005B5 B90F000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000005BA B81F000000          <1>  mov eax, %1
   130                              <1> 
   131 000005BF CD40                <1>  int 40h
   903                                  
   904 000005C1 45                      	inc	ebp
   905 000005C2 6683C608                	add	si, 8 ; next char pos
   906 000005C6 FE0D[54330000]          	dec	byte [columns]
   907 000005CC 75DB                    	jnz	short p_d_x_n	; next column
   908 000005CE 6631F6                  	xor	si, si
   909 000005D1 81C600000800            	add	esi, 00080000h	; next row ; 8*8
   910 000005D7 EBC7                    	jmp	short p_d_x
   911                                  p_d_x_ok:
   912 000005D9 C3                      	retn
   913                                  %endif
   914                                  
   915                                  	; 06/02/2025
   916                                  use_int31h:
   917                                  	; 31/12/2024
   918 000005DA B800130000              	mov	eax, 1300h ; write character string
   919 000005DF BB0F000000              	mov	ebx, 0Fh
   920 000005E4 B9C0030000              	mov	ecx, 24*40
   921 000005E9 31D2                    	xor	edx, edx
   922                                  	;int	10h
   923 000005EB CD31                    	int	31h
   924                                  
   925 000005ED C3                      	retn
   926                                  
   927                                  ; -------------------------------------------------------------
   928                                  
   929                                  	; 21/12/2024
   930                                  set_text_mode:
   931 000005EE 30E4                    	xor    ah, ah
   932 000005F0 B003                    	mov    al, 3                        
   933                                   	;int   10h ; al = 03h text mode, int 10 video
   934 000005F2 CD31                    	int    31h ; TRDOS 386 - Video interrupt
   935 000005F4 C3                      	retn
   936                                  
   937                                  ; -------------------------------------------------------------
   938                                  
   939                                  	; 02/12/2024
   940                                  Player_Quit@:
   941 000005F5 58                      	pop	eax ; return addr (call PlayWav@)
   942                                  	
   943                                  	; 29/11/2024
   944                                  Player_Quit:
   945 000005F6 E906FFFFFF              	jmp	 terminate
   946                                  
   947                                  ; -------------------------------------------------------------
   948                                  
   949                                  	; 30/12/2024 (cgaplay.s)
   950                                  	; 29/12/2024 (vgaplay3.s)
   951                                  	; 02/12/2024 (ac97play.s)
   952                                  PlayWav:
   953                                  	; 30/12/2024
   954 000005FB A1[2C390000]            	mov	eax, [_bdl_buffer] ; BDL_BUFFER physical address
   955 00000600 09C0                    	or	eax, eax
   956 00000602 751D                    	jnz	short PlayWav@
   957                                  
   958                                  	; 29/05/2024
   959                                  	; Allocate memory block (33 pages)
   960                                  	sys	_alloc, BDL_BUFFER, 33*4096, 0	; no upper limit
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000604 BB[00400000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000609 B900100200          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000060E BA00000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000613 B82A000000          <1>  mov eax, %1
   130                              <1> 
   131 00000618 CD40                <1>  int 40h
   961                                  	;jc	short Player_Quit ; 01/12/2024
   962 0000061A 72D9                    	jc	short Player_Quit@ ; 02/12/2024
   963                                  
   964 0000061C A3[2C390000]            	mov	[_bdl_buffer], eax ; BDL_BUFFER physical address
   965                                  
   966                                  PlayWav@:
   967                                  	; create Buffer Descriptor List
   968                                  
   969                                  	;  Generic Form of Buffer Descriptor
   970                                  	;  ---------------------------------
   971                                  	;  63   62    61-48    47-32   31-0
   972                                  	;  ---  ---  --------  ------- -----
   973                                  	;  IOC  BUP -reserved- Buffer  Buffer
   974                                  	;		      Length   Pointer
   975                                  	;		      [15:0]   [31:0]
   976                                  
   977                                  	; 30/12/2024	
   978                                  
   979 00000621 0500100000              	add	eax, 4096	; WAVBUFFER_1 physical address
   980 00000626 89C3                    	mov	ebx, eax
   981                                  	;mov	[wav_buffer1], eax
   982                                  	;add	eax, 65536	; WAVBUFFER_2 physical address
   983                                  	;mov	[wav_buffer2], eax
   984                                  
   985 00000628 BF[00400000]            	mov	edi, BDL_BUFFER
   986 0000062D B910000000              	mov	ecx, 16
   987                                  _pw0:
   988                                  	;mov	eax, WAVBUFFER_1
   989 00000632 89D8                    	mov	eax, ebx	; WAVBUFFER_1 physical address
   990 00000634 AB                      	stosd
   991                                  
   992 00000635 A1[14390000]            	mov	eax, [buffersize]
   993                                  	; 02/12/2024
   994 0000063A D1E8                    	shr	eax, 1 ; buffer size in word
   995 0000063C 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
   996 00000641 AB                      	stosd
   997                                  
   998                                  	;mov	eax, WAVBUFFER_2
   999 00000642 89D8                    	mov	eax, ebx
  1000 00000644 0500000100              	add	eax, 65536	; WAVBUFFER_2 physical address
  1001 00000649 AB                      	stosd
  1002                                  
  1003 0000064A A1[14390000]            	mov	eax, [buffersize]
  1004                                  	; 02/12/2024
  1005 0000064F D1E8                    	shr	eax, 1 ; buffer size in word
  1006 00000651 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
  1007 00000656 AB                      	stosd
  1008                                  
  1009 00000657 E2D9                    	loop	_pw0
  1010                                  
  1011                                  	; 14/11/2024
  1012                                  	;mov	dword [count], ecx ; 0
  1013                                  	;mov	dword [LoadedDataBytes], 0
  1014                                  
  1015                                  RePlayWav:
  1016                                  	; 01/12/2024
  1017                                  	; load 64k into buffer 1
  1018 00000659 BF[00500000]            	mov	edi, WAVBUFFER_1
  1019                                  	; 05/02/2025
  1020 0000065E 893D[58330000]          	mov	[audio_buffer], edi
  1021 00000664 FF15[0C390000]          	call	dword [loadfromwavfile]
  1022                                  	; 01/12/2024
  1023                                  	; 14/11/2024
  1024 0000066A A1[20390000]            	mov	eax, [count]
  1025 0000066F 0105[24390000]          	add	[LoadedDataBytes], eax
  1026                                  
  1027                                  	; 18/12/2024
  1028 00000675 C705[20390000]0000-     	mov	dword [count], 0
  1028 0000067D 0000               
  1029                                  
  1030                                  	; and 64k into buffer 2
  1031 0000067F BF[00500100]            	mov	edi, WAVBUFFER_2
  1032                                  	; 05/02/2025
  1033 00000684 893D[58330000]          	mov	[audio_buffer], edi
  1034 0000068A FF15[0C390000]          	call	dword [loadfromwavfile]
  1035                                  	; 01/12/2024
  1036                                  	; 14/11/2024
  1037 00000690 A1[20390000]            	mov	eax, [count]
  1038 00000695 0105[24390000]          	add	[LoadedDataBytes], eax
  1039                                  	
  1040                                  	; write NABMBAR+10h with offset of buffer descriptor list
  1041                                  
  1042                                         	;;mov	eax, BDL_BUFFER
  1043                                          ;mov	eax, esi	; BDL_BUFFER physical address
  1044                                  
  1045                                  	;mov	eax, [_bdl_buffer] ; BDL_BUFFER physical address
  1046                                  	; 02/12/2024
  1047 0000069B 8B1D[2C390000]          	mov	ebx, [_bdl_buffer]
  1048                                  
  1049 000006A1 668B15[0A390000]        	mov	dx, [NABMBAR]
  1050 000006A8 6683C210                        add     dx, PO_BDBAR_REG	; set pointer to BDL
  1051                                  	;out	dx, eax 		; write to AC97 controller
  1052                                  	; 29/05/2024
  1053                                  	;mov	ebx, eax ; data, dword
  1054                                  	; 02/12/2024
  1055                                  	; ebx = [_bdl_buffer] ; data, dword
  1056 000006AC B405                    	mov	ah, 5	; write port dword
  1057 000006AE CD34                    	int	34h
  1058                                  
  1059                                  	; 31/05/2024
  1060                                  	; 19/05/2024
  1061                                  	;call	delay1_4ms
  1062                                  
  1063 000006B0 B01F                            mov	al, 31
  1064 000006B2 E8E9060000              	call	setLastValidIndex
  1065                                  
  1066                                  	; 31/05/2024
  1067                                  	; 19/05/2024
  1068                                  	;call	delay1_4ms
  1069                                  
  1070                                  	; 17/02/2017
  1071 000006B7 668B15[0A390000]                mov	dx, [NABMBAR]
  1072 000006BE 6683C21B                        add	dx, PO_CR_REG		; PCM out Control Register
  1073                                          ;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
  1074                                  	;			; (LVBI interrupt will not be enabled)
  1075                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
  1076 000006C2 B001                    	mov	al, RPBM
  1077                                  	;out	dx, al			; Start bus master operation.
  1078                                  	; 29/05/2024
  1079                                  	; al = data, byte
  1080 000006C4 B401                    	mov	ah, 1 ; write port, byte
  1081 000006C6 CD34                    	int	34h
  1082                                  
  1083                                  	; 30/12/2024
  1084                                  
  1085                                  ; -------------------------------------------
  1086                                  
  1087                                  	; 30/12/2024 (cgaplay.s)
  1088                                  	; 29/12/2024 (vgaplay3.s)
  1089                                  	; 18/12/2024 (ac97play.s)
  1090                                  	; 01/12/2024 (32bit)
  1091                                  	; 29/11/2024
  1092                                  tuneLoop:
  1093                                  	; 30/05/2024
  1094                                  	; 18/11/2023 (ich_wav4.asm)
  1095                                  	; 08/11/2023
  1096                                  	; 06/11/2023
  1097                                  tLWait:
  1098                                  	; 18/11/2024
  1099 000006C8 803D[5C380000]00        	cmp	byte [stopped], 0
  1100                                  	;jna	short tL@
  1101                                  	; 21/11/2024
  1102 000006CF 7718                    	ja	short tLWait@
  1103 000006D1 A0[5E380000]            	mov	al, [tLP]
  1104 000006D6 3C31                    	cmp	al, '1'
  1105 000006D8 7458                    	je	short tL1@
  1106 000006DA 0F87A9000000            	ja	tL2@
  1107 000006E0 B031                    	mov	al, '1'
  1108 000006E2 A2[5E380000]            	mov	[tLP], al
  1109 000006E7 EB49                    	jmp	short tL1@ 
  1110                                  tLWait@:	; 21/11/2024
  1111                                  	;;;
  1112                                  	; 09/12/2024
  1113 000006E9 803D[5C380000]03        	cmp	byte [stopped], 3
  1114 000006F0 0F83EB000000            	jnb	_exitt_
  1115                                  	;;;
  1116 000006F6 E815210000              	call	checkUpdateEvents
  1117 000006FB 0F82E0000000            	jc	_exitt_
  1118                                  	;;;
  1119                                  	; 29/11/2024
  1120 00000701 803D[6A380000]4E        	cmp	byte [command], 'N'
  1121 00000708 0F84D3000000            	je	_exitt_
  1122 0000070E 803D[6A380000]50        	cmp	byte [command], 'P'
  1123 00000715 0F84C6000000            	je	_exitt_
  1124                                  	;;;
  1125 0000071B 803D[5D380000]30        	cmp	byte [tLO], '0'
  1126 00000722 74A4                    	je	short tLWait
  1127 00000724 E8C2000000              	call	tLZ
  1128 00000729 C605[5D380000]30        	mov	byte [tLO], '0'
  1129 00000730 EB96                    	jmp	short tLWait
  1130                                  
  1131                                  ;tLO:	db 0
  1132                                  	
  1133                                  tL1@:
  1134                                  	;mov	al, '1'
  1135                                  	; 19/11/2024
  1136 00000732 A2[5D380000]            	mov	[tLO], al
  1137 00000737 E8B1000000              	call	tL0
  1138                                  tL1:
  1139 0000073C E822060000              	call	updateLVI	; /set LVI != CIV/
  1140 00000741 0F849A000000            	jz	_exitt_		; 08/11/2023
  1141                                  	;;;
  1142                                  	;call	check4keyboardstop
  1143                                  	; 14/11/2024
  1144 00000747 E8C4200000              	call	checkUpdateEvents
  1145 0000074C 0F828F000000            	jc	_exitt_
  1146                                  	; 18/11/2024
  1147 00000752 803D[5C380000]00        	cmp	byte [stopped], 0
  1148 00000759 778E                    	ja	short tLWait@	; 21/11/2024
  1149                                  	;;;
  1150 0000075B E8F3050000              	call	getCurrentIndex
  1151 00000760 A801                    	test	al, BIT0
  1152 00000762 74D8                    	jz	short tL1	; loop if buffer 2 is not playing
  1153                                  
  1154                                  	; load buffer 1
  1155                                  	;mov	ax, [WAV_BUFFER1]
  1156                                  	; 01/12/2024
  1157 00000764 BF[00500000]            	mov	edi, WAVBUFFER_1
  1158                                  	; 05/02/2025
  1159 00000769 893D[58330000]          	mov	[audio_buffer], edi	
  1160                                  
  1161                                  	;call	loadFromFile
  1162                                  	; 18/11/2023
  1163                                  	;call	word [loadfromwavfile]
  1164                                  	; 01/12/2024
  1165 0000076F FF15[0C390000]          	call	dword [loadfromwavfile]
  1166 00000775 726A                    	jc	short _exitt_	; end of file
  1167                                  
  1168                                  	; 14/11/2024
  1169                                  	;mov	ax, [count]
  1170                                  	;add	[LoadedDataBytes], ax
  1171                                  	;adc	word [LoadedDataBytes+2], 0
  1172                                  	; 01/12/2024
  1173 00000777 A1[20390000]            	mov	eax, [count]
  1174 0000077C 0105[24390000]          	add	[LoadedDataBytes], eax
  1175                                  
  1176 00000782 B032                    	mov	al, '2'
  1177                                  	; 21/11/2024
  1178 00000784 A2[5E380000]            	mov	[tLP], al
  1179                                  tL2@:
  1180                                  	; 19/11/2024
  1181 00000789 A2[5D380000]            	mov	[tLO], al
  1182 0000078E E85A000000              	call	tL0
  1183                                  tL2:
  1184 00000793 E8CB050000              	call    updateLVI
  1185 00000798 7447                    	jz	short _exitt_	; 08/11/2023
  1186                                  	;;;
  1187                                  	;call	check4keyboardstop
  1188                                  	; 14/11/2024
  1189 0000079A E871200000              	call	checkUpdateEvents
  1190 0000079F 7240                    	jc	short _exitt_
  1191                                  	; 18/11/2024
  1192 000007A1 803D[5C380000]00        	cmp	byte [stopped], 0
  1193 000007A8 0F873BFFFFFF            	ja	tLWait@		; 21/11/2024 
  1194                                  	;;;
  1195 000007AE E8A0050000              	call    getCurrentIndex
  1196 000007B3 A801                    	test	al, BIT0
  1197 000007B5 75DC                    	jnz	short tL2	; loop if buffer 1 is not playing
  1198                                  
  1199                                  	; load buffer 2
  1200                                  	;mov	ax, [WAV_BUFFER2]
  1201                                  	; 01/12/2024
  1202 000007B7 BF[00500100]            	mov	edi, WAVBUFFER_2
  1203                                  	; 05/02/2025
  1204 000007BC 893D[58330000]          	mov	[audio_buffer], edi
  1205                                  
  1206                                  	;call	loadFromFile
  1207                                  	; 18/11/2023
  1208                                  	;call	word [loadfromwavfile]
  1209                                  	; 01/12/2024
  1210 000007C2 FF15[0C390000]          	call	dword [loadfromwavfile]
  1211                                  	;jnc	short tuneLoop
  1212 000007C8 7217                    	jc	short _exitt_
  1213                                  
  1214                                  	; 14/11/2024
  1215                                  	;mov	ax, [count]
  1216                                  	;add	[LoadedDataBytes], ax
  1217                                  	;adc	word [LoadedDataBytes+2], 0
  1218                                  	; 01/12/2024
  1219 000007CA A1[20390000]            	mov	eax, [count]
  1220 000007CF 0105[24390000]          	add	[LoadedDataBytes], eax	
  1221                                  
  1222                                  	; 21/11/2024
  1223 000007D5 C605[5E380000]31        	mov	byte [tLP], '1'
  1224 000007DC E9E7FEFFFF              	jmp	tuneLoop
  1225                                  
  1226                                  	; 29/12/2024 (vgaplay3.s)
  1227                                  _exitt_:
  1228                                  	; 07/12/2024
  1229                                  	; Stop Playing
  1230                                  	;mov	byte [stopped], 2
  1231                                  	;sys	_audio, 0700h
  1232 000007E1 E8FF040000              	call	ac97_stop
  1233                                  
  1234                                  	;;;
  1235                                  	; 14/11/2024
  1236 000007E6 E8E1230000              	call	UpdateProgressBar
  1237                                  	;;;
  1238                                  
  1239                                  	; 18/11/2024
  1240                                  tLZ:
  1241                                  	; 30/05/2024
  1242 000007EB B030                    	mov	al, '0'
  1243                                  
  1244                                  	;add	al, '0'
  1245                                  	;call	tL0
  1246                                  	;
  1247                                  	;retn
  1248                                  	; 06/11/2023
  1249                                  	;jmp	short tL0
  1250                                  	;retn
  1251                                  
  1252                                  tL0:
  1253                                  	; 31/12/2024 (int 31h)
  1254                                  	; 30/12/2024 (cgaplay.s)
  1255                                  	; 29/05/2024 (TRDOS 386)
  1256                                  	; 08/11/2023
  1257                                  	; 05/11/2023
  1258                                  	; 17/02/2017 - Buffer switch test (temporary)
  1259                                  	; 06/11/2023
  1260                                  	; al = buffer indicator ('1', '2' or '0' -stop- )
  1261                                  
  1262                                  	; 30/12/2024 (video mode 13h modification)
  1263                                  	; (320*200, 256 colors)
  1264                                  	;;;
  1265 000007ED 88C2                    	mov	dl, al ; character
  1266 000007EF BF00000A00              	mov	edi, 0A0000h
  1267                                  
  1268 000007F4 BB08000000              	mov	ebx, 8 ; 8 pixels (8*8 pixels font)
  1269                                  
  1270 000007F9 B00C                    	mov	al, 0Ch ; red
  1271                                  tL0_1:
  1272                                  	;mov	ecx, 8 ; 8 pixels (8*8 pixels font)
  1273 000007FB B907000000              	mov	ecx, 7
  1274                                  tL0_2:
  1275 00000800 AA                      	stosb
  1276 00000801 49                      	dec	ecx
  1277 00000802 75FC                    	jnz	short tL0_2
  1278 00000804 4B                      	dec	ebx
  1279 00000805 7408                    	jz	short tL0_3
  1280                                  	;add	edi, 320-8 ; next line
  1281 00000807 81C739010000            	add	edi, 320-7
  1282 0000080D EBEC                    	jmp	short tL0_1
  1283                                  tL0_3:
  1284                                  
  1285                                  ; 31/12/2024
  1286                                  %if 0
  1287                                  	; write system font
  1288                                  	mov	dh, 01h
  1289                                  	;mov	dl, al ; character
  1290                                  	xor	esi, esi ; = row 0, column 0
  1291                                  	sys	_video, 010Fh, 0Eh ; yellow
  1292                                  	;;;
  1293                                  %endif
  1294                                  	; 31/12/2024
  1295 0000080F 52                      	push	edx
  1296 00000810 31D2                    	xor	edx, edx ; row 0, column 0
  1297 00000812 E81B220000              	call	setCursorPosition
  1298 00000817 58                      	pop	eax
  1299                                  	;
  1300 00000818 B40E                    	mov	ah, 0Eh
  1301 0000081A BB0E000000              	mov	ebx, 0Eh
  1302                                  	;int	10h
  1303 0000081F CD31                    	int	31h
  1304                                  	
  1305 00000821 C3                      	retn
  1306                                  
  1307                                  ; -------------------------------------------
  1308                                  
  1309                                  	; 29/12/2024 (vgaplay3.s)
  1310                                  	; 18/12/2024 (ac97play.s)
  1311                                  	; 14/11/2024
  1312                                  ;SetMasterVolume:
  1313                                  	; 15/11/2024
  1314                                  SetPCMOutVolume:
  1315                                  	;cmp	al, 31
  1316                                  	;ja	short setvolume_ok
  1317 00000822 A2[312A0000]            	mov	[volume], al  ; max = 0, min = 31
  1318                                  SetPCMOutVolume@:	; 19/11/2024
  1319 00000827 88C4                    	mov	ah, al
  1320 00000829 668B15[08390000]        	mov	dx, [NAMBAR]
  1321                                  	; 15/11/2024 (QEMU)
  1322                                    	;add	dx, CODEC_MASTER_VOL_REG
  1323 00000830 6683C218                	add	dx, CODEC_PCM_OUT_REG
  1324                                  	;out	dx, ax
  1325                                  	; 01/12/2024
  1326                                  	; bx = data, word
  1327                                  	; 03/12/2024
  1328 00000834 89C3                    	mov	ebx, eax
  1329 00000836 B403                    	mov	ah, 3  ; write port, word
  1330 00000838 CD34                    	int	34h
  1331                                  ;setvolume_ok:
  1332 0000083A C3                      	retn
  1333                                  
  1334                                  ; -------------------------------------------
  1335                                  
  1336                                  	; 29/12/2024 (vgaplay3.s)
  1337                                  	; 18/12/2024 (ac97play.s)
  1338                                  	; 30/05/2024
  1339                                  DetectAC97:
  1340                                  DetectICH:
  1341                                  	; 22/11/2023
  1342                                  	; 19/11/2023
  1343                                  	; 01/11/2023 - TRDOS 386 Kernel v2.0.7
  1344                                  	;; 10/06/2017
  1345                                  	;; 05/06/2017
  1346                                  	;; 29/05/2017
  1347                                  	;; 28/05/2017
  1348                                  
  1349                                  	; 01/12/2024
  1350                                  	; 19/11/2023
  1351 0000083B BE[B82C0000]            	mov	esi, valid_ids	; address of Valid ICH (AC97) Device IDs
  1352 00000840 B915000000              	mov	ecx, valid_id_count
  1353                                  pfd_1:
  1354 00000845 AD                      	lodsd
  1355 00000846 E8B4000000              	call	pciFindDevice
  1356 0000084B 7303                    	jnc	short d_ac97_1
  1357 0000084D E2F6                    	loop	pfd_1
  1358                                  
  1359                                  	;stc
  1360 0000084F C3                      	retn
  1361                                  
  1362                                  d_ac97_1:
  1363                                  	; eax = BUS/DEV/FN
  1364                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1365                                  	; edx = DEV/VENDOR
  1366                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1367                                  
  1368                                  	; playwav4.asm - 19/05/2024
  1369                                  
  1370 00000850 A3[00390000]            	mov	[bus_dev_fn], eax
  1371 00000855 8915[04390000]          	mov	[dev_vendor], edx
  1372                                  
  1373                                  	; get ICH base address regs for mixer and bus master
  1374                                  
  1375 0000085B B010                            mov     al, NAMBAR_REG
  1376 0000085D E82B010000                      call    pciRegRead16			; read PCI registers 10-11
  1377                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
  1378                                  	; 19/05/2024
  1379 00000862 80E2FE                  	and	dl, 0FEh
  1380                                  
  1381 00000865 668915[08390000]                mov     [NAMBAR], dx			; save audio mixer base addr
  1382                                  
  1383 0000086C B014                    	mov     al, NABMBAR_REG
  1384 0000086E E81A010000                      call    pciRegRead16
  1385                                          ;and    dx, IO_ADDR_MASK
  1386                                  	; 19/05/2024
  1387 00000873 80E2C0                  	and	dl, 0C0h
  1388                                  
  1389 00000876 668915[0A390000]                mov     [NABMBAR], dx			; save bus master base addr
  1390                                  
  1391 0000087D B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
  1392 0000087F E802010000              	call	pciRegRead8 ; 17/02/2017
  1393                                  	
  1394 00000884 8815[9B380000]          	mov	[ac97_int_ln_reg], dl
  1395                                  
  1396                                  	;clc
  1397                                  
  1398 0000088A C3                      	retn
  1399                                  
  1400                                  ; ----------------------------------
  1401                                  	
  1402                                  	; 26/12/2024
  1403                                  	; 07/12/2024
  1404                                  	; 01/12/2024
  1405                                  	; 14/11/2024
  1406                                  	; INPUT: ds:dx = file name address
  1407                                  	; OUTPUT: [filehandle] = ; -1 = not open
  1408                                  openFile:
  1409                                  	; 26/12/2024
  1410                                  	; 01/12/2024
  1411                                  	sys	_open, edx, 0
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000088B 89D3                <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000088D B900000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000892 B805000000          <1>  mov eax, %1
   130                              <1> 
   131 00000897 CD40                <1>  int 40h
  1412                                  	; 07/12/2024
  1413                                  	;sys	_open, wav_file_name, 0
  1414 00000899 7305                    	jnc	short _of1
  1415                                  
  1416 0000089B B8FFFFFFFF              	mov	eax, -1
  1417                                  	; cf = 1 -> not found or access error
  1418                                  _of1:
  1419 000008A0 A3[9C380000]            	mov	[filehandle], eax
  1420 000008A5 C3                      	retn
  1421                                  
  1422                                  ; ----------------------------------
  1423                                  
  1424                                  ; close the currently open file
  1425                                  
  1426                                  	; 01/12/2024
  1427                                  	; 14/11/2024
  1428                                  	; INPUT: [filehandle] ; -1 = not open
  1429                                  	; OUTPUT: none
  1430                                  closeFile:
  1431 000008A6 833D[9C380000]FF        	cmp	dword [filehandle], -1
  1432 000008AD 740D                    	jz	short _cf1
  1433                                  	; 01/12/2024
  1434                                  	sys	_close, [filehandle]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000008AF 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000008B5 B806000000          <1>  mov eax, %1
   130                              <1> 
   131 000008BA CD40                <1>  int 40h
  1435                                  	;mov 	dword [filehandle], -1
  1436                                  _cf1:
  1437 000008BC C3                      	retn
  1438                                  
  1439                                  ; ----------------------------------
  1440                                  
  1441                                  	; 05/02/2025
  1442                                  	; 01/12/2024
  1443                                  	; 14/11/2024 - Erdogan Tan
  1444                                  getWAVParameters:
  1445                                  ; reads WAV file header(s) (44 bytes) from the .wav file.
  1446                                  ; entry: none - assumes file is already open
  1447                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
  1448                                  ;	cx = number of channels (mono=1, stereo=2)
  1449                                  ;	dx = bits per sample (8, 16)
  1450                                  ;	bx = number of bytes per sample (1 to 4)
  1451                                  
  1452                                          ;mov	dx, WAVFILEHEADERbuff
  1453                                  	;mov	bx, [filehandle]
  1454                                          ;mov	cx, 44			; 44 bytes
  1455                                  	;mov	ah, 3Fh
  1456                                          ;int	21h
  1457                                  	;jc	short gwavp_retn
  1458                                  	; 01/12/2024 (TRDOS 386)
  1459                                  	sys	_read, [filehandle], WAVFILEHEADERbuff, 44
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000008BD 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000008C3 B9[6C380000]        <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000008C8 BA2C000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000008CD B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000008D2 CD40                <1>  int 40h
  1460 000008D4 7228                    	jc	short gwavp_retn
  1461                                  
  1462 000008D6 83F82C                  	cmp	eax, 44
  1463 000008D9 7223                    	jb	short gwavp_retn
  1464                                  
  1465 000008DB 813D[74380000]5741-     	cmp	dword [RIFF_Format], 'WAVE'
  1465 000008E3 5645               
  1466 000008E5 7516                    	jne	short gwavp_stc_retn
  1467                                  
  1468 000008E7 66833D[80380000]01      	cmp	word [WAVE_AudioFormat], 1 ; Offset 20, must be 1 (= PCM)
  1469                                  	; 05/02/2025
  1470 000008EF 750C                    	jne	short gwavp_stc_retn
  1471                                  	;je	short gwavp_retn ; 15/11/2024
  1472                                  
  1473                                  	; 05/02/2025
  1474                                  	; (Open MPT creates wav files with a new type header,
  1475                                  	;  this program can not use the new type
  1476                                  	;  because of 'data' offset is not at DATA_SubchunkID.)
  1477                                  	; ((GoldWave creates common type wav file.))
  1478 000008F1 813D[90380000]6461-     	cmp	dword [DATA_SubchunkID], 'data'
  1478 000008F9 7461               
  1479 000008FB 7401                    	je	short gwavp_retn
  1480                                  
  1481                                  	; 15/11/2024
  1482                                  	;mov	cx, [WAVE_NumChannels]	; return num of channels in CX
  1483                                          ;mov    ax, [WAVE_SampleRate]	; return sample rate in AX
  1484                                  	;mov	dx, [WAVE_BitsPerSample] 
  1485                                  					; return bits per sample value in DX
  1486                                  	;mov	bx, [WAVE_BlockAlign]	; return bytes per sample in BX
  1487                                  ;gwavp_retn:
  1488                                          ;retn
  1489                                  
  1490                                  gwavp_stc_retn:
  1491 000008FD F9                      	stc
  1492                                  gwavp_retn:
  1493 000008FE C3                      	retn
  1494                                  
  1495                                  
  1496                                  ; 29/12/2024 (vgaplay3.s)
  1497                                  ; 18/12/2024 (ac97play.s)
  1498                                  ; --------------------------------------------------------
  1499                                  ; 27/05/2024 - (TRDOS 386 Kernel) audio.s
  1500                                  ; --------------------------------------------------------
  1501                                  
  1502                                  NOT_PCI32_PCI16	EQU 03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
  1503                                  NOT_BIT31 EQU 7FFFFFFFh
  1504                                  
  1505                                  pciFindDevice:
  1506                                  	; 19/11/2023
  1507                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1508                                  	;
  1509                                  	; scan through PCI space looking for a device+vendor ID
  1510                                  	;
  1511                                  	; Entry: EAX=Device+Vendor ID
  1512                                  	;
  1513                                  	; Exit: EAX=PCI address if device found
  1514                                  	;	EDX=Device+Vendor ID
  1515                                  	;       CY clear if found, set if not found. EAX invalid if CY set.
  1516                                  	;
  1517                                  	; Destroys: ebx, edi ; 19/11/2023
  1518                                  
  1519                                          ; 19/11/2023
  1520 000008FF 89C3                    	mov	ebx, eax
  1521 00000901 BF00000080              	mov	edi, 80000000h
  1522                                  nextPCIdevice:
  1523 00000906 89F8                    	mov 	eax, edi		; read PCI registers
  1524 00000908 E88C000000              	call	pciRegRead32
  1525                                  	; 19/11/2023
  1526 0000090D 39DA                    	cmp	edx, ebx
  1527 0000090F 7412                    	je	short PCIScanExit	; found
  1528                                  	; 19/11/2023
  1529 00000911 81FF00F8FF80            	cmp	edi, 80FFF800h
  1530 00000917 7308                    	jnb	short pfd_nf		; not found
  1531 00000919 81C700010000            	add	edi, 100h
  1532 0000091F EBE5                    	jmp	short nextPCIdevice
  1533                                  pfd_nf:
  1534 00000921 F9                      	stc
  1535 00000922 C3                      	retn
  1536                                  PCIScanExit:
  1537                                  	;pushf
  1538 00000923 B8FFFFFF7F              	mov	eax, NOT_BIT31 	; 19/03/2017
  1539 00000928 21F8                    	and	eax, edi	; return only bus/dev/fn #
  1540 0000092A C3                      	retn
  1541                                  
  1542                                  pciRegRead:
  1543                                  	; 01/12/2024
  1544                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  1545                                  	;
  1546                                  	; 8/16/32bit PCI reader
  1547                                  	;
  1548                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1549                                  	;           BIT30 set if 32 bit access requested
  1550                                  	;           BIT29 set if 16 bit access requested
  1551                                  	;           otherwise defaults to 8 bit read
  1552                                  	;
  1553                                  	; Exit:  DL,DX,EDX register data depending on requested read size
  1554                                  	;
  1555                                  	; Note1: this routine is meant to be called via pciRegRead8,
  1556                                  	;	 pciRegread16 or pciRegRead32, listed below.
  1557                                  	;
  1558                                  	; Note2: don't attempt to read 32 bits of data from a non dword
  1559                                  	;	 aligned reg number. Likewise, don't do 16 bit reads from
  1560                                  	;	 non word aligned reg #
  1561                                  
  1562 0000092B 53                      	push	ebx
  1563 0000092C 51                      	push	ecx
  1564 0000092D 89C3                            mov     ebx, eax		; save eax, dh
  1565 0000092F 88F1                            mov     cl, dh
  1566                                  
  1567 00000931 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1568 00000936 0D00000080                      or      eax, BIT31		; make a PCI access request
  1569 0000093B 24FC                            and     al, ~3 ; NOT 3 ; 0FCh	; force index to be dword
  1570                                  
  1571 0000093D 66BAF80C                        mov     dx, PCI_INDEX_PORT
  1572                                          ;out	dx, eax			; write PCI selector
  1573                                  	; 29/05/2024
  1574 00000941 53                      	push	ebx
  1575 00000942 89C3                    	mov	ebx, eax ; data, dword
  1576 00000944 B405                    	mov	ah, 5 ; write port, dword
  1577                                  	; dx = port number
  1578 00000946 CD34                    	int	34h
  1579 00000948 5B                      	pop	ebx
  1580                                  	
  1581 00000949 66BAFC0C                        mov     dx, PCI_DATA_PORT
  1582 0000094D 88D8                            mov     al, bl
  1583 0000094F 2403                            and     al, 3			; figure out which port to
  1584 00000951 00C2                            add     dl, al			; read to
  1585                                  
  1586 00000953 F7C3000000C0            	test    ebx, PCI32+PCI16
  1587 00000959 750A                            jnz     short _pregr0
  1588                                  
  1589                                  	;in	al, dx			; return 8 bits of data
  1590                                  	; 29/05/2024
  1591 0000095B B400                    	mov	ah, 0 ; read port, byte
  1592                                  	; dx = port number
  1593 0000095D CD34                    	int	34h
  1594                                          
  1595 0000095F 88C2                    	mov	dl, al
  1596 00000961 88CE                    	mov     dh, cl			; restore dh for 8 bit read
  1597 00000963 EB17                    	jmp	short _pregr2
  1598                                  _pregr0:	
  1599 00000965 F7C300000080            	test    ebx, PCI32
  1600 0000096B 7509                            jnz	short _pregr1
  1601                                  
  1602                                  	;in	ax, dx
  1603                                  	; 29/05/2024
  1604 0000096D B402                    	mov	ah, 2 ; read port, word
  1605                                  	; dx = port number
  1606 0000096F CD34                    	int	34h
  1607                                  
  1608 00000971 6689C2                  	mov     dx, ax			; return 16 bits of data
  1609 00000974 EB06                    	jmp	short _pregr2
  1610                                  _pregr1:
  1611                                  	;in	eax, dx			; return 32 bits of data
  1612                                  	; 29/05/2024
  1613 00000976 B404                    	mov	ah, 4 ; read port, dword
  1614                                  	; dx = port number
  1615 00000978 CD34                    	int	34h
  1616                                  
  1617 0000097A 89C2                    	mov	edx, eax
  1618                                  _pregr2:
  1619 0000097C 89D8                    	mov     eax, ebx		; restore eax
  1620 0000097E 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1621 00000983 59                      	pop	ecx
  1622 00000984 5B                      	pop	ebx
  1623 00000985 C3                      	retn
  1624                                  
  1625                                  pciRegRead8:
  1626 00000986 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
  1627 0000098B EB9E                            jmp     short pciRegRead	; call generic PCI access
  1628                                  
  1629                                  pciRegRead16:
  1630 0000098D 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
  1631 00000992 0D00000040                      or      eax, PCI16		; call generic PCI access
  1632 00000997 EB92                            jmp     short pciRegRead
  1633                                  
  1634                                  pciRegRead32:
  1635 00000999 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
  1636 0000099E 0D00000080                      or      eax, PCI32		; call generic PCI access
  1637 000009A3 EB86                            jmp     pciRegRead
  1638                                  
  1639                                  pciRegWrite:
  1640                                  	; 01/12/2024
  1641                                  	; 03/04/2017 ('pci.asm', 29/11/2016)
  1642                                  	;
  1643                                  	; 8/16/32bit PCI writer
  1644                                  	;
  1645                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  1646                                  	;           BIT31 set if 32 bit access requested
  1647                                  	;           BIT30 set if 16 bit access requested
  1648                                  	;           otherwise defaults to 8bit read
  1649                                  	;        DL/DX/EDX data to write depending on size
  1650                                  	;
  1651                                  	; Note1: this routine is meant to be called via pciRegWrite8,
  1652                                  	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
  1653                                  	;
  1654                                  	; Note2: don't attempt to write 32bits of data from a non dword
  1655                                  	;	 aligned reg number. Likewise, don't do 16 bit writes from
  1656                                  	;	 non word aligned reg #
  1657                                  
  1658 000009A5 53                      	push	ebx
  1659 000009A6 51                      	push	ecx
  1660 000009A7 89C3                            mov     ebx, eax		; save eax, edx
  1661 000009A9 89D1                            mov     ecx, edx
  1662 000009AB 25FFFFFF3F              	and     eax, NOT_PCI32_PCI16	; clear out data size request
  1663 000009B0 0D00000080                      or      eax, BIT31		; make a PCI access request
  1664 000009B5 24FC                            and     al, ~3 ; NOT 3 ; 0FCh	; force index to be dword
  1665                                  
  1666 000009B7 66BAF80C                        mov     dx, PCI_INDEX_PORT
  1667                                  	;out	dx, eax			; write PCI selector
  1668                                  	; 29/05/2024
  1669 000009BB 53                      	push	ebx
  1670 000009BC 89C3                    	mov	ebx, eax ; data, dword
  1671 000009BE B405                    	mov	ah, 5 ; write port, dword
  1672                                  	; dx = port number
  1673 000009C0 CD34                    	int	34h
  1674 000009C2 5B                      	pop	ebx
  1675                                  	
  1676 000009C3 66BAFC0C                        mov     dx, PCI_DATA_PORT
  1677 000009C7 88D8                            mov     al, bl
  1678 000009C9 2403                            and     al, 3			; figure out which port to
  1679 000009CB 00C2                            add     dl, al			; write to
  1680                                  
  1681 000009CD F7C3000000C0            	test    ebx, PCI32+PCI16
  1682 000009D3 7508                            jnz     short _pregw0
  1683 000009D5 88C8                    	mov	al, cl 			; put data into al
  1684                                  	;out	dx, al
  1685                                  	; 29/05/2024
  1686                                  	; al = data, byte
  1687 000009D7 B401                    	mov	ah, 1 ; write port, byte
  1688                                  	; dx = port number
  1689 000009D9 CD34                    	int	34h
  1690                                  
  1691 000009DB EB1F                    	jmp	short _pregw2
  1692                                  _pregw0:
  1693 000009DD F7C300000080            	test    ebx, PCI32
  1694 000009E3 750D                            jnz     short _pregw1
  1695 000009E5 6689C8                  	mov	ax, cx			; put data into ax
  1696                                  	;out	dx, ax
  1697                                  	; 29/05/2024
  1698 000009E8 53                      	push	ebx
  1699 000009E9 89C3                    	mov	ebx, eax ; data, word
  1700 000009EB B403                    	mov	ah, 3 ; write port, word
  1701                                  	; dx = port number
  1702 000009ED CD34                    	int	34h
  1703 000009EF 5B                      	pop	ebx
  1704                                  
  1705 000009F0 EB0A                    	jmp	short _pregw2
  1706                                  _pregw1:
  1707 000009F2 89C8                    	mov	eax, ecx		; put data into eax
  1708                                  	;out	dx, eax
  1709                                  	; 29/05/2024
  1710 000009F4 53                      	push	ebx
  1711 000009F5 89C3                    	mov	ebx, eax ; data, dword
  1712 000009F7 B405                    	mov	ah, 5 ; write port, dword
  1713                                  	; dx = port number
  1714 000009F9 CD34                    	int	34h
  1715 000009FB 5B                      	pop	ebx
  1716                                  _pregw2:
  1717 000009FC 89D8                            mov     eax, ebx		; restore eax
  1718 000009FE 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  1719 00000A03 89CA                            mov     edx, ecx		; restore dx
  1720 00000A05 59                      	pop	ecx
  1721 00000A06 5B                      	pop	ebx
  1722 00000A07 C3                      	retn
  1723                                  
  1724                                  pciRegWrite8:
  1725 00000A08 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
  1726 00000A0D EB96                            jmp	short pciRegWrite	; call generic PCI access
  1727                                  
  1728                                  pciRegWrite16:
  1729 00000A0F 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
  1730 00000A14 0D00000040                      or      eax, PCI16		; call generic PCI access
  1731 00000A19 EB8A                            jmp	short pciRegWrite
  1732                                  
  1733                                  pciRegWrite32:
  1734 00000A1B 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
  1735 00000A20 0D00000080                      or      eax, PCI32		; call generic PCI access
  1736 00000A25 E97BFFFFFF                      jmp	pciRegWrite
  1737                                  
  1738                                  ; --------------------------------------------------------
  1739                                  ; 19/05/2024 - (playwav4.asm) ac97_vra.asm
  1740                                  ; --------------------------------------------------------
  1741                                  
  1742                                  	; 13/11/2023
  1743                                  
  1744                                  ;VRA:	db 1
  1745                                  
  1746                                  codecConfig:
  1747                                  	; 01/12/2024 (ac97play.s)
  1748                                  	; 29/05/2024 (playwav7.s modification)
  1749                                  	; 19/05/2024
  1750                                  	; 19/11/2023
  1751                                  	; 15/11/2023
  1752                                  	; 04/11/2023
  1753                                  	; 17/02/2017 
  1754                                  	; 07/11/2016 (Erdogan Tan)
  1755                                  
  1756                                  	;AC97_EA_VRA equ 1
  1757                                  	AC97_EA_VRA equ BIT0
  1758                                  
  1759                                  	; 04/11/2023
  1760                                  init_ac97_controller:
  1761 00000A2A A1[00390000]            	mov	eax, [bus_dev_fn]
  1762 00000A2F B004                    	mov	al, PCI_CMD_REG
  1763 00000A31 E857FFFFFF              	call	pciRegRead16		; read PCI command register
  1764 00000A36 80CA05                  	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
  1765 00000A39 E8D1FFFFFF              	call	pciRegWrite16
  1766                                  
  1767                                  	;call	delay_100ms
  1768                                  
  1769                                  	; 19/05/2024
  1770                                  	; ('PLAYMOD3.ASM', Erdogan Tan, 18/05/2024)
  1771                                  
  1772                                  init_ac97_codec:
  1773                                  	; 18/11/2023
  1774 00000A3E BD28000000              	mov	ebp, 40
  1775                                  	; 29/05/2024
  1776                                  	;mov	ebp, 1000
  1777                                  _initc_1:
  1778                                  	; 29/05/2024
  1779 00000A43 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  1780 00000A47 660315[0A390000]        	add	dx, [NABMBAR]
  1781                                  	;in	eax, dx
  1782 00000A4E B404                    	mov	ah, 4	; read port, dword
  1783 00000A50 CD34                    	int	34h
  1784                                  
  1785                                  	; 19/05/2024
  1786                                  	;call	delay1_4ms
  1787                                  
  1788 00000A52 83F8FF                  	cmp	eax, 0FFFFFFFFh ; -1
  1789 00000A55 750A                    	jne	short _initc_3
  1790                                  _initc_2:
  1791 00000A57 4D                      	dec	ebp
  1792 00000A58 7425                    	jz	short _ac97_codec_ready
  1793                                  
  1794                                  	; 31/05/2024
  1795 00000A5A E8B3020000              	call	delay_100ms
  1796 00000A5F EBE2                    	jmp	short _initc_1
  1797                                  _initc_3:
  1798 00000A61 A900030010              	test	eax, CTRL_ST_CREADY
  1799 00000A66 7517                    	jnz	short _ac97_codec_ready
  1800                                  
  1801                                  	; 30/05/2024
  1802 00000A68 803D[672D0000]01        	cmp	byte [reset], 1
  1803 00000A6F 73E6                    	jnb	short _initc_2
  1804                                  
  1805 00000A71 E893010000              	call	reset_ac97_codec
  1806                                  	; 30/05/2024
  1807 00000A76 C605[672D0000]01        	mov	byte [reset], 1
  1808                                  	; 19/05/2024
  1809 00000A7D EBD8                    	jmp	short _initc_2
  1810                                  
  1811                                  _ac97_codec_ready:
  1812 00000A7F 668B15[08390000]        	mov	dx, [NAMBAR]
  1813                                  	;add	dx, 0 ; ac_reg_0 ; reset register
  1814                                  	;out	dx, ax
  1815                                  	; 29/05/2024
  1816 00000A86 53                      	push	ebx
  1817 00000A87 89C3                    	mov	ebx, eax ; bx = data, word
  1818 00000A89 B403                    	mov	ah, 3	; write port, word
  1819 00000A8B CD34                    	int	34h
  1820 00000A8D 5B                      	pop	ebx
  1821                                  
  1822                                  	; 31/05/2024
  1823                                  	; 29/05/2024
  1824                                  	;call	delay_100ms
  1825                                  
  1826                                  	; 19/11/2023
  1827 00000A8E 09ED                    	or	ebp, ebp
  1828 00000A90 7539                    	jnz	short _ac97_codec_init_ok
  1829                                  
  1830 00000A92 31C0                    	xor	eax, eax ; 0
  1831 00000A94 668B15[08390000]        	mov	dx, [NAMBAR]
  1832 00000A9B 6683C226                	add	dx, CODEC_REG_POWERDOWN
  1833                                  	;out	dx, ax
  1834                                  	; 29/05/2024
  1835 00000A9F 53                      	push	ebx
  1836 00000AA0 89C3                    	mov	ebx, eax
  1837 00000AA2 B403                    	mov	ah, 3	; write port, word
  1838 00000AA4 CD34                    	int	34h
  1839 00000AA6 5B                      	pop	ebx
  1840                                  
  1841                                  	; 19/11/2023
  1842                                  	; wait for 1 second
  1843                                  	; 19/05/2024
  1844 00000AA7 B9E8030000              	mov	ecx, 1000 ; 1000*4*0.25ms = 1s
  1845                                  	;;mov	ecx, 10
  1846                                  	; 30/05/2024
  1847                                  	;mov	ecx, 40
  1848                                  _ac97_codec_rloop:
  1849                                  	;call	delay_100ms
  1850                                  	; 31/05/2024
  1851 00000AAC E870020000              	call	delay1_4ms
  1852                                  
  1853                                  	;mov	dx, [NAMBAR]
  1854                                  	;add	dx, CODEC_REG_POWERDOWN
  1855                                  	;in	ax, dx
  1856                                  	; 29/05/2024
  1857 00000AB1 668B15[08390000]        	mov	dx, [NAMBAR]
  1858 00000AB8 6683C226                	add	dx, CODEC_REG_POWERDOWN
  1859                                  	; 31/05/2024
  1860 00000ABC B402                    	mov	ah, 2	; read port, word
  1861 00000ABE CD34                    	int	34h
  1862                                  
  1863                                  	; 31/05/2024
  1864                                  	;call	delay1_4ms
  1865                                  	
  1866 00000AC0 6683E00F                	and	ax, 0Fh
  1867 00000AC4 3C0F                    	cmp	al, 0Fh
  1868 00000AC6 7403                    	je	short _ac97_codec_init_ok
  1869 00000AC8 E2E2                    	loop	_ac97_codec_rloop 
  1870                                  
  1871                                  init_ac97_codec_err1:
  1872                                  	;stc	; cf = 1 ; 19/05/2024
  1873                                  init_ac97_codec_err2:
  1874 00000ACA C3                      	retn
  1875                                  
  1876                                  _ac97_codec_init_ok:
  1877 00000ACB E8DA000000              	call 	reset_ac97_controller
  1878                                  
  1879                                  	; 31/05/2024
  1880                                  	; 30/05/2024
  1881                                  	; 19/05/2024
  1882                                  	;call	delay_100ms
  1883                                  
  1884                                  	; 30/05/2024
  1885                                  	;call	delay1_4ms
  1886                                  	;call	delay1_4ms
  1887                                  	;call	delay1_4ms
  1888                                  	;call	delay1_4ms
  1889                                  
  1890                                  	; 01/12/2024
  1891                                  setup_ac97_codec:
  1892                                  	; 12/11/2023
  1893 00000AD0 66813D[84380000]80-     	cmp	word [WAVE_SampleRate], 48000
  1893 00000AD8 BB                 
  1894 00000AD9 0F849C000000            	je	skip_rate
  1895                                  	
  1896                                  	; 31/05/2024
  1897                                  	; 30/05/2024
  1898                                  	; 29/05/2024
  1899                                  	;cmp	byte [VRA], 0
  1900                                  	;jna	short skip_rate
  1901                                  
  1902                                  	; 11/11/2023
  1903 00000ADF 668B15[08390000]        	mov	dx, [NAMBAR]
  1904 00000AE6 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1905                                  	;in	ax, dx
  1906                                  	; 29/05/2024
  1907 00000AEA B402                    	mov	ah, 2 ; read port, word
  1908 00000AEC CD34                    	int	34h
  1909                                  
  1910                                  	; 30/05/2024
  1911                                  	; 19/05/2024
  1912 00000AEE E82E020000              	call	delay1_4ms
  1913                                  
  1914                                  	;and	al, ~BIT1 ; Clear DRA
  1915                                  	;;;
  1916                                  	; 30/05/2024
  1917 00000AF3 24FC                    	and	al, ~(BIT1+BIT0) ; Clear DRA+VRA
  1918                                  	; 01/12/2024 (FASM)
  1919                                  	;and	al, NOT (BIT1+BIT0) ; 0FCh
  1920                                  	;out	dx, ax
  1921                                  	; 31/05/2024
  1922 00000AF5 53                      	push	ebx
  1923 00000AF6 89C3                    	mov	ebx, eax
  1924 00000AF8 668B15[08390000]        	mov	dx, [NAMBAR]
  1925 00000AFF 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1926 00000B03 B403                    	mov	ah, 3 ; write port, word
  1927 00000B05 CD34                    	int	34h
  1928 00000B07 5B                      	pop	ebx
  1929                                  
  1930                                  	; 31/05/2024
  1931 00000B08 E8B1010000              	call	check_vra
  1932                                  
  1933                                  	; 31/05/2024 - temporary (interpolated sample rate test)
  1934                                  	;mov	byte [VRA], 0
  1935                                  
  1936                                  	; 31/05/2024
  1937 00000B0D 803D[69380000]00        	cmp	byte [VRA], 0
  1938 00000B14 7665                    	jna	short skip_rate
  1939                                  
  1940 00000B16 668B15[08390000]        	mov	dx, [NAMBAR]
  1941 00000B1D 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1942                                  	;in	ax, dx
  1943                                  	; 31/05/2024
  1944 00000B21 B402                    	mov	ah, 2 ; read port, word
  1945 00000B23 CD34                    	int	34h
  1946                                  
  1947                                  	;and	al, ~BIT1 ; Clear DRA
  1948                                  	;;;
  1949                                  
  1950 00000B25 0C01                    	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
  1951                                  	;out	dx, ax	; Enable variable rate audio
  1952                                  	; 29/05/2024
  1953 00000B27 53                      	push	ebx
  1954 00000B28 89C3                    	mov	ebx, eax
  1955                                  	;
  1956                                  	; 30/05/2024
  1957 00000B2A 668B15[08390000]        	mov	dx, [NAMBAR]
  1958 00000B31 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1959                                  	;
  1960 00000B35 B403                    	mov	ah, 3 ; write port, word
  1961 00000B37 CD34                    	int	34h
  1962 00000B39 5B                      	pop	ebx
  1963                                  
  1964                                  	;mov	cx, 10
  1965 00000B3A B90A000000              	mov	ecx, 10 ; 30/05/2024
  1966                                  check_vra_loop:
  1967                                  	; 31/05/2024
  1968                                  	;call	delay_100ms
  1969                                  	; 30/05/2024
  1970 00000B3F E8DD010000              	call	delay1_4ms
  1971                                  
  1972                                  	; 11/11/2023
  1973                                  	;in	ax, dx
  1974                                  	; 29/05/2024
  1975 00000B44 668B15[08390000]        	mov	dx, [NAMBAR]
  1976 00000B4B 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  1977 00000B4F B402                    	mov	ah, 2 ; read port, word
  1978 00000B51 CD34                    	int	34h
  1979                                  
  1980 00000B53 A801                    	test	al, AC97_EA_VRA ; 1
  1981 00000B55 750B                    	jnz	short set_rate
  1982                                  
  1983                                  	; 11/11/2023
  1984 00000B57 E2E6                    	loop	check_vra_loop
  1985                                  
  1986                                  ;vra_not_supported:	; 19/05/2024
  1987 00000B59 C605[69380000]00        	mov	byte [VRA], 0
  1988 00000B60 EB19                    	jmp	short skip_rate
  1989                                  
  1990                                  set_rate:
  1991                                  	;mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
  1992                                  	; 01/12/2024
  1993 00000B62 66A1[84380000]          	mov	ax, [WAVE_SampleRate]
  1994                                  
  1995 00000B68 668B15[08390000]        	mov    	dx, [NAMBAR]
  1996 00000B6F 6683C22C                	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch
  1997                                  	;out	dx, ax 	; PCM Front/Center Output Sample Rate
  1998                                  	; 29/05/2024
  1999 00000B73 53                      	push	ebx
  2000 00000B74 89C3                    	mov	ebx, eax  ; bx = data, word
  2001 00000B76 B403                    	mov	ah, 3 ; write port, word
  2002 00000B78 CD34                    	int	34h
  2003 00000B7A 5B                      	pop	ebx
  2004                                  
  2005                                  	; 29/05/2024
  2006                                  	;call	delay_100ms
  2007                                  	; 30/05/2024
  2008                                  	;call	delay1_4ms
  2009                                  
  2010                                  	; 12/11/2023
  2011                                  skip_rate:
  2012 00000B7B 66B80202                	mov	ax, 0202h
  2013 00000B7F 668B15[08390000]          	mov	dx, [NAMBAR]
  2014 00000B86 6683C202                  	add	dx, CODEC_MASTER_VOL_REG ;02h
  2015                                  	;out	dx, ax
  2016                                  	; 29/05/2024
  2017 00000B8A 53                      	push	ebx
  2018 00000B8B 89C3                    	mov	ebx, eax  ; bx = data, word
  2019 00000B8D B403                    	mov	ah, 3 ; write port, word
  2020 00000B8F CD34                    	int	34h
  2021 00000B91 5B                      	pop	ebx
  2022                                  
  2023                                  	; 29/05/2024
  2024                                  	;call	delay1_4ms
  2025                                  	;call	delay1_4ms
  2026                                  	;call	delay1_4ms
  2027                                  	;call	delay1_4ms
  2028                                  
  2029 00000B92 66B80202                	mov	ax, 0202h
  2030 00000B96 668B15[08390000]          	mov	dx, [NAMBAR]
  2031 00000B9D 6683C218                  	add	dx, CODEC_PCM_OUT_REG		;18h
  2032                                    	;out	dx, ax
  2033                                  	; 29/05/2024
  2034 00000BA1 53                      	push	ebx
  2035 00000BA2 89C3                    	mov	ebx, eax  ; bx = data, word
  2036 00000BA4 B403                    	mov	ah, 3 ; write port, word
  2037 00000BA6 CD34                    	int	34h
  2038 00000BA8 5B                      	pop	ebx
  2039                                  
  2040                                   	; 29/05/2024
  2041                                  	;call	delay1_4ms
  2042                                  	;call	delay1_4ms
  2043                                  	;call	delay1_4ms
  2044                                  	;call	delay1_4ms
  2045                                  
  2046                                  	; 19/05/2024
  2047                                  	;clc
  2048                                  
  2049 00000BA9 C3                              retn
  2050                                  
  2051                                  reset_ac97_controller:
  2052                                  	; 29/05/2024 (TRDOS 386)
  2053                                  	; 19/05/2024
  2054                                  	; 11/11/2023
  2055                                  	; 10/06/2017
  2056                                  	; 29/05/2017
  2057                                  	; 28/05/2017
  2058                                  	; reset AC97 audio controller registers
  2059 00000BAA 31C0                    	xor	eax, eax
  2060 00000BAC 66BA0B00                        mov	dx, PI_CR_REG
  2061 00000BB0 660315[0A390000]        	add	dx, [NABMBAR]
  2062                                  	;out	dx, al
  2063                                  	; 29/05/2024
  2064                                  	; al = data, byte
  2065 00000BB7 B401                    	mov	ah, 1 ; write port, byte
  2066 00000BB9 CD34                    	int	34h
  2067                                  
  2068                                  	; 19/05/2024
  2069                                  	;call	delay1_4ms
  2070                                  
  2071 00000BBB 66BA1B00                        mov     dx, PO_CR_REG
  2072 00000BBF 660315[0A390000]        	add	dx, [NABMBAR]
  2073                                  	;out	dx, al
  2074                                  	; 29/05/2024
  2075                                  	; al = data, byte
  2076 00000BC6 B401                    	mov	ah, 1 ; write port, byte
  2077 00000BC8 CD34                    	int	34h
  2078                                  
  2079                                  	; 19/05/2024
  2080                                  	;call	delay1_4ms
  2081                                  
  2082 00000BCA 66BA2B00                        mov     dx, MC_CR_REG
  2083 00000BCE 660315[0A390000]        	add	dx, [NABMBAR]
  2084                                  	;out	dx, al
  2085                                  	; 29/05/2024
  2086                                  	; al = data, byte
  2087 00000BD5 B401                    	mov	ah, 1 ; write port, byte
  2088 00000BD7 CD34                    	int	34h
  2089                                  
  2090                                  	; 19/05/2024
  2091                                  	;call	delay1_4ms
  2092                                  
  2093 00000BD9 B002                            mov	al, RR
  2094 00000BDB 66BA0B00                        mov	dx, PI_CR_REG
  2095 00000BDF 660315[0A390000]        	add	dx, [NABMBAR]
  2096                                  	;out	dx, al
  2097                                  	; 29/05/2024
  2098                                  	; al = data, byte
  2099 00000BE6 B401                    	mov	ah, 1 ; write port, byte
  2100 00000BE8 CD34                    	int	34h
  2101                                  
  2102                                  	; 19/05/2024
  2103                                  	;call	delay1_4ms
  2104                                  
  2105 00000BEA 66BA1B00                        mov	dx, PO_CR_REG
  2106 00000BEE 660315[0A390000]        	add	dx, [NABMBAR]
  2107                                  	;out	dx, al
  2108                                  	; 29/05/2024
  2109                                  	; al = data, byte
  2110 00000BF5 B401                    	mov	ah, 1 ; write port, byte
  2111 00000BF7 CD34                    	int	34h
  2112                                  
  2113                                  	; 19/05/2024
  2114                                  	;call	delay1_4ms
  2115                                  
  2116 00000BF9 66BA2B00                        mov	dx, MC_CR_REG
  2117 00000BFD 660315[0A390000]        	add	dx, [NABMBAR]
  2118                                  	;out	dx, al
  2119                                  	; 29/05/2024
  2120                                  	; al = data, byte
  2121 00000C04 B401                    	mov	ah, 1 ; write port, byte
  2122 00000C06 CD34                    	int	34h
  2123                                  
  2124                                  	; 19/05/2024
  2125                                  	;call	delay1_4ms
  2126                                  
  2127 00000C08 C3                      	retn
  2128                                  
  2129                                  reset_ac97_codec:
  2130                                  	; 29/05/2024 (TRDOS 386)
  2131                                  	; 11/11/2023
  2132                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2133 00000C09 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2134 00000C0D 660315[0A390000]        	add	dx, [NABMBAR]
  2135                                  	;in	eax, dx
  2136                                  	; 29/05/2024
  2137 00000C14 B404                    	mov	ah, 4 ; read port, dword
  2138 00000C16 CD34                    	int	34h
  2139                                  
  2140                                  	;test	eax, 2
  2141                                  	; 06/08/2022
  2142 00000C18 A802                    	test	al, 2
  2143 00000C1A 7407                    	jz	short _r_ac97codec_cold
  2144                                  
  2145 00000C1C E80F000000              	call	warm_ac97codec_reset
  2146 00000C21 7308                    	jnc	short _r_ac97codec_ok
  2147                                  _r_ac97codec_cold:
  2148 00000C23 E845000000                      call	cold_ac97codec_reset
  2149 00000C28 7301                            jnc	short _r_ac97codec_ok
  2150                                  	
  2151                                  	; 16/04/2017
  2152                                          ;xor	eax, eax	; timeout error
  2153                                         	;stc
  2154 00000C2A C3                      	retn
  2155                                  
  2156                                  _r_ac97codec_ok:
  2157 00000C2B 31C0                            xor     eax, eax
  2158                                          ;mov	al, VIA_ACLINK_C00_READY ; 1
  2159 00000C2D FEC0                            inc	al
  2160 00000C2F C3                      	retn
  2161                                  
  2162                                  warm_ac97codec_reset:
  2163                                  	; 29/05/2024 (TRDOS 386)
  2164                                  	; 11/11/2023
  2165                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  2166                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2167 00000C30 B806000000              	mov	eax, 6
  2168 00000C35 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2169 00000C39 660315[0A390000]        	add	dx, [NABMBAR]
  2170                                  	;out	dx, eax
  2171                                  	; 29/05/2024
  2172 00000C40 53                      	push	ebx
  2173 00000C41 89C3                    	mov	ebx, eax  ; ebx = data, dword
  2174 00000C43 B405                    	mov	ah, 5 ; write port, dword
  2175 00000C45 CD34                    	int	34h
  2176 00000C47 5B                      	pop	ebx
  2177                                  
  2178                                  	; 30/05/2024
  2179 00000C48 B90A000000              	mov	ecx, 10	; total 1s
  2180                                  	; 29/05/2024
  2181                                  	;mov	ecx, 4000
  2182                                  _warm_ac97c_rst_wait:
  2183                                  	; 30/05/2024
  2184 00000C4D E8C0000000              	call	delay_100ms
  2185                                  
  2186 00000C52 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  2187 00000C56 660315[0A390000]        	add	dx, [NABMBAR]
  2188                                  	;in	eax, dx
  2189                                  	; 29/05/2024
  2190 00000C5D B404                    	mov	ah, 4 ; read port, dword
  2191 00000C5F CD34                    	int	34h
  2192                                  
  2193 00000C61 A900030010              	test	eax, CTRL_ST_CREADY
  2194 00000C66 7504                    	jnz	short _warm_ac97c_rst_ok
  2195                                  
  2196 00000C68 49                      	dec	ecx
  2197 00000C69 75E2                    	jnz	short _warm_ac97c_rst_wait
  2198                                  
  2199                                  _warm_ac97c_rst_fail:
  2200 00000C6B F9                              stc
  2201                                  _warm_ac97c_rst_ok:
  2202 00000C6C C3                      	retn
  2203                                  
  2204                                  cold_ac97codec_reset:
  2205                                  	; 11/11/2023
  2206                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  2207                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2208 00000C6D B802000000                      mov	eax, 2
  2209 00000C72 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  2210 00000C76 660315[0A390000]        	add	dx, [NABMBAR]
  2211                                  	;out	dx, eax
  2212                                  	; 29/05/2024
  2213 00000C7D 53                      	push	ebx
  2214 00000C7E 89C3                    	mov	ebx, eax  ; ebx = data, dword
  2215 00000C80 B405                    	mov	ah, 5 ; write port, dword
  2216 00000C82 CD34                    	int	34h
  2217 00000C84 5B                      	pop	ebx
  2218                                  
  2219                                  	; 30/05/2024
  2220 00000C85 E888000000              	call	delay_100ms 	; wait 100 ms
  2221 00000C8A E883000000              	call	delay_100ms 	; wait 100 ms
  2222 00000C8F E87E000000              	call	delay_100ms 	; wait 100 ms
  2223 00000C94 E879000000              	call	delay_100ms 	; wait 100 ms
  2224                                  
  2225                                  	; 30/05/2024
  2226 00000C99 B910000000              	mov	ecx, 16	; total 20*100 ms = 2s
  2227                                  	; 29/05/2024
  2228                                  	;mov	ecx, 16000
  2229                                  _cold_ac97c_rst_wait:
  2230 00000C9E 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  2231 00000CA2 660315[0A390000]        	add	dx, [NABMBAR]
  2232                                  	;in	eax, dx
  2233                                  	; 29/05/2024
  2234 00000CA9 B404                    	mov	ah, 4 ; read port, dword
  2235 00000CAB CD34                    	int	34h
  2236                                  
  2237 00000CAD A900030010              	test	eax, CTRL_ST_CREADY
  2238 00000CB2 7509                    	jnz	short _cold_ac97c_rst_ok
  2239                                  
  2240                                  	; 30/05/2024
  2241                                  	; 29/05/2024
  2242 00000CB4 E859000000              	call	delay_100ms
  2243                                  
  2244 00000CB9 49                      	dec	ecx
  2245 00000CBA 75E2                    	jnz	short _cold_ac97c_rst_wait
  2246                                  
  2247                                  _cold_ac97c_rst_fail:
  2248 00000CBC F9                              stc
  2249                                  _cold_ac97c_rst_ok:
  2250 00000CBD C3                      	retn
  2251                                  
  2252                                  ; 29/12/2024 (vgaplay3.s, NASM)
  2253                                  ; 18/12/2024 (ac97play.s, FASM)
  2254                                  ; 13/11/2024
  2255                                  ; 30/05/2024
  2256                                  %if 1
  2257                                  ;if 1
  2258                                  check_vra:
  2259                                  	; 29/05/2024
  2260 00000CBE C605[69380000]01        	mov	byte [VRA], 1
  2261                                  
  2262                                  	; 29/05/2024 - audio.s (TRDOS 386 Kernel) - 27/05/2024
  2263                                  	; 24/05/2024
  2264                                  	; 23/05/2024
  2265 00000CC5 668B15[08390000]        	mov	dx, [NAMBAR]
  2266 00000CCC 6683C228                	add	dx, CODEC_EXT_AUDIO_REG	; 28h
  2267                                  	;in	ax, dx
  2268                                  	; 29/05/2024
  2269 00000CD0 B402                    	mov	ah, 2 ; read port, word
  2270 00000CD2 CD34                    	int	34h
  2271                                  
  2272                                  	; 30/05/2024
  2273                                  	; 23/05/2024
  2274 00000CD4 E848000000              	call	delay1_4ms
  2275                                  
  2276                                  	; 29/05/2024
  2277 00000CD9 A801                    	test	al, BIT0
  2278                                  	;test	al, 1 ; BIT0 ; Variable Rate Audio bit
  2279 00000CDB 7507                    	jnz	short check_vra_ok
  2280                                  
  2281                                  vra_not_supported:
  2282                                  	; 13/11/2023
  2283 00000CDD C605[69380000]00        	mov	byte [VRA], 0
  2284                                  check_vra_ok:
  2285 00000CE4 C3                      	retn
  2286                                  ;end if
  2287                                  %endif
  2288                                  
  2289                                  ; --------------------------------------------------------
  2290                                  ; --------------------------------------------------------
  2291                                  
  2292                                  ; 29/12/2024 (vgaplay3.s)
  2293                                  ; 18/12/2024 (ac97play.s)
  2294                                  ;
  2295                                  ; 18/11/2024
  2296                                  ; Ref: TRDOS 386 v2.0.9, audio.s, Erdogan Tan, 06/06/2024
  2297                                  
  2298                                  ac97_stop: 
  2299                                  	; 18/11/2024
  2300 00000CE5 C605[5C380000]02        	mov	byte [stopped], 2
  2301                                  
  2302                                  ac97_po_cmd@:
  2303 00000CEC 30C0                    	xor	al, al ; 0
  2304                                  ac97_po_cmd:
  2305 00000CEE 668B15[0A390000]        	mov     dx, [NABMBAR]
  2306 00000CF5 6683C21B                        add     dx, PO_CR_REG	; PCM out control register
  2307                                  	;out	dx, al
  2308                                  	; 01/12/2024
  2309 00000CF9 B401                    	mov	ah, 1 ; write port, byte
  2310 00000CFB CD34                    	int	34h
  2311 00000CFD C3                      	retn
  2312                                  
  2313                                  ac97_pause:
  2314 00000CFE C605[5C380000]01        	mov	byte [stopped], 1 ; paused
  2315                                  	;mov	al, 0
  2316                                  	;jmp	short ac97_po_cmd
  2317 00000D05 EBE5                    	jmp	short ac97_po_cmd@
  2318                                  
  2319                                  ac97_play: ; continue to play (after pause)
  2320 00000D07 C605[5C380000]00        	mov	byte [stopped], 0
  2321 00000D0E B001                    	mov	al, RPBM
  2322 00000D10 EBDC                    	jmp	short ac97_po_cmd
  2323                                  
  2324                                  ; --------------------------------------------------------
  2325                                  
  2326                                  PORTB		EQU 061h
  2327                                  REFRESH_STATUS	EQU 010h	; Refresh signal status
  2328                                  
  2329                                  	; 29/12/2024 (vgaplay3.s)
  2330                                  	; 18/12/2024
  2331                                  	; 01/12/2024 (ac97play.s)
  2332                                  delay_100ms:
  2333                                  	; 30/05/2024 (playwav7.s)
  2334 00000D12 51                      	push	ecx
  2335 00000D13 B990010000              	mov	ecx, 400  ; 400*0.25ms
  2336                                  _delay_x_ms:
  2337 00000D18 E804000000              	call	delay1_4ms
  2338 00000D1D E2F9                            loop	_delay_x_ms
  2339 00000D1F 59                      	pop	ecx
  2340 00000D20 C3                      	retn
  2341                                  
  2342                                  delay1_4ms:
  2343                                  	; 30/05/2024 (TRDOS 386)
  2344 00000D21 50                              push    eax 
  2345 00000D22 51                              push    ecx
  2346 00000D23 53                      	push	ebx
  2347 00000D24 52                      	push	edx
  2348 00000D25 B910000000                      mov     ecx, 16			; close enough.
  2349                                  	;in	al, PORTB
  2350                                  	; 30/05/2024
  2351 00000D2A 66BA6100                	mov	dx, PORTB
  2352 00000D2E B400                    	mov	ah, 0  ; read port, byte
  2353 00000D30 CD34                    	int	34h
  2354                                  
  2355 00000D32 2410                    	and	al, REFRESH_STATUS
  2356                                  	;mov	ah, al			; Start toggle state
  2357 00000D34 88C3                    	mov	bl, al
  2358 00000D36 09C9                    	or	ecx, ecx
  2359 00000D38 7401                    	jz	short _d4ms1
  2360 00000D3A 41                      	inc	ecx			; Throwaway first toggle
  2361                                  _d4ms1:	
  2362                                  	;in	al, PORTB		; Read system control port
  2363                                  	; 30/05/2024
  2364 00000D3B 66BA6100                	mov	dx, PORTB
  2365 00000D3F B400                    	mov	ah, 0  ; read port, byte
  2366 00000D41 CD34                    	int	34h
  2367                                  
  2368 00000D43 2410                    	and	al, REFRESH_STATUS	; Refresh toggles 15.085 microseconds
  2369                                  	;cmp	ah, al
  2370 00000D45 38C3                    	cmp	bl, al
  2371 00000D47 74F2                    	je	short _d4ms1		; Wait for state change
  2372                                  
  2373                                  	;mov	ah, al			; Update with new state
  2374 00000D49 88C3                    	mov	bl, al
  2375 00000D4B 49                      	dec	ecx
  2376 00000D4C 75ED                    	jnz	short _d4ms1
  2377                                  
  2378 00000D4E 5A                      	pop	edx
  2379 00000D4F 5B                              pop	ebx
  2380 00000D50 59                      	pop	ecx
  2381 00000D51 58                              pop	eax
  2382                                  c4ue_okk:
  2383 00000D52 C3                              retn
  2384                                  
  2385                                  ; --------------------------------------------------------
  2386                                  
  2387                                  getCurrentIndex:
  2388                                  	; returns AL = current index value
  2389                                  	; 01/12/2024
  2390                                  	; 29/05/2024 (TRDOS 386)
  2391                                  	; 08/11/2023
  2392 00000D53 668B15[0A390000]        	mov	dx, [NABMBAR]
  2393 00000D5A 6683C214                	add	dx, PO_CIV_REG
  2394                                  	;in	al, dx
  2395                                  	; 29/05/2024
  2396 00000D5E B400                    	mov	ah, 0 ; read port, byte
  2397 00000D60 CD34                    	int	34h
  2398                                  uLVI2:	;	06/11/2023
  2399 00000D62 C3                      	retn
  2400                                  
  2401                                  ; --------------------------------------------------------
  2402                                  
  2403                                  updateLVI:
  2404                                  	; 01/12/2024
  2405                                  	; 29/05/2024 (TRDOS 386)
  2406                                  	; 08/11/2023
  2407                                  	; 07/11/2023
  2408                                  	; 06/11/2023
  2409 00000D63 668B15[0A390000]        	mov	dx, [NABMBAR]
  2410 00000D6A 6683C214                	add	dx, PO_CIV_REG
  2411                                  	; (Current Index Value and Last Valid Index value)
  2412                                  	;in	ax, dx
  2413                                  	; 29/05/2024
  2414 00000D6E B402                    	mov	ah, 2 ; read port, word
  2415 00000D70 CD34                    	int	34h
  2416                                  
  2417 00000D72 38E0                    	cmp	al, ah ; is current index = last index ?
  2418 00000D74 75EC                    	jne	short uLVI2
  2419                                  
  2420                                  	; 08/11/2023	
  2421 00000D76 E8D8FFFFFF              	call	getCurrentIndex
  2422                                   
  2423 00000D7B F605[9A380000]01        	test	byte [flags], ENDOFFILE
  2424                                  	;jnz	short uLVI1
  2425 00000D82 7418                    	jz	short uLVI0  ; 08/11/2023
  2426                                  
  2427                                  	; 08/11/2023
  2428 00000D84 50                      	push	eax	; 29/05/2024 (32 bit)
  2429 00000D85 668B15[0A390000]        	mov	dx, [NABMBAR]
  2430 00000D8C 6683C216                	add	dx, PO_SR_REG  ; PCM out status register
  2431                                  	;in	ax, dx
  2432                                  	; 29/05/2024
  2433 00000D90 B402                    	mov	ah, 2 ; read port, word
  2434 00000D92 CD34                    	int	34h
  2435                                  
  2436 00000D94 A803                    	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
  2437                                  		      ; (has been processed)
  2438                                  		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
  2439 00000D96 58                      	pop	eax
  2440 00000D97 7407                    	jz	short uLVI1
  2441                                  uLVI3:
  2442 00000D99 31C0                    	xor	eax, eax
  2443                                  	; zf = 1
  2444 00000D9B C3                      	retn
  2445                                  uLVI0:
  2446                                          ; not at the end of the file yet.
  2447 00000D9C FEC8                    	dec	al
  2448 00000D9E 241F                    	and	al, 1Fh
  2449                                  uLVI1:
  2450                                  	;call	setLastValidIndex
  2451                                  ;uLVI2:
  2452                                  	;retn
  2453                                  
  2454                                  ;input AL = index # to stop on
  2455                                  setLastValidIndex:
  2456                                  	; 01/12/2024
  2457                                  	; 29/05/2024 (TRDOS 386)
  2458                                  	; 08/11/2023
  2459 00000DA0 668B15[0A390000]        	mov	dx, [NABMBAR]
  2460 00000DA7 6683C215                	add	dx, PO_LVI_REG
  2461                                          ;out	dx, al
  2462                                  	; 29/05/2024
  2463                                  	; al = data, byte
  2464 00000DAB B401                    	mov	ah, 1 ; write port, byte
  2465 00000DAD CD34                    	int	34h
  2466 00000DAF C3                      	retn
  2467                                  
  2468                                  ; --------------------------------------------------------
  2469                                  ; 07/12/2024
  2470                                  ; --------------------------------------------------------
  2471                                  
  2472                                  ; /////
  2473                                  	; 14/12/2024
  2474                                  	; 07/12/2024
  2475                                  	; 01/12/2024
  2476                                  	; 30/05/2024 (ich_wav4.asm, 19/05/2024)
  2477                                  loadFromFile:
  2478                                  	; 07/11/2023
  2479                                  
  2480 00000DB0 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2481                                  					; last of the file?
  2482 00000DB7 7402                    	jz	short lff_0		; no
  2483 00000DB9 F9                      	stc
  2484 00000DBA C3                      	retn
  2485                                  
  2486                                  lff_0:
  2487                                  	; 07/12/2024
  2488                                  	; 26/11/2023 (playwav8.s)
  2489                                  	;mov	edi, audio_buffer
  2490                                  
  2491                                  	; 01/12/2024 (TRDOS 386)
  2492                                  	; edi = audio buffer address
  2493                                  
  2494                                  	; 14/12/2024
  2495                                  	; 01/12/2024
  2496                                  	; 17/11/2024
  2497                                  	;mov	ebx, [filehandle]
  2498                                  	; 02/12/2024
  2499                                  	;mov	edx, [loadsize] 
  2500                                  
  2501                                  	; 17/11/2024
  2502 00000DBB 803D[FE380000]00        	cmp	byte [fbs_shift], 0
  2503 00000DC2 7677                    	jna	short lff_1 ; stereo, 16 bit
  2504                                  
  2505                                  lff_2:
  2506                                  	; 01/12/2024
  2507 00000DC4 BE[00500200]            	mov	esi, temp_buffer 
  2508                                  	; 14/12/2024
  2509                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000DC9 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000DCF 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00000DD1 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000DD7 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00000DDC CD40                <1>  int 40h
  2510 00000DDE 0F8289000000            	jc	lff_4 ; error !
  2511                                  
  2512                                  	; 01/12/2024
  2513                                  	; 14/11/2024
  2514 00000DE4 A3[20390000]            	mov	[count], eax
  2515                                  
  2516                                  	; 01/12/2024
  2517 00000DE9 21C0                    	and	eax, eax
  2518                                  	;jz	short lff_3
  2519                                  	; 14/12/2024
  2520 00000DEB 0F8485000000            	jz	lff_10
  2521                                  
  2522 00000DF1 8A1D[FE380000]          	mov	bl, [fbs_shift]
  2523                                  
  2524                                  	; 14/12/2024
  2525 00000DF7 89FA                    	mov	edx, edi ; audio buffer start address
  2526                                  
  2527                                  	; 01/12/2024
  2528 00000DF9 89C1                    	mov	ecx, eax
  2529 00000DFB 803D[8E380000]08        	cmp	byte [WAVE_BitsPerSample], 8 ; bits per sample (8 or 16)
  2530 00000E02 751E                    	jne	short lff_7 ; 16 bit samples
  2531                                  	; 8 bit samples
  2532 00000E04 FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
  2533 00000E06 740E                    	jz	short lff_6 ; 8 bit, stereo
  2534                                  	; 01/12/2024 (32bit registers)
  2535                                  lff_5:
  2536                                  	; mono & 8 bit
  2537 00000E08 AC                      	lodsb
  2538 00000E09 2C80                    	sub	al, 80h ; 08/11/2023
  2539 00000E0B C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
  2540 00000E0E 66AB                    	stosw	; left channel
  2541 00000E10 66AB                    	stosw	; right channel
  2542 00000E12 E2F4                    	loop	lff_5
  2543 00000E14 EB16                    	jmp	short lff_9
  2544                                  lff_6:
  2545                                  	; stereo & 8 bit
  2546 00000E16 AC                      	lodsb
  2547 00000E17 2C80                    	sub	al, 80h ; 08/11/2023
  2548 00000E19 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
  2549 00000E1C 66AB                    	stosw
  2550 00000E1E E2F6                    	loop	lff_6
  2551 00000E20 EB0A                    	jmp	short lff_9
  2552                                  lff_7:
  2553 00000E22 D1E9                    	shr	ecx, 1 ; word count
  2554                                  lff_8:
  2555 00000E24 66AD                    	lodsw
  2556 00000E26 66AB                    	stosw	; left channel
  2557 00000E28 66AB                    	stosw	; right channel
  2558 00000E2A E2F8                    	loop	lff_8
  2559                                  lff_9:
  2560                                  	; 14/12/2024
  2561 00000E2C 89F8                    	mov	eax, edi
  2562 00000E2E 8B0D[14390000]          	mov	ecx, [buffersize] 
  2563 00000E34 01D1                    	add	ecx, edx ; + buffer start address
  2564 00000E36 39C8                    	cmp	eax, ecx	
  2565 00000E38 7225                    	jb	short lff_3
  2566 00000E3A C3                      	retn
  2567                                  	
  2568                                  lff_1:  
  2569                                  	; 07/12/2024
  2570                                  	; 01/12/2024
  2571                                  	;sys 	_read, [filehandle], esi, [loadsize] ; edx
  2572                                  	; 14/12/2024
  2573                                  	sys 	_read, [filehandle], edi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000E3B 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000E41 89F9                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00000E43 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000E49 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00000E4E CD40                <1>  int 40h
  2574                                  	; 07/11/2023
  2575 00000E50 721B                    	jc	short lff_4 ; error !
  2576                                  
  2577                                  	; 01/12/2024
  2578                                  	; 14/11/2024
  2579 00000E52 A3[20390000]            	mov	[count], eax
  2580                                  
  2581                                  	; 02/12/2024
  2582 00000E57 39D0                    	cmp	eax, edx ; cmp eax, [loadsize]	
  2583 00000E59 7411                    	je	short endLFF
  2584                                  	; edi = buffer (start) address
  2585 00000E5B 01C7                    	add	edi, eax
  2586 00000E5D 89D1                    	mov	ecx, edx
  2587                                  lff_3:
  2588                                  	;call	padfill			; blank pad the remainder
  2589                                  	; 21/12/2024
  2590                                  padfill:
  2591                                  	; 14/12/2024
  2592                                  	; 01/12/2024 (TRDOS 386, 32bit registers)
  2593                                  	; 17/11/2024
  2594                                  	;   di = offset (to be filled with ZEROs)
  2595                                  	;   bp = buffer segment
  2596                                  	;   ax = di = number of bytes loaded
  2597                                  	;   cx = buffer size (> loaded bytes)	
  2598                                  	; 07/11/2023
  2599                                  	; 06/11/2023
  2600                                  	; 17/02/2017
  2601                                  	; 01/12/2024
  2602 00000E5F 29C1                    	sub	ecx, eax
  2603                                  	; 01/12/2024
  2604                                  	; 25/11/2024
  2605 00000E61 31C0                    	xor	eax, eax
  2606                                  	; 14/12/2024
  2607 00000E63 F3AA                    	rep	stosb
  2608                                  	; 21/12/2024
  2609                                  	;retn
  2610                                  	; ----------
  2611                                          ;clc				; don't exit with CY yet.
  2612 00000E65 800D[9A380000]01                or	byte [flags], ENDOFFILE	; end of file flag
  2613                                  endLFF:
  2614 00000E6C C3                              retn
  2615                                  lff_4:
  2616                                  	; 08/11/2023
  2617 00000E6D B021                    	mov	al, '!'  ; error
  2618 00000E6F E879F9FFFF              	call	tL0
  2619                                  
  2620                                  	; 01/12/2024
  2621 00000E74 31C0                    	xor	eax, eax
  2622                                  lff_10:
  2623                                  	; 14/12/2024
  2624 00000E76 8B0D[14390000]          	mov	ecx, [buffersize]
  2625 00000E7C EBE1                    	jmp	short lff_3
  2626                                  
  2627                                  ; /////
  2628                                  
  2629                                  ; --------------------------------------------------------
  2630                                  ; --------------------------------------------------------
  2631                                  	
  2632                                  write_audio_dev_info:
  2633                                  	; 30/05/2024
  2634                                       	;sys_msg msgAudioCardInfo, 0Fh
  2635                                  	; 01/12/2024
  2636                                  	sys 	_msg, msgAudioCardInfo, 255, 0Fh
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00000E7E BB[682D0000]        <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00000E83 B9FF000000          <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00000E88 BA0F000000          <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00000E8D B823000000          <1>  mov eax, %1
   130                              <1> 
   131 00000E92 CD40                <1>  int 40h
  2637 00000E94 C3                      	retn
  2638                                  
  2639                                  ; --------------------------------------------------------
  2640                                  
  2641                                  write_ac97_pci_dev_info:
  2642                                  	; 19/11/2024
  2643                                  	; 30/05/2024
  2644                                  	; 06/06/2017
  2645                                  	; 03/06/2017
  2646                                  	; BUS/DEV/FN
  2647                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  2648                                  	; DEV/VENDOR
  2649                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  2650                                  
  2651 00000E95 A1[04390000]            	mov	eax, [dev_vendor]
  2652 00000E9A 31DB                    	xor	ebx, ebx
  2653 00000E9C 88C3                    	mov	bl, al
  2654 00000E9E 88DA                    	mov	dl, bl
  2655 00000EA0 80E30F                  	and	bl, 0Fh
  2656 00000EA3 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2657 00000EA9 A2[D62E0000]            	mov	[msgVendorId+3], al
  2658 00000EAE 88D3                    	mov	bl, dl
  2659 00000EB0 C0EB04                  	shr	bl, 4
  2660 00000EB3 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2661 00000EB9 A2[D52E0000]            	mov	[msgVendorId+2], al
  2662 00000EBE 88E3                    	mov	bl, ah
  2663 00000EC0 88DA                    	mov	dl, bl
  2664 00000EC2 80E30F                  	and	bl, 0Fh
  2665 00000EC5 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2666 00000ECB A2[D42E0000]            	mov	[msgVendorId+1], al
  2667 00000ED0 88D3                    	mov	bl, dl
  2668 00000ED2 C0EB04                  	shr	bl, 4
  2669 00000ED5 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2670 00000EDB A2[D32E0000]            	mov	[msgVendorId], al
  2671 00000EE0 C1E810                  	shr	eax, 16
  2672 00000EE3 88C3                    	mov	bl, al
  2673 00000EE5 88DA                    	mov	dl, bl
  2674 00000EE7 80E30F                  	and	bl, 0Fh
  2675 00000EEA 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2676 00000EF0 A2[E72E0000]            	mov	[msgDevId+3], al
  2677 00000EF5 88D3                    	mov	bl, dl
  2678 00000EF7 C0EB04                  	shr	bl, 4
  2679 00000EFA 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2680 00000F00 A2[E62E0000]            	mov	[msgDevId+2], al
  2681 00000F05 88E3                    	mov	bl, ah
  2682 00000F07 88DA                    	mov	dl, bl
  2683 00000F09 80E30F                  	and	bl, 0Fh
  2684 00000F0C 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2685 00000F12 A2[E52E0000]            	mov	[msgDevId+1], al
  2686 00000F17 88D3                    	mov	bl, dl
  2687 00000F19 C0EB04                  	shr	bl, 4
  2688 00000F1C 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2689 00000F22 A2[E42E0000]            	mov	[msgDevId], al
  2690                                  
  2691 00000F27 A1[00390000]            	mov	eax, [bus_dev_fn]
  2692 00000F2C C1E808                  	shr	eax, 8
  2693 00000F2F 88C3                    	mov	bl, al
  2694 00000F31 88DA                    	mov	dl, bl
  2695 00000F33 80E307                  	and	bl, 7 ; bit 0,1,2
  2696 00000F36 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2697 00000F3C A2[0C2F0000]            	mov	[msgFncNo+1], al
  2698 00000F41 88D3                    	mov	bl, dl
  2699 00000F43 C0EB03                  	shr	bl, 3
  2700 00000F46 88DA                    	mov	dl, bl
  2701 00000F48 80E30F                  	and	bl, 0Fh
  2702 00000F4B 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2703 00000F51 A2[FE2E0000]            	mov	[msgDevNo+1], al
  2704 00000F56 88D3                    	mov	bl, dl
  2705 00000F58 C0EB04                  	shr	bl, 4
  2706 00000F5B 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2707 00000F61 A2[FD2E0000]            	mov	[msgDevNo], al
  2708 00000F66 88E3                    	mov	bl, ah
  2709 00000F68 88DA                    	mov	dl, bl
  2710 00000F6A 80E30F                  	and	bl, 0Fh
  2711 00000F6D 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2712 00000F73 A2[F22E0000]            	mov	[msgBusNo+1], al
  2713 00000F78 88D3                    	mov	bl, dl
  2714 00000F7A C0EB04                  	shr	bl, 4
  2715 00000F7D 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2716 00000F83 A2[F12E0000]            	mov	[msgBusNo], al
  2717                                  
  2718                                  	;mov	ax, [ac97_NamBar]
  2719 00000F88 66A1[08390000]          	mov	ax, [NAMBAR]
  2720 00000F8E 88C3                    	mov	bl, al
  2721 00000F90 88DA                    	mov	dl, bl
  2722 00000F92 80E30F                  	and	bl, 0Fh
  2723 00000F95 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2724 00000F9B A2[1C2F0000]            	mov	[msgNamBar+3], al
  2725 00000FA0 88D3                    	mov	bl, dl
  2726 00000FA2 C0EB04                  	shr	bl, 4
  2727 00000FA5 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2728 00000FAB A2[1B2F0000]            	mov	[msgNamBar+2], al
  2729 00000FB0 88E3                    	mov	bl, ah
  2730 00000FB2 88DA                    	mov	dl, bl
  2731 00000FB4 80E30F                  	and	bl, 0Fh
  2732 00000FB7 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2733 00000FBD A2[1A2F0000]            	mov	[msgNamBar+1], al
  2734 00000FC2 88D3                    	mov	bl, dl
  2735 00000FC4 C0EB04                  	shr	bl, 4
  2736 00000FC7 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2737 00000FCD A2[192F0000]            	mov	[msgNamBar], al
  2738                                  
  2739                                  	;mov	ax, [ac97_NabmBar]
  2740 00000FD2 66A1[0A390000]          	mov	ax, [NABMBAR]
  2741 00000FD8 88C3                    	mov	bl, al
  2742 00000FDA 88DA                    	mov	dl, bl
  2743 00000FDC 80E30F                  	and	bl, 0Fh
  2744 00000FDF 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2745 00000FE5 A2[2C2F0000]            	mov	[msgNabmBar+3], al
  2746 00000FEA 88D3                    	mov	bl, dl
  2747 00000FEC C0EB04                  	shr	bl, 4
  2748 00000FEF 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2749 00000FF5 A2[2B2F0000]            	mov	[msgNabmBar+2], al
  2750 00000FFA 88E3                    	mov	bl, ah
  2751 00000FFC 88DA                    	mov	dl, bl
  2752 00000FFE 80E30F                  	and	bl, 0Fh
  2753 00001001 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2754 00001007 A2[2A2F0000]            	mov	[msgNabmBar+1], al
  2755 0000100C 88D3                    	mov	bl, dl
  2756 0000100E C0EB04                  	shr	bl, 4
  2757 00001011 8A83[8F2E0000]          	mov	al, [hex_chars+ebx]
  2758 00001017 A2[292F0000]            	mov	[msgNabmBar], al
  2759                                  
  2760 0000101C 31C0                    	xor	eax, eax
  2761 0000101E A0[9B380000]            	mov	al, [ac97_int_ln_reg]
  2762 00001023 B10A                    	mov	cl, 10
  2763 00001025 F6F1                    	div	cl
  2764                                  	; 23/11/2024
  2765                                  	;add	[msgIRQ], ax
  2766 00001027 66053030                	add	ax, 3030h
  2767 0000102B 66A3[352F0000]          	mov	[msgIRQ], ax
  2768                                  	;and	al, al
  2769 00001031 3C30                    	cmp	al, 30h
  2770 00001033 750D                    	jnz	short _w_ac97imsg_
  2771 00001035 A0[362F0000]            	mov	al, byte [msgIRQ+1]
  2772 0000103A B420                    	mov	ah, ' '
  2773 0000103C 66A3[352F0000]          	mov	[msgIRQ], ax
  2774                                  _w_ac97imsg_:
  2775                                  	; 19/11/2024
  2776 00001042 E85C1C0000              	call 	clear_window
  2777                                  	;mov	dh, 13
  2778                                  	; 30/12/2024 (video mode 13h)
  2779 00001047 B60B                    	mov	dh, 11
  2780 00001049 B200                    	mov	dl, 0
  2781 0000104B E8E2190000              	call	setCursorPosition
  2782                                  	;;;
  2783                                  	; 21/12/2024
  2784 00001050 BD[A02E0000]            	mov	ebp, msgAC97Info ; message
  2785                                  	; 22/12/2024
  2786                                  	;mov	cl, 07h ; color 
  2787 00001055 E81F000000              	call	sys_gmsg
  2788                                  	;
  2789                                  	; 30/05/2024
  2790                                  write_VRA_info:
  2791                                  	; 21/12/2024
  2792 0000105A BD[3A2F0000]            	mov	ebp, msgVRAheader ; message
  2793                                  	;mov	cl, 07h ; color 
  2794 0000105F E815000000              	call	sys_gmsg
  2795                                  	;
  2796 00001064 803D[69380000]00        	cmp	byte [VRA], 0
  2797 0000106B 7607                    	jna	short _w_VRAi_no
  2798                                  _w_VRAi_yes:
  2799 0000106D BD[492F0000]            	mov	ebp, msgVRAyes
  2800 00001072 EB05                    	jmp	short _w_VRAi_yn_msg
  2801                                  _w_VRAi_no:
  2802 00001074 BD[4F2F0000]            	mov	ebp, msgVRAno
  2803                                  _w_VRAi_yn_msg:
  2804                                  	;mov	cl, 07h ; color 
  2805                                  	;call	sys_msg
  2806                                  	;retn
  2807                                  	;jmp	short sys_gmsg
  2808                                  	;;;
  2809                                  ; --------------------------------------------------------
  2810                                  
  2811                                  	; 31/12/2024 (int 31h)
  2812                                  	; 30/12/2024 (Video Mode 13h)
  2813                                  	; (write message in VGA/CGA mode)
  2814                                  	; 22/12/2024
  2815                                  	; 21/12/2024
  2816                                  	; (write message in VGA/VESA-VBE mode)
  2817                                  sys_gmsg:
  2818 00001079 8A4500                  	mov	al, [ebp]
  2819 0000107C 20C0                    	and	al, al
  2820 0000107E 740D                    	jz	short sys_gmsg_ok
  2821                                  
  2822                                  ; 31/12/2024
  2823                                  %if 0
  2824                                  	cmp	al, 20h
  2825                                  	jnb	short sys_gmsg_3
  2826                                  	cmp	al, CR ; 13
  2827                                  	jne	short sys_gmsg_2
  2828                                  	; carriege return, move cursor to column 0
  2829                                  	mov	word [screenpos], 0
  2830                                  sys_gmsg_1:
  2831                                  	inc	ebp
  2832                                  	jmp	short sys_gmsg
  2833                                  sys_gmsg_2:
  2834                                  	cmp	al, LF ; 10
  2835                                  	jne	short sys_gmsg_ok ; 22/12/2024
  2836                                  	; line feed, move cursor to next row
  2837                                  	;add	word [screenpos+2], 16
  2838                                  	; 30/12/2024
  2839                                  	add	word [screenpos+2], 8
  2840                                  	jmp	short sys_gmsg_1
  2841                                  sys_gmsg_3:
  2842                                  	mov	esi, [screenpos]
  2843                                  		; hw = (cursor) row
  2844                                  		; si = (cursor) column
  2845                                  	mov	ecx, 07h ; gray (light)
  2846                                  	call	write_character
  2847                                  	add	esi, 8
  2848                                  	;;;
  2849                                  	;cmp	si, 640
  2850                                  	; 30/12/2024 (cgaplay.s)
  2851                                  	cmp	si, 320
  2852                                  	jb	short sys_gmsg_5
  2853                                  	shr	esi, 16
  2854                                  	;add	si, 16
  2855                                  	;cmp	si, 480
  2856                                  	; 30/12/2024
  2857                                  	add	si, 8
  2858                                  	cmp	si, 200
  2859                                  	jb	short sys_gmsg_4
  2860                                  	xor	esi, esi
  2861                                  sys_gmsg_4:
  2862                                  	shl	esi, 16
  2863                                  	;;;
  2864                                  sys_gmsg_5:
  2865                                  	mov	[screenpos], esi
  2866                                  	inc	ebp
  2867                                  	jmp	short sys_gmsg
  2868                                  %endif
  2869                                  	; 31/12/2024
  2870 00001080 B907000000              	mov	ecx, 07h ; gray (light)
  2871 00001085 E8341B0000              	call	write_character
  2872 0000108A 45                      	inc	ebp
  2873 0000108B EBEC                    	jmp	short sys_gmsg
  2874                                  
  2875                                  sys_gmsg_ok:
  2876 0000108D C3                      	retn
  2877                                  	;;;
  2878                                  
  2879                                  ; --------------------------------------------------------
  2880                                  
  2881                                  ; 05/02/2025 - cgaplay.s
  2882                                  ; 02/02/2025 - playwav9.s - ac97play.s - dplaywav.s - dplayw2.s
  2883                                  ; 29/12/2024 - vgaplay3.s
  2884                                  ; 18/12/2024
  2885                                  ; 01/12/2024 - ac97play.s
  2886                                  ; 29/05/2024
  2887                                  ; 26/11/2023
  2888                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  2889                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  2890                                  ; 14/11/2023
  2891                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  2892                                  ; --------------------------------------------------------
  2893                                  
  2894                                  ;;Note:	At the end of every buffer load,
  2895                                  ;;	during buffer switch/swap, there will be discontinuity
  2896                                  ;;	between the last converted sample and the 1st sample
  2897                                  ;;	of the next buffer.
  2898                                  ;;	(like as a dot noises vaguely between normal sound samples)
  2899                                  ;;	-To avoid this defect, the 1st sample of
  2900                                  ;;	the next buffer may be read from the wav file but
  2901                                  ;;	the file pointer would need to be set to 1 sample back
  2902                                  ;;	again via seek system call. Time comsumption problem! -
  2903                                  ;;
  2904                                  ;;	Erdogan Tan - 15/11/2023
  2905                                  ;;
  2906                                  ;;	((If entire wav data would be loaded at once.. conversion
  2907                                  ;;	defect/noise would disappear.. but for DOS, to keep
  2908                                  ;;	64KB buffer limit is important also it is important
  2909                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  2910                                  ;;	I have tested this program by using 2-30MB wav files.))
  2911                                  ;;
  2912                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  2913                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  2914                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  2915                                  ;;			Realtek ALC850 codec.
  2916                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  2917                                  
  2918                                  load_8khz_mono_8_bit:
  2919                                  	; 02/02/2025
  2920                                  	; 15/11/2023
  2921                                  	; 14/11/2023
  2922                                  	; 13/11/2023
  2923 0000108E F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2924                                  					; last of the file?
  2925 00001095 7402                    	jz	short lff8m_0		; no
  2926 00001097 F9                      	stc
  2927 00001098 C3                      	retn
  2928                                  
  2929                                  lff8m_0:
  2930                                  	; 01/12/2024
  2931                                  	; edi = audio buffer address
  2932 00001099 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2933                                          ;mov	edx, [loadsize]
  2934                                  
  2935                                  	; esi = buffer address
  2936                                  	;; edx = buffer size
  2937                                  
  2938                                  	; load file into memory
  2939                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000109E 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000010A4 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000010A6 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000010AC B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000010B1 CD40                <1>  int 40h
  2940 000010B3 7305                    	jnc	short lff8m_6
  2941 000010B5 E9AF000000              	jmp	lff8m_5  ; error !
  2942                                  
  2943                                  lff8m_6:
  2944                                  	; 01/12/2024
  2945 000010BA A3[20390000]            	mov	[count], eax
  2946                                  	;;;
  2947                                  	; 29/05/2024
  2948                                  	;mov	edi, [audio_buffer]
  2949                                  	;;;
  2950 000010BF 21C0                    	and	eax, eax
  2951 000010C1 0F8499000000            	jz	lff8_eof
  2952                                  
  2953 000010C7 89C1                    	mov	ecx, eax		; byte count
  2954                                  lff8m_1:
  2955 000010C9 AC                      	lodsb
  2956 000010CA A2[07280000]            	mov	[previous_val], al
  2957 000010CF 2C80                    	sub	al, 80h
  2958 000010D1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2959 000010D5 66AB                    	stosw		; original sample (left channel)
  2960 000010D7 66AB                    	stosw		; original sample (right channel)
  2961                                  	; 02/02/2025
  2962                                  	;xor	eax, eax
  2963 000010D9 8A06                    	mov	al, [esi]
  2964 000010DB 49                      	dec	ecx
  2965 000010DC 7502                    	jnz	short lff8m_2
  2966 000010DE B080                    	mov	al, 80h
  2967                                  lff8m_2:
  2968                                  	;mov	[next_val], ax
  2969 000010E0 88C7                    	mov	bh, al	; [next_val]
  2970 000010E2 8A25[07280000]          	mov	ah, [previous_val]
  2971 000010E8 00E0                    	add	al, ah	; [previous_val]
  2972 000010EA D0D8                    	rcr	al, 1
  2973 000010EC 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  2974 000010EE 00E0                    	add	al, ah	; [previous_val]
  2975 000010F0 D0D8                    	rcr	al, 1	
  2976 000010F2 88C3                    	mov	bl, al 	; this is temporary interpolation value
  2977 000010F4 00E0                    	add	al, ah	; [previous_val]
  2978 000010F6 D0D8                    	rcr	al, 1
  2979 000010F8 2C80                    	sub	al, 80h
  2980 000010FA 66C1E008                	shl	ax, 8	
  2981 000010FE 66AB                    	stosw		; this is 1st interpolated sample (L)
  2982 00001100 66AB                    	stosw		; this is 1st interpolated sample (R)
  2983 00001102 88D8                    	mov	al, bl
  2984 00001104 00D0                    	add	al, dl
  2985 00001106 D0D8                    	rcr	al, 1
  2986 00001108 2C80                    	sub	al, 80h
  2987 0000110A 66C1E008                	shl	ax, 8
  2988 0000110E 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2989 00001110 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2990 00001112 88D0                    	mov	al, dl
  2991 00001114 2C80                    	sub	al, 80h
  2992 00001116 66C1E008                	shl	ax, 8
  2993 0000111A 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  2994 0000111C 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  2995                                  	;mov	al, [next_val]
  2996 0000111E 88F8                    	mov	al, bh
  2997 00001120 00D0                    	add	al, dl
  2998 00001122 D0D8                    	rcr	al, 1
  2999 00001124 88C3                    	mov	bl, al	; this is temporary interpolation value
  3000 00001126 00D0                    	add	al, dl
  3001 00001128 D0D8                    	rcr	al, 1
  3002 0000112A 2C80                    	sub	al, 80h
  3003 0000112C 66C1E008                	shl	ax, 8
  3004 00001130 66AB                    	stosw		; this is 4th interpolated sample (L)
  3005 00001132 66AB                    	stosw		; this is 4th interpolated sample (R)
  3006                                  	;mov	al, [next_val]
  3007 00001134 88F8                    	mov	al, bh
  3008 00001136 00D8                    	add	al, bl
  3009 00001138 D0D8                    	rcr	al, 1
  3010 0000113A 2C80                    	sub	al, 80h
  3011 0000113C 66C1E008                	shl	ax, 8
  3012 00001140 66AB                    	stosw		; this is 5th interpolated sample (L)
  3013 00001142 66AB                    	stosw		; this is 5th interpolated sample (R)
  3014                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3015 00001144 09C9                    	or	ecx, ecx
  3016 00001146 7581                    	jnz	short lff8m_1
  3017                                  
  3018                                  	; --------------
  3019                                  
  3020                                  lff8s_3:
  3021                                  lff8m_3:
  3022                                  lff8s2_3:
  3023                                  lff8m2_3:
  3024                                  lff16s_3:
  3025                                  lff16m_3:
  3026                                  lff16s2_3:
  3027                                  lff16m2_3:
  3028                                  lff24_3:
  3029                                  lff32_3:
  3030                                  lff44_3:
  3031                                  lff22_3:
  3032                                  lff11_3:
  3033                                  lff12_3: 	; 02/02/2025
  3034                                  	; 08/12/2024 (BugFix)
  3035                                  	; 31/05/2024 (BugFix)
  3036 00001148 8B0D[14390000]          	mov	ecx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  3037                                  	;shl	ecx, 1	; byte count ; Bug !
  3038                                  	; 08/12/2024
  3039                                  	;add	ecx, audio_buffer
  3040                                  	; 05/02/2025
  3041 0000114E 030D[58330000]          	add	ecx, [audio_buffer]
  3042 00001154 29F9                    	sub	ecx, edi
  3043 00001156 7607                    	jna	short lff8m_4
  3044                                  	;inc	ecx
  3045 00001158 C1E902                  	shr	ecx, 2
  3046 0000115B 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros
  3047 0000115D F3AB                    	rep	stosd
  3048                                  lff8m_4:
  3049                                  	; 31/05/2024 (BugFix)
  3050                                  	; cf=1 ; Bug !
  3051                                  	; 08/12/2024
  3052                                  	;clc
  3053 0000115F C3                      	retn
  3054                                  
  3055                                  lff8_eof:
  3056                                  lff16_eof:
  3057                                  lff24_eof:
  3058                                  lff32_eof:
  3059                                  lff44_eof:
  3060                                  lff22_eof:
  3061                                  lff11_eof:
  3062                                  lff12_eof:	; 02/02/2025
  3063                                  	; 15/11/2023
  3064 00001160 C605[9A380000]01        	mov	byte [flags], ENDOFFILE
  3065 00001167 EBDF                    	jmp	short lff8m_3
  3066                                  
  3067                                  lff8s_5:
  3068                                  lff8m_5:
  3069                                  lff8s2_5:
  3070                                  lff8m2_5:
  3071                                  lff16s_5:
  3072                                  lff16m_5:
  3073                                  lff16s2_5:
  3074                                  lff16m2_5:
  3075                                  lff24_5:
  3076                                  lff32_5:
  3077                                  lff44_5:
  3078                                  lff22_5:
  3079                                  lff11_5:
  3080                                  lff12_5:	; 02/02/2025
  3081 00001169 B021                    	mov	al, '!'  ; error
  3082 0000116B E87DF6FFFF              	call	tL0
  3083                                  	
  3084                                  	;jmp	short lff8m_3
  3085                                  	; 15/11/2023
  3086 00001170 EBEE                    	jmp	lff8_eof
  3087                                  
  3088                                  	; --------------
  3089                                  
  3090                                  load_8khz_stereo_8_bit:
  3091                                  	; 02/02/2025
  3092                                  	; 15/11/2023
  3093                                  	; 14/11/2023
  3094                                  	; 13/11/2023
  3095 00001172 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3096                                  					; last of the file?
  3097 00001179 7402                    	jz	short lff8s_0		; no
  3098 0000117B F9                      	stc
  3099 0000117C C3                      	retn
  3100                                  
  3101                                  lff8s_0:
  3102                                  	; 01/12/2024
  3103                                  	; edi = audio buffer address
  3104 0000117D BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3105                                          ;mov	edx, [loadsize]
  3106                                  
  3107                                  	; esi = buffer address
  3108                                  	;; edx = buffer size
  3109                                  
  3110                                  	; load file into memory
  3111                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001182 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001188 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000118A 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001190 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001195 CD40                <1>  int 40h
  3112 00001197 72D0                    	jc	short lff8s_5 ; error !
  3113                                  
  3114                                  	; 01/12/2024
  3115 00001199 A3[20390000]            	mov	[count], eax
  3116                                  	;;;
  3117                                  	; 29/05/2024
  3118                                  	;mov	edi, [audio_buffer]
  3119                                  	;;;
  3120 0000119E D1E8                    	shr	eax, 1
  3121 000011A0 74BE                    	jz	short lff8_eof
  3122                                  
  3123 000011A2 89C1                    	mov	ecx, eax	; word count
  3124                                  lff8s_1:
  3125 000011A4 AC                      	lodsb
  3126 000011A5 A2[07280000]            	mov	[previous_val_l], al
  3127 000011AA 2C80                    	sub	al, 80h
  3128 000011AC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3129 000011B0 66AB                    	stosw		; original sample (L)
  3130 000011B2 AC                      	lodsb
  3131 000011B3 A2[09280000]            	mov	[previous_val_r], al
  3132 000011B8 2C80                    	sub	al, 80h
  3133 000011BA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3134 000011BE 66AB                    	stosw		; original sample (R)
  3135                                  
  3136                                  	;xor	eax, eax
  3137                                  	; 02/02/2025
  3138 000011C0 668B06                  	mov	ax, [esi]
  3139 000011C3 49                      	dec	ecx
  3140 000011C4 7504                    	jnz	short lff8s_2
  3141                                  		; convert 8 bit sample to 16 bit sample
  3142 000011C6 66B88080                	mov	ax, 8080h
  3143                                  lff8s_2:
  3144 000011CA A2[0B280000]            	mov	[next_val_l], al
  3145 000011CF 8825[0D280000]          	mov	[next_val_r], ah
  3146 000011D5 8A25[07280000]          	mov	ah, [previous_val_l]
  3147 000011DB 00E0                    	add	al, ah
  3148 000011DD D0D8                    	rcr	al, 1
  3149 000011DF 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  3150 000011E1 00E0                    	add	al, ah
  3151 000011E3 D0D8                    	rcr	al, 1
  3152 000011E5 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  3153 000011E7 00E0                    	add	al, ah
  3154 000011E9 D0D8                    	rcr	al, 1
  3155 000011EB 2C80                    	sub	al, 80h
  3156 000011ED 66C1E008                	shl	ax, 8
  3157 000011F1 66AB                    	stosw		; this is 1st interpolated sample (L)
  3158 000011F3 A0[0D280000]            	mov	al, [next_val_r]
  3159 000011F8 8A25[09280000]          	mov	ah, [previous_val_r]
  3160 000011FE 00E0                    	add	al, ah
  3161 00001200 D0D8                    	rcr	al, 1
  3162 00001202 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  3163 00001204 00E0                    	add	al, ah
  3164 00001206 D0D8                    	rcr	al, 1
  3165 00001208 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  3166 0000120A 00E0                    	add	al, ah
  3167 0000120C D0D8                    	rcr	al, 1
  3168 0000120E 2C80                    	sub	al, 80h
  3169 00001210 66C1E008                	shl	ax, 8
  3170 00001214 66AB                    	stosw		; this is 1st interpolated sample (R)
  3171 00001216 88D8                    	mov	al, bl
  3172 00001218 00D0                    	add	al, dl
  3173 0000121A D0D8                    	rcr	al, 1
  3174 0000121C 2C80                    	sub	al, 80h
  3175 0000121E 66C1E008                	shl	ax, 8
  3176 00001222 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3177 00001224 88F8                    	mov	al, bh
  3178 00001226 00F0                    	add	al, dh
  3179 00001228 D0D8                    	rcr	al, 1
  3180 0000122A 2C80                    	sub	al, 80h
  3181 0000122C 66C1E008                	shl	ax, 8
  3182 00001230 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3183 00001232 88D0                    	mov	al, dl
  3184 00001234 2C80                    	sub	al, 80h
  3185 00001236 66C1E008                	shl	ax, 8
  3186 0000123A 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3187 0000123C 88F0                    	mov	al, dh
  3188 0000123E 2C80                    	sub	al, 80h
  3189 00001240 66C1E008                	shl	ax, 8
  3190 00001244 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3191 00001246 A0[0B280000]            	mov	al, [next_val_l]
  3192 0000124B 00D0                    	add	al, dl
  3193 0000124D D0D8                    	rcr	al, 1
  3194 0000124F 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  3195 00001251 00D0                    	add	al, dl
  3196 00001253 D0D8                    	rcr	al, 1
  3197 00001255 2C80                    	sub	al, 80h
  3198 00001257 66C1E008                	shl	ax, 8
  3199 0000125B 66AB                    	stosw		; this is 4th interpolated sample (L)
  3200 0000125D A0[0D280000]            	mov	al, [next_val_r]
  3201 00001262 00F0                    	add	al, dh
  3202 00001264 D0D8                    	rcr	al, 1
  3203 00001266 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  3204 00001268 00F0                    	add	al, dh
  3205 0000126A D0D8                    	rcr	al, 1
  3206 0000126C 2C80                    	sub	al, 80h
  3207 0000126E 66C1E008                	shl	ax, 8
  3208 00001272 66AB                    	stosw		; this is 4th interpolated sample (R)
  3209 00001274 A0[0B280000]            	mov	al, [next_val_l]
  3210 00001279 00D8                    	add	al, bl
  3211 0000127B D0D8                    	rcr	al, 1
  3212 0000127D 2C80                    	sub	al, 80h
  3213 0000127F 66C1E008                	shl	ax, 8
  3214 00001283 66AB                    	stosw		; this is 5th interpolated sample (L)
  3215 00001285 A0[0D280000]            	mov	al, [next_val_r]
  3216 0000128A 00F8                    	add	al, bh
  3217 0000128C D0D8                    	rcr	al, 1
  3218 0000128E 2C80                    	sub	al, 80h
  3219 00001290 66C1E008                	shl	ax, 8
  3220 00001294 66AB                    	stosw		; this is 5th interpolated sample (R)
  3221                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3222 00001296 E305                    	jecxz	lff8s_6
  3223 00001298 E907FFFFFF              	jmp	lff8s_1
  3224                                  lff8s_6:
  3225 0000129D E9A6FEFFFF              	jmp	lff8s_3
  3226                                  
  3227                                  load_8khz_mono_16_bit:
  3228                                  	; 02/02/2025
  3229                                  	; 13/11/2023
  3230 000012A2 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3231                                  					; last of the file?
  3232 000012A9 7402                    	jz	short lff8m2_0		; no
  3233 000012AB F9                      	stc
  3234 000012AC C3                      	retn
  3235                                  
  3236                                  lff8m2_0:
  3237                                  	; 01/12/2024
  3238                                  	; edi = audio buffer address
  3239 000012AD BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3240                                          ;mov	edx, [loadsize]
  3241                                  
  3242                                  	; esi = buffer address
  3243                                  	;; edx = buffer size
  3244                                  
  3245                                  	; load file into memory
  3246                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000012B2 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000012B8 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000012BA 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000012C0 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000012C5 CD40                <1>  int 40h
  3247 000012C7 0F82A0000000            	jc	lff8m2_7 ; error !
  3248                                  
  3249                                  	; 01/12/2024
  3250 000012CD A3[20390000]            	mov	[count], eax
  3251                                  	;;;
  3252                                  	; 29/05/2024
  3253                                  	;mov	edi, [audio_buffer]
  3254                                  	;;;
  3255 000012D2 D1E8                    	shr	eax, 1
  3256 000012D4 7505                    	jnz	short lff8m2_8
  3257 000012D6 E985FEFFFF              	jmp	lff8_eof
  3258                                  
  3259                                  lff8m2_8:
  3260 000012DB 89C1                    	mov	ecx, eax	; word count
  3261                                  lff8m2_1:
  3262 000012DD 66AD                    	lodsw
  3263 000012DF 66AB                    	stosw		; original sample (left channel)
  3264 000012E1 66AB                    	stosw		; original sample (right channel)
  3265 000012E3 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3266 000012E6 66A3[07280000]          	mov	[previous_val], ax
  3267                                  	; 02/02/2025
  3268 000012EC 668B06                  	mov	ax, [esi]
  3269 000012EF 49                      	dec	ecx
  3270 000012F0 7502                    	jnz	short lff8m2_2
  3271 000012F2 31C0                    	xor	eax, eax
  3272                                  lff8m2_2:
  3273 000012F4 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  3274 000012F7 89C5                    	mov	ebp, eax	; [next_val]
  3275 000012F9 660305[07280000]        	add	ax, [previous_val]
  3276 00001300 66D1D8                  	rcr	ax, 1
  3277 00001303 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  3278 00001305 660305[07280000]        	add	ax, [previous_val]
  3279 0000130C 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  3280 0000130F 89C3                    	mov	ebx, eax 		
  3281 00001311 660305[07280000]        	add	ax, [previous_val]
  3282 00001318 66D1D8                  	rcr	ax, 1
  3283 0000131B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3284 0000131E 66AB                    	stosw		; this is 1st interpolated sample (L)
  3285 00001320 66AB                    	stosw		; this is 1st interpolated sample (R)
  3286 00001322 89D8                    	mov	eax, ebx
  3287 00001324 6601D0                  	add	ax, dx
  3288 00001327 66D1D8                  	rcr	ax, 1
  3289 0000132A 80EC80                  	sub	ah, 80h
  3290 0000132D 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3291 0000132F 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3292 00001331 89D0                    	mov	eax, edx
  3293 00001333 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3294 00001336 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3295 00001338 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3296 0000133A 89E8                    	mov	eax, ebp
  3297 0000133C 6601D0                  	add	ax, dx
  3298 0000133F 66D1D8                  	rcr	ax, 1
  3299 00001342 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  3300 00001344 6601D0                  	add	ax, dx
  3301 00001347 66D1D8                  	rcr	ax, 1
  3302 0000134A 80EC80                  	sub	ah, 80h
  3303 0000134D 66AB                    	stosw		; this is 4th interpolated sample (L)
  3304 0000134F 66AB                    	stosw		; this is 4th interpolated sample (R)
  3305 00001351 89E8                    	mov	eax, ebp
  3306 00001353 6601D8                  	add	ax, bx
  3307 00001356 66D1D8                  	rcr	ax, 1
  3308 00001359 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3309 0000135C 66AB                    	stosw		; this is 5th interpolated sample (L)
  3310 0000135E 66AB                    	stosw		; this is 5th interpolated sample (R)
  3311                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3312 00001360 09C9                    	or	ecx, ecx
  3313 00001362 0F8575FFFFFF            	jnz	lff8m2_1
  3314 00001368 E9DBFDFFFF              	jmp	lff8m2_3
  3315                                  
  3316                                  lff8m2_7:
  3317                                  lff8s2_7:
  3318 0000136D E9F7FDFFFF              	jmp	lff8m2_5  ; error
  3319                                  
  3320                                  load_8khz_stereo_16_bit:
  3321                                  	; 02/02/2025
  3322                                  	; 16/11/2023
  3323                                  	; 15/11/2023
  3324                                  	; 13/11/2023
  3325 00001372 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3326                                  					; last of the file?
  3327 00001379 7402                    	jz	short lff8s2_0		; no
  3328 0000137B F9                      	stc
  3329 0000137C C3                      	retn
  3330                                  
  3331                                  lff8s2_0:
  3332                                  	; 01/12/2024
  3333                                  	; edi = audio buffer address
  3334 0000137D BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3335                                          ;mov	edx, [loadsize]
  3336                                  
  3337                                  	; esi = buffer address
  3338                                  	;; edx = buffer size
  3339                                  
  3340                                  	; load file into memory
  3341                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001382 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001388 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000138A 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001390 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001395 CD40                <1>  int 40h
  3342 00001397 72D4                    	jc	short lff8s2_7 ; error !
  3343                                  
  3344                                  	; 01/12/2024
  3345 00001399 A3[20390000]            	mov	[count], eax
  3346                                  	;;;
  3347                                  	; 29/05/2024
  3348                                  	;mov	edi, [audio_buffer]
  3349                                  	;;;
  3350 0000139E C1E802                  	shr	eax, 2
  3351 000013A1 7505                    	jnz	short lff8s2_8
  3352 000013A3 E9B8FDFFFF              	jmp	lff8_eof
  3353                                  
  3354                                  lff8s2_8:
  3355 000013A8 89C1                    	mov	ecx, eax ; dword count
  3356                                  lff8s2_1:
  3357 000013AA 66AD                    	lodsw
  3358 000013AC 66AB                    	stosw		; original sample (L)
  3359                                  	; 15/11/2023
  3360 000013AE 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3361 000013B1 66A3[07280000]          	mov	[previous_val_l], ax
  3362 000013B7 66AD                    	lodsw
  3363 000013B9 66AB                    	stosw		; original sample (R)
  3364 000013BB 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3365 000013BE 66A3[09280000]          	mov	[previous_val_r], ax
  3366                                  	; 02/02/2025
  3367 000013C4 668B06                  	mov	ax, [esi]
  3368 000013C7 668B5602                	mov	dx, [esi+2]
  3369                                  	; 16/11/2023
  3370 000013CB 49                      	dec	ecx
  3371 000013CC 7504                    	jnz	short lff8s2_2
  3372 000013CE 31D2                    	xor	edx, edx
  3373 000013D0 31C0                    	xor	eax, eax
  3374                                  lff8s2_2:
  3375 000013D2 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  3376 000013D5 66A3[0B280000]          	mov	[next_val_l], ax
  3377 000013DB 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  3378 000013DE 668915[0D280000]        	mov	[next_val_r], dx
  3379 000013E5 660305[07280000]        	add	ax, [previous_val_l]
  3380 000013EC 66D1D8                  	rcr	ax, 1
  3381 000013EF 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  3382 000013F1 660305[07280000]        	add	ax, [previous_val_l]
  3383 000013F8 66D1D8                  	rcr	ax, 1	
  3384 000013FB 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  3385 000013FD 660305[07280000]        	add	ax, [previous_val_l]
  3386 00001404 66D1D8                  	rcr	ax, 1
  3387 00001407 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3388 0000140A 66AB                    	stosw		; this is 1st interpolated sample (L)
  3389 0000140C 66A1[0D280000]          	mov	ax, [next_val_r]
  3390 00001412 660305[09280000]        	add	ax, [previous_val_r]
  3391 00001419 66D1D8                  	rcr	ax, 1
  3392 0000141C 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  3393 0000141E 660305[09280000]        	add	ax, [previous_val_r]
  3394 00001425 66D1D8                  	rcr	ax, 1
  3395 00001428 50                      	push	eax ; *	; this is temporary interpolation value (R)
  3396 00001429 660305[09280000]        	add	ax, [previous_val_r]
  3397 00001430 66D1D8                  	rcr	ax, 1
  3398 00001433 80EC80                  	sub	ah, 80h
  3399 00001436 66AB                    	stosw		; this is 1st interpolated sample (R)
  3400 00001438 89D8                    	mov	eax, ebx
  3401 0000143A 6601D0                  	add	ax, dx
  3402 0000143D 66D1D8                  	rcr	ax, 1
  3403 00001440 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3404 00001443 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3405 00001445 58                      	pop	eax ; *
  3406 00001446 6601E8                  	add	ax, bp
  3407 00001449 66D1D8                  	rcr	ax, 1
  3408 0000144C 80EC80                  	sub	ah, 80h
  3409 0000144F 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3410 00001451 89D0                    	mov	eax, edx
  3411 00001453 80EC80                  	sub	ah, 80h
  3412 00001456 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  3413 00001458 89E8                    	mov	eax, ebp
  3414 0000145A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3415 0000145D 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  3416 0000145F 66A1[0B280000]          	mov	ax, [next_val_l]
  3417 00001465 6601D0                  	add	ax, dx
  3418 00001468 66D1D8                  	rcr	ax, 1
  3419 0000146B 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  3420 0000146D 6601D0                  	add	ax, dx
  3421 00001470 66D1D8                  	rcr	ax, 1
  3422 00001473 80EC80                  	sub	ah, 80h
  3423 00001476 66AB                    	stosw		; this is 4th interpolated sample (L)
  3424 00001478 66A1[0D280000]          	mov	ax, [next_val_r]
  3425 0000147E 6601E8                  	add	ax, bp
  3426 00001481 66D1D8                  	rcr	ax, 1
  3427 00001484 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  3428 00001485 6601E8                  	add	ax, bp
  3429 00001488 66D1D8                  	rcr	ax, 1
  3430 0000148B 80EC80                  	sub	ah, 80h
  3431 0000148E 66AB                    	stosw		; this is 4th interpolated sample (R)
  3432 00001490 66A1[0B280000]          	mov	ax, [next_val_l]
  3433 00001496 6601D8                  	add	ax, bx
  3434 00001499 66D1D8                  	rcr	ax, 1
  3435 0000149C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3436 0000149F 66AB                    	stosw		; this is 5th interpolated sample (L)
  3437 000014A1 58                      	pop	eax ; **
  3438 000014A2 660305[0D280000]        	add	ax, [next_val_r]
  3439 000014A9 66D1D8                  	rcr	ax, 1
  3440 000014AC 80EC80                  	sub	ah, 80h
  3441 000014AF 66AB                    	stosw		; this is 5th interpolated sample (R)
  3442                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3443 000014B1 E305                    	jecxz	lff8_s2_9
  3444 000014B3 E9F2FEFFFF              	jmp	lff8s2_1
  3445                                  lff8_s2_9:
  3446 000014B8 E98BFCFFFF              	jmp	lff8s2_3
  3447                                  
  3448                                  ; .....................
  3449                                  
  3450                                  load_16khz_mono_8_bit:
  3451                                  	; 02/02/2025
  3452                                  	; 14/11/2023
  3453                                  	; 13/11/2023
  3454 000014BD F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3455                                  					; last of the file?
  3456 000014C4 7402                    	jz	short lff16m_0		; no
  3457 000014C6 F9                      	stc
  3458 000014C7 C3                      	retn
  3459                                  
  3460                                  lff16m_0:
  3461                                  	; 01/12/2024
  3462                                  	; edi = audio buffer address
  3463 000014C8 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3464                                          ;mov	edx, [loadsize]
  3465                                  
  3466                                  	; esi = buffer address
  3467                                  	;; edx = buffer size
  3468                                  
  3469                                  	; load file into memory
  3470                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000014CD 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000014D3 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000014D5 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000014DB B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000014E0 CD40                <1>  int 40h
  3471 000014E2 7253                    	jc	short lff16m_7 ; error !
  3472                                  
  3473                                  	; 01/12/2024
  3474 000014E4 A3[20390000]            	mov	[count], eax
  3475                                  	;;;
  3476                                  	; 29/05/2024
  3477                                  	;mov	edi, [audio_buffer]
  3478                                  	;;;
  3479 000014E9 21C0                    	and	eax, eax
  3480 000014EB 7505                    	jnz	short lff16m_8
  3481 000014ED E96EFCFFFF              	jmp	lff16_eof
  3482                                  
  3483                                  lff16m_8:
  3484 000014F2 89C1                    	mov	ecx, eax		; byte count
  3485                                  lff16m_1:
  3486 000014F4 AC                      	lodsb
  3487                                  	;mov	[previous_val], al
  3488 000014F5 88C3                    	mov	bl, al
  3489 000014F7 2C80                    	sub	al, 80h
  3490 000014F9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3491 000014FD 66AB                    	stosw		; original sample (left channel)
  3492 000014FF 66AB                    	stosw		; original sample (right channel)
  3493                                  	;xor	eax, eax
  3494                                  	; 02/02/2025
  3495 00001501 8A06                    	mov	al, [esi]
  3496 00001503 49                      	dec	ecx
  3497 00001504 7502                    	jnz	short lff16m_2
  3498                                  	; 14/11/2023
  3499 00001506 B080                    	mov	al, 80h
  3500                                  lff16m_2:
  3501                                  	;mov	[next_val], al
  3502 00001508 88C7                    	mov	bh, al
  3503                                  	;add	al, [previous_val]
  3504 0000150A 00D8                    	add	al, bl
  3505 0000150C D0D8                    	rcr	al, 1
  3506 0000150E 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  3507                                  	;add	al, [previous_val]
  3508 00001510 00D8                    	add	al, bl
  3509 00001512 D0D8                    	rcr	al, 1
  3510 00001514 2C80                    	sub	al, 80h
  3511 00001516 66C1E008                	shl	ax, 8
  3512 0000151A 66AB                    	stosw		; this is 1st interpolated sample (L)
  3513 0000151C 66AB                    	stosw		; this is 1st interpolated sample (R)
  3514                                  	;mov	al, [next_val]
  3515 0000151E 88F8                    	mov	al, bh
  3516 00001520 00D0                    	add	al, dl
  3517 00001522 D0D8                    	rcr	al, 1
  3518 00001524 2C80                    	sub	al, 80h
  3519 00001526 66C1E008                	shl	ax, 8
  3520 0000152A 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3521 0000152C 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3522                                  	
  3523                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3524 0000152E 09C9                    	or	ecx, ecx
  3525 00001530 75C2                    	jnz	short lff16m_1
  3526 00001532 E911FCFFFF              	jmp	lff16m_3
  3527                                  
  3528                                  lff16m_7:
  3529                                  lff16s_7:
  3530 00001537 E92DFCFFFF              	jmp	lff16m_5  ; error
  3531                                  
  3532                                  load_16khz_stereo_8_bit:
  3533                                  	; 02/02/2025
  3534                                  	; 14/11/2023
  3535                                  	; 13/11/2023
  3536 0000153C F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3537                                  					; last of the file?
  3538 00001543 7402                    	jz	short lff16s_0		; no
  3539 00001545 F9                      	stc
  3540 00001546 C3                      	retn
  3541                                  
  3542                                  lff16s_0:
  3543                                  	; 01/12/2024
  3544                                  	; edi = audio buffer address
  3545 00001547 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3546                                          ;mov	edx, [loadsize]
  3547                                  
  3548                                  	; esi = buffer address
  3549                                  	;; edx = buffer size
  3550                                  
  3551                                  	; load file into memory
  3552                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000154C 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001552 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001554 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000155A B803000000          <1>  mov eax, %1
   130                              <1> 
   131 0000155F CD40                <1>  int 40h
  3553 00001561 72D4                    	jc	short lff16s_7 ; error !
  3554                                  
  3555                                  	; 01/12/2024
  3556 00001563 A3[20390000]            	mov	[count], eax
  3557                                  	;;;
  3558                                  	; 29/05/2024
  3559                                  	;mov	edi, [audio_buffer]
  3560                                  	;;;
  3561 00001568 D1E8                    	shr	eax, 1
  3562 0000156A 7505                    	jnz	short lff16s_8
  3563 0000156C E9EFFBFFFF              	jmp	lff16_eof
  3564                                  
  3565                                  lff16s_8:
  3566 00001571 89C1                    	mov	ecx, eax	; word count
  3567                                  lff16s_1:
  3568 00001573 AC                      	lodsb
  3569 00001574 A2[07280000]            	mov	[previous_val_l], al
  3570 00001579 2C80                    	sub	al, 80h
  3571 0000157B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3572 0000157F 66AB                    	stosw		; original sample (L)
  3573 00001581 AC                      	lodsb
  3574 00001582 A2[09280000]            	mov	[previous_val_r], al
  3575 00001587 2C80                    	sub	al, 80h
  3576 00001589 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3577 0000158D 66AB                    	stosw		; original sample (R)
  3578                                  
  3579                                  	;xor	eax, eax
  3580                                  	; 02/02/2025
  3581 0000158F 668B06                  	mov	ax, [esi]
  3582 00001592 49                      	dec	ecx
  3583 00001593 7504                    	jnz	short lff16s_2
  3584                                  		; convert 8 bit sample to 16 bit sample
  3585                                  	; 14/11/2023
  3586 00001595 66B88080                	mov	ax, 8080h
  3587                                  lff16s_2:
  3588                                  	;mov	[next_val_l], al
  3589                                  	;mov	[next_val_r], ah
  3590 00001599 89C3                    	mov	ebx, eax
  3591 0000159B 0205[07280000]          	add	al, [previous_val_l]
  3592 000015A1 D0D8                    	rcr	al, 1
  3593 000015A3 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  3594 000015A5 0205[07280000]          	add	al, [previous_val_l]
  3595 000015AB D0D8                    	rcr	al, 1
  3596 000015AD 2C80                    	sub	al, 80h
  3597 000015AF 66C1E008                	shl	ax, 8
  3598 000015B3 66AB                    	stosw		; this is 1st interpolated sample (L)
  3599 000015B5 88F8                    	mov	al, bh	; [next_val_r]
  3600 000015B7 0205[09280000]          	add	al, [previous_val_r]
  3601 000015BD D0D8                    	rcr	al, 1
  3602 000015BF 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  3603 000015C1 0205[09280000]          	add	al, [previous_val_r]
  3604 000015C7 D0D8                    	rcr	al, 1
  3605 000015C9 2C80                    	sub	al, 80h
  3606 000015CB 66C1E008                	shl	ax, 8
  3607 000015CF 66AB                    	stosw		; this is 1st interpolated sample (R)
  3608 000015D1 88D0                    	mov	al, dl
  3609 000015D3 00D8                    	add	al, bl	; [next_val_l]
  3610 000015D5 D0D8                    	rcr	al, 1
  3611 000015D7 2C80                    	sub	al, 80h
  3612 000015D9 66C1E008                	shl	ax, 8
  3613 000015DD 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3614 000015DF 88F0                    	mov	al, dh
  3615 000015E1 00F8                    	add	al, bh	; [next_val_r]
  3616 000015E3 D0D8                    	rcr	al, 1
  3617 000015E5 2C80                    	sub	al, 80h
  3618 000015E7 66C1E008                	shl	ax, 8
  3619 000015EB 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3620                                  	
  3621                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3622 000015ED 09C9                    	or	ecx, ecx
  3623 000015EF 7582                    	jnz	short lff16s_1
  3624 000015F1 E952FBFFFF              	jmp	lff16s_3
  3625                                  
  3626                                  load_16khz_mono_16_bit:
  3627                                  	; 02/02/2025
  3628                                  	; 15/11/2023
  3629                                  	; 13/11/2023
  3630 000015F6 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3631                                  					; last of the file?
  3632 000015FD 7402                    	jz	short lff16m2_0		; no
  3633 000015FF F9                      	stc
  3634 00001600 C3                      	retn
  3635                                  
  3636                                  lff16m2_0:
  3637                                  	; 01/12/2024
  3638                                  	; edi = audio buffer address
  3639 00001601 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3640                                          ;mov	edx, [loadsize]
  3641                                  
  3642                                  	; esi = buffer address
  3643                                  	;; edx = buffer size
  3644                                  
  3645                                  	; load file into memory
  3646                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001606 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000160C 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000160E 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001614 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001619 CD40                <1>  int 40h
  3647 0000161B 7255                    	jc	short lff16m2_7 ; error !
  3648                                  
  3649                                  	; 01/12/2024
  3650 0000161D A3[20390000]            	mov	[count], eax
  3651                                  	;;;
  3652                                  	; 29/05/2024
  3653                                  	;mov	edi, [audio_buffer]
  3654                                  	;;;
  3655 00001622 D1E8                    	shr	eax, 1
  3656 00001624 7505                    	jnz	short lff16m2_8
  3657 00001626 E935FBFFFF              	jmp	lff16_eof
  3658                                  
  3659                                  lff16m2_8:
  3660 0000162B 89C1                    	mov	ecx, eax  ; word count
  3661                                  lff16m2_1:
  3662 0000162D 66AD                    	lodsw
  3663 0000162F 66AB                    	stosw		; original sample (left channel)
  3664 00001631 66AB                    	stosw		; original sample (right channel)
  3665 00001633 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3666                                  	;mov	[previous_val], ax
  3667 00001636 89C3                    	mov	ebx, eax
  3668                                  	; 02/02/2025
  3669 00001638 668B06                  	mov	ax, [esi]
  3670 0000163B 49                      	dec	ecx
  3671 0000163C 7502                    	jnz	short lff16m2_2
  3672 0000163E 31C0                    	xor	eax, eax
  3673                                  lff16m2_2:
  3674 00001640 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3675 00001643 89C5                    	mov	ebp, eax	; [next_val]
  3676                                  	;add	ax, [previous_val]
  3677 00001645 6601D8                  	add	ax, bx
  3678 00001648 66D1D8                  	rcr	ax, 1
  3679 0000164B 89C2                    	mov	edx, eax ; this is temporary interpolation value
  3680                                  	;add	ax, [previous_val]
  3681 0000164D 6601D8                  	add	ax, bx
  3682 00001650 66D1D8                  	rcr	ax, 1
  3683 00001653 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3684 00001656 66AB                    	stosw		; this is 1st interpolated sample (L)
  3685 00001658 66AB                    	stosw		; this is 1st interpolated sample (R)
  3686 0000165A 89E8                    	mov	eax, ebp
  3687 0000165C 6601D0                  	add	ax, dx
  3688 0000165F 66D1D8                  	rcr	ax, 1
  3689 00001662 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3690 00001665 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3691 00001667 66AB                    	stosw		; this is 2nd interpolated sample (R)
  3692                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3693 00001669 09C9                    	or	ecx, ecx
  3694 0000166B 75C0                    	jnz	short lff16m2_1
  3695 0000166D E9D6FAFFFF              	jmp	lff16m2_3
  3696                                  
  3697                                  lff16m2_7:
  3698                                  lff16s2_7:
  3699 00001672 E9F2FAFFFF              	jmp	lff16m2_5  ; error
  3700                                  
  3701                                  load_16khz_stereo_16_bit:
  3702                                  	; 02/02/2025
  3703                                  	; 16/11/2023
  3704                                  	; 15/11/2023
  3705                                  	; 13/11/2023
  3706 00001677 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3707                                  					; last of the file?
  3708 0000167E 7402                    	jz	short lff16s2_0		; no
  3709 00001680 F9                      	stc
  3710 00001681 C3                      	retn
  3711                                  
  3712                                  lff16s2_0:
  3713                                  	; 01/12/2024
  3714                                  	; edi = audio buffer address
  3715 00001682 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3716                                          ;mov	edx, [loadsize]
  3717                                  
  3718                                  	; esi = buffer address
  3719                                  	;; edx = buffer size
  3720                                  
  3721                                  	; load file into memory
  3722                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001687 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000168D 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000168F 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001695 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 0000169A CD40                <1>  int 40h
  3723 0000169C 72D4                    	jc	short lff16s2_7 ; error !
  3724                                  
  3725                                  	; 01/12/2024
  3726 0000169E A3[20390000]            	mov	[count], eax
  3727                                  	;;;
  3728                                  	; 29/05/2024
  3729                                  	;mov	edi, [audio_buffer]
  3730                                  	;;;
  3731 000016A3 C1E802                  	shr	eax, 2
  3732 000016A6 7505                    	jnz	short lff16s2_8
  3733 000016A8 E9B3FAFFFF              	jmp	lff16_eof
  3734                                  
  3735                                  lff16s2_8:
  3736 000016AD 89C1                    	mov	ecx, eax  ; dword count
  3737                                  lff16s2_1:
  3738 000016AF 66AD                    	lodsw
  3739 000016B1 66AB                    	stosw		; original sample (L)
  3740 000016B3 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3741 000016B6 66A3[07280000]          	mov	[previous_val_l], ax
  3742 000016BC 66AD                    	lodsw
  3743 000016BE 66AB                    	stosw		; original sample (R)
  3744 000016C0 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3745 000016C3 66A3[09280000]          	mov	[previous_val_r], ax
  3746                                  	; 02/02/2025
  3747 000016C9 668B06                  	mov	ax, [esi]
  3748 000016CC 668B5602                	mov	dx, [esi+2]
  3749                                  	; 16/11/2023
  3750 000016D0 49                      	dec	ecx
  3751 000016D1 7504                    	jnz	short lff16s2_2
  3752 000016D3 31D2                    	xor	edx, edx
  3753 000016D5 31C0                    	xor	eax, eax
  3754                                  lff16s2_2:
  3755 000016D7 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  3756                                  	;mov	[next_val_l], ax
  3757 000016DA 89C5                    	mov	ebp, eax
  3758 000016DC 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  3759 000016DF 668915[0D280000]        	mov	[next_val_r], dx
  3760 000016E6 660305[07280000]        	add	ax, [previous_val_l]
  3761 000016ED 66D1D8                  	rcr	ax, 1
  3762 000016F0 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  3763 000016F2 660305[07280000]        	add	ax, [previous_val_l]
  3764 000016F9 66D1D8                  	rcr	ax, 1
  3765 000016FC 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  3766 000016FF 66AB                    	stosw		; this is 1st interpolated sample (L)
  3767 00001701 66A1[0D280000]          	mov	ax, [next_val_r]
  3768 00001707 660305[09280000]        	add	ax, [previous_val_r]
  3769 0000170E 66D1D8                  	rcr	ax, 1
  3770 00001711 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  3771 00001713 660305[09280000]        	add	ax, [previous_val_r]
  3772 0000171A 66D1D8                  	rcr	ax, 1
  3773 0000171D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3774 00001720 66AB                    	stosw		; this is 1st interpolated sample (R)
  3775                                  	;mov	ax, [next_val_l]
  3776 00001722 89E8                    	mov	eax, ebp
  3777 00001724 6601D0                  	add	ax, dx
  3778 00001727 66D1D8                  	rcr	ax, 1
  3779 0000172A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3780 0000172D 66AB                    	stosw		; this is 2nd interpolated sample (L)
  3781 0000172F 66A1[0D280000]          	mov	ax, [next_val_r]
  3782 00001735 6601D8                  	add	ax, bx
  3783 00001738 66D1D8                  	rcr	ax, 1
  3784 0000173B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3785 0000173E 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  3786                                  	
  3787                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3788 00001740 09C9                    	or	ecx, ecx
  3789 00001742 0F8567FFFFFF            	jnz	lff16s2_1
  3790 00001748 E9FBF9FFFF              	jmp	lff16s2_3
  3791                                  
  3792                                  ; .....................
  3793                                  
  3794                                  load_24khz_mono_8_bit:
  3795                                  	; 02/02/2025
  3796                                  	; 15/11/2023
  3797 0000174D F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3798                                  					; last of the file?
  3799 00001754 7402                    	jz	short lff24m_0		; no
  3800 00001756 F9                      	stc
  3801 00001757 C3                      	retn
  3802                                  
  3803                                  lff24m_0:
  3804                                  	; 01/12/2024
  3805                                  	; edi = audio buffer address
  3806 00001758 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3807                                          ;mov	edx, [loadsize]
  3808                                  
  3809                                  	; esi = buffer address
  3810                                  	;; edx = buffer size
  3811                                  
  3812                                  	; load file into memory
  3813                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000175D 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001763 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001765 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000176B B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001770 CD40                <1>  int 40h
  3814 00001772 723B                    	jc	short lff24m_7 ; error !
  3815                                  
  3816                                  	; 01/12/2024
  3817 00001774 A3[20390000]            	mov	[count], eax
  3818                                  	;;;
  3819                                  	; 29/05/2024
  3820                                  	;mov	edi, [audio_buffer]
  3821                                  	;;;
  3822 00001779 21C0                    	and	eax, eax
  3823 0000177B 7505                    	jnz	short lff24m_8
  3824 0000177D E9DEF9FFFF              	jmp	lff24_eof
  3825                                  
  3826                                  lff24m_8:
  3827 00001782 89C1                    	mov	ecx, eax	; byte count
  3828                                  lff24m_1:
  3829 00001784 AC                      	lodsb
  3830                                  	;mov	[previous_val], al
  3831 00001785 88C3                    	mov	bl, al
  3832 00001787 2C80                    	sub	al, 80h
  3833 00001789 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3834 0000178D 66AB                    	stosw		; original sample (left channel)
  3835 0000178F 66AB                    	stosw		; original sample (right channel)
  3836                                  	;xor	eax, eax
  3837                                  	; 02/02/2025
  3838 00001791 8A06                    	mov	al, [esi]
  3839 00001793 49                      	dec	ecx
  3840 00001794 7502                    	jnz	short lff24m_2
  3841 00001796 B080                    	mov	al, 80h
  3842                                  lff24m_2:
  3843                                  	;;mov	[next_val], al
  3844                                  	;mov	bh, al
  3845                                  	;add	al, [previous_val]
  3846 00001798 00D8                    	add	al, bl
  3847 0000179A D0D8                    	rcr	al, 1
  3848 0000179C 2C80                    	sub	al, 80h
  3849 0000179E 66C1E008                	shl	ax, 8
  3850 000017A2 66AB                    	stosw		; this is interpolated sample (L)
  3851 000017A4 66AB                    	stosw		; this is interpolated sample (R)
  3852                                  	
  3853                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  3854 000017A6 09C9                    	or	ecx, ecx
  3855 000017A8 75DA                    	jnz	short lff24m_1
  3856 000017AA E999F9FFFF              	jmp	lff24_3
  3857                                  
  3858                                  lff24m_7:
  3859                                  lff24s_7:
  3860 000017AF E9B5F9FFFF              	jmp	lff24_5  ; error
  3861                                  
  3862                                  load_24khz_stereo_8_bit:
  3863                                  	; 02/02/2025
  3864                                  	; 15/11/2023
  3865 000017B4 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3866                                  					; last of the file?
  3867 000017BB 7402                    	jz	short lff24s_0		; no
  3868 000017BD F9                      	stc
  3869 000017BE C3                      	retn
  3870                                  
  3871                                  lff24s_0:
  3872                                  	; 01/12/2024
  3873                                  	; edi = audio buffer address
  3874 000017BF BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3875                                          ;mov	edx, [loadsize]
  3876                                  
  3877                                  	; esi = buffer address
  3878                                  	;; edx = buffer size
  3879                                  
  3880                                  	; load file into memory
  3881                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000017C4 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000017CA 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000017CC 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000017D2 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000017D7 CD40                <1>  int 40h
  3882 000017D9 72D4                    	jc	short lff24s_7 ; error !
  3883                                  
  3884                                  	; 01/12/2024
  3885 000017DB A3[20390000]            	mov	[count], eax
  3886                                  	;;;
  3887                                  	; 29/05/2024
  3888                                  	;mov	edi, [audio_buffer]
  3889                                  	;;;
  3890 000017E0 D1E8                    	shr	eax, 1
  3891 000017E2 7505                    	jnz	short lff24s_8
  3892 000017E4 E977F9FFFF              	jmp	lff24_eof
  3893                                  
  3894                                  lff24s_8:
  3895 000017E9 89C1                    	mov	ecx, eax  ; word count
  3896                                  lff24s_1:
  3897 000017EB AC                      	lodsb
  3898 000017EC A2[07280000]            	mov	[previous_val_l], al
  3899 000017F1 2C80                    	sub	al, 80h
  3900 000017F3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3901 000017F7 66AB                    	stosw		; original sample (L)
  3902 000017F9 AC                      	lodsb
  3903 000017FA A2[09280000]            	mov	[previous_val_r], al
  3904 000017FF 2C80                    	sub	al, 80h
  3905 00001801 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3906 00001805 66AB                    	stosw		; original sample (R)
  3907                                  
  3908                                  	;xor	eax, eax
  3909                                  	; 02/02/2025
  3910 00001807 668B06                  	mov	ax, [esi]
  3911 0000180A 49                      	dec	ecx
  3912 0000180B 7504                    	jnz	short lff24s_2
  3913                                  		; convert 8 bit sample to 16 bit sample
  3914 0000180D 66B88080                	mov	ax, 8080h
  3915                                  lff24s_2:
  3916                                  	;;mov	[next_val_l], al
  3917                                  	;;mov	[next_val_r], ah
  3918                                  	;mov	bx, ax
  3919 00001811 88E7                    	mov	bh, ah
  3920 00001813 0205[07280000]          	add	al, [previous_val_l]
  3921 00001819 D0D8                    	rcr	al, 1
  3922                                  	;mov	dl, al
  3923 0000181B 2C80                    	sub	al, 80h
  3924 0000181D 66C1E008                	shl	ax, 8
  3925 00001821 66AB                    	stosw		; this is interpolated sample (L)
  3926 00001823 88F8                    	mov	al, bh	; [next_val_r]
  3927 00001825 0205[09280000]          	add	al, [previous_val_r]
  3928 0000182B D0D8                    	rcr	al, 1
  3929                                  	;mov	dh, al
  3930 0000182D 2C80                    	sub	al, 80h
  3931 0000182F 66C1E008                	shl	ax, 8
  3932 00001833 66AB                    	stosw		; this is interpolated sample (R)
  3933                                  		
  3934                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  3935 00001835 09C9                    	or	ecx, ecx
  3936 00001837 75B2                    	jnz	short lff24s_1
  3937 00001839 E90AF9FFFF              	jmp	lff24_3
  3938                                  
  3939                                  load_24khz_mono_16_bit:
  3940                                  	; 02/02/2025
  3941                                  	; 15/11/2023
  3942 0000183E F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3943                                  					; last of the file?
  3944 00001845 7402                    	jz	short lff24m2_0		; no
  3945 00001847 F9                      	stc
  3946 00001848 C3                      	retn
  3947                                  
  3948                                  lff24m2_0:
  3949                                  	; 01/12/2024
  3950                                  	; edi = audio buffer address
  3951 00001849 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3952                                          ;mov	edx, [loadsize]
  3953                                  
  3954                                  	; esi = buffer address
  3955                                  	;; edx = buffer size
  3956                                  
  3957                                  	; load file into memory
  3958                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000184E 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001854 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001856 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000185C B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001861 CD40                <1>  int 40h
  3959 00001863 723A                    	jc	short lff24m2_7 ; error !
  3960                                  
  3961                                  	; 01/12/2024
  3962 00001865 A3[20390000]            	mov	[count], eax
  3963                                  	;;;
  3964                                  	; 29/05/2024
  3965                                  	;mov	edi, [audio_buffer]
  3966                                  	;;;
  3967 0000186A D1E8                    	shr	eax, 1
  3968 0000186C 7505                    	jnz	short lff24m2_8
  3969 0000186E E9EDF8FFFF              	jmp	lff24_eof
  3970                                  
  3971                                  lff24m2_8:
  3972 00001873 89C1                    	mov	ecx, eax  ; word count
  3973                                  lff24m2_1:
  3974 00001875 66AD                    	lodsw
  3975 00001877 66AB                    	stosw		; original sample (left channel)
  3976 00001879 66AB                    	stosw		; original sample (right channel)
  3977 0000187B 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3978                                  	;mov	[previous_val], ax
  3979                                  	;mov	ebx, eax
  3980                                  	; 02/02/2025
  3981 0000187E 668B1E                  	mov	bx, [esi]
  3982 00001881 49                      	dec	ecx
  3983 00001882 7502                    	jnz	short lff24m2_2
  3984                                  	;xor	eax, eax
  3985 00001884 31DB                    	xor	ebx, ebx
  3986                                  lff24m2_2:
  3987                                  	; 02/02/2025
  3988 00001886 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  3989                                  	;add	ah, 80h
  3990                                  	;mov	ebp, eax	; [next_val]
  3991                                  	;add	ax, [previous_val]
  3992                                  	; ax = [previous_val]
  3993                                  	; bx = [next_val]
  3994 00001889 6601D8                  	add	ax, bx
  3995 0000188C 66D1D8                  	rcr	ax, 1
  3996 0000188F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3997 00001892 66AB                    	stosw		; this is interpolated sample (L)
  3998 00001894 66AB                    	stosw		; this is interpolated sample (R)
  3999                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  4000 00001896 09C9                    	or	ecx, ecx
  4001 00001898 75DB                    	jnz	short lff24m2_1
  4002 0000189A E9A9F8FFFF              	jmp	lff24_3
  4003                                  
  4004                                  lff24m2_7:
  4005                                  lff24s2_7:
  4006 0000189F E9C5F8FFFF              	jmp	lff24_5  ; error
  4007                                  
  4008                                  load_24khz_stereo_16_bit:
  4009                                  	; 02/02/2025
  4010                                  	; 16/11/2023
  4011                                  	; 15/11/2023
  4012 000018A4 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4013                                  					; last of the file?
  4014 000018AB 7402                    	jz	short lff24s2_0		; no
  4015 000018AD F9                      	stc
  4016 000018AE C3                      	retn
  4017                                  
  4018                                  lff24s2_0:
  4019                                  	; 01/12/2024
  4020                                  	; edi = audio buffer address
  4021 000018AF BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4022                                          ;mov	edx, [loadsize]
  4023                                  
  4024                                  	; esi = buffer address
  4025                                  	;; edx = buffer size
  4026                                  
  4027                                  	; load file into memory
  4028                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000018B4 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000018BA 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000018BC 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000018C2 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000018C7 CD40                <1>  int 40h
  4029 000018C9 72D4                    	jc	short lff24s2_7 ; error !
  4030                                  
  4031                                  	; 01/12/2024
  4032 000018CB A3[20390000]            	mov	[count], eax
  4033                                  	;;;
  4034                                  	; 29/05/2024
  4035                                  	;mov	edi, [audio_buffer]
  4036                                  	;;;
  4037 000018D0 C1E802                  	shr	eax, 2
  4038 000018D3 7505                    	jnz	short lff24s2_8
  4039 000018D5 E986F8FFFF              	jmp	lff24_eof
  4040                                  
  4041                                  lff24s2_8:
  4042 000018DA 89C1                    	mov	ecx, eax  ; dword count
  4043                                  lff24s2_1:
  4044 000018DC 66AD                    	lodsw
  4045 000018DE 66AB                    	stosw		; original sample (L)
  4046 000018E0 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  4047 000018E3 66A3[07280000]          	mov	[previous_val_l], ax
  4048 000018E9 66AD                    	lodsw
  4049 000018EB 66AB                    	stosw		; original sample (R)
  4050 000018ED 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  4051                                  	;mov	[previous_val_r], ax
  4052 000018F0 89C3                    	mov	ebx, eax
  4053                                  	; 02/02/2025
  4054 000018F2 668B06                  	mov	ax, [esi]
  4055 000018F5 668B5602                	mov	dx, [esi+2]
  4056                                  	; 16/11/2023
  4057 000018F9 49                      	dec	ecx
  4058 000018FA 7504                    	jnz	short lff24s2_2
  4059 000018FC 31D2                    	xor	edx, edx
  4060 000018FE 31C0                    	xor	eax, eax
  4061                                  lff24s2_2:
  4062 00001900 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  4063                                  	;;mov	[next_val_l], ax
  4064                                  	;mov	ebp, eax
  4065 00001903 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  4066                                  	;mov	[next_val_r], dx
  4067 00001906 660305[07280000]        	add	ax, [previous_val_l]
  4068 0000190D 66D1D8                  	rcr	ax, 1
  4069 00001910 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  4070 00001913 66AB                    	stosw		; this is interpolated sample (L)
  4071                                  	;mov	ax, [next_val_r]
  4072 00001915 89D0                    	mov	eax, edx
  4073                                  	;add	ax, [previous_val_r]
  4074 00001917 6601D8                  	add	ax, bx
  4075 0000191A 66D1D8                  	rcr	ax, 1
  4076 0000191D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4077 00001920 66AB                    	stosw		; this is interpolated sample (R)
  4078                                  	
  4079                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  4080 00001922 09C9                    	or	ecx, ecx
  4081 00001924 75B6                    	jnz	short lff24s2_1
  4082 00001926 E91DF8FFFF              	jmp	lff24_3
  4083                                  
  4084                                  ; .....................
  4085                                  
  4086                                  load_32khz_mono_8_bit:
  4087                                  	; 02/02/2025
  4088                                  	; 15/11/2023
  4089 0000192B F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4090                                  					; last of the file?
  4091 00001932 7402                    	jz	short lff32m_0		; no
  4092 00001934 F9                      	stc
  4093 00001935 C3                      	retn
  4094                                  
  4095                                  lff32m_0:
  4096                                  	; 01/12/2024
  4097                                  	; edi = audio buffer address
  4098 00001936 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4099                                          ;mov	edx, [loadsize]
  4100                                  
  4101                                  	; esi = buffer address
  4102                                  	;; edx = buffer size
  4103                                  
  4104                                  	; load file into memory
  4105                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000193B 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001941 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001943 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001949 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 0000194E CD40                <1>  int 40h
  4106 00001950 7247                    	jc	short lff32m_7 ; error !
  4107                                  
  4108                                  	; 01/12/2024
  4109 00001952 A3[20390000]            	mov	[count], eax
  4110                                  	;;;
  4111                                  	; 29/05/2024
  4112                                  	;mov	edi, [audio_buffer]
  4113                                  	;;;
  4114 00001957 21C0                    	and	eax, eax
  4115 00001959 7505                    	jnz	short lff32m_8
  4116 0000195B E900F8FFFF              	jmp	lff32_eof
  4117                                  
  4118                                  lff32m_8:
  4119 00001960 89C1                    	mov	ecx, eax	; byte count
  4120                                  lff32m_1:
  4121 00001962 AC                      	lodsb
  4122                                  	;mov	[previous_val], al
  4123 00001963 88C3                    	mov	bl, al
  4124 00001965 2C80                    	sub	al, 80h
  4125 00001967 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4126 0000196B 66AB                    	stosw		; original sample (left channel)
  4127 0000196D 66AB                    	stosw		; original sample (right channel)
  4128                                  	;xor	eax, eax
  4129                                  	; 02/02/2025
  4130 0000196F 8A06                    	mov	al, [esi]
  4131 00001971 49                      	dec	ecx
  4132 00001972 7502                    	jnz	short lff32m_2
  4133 00001974 B080                    	mov	al, 80h
  4134                                  lff32m_2:
  4135                                  	;;mov	[next_val], al
  4136                                  	;mov	bh, al
  4137                                  	;add	al, [previous_val]
  4138 00001976 00D8                    	add	al, bl
  4139 00001978 D0D8                    	rcr	al, 1
  4140 0000197A 2C80                    	sub	al, 80h
  4141 0000197C 66C1E008                	shl	ax, 8
  4142 00001980 66AB                    	stosw		; this is interpolated sample (L)
  4143 00001982 66AB                    	stosw		; this is interpolated sample (R)
  4144                                  	
  4145                                  	; different than 8-16-24 kHZ !
  4146                                  	; 'original-interpolated-original' trio samples
  4147 00001984 E30E                    	jecxz	lff32m_3
  4148                                  
  4149 00001986 AC                      	lodsb
  4150 00001987 2C80                    	sub	al, 80h
  4151 00001989 66C1E008                	shl	ax, 8
  4152 0000198D 66AB                    	stosw		; original sample (left channel)
  4153 0000198F 66AB                    	stosw		; original sample (right channel)
  4154                                  
  4155                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  4156 00001991 49                      	dec	ecx
  4157 00001992 75CE                    	jnz	short lff32m_1
  4158                                  lff32m_3:
  4159 00001994 E9AFF7FFFF              	jmp	lff32_3
  4160                                  
  4161                                  lff32m_7:
  4162                                  lff32s_7:
  4163 00001999 E9CBF7FFFF              	jmp	lff32_5  ; error
  4164                                  
  4165                                  load_32khz_stereo_8_bit:
  4166                                  	; 02/02/2025
  4167                                  	; 15/11/2023
  4168 0000199E F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4169                                  					; last of the file?
  4170 000019A5 7402                    	jz	short lff32s_0		; no
  4171 000019A7 F9                      	stc
  4172 000019A8 C3                      	retn
  4173                                  
  4174                                  lff32s_0:
  4175                                  	; 01/12/2024
  4176                                  	; edi = audio buffer address
  4177 000019A9 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4178                                          ;mov	edx, [loadsize]
  4179                                  
  4180                                  	; esi = buffer address
  4181                                  	;; edx = buffer size
  4182                                  
  4183                                  	; load file into memory
  4184                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000019AE 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000019B4 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000019B6 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000019BC B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000019C1 CD40                <1>  int 40h
  4185 000019C3 72D4                    	jc	short lff32s_7 ; error !
  4186                                  
  4187                                  	; 01/12/2024
  4188 000019C5 A3[20390000]            	mov	[count], eax
  4189                                  	;;;
  4190                                  	; 29/05/2024
  4191                                  	;mov	edi, [audio_buffer]
  4192                                  	;;;
  4193 000019CA D1E8                    	shr	eax, 1
  4194 000019CC 7505                    	jnz	short lff32s_8
  4195 000019CE E98DF7FFFF              	jmp	lff32_eof
  4196                                  
  4197                                  lff32s_8:
  4198 000019D3 89C1                    	mov	ecx, eax  ; word count
  4199                                  lff32s_1:
  4200 000019D5 AC                      	lodsb
  4201 000019D6 A2[07280000]            	mov	[previous_val_l], al
  4202 000019DB 2C80                    	sub	al, 80h
  4203 000019DD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4204 000019E1 66AB                    	stosw		; original sample (L)
  4205 000019E3 AC                      	lodsb
  4206 000019E4 A2[09280000]            	mov	[previous_val_r], al
  4207 000019E9 2C80                    	sub	al, 80h
  4208 000019EB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4209 000019EF 66AB                    	stosw		; original sample (R)
  4210                                  
  4211                                  	;xor	eax, eax
  4212                                  	; 02/02/2025
  4213 000019F1 668B06                  	mov	ax, [esi]
  4214 000019F4 49                      	dec	ecx
  4215 000019F5 7504                    	jnz	short lff32s_2
  4216                                  		; convert 8 bit sample to 16 bit sample
  4217 000019F7 66B88080                	mov	ax, 8080h
  4218                                  lff32s_2:
  4219                                  	;;mov	[next_val_l], al
  4220                                  	;;mov	[next_val_r], ah
  4221                                  	;mov	bx, ax
  4222 000019FB 88E7                    	mov	bh, ah
  4223 000019FD 0205[07280000]          	add	al, [previous_val_l]
  4224 00001A03 D0D8                    	rcr	al, 1
  4225                                  	;mov	dl, al
  4226 00001A05 2C80                    	sub	al, 80h
  4227 00001A07 66C1E008                	shl	ax, 8
  4228 00001A0B 66AB                    	stosw		; this is interpolated sample (L)
  4229 00001A0D 88F8                    	mov	al, bh	; [next_val_r]
  4230 00001A0F 0205[09280000]          	add	al, [previous_val_r]
  4231 00001A15 D0D8                    	rcr	al, 1
  4232                                  	;mov	dh, al
  4233 00001A17 2C80                    	sub	al, 80h
  4234 00001A19 66C1E008                	shl	ax, 8
  4235 00001A1D 66AB                    	stosw		; this is interpolated sample (R)
  4236                                  
  4237                                  	; different than 8-16-24 kHZ !
  4238                                  	; 'original-interpolated-original' trio samples
  4239 00001A1F E315                    	jecxz	lff32s_3
  4240                                  
  4241 00001A21 AC                      	lodsb
  4242 00001A22 2C80                    	sub	al, 80h
  4243 00001A24 66C1E008                	shl	ax, 8
  4244 00001A28 66AB                    	stosw		; original sample (left channel)
  4245                                  
  4246 00001A2A AC                      	lodsb
  4247 00001A2B 2C80                    	sub	al, 80h
  4248 00001A2D 66C1E008                	shl	ax, 8
  4249 00001A31 66AB                    	stosw		; original sample (right channel)
  4250                                  		
  4251                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  4252 00001A33 49                      	dec	ecx
  4253 00001A34 759F                    	jnz	short lff32s_1
  4254                                  lff32s_3:
  4255 00001A36 E90DF7FFFF              	jmp	lff32_3
  4256                                  
  4257                                  load_32khz_mono_16_bit:
  4258                                  	; 02/02/2025
  4259                                  	; 15/11/2023
  4260 00001A3B F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4261                                  					; last of the file?
  4262 00001A42 7402                    	jz	short lff32m2_0		; no
  4263 00001A44 F9                      	stc
  4264 00001A45 C3                      	retn
  4265                                  
  4266                                  lff32m2_0:
  4267                                  	; 01/12/2024
  4268                                  	; edi = audio buffer address
  4269 00001A46 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4270                                          ;mov	edx, [loadsize]
  4271                                  
  4272                                  	; esi = buffer address
  4273                                  	;; edx = buffer size
  4274                                  
  4275                                  	; load file into memory
  4276                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001A4B 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001A51 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001A53 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001A59 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001A5E CD40                <1>  int 40h
  4277 00001A60 7241                    	jc	short lff32m2_7 ; error !
  4278                                  
  4279                                  	; 01/12/2024
  4280 00001A62 A3[20390000]            	mov	[count], eax
  4281                                  	;;;
  4282                                  	; 29/05/2024
  4283                                  	;mov	edi, [audio_buffer]
  4284                                  	;;;
  4285 00001A67 D1E8                    	shr	eax, 1
  4286 00001A69 7505                    	jnz	short lff32m2_8
  4287 00001A6B E9F0F6FFFF              	jmp	lff32_eof
  4288                                  
  4289                                  lff32m2_8:
  4290 00001A70 89C1                    	mov	ecx, eax  ; word count
  4291                                  lff32m2_1:
  4292 00001A72 66AD                    	lodsw
  4293 00001A74 66AB                    	stosw		; original sample (left channel)
  4294 00001A76 66AB                    	stosw		; original sample (right channel)
  4295 00001A78 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4296                                  	;mov	[previous_val], ax
  4297                                  	;mov	ebx, eax
  4298                                  	;xor	eax, eax
  4299                                  	; 02/02/2025
  4300                                  	;mov	ax, [esi]
  4301 00001A7B 668B1E                  	mov	bx, [esi]
  4302 00001A7E 49                      	dec	ecx
  4303 00001A7F 7502                    	jnz	short lff32m2_2
  4304 00001A81 31DB                    	xor	ebx, ebx
  4305                                  lff32m2_2:
  4306                                  	; 02/02/2025
  4307 00001A83 80C780                  	add	bh, 80h ; convert sound level 0 to 65535 format
  4308                                  	;add	ah, 80h
  4309                                  	;mov	ebp, eax ; [next_val]
  4310                                  	;add	ax, [previous_val]
  4311                                  	; ax = [previous_val]
  4312                                  	; bx = [next_val]
  4313 00001A86 6601D8                  	add	ax, bx
  4314 00001A89 66D1D8                  	rcr	ax, 1
  4315 00001A8C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4316 00001A8F 66AB                    	stosw		; this is interpolated sample (L)
  4317 00001A91 66AB                    	stosw		; this is interpolated sample (R)
  4318                                  
  4319                                  	; different than 8-16-24 kHZ !
  4320                                  	; 'original-interpolated-original' trio samples 
  4321 00001A93 E309                    	jecxz	lff32m2_3
  4322                                  
  4323 00001A95 66AD                    	lodsw
  4324 00001A97 66AB                    	stosw		; original sample (left channel)
  4325 00001A99 66AB                    	stosw		; original sample (right channel)
  4326                                  
  4327                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  4328 00001A9B 49                      	dec	ecx
  4329 00001A9C 75D4                    	jnz	short lff32m2_1
  4330                                  lff32m2_3:
  4331 00001A9E E9A5F6FFFF              	jmp	lff32_3
  4332                                  
  4333                                  lff32m2_7:
  4334                                  lff32s2_7:
  4335 00001AA3 E9C1F6FFFF              	jmp	lff32_5  ; error
  4336                                  
  4337                                  load_32khz_stereo_16_bit:
  4338                                  	; 02/02/2025
  4339                                  	; 16/11/2023
  4340                                  	; 15/11/2023
  4341 00001AA8 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4342                                  					; last of the file?
  4343 00001AAF 7402                    	jz	short lff32s2_0		; no
  4344 00001AB1 F9                      	stc
  4345 00001AB2 C3                      	retn
  4346                                  
  4347                                  lff32s2_0:
  4348                                  	; 01/12/2024
  4349                                  	; edi = audio buffer address
  4350 00001AB3 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4351                                          ;mov	edx, [loadsize]
  4352                                  
  4353                                  	; esi = buffer address
  4354                                  	;; edx = buffer size
  4355                                  
  4356                                  	; load file into memory
  4357                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001AB8 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001ABE 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001AC0 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001AC6 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001ACB CD40                <1>  int 40h
  4358 00001ACD 72D4                    	jc	short lff32s2_7 ; error !
  4359                                  
  4360                                  	; 01/12/2024
  4361 00001ACF A3[20390000]            	mov	[count], eax
  4362                                  	;;;
  4363                                  	; 29/05/2024
  4364                                  	;mov	edi, [audio_buffer]
  4365                                  	;;;
  4366 00001AD4 C1E802                  	shr	eax, 2
  4367 00001AD7 7505                    	jnz	short lff32s2_8
  4368 00001AD9 E982F6FFFF              	jmp	lff32_eof
  4369                                  
  4370                                  lff32s2_8:
  4371 00001ADE 89C1                    	mov	ecx, eax ; dword count
  4372                                  lff32s2_1:
  4373 00001AE0 66AD                    	lodsw
  4374 00001AE2 66AB                    	stosw		; original sample (L)
  4375 00001AE4 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  4376 00001AE7 66A3[07280000]          	mov	[previous_val_l], ax
  4377 00001AED 66AD                    	lodsw
  4378 00001AEF 66AB                    	stosw		; original sample (R)
  4379 00001AF1 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  4380                                  	;mov	[previous_val_r], ax
  4381 00001AF4 89C3                    	mov	ebx, eax
  4382                                  	; 02/02/2025
  4383 00001AF6 668B06                  	mov	ax, [esi]
  4384 00001AF9 668B5602                	mov	dx, [esi+2]
  4385                                  	; 16/11/2023
  4386 00001AFD 49                      	dec	ecx
  4387 00001AFE 7504                    	jnz	short lff32s2_2
  4388 00001B00 31D2                    	xor	edx, edx
  4389 00001B02 31C0                    	xor	eax, eax
  4390                                  lff32s2_2:
  4391 00001B04 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format
  4392                                  	;;mov	[next_val_l], ax
  4393                                  	;mov	ebp, eax
  4394 00001B07 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format
  4395                                  	;mov	[next_val_r], dx
  4396 00001B0A 660305[07280000]        	add	ax, [previous_val_l]
  4397 00001B11 66D1D8                  	rcr	ax, 1
  4398 00001B14 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  4399 00001B17 66AB                    	stosw		; this is interpolated sample (L)
  4400                                  	;mov	ax, [next_val_r]
  4401 00001B19 89D0                    	mov	eax, edx
  4402                                  	;add	ax, [previous_val_r]
  4403 00001B1B 6601D8                  	add	ax, bx
  4404 00001B1E 66D1D8                  	rcr	ax, 1
  4405 00001B21 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4406 00001B24 66AB                    	stosw		; this is interpolated sample (R)
  4407                                  
  4408                                  	; different than 8-16-24 kHZ !
  4409                                  	; 'original-interpolated-original' trio samples
  4410 00001B26 E30B                    	jecxz	lff32s2_3
  4411                                  
  4412 00001B28 66AD                    	lodsw
  4413 00001B2A 66AB                    	stosw	; original sample (L)
  4414 00001B2C 66AD                    	lodsw
  4415 00001B2E 66AB                    	stosw	; original sample (R)
  4416                                  	
  4417                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  4418 00001B30 49                      	dec	ecx
  4419 00001B31 75AD                    	jnz	short lff32s2_1
  4420                                  lff32s2_3:
  4421 00001B33 E910F6FFFF              	jmp	lff32_3
  4422                                  
  4423                                  ; .....................
  4424                                  
  4425                                  load_22khz_mono_8_bit:
  4426                                  	; 02/02/2025
  4427                                  	; 16/11/2023
  4428 00001B38 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4429                                  					; last of the file?
  4430 00001B3F 7402                    	jz	short lff22m_0		; no
  4431 00001B41 F9                      	stc
  4432 00001B42 C3                      	retn
  4433                                  
  4434                                  lff22m_0:
  4435                                  	; 01/12/2024
  4436                                  	; edi = audio buffer address
  4437 00001B43 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4438                                          ;mov	edx, [loadsize]
  4439                                  
  4440                                  	; esi = buffer address
  4441                                  	;; edx = buffer size
  4442                                  
  4443                                  	; load file into memory
  4444                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001B48 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001B4E 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001B50 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001B56 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001B5B CD40                <1>  int 40h
  4445 00001B5D 725D                    	jc	short lff22m_7 ; error !
  4446                                  
  4447                                  	; 01/12/2024
  4448 00001B5F A3[20390000]            	mov	[count], eax
  4449                                  	;;;
  4450                                  	; 29/05/2024
  4451                                  	;mov	edi, [audio_buffer]
  4452                                  	;;;
  4453 00001B64 21C0                    	and	eax, eax
  4454 00001B66 7505                    	jnz	short lff22m_8
  4455 00001B68 E9F3F5FFFF              	jmp	lff22_eof
  4456                                  
  4457                                  lff22m_8:
  4458 00001B6D 89C1                    	mov	ecx, eax	; byte count
  4459                                  lff22m_9:
  4460 00001B6F BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4461 00001B74 C605[0F280000]03        	mov	byte [faz], 3  ; 3 steps/phases
  4462                                  lff22m_1:
  4463                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4464 00001B7B AC                      	lodsb
  4465                                  	; 02/02/2025
  4466 00001B7C 8A16                    	mov	dl, [esi]
  4467 00001B7E 49                      	dec	ecx
  4468 00001B7F 7502                    	jnz	short lff22m_2_1
  4469 00001B81 B280                    	mov	dl, 80h
  4470                                  lff22m_2_1:	
  4471                                  	; al = [previous_val]
  4472                                  	; dl = [next_val]
  4473 00001B83 E835070000              	call	interpolating_3_8bit_mono ; 1 of 17
  4474 00001B88 E32D                    	jecxz	lff22m_3
  4475                                  lff22m_2_2:
  4476 00001B8A AC                      	lodsb
  4477                                  	; 02/02/2025
  4478 00001B8B 8A16                    	mov	dl, [esi]
  4479 00001B8D 49                      	dec	ecx
  4480 00001B8E 7502                    	jnz	short lff22m_2_3
  4481 00001B90 B280                    	mov	dl, 80h
  4482                                  lff22m_2_3:
  4483 00001B92 E8B0070000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  4484 00001B97 E31E                    	jecxz	lff22m_3
  4485 00001B99 4D                      	dec	ebp
  4486 00001B9A 75EE                    	jnz	short lff22m_2_2
  4487                                  
  4488 00001B9C A0[0F280000]            	mov	al, [faz]
  4489 00001BA1 FEC8                    	dec	al
  4490 00001BA3 74CA                    	jz	short lff22m_9
  4491 00001BA5 FE0D[0F280000]          	dec	byte [faz]
  4492 00001BAB BD04000000              	mov	ebp, 4
  4493 00001BB0 FEC8                    	dec	al
  4494 00001BB2 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  4495 00001BB4 45                      	inc	ebp ; 5
  4496 00001BB5 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4497                                  
  4498                                  lff22m_3:
  4499                                  lff22s_3:
  4500 00001BB7 E98CF5FFFF              	jmp	lff22_3	; padfill
  4501                                  		; (put zeros in the remain words of the buffer)
  4502                                  lff22m_7:
  4503                                  lff22s_7:
  4504 00001BBC E9A8F5FFFF              	jmp	lff22_5  ; error
  4505                                  
  4506                                  load_22khz_stereo_8_bit:
  4507                                  	; 02/02/2025
  4508                                  	; 16/11/2023
  4509 00001BC1 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4510                                  					; last of the file?
  4511 00001BC8 7402                    	jz	short lff22s_0		; no
  4512 00001BCA F9                      	stc
  4513 00001BCB C3                      	retn
  4514                                  
  4515                                  lff22s_0:
  4516                                  	; 01/12/2024
  4517                                  	; edi = audio buffer address
  4518 00001BCC BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4519                                          ;mov	edx, [loadsize]
  4520                                  
  4521                                  	; esi = buffer address
  4522                                  	;; edx = buffer size
  4523                                  
  4524                                  	; load file into memory
  4525                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001BD1 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001BD7 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001BD9 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001BDF B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001BE4 CD40                <1>  int 40h
  4526 00001BE6 72D4                    	jc	short lff22s_7 ; error !
  4527                                  
  4528                                  	; 01/12/2024
  4529 00001BE8 A3[20390000]            	mov	[count], eax
  4530                                  	;;;
  4531                                  	; 29/05/2024
  4532                                  	;mov	edi, [audio_buffer]
  4533                                  	;;;
  4534 00001BED D1E8                    	shr	eax, 1
  4535 00001BEF 7505                    	jnz	short lff22s_8
  4536 00001BF1 E96AF5FFFF              	jmp	lff22_eof
  4537                                  
  4538                                  lff22s_8:
  4539 00001BF6 89C1                    	mov	ecx, eax	; word count
  4540                                  lff22s_9:
  4541 00001BF8 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4542 00001BFD C605[0F280000]03        	mov	byte [faz], 3  ; 3 steps/phase
  4543                                  lff22s_1:
  4544                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4545 00001C04 66AD                    	lodsw
  4546                                  	; 02/02/2025
  4547 00001C06 668B16                  	mov	dx, [esi]
  4548 00001C09 49                      	dec	ecx
  4549 00001C0A 7504                    	jnz	short lff22s_2_1
  4550 00001C0C 66BA8080                	mov	dx, 8080h
  4551                                  lff22s_2_1:	
  4552                                  	; al = [previous_val_l]
  4553                                  	; ah = [previous_val_r]
  4554                                  	; dl = [next_val_l]
  4555                                  	; dh = [next_val_r]
  4556 00001C10 E8DB060000              	call	interpolating_3_8bit_stereo ; 1 of 17
  4557 00001C15 E3A0                    	jecxz	lff22s_3
  4558                                  lff22s_2_2:
  4559 00001C17 66AD                    	lodsw
  4560                                  	; 02/02/2025
  4561 00001C19 668B16                  	mov	dx, [esi]
  4562 00001C1C 49                      	dec	ecx
  4563 00001C1D 7504                    	jnz	short lff22s_2_3
  4564 00001C1F 66BA8080                	mov	dx, 8080h
  4565                                  lff22s_2_3:
  4566 00001C23 E83C070000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  4567 00001C28 E38D                    	jecxz	lff22s_3
  4568 00001C2A 4D                      	dec	ebp
  4569 00001C2B 75EA                    	jnz	short lff22s_2_2
  4570                                  
  4571 00001C2D A0[0F280000]            	mov	al, [faz]
  4572 00001C32 FEC8                    	dec	al
  4573 00001C34 74C2                    	jz	short lff22s_9
  4574 00001C36 FE0D[0F280000]          	dec	byte [faz]
  4575 00001C3C BD04000000              	mov	ebp, 4
  4576 00001C41 FEC8                    	dec	al
  4577 00001C43 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  4578 00001C45 45                      	inc	ebp ; 5
  4579 00001C46 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4580                                  
  4581                                  load_22khz_mono_16_bit:
  4582                                  	; 02/02/2025
  4583                                  	; 16/11/2023
  4584 00001C48 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4585                                  					; last of the file?
  4586 00001C4F 7402                    	jz	short lff22m2_0		; no
  4587 00001C51 F9                      	stc
  4588 00001C52 C3                      	retn
  4589                                  
  4590                                  lff22m2_0:
  4591                                  	; 01/12/2024
  4592                                  	; edi = audio buffer address
  4593 00001C53 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4594                                          ;mov	edx, [loadsize]
  4595                                  
  4596                                  	; esi = buffer address
  4597                                  	;; edx = buffer size
  4598                                  
  4599                                  	; load file into memory
  4600                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001C58 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001C5E 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001C60 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001C66 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001C6B CD40                <1>  int 40h
  4601 00001C6D 7261                    	jc	short lff22m2_7 ; error !
  4602                                  
  4603                                  	; 01/12/2024
  4604 00001C6F A3[20390000]            	mov	[count], eax
  4605                                  	;;;
  4606                                  	; 29/05/2024
  4607                                  	;mov	edi, [audio_buffer]
  4608                                  	;;;
  4609 00001C74 D1E8                    	shr	eax, 1
  4610 00001C76 7505                    	jnz	short lff22m2_8
  4611 00001C78 E9E3F4FFFF              	jmp	lff22_eof
  4612                                  
  4613                                  lff22m2_8:
  4614 00001C7D 89C1                    	mov	ecx, eax	; word count
  4615                                  lff22m2_9:
  4616 00001C7F BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4617 00001C84 C605[0F280000]03        	mov	byte [faz], 3  ; 3 steps/phases
  4618                                  lff22m2_1:
  4619                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4620 00001C8B 66AD                    	lodsw
  4621                                  	; 02/02/2025
  4622 00001C8D 668B16                  	mov	dx, [esi]
  4623 00001C90 49                      	dec	ecx
  4624 00001C91 7502                    	jnz	short lff22m2_2_1
  4625 00001C93 31D2                    	xor	edx, edx
  4626                                  lff22m2_2_1:	
  4627                                  	; ax = [previous_val]
  4628                                  	; dx = [next_val]
  4629 00001C95 E8FB060000              	call	interpolating_3_16bit_mono ; 1 of 17
  4630 00001C9A E32F                    	jecxz	lff22m2_3
  4631                                  lff22m2_2_2:
  4632 00001C9C 66AD                    	lodsw
  4633                                  	; 02/02/2025
  4634 00001C9E 668B16                  	mov	dx, [esi]
  4635 00001CA1 49                      	dec	ecx
  4636 00001CA2 7502                    	jnz	short lff22m2_2_3
  4637 00001CA4 31D2                    	xor	edx, edx
  4638                                  lff22m2_2_3:
  4639 00001CA6 E87D070000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  4640 00001CAB E31E                    	jecxz	lff22m2_3
  4641 00001CAD 4D                      	dec	ebp
  4642 00001CAE 75EC                    	jnz	short lff22m2_2_2
  4643                                  
  4644 00001CB0 A0[0F280000]            	mov	al, [faz]
  4645 00001CB5 FEC8                    	dec	al
  4646 00001CB7 74C6                    	jz	short lff22m2_9
  4647 00001CB9 FE0D[0F280000]          	dec	byte [faz]
  4648 00001CBF BD04000000              	mov	ebp, 4
  4649 00001CC4 FEC8                    	dec	al
  4650 00001CC6 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4651 00001CC8 45                      	inc	ebp ; 5
  4652 00001CC9 EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4653                                  
  4654                                  lff22m2_3:
  4655                                  lff22s2_3:
  4656 00001CCB E978F4FFFF              	jmp	lff22_3	; padfill
  4657                                  		; (put zeros in the remain words of the buffer)
  4658                                  lff22m2_7:
  4659                                  lff22s2_7:
  4660 00001CD0 E994F4FFFF              	jmp	lff22_5  ; error
  4661                                  
  4662                                  load_22khz_stereo_16_bit:
  4663                                  	; 16/11/2023
  4664 00001CD5 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4665                                  					; last of the file?
  4666 00001CDC 7402                    	jz	short lff22s2_0		; no
  4667 00001CDE F9                      	stc
  4668 00001CDF C3                      	retn
  4669                                  
  4670                                  lff22s2_0:
  4671                                  	; 01/12/2024
  4672                                  	; edi = audio buffer address
  4673 00001CE0 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4674                                          ;mov	edx, [loadsize]
  4675                                  
  4676                                  	; esi = buffer address
  4677                                  	;; edx = buffer size
  4678                                  
  4679                                  	; load file into memory
  4680                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001CE5 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001CEB 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001CED 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001CF3 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001CF8 CD40                <1>  int 40h
  4681 00001CFA 72D4                    	jc	short lff22s2_7 ; error !
  4682                                  
  4683                                  	; 01/12/2024
  4684 00001CFC A3[20390000]            	mov	[count], eax
  4685                                  	;;;
  4686                                  	; 29/05/2024
  4687                                  	;mov	edi, [audio_buffer]
  4688                                  	;;;
  4689 00001D01 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  4690 00001D04 7505                    	jnz	short lff22s2_8
  4691 00001D06 E955F4FFFF              	jmp	lff22_eof
  4692                                  
  4693                                  lff22s2_8:
  4694 00001D0B 89C1                    	mov	ecx, eax	; dword count
  4695                                  lff22s2_9:
  4696 00001D0D BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  4697 00001D12 C605[0F280000]03        	mov	byte [faz], 3  ; 3 steps/phase
  4698                                  lff22s2_1:
  4699                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  4700 00001D19 66AD                    	lodsw
  4701 00001D1B 89C3                    	mov	ebx, eax
  4702 00001D1D 66AD                    	lodsw
  4703 00001D1F 8B16                    	mov	edx, [esi]
  4704 00001D21 668915[0B280000]        	mov	[next_val_l], dx
  4705                                  	; 26/11/2023
  4706 00001D28 C1EA10                  	shr	edx, 16
  4707 00001D2B 49                      	dec	ecx
  4708 00001D2C 7509                    	jnz	short lff22s2_2_1
  4709 00001D2E 31D2                    	xor	edx, edx ; 0
  4710 00001D30 668915[0B280000]        	mov	[next_val_l], dx
  4711                                  lff22s2_2_1:
  4712                                  	; bx = [previous_val_l]
  4713                                  	; ax = [previous_val_r]
  4714                                  	; [next_val_l]
  4715                                  	; dx = [next_val_r]
  4716 00001D37 E889060000              	call	interpolating_3_16bit_stereo ; 1 of 17
  4717 00001D3C E38D                    	jecxz	lff22s2_3
  4718                                  lff22s2_2_2:
  4719 00001D3E 66AD                    	lodsw
  4720 00001D40 89C3                    	mov	ebx, eax
  4721 00001D42 66AD                    	lodsw
  4722 00001D44 8B16                    	mov	edx, [esi]
  4723 00001D46 668915[0B280000]        	mov	[next_val_l], dx
  4724                                  	; 26/11/2023
  4725 00001D4D C1EA10                  	shr	edx, 16
  4726 00001D50 49                      	dec	ecx
  4727 00001D51 7509                    	jnz	short lff22s2_2_3
  4728 00001D53 31D2                    	xor	edx, edx ; 0
  4729 00001D55 668915[0B280000]        	mov	[next_val_l], dx
  4730                                  lff22s2_2_3:
  4731 00001D5C E8DF060000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  4732 00001D61 E31E                    	jecxz	lff22s2_2_4
  4733                                  
  4734 00001D63 4D                      	dec	ebp
  4735 00001D64 75D8                    	jnz	short lff22s2_2_2
  4736                                  
  4737 00001D66 A0[0F280000]            	mov	al, [faz]
  4738 00001D6B FEC8                    	dec	al
  4739 00001D6D 749E                    	jz	short lff22s2_9
  4740 00001D6F FE0D[0F280000]          	dec	byte [faz]
  4741 00001D75 BD04000000              	mov	ebp, 4
  4742 00001D7A FEC8                    	dec	al
  4743 00001D7C 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  4744 00001D7E 45                      	inc	ebp ; 5
  4745 00001D7F EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  4746                                  
  4747                                  lff22s2_2_4:
  4748                                  	; 26/11/2023
  4749 00001D81 E9C2F3FFFF              	jmp	lff22_3	; padfill
  4750                                  
  4751                                  ; .....................
  4752                                  
  4753                                  load_11khz_mono_8_bit:
  4754                                  	; 02/02/2025
  4755                                  	; 18/11/2023
  4756 00001D86 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4757                                  					; last of the file?
  4758 00001D8D 7402                    	jz	short lff11m_0		; no
  4759 00001D8F F9                      	stc
  4760 00001D90 C3                      	retn
  4761                                  
  4762                                  lff11m_0:
  4763                                  	; 01/12/2024
  4764                                  	; edi = audio buffer address
  4765 00001D91 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4766                                          ;mov	edx, [loadsize]
  4767                                  
  4768                                  	; esi = buffer address
  4769                                  	;; edx = buffer size
  4770                                  
  4771                                  	; load file into memory
  4772                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001D96 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001D9C 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001D9E 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001DA4 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001DA9 CD40                <1>  int 40h
  4773 00001DAB 7247                    	jc	short lff11m_7 ; error !
  4774                                  
  4775                                  	; 01/12/2024
  4776 00001DAD A3[20390000]            	mov	[count], eax
  4777                                  	;;;
  4778                                  	; 29/05/2024
  4779                                  	;mov	edi, [audio_buffer]
  4780                                  	;;;
  4781 00001DB2 21C0                    	and	eax, eax
  4782 00001DB4 7505                    	jnz	short lff11m_8
  4783 00001DB6 E9A5F3FFFF              	jmp	lff11_eof
  4784                                  
  4785                                  lff11m_8:
  4786 00001DBB 89C1                    	mov	ecx, eax		; byte count
  4787                                  lff11m_9:
  4788 00001DBD BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4789                                  lff11m_1:
  4790                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4791 00001DC2 AC                      	lodsb
  4792                                  	; 02/02/2025
  4793 00001DC3 8A16                    	mov	dl, [esi]
  4794 00001DC5 49                      	dec	ecx
  4795 00001DC6 7502                    	jnz	short lff11m_2_1
  4796 00001DC8 B280                    	mov	dl, 80h
  4797                                  lff11m_2_1:	
  4798                                  	; al = [previous_val]
  4799                                  	; dl = [next_val]
  4800 00001DCA E8A0060000              	call	interpolating_5_8bit_mono
  4801 00001DCF E328                    	jecxz	lff11m_3
  4802                                  lff11m_2_2:
  4803 00001DD1 AC                      	lodsb
  4804                                  	; 02/02/2025
  4805 00001DD2 8A16                    	mov	dl, [esi]
  4806 00001DD4 49                      	dec	ecx
  4807 00001DD5 7502                    	jnz	short lff11m_2_3
  4808 00001DD7 B280                    	mov	dl, 80h
  4809                                  lff11m_2_3:
  4810 00001DD9 E89D070000               	call	interpolating_4_8bit_mono
  4811 00001DDE E319                    	jecxz	lff11m_3
  4812                                  
  4813 00001DE0 4D                      	dec	ebp
  4814 00001DE1 74DA                    	jz	short lff11m_9
  4815                                  
  4816 00001DE3 AC                      	lodsb
  4817                                  	; 02/02/2025
  4818 00001DE4 8A16                    	mov	dl, [esi]
  4819 00001DE6 49                      	dec	ecx
  4820 00001DE7 7502                    	jnz	short lff11m_2_4
  4821 00001DE9 B280                    	mov	dl, 80h
  4822                                  lff11m_2_4:
  4823 00001DEB E88B070000              	call	interpolating_4_8bit_mono
  4824 00001DF0 E307                    	jecxz	lff11m_3
  4825 00001DF2 EBCE                    	jmp	short lff11m_1
  4826                                  
  4827                                  lff11m_7:
  4828                                  lff11s_7:
  4829 00001DF4 E970F3FFFF              	jmp	lff11_5  ; error
  4830                                  
  4831                                  lff11m_3:
  4832                                  lff11s_3:
  4833 00001DF9 E94AF3FFFF              	jmp	lff11_3	; padfill
  4834                                  		; (put zeros in the remain words of the buffer)
  4835                                  
  4836                                  load_11khz_stereo_8_bit:
  4837                                  	; 02/02/2025
  4838                                  	; 18/11/2023
  4839 00001DFE F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4840                                  					; last of the file?
  4841 00001E05 7402                    	jz	short lff11s_0		; no
  4842 00001E07 F9                      	stc
  4843 00001E08 C3                      	retn
  4844                                  
  4845                                  lff11s_0:
  4846                                  	; 01/12/2024
  4847                                  	; edi = audio buffer address
  4848 00001E09 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4849                                          ;mov	edx, [loadsize]
  4850                                  
  4851                                  	; esi = buffer address
  4852                                  	;; edx = buffer size
  4853                                  
  4854                                  	; load file into memory
  4855                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001E0E 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001E14 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001E16 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001E1C B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001E21 CD40                <1>  int 40h
  4856 00001E23 72CF                    	jc	short lff11s_7 ; error !
  4857                                  
  4858                                  	; 01/12/2024
  4859 00001E25 A3[20390000]            	mov	[count], eax
  4860                                  	;;;
  4861                                  	; 29/05/2024
  4862                                  	;mov	edi, [audio_buffer]
  4863                                  	;;;
  4864 00001E2A D1E8                    	shr	eax, 1
  4865 00001E2C 7505                    	jnz	short lff11s_8
  4866 00001E2E E92DF3FFFF              	jmp	lff11_eof
  4867                                  
  4868                                  lff11s_8:
  4869 00001E33 89C1                    	mov	ecx, eax	; word count
  4870                                  lff11s_9:
  4871 00001E35 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4872                                  lff11s_1:
  4873                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4874 00001E3A 66AD                    	lodsw
  4875                                  	; 02/02/2025
  4876 00001E3C 668B16                  	mov	dx, [esi]
  4877 00001E3F 49                      	dec	ecx
  4878 00001E40 7504                    	jnz	short lff11s_2_1
  4879 00001E42 66BA8080                	mov	dx, 8080h
  4880                                  lff11s_2_1:	
  4881                                  	; al = [previous_val_l]
  4882                                  	; ah = [previous_val_r]
  4883                                  	; dl = [next_val_l]
  4884                                  	; dh = [next_val_r]
  4885 00001E46 E883060000              	call	interpolating_5_8bit_stereo
  4886 00001E4B E3AC                    	jecxz	lff11s_3
  4887                                  lff11s_2_2:
  4888 00001E4D 66AD                    	lodsw
  4889                                  	; 02/02/2025
  4890 00001E4F 668B16                  	mov	dx, [esi]
  4891 00001E52 49                      	dec	ecx
  4892 00001E53 7504                    	jnz	short lff11s_2_3
  4893 00001E55 66BA8080                	mov	dx, 8080h
  4894                                  lff11s_2_3:
  4895 00001E59 E85C070000               	call	interpolating_4_8bit_stereo
  4896 00001E5E E399                    	jecxz	lff11s_3
  4897                                  	
  4898 00001E60 4D                      	dec	ebp
  4899 00001E61 74D2                    	jz	short lff11s_9
  4900                                  
  4901 00001E63 66AD                    	lodsw
  4902                                  	; 02/02/2025
  4903 00001E65 668B16                  	mov	dx, [esi]
  4904 00001E68 49                      	dec	ecx
  4905 00001E69 7504                    	jnz	short lff11s_2_4
  4906 00001E6B 66BA8080                	mov	dx, 8080h
  4907                                  lff11s_2_4:
  4908 00001E6F E846070000              	call	interpolating_4_8bit_stereo
  4909 00001E74 E383                    	jecxz	lff11s_3
  4910 00001E76 EBC2                    	jmp	short lff11s_1
  4911                                  
  4912                                  load_11khz_mono_16_bit:
  4913                                  	; 02/02/2025
  4914                                  	; 18/11/2023
  4915 00001E78 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4916                                  					; last of the file?
  4917 00001E7F 7402                    	jz	short lff11m2_0		; no
  4918 00001E81 F9                      	stc
  4919 00001E82 C3                      	retn
  4920                                  
  4921                                  lff11m2_0:
  4922                                  	; 01/12/2024
  4923                                  	; edi = audio buffer address
  4924 00001E83 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  4925                                          ;mov	edx, [loadsize]
  4926                                  
  4927                                  	; esi = buffer address
  4928                                  	;; edx = buffer size
  4929                                  
  4930                                  	; load file into memory
  4931                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001E88 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001E8E 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001E90 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001E96 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001E9B CD40                <1>  int 40h
  4932 00001E9D 724D                    	jc	short lff11m2_7 ; error !
  4933                                  
  4934                                  	; 01/12/2024
  4935 00001E9F A3[20390000]            	mov	[count], eax
  4936                                  	;;;
  4937                                  	; 29/05/2024
  4938                                  	;mov	edi, [audio_buffer]
  4939                                  	;;;
  4940 00001EA4 D1E8                    	shr	eax, 1
  4941 00001EA6 7505                    	jnz	short lff11m2_8
  4942 00001EA8 E9B3F2FFFF              	jmp	lff11_eof
  4943                                  
  4944                                  lff11m2_8:
  4945 00001EAD 89C1                    	mov	ecx, eax	; word count
  4946                                  lff11m2_9:
  4947 00001EAF BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  4948                                  lff11m2_1:
  4949                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  4950 00001EB4 66AD                    	lodsw
  4951                                  	; 02/02/2025
  4952 00001EB6 668B16                  	mov	dx, [esi]
  4953 00001EB9 49                      	dec	ecx
  4954 00001EBA 7502                    	jnz	short lff11m2_2_1
  4955 00001EBC 31D2                    	xor	edx, edx
  4956                                  lff11m2_2_1:	
  4957                                  	; ax = [previous_val]
  4958                                  	; dx = [next_val]
  4959 00001EBE E864070000              	call	interpolating_5_16bit_mono
  4960 00001EC3 E362                    	jecxz	lff11m2_3
  4961                                  lff11m2_2_2:
  4962 00001EC5 66AD                    	lodsw
  4963                                  	; 02/02/2025
  4964 00001EC7 668B16                  	mov	dx, [esi]
  4965 00001ECA 49                      	dec	ecx
  4966 00001ECB 7502                    	jnz	short lff11m2_2_3
  4967 00001ECD 31D2                    	xor	edx, edx
  4968                                  lff11m2_2_3:
  4969 00001ECF E87D080000               	call	interpolating_4_16bit_mono
  4970 00001ED4 E351                    	jecxz	lff11m2_3
  4971                                  
  4972 00001ED6 4D                      	dec	ebp
  4973 00001ED7 74D6                    	jz	short lff11m2_9
  4974                                  
  4975 00001ED9 66AD                    	lodsw
  4976                                  	; 02/02/2025
  4977 00001EDB 668B16                  	mov	dx, [esi]
  4978 00001EDE 49                      	dec	ecx
  4979 00001EDF 7502                    	jnz	short lff11m2_2_4
  4980 00001EE1 31D2                    	xor	edx, edx
  4981                                  lff11m2_2_4:
  4982 00001EE3 E869080000               	call	interpolating_4_16bit_mono
  4983 00001EE8 E33D                    	jecxz	lff11m2_3
  4984 00001EEA EBC8                    	jmp	short lff11m2_1
  4985                                  
  4986                                  lff11m2_7:
  4987                                  lff11s2_7:
  4988 00001EEC E978F2FFFF              	jmp	lff11_5  ; error
  4989                                  
  4990                                  load_11khz_stereo_16_bit:
  4991                                  	; 17/01/2025
  4992                                  	; 18/11/2023
  4993 00001EF1 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  4994                                  					; last of the file?
  4995 00001EF8 7402                    	jz	short lff11s2_0		; no
  4996 00001EFA F9                      	stc
  4997 00001EFB C3                      	retn
  4998                                  
  4999                                  lff11s2_0:
  5000                                  	; 01/12/2024
  5001                                  	; edi = audio buffer address
  5002 00001EFC BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5003                                          ;mov	edx, [loadsize]
  5004                                  
  5005                                  	; esi = buffer address
  5006                                  	;; edx = buffer size
  5007                                  
  5008                                  	; load file into memory
  5009                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001F01 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001F07 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001F09 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001F0F B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001F14 CD40                <1>  int 40h
  5010 00001F16 72D4                    	jc	short lff11s2_7 ; error !
  5011                                  
  5012                                  	; 01/12/2024
  5013 00001F18 A3[20390000]            	mov	[count], eax
  5014                                  	;;;
  5015                                  	; 29/05/2024
  5016                                  	;mov	edi, [audio_buffer]
  5017                                  	;;;
  5018 00001F1D C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  5019 00001F20 750A                    	jnz	short lff11s2_8
  5020 00001F22 E939F2FFFF              	jmp	lff11_eof
  5021                                  
  5022                                  lff11m2_3:
  5023                                  lff11s2_3:
  5024 00001F27 E91CF2FFFF              	jmp	lff11_3	; padfill
  5025                                  		; (put zeros in the remain words of the buffer)
  5026                                  
  5027                                  lff11s2_8:
  5028 00001F2C 89C1                    	mov	ecx, eax	; dword count
  5029                                  lff11s2_9:
  5030 00001F2E BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  5031                                  lff11s2_1:
  5032                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  5033 00001F33 66AD                    	lodsw
  5034 00001F35 89C3                    	mov	ebx, eax
  5035 00001F37 66AD                    	lodsw
  5036 00001F39 8B16                    	mov	edx, [esi]
  5037                                  	; 17/01/2025
  5038                                  	;mov	[next_val_l], edx
  5039                                  	; 26/11/2023
  5040                                  	;shr	edx, 16
  5041                                  	;mov	[next_val_r], dx
  5042 00001F3B 49                      	dec	ecx
  5043 00001F3C 7502                    	jnz	short lff11s2_2_1
  5044 00001F3E 31D2                    	xor	edx, edx ; 0
  5045                                  	;mov	[next_val_l], dx
  5046                                  	;mov	[next_val_r], dx
  5047                                  lff11s2_2_1:
  5048                                  	; bx = [previous_val_l]
  5049                                  	; ax = [previous_val_r]
  5050                                  	; [next_val_l]
  5051                                  	; dx = [next_val_r]
  5052                                  	;;;
  5053                                  	; 17/01/2025 (BugFix)
  5054 00001F40 8915[0B280000]          	mov	[next_val_l], edx
  5055                                  	;;;
  5056 00001F46 E837070000              	call	interpolating_5_16bit_stereo
  5057 00001F4B E3DA                    	jecxz	lff11s2_3
  5058                                  lff11s2_2_2:
  5059 00001F4D 66AD                    	lodsw
  5060 00001F4F 89C3                    	mov	ebx, eax
  5061 00001F51 66AD                    	lodsw
  5062 00001F53 8B16                    	mov	edx, [esi]
  5063                                  	; 17/01/2025
  5064                                  	;mov	[next_val_l], dx
  5065                                  	; 26/11/2023
  5066                                  	;shr	edx, 16
  5067                                  	;mov	[next_val_r], dx
  5068 00001F55 49                      	dec	ecx
  5069 00001F56 7502                    	jnz	short lff11s2_2_3
  5070 00001F58 31D2                    	xor	edx, edx ; 0
  5071                                  	;mov	[next_val_l], dx
  5072                                  	;mov	[next_val_r], dx
  5073                                  lff11s2_2_3:
  5074                                  	;;;
  5075                                  	; 17/01/2025 (BugFix)
  5076 00001F5A 8915[0B280000]          	mov	[next_val_l], edx
  5077                                  	;;;
  5078 00001F60 E825080000              	call	interpolating_4_16bit_stereo
  5079 00001F65 E3C0                    	jecxz	lff11s2_3
  5080                                  	
  5081 00001F67 4D                      	dec	ebp
  5082 00001F68 74C4                    	jz	short lff11s2_9
  5083                                  
  5084 00001F6A 66AD                    	lodsw
  5085 00001F6C 89C3                    	mov	ebx, eax
  5086 00001F6E 66AD                    	lodsw
  5087 00001F70 8B16                    	mov	edx, [esi]
  5088                                  	; 17/01/2025
  5089                                  	;mov	[next_val_l], dx
  5090                                  	; 26/11/2023
  5091                                  	;shr	edx, 16
  5092                                  	;mov	[next_val_r], dx
  5093 00001F72 49                      	dec	ecx
  5094 00001F73 7502                    	jnz	short lff11s2_2_4
  5095 00001F75 31D2                    	xor	edx, edx ; 0
  5096                                  	;mov	[next_val_l], dx
  5097                                  	;mov	[next_val_r], dx
  5098                                  lff11s2_2_4:
  5099                                  	;;;
  5100                                  	; 17/01/2025 (BugFix)
  5101 00001F77 8915[0B280000]          	mov	[next_val_l], edx
  5102                                  	;;;
  5103 00001F7D E808080000               	call	interpolating_4_16bit_stereo
  5104 00001F82 E3A3                    	jecxz	lff11s2_3
  5105 00001F84 EBAD                    	jmp	short lff11s2_1
  5106                                  
  5107                                  ; .....................
  5108                                  
  5109                                  load_44khz_mono_8_bit:
  5110                                  	; 02/02/2025
  5111                                  	; 18/11/2023
  5112 00001F86 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5113                                  					; last of the file?
  5114 00001F8D 7402                    	jz	short lff44m_0		; no
  5115 00001F8F F9                      	stc
  5116 00001F90 C3                      	retn
  5117                                  
  5118                                  lff44m_0:
  5119                                  	; 01/12/2024
  5120                                  	; edi = audio buffer address
  5121 00001F91 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5122                                          ;mov	edx, [loadsize]
  5123                                  
  5124                                  	; esi = buffer address
  5125                                  	;; edx = buffer size
  5126                                  
  5127                                  	; load file into memory
  5128                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00001F96 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00001F9C 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00001F9E 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00001FA4 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00001FA9 CD40                <1>  int 40h
  5129 00001FAB 7250                    	jc	short lff44m_7 ; error !
  5130                                  
  5131                                  	; 01/12/2024
  5132 00001FAD A3[20390000]            	mov	[count], eax
  5133                                  	;;;
  5134                                  	; 29/05/2024
  5135                                  	;mov	edi, [audio_buffer]
  5136                                  	;;;
  5137 00001FB2 21C0                    	and	eax, eax
  5138 00001FB4 7505                    	jnz	short lff44m_8
  5139 00001FB6 E9A5F1FFFF              	jmp	lff44_eof
  5140                                  
  5141                                  lff44m_8:
  5142 00001FBB 89C1                    	mov	ecx, eax	; byte count
  5143                                  lff44m_9:
  5144 00001FBD BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5145 00001FC2 C605[0F280000]02        	mov	byte [faz], 2  ; 2 steps/phases
  5146                                  lff44m_1:
  5147                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5148                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5149 00001FC9 AC                      	lodsb
  5150                                  	; 02/02/2025
  5151 00001FCA 8A16                    	mov	dl, [esi]
  5152 00001FCC 49                      	dec	ecx
  5153 00001FCD 7502                    	jnz	short lff44m_2_1
  5154 00001FCF B280                    	mov	dl, 80h
  5155                                  lff44m_2_1:	
  5156                                  	; al = [previous_val]
  5157                                  	; dl = [next_val]
  5158 00001FD1 E871030000              	call	interpolating_2_8bit_mono
  5159 00001FD6 E320                    	jecxz	lff44m_3
  5160                                  lff44m_2_2:
  5161 00001FD8 AC                      	lodsb
  5162 00001FD9 2C80                    	sub	al, 80h
  5163 00001FDB 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5164 00001FDF 66AB                    	stosw		; (L)
  5165 00001FE1 66AB                    	stosw		; (R)
  5166                                  
  5167 00001FE3 49                      	dec	ecx
  5168 00001FE4 7412                    	jz	short lff44m_3
  5169 00001FE6 4D                      	dec	ebp
  5170 00001FE7 75EF                    	jnz	short lff44m_2_2
  5171                                  	
  5172 00001FE9 FE0D[0F280000]          	dec	byte [faz]
  5173 00001FEF 74CC                    	jz	short lff44m_9 
  5174 00001FF1 BD0B000000              	mov	ebp, 11
  5175 00001FF6 EBD1                    	jmp	short lff44m_1
  5176                                  
  5177                                  lff44m_3:
  5178                                  lff44s_3:
  5179 00001FF8 E94BF1FFFF              	jmp	lff44_3	; padfill
  5180                                  		; (put zeros in the remain words of the buffer)
  5181                                  lff44m_7:
  5182                                  lff44s_7:
  5183 00001FFD E967F1FFFF              	jmp	lff44_5  ; error
  5184                                  
  5185                                  load_44khz_stereo_8_bit:
  5186                                  	; 02/02/2025
  5187                                  	; 16/11/2023
  5188 00002002 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5189                                  					; last of the file?
  5190 00002009 7402                    	jz	short lff44s_0		; no
  5191 0000200B F9                      	stc
  5192 0000200C C3                      	retn
  5193                                  
  5194                                  lff44s_0:
  5195                                  	; 01/12/2024
  5196                                  	; edi = audio buffer address
  5197 0000200D BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5198                                          ;mov	edx, [loadsize]
  5199                                  
  5200                                  	; esi = buffer address
  5201                                  	;; edx = buffer size
  5202                                  
  5203                                  	; load file into memory
  5204                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002012 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00002018 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000201A 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002020 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00002025 CD40                <1>  int 40h
  5205 00002027 72D4                    	jc	short lff44s_7 ; error !
  5206                                  
  5207                                  	; 01/12/2024
  5208 00002029 A3[20390000]            	mov	[count], eax
  5209                                  	;;;
  5210                                  	; 29/05/2024
  5211                                  	;mov	edi, [audio_buffer]
  5212                                  	;;;
  5213 0000202E D1E8                    	shr	eax, 1
  5214 00002030 7505                    	jnz	short lff44s_8
  5215 00002032 E929F1FFFF              	jmp	lff44_eof
  5216                                  
  5217                                  lff44s_8:
  5218 00002037 89C1                    	mov	ecx, eax	; word count
  5219                                  lff44s_9:
  5220 00002039 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5221 0000203E C605[0F280000]02        	mov	byte [faz], 2  ; 2 steps/phase
  5222                                  lff44s_1:
  5223                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5224                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5225 00002045 66AD                    	lodsw
  5226                                  	; 02/02/2025
  5227 00002047 668B16                  	mov	dx, [esi]
  5228 0000204A 49                      	dec	ecx
  5229 0000204B 7504                    	jnz	short lff44s_2_1
  5230 0000204D 66BA8080                	mov	dx, 8080h
  5231                                  lff44s_2_1:	
  5232                                  	; al = [previous_val_l]
  5233                                  	; ah = [previous_val_r]
  5234                                  	; dl = [next_val_l]
  5235                                  	; dh = [next_val_r]
  5236 00002051 E80E030000              	call	interpolating_2_8bit_stereo
  5237 00002056 E3A0                    	jecxz	lff44s_3
  5238                                  lff44s_2_2:
  5239 00002058 AC                      	lodsb
  5240 00002059 2C80                    	sub	al, 80h
  5241 0000205B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5242 0000205F 66AB                    	stosw		; (L)
  5243 00002061 AC                      	lodsb
  5244 00002062 2C80                    	sub	al, 80h
  5245 00002064 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5246 00002068 66AB                    	stosw		; (R)
  5247                                  
  5248 0000206A 49                      	dec	ecx
  5249 0000206B 748B                    	jz	short lff44s_3
  5250 0000206D 4D                      	dec	ebp
  5251 0000206E 75E8                    	jnz	short lff44s_2_2
  5252                                  	
  5253 00002070 FE0D[0F280000]          	dec	byte [faz]
  5254 00002076 74C1                    	jz	short lff44s_9 
  5255 00002078 BD0B000000              	mov	ebp, 11
  5256 0000207D EBC6                    	jmp	short lff44s_1
  5257                                  
  5258                                  load_44khz_mono_16_bit:
  5259                                  	; 02/02/2025
  5260                                  	; 18/11/2023
  5261 0000207F F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5262                                  					; last of the file?
  5263 00002086 7402                    	jz	short lff44m2_0		; no
  5264 00002088 F9                      	stc
  5265 00002089 C3                      	retn
  5266                                  
  5267                                  lff44m2_0:
  5268                                  	; 01/12/2024
  5269                                  	; edi = audio buffer address
  5270 0000208A BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5271                                          ;mov	edx, [loadsize]
  5272                                  
  5273                                  	; esi = buffer address
  5274                                  	;; edx = buffer size
  5275                                  
  5276                                  	; load file into memory
  5277                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 0000208F 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 00002095 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00002097 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 0000209D B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000020A2 CD40                <1>  int 40h
  5278 000020A4 724D                    	jc	short lff44m2_7 ; error !
  5279                                  
  5280                                  	; 01/12/2024
  5281 000020A6 A3[20390000]            	mov	[count], eax
  5282                                  	;;;
  5283                                  	; 29/05/2024
  5284                                  	;mov	edi, [audio_buffer]
  5285                                  	;;;
  5286 000020AB D1E8                    	shr	eax, 1
  5287 000020AD 7505                    	jnz	short lff44m2_8
  5288 000020AF E9ACF0FFFF              	jmp	lff44_eof
  5289                                  
  5290                                  lff44m2_8:
  5291 000020B4 89C1                    	mov	ecx, eax	; word count
  5292                                  lff44m2_9:
  5293 000020B6 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5294 000020BB C605[0F280000]02        	mov	byte [faz], 2  ; 2 steps/phases
  5295                                  lff44m2_1:
  5296                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5297                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5298 000020C2 66AD                    	lodsw
  5299                                  	; 02/02/2025
  5300 000020C4 668B16                  	mov	dx, [esi]
  5301 000020C7 49                      	dec	ecx
  5302 000020C8 7502                    	jnz	short lff44m2_2_1
  5303 000020CA 31D2                    	xor	edx, edx
  5304                                  lff44m2_2_1:	
  5305                                  	; ax = [previous_val]
  5306                                  	; dx = [next_val]
  5307 000020CC E857030000              	call	interpolating_2_16bit_mono
  5308 000020D1 E31B                    	jecxz	lff44m2_3
  5309                                  lff44m2_2_2:
  5310 000020D3 66AD                    	lodsw
  5311 000020D5 66AB                    	stosw		; (L)eft Channel
  5312 000020D7 66AB                    	stosw		; (R)ight Channel
  5313                                  
  5314 000020D9 49                      	dec	ecx
  5315 000020DA 7412                    	jz	short lff44m2_3
  5316 000020DC 4D                      	dec	ebp
  5317 000020DD 75F4                    	jnz	short lff44m2_2_2
  5318                                  	
  5319 000020DF FE0D[0F280000]          	dec	byte [faz]
  5320 000020E5 74CF                    	jz	short lff44m2_9
  5321 000020E7 BD0B000000              	mov	ebp, 11
  5322 000020EC EBD4                    	jmp	short lff44m2_1
  5323                                  
  5324                                  lff44m2_3:
  5325                                  lff44s2_3:
  5326 000020EE E955F0FFFF              	jmp	lff44_3	; padfill
  5327                                  		; (put zeros in the remain words of the buffer)
  5328                                  lff44m2_7:
  5329                                  lff44s2_7:
  5330 000020F3 E971F0FFFF              	jmp	lff44_5  ; error
  5331                                  
  5332                                  load_44khz_stereo_16_bit:
  5333                                  	; 18/11/2023
  5334 000020F8 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5335                                  					; last of the file?
  5336 000020FF 7402                    	jz	short lff44s2_0		; no
  5337 00002101 F9                      	stc
  5338 00002102 C3                      	retn
  5339                                  
  5340                                  lff44s2_0:
  5341                                  	; 01/12/2024
  5342                                  	; edi = audio buffer address
  5343 00002103 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5344                                          ;mov	edx, [loadsize]
  5345                                  
  5346                                  	; esi = buffer address
  5347                                  	;; edx = buffer size
  5348                                  
  5349                                  	; load file into memory
  5350                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002108 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000210E 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 00002110 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002116 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 0000211B CD40                <1>  int 40h
  5351 0000211D 72D4                    	jc	short lff44s2_7 ; error !
  5352                                  
  5353                                  	; 01/12/2024
  5354 0000211F A3[20390000]            	mov	[count], eax
  5355                                  	;;;
  5356                                  	; 29/05/2024
  5357                                  	;mov	edi, [audio_buffer]
  5358                                  	;;;
  5359 00002124 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  5360 00002127 7505                    	jnz	short lff44s2_8
  5361 00002129 E932F0FFFF              	jmp	lff44_eof
  5362                                  
  5363                                  lff44s2_8:
  5364 0000212E 89C1                    	mov	ecx, eax	; dword count
  5365                                  lff44s2_9:
  5366 00002130 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  5367 00002135 C605[0F280000]02        	mov	byte [faz], 2  ; 2 steps/phase
  5368                                  lff44s2_1:
  5369                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  5370                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  5371 0000213C 66AD                    	lodsw
  5372 0000213E 89C3                    	mov	ebx, eax
  5373 00002140 66AD                    	lodsw
  5374                                  	;mov	dx, [esi]
  5375                                  	;mov	[next_val_l], dx
  5376                                  	;mov	dx, [esi+2]
  5377                                  	; 26/11/2023
  5378 00002142 8B16                    	mov	edx, [esi]
  5379 00002144 668915[0B280000]        	mov	[next_val_l], dx
  5380 0000214B C1EA10                  	shr	edx, 16
  5381 0000214E 49                      	dec	ecx
  5382 0000214F 7509                    	jnz	short lff44s2_2_1
  5383 00002151 31D2                    	xor	edx, edx ; 0
  5384 00002153 668915[0B280000]        	mov	[next_val_l], dx
  5385                                  lff44s2_2_1:
  5386                                  	; bx = [previous_val_l]
  5387                                  	; ax = [previous_val_r]
  5388                                  	; [next_val_l]
  5389                                  	; dx = [next_val_r]
  5390 0000215A E8E1020000              	call	interpolating_2_16bit_stereo
  5391 0000215F E38D                    	jecxz	lff44s2_3
  5392                                  lff44s2_2_2:
  5393                                  	;movsw		; (L)eft Channel
  5394                                  	;movsw		; (R)ight Channel
  5395 00002161 A5                      	movsd
  5396                                  
  5397 00002162 49                      	dec	ecx
  5398 00002163 7489                    	jz	short lff44s2_3	
  5399 00002165 4D                      	dec	ebp
  5400 00002166 75F9                    	jnz	short lff44s2_2_2
  5401                                  	
  5402 00002168 FE0D[0F280000]          	dec	byte [faz]
  5403 0000216E 74C0                    	jz	short lff44s2_9 
  5404 00002170 BD0B000000              	mov	ebp, 11
  5405 00002175 EBC5                    	jmp	short lff44s2_1
  5406                                  
  5407                                  ; .....................
  5408                                  
  5409                                  	; 02/02/2025
  5410                                  load_12khz_mono_8_bit:
  5411 00002177 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5412                                  					; last of the file?
  5413 0000217E 7402                    	jz	short lff12m_0		; no
  5414 00002180 F9                      	stc
  5415 00002181 C3                      	retn
  5416                                  
  5417                                  lff12m_0:
  5418                                  	; edi = audio buffer address
  5419 00002182 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5420                                  
  5421                                  	; load file into memory
  5422                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002187 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000218D 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000218F 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002195 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 0000219A CD40                <1>  int 40h
  5423 0000219C 7256                    	jc	short lff12m_7 ; error !
  5424                                  
  5425 0000219E A3[20390000]            	mov	[count], eax
  5426                                  
  5427 000021A3 21C0                    	and	eax, eax
  5428 000021A5 7505                    	jnz	short lff12m_8
  5429 000021A7 E9B4EFFFFF              	jmp	lff12_eof
  5430                                  
  5431                                  lff12m_8:
  5432 000021AC 89C1                    	mov	ecx, eax		; byte count
  5433                                  lff12m_1:
  5434                                  	; original-interpolated-interpolated-interpolated
  5435 000021AE AC                      	lodsb
  5436                                  	; 02/02/2025
  5437 000021AF 8A16                    	mov	dl, [esi]
  5438 000021B1 49                      	dec	ecx
  5439 000021B2 7502                    	jnz	short lff12m_2
  5440 000021B4 B280                    	mov	dl, 80h
  5441                                  lff12m_2:	
  5442                                  	; al = [previous_val]
  5443                                  	; dl = [next_val]
  5444 000021B6 E8C0030000               	call	interpolating_4_8bit_mono
  5445 000021BB E353                    	jecxz	lff12m_3
  5446 000021BD EBEF                    	jmp	short lff12m_1
  5447                                  
  5448                                  	; 02/02/2025
  5449                                  load_12khz_stereo_8_bit:
  5450 000021BF F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5451                                  					; last of the file?
  5452 000021C6 7402                    	jz	short lff12s_0		; no
  5453 000021C8 F9                      	stc
  5454 000021C9 C3                      	retn
  5455                                  
  5456                                  lff12s_0:
  5457                                  	; edi = audio buffer address
  5458 000021CA BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5459                                  
  5460                                  	; load file into memory
  5461                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000021CF 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 000021D5 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 000021D7 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000021DD B803000000          <1>  mov eax, %1
   130                              <1> 
   131 000021E2 CD40                <1>  int 40h
  5462 000021E4 720E                    	jc	short lff12s_7 ; error !
  5463                                  
  5464 000021E6 A3[20390000]            	mov	[count], eax
  5465                                  
  5466 000021EB D1E8                    	shr	eax, 1
  5467 000021ED 750A                    	jnz	short lff12s_8
  5468 000021EF E96CEFFFFF              	jmp	lff12_eof
  5469                                  
  5470                                  lff12m_7:
  5471                                  lff12s_7:
  5472 000021F4 E970EFFFFF              	jmp	lff12_5  ; error
  5473                                  
  5474                                  lff12s_8:
  5475 000021F9 89C1                    	mov	ecx, eax	; word count
  5476                                  lff12s_1:
  5477                                  	; original-interpolated-interpolated-interpolated
  5478 000021FB 66AD                    	lodsw
  5479                                  	; 02/02/2025
  5480 000021FD 668B16                  	mov	dx, [esi]
  5481 00002200 49                      	dec	ecx
  5482 00002201 7504                    	jnz	short lff12s_2
  5483 00002203 66BA8080                	mov	dx, 8080h
  5484                                  lff12s_2:	
  5485                                  	; al = [previous_val_l]
  5486                                  	; ah = [previous_val_r]
  5487                                  	; dl = [next_val_l]
  5488                                  	; dh = [next_val_r]
  5489 00002207 E8AE030000              	call	interpolating_4_8bit_stereo
  5490 0000220C E302                    	jecxz	lff12s_3
  5491 0000220E EBEB                    	jmp	short lff12s_1
  5492                                  
  5493                                  lff12m_3:
  5494                                  lff12s_3:
  5495 00002210 E933EFFFFF              	jmp	lff12_3	; padfill
  5496                                  		; (put zeros in the remain words of the buffer)
  5497                                  
  5498                                  	; 02/02/2025
  5499                                  load_12khz_mono_16_bit:
  5500 00002215 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5501                                  					; last of the file?
  5502 0000221C 7402                    	jz	short lff12m2_0		; no
  5503 0000221E F9                      	stc
  5504 0000221F C3                      	retn
  5505                                  
  5506                                  lff12m2_0:
  5507                                  	; edi = audio buffer address
  5508 00002220 BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5509                                  
  5510                                  	; load file into memory
  5511                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002225 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000222B 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000222D 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002233 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00002238 CD40                <1>  int 40h
  5512 0000223A 7223                    	jc	short lff12m2_7 ; error !
  5513                                  
  5514 0000223C A3[20390000]            	mov	[count], eax
  5515                                  
  5516 00002241 D1E8                    	shr	eax, 1
  5517 00002243 7505                    	jnz	short lff12m2_8
  5518 00002245 E916EFFFFF              	jmp	lff12_eof
  5519                                  
  5520                                  lff12m2_8:
  5521 0000224A 89C1                    	mov	ecx, eax	; word count
  5522                                  lff12m2_1:
  5523                                  	; original-interpolated-interpolated-interpolated
  5524 0000224C 66AD                    	lodsw
  5525                                  	; 02/02/2025
  5526 0000224E 668B16                  	mov	dx, [esi]
  5527 00002251 49                      	dec	ecx
  5528 00002252 7502                    	jnz	short lff12m2_2
  5529 00002254 31D2                    	xor	edx, edx
  5530                                  lff12m2_2:	
  5531                                  	; ax = [previous_val]
  5532                                  	; dx = [next_val]
  5533 00002256 E8F6040000               	call	interpolating_4_16bit_mono
  5534 0000225B E3B3                    	jecxz	lff12m_3
  5535 0000225D EBED                    	jmp	short lff12m2_1
  5536                                  
  5537                                  lff12m2_7:
  5538                                  lff12s2_7:
  5539 0000225F E905EFFFFF              	jmp	lff12_5  ; error
  5540                                  
  5541                                  	; 02/02/2025
  5542                                  load_12khz_stereo_16_bit:
  5543 00002264 F605[9A380000]01                test    byte [flags], ENDOFFILE	; have we already read the
  5544                                  					; last of the file?
  5545 0000226B 7402                    	jz	short lff12s2_0		; no
  5546 0000226D F9                      	stc
  5547 0000226E C3                      	retn
  5548                                  
  5549                                  lff12s2_0:
  5550                                  	; edi = audio buffer address
  5551 0000226F BE[00500200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  5552                                  
  5553                                  	; load file into memory
  5554                                  	sys 	_read, [filehandle], esi, [loadsize]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002274 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123 0000227A 89F1                <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125 0000227C 8B15[10390000]      <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002282 B803000000          <1>  mov eax, %1
   130                              <1> 
   131 00002287 CD40                <1>  int 40h
  5555 00002289 72D4                    	jc	short lff12s2_7 ; error !
  5556                                  
  5557 0000228B A3[20390000]            	mov	[count], eax
  5558                                  
  5559 00002290 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  5560 00002293 750A                    	jnz	short lff12s2_8
  5561 00002295 E9C6EEFFFF              	jmp	lff12_eof
  5562                                  
  5563                                  lff12m2_3:
  5564                                  lff12s2_3:
  5565 0000229A E9A9EEFFFF              	jmp	lff12_3	; padfill
  5566                                  		; (put zeros in the remain words of the buffer)
  5567                                  
  5568                                  lff12s2_8:
  5569 0000229F 89C1                    	mov	ecx, eax	; dword count
  5570                                  lff12s2_1:
  5571                                  	; original-interpolated-interpolated-interpolated
  5572 000022A1 66AD                    	lodsw
  5573 000022A3 89C3                    	mov	ebx, eax
  5574 000022A5 66AD                    	lodsw
  5575 000022A7 8B16                    	mov	edx, [esi]
  5576 000022A9 49                      	dec	ecx
  5577 000022AA 7502                    	jnz	short lff12s2_2
  5578 000022AC 31D2                    	xor	edx, edx ; 0
  5579                                  lff12s2_2:
  5580                                  	;mov	[next_val_l], dx
  5581                                  	;shr	edx, 16
  5582                                  	;mov	[next_val_r], dx
  5583                                  	; 02/02/2025
  5584 000022AE 8915[0B280000]          	mov	[next_val_l], edx
  5585                                  
  5586                                  	; bx = [previous_val_l]
  5587                                  	; ax = [previous_val_r]
  5588                                  	; [next_val_l]
  5589                                  	; [next_val_r]
  5590 000022B4 E8D1040000              	call	interpolating_4_16bit_stereo
  5591 000022B9 E3DF                    	jecxz	lff12s2_3
  5592 000022BB EBE4                    	jmp	short lff12s2_1
  5593                                  
  5594                                  ; .....................
  5595                                  
  5596                                  interpolating_3_8bit_mono:
  5597                                  	; 02/02/2025
  5598                                  	; 16/11/2023
  5599                                  	; al = [previous_val]
  5600                                  	; dl = [next_val]
  5601                                  	; original-interpolated-interpolated
  5602 000022BD 88C3                    	mov	bl, al
  5603 000022BF 2C80                    	sub	al, 80h
  5604 000022C1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5605 000022C5 66AB                    	stosw		; original sample (L)
  5606 000022C7 66AB                    	stosw		; original sample (R)
  5607 000022C9 88D8                    	mov	al, bl
  5608 000022CB 00D0                    	add	al, dl
  5609 000022CD D0D8                    	rcr	al, 1
  5610 000022CF 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5611 000022D1 00D8                    	add	al, bl
  5612 000022D3 D0D8                    	rcr	al, 1
  5613 000022D5 2C80                    	sub	al, 80h
  5614 000022D7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5615 000022DB 66AB                    	stosw		; interpolated sample 1 (L)
  5616 000022DD 66AB                    	stosw		; interpolated sample 1 (R)
  5617 000022DF 88F8                    	mov	al, bh
  5618 000022E1 00D0                    	add	al, dl	; [next_val]
  5619 000022E3 D0D8                    	rcr	al, 1
  5620                                  	; 02/02/2025
  5621 000022E5 2C80                    	sub	al, 80h
  5622 000022E7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5623 000022EB 66AB                    	stosw		; interpolated sample 2 (L)
  5624 000022ED 66AB                    	stosw		; interpolated sample 2 (R)
  5625 000022EF C3                      	retn
  5626                                  
  5627                                  interpolating_3_8bit_stereo:
  5628                                  	; 02/02/2025
  5629                                  	; 16/11/2023
  5630                                  	; al = [previous_val_l]
  5631                                  	; ah = [previous_val_r]
  5632                                  	; dl = [next_val_l]
  5633                                  	; dh = [next_val_r]	
  5634                                  	; original-interpolated-interpolated
  5635 000022F0 89C3                    	mov	ebx, eax
  5636 000022F2 2C80                    	sub	al, 80h
  5637 000022F4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5638 000022F8 66AB                    	stosw		; original sample (L)
  5639 000022FA 88F8                    	mov	al, bh
  5640 000022FC 2C80                    	sub	al, 80h
  5641 000022FE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5642 00002302 66AB                    	stosw		; original sample (R)
  5643 00002304 88D8                    	mov	al, bl
  5644 00002306 00D0                    	add	al, dl	; [next_val_l]
  5645 00002308 D0D8                    	rcr	al, 1
  5646 0000230A 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  5647 0000230B 00D8                    	add	al, bl	; [previous_val_l]
  5648 0000230D D0D8                    	rcr	al, 1
  5649 0000230F 2C80                    	sub	al, 80h
  5650 00002311 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5651 00002315 66AB                    	stosw		; interpolated sample 1 (L)
  5652 00002317 88F8                    	mov	al, bh
  5653 00002319 00F0                    	add	al, dh	; [next_val_r]
  5654 0000231B D0D8                    	rcr	al, 1
  5655 0000231D 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  5656 0000231E 00F8                    	add	al, bh	; [previous_val_r]
  5657 00002320 D0D8                    	rcr	al, 1
  5658 00002322 2C80                    	sub	al, 80h
  5659 00002324 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5660 00002328 66AB                    	stosw		; interpolated sample 1 (R)
  5661 0000232A 5B                      	pop	ebx ; **
  5662 0000232B 58                      	pop	eax ; *
  5663 0000232C 00D0                    	add	al, dl	; [next_val_l]
  5664 0000232E D0D8                    	rcr	al, 1
  5665                                  	; 02/02/2025
  5666 00002330 2C80                    	sub	al, 80h
  5667 00002332 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5668 00002336 66AB                    	stosw		; interpolated sample 2 (L)
  5669 00002338 88D8                    	mov	al, bl
  5670 0000233A 00F0                    	add	al, dh	; [next_val_r]
  5671 0000233C D0D8                    	rcr	al, 1
  5672                                  	; 02/02/2025
  5673 0000233E 2C80                    	sub	al, 80h
  5674 00002340 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5675 00002344 66AB                    	stosw		; interpolated sample 2 (R)
  5676 00002346 C3                      	retn
  5677                                  
  5678                                  interpolating_2_8bit_mono:
  5679                                  	; 16/11/2023
  5680                                  	; al = [previous_val]
  5681                                  	; dl = [next_val]
  5682                                  	; original-interpolated
  5683 00002347 88C3                    	mov	bl, al
  5684 00002349 2C80                    	sub	al, 80h
  5685 0000234B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5686 0000234F 66AB                    	stosw		; original sample (L)
  5687 00002351 66AB                    	stosw		; original sample (R)
  5688 00002353 88D8                    	mov	al, bl
  5689 00002355 00D0                    	add	al, dl
  5690 00002357 D0D8                    	rcr	al, 1
  5691 00002359 2C80                    	sub	al, 80h
  5692 0000235B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5693 0000235F 66AB                    	stosw		; interpolated sample (L)
  5694 00002361 66AB                    	stosw		; interpolated sample (R)
  5695 00002363 C3                      	retn
  5696                                  
  5697                                  interpolating_2_8bit_stereo:
  5698                                  	; 16/11/2023
  5699                                  	; al = [previous_val_l]
  5700                                  	; ah = [previous_val_r]
  5701                                  	; dl = [next_val_l]
  5702                                  	; dh = [next_val_r]
  5703                                  	; original-interpolated
  5704 00002364 89C3                    	mov	ebx, eax
  5705 00002366 2C80                    	sub	al, 80h
  5706 00002368 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5707 0000236C 66AB                    	stosw		; original sample (L)
  5708 0000236E 88F8                    	mov	al, bh
  5709 00002370 2C80                    	sub	al, 80h
  5710 00002372 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5711 00002376 66AB                    	stosw		; original sample (R)
  5712 00002378 88D8                    	mov	al, bl	; [previous_val_l]
  5713 0000237A 00D0                    	add	al, dl	; [next_val_l]
  5714 0000237C D0D8                    	rcr	al, 1
  5715 0000237E 2C80                    	sub	al, 80h
  5716 00002380 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5717 00002384 66AB                    	stosw		; interpolated sample (L)
  5718 00002386 88F8                    	mov	al, bh
  5719 00002388 00F0                    	add	al, dh	; [next_val_r]
  5720 0000238A D0D8                    	rcr	al, 1
  5721 0000238C 2C80                    	sub	al, 80h
  5722 0000238E 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5723 00002392 66AB                    	stosw		; interpolated sample (R)
  5724 00002394 C3                      	retn
  5725                                  
  5726                                  interpolating_3_16bit_mono:
  5727                                  	; 16/11/2023
  5728                                  	; ax = [previous_val]
  5729                                  	; dx = [next_val]
  5730                                  	; original-interpolated-interpolated
  5731                                  
  5732 00002395 66AB                    	stosw		; original sample (L)
  5733 00002397 66AB                    	stosw		; original sample (R)
  5734 00002399 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5735 0000239C 50                      	push	eax ; *	; [previous_val]
  5736 0000239D 80C680                  	add	dh, 80h
  5737 000023A0 6601D0                  	add	ax, dx
  5738 000023A3 66D1D8                  	rcr	ax, 1
  5739 000023A6 5B                      	pop	ebx ; *
  5740 000023A7 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  5741 000023A8 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  5742 000023AB 66D1D8                  	rcr	ax, 1
  5743 000023AE 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5744 000023B1 66AB                    	stosw 		; interpolated sample 1 (L)
  5745 000023B3 66AB                    	stosw		; interpolated sample 1 (R)
  5746 000023B5 89D8                    	mov	eax, ebx
  5747 000023B7 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  5748 000023BA 66D1D8                  	rcr	ax, 1
  5749 000023BD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5750 000023C0 66AB                    	stosw		; interpolated sample 2 (L)
  5751 000023C2 66AB                    	stosw		; interpolated sample 2 (R)
  5752 000023C4 C3                      	retn
  5753                                  
  5754                                  interpolating_3_16bit_stereo:
  5755                                  	; 16/11/2023
  5756                                  	; bx = [previous_val_l]
  5757                                  	; ax = [previous_val_r]
  5758                                  	; [next_val_l]
  5759                                  	; dx = [next_val_r]
  5760                                  	; original-interpolated-interpolated
  5761                                  
  5762 000023C5 93                      	xchg	eax, ebx
  5763 000023C6 66AB                    	stosw		; original sample (L)
  5764 000023C8 93                      	xchg	eax, ebx
  5765 000023C9 66AB                    	stosw		; original sample (R)
  5766 000023CB 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5767 000023CE 50                      	push	eax ; *	; [previous_val_r]
  5768 000023CF 80C780                  	add	bh, 80h
  5769 000023D2 8005[0C280000]80        	add	byte [next_val_l+1], 80h
  5770 000023D9 66A1[0B280000]          	mov	ax, [next_val_l]
  5771 000023DF 6601D8                  	add	ax, bx	; [previous_val_l]
  5772 000023E2 66D1D8                  	rcr	ax, 1
  5773 000023E5 93                      	xchg	eax, ebx ; ax = [previous_val_l]
  5774 000023E6 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  5775 000023E9 66D1D8                  	rcr	ax, 1
  5776 000023EC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5777 000023EF 66AB                    	stosw 		; interpolated sample 1 (L)
  5778 000023F1 58                      	pop	eax  ; *
  5779 000023F2 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  5780 000023F5 52                      	push	edx  ; * ; [next_val_r]
  5781 000023F6 92                      	xchg	eax, edx
  5782 000023F7 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  5783 000023FA 66D1D8                  	rcr	ax, 1	; / 2
  5784 000023FD 50                      	push	eax ; ** ; interpolated middle (R)
  5785 000023FE 6601D0                  	add	ax, dx	; + [previous_val_r]
  5786 00002401 66D1D8                  	rcr	ax, 1
  5787 00002404 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5788 00002407 66AB                    	stosw 		; interpolated sample 1 (R)
  5789 00002409 66A1[0B280000]          	mov	ax, [next_val_l]
  5790 0000240F 6601D8                  	add	ax, bx	; + interpolated middle (L)
  5791 00002412 66D1D8                  	rcr	ax, 1
  5792 00002415 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5793 00002418 66AB                    	stosw 		; interpolated sample 2 (L)
  5794 0000241A 58                      	pop	eax ; **
  5795 0000241B 5A                      	pop	edx ; *
  5796 0000241C 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  5797 0000241F 66D1D8                  	rcr	ax, 1	; / 2
  5798 00002422 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5799 00002425 66AB                    	stosw 		; interpolated sample 2 (L)
  5800 00002427 C3                      	retn
  5801                                  
  5802                                  interpolating_2_16bit_mono:
  5803                                  	; 16/11/2023
  5804                                  	; ax = [previous_val]
  5805                                  	; dx = [next_val]
  5806                                  	; original-interpolated
  5807                                  
  5808 00002428 66AB                    	stosw		; original sample (L)
  5809 0000242A 66AB                    	stosw		; original sample (R)
  5810 0000242C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5811 0000242F 80C680                  	add	dh, 80h
  5812 00002432 6601D0                  	add	ax, dx
  5813 00002435 66D1D8                  	rcr	ax, 1
  5814 00002438 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5815 0000243B 66AB                    	stosw		; interpolated sample (L)
  5816 0000243D 66AB                    	stosw		; interpolated sample (R)
  5817 0000243F C3                      	retn
  5818                                  
  5819                                  interpolating_2_16bit_stereo:
  5820                                  	; 17/01/2025
  5821                                  	; 16/11/2023
  5822                                  	; bx = [previous_val_l]
  5823                                  	; ax = [previous_val_r]
  5824                                  	; [next_val_l]
  5825                                  	; dx = [next_val_r]
  5826                                  	; original-interpolated
  5827                                  
  5828 00002440 93                      	xchg	eax, ebx
  5829 00002441 66AB                    	stosw		; original sample (L)
  5830 00002443 93                      	xchg	eax, ebx
  5831 00002444 66AB                    	stosw		; original sample (R)
  5832 00002446 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  5833 00002449 80C680                  	add	dh, 80h
  5834 0000244C 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  5835 0000244F 66D1D8                  	rcr	ax, 1	; / 2
  5836                                  	; 17/01/2025
  5837 00002452 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5838                                  	;push	eax ; *	; interpolated sample (R)
  5839                                  	; 17/01/2025
  5840 00002455 C1E010                  	shl	eax, 16
  5841 00002458 66A1[0B280000]          	mov	ax, [next_val_l]
  5842 0000245E 80C480                  	add	ah, 80h
  5843 00002461 80C780                  	add	bh, 80h
  5844 00002464 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  5845 00002467 66D1D8                  	rcr	ax, 1	; / 2
  5846 0000246A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  5847                                  	; 17/01/2025
  5848                                  	;stosw 		; interpolated sample (L)
  5849                                  	;pop	eax ; *
  5850                                  	;sub	ah, 80h	; -32768 to +32767 format again
  5851                                  	;stosw 		; interpolated sample (R)
  5852                                  	; 17/01/2025
  5853 0000246D AB                      	stosd
  5854 0000246E C3                      	retn
  5855                                  
  5856                                  interpolating_5_8bit_mono:
  5857                                  	; 17/11/2023
  5858                                  	; al = [previous_val]
  5859                                  	; dl = [next_val]
  5860                                  	; original-interpltd-interpltd-interpltd-interpltd
  5861 0000246F 88C3                    	mov	bl, al
  5862 00002471 2C80                    	sub	al, 80h
  5863 00002473 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5864 00002477 66AB                    	stosw		; original sample (L)
  5865 00002479 66AB                    	stosw		; original sample (R)
  5866 0000247B 88D8                    	mov	al, bl
  5867 0000247D 00D0                    	add	al, dl
  5868 0000247F D0D8                    	rcr	al, 1
  5869 00002481 88C7                    	mov	bh, al	; interpolated middle (temporary)
  5870 00002483 00D8                    	add	al, bl  ; [previous_val]
  5871 00002485 D0D8                    	rcr	al, 1
  5872 00002487 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  5873 00002489 00D8                    	add	al, bl
  5874 0000248B D0D8                    	rcr	al, 1
  5875 0000248D 2C80                    	sub	al, 80h
  5876 0000248F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5877 00002493 66AB                    	stosw		; interpolated sample 1 (L)
  5878 00002495 66AB                    	stosw		; interpolated sample 1 (R)
  5879 00002497 88F8                    	mov	al, bh
  5880 00002499 00F0                    	add	al, dh
  5881 0000249B D0D8                    	rcr	al, 1
  5882 0000249D 2C80                    	sub	al, 80h
  5883 0000249F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5884 000024A3 66AB                    	stosw		; interpolated sample 2 (L)
  5885 000024A5 66AB                    	stosw		; interpolated sample 2 (R)
  5886 000024A7 88F8                    	mov	al, bh
  5887 000024A9 00D0                    	add	al, dl	; [next_val]
  5888 000024AB D0D8                    	rcr	al, 1
  5889 000024AD 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  5890 000024AF 00F8                    	add	al, bh
  5891 000024B1 D0D8                    	rcr	al, 1
  5892 000024B3 2C80                    	sub	al, 80h
  5893 000024B5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5894 000024B9 66AB                    	stosw		; interpolated sample 3 (L)
  5895 000024BB 66AB                    	stosw		; interpolated sample 3 (R)
  5896 000024BD 88F0                    	mov	al, dh
  5897 000024BF 00D0                    	add	al, dl
  5898 000024C1 D0D8                    	rcr	al, 1
  5899 000024C3 2C80                    	sub	al, 80h
  5900 000024C5 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5901 000024C9 66AB                    	stosw		; interpolated sample 4 (L)
  5902 000024CB 66AB                    	stosw		; interpolated sample 4 (R)
  5903 000024CD C3                      	retn
  5904                                  
  5905                                  interpolating_5_8bit_stereo:
  5906                                  	; 17/11/2023
  5907                                  	; al = [previous_val_l]
  5908                                  	; ah = [previous_val_r]
  5909                                  	; dl = [next_val_l]
  5910                                  	; dh = [next_val_r]
  5911                                  	; original-interpltd-interpltd-interpltd-interpltd
  5912 000024CE 89C3                    	mov	ebx, eax
  5913 000024D0 2C80                    	sub	al, 80h
  5914 000024D2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5915 000024D6 66AB                    	stosw		; original sample (L)
  5916 000024D8 88F8                    	mov	al, bh
  5917 000024DA 2C80                    	sub	al, 80h
  5918 000024DC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5919 000024E0 66AB                    	stosw		; original sample (R)
  5920 000024E2 52                      	push	edx ; *
  5921 000024E3 88D8                    	mov	al, bl
  5922 000024E5 00D0                    	add	al, dl	; [next_val_l]
  5923 000024E7 D0D8                    	rcr	al, 1
  5924 000024E9 50                      	push	eax ; ** ; al = interpolated middle (L) (temporary)
  5925 000024EA 00D8                    	add	al, bl	; [previous_val_l]
  5926 000024EC D0D8                    	rcr	al, 1
  5927 000024EE 86D8                    	xchg	al, bl
  5928 000024F0 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  5929 000024F2 D0D8                    	rcr	al, 1
  5930 000024F4 2C80                    	sub	al, 80h
  5931 000024F6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5932 000024FA 66AB                    	stosw		; interpolated sample 1 (L)
  5933 000024FC 88F8                    	mov	al, bh
  5934 000024FE 00F0                    	add	al, dh	; [next_val_r]
  5935 00002500 D0D8                    	rcr	al, 1
  5936 00002502 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  5937 00002503 00F8                    	add	al, bh	; [previous_val_r]
  5938 00002505 D0D8                    	rcr	al, 1
  5939 00002507 86F8                    	xchg	al, bh
  5940 00002509 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  5941 0000250B D0D8                    	rcr	al, 1
  5942 0000250D 2C80                    	sub	al, 80h
  5943 0000250F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5944 00002513 66AB                    	stosw		; interpolated sample 1 (R)
  5945 00002515 5A                      	pop	edx ; ***
  5946 00002516 58                      	pop	eax ; ** ; al = interpolated middle (L) (temporary)
  5947 00002517 86D8                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  5948 00002519 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  5949 0000251B D0D8                    	rcr	al, 1
  5950 0000251D 2C80                    	sub	al, 80h
  5951 0000251F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5952 00002523 66AB                    	stosw		; interpolated sample 2 (L)	
  5953 00002525 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  5954 00002527 86F8                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  5955 00002529 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  5956 0000252B D0D8                    	rcr	al, 1
  5957 0000252D 2C80                    	sub	al, 80h
  5958 0000252F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5959 00002533 66AB                    	stosw		; interpolated sample 2 (R)
  5960 00002535 5A                      	pop	edx ; *
  5961 00002536 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  5962 00002538 00D0                    	add	al, dl	; [next_val_l]
  5963 0000253A D0D8                    	rcr	al, 1
  5964 0000253C 86D8                    	xchg	al, bl	; al = interpolated middle (R) (temporary)
  5965 0000253E 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  5966 00002540 D0D8                    	rcr	al, 1
  5967 00002542 2C80                    	sub	al, 80h
  5968 00002544 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5969 00002548 66AB                    	stosw		; interpolated sample 3 (L)
  5970 0000254A 88F8                    	mov	al, bh	
  5971 0000254C 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  5972 0000254E D0D8                    	rcr	al, 1
  5973 00002550 86F8                    	xchg	al, bh	; al = interpolated middle (R)
  5974 00002552 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  5975 00002554 D0D8                    	rcr	al, 1
  5976 00002556 2C80                    	sub	al, 80h
  5977 00002558 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5978 0000255C 66AB                    	stosw		; interpolated sample 3 (R)
  5979 0000255E 88D8                    	mov	al, bl
  5980 00002560 00D0                    	add	al, dl	; [next_val_l]
  5981 00002562 D0D8                    	rcr	al, 1
  5982 00002564 2C80                    	sub	al, 80h
  5983 00002566 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5984 0000256A 66AB                    	stosw		; interpolated sample 4 (L)
  5985 0000256C 88F8                    	mov	al, bh
  5986 0000256E 00F0                    	add	al, dh	; [next_val_r]
  5987 00002570 D0D8                    	rcr	al, 1
  5988 00002572 2C80                    	sub	al, 80h
  5989 00002574 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  5990 00002578 66AB                    	stosw		; interpolated sample 4 (R)
  5991 0000257A C3                      	retn
  5992                                  
  5993                                  interpolating_4_8bit_mono:
  5994                                  	; 17/11/2023
  5995                                  	; al = [previous_val]
  5996                                  	; dl = [next_val]
  5997                                  	; original-interpolated-interpolated-interpolated
  5998 0000257B 88C3                    	mov	bl, al
  5999 0000257D 2C80                    	sub	al, 80h
  6000 0000257F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6001 00002583 66AB                    	stosw		; original sample (L)
  6002 00002585 66AB                    	stosw		; original sample (R)
  6003 00002587 88D8                    	mov	al, bl
  6004 00002589 00D0                    	add	al, dl
  6005 0000258B D0D8                    	rcr	al, 1
  6006 0000258D 86D8                    	xchg	al, bl  ; al = [previous_val]
  6007 0000258F 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  6008 00002591 D0D8                    	rcr	al, 1
  6009 00002593 2C80                    	sub	al, 80h
  6010 00002595 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6011 00002599 66AB                    	stosw		; interpolated sample 1 (L)
  6012 0000259B 66AB                    	stosw		; interpolated sample 1 (R)
  6013 0000259D 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  6014 0000259F 2C80                    	sub	al, 80h
  6015 000025A1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6016 000025A5 66AB                    	stosw		; interpolated sample 2 (L)
  6017 000025A7 66AB                    	stosw		; interpolated sample 2 (R)
  6018 000025A9 88D8                    	mov	al, bl
  6019 000025AB 00D0                    	add	al, dl	; [next_val]
  6020 000025AD D0D8                    	rcr	al, 1
  6021 000025AF 2C80                    	sub	al, 80h
  6022 000025B1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6023 000025B5 66AB                    	stosw		; interpolated sample 3 (L)
  6024 000025B7 66AB                    	stosw		; interpolated sample 3 (R)
  6025 000025B9 C3                      	retn
  6026                                  
  6027                                  interpolating_4_8bit_stereo:
  6028                                  	; 17/11/2023
  6029                                  	; al = [previous_val_l]
  6030                                  	; ah = [previous_val_r]
  6031                                  	; dl = [next_val_l]
  6032                                  	; dh = [next_val_r]
  6033                                  	; original-interpolated-interpolated-interpolated
  6034 000025BA 89C3                    	mov	ebx, eax
  6035 000025BC 2C80                    	sub	al, 80h
  6036 000025BE 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6037 000025C2 66AB                    	stosw		; original sample (L)
  6038 000025C4 88F8                    	mov	al, bh
  6039 000025C6 2C80                    	sub	al, 80h
  6040 000025C8 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6041 000025CC 66AB                    	stosw		; original sample (R)
  6042 000025CE 88D8                    	mov	al, bl
  6043 000025D0 00D0                    	add	al, dl	; [next_val_l]
  6044 000025D2 D0D8                    	rcr	al, 1
  6045 000025D4 86D8                    	xchg	al, bl	; al = [previous_val_l]
  6046 000025D6 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  6047 000025D8 D0D8                    	rcr	al, 1
  6048 000025DA 2C80                    	sub	al, 80h
  6049 000025DC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6050 000025E0 66AB                    	stosw		; interpolated sample 1 (L)
  6051 000025E2 88F8                    	mov	al, bh
  6052 000025E4 00F0                    	add	al, dh	; [next_val_r]
  6053 000025E6 D0D8                    	rcr	al, 1
  6054 000025E8 86F8                    	xchg	al, bh	; al = [previous_val_h]
  6055 000025EA 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  6056 000025EC D0D8                    	rcr	al, 1
  6057 000025EE 2C80                    	sub	al, 80h
  6058 000025F0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6059 000025F4 66AB                    	stosw		; interpolated sample 1 (R)
  6060 000025F6 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  6061 000025F8 2C80                    	sub	al, 80h
  6062 000025FA 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6063 000025FE 66AB                    	stosw		; interpolated sample 2 (L)
  6064 00002600 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  6065 00002602 2C80                    	sub	al, 80h
  6066 00002604 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6067 00002608 66AB                    	stosw		; interpolated sample 2 (L)
  6068 0000260A 88D8                    	mov	al, bl
  6069 0000260C 00D0                    	add	al, dl	; [next_val_l]
  6070 0000260E D0D8                    	rcr	al, 1
  6071 00002610 2C80                    	sub	al, 80h
  6072 00002612 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6073 00002616 66AB                    	stosw		; interpolated sample 3 (L)
  6074 00002618 88F8                    	mov	al, bh
  6075 0000261A 00F0                    	add	al, dh	; [next_val_r]
  6076 0000261C D0D8                    	rcr	al, 1
  6077 0000261E 2C80                    	sub	al, 80h
  6078 00002620 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  6079 00002624 66AB                    	stosw		; interpolated sample 3 (R)
  6080 00002626 C3                      	retn
  6081                                  
  6082                                  interpolating_5_16bit_mono:
  6083                                  	; 18/11/2023
  6084                                  	; ax = [previous_val]
  6085                                  	; dx = [next_val]
  6086                                  	; original-interpltd-interpltd-interpltd-interpltd
  6087 00002627 66AB                    	stosw		; original sample (L)
  6088 00002629 66AB                    	stosw		; original sample (R)
  6089 0000262B 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  6090 0000262E 89C3                    	mov	ebx, eax ; [previous_val]
  6091 00002630 80C680                  	add	dh, 80h
  6092 00002633 6601D0                  	add	ax, dx
  6093 00002636 66D1D8                  	rcr	ax, 1
  6094 00002639 50                      	push	eax ; *	; interpolated middle (temporary)
  6095 0000263A 6601D8                  	add	ax, bx	; interpolated middle + [previous_val]
  6096 0000263D 66D1D8                  	rcr	ax, 1
  6097 00002640 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  6098 00002641 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  6099 00002644 66D1D8                  	rcr	ax, 1	
  6100 00002647 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6101 0000264A 66AB                    	stosw 		; interpolated sample 1 (L)
  6102 0000264C 66AB                    	stosw		; interpolated sample 1 (R)
  6103 0000264E 58                      	pop	eax ; **
  6104 0000264F 5B                      	pop	ebx ; *
  6105 00002650 6601D8                  	add	ax, bx	; 1st quarter + middle
  6106 00002653 66D1D8                  	rcr	ax, 1	; / 2
  6107 00002656 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  6108 00002659 66AB                    	stosw		; interpolated sample 2 (L)
  6109 0000265B 66AB                    	stosw		; interpolated sample 2 (R)
  6110 0000265D 89D8                    	mov	eax, ebx
  6111 0000265F 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  6112 00002662 66D1D8                  	rcr	ax, 1
  6113 00002665 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  6114 00002666 6601D8                  	add	ax, bx	; + interpolated middle
  6115 00002669 66D1D8                  	rcr	ax, 1
  6116 0000266C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6117 0000266F 66AB                    	stosw		; interpolated sample 3 (L)
  6118 00002671 66AB                    	stosw		; interpolated sample 3 (R)
  6119 00002673 58                      	pop	eax ; *
  6120 00002674 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  6121 00002677 66D1D8                  	rcr	ax, 1	; / 2
  6122 0000267A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6123 0000267D 66AB                    	stosw		; interpolated sample 4 (L)
  6124 0000267F 66AB                    	stosw		; interpolated sample 4 (R)
  6125 00002681 C3                      	retn
  6126                                  
  6127                                  interpolating_5_16bit_stereo:
  6128                                  	; 18/11/2023
  6129                                  	; bx = [previous_val_l]
  6130                                  	; ax = [previous_val_r]
  6131                                  	; [next_val_l]
  6132                                  	; [next_val_r]
  6133                                  	; original-interpltd-interpltd-interpltd-interpltd
  6134 00002682 51                      	push	ecx ; !
  6135 00002683 93                      	xchg	eax, ebx
  6136 00002684 66AB                    	stosw		; original sample (L)
  6137 00002686 93                      	xchg	eax, ebx
  6138 00002687 66AB                    	stosw		; original sample (R)
  6139 00002689 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  6140 0000268C 50                      	push	eax ; *	; [previous_val_r]
  6141 0000268D 80C780                  	add	bh, 80h
  6142 00002690 8005[0C280000]80        	add	byte [next_val_l+1], 80h
  6143 00002697 66A1[0B280000]          	mov	ax, [next_val_l]
  6144 0000269D 6601D8                  	add	ax, bx	; [previous_val_l]
  6145 000026A0 66D1D8                  	rcr	ax, 1
  6146 000026A3 89C1                    	mov	ecx, eax ; interpolated middle (L)
  6147 000026A5 6601D8                  	add	ax, bx
  6148 000026A8 66D1D8                  	rcr	ax, 1
  6149 000026AB 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)
  6150 000026AD 6601D8                  	add	ax, bx	; [previous_val_l]
  6151 000026B0 66D1D8                  	rcr	ax, 1
  6152 000026B3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6153 000026B6 66AB                    	stosw 		; interpolated sample 1 (L)
  6154 000026B8 89C8                    	mov	eax, ecx
  6155 000026BA 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L)
  6156 000026BD 66D1D8                  	rcr	ax, 1	; / 2
  6157 000026C0 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  6158 000026C2 5A                      	pop	edx ; *	; [previous_val_r]
  6159 000026C3 89D0                    	mov	eax, edx
  6160 000026C5 8005[0E280000]80        	add	byte [next_val_r+1], 80h
  6161 000026CC 660305[0D280000]        	add	ax, [next_val_r]
  6162 000026D3 66D1D8                  	rcr	ax, 1
  6163 000026D6 50                      	push	eax ; *	; interpolated middle (R)
  6164 000026D7 6601D0                  	add	ax, dx
  6165 000026DA 66D1D8                  	rcr	ax, 1
  6166 000026DD 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  6167 000026DE 6601D0                  	add	ax, dx	; [previous_val_r]
  6168 000026E1 66D1D8                  	rcr	ax, 1
  6169 000026E4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6170 000026E7 66AB                    	stosw 		; interpolated sample 1 (R)
  6171 000026E9 89D8                    	mov	eax, ebx
  6172 000026EB 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6173 000026EE 66AB                    	stosw 		; interpolated sample 2 (L)
  6174 000026F0 58                      	pop	eax ; **
  6175 000026F1 5A                      	pop	edx ; *
  6176 000026F2 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  6177 000026F5 66D1D8                  	rcr	ax, 1	; / 2
  6178 000026F8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6179 000026FB 66AB                    	stosw 		; interpolated sample 2 (R)
  6180 000026FD 89C8                    	mov	eax, ecx
  6181 000026FF 660305[0B280000]        	add	ax, [next_val_l]
  6182 00002706 66D1D8                  	rcr	ax, 1
  6183 00002709 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  6184 0000270A 6601C8                  	add	ax, cx	; interpolated middle (L)
  6185 0000270D 66D1D8                  	rcr	ax, 1
  6186 00002710 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6187 00002713 66AB                    	stosw 		; interpolated sample 3 (L)
  6188 00002715 89D0                    	mov	eax, edx
  6189 00002717 660305[0D280000]        	add	ax, [next_val_r]
  6190 0000271E 66D1D8                  	rcr	ax, 1
  6191 00002721 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  6192 00002722 6601D0                  	add	ax, dx	; interpolated middle (R)
  6193 00002725 66D1D8                  	rcr	ax, 1
  6194 00002728 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6195 0000272B 66AB                    	stosw 		; interpolated sample 3 (R)
  6196 0000272D 5B                      	pop	ebx ; **
  6197 0000272E 58                      	pop	eax ; *
  6198 0000272F 660305[0B280000]        	add	ax, [next_val_l]
  6199 00002736 66D1D8                  	rcr	ax, 1
  6200 00002739 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6201 0000273C 66AB                    	stosw 		; interpolated sample 4 (L)
  6202 0000273E 89D8                    	mov	eax, ebx	
  6203 00002740 660305[0D280000]        	add	ax, [next_val_r]
  6204 00002747 66D1D8                  	rcr	ax, 1
  6205 0000274A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6206 0000274D 66AB                    	stosw 		; interpolated sample 4 (R)
  6207 0000274F 59                      	pop	ecx ; !
  6208 00002750 C3                      	retn
  6209                                  
  6210                                  interpolating_4_16bit_mono:
  6211                                  	; 18/11/2023
  6212                                  	; ax = [previous_val]
  6213                                  	; dx = [next_val]
  6214                                  	; 02/02/2025
  6215                                  	; original-interpolated-interpolated-interpolated
  6216                                  
  6217 00002751 66AB                    	stosw		; original sample (L)
  6218 00002753 66AB                    	stosw		; original sample (R)
  6219 00002755 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  6220 00002758 89C3                    	mov	ebx, eax ; [previous_val]
  6221 0000275A 80C680                  	add	dh, 80h
  6222 0000275D 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  6223 00002760 66D1D8                  	rcr	ax, 1
  6224 00002763 93                      	xchg	eax, ebx
  6225 00002764 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  6226 00002767 66D1D8                  	rcr	ax, 1
  6227 0000276A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6228 0000276D 66AB                    	stosw 		; interpolated sample 1 (L)
  6229 0000276F 66AB                    	stosw		; interpolated sample 1 (R)
  6230 00002771 89D8                    	mov	eax, ebx ; interpolated middle
  6231 00002773 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6232 00002776 66AB                    	stosw 		; interpolated sample 2 (L)
  6233 00002778 66AB                    	stosw		; interpolated sample 2 (R)
  6234 0000277A 89D8                    	mov	eax, ebx
  6235 0000277C 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  6236 0000277F 66D1D8                  	rcr	ax, 1
  6237 00002782 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6238 00002785 66AB                    	stosw		; interpolated sample 3 (L)
  6239 00002787 66AB                    	stosw		; interpolated sample 3 (R)
  6240 00002789 C3                      	retn
  6241                                  
  6242                                  interpolating_4_16bit_stereo:
  6243                                  	; 18/11/2023
  6244                                  	; bx = [previous_val_l]
  6245                                  	; ax = [previous_val_r]
  6246                                  	; [next_val_l]
  6247                                  	; [next_val_r]
  6248                                  	; original-interpolated-interpolated-interpolated
  6249 0000278A 93                      	xchg	eax, ebx
  6250 0000278B 66AB                    	stosw		; original sample (L)
  6251 0000278D 93                      	xchg	eax, ebx
  6252 0000278E 66AB                    	stosw		; original sample (R)
  6253 00002790 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  6254 00002793 89C2                    	mov	edx, eax ; [previous_val_r]
  6255 00002795 80C780                  	add	bh, 80h
  6256 00002798 8005[0C280000]80        	add	byte [next_val_l+1], 80h
  6257 0000279F 66A1[0B280000]          	mov	ax, [next_val_l]
  6258 000027A5 6601D8                  	add	ax, bx	; [previous_val_l]
  6259 000027A8 66D1D8                  	rcr	ax, 1
  6260 000027AB 93                      	xchg	eax, ebx
  6261 000027AC 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  6262 000027AF 66D1D8                  	rcr	ax, 1
  6263 000027B2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6264 000027B5 66AB                    	stosw 		; interpolated sample 1 (L)
  6265 000027B7 8005[0E280000]80        	add	byte [next_val_r+1], 80h
  6266 000027BE 89D0                    	mov	eax, edx ; [previous_val_r]
  6267 000027C0 660305[0D280000]        	add	ax, [next_val_r]
  6268 000027C7 66D1D8                  	rcr	ax, 1
  6269 000027CA 92                      	xchg	eax, edx
  6270 000027CB 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  6271 000027CE 66D1D8                  	rcr	ax, 1
  6272 000027D1 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6273 000027D4 66AB                    	stosw 		; interpolated sample 1 (R)
  6274 000027D6 89D8                    	mov	eax, ebx
  6275 000027D8 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6276 000027DB 66AB                    	stosw 		; interpolated sample 2 (L)
  6277 000027DD 89D0                    	mov	eax, edx
  6278 000027DF 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6279 000027E2 66AB                    	stosw 		; interpolated sample 2 (R)
  6280 000027E4 89D8                    	mov	eax, ebx
  6281 000027E6 660305[0B280000]        	add	ax, [next_val_l]
  6282 000027ED 66D1D8                  	rcr	ax, 1
  6283 000027F0 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6284 000027F3 66AB                    	stosw 		; interpolated sample 3 (L)
  6285 000027F5 89D0                    	mov	eax, edx
  6286 000027F7 660305[0D280000]        	add	ax, [next_val_r]
  6287 000027FE 66D1D8                  	rcr	ax, 1
  6288 00002801 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  6289 00002804 66AB                    	stosw 		; interpolated sample 3 (R)
  6290 00002806 C3                      	retn
  6291                                  
  6292                                  ; 13/11/2023
  6293                                  previous_val:
  6294 00002807 0000                    previous_val_l: dw 0
  6295 00002809 0000                    previous_val_r: dw 0
  6296                                  next_val:
  6297 0000280B 0000                    next_val_l: dw 0
  6298 0000280D 0000                    next_val_r: dw 0
  6299                                  
  6300                                  ; 16/11/2023
  6301 0000280F 00                      faz:	db 0
  6302                                  
  6303                                  ; --------------------------------------------------------
  6304                                  ; 14/11/2024 - Erdogan Tan
  6305                                  ; --------------------------------------------------------
  6306                                  
  6307                                  	; 07/12/2024
  6308                                  	; 01/12/2024 (32bit registers)
  6309                                  	; 29/11/2024
  6310                                  checkUpdateEvents:
  6311 00002810 E8B9010000              	call	check4keyboardstop
  6312 00002815 7272                    	jc	short c4ue_ok
  6313                                  
  6314                                  	; 18/11/2024
  6315 00002817 50                      	push	eax ; *
  6316 00002818 09C0                    	or	eax, eax
  6317 0000281A 0F84D1000000            	jz	c4ue_cpt
  6318                                  
  6319                                  	; 18/11/2024
  6320 00002820 3C20                    	cmp	al, 20h ; SPACE (spacebar) ; pause/play
  6321 00002822 7543                    	jne	short c4ue_chk_s
  6322 00002824 803D[5C380000]00        	cmp	byte [stopped], 0
  6323 0000282B 7714                    	ja	short c4ue_chk_ps
  6324                                  	; pause
  6325 0000282D E8CCE4FFFF              	call	ac97_pause
  6326                                  	; 21/11/2024
  6327 00002832 A0[5D380000]            	mov	al, [tLO]
  6328 00002837 A2[5E380000]            	mov	byte [tLP], al
  6329 0000283C E9B0000000              	jmp	c4ue_cpt
  6330                                  c4ue_chk_ps:
  6331 00002841 803D[5C380000]01        	cmp	byte [stopped], 1
  6332 00002848 770A                    	ja	short c4ue_replay
  6333                                  	; continue to play (after a pause)
  6334 0000284A E8B8E4FFFF              	call	ac97_play 
  6335 0000284F E99D000000              	jmp	c4ue_cpt
  6336                                  c4ue_replay:
  6337                                  	; 19/11/2024
  6338 00002854 58                      	pop	eax ; *
  6339 00002855 58                      	pop	eax ; return address
  6340                                  	; 07/02/2024
  6341                                  	;mov	al, [volume]
  6342                                  	;call	SetmasterVolume
  6343 00002856 C605[5C380000]00        	mov	byte [stopped], 0
  6344 0000285D E812040000              	call	move_to_beginning
  6345                                  	;jmp	PlayWav
  6346                                  	; 07/12/2024
  6347 00002862 E9F2DDFFFF              	jmp	RePlayWav
  6348                                  
  6349                                  c4ue_chk_s:
  6350 00002867 3C53                    	cmp	al, 'S'	; stop
  6351 00002869 751F                    	jne	short c4ue_chk_fb
  6352 0000286B 803D[5C380000]00        	cmp	byte [stopped], 0
  6353 00002872 777D                    	ja	c4ue_cpt ; Already stopped/paused
  6354 00002874 E86CE4FFFF              	call	ac97_stop
  6355                                  	; 19/11/2024
  6356 00002879 C605[5D380000]00        	mov	byte [tLO], 0
  6357                                  	; 21/11/2024
  6358 00002880 C605[5E380000]30        	mov	byte [tLP], '0'
  6359 00002887 EB68                    	jmp	c4ue_cpt
  6360                                  
  6361                                  	; 01/12/2024
  6362                                  	; 18/11/2024
  6363                                  c4ue_ok:
  6364 00002889 C3                      	retn
  6365                                  
  6366                                  c4ue_chk_fb:
  6367                                  	; 17/11/2024
  6368 0000288A 3C46                    	cmp	al, 'F'
  6369 0000288C 7507                    	jne	short c4ue_chk_b
  6370 0000288E E8B9030000              	call 	Player_ProcessKey_Forwards
  6371 00002893 EB5C                    	jmp	c4ue_cpt
  6372                                  
  6373                                  c4ue_chk_b:
  6374 00002895 3C42                    	cmp	al, 'B'
  6375                                  	;;jne	short c4ue_cpt
  6376                                  	; 19/11/2024
  6377                                  	;jne	short c4ue_chk_h
  6378                                  	; 25/12/2024
  6379                                  	; 29/11/2024
  6380 00002897 7507                    	jne	short c4ue_chk_n
  6381 00002899 E8AA030000              	call 	Player_ProcessKey_Backwards
  6382 0000289E EB51                    	jmp	short c4ue_cpt
  6383                                  
  6384                                  	;;;
  6385                                  	; 25/12/2024
  6386                                  	; 29/11/2024
  6387                                  c4ue_chk_n:
  6388 000028A0 3C4E                    	cmp	al, 'N'
  6389 000028A2 7404                    	je	short c4ue_nps
  6390                                  c4ue_chk_p:
  6391 000028A4 3C50                    	cmp	al, 'P'
  6392 000028A6 7509                    	jne	short c4ue_chk_h
  6393                                  c4ue_nps:
  6394 000028A8 C605[5C380000]03        	mov	byte [stopped], 3
  6395 000028AF EB40                    	jmp	short c4ue_cpt
  6396                                  	;;;
  6397                                  
  6398                                  c4ue_chk_h:
  6399                                  	; 19/11/2024
  6400 000028B1 3C48                    	cmp	al, 'H'
  6401 000028B3 750E                    	jne	short c4ue_chk_cr
  6402 000028B5 C605[5F380000]00        	mov	byte [wpoints], 0
  6403 000028BC E8D4E5FFFF              	call 	write_ac97_pci_dev_info
  6404                                  	; 30/12/2024
  6405 000028C1 EB2E                    	jmp	short c4ue_cpt
  6406                                  c4ue_chk_cr:
  6407                                  	;;;
  6408                                  	; 24/12/2024 (wave lighting points option)
  6409                                  	;mov	ah, [wpoints]
  6410                                  	; 30/12/2024
  6411 000028C3 31DB                    	xor	ebx, ebx
  6412 000028C5 8A1D[5F380000]          	mov	bl, [wpoints]
  6413 000028CB 3C47                    	cmp	al, 'G'
  6414 000028CD 7406                    	je	short c4ue_g
  6415                                  	; 19/11/2024
  6416 000028CF 3C0D                    	cmp	al, 0Dh ; ENTER/CR key
  6417 000028D1 751E                    	jne	short c4ue_cpt
  6418                                  	; 23/11/2024
  6419                                  	;xor	ebx, ebx
  6420                                  	; 30/12/2024
  6421                                  	;mov	bl, ah ; 24/12/2024
  6422 000028D3 FEC3                    	inc	bl
  6423                                  c4ue_g:	; 30/12/2024
  6424 000028D5 80E307                  	and	bl, 07h
  6425 000028D8 7501                    	jnz	short c4ue_sc
  6426 000028DA 43                      	inc	ebx
  6427                                  c4ue_sc:
  6428 000028DB 881D[5F380000]          	mov	[wpoints], bl
  6429                                  	; 30/12/2024
  6430 000028E1 8A83[3F330000]          	mov	al, [ebx+colors-1] ; 1 to 7
  6431                                  	; 24/12/2024
  6432 000028E7 A2[47330000]            	mov	[ccolor], al
  6433                                  	; 30/12/2024
  6434 000028EC E8B2030000              	call	clear_window
  6435                                  	;;;
  6436                                  c4ue_cpt:
  6437                                  	; 24/12/2024
  6438                                  	; 18/11/2024
  6439 000028F1 59                      	pop	ecx ; *
  6440                                  	;;;
  6441                                  	; 29/12/2024
  6442                                  	; 24/12/2024 (skip wave lighting if data is not loaded yet)
  6443                                  	;cmp	byte [SRB], 0
  6444                                  	;ja	short c4ue_vb_ok
  6445                                  	;;;
  6446                                  	; 01/12/2024 (TRDOS 386)
  6447                                  	sys	_time, 4 ; get timer ticks (18.2 ticks/second),
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 000028F2 BB04000000          <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 000028F7 B80D000000          <1>  mov eax, %1
   130                              <1> 
   131 000028FC CD40                <1>  int 40h
  6448                                  	; 24/12/2024
  6449                                  	; 18/11/2024
  6450                                  	;pop	ecx ; *
  6451                                  	; 01/12/2024
  6452 000028FE 3B05[28390000]          	cmp	eax, [timerticks]
  6453                                  	;je	short c4ue_ok
  6454                                  	; 18/11/2024
  6455 00002904 7408                    	je	short c4ue_skip_utt
  6456                                  c4ue_utt:	
  6457                                  	; 01/12/2024
  6458 00002906 A3[28390000]            	mov	[timerticks], eax
  6459 0000290B EB05                    	jmp	short c4ue_cpt_@
  6460                                  
  6461                                  	; 30/12/2024
  6462                                  c4ue_vb_ok:
  6463 0000290D C3                      	retn
  6464                                  
  6465                                  c4ue_skip_utt:
  6466                                  	; 18/11/2024
  6467 0000290E 21C9                    	and	ecx, ecx
  6468 00002910 74FB                    	jz	short c4ue_vb_ok
  6469                                  c4ue_cpt_@:
  6470                                  	; 18/11/2024
  6471 00002912 803D[5C380000]00        	cmp	byte [stopped], 0
  6472 00002919 77F2                    	ja	short c4ue_vb_ok
  6473                                  	
  6474 0000291B E8C2010000              	call	CalcProgressTime
  6475                                  
  6476                                  	;cmp	ax, [ProgressTime]
  6477                                  	; 01/12/2024
  6478 00002920 3B05[1C390000]          	cmp	eax, [ProgressTime]
  6479                                  	;je	short c4ue_vb_ok
  6480                                  			; same second, no need to update
  6481                                  	; 23/11/2024
  6482 00002926 7405                    	je	short c4ue_uvb
  6483                                  
  6484                                  	;call	UpdateProgressTime
  6485                                  	;call	UpdateProgressBar@
  6486 00002928 E89F020000              	call	UpdateProgressBar
  6487                                  
  6488                                  	; 23/11/2024
  6489                                  c4ue_uvb:
  6490 0000292D 803D[5F380000]00        	cmp	byte [wpoints], 0
  6491 00002934 76D7                    	jna	short c4ue_vb_ok
  6492                                  
  6493                                  	; 30/12/2024
  6494                                  	;call	UpdateWavePoints
  6495                                  	;retn
  6496                                  
  6497                                  ; --------------------------------------------------------
  6498                                  ; 27/12/2024 - Erdogan Tan
  6499                                  ; --------------------------------------------------------
  6500                                  
  6501                                  	; 30/12/2024 (cgaplay.s)
  6502                                  	;  * 320*200 pixels, 256 colors
  6503                                  	;  * 64 volume levels
  6504                                  	; 29/12/2024
  6505                                  	; 27/12/2024 (DMA Buffer Tracking)
  6506                                  	; 26/12/2024
  6507                                  	; 24/12/2024
  6508                                  UpdateWavePoints:
  6509 00002936 BE[5C330000]            	mov	esi, prev_points
  6510 0000293B 833E00                  	cmp	dword [esi], 0
  6511 0000293E 740B                    	jz	short lights_off_ok
  6512                                  	;mov	ecx, 640
  6513                                  	; 30/12/2024
  6514 00002940 B940010000              	mov	ecx, 320
  6515                                  light_off:
  6516 00002945 AD                      	lodsd
  6517                                  	; eax = wave point (lighting point) address
  6518 00002946 C60000                  	mov	byte [eax], 0 ; black point (light off)
  6519 00002949 E2FA                    	loop	light_off	
  6520                                  
  6521                                  lights_off_ok:
  6522                                  	; 29/12/2024
  6523 0000294B 803D[5D380000]32        	cmp	byte [tLO],'2'
  6524 00002952 7507                    	jne	short lights_on_buff_1
  6525                                  lights_on_buff_2:
  6526 00002954 BA[00500100]            	mov	edx, WAVBUFFER_2
  6527 00002959 EB05                    	jmp	short lights_on
  6528                                  lights_on_buff_1:
  6529 0000295B BA[00500000]            	mov	edx, WAVBUFFER_1
  6530                                  lights_on:
  6531 00002960 3915[64380000]          	cmp	[pbuf_s], edx
  6532 00002966 7520                    	jne	short lights_on_2
  6533 00002968 8B1D[48330000]          	mov	ebx, [wpoints_dif]
  6534 0000296E 8B35[60380000]          	mov	esi, [pbuf_o]
  6535 00002974 8B0D[14390000]          	mov	ecx, [buffersize] ; bytes
  6536 0000297A 29D9                    	sub	ecx, ebx ; sub ecx, [wpoints_dif]
  6537 0000297C 01DE                    	add	esi, ebx
  6538 0000297E 7204                    	jc	short lights_on_1
  6539 00002980 39CE                    	cmp	esi, ecx
  6540 00002982 760C                    	jna	short lights_on_3
  6541                                  lights_on_1:
  6542 00002984 89CE                    	mov	esi, ecx
  6543 00002986 EB08                    	jmp	short lights_on_3
  6544                                  
  6545                                  lights_on_2:
  6546                                  	; 29/12/2024
  6547 00002988 8915[64380000]          	mov	[pbuf_s], edx
  6548 0000298E 31F6                    	xor	esi, esi ; 0
  6549                                  lights_on_3:
  6550 00002990 8935[60380000]          	mov	[pbuf_o], esi
  6551                                  	; 29/12/2024
  6552                                  	;add	esi, [pbuf_s]
  6553 00002996 01D6                    	add	esi, edx
  6554                                  	;mov	ecx, 640
  6555                                  	; 30/12/2024
  6556 00002998 B940010000              	mov	ecx, 320
  6557 0000299D 89CD                    	mov	ebp, ecx
  6558                                  	; 26/12/2024
  6559 0000299F BF[5C330000]            	mov	edi, prev_points
  6560 000029A4 8B1D[4C330000]          	mov	ebx, [graphstart] ; start (top) line
  6561                                  lights_on_4:
  6562 000029AA 31C0                    	xor	eax, eax ; 0
  6563 000029AC 66AD                    	lodsw	; left
  6564 000029AE 80C480                  	add	ah, 80h
  6565 000029B1 89C2                    	mov	edx, eax
  6566 000029B3 66AD                    	lodsw	; right
  6567                                  	;add	ax, dx
  6568 000029B5 80C480                  	add	ah, 80h
  6569                                  	;;shr	eax, 9	; 128 volume levels
  6570                                  	; 01/01/2024
  6571 000029B8 01D0                    	add	eax, edx
  6572                                  	;;shr	eax, 10	; (L+R/2) & 128 volume levels
  6573                                  	;shr	eax, 9	; (L+R/2) & 256 volume levels
  6574                                  	; 30/12/2024
  6575 000029BA C1E80B                  	shr	eax, 11	; (L+R/2) & 64 volume levels
  6576                                  	; * 320 row  ; 30/12/2024
  6577 000029BD F7E5                    	mul	ebp	; * 640 (row) 
  6578 000029BF 01D8                    	add	eax, ebx ; + column
  6579 000029C1 8A15[47330000]          	mov	dl, [ccolor]
  6580 000029C7 8810                    	mov	[eax], dl ; pixel (light on) color
  6581 000029C9 AB                      	stosd		; save light on addr in prev_points
  6582 000029CA 43                      	inc	ebx
  6583 000029CB E2DD                    	loop	lights_on_4
  6584 000029CD C3                      	retn
  6585                                  
  6586                                  ; --------------------------------------------------------
  6587                                  ; 19/05/2024 - (playwav4.asm) ich_wav4.asm
  6588                                  ; --------------------------------------------------------
  6589                                  
  6590                                  	; 29/12/2024
  6591                                  	; 25/12/2024
  6592                                  	; 07/12/2024
  6593                                  	; 01/12/2024 (TRDOS 386)
  6594                                  	; 29/11/2024
  6595                                  check4keyboardstop:
  6596                                  	; 19/05/2024
  6597                                  	; 08/11/2023
  6598                                  	; 04/11/2023
  6599 000029CE B401                    	mov	ah, 1
  6600                                  	;int	16h
  6601                                  	; 01/12/2024 (TRDOS 386 keyboard interrupt)
  6602 000029D0 CD32                    	int	32h
  6603                                  	;clc
  6604 000029D2 7433                    	jz	short _cksr
  6605                                  
  6606 000029D4 30E4                    	xor	ah, ah
  6607                                  	;int	16h
  6608                                  	; 01/12/2024 (TRDOS 386 keyboard interrupt)
  6609 000029D6 CD32                    	int	32h
  6610                                  
  6611                                  	; 25/12/2024
  6612                                  	; 29/11/2024
  6613                                  	;mov	[command], al
  6614                                  
  6615                                  	;;;
  6616                                  	; 19/05/2024 (change PCM out volume)
  6617 000029D8 3C2B                    	cmp	al, '+'
  6618 000029DA 750D                    	jne	short p_1
  6619                                  	
  6620 000029DC A0[312A0000]            	mov	al, [volume]
  6621 000029E1 3C00                    	cmp	al, 0
  6622 000029E3 7624                    	jna	short p_3
  6623 000029E5 FEC8                    	dec	al
  6624 000029E7 EB0F                    	jmp	short p_2
  6625                                  p_1:
  6626 000029E9 3C2D                    	cmp	al, '-'
  6627 000029EB 751D                    	jne	short p_4
  6628                                  
  6629 000029ED A0[312A0000]            	mov	al, [volume]
  6630 000029F2 3C1F                    	cmp	al, 31
  6631 000029F4 7313                    	jnb	short p_3
  6632 000029F6 FEC0                    	inc	al
  6633                                  p_2:
  6634 000029F8 A2[312A0000]            	mov	[volume], al
  6635                                  	; 29/12/2024
  6636                                  	; 14/11/2024
  6637 000029FD E820DEFFFF              	call	SetPCMOutVolume
  6638                                  	; 15/11/2024 (QEMU)
  6639                                  	; 07/12/2024
  6640                                  	;call	SetMasterVolume
  6641                                  	;call	UpdateVolume
  6642                                  	;;clc
  6643                                  	;retn
  6644 00002A02 E97C010000              	jmp	UpdateVolume
  6645                                  	;mov	ah, al
  6646                                  	;mov    dx, [NAMBAR]
  6647                                    	;;add   dx, CODEC_MASTER_VOL_REG
  6648                                  	;add	dx, CODEC_PCM_OUT_REG
  6649                                  	;out    dx, ax
  6650                                  	;
  6651                                  	;call   delay1_4ms
  6652                                          ;call   delay1_4ms
  6653                                          ;call   delay1_4ms
  6654                                          ;call   delay1_4ms
  6655                                  _cksr:		; 19/05/2024
  6656                                  	; 18/12/2024
  6657 00002A07 31C0                    	xor	eax, eax
  6658                                  	;clc
  6659                                  p_3:
  6660 00002A09 C3                      	retn
  6661                                  p_4:
  6662                                  	; 17/11/2024
  6663 00002A0A 80FC01                  	cmp	ah, 01h  ; ESC
  6664 00002A0D 7419                        	je	short p_q
  6665                                  	;cmp	ax, 2E03h ; 21/12/2024 
  6666 00002A0F 3C03                    	cmp	al, 03h  ; CTRL+C
  6667 00002A11 7415                    	je	short p_q
  6668                                  
  6669                                  	; 18/11/2024
  6670 00002A13 3C20                    	cmp	al, 20h
  6671 00002A15 7419                    	je	short p_r
  6672                                  
  6673                                  	; 19/11/2024
  6674 00002A17 3C0D                    	cmp	al, 0Dh ; CR/ENTER
  6675 00002A19 7415                    	je	short p_r
  6676                                  
  6677 00002A1B 24DF                    	and	al, 0DFh
  6678                                  
  6679                                  	; 25/12/2024
  6680                                  	; 29/11/2024
  6681 00002A1D A2[6A380000]            	mov	[command], al
  6682                                  
  6683                                  	;cmp	al, 'B'
  6684                                  	;je	short p_r
  6685                                  	;cmp	al, 'F'
  6686                                  	;je	short p_r
  6687                                  
  6688                                  	; 29/11/2024
  6689                                  	;cmp	al, 'N'
  6690                                  	;je	short p_r
  6691                                  	;cmp	al, 'P'
  6692                                  	;je	short p_r
  6693                                  
  6694 00002A22 3C51                    	cmp	al, 'Q'
  6695                                  	;je	short p_q
  6696 00002A24 7409                    	je	short p_quit ; 29/11/2024
  6697                                  
  6698 00002A26 F8                      	clc
  6699 00002A27 C3                      	retn
  6700                                  
  6701                                  	;;;
  6702                                  ;_cskr:	
  6703                                  p_q:
  6704                                  	; 27/12/2024
  6705 00002A28 C605[6A380000]51        	mov	byte [command], 'Q'
  6706                                  p_quit:
  6707 00002A2F F9                      	stc
  6708                                  p_r:
  6709 00002A30 C3                      	retn
  6710                                  
  6711                                  ; 29/05/2024
  6712                                  ; 19/05/2024
  6713                                  volume: 
  6714                                  	;db	02h
  6715                                  ; 26/12/2024
  6716 00002A31 03                      	db	03h
  6717                                  
  6718                                  ; --------------------------------------------------------
  6719                                  
  6720                                  	; 31/12/2024 (int31h)
  6721                                  	; 30/12/2024
  6722                                  	; simulate cursor position in VGA mode 13h
  6723                                  	; ! for 320*200, 256 colors (1 byte/pixel) !
  6724                                  setCursorPosition:
  6725                                  	; dh = Row
  6726                                  	; dl = Column
  6727                                  
  6728                                  	; 31/12/2024
  6729 00002A32 B700                    	mov	bh, 0
  6730 00002A34 B402                    	mov	ah, 02h
  6731                                  	;int	10h
  6732 00002A36 CD31                    	int	31h
  6733 00002A38 C3                      	retn
  6734                                  
  6735                                  ; 31/12/2024
  6736                                  %if 0
  6737                                  	xor	eax, eax
  6738                                  	; row height is 8 pixels (8*8)
  6739                                  	mov	al, dh
  6740                                  	shl	eax, 3
  6741                                  	add	ax, 2	; top margin
  6742                                  	shl	eax, 16
  6743                                  	mov	al, dl	; * 8 ; character width = 8 pixels
  6744                                  	shl	ax, 3
  6745                                  			; hw = row, ax = column
  6746                                  	mov	[screenpos], eax
  6747                                  	; 22/12/2024
  6748                                  	xor	eax, eax
  6749                                  	retn
  6750                                  %endif
  6751                                  	
  6752                                  ; --------------------------------------------------------
  6753                                  ; 14/11/2024
  6754                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6755                                  
  6756                                  ;; NAME:	SetTotalTime
  6757                                  ;; DESCRIPTION: Calculates the total time in seconds in file
  6758                                  ;; INPUT:	DATA_SubchunkSize, WAVE_SampleRate, WAVE_BlockAlign
  6759                                  ;; OUTPUT:	CurrentTotalTime=Total time in seconds in file,
  6760                                  ;; 		Output on the screen of the total time in seconds
  6761                                  
  6762                                  	; 01/12/2024 (32 bit registers)
  6763                                  SetTotalTime:
  6764                                  	;; Calculate total seconds in file
  6765                                  	;mov	ax, [DATA_SubchunkSize]
  6766                                  	;mov	dx, [DATA_SubchunkSize + 2]
  6767                                  	;mov	bx, [WAVE_SampleRate]
  6768                                  	;div	bx
  6769                                  	;xor	dx, dx
  6770                                  	; 01/12/2024
  6771 00002A39 A1[94380000]            	mov	eax, [DATA_SubchunkSize]
  6772 00002A3E 0FB71D[84380000]        	movzx	ebx, word [WAVE_SampleRate]
  6773 00002A45 31D2                    	xor	edx, edx
  6774 00002A47 F7F3                    	div	ebx
  6775                                  
  6776                                  	;mov	bx, [WAVE_BlockAlign]
  6777                                  	;div	bx
  6778                                  	; 01/12/2024
  6779 00002A49 668B1D[8C380000]        	mov	bx, [WAVE_BlockAlign]
  6780 00002A50 31D2                    	xor	edx, edx
  6781 00002A52 F7F3                    	div	ebx
  6782                                  
  6783                                  	;mov	[TotalTime], ax
  6784 00002A54 A3[18390000]            	mov	[TotalTime], eax
  6785                                  
  6786 00002A59 B33C                    	mov	bl, 60
  6787 00002A5B F6F3                    	div	bl
  6788                                  
  6789                                  	;; al = minutes, ah = seconds
  6790 00002A5D 50                      	push	eax ; **
  6791 00002A5E 50                      	push	eax ; *
  6792                                  
  6793                                  	;mov	dh, 24
  6794                                  	; 21/12/2024 (640*480)
  6795                                  	;mov	dh, 32
  6796                                  	;mov	dl, 42
  6797                                  	; 30/12/2024 (320*200)
  6798 00002A5F B617                    	mov	dh, 23
  6799 00002A61 B216                    	mov	dl, 22
  6800 00002A63 E8CAFFFFFF              	call	setCursorPosition
  6801                                  
  6802 00002A68 58                      	pop	eax ; *
  6803 00002A69 30E4                    	xor	ah, ah
  6804 00002A6B BD02000000              	mov	ebp, 2
  6805 00002A70 E812000000              	call	PrintNumber
  6806                                  	
  6807                                  	;mov	dh, 24
  6808                                  	; 21/12/2024 (640*480)
  6809                                  	;mov	dh, 32
  6810                                  	;mov	dl, 45
  6811                                  	; 30/12/2024 (320*200)
  6812 00002A75 B617                    	mov	dh, 23
  6813 00002A77 B219                    	mov	dl, 25
  6814 00002A79 E8B4FFFFFF              	call	setCursorPosition
  6815                                  
  6816 00002A7E 58                      	pop	eax ; **
  6817 00002A7F 88E0                    	mov	al, ah
  6818 00002A81 30E4                    	xor	ah, ah
  6819                                  	; 21/12/2024
  6820 00002A83 66BD0200                	mov	bp, 2
  6821                                  	;jmp	short PrintNumber
  6822                                  
  6823                                  ; --------------------------------------------------------
  6824                                  
  6825                                  	; 31/12/2024 (int 31h)
  6826                                  	; 21/12/2024 (write numbers in VESA VBE graphics mode)
  6827                                  	; 01/12/2024 (32bit registers)
  6828                                  PrintNumber:
  6829                                  	; eax = binary number
  6830                                  	; ebp = digits
  6831                                  	;mov	esi, [screenpos]
  6832                                  		; hw = row, si = column
  6833 00002A87 BB0A000000              	mov	ebx, 10
  6834 00002A8C 31C9                    	xor	ecx, ecx
  6835                                  printNumber_CutNumber:
  6836 00002A8E 41                      	inc	ecx
  6837 00002A8F 31D2                    	xor	edx, edx
  6838 00002A91 F7F3                    	div	ebx
  6839 00002A93 52                      	push	edx
  6840 00002A94 39E9                    	cmp	ecx, ebp
  6841 00002A96 7402                    	je	short printNumber_printloop
  6842 00002A98 EBF4                    	jmp	printNumber_CutNumber
  6843                                  
  6844                                  printNumber_printloop:
  6845 00002A9A 58                      	pop	eax
  6846                                  	; 21/12/2024
  6847                                  	; ebp = count of digits
  6848                                  	; eax <= 9
  6849                                  
  6850 00002A9B 0430                    	add	al, '0'
  6851                                  	
  6852                                  	; esi = pixel position (hw = row, si = column)
  6853                                  	; eax = al = character
  6854                                  	;call	write_character
  6855                                  	; 22/12/2024
  6856 00002A9D E817010000              	call	write_character_white
  6857                                  
  6858 00002AA2 4D                      	dec	ebp
  6859 00002AA3 7402                     	jz	short printNumber_ok
  6860                                  	;add	esi, 8	; next column
  6861 00002AA5 EBF3                    	jmp	short printNumber_printloop
  6862                                  printNumber_ok:
  6863 00002AA7 C3                      	retn
  6864                                  
  6865                                  ; --------------------------------------------------------
  6866                                  
  6867                                  	; 14/11/2024 - Erdogan Tan
  6868                                  SetProgressTime:
  6869                                  	;; Calculate playing/progress seconds in file
  6870 00002AA8 E835000000              	call	CalcProgressTime
  6871                                  
  6872                                  	; 01/12/2024 (32bit registers)
  6873                                  UpdateProgressTime:
  6874                                  	; eax = (new) progress time 
  6875                                  
  6876 00002AAD A3[1C390000]            	mov	[ProgressTime], eax
  6877                                  
  6878 00002AB2 B33C                    	mov	bl, 60
  6879 00002AB4 F6F3                    	div	bl
  6880                                  
  6881                                  	;; al = minutes, ah = seconds
  6882 00002AB6 50                      	push	eax ; **
  6883 00002AB7 50                      	push	eax ; *
  6884                                  
  6885                                  	;mov	dh, 24
  6886                                  	; 21/12/2024 (640*480)
  6887                                  	;mov	dh, 32
  6888                                  	;mov	dl, 33
  6889                                  	; 30/12/2024 (320*200)
  6890 00002AB8 B617                    	mov	dh, 23
  6891 00002ABA B20D                    	mov	dl, 13
  6892 00002ABC E871FFFFFF              	call	setCursorPosition
  6893                                  
  6894 00002AC1 58                      	pop	eax ; *
  6895 00002AC2 30E4                    	xor	ah, ah
  6896 00002AC4 BD02000000              	mov	ebp, 2
  6897 00002AC9 E8B9FFFFFF              	call	PrintNumber
  6898                                  	
  6899                                  	;mov	dh, 24
  6900                                  	; 21/12/2024 (640*480)
  6901                                  	;mov	dh, 32
  6902                                  	;mov	dl, 36
  6903                                  	; 30/12/2024 (320*200)
  6904 00002ACE B617                    	mov	dh, 23
  6905 00002AD0 B210                    	mov	dl, 16
  6906 00002AD2 E85BFFFFFF              	call	setCursorPosition
  6907                                  
  6908 00002AD7 58                      	pop	eax ; **
  6909 00002AD8 88E0                    	mov	al, ah
  6910 00002ADA 30E4                    	xor	ah, ah
  6911                                  	; 21/12/2024
  6912 00002ADC 66BD0200                	mov	bp, 2
  6913 00002AE0 EBA5                    	jmp	short PrintNumber
  6914                                  
  6915                                  ; --------------------------------------------------------
  6916                                  
  6917                                  	; 01/12/2024 (32bit registers)
  6918                                  	; 17/11/2024
  6919                                  	; 14/11/2024
  6920                                  CalcProgressTime:
  6921                                  	;mov	ax, [LoadedDataBytes]
  6922                                  	;mov	dx, [LoadedDataBytes+2]
  6923                                  	;mov	bx, ax
  6924                                  	;or	bx, dx
  6925                                  	;jz	short cpt_ok
  6926                                  	; 01/12/2024
  6927 00002AE2 A1[24390000]            	mov	eax, [LoadedDataBytes]
  6928 00002AE7 09C0                    	or	eax, eax
  6929 00002AE9 7416                    	jz	short cpt_ok
  6930                                  
  6931                                  	;mov	bx, [WAVE_SampleRate]
  6932                                  	;div	bx
  6933                                  	;xor	dx, dx
  6934                                  	;mov	bx, [WAVE_BlockAlign]
  6935                                  	;div	bx
  6936                                  	; 01/12/2024
  6937 00002AEB 0FB71D[84380000]        	movzx	ebx, word [WAVE_SampleRate]
  6938 00002AF2 31D2                    	xor	edx, edx
  6939 00002AF4 F7F3                    	div	ebx
  6940 00002AF6 31D2                    	xor	edx, edx
  6941 00002AF8 668B1D[8C380000]        	mov	bx, [WAVE_BlockAlign]
  6942 00002AFF F7F3                    	div	ebx
  6943                                  cpt_ok:
  6944                                  	; eax = (new) progress time
  6945 00002B01 C3                      	retn
  6946                                  
  6947                                  ; --------------------------------------------------------
  6948                                  ; 14/11/2024
  6949                                  ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017)
  6950                                  
  6951                                  ;; DESCRIPTION: Update file information on template
  6952                                  ;; PARAMS:	WAVE parameters and other variables
  6953                                  ;; REGS:	AX(RW)
  6954                                  ;; VARS:	CurrentFileName, WAVE_SampleRate, 
  6955                                  ;; RETURNS:	On-screen file info is updated.
  6956                                  
  6957                                  	; 01/12/2024 (32bit registers)
  6958                                  UpdateFileInfo:
  6959                                  	;; Print File Name
  6960                                  	;mov	dh, 9
  6961                                  	; 21/12/2024 (640*480 graphics display)
  6962                                  	;mov	dh, 8
  6963                                  	;mov	dl, 23
  6964                                  	; 30/12/2024 (320*200, video mode 13h)
  6965 00002B02 B607                    	mov	dh, 7
  6966 00002B04 B208                    	mov	dl, 8
  6967 00002B06 E827FFFFFF              	call	setCursorPosition
  6968                                  	
  6969 00002B0B BE[AC380000]            	mov	esi, wav_file_name
  6970                                  	
  6971                                  	;;;
  6972                                  	; 14/11/2024
  6973                                  	; skip directory separators
  6974                                  	; (note: asciiz string, max. 79 bytes except zero tail)
  6975 00002B10 89F3                    	mov	ebx, esi
  6976                                  chk4_nxt_sep:
  6977 00002B12 AC                      	lodsb
  6978 00002B13 3C2F                    	cmp	al, '/'	; 14/12/2024
  6979 00002B15 7406                    	je	short chg_fpos
  6980 00002B17 20C0                    	and	al, al
  6981 00002B19 7406                    	jz	short chg_fpos_ok
  6982 00002B1B EBF5                    	jmp	short chk4_nxt_sep
  6983                                  chg_fpos:
  6984 00002B1D 89F3                    	mov	ebx, esi
  6985 00002B1F EBF1                    	jmp	short chk4_nxt_sep
  6986                                  chg_fpos_ok:
  6987 00002B21 89DE                    	mov	esi, ebx ; file name (without its path/directory)
  6988                                  	;;;
  6989                                  _fnl_chk:
  6990                                  	; 30/12/2024 (cgaplay.s)
  6991                                  	; ????????.wav
  6992                                  	; 26/12/2024 (file name length limit -display-)
  6993 00002B23 BB0C000000              	mov	ebx, 12
  6994                                  	;mov	ebx, 17 ; ????????.wav?????
  6995 00002B28 56                      	push	esi
  6996                                  _fnl_chk_loop:
  6997 00002B29 AC                      	lodsb
  6998 00002B2A 20C0                    	and	al, al
  6999 00002B2C 7406                    	jz	short _fnl_ok
  7000 00002B2E 4B                       	dec	ebx
  7001 00002B2F 75F8                    	jnz	short _fnl_chk_loop
  7002 00002B31 C60600                  	mov	byte [esi], 0
  7003                                  _fnl_ok:
  7004 00002B34 5E                      	pop	esi
  7005                                  	;;;
  7006                                  
  7007 00002B35 E870000000              	call	PrintString
  7008                                  	
  7009                                  	;; Print Frequency
  7010                                  	;mov	dh, 10
  7011                                  	; 21/12/2024 (640*480 graphics display)
  7012                                  	;mov	dh, 9
  7013                                  	;mov	dl, 23
  7014                                  	; 30/12/2024 (320*200, video mode 13h)
  7015 00002B3A B608                    	mov	dh, 8
  7016 00002B3C B208                    	mov	dl, 8
  7017 00002B3E E8EFFEFFFF              	call	setCursorPosition
  7018                                  	;movzx	eax, word [WAVE_SampleRate]
  7019                                  	; 22/12/2024
  7020                                  	; eax = 0
  7021 00002B43 66A1[84380000]          	mov	ax, [WAVE_SampleRate]
  7022 00002B49 BD05000000              	mov	ebp, 5
  7023 00002B4E E834FFFFFF              	call	PrintNumber
  7024                                  
  7025                                  	;; Print BitRate
  7026                                  	;mov	dh, 9
  7027                                  	; 21/12/2024 (640*480 graphics display)
  7028                                  	;mov	dh, 8
  7029                                  	;mov	dl, 57
  7030                                  	; 30/12/2024 (320*200, video mode 13h)
  7031 00002B53 B607                    	mov	dh, 7
  7032 00002B55 B21F                    	mov	dl, 31
  7033 00002B57 E8D6FEFFFF              	call	setCursorPosition
  7034 00002B5C 66A1[8E380000]          	mov	ax, [WAVE_BitsPerSample]
  7035 00002B62 66BD0200                	mov	bp, 2
  7036 00002B66 E81CFFFFFF              	call	PrintNumber
  7037                                  
  7038                                  	;; Print Channel Number
  7039                                  	;mov	dh, 10
  7040                                  	; 21/12/2024 (640*480 graphics display)
  7041                                  	;mov	dh, 9
  7042                                  	;mov	dl, 57
  7043                                  	; 30/12/2024 (320*200, video mode 13h)
  7044 00002B6B B608                    	mov	dh, 8
  7045 00002B6D B21F                    	mov	dl, 31
  7046 00002B6F E8BEFEFFFF              	call	setCursorPosition
  7047 00002B74 66A1[82380000]          	mov	ax, [WAVE_NumChannels]
  7048 00002B7A 66BD0100                	mov	bp, 1
  7049 00002B7E E804FFFFFF              	call	PrintNumber
  7050                                  
  7051                                  	;call	UpdateVolume
  7052                                  	;retn
  7053                                  
  7054                                  ; --------------------------------------------------------
  7055                                  
  7056                                  	; 14/11/2024
  7057                                  UpdateVolume:
  7058                                  	;; Print Volume
  7059                                  	;mov	dh, 24
  7060                                  	; 21/12/2024 (640*480)
  7061                                  	;mov	dh, 32
  7062                                  	;mov	dl, 75
  7063                                  	; 30/12/2024 (320*200, video mode 13h)
  7064 00002B83 B617                    	mov	dh, 23
  7065 00002B85 B223                    	mov	dl, 35
  7066 00002B87 E8A6FEFFFF              	call	setCursorPosition
  7067                                  	; 22/12/2024
  7068                                  	; eax = 0
  7069                                  
  7070 00002B8C A0[312A0000]            	mov	al, [volume]
  7071                                  
  7072 00002B91 B364                    	mov	bl, 100
  7073 00002B93 F6E3                    	mul	bl
  7074                                  
  7075 00002B95 B31F                    	mov	bl, 31
  7076 00002B97 F6F3                    	div	bl
  7077                                  
  7078                                  	;neg	ax
  7079                                  	;add	ax, 100	
  7080                                  	; 01/12/2024
  7081 00002B99 B464                    	mov	ah, 100
  7082 00002B9B 28C4                    	sub	ah, al
  7083 00002B9D 0FB6C4                  	movzx	eax, ah
  7084                                  	;xor	ah, ah
  7085                                  	;mov	bp, 3
  7086 00002BA0 BD03000000              	mov	ebp, 3
  7087                                  	;call	PrintNumber
  7088                                  	;retn
  7089 00002BA5 E9DDFEFFFF              	jmp	PrintNumber	
  7090                                  
  7091                                  ; --------------------------------------------------------
  7092                                  
  7093                                  	; 31/12/2024 (int 31h)
  7094                                  	; 21/12/2024
  7095                                  	; write text in VESA VBE graphics mode
  7096                                  PrintString:
  7097                                  	; esi = string address
  7098                                  printstr_loop:
  7099 00002BAA 31C0                    	xor	eax, eax
  7100 00002BAC AC                      	lodsb
  7101 00002BAD 08C0                    	or	al, al
  7102 00002BAF 7407                    	jz	short printstr_ok
  7103                                  
  7104                                  	;push	esi
  7105                                  
  7106                                  	;mov	esi, [screenpos]
  7107                                  
  7108                                  	; esi = pixel position (hw = row, si = column)
  7109                                  	; eax = al = character
  7110                                  	;call	write_character
  7111                                  	; 22/12/2024
  7112 00002BB1 E803000000              	call	write_character_white
  7113                                  
  7114                                  	; 31/12/2024
  7115                                  	;add	word [screenpos], 8 ; update column (only, not row)
  7116                                  
  7117                                  	;pop	esi
  7118 00002BB6 EBF2                    	jmp	short printstr_loop
  7119                                  
  7120                                  printstr_ok:
  7121 00002BB8 C3                      	retn
  7122                                  
  7123                                  ; --------------------------------------------------------
  7124                                  
  7125                                  	; 31/12/2024 (int 31h)
  7126                                  	; 30/12/2024
  7127                                  	; write character (at cursor position)
  7128                                  	; in video mode 13h (320*200, 256 colors)
  7129                                  	; 21/12/2024
  7130                                  	; write character (at cursor position)
  7131                                  	; in graphics mode (640*480, 256 colors)
  7132                                  	; 22/12/2024
  7133                                  write_character_white:
  7134 00002BB9 B90F000000              	mov	ecx, 0Fh
  7135                                  	; 26/12/2024
  7136                                  	;movzx	ecx, byte [tcolor]
  7137                                  write_character:
  7138                                  	; esi = pixel position (hw = row, si = column)
  7139                                  	; eax = al = character
  7140                                  	; cl = color
  7141 00002BBE 890D[50330000]          	mov	[wcolor], ecx ; 22/12/2024
  7142                                  
  7143                                  ; 31/12/2024
  7144                                  %if 0
  7145                                  	; 30/12/2024
  7146                                  	; 22/12/2024
  7147                                  	push	eax
  7148                                  	; clear previous character pixels
  7149                                  	mov	edi, fillblock
  7150                                  	;;sys	_video, 020Fh, 0, 8001h
  7151                                  	; 30/12/2024
  7152                                  	sys	_video, 010Fh, 0, 8000h ; 8*8 userfont
  7153                                  	pop	eax
  7154                                  
  7155                                  	; 30/12/2024
  7156                                  	;shl	eax, 4 ; 8*16 pixel user font
  7157                                  	;mov	edi, fontbuff2 ; start of user font data
  7158                                  	;add	edi, eax
  7159                                  
  7160                                  	; 21/12/2024
  7161                                  	; NOTE:
  7162                                  	; TRDOS 386 does not use 8*14 pixel fonts in sysvideo
  7163                                  	; system calls -in graphics mode-
  7164                                  	; because 8*16 pixel operations are faster
  7165                                  	;			than 8*14 pixel operations.
  7166                                  	; ((so, 8*14 fonts can be converted to 8*16 fonts by
  7167                                  	; adding 2 empty lines))
  7168                                  	; (8*14 characters can be written via pixel operations)
  7169                                    	
  7170                                  	; 21/12/2024 (TRDOS 386 v2.0.9, trdosk6.s, 27/09/2024)
  7171                                  	;;;;;;;;;;;;;;;;; ; sysvideo system call
  7172                                  	;sysvideo:
  7173                                  	;   function in BH
  7174                                  	;	02h: Super VGA, LINEAR FRAME BUFFER data transfers
  7175                                  	;   sub function in BL
  7176                                  	;	0Fh: WRITE CHARACTER (FONT)
  7177                                  	;          CL = char's color (8 bit, 256 colors)
  7178                                  	;	If DH bit 7 = 1
  7179                                  	;	   USER FONT (from user buffer)
  7180                                  	;	         DL = 1 -> 8x16 pixel font
  7181                                   	;	   EDI = user's font buffer address
  7182                                  	;		(NOTE: byte order is as row0,row1,row2..)
  7183                                  	;	   ESI = start position (row, column)
  7184                                  	;		(HW = row, SI = column)
  7185                                  	;;;;;;;;;;;;;;;;;
  7186                                  
  7187                                  	;sys	_video, 020Fh, [wcolor], 8001h
  7188                                  
  7189                                  	; 30/12/2024
  7190                                  	; sysvideo system call
  7191                                  	; BH = 01h = VGA graphics (0A0000h) data transfers
  7192                                  	; BL = 0Fh = write character/font
  7193                                  	; DH = 01h = 8*8 system font 
  7194                                  	; CL = [wcolor] = color
  7195                                  	; ESI = cursor/writing position (pixels)
  7196                                  	;	HW = row, SI = column
  7197                                  	; DL = character (ASCII code)
  7198                                  
  7199                                  	mov	ah, 01h ; 8*8 pixels
  7200                                  
  7201                                  	sys	_video, 010Fh, [wcolor], eax
  7202                                  %endif
  7203                                  
  7204                                  	; 31/12/2024
  7205 00002BC4 0FB6D9                  	movzx	ebx, cl ; bl = foreground color
  7206                                  	; al = character (ASCII code)
  7207 00002BC7 B40E                    	mov	ah, 0Eh
  7208                                  	;int	10h
  7209 00002BC9 CD31                    	int	31h
  7210 00002BCB C3                      	retn
  7211                                  
  7212                                  ; --------------------------------------------------------
  7213                                  
  7214                                  	; 30/12/2024
  7215                                  	; write characters in video mode 13h
  7216                                  	; (320*200 pixels, 256 colors)
  7217                                  	; 22/12/2024
  7218                                  	; 21/12/2024
  7219                                  	; (write chars in VESA VBE graphics mode)
  7220                                  	; 14/11/2024
  7221                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  7222                                  	; (Modification: Erdogan Tan, 14/11/2024)
  7223                                  
  7224                                  	;PROGRESSBAR_ROW equ 23
  7225                                  	; 21/12/2024 (640*480)
  7226                                  	;PROGRESSBAR_ROW equ 31
  7227                                  	; 30/12/2024 (320*200)
  7228                                  	PROGRESSBAR_ROW equ 22
  7229                                  
  7230                                  UpdateProgressBar:
  7231 00002BCC E8D7FEFFFF              	call	SetProgressTime	; 14/11/2024
  7232                                  
  7233                                  	; 01/12/2024 (32bit registers)
  7234 00002BD1 A1[1C390000]            	mov	eax, [ProgressTime]
  7235                                  UpdateProgressBar@:
  7236                                  	;mov	edx, 80
  7237                                  	; 30/12/2024
  7238 00002BD6 BA28000000              	mov	edx, 40 ; 320*200 pixels, 40 columns 
  7239 00002BDB F7E2                    	mul	edx
  7240 00002BDD 8B1D[18390000]          	mov	ebx, [TotalTime]
  7241 00002BE3 F7F3                    	div	ebx
  7242                                  
  7243                                  	; 22/12/2024
  7244                                  	; check progress bar indicator position if it is same 
  7245 00002BE5 3A05[55330000]          	cmp	al, [pbprev]
  7246 00002BEB 7427                    	je	short UpdateProgressBar_ok
  7247 00002BED A2[55330000]            	mov	[pbprev], al
  7248                                  
  7249                                  UpdateProgressBar@@:
  7250                                  	;; Push for the 'Clean' part
  7251 00002BF2 50                      	push	eax ; **
  7252 00002BF3 50                      	push	eax ; *
  7253                                  
  7254                                  	;; Set cursor position
  7255 00002BF4 B616                    	mov	dh, PROGRESSBAR_ROW
  7256 00002BF6 B200                    	mov	dl, 0
  7257 00002BF8 E835FEFFFF              	call	setCursorPosition
  7258                                  
  7259 00002BFD 58                      	pop	eax ; *
  7260 00002BFE 09C0                    	or	eax, eax
  7261 00002C00 7426                    	jz	short UpdateProgressBar_Clean
  7262                                  
  7263                                  UpdateProgressBar_DrawProgress:
  7264                                  	; 31/12/2024 (int 31h)
  7265                                  	; 22/12/2024
  7266                                  	; 21/12/2024
  7267                                  	; (write progress bar chars in graphics mode)
  7268                                  	;;;;
  7269 00002C02 89C5                    	mov	ebp, eax
  7270 00002C04 50                      	push	eax ; ***
  7271                                  	; 31/12/2024
  7272                                  	;mov	esi, [screenpos]
  7273                                  UpdateProgressBar_DrawProgress_@:
  7274 00002C05 B8DF000000              	mov	eax, 223
  7275                                  	
  7276                                  	; esi = pixel position (hw = row, si = column)
  7277                                  	; eax = al = character
  7278                                  	;call	write_character
  7279                                  	; 22/12/2024
  7280 00002C0A E8AAFFFFFF              	call	write_character_white
  7281                                  
  7282 00002C0F 4D                      	dec	ebp
  7283 00002C10 7403                    	jz	short UpdateProgressBar_DrawCursor
  7284                                  
  7285                                  	; 31/12/2024
  7286                                  	;add	esi, 8 ; next column
  7287 00002C12 EBF1                    	jmp	short UpdateProgressBar_DrawProgress_@
  7288                                  	;;;
  7289                                  
  7290                                  UpdateProgressBar_ok:
  7291 00002C14 C3                      	retn
  7292                                  
  7293                                  UpdateProgressBar_DrawCursor:
  7294                                  	; 22/12/2024
  7295 00002C15 5A                      	pop	edx ; ***
  7296 00002C16 B616                    	mov	dh, PROGRESSBAR_ROW
  7297                                  	; 31/12/2024
  7298 00002C18 FECA                    	dec	dl ; last written position again
  7299 00002C1A E813FEFFFF              	call	setCursorPosition
  7300                                  
  7301                                  	; 21/12/2024
  7302                                  	; (write progress bar character in graphics mode)
  7303                                  	;;;;
  7304                                  	;;;mov	eax, 223
  7305                                  	;;;shl	eax, 4 ; 8*16 pixel user font
  7306                                  	;;mov	eax, 223*16
  7307                                  	;;mov	edi, fontbuff2 ; start of user font data
  7308                                  	;;add	edi, eax
  7309                                  	;mov	edi, fontbuff2+(223*16)
  7310                                  	;
  7311                                  	;sys	_video, 020Fh, 0Ch, 8001h
  7312                                  	; 22/12/2024
  7313                                  	;mov	eax, 223
  7314                                  	; eax = 0
  7315 00002C1F B0DF                    	mov	al, 223
  7316 00002C21 B10C                    	mov	cl, 0Ch ; red
  7317 00002C23 E896FFFFFF              	call	write_character
  7318                                  	;;;;
  7319                                  
  7320                                  UpdateProgressBar_Clean:
  7321                                  	;pop	eax  ; **
  7322                                  	; 22/12/2024
  7323 00002C28 5A                      	pop	edx  ; **
  7324                                  	; 30/12/2024
  7325                                  	; 21/12/2024
  7326                                  	;mov	ebp, 80
  7327                                  	; 30/12/2024
  7328 00002C29 BD28000000              	mov	ebp, 40 ; 40 columns (320*200 pixels)
  7329                                  	;sub	bp, ax
  7330 00002C2E 6629D5                  	sub	bp, dx ; 22/12/2024
  7331                                  	;jz	short UpdateProgressBar_ok
  7332                                  	; 31/12/2024
  7333 00002C31 76E1                    	jna	short UpdateProgressBar_ok
  7334                                  
  7335 00002C33 B616                    	mov	dh, PROGRESSBAR_ROW
  7336                                  	;mov	dl, al ; 22/12/2024
  7337 00002C35 E8F8FDFFFF              	call	setCursorPosition
  7338                                  
  7339                                  	; 21/12/2024
  7340                                  	; (write progress bar chars in graphics mode)
  7341                                  	;;;;
  7342                                  	; 31/12/2024
  7343                                  	;mov	esi, [screenpos]
  7344                                  UpdateProgressBar_Clean_@:
  7345                                  	;;;mov	eax, 223
  7346                                  	;;;shl	eax, 4 ; 8*16 pixel user font
  7347                                  	;;mov	eax, 223*16
  7348                                  	;mov	edi, fontbuff2 ; start of user font data
  7349                                  	;add	edi, eax
  7350                                  	;mov	edi, fontbuff2+(223*16)
  7351                                  	;
  7352                                  	;sys	_video, 020Fh, 08h, 8001h
  7353                                  	; 22/12/2024
  7354                                  	;mov	eax, 223
  7355                                  	; eax = 0
  7356 00002C3A B0DF                    	mov	al, 223
  7357 00002C3C B108                    	mov	cl, 08h ; gray (dark)
  7358 00002C3E E87BFFFFFF              	call	write_character
  7359                                  	;;;;
  7360                                  
  7361 00002C43 4D                      	dec	ebp
  7362 00002C44 74CE                    	jz	short UpdateProgressBar_ok
  7363                                  
  7364                                  	; 31/12/2024
  7365                                  	;add	esi, 8 ; next column
  7366 00002C46 EBF2                    	jmp	short UpdateProgressBar_Clean_@
  7367                                  	;;;;
  7368                                  
  7369                                  ; --------------------------------------------------------
  7370                                  ; 17/11/2024
  7371                                  
  7372                                  Player_ProcessKey_Backwards:
  7373                                  	;; In order to go backwards 5 seconds:
  7374                                  	;; Update file pointer to the beginning, skip headers
  7375 00002C48 B142                    	mov	cl, 'B'
  7376 00002C4A EB02                    	jmp	short Player_ProcessKey_B_or_F
  7377                                  
  7378                                  Player_ProcessKey_Forwards:
  7379                                  	;; In order to fast-forward 5 seconds, set the file pointer
  7380                                  	;; to CUR_SEEK + 5 * Freq
  7381                                  
  7382 00002C4C B146                    	mov	cl, 'F'
  7383                                  	;jmp	short Player_ProcessKey_B_or_F
  7384                                  
  7385                                  	; 01/12/2024 (32bit regsisters)
  7386                                  Player_ProcessKey_B_or_F:
  7387                                  	; 17/11/2024
  7388                                  	; 04/11/2024
  7389                                  	; (Ref: player.asm, Matan Alfasi, 2017)
  7390                                    
  7391                                  	; 04/11/2024
  7392 00002C4E B805000000              	mov	eax, 5
  7393 00002C53 0FB71D[8C380000]        	movzx	ebx, word [WAVE_BlockAlign]
  7394 00002C5A F7E3                    	mul	ebx
  7395 00002C5C 668B1D[84380000]        	mov	bx, [WAVE_SampleRate]
  7396 00002C63 F7E3                    	mul	ebx
  7397                                  	; eax = transfer byte count for 5 seconds
  7398                                  	
  7399                                  	; 17/11/2024
  7400 00002C65 80F942                  	cmp	cl, 'B'
  7401                                  	;mov	bx, [LoadedDataBytes]
  7402                                  	;mov	cx, [LoadedDataBytes+2]
  7403                                  	; 01/12/2024
  7404 00002C68 8B0D[24390000]          	mov	ecx, [LoadedDataBytes]
  7405 00002C6E 7508                    	jne	short move_forward ; cl = 'F'
  7406                                  move_backward:
  7407                                  	;sub	bx, ax
  7408                                  	;sbb	cx, dx
  7409 00002C70 29C1                    	sub	ecx, eax
  7410 00002C72 7316                    	jnc	short move_file_pointer
  7411                                  move_to_beginning:
  7412                                  	;xor	cx, cx ; 0
  7413                                  	;xor	bx, bx ; 0
  7414 00002C74 31C9                    	xor	ecx, ecx
  7415 00002C76 EB12                    	jmp	short move_file_pointer
  7416                                  move_forward: 
  7417                                  	;add	bx, ax
  7418                                  	;adc	cx, dx
  7419 00002C78 01C1                    	add	ecx, eax
  7420 00002C7A 7208                    	jc	short move_to_end
  7421                                  	;cmp	cx, [DATA_SubchunkSize+2]
  7422                                  	;ja	short move_to_end
  7423                                  	;jb	short move_file_pointer
  7424                                  	;cmp	bx, [DATA_SubchunkSize]
  7425                                  	;jna	short move_file_pointer
  7426 00002C7C 3B0D[94380000]          	cmp	ecx, [DATA_SubchunkSize]
  7427 00002C82 7606                    	jna	short move_file_pointer
  7428                                  move_to_end:
  7429                                  	;mov	bx, [DATA_SubchunkSize]
  7430                                  	;mov	cx, [DATA_SubchunkSize+2]
  7431 00002C84 8B0D[94380000]          	mov	ecx, [DATA_SubchunkSize]
  7432                                  move_file_pointer:
  7433                                  	;mov	dx, bx    
  7434                                  	;mov	[LoadedDataBytes], dx
  7435                                  	;mov	[LoadedDataBytes+2], cx
  7436 00002C8A 890D[24390000]          	mov	[LoadedDataBytes], ecx
  7437                                  	;add	dx, 44 ; + header
  7438                                  	;adc	cx, 0
  7439 00002C90 83C12C                  	add	ecx, 44 
  7440                                  
  7441                                  	; seek
  7442                                  	;mov	bx, [filehandle]
  7443                                  	;mov	ax, 4200h
  7444                                  	;int	21h
  7445                                  	; 01/12/2024
  7446 00002C93 31D2                    	xor	edx, edx ; offset from beginning of the file
  7447                                  	; ecx = offset	
  7448                                  	; ebx = file handle
  7449                                  	; edx = 0
  7450                                  	sys	_seek, [filehandle]
   116                              <1> 
   117                              <1> 
   118                              <1> 
   119                              <1> 
   120                              <1>  %if %0 >= 2
   121 00002C95 8B1D[9C380000]      <1>  mov ebx, %2
   122                              <1>  %if %0 >= 3
   123                              <1>  mov ecx, %3
   124                              <1>  %if %0 = 4
   125                              <1>  mov edx, %4
   126                              <1>  %endif
   127                              <1>  %endif
   128                              <1>  %endif
   129 00002C9B B813000000          <1>  mov eax, %1
   130                              <1> 
   131 00002CA0 CD40                <1>  int 40h
  7451 00002CA2 C3                      	retn
  7452                                  
  7453                                  ; --------------------------------------------------------
  7454                                  
  7455                                  	; 30/12/2024 (video mode 13h)
  7456                                  	; (320*200, 256 colors)
  7457                                  	; 25/12/2024
  7458                                  	; 22/12/2024 (VESA VBE mode graphics) 
  7459                                  	; (640*480, 256 colors)
  7460                                  clear_window:
  7461                                  	;mov	edi, [LFB_ADDR]
  7462                                  	; 30/12/2024
  7463                                  	;mov	edi, 0A0000h
  7464                                  	;;add	edi, (13*80*8*14)
  7465                                  	; 25/12/2024
  7466                                  	;;add	edi, 164*640
  7467                                  	;add	edi, 12*8*320
  7468                                  	; 30/12/2024
  7469                                  	;mov	edi, [graphstart] ; 12*8*320
  7470 00002CA3 BF80700A00              	mov	edi, 0A0000h+(11*8*320)+(2*320) ; *
  7471                                  				; AC97 info start 
  7472 00002CA8 29C0                    	sub	eax, eax
  7473                                  	;;mov	ecx, (16*640*14)/4 ; 16 rows
  7474                                  	;mov	ecx, 64*640 ; 256 volume level points
  7475                                  	; 30/12/2024
  7476                                  	;mov	ecx, (8*8*320)/4 ; 8 rows 
  7477 00002CAA B900190000              	mov	ecx, (10*8*320)/4 ; *
  7478 00002CAF F3AB                    	rep	stosd
  7479                                  	; 24/12/2024
  7480 00002CB1 A3[5C330000]            	mov	[prev_points], eax ; 0
  7481                                  	;
  7482 00002CB6 C3                      	retn
  7483                                  
  7484                                  ; -------------------------------------------------------------
  7485                                  ; ac97.inc (11/11/2023)
  7486                                  ; -------------------------------------------------------------
  7487                                  
  7488                                  ; special characters
  7489                                  LF      EQU 10
  7490                                  CR      EQU 13
  7491                                  
  7492                                  ; PCI stuff
  7493                                  
  7494                                  BIT0  EQU 1
  7495                                  BIT1  EQU 2
  7496                                  BIT2  EQU 4
  7497                                  BIT8  EQU 100h
  7498                                  BIT9  EQU 200h
  7499                                  BIT28 EQU 10000000h
  7500                                  BIT30 EQU 40000000h
  7501                                  BIT31 EQU 80000000h
  7502                                  
  7503                                  BUP		equ	BIT30		; Buffer Underrun Policy.
  7504                                  					; if this buffer is the last buffer
  7505                                  					; in a playback, fill the remaining
  7506                                  					; samples with 0 (silence) or not.
  7507                                  					; It's a good idea to set this to 1
  7508                                  					; for the last buffer in playback,
  7509                                  					; otherwise you're likely to get a lot
  7510                                  					; of noise at the end of the sound.
  7511                                  
  7512                                  RR		equ	BIT1		; reset registers. Nukes all regs
  7513                                                                          ; except bits 4:2 of this register.
  7514                                                                          ; Only set this bit if BIT 0 is 0
  7515                                  RPBM		equ	BIT0		; Run/Pause
  7516                                  					; set this bit to start the codec!
  7517                                  IO_ENA		EQU	BIT0		; i/o decode enable
  7518                                  BM_ENA		EQU	BIT2		; bus master enable
  7519                                  
  7520                                  PCI_INDEX_PORT  EQU     0CF8h
  7521                                  PCI_DATA_PORT   EQU     0CFCh
  7522                                  PCI32           EQU     BIT31           ; bitflag to signal 32bit access
  7523                                  PCI16           EQU     BIT30           ; bitflag for 16bit access
  7524                                  
  7525                                  AC97_INT_LINE	equ	3Ch		; AC97 Interrupt Line register offset
  7526                                  
  7527                                  ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
  7528                                  
  7529                                  INTEL_VID       equ     8086h           ; Intel's PCI vendor ID
  7530                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  7531                                  SIS_VID		equ	1039h
  7532                                  NVIDIA_VID	equ	10DEh	 ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
  7533                                  AMD_VID		equ	1022h
  7534                                  
  7535                                  ICH_DID         equ     2415h           ; ICH device ID
  7536                                  ICH0_DID        equ     2425h           ; ICH0
  7537                                  ICH2_DID        equ     2445h           ; ICH2 I think there are more ICHes.
  7538                                                                          ; they all should be compatible.
  7539                                  
  7540                                  ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
  7541                                  ICH3_DID	equ     2485h           ; ICH3
  7542                                  ICH4_DID        equ     24C5h           ; ICH4
  7543                                  ICH5_DID	equ     24D5h           ; ICH5
  7544                                  ICH6_DID	equ     266Eh           ; ICH6
  7545                                  ESB6300_DID	equ     25A6h           ; 6300ESB
  7546                                  ESB631X_DID	equ     2698h           ; 631XESB
  7547                                  ICH7_DID	equ	27DEh		; ICH7
  7548                                  ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
  7549                                  MX82440_DID	equ	7195h
  7550                                  SI7012_DID	equ	7012h
  7551                                  NFORCE_DID	equ	01B1h
  7552                                  NFORCE2_DID	equ	006Ah
  7553                                  AMD8111_DID	equ	746Dh
  7554                                  AMD768_DID	equ	7445h
  7555                                  ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
  7556                                  CK804_DID	equ	0059h
  7557                                  MCP04_DID	equ	003Ah
  7558                                  CK8_DID		equ	008Ah
  7559                                  NFORCE3_DID	equ	00DAh
  7560                                  CK8S_DID	equ	00EAh
  7561                                  
  7562                                  NAMBAR_REG	equ	10h		; native audio mixer BAR
  7563                                  NABMBAR_REG	equ	14h		; native audio bus mastering BAR
  7564                                  
  7565                                  CODEC_MASTER_VOL_REG	equ	02h	; master volume
  7566                                  CODEC_MASTER_TONE_REG	equ	08h	; master tone (R+L)
  7567                                  CODEC_PCM_OUT_REG 	equ	18h     ; PCM output volume
  7568                                  CODEC_EXT_AUDIO_REG	equ	28h	; extended audio
  7569                                  CODEC_EXT_AUDIO_CTRL_REG equ	2Ah	; extended audio control
  7570                                  CODEC_PCM_FRONT_DACRATE_REG equ	2Ch	; PCM out sample rate
  7571                                  
  7572                                  ; ICH supports 3 different types of register sets for three types of things
  7573                                  ; it can do, thus:
  7574                                  ;
  7575                                  ; PCM in (for recording) aka PI
  7576                                  ; PCM out (for playback) aka PO
  7577                                  ; MIC in (for recording) aka MC
  7578                                  
  7579                                  PI_BDBAR_REG	equ	0		; PCM in buffer descriptor BAR
  7580                                  PO_BDBAR_REG	equ	10h		; PCM out buffer descriptor BAR
  7581                                  
  7582                                  GLOB_CNT_REG	equ	2Ch		; Global control register
  7583                                  GLOB_STS_REG 	equ	30h		; Global Status register (RO)
  7584                                  
  7585                                  PI_CR_REG 	equ	0Bh		; PCM in Control Register
  7586                                  PO_CR_REG	equ	1Bh		; PCM out Control Register
  7587                                  MC_CR_REG	equ	2Bh		; MIC in Control Register
  7588                                  
  7589                                  PCI_CMD_REG	EQU	04h		; reg 04h, command register
  7590                                  
  7591                                  CTRL_ST_CREADY		equ	BIT8+BIT9+BIT28 ; Primary Codec Ready
  7592                                  CODEC_REG_POWERDOWN	equ	26h
  7593                                  
  7594                                  PO_CIV_REG	equ	14h		; PCM out current Index value (RO)
  7595                                  PO_LVI_REG	equ	15h		; PCM out Last Valid Index
  7596                                  PO_SR_REG	equ	16h		; PCM out Status register
  7597                                  
  7598                                  ; -------------------------------------------------------------
  7599                                  
  7600                                  ; 22/12/2024
  7601 00002CB7 90                      align 4
  7602                                  
  7603                                  ; 13/11/2024
  7604                                  ; ('<<' to 'shl' conversion for FASM)
  7605                                  ;
  7606                                  ; 29/05/2024 (TRDOS 386)
  7607                                  ; 17/02/2017
  7608                                  ; Valid ICH device IDs
  7609                                  
  7610                                  valid_ids:
  7611                                  	;dd (ICH_DID shl 16) + INTEL_VID	; 8086h:2415h
  7612 00002CB8 86801524                	dd (ICH_DID << 16) + INTEL_VID		; 8086h:2415h
  7613 00002CBC 86802524                	dd (ICH0_DID << 16) + INTEL_VID		; 8086h:2425h
  7614 00002CC0 86804524                	dd (ICH2_DID << 16) + INTEL_VID		; 8086h:2445h
  7615 00002CC4 86808524                	dd (ICH3_DID << 16) + INTEL_VID		; 8086h:2485h
  7616 00002CC8 8680C524                	dd (ICH4_DID << 16) + INTEL_VID		; 8086h:24C5h
  7617 00002CCC 8680D524                	dd (ICH5_DID << 16) + INTEL_VID		; 8086h:24D5h
  7618 00002CD0 86806E26                	dd (ICH6_DID << 16) + INTEL_VID		; 8086h:266Eh
  7619 00002CD4 8680A625                	dd (ESB6300_DID << 16) + INTEL_VID	; 8086h:25A6h
  7620 00002CD8 86809826                	dd (ESB631X_DID << 16) + INTEL_VID	; 8086h:2698h
  7621 00002CDC 8680DE27                	dd (ICH7_DID << 16) + INTEL_VID		; 8086h:27DEh
  7622                                  	; 03/11/2023 - Erdogan Tan
  7623 00002CE0 86809571                	dd (MX82440_DID << 16) + INTEL_VID	; 8086h:7195h
  7624 00002CE4 39101270                	dd (SI7012_DID << 16)  + SIS_VID	; 1039h:7012h
  7625 00002CE8 DE10B101                	dd (NFORCE_DID << 16)  + NVIDIA_VID	; 10DEh:01B1h
  7626 00002CEC DE106A00                	dd (NFORCE2_DID << 16) + NVIDIA_VID	; 10DEh:006Ah
  7627 00002CF0 22106D74                	dd (AMD8111_DID << 16) + AMD_VID	; 1022h:746Dh
  7628 00002CF4 22104574                	dd (AMD768_DID << 16)  + AMD_VID	; 1022h:7445h
  7629 00002CF8 DE105900                	dd (CK804_DID << 16) + NVIDIA_VID	; 10DEh:0059h
  7630 00002CFC DE103A00                	dd (MCP04_DID << 16) + NVIDIA_VID	; 10DEh:003Ah
  7631 00002D00 DE108A00                	dd (CK8_DID << 16) + NVIDIA_VID		; 1022h:008Ah
  7632 00002D04 DE10DA00                	dd (NFORCE3_DID << 16) + NVIDIA_VID	; 10DEh:00DAh
  7633 00002D08 DE10EA00                	dd (CK8S_DID << 16) + NVIDIA_VID	; 10DEh:00EAh
  7634                                  
  7635                                  valid_id_count equ (($ - valid_ids)>>2)	; 05/11/2023
  7636                                  ; 13/11/2024
  7637                                  ;valid_id_count = ($ - valid_ids) shr 2	; 05/11/2023
  7638                                  
  7639 00002D0C 00000000                	dd 0
  7640                                  
  7641                                  Credits:
  7642 00002D10 564741205741562050-     	db 'VGA WAV Player for TRDOS 386 by Erdogan Tan. '
  7642 00002D19 6C6179657220666F72-
  7642 00002D22 205452444F53203338-
  7642 00002D2B 36206279204572646F-
  7642 00002D34 67616E2054616E2E20 
  7643                                  	;db 'January 2025.',10,13,0
  7644 00002D3D 466562727561727920-     	db 'February 2025.', 10,13,0
  7644 00002D46 323032352E0A0D00   
  7645                                  	;;db '01/01/2025', 10,13
  7646                                  	;db '18/01/2025', 10,13
  7647 00002D4E 30352F30322F323032-     	db '05/02/2025', 10,13,0
  7647 00002D57 350A0D00           
  7648 00002D5B 30362F30322F323032-     	db '06/02/2025', 10,13
  7648 00002D64 350A0D             
  7649                                  ; 15/11/2024
  7650                                  reset:
  7651 00002D67 00                      	db 0
  7652                                  
  7653                                  msgAudioCardInfo:
  7654 00002D68 666F7220496E74656C-     	db 'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  7654 00002D71 204143393720284943-
  7654 00002D7A 482920417564696F20-
  7654 00002D83 436F6E74726F6C6C65-
  7654 00002D8C 722E0A0D00         
  7655                                  
  7656                                  	; 06/02/2025
  7657                                  	; 31/12/2024
  7658                                  msg_usage:
  7659 00002D91 75736167653A204347-     	db 'usage: CGAPLAY0 <FileName1> <FileName2> <...>',10,13,0
  7659 00002D9A 41504C415930203C46-
  7659 00002DA3 696C654E616D65313E-
  7659 00002DAC 203C46696C654E616D-
  7659 00002DB5 65323E203C2E2E2E3E-
  7659 00002DBE 0A0D00             
  7660                                  
  7661                                  noDevMsg:
  7662 00002DC1 4572726F723A20556E-     	db 'Error: Unable to find AC97 audio device!'
  7662 00002DCA 61626C6520746F2066-
  7662 00002DD3 696E64204143393720-
  7662 00002DDC 617564696F20646576-
  7662 00002DE5 69636521           
  7663 00002DE9 0A0D00                  	db 10,13,0
  7664                                  
  7665                                  noFileErrMsg:
  7666 00002DEC 4572726F723A206669-     	db 'Error: file not found.',10,13,0
  7666 00002DF5 6C65206E6F7420666F-
  7666 00002DFE 756E642E0A0D00     
  7667                                  
  7668                                  ; 07/12/2024
  7669                                  trdos386_err_msg:
  7670 00002E05 5452444F5320333836-     	db 'TRDOS 386 System call error !',10,13,0
  7670 00002E0E 2053797374656D2063-
  7670 00002E17 616C6C206572726F72-
  7670 00002E20 20210A0D00         
  7671                                  
  7672                                  ; 29/05/2024
  7673                                  ; 11/11/2023
  7674                                  msg_init_err:
  7675 00002E25 0D0A                    	db CR, LF
  7676 00002E27 4143393720436F6E74-     	db 'AC97 Controller/Codec initialization error !'
  7676 00002E30 726F6C6C65722F436F-
  7676 00002E39 64656320696E697469-
  7676 00002E42 616C697A6174696F6E-
  7676 00002E4B 206572726F722021   
  7677 00002E53 0D0A00                  	db CR, LF, 0 ; 07/12/2024
  7678                                  
  7679                                  ; 25/11/2023
  7680                                  msg_no_vra:
  7681 00002E56 0A0D                    	db 10,13
  7682 00002E58 4E6F20565241207375-     	db 'No VRA support ! Only 48 kHZ sample rate supported !'
  7682 00002E61 70706F72742021204F-
  7682 00002E6A 6E6C79203438206B48-
  7682 00002E73 5A2073616D706C6520-
  7682 00002E7C 726174652073757070-
  7682 00002E85 6F727465642021     
  7683 00002E8C 0A0D00                  	db 10,13,0
  7684                                  
  7685                                  ; 19/11/2024
  7686                                  ; 03/06/2017
  7687                                  hex_chars:
  7688 00002E8F 303132333435363738-     	db '0123456789ABCDEF', 0
  7688 00002E98 3941424344454600   
  7689                                  msgAC97Info:
  7690 00002EA0 0D0A                    	db 0Dh, 0Ah
  7691 00002EA2 204143393720417564-     	db ' AC97 Audio Controller & Codec Info', 0Dh, 0Ah 
  7691 00002EAB 696F20436F6E74726F-
  7691 00002EB4 6C6C6572202620436F-
  7691 00002EBD 64656320496E666F0D-
  7691 00002EC6 0A                 
  7692 00002EC7 2056656E646F722049-     	db ' Vendor ID: '
  7692 00002ED0 443A20             
  7693                                  msgVendorId:
  7694 00002ED3 303030306820446576-     	db '0000h Device ID: '
  7694 00002EDC 6963652049443A20   
  7695                                  msgDevId:
  7696 00002EE4 30303030680D0A          	db '0000h', 0Dh, 0Ah
  7697 00002EEB 204275733A20            	db ' Bus: '
  7698                                  msgBusNo:
  7699 00002EF1 303068204465766963-     	db '00h Device: '
  7699 00002EFA 653A20             
  7700                                  msgDevNo:
  7701 00002EFD 3030682046756E6374-     	db '00h Function: '
  7701 00002F06 696F6E3A20         
  7702                                  msgFncNo:
  7703 00002F0B 303068                  	db '00h'
  7704 00002F0E 0D0A                    	db 0Dh, 0Ah
  7705 00002F10 204E414D4241523A20      	db ' NAMBAR: '
  7706                                  msgNamBar:
  7707 00002F19 30303030682020          	db '0000h  '
  7708 00002F20 4E41424D4241523A20      	db 'NABMBAR: '
  7709                                  msgNabmBar:
  7710 00002F29 303030306820204952-     	db '0000h  IRQ: '
  7710 00002F32 513A20             
  7711                                  msgIRQ:
  7712 00002F35 3030                    	dw 3030h
  7713 00002F37 0D0A00                  	db 0Dh, 0Ah, 0
  7714                                  ; 25/11/2023
  7715                                  msgVRAheader:
  7716 00002F3A 205652412073757070-     	db ' VRA support: '
  7716 00002F43 6F72743A20         
  7717 00002F48 00                      	db 0	
  7718                                  msgVRAyes:
  7719 00002F49 5945530D0A00            	db 'YES', 0Dh, 0Ah, 0
  7720                                  msgVRAno:
  7721 00002F4F 4E4F200D0A              	db 'NO ', 0Dh, 0Ah
  7722                                  	;db ' (Interpolated sample rate playing method)'
  7723                                  	; 30/12/2024
  7724 00002F54 2028496E746572706F-     	db ' (Interpolated samplerate play method)'
  7724 00002F5D 6C617465642073616D-
  7724 00002F66 706C65726174652070-
  7724 00002F6F 6C6179206D6574686F-
  7724 00002F78 6429               
  7725 00002F7A 0D0A00                  	db 0Dh, 0Ah, 0
  7726                                  
  7727 00002F7D 90<rep 3h>              align 4
  7728                                  
  7729                                  ; -------------------------------------------------------------
  7730                                  
  7731                                  	; 30/12/2024
  7732                                  PlayingScreen:
  7733 00002F80 DBDBDBDBDBDBDBDBDB-     	db  14 dup(219), " DOS Player ", 14 dup(219)
  7733 00002F89 DBDBDBDBDB20444F53-
  7733 00002F92 20506C6179657220DB-
  7733 00002F9B DBDBDBDBDBDBDBDBDB-
  7733 00002FA4 DBDBDBDB           
  7734 00002FA8 C9CDCDCDCDCDCDCDCD-     	db  201, 38 dup(205), 187
  7734 00002FB1 CDCDCDCDCDCDCDCDCD-
  7734 00002FBA CDCDCDCDCDCDCDCDCD-
  7734 00002FC3 CDCDCDCDCDCDCDCDCD-
  7734 00002FCC CDCDCDBB           
  7735 00002FD0 BA203C53706163653E-     	db  186, " <Space> Play/Pause <N>/<P> Next/Prev ", 186
  7735 00002FD9 20506C61792F506175-
  7735 00002FE2 7365203C4E3E2F3C50-
  7735 00002FEB 3E204E6578742F5072-
  7735 00002FF4 657620BA           
  7736 00002FF8 BA203C533E20202020-     	db  186, " <S>     Stop       <Enter> Color     ", 186
  7736 00003001 2053746F7020202020-
  7736 0000300A 2020203C456E746572-
  7736 00003013 3E20436F6C6F722020-
  7736 0000301C 202020BA           
  7737 00003020 BA203C463E20202020-     	db  186, " <F>     Forwards   <+>/<-> Volume    ", 186
  7737 00003029 20466F727761726473-
  7737 00003032 2020203C2B3E2F3C2D-
  7737 0000303B 3E20566F6C756D6520-
  7737 00003044 202020BA           
  7738 00003048 BA203C423E20202020-     	db  186, " <B>     Backwards  <Q>     Quit Prg  ", 186
  7738 00003051 204261636B77617264-
  7738 0000305A 7320203C513E202020-
  7738 00003063 202051756974205072-
  7738 0000306C 672020BA           
  7739 00003070 CCCDCDCDCDCDCDCDCD-     	db  204, 38 dup(205), 185
  7739 00003079 CDCDCDCDCDCDCDCDCD-
  7739 00003082 CDCDCDCDCDCDCDCDCD-
  7739 0000308B CDCDCDCDCDCDCDCDCD-
  7739 00003094 CDCDCDB9           
  7740 00003098 BA2046696C653A2020-     	db  186, " File:              Bits:     0       ", 186
  7740 000030A1 202020202020202020-
  7740 000030AA 202020426974733A20-
  7740 000030B3 202020203020202020-
  7740 000030BC 202020BA           
  7741 000030C0 BA20467265713A2030-     	db  186, " Freq: 0     Hz     Channels: 0       ", 186
  7741 000030C9 2020202020487A2020-
  7741 000030D2 2020204368616E6E65-
  7741 000030DB 6C733A203020202020-
  7741 000030E4 202020BA           
  7742 000030E8 C8CDCDCDCDCDCDCDCD-     	db  200, 38 dup(205), 188
  7742 000030F1 CDCDCDCDCDCDCDCDCD-
  7742 000030FA CDCDCDCDCDCDCDCDCD-
  7742 00003103 CDCDCDCDCDCDCDCDCD-
  7742 0000310C CDCDCDBC           
  7743 00003110 202020202020202020-     	db  40 dup(32)
  7743 00003119 202020202020202020-
  7743 00003122 202020202020202020-
  7743 0000312B 202020202020202020-
  7743 00003134 20202020           
  7744                                  improper_samplerate_txt:
  7745                                  read_error_txt:
  7746 00003138 202020202020202020-     	db  40 dup(32)
  7746 00003141 202020202020202020-
  7746 0000314A 202020202020202020-
  7746 00003153 202020202020202020-
  7746 0000315C 20202020           
  7747 00003160 202020202020202020-     	db  40 dup(32)
  7747 00003169 202020202020202020-
  7747 00003172 202020202020202020-
  7747 0000317B 202020202020202020-
  7747 00003184 20202020           
  7748 00003188 202020202020202020-     	db  40 dup(32)
  7748 00003191 202020202020202020-
  7748 0000319A 202020202020202020-
  7748 000031A3 202020202020202020-
  7748 000031AC 20202020           
  7749 000031B0 202020202020202020-     	db  40 dup(32)
  7749 000031B9 202020202020202020-
  7749 000031C2 202020202020202020-
  7749 000031CB 202020202020202020-
  7749 000031D4 20202020           
  7750 000031D8 202020202020202020-     	db  40 dup(32)
  7750 000031E1 202020202020202020-
  7750 000031EA 202020202020202020-
  7750 000031F3 202020202020202020-
  7750 000031FC 20202020           
  7751 00003200 202020202020202020-     	db  40 dup(32)
  7751 00003209 202020202020202020-
  7751 00003212 202020202020202020-
  7751 0000321B 202020202020202020-
  7751 00003224 20202020           
  7752 00003228 202020202020202020-     	db  40 dup(32)
  7752 00003231 202020202020202020-
  7752 0000323A 202020202020202020-
  7752 00003243 202020202020202020-
  7752 0000324C 20202020           
  7753 00003250 202020202020202020-     	db  40 dup(32)
  7753 00003259 202020202020202020-
  7753 00003262 202020202020202020-
  7753 0000326B 202020202020202020-
  7753 00003274 20202020           
  7754 00003278 202020202020202020-     	db  40 dup(32)
  7754 00003281 202020202020202020-
  7754 0000328A 202020202020202020-
  7754 00003293 202020202020202020-
  7754 0000329C 20202020           
  7755 000032A0 202020202020202020-     	db  40 dup(32)
  7755 000032A9 202020202020202020-
  7755 000032B2 202020202020202020-
  7755 000032BB 202020202020202020-
  7755 000032C4 20202020           
  7756 000032C8 CDCDCDCDCDCDCDCDCD-     	db  40 dup(205)
  7756 000032D1 CDCDCDCDCDCDCDCDCD-
  7756 000032DA CDCDCDCDCDCDCDCDCD-
  7756 000032E3 CDCDCDCDCDCDCDCDCD-
  7756 000032EC CDCDCDCD           
  7757 000032F0 202020202020202020-     	db  40 dup(32)
  7757 000032F9 202020202020202020-
  7757 00003302 202020202020202020-
  7757 0000330B 202020202020202020-
  7757 00003314 20202020           
  7758 00003318 202020202020202020-     	db  13 dup(32), "00:00 ", 174, 175, " 00:00", 4 dup(32), "VOL 000%"
  7758 00003321 2020202030303A3030-
  7758 0000332A 20AEAF2030303A3030-
  7758 00003333 20202020564F4C2030-
  7758 0000333C 303025             
  7759                                  	;db  40 dup(32) ; not necessary
  7760 0000333F 00                      	db 0
  7761                                  
  7762                                  ; -------------------------------------------------------------
  7763                                  
  7764                                  ; 31/12/2024
  7765                                  	; 30/12/2024
  7766                                  ;fillblock:
  7767                                  ;	times 8 db 0FFh
  7768                                  ;	dw 0
  7769                                  
  7770                                  ; -------------------------------------------------------------
  7771                                  
  7772                                  ; 30/12/2024
  7773                                  ; 23/11/2024
  7774                                  colors:
  7775 00003340 0F0B0A0C0E090D          	db 0Fh, 0Bh, 0Ah, 0Ch, 0Eh, 09h, 0Dh
  7776                                  	; white, cyan, green, red, yellow, blue, magenta
  7777 00003347 0B                      ccolor:	db 0Bh	; cyan
  7778                                  
  7779                                  EOF: 
  7780                                  
  7781                                  ; -------------------------------------------------------------
  7782                                  
  7783                                  bss:
  7784                                  
  7785                                  ABSOLUTE bss
  7786                                  
  7787                                  alignb 4
  7788                                  
  7789                                  ; 24/12/2024
  7790                                  wpoints_dif:	; wave lighting points factor (differential) 
  7791 00003348 ????????                	resd 1	; required bytes for 1/18 second wave lighting
  7792                                  graphstart:
  7793 0000334C ????????                	resd 1	; start (top) line/row for wave lighting points 	 
  7794                                  
  7795                                  ; 30/12/2024
  7796                                  ;LFB_ADDR:
  7797                                  ;	resd 1
  7798                                  
  7799                                  ;nextrow:
  7800                                  	;resd 1
  7801                                  
  7802                                  ; 31/12/2024
  7803                                  ;screenpos: ; hw = (cursor) row, lw = (cursor) column
  7804                                  	;resd 1
  7805                                  
  7806 00003350 ????????                wcolor:	resd 1
  7807                                  ; 26/12/2024
  7808                                  ;tcolor: resb 1 ; text color
  7809                                  columns:
  7810 00003354 ??                      	resb 1
  7811 00003355 ??                      pbprev:	resb 1 ; previous progress bar indicator position
  7812                                  
  7813 00003356 ????                    alignb 4
  7814                                  
  7815                                  bss_start:
  7816                                  
  7817                                  ; 29/12/2024
  7818                                  audio_buffer:
  7819 00003358 ????????                	resd 1
  7820                                  
  7821                                  ; 30/12/2024
  7822                                  prev_points:
  7823 0000335C <res 500h>              	resd 320 ; previous wave points (which are lighting)	
  7824                                  
  7825                                  ; 18/11/2024
  7826                                  stopped:
  7827 0000385C ??                      	resb 1
  7828 0000385D ??                      tLO:	resb 1
  7829                                  ; 21/11/2024
  7830 0000385E ??                      tLP:	resb 1
  7831                                  ; 30/12/2024
  7832                                  wpoints:
  7833 0000385F ??                      	resb 1
  7834 00003860 ????????                pbuf_o:	resd 1
  7835                                  ; 29/12/2024
  7836 00003864 ????????                pbuf_s:	resd 1
  7837                                  
  7838                                  ; 07/12/2024
  7839                                  ; 24/11/2024
  7840                                  half_buffer:
  7841 00003868 ??                      	resb 1	; dma half buffer 1 or 2 (0 or 1)
  7842                                  
  7843                                  ; 30/05/2024
  7844 00003869 ??                      VRA:	resb 1	; Variable Rate Audio Support Status
  7845                                  
  7846                                  ; 25/12/2024
  7847                                  ; 29/11/2024
  7848                                  command:
  7849 0000386A ??                      	resb 1
  7850                                  filecount:
  7851 0000386B ??                      	resb 1
  7852                                  
  7853                                  ; 30/11/2024
  7854                                  alignb 4
  7855                                  
  7856                                  ;;;;;;;;;;;;;;
  7857                                  ; 14/11/2024
  7858                                  ; (Ref: player.asm, Matan Alfasi, 2017)  
  7859                                  WAVFILEHEADERbuff:
  7860                                  RIFF_ChunkID:
  7861 0000386C ????????                	resd 1	; Must be equal to "RIFF" - big-endian
  7862                                  		; 0x52494646
  7863                                  RIFF_ChunkSize:
  7864 00003870 ????????                	resd 1	; Represents total file size, not 
  7865                                          	; including the first 2 fields 
  7866                                  		; (Total_File_Size - 8), little-endian
  7867                                  RIFF_Format:
  7868 00003874 ????????                	resd 1	; Must be equal to "WAVE" - big-endian
  7869                                  		; 0x57415645
  7870                                  
  7871                                  ;; WAVE header parameters ("Sub-chunk")
  7872                                  WAVE_SubchunkID:
  7873 00003878 ????????                	resd 1	; Must be equal to "fmt " - big-endian
  7874                                  		; 0x666d7420
  7875                                  WAVE_SubchunkSize:
  7876 0000387C ????????                	resd 1	; Represents total chunk size
  7877                                  WAVE_AudioFormat:
  7878 00003880 ????                    	resw 1	; PCM (Raw) - is 1, other - is a form 
  7879                                  		; of compression, not supported.
  7880                                  WAVE_NumChannels:
  7881 00003882 ????                    	resw 1	; Number of channels, Mono-1, Stereo-2
  7882                                  WAVE_SampleRate:
  7883 00003884 ????????                	resd 1	; Frequency rate, in Hz (8000, 44100 ...)
  7884                                  WAVE_ByteRate:
  7885 00003888 ????????                	resd 1	; SampleRate * NumChannels * BytesPerSample
  7886                                  WAVE_BlockAlign:
  7887 0000388C ????                    	resw 1	; NumChannels * BytesPerSample
  7888                                  		; Number of bytes for one sample.
  7889                                  WAVE_BitsPerSample:
  7890 0000388E ????                    	resw 1	; 8 = 8 bits, 16 = 16 bits, etc.
  7891                                  
  7892                                  ;; DATA header parameters
  7893                                  DATA_SubchunkID:
  7894 00003890 ????????                	resd 1	; Must be equal to "data" - big-endian
  7895                                          	; 0x64617461
  7896                                  DATA_SubchunkSize:
  7897 00003894 ????????                	resd 1	; NumSamples * NumChannels * BytesPerSample
  7898                                          	; Number of bytes in the data.
  7899                                  ;;;;;;;;;;;;;;
  7900                                  
  7901                                  ; 28/12/2024
  7902                                  ; 15/11/2024
  7903                                  ;cursortype:
  7904 00003898 ????                    	resw 1
  7905 0000389A ??                      flags:	resb 1
  7906                                  ; 06/11/2023
  7907                                  ac97_int_ln_reg:
  7908 0000389B ??                      	resb 1
  7909                                  filehandle:
  7910 0000389C ????????                	resd 1
  7911                                  
  7912                                  ; 25/12/2024
  7913                                  ; 30/11/2024
  7914                                  ;argc:	resb 1	; argument count
  7915 000038A0 ????????                argv:	resd 1	; current argument (wav file) ptr
  7916 000038A4 ????????                argvf:	resd 1	; 1st argument (wav file) ptr
  7917 000038A8 ????????                argvl:	resd 1	; last argument (wav file) ptr
  7918                                  
  7919                                  ; 30/05/2024
  7920                                  wav_file_name:
  7921 000038AC <res 50h>               	resb 80	; wave file, path name (<= 80 bytes)
  7922 000038FC ????                    	resw 1	; 30/11/2024
  7923                                  
  7924                                  ; 08/11/2023
  7925                                  ; 07/11/2023
  7926                                  fbs_shift:
  7927 000038FE ??                      	resb 1
  7928                                  ; 07/12/2024
  7929 000038FF ??                      SRB:	resb 1
  7930                                  
  7931                                  ; 12/11/2016 - Erdogan Tan
  7932                                  bus_dev_fn:
  7933 00003900 ????????                	resd 1
  7934                                  dev_vendor:
  7935 00003904 ????????                	resd 1
  7936                                  
  7937                                  ; 17/02/2017
  7938                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  7939                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  7940                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  7941                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  7942 00003908 ????                    NAMBAR:	resw 1	; BAR for mixer
  7943                                  NABMBAR:
  7944 0000390A ????                    	resw 1	; BAR for bus master regs
  7945                                  
  7946                                  ; 15/11/2024
  7947                                  loadfromwavfile:
  7948 0000390C ????????                	resd 1	; 'loadfromfile' or load+conversion proc address
  7949                                  loadsize:
  7950 00003910 ????????                	resd 1	; (.wav file) read count (bytes) per one time
  7951                                  buffersize:
  7952 00003914 ????????                	resd 1	; 16 bit samples (not bytes)
  7953                                  		
  7954                                  ; 14/11/2024
  7955                                  TotalTime:
  7956 00003918 ????????                	resd 1	; Total (WAV File) Playing Time in seconds
  7957                                  ProgressTime:
  7958 0000391C ????????                	resd 1
  7959 00003920 ????????                count:	resd 1	; byte count of one (wav file) read
  7960                                  LoadedDataBytes:
  7961 00003924 ????????                	resd 1	; total read/load count
  7962                                  
  7963                                  timerticks:
  7964 00003928 ????????                	resd 1	; (to eliminate excessive lookup of events in tuneloop)
  7965                                  		; (in order to get the emulator/qemu to run correctly)
  7966                                  ; 01/12/2024
  7967                                  _bdl_buffer:
  7968 0000392C ????????                	resd 1
  7969                                  
  7970                                  ; 14/11/2024
  7971                                  bss_end:
  7972                                  
  7973                                  ; 29/12/2024
  7974 00003930 <res 6D0h>              alignb 4096
  7975                                  
  7976                                  ; 01/12/2024
  7977                                  BDL_BUFFER:
  7978 00004000 <res 100h>              	resb 256
  7979                                  	; 02/12/2024
  7980 00004100 <res F00h>              	resb 4096-256
  7981                                  
  7982                                  ;alignb 4096
  7983                                  
  7984                                  ; 29/05/2024
  7985                                  WAVBUFFER_1:
  7986 00005000 <res 10000h>            	resb 65536
  7987                                  WAVBUFFER_2:
  7988 00015000 <res 10000h>            	resb 65536
  7989                                  
  7990                                  ; 01/12/2024
  7991                                  ; 26/11/2023
  7992                                  temp_buffer:
  7993 00025000 <res 10000h>            	resb 65536  ;  resb BUFFERSIZE
