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