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