     1                                  ; ****************************************************************************
     2                                  ; playwav7.s (for TRDOS 386)
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; PLAYWAV7.PRG ! AC'97 (ICH) .WAV PLAYER program by Erdogan TAN
     5                                  ;
     6                                  ; 29/05/2024
     7                                  ;
     8                                  ; [ Last Modification: 01/06/2024 ]
     9                                  ;
    10                                  ; Modified from PLAYWAV6.PRG .wav player program by Erdogan Tan, 27/11/2023
    11                                  ; Modified from PLAYWAV4.COM .wav player program by Erdogan Tan, 19/05/2024
    12                                  ;
    13                                  ; Assembler: NASM version 2.15
    14                                  ;	     nasm playwav7.s -l playwav7.txt -o PLAYWAV7.PRG	
    15                                  ; ----------------------------------------------------------------------------
    16                                  ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
    17                                  
    18                                  ; tuneloop (user mode) version (29/05/2024
    19                                  
    20                                  ; previous version: playwav6.s (27/11/2023)
    21                                  
    22                                  ; CODE
    23                                  
    24                                  ; 14/07/2020
    25                                  ; 31/12/2017
    26                                  ; TRDOS 386 (v2.0) system calls
    27                                  _ver 	equ 0
    28                                  _exit 	equ 1
    29                                  _fork 	equ 2
    30                                  _read 	equ 3
    31                                  _write	equ 4
    32                                  _open	equ 5
    33                                  _close 	equ 6
    34                                  _wait 	equ 7
    35                                  _create	equ 8
    36                                  _rename	equ 9
    37                                  _delete	equ 10
    38                                  _exec	equ 11
    39                                  _chdir	equ 12
    40                                  _time 	equ 13
    41                                  _mkdir 	equ 14
    42                                  _chmod	equ 15
    43                                  _rmdir	equ 16
    44                                  _break	equ 17
    45                                  _drive	equ 18
    46                                  _seek	equ 19
    47                                  _tell 	equ 20
    48                                  _memory	equ 21
    49                                  _prompt	equ 22
    50                                  _path	equ 23
    51                                  _env	equ 24
    52                                  _stime	equ 25
    53                                  _quit	equ 26
    54                                  _intr	equ 27
    55                                  _dir	equ 28
    56                                  _emt 	equ 29
    57                                  _ldrvt 	equ 30
    58                                  _video 	equ 31
    59                                  _audio	equ 32
    60                                  _timer	equ 33
    61                                  _sleep	equ 34
    62                                  _msg    equ 35
    63                                  _geterr	equ 36
    64                                  _fpstat	equ 37
    65                                  _pri	equ 38
    66                                  _rele	equ 39
    67                                  _fff	equ 40
    68                                  _fnf	equ 41
    69                                  _alloc	equ 42
    70                                  _dalloc equ 43
    71                                  _calbac equ 44
    72                                  _dma	equ 45
    73                                  
    74                                  %macro sys 1-4
    75                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    76                                      ; 03/09/2015	
    77                                      ; 13/04/2015
    78                                      ; Retro UNIX 386 v1 system call.	
    79                                      %if %0 >= 2   
    80                                          mov ebx, %2
    81                                          %if %0 >= 3    
    82                                              mov ecx, %3
    83                                              %if %0 = 4
    84                                                 mov edx, %4   
    85                                              %endif
    86                                          %endif
    87                                      %endif
    88                                      mov eax, %1
    89                                      ;int 30h
    90                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
    91                                  %endmacro
    92                                  
    93                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
    94                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    95                                  
    96                                  ;BUFFERSIZE	equ	32768	; audio buffer size 
    97                                  ENDOFFILE       equ     1	; flag for knowing end of file
    98                                  
    99                                  [BITS 32]
   100                                  
   101                                  [ORG 0]
   102                                  
   103                                  	; 29/05/2024
   104                                  	%include 'ac97.inc' ; 17/02/2017 
     1                              <1> ; 11/11/2023
     2                              <1> ; 05/11/2023
     3                              <1> ; 03/11/2023
     4                              <1> ; 17/02/2017 (Erdogan Tan, PLAYWAV.ASM)
     5                              <1> ; constant.inc & codec.inc (for ICH AC97 wav player, 'PLAYWAV.COM') 
     6                              <1> 
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; CONSTANT.INC
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> 
    11                              <1> ;constants of stuff that seem hard to remember at times.
    12                              <1> 
    13                              <1> TRUE  EQU 1
    14                              <1> FALSE EQU 0
    15                              <1> 
    16                              <1> ENABLED  EQU 1
    17                              <1> DISABLED EQU 0
    18                              <1> 
    19                              <1> BIT0  EQU 1
    20                              <1> BIT1  EQU 2
    21                              <1> BIT2  EQU 4
    22                              <1> BIT3  EQU 8
    23                              <1> BIT4  EQU 10h
    24                              <1> BIT5  EQU 20h
    25                              <1> BIT6  EQU 40h
    26                              <1> BIT7  EQU 80h
    27                              <1> BIT8  EQU 100h
    28                              <1> BIT9  EQU 200h
    29                              <1> BIT10 EQU 400h
    30                              <1> BIT11 EQU 800h
    31                              <1> BIT12 EQU 1000h
    32                              <1> BIT13 EQU 2000h
    33                              <1> BIT14 EQU 4000h
    34                              <1> BIT15 EQU 8000h
    35                              <1> BIT16 EQU 10000h
    36                              <1> BIT17 EQU 20000h
    37                              <1> BIT18 EQU 40000h
    38                              <1> BIT19 EQU 80000h
    39                              <1> BIT20 EQU 100000h
    40                              <1> BIT21 EQU 200000h
    41                              <1> BIT22 EQU 400000h
    42                              <1> BIT23 EQU 800000h
    43                              <1> BIT24 EQU 1000000h
    44                              <1> BIT25 EQU 2000000h
    45                              <1> BIT26 EQU 4000000h
    46                              <1> BIT27 EQU 8000000h
    47                              <1> BIT28 EQU 10000000h
    48                              <1> BIT29 EQU 20000000h
    49                              <1> BIT30 EQU 40000000h
    50                              <1> BIT31 EQU 80000000h
    51                              <1> 
    52                              <1> ;special characters
    53                              <1> NUL     EQU 0
    54                              <1> NULL    EQU 0
    55                              <1> BELL    EQU 07
    56                              <1> BS      EQU 08
    57                              <1> TAB     EQU 09
    58                              <1> LF      EQU 10
    59                              <1> CR      EQU 13
    60                              <1> ESCAPE  EQU 27           ;ESC is a reserved word....
    61                              <1> 
    62                              <1> 
    63                              <1> ;file stuff
    64                              <1> READONLY  EQU   BIT0
    65                              <1> HIDDEN    EQU   BIT1
    66                              <1> SYSTEM    EQU   BIT2
    67                              <1> VOLUME    EQU   BIT3         ;ignored for file access
    68                              <1> DIRECTORY EQU   BIT4         ;must be 0 for file access
    69                              <1> ARCHIVE   EQU   BIT5
    70                              <1> SHAREABLE EQU   BIT7         ;for novell networks
    71                              <1> OPEN	EQU	2		; open existing file
    72                              <1> CREATE	EQU	1		; create new file
    73                              <1> 
    74                              <1> 
    75                              <1> ; PCI equates
    76                              <1> ; PCI function address (PFA)
    77                              <1> ; bit 31 = 1
    78                              <1> ; bit 23:16 = bus number     (0-255)
    79                              <1> ; bit 15:11 = device number  (0-31)
    80                              <1> ; bit 10:8 = function number (0-7)
    81                              <1> ; bit 7:0 = register number  (0-255)
    82                              <1> 
    83                              <1> IO_ADDR_MASK    EQU     0FFFEh          ; mask off bit 0 for reading BARs
    84                              <1> PCI_INDEX_PORT  EQU     0CF8h
    85                              <1> PCI_DATA_PORT   EQU     0CFCh
    86                              <1> PCI32           EQU     BIT31           ; bitflag to signal 32bit access
    87                              <1> PCI16           EQU     BIT30           ; bitflag for 16bit access
    88                              <1> 
    89                              <1> PCI_FN0         EQU     0 << 8
    90                              <1> PCI_FN1         EQU     1 << 8
    91                              <1> PCI_FN2         EQU     2 << 8
    92                              <1> PCI_FN3         EQU     3 << 8
    93                              <1> PCI_FN4         EQU     4 << 8
    94                              <1> PCI_FN5         EQU     5 << 8
    95                              <1> PCI_FN6         EQU     6 << 8
    96                              <1> PCI_FN7         EQU     7 << 8
    97                              <1> 
    98                              <1> PCI_CMD_REG		EQU	04h		; reg 04, command reg
    99                              <1>  IO_ENA			EQU	BIT0		; i/o decode enable
   100                              <1>  MEM_ENA		EQU	BIT1		; memory decode enable
   101                              <1>  BM_ENA                 EQU     BIT2		; bus master enable
   102                              <1> 
   103                              <1> ; ----------------------------------------------------------------------------
   104                              <1> ; CODEC.INC
   105                              <1> ; ----------------------------------------------------------------------------
   106                              <1> 
   107                              <1> ;Codec registers.
   108                              <1> ;
   109                              <1> ;Not all codecs are created equal. Refer to the spec for your specific codec.
   110                              <1> ;
   111                              <1> ;All registers are 16bits wide.  Access to codec registers over the AC97 link
   112                              <1> ;is defined by the OEM.  
   113                              <1> ;
   114                              <1> ;Secondary codec's are accessed by ORing in BIT7 of all register accesses.
   115                              <1> ;
   116                              <1> 
   117                              <1> ; each codec/mixer register is 16bits
   118                              <1> 
   119                              <1> CODEC_RESET_REG                 equ     00      ; reset codec
   120                              <1> CODEC_MASTER_VOL_REG            equ     02      ; master volume
   121                              <1> CODEC_HP_VOL_REG                equ     04      ; headphone volume
   122                              <1> CODEC_MASTER_MONO_VOL_REG       equ     06      ; master mono volume
   123                              <1> CODEC_MASTER_TONE_REG           equ     08      ; master tone (R+L)
   124                              <1> CODEC_PCBEEP_VOL_REG            equ     0ah     ; PC beep volume
   125                              <1> CODEC_PHONE_VOL_REG             equ     0bh     ; phone volume
   126                              <1> CODEC_MIC_VOL_REG               equ     0eh     ; MIC volume
   127                              <1> CODEC_LINE_IN_VOL_REG           equ     10h     ; line input volume
   128                              <1> CODEC_CD_VOL_REG                equ     12h     ; CD volume
   129                              <1> CODEC_VID_VOL_REG               equ     14h     ; video volume
   130                              <1> CODEC_AUX_VOL_REG               equ     16h     ; aux volume
   131                              <1> CODEC_PCM_OUT_REG               equ     18h     ; PCM output volume
   132                              <1> CODEC_RECORD_SELECT_REG         equ     1ah     ; record select input
   133                              <1> CODEC_RECORD_VOL_REG            equ     1ch     ; record volume
   134                              <1> CODEC_RECORD_MIC_VOL_REG        equ     1eh     ; record mic volume
   135                              <1> CODEC_GP_REG                    equ     20h     ; general purpose
   136                              <1> CODEC_3D_CONTROL_REG            equ     22h     ; 3D control
   137                              <1> ; 24h is reserved
   138                              <1> CODEC_POWER_CTRL_REG            equ     26h     ; powerdown control
   139                              <1> CODEC_EXT_AUDIO_REG             equ     28h     ; extended audio
   140                              <1> CODEC_EXT_AUDIO_CTRL_REG        equ     2ah     ; extended audio control
   141                              <1> CODEC_PCM_FRONT_DACRATE_REG     equ     2ch     ; PCM out sample rate
   142                              <1> CODEC_PCM_SURND_DACRATE_REG     equ     2eh     ; surround sound sample rate
   143                              <1> CODEC_PCM_LFE_DACRATE_REG       equ     30h     ; LFE sample rate
   144                              <1> CODEC_LR_ADCRATE_REG            equ     32h     ; PCM in sample rate
   145                              <1> CODEC_MIC_ADCRATE_REG           equ     34h     ; mic in sample rate
   146                              <1> 
   147                              <1> ; registers 36-7a are reserved on the ICH
   148                              <1> 
   149                              <1> CODEC_VENDORID1_REG             equ     7ch     ; codec vendor ID 1
   150                              <1> CODEC_VENDORID2_REG             equ     7eh     ; codec vendor ID 2
   151                              <1> 
   152                              <1> ; Mixer registers 0 through 51h reside in the ICH and are not forwarded over
   153                              <1> ; the AC97 link to the codec, which I think is a little weird.  Looks like
   154                              <1> ; the ICH makes it so you don't need a fully functional codec to play audio?
   155                              <1> ;
   156                              <1> ; whenever 2 codecs are present in the system, use BIT7 to access the 2nd
   157                              <1> ; set of registers, ie 80h-feh
   158                              <1> 
   159                              <1> PRIMARY_CODEC                   equ     0       ; 0-7F for primary codec
   160                              <1> SECONDARY_CODEC                 equ     BIT7    ; 80-8f registers for 2ndary
   161                              <1> 
   162                              <1> SAMPLE_RATE_441khz	equ     44100   ; 44.1Khz (cd quality) rate
   163                              <1> 
   164                              <1> ; ----------------------------------------------------------------------------
   165                              <1> ; 17/02/2017
   166                              <1> PCI_IO_BASE	equ 10h			; = NAMBAR register offset
   167                              <1> AC97_INT_LINE   equ 3Ch			; AC97 Interrupt Line register offset
   168                              <1> 
   169                              <1> ; ----------------------------------------------------------------------------
   170                              <1> ; ICH2AC97.INC
   171                              <1> ; ----------------------------------------------------------------------------
   172                              <1> 
   173                              <1> ; PCI stuff
   174                              <1> 
   175                              <1> ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
   176                              <1> 
   177                              <1> INTEL_VID       equ     8086h           ; Intel's PCI vendor ID
   178                              <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
   179                              <1> SIS_VID		equ	1039h
   180                              <1> NVIDIA_VID	equ	10DEh	 ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
   181                              <1> AMD_VID		equ	1022h
   182                              <1> 
   183                              <1> ICH_DID         equ     2415h           ; ICH device ID
   184                              <1> ICH0_DID        equ     2425h           ; ICH0
   185                              <1> ICH2_DID        equ     2445h           ; ICH2 I think there are more ICHes.
   186                              <1>                                         ; they all should be compatible.
   187                              <1> 
   188                              <1> ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
   189                              <1> ICH3_DID	equ     2485h           ; ICH3
   190                              <1> ICH4_DID        equ     24C5h           ; ICH4
   191                              <1> ICH5_DID	equ     24D5h           ; ICH5 
   192                              <1> ICH6_DID	equ     266Eh           ; ICH6
   193                              <1> ESB6300_DID	equ     25A6h           ; 6300ESB
   194                              <1> ESB631X_DID	equ     2698h           ; 631XESB
   195                              <1> ICH7_DID	equ	27DEh		; ICH7
   196                              <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
   197                              <1> MX82440_DID	equ	7195h
   198                              <1> SI7012_DID	equ	7012h
   199                              <1> NFORCE_DID	equ	01B1h
   200                              <1> NFORCE2_DID	equ	006Ah
   201                              <1> AMD8111_DID	equ	746Dh
   202                              <1> AMD768_DID	equ	7445h
   203                              <1> ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
   204                              <1> CK804_DID	equ	0059h
   205                              <1> MCP04_DID	equ	003Ah
   206                              <1> CK8_DID		equ	008Ah
   207                              <1> NFORCE3_DID	equ	00DAh
   208                              <1> CK8S_DID	equ	00EAh
   209                              <1> 
   210                              <1> NAMBAR_REG      equ     10h             ; native audio mixer BAR
   211                              <1>  NAM_SIZE       equ     256             ; 256 bytes required.
   212                              <1> 
   213                              <1> NABMBAR_REG     equ     14h             ; native audio bus mastering BAR
   214                              <1>  NABM_SIZE      equ     64              ; 64 bytes
   215                              <1> 
   216                              <1> ; BUS master registers, accessed via NABMBAR+offset
   217                              <1> 
   218                              <1> ; ICH supports 3 different types of register sets for three types of things
   219                              <1> ; it can do, thus:
   220                              <1> ;
   221                              <1> ; PCM in (for recording) aka PI
   222                              <1> ; PCM out (for playback) aka PO
   223                              <1> ; MIC in (for recording) aka MC
   224                              <1> 
   225                              <1> PI_BDBAR_REG            equ     0       ; PCM in buffer descriptor BAR
   226                              <1> PO_BDBAR_REG            equ     10h     ; PCM out buffer descriptor BAR
   227                              <1> MC_BDBAR_REG            equ     20h     ; MIC in buffer descriptor BAR
   228                              <1> 
   229                              <1> ; each buffer descriptor BAR holds a pointer which has entries to the buffer
   230                              <1> ; contents of the .WAV file we're going to play. Each entry is 8 bytes long
   231                              <1> ; (more on that later) and can contain 32 entries total, so each BAR is
   232                              <1> ; 256 bytes in length, thus:
   233                              <1> 
   234                              <1> BDL_SIZE                equ     32*8    ; Buffer Descriptor List size
   235                              <1> INDEX_MASK              equ     31      ; indexes must be 0-31
   236                              <1> 
   237                              <1> 
   238                              <1> 
   239                              <1> PI_CIV_REG              equ     4       ; PCM in current Index value (RO)
   240                              <1> PO_CIV_REG              equ     14h     ; PCM out current Index value (RO)
   241                              <1> MC_CIV_REG              equ     24h     ; MIC in current Index value (RO)
   242                              <1> ;8bit read only
   243                              <1> ; each current index value is simply a pointer showing us which buffer
   244                              <1> ; (0-31) the codec is currently processing. Once this counter hits 31, it
   245                              <1> ; wraps back to 0.
   246                              <1> ; this can be handy to know, as once it hits 31, we're almost out of data to
   247                              <1> ; play back or room to record!
   248                              <1> 
   249                              <1> 
   250                              <1> PI_LVI_REG              equ     5       ; PCM in Last Valid Index
   251                              <1> PO_LVI_REG              equ     15h     ; PCM out Last Valid Index
   252                              <1> MC_LVI_REG              equ     25h     ; MIC in Last Valid Index
   253                              <1> ;8bit read/write
   254                              <1> ; The Last Valid Index is a number (0-31) to let the codec know what buffer
   255                              <1> ; number to stop on after processing. It could be very nasty to play audio
   256                              <1> ; from buffers that aren't filled with the audio we want to play.
   257                              <1> 
   258                              <1> 
   259                              <1> PI_SR_REG               equ     6       ; PCM in Status register
   260                              <1> PO_SR_REG               equ     16h     ; PCM out Status register
   261                              <1> MC_SR_REG               equ     26h     ; MIC in Status register
   262                              <1> ;16bit read/write
   263                              <1> ; status registers.  Bitfields follow:
   264                              <1> 
   265                              <1> FIFO_ERR                equ     BIT4    ; FIFO Over/Underrun W1TC.
   266                              <1> 
   267                              <1> BCIS                    equ     BIT3    ; buffer completion interrupt status.
   268                              <1>                                         ; Set whenever the last sample in ANY
   269                              <1>                                         ; buffer is finished.  Bit is only
   270                              <1>                                         ; set when the Interrupt on Complete
   271                              <1>                                         ; (BIT4 of control reg) is set.
   272                              <1> 
   273                              <1> LVBCI                   equ     BIT2    ; Set whenever the codec has processed
   274                              <1>                                         ; the last buffer in the buffer list.
   275                              <1>                                         ; Will fire an interrupt if IOC bit is
   276                              <1>                                         ; set. Probably set after the last
   277                              <1>                                         ; sample in the last buffer is
   278                              <1>                                         ; processed.  W1TC
   279                              <1> 
   280                              <1>                                         ; 
   281                              <1> CELV                    equ     BIT1    ; Current buffer == last valid.
   282                              <1>                                         ; Bit is RO and remains set until LVI is
   283                              <1>                                         ; cleared.  Probably set up the start
   284                              <1>                                         ; of processing for the last buffer.
   285                              <1> 
   286                              <1> 
   287                              <1> DCH                     equ     BIT0    ; DMA controller halted.
   288                              <1>                                         ; set whenever audio stream is stopped
   289                              <1>                                         ; or something else goes wrong.
   290                              <1> 
   291                              <1> 
   292                              <1> PI_PICB_REG             equ     8       ; PCM in position in current buffer(RO)
   293                              <1> PO_PICB_REG             equ     18h     ; PCM out position in current buffer(RO)
   294                              <1> MC_PICB_REG             equ     28h     ; MIC in position in current buffer (RO)
   295                              <1> ;16bit read only
   296                              <1> ; position in current buffer regs show the number of dwords left to be
   297                              <1> ; processed in the current buffer.
   298                              <1> ; 
   299                              <1> 
   300                              <1> PI_PIV_REG              equ     0ah     ; PCM in Prefected index value
   301                              <1> PO_PIV_REG              equ     1ah     ; PCM out Prefected index value
   302                              <1> MC_PIV_REG              equ     2ah     ; MIC in Prefected index value
   303                              <1> ;8bit, read only
   304                              <1> ; Prefetched index value register.
   305                              <1> ; tells which buffer number (0-31) has be prefetched. I'd imagine this
   306                              <1> ; value follows the current index value fairly closely. (CIV+1)
   307                              <1> ;
   308                              <1> 
   309                              <1> 
   310                              <1> PI_CR_REG               equ     0bh     ; PCM in Control Register
   311                              <1> PO_CR_REG               equ     1bh     ; PCM out Control Register
   312                              <1> MC_CR_REG               equ     2bh     ; MIC in Control Register
   313                              <1> ; 8bit
   314                              <1> ; Control register *MUST* only be accessed as an 8bit value.
   315                              <1> ; Control register. See bitfields below.
   316                              <1> ;
   317                              <1> 
   318                              <1> 
   319                              <1> IOCE                    equ     BIT4    ; interrupt on complete enable.
   320                              <1>                                         ; set this bit if you want an intrtpt
   321                              <1>                                         ; to fire whenever LVBCI is set.
   322                              <1> FEIFE                   equ     BIT3    ; set if you want an interrupt to fire
   323                              <1>                                         ; whenever there is a FIFO (over or
   324                              <1>                                         ; under) error.
   325                              <1> LVBIE                   equ     BIT2    ; last valid buffer interrupt enable.
   326                              <1>                                         ; set if you want an interrupt to fire
   327                              <1>                                         ; whenever the completion of the last
   328                              <1>                                         ; valid buffer.
   329                              <1> RR                      equ     BIT1    ; reset registers.  Nukes all regs
   330                              <1>                                         ; except bits 4:2 of this register.
   331                              <1>                                         ; Only set this bit if BIT 0 is 0
   332                              <1> RPBM                    equ     BIT0    ; Run/Pause
   333                              <1>                                         ; set this bit to start the codec!
   334                              <1> 
   335                              <1> 
   336                              <1> GLOB_CNT_REG            equ     2ch     ; Global control register
   337                              <1> SEC_RES_EN              equ     BIT5    ; secondary codec resume event 
   338                              <1>                                         ; interrupt enable.  Not used here.
   339                              <1> PRI_RES_EN              equ     BIT4    ; ditto for primary. Not used here.
   340                              <1> ACLINK_OFF              equ     BIT3    ; Turn off the AC97 link
   341                              <1> ACWARM_RESET            equ     BIT2    ; Awaken the AC97 link from sleep.
   342                              <1>                                         ; registers preserved, bit self clears
   343                              <1> ACCOLD_RESET            equ     BIT1    ; Reset everything in the AC97 and
   344                              <1>                                         ; reset all registers.  Not self clearing
   345                              <1> 
   346                              <1> GPIIE                   equ     BIT0    ; GPI Interrupt enable.
   347                              <1>                                         ; set if you want an interrupt to
   348                              <1>                                         ; fire upon ANY of the bits in the
   349                              <1>                                         ; GPI (general pursose inputs?) not used.
   350                              <1> 
   351                              <1> GLOB_STS_REG            equ     30h     ; Global Status register (RO)
   352                              <1> 
   353                              <1> MD3                     equ     BIT17   ; modem powerdown status (yawn)
   354                              <1> AD3                     equ     BIT16   ; Audio powerdown status (yawn)
   355                              <1> RD_COMPLETE_STS         equ     BIT15   ; Codec read timed out. 0=normal
   356                              <1> BIT3SLOT12              equ     BIT14   ; shadowed status of bit 3 in slot 12
   357                              <1> BIT2SLOT12              equ     BIT13   ; shadowed status of bit 2 in slot 12
   358                              <1> BIT1SLOT12              equ     BIT12   ; shadowed status of bit 1 in slot 12
   359                              <1> SEC_RESUME_STS          equ     BIT11   ; secondary codec has resumed (and irqed)
   360                              <1> PRI_RESUME_STS          equ     BIT10   ; primary codec has resumed (and irqed)
   361                              <1> SEC_CODEC_RDY           equ     BIT9    ; secondary codec is ready for action
   362                              <1> PRI_CODEC_RDY           equ     BIT8    ; Primary codec is ready for action
   363                              <1>                                         ; software must check these bits before
   364                              <1>                                         ; starting the codec!
   365                              <1> MIC_IN_IRQ              equ     BIT7    ; MIC in caused an interrupt
   366                              <1> PCM_OUT_IRQ             equ     BIT6    ; One of the PCM out channels IRQed
   367                              <1> PCM_IN_IRQ              equ     BIT5    ; One of the PCM in channels IRQed
   368                              <1> MODEM_OUT_IRQ           equ     BIT2    ; modem out channel IRQed
   369                              <1> MODEM_IN_IRQ            equ     BIT1    ; modem in channel IRQed
   370                              <1> GPI_STS_CHANGE          equ     BIT0    ; set whenever GPI's have changed.
   371                              <1>                                         ; BIT0 of slot 12 also reflects this.
   372                              <1> 
   373                              <1> ACC_SEMA_REG            equ     34h     ; Codec write semiphore register
   374                              <1> CODEC_BUSY              equ     BIT0    ; codec register I/O is happening
   375                              <1>                                         ; self clearing
   376                              <1> ;
   377                              <1> ; Buffer Descriptors List
   378                              <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32 
   379                              <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
   380                              <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
   381                              <1> ; entry describe various control things detailed below.
   382                              <1> ; 
   383                              <1> ; Buffer pointers must always be aligned on a Dword boundry.
   384                              <1> ;
   385                              <1> 
   386                              <1> IOC                     equ     BIT31   ; Fire an interrupt whenever this
   387                              <1>                                         ; buffer is complete.
   388                              <1> 
   389                              <1> BUP                     equ     BIT30   ; Buffer Underrun Policy.
   390                              <1>                                         ; if this buffer is the last buffer
   391                              <1>                                         ; in a playback, fill the remaining
   392                              <1>                                         ; samples with 0 (silence) or not.
   393                              <1>                                         ; It's a good idea to set this to 1
   394                              <1>                                         ; for the last buffer in playback,
   395                              <1>                                         ; otherwise you're likely to get a lot
   396                              <1>                                         ; of noise at the end of the sound.
   397                              <1> 
   398                              <1> ;
   399                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
   400                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
   401                              <1> ; Luckily for us, that's the same format as .wav files.
   402                              <1> ;
   403                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
   404                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
   405                              <1> ;
   406                              <1> ; A value of 0 in these bits means play no samples.
   407                              <1> ;
   408                              <1> 
   409                              <1> ; 11/11/2023
   410                              <1> CTRL_ST_CREADY		equ	BIT8+BIT9+BIT28 ; Primary Codec Ready
   411                              <1> CODEC_REG_POWERDOWN	equ	26h
   105                                  
   106                                  _STARTUP:
   107                                  	; Prints the Credits Text.
   108                                  	sys	_msg, Credits, 255, 0Bh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000000 BB[56250000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000005 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000000A BA0B000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000000F B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000014 CD40                <1>  int 40h
   109                                  
   110                                  	; clear bss
   111 00000016 B9[F6280000]            	mov	ecx, bss_end
   112 0000001B BF[69280000]            	mov	edi, bss_start
   113 00000020 29F9                    	sub	ecx, edi
   114 00000022 D1E9                    	shr	ecx, 1
   115 00000024 31C0                    	xor	eax, eax
   116 00000026 F366AB                  	rep	stosw
   117                                  
   118                                  	; Detect (& Enable) AC'97 Audio Device
   119 00000029 E80D050000              	call	DetectAC97
   120 0000002E 731B                    	jnc     short GetFileName
   121                                  
   122                                  _dev_not_ready:
   123                                  	; couldn't find the audio device!
   124                                  	sys	_msg, noDevMsg, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000030 BB[0C260000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000035 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000003A BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000003F B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000044 CD40                <1>  int 40h
   125 00000046 E979030000                      jmp     Exit
   126                                  
   127                                  GetFileName:  
   128 0000004B 89E6                    	mov	esi, esp
   129 0000004D AD                      	lodsd
   130 0000004E 83F802                  	cmp	eax, 2 ; two arguments 
   131                                  	       ; (program file name & mod file name)
   132 00000051 0F827B030000            	jb	pmsg_usage ; nothing to do
   133                                  
   134 00000057 AD                      	lodsd ; program file name address 
   135 00000058 AD                      	lodsd ; mod file name address (file to be read)
   136 00000059 89C6                    	mov	esi, eax
   137 0000005B BF[8E280000]            	mov	edi, wav_file_name
   138                                  ScanName:       
   139 00000060 AC                      	lodsb
   140 00000061 84C0                    	test	al, al
   141 00000063 0F8469030000            	je	pmsg_usage
   142 00000069 3C20                    	cmp	al, 20h
   143 0000006B 74F3                    	je	short ScanName	; scan start of name.
   144 0000006D AA                      	stosb
   145 0000006E B4FF                    	mov	ah, 0FFh
   146                                  a_0:	
   147 00000070 FEC4                    	inc	ah
   148                                  a_1:
   149 00000072 AC                      	lodsb
   150 00000073 AA                      	stosb
   151 00000074 3C2E                    	cmp	al, '.'
   152 00000076 74F8                    	je	short a_0	
   153 00000078 20C0                    	and	al, al
   154 0000007A 75F6                    	jnz	short a_1
   155                                  
   156 0000007C 08E4                    	or	ah, ah		; if period NOT found,
   157 0000007E 750B                    	jnz	short _1 	; then add a .WAV extension.
   158                                  SetExt:
   159 00000080 4F                      	dec	edi
   160 00000081 C7072E574156            	mov	dword [edi], '.WAV'
   161 00000087 C6470400                	mov	byte [edi+4], 0
   162                                  
   163                                  _1:
   164 0000008B E849060000              	call	write_audio_dev_info 
   165                                  
   166                                  ; open the file
   167                                          ; open existing file
   168 00000090 E8F6040000                      call    openFile ; no error? ok.
   169 00000095 731B                            jnc     short _gsr
   170                                  
   171                                  ; file not found!
   172                                  	sys	_msg, noFileErrMsg, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000097 BB[37260000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000009C B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000000A1 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000000A6 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000000AB CD40                <1>  int 40h
   173                                  _exit_:
   174 000000AD E912030000                      jmp     Exit
   175                                  
   176                                  _gsr:  
   177 000000B2 E80E050000                     	call    getSampleRate		; read the sample rate
   178                                                                          ; pass it onto codec.
   179                                  	; 25/11/2023
   180 000000B7 72F4                    	jc	short _exit_		; nothing to do
   181                                  
   182 000000B9 66A3[6E280000]          	mov	[sample_rate], ax
   183 000000BF 880D[6C280000]          	mov	[stmo], cl
   184 000000C5 8815[6D280000]          	mov	[bps], dl
   185                                  
   186                                  	; 26/11/2023
   187 000000CB C605[E1280000]00        	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   188 000000D2 FEC9                    	dec	cl
   189 000000D4 7506                    	jnz	short _gsr_1 ; stereo
   190 000000D6 FE05[E1280000]          	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   191                                  _gsr_1:	
   192 000000DC 80FA08                  	cmp	dl, 8 
   193 000000DF 7706                    	ja	short _gsr_2 ; 16 bit samples
   194 000000E1 FE05[E1280000]          	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   195                                  _gsr_2:	
   196                                  	; 29/05/2024
   197 000000E7 E8CF060000              	call	write_ac97_pci_dev_info
   198                                  
   199                                  	; 31/05/2024
   200                                  	; 30/05/2024
   201                                  	;call	check_vra
   202                                  
   203                                  	; 30/05/2024
   204 000000EC E86B200000              	call	codecConfig		; unmute codec, set rates.
   205 000000F1 0F82F3020000            	jc	init_err
   206                                  
   207                                  	; 25/11/2023
   208 000000F7 E87F080000              	call	write_VRA_info
   209                                  
   210                                  	; 01/05/2017
   211 000000FC E8EF050000              	call	write_wav_file_info
   212                                  
   213                                  	; 25/11/2023
   214                                  	; ------------------------------------------
   215                                  
   216 00000101 803D[71280000]01        	cmp	byte [VRA], 1
   217 00000108 7205                    	jb	short chk_sample_rate
   218                                  
   219                                  playwav_48_khz:	
   220                                  	;mov	dword [loadfromwavfile], loadFromFile
   221                                  	;mov	dword [buffersize], 65536
   222 0000010A E969020000              	jmp	PlayNow
   223                                  
   224                                  chk_sample_rate:
   225                                  	; set conversion parameters
   226                                  	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
   227 0000010F 66A1[6E280000]          	mov	ax, [sample_rate]
   228 00000115 663D80BB                	cmp	ax, 48000
   229 00000119 74EF                    	je	short playwav_48_khz
   230                                  chk_22khz:
   231 0000011B 663D2256                	cmp	ax, 22050
   232 0000011F 7545                    	jne	short chk_11khz
   233 00000121 803D[6D280000]08        	cmp	byte [bps], 8
   234 00000128 7615                    	jna	short chk_22khz_1
   235 0000012A BB[17160000]            	mov	ebx, load_22khz_stereo_16_bit
   236 0000012F 803D[6C280000]01        	cmp	byte [stmo], 1 
   237 00000136 751A                    	jne	short chk_22khz_2
   238 00000138 BB[89150000]            	mov	ebx, load_22khz_mono_16_bit
   239 0000013D EB13                    	jmp	short chk_22khz_2
   240                                  chk_22khz_1:
   241 0000013F BB[01150000]            	mov	ebx, load_22khz_stereo_8_bit
   242 00000144 803D[6C280000]01        	cmp	byte [stmo], 1 
   243 0000014B 7505                    	jne	short chk_22khz_2
   244 0000014D BB[77140000]            	mov	ebx, load_22khz_mono_8_bit
   245                                  chk_22khz_2:
   246 00000152 B85A1D0000              	mov	eax, 7514  ; (442*17)
   247 00000157 BA25000000              	mov	edx, 37
   248 0000015C B911000000              	mov	ecx, 17 
   249 00000161 E9BA010000              	jmp	set_sizes	
   250                                  chk_11khz:
   251 00000166 663D112B                	cmp	ax, 11025
   252 0000016A 7545                    	jne	short chk_44khz
   253 0000016C 803D[6D280000]08        	cmp	byte [bps], 8
   254 00000173 7615                    	jna	short chk_11khz_1
   255 00000175 BB[37180000]            	mov	ebx, load_11khz_stereo_16_bit
   256 0000017A 803D[6C280000]01        	cmp	byte [stmo], 1 
   257 00000181 751A                    	jne	short chk_11khz_2
   258 00000183 BB[BD170000]            	mov	ebx, load_11khz_mono_16_bit
   259 00000188 EB13                    	jmp	short chk_11khz_2
   260                                  chk_11khz_1:
   261 0000018A BB[42170000]            	mov	ebx, load_11khz_stereo_8_bit
   262 0000018F 803D[6C280000]01        	cmp	byte [stmo], 1 
   263 00000196 7505                    	jne	short chk_11khz_2
   264 00000198 BB[C9160000]            	mov	ebx, load_11khz_mono_8_bit
   265                                  chk_11khz_2:
   266 0000019D B8AD0E0000              	mov	eax, 3757  ; (221*17)
   267 000001A2 BA4A000000              	mov	edx, 74
   268 000001A7 B911000000              	mov	ecx, 17
   269 000001AC E96F010000              	jmp	set_sizes 
   270                                  chk_44khz:
   271 000001B1 663D44AC                	cmp	ax, 44100
   272 000001B5 7545                    	jne	short chk_16khz
   273 000001B7 803D[6D280000]08        	cmp	byte [bps], 8
   274 000001BE 7615                    	jna	short chk_44khz_1
   275 000001C0 BB[621A0000]            	mov	ebx, load_44khz_stereo_16_bit
   276 000001C5 803D[6C280000]01        	cmp	byte [stmo], 1 
   277 000001CC 751A                    	jne	short chk_44khz_2
   278 000001CE BB[E8190000]            	mov	ebx, load_44khz_mono_16_bit
   279 000001D3 EB13                    	jmp	short chk_44khz_2
   280                                  chk_44khz_1:
   281 000001D5 BB[6A190000]            	mov	ebx, load_44khz_stereo_8_bit
   282 000001DA 803D[6C280000]01        	cmp	byte [stmo], 1 
   283 000001E1 7505                    	jne	short chk_44khz_2
   284 000001E3 BB[ED180000]            	mov	ebx, load_44khz_mono_8_bit
   285                                  chk_44khz_2:
   286 000001E8 B8D93A0000              	mov	eax, 15065 ; (655*23)
   287 000001ED BA19000000              	mov	edx, 25
   288 000001F2 B917000000              	mov	ecx, 23
   289 000001F7 E924010000              	jmp	set_sizes 
   290                                  chk_16khz:
   291 000001FC 663D803E                	cmp	ax, 16000
   292 00000200 7545                    	jne	short chk_8khz
   293 00000202 803D[6D280000]08        	cmp	byte [bps], 8
   294 00000209 7615                    	jna	short chk_16khz_1
   295 0000020B BB[B30F0000]            	mov	ebx, load_16khz_stereo_16_bit
   296 00000210 803D[6C280000]01        	cmp	byte [stmo], 1 
   297 00000217 751A                    	jne	short chk_16khz_2
   298 00000219 BB[310F0000]            	mov	ebx, load_16khz_mono_16_bit
   299 0000021E EB13                    	jmp	short chk_16khz_2
   300                                  chk_16khz_1:
   301 00000220 BB[760E0000]            	mov	ebx, load_16khz_stereo_8_bit
   302 00000225 803D[6C280000]01        	cmp	byte [stmo], 1 
   303 0000022C 7505                    	jne	short chk_16khz_2
   304 0000022E BB[F60D0000]            	mov	ebx, load_16khz_mono_8_bit
   305                                  chk_16khz_2:
   306 00000233 B855150000              	mov	eax, 5461
   307 00000238 BA03000000              	mov	edx, 3
   308 0000023D B901000000              	mov	ecx, 1
   309 00000242 E9D9000000              	jmp	set_sizes 
   310                                  chk_8khz:
   311 00000247 663D401F                	cmp	ax, 8000
   312 0000024B 7545                    	jne	short chk_24khz
   313 0000024D 803D[6D280000]08        	cmp	byte [bps], 8
   314 00000254 7615                    	jna	short chk_8khz_1
   315 00000256 BB[AA0C0000]            	mov	ebx, load_8khz_stereo_16_bit
   316 0000025B 803D[6C280000]01        	cmp	byte [stmo], 1 
   317 00000262 751A                    	jne	short chk_8khz_2
   318 00000264 BB[D90B0000]            	mov	ebx, load_8khz_mono_16_bit
   319 00000269 EB13                    	jmp	short chk_8khz_2
   320                                  chk_8khz_1:
   321 0000026B BB[A80A0000]            	mov	ebx, load_8khz_stereo_8_bit
   322 00000270 803D[6C280000]01        	cmp	byte [stmo], 1 
   323 00000277 7505                    	jne	short chk_8khz_2
   324 00000279 BB[C8090000]            	mov	ebx, load_8khz_mono_8_bit
   325                                  chk_8khz_2:
   326 0000027E B8AA0A0000              	mov	eax, 2730
   327 00000283 BA06000000              	mov	edx, 6
   328 00000288 B901000000              	mov	ecx, 1
   329 0000028D E98E000000              	jmp	set_sizes 
   330                                  chk_24khz:
   331 00000292 663DC05D                	cmp	ax, 24000
   332 00000296 7542                    	jne	short chk_32khz
   333 00000298 803D[6D280000]08        	cmp	byte [bps], 8
   334 0000029F 7615                    	jna	short chk_24khz_1
   335 000002A1 BB[E1110000]            	mov	ebx, load_24khz_stereo_16_bit
   336 000002A6 803D[6C280000]01        	cmp	byte [stmo], 1 
   337 000002AD 751A                    	jne	short chk_24khz_2
   338 000002AF BB[7D110000]            	mov	ebx, load_24khz_mono_16_bit
   339 000002B4 EB13                    	jmp	short chk_24khz_2
   340                                  chk_24khz_1:
   341 000002B6 BB[F2100000]            	mov	ebx, load_24khz_stereo_8_bit
   342 000002BB 803D[6C280000]01        	cmp	byte [stmo], 1 
   343 000002C2 7505                    	jne	short chk_24khz_2
   344 000002C4 BB[8A100000]            	mov	ebx, load_24khz_mono_8_bit
   345                                  chk_24khz_2:
   346 000002C9 B800200000              	mov	eax, 8192
   347 000002CE BA02000000              	mov	edx, 2
   348 000002D3 B901000000              	mov	ecx, 1
   349 000002D8 EB46                    	jmp	short set_sizes 
   350                                  chk_32khz:
   351 000002DA 663D007D                	cmp	ax, 32000
   352 000002DE 7574                    	jne	short vra_needed
   353 000002E0 803D[6D280000]08        	cmp	byte [bps], 8
   354 000002E7 7615                    	jna	short chk_32khz_1
   355 000002E9 BB[E6130000]            	mov	ebx, load_32khz_stereo_16_bit
   356 000002EE 803D[6C280000]01        	cmp	byte [stmo], 1 
   357 000002F5 751A                    	jne	short chk_32khz_2
   358 000002F7 BB[7B130000]            	mov	ebx, load_32khz_mono_16_bit
   359 000002FC EB13                    	jmp	short chk_32khz_2
   360                                  chk_32khz_1:
   361 000002FE BB[DD120000]            	mov	ebx, load_32khz_stereo_8_bit
   362 00000303 803D[6C280000]01        	cmp	byte [stmo], 1 
   363 0000030A 7505                    	jne	short chk_32khz_2
   364 0000030C BB[69120000]            	mov	ebx, load_32khz_mono_8_bit
   365                                  chk_32khz_2:
   366 00000311 B8AA2A0000              	mov	eax, 10922
   367 00000316 BA03000000              	mov	edx, 3
   368 0000031B B902000000              	mov	ecx, 2
   369                                  	;jmp	short set_sizes 
   370                                  set_sizes:
   371 00000320 803D[6C280000]01        	cmp	byte [stmo], 1
   372 00000327 7402                    	je	short ss_1
   373 00000329 D1E0                    	shl	eax, 1
   374                                  ss_1:
   375 0000032B 803D[6D280000]08        	cmp	byte [bps], 8
   376 00000332 7602                    	jna	short ss_2
   377                                  	; 16 bit samples
   378 00000334 D1E0                    	shl	eax, 1
   379                                  ss_2:
   380 00000336 A3[70030000]            	mov	[loadsize], eax
   381 0000033B F7E2                    	mul	edx
   382                                  	;cmp	ecx, 1
   383                                  	;je	short ss_3
   384                                  ;ss_3:
   385 0000033D F7F1                    	div	ecx
   386 0000033F 8A0D[E1280000]          	mov	cl, [fbs_shift]
   387 00000345 D3E0                    	shl	eax, cl
   388                                  	; 26/11/2023
   389                                  	;shr	eax, 1	; buffer size is 16 bit sample count
   390 00000347 A3[74030000]            	mov	[buffersize], eax ; buffer size in bytes 
   391 0000034C 891D[6C030000]          	mov	[loadfromwavfile], ebx
   392 00000352 EB24                    	jmp	short PlayNow
   393                                  
   394                                  vra_needed:
   395                                  	sys	_msg, msg_no_vra, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000354 BB[A1260000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000359 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000035E BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000363 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000368 CD40                <1>  int 40h
   396 0000036A EB58                    	jmp	Exit
   397                                  
   398                                  	; 26/11/2023
   399                                  	; 13/11/2023
   400                                  loadfromwavfile:
   401 0000036C [23060000]              	dd	loadFromFile
   402                                  loadsize:	; read from wav file
   403 00000370 00000000                	dd	0
   404                                  buffersize:	; write to DMA buffer
   405 00000374 00000100                	dd	65536 ; bytes
   406                                  
   407                                  PlayNow: 
   408                                  
   409                                  ; 26/11/2023
   410                                  %if 0
   411                                  	; Allocate Audio Buffer (for user)
   412                                  	;sys	_audio, 0200h, BUFFERSIZE, audio_buffer
   413                                  	; 26/11/2023
   414                                  	sys	_audio, 0200h, [buffersize], audio_buffer
   415                                  	jnc	short _2
   416                                  
   417                                  	; 26/11/2023 - temporary
   418                                  	;sys	_msg, test_1, 255, 0Ch
   419                                  
   420                                  error_exit:
   421                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   422                                  	jmp	Exit
   423                                  _2:
   424                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   425                                  	; bl = 0, bh = 4
   426                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   427                                  
   428                                  	sys	_video, 0400h
   429                                  	cmp	eax, 0B8000h
   430                                  	jne	short error_exit
   431                                  
   432                                  	; Initialize Audio Device (bh = 3)
   433                                  	sys	_audio, 0301h, 0, audio_int_handler 
   434                                  ;	jc	short error_exit
   435                                  _3:
   436                                  
   437                                  %else
   438                                  	; 29/05/2024
   439                                  	; playwav4.asm
   440                                  _2:	
   441 00000378 E82E210000              	call	check4keyboardstop	; flush keyboard buffer
   442 0000037D 72F9                    	jc	short _2		; 07/11/2023
   443                                  
   444                                   	;call	codecConfig		; unmute codec, set rates.
   445                                  	; 11/11/2023
   446                                  	;jc	short init_err
   447                                  %endif
   448                                  
   449                                  ;
   450                                  ; position file pointer to start in actual wav data
   451                                  ; MUCH improvement should really be done here to check if sample size is
   452                                  ; supported, make sure there are 2 channels, etc.  
   453                                  ;
   454                                          ;mov     ah, 42h
   455                                          ;mov     al, 0	; from start of file
   456                                          ;mov     bx, [FileHandle]
   457                                          ;xor     cx, cx
   458                                          ;mov     dx, 44	; jump past .wav/riff header
   459                                          ;int     21h
   460                                  
   461                                  	sys	_seek, [FileHandle], 44, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000037F 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000385 B92C000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000038A BA00000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000038F B813000000          <1>  mov eax, %1
    89                              <1> 
    90 00000394 CD40                <1>  int 40h
   462                                  
   463                                  	sys	_msg, nextline, 255, 07h ; 01/05/2017
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000396 BB[7A270000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000039B B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003A0 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003A5 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000003AA CD40                <1>  int 40h
   464                                  
   465                                  	; 29/05/2024
   466                                  	; ----
   467                                  	; DIRECT CGA (TEXT MODE) MEMORY ACCESS
   468                                  	; bl = 0, bh = 4
   469                                  	; Direct access/map to CGA (Text) memory (0B8000h)
   470                                  
   471                                  	sys	_video, 0400h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003AC BB00040000          <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003B1 B81F000000          <1>  mov eax, %1
    89                              <1> 
    90 000003B6 CD40                <1>  int 40h
   472 000003B8 3D00800B00              	cmp	eax, 0B8000h
   473 000003BD 7543                    	jne	short error_exit
   474                                  	; ----
   475                                  
   476                                  ; play the .wav file. Most of the good stuff is in here.
   477                                  
   478 000003BF E856000000              	call    PlayWav
   479                                  
   480                                  ; close the .wav file and exit.
   481                                  
   482                                  ; 29/05/2024
   483                                  %if 0
   484                                  StopPlaying:
   485                                  	; Stop Playing
   486                                  	sys	_audio, 0700h
   487                                  	; Cancel callback service (for user)
   488                                  	sys	_audio, 0900h
   489                                  	; Deallocate Audio Buffer (for user)
   490                                  	sys	_audio, 0A00h
   491                                  	; Disable Audio Device
   492                                  	sys	_audio, 0C00h
   493                                  %endif
   494                                  
   495                                  Exit:  
   496 000003C4 E8DB010000                      call    closeFile
   497                                           
   498                                  	sys	_exit	; Bye!
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80                              <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003C9 B801000000          <1>  mov eax, %1
    89                              <1> 
    90 000003CE CD40                <1>  int 40h
   499                                  here:
   500 000003D0 EBFE                    	jmp	short here
   501                                  
   502                                  pmsg_usage:
   503                                  	sys	_msg, msg_usage, 255, 0Bh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003D2 BB[ED250000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000003D7 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003DC BA0B000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003E1 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000003E6 CD40                <1>  int 40h
   504 000003E8 EBDA                    	jmp	short Exit
   505                                  
   506                                  	; 29/05/2024
   507                                  init_err:
   508                                  	sys	_msg, msg_init_err, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000003EA BB[70260000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000003EF B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000003F4 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000003F9 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000003FE CD40                <1>  int 40h
   509 00000400 EBC2                    	jmp	short Exit
   510                                  
   511                                  	; 29/05/2024
   512                                  error_exit:
   513                                  	sys	_msg, msg_error, 255, 0Eh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000402 BB[50260000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000407 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000040C BA0E000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000411 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000416 CD40                <1>  int 40h
   514 00000418 EBAA                    	jmp	short Exit
   515                                  
   516                                  	; --------------------------------------------
   517                                  	
   518                                  	; 29/05/2024 (TYRDOS 386, playwav7.s)
   519                                  	; ((Modified from playwav4.asm, ich_wav4.asm))
   520                                  	; ------------------
   521                                  ;playwav_vra:
   522                                  PlayWav:
   523                                  	; create Buffer Descriptor List
   524                                  
   525                                  	;  Generic Form of Buffer Descriptor
   526                                  	;  ---------------------------------
   527                                  	;  63   62    61-48    47-32   31-0
   528                                  	;  ---  ---  --------  ------- -----
   529                                  	;  IOC  BUP -reserved- Buffer  Buffer
   530                                  	;		      Length   Pointer
   531                                  	;		      [15:0]   [31:0]
   532                                  
   533                                  	; 29/05/2024
   534                                  	; Allocate memory block (33 pages)
   535                                  	sys	_alloc, BDL_BUFFER, 33*4096, 0 ; no upper limit
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000041A BB[00300000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000041F B900100200          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000424 BA00000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000429 B82A000000          <1>  mov eax, %1
    89                              <1> 
    90 0000042E CD40                <1>  int 40h
   536 00000430 72D0                    	jc	short error_exit
   537                                  	
   538                                  	;mov	esi, eax
   539                                  
   540 00000432 A3[F2280000]            	mov	[_bdl_buffer], eax ; BDL_BUFFER physical address 
   541                                  
   542 00000437 0500100000              	add	eax, 4096	; WAVBUFFER_1 physical address
   543 0000043C 89C3                    	mov	ebx, eax
   544                                  	;mov	[wav_buffer1], eax
   545                                  	;add	eax, 65536	; WAVBUFFER_2 physical address
   546                                  	;mov	[wav_buffer2], eax
   547                                  
   548 0000043E BF[00300000]            	mov	edi, BDL_BUFFER
   549 00000443 B910000000              	mov	ecx, 16
   550                                  _0:
   551                                  	;mov	eax, WAVBUFFER_1
   552 00000448 89D8                    	mov	eax, ebx	; WAVBUFFER_1 physical address
   553 0000044A AB                      	stosd
   554                                  
   555 0000044B A1[74030000]            	mov	eax, [buffersize]
   556 00000450 D1E8                    	shr	eax, 1 ; buffer size in word
   557 00000452 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
   558 00000457 AB                      	stosd
   559                                  
   560                                  	;mov	eax, WAVBUFFER_2
   561 00000458 89D8                    	mov	eax, ebx
   562 0000045A 0500000100              	add	eax, 65536	; WAVBUFFER_2 physical address
   563 0000045F AB                      	stosd
   564                                  
   565 00000460 A1[74030000]            	mov	eax, [buffersize]
   566 00000465 D1E8                    	shr	eax, 1 ; buffer size in word
   567 00000467 0D00000040              	or	eax, BUP	; tuneloop (without interrupt)
   568 0000046C AB                      	stosd
   569                                  
   570 0000046D E2D9                    	loop	_0
   571                                  
   572                                  	;push	esi
   573                                  
   574                                  	; load 64k into buffer 1
   575 0000046F C705[EE280000]-         	mov	dword [audio_buffer], WAVBUFFER_1
   575 00000475 [00400000]         
   576 00000479 FF15[6C030000]          	call	dword [loadfromwavfile]
   577                                  
   578                                  	; and 64k into buffer 2
   579 0000047F C705[EE280000]-         	mov	dword [audio_buffer], WAVBUFFER_2
   579 00000485 [00400100]         
   580 00000489 FF15[6C030000]          	call	dword [loadfromwavfile]
   581                                  
   582                                  	;pop	esi
   583                                  	
   584                                  	; write NABMBAR+10h with offset of buffer descriptor list
   585                                  
   586                                         	;;mov	eax, BDL_BUFFER
   587                                          ;mov	eax, esi	; BDL_BUFFER physical address
   588                                  
   589 0000048F A1[F2280000]            	mov	eax, [_bdl_buffer] ; BDL_BUFFER physical address
   590                                  
   591 00000494 668B15[EC280000]        	mov	dx, [NABMBAR]
   592 0000049B 6683C210                        add     dx, PO_BDBAR_REG	; set pointer to BDL
   593                                  	;out	dx, eax 		; write to AC97 controller
   594                                  	; 29/05/2024
   595 0000049F 89C3                    	mov	ebx, eax ; data, dword
   596 000004A1 B405                    	mov	ah, 5	; write port dword
   597 000004A3 CD34                    	int	34h
   598                                  
   599                                  	; 31/05/2024
   600                                  	; 19/05/2024
   601                                  	;call	delay1_4ms
   602                                  
   603 000004A5 B01F                            mov	al, 31
   604 000004A7 E894200000              	call	setLastValidIndex
   605                                  
   606                                  	; 31/05/2024
   607                                  	; 19/05/2024
   608                                  	;call	delay1_4ms
   609                                  
   610                                  	; 17/02/2017
   611 000004AC 668B15[EC280000]                mov	dx, [NABMBAR]
   612 000004B3 6683C21B                        add	dx, PO_CR_REG		; PCM out Control Register
   613                                          ;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
   614                                  	;			; (LVBI interrupt will not be enabled)
   615                                  	; 06/11/2023 (TUNELOOP version, without interrupt)
   616 000004B7 B001                    	mov	al, RPBM
   617                                  	;out	dx, al			; Start bus master operation.
   618                                  	; 29/05/2024
   619                                  	; al = data, byte
   620 000004B9 B401                    	mov	ah, 1 ; write port, byte
   621 000004BB CD34                    	int	34h
   622                                  
   623                                  	; 19/05/2024
   624                                  	; 06/11/2023
   625                                  	;call	delay1_4ms	; 31/05/2024
   626                                  	;call	delay1_4ms
   627                                  	;call	delay1_4ms
   628                                  	;call	delay1_4ms
   629                                  
   630                                  ; while DMA engine is running, examine current index and wait until it hits 1
   631                                  ; as soon as it's 1, we need to refresh the data in wavbuffer1 with another
   632                                  ; 64k. Likewise when it's playing buffer 2, refresh buffer 1 and repeat.
   633                                  
   634                                  ; 18/11/2023
   635                                  ; 08/11/2023
   636                                  ; 07/11/2023
   637                                  
   638                                  tuneLoop:
   639                                  	; 18/11/2023 (ich_wav4.asm)
   640                                  	; 08/11/2023
   641                                  	; 06/11/2023
   642 000004BD B031                    	mov	al, '1'
   643 000004BF E86C000000              	call	tL0
   644                                  tL1:
   645 000004C4 E83A200000              	call	updateLVI	; /set LVI != CIV/
   646 000004C9 7452                    	jz	short _exitt_	; 08/11/2023
   647 000004CB E8DB1F0000              	call	check4keyboardstop
   648 000004D0 724B                    	jc	short _exitt_
   649 000004D2 E81C200000              	call	getCurrentIndex
   650 000004D7 A801                    	test	al, BIT0
   651 000004D9 74E9                    	jz	short tL1	; loop if buffer 2 is not playing
   652                                  
   653                                  	; 29/05/2024
   654                                  	; load buffer 1
   655 000004DB C705[EE280000]-         	mov	dword [audio_buffer], WAVBUFFER_1
   655 000004E1 [00400000]         
   656 000004E5 FF15[6C030000]          	call	dword [loadfromwavfile]
   657 000004EB 7230                    	jc	short _exitt_	; end of file
   658                                  
   659 000004ED B032                    	mov	al, '2'
   660 000004EF E83C000000              	call	tL0
   661                                  tL2:
   662 000004F4 E80A200000              	call    updateLVI
   663 000004F9 7422                    	jz	short _exitt_	; 08/11/2023
   664 000004FB E8AB1F0000              	call    check4keyboardstop
   665 00000500 721B                    	jc	short _exitt_
   666 00000502 E8EC1F0000              	call    getCurrentIndex
   667 00000507 A801                    	test	al, BIT0
   668 00000509 75E9                    	jnz	short tL2	; loop if buffer 1 is not playing
   669                                  
   670                                  	; 29/05/2024
   671                                  	; load buffer 2
   672 0000050B C705[EE280000]-         	mov	dword [audio_buffer], WAVBUFFER_2
   672 00000511 [00400100]         
   673 00000515 FF15[6C030000]          	call	dword [loadfromwavfile]
   674 0000051B 73A0                    	jnc	short tuneLoop
   675                                  _exitt_:
   676 0000051D 668B15[EC280000]        	mov	dx, [NABMBAR]		
   677 00000524 6683C21B                	add	dx, PO_CR_REG	; PCM out Control Register
   678 00000528 B000                    	mov	al, 0
   679                                  	;out	dx, al		; stop player
   680                                  	; 29/05/2024
   681                                  	; al = data, byte
   682 0000052A B401                    	mov	ah, 1  ; write port, byte
   683 0000052C CD34                    	int	34h	
   684                                  
   685                                  	; 29/05/2024
   686 0000052E B030                    	mov	al, '0'
   687                                  
   688                                  	;add	al, '0'
   689                                  	;call	tL0
   690                                  	;
   691                                  	;retn
   692                                  	; 06/11/2023
   693                                  	;jmp	short tL0
   694                                  	;retn
   695                                  
   696                                  	; 06/11/2023
   697                                  tL0:
   698                                  	; 29/05/2024 (TRDOS 386)
   699                                  	; 08/11/2023
   700                                  	; 05/11/2023
   701                                  	; 17/02/2017 - Buffer switch test (temporary)
   702                                  	; 06/11/2023
   703                                  	; al = buffer indicator ('1', '2' or '0' -stop- )
   704                                  	
   705 00000530 BB00800B00              	mov	ebx, 0B8000h ; video display page address
   706 00000535 B44E                    	mov	ah, 4Eh
   707 00000537 668903                  	mov	[ebx], ax ; show current play buffer (1, 2)
   708 0000053A C3                      	retn
   709                                  
   710                                  	; ------------------
   711                                  
   712                                  ; 29/05/2024
   713                                  %if 0
   714                                  	; 25/11/2023
   715                                  DetectAC97:
   716                                  	; Detect (BH=1) AC'97 (BL=2) Audio Device
   717                                          sys	_audio, 0102h
   718                                  	jc	short DetectAC97_retn
   719                                  
   720                                  	; 25/11/2023
   721                                  	; Get AC'97 Codec info
   722                                  	; (Function 14, sub function 1)
   723                                  	sys	_audio, 0E01h
   724                                  	; Save Variable Rate Audio support bit
   725                                  	and	al, 1
   726                                  	mov	[VRA], al
   727                                  
   728                                  DetectAC97_retn:
   729                                  	retn
   730                                  %else
   731                                  	; 29/05/2024
   732                                  DetectAC97:
   733                                  DetectICH:
   734                                  	; 22/11/2023
   735                                  	; 19/11/2023
   736                                  	; 01/11/2023 - TRDOS 386 Kernel v2.0.7
   737                                  	;; 10/06/2017
   738                                  	;; 05/06/2017
   739                                  	;; 29/05/2017
   740                                  	;; 28/05/2017
   741                                  
   742                                  	; 19/11/2023
   743 0000053B BE[DA260000]            	mov	esi, valid_ids	; address of Valid ICH (AC97) Device IDs
   744 00000540 B915000000              	mov	ecx, valid_id_count
   745                                  pfd_1:
   746 00000545 AD                      	lodsd
   747 00000546 E8E61A0000              	call	pciFindDevice
   748 0000054B 7303                    	jnc	short d_ac97_1
   749 0000054D E2F6                    	loop	pfd_1
   750                                  
   751                                  	;stc
   752 0000054F C3                      	retn
   753                                  
   754                                  d_ac97_1:
   755                                  	; eax = BUS/DEV/FN
   756                                  	;	00000000BBBBBBBBDDDDDFFF00000000
   757                                  	; edx = DEV/VENDOR
   758                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
   759                                  
   760                                  	; playwav4.asm - 19/05/2024
   761                                  
   762 00000550 A3[E6280000]            	mov	[bus_dev_fn], eax
   763 00000555 8915[E2280000]          	mov	[dev_vendor], edx
   764                                  
   765                                  	; get ICH base address regs for mixer and bus master
   766                                  
   767 0000055B B010                            mov     al, NAMBAR_REG
   768 0000055D E85D1B0000                      call    pciRegRead16			; read PCI registers 10-11
   769                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
   770                                  	; 19/05/2024
   771 00000562 80E2FE                  	and	dl, 0FEh
   772                                  
   773 00000565 668915[EA280000]                mov     [NAMBAR], dx			; save audio mixer base addr
   774                                  
   775 0000056C B014                    	mov     al, NABMBAR_REG
   776 0000056E E84C1B0000                      call    pciRegRead16
   777                                          ;and    dx, IO_ADDR_MASK
   778                                  	; 19/05/2024
   779 00000573 80E2C0                  	and	dl, 0C0h
   780                                  
   781 00000576 668915[EC280000]                mov     [NABMBAR], dx			; save bus master base addr
   782                                  
   783 0000057D B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
   784 0000057F E8341B0000              	call	pciRegRead8 ; 17/02/2017
   785                                  
   786 00000584 8815[E0280000]          	mov     [ac97_int_ln_reg], dl
   787                                  
   788                                  	;clc
   789                                  
   790 0000058A C3                      	retn
   791                                  %endif
   792                                  
   793                                  ;open or create file
   794                                  ;
   795                                  ;input: ds:dx-->filename (asciiz)
   796                                  ;       al=file Mode (create or open)
   797                                  ;output: none  cs:[FileHandle] filled
   798                                  ;
   799                                  openFile:
   800                                  	;mov	ah, 3Bh	; start with a mode
   801                                  	;add	ah, al	; add in create or open mode
   802                                  	;xor	ecx, ecx
   803                                  	;int	21h
   804                                  	;jc	short _of1
   805                                  	;;mov	[cs:FileHandle], ax
   806                                  
   807                                  	sys	_open, wav_file_name, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000058B BB[8E280000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000590 B900000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000595 B805000000          <1>  mov eax, %1
    89                              <1> 
    90 0000059A CD40                <1>  int 40h
   808 0000059C 7205                    	jc	short _of1
   809                                  
   810 0000059E A3[51250000]            	mov	[FileHandle], eax
   811                                  _of1:
   812 000005A3 C3                      	retn
   813                                  
   814                                  ; close the currently open file
   815                                  ; input: none, uses cs:[FileHandle]
   816                                  closeFile:
   817 000005A4 833D[51250000]FF        	cmp	dword [FileHandle], -1
   818 000005AB 7417                    	je	short _cf1
   819                                  	;mov    bx, [FileHandle]  
   820                                  	;mov    ax, 3E00h
   821                                          ;int    21h              ;close file
   822                                  
   823                                  	sys	_close, [FileHandle]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000005AD 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82                              <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000005B3 B806000000          <1>  mov eax, %1
    89                              <1> 
    90 000005B8 CD40                <1>  int 40h
   824 000005BA C705[51250000]FFFF-     	mov 	dword [FileHandle], -1
   824 000005C2 FFFF               
   825                                  _cf1:
   826 000005C4 C3                      	retn
   827                                  
   828                                  getSampleRate:
   829                                  	
   830                                  ; reads the sample rate from the .wav file.
   831                                  ; entry: none - assumes file is already open
   832                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   833                                  ;	cx = number of channels (mono=1, stereo=2)
   834                                  ;	dx = bits per sample (8, 16)
   835                                  
   836 000005C5 53                      	push    ebx
   837                                  
   838                                          ;mov	ah, 42h
   839                                          ;mov	al, 0	; from start of file
   840                                          ;mov	bx, [FileHandle]
   841                                          ;xor	ecx, ecx
   842                                          ;mov	dx, 08h	; "WAVE"
   843                                          ;int	21h
   844                                  	
   845                                  	sys	_seek, [FileHandle], 8, 0
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000005C6 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000005CC B908000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000005D1 BA00000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000005D6 B813000000          <1>  mov eax, %1
    89                              <1> 
    90 000005DB CD40                <1>  int 40h
   846                                  
   847                                          ;mov	dx, smpRBuff
   848                                          ;mov	cx, 28	; 28 bytes
   849                                  	;mov	ah, 3fh
   850                                          ;int	21h
   851                                  
   852                                  	sys	_read, [FileHandle], smpRBuff, 28
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000005DD 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000005E3 B9[72280000]        <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000005E8 BA1C000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000005ED B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000005F2 CD40                <1>  int 40h
   853                                  
   854 000005F4 813D[72280000]5741-     	cmp	dword [smpRBuff], 'WAVE'
   854 000005FC 5645               
   855 000005FE 7520                    	jne	short gsr_stc
   856                                  
   857 00000600 66833D[7E280000]01      	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   858 00000608 7516                    	jne	short gsr_stc
   859                                  
   860 0000060A 668B0D[80280000]        	mov	cx, [smpRBuff+14]	; return num of channels in CX
   861 00000611 66A1[82280000]                  mov     ax, [smpRBuff+16]	; return sample rate in AX
   862 00000617 668B15[8C280000]        	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   863                                  gsr_retn:
   864 0000061E 5B                              pop     ebx
   865 0000061F C3                              retn
   866                                  gsr_stc:
   867 00000620 F9                      	stc
   868 00000621 EBFB                    	jmp	short gsr_retn
   869                                  
   870                                  ; 29/05/2024
   871                                  %if 0
   872                                  audio_int_handler:
   873                                  	; 18/08/2020 (14/10/2020, 'wavplay2.s')
   874                                  
   875                                  	;mov	byte [srb], 1 ; interrupt (or signal response byte)
   876                                  	
   877                                  	;cmp	byte [cbs_busy], 1
   878                                  	;jnb	short _callback_bsy_retn
   879                                  	
   880                                  	;mov	byte [cbs_busy], 1
   881                                  
   882                                  	mov	al, [half_buff]
   883                                  
   884                                  	cmp	al, 1
   885                                  	jb	short _callback_retn
   886                                  
   887                                  	; 18/08/2020
   888                                  	mov	byte [srb], 1
   889                                  
   890                                  	xor	byte [half_buff], 3 ; 2->1, 1->2
   891                                  
   892                                  	add	al, '0'
   893                                  tL0:	; 26/11/2023
   894                                  	mov	ah, 4Eh
   895                                  	mov	ebx, 0B8000h ; video display page address
   896                                  	mov	[ebx], ax ; show playing buffer (1, 2)
   897                                  _callback_retn:
   898                                  	;mov	byte [cbs_busy], 0
   899                                  _callback_bsy_retn:
   900                                  	sys	_rele ; return from callback service 
   901                                  	; we must not come here !
   902                                  	sys	_exit
   903                                  %endif
   904                                  	
   905                                  loadFromFile:
   906                                  	; 26/11/2023
   907 00000623 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
   908                                  					; last of the file?
   909 0000062A 7402                    	jz	short lff_0		; no
   910 0000062C F9                      	stc
   911 0000062D C3                      	retn
   912                                  lff_0:
   913                                  	; 13/06/2017
   914                                  	;mov	edx, BUFFERSIZE
   915                                  	; 26/11/2023
   916                                  	;mov	edi, audio_buffer
   917                                  	; 29/05/2024
   918 0000062E 8B3D[EE280000]          	mov	edi, [audio_buffer]
   919 00000634 8B15[74030000]          	mov	edx, [buffersize]	; bytes
   920 0000063A 8A0D[E1280000]          	mov	cl, [fbs_shift]   
   921 00000640 20C9                    	and	cl, cl
   922 00000642 7409                    	jz	short lff_1 ; stereo, 16 bit
   923                                  
   924                                  	; fbs_shift =
   925                                  	;	2 for mono and 8 bit sample (multiplier = 4)
   926                                  	;	1 for mono or 8 bit sample (multiplier = 2)
   927 00000644 D3EA                    	shr	edx, cl
   928                                  	;inc	edx
   929                                  
   930 00000646 BE[00400200]            	mov     esi, temp_buffer
   931 0000064B EB02                    	jmp	short lff_2
   932                                  lff_1:
   933                                  	;;mov	esi, audio_buffer
   934                                  	; 29/05/2024
   935                                  	;mov	esi, [audio_buffer]
   936 0000064D 89FE                    	mov	esi, edi ; audio_buffer
   937                                  lff_2:
   938                                  	; 17/03/2017
   939                                  	; esi = buffer address
   940                                  	; edx = buffer size
   941                                   
   942                                  	; 26/11/2023
   943                                  	; load file into memory
   944                                  	sys 	_read, [FileHandle], esi
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000064F 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000655 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84                              <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000657 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000065C CD40                <1>  int 40h
   945 0000065E 89D1                    	mov	ecx, edx
   946 00000660 724A                    	jc	short padfill ; error !
   947                                  
   948 00000662 21C0                    	and	eax, eax
   949 00000664 7446                    	jz	short padfill
   950                                  lff_3:
   951                                  	; 26/11/2023
   952 00000666 8A1D[E1280000]          	mov	bl, [fbs_shift]
   953 0000066C 20DB                    	and	bl, bl
   954 0000066E 745C                    	jz	short lff_11
   955                                  
   956 00000670 29C1                    	sub	ecx, eax
   957 00000672 89CD                    	mov	ebp, ecx
   958                                  
   959                                  	;mov	esi, temp_buffer
   960                                  	;mov	edi, audio_buffer
   961 00000674 89C1                    	mov	ecx, eax   ; byte count
   962                                  
   963 00000676 803D[6D280000]08        	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   964 0000067D 751E                    	jne	short lff_6 ; 16 bit samples
   965                                  	; 8 bit samples
   966 0000067F FECB                    	dec	bl  ; shift count, 1 = stereo, 2 = mono
   967 00000681 740E                    	jz	short lff_5 ; 8 bit, stereo
   968                                  lff_4:
   969                                  	; mono & 8 bit
   970 00000683 AC                      	lodsb
   971 00000684 2C80                    	sub	al, 80h ; 08/11/2023
   972 00000686 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   973 00000689 66AB                    	stosw	; left channel
   974 0000068B 66AB                    	stosw	; right channel
   975 0000068D E2F4                    	loop	lff_4
   976 0000068F EB16                    	jmp	short lff_8
   977                                  lff_5:
   978                                  	; stereo & 8 bit
   979 00000691 AC                      	lodsb
   980 00000692 2C80                    	sub	al, 80h ; 08/11/2023
   981 00000694 C1E008                  	shl	eax, 8 ; convert 8 bit sample to 16 bit sample
   982 00000697 66AB                    	stosw
   983 00000699 E2F6                    	loop	lff_5			
   984 0000069B EB0A                    	jmp	short lff_8
   985                                  lff_6:
   986 0000069D D1E9                    	shr	ecx, 1 ; word count
   987                                  lff_7:
   988 0000069F 66AD                    	lodsw
   989 000006A1 66AB                    	stosw	; left channel
   990 000006A3 66AB                    	stosw	; right channel
   991 000006A5 E2F8                    	loop	lff_7
   992                                  lff_8:
   993                                  	; 27/11/2023
   994 000006A7 F8                      	clc
   995 000006A8 89E9                    	mov	ecx, ebp
   996 000006AA E314                    	jecxz	endLFF_retn
   997                                  	
   998                                  padfill:
   999 000006AC 803D[6D280000]10        	cmp 	byte [bps], 16
  1000 000006B3 740C                    	je	short lff_10
  1001                                  	; Minimum Value = 0
  1002 000006B5 30C0                            xor     al, al
  1003 000006B7 F3AA                    	rep	stosb
  1004                                  lff_9:
  1005 000006B9 800D[70280000]01                or	byte [flags], ENDOFFILE	; end of file flag
  1006                                  endLFF_retn:
  1007 000006C0 C3                              retn
  1008                                  lff_10:
  1009 000006C1 31C0                    	xor	eax, eax
  1010                                  	; Minimum value = 8000h (-32768)
  1011 000006C3 D1E9                    	shr	ecx, 1 
  1012 000006C5 B480                    	mov	ah, 80h ; ax = -32768
  1013 000006C7 F366AB                  	rep	stosw
  1014 000006CA EBED                    	jmp	short lff_9
  1015                                  
  1016                                  lff_11:
  1017                                  	; 16 bit stereo
  1018                                  	; ecx = buffer size
  1019                                  	; eax = read count
  1020 000006CC 29C1                    	sub	ecx, eax
  1021 000006CE 76F0                    	jna	short endLFF_retn
  1022 000006D0 01C7                    	add	edi, eax  ; audio_buffer + eax
  1023 000006D2 EBED                    	jmp	short lff_10 ; padfill
  1024                                  
  1025                                  error_exit_2:
  1026                                  	; 26/11/2023 - temporary
  1027                                  	;sys	_msg, test_2, 255, 0Ch
  1028 000006D4 E929FDFFFF              	jmp	error_exit
  1029                                  	
  1030                                  	; 26/11/2023 - temporary
  1031                                  ;test_1:
  1032                                  ;	db 13, 10, 'Test 1', 13,10, 0
  1033                                  ;test_2:
  1034                                  ;	db 13, 10, 'Test 2', 13,10, 0
  1035                                  	
  1036                                  ; 29/05/2024
  1037                                  %if 0
  1038                                  
  1039                                  PlayWav:
  1040                                  	; 26/11/2023
  1041                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
  1042                                  	; 13/06/2017
  1043                                  	; Convert 8 bit samples to 16 bit samples
  1044                                  	; and convert mono samples to stereo samples
  1045                                  
  1046                                  	; 26/11/2023
  1047                                  	; load 32768 bytes into audio buffer
  1048                                  	;mov	edi, audio_buffer
  1049                                  	;;mov	edx, BUFFERSIZE
  1050                                  	; 26/11/2023
  1051                                  	;mov	edx, [buffersize]
  1052                                  	;call	loadFromFile
  1053                                  	; 26/11/2023
  1054                                  	call	dword [loadfromwavfile]
  1055                                  	jc	short error_exit_2
  1056                                  	mov	byte [half_buff], 1 ; (DMA) Buffer 1
  1057                                  
  1058                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
  1059                                  	test    byte [flags], ENDOFFILE  ; end of file
  1060                                  	jnz	short _6 ; yes
  1061                                  			 ; bypass filling dma half buffer 2
  1062                                  
  1063                                  	; bh = 16 : update (current, first) dma half buffer
  1064                                  	; bl = 0  : then switch to the next (second) half buffer
  1065                                  	sys	_audio, 1000h
  1066                                  
  1067                                  	; 18/08/2020
  1068                                  	; [audio_flag] = 1 (in TRDOS 386 kernel)
  1069                                  
  1070                                  	; audio_buffer must be filled again after above system call 
  1071                                  	; (Because audio interrupt will be generated by AC97 hardware
  1072                                  	; at the end of the first half of dma buffer.. so, 
  1073                                  	; the second half must be ready. 'sound_play' will use it.)
  1074                                  
  1075                                  	; 26/11/2023
  1076                                  	;mov	edi, audio_buffer
  1077                                  	;;mov	edx, BUFFERSIZE
  1078                                  	; 26/11/2023
  1079                                  	;mov	edx, [buffersize]
  1080                                  	;call	loadFromFile
  1081                                  	; 26/11/2023
  1082                                  	call	dword [loadfromwavfile]
  1083                                  	;jc	short p_return
  1084                                  _6:
  1085                                  	; Set Master Volume Level (BL=0 or 80h)
  1086                                  	; 	for next playing (BL>=80h)
  1087                                  	;sys	_audio, 0B80h, 1D1Dh
  1088                                  	sys	_audio, 0B00h, 1D1Dh
  1089                                  
  1090                                  	; 18/08/2020
  1091                                  	;mov	byte [volume_level], 1Dh
  1092                                  	mov	[volume_level], cl
  1093                                  
  1094                                  	; Start	to play
  1095                                  	mov	al, [bps]
  1096                                  	shr	al, 4 ; 8 -> 0, 16 -> 1
  1097                                  	shl	al, 1 ; 16 -> 2, 8 -> 0
  1098                                  	mov	bl, [stmo]
  1099                                  	dec	bl
  1100                                  	or	bl, al
  1101                                  	mov	cx, [sample_rate] 
  1102                                  	mov	bh, 4 ; start to play	
  1103                                  	sys	_audio
  1104                                  
  1105                                  	;mov	ebx, 0B8000h ; video display page address
  1106                                  	;mov	ah, 4Eh
  1107                                  	;mov	al, [half_buffer]
  1108                                  	;mov	[ebx], ax ; show playing buffer (1, 2)
  1109                                  
  1110                                  	; 18/08/2020 (27/07/2020, 'wavplay2.s')
  1111                                  	; Here..
  1112                                  	; If byte [flags] <> ENDOFFILE ...
  1113                                  	; user's audio_buffer has been copied to dma half buffer 2
  1114                                  
  1115                                  	; [audio_flag] = 0 (in TRDOS 386 kernel)
  1116                                  
  1117                                  	; audio_buffer must be filled again after above system call 
  1118                                  	; (Because, audio interrupt will be generated by VT8237R
  1119                                  	; at the end of the first half of dma buffer.. so, 
  1120                                  	; the 2nd half of dma buffer is ready but the 1st half
  1121                                  	; must be filled again.)
  1122                                  
  1123                                  	; 18/08/2020
  1124                                  	test    byte [flags], ENDOFFILE  ; end of file
  1125                                  	jnz	short p_loop ; yes
  1126                                  
  1127                                  	; 18/08/2020
  1128                                  	; load 32768 bytes into audio buffer
  1129                                  	;; (for the second half of DMA buffer)
  1130                                  	; 27/11/2023
  1131                                  	; 20/05/2017
  1132                                  	;mov	edi, audio_buffer
  1133                                  	;mov	edx, BUFFERSIZE
  1134                                  	; 26/11/2023
  1135                                  	;mov	edx, [buffersize]
  1136                                  	;call	loadFromFile
  1137                                  	; 26/11/2023
  1138                                  	call	dword [loadfromwavfile]
  1139                                  	;jc	short p_return
  1140                                  	;mov	byte [half_buff], 2 ; (DMA) Buffer 2
  1141                                  
  1142                                  	; we need to wait for 'SRB' (audio interrupt)
  1143                                  	; (we can not return from 'PlayWav' here 
  1144                                  	;  even if we have got an error from file reading)
  1145                                  	; ((!!current audio data must be played!!))
  1146                                  
  1147                                  	; 18/08/2020
  1148                                  	;mov	byte [srb], 1
  1149                                  
  1150                                  p_loop:
  1151                                  	;mov	ah, 1		; any key pressed?
  1152                                  	;int	32h		; no, Loop.
  1153                                  	;jz	short q_loop
  1154                                  	;
  1155                                  	;mov	ah, 0		; flush key buffer...
  1156                                  	;int	32h
  1157                                  
  1158                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
  1159                                  	cmp	byte [srb], 0
  1160                                  	jna	short q_loop
  1161                                  	mov	byte [srb], 0
  1162                                  	; 27/11/2023
  1163                                  	;mov	edi, audio_buffer
  1164                                  	;mov	edx, BUFFERSIZE
  1165                                  	; 26/11/2023
  1166                                  	;mov	edx, [buffersize]
  1167                                  	;call	loadFromFile
  1168                                  	; 26/11/2023
  1169                                  	call	dword [loadfromwavfile]
  1170                                  	jc	short p_return
  1171                                  q_loop:
  1172                                  	mov     ah, 1		; any key pressed?
  1173                                  	int     32h		; no, Loop.
  1174                                  	jz	short p_loop
  1175                                  
  1176                                  	mov     ah, 0		; flush key buffer...
  1177                                  	int     32h
  1178                                  	
  1179                                  	cmp	al, '+' ; increase sound volume
  1180                                  	je	short inc_volume_level
  1181                                  	cmp	al, '-'
  1182                                  	je	short dec_volume_level
  1183                                  
  1184                                  p_return:
  1185                                  	mov	byte [half_buff], 0
  1186                                  	retn
  1187                                  
  1188                                  	; 18/08/2020 (14/10/2017, 'wavplay2.s')
  1189                                  inc_volume_level:
  1190                                  	mov	cl, [volume_level]
  1191                                  	cmp	cl, 1Fh ; 31
  1192                                  	jnb	short q_loop
  1193                                  	inc	cl
  1194                                  change_volume_level:
  1195                                  	mov	[volume_level], cl
  1196                                  	mov	ch, cl
  1197                                  	; Set Master Volume Level
  1198                                  	sys	_audio, 0B00h
  1199                                  	jmp	short p_loop
  1200                                  dec_volume_level:
  1201                                  	mov	cl, [volume_level]
  1202                                  	cmp	cl, 1 ; 1
  1203                                  	jna	short p_loop
  1204                                  	dec	cl
  1205                                  	jmp	short change_volume_level
  1206                                  %endif
  1207                                  
  1208                                  write_audio_dev_info:
  1209                                  	; EBX = Message address
  1210                                  	; ECX = Max. message length (or stop on ZERO character)
  1211                                  	;	(1 to 255)
  1212                                  	; DL  = Message color (07h = light gray, 0Fh = white) 
  1213                                       	sys 	_msg, msgAudioCardInfo, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000006D9 BB[C4250000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000006DE B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000006E3 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000006E8 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000006ED CD40                <1>  int 40h
  1214 000006EF C3                      	retn
  1215                                  
  1216                                  write_wav_file_info:
  1217                                  	; 01/05/2017
  1218                                  	sys	_msg, msgWavFileName, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000006F0 BB[2E270000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000006F5 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000006FA BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000006FF B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000704 CD40                <1>  int 40h
  1219                                  	sys	_msg, wav_file_name, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000706 BB[8E280000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000070B B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000710 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000715 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000071A CD40                <1>  int 40h
  1220                                  
  1221                                  write_sample_rate:
  1222                                  	; 01/05/2017
  1223 0000071C 66A1[6E280000]          	mov	ax, [sample_rate]
  1224                                  	; ax = sample rate (hertz)
  1225 00000722 31D2                    	xor	edx, edx
  1226 00000724 66B90A00                	mov	cx, 10
  1227 00000728 66F7F1                  	div	cx
  1228 0000072B 0015[53270000]          	add	[msgHertz+4], dl
  1229 00000731 29D2                    	sub	edx, edx
  1230 00000733 66F7F1                  	div	cx
  1231 00000736 0015[52270000]          	add	[msgHertz+3], dl
  1232 0000073C 29D2                    	sub	edx, edx
  1233 0000073E 66F7F1                  	div	cx
  1234 00000741 0015[51270000]          	add	[msgHertz+2], dl
  1235 00000747 29D2                    	sub	edx, edx
  1236 00000749 66F7F1                  	div	cx
  1237 0000074C 0015[50270000]          	add	[msgHertz+1], dl
  1238 00000752 0005[4F270000]          	add	[msgHertz], al
  1239                                  	
  1240                                  	sys	_msg, msgSampleRate, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000758 BB[40270000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000075D B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000762 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000767 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000076C CD40                <1>  int 40h
  1241                                  
  1242 0000076E BE[6A270000]            	mov	esi, msg16Bits
  1243 00000773 803D[6D280000]10        	cmp	byte [bps], 16
  1244 0000077A 7405                    	je	short wsr_1
  1245 0000077C BE[5A270000]            	mov	esi, msg8Bits
  1246                                  wsr_1:
  1247                                  	sys	_msg, esi, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000781 89F3                <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000783 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000788 BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000078D B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000792 CD40                <1>  int 40h
  1248                                  
  1249 00000794 BE[63270000]            	mov	esi, msgMono
  1250 00000799 803D[6C280000]01        	cmp	byte [stmo], 1
  1251 000007A0 7405                    	je	short wsr_2
  1252 000007A2 BE[74270000]            	mov	esi, msgStereo		
  1253                                  wsr_2:
  1254                                  	sys	_msg, esi, 255, 0Fh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000007A7 89F3                <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000007A9 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000007AE BA0F000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000007B3 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000007B8 CD40                <1>  int 40h
  1255 000007BA C3                              retn
  1256                                  
  1257                                  write_ac97_pci_dev_info:
  1258                                  	; 06/06/2017
  1259                                  	; 03/06/2017
  1260                                  	; BUS/DEV/FN
  1261                                  	;	00000000BBBBBBBBDDDDDFFF00000000
  1262                                  	; DEV/VENDOR
  1263                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  1264                                  
  1265                                  	;mov	esi, [dev_vendor]
  1266                                  	;mov	eax, esi
  1267                                  	; 31/05/2024
  1268 000007BB A1[E2280000]            	mov	eax, [dev_vendor]
  1269 000007C0 0FB6D8                  	movzx	ebx, al
  1270 000007C3 88DA                    	mov	dl, bl
  1271 000007C5 80E30F                  	and	bl, 0Fh
  1272 000007C8 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1273 000007CE A2[C2270000]            	mov	[msgVendorId+3], al
  1274 000007D3 88D3                    	mov	bl, dl
  1275 000007D5 C0EB04                  	shr	bl, 4
  1276 000007D8 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1277 000007DE A2[C1270000]            	mov	[msgVendorId+2], al
  1278 000007E3 88E3                    	mov	bl, ah
  1279 000007E5 88DA                    	mov	dl, bl
  1280 000007E7 80E30F                  	and	bl, 0Fh
  1281 000007EA 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1282 000007F0 A2[C0270000]            	mov	[msgVendorId+1], al
  1283 000007F5 88D3                    	mov	bl, dl
  1284 000007F7 C0EB04                  	shr	bl, 4
  1285 000007FA 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1286 00000800 A2[BF270000]            	mov	[msgVendorId], al
  1287 00000805 C1E810                  	shr	eax, 16
  1288 00000808 88C3                    	mov	bl, al
  1289 0000080A 88DA                    	mov	dl, bl
  1290 0000080C 80E30F                  	and	bl, 0Fh
  1291 0000080F 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1292 00000815 A2[D3270000]            	mov	[msgDevId+3], al
  1293 0000081A 88D3                    	mov	bl, dl
  1294 0000081C C0EB04                  	shr	bl, 4
  1295 0000081F 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1296 00000825 A2[D2270000]            	mov	[msgDevId+2], al
  1297 0000082A 88E3                    	mov	bl, ah
  1298 0000082C 88DA                    	mov	dl, bl
  1299 0000082E 80E30F                  	and	bl, 0Fh
  1300 00000831 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1301 00000837 A2[D1270000]            	mov	[msgDevId+1], al
  1302 0000083C 88D3                    	mov	bl, dl
  1303 0000083E C0EB04                  	shr	bl, 4
  1304 00000841 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1305 00000847 A2[D0270000]            	mov	[msgDevId], al
  1306                                  
  1307                                  	;mov	esi, [bus_dev_fn]
  1308                                  	;shr	esi, 8
  1309                                  	;mov	ax, si
  1310                                  	; 31/05/2024
  1311 0000084C A1[E6280000]            	mov	eax, [bus_dev_fn]
  1312 00000851 C1E808                  	shr	eax, 8
  1313 00000854 88C3                    	mov	bl, al
  1314 00000856 88DA                    	mov	dl, bl
  1315 00000858 80E307                  	and	bl, 7 ; bit 0,1,2
  1316 0000085B 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1317 00000861 A2[F7270000]            	mov	[msgFncNo+1], al
  1318 00000866 88D3                    	mov	bl, dl
  1319 00000868 C0EB03                  	shr	bl, 3
  1320 0000086B 88DA                    	mov	dl, bl
  1321 0000086D 80E30F                  	and	bl, 0Fh
  1322 00000870 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1323 00000876 A2[E9270000]            	mov	[msgDevNo+1], al
  1324 0000087B 88D3                    	mov	bl, dl
  1325 0000087D C0EB04                  	shr	bl, 4
  1326 00000880 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1327 00000886 A2[E8270000]            	mov	[msgDevNo], al
  1328 0000088B 88E3                    	mov	bl, ah
  1329 0000088D 88DA                    	mov	dl, bl
  1330 0000088F 80E30F                  	and	bl, 0Fh
  1331 00000892 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1332 00000898 A2[DD270000]            	mov	[msgBusNo+1], al
  1333 0000089D 88D3                    	mov	bl, dl
  1334 0000089F C0EB04                  	shr	bl, 4
  1335 000008A2 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1336 000008A8 A2[DC270000]            	mov	[msgBusNo], al
  1337                                  
  1338                                  	;mov	ax, [ac97_NamBar]
  1339 000008AD 66A1[EA280000]          	mov	ax, [NAMBAR]	; 29/05/2024
  1340 000008B3 88C3                    	mov	bl, al
  1341 000008B5 88DA                    	mov	dl, bl
  1342 000008B7 80E30F                  	and	bl, 0Fh
  1343 000008BA 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1344 000008C0 A2[06280000]            	mov	[msgNamBar+3], al
  1345 000008C5 88D3                    	mov	bl, dl
  1346 000008C7 C0EB04                  	shr	bl, 4
  1347 000008CA 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1348 000008D0 A2[05280000]            	mov	[msgNamBar+2], al
  1349 000008D5 88E3                    	mov	bl, ah
  1350 000008D7 88DA                    	mov	dl, bl
  1351 000008D9 80E30F                  	and	bl, 0Fh
  1352 000008DC 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1353 000008E2 A2[04280000]            	mov	[msgNamBar+1], al
  1354 000008E7 88D3                    	mov	bl, dl
  1355 000008E9 C0EB04                  	shr	bl, 4
  1356 000008EC 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1357 000008F2 A2[03280000]            	mov	[msgNamBar], al
  1358                                  
  1359                                  	;mov	ax, [ac97_NabmBar]
  1360 000008F7 66A1[EC280000]          	mov	ax, [NABMBAR]	; 29/05/2024
  1361 000008FD 88C3                    	mov	bl, al
  1362 000008FF 88DA                    	mov	dl, bl
  1363 00000901 80E30F                  	and	bl, 0Fh
  1364 00000904 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1365 0000090A A2[16280000]            	mov	[msgNabmBar+3], al
  1366 0000090F 88D3                    	mov	bl, dl
  1367 00000911 C0EB04                  	shr	bl, 4
  1368 00000914 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1369 0000091A A2[15280000]            	mov	[msgNabmBar+2], al
  1370 0000091F 88E3                    	mov	bl, ah
  1371 00000921 88DA                    	mov	dl, bl
  1372 00000923 80E30F                  	and	bl, 0Fh
  1373 00000926 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1374 0000092C A2[14280000]            	mov	[msgNabmBar+1], al
  1375 00000931 88D3                    	mov	bl, dl
  1376 00000933 C0EB04                  	shr	bl, 4
  1377 00000936 8A83[7D270000]          	mov	al, [ebx+hex_chars]
  1378 0000093C A2[13280000]            	mov	[msgNabmBar], al
  1379                                  
  1380                                  	;xor	ah, ah
  1381 00000941 31C0                    	xor	eax, eax ; 31/05/2024
  1382 00000943 A0[E0280000]            	mov	al, [ac97_int_ln_reg]
  1383 00000948 B10A                    	mov	cl, 10
  1384 0000094A F6F1                    	div	cl
  1385 0000094C 660105[1F280000]        	add	[msgIRQ], ax
  1386 00000953 20C0                    	and	al, al
  1387 00000955 750D                    	jnz	short _w_ac97imsg_
  1388 00000957 A0[20280000]            	mov	al, [msgIRQ+1]
  1389 0000095C B420                    	mov	ah, ' '
  1390 0000095E 66A3[1F280000]          	mov	[msgIRQ], ax
  1391                                  _w_ac97imsg_:
  1392                                  	sys	_msg, msgAC97Info, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000964 BB[8E270000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000969 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000096E BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000973 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 00000978 CD40                <1>  int 40h
  1393                                  
  1394 0000097A C3                              retn
  1395                                  
  1396                                  write_VRA_info:
  1397                                  	; 25/11/2023
  1398                                  	sys	_msg, msgVRAheader, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000097B BB[24280000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000980 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000985 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000098A B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000098F CD40                <1>  int 40h
  1399 00000991 803D[71280000]00        	cmp	byte [VRA], 0
  1400 00000998 7617                    	jna	short _w_VRAi_no
  1401                                  _w_VRAi_yes:
  1402                                  	sys	_msg, msgVRAyes, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000099A BB[32280000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000099F B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009A4 BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009A9 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000009AE CD40                <1>  int 40h
  1403 000009B0 C3                      	retn
  1404                                  _w_VRAi_no:
  1405                                  	sys	_msg, msgVRAno, 255, 07h
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009B1 BB[38280000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000009B6 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009BB BA07000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009C0 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000009C5 CD40                <1>  int 40h
  1406 000009C7 C3                      	retn
  1407                                  
  1408                                  ; 26/11/2023
  1409                                  ; 25/11/2023 - playwav6.s (32 bit registers, TRDOS 386 adaption)
  1410                                  ; 15/11/2023 - PLAYWAV5.COM, ich_wav5.asm
  1411                                  ; 14/11/2023
  1412                                  ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1413                                  ; --------------------------------------------------------
  1414                                  
  1415                                  ;;Note:	At the end of every buffer load,
  1416                                  ;;	during buffer switch/swap, there will be discontinuity
  1417                                  ;;	between the last converted sample and the 1st sample
  1418                                  ;;	of the next buffer.
  1419                                  ;;	(like as a dot noises vaguely between normal sound samples)
  1420                                  ;;	-To avoid this defect, the 1st sample of
  1421                                  ;;	the next buffer may be read from the wav file but
  1422                                  ;;	the file pointer would need to be set to 1 sample back
  1423                                  ;;	again via seek system call. Time comsumption problem! -
  1424                                  ;;
  1425                                  ;;	Erdogan Tan - 15/11/2023
  1426                                  ;;
  1427                                  ;;	((If entire wav data would be loaded at once.. conversion
  1428                                  ;;	defect/noise would disappear.. but for DOS, to keep
  1429                                  ;;	64KB buffer limit is important also it is important
  1430                                  ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1431                                  ;;	I have tested this program by using 2-30MB wav files.))
  1432                                  ;;
  1433                                  ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1434                                  ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1435                                  ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1436                                  ;;			Realtek ALC850 codec.
  1437                                  ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1438                                  
  1439                                  load_8khz_mono_8_bit:
  1440                                  	; 15/11/2023
  1441                                  	; 14/11/2023
  1442                                  	; 13/11/2023
  1443 000009C8 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1444                                  					; last of the file?
  1445 000009CF 7402                    	jz	short lff8m_0		; no
  1446 000009D1 F9                      	stc
  1447 000009D2 C3                      	retn
  1448                                  
  1449                                  lff8m_0:
  1450 000009D3 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1451                                          ;mov	edx, [loadsize]
  1452                                  
  1453                                  	; esi = buffer address
  1454                                  	;; edx = buffer size
  1455                                  
  1456                                  	; load file into memory
  1457                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000009D8 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000009DE 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000009E0 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000009E6 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000009EB CD40                <1>  int 40h
  1458 000009ED 7305                    	jnc	short lff8m_6
  1459 000009EF E9AB000000              	jmp	lff8m_5  ; error !
  1460                                  
  1461                                  lff8m_6:
  1462                                  	;mov	edi, audio_buffer
  1463                                  	; 29/05/2024
  1464 000009F4 8B3D[EE280000]          	mov	edi, [audio_buffer]
  1465 000009FA 21C0                    	and	eax, eax
  1466 000009FC 0F8494000000            	jz	lff8_eof
  1467                                  
  1468 00000A02 89C1                    	mov	ecx, eax		; byte count
  1469                                  lff8m_1:
  1470 00000A04 AC                      	lodsb
  1471 00000A05 A2[28200000]            	mov	[previous_val], al
  1472 00000A0A 2C80                    	sub	al, 80h
  1473 00000A0C 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1474 00000A10 66AB                    	stosw		; original sample (left channel)
  1475 00000A12 66AB                    	stosw		; original sample (right channel)
  1476                                  	;xor	eax, eax
  1477 00000A14 B080                    	mov	al, 80h
  1478 00000A16 49                      	dec	ecx
  1479 00000A17 7402                    	jz	short lff8m_2
  1480 00000A19 8A06                    	mov	al, [esi]
  1481                                  lff8m_2:
  1482                                  	;mov	[next_val], ax
  1483 00000A1B 88C7                    	mov	bh, al	; [next_val]
  1484 00000A1D 8A25[28200000]          	mov	ah, [previous_val]
  1485 00000A23 00E0                    	add	al, ah	; [previous_val]
  1486 00000A25 D0D8                    	rcr	al, 1
  1487 00000A27 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample
  1488 00000A29 00E0                    	add	al, ah	; [previous_val]
  1489 00000A2B D0D8                    	rcr	al, 1	
  1490 00000A2D 88C3                    	mov	bl, al 	; this is temporary interpolation value	
  1491 00000A2F 00E0                    	add	al, ah	; [previous_val]
  1492 00000A31 D0D8                    	rcr	al, 1
  1493 00000A33 2C80                    	sub	al, 80h
  1494 00000A35 66C1E008                	shl	ax, 8	
  1495 00000A39 66AB                    	stosw		; this is 1st interpolated sample (L)
  1496 00000A3B 66AB                    	stosw		; this is 1st interpolated sample (R)
  1497 00000A3D 88D8                    	mov	al, bl
  1498 00000A3F 00D0                    	add	al, dl
  1499 00000A41 D0D8                    	rcr	al, 1
  1500 00000A43 2C80                    	sub	al, 80h
  1501 00000A45 66C1E008                	shl	ax, 8
  1502 00000A49 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1503 00000A4B 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1504 00000A4D 88D0                    	mov	al, dl
  1505 00000A4F 2C80                    	sub	al, 80h
  1506 00000A51 66C1E008                	shl	ax, 8
  1507 00000A55 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1508 00000A57 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1509                                  	;mov	al, [next_val]
  1510 00000A59 88F8                    	mov	al, bh
  1511 00000A5B 00D0                    	add	al, dl
  1512 00000A5D D0D8                    	rcr	al, 1
  1513 00000A5F 88C3                    	mov	bl, al	; this is temporary interpolation value
  1514 00000A61 00D0                    	add	al, dl
  1515 00000A63 D0D8                    	rcr	al, 1
  1516 00000A65 2C80                    	sub	al, 80h
  1517 00000A67 66C1E008                	shl	ax, 8
  1518 00000A6B 66AB                    	stosw		; this is 4th interpolated sample (L)
  1519 00000A6D 66AB                    	stosw		; this is 4th interpolated sample (R)
  1520                                  	;mov	al, [next_val]
  1521 00000A6F 88F8                    	mov	al, bh
  1522 00000A71 00D8                    	add	al, bl
  1523 00000A73 D0D8                    	rcr	al, 1
  1524 00000A75 2C80                    	sub	al, 80h
  1525 00000A77 66C1E008                	shl	ax, 8
  1526 00000A7B 66AB                    	stosw		; this is 5th interpolated sample (L)
  1527 00000A7D 66AB                    	stosw		; this is 5th interpolated sample (R)
  1528                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1529 00000A7F 09C9                    	or	ecx, ecx
  1530 00000A81 7581                    	jnz	short lff8m_1
  1531                                  
  1532                                  	; --------------
  1533                                  
  1534                                  lff8s_3:
  1535                                  lff8m_3:
  1536                                  lff8s2_3:
  1537                                  lff8m2_3:
  1538                                  lff16s_3:
  1539                                  lff16m_3:
  1540                                  lff16s2_3:
  1541                                  lff16m2_3:
  1542                                  lff24_3:
  1543                                  lff32_3:
  1544                                  lff44_3:
  1545                                  lff22_3:
  1546                                  lff11_3:
  1547                                  	; 31/05/2024 (BugFix)
  1548 00000A83 8B0D[74030000]          	mov	ecx, [buffersize] ; buffer size in bytes
  1549                                  	;shl	ecx, 1 ; Bug !
  1550 00000A89 29F9                    	sub	ecx, edi
  1551 00000A8B 7607                    	jna	short lff8m_4
  1552                                  	;inc	ecx
  1553 00000A8D C1E902                  	shr	ecx, 2
  1554 00000A90 31C0                    	xor	eax, eax ; fill (remain part of) buffer with zeros	
  1555 00000A92 F3AB                    	rep	stosd
  1556                                  lff8m_4:
  1557                                  	; 31/05/2024 (BugFix)
  1558                                  	; cf=1 ; Bug !
  1559 00000A94 F8                      	clc
  1560 00000A95 C3                      	retn
  1561                                  
  1562                                  lff8_eof:
  1563                                  lff16_eof:
  1564                                  lff24_eof:
  1565                                  lff32_eof:
  1566                                  lff44_eof:
  1567                                  lff22_eof:
  1568                                  lff11_eof:
  1569                                  	; 15/11/2023
  1570 00000A96 C605[70280000]01        	mov	byte [flags], ENDOFFILE
  1571 00000A9D EBE4                    	jmp	short lff8m_3
  1572                                  
  1573                                  lff8s_5:
  1574                                  lff8m_5:
  1575                                  lff8s2_5:
  1576                                  lff8m2_5:
  1577                                  lff16s_5:
  1578                                  lff16m_5:
  1579                                  lff16s2_5:
  1580                                  lff16m2_5:
  1581                                  lff24_5:
  1582                                  lff32_5:
  1583                                  lff44_5:
  1584                                  lff22_5:
  1585                                  lff11_5:
  1586 00000A9F B021                    	mov	al, '!'  ; error
  1587 00000AA1 E88AFAFFFF              	call	tL0
  1588                                  	
  1589                                  	;jmp	short lff8m_3
  1590                                  	; 15/11/2023
  1591 00000AA6 EBEE                    	jmp	lff8_eof
  1592                                  
  1593                                  	; --------------
  1594                                  
  1595                                  load_8khz_stereo_8_bit:
  1596                                  	; 15/11/2023
  1597                                  	; 14/11/2023
  1598                                  	; 13/11/2023
  1599 00000AA8 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1600                                  					; last of the file?
  1601 00000AAF 7402                    	jz	short lff8s_0		; no
  1602 00000AB1 F9                      	stc
  1603 00000AB2 C3                      	retn
  1604                                  
  1605                                  lff8s_0:
  1606 00000AB3 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1607                                          ;mov	edx, [loadsize]
  1608                                  
  1609                                  	; esi = buffer address
  1610                                  	;; edx = buffer size
  1611                                  
  1612                                  	; load file into memory
  1613                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000AB8 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000ABE 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000AC0 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000AC6 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000ACB CD40                <1>  int 40h
  1614 00000ACD 72D0                    	jc	short lff8s_5 ; error !
  1615                                  
  1616                                  	;mov	edi, audio_buffer
  1617                                  	; 29/05/2024
  1618 00000ACF 8B3D[EE280000]          	mov	edi, [audio_buffer]
  1619                                  	
  1620 00000AD5 D1E8                    	shr	eax, 1
  1621 00000AD7 74BD                    	jz	short lff8_eof
  1622                                  
  1623 00000AD9 89C1                    	mov	ecx, eax	; word count
  1624                                  lff8s_1:
  1625 00000ADB AC                      	lodsb
  1626 00000ADC A2[28200000]            	mov	[previous_val_l], al
  1627 00000AE1 2C80                    	sub	al, 80h
  1628 00000AE3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1629 00000AE7 66AB                    	stosw		; original sample (L)
  1630 00000AE9 AC                      	lodsb
  1631 00000AEA A2[2A200000]            	mov	[previous_val_r], al
  1632 00000AEF 2C80                    	sub	al, 80h
  1633 00000AF1 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1634 00000AF5 66AB                    	stosw		; original sample (R)
  1635                                  
  1636                                  	;xor	eax, eax
  1637 00000AF7 66B88080                	mov	ax, 8080h
  1638 00000AFB 49                      	dec	ecx
  1639 00000AFC 7403                    	jz	short lff8s_2
  1640                                  		; convert 8 bit sample to 16 bit sample
  1641 00000AFE 668B06                  	mov	ax, [esi]
  1642                                  lff8s_2:
  1643 00000B01 A2[2C200000]            	mov	[next_val_l], al
  1644 00000B06 8825[2E200000]          	mov	[next_val_r], ah
  1645 00000B0C 8A25[28200000]          	mov	ah, [previous_val_l]
  1646 00000B12 00E0                    	add	al, ah
  1647 00000B14 D0D8                    	rcr	al, 1
  1648 00000B16 88C2                    	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1649 00000B18 00E0                    	add	al, ah
  1650 00000B1A D0D8                    	rcr	al, 1	
  1651 00000B1C 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1652 00000B1E 00E0                    	add	al, ah
  1653 00000B20 D0D8                    	rcr	al, 1
  1654 00000B22 2C80                    	sub	al, 80h
  1655 00000B24 66C1E008                	shl	ax, 8
  1656 00000B28 66AB                    	stosw		; this is 1st interpolated sample (L)
  1657 00000B2A A0[2E200000]            	mov	al, [next_val_r]
  1658 00000B2F 8A25[2A200000]          	mov	ah, [previous_val_r]
  1659 00000B35 00E0                    	add	al, ah
  1660 00000B37 D0D8                    	rcr	al, 1
  1661 00000B39 88C6                    	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1662 00000B3B 00E0                    	add	al, ah
  1663 00000B3D D0D8                    	rcr	al, 1
  1664 00000B3F 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1665 00000B41 00E0                    	add	al, ah
  1666 00000B43 D0D8                    	rcr	al, 1
  1667 00000B45 2C80                    	sub	al, 80h
  1668 00000B47 66C1E008                	shl	ax, 8
  1669 00000B4B 66AB                    	stosw		; this is 1st interpolated sample (R)
  1670 00000B4D 88D8                    	mov	al, bl
  1671 00000B4F 00D0                    	add	al, dl
  1672 00000B51 D0D8                    	rcr	al, 1
  1673 00000B53 2C80                    	sub	al, 80h
  1674 00000B55 66C1E008                	shl	ax, 8
  1675 00000B59 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1676 00000B5B 88F8                    	mov	al, bh
  1677 00000B5D 00F0                    	add	al, dh
  1678 00000B5F D0D8                    	rcr	al, 1
  1679 00000B61 2C80                    	sub	al, 80h
  1680 00000B63 66C1E008                	shl	ax, 8
  1681 00000B67 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1682 00000B69 88D0                    	mov	al, dl
  1683 00000B6B 2C80                    	sub	al, 80h
  1684 00000B6D 66C1E008                	shl	ax, 8
  1685 00000B71 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1686 00000B73 88F0                    	mov	al, dh
  1687 00000B75 2C80                    	sub	al, 80h
  1688 00000B77 66C1E008                	shl	ax, 8
  1689 00000B7B 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1690 00000B7D A0[2C200000]            	mov	al, [next_val_l]
  1691 00000B82 00D0                    	add	al, dl
  1692 00000B84 D0D8                    	rcr	al, 1
  1693 00000B86 88C3                    	mov	bl, al	; this is temporary interpolation value (L)
  1694 00000B88 00D0                    	add	al, dl
  1695 00000B8A D0D8                    	rcr	al, 1
  1696 00000B8C 2C80                    	sub	al, 80h
  1697 00000B8E 66C1E008                	shl	ax, 8
  1698 00000B92 66AB                    	stosw		; this is 4th interpolated sample (L)
  1699 00000B94 A0[2E200000]            	mov	al, [next_val_r]
  1700 00000B99 00F0                    	add	al, dh
  1701 00000B9B D0D8                    	rcr	al, 1
  1702 00000B9D 88C7                    	mov	bh, al	; this is temporary interpolation value (R)
  1703 00000B9F 00F0                    	add	al, dh
  1704 00000BA1 D0D8                    	rcr	al, 1
  1705 00000BA3 2C80                    	sub	al, 80h
  1706 00000BA5 66C1E008                	shl	ax, 8
  1707 00000BA9 66AB                    	stosw		; this is 4th interpolated sample (R)
  1708 00000BAB A0[2C200000]            	mov	al, [next_val_l]
  1709 00000BB0 00D8                    	add	al, bl
  1710 00000BB2 D0D8                    	rcr	al, 1
  1711 00000BB4 2C80                    	sub	al, 80h
  1712 00000BB6 66C1E008                	shl	ax, 8
  1713 00000BBA 66AB                    	stosw		; this is 5th interpolated sample (L)
  1714 00000BBC A0[2E200000]            	mov	al, [next_val_r]
  1715 00000BC1 00F8                    	add	al, bh
  1716 00000BC3 D0D8                    	rcr	al, 1
  1717 00000BC5 2C80                    	sub	al, 80h
  1718 00000BC7 66C1E008                	shl	ax, 8
  1719 00000BCB 66AB                    	stosw		; this is 5th interpolated sample (R)
  1720                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1721 00000BCD E305                    	jecxz	lff8s_6
  1722 00000BCF E907FFFFFF              	jmp	lff8s_1
  1723                                  lff8s_6:
  1724 00000BD4 E9AAFEFFFF              	jmp	lff8s_3
  1725                                  
  1726                                  load_8khz_mono_16_bit:
  1727                                  	; 13/11/2023
  1728 00000BD9 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1729                                  					; last of the file?
  1730 00000BE0 7402                    	jz	short lff8m2_0		; no
  1731 00000BE2 F9                      	stc
  1732 00000BE3 C3                      	retn
  1733                                  
  1734                                  lff8m2_0:
  1735 00000BE4 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1736                                          ;mov	edx, [loadsize]
  1737                                  
  1738                                  	; esi = buffer address
  1739                                  	;; edx = buffer size
  1740                                  
  1741                                  	; load file into memory
  1742                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000BE9 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000BEF 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000BF1 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000BF7 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000BFC CD40                <1>  int 40h
  1743 00000BFE 0F82A1000000            	jc	lff8m2_7 ; error !
  1744                                  
  1745                                  	;mov	edi, audio_buffer
  1746                                  	; 29/05/2024
  1747 00000C04 8B3D[EE280000]          	mov	edi, [audio_buffer]
  1748                                  	
  1749 00000C0A D1E8                    	shr	eax, 1
  1750 00000C0C 7505                    	jnz	short lff8m2_8
  1751 00000C0E E983FEFFFF              	jmp	lff8_eof
  1752                                  
  1753                                  lff8m2_8:
  1754 00000C13 89C1                    	mov	ecx, eax	; word count
  1755                                  lff8m2_1:
  1756 00000C15 66AD                    	lodsw
  1757 00000C17 66AB                    	stosw		; original sample (left channel)
  1758 00000C19 66AB                    	stosw		; original sample (right channel)
  1759 00000C1B 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1760 00000C1E 66A3[28200000]          	mov	[previous_val], ax
  1761 00000C24 31C0                    	xor	eax, eax
  1762 00000C26 49                      	dec	ecx
  1763 00000C27 7403                    	jz	short lff8m2_2
  1764 00000C29 668B06                  	mov	ax, [esi]
  1765                                  lff8m2_2:
  1766 00000C2C 80C480                  	add	ah, 80h ; convert sound level to 0-65535 format
  1767 00000C2F 89C5                    	mov	ebp, eax	; [next_val]
  1768 00000C31 660305[28200000]        	add	ax, [previous_val]
  1769 00000C38 66D1D8                  	rcr	ax, 1
  1770 00000C3B 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample
  1771 00000C3D 660305[28200000]        	add	ax, [previous_val]
  1772 00000C44 66D1D8                  	rcr	ax, 1	; this is temporary interpolation value
  1773 00000C47 89C3                    	mov	ebx, eax 		
  1774 00000C49 660305[28200000]        	add	ax, [previous_val]
  1775 00000C50 66D1D8                  	rcr	ax, 1
  1776 00000C53 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1777 00000C56 66AB                    	stosw		; this is 1st interpolated sample (L)
  1778 00000C58 66AB                    	stosw		; this is 1st interpolated sample (R)
  1779 00000C5A 89D8                    	mov	eax, ebx
  1780 00000C5C 6601D0                  	add	ax, dx
  1781 00000C5F 66D1D8                  	rcr	ax, 1
  1782 00000C62 80EC80                  	sub	ah, 80h
  1783 00000C65 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1784 00000C67 66AB                    	stosw		; this is 2nd interpolated sample (R)
  1785 00000C69 89D0                    	mov	eax, edx
  1786 00000C6B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1787 00000C6E 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1788 00000C70 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1789 00000C72 89E8                    	mov	eax, ebp
  1790 00000C74 6601D0                  	add	ax, dx
  1791 00000C77 66D1D8                  	rcr	ax, 1
  1792 00000C7A 89C3                    	mov	ebx, eax ; this is temporary interpolation value
  1793 00000C7C 6601D0                  	add	ax, dx
  1794 00000C7F 66D1D8                  	rcr	ax, 1
  1795 00000C82 80EC80                  	sub	ah, 80h
  1796 00000C85 66AB                    	stosw		; this is 4th interpolated sample (L)
  1797 00000C87 66AB                    	stosw		; this is 4th interpolated sample (R)
  1798 00000C89 89E8                    	mov	eax, ebp
  1799 00000C8B 6601D8                  	add	ax, bx
  1800 00000C8E 66D1D8                  	rcr	ax, 1
  1801 00000C91 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1802 00000C94 66AB                    	stosw		; this is 5th interpolated sample (L)
  1803 00000C96 66AB                    	stosw		; this is 5th interpolated sample (R)
  1804                                  	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1805 00000C98 09C9                    	or	ecx, ecx
  1806 00000C9A 0F8575FFFFFF            	jnz	lff8m2_1
  1807 00000CA0 E9DEFDFFFF              	jmp	lff8m2_3
  1808                                  
  1809                                  lff8m2_7:
  1810                                  lff8s2_7:
  1811 00000CA5 E9F5FDFFFF              	jmp	lff8m2_5  ; error
  1812                                  
  1813                                  load_8khz_stereo_16_bit:
  1814                                  	; 16/11/2023
  1815                                  	; 15/11/2023
  1816                                  	; 13/11/2023
  1817 00000CAA F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1818                                  					; last of the file?
  1819 00000CB1 7402                    	jz	short lff8s2_0		; no
  1820 00000CB3 F9                      	stc
  1821 00000CB4 C3                      	retn
  1822                                  
  1823                                  lff8s2_0:
  1824 00000CB5 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1825                                          ;mov	edx, [loadsize]
  1826                                  
  1827                                  	; esi = buffer address
  1828                                  	;; edx = buffer size
  1829                                  
  1830                                  	; load file into memory
  1831                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000CBA 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000CC0 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000CC2 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000CC8 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000CCD CD40                <1>  int 40h
  1832 00000CCF 72D4                    	jc	short lff8s2_7 ; error !
  1833                                  
  1834                                  	;mov	edi, audio_buffer
  1835                                  	; 29/05/2024
  1836 00000CD1 8B3D[EE280000]          	mov	edi, [audio_buffer]
  1837                                  	
  1838 00000CD7 C1E802                  	shr	eax, 2
  1839 00000CDA 7505                    	jnz	short lff8s2_8
  1840 00000CDC E9B5FDFFFF              	jmp	lff8_eof
  1841                                  
  1842                                  lff8s2_8:
  1843 00000CE1 89C1                    	mov	ecx, eax ; dword count
  1844                                  lff8s2_1:
  1845 00000CE3 66AD                    	lodsw
  1846 00000CE5 66AB                    	stosw		; original sample (L)
  1847                                  	; 15/11/2023
  1848 00000CE7 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1849 00000CEA 66A3[28200000]          	mov	[previous_val_l], ax
  1850 00000CF0 66AD                    	lodsw
  1851 00000CF2 66AB                    	stosw		; original sample (R)
  1852 00000CF4 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1853 00000CF7 66A3[2A200000]          	mov	[previous_val_r], ax
  1854 00000CFD 31D2                    	xor	edx, edx
  1855 00000CFF 31C0                    	xor	eax, eax
  1856                                  	; 16/11/2023
  1857 00000D01 49                      	dec	ecx
  1858 00000D02 7407                    	jz	short lff8s2_2
  1859 00000D04 668B06                  	mov	ax, [esi]
  1860 00000D07 668B5602                	mov	dx, [esi+2]
  1861                                  lff8s2_2:
  1862 00000D0B 80C480                  	add	ah, 80h	; convert sound level to 0-65535 format
  1863 00000D0E 66A3[2C200000]          	mov	[next_val_l], ax
  1864 00000D14 80C680                  	add	dh, 80h	; convert sound level to 0-65535 format
  1865 00000D17 668915[2E200000]        	mov	[next_val_r], dx
  1866 00000D1E 660305[28200000]        	add	ax, [previous_val_l]
  1867 00000D25 66D1D8                  	rcr	ax, 1
  1868 00000D28 89C2                    	mov	edx, eax ; this is interpolated middle (3th) sample (L)
  1869 00000D2A 660305[28200000]        	add	ax, [previous_val_l]
  1870 00000D31 66D1D8                  	rcr	ax, 1	
  1871 00000D34 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1872 00000D36 660305[28200000]        	add	ax, [previous_val_l]
  1873 00000D3D 66D1D8                  	rcr	ax, 1
  1874 00000D40 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1875 00000D43 66AB                    	stosw		; this is 1st interpolated sample (L)
  1876 00000D45 66A1[2E200000]          	mov	ax, [next_val_r]
  1877 00000D4B 660305[2A200000]        	add	ax, [previous_val_r]
  1878 00000D52 66D1D8                  	rcr	ax, 1
  1879 00000D55 89C5                    	mov	ebp, eax ; this is interpolated middle (3th) sample (R)
  1880 00000D57 660305[2A200000]        	add	ax, [previous_val_r]
  1881 00000D5E 66D1D8                  	rcr	ax, 1
  1882 00000D61 50                      	push	eax ; *	; this is temporary interpolation value (R)
  1883 00000D62 660305[2A200000]        	add	ax, [previous_val_r]
  1884 00000D69 66D1D8                  	rcr	ax, 1
  1885 00000D6C 80EC80                  	sub	ah, 80h
  1886 00000D6F 66AB                    	stosw		; this is 1st interpolated sample (R)
  1887 00000D71 89D8                    	mov	eax, ebx
  1888 00000D73 6601D0                  	add	ax, dx
  1889 00000D76 66D1D8                  	rcr	ax, 1
  1890 00000D79 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1891 00000D7C 66AB                    	stosw		; this is 2nd interpolated sample (L)
  1892 00000D7E 58                      	pop	eax ; *
  1893 00000D7F 6601E8                  	add	ax, bp
  1894 00000D82 66D1D8                  	rcr	ax, 1
  1895 00000D85 80EC80                  	sub	ah, 80h
  1896 00000D88 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  1897 00000D8A 89D0                    	mov	eax, edx
  1898 00000D8C 80EC80                  	sub	ah, 80h
  1899 00000D8F 66AB                    	stosw		; this is middle (3th) interpolated sample (L)
  1900 00000D91 89E8                    	mov	eax, ebp
  1901 00000D93 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1902 00000D96 66AB                    	stosw		; this is middle (3th) interpolated sample (R)
  1903 00000D98 66A1[2C200000]          	mov	ax, [next_val_l]
  1904 00000D9E 6601D0                  	add	ax, dx
  1905 00000DA1 66D1D8                  	rcr	ax, 1
  1906 00000DA4 89C3                    	mov	ebx, eax ; this is temporary interpolation value (L)
  1907 00000DA6 6601D0                  	add	ax, dx
  1908 00000DA9 66D1D8                  	rcr	ax, 1
  1909 00000DAC 80EC80                  	sub	ah, 80h
  1910 00000DAF 66AB                    	stosw		; this is 4th interpolated sample (L)
  1911 00000DB1 66A1[2E200000]          	mov	ax, [next_val_r]
  1912 00000DB7 6601E8                  	add	ax, bp
  1913 00000DBA 66D1D8                  	rcr	ax, 1
  1914 00000DBD 50                      	push	eax ; ** ; this is temporary interpolation value (R)
  1915 00000DBE 6601E8                  	add	ax, bp
  1916 00000DC1 66D1D8                  	rcr	ax, 1
  1917 00000DC4 80EC80                  	sub	ah, 80h
  1918 00000DC7 66AB                    	stosw		; this is 4th interpolated sample (R)
  1919 00000DC9 66A1[2C200000]          	mov	ax, [next_val_l]
  1920 00000DCF 6601D8                  	add	ax, bx
  1921 00000DD2 66D1D8                  	rcr	ax, 1
  1922 00000DD5 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  1923 00000DD8 66AB                    	stosw		; this is 5th interpolated sample (L)
  1924 00000DDA 58                      	pop	eax ; **
  1925 00000DDB 660305[2E200000]        	add	ax, [next_val_r]
  1926 00000DE2 66D1D8                  	rcr	ax, 1
  1927 00000DE5 80EC80                  	sub	ah, 80h
  1928 00000DE8 66AB                    	stosw		; this is 5th interpolated sample (R)
  1929                                  	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1930 00000DEA E305                    	jecxz	lff8_s2_9
  1931 00000DEC E9F2FEFFFF              	jmp	lff8s2_1
  1932                                  lff8_s2_9:
  1933 00000DF1 E98DFCFFFF              	jmp	lff8s2_3
  1934                                  
  1935                                  ; .....................
  1936                                  
  1937                                  load_16khz_mono_8_bit:
  1938                                  	; 14/11/2023
  1939                                  	; 13/11/2023
  1940 00000DF6 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  1941                                  					; last of the file?
  1942 00000DFD 7402                    	jz	short lff16m_0		; no
  1943 00000DFF F9                      	stc
  1944 00000E00 C3                      	retn
  1945                                  
  1946                                  lff16m_0:
  1947 00000E01 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  1948                                          ;mov	edx, [loadsize]
  1949                                  
  1950                                  	; esi = buffer address
  1951                                  	;; edx = buffer size
  1952                                  
  1953                                  	; load file into memory
  1954                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000E06 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000E0C 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000E0E 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000E14 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000E19 CD40                <1>  int 40h
  1955 00000E1B 7254                    	jc	short lff16m_7 ; error !
  1956                                  
  1957                                  	;mov	edi, audio_buffer
  1958                                  	; 29/05/2024
  1959 00000E1D 8B3D[EE280000]          	mov	edi, [audio_buffer]
  1960                                  	
  1961 00000E23 21C0                    	and	eax, eax
  1962 00000E25 7505                    	jnz	short lff16m_8
  1963 00000E27 E96AFCFFFF              	jmp	lff16_eof
  1964                                  
  1965                                  lff16m_8:
  1966 00000E2C 89C1                    	mov	ecx, eax		; byte count
  1967                                  lff16m_1:
  1968 00000E2E AC                      	lodsb
  1969                                  	;mov	[previous_val], al
  1970 00000E2F 88C3                    	mov	bl, al
  1971 00000E31 2C80                    	sub	al, 80h
  1972 00000E33 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1973 00000E37 66AB                    	stosw		; original sample (left channel)
  1974 00000E39 66AB                    	stosw		; original sample (right channel)
  1975                                  	;xor	ax, ax
  1976                                  	; 14/11/22023
  1977 00000E3B B080                    	mov	al, 80h
  1978 00000E3D 49                      	dec	ecx
  1979 00000E3E 7402                    	jz	short lff16m_2
  1980 00000E40 8A06                    	mov	al, [esi]
  1981                                  lff16m_2:
  1982                                  	;mov	[next_val], al
  1983 00000E42 88C7                    	mov	bh, al
  1984                                  	;add	al, [previous_val]
  1985 00000E44 00D8                    	add	al, bl
  1986 00000E46 D0D8                    	rcr	al, 1
  1987 00000E48 88C2                    	mov	dl, al	; this is interpolated middle (temp) sample
  1988                                  	;add	al, [previous_val]
  1989 00000E4A 00D8                    	add	al, bl
  1990 00000E4C D0D8                    	rcr	al, 1
  1991 00000E4E 2C80                    	sub	al, 80h
  1992 00000E50 66C1E008                	shl	ax, 8
  1993 00000E54 66AB                    	stosw		; this is 1st interpolated sample (L)
  1994 00000E56 66AB                    	stosw		; this is 1st interpolated sample (R)
  1995                                  	;mov	al, [next_val]
  1996 00000E58 88F8                    	mov	al, bh
  1997 00000E5A 00D0                    	add	al, dl
  1998 00000E5C D0D8                    	rcr	al, 1
  1999 00000E5E 2C80                    	sub	al, 80h
  2000 00000E60 66C1E008                	shl	ax, 8
  2001 00000E64 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2002 00000E66 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2003                                  	
  2004                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2005 00000E68 09C9                    	or	ecx, ecx
  2006 00000E6A 75C2                    	jnz	short lff16m_1
  2007 00000E6C E912FCFFFF              	jmp	lff16m_3
  2008                                  
  2009                                  lff16m_7:
  2010                                  lff16s_7:
  2011 00000E71 E929FCFFFF              	jmp	lff16m_5  ; error
  2012                                  
  2013                                  load_16khz_stereo_8_bit:
  2014                                  	; 14/11/2023
  2015                                  	; 13/11/2023
  2016 00000E76 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2017                                  					; last of the file?
  2018 00000E7D 7402                    	jz	short lff16s_0		; no
  2019 00000E7F F9                      	stc
  2020 00000E80 C3                      	retn
  2021                                  
  2022                                  lff16s_0:
  2023 00000E81 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2024                                          ;mov	edx, [loadsize]
  2025                                  
  2026                                  	; esi = buffer address
  2027                                  	;; edx = buffer size
  2028                                  
  2029                                  	; load file into memory
  2030                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000E86 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000E8C 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000E8E 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000E94 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000E99 CD40                <1>  int 40h
  2031 00000E9B 72D4                    	jc	short lff16s_7 ; error !
  2032                                  
  2033                                  	;mov	edi, audio_buffer
  2034                                  	; 29/05/2024
  2035 00000E9D 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2036                                  	
  2037 00000EA3 D1E8                    	shr	eax, 1
  2038 00000EA5 7505                    	jnz	short lff16s_8
  2039 00000EA7 E9EAFBFFFF              	jmp	lff16_eof
  2040                                  
  2041                                  lff16s_8:
  2042 00000EAC 89C1                    	mov	ecx, eax	; word count
  2043                                  lff16s_1:
  2044 00000EAE AC                      	lodsb
  2045 00000EAF A2[28200000]            	mov	[previous_val_l], al
  2046 00000EB4 2C80                    	sub	al, 80h
  2047 00000EB6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2048 00000EBA 66AB                    	stosw		; original sample (L)
  2049 00000EBC AC                      	lodsb
  2050 00000EBD A2[2A200000]            	mov	[previous_val_r], al
  2051 00000EC2 2C80                    	sub	al, 80h
  2052 00000EC4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2053 00000EC8 66AB                    	stosw		; original sample (R)
  2054                                  
  2055                                  	;xor	eax, eax
  2056 00000ECA 66B88080                	mov	ax, 8080h
  2057 00000ECE 49                      	dec	ecx
  2058 00000ECF 7403                    	jz	short lff16s_2
  2059                                  		; convert 8 bit sample to 16 bit sample
  2060 00000ED1 668B06                  	mov	ax, [esi]
  2061                                  lff16s_2:
  2062                                  	;mov	[next_val_l], al
  2063                                  	;mov	[next_val_r], ah
  2064 00000ED4 89C3                    	mov	ebx, eax
  2065 00000ED6 0205[28200000]          	add	al, [previous_val_l]
  2066 00000EDC D0D8                    	rcr	al, 1
  2067 00000EDE 88C2                    	mov	dl, al	; this is temporary interpolation value (L)
  2068 00000EE0 0205[28200000]          	add	al, [previous_val_l]
  2069 00000EE6 D0D8                    	rcr	al, 1
  2070 00000EE8 2C80                    	sub	al, 80h
  2071 00000EEA 66C1E008                	shl	ax, 8
  2072 00000EEE 66AB                    	stosw		; this is 1st interpolated sample (L)
  2073 00000EF0 88F8                    	mov	al, bh	; [next_val_r]
  2074 00000EF2 0205[2A200000]          	add	al, [previous_val_r]
  2075 00000EF8 D0D8                    	rcr	al, 1
  2076 00000EFA 88C6                    	mov	dh, al	; this is temporary interpolation value (R)
  2077 00000EFC 0205[2A200000]          	add	al, [previous_val_r]
  2078 00000F02 D0D8                    	rcr	al, 1
  2079 00000F04 2C80                    	sub	al, 80h
  2080 00000F06 66C1E008                	shl	ax, 8
  2081 00000F0A 66AB                    	stosw		; this is 1st interpolated sample (R)
  2082 00000F0C 88D0                    	mov	al, dl
  2083 00000F0E 00D8                    	add	al, bl	; [next_val_l]
  2084 00000F10 D0D8                    	rcr	al, 1
  2085 00000F12 2C80                    	sub	al, 80h
  2086 00000F14 66C1E008                	shl	ax, 8
  2087 00000F18 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2088 00000F1A 88F0                    	mov	al, dh
  2089 00000F1C 00F8                    	add	al, bh	; [next_val_r]
  2090 00000F1E D0D8                    	rcr	al, 1
  2091 00000F20 2C80                    	sub	al, 80h
  2092 00000F22 66C1E008                	shl	ax, 8
  2093 00000F26 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2094                                  	
  2095                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2096 00000F28 09C9                    	or	ecx, ecx
  2097 00000F2A 7582                    	jnz	short lff16s_1
  2098 00000F2C E952FBFFFF              	jmp	lff16s_3
  2099                                  
  2100                                  load_16khz_mono_16_bit:
  2101                                  	; 15/11/2023
  2102                                  	; 13/11/2023
  2103 00000F31 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2104                                  					; last of the file?
  2105 00000F38 7402                    	jz	short lff16m2_0		; no
  2106 00000F3A F9                      	stc
  2107 00000F3B C3                      	retn
  2108                                  
  2109                                  lff16m2_0:
  2110 00000F3C BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2111                                          ;mov	edx, [loadsize]
  2112                                  
  2113                                  	; esi = buffer address
  2114                                  	;; edx = buffer size
  2115                                  
  2116                                  	; load file into memory
  2117                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000F41 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000F47 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000F49 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000F4F B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000F54 CD40                <1>  int 40h
  2118 00000F56 7256                    	jc	short lff16m2_7 ; error !
  2119                                  
  2120                                  	;mov	edi, audio_buffer
  2121                                  	; 29/05/2024
  2122 00000F58 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2123                                  	
  2124 00000F5E D1E8                    	shr	eax, 1
  2125 00000F60 7505                    	jnz	short lff16m2_8
  2126 00000F62 E92FFBFFFF              	jmp	lff16_eof
  2127                                  
  2128                                  lff16m2_8:
  2129 00000F67 89C1                    	mov	ecx, eax  ; word count
  2130                                  lff16m2_1:
  2131 00000F69 66AD                    	lodsw
  2132 00000F6B 66AB                    	stosw		; original sample (left channel)
  2133 00000F6D 66AB                    	stosw		; original sample (right channel)
  2134 00000F6F 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2135                                  	;mov	[previous_val], ax
  2136 00000F72 89C3                    	mov	ebx, eax	
  2137 00000F74 31C0                    	xor	eax, eax
  2138 00000F76 49                      	dec	ecx
  2139 00000F77 7403                    	jz	short lff16m2_2
  2140 00000F79 668B06                  	mov	ax, [esi]
  2141                                  lff16m2_2:
  2142 00000F7C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2143 00000F7F 89C5                    	mov	ebp, eax	; [next_val]
  2144                                  	;add	ax, [previous_val]
  2145 00000F81 6601D8                  	add	ax, bx
  2146 00000F84 66D1D8                  	rcr	ax, 1
  2147 00000F87 89C2                    	mov	edx, eax ; this is temporary interpolation value
  2148                                  	;add	ax, [previous_val]
  2149 00000F89 6601D8                  	add	ax, bx
  2150 00000F8C 66D1D8                  	rcr	ax, 1
  2151 00000F8F 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2152 00000F92 66AB                    	stosw		; this is 1st interpolated sample (L)
  2153 00000F94 66AB                    	stosw		; this is 1st interpolated sample (R)
  2154 00000F96 89E8                    	mov	eax, ebp 
  2155 00000F98 6601D0                  	add	ax, dx
  2156 00000F9B 66D1D8                  	rcr	ax, 1
  2157 00000F9E 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2158 00000FA1 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2159 00000FA3 66AB                    	stosw		; this is 2nd interpolated sample (R)
  2160                                  	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2161 00000FA5 09C9                    	or	ecx, ecx
  2162 00000FA7 75C0                    	jnz	short lff16m2_1
  2163 00000FA9 E9D5FAFFFF              	jmp	lff16m2_3
  2164                                  
  2165                                  lff16m2_7:
  2166                                  lff16s2_7:
  2167 00000FAE E9ECFAFFFF              	jmp	lff16m2_5  ; error
  2168                                  
  2169                                  load_16khz_stereo_16_bit:
  2170                                  	; 16/11/2023
  2171                                  	; 15/11/2023
  2172                                  	; 13/11/2023
  2173 00000FB3 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2174                                  					; last of the file?
  2175 00000FBA 7402                    	jz	short lff16s2_0		; no
  2176 00000FBC F9                      	stc
  2177 00000FBD C3                      	retn
  2178                                  
  2179                                  lff16s2_0:
  2180 00000FBE BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2181                                          ;mov	edx, [loadsize]
  2182                                  
  2183                                  	; esi = buffer address
  2184                                  	;; edx = buffer size
  2185                                  
  2186                                  	; load file into memory
  2187                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00000FC3 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00000FC9 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00000FCB 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00000FD1 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00000FD6 CD40                <1>  int 40h
  2188 00000FD8 72D4                    	jc	short lff16s2_7 ; error !
  2189                                  
  2190                                  	;mov	edi, audio_buffer
  2191                                  	; 29/05/2024
  2192 00000FDA 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2193                                  	
  2194 00000FE0 C1E802                  	shr	eax, 2
  2195 00000FE3 7505                    	jnz	short lff16s2_8
  2196 00000FE5 E9ACFAFFFF              	jmp	lff16_eof
  2197                                  
  2198                                  lff16s2_8:
  2199 00000FEA 89C1                    	mov	ecx, eax  ; dword count
  2200                                  lff16s2_1:
  2201 00000FEC 66AD                    	lodsw
  2202 00000FEE 66AB                    	stosw		; original sample (L)
  2203 00000FF0 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2204 00000FF3 66A3[28200000]          	mov	[previous_val_l], ax
  2205 00000FF9 66AD                    	lodsw
  2206 00000FFB 66AB                    	stosw		; original sample (R)
  2207 00000FFD 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2208 00001000 66A3[2A200000]          	mov	[previous_val_r], ax
  2209 00001006 31D2                    	xor	edx, edx
  2210 00001008 31C0                    	xor	eax, eax
  2211                                  	; 16/11/2023
  2212 0000100A 49                      	dec	ecx
  2213 0000100B 7407                    	jz	short lff16s2_2
  2214 0000100D 668B06                  	mov	ax, [esi]
  2215 00001010 668B5602                	mov	dx, [esi+2]
  2216                                  lff16s2_2:
  2217 00001014 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2218                                  	;mov	[next_val_l], ax
  2219 00001017 89C5                    	mov	ebp, eax
  2220 00001019 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2221 0000101C 668915[2E200000]        	mov	[next_val_r], dx
  2222 00001023 660305[28200000]        	add	ax, [previous_val_l]
  2223 0000102A 66D1D8                  	rcr	ax, 1
  2224 0000102D 89C2                    	mov	edx, eax ; this is temporary interpolation value (L)
  2225 0000102F 660305[28200000]        	add	ax, [previous_val_l]
  2226 00001036 66D1D8                  	rcr	ax, 1
  2227 00001039 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2228 0000103C 66AB                    	stosw		; this is 1st interpolated sample (L)
  2229 0000103E 66A1[2E200000]          	mov	ax, [next_val_r]
  2230 00001044 660305[2A200000]        	add	ax, [previous_val_r]
  2231 0000104B 66D1D8                  	rcr	ax, 1
  2232 0000104E 89C3                    	mov	ebx, eax ; this is temporary interpolation value (R)
  2233 00001050 660305[2A200000]        	add	ax, [previous_val_r]
  2234 00001057 66D1D8                  	rcr	ax, 1
  2235 0000105A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2236 0000105D 66AB                    	stosw		; this is 1st interpolated sample (R)
  2237                                  	;mov	ax, [next_val_l]
  2238 0000105F 89E8                    	mov	eax, ebp
  2239 00001061 6601D0                  	add	ax, dx
  2240 00001064 66D1D8                  	rcr	ax, 1
  2241 00001067 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2242 0000106A 66AB                    	stosw		; this is 2nd interpolated sample (L)
  2243 0000106C 66A1[2E200000]          	mov	ax, [next_val_r]
  2244 00001072 6601D8                  	add	ax, bx
  2245 00001075 66D1D8                  	rcr	ax, 1
  2246 00001078 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2247 0000107B 66AB                    	stosw 		; this is 2nd interpolated sample (R)
  2248                                  	
  2249                                  	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2250 0000107D 09C9                    	or	ecx, ecx
  2251 0000107F 0F8567FFFFFF            	jnz	lff16s2_1
  2252 00001085 E9F9F9FFFF              	jmp	lff16s2_3
  2253                                  
  2254                                  ; .....................
  2255                                  
  2256                                  load_24khz_mono_8_bit:
  2257                                  	; 15/11/2023
  2258 0000108A F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2259                                  					; last of the file?
  2260 00001091 7402                    	jz	short lff24m_0		; no
  2261 00001093 F9                      	stc
  2262 00001094 C3                      	retn
  2263                                  
  2264                                  lff24m_0:
  2265 00001095 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2266                                          ;mov	edx, [loadsize]
  2267                                  
  2268                                  	; esi = buffer address
  2269                                  	;; edx = buffer size
  2270                                  
  2271                                  	; load file into memory
  2272                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000109A 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000010A0 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000010A2 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000010A8 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000010AD CD40                <1>  int 40h
  2273 000010AF 723C                    	jc	short lff24m_7 ; error !
  2274                                  
  2275                                  	;mov	edi, audio_buffer
  2276                                  	; 29/05/2024
  2277 000010B1 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2278                                  	
  2279 000010B7 21C0                    	and	eax, eax
  2280 000010B9 7505                    	jnz	short lff24m_8
  2281 000010BB E9D6F9FFFF              	jmp	lff24_eof
  2282                                  
  2283                                  lff24m_8:
  2284 000010C0 89C1                    	mov	ecx, eax	; byte count
  2285                                  lff24m_1:
  2286 000010C2 AC                      	lodsb
  2287                                  	;mov	[previous_val], al
  2288 000010C3 88C3                    	mov	bl, al
  2289 000010C5 2C80                    	sub	al, 80h
  2290 000010C7 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2291 000010CB 66AB                    	stosw		; original sample (left channel)
  2292 000010CD 66AB                    	stosw		; original sample (right channel)
  2293                                  	;xor	eax, eax
  2294 000010CF B080                    	mov	al, 80h
  2295 000010D1 49                      	dec	ecx
  2296 000010D2 7402                    	jz	short lff24m_2
  2297 000010D4 8A06                    	mov	al, [esi]
  2298                                  lff24m_2:
  2299                                  	;;mov	[next_val], al
  2300                                  	;mov	bh, al
  2301                                  	;add	al, [previous_val]
  2302 000010D6 00D8                    	add	al, bl
  2303 000010D8 D0D8                    	rcr	al, 1
  2304 000010DA 2C80                    	sub	al, 80h
  2305 000010DC 66C1E008                	shl	ax, 8
  2306 000010E0 66AB                    	stosw		; this is interpolated sample (L)
  2307 000010E2 66AB                    	stosw		; this is interpolated sample (R)
  2308                                  	
  2309                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2310 000010E4 09C9                    	or	ecx, ecx
  2311 000010E6 75DA                    	jnz	short lff24m_1
  2312 000010E8 E996F9FFFF              	jmp	lff24_3
  2313                                  
  2314                                  lff24m_7:
  2315                                  lff24s_7:
  2316 000010ED E9ADF9FFFF              	jmp	lff24_5  ; error
  2317                                  
  2318                                  load_24khz_stereo_8_bit:
  2319                                  	; 15/11/2023
  2320 000010F2 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2321                                  					; last of the file?
  2322 000010F9 7402                    	jz	short lff24s_0		; no
  2323 000010FB F9                      	stc
  2324 000010FC C3                      	retn
  2325                                  
  2326                                  lff24s_0:
  2327 000010FD BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2328                                          ;mov	edx, [loadsize]
  2329                                  
  2330                                  	; esi = buffer address
  2331                                  	;; edx = buffer size
  2332                                  
  2333                                  	; load file into memory
  2334                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001102 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001108 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000110A 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001110 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001115 CD40                <1>  int 40h
  2335 00001117 72D4                    	jc	short lff24s_7 ; error !
  2336                                  
  2337                                  	;mov	edi, audio_buffer
  2338                                  	; 29/05/2024
  2339 00001119 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2340                                  	
  2341 0000111F D1E8                    	shr	eax, 1
  2342 00001121 7505                    	jnz	short lff24s_8
  2343 00001123 E96EF9FFFF              	jmp	lff24_eof
  2344                                  
  2345                                  lff24s_8:
  2346 00001128 89C1                    	mov	ecx, eax  ; word count
  2347                                  lff24s_1:
  2348 0000112A AC                      	lodsb
  2349 0000112B A2[28200000]            	mov	[previous_val_l], al
  2350 00001130 2C80                    	sub	al, 80h
  2351 00001132 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2352 00001136 66AB                    	stosw		; original sample (L)
  2353 00001138 AC                      	lodsb
  2354 00001139 A2[2A200000]            	mov	[previous_val_r], al
  2355 0000113E 2C80                    	sub	al, 80h
  2356 00001140 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2357 00001144 66AB                    	stosw		; original sample (R)
  2358                                  
  2359                                  	;xor	eax, eax
  2360 00001146 66B88080                	mov	ax, 8080h
  2361 0000114A 49                      	dec	ecx
  2362 0000114B 7403                    	jz	short lff24s_2
  2363                                  		; convert 8 bit sample to 16 bit sample
  2364 0000114D 668B06                  	mov	ax, [esi]
  2365                                  lff24s_2:
  2366                                  	;;mov	[next_val_l], al
  2367                                  	;;mov	[next_val_r], ah
  2368                                  	;mov	bx, ax
  2369 00001150 88E7                    	mov	bh, ah
  2370 00001152 0205[28200000]          	add	al, [previous_val_l]
  2371 00001158 D0D8                    	rcr	al, 1
  2372                                  	;mov	dl, al
  2373 0000115A 2C80                    	sub	al, 80h
  2374 0000115C 66C1E008                	shl	ax, 8
  2375 00001160 66AB                    	stosw		; this is interpolated sample (L)
  2376 00001162 88F8                    	mov	al, bh	; [next_val_r]
  2377 00001164 0205[2A200000]          	add	al, [previous_val_r]
  2378 0000116A D0D8                    	rcr	al, 1
  2379                                  	;mov	dh, al
  2380 0000116C 2C80                    	sub	al, 80h
  2381 0000116E 66C1E008                	shl	ax, 8
  2382 00001172 66AB                    	stosw		; this is interpolated sample (R)
  2383                                  		
  2384                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2385 00001174 09C9                    	or	ecx, ecx
  2386 00001176 75B2                    	jnz	short lff24s_1
  2387 00001178 E906F9FFFF              	jmp	lff24_3
  2388                                  
  2389                                  load_24khz_mono_16_bit:
  2390                                  	; 15/11/2023
  2391 0000117D F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2392                                  					; last of the file?
  2393 00001184 7402                    	jz	short lff24m2_0		; no
  2394 00001186 F9                      	stc
  2395 00001187 C3                      	retn
  2396                                  
  2397                                  lff24m2_0:
  2398 00001188 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2399                                          ;mov	edx, [loadsize]
  2400                                  
  2401                                  	; esi = buffer address
  2402                                  	;; edx = buffer size
  2403                                  
  2404                                  	; load file into memory
  2405                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000118D 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001193 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001195 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000119B B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000011A0 CD40                <1>  int 40h
  2406 000011A2 7238                    	jc	short lff24m2_7 ; error !
  2407                                  
  2408                                  	;mov	edi, audio_buffer
  2409                                  	; 29/05/2024
  2410 000011A4 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2411                                  	
  2412 000011AA D1E8                    	shr	eax, 1
  2413 000011AC 7505                    	jnz	short lff24m2_8
  2414 000011AE E9E3F8FFFF              	jmp	lff24_eof
  2415                                  
  2416                                  lff24m2_8:
  2417 000011B3 89C1                    	mov	ecx, eax  ; word count
  2418                                  lff24m2_1:
  2419 000011B5 66AD                    	lodsw
  2420 000011B7 66AB                    	stosw		; original sample (left channel)
  2421 000011B9 66AB                    	stosw		; original sample (right channel)
  2422 000011BB 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2423                                  	;mov	[previous_val], ax
  2424                                  	;mov	ebx, eax	
  2425                                  	;xor	eax, eax
  2426 000011BE 31DB                    	xor	ebx, ebx
  2427 000011C0 49                      	dec	ecx
  2428 000011C1 7403                    	jz	short lff24m2_2
  2429                                  	;mov	ax, [esi]
  2430 000011C3 668B1E                  	mov	bx, [esi]
  2431                                  lff24m2_2:
  2432                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2433                                  	;mov	ebp, eax	; [next_val]
  2434                                  	;add	ax, [previous_val]
  2435                                  	; ax = [previous_val]
  2436                                  	; bx = [next_val]
  2437 000011C6 6601D8                  	add	ax, bx
  2438 000011C9 66D1D8                  	rcr	ax, 1
  2439 000011CC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2440 000011CF 66AB                    	stosw		; this is interpolated sample (L)
  2441 000011D1 66AB                    	stosw		; this is interpolated sample (R)
  2442                                  	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2443 000011D3 09C9                    	or	ecx, ecx
  2444 000011D5 75DE                    	jnz	short lff24m2_1
  2445 000011D7 E9A7F8FFFF              	jmp	lff24_3
  2446                                  
  2447                                  lff24m2_7:
  2448                                  lff24s2_7:
  2449 000011DC E9BEF8FFFF              	jmp	lff24_5  ; error
  2450                                  
  2451                                  load_24khz_stereo_16_bit:
  2452                                  	; 16/11/2023
  2453                                  	; 15/11/2023
  2454 000011E1 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2455                                  					; last of the file?
  2456 000011E8 7402                    	jz	short lff24s2_0		; no
  2457 000011EA F9                      	stc
  2458 000011EB C3                      	retn
  2459                                  
  2460                                  lff24s2_0:
  2461 000011EC BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2462                                          ;mov	edx, [loadsize]
  2463                                  
  2464                                  	; esi = buffer address
  2465                                  	;; edx = buffer size
  2466                                  
  2467                                  	; load file into memory
  2468                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000011F1 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000011F7 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000011F9 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000011FF B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001204 CD40                <1>  int 40h
  2469 00001206 72D4                    	jc	short lff24s2_7 ; error !
  2470                                  
  2471                                  	;mov	edi, audio_buffer
  2472                                  	; 29/05/2024
  2473 00001208 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2474                                  	
  2475 0000120E C1E802                  	shr	eax, 2
  2476 00001211 7505                    	jnz	short lff24s2_8
  2477 00001213 E97EF8FFFF              	jmp	lff24_eof
  2478                                  
  2479                                  lff24s2_8:
  2480 00001218 89C1                    	mov	ecx, eax  ; dword count
  2481                                  lff24s2_1:
  2482 0000121A 66AD                    	lodsw
  2483 0000121C 66AB                    	stosw		; original sample (L)
  2484 0000121E 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2485 00001221 66A3[28200000]          	mov	[previous_val_l], ax
  2486 00001227 66AD                    	lodsw
  2487 00001229 66AB                    	stosw		; original sample (R)
  2488 0000122B 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2489                                  	;mov	[previous_val_r], ax
  2490 0000122E 89C3                    	mov	ebx, eax
  2491 00001230 31D2                    	xor	edx, edx
  2492 00001232 31C0                    	xor	eax, eax
  2493                                  	; 16/11/2023
  2494 00001234 49                      	dec	ecx
  2495 00001235 7407                    	jz	short lff24s2_2
  2496 00001237 668B06                  	mov	ax, [esi]
  2497 0000123A 668B5602                	mov	dx, [esi+2]
  2498                                  lff24s2_2:
  2499 0000123E 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2500                                  	;;mov	[next_val_l], ax
  2501                                  	;mov	ebp, eax
  2502 00001241 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2503                                  	;mov	[next_val_r], dx
  2504 00001244 660305[28200000]        	add	ax, [previous_val_l]
  2505 0000124B 66D1D8                  	rcr	ax, 1
  2506 0000124E 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2507 00001251 66AB                    	stosw		; this is interpolated sample (L)
  2508                                  	;mov	ax, [next_val_r]
  2509 00001253 89D0                    	mov	eax, edx
  2510                                  	;add	ax, [previous_val_r]
  2511 00001255 6601D8                  	add	ax, bx
  2512 00001258 66D1D8                  	rcr	ax, 1
  2513 0000125B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2514 0000125E 66AB                    	stosw		; this is interpolated sample (R)
  2515                                  	
  2516                                  	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2517 00001260 09C9                    	or	ecx, ecx
  2518 00001262 75B6                    	jnz	short lff24s2_1
  2519 00001264 E91AF8FFFF              	jmp	lff24_3
  2520                                  
  2521                                  ; .....................
  2522                                  
  2523                                  load_32khz_mono_8_bit:
  2524                                  	; 15/11/2023
  2525 00001269 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2526                                  					; last of the file?
  2527 00001270 7402                    	jz	short lff32m_0		; no
  2528 00001272 F9                      	stc
  2529 00001273 C3                      	retn
  2530                                  
  2531                                  lff32m_0:
  2532 00001274 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2533                                          ;mov	edx, [loadsize]
  2534                                  
  2535                                  	; esi = buffer address
  2536                                  	;; edx = buffer size
  2537                                  
  2538                                  	; load file into memory
  2539                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001279 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000127F 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001281 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001287 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000128C CD40                <1>  int 40h
  2540 0000128E 7248                    	jc	short lff32m_7 ; error !
  2541                                  
  2542                                  	;mov	edi, audio_buffer
  2543                                  	; 29/05/2024
  2544 00001290 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2545                                  	
  2546 00001296 21C0                    	and	eax, eax
  2547 00001298 7505                    	jnz	short lff32m_8
  2548 0000129A E9F7F7FFFF              	jmp	lff32_eof
  2549                                  
  2550                                  lff32m_8:
  2551 0000129F 89C1                    	mov	ecx, eax	; byte count
  2552                                  lff32m_1:
  2553 000012A1 AC                      	lodsb
  2554                                  	;mov	[previous_val], al
  2555 000012A2 88C3                    	mov	bl, al
  2556 000012A4 2C80                    	sub	al, 80h
  2557 000012A6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2558 000012AA 66AB                    	stosw		; original sample (left channel)
  2559 000012AC 66AB                    	stosw		; original sample (right channel)
  2560                                  	;xor	eax, eax
  2561 000012AE B080                    	mov	al, 80h
  2562 000012B0 49                      	dec	ecx
  2563 000012B1 7402                    	jz	short lff32m_2
  2564 000012B3 8A06                    	mov	al, [esi]
  2565                                  lff32m_2:
  2566                                  	;;mov	[next_val], al
  2567                                  	;mov	bh, al
  2568                                  	;add	al, [previous_val]
  2569 000012B5 00D8                    	add	al, bl
  2570 000012B7 D0D8                    	rcr	al, 1
  2571 000012B9 2C80                    	sub	al, 80h
  2572 000012BB 66C1E008                	shl	ax, 8
  2573 000012BF 66AB                    	stosw		; this is interpolated sample (L)
  2574 000012C1 66AB                    	stosw		; this is interpolated sample (R)
  2575                                  	
  2576                                  	; different than 8-16-24 kHZ !
  2577                                  	; 'original-interpolated-original' trio samples 
  2578 000012C3 E30E                    	jecxz	lff32m_3
  2579                                  
  2580 000012C5 AC                      	lodsb
  2581 000012C6 2C80                    	sub	al, 80h
  2582 000012C8 66C1E008                	shl	ax, 8
  2583 000012CC 66AB                    	stosw		; original sample (left channel)
  2584 000012CE 66AB                    	stosw		; original sample (right channel)
  2585                                  
  2586                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2587 000012D0 49                      	dec	ecx
  2588 000012D1 75CE                    	jnz	short lff32m_1
  2589                                  lff32m_3:
  2590 000012D3 E9ABF7FFFF              	jmp	lff32_3
  2591                                  
  2592                                  lff32m_7:
  2593                                  lff32s_7:
  2594 000012D8 E9C2F7FFFF              	jmp	lff32_5  ; error
  2595                                  
  2596                                  load_32khz_stereo_8_bit:
  2597                                  	; 15/11/2023
  2598 000012DD F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2599                                  					; last of the file?
  2600 000012E4 7402                    	jz	short lff32s_0		; no
  2601 000012E6 F9                      	stc
  2602 000012E7 C3                      	retn
  2603                                  
  2604                                  lff32s_0:
  2605 000012E8 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2606                                          ;mov	edx, [loadsize]
  2607                                  
  2608                                  	; esi = buffer address
  2609                                  	;; edx = buffer size
  2610                                  
  2611                                  	; load file into memory
  2612                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000012ED 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000012F3 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000012F5 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000012FB B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001300 CD40                <1>  int 40h
  2613 00001302 72D4                    	jc	short lff32s_7 ; error !
  2614                                  
  2615                                  	;mov	edi, audio_buffer
  2616                                  	; 29/05/2024
  2617 00001304 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2618                                  	
  2619 0000130A D1E8                    	shr	eax, 1
  2620 0000130C 7505                    	jnz	short lff32s_8
  2621 0000130E E983F7FFFF              	jmp	lff32_eof
  2622                                  
  2623                                  lff32s_8:
  2624 00001313 89C1                    	mov	ecx, eax  ; word count
  2625                                  lff32s_1:
  2626 00001315 AC                      	lodsb
  2627 00001316 A2[28200000]            	mov	[previous_val_l], al
  2628 0000131B 2C80                    	sub	al, 80h
  2629 0000131D 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2630 00001321 66AB                    	stosw		; original sample (L)
  2631 00001323 AC                      	lodsb
  2632 00001324 A2[2A200000]            	mov	[previous_val_r], al
  2633 00001329 2C80                    	sub	al, 80h
  2634 0000132B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2635 0000132F 66AB                    	stosw		; original sample (R)
  2636                                  
  2637                                  	;xor	eax, eax
  2638 00001331 66B88080                	mov	ax, 8080h
  2639 00001335 49                      	dec	ecx
  2640 00001336 7403                    	jz	short lff32s_2
  2641                                  		; convert 8 bit sample to 16 bit sample
  2642 00001338 668B06                  	mov	ax, [esi]
  2643                                  lff32s_2:
  2644                                  	;;mov	[next_val_l], al
  2645                                  	;;mov	[next_val_r], ah
  2646                                  	;mov	bx, ax
  2647 0000133B 88E7                    	mov	bh, ah
  2648 0000133D 0205[28200000]          	add	al, [previous_val_l]
  2649 00001343 D0D8                    	rcr	al, 1
  2650                                  	;mov	dl, al
  2651 00001345 2C80                    	sub	al, 80h
  2652 00001347 66C1E008                	shl	ax, 8
  2653 0000134B 66AB                    	stosw		; this is interpolated sample (L)
  2654 0000134D 88F8                    	mov	al, bh	; [next_val_r]
  2655 0000134F 0205[2A200000]          	add	al, [previous_val_r]
  2656 00001355 D0D8                    	rcr	al, 1
  2657                                  	;mov	dh, al
  2658 00001357 2C80                    	sub	al, 80h
  2659 00001359 66C1E008                	shl	ax, 8
  2660 0000135D 66AB                    	stosw		; this is interpolated sample (R)
  2661                                  
  2662                                  	; different than 8-16-24 kHZ !
  2663                                  	; 'original-interpolated-original' trio samples 
  2664 0000135F E315                    	jecxz	lff32s_3
  2665                                  
  2666 00001361 AC                      	lodsb
  2667 00001362 2C80                    	sub	al, 80h
  2668 00001364 66C1E008                	shl	ax, 8
  2669 00001368 66AB                    	stosw		; original sample (left channel)
  2670                                  
  2671 0000136A AC                      	lodsb
  2672 0000136B 2C80                    	sub	al, 80h
  2673 0000136D 66C1E008                	shl	ax, 8
  2674 00001371 66AB                    	stosw		; original sample (right channel)
  2675                                  		
  2676                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2677 00001373 49                      	dec	ecx
  2678 00001374 759F                    	jnz	short lff32s_1
  2679                                  lff32s_3:
  2680 00001376 E908F7FFFF              	jmp	lff32_3
  2681                                  
  2682                                  load_32khz_mono_16_bit:
  2683                                  	; 15/11/2023
  2684 0000137B F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2685                                  					; last of the file?
  2686 00001382 7402                    	jz	short lff32m2_0		; no
  2687 00001384 F9                      	stc
  2688 00001385 C3                      	retn
  2689                                  
  2690                                  lff32m2_0:
  2691 00001386 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2692                                          ;mov	edx, [loadsize]
  2693                                  
  2694                                  	; esi = buffer address
  2695                                  	;; edx = buffer size
  2696                                  
  2697                                  	; load file into memory
  2698                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000138B 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001391 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001393 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001399 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000139E CD40                <1>  int 40h
  2699 000013A0 723F                    	jc	short lff32m2_7 ; error !
  2700                                  
  2701                                  	;mov	edi, audio_buffer
  2702                                  	; 29/05/2024
  2703 000013A2 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2704                                  	
  2705 000013A8 D1E8                    	shr	eax, 1
  2706 000013AA 7505                    	jnz	short lff32m2_8
  2707 000013AC E9E5F6FFFF              	jmp	lff32_eof
  2708                                  
  2709                                  lff32m2_8:
  2710 000013B1 89C1                    	mov	ecx, eax  ; word count
  2711                                  lff32m2_1:
  2712 000013B3 66AD                    	lodsw
  2713 000013B5 66AB                    	stosw		; original sample (left channel)
  2714 000013B7 66AB                    	stosw		; original sample (right channel)
  2715 000013B9 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  2716                                  	;mov	[previous_val], ax
  2717                                  	;mov	ebx, eax	
  2718                                  	;xor	eax, eax
  2719 000013BC 31DB                    	xor	ebx, ebx
  2720 000013BE 49                      	dec	ecx
  2721 000013BF 7403                    	jz	short lff32m2_2
  2722                                  	;mov	ax, [esi]
  2723 000013C1 668B1E                  	mov	bx, [esi]
  2724                                  lff32m2_2:
  2725                                  	;add	ah, 80h ; convert sound level 0 to 65535 format
  2726                                  	;mov	ebp, eax	; [next_val]
  2727                                  	;add	ax, [previous_val]
  2728                                  	; ax = [previous_val]
  2729                                  	; bx = [next_val]
  2730 000013C4 6601D8                  	add	ax, bx
  2731 000013C7 66D1D8                  	rcr	ax, 1
  2732 000013CA 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2733 000013CD 66AB                    	stosw		; this is interpolated sample (L)
  2734 000013CF 66AB                    	stosw		; this is interpolated sample (R)
  2735                                  
  2736                                  	; different than 8-16-24 kHZ !
  2737                                  	; 'original-interpolated-original' trio samples 
  2738 000013D1 E309                    	jecxz	lff32m2_3
  2739                                  
  2740 000013D3 66AD                    	lodsw
  2741 000013D5 66AB                    	stosw		; original sample (left channel)
  2742 000013D7 66AB                    	stosw		; original sample (right channel)
  2743                                  
  2744                                  	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2745 000013D9 49                      	dec	ecx
  2746 000013DA 75D7                    	jnz	short lff32m2_1
  2747                                  lff32m2_3:
  2748 000013DC E9A2F6FFFF              	jmp	lff32_3
  2749                                  
  2750                                  lff32m2_7:
  2751                                  lff32s2_7:
  2752 000013E1 E9B9F6FFFF              	jmp	lff32_5  ; error
  2753                                  
  2754                                  load_32khz_stereo_16_bit:
  2755                                  	; 16/11/2023
  2756                                  	; 15/11/2023
  2757 000013E6 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2758                                  					; last of the file?
  2759 000013ED 7402                    	jz	short lff32s2_0		; no
  2760 000013EF F9                      	stc
  2761 000013F0 C3                      	retn
  2762                                  
  2763                                  lff32s2_0:
  2764 000013F1 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2765                                          ;mov	edx, [loadsize]
  2766                                  
  2767                                  	; esi = buffer address
  2768                                  	;; edx = buffer size
  2769                                  
  2770                                  	; load file into memory
  2771                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000013F6 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000013FC 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000013FE 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001404 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001409 CD40                <1>  int 40h
  2772 0000140B 72D4                    	jc	short lff32s2_7 ; error !
  2773                                  
  2774                                  	;mov	edi, audio_buffer
  2775                                  	; 29/05/2024
  2776 0000140D 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2777                                  	
  2778 00001413 C1E802                  	shr	eax, 2
  2779 00001416 7505                    	jnz	short lff32s2_8
  2780 00001418 E979F6FFFF              	jmp	lff32_eof
  2781                                  
  2782                                  lff32s2_8:
  2783 0000141D 89C1                    	mov	ecx, eax ; dword count
  2784                                  lff32s2_1:
  2785 0000141F 66AD                    	lodsw
  2786 00001421 66AB                    	stosw		; original sample (L)
  2787 00001423 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2788 00001426 66A3[28200000]          	mov	[previous_val_l], ax
  2789 0000142C 66AD                    	lodsw
  2790 0000142E 66AB                    	stosw		; original sample (R)
  2791 00001430 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2792                                  	;mov	[previous_val_r], ax
  2793 00001433 89C3                    	mov	ebx, eax
  2794 00001435 31D2                    	xor	edx, edx
  2795 00001437 31C0                    	xor	eax, eax
  2796                                  	; 16/11/2023
  2797 00001439 49                      	dec	ecx
  2798 0000143A 7407                    	jz	short lff32s2_2
  2799 0000143C 668B06                  	mov	ax, [esi]
  2800 0000143F 668B5602                	mov	dx, [esi+2]
  2801                                  lff32s2_2:
  2802 00001443 80C480                  	add	ah, 80h	; convert sound level 0 to 65535 format 
  2803                                  	;;mov	[next_val_l], ax
  2804                                  	;mov	ebp, eax
  2805 00001446 80C680                  	add	dh, 80h	; convert sound level 0 to 65535 format 
  2806                                  	;mov	[next_val_r], dx
  2807 00001449 660305[28200000]        	add	ax, [previous_val_l]
  2808 00001450 66D1D8                  	rcr	ax, 1
  2809 00001453 80EC80                  	sub	ah, 80h ; -32768 to +32767 format again
  2810 00001456 66AB                    	stosw		; this is interpolated sample (L)
  2811                                  	;mov	ax, [next_val_r]
  2812 00001458 89D0                    	mov	eax, edx
  2813                                  	;add	ax, [previous_val_r]
  2814 0000145A 6601D8                  	add	ax, bx
  2815 0000145D 66D1D8                  	rcr	ax, 1
  2816 00001460 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  2817 00001463 66AB                    	stosw		; this is interpolated sample (R)
  2818                                  
  2819                                  	; different than 8-16-24 kHZ !
  2820                                  	; 'original-interpolated-original' trio samples 
  2821 00001465 E30B                    	jecxz	lff32s2_3
  2822                                  
  2823 00001467 66AD                    	lodsw
  2824 00001469 66AB                    	stosw	; original sample (L)
  2825 0000146B 66AD                    	lodsw
  2826 0000146D 66AB                    	stosw	; original sample (R)
  2827                                  	
  2828                                  	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2829 0000146F 49                      	dec	ecx
  2830 00001470 75AD                    	jnz	short lff32s2_1
  2831                                  lff32s2_3:
  2832 00001472 E90CF6FFFF              	jmp	lff32_3
  2833                                  
  2834                                  ; .....................
  2835                                  
  2836                                  load_22khz_mono_8_bit:
  2837                                  	; 16/11/2023
  2838 00001477 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2839                                  					; last of the file?
  2840 0000147E 7402                    	jz	short lff22m_0		; no
  2841 00001480 F9                      	stc
  2842 00001481 C3                      	retn
  2843                                  
  2844                                  lff22m_0:
  2845 00001482 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2846                                          ;mov	edx, [loadsize]
  2847                                  
  2848                                  	; esi = buffer address
  2849                                  	;; edx = buffer size
  2850                                  
  2851                                  	; load file into memory
  2852                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001487 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000148D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000148F 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001495 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000149A CD40                <1>  int 40h
  2853 0000149C 725E                    	jc	short lff22m_7 ; error !
  2854                                  
  2855                                  	;mov	edi, audio_buffer
  2856                                  	; 29/05/2024
  2857 0000149E 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2858                                  	
  2859 000014A4 21C0                    	and	eax, eax
  2860 000014A6 7505                    	jnz	short lff22m_8
  2861 000014A8 E9E9F5FFFF              	jmp	lff22_eof
  2862                                  
  2863                                  lff22m_8:
  2864 000014AD 89C1                    	mov	ecx, eax	; byte count
  2865                                  lff22m_9:
  2866 000014AF BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2867 000014B4 C605[30200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  2868                                  lff22m_1:
  2869                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2870 000014BB AC                      	lodsb
  2871 000014BC B280                    	mov	dl, 80h
  2872 000014BE 49                      	dec	ecx
  2873 000014BF 7402                    	jz	short lff22m_2_1
  2874 000014C1 8A16                    	mov	dl, [esi]
  2875                                  lff22m_2_1:	
  2876                                  	; al = [previous_val]
  2877                                  	; dl = [next_val]
  2878 000014C3 E81A060000              	call	interpolating_3_8bit_mono ; 1 of 17
  2879 000014C8 E32D                    	jecxz	lff22m_3
  2880                                  lff22m_2_2:
  2881 000014CA AC                      	lodsb
  2882 000014CB B280                    	mov	dl, 80h
  2883 000014CD 49                      	dec	ecx
  2884 000014CE 7402                    	jz	short lff22m_2_3
  2885 000014D0 8A16                    	mov	dl, [esi]
  2886                                  lff22m_2_3:
  2887 000014D2 E88F060000               	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2888 000014D7 E31E                    	jecxz	lff22m_3
  2889 000014D9 4D                      	dec	ebp
  2890 000014DA 75EE                    	jnz	short lff22m_2_2
  2891                                  
  2892 000014DC A0[30200000]            	mov	al, [faz]
  2893 000014E1 FEC8                    	dec	al
  2894 000014E3 74CA                    	jz	short lff22m_9
  2895 000014E5 FE0D[30200000]          	dec	byte [faz]
  2896 000014EB BD04000000              	mov	ebp, 4
  2897 000014F0 FEC8                    	dec	al
  2898 000014F2 75C7                    	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2899 000014F4 45                      	inc	ebp ; 5
  2900 000014F5 EBC4                    	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2901                                  
  2902                                  lff22m_3:
  2903                                  lff22s_3:
  2904 000014F7 E987F5FFFF              	jmp	lff22_3	; padfill
  2905                                  		; (put zeros in the remain words of the buffer)
  2906                                  lff22m_7:
  2907                                  lff22s_7:
  2908 000014FC E99EF5FFFF              	jmp	lff22_5  ; error
  2909                                  
  2910                                  load_22khz_stereo_8_bit:
  2911                                  	; 16/11/2023
  2912 00001501 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2913                                  					; last of the file?
  2914 00001508 7402                    	jz	short lff22s_0		; no
  2915 0000150A F9                      	stc
  2916 0000150B C3                      	retn
  2917                                  
  2918                                  lff22s_0:
  2919 0000150C BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2920                                          ;mov	edx, [loadsize]
  2921                                  
  2922                                  	; esi = buffer address
  2923                                  	;; edx = buffer size
  2924                                  
  2925                                  	; load file into memory
  2926                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001511 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001517 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001519 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000151F B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001524 CD40                <1>  int 40h
  2927 00001526 72D4                    	jc	short lff22s_7 ; error !
  2928                                  
  2929                                  	;mov	edi, audio_buffer
  2930                                  	; 29/05/2024
  2931 00001528 8B3D[EE280000]          	mov	edi, [audio_buffer]
  2932                                  	
  2933 0000152E D1E8                    	shr	eax, 1
  2934 00001530 7505                    	jnz	short lff22s_8
  2935 00001532 E95FF5FFFF              	jmp	lff22_eof
  2936                                  
  2937                                  lff22s_8:
  2938 00001537 89C1                    	mov	ecx, eax	; word count
  2939                                  lff22s_9:
  2940 00001539 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  2941 0000153E C605[30200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  2942                                  lff22s_1:
  2943                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2944 00001545 66AD                    	lodsw
  2945 00001547 66BA8080                	mov	dx, 8080h
  2946 0000154B 49                      	dec	ecx
  2947 0000154C 7403                    	jz	short lff22s_2_1 
  2948 0000154E 668B16                  	mov	dx, [esi]
  2949                                  lff22s_2_1:	
  2950                                  	; al = [previous_val_l]
  2951                                  	; ah = [previous_val_r]
  2952                                  	; dl = [next_val_l]
  2953                                  	; dh = [next_val_r]	
  2954 00001551 E8BD050000              	call	interpolating_3_8bit_stereo ; 1 of 17 
  2955 00001556 E39F                    	jecxz	lff22s_3
  2956                                  lff22s_2_2:
  2957 00001558 66AD                    	lodsw
  2958 0000155A 66BA8080                	mov	dx, 8080h
  2959 0000155E 49                      	dec	ecx
  2960 0000155F 7403                    	jz	short lff22s_2_3
  2961 00001561 668B16                  	mov	dx, [esi]
  2962                                  lff22s_2_3:
  2963 00001564 E81A060000               	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2964 00001569 E38C                    	jecxz	lff22s_3
  2965 0000156B 4D                      	dec	ebp
  2966 0000156C 75EA                    	jnz	short lff22s_2_2
  2967                                  
  2968 0000156E A0[30200000]            	mov	al, [faz]
  2969 00001573 FEC8                    	dec	al
  2970 00001575 74C2                    	jz	short lff22s_9
  2971 00001577 FE0D[30200000]          	dec	byte [faz]
  2972 0000157D BD04000000              	mov	ebp, 4
  2973 00001582 FEC8                    	dec	al
  2974 00001584 75BF                    	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2975 00001586 45                      	inc	ebp ; 5
  2976 00001587 EBBC                    	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2977                                  
  2978                                  load_22khz_mono_16_bit:
  2979                                  	; 16/11/2023
  2980 00001589 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  2981                                  					; last of the file?
  2982 00001590 7402                    	jz	short lff22m2_0		; no
  2983 00001592 F9                      	stc
  2984 00001593 C3                      	retn
  2985                                  
  2986                                  lff22m2_0:
  2987 00001594 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  2988                                          ;mov	edx, [loadsize]
  2989                                  
  2990                                  	; esi = buffer address
  2991                                  	;; edx = buffer size
  2992                                  
  2993                                  	; load file into memory
  2994                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001599 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000159F 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000015A1 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000015A7 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000015AC CD40                <1>  int 40h
  2995 000015AE 7262                    	jc	short lff22m2_7 ; error !
  2996                                  
  2997                                  	;mov	edi, audio_buffer
  2998                                  	; 29/05/2024
  2999 000015B0 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3000                                  	
  3001 000015B6 D1E8                    	shr	eax, 1
  3002 000015B8 7505                    	jnz	short lff22m2_8
  3003 000015BA E9D7F4FFFF              	jmp	lff22_eof
  3004                                  
  3005                                  lff22m2_8:
  3006 000015BF 89C1                    	mov	ecx, eax	; word count
  3007                                  lff22m2_9:
  3008 000015C1 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  3009 000015C6 C605[30200000]03        	mov	byte [faz], 3  ; 3 steps/phases
  3010                                  lff22m2_1:
  3011                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  3012 000015CD 66AD                    	lodsw
  3013 000015CF 31D2                    	xor	edx, edx
  3014 000015D1 49                      	dec	ecx
  3015 000015D2 7403                    	jz	short lff22m2_2_1
  3016 000015D4 668B16                  	mov	dx, [esi]
  3017                                  lff22m2_2_1:	
  3018                                  	; ax = [previous_val]
  3019                                  	; dx = [next_val]
  3020 000015D7 E8D8050000              	call	interpolating_3_16bit_mono ; 1 of 17
  3021 000015DC E32F                    	jecxz	lff22m2_3
  3022                                  lff22m2_2_2:
  3023 000015DE 66AD                    	lodsw
  3024 000015E0 31D2                    	xor	edx, edx
  3025 000015E2 49                      	dec	ecx
  3026 000015E3 7403                    	jz	short lff22m2_2_3
  3027 000015E5 668B16                  	mov	dx, [esi]
  3028                                  lff22m2_2_3:
  3029 000015E8 E85A060000               	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  3030 000015ED E31E                    	jecxz	lff22m2_3
  3031 000015EF 4D                      	dec	ebp
  3032 000015F0 75EC                    	jnz	short lff22m2_2_2
  3033                                  
  3034 000015F2 A0[30200000]            	mov	al, [faz]
  3035 000015F7 FEC8                    	dec	al
  3036 000015F9 74C6                    	jz	short lff22m2_9
  3037 000015FB FE0D[30200000]          	dec	byte [faz]
  3038 00001601 BD04000000              	mov	ebp, 4
  3039 00001606 FEC8                    	dec	al
  3040 00001608 75C3                    	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  3041 0000160A 45                      	inc	ebp ; 5
  3042 0000160B EBC0                    	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  3043                                  
  3044                                  lff22m2_3:
  3045                                  lff22s2_3:
  3046 0000160D E971F4FFFF              	jmp	lff22_3	; padfill
  3047                                  		; (put zeros in the remain words of the buffer)
  3048                                  lff22m2_7:
  3049                                  lff22s2_7:
  3050 00001612 E988F4FFFF              	jmp	lff22_5  ; error
  3051                                  
  3052                                  load_22khz_stereo_16_bit:
  3053                                  	; 16/11/2023
  3054 00001617 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3055                                  					; last of the file?
  3056 0000161E 7402                    	jz	short lff22s2_0		; no
  3057 00001620 F9                      	stc
  3058 00001621 C3                      	retn
  3059                                  
  3060                                  lff22s2_0:
  3061 00001622 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3062                                          ;mov	edx, [loadsize]
  3063                                  
  3064                                  	; esi = buffer address
  3065                                  	;; edx = buffer size
  3066                                  
  3067                                  	; load file into memory
  3068                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001627 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000162D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000162F 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001635 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000163A CD40                <1>  int 40h
  3069 0000163C 72D4                    	jc	short lff22s2_7 ; error !
  3070                                  
  3071                                  	;mov	edi, audio_buffer
  3072                                  	; 29/05/2024
  3073 0000163E 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3074                                  	
  3075 00001644 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3076 00001647 7505                    	jnz	short lff22s2_8
  3077 00001649 E948F4FFFF              	jmp	lff22_eof
  3078                                  
  3079                                  lff22s2_8:
  3080 0000164E 89C1                    	mov	ecx, eax	; dword count
  3081                                  lff22s2_9:
  3082 00001650 BD05000000              	mov	ebp, 5 ; interpolation (one step) loop count
  3083 00001655 C605[30200000]03        	mov	byte [faz], 3  ; 3 steps/phase
  3084                                  lff22s2_1:
  3085                                  	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  3086 0000165C 66AD                    	lodsw
  3087 0000165E 89C3                    	mov	ebx, eax
  3088 00001660 66AD                    	lodsw
  3089 00001662 8B16                    	mov	edx, [esi]
  3090 00001664 668915[2C200000]        	mov	[next_val_l], dx
  3091                                  	; 26/11/2023
  3092 0000166B C1EA10                  	shr	edx, 16
  3093 0000166E 49                      	dec	ecx
  3094 0000166F 7509                    	jnz	short lff22s2_2_1
  3095 00001671 31D2                    	xor	edx, edx ; 0
  3096 00001673 668915[2C200000]        	mov	[next_val_l], dx
  3097                                  lff22s2_2_1:
  3098                                  	; bx = [previous_val_l]
  3099                                  	; ax = [previous_val_r]
  3100                                  	; [next_val_l]
  3101                                  	; dx = [next_val_r]
  3102 0000167A E865050000              	call	interpolating_3_16bit_stereo ; 1 of 17 
  3103 0000167F E38C                    	jecxz	lff22s2_3
  3104                                  lff22s2_2_2:
  3105 00001681 66AD                    	lodsw
  3106 00001683 89C3                    	mov	ebx, eax
  3107 00001685 66AD                    	lodsw
  3108 00001687 8B16                    	mov	edx, [esi]
  3109 00001689 668915[2C200000]        	mov	[next_val_l], dx
  3110                                  	; 26/11/2023
  3111 00001690 C1EA10                  	shr	edx, 16
  3112 00001693 49                      	dec	ecx
  3113 00001694 7509                    	jnz	short lff22s2_2_3
  3114 00001696 31D2                    	xor	edx, edx ; 0
  3115 00001698 668915[2C200000]        	mov	[next_val_l], dx
  3116                                  lff22s2_2_3:
  3117 0000169F E8BB050000               	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  3118 000016A4 E31E                    	jecxz	lff22s2_2_4
  3119                                  
  3120 000016A6 4D                      	dec	ebp
  3121 000016A7 75D8                    	jnz	short lff22s2_2_2
  3122                                  
  3123 000016A9 A0[30200000]            	mov	al, [faz]
  3124 000016AE FEC8                    	dec	al
  3125 000016B0 749E                    	jz	short lff22s2_9
  3126 000016B2 FE0D[30200000]          	dec	byte [faz]
  3127 000016B8 BD04000000              	mov	ebp, 4
  3128 000016BD FEC8                    	dec	al
  3129 000016BF 759B                    	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  3130 000016C1 45                      	inc	ebp ; 5
  3131 000016C2 EB98                    	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  3132                                  
  3133                                  lff22s2_2_4:
  3134                                  	; 26/11/2023
  3135 000016C4 E9BAF3FFFF              	jmp	lff22_3	; padfill
  3136                                  
  3137                                  ; .....................
  3138                                  
  3139                                  load_11khz_mono_8_bit:
  3140                                  	; 18/11/2023
  3141 000016C9 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3142                                  					; last of the file?
  3143 000016D0 7402                    	jz	short lff11m_0		; no
  3144 000016D2 F9                      	stc
  3145 000016D3 C3                      	retn
  3146                                  
  3147                                  lff11m_0:
  3148 000016D4 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3149                                          ;mov	edx, [loadsize]
  3150                                  
  3151                                  	; esi = buffer address
  3152                                  	;; edx = buffer size
  3153                                  
  3154                                  	; load file into memory
  3155                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000016D9 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000016DF 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000016E1 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000016E7 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000016EC CD40                <1>  int 40h
  3156 000016EE 7248                    	jc	short lff11m_7 ; error !
  3157                                  
  3158                                  	;mov	edi, audio_buffer
  3159                                  	; 29/05/2024
  3160 000016F0 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3161                                  	
  3162 000016F6 21C0                    	and	eax, eax
  3163 000016F8 7505                    	jnz	short lff11m_8
  3164 000016FA E997F3FFFF              	jmp	lff11_eof
  3165                                  
  3166                                  lff11m_8:
  3167 000016FF 89C1                    	mov	ecx, eax		; byte count
  3168                                  lff11m_9:
  3169 00001701 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3170                                  lff11m_1:
  3171                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3172 00001706 AC                      	lodsb
  3173 00001707 B280                    	mov	dl, 80h
  3174 00001709 49                      	dec	ecx
  3175 0000170A 7402                    	jz	short lff11m_2_1
  3176 0000170C 8A16                    	mov	dl, [esi]
  3177                                  lff11m_2_1:	
  3178                                  	; al = [previous_val]
  3179                                  	; dl = [next_val]
  3180 0000170E E87D050000              	call	interpolating_5_8bit_mono
  3181 00001713 E328                    	jecxz	lff11m_3
  3182                                  lff11m_2_2:
  3183 00001715 AC                      	lodsb
  3184 00001716 B280                    	mov	dl, 80h
  3185 00001718 49                      	dec	ecx
  3186 00001719 7402                    	jz	short lff11m_2_3
  3187 0000171B 8A16                    	mov	dl, [esi]
  3188                                  lff11m_2_3:
  3189 0000171D E87A060000               	call	interpolating_4_8bit_mono
  3190 00001722 E319                    	jecxz	lff11m_3
  3191                                  
  3192 00001724 4D                      	dec	ebp
  3193 00001725 74DA                    	jz	short lff11m_9
  3194                                  
  3195 00001727 AC                      	lodsb
  3196 00001728 B280                    	mov	dl, 80h
  3197 0000172A 49                      	dec	ecx
  3198 0000172B 7402                    	jz	short lff11m_2_4
  3199 0000172D 8A16                    	mov	dl, [esi]
  3200                                  lff11m_2_4:
  3201 0000172F E868060000              	call	interpolating_4_8bit_mono
  3202 00001734 E307                    	jecxz	lff11m_3
  3203 00001736 EBCE                    	jmp	short lff11m_1
  3204                                  
  3205                                  lff11m_7:
  3206                                  lff11s_7:
  3207 00001738 E962F3FFFF              	jmp	lff11_5  ; error
  3208                                  
  3209                                  lff11m_3:
  3210                                  lff11s_3:
  3211 0000173D E941F3FFFF              	jmp	lff11_3	; padfill
  3212                                  		; (put zeros in the remain words of the buffer)
  3213                                  
  3214                                  load_11khz_stereo_8_bit:
  3215                                  	; 18/11/2023
  3216 00001742 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3217                                  					; last of the file?
  3218 00001749 7402                    	jz	short lff11s_0		; no
  3219 0000174B F9                      	stc
  3220 0000174C C3                      	retn
  3221                                  
  3222                                  lff11s_0:
  3223 0000174D BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3224                                          ;mov	edx, [loadsize]
  3225                                  
  3226                                  	; esi = buffer address
  3227                                  	;; edx = buffer size
  3228                                  
  3229                                  	; load file into memory
  3230                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001752 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001758 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000175A 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001760 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001765 CD40                <1>  int 40h
  3231 00001767 72CF                    	jc	short lff11s_7 ; error !
  3232                                  
  3233                                  	;mov	edi, audio_buffer
  3234                                  	; 29/05/2024
  3235 00001769 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3236                                  	
  3237 0000176F D1E8                    	shr	eax, 1
  3238 00001771 7505                    	jnz	short lff11s_8
  3239 00001773 E91EF3FFFF              	jmp	lff11_eof
  3240                                  
  3241                                  lff11s_8:
  3242 00001778 89C1                    	mov	ecx, eax	; word count
  3243                                  lff11s_9:
  3244 0000177A BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3245                                  lff11s_1:
  3246                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3247 0000177F 66AD                    	lodsw
  3248 00001781 66BA8080                	mov	dx, 8080h
  3249 00001785 49                      	dec	ecx
  3250 00001786 7403                    	jz	short lff11s_2_1 
  3251 00001788 668B16                  	mov	dx, [esi]
  3252                                  lff11s_2_1:	
  3253                                  	; al = [previous_val_l]
  3254                                  	; ah = [previous_val_r]
  3255                                  	; dl = [next_val_l]
  3256                                  	; dh = [next_val_r]	
  3257 0000178B E85F050000              	call	interpolating_5_8bit_stereo
  3258 00001790 E3AB                    	jecxz	lff11s_3
  3259                                  lff11s_2_2:
  3260 00001792 66AD                    	lodsw
  3261 00001794 66BA8080                	mov	dx, 8080h
  3262 00001798 49                      	dec	ecx
  3263 00001799 7403                    	jz	short lff11s_2_3
  3264 0000179B 668B16                  	mov	dx, [esi]
  3265                                  lff11s_2_3:
  3266 0000179E E838060000               	call	interpolating_4_8bit_stereo
  3267 000017A3 E398                    	jecxz	lff11s_3
  3268                                  	
  3269 000017A5 4D                      	dec	ebp
  3270 000017A6 74D2                    	jz	short lff11s_9
  3271                                  
  3272 000017A8 66AD                    	lodsw
  3273 000017AA 66BA8080                	mov	dx, 8080h
  3274 000017AE 49                      	dec	ecx
  3275 000017AF 7403                    	jz	short lff11s_2_4
  3276 000017B1 668B16                  	mov	dx, [esi]
  3277                                  lff11s_2_4:
  3278 000017B4 E822060000              	call	interpolating_4_8bit_stereo
  3279 000017B9 E382                    	jecxz	lff11s_3
  3280 000017BB EBC2                    	jmp	short lff11s_1
  3281                                  
  3282                                  load_11khz_mono_16_bit:
  3283                                  	; 18/11/2023
  3284 000017BD F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3285                                  					; last of the file?
  3286 000017C4 7402                    	jz	short lff11m2_0		; no
  3287 000017C6 F9                      	stc
  3288 000017C7 C3                      	retn
  3289                                  
  3290                                  lff11m2_0:
  3291 000017C8 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3292                                          ;mov	edx, [loadsize]
  3293                                  
  3294                                  	; esi = buffer address
  3295                                  	;; edx = buffer size
  3296                                  
  3297                                  	; load file into memory
  3298                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000017CD 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000017D3 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000017D5 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000017DB B803000000          <1>  mov eax, %1
    89                              <1> 
    90 000017E0 CD40                <1>  int 40h
  3299 000017E2 724E                    	jc	short lff11m2_7 ; error !
  3300                                  
  3301                                  	;mov	edi, audio_buffer
  3302                                  	; 29/05/2024
  3303 000017E4 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3304                                  	
  3305 000017EA D1E8                    	shr	eax, 1
  3306 000017EC 7505                    	jnz	short lff11m2_8
  3307 000017EE E9A3F2FFFF              	jmp	lff11_eof
  3308                                  
  3309                                  lff11m2_8:
  3310 000017F3 89C1                    	mov	ecx, eax	; word count
  3311                                  lff11m2_9:
  3312 000017F5 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3313                                  lff11m2_1:
  3314                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3315 000017FA 66AD                    	lodsw
  3316 000017FC 31D2                    	xor	edx, edx
  3317 000017FE 49                      	dec	ecx
  3318 000017FF 7403                    	jz	short lff11m2_2_1
  3319 00001801 668B16                  	mov	dx, [esi]
  3320                                  lff11m2_2_1:	
  3321                                  	; ax = [previous_val]
  3322                                  	; dx = [next_val]
  3323 00001804 E83F060000              	call	interpolating_5_16bit_mono
  3324 00001809 E363                    	jecxz	lff11m2_3
  3325                                  lff11m2_2_2:
  3326 0000180B 66AD                    	lodsw
  3327 0000180D 31D2                    	xor	edx, edx
  3328 0000180F 49                      	dec	ecx
  3329 00001810 7403                    	jz	short lff11m2_2_3
  3330 00001812 668B16                  	mov	dx, [esi]
  3331                                  lff11m2_2_3:
  3332 00001815 E858070000               	call	interpolating_4_16bit_mono
  3333 0000181A E352                    	jecxz	lff11m2_3
  3334                                  
  3335 0000181C 4D                      	dec	ebp
  3336 0000181D 74D6                    	jz	short lff11m2_9
  3337                                  
  3338 0000181F 66AD                    	lodsw
  3339 00001821 31D2                    	xor	edx, edx
  3340 00001823 49                      	dec	ecx
  3341 00001824 7403                    	jz	short lff11m2_2_4
  3342 00001826 668B16                  	mov	dx, [esi]
  3343                                  lff11m2_2_4:
  3344 00001829 E844070000               	call	interpolating_4_16bit_mono
  3345 0000182E E33E                    	jecxz	lff11m2_3
  3346 00001830 EBC8                    	jmp	short lff11m2_1
  3347                                  
  3348                                  lff11m2_7:
  3349                                  lff11s2_7:
  3350 00001832 E968F2FFFF              	jmp	lff11_5  ; error
  3351                                  
  3352                                  load_11khz_stereo_16_bit:
  3353                                  	; 18/11/2023
  3354 00001837 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3355                                  					; last of the file?
  3356 0000183E 7402                    	jz	short lff11s2_0		; no
  3357 00001840 F9                      	stc
  3358 00001841 C3                      	retn
  3359                                  
  3360                                  lff11s2_0:
  3361 00001842 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3362                                          ;mov	edx, [loadsize]
  3363                                  
  3364                                  	; esi = buffer address
  3365                                  	;; edx = buffer size
  3366                                  
  3367                                  	; load file into memory
  3368                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001847 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000184D 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 0000184F 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001855 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000185A CD40                <1>  int 40h
  3369 0000185C 72D4                    	jc	short lff11s2_7 ; error !
  3370                                  
  3371                                  	;mov	edi, audio_buffer
  3372                                  	; 29/05/2024
  3373 0000185E 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3374                                  	
  3375 00001864 C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3376 00001867 750A                    	jnz	short lff11s2_8
  3377 00001869 E928F2FFFF              	jmp	lff11_eof
  3378                                  
  3379                                  lff11m2_3:
  3380                                  lff11s2_3:
  3381 0000186E E910F2FFFF              	jmp	lff11_3	; padfill
  3382                                  		; (put zeros in the remain words of the buffer)
  3383                                  
  3384                                  lff11s2_8:
  3385 00001873 89C1                    	mov	ecx, eax	; dword count
  3386                                  lff11s2_9:
  3387 00001875 BD06000000              	mov	ebp, 6 ; interpolation (one step) loop count
  3388                                  lff11s2_1:
  3389                                  	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3390 0000187A 66AD                    	lodsw
  3391 0000187C 89C3                    	mov	ebx, eax
  3392 0000187E 66AD                    	lodsw
  3393 00001880 8B16                    	mov	edx, [esi]
  3394 00001882 8915[2C200000]          	mov	[next_val_l], edx
  3395                                  	; 26/11/2023
  3396 00001888 C1EA10                  	shr	edx, 16
  3397                                  	;mov	[next_val_r], dx
  3398 0000188B 49                      	dec	ecx
  3399 0000188C 7509                    	jnz	short lff11s2_2_1
  3400 0000188E 31D2                    	xor	edx, edx ; 0
  3401 00001890 668915[2C200000]        	mov	[next_val_l], dx
  3402                                  	;mov	[next_val_r], dx
  3403                                  lff11s2_2_1:
  3404                                  	; bx = [previous_val_l]
  3405                                  	; ax = [previous_val_r]
  3406                                  	; [next_val_l]
  3407                                  	; dx = [next_val_r]
  3408 00001897 E807060000              	call	interpolating_5_16bit_stereo
  3409 0000189C E3D0                    	jecxz	lff11s2_3
  3410                                  lff11s2_2_2:
  3411 0000189E 66AD                    	lodsw
  3412 000018A0 89C3                    	mov	ebx, eax
  3413 000018A2 66AD                    	lodsw
  3414 000018A4 8B16                    	mov	edx, [esi]
  3415 000018A6 668915[2C200000]        	mov	[next_val_l], dx
  3416                                  	; 26/11/2023
  3417 000018AD C1EA10                  	shr	edx, 16
  3418                                  	;mov	[next_val_r], dx
  3419 000018B0 49                      	dec	ecx
  3420 000018B1 7509                    	jnz	short lff11s2_2_3
  3421 000018B3 31D2                    	xor	edx, edx ; 0
  3422 000018B5 668915[2C200000]        	mov	[next_val_l], dx
  3423                                  	;mov	[next_val_r], dx
  3424                                  lff11s2_2_3:
  3425 000018BC E8EA060000               	call	interpolating_4_16bit_stereo
  3426 000018C1 E3AB                    	jecxz	lff11s2_3
  3427                                  	
  3428 000018C3 4D                      	dec	ebp
  3429 000018C4 74AF                    	jz	short lff11s2_9
  3430                                  
  3431 000018C6 66AD                    	lodsw
  3432 000018C8 89C3                    	mov	ebx, eax
  3433 000018CA 66AD                    	lodsw
  3434 000018CC 8B16                    	mov	edx, [esi]
  3435 000018CE 668915[2C200000]        	mov	[next_val_l], dx
  3436                                  	; 26/11/2023
  3437 000018D5 C1EA10                  	shr	edx, 16
  3438                                  	;mov	[next_val_r], dx
  3439 000018D8 49                      	dec	ecx
  3440 000018D9 7509                    	jnz	short lff11s2_2_4
  3441 000018DB 31D2                    	xor	edx, edx ; 0
  3442 000018DD 668915[2C200000]        	mov	[next_val_l], dx
  3443                                  	;mov	[next_val_r], dx
  3444                                  lff11s2_2_4:
  3445 000018E4 E8C2060000               	call	interpolating_4_16bit_stereo
  3446 000018E9 E383                    	jecxz	lff11s2_3
  3447 000018EB EB8D                    	jmp	short lff11s2_1
  3448                                  
  3449                                  ; .....................
  3450                                  
  3451                                  load_44khz_mono_8_bit:
  3452                                  	; 18/11/2023
  3453 000018ED F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3454                                  					; last of the file?
  3455 000018F4 7402                    	jz	short lff44m_0		; no
  3456 000018F6 F9                      	stc
  3457 000018F7 C3                      	retn
  3458                                  
  3459                                  lff44m_0:
  3460 000018F8 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3461                                          ;mov	edx, [loadsize]
  3462                                  
  3463                                  	; esi = buffer address
  3464                                  	;; edx = buffer size
  3465                                  
  3466                                  	; load file into memory
  3467                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000018FD 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001903 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001905 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 0000190B B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001910 CD40                <1>  int 40h
  3468 00001912 7251                    	jc	short lff44m_7 ; error !
  3469                                  
  3470                                  	;mov	edi, audio_buffer
  3471                                  	; 29/05/2024
  3472 00001914 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3473                                  	
  3474 0000191A 21C0                    	and	eax, eax
  3475 0000191C 7505                    	jnz	short lff44m_8
  3476 0000191E E973F1FFFF              	jmp	lff44_eof
  3477                                  
  3478                                  lff44m_8:
  3479 00001923 89C1                    	mov	ecx, eax	; byte count
  3480                                  lff44m_9:
  3481 00001925 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3482 0000192A C605[30200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3483                                  lff44m_1:
  3484                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3485                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3486 00001931 AC                      	lodsb
  3487 00001932 B280                    	mov	dl, 80h
  3488 00001934 49                      	dec	ecx
  3489 00001935 7402                    	jz	short lff44m_2_1
  3490 00001937 8A16                    	mov	dl, [esi]
  3491                                  lff44m_2_1:	
  3492                                  	; al = [previous_val]
  3493                                  	; dl = [next_val]
  3494 00001939 E828020000              	call	interpolating_2_8bit_mono
  3495 0000193E E320                    	jecxz	lff44m_3
  3496                                  lff44m_2_2:
  3497 00001940 AC                      	lodsb
  3498 00001941 2C80                    	sub	al, 80h
  3499 00001943 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3500 00001947 66AB                    	stosw		; (L)
  3501 00001949 66AB                    	stosw		; (R)	
  3502                                  
  3503 0000194B 49                      	dec	ecx
  3504 0000194C 7412                    	jz	short lff44m_3	
  3505 0000194E 4D                      	dec	ebp
  3506 0000194F 75EF                    	jnz	short lff44m_2_2
  3507                                  	
  3508 00001951 FE0D[30200000]          	dec	byte [faz]
  3509 00001957 74CC                    	jz	short lff44m_9 
  3510 00001959 BD0B000000              	mov	ebp, 11
  3511 0000195E EBD1                    	jmp	short lff44m_1
  3512                                  
  3513                                  lff44m_3:
  3514                                  lff44s_3:
  3515 00001960 E91EF1FFFF              	jmp	lff44_3	; padfill
  3516                                  		; (put zeros in the remain words of the buffer)
  3517                                  lff44m_7:
  3518                                  lff44s_7:
  3519 00001965 E935F1FFFF              	jmp	lff44_5  ; error
  3520                                  
  3521                                  load_44khz_stereo_8_bit:
  3522                                  	; 16/11/2023
  3523 0000196A F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3524                                  					; last of the file?
  3525 00001971 7402                    	jz	short lff44s_0		; no
  3526 00001973 F9                      	stc
  3527 00001974 C3                      	retn
  3528                                  
  3529                                  lff44s_0:
  3530 00001975 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3531                                          ;mov	edx, [loadsize]
  3532                                  
  3533                                  	; esi = buffer address
  3534                                  	;; edx = buffer size
  3535                                  
  3536                                  	; load file into memory
  3537                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 0000197A 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001980 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001982 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001988 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 0000198D CD40                <1>  int 40h
  3538 0000198F 72D4                    	jc	short lff44s_7 ; error !
  3539                                  
  3540                                  	;mov	edi, audio_buffer
  3541                                  	; 29/05/2024
  3542 00001991 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3543                                  	
  3544 00001997 D1E8                    	shr	eax, 1
  3545 00001999 7505                    	jnz	short lff44s_8
  3546 0000199B E9F6F0FFFF              	jmp	lff44_eof
  3547                                  
  3548                                  lff44s_8:
  3549 000019A0 89C1                    	mov	ecx, eax	; word count
  3550                                  lff44s_9:
  3551 000019A2 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3552 000019A7 C605[30200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3553                                  lff44s_1:
  3554                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3555                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3556 000019AE 66AD                    	lodsw
  3557 000019B0 66BA8080                	mov	dx, 8080h
  3558 000019B4 49                      	dec	ecx
  3559 000019B5 7403                    	jz	short lff44s_2_1 
  3560 000019B7 668B16                  	mov	dx, [esi]
  3561                                  lff44s_2_1:	
  3562                                  	; al = [previous_val_l]
  3563                                  	; ah = [previous_val_r]
  3564                                  	; dl = [next_val_l]
  3565                                  	; dh = [next_val_r]	
  3566 000019BA E8C4010000              	call	interpolating_2_8bit_stereo
  3567 000019BF E39F                    	jecxz	lff44s_3
  3568                                  lff44s_2_2:
  3569 000019C1 AC                      	lodsb
  3570 000019C2 2C80                    	sub	al, 80h
  3571 000019C4 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3572 000019C8 66AB                    	stosw		; (L)
  3573 000019CA AC                      	lodsb
  3574 000019CB 2C80                    	sub	al, 80h
  3575 000019CD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3576 000019D1 66AB                    	stosw		; (R)
  3577                                  
  3578 000019D3 49                      	dec	ecx
  3579 000019D4 748A                    	jz	short lff44s_3	
  3580 000019D6 4D                      	dec	ebp
  3581 000019D7 75E8                    	jnz	short lff44s_2_2
  3582                                  	
  3583 000019D9 FE0D[30200000]          	dec	byte [faz]
  3584 000019DF 74C1                    	jz	short lff44s_9 
  3585 000019E1 BD0B000000              	mov	ebp, 11
  3586 000019E6 EBC6                    	jmp	short lff44s_1
  3587                                  
  3588                                  load_44khz_mono_16_bit:
  3589                                  	; 18/11/2023
  3590 000019E8 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3591                                  					; last of the file?
  3592 000019EF 7402                    	jz	short lff44m2_0		; no
  3593 000019F1 F9                      	stc
  3594 000019F2 C3                      	retn
  3595                                  
  3596                                  lff44m2_0:
  3597 000019F3 BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3598                                          ;mov	edx, [loadsize]
  3599                                  
  3600                                  	; esi = buffer address
  3601                                  	;; edx = buffer size
  3602                                  
  3603                                  	; load file into memory
  3604                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000019F8 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000019FE 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001A00 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001A06 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001A0B CD40                <1>  int 40h
  3605 00001A0D 724E                    	jc	short lff44m2_7 ; error !
  3606                                  
  3607                                  	;mov	edi, audio_buffer
  3608                                  	; 29/05/2024
  3609 00001A0F 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3610                                  	
  3611 00001A15 D1E8                    	shr	eax, 1
  3612 00001A17 7505                    	jnz	short lff44m2_8
  3613 00001A19 E978F0FFFF              	jmp	lff44_eof
  3614                                  
  3615                                  lff44m2_8:
  3616 00001A1E 89C1                    	mov	ecx, eax	; word count
  3617                                  lff44m2_9:
  3618 00001A20 BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3619 00001A25 C605[30200000]02        	mov	byte [faz], 2  ; 2 steps/phases
  3620                                  lff44m2_1:
  3621                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3622                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3623 00001A2C 66AD                    	lodsw
  3624 00001A2E 31D2                    	xor	edx, edx
  3625 00001A30 49                      	dec	ecx
  3626 00001A31 7403                    	jz	short lff44m2_2_1
  3627 00001A33 668B16                  	mov	dx, [esi]
  3628                                  lff44m2_2_1:	
  3629                                  	; ax = [previous_val]
  3630                                  	; dx = [next_val]
  3631 00001A36 E80C020000              	call	interpolating_2_16bit_mono
  3632 00001A3B E31B                    	jecxz	lff44m2_3
  3633                                  lff44m2_2_2:
  3634 00001A3D 66AD                    	lodsw
  3635 00001A3F 66AB                    	stosw		; (L)eft Channel
  3636 00001A41 66AB                    	stosw		; (R)ight Channel
  3637                                  
  3638 00001A43 49                      	dec	ecx
  3639 00001A44 7412                    	jz	short lff44m2_3	
  3640 00001A46 4D                      	dec	ebp
  3641 00001A47 75F4                    	jnz	short lff44m2_2_2
  3642                                  	
  3643 00001A49 FE0D[30200000]          	dec	byte [faz]
  3644 00001A4F 74CF                    	jz	short lff44m2_9 
  3645 00001A51 BD0B000000              	mov	ebp, 11
  3646 00001A56 EBD4                    	jmp	short lff44m2_1
  3647                                  
  3648                                  lff44m2_3:
  3649                                  lff44s2_3:
  3650 00001A58 E926F0FFFF              	jmp	lff44_3	; padfill
  3651                                  		; (put zeros in the remain words of the buffer)
  3652                                  lff44m2_7:
  3653                                  lff44s2_7:
  3654 00001A5D E93DF0FFFF              	jmp	lff44_5  ; error
  3655                                  
  3656                                  load_44khz_stereo_16_bit:
  3657                                  	; 18/11/2023
  3658 00001A62 F605[70280000]01                test    byte [flags], ENDOFFILE	; have we already read the
  3659                                  					; last of the file?
  3660 00001A69 7402                    	jz	short lff44s2_0		; no
  3661 00001A6B F9                      	stc
  3662 00001A6C C3                      	retn
  3663                                  
  3664                                  lff44s2_0:
  3665 00001A6D BE[00400200]            	mov	esi, temp_buffer ; temporary buffer for wav data
  3666                                          ;mov	edx, [loadsize]
  3667                                  
  3668                                  	; esi = buffer address
  3669                                  	;; edx = buffer size
  3670                                  
  3671                                  	; load file into memory
  3672                                  	sys 	_read, [FileHandle], esi, [loadsize]
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00001A72 8B1D[51250000]      <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 00001A78 89F1                <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00001A7A 8B15[70030000]      <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00001A80 B803000000          <1>  mov eax, %1
    89                              <1> 
    90 00001A85 CD40                <1>  int 40h
  3673 00001A87 72D4                    	jc	short lff44s2_7 ; error !
  3674                                  
  3675                                  	;mov	edi, audio_buffer
  3676                                  	; 29/05/2024
  3677 00001A89 8B3D[EE280000]          	mov	edi, [audio_buffer]
  3678                                  	
  3679 00001A8F C1E802                  	shr	eax, 2	; dword (left chan word + right chan word)
  3680 00001A92 7505                    	jnz	short lff44s2_8
  3681 00001A94 E9FDEFFFFF              	jmp	lff44_eof
  3682                                  
  3683                                  lff44s2_8:
  3684 00001A99 89C1                    	mov	ecx, eax	; dword count
  3685                                  lff44s2_9:
  3686 00001A9B BD0A000000              	mov	ebp, 10 ; interpolation (one step) loop count
  3687 00001AA0 C605[30200000]02        	mov	byte [faz], 2  ; 2 steps/phase
  3688                                  lff44s2_1:
  3689                                  	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3690                                  	; 2:1:1:1:1:1:1:1:1:1:1:1
  3691 00001AA7 66AD                    	lodsw
  3692 00001AA9 89C3                    	mov	ebx, eax
  3693 00001AAB 66AD                    	lodsw
  3694                                  	;mov	dx, [esi]
  3695                                  	;mov	[next_val_l], dx
  3696                                  	;mov	dx, [esi+2]
  3697                                  	; 26/11/2023
  3698 00001AAD 8B16                    	mov	edx, [esi]
  3699 00001AAF 668915[2C200000]        	mov	[next_val_l], dx
  3700 00001AB6 C1EA10                  	shr	edx, 16
  3701 00001AB9 49                      	dec	ecx
  3702 00001ABA 7509                    	jnz	short lff44s2_2_1
  3703 00001ABC 31D2                    	xor	edx, edx ; 0
  3704 00001ABE 668915[2C200000]        	mov	[next_val_l], dx
  3705                                  lff44s2_2_1:
  3706                                  	; bx = [previous_val_l]
  3707                                  	; ax = [previous_val_r]
  3708                                  	; [next_val_l]
  3709                                  	; dx = [next_val_r]
  3710 00001AC5 E895010000              	call	interpolating_2_16bit_stereo
  3711 00001ACA E38C                    	jecxz	lff44s2_3
  3712                                  lff44s2_2_2:
  3713                                  	;movsw		; (L)eft Channel
  3714                                  	;movsw		; (R)ight Channel
  3715 00001ACC A5                      	movsd
  3716                                  
  3717 00001ACD 49                      	dec	ecx
  3718 00001ACE 7488                    	jz	short lff44s2_3	
  3719 00001AD0 4D                      	dec	ebp
  3720 00001AD1 75F9                    	jnz	short lff44s2_2_2
  3721                                  	
  3722 00001AD3 FE0D[30200000]          	dec	byte [faz]
  3723 00001AD9 74C0                    	jz	short lff44s2_9 
  3724 00001ADB BD0B000000              	mov	ebp, 11
  3725 00001AE0 EBC5                    	jmp	short lff44s2_1
  3726                                  
  3727                                  ; .....................
  3728                                  
  3729                                  interpolating_3_8bit_mono:
  3730                                  	; 16/11/2023
  3731                                  	; al = [previous_val]
  3732                                  	; dl = [next_val]
  3733                                  	; original-interpolated-interpolated
  3734 00001AE2 88C3                    	mov	bl, al
  3735 00001AE4 2C80                    	sub	al, 80h
  3736 00001AE6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3737 00001AEA 66AB                    	stosw		; original sample (L)
  3738 00001AEC 66AB                    	stosw		; original sample (R)
  3739 00001AEE 88D8                    	mov	al, bl
  3740 00001AF0 00D0                    	add	al, dl	
  3741 00001AF2 D0D8                    	rcr	al, 1
  3742 00001AF4 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3743 00001AF6 00D8                    	add	al, bl
  3744 00001AF8 D0D8                    	rcr	al, 1
  3745 00001AFA 2C80                    	sub	al, 80h
  3746 00001AFC 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3747 00001B00 66AB                    	stosw		; interpolated sample 1 (L)
  3748 00001B02 66AB                    	stosw		; interpolated sample 1 (R)
  3749 00001B04 88F8                    	mov	al, bh
  3750 00001B06 00D0                    	add	al, dl	; [next_val]
  3751 00001B08 D0D8                    	rcr	al, 1
  3752 00001B0A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3753 00001B0E 66AB                    	stosw		; interpolated sample 2 (L)
  3754 00001B10 66AB                    	stosw		; interpolated sample 2 (R)
  3755 00001B12 C3                      	retn
  3756                                  
  3757                                  interpolating_3_8bit_stereo:
  3758                                  	; 16/11/2023
  3759                                  	; al = [previous_val_l]
  3760                                  	; ah = [previous_val_r]
  3761                                  	; dl = [next_val_l]
  3762                                  	; dh = [next_val_r]	
  3763                                  	; original-interpolated-interpolated
  3764 00001B13 89C3                    	mov	ebx, eax
  3765 00001B15 2C80                    	sub	al, 80h
  3766 00001B17 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3767 00001B1B 66AB                    	stosw		; original sample (L)
  3768 00001B1D 88F8                    	mov	al, bh
  3769 00001B1F 2C80                    	sub	al, 80h
  3770 00001B21 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3771 00001B25 66AB                    	stosw		; original sample (R)
  3772 00001B27 88D8                    	mov	al, bl
  3773 00001B29 00D0                    	add	al, dl	; [next_val_l]	
  3774 00001B2B D0D8                    	rcr	al, 1
  3775 00001B2D 50                      	push	eax ; *	; al = interpolated middle (L) (temporary)
  3776 00001B2E 00D8                    	add	al, bl	; [previous_val_l]
  3777 00001B30 D0D8                    	rcr	al, 1
  3778 00001B32 2C80                    	sub	al, 80h
  3779 00001B34 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3780 00001B38 66AB                    	stosw		; interpolated sample 1 (L)
  3781 00001B3A 88F8                    	mov	al, bh
  3782 00001B3C 00F0                    	add	al, dh	; [next_val_r]
  3783 00001B3E D0D8                    	rcr	al, 1
  3784 00001B40 50                      	push	eax ; ** ; al = interpolated middle (R) (temporary)
  3785 00001B41 00F8                    	add	al, bh	; [previous_val_r]
  3786 00001B43 D0D8                    	rcr	al, 1
  3787 00001B45 2C80                    	sub	al, 80h
  3788 00001B47 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3789 00001B4B 66AB                    	stosw		; interpolated sample 1 (R)
  3790 00001B4D 5B                      	pop	ebx ; **
  3791 00001B4E 58                      	pop	eax ; *
  3792 00001B4F 00D0                    	add	al, dl	; [next_val_l]
  3793 00001B51 D0D8                    	rcr	al, 1
  3794 00001B53 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3795 00001B57 66AB                    	stosw		; interpolated sample 2 (L)
  3796 00001B59 88D8                    	mov	al, bl
  3797 00001B5B 00F0                    	add	al, dh	; [next_val_r]
  3798 00001B5D D0D8                    	rcr	al, 1
  3799 00001B5F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3800 00001B63 66AB                    	stosw		; interpolated sample 2 (R)
  3801 00001B65 C3                      	retn
  3802                                  
  3803                                  interpolating_2_8bit_mono:
  3804                                  	; 16/11/2023
  3805                                  	; al = [previous_val]
  3806                                  	; dl = [next_val]
  3807                                  	; original-interpolated
  3808 00001B66 88C3                    	mov	bl, al
  3809 00001B68 2C80                    	sub	al, 80h
  3810 00001B6A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3811 00001B6E 66AB                    	stosw		; original sample (L)
  3812 00001B70 66AB                    	stosw		; original sample (R)
  3813 00001B72 88D8                    	mov	al, bl
  3814 00001B74 00D0                    	add	al, dl	
  3815 00001B76 D0D8                    	rcr	al, 1
  3816 00001B78 2C80                    	sub	al, 80h
  3817 00001B7A 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3818 00001B7E 66AB                    	stosw		; interpolated sample (L)
  3819 00001B80 66AB                    	stosw		; interpolated sample (R)
  3820 00001B82 C3                      	retn
  3821                                  
  3822                                  interpolating_2_8bit_stereo:
  3823                                  	; 16/11/2023
  3824                                  	; al = [previous_val_l]
  3825                                  	; ah = [previous_val_r]
  3826                                  	; dl = [next_val_l]
  3827                                  	; dh = [next_val_r]	
  3828                                  	; original-interpolated
  3829 00001B83 89C3                    	mov	ebx, eax
  3830 00001B85 2C80                    	sub	al, 80h
  3831 00001B87 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3832 00001B8B 66AB                    	stosw		; original sample (L)
  3833 00001B8D 88F8                    	mov	al, bh
  3834 00001B8F 2C80                    	sub	al, 80h
  3835 00001B91 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3836 00001B95 66AB                    	stosw		; original sample (R)
  3837 00001B97 88D8                    	mov	al, bl	; [previous_val_l]
  3838 00001B99 00D0                    	add	al, dl	; [next_val_l]	
  3839 00001B9B D0D8                    	rcr	al, 1
  3840 00001B9D 2C80                    	sub	al, 80h
  3841 00001B9F 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3842 00001BA3 66AB                    	stosw		; interpolated sample (L)
  3843 00001BA5 88F8                    	mov	al, bh
  3844 00001BA7 00F0                    	add	al, dh	; [next_val_r]
  3845 00001BA9 D0D8                    	rcr	al, 1
  3846 00001BAB 2C80                    	sub	al, 80h
  3847 00001BAD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3848 00001BB1 66AB                    	stosw		; interpolated sample (R)
  3849 00001BB3 C3                      	retn
  3850                                  
  3851                                  interpolating_3_16bit_mono:
  3852                                  	; 16/11/2023
  3853                                  	; ax = [previous_val]
  3854                                  	; dx = [next_val]
  3855                                  	; original-interpolated-interpolated
  3856                                  
  3857 00001BB4 66AB                    	stosw		; original sample (L)
  3858 00001BB6 66AB                    	stosw		; original sample (R)
  3859 00001BB8 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3860 00001BBB 50                      	push	eax ; *	; [previous_val]
  3861 00001BBC 80C680                  	add	dh, 80h
  3862 00001BBF 6601D0                  	add	ax, dx
  3863 00001BC2 66D1D8                  	rcr	ax, 1
  3864 00001BC5 5B                      	pop	ebx ; *		
  3865 00001BC6 93                      	xchg	ebx, eax ; bx  = interpolated middle (temporary)
  3866 00001BC7 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  3867 00001BCA 66D1D8                  	rcr	ax, 1
  3868 00001BCD 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3869 00001BD0 66AB                    	stosw 		; interpolated sample 1 (L)
  3870 00001BD2 66AB                    	stosw		; interpolated sample 1 (R)
  3871 00001BD4 89D8                    	mov	eax, ebx
  3872 00001BD6 6601D0                  	add	ax, dx	 ;interpolated middle + [next_val]
  3873 00001BD9 66D1D8                  	rcr	ax, 1
  3874 00001BDC 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3875 00001BDF 66AB                    	stosw		; interpolated sample 2 (L)
  3876 00001BE1 66AB                    	stosw		; interpolated sample 2 (R)
  3877 00001BE3 C3                      	retn
  3878                                  
  3879                                  interpolating_3_16bit_stereo:
  3880                                  	; 16/11/2023
  3881                                  	; bx = [previous_val_l]
  3882                                  	; ax = [previous_val_r]
  3883                                  	; [next_val_l]
  3884                                  	; dx = [next_val_r]
  3885                                  	; original-interpolated-interpolated
  3886                                  
  3887 00001BE4 93                      	xchg	eax, ebx
  3888 00001BE5 66AB                    	stosw		; original sample (L)
  3889 00001BE7 93                      	xchg	eax, ebx
  3890 00001BE8 66AB                    	stosw		; original sample (R)
  3891 00001BEA 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3892 00001BED 50                      	push	eax ; *	; [previous_val_r]
  3893 00001BEE 80C780                  	add	bh, 80h
  3894 00001BF1 8005[2D200000]80        	add	byte [next_val_l+1], 80h
  3895 00001BF8 66A1[2C200000]          	mov	ax, [next_val_l]
  3896 00001BFE 6601D8                  	add	ax, bx	; [previous_val_l]
  3897 00001C01 66D1D8                  	rcr	ax, 1
  3898 00001C04 93                      	xchg	eax, ebx ; ax = [previous_val_l]	
  3899 00001C05 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  3900 00001C08 66D1D8                  	rcr	ax, 1
  3901 00001C0B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3902 00001C0E 66AB                    	stosw 		; interpolated sample 1 (L)
  3903 00001C10 58                      	pop	eax  ; *
  3904 00001C11 80C680                  	add	dh, 80h ; convert sound level 0 to 65535 format
  3905 00001C14 52                      	push	edx  ; * ; [next_val_r]
  3906 00001C15 92                      	xchg	eax, edx
  3907 00001C16 6601D0                  	add	ax, dx	; [next_val_r] + [previous_val_r]
  3908 00001C19 66D1D8                  	rcr	ax, 1	; / 2
  3909 00001C1C 50                      	push	eax ; ** ; interpolated middle (R)
  3910 00001C1D 6601D0                  	add	ax, dx	; + [previous_val_r]
  3911 00001C20 66D1D8                  	rcr	ax, 1
  3912 00001C23 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3913 00001C26 66AB                    	stosw 		; interpolated sample 1 (R)
  3914 00001C28 66A1[2C200000]          	mov	ax, [next_val_l]
  3915 00001C2E 6601D8                  	add	ax, bx	; + interpolated middle (L)
  3916 00001C31 66D1D8                  	rcr	ax, 1
  3917 00001C34 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3918 00001C37 66AB                    	stosw 		; interpolated sample 2 (L)
  3919 00001C39 58                      	pop	eax ; **
  3920 00001C3A 5A                      	pop	edx ; *	
  3921 00001C3B 6601D0                  	add	ax, dx	; interpolated middle + [next_val_r]
  3922 00001C3E 66D1D8                  	rcr	ax, 1	; / 2
  3923 00001C41 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3924 00001C44 66AB                    	stosw 		; interpolated sample 2 (L)
  3925 00001C46 C3                      	retn
  3926                                  
  3927                                  interpolating_2_16bit_mono:
  3928                                  	; 16/11/2023
  3929                                  	; ax = [previous_val]
  3930                                  	; dx = [next_val]
  3931                                  	; original-interpolated
  3932                                  
  3933 00001C47 66AB                    	stosw		; original sample (L)
  3934 00001C49 66AB                    	stosw		; original sample (R)
  3935 00001C4B 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3936 00001C4E 80C680                  	add	dh, 80h
  3937 00001C51 6601D0                  	add	ax, dx
  3938 00001C54 66D1D8                  	rcr	ax, 1
  3939 00001C57 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3940 00001C5A 66AB                    	stosw		; interpolated sample (L)
  3941 00001C5C 66AB                    	stosw		; interpolated sample (R)
  3942 00001C5E C3                      	retn
  3943                                  
  3944                                  interpolating_2_16bit_stereo:
  3945                                  	; 16/11/2023
  3946                                  	; bx = [previous_val_l]
  3947                                  	; ax = [previous_val_r]
  3948                                  	; [next_val_l]
  3949                                  	; dx = [next_val_r]
  3950                                  	; original-interpolated
  3951                                  
  3952 00001C5F 93                      	xchg	eax, ebx
  3953 00001C60 66AB                    	stosw		; original sample (L)
  3954 00001C62 93                      	xchg	eax, ebx
  3955 00001C63 66AB                    	stosw		; original sample (R)
  3956 00001C65 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  3957 00001C68 80C680                  	add	dh, 80h
  3958 00001C6B 6601D0                  	add	ax, dx	; [previous_val_r] + [next_val_r]
  3959 00001C6E 66D1D8                  	rcr	ax, 1	; / 2
  3960 00001C71 50                      	push	eax ; *	; interpolated sample (R)
  3961 00001C72 66A1[2C200000]          	mov	ax, [next_val_l]
  3962 00001C78 80C480                  	add	ah, 80h
  3963 00001C7B 80C780                  	add	bh, 80h
  3964 00001C7E 6601D8                  	add	ax, bx	; [next_val_l] + [previous_val_l]
  3965 00001C81 66D1D8                  	rcr	ax, 1	; / 2		
  3966 00001C84 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3967 00001C87 66AB                    	stosw 		; interpolated sample (L)
  3968 00001C89 58                      	pop	eax ; *	
  3969 00001C8A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  3970 00001C8D 66AB                    	stosw 		; interpolated sample (R)
  3971 00001C8F C3                      	retn
  3972                                  
  3973                                  interpolating_5_8bit_mono:
  3974                                  	; 17/11/2023
  3975                                  	; al = [previous_val]
  3976                                  	; dl = [next_val]
  3977                                  	; original-interpltd-interpltd-interpltd-interpltd
  3978 00001C90 88C3                    	mov	bl, al
  3979 00001C92 2C80                    	sub	al, 80h
  3980 00001C94 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3981 00001C98 66AB                    	stosw		; original sample (L)
  3982 00001C9A 66AB                    	stosw		; original sample (R)
  3983 00001C9C 88D8                    	mov	al, bl
  3984 00001C9E 00D0                    	add	al, dl	
  3985 00001CA0 D0D8                    	rcr	al, 1
  3986 00001CA2 88C7                    	mov	bh, al	; interpolated middle (temporary)
  3987 00001CA4 00D8                    	add	al, bl  ; [previous_val]
  3988 00001CA6 D0D8                    	rcr	al, 1 	
  3989 00001CA8 88C6                    	mov	dh, al	; interpolated 1st quarter (temporary)
  3990 00001CAA 00D8                    	add	al, bl
  3991 00001CAC D0D8                    	rcr	al, 1
  3992 00001CAE 2C80                    	sub	al, 80h
  3993 00001CB0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3994 00001CB4 66AB                    	stosw		; interpolated sample 1 (L)
  3995 00001CB6 66AB                    	stosw		; interpolated sample 1 (R)
  3996 00001CB8 88F8                    	mov	al, bh
  3997 00001CBA 00F0                    	add	al, dh
  3998 00001CBC D0D8                    	rcr	al, 1
  3999 00001CBE 2C80                    	sub	al, 80h
  4000 00001CC0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4001 00001CC4 66AB                    	stosw		; interpolated sample 2 (L)
  4002 00001CC6 66AB                    	stosw		; interpolated sample 2 (R)
  4003 00001CC8 88F8                    	mov	al, bh
  4004 00001CCA 00D0                    	add	al, dl	; [next_val]
  4005 00001CCC D0D8                    	rcr	al, 1
  4006 00001CCE 88C6                    	mov	dh, al	; interpolated 3rd quarter (temporary)
  4007 00001CD0 00F8                    	add	al, bh
  4008 00001CD2 D0D8                    	rcr	al, 1
  4009 00001CD4 2C80                    	sub	al, 80h
  4010 00001CD6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4011 00001CDA 66AB                    	stosw		; interpolated sample 3 (L)
  4012 00001CDC 66AB                    	stosw		; interpolated sample 3 (R)
  4013 00001CDE 88F0                    	mov	al, dh
  4014 00001CE0 00D0                    	add	al, dl
  4015 00001CE2 D0D8                    	rcr	al, 1
  4016 00001CE4 2C80                    	sub	al, 80h
  4017 00001CE6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4018 00001CEA 66AB                    	stosw		; interpolated sample 4 (L)
  4019 00001CEC 66AB                    	stosw		; interpolated sample 4 (R)
  4020 00001CEE C3                      	retn
  4021                                  
  4022                                  interpolating_5_8bit_stereo:
  4023                                  	; 17/11/2023
  4024                                  	; al = [previous_val_l]
  4025                                  	; ah = [previous_val_r]
  4026                                  	; dl = [next_val_l]
  4027                                  	; dh = [next_val_r]	
  4028                                  	; original-interpltd-interpltd-interpltd-interpltd
  4029 00001CEF 89C3                    	mov	ebx, eax
  4030 00001CF1 2C80                    	sub	al, 80h
  4031 00001CF3 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4032 00001CF7 66AB                    	stosw		; original sample (L)
  4033 00001CF9 88F8                    	mov	al, bh
  4034 00001CFB 2C80                    	sub	al, 80h
  4035 00001CFD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4036 00001D01 66AB                    	stosw		; original sample (R)
  4037 00001D03 52                      	push	edx ; *
  4038 00001D04 88D8                    	mov	al, bl
  4039 00001D06 00D0                    	add	al, dl	; [next_val_l]
  4040 00001D08 D0D8                    	rcr	al, 1
  4041 00001D0A 50                      	push	eax ; **	; al = interpolated middle (L) (temporary)
  4042 00001D0B 00D8                    	add	al, bl	; [previous_val_l]
  4043 00001D0D D0D8                    	rcr	al, 1
  4044 00001D0F 86C3                    	xchg	al, bl	
  4045 00001D11 00D8                    	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  4046 00001D13 D0D8                    	rcr	al, 1
  4047 00001D15 2C80                    	sub	al, 80h
  4048 00001D17 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4049 00001D1B 66AB                    	stosw		; interpolated sample 1 (L)
  4050 00001D1D 88F8                    	mov	al, bh
  4051 00001D1F 00F0                    	add	al, dh	; [next_val_r]
  4052 00001D21 D0D8                    	rcr	al, 1
  4053 00001D23 50                      	push	eax ; *** ; al = interpolated middle (R) (temporary)
  4054 00001D24 00F8                    	add	al, bh	; [previous_val_r]
  4055 00001D26 D0D8                    	rcr	al, 1
  4056 00001D28 86C7                    	xchg	al, bh	
  4057 00001D2A 00F8                    	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  4058 00001D2C D0D8                    	rcr	al, 1
  4059 00001D2E 2C80                    	sub	al, 80h
  4060 00001D30 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4061 00001D34 66AB                    	stosw		; interpolated sample 1 (R)
  4062 00001D36 5A                      	pop	edx ; ***
  4063 00001D37 58                      	pop	eax ; **	; al = interpolated middle (L) (temporary)
  4064 00001D38 86C3                    	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  4065 00001D3A 00D8                    	add	al, bl	; bl = interpolated middle (L) (temporary)
  4066 00001D3C D0D8                    	rcr	al, 1
  4067 00001D3E 2C80                    	sub	al, 80h
  4068 00001D40 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4069 00001D44 66AB                    	stosw		; interpolated sample 2 (L)	
  4070 00001D46 88D0                    	mov	al, dl 	; interpolated middle (R) (temporary)
  4071 00001D48 86C7                    	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  4072 00001D4A 00F8                    	add	al, bh	; bh = interpolated middle (R) (temporary)
  4073 00001D4C D0D8                    	rcr	al, 1
  4074 00001D4E 2C80                    	sub	al, 80h
  4075 00001D50 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4076 00001D54 66AB                    	stosw		; interpolated sample 2 (R)
  4077 00001D56 5A                      	pop	edx ; *
  4078 00001D57 88D8                    	mov	al, bl	; interpolated middle (L) (temporary)
  4079 00001D59 00D0                    	add	al, dl	; [next_val_l]
  4080 00001D5B D0D8                    	rcr	al, 1
  4081 00001D5D 86C3                    	xchg	al, bl	; al = interpolated middle (R) (temporary)	
  4082 00001D5F 00D8                    	add	al, bl	; bl = interpolated 3rd quarter (L) (temp) 
  4083 00001D61 D0D8                    	rcr	al, 1
  4084 00001D63 2C80                    	sub	al, 80h
  4085 00001D65 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4086 00001D69 66AB                    	stosw		; interpolated sample 3 (L)
  4087 00001D6B 88F8                    	mov	al, bh	
  4088 00001D6D 00F0                    	add	al, dh	; interpolated middle (R) + [next_val_r]
  4089 00001D6F D0D8                    	rcr	al, 1
  4090 00001D71 86C7                    	xchg	al, bh	; al = interpolated middle (R)
  4091 00001D73 00F8                    	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  4092 00001D75 D0D8                    	rcr	al, 1
  4093 00001D77 2C80                    	sub	al, 80h
  4094 00001D79 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4095 00001D7D 66AB                    	stosw		; interpolated sample 3 (R)
  4096 00001D7F 88D8                    	mov	al, bl
  4097 00001D81 00D0                    	add	al, dl	; [next_val_l]
  4098 00001D83 D0D8                    	rcr	al, 1
  4099 00001D85 2C80                    	sub	al, 80h
  4100 00001D87 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4101 00001D8B 66AB                    	stosw		; interpolated sample 4 (L)
  4102 00001D8D 88F8                    	mov	al, bh
  4103 00001D8F 00F0                    	add	al, dh	; [next_val_r]
  4104 00001D91 D0D8                    	rcr	al, 1
  4105 00001D93 2C80                    	sub	al, 80h
  4106 00001D95 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4107 00001D99 66AB                    	stosw		; interpolated sample 4 (R)
  4108 00001D9B C3                      	retn
  4109                                  
  4110                                  interpolating_4_8bit_mono:
  4111                                  	; 17/11/2023
  4112                                  	; al = [previous_val]
  4113                                  	; dl = [next_val]
  4114                                  	; original-interpolated-interpolated-interpolated
  4115 00001D9C 88C3                    	mov	bl, al
  4116 00001D9E 2C80                    	sub	al, 80h
  4117 00001DA0 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4118 00001DA4 66AB                    	stosw		; original sample (L)
  4119 00001DA6 66AB                    	stosw		; original sample (R)
  4120 00001DA8 88D8                    	mov	al, bl
  4121 00001DAA 00D0                    	add	al, dl	
  4122 00001DAC D0D8                    	rcr	al, 1
  4123 00001DAE 86C3                    	xchg	al, bl  ; al = [previous_val]
  4124 00001DB0 00D8                    	add	al, bl	; bl = interpolated middle (sample 2)
  4125 00001DB2 D0D8                    	rcr	al, 1 	
  4126 00001DB4 2C80                    	sub	al, 80h
  4127 00001DB6 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4128 00001DBA 66AB                    	stosw		; interpolated sample 1 (L)
  4129 00001DBC 66AB                    	stosw		; interpolated sample 1 (R)
  4130 00001DBE 88D8                    	mov	al, bl	; interpolated middle (sample 2)
  4131 00001DC0 2C80                    	sub	al, 80h
  4132 00001DC2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4133 00001DC6 66AB                    	stosw		; interpolated sample 2 (L)
  4134 00001DC8 66AB                    	stosw		; interpolated sample 2 (R)
  4135 00001DCA 88D8                    	mov	al, bl
  4136 00001DCC 00D0                    	add	al, dl	; [next_val]
  4137 00001DCE D0D8                    	rcr	al, 1
  4138 00001DD0 2C80                    	sub	al, 80h
  4139 00001DD2 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4140 00001DD6 66AB                    	stosw		; interpolated sample 3 (L)
  4141 00001DD8 66AB                    	stosw		; interpolated sample 3 (R)
  4142 00001DDA C3                      	retn
  4143                                  
  4144                                  interpolating_4_8bit_stereo:
  4145                                  	; 17/11/2023
  4146                                  	; al = [previous_val_l]
  4147                                  	; ah = [previous_val_r]
  4148                                  	; dl = [next_val_l]
  4149                                  	; dh = [next_val_r]	
  4150                                  	; original-interpolated-interpolated-interpolated
  4151 00001DDB 89C3                    	mov	ebx, eax
  4152 00001DDD 2C80                    	sub	al, 80h
  4153 00001DDF 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4154 00001DE3 66AB                    	stosw		; original sample (L)
  4155 00001DE5 88F8                    	mov	al, bh
  4156 00001DE7 2C80                    	sub	al, 80h
  4157 00001DE9 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4158 00001DED 66AB                    	stosw		; original sample (R)
  4159 00001DEF 88D8                    	mov	al, bl
  4160 00001DF1 00D0                    	add	al, dl	; [next_val_l]
  4161 00001DF3 D0D8                    	rcr	al, 1
  4162 00001DF5 86C3                    	xchg	al, bl	; al = [previous_val_l]
  4163 00001DF7 00D8                    	add	al, bl	; bl = interpolated middle (L) (sample 2)
  4164 00001DF9 D0D8                    	rcr	al, 1
  4165 00001DFB 2C80                    	sub	al, 80h
  4166 00001DFD 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4167 00001E01 66AB                    	stosw		; interpolated sample 1 (L)
  4168 00001E03 88F8                    	mov	al, bh
  4169 00001E05 00F0                    	add	al, dh	; [next_val_r]
  4170 00001E07 D0D8                    	rcr	al, 1
  4171 00001E09 86C7                    	xchg	al, bh	; al = [previous_val_h]
  4172 00001E0B 00F8                    	add	al, bh	; bh = interpolated middle (R) (sample 2)
  4173 00001E0D D0D8                    	rcr	al, 1
  4174 00001E0F 2C80                    	sub	al, 80h
  4175 00001E11 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4176 00001E15 66AB                    	stosw		; interpolated sample 1 (R)
  4177 00001E17 88D8                    	mov	al, bl	; interpolated middle (L) (sample 2)
  4178 00001E19 2C80                    	sub	al, 80h
  4179 00001E1B 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4180 00001E1F 66AB                    	stosw		; interpolated sample 2 (L)
  4181 00001E21 88F8                    	mov	al, bh	; interpolated middle (L) (sample 2)
  4182 00001E23 2C80                    	sub	al, 80h
  4183 00001E25 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4184 00001E29 66AB                    	stosw		; interpolated sample 2 (L)
  4185 00001E2B 88D8                    	mov	al, bl
  4186 00001E2D 00D0                    	add	al, dl	; [next_val_l]
  4187 00001E2F D0D8                    	rcr	al, 1
  4188 00001E31 2C80                    	sub	al, 80h
  4189 00001E33 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4190 00001E37 66AB                    	stosw		; interpolated sample 3 (L)
  4191 00001E39 88F8                    	mov	al, bh
  4192 00001E3B 00F0                    	add	al, dh	; [next_val_r]
  4193 00001E3D D0D8                    	rcr	al, 1
  4194 00001E3F 2C80                    	sub	al, 80h
  4195 00001E41 66C1E008                	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4196 00001E45 66AB                    	stosw		; interpolated sample 3 (R)
  4197 00001E47 C3                      	retn
  4198                                  
  4199                                  interpolating_5_16bit_mono:
  4200                                  	; 18/11/2023
  4201                                  	; ax = [previous_val]
  4202                                  	; dx = [next_val]
  4203                                  	; original-interpltd-interpltd-interpltd-interpltd
  4204 00001E48 66AB                    	stosw		; original sample (L)
  4205 00001E4A 66AB                    	stosw		; original sample (R)
  4206 00001E4C 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4207 00001E4F 89C3                    	mov	ebx, eax ; [previous_val]
  4208 00001E51 80C680                  	add	dh, 80h
  4209 00001E54 6601D0                  	add	ax, dx
  4210 00001E57 66D1D8                  	rcr	ax, 1
  4211 00001E5A 50                      	push	eax ; *	; interpolated middle (temporary)
  4212 00001E5B 6601D8                  	add	ax, bx	; interpolated middle + [previous_val] 
  4213 00001E5E 66D1D8                  	rcr	ax, 1
  4214 00001E61 50                      	push	eax ; **	; interpolated 1st quarter (temporary)
  4215 00001E62 6601D8                  	add	ax, bx	; 1st quarter + [previous_val]
  4216 00001E65 66D1D8                  	rcr	ax, 1	
  4217 00001E68 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4218 00001E6B 66AB                    	stosw 		; interpolated sample 1 (L)
  4219 00001E6D 66AB                    	stosw		; interpolated sample 1 (R)
  4220 00001E6F 58                      	pop	eax ; **	
  4221 00001E70 5B                      	pop	ebx ; *
  4222 00001E71 6601D8                  	add	ax, bx	; 1st quarter + middle
  4223 00001E74 66D1D8                  	rcr	ax, 1	; / 2
  4224 00001E77 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again	
  4225 00001E7A 66AB                    	stosw		; interpolated sample 2 (L)
  4226 00001E7C 66AB                    	stosw		; interpolated sample 2 (R)		
  4227 00001E7E 89D8                    	mov	eax, ebx
  4228 00001E80 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4229 00001E83 66D1D8                  	rcr	ax, 1
  4230 00001E86 50                      	push	eax ; *	; interpolated 3rd quarter (temporary)
  4231 00001E87 6601D8                  	add	ax, bx	; + interpolated middle
  4232 00001E8A 66D1D8                  	rcr	ax, 1
  4233 00001E8D 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4234 00001E90 66AB                    	stosw		; interpolated sample 3 (L)
  4235 00001E92 66AB                    	stosw		; interpolated sample 3 (R)
  4236 00001E94 58                      	pop	eax ; *	
  4237 00001E95 6601D0                  	add	ax, dx	; 3rd quarter + [next_val]
  4238 00001E98 66D1D8                  	rcr	ax, 1	; / 2
  4239 00001E9B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4240 00001E9E 66AB                    	stosw		; interpolated sample 4 (L)
  4241 00001EA0 66AB                    	stosw		; interpolated sample 4 (R)
  4242 00001EA2 C3                      	retn
  4243                                  
  4244                                  interpolating_5_16bit_stereo:
  4245                                  	; 18/11/2023
  4246                                  	; bx = [previous_val_l]
  4247                                  	; ax = [previous_val_r]
  4248                                  	; [next_val_l]
  4249                                  	; [next_val_r]
  4250                                  	; original-interpltd-interpltd-interpltd-interpltd
  4251 00001EA3 51                      	push	ecx ; !
  4252 00001EA4 93                      	xchg	eax, ebx
  4253 00001EA5 66AB                    	stosw		; original sample (L)
  4254 00001EA7 93                      	xchg	eax, ebx
  4255 00001EA8 66AB                    	stosw		; original sample (R)
  4256 00001EAA 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4257 00001EAD 50                      	push	eax ; *	; [previous_val_r]
  4258 00001EAE 80C780                  	add	bh, 80h
  4259 00001EB1 8005[2D200000]80        	add	byte [next_val_l+1], 80h
  4260 00001EB8 66A1[2C200000]          	mov	ax, [next_val_l]
  4261 00001EBE 6601D8                  	add	ax, bx	; [previous_val_l]
  4262 00001EC1 66D1D8                  	rcr	ax, 1
  4263 00001EC4 89C1                    	mov	ecx, eax ; interpolated middle (L)
  4264 00001EC6 6601D8                  	add	ax, bx	
  4265 00001EC9 66D1D8                  	rcr	ax, 1
  4266 00001ECC 89C2                    	mov	edx, eax ; interpolated 1st quarter (L)	
  4267 00001ECE 6601D8                  	add	ax, bx	; [previous_val_l]
  4268 00001ED1 66D1D8                  	rcr	ax, 1
  4269 00001ED4 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4270 00001ED7 66AB                    	stosw 		; interpolated sample 1 (L)
  4271 00001ED9 89C8                    	mov	eax, ecx
  4272 00001EDB 6601D0                  	add	ax, dx	; middle (L) + 1st quarter (L) 
  4273 00001EDE 66D1D8                  	rcr	ax, 1	; / 2
  4274 00001EE1 89C3                    	mov	ebx, eax  ; interpolated sample 2 (L)
  4275 00001EE3 5A                      	pop	edx ; *	; [previous_val_r]
  4276 00001EE4 89D0                    	mov	eax, edx
  4277 00001EE6 8005[2F200000]80        	add	byte [next_val_r+1], 80h
  4278 00001EED 660305[2E200000]        	add	ax, [next_val_r]
  4279 00001EF4 66D1D8                  	rcr	ax, 1
  4280 00001EF7 50                      	push	eax ; *	; interpolated middle (R)
  4281 00001EF8 6601D0                  	add	ax, dx
  4282 00001EFB 66D1D8                  	rcr	ax, 1
  4283 00001EFE 50                      	push	eax ; ** ; interpolated 1st quarter (R)
  4284 00001EFF 6601D0                  	add	ax, dx	; [previous_val_r]
  4285 00001F02 66D1D8                  	rcr	ax, 1
  4286 00001F05 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4287 00001F08 66AB                    	stosw 		; interpolated sample 1 (R)
  4288 00001F0A 89D8                    	mov	eax, ebx
  4289 00001F0C 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4290 00001F0F 66AB                    	stosw 		; interpolated sample 2 (L)
  4291 00001F11 58                      	pop	eax ; **
  4292 00001F12 5A                      	pop	edx ; *
  4293 00001F13 6601D0                  	add	ax, dx	; 1st quarter (R) + middle (R)
  4294 00001F16 66D1D8                  	rcr	ax, 1	; / 2
  4295 00001F19 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4296 00001F1C 66AB                    	stosw 		; interpolated sample 2 (R)
  4297 00001F1E 89C8                    	mov	eax, ecx
  4298 00001F20 660305[2C200000]        	add	ax, [next_val_l]
  4299 00001F27 66D1D8                  	rcr	ax, 1
  4300 00001F2A 50                      	push	eax ; * ; interpolated 3rd quarter (L)
  4301 00001F2B 6601C8                  	add	ax, cx	; interpolated middle (L)
  4302 00001F2E 66D1D8                  	rcr	ax, 1
  4303 00001F31 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4304 00001F34 66AB                    	stosw 		; interpolated sample 3 (L)
  4305 00001F36 89D0                    	mov	eax, edx
  4306 00001F38 660305[2E200000]        	add	ax, [next_val_r]
  4307 00001F3F 66D1D8                  	rcr	ax, 1
  4308 00001F42 50                      	push	eax ; ** ; interpolated 3rd quarter (R)
  4309 00001F43 6601D0                  	add	ax, dx	; interpolated middle (R)
  4310 00001F46 66D1D8                  	rcr	ax, 1
  4311 00001F49 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4312 00001F4C 66AB                    	stosw 		; interpolated sample 3 (R)
  4313 00001F4E 5B                      	pop	ebx ; **
  4314 00001F4F 58                      	pop	eax ; *
  4315 00001F50 660305[2C200000]        	add	ax, [next_val_l]
  4316 00001F57 66D1D8                  	rcr	ax, 1
  4317 00001F5A 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4318 00001F5D 66AB                    	stosw 		; interpolated sample 4 (L)
  4319 00001F5F 89D8                    	mov	eax, ebx	
  4320 00001F61 660305[2E200000]        	add	ax, [next_val_r]
  4321 00001F68 66D1D8                  	rcr	ax, 1
  4322 00001F6B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4323 00001F6E 66AB                    	stosw 		; interpolated sample 4 (R)
  4324 00001F70 59                      	pop	ecx ; !
  4325 00001F71 C3                      	retn
  4326                                  
  4327                                  interpolating_4_16bit_mono:
  4328                                  	; 18/11/2023
  4329                                  	; ax = [previous_val]
  4330                                  	; dx = [next_val]
  4331                                  	; original-interpolated
  4332                                  
  4333 00001F72 66AB                    	stosw		; original sample (L)
  4334 00001F74 66AB                    	stosw		; original sample (R)
  4335 00001F76 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4336 00001F79 89C3                    	mov	ebx, eax ; [previous_val]
  4337 00001F7B 80C680                  	add	dh, 80h
  4338 00001F7E 6601D0                  	add	ax, dx	; [previous_val] + [next_val]
  4339 00001F81 66D1D8                  	rcr	ax, 1
  4340 00001F84 93                      	xchg	eax, ebx	
  4341 00001F85 6601D8                  	add	ax, bx	; [previous_val] + interpolated middle
  4342 00001F88 66D1D8                  	rcr	ax, 1
  4343 00001F8B 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4344 00001F8E 66AB                    	stosw 		; interpolated sample 1 (L)
  4345 00001F90 66AB                    	stosw		; interpolated sample 1 (R)
  4346 00001F92 89D8                    	mov	eax, ebx ; interpolated middle
  4347 00001F94 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4348 00001F97 66AB                    	stosw 		; interpolated sample 2 (L)
  4349 00001F99 66AB                    	stosw		; interpolated sample 2 (R)
  4350 00001F9B 89D8                    	mov	eax, ebx
  4351 00001F9D 6601D0                  	add	ax, dx	; interpolated middle + [next_val]
  4352 00001FA0 66D1D8                  	rcr	ax, 1
  4353 00001FA3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4354 00001FA6 66AB                    	stosw		; interpolated sample 3 (L)
  4355 00001FA8 66AB                    	stosw		; interpolated sample 3 (R)
  4356 00001FAA C3                      	retn
  4357                                  
  4358                                  interpolating_4_16bit_stereo:
  4359                                  	; 18/11/2023
  4360                                  	; bx = [previous_val_l]
  4361                                  	; ax = [previous_val_r]
  4362                                  	; [next_val_l]
  4363                                  	; [next_val_r]
  4364                                  	; original-interpolated-interpolated-interpolated
  4365 00001FAB 93                      	xchg	eax, ebx
  4366 00001FAC 66AB                    	stosw		; original sample (L)
  4367 00001FAE 93                      	xchg	eax, ebx
  4368 00001FAF 66AB                    	stosw		; original sample (R)
  4369 00001FB1 80C480                  	add	ah, 80h ; convert sound level 0 to 65535 format
  4370 00001FB4 89C2                    	mov	edx, eax ; [previous_val_r]
  4371 00001FB6 80C780                  	add	bh, 80h
  4372 00001FB9 8005[2D200000]80        	add	byte [next_val_l+1], 80h
  4373 00001FC0 66A1[2C200000]          	mov	ax, [next_val_l]
  4374 00001FC6 6601D8                  	add	ax, bx	; [previous_val_l]
  4375 00001FC9 66D1D8                  	rcr	ax, 1
  4376 00001FCC 93                      	xchg	eax, ebx	
  4377 00001FCD 6601D8                  	add	ax, bx	; bx = interpolated middle (L)
  4378 00001FD0 66D1D8                  	rcr	ax, 1
  4379 00001FD3 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4380 00001FD6 66AB                    	stosw 		; interpolated sample 1 (L)
  4381 00001FD8 8005[2F200000]80        	add	byte [next_val_r+1], 80h
  4382 00001FDF 89D0                    	mov	eax, edx ; [previous_val_r]
  4383 00001FE1 660305[2E200000]        	add	ax, [next_val_r]
  4384 00001FE8 66D1D8                  	rcr	ax, 1
  4385 00001FEB 92                      	xchg	eax, edx	
  4386 00001FEC 6601D0                  	add	ax, dx	; dx = interpolated middle (R)
  4387 00001FEF 66D1D8                  	rcr	ax, 1
  4388 00001FF2 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4389 00001FF5 66AB                    	stosw 		; interpolated sample 1 (R)
  4390 00001FF7 89D8                    	mov	eax, ebx
  4391 00001FF9 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4392 00001FFC 66AB                    	stosw 		; interpolated sample 2 (L)
  4393 00001FFE 89D0                    	mov	eax, edx
  4394 00002000 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4395 00002003 66AB                    	stosw 		; interpolated sample 2 (R)
  4396 00002005 89D8                    	mov	eax, ebx
  4397 00002007 660305[2C200000]        	add	ax, [next_val_l]
  4398 0000200E 66D1D8                  	rcr	ax, 1
  4399 00002011 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4400 00002014 66AB                    	stosw 		; interpolated sample 3 (L)
  4401 00002016 89D0                    	mov	eax, edx
  4402 00002018 660305[2E200000]        	add	ax, [next_val_r]
  4403 0000201F 66D1D8                  	rcr	ax, 1
  4404 00002022 80EC80                  	sub	ah, 80h	; -32768 to +32767 format again
  4405 00002025 66AB                    	stosw 		; interpolated sample 3 (R)
  4406 00002027 C3                      	retn
  4407                                  
  4408                                  ; 13/11/2023
  4409                                  previous_val:
  4410 00002028 0000                    previous_val_l: dw 0
  4411 0000202A 0000                    previous_val_r: dw 0
  4412                                  next_val:
  4413 0000202C 0000                    next_val_l: dw 0
  4414 0000202E 0000                    next_val_r: dw 0
  4415                                  
  4416                                  ; 16/11/2023
  4417 00002030 00                      faz:	db 0	
  4418                                  	
  4419                                  ; --------------------------------------------------------
  4420                                  ; 27/05/2024 - (TRDOS 386 Kernel) audio.s
  4421                                  ; --------------------------------------------------------
  4422                                  
  4423                                  NOT_PCI32_PCI16	EQU 03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
  4424                                  NOT_BIT31 EQU 7FFFFFFFh
  4425                                  
  4426                                  pciFindDevice:
  4427                                  	; 19/11/2023
  4428                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  4429                                  	;
  4430                                  	; scan through PCI space looking for a device+vendor ID
  4431                                  	;
  4432                                  	; Entry: EAX=Device+Vendor ID
  4433                                  	;
  4434                                  	; Exit: EAX=PCI address if device found
  4435                                  	;	EDX=Device+Vendor ID
  4436                                  	;       CY clear if found, set if not found. EAX invalid if CY set.
  4437                                  	;
  4438                                  	; Destroys: ebx, edi ; 19/11/2023
  4439                                  
  4440                                          ; 19/11/2023
  4441 00002031 89C3                    	mov	ebx, eax
  4442 00002033 BF00000080              	mov	edi, 80000000h
  4443                                  nextPCIdevice:
  4444 00002038 89F8                    	mov 	eax, edi		; read PCI registers
  4445 0000203A E88C000000              	call	pciRegRead32
  4446                                  	; 19/11/2023
  4447 0000203F 39DA                    	cmp	edx, ebx
  4448 00002041 7412                    	je	short PCIScanExit	; found
  4449                                  	; 19/11/2023
  4450 00002043 81FF00F8FF80            	cmp	edi, 80FFF800h
  4451 00002049 7308                    	jnb	short pfd_nf		; not found
  4452 0000204B 81C700010000            	add	edi, 100h
  4453 00002051 EBE5                    	jmp	short nextPCIdevice
  4454                                  pfd_nf:
  4455 00002053 F9                      	stc
  4456 00002054 C3                      	retn
  4457                                  PCIScanExit:
  4458                                  	;pushf
  4459 00002055 B8FFFFFF7F              	mov	eax, NOT_BIT31 	; 19/03/2017
  4460 0000205A 21F8                    	and	eax, edi	; return only bus/dev/fn #
  4461 0000205C C3                      	retn
  4462                                  
  4463                                  pciRegRead:
  4464                                  	; 03/04/2017 ('pci.asm', 20/03/2017)
  4465                                  	;
  4466                                  	; 8/16/32bit PCI reader
  4467                                  	;
  4468                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  4469                                  	;           BIT30 set if 32 bit access requested
  4470                                  	;           BIT29 set if 16 bit access requested
  4471                                  	;           otherwise defaults to 8 bit read
  4472                                  	;
  4473                                  	; Exit:  DL,DX,EDX register data depending on requested read size
  4474                                  	;
  4475                                  	; Note1: this routine is meant to be called via pciRegRead8,
  4476                                  	;	 pciRegread16 or pciRegRead32, listed below.
  4477                                  	;
  4478                                  	; Note2: don't attempt to read 32 bits of data from a non dword
  4479                                  	;	 aligned reg number. Likewise, don't do 16 bit reads from
  4480                                  	;	 non word aligned reg #
  4481                                  	
  4482 0000205D 53                      	push	ebx
  4483 0000205E 51                      	push	ecx
  4484 0000205F 89C3                            mov     ebx, eax		; save eax, dh
  4485 00002061 88F1                            mov     cl, dh
  4486                                  
  4487 00002063 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  4488 00002068 0D00000080                      or      eax, BIT31		; make a PCI access request
  4489 0000206D 24FC                            and     al, ~3 ; NOT 3		; force index to be dword
  4490                                  
  4491 0000206F 66BAF80C                        mov     dx, PCI_INDEX_PORT
  4492                                          ;out	dx, eax			; write PCI selector
  4493                                  	; 29/05/2024
  4494 00002073 53                      	push	ebx
  4495 00002074 89C3                    	mov	ebx, eax ; data, dword
  4496 00002076 B405                    	mov	ah, 5 ; write port, dword
  4497                                  	; dx = port number
  4498 00002078 CD34                    	int	34h
  4499 0000207A 5B                      	pop	ebx
  4500                                  	
  4501 0000207B 66BAFC0C                        mov     dx, PCI_DATA_PORT
  4502 0000207F 88D8                            mov     al, bl
  4503 00002081 2403                            and     al, 3			; figure out which port to
  4504 00002083 00C2                            add     dl, al			; read to
  4505                                  
  4506 00002085 F7C3000000C0            	test    ebx, PCI32+PCI16
  4507 0000208B 750A                            jnz     short _pregr0
  4508                                  
  4509                                  	;in	al, dx			; return 8 bits of data
  4510                                  	; 29/05/2024
  4511 0000208D B400                    	mov	ah, 0 ; read port, byte
  4512                                  	; dx = port number
  4513 0000208F CD34                    	int	34h
  4514                                          
  4515 00002091 88C2                    	mov	dl, al
  4516 00002093 88CE                    	mov     dh, cl			; restore dh for 8 bit read
  4517 00002095 EB17                    	jmp	short _pregr2
  4518                                  _pregr0:	
  4519 00002097 F7C300000080            	test    ebx, PCI32
  4520 0000209D 7509                            jnz	short _pregr1
  4521                                  
  4522                                  	;in	ax, dx
  4523                                  	; 29/05/2024
  4524 0000209F B402                    	mov	ah, 2 ; read port, word
  4525                                  	; dx = port number
  4526 000020A1 CD34                    	int	34h	        
  4527                                  
  4528 000020A3 6689C2                  	mov     dx, ax			; return 16 bits of data
  4529 000020A6 EB06                    	jmp	short _pregr2
  4530                                  _pregr1:
  4531                                  	;in	eax, dx			; return 32 bits of data
  4532                                  	; 29/05/2024
  4533 000020A8 B404                    	mov	ah, 4 ; read port, dword
  4534                                  	; dx = port number
  4535 000020AA CD34                    	int	34h
  4536                                  
  4537 000020AC 89C2                    	mov	edx, eax
  4538                                  _pregr2:
  4539 000020AE 89D8                    	mov     eax, ebx		; restore eax
  4540 000020B0 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  4541 000020B5 59                      	pop	ecx
  4542 000020B6 5B                      	pop	ebx
  4543 000020B7 C3                      	retn
  4544                                  
  4545                                  pciRegRead8:
  4546 000020B8 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
  4547 000020BD EB9E                            jmp     short pciRegRead	; call generic PCI access
  4548                                  
  4549                                  pciRegRead16:
  4550 000020BF 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
  4551 000020C4 0D00000040                      or      eax, PCI16		; call generic PCI access
  4552 000020C9 EB92                            jmp     short pciRegRead
  4553                                  
  4554                                  pciRegRead32:
  4555 000020CB 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
  4556 000020D0 0D00000080                      or      eax, PCI32		; call generic PCI access
  4557 000020D5 EB86                            jmp     pciRegRead
  4558                                  
  4559                                  pciRegWrite:
  4560                                  	; 03/04/2017 ('pci.asm', 29/11/2016)
  4561                                  	;
  4562                                  	; 8/16/32bit PCI writer
  4563                                  	;
  4564                                  	; Entry: EAX=PCI Bus/Device/fn/register number
  4565                                  	;           BIT31 set if 32 bit access requested
  4566                                  	;           BIT30 set if 16 bit access requested
  4567                                  	;           otherwise defaults to 8bit read
  4568                                  	;        DL/DX/EDX data to write depending on size
  4569                                  	;
  4570                                  	; Note1: this routine is meant to be called via pciRegWrite8, 
  4571                                  	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
  4572                                  	;
  4573                                  	; Note2: don't attempt to write 32bits of data from a non dword
  4574                                  	;	 aligned reg number. Likewise, don't do 16 bit writes from
  4575                                  	;	 non word aligned reg #
  4576                                  
  4577 000020D7 53                      	push	ebx
  4578 000020D8 51                      	push	ecx
  4579 000020D9 89C3                            mov     ebx, eax		; save eax, edx
  4580 000020DB 89D1                            mov     ecx, edx
  4581 000020DD 25FFFFFF3F              	and     eax, NOT_PCI32_PCI16	; clear out data size request
  4582 000020E2 0D00000080                      or      eax, BIT31		; make a PCI access request
  4583 000020E7 24FC                            and     al, ~3 ; NOT 3		; force index to be dword
  4584                                  
  4585 000020E9 66BAF80C                        mov     dx, PCI_INDEX_PORT
  4586                                  	;out	dx, eax			; write PCI selector
  4587                                  	; 29/05/2024
  4588 000020ED 53                      	push	ebx
  4589 000020EE 89C3                    	mov	ebx, eax ; data, dword
  4590 000020F0 B405                    	mov	ah, 5 ; write port, dword
  4591                                  	; dx = port number
  4592 000020F2 CD34                    	int	34h
  4593 000020F4 5B                      	pop	ebx
  4594                                  	
  4595 000020F5 66BAFC0C                        mov     dx, PCI_DATA_PORT
  4596 000020F9 88D8                            mov     al, bl
  4597 000020FB 2403                            and     al, 3			; figure out which port to
  4598 000020FD 00C2                            add     dl, al			; write to
  4599                                  
  4600 000020FF F7C3000000C0            	test    ebx, PCI32+PCI16
  4601 00002105 7508                            jnz     short _pregw0
  4602 00002107 88C8                    	mov	al, cl 			; put data into al
  4603                                  	;out	dx, al
  4604                                  	; 29/05/2024
  4605                                  	; al = data, byte
  4606 00002109 B401                    	mov	ah, 1 ; write port, byte
  4607                                  	; dx = port number
  4608 0000210B CD34                    	int	34h
  4609                                  
  4610 0000210D EB1F                    	jmp	short _pregw2
  4611                                  _pregw0:
  4612 0000210F F7C300000080            	test    ebx, PCI32
  4613 00002115 750D                            jnz     short _pregw1
  4614 00002117 6689C8                  	mov	ax, cx			; put data into ax
  4615                                  	;out	dx, ax
  4616                                  	; 29/05/2024
  4617 0000211A 53                      	push	ebx
  4618 0000211B 89C3                    	mov	ebx, eax ; data, word
  4619 0000211D B403                    	mov	ah, 3 ; write port, word
  4620                                  	; dx = port number
  4621 0000211F CD34                    	int	34h
  4622 00002121 5B                      	pop	ebx
  4623                                  
  4624 00002122 EB0A                    	jmp	short _pregw2
  4625                                  _pregw1:
  4626 00002124 89C8                    	mov	eax, ecx		; put data into eax
  4627                                  	;out	dx, eax
  4628                                  	; 29/05/2024
  4629 00002126 53                      	push	ebx
  4630 00002127 89C3                    	mov	ebx, eax ; data, dword
  4631 00002129 B405                    	mov	ah, 5 ; write port, dword
  4632                                  	; dx = port number
  4633 0000212B CD34                    	int	34h
  4634 0000212D 5B                      	pop	ebx
  4635                                  _pregw2:
  4636 0000212E 89D8                            mov     eax, ebx		; restore eax
  4637 00002130 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; clear out data size request
  4638 00002135 89CA                            mov     edx, ecx		; restore dx
  4639 00002137 59                      	pop	ecx
  4640 00002138 5B                      	pop	ebx
  4641 00002139 C3                      	retn
  4642                                  
  4643                                  pciRegWrite8:
  4644 0000213A 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
  4645 0000213F EB96                            jmp	short pciRegWrite	; call generic PCI access
  4646                                  
  4647                                  pciRegWrite16:
  4648 00002141 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
  4649 00002146 0D00000040                      or      eax, PCI16		; call generic PCI access
  4650 0000214B EB8A                            jmp	short pciRegWrite
  4651                                  
  4652                                  pciRegWrite32:
  4653 0000214D 25FFFFFF3F                      and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
  4654 00002152 0D00000080                      or      eax, PCI32		; call generic PCI access
  4655 00002157 E97BFFFFFF                      jmp	pciRegWrite
  4656                                  
  4657                                  ; --------------------------------------------------------
  4658                                  ; 19/05/2024 - (playwav4.asm) ac97_vra.asm
  4659                                  ; --------------------------------------------------------
  4660                                  
  4661                                  	; 13/11/2023
  4662                                  
  4663                                  ;VRA:	db 1
  4664                                  
  4665                                  codecConfig:
  4666                                  	; 29/05/2024 (playwav7.s modification)
  4667                                  	; 19/05/2024
  4668                                  	; 19/11/2023
  4669                                  	; 15/11/2023
  4670                                  	; 04/11/2023
  4671                                  	; 17/02/2017 
  4672                                  	; 07/11/2016 (Erdogan Tan)
  4673                                  
  4674                                  	;AC97_EA_VRA equ 1
  4675                                  	AC97_EA_VRA equ BIT0
  4676                                  
  4677                                  	; 04/11/2023
  4678                                  init_ac97_controller:
  4679 0000215C A1[E6280000]            	mov	eax, [bus_dev_fn]
  4680 00002161 B004                    	mov	al, PCI_CMD_REG
  4681 00002163 E857FFFFFF              	call	pciRegRead16		; read PCI command register
  4682 00002168 80CA05                  	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
  4683 0000216B E8D1FFFFFF              	call	pciRegWrite16
  4684                                  
  4685                                  	;call	delay_100ms
  4686                                  
  4687                                  	; 19/05/2024
  4688                                  	; ('PLAYMOD3.ASM', Erdogan Tan, 18/05/2024)
  4689                                  
  4690                                  init_ac97_codec:
  4691                                  	; 18/11/2023
  4692 00002170 BD28000000              	mov	ebp, 40
  4693                                  	; 29/05/2024
  4694                                  	;mov	ebp, 1000
  4695                                  _initc_1:
  4696                                  	; 29/05/2024
  4697 00002175 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  4698 00002179 660315[EC280000]        	add	dx, [NABMBAR]
  4699                                  	;in	eax, dx
  4700 00002180 B404                    	mov	ah, 4	; read port, dword
  4701 00002182 CD34                    	int	34h
  4702                                  
  4703                                  	; 19/05/2024
  4704                                  	;call	delay1_4ms
  4705                                  
  4706 00002184 83F8FF                  	cmp	eax, 0FFFFFFFFh ; -1
  4707 00002187 750A                    	jne	short _initc_3
  4708                                  _initc_2:
  4709 00002189 4D                      	dec	ebp
  4710 0000218A 7425                    	jz	short _ac97_codec_ready
  4711                                  
  4712                                  	; 31/05/2024
  4713 0000218C E8D9020000              	call	delay_100ms
  4714 00002191 EBE2                    	jmp	short _initc_1
  4715                                  _initc_3:
  4716 00002193 A900030010              	test	eax, CTRL_ST_CREADY
  4717 00002198 7517                    	jnz	short _ac97_codec_ready
  4718                                  
  4719                                  	; 30/05/2024
  4720 0000219A 803D[55250000]01        	cmp	byte [reset], 1
  4721 000021A1 73E6                    	jnb	short _initc_2
  4722                                  
  4723 000021A3 E8E6010000              	call	reset_ac97_codec
  4724                                  	; 30/05/2024
  4725 000021A8 C605[55250000]01        	mov	byte [reset], 1
  4726                                  	; 19/05/2024
  4727 000021AF EBD8                    	jmp	short _initc_2
  4728                                  
  4729                                  _ac97_codec_ready:
  4730 000021B1 668B15[EA280000]        	mov	dx, [NAMBAR]
  4731                                  	;add	dx, 0 ; ac_reg_0 ; reset register
  4732                                  	;out	dx, ax
  4733                                  	; 29/05/2024
  4734 000021B8 53                      	push	ebx
  4735 000021B9 89C3                    	mov	ebx, eax ; bx = data, word
  4736 000021BB B403                    	mov	ah, 3	; write port, word
  4737 000021BD CD34                    	int	34h
  4738 000021BF 5B                      	pop	ebx
  4739                                  
  4740                                  	; 31/05/2024
  4741                                  	; 29/05/2024
  4742                                  	;call	delay_100ms
  4743                                  
  4744                                  	; 19/11/2023
  4745 000021C0 09ED                    	or	ebp, ebp
  4746 000021C2 7539                    	jnz	short _ac97_codec_init_ok
  4747                                  
  4748 000021C4 31C0                    	xor	eax, eax ; 0
  4749 000021C6 668B15[EA280000]        	mov	dx, [NAMBAR]
  4750 000021CD 6683C226                	add	dx, CODEC_REG_POWERDOWN
  4751                                  	;out	dx, ax
  4752                                  	; 29/05/2024
  4753 000021D1 53                      	push	ebx
  4754 000021D2 89C3                    	mov	ebx, eax
  4755 000021D4 B403                    	mov	ah, 3	; write port, word
  4756 000021D6 CD34                    	int	34h
  4757 000021D8 5B                      	pop	ebx
  4758                                  	
  4759                                  	; 19/11/2023
  4760                                  	; wait for 1 second
  4761                                  	; 19/05/2024
  4762 000021D9 B9E8030000              	mov	ecx, 1000 ; 1000*4*0.25ms = 1s
  4763                                  	;;mov	ecx, 10
  4764                                  	; 30/05/2024
  4765                                  	;mov	ecx, 40
  4766                                  _ac97_codec_rloop:
  4767                                  	;call	delay_100ms
  4768                                  	; 31/05/2024
  4769 000021DE E896020000              	call	delay1_4ms
  4770                                  
  4771                                  	;mov	dx, [NAMBAR]
  4772                                  	;add	dx, CODEC_REG_POWERDOWN
  4773                                  	;in	ax, dx
  4774                                  	; 29/05/2024
  4775 000021E3 668B15[EA280000]        	mov	dx, [NAMBAR]
  4776 000021EA 6683C226                	add	dx, CODEC_REG_POWERDOWN
  4777                                  	; 31/05/2024
  4778 000021EE B402                    	mov	ah, 2	; read port, word
  4779 000021F0 CD34                    	int	34h
  4780                                  
  4781                                  	; 31/05/2024
  4782                                  	;call	delay1_4ms
  4783                                  	
  4784 000021F2 6683E00F                	and	ax, 0Fh
  4785 000021F6 3C0F                    	cmp	al, 0Fh
  4786 000021F8 7403                    	je	short _ac97_codec_init_ok
  4787 000021FA E2E2                    	loop	_ac97_codec_rloop 
  4788                                  
  4789                                  init_ac97_codec_err1:
  4790                                  	;stc	; cf = 1 ; 19/05/2024
  4791                                  init_ac97_codec_err2:
  4792 000021FC C3                      	retn
  4793                                  
  4794                                  _ac97_codec_init_ok:
  4795 000021FD E82D010000              	call 	reset_ac97_controller
  4796                                  
  4797                                  	; 31/05/2024
  4798                                  	; 30/05/2024
  4799                                  	; 19/05/2024
  4800                                  	;call	delay_100ms
  4801                                  
  4802                                  	; 30/05/2024
  4803                                  	;call	delay1_4ms
  4804                                  	;call	delay1_4ms
  4805                                  	;call	delay1_4ms
  4806                                  	;call	delay1_4ms
  4807                                  
  4808                                  setup_ac97_codec:
  4809                                  	; 12/11/2023
  4810 00002202 66813D[6E280000]80-     	cmp	word [sample_rate], 48000
  4810 0000220A BB                 
  4811 0000220B 0F84EF000000            	je	skip_rate
  4812                                  	
  4813                                  	; 31/05/2024
  4814                                  	; 30/05/2024
  4815                                  	; 29/05/2024
  4816                                  	;cmp	byte [VRA], 0
  4817                                  	;jna	short skip_rate
  4818                                  
  4819                                  	; 11/11/2023
  4820 00002211 668B15[EA280000]        	mov	dx, [NAMBAR]
  4821 00002218 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  4822                                  	;in	ax, dx
  4823                                  	; 29/05/2024
  4824 0000221C B402                    	mov	ah, 2 ; read port, word
  4825 0000221E CD34                    	int	34h
  4826                                  
  4827                                  	; 30/05/2024
  4828                                  	; 19/05/2024
  4829 00002220 E854020000              	call	delay1_4ms
  4830                                  
  4831                                  	;and	al, ~BIT1 ; Clear DRA
  4832                                  	;;;
  4833                                  	; 30/05/2024
  4834 00002225 24FC                    	and	al, ~(BIT1+BIT0) ; Clear DRA+VRA
  4835                                  	;out	dx, ax
  4836                                  	; 31/05/2024
  4837 00002227 53                      	push	ebx
  4838 00002228 89C3                    	mov	ebx, eax
  4839 0000222A 668B15[EA280000]        	mov	dx, [NAMBAR]
  4840 00002231 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  4841 00002235 B403                    	mov	ah, 3 ; write port, word
  4842 00002237 CD34                    	int	34h
  4843 00002239 5B                      	pop	ebx
  4844                                  
  4845                                  	; 31/05/2024
  4846 0000223A E804020000              	call	check_vra
  4847                                  
  4848                                  	; 31/05/2024 - temporary (interpolated sample rate test)
  4849                                  	;mov	byte [VRA], 0
  4850                                  
  4851                                  	; 05/06/2024 - temporary
  4852 0000223F 803D[71280000]00        	cmp	byte [VRA], 0
  4853 00002246 7716                    	ja	short bunugec
  4854                                  
  4855                                  	sys	_msg, burasi1, 255, 0Ch
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 00002248 BB[CD220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 0000224D B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 00002252 BA0C000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 00002257 B823000000          <1>  mov eax, %1
    89                              <1> 
    90 0000225C CD40                <1>  int 40h
  4856                                  bunugec:
  4857                                  
  4858                                  	; 31/05/2024
  4859 0000225E 803D[71280000]00        	cmp	byte [VRA], 0
  4860 00002265 0F8695000000            	jna	skip_rate ;  short olacak ; 05/06/2024
  4861                                  
  4862 0000226B 668B15[EA280000]        	mov	dx, [NAMBAR]
  4863 00002272 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  4864                                  	;in	ax, dx
  4865                                  	; 31/05/2024
  4866 00002276 B402                    	mov	ah, 2 ; read port, word
  4867 00002278 CD34                    	int	34h
  4868                                  
  4869                                  	;and	al, ~BIT1 ; Clear DRA
  4870                                  	;;;
  4871                                  
  4872 0000227A 0C01                    	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
  4873                                  	;out	dx, ax			; Enable variable rate audio
  4874                                  	; 29/05/2024
  4875 0000227C 53                      	push	ebx
  4876 0000227D 89C3                    	mov	ebx, eax
  4877                                  	;
  4878                                  	; 30/05/2024
  4879 0000227F 668B15[EA280000]        	mov	dx, [NAMBAR]
  4880 00002286 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  4881                                  	;
  4882 0000228A B403                    	mov	ah, 3 ; write port, word
  4883 0000228C CD34                    	int	34h
  4884 0000228E 5B                      	pop	ebx
  4885                                  
  4886                                  	;mov	cx, 10
  4887 0000228F B90A000000              	mov	ecx, 10 ; 30/05/2024
  4888                                  check_vra_loop:
  4889                                  	; 31/05/2024
  4890                                  	;call	delay_100ms
  4891                                  	; 30/05/2024
  4892 00002294 E8E0010000              	call	delay1_4ms
  4893                                  
  4894                                  	; 11/11/2023
  4895                                  	;in	ax, dx
  4896                                  	; 29/05/2024
  4897 00002299 668B15[EA280000]        	mov	dx, [NAMBAR]
  4898 000022A0 6683C22A                	add	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
  4899 000022A4 B402                    	mov	ah, 2 ; read port, word
  4900 000022A6 CD34                    	int	34h
  4901                                  
  4902 000022A8 A801                    	test	al, AC97_EA_VRA ; 1
  4903 000022AA 753B                    	jnz	short set_rate
  4904                                  
  4905                                  	; 11/11/2023
  4906 000022AC E2E6                    	loop	check_vra_loop
  4907                                  
  4908                                  	; 05/06/2024
  4909                                  	sys	_msg, burasi2, 255, 0Eh
    75                              <1> 
    76                              <1> 
    77                              <1> 
    78                              <1> 
    79                              <1>  %if %0 >= 2
    80 000022AE BB[DA220000]        <1>  mov ebx, %2
    81                              <1>  %if %0 >= 3
    82 000022B3 B9FF000000          <1>  mov ecx, %3
    83                              <1>  %if %0 = 4
    84 000022B8 BA0E000000          <1>  mov edx, %4
    85                              <1>  %endif
    86                              <1>  %endif
    87                              <1>  %endif
    88 000022BD B823000000          <1>  mov eax, %1
    89                              <1> 
    90 000022C2 CD40                <1>  int 40h
  4910                                  
  4911                                  
  4912                                  ;vra_not_supported:	; 19/05/2024
  4913 000022C4 C605[71280000]00        	mov	byte [VRA], 0
  4914 000022CB EB33                    	jmp	short skip_rate
  4915                                  
  4916                                  burasi1:
  4917 000022CD 0D0A                    	db 0Dh, 0Ah
  4918 000022CF 4275726173FD2031        	db "Buras 1"
  4919 000022D7 0D0A00                  	db 0Dh, 0Ah, 0
  4920                                  
  4921                                  burasi2:
  4922 000022DA 0D0A                    	db 0Dh, 0Ah
  4923 000022DC 4275726173FD2032        	db "Buras 2"
  4924 000022E4 0D0A00                  	db 0Dh, 0Ah, 0
  4925                                  
  4926                                  set_rate:
  4927 000022E7 66A1[6E280000]          	mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
  4928                                  
  4929 000022ED 668B15[EA280000]        	mov    	dx, [NAMBAR]               	
  4930 000022F4 6683C22C                	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  4931                                  	;out	dx, ax 			; PCM Front/Center Output Sample Rate
  4932                                  	; 29/05/2024
  4933 000022F8 53                      	push	ebx
  4934 000022F9 89C3                    	mov	ebx, eax  ; bx = data, word
  4935 000022FB B403                    	mov	ah, 3 ; write port, word
  4936 000022FD CD34                    	int	34h
  4937 000022FF 5B                      	pop	ebx
  4938                                  
  4939                                  	; 29/05/2024
  4940                                  	;call	delay_100ms
  4941                                  	; 30/05/2024
  4942                                  	;call	delay1_4ms
  4943                                  
  4944                                  	; 12/11/2023
  4945                                  skip_rate:
  4946 00002300 66B80202                	mov	ax, 0202h
  4947 00002304 668B15[EA280000]          	mov	dx, [NAMBAR]
  4948 0000230B 6683C202                  	add	dx, CODEC_MASTER_VOL_REG	;02h 
  4949                                  	;out	dx, ax
  4950                                  	; 29/05/2024
  4951 0000230F 53                      	push	ebx
  4952 00002310 89C3                    	mov	ebx, eax  ; bx = data, word
  4953 00002312 B403                    	mov	ah, 3 ; write port, word
  4954 00002314 CD34                    	int	34h
  4955 00002316 5B                      	pop	ebx
  4956                                  
  4957                                  	; 29/05/2024
  4958                                  	;call	delay1_4ms
  4959                                  	;call	delay1_4ms
  4960                                  	;call	delay1_4ms
  4961                                  	;call	delay1_4ms
  4962                                  
  4963 00002317 66B80202                	mov	ax, 0202h
  4964 0000231B 668B15[EA280000]          	mov	dx, [NAMBAR]
  4965 00002322 6683C218                  	add	dx, CODEC_PCM_OUT_REG		;18h 
  4966                                    	;out	dx, ax
  4967                                  	; 29/05/2024
  4968 00002326 53                      	push	ebx
  4969 00002327 89C3                    	mov	ebx, eax  ; bx = data, word
  4970 00002329 B403                    	mov	ah, 3 ; write port, word
  4971 0000232B CD34                    	int	34h
  4972 0000232D 5B                      	pop	ebx
  4973                                  
  4974                                   	; 29/05/2024
  4975                                  	;call	delay1_4ms
  4976                                  	;call	delay1_4ms
  4977                                  	;call	delay1_4ms
  4978                                  	;call	delay1_4ms
  4979                                  
  4980                                  	; 19/05/2024
  4981                                  	;clc
  4982                                  
  4983 0000232E C3                              retn
  4984                                  
  4985                                  reset_ac97_controller:
  4986                                  	; 29/05/2024 (TRDOS 386)
  4987                                  	; 19/05/2024
  4988                                  	; 11/11/2023
  4989                                  	; 10/06/2017
  4990                                  	; 29/05/2017
  4991                                  	; 28/05/2017
  4992                                  	; reset AC97 audio controller registers
  4993 0000232F 31C0                    	xor	eax, eax
  4994 00002331 66BA0B00                        mov	dx, PI_CR_REG
  4995 00002335 660315[EC280000]        	add	dx, [NABMBAR]
  4996                                  	;out	dx, al
  4997                                  	; 29/05/2024
  4998                                  	; al = data, byte
  4999 0000233C B401                    	mov	ah, 1 ; write port, byte
  5000 0000233E CD34                    	int	34h
  5001                                  
  5002                                  	; 19/05/2024
  5003                                  	;call	delay1_4ms
  5004                                  
  5005 00002340 66BA1B00                        mov     dx, PO_CR_REG
  5006 00002344 660315[EC280000]        	add	dx, [NABMBAR]
  5007                                  	;out	dx, al
  5008                                  	; 29/05/2024
  5009                                  	; al = data, byte
  5010 0000234B B401                    	mov	ah, 1 ; write port, byte
  5011 0000234D CD34                    	int	34h
  5012                                  
  5013                                  	; 19/05/2024
  5014                                  	;call	delay1_4ms
  5015                                  
  5016 0000234F 66BA2B00                        mov     dx, MC_CR_REG
  5017 00002353 660315[EC280000]        	add	dx, [NABMBAR]
  5018                                  	;out	dx, al
  5019                                  	; 29/05/2024
  5020                                  	; al = data, byte
  5021 0000235A B401                    	mov	ah, 1 ; write port, byte
  5022 0000235C CD34                    	int	34h
  5023                                  
  5024                                  	; 19/05/2024
  5025                                  	;call	delay1_4ms
  5026                                  
  5027 0000235E B002                            mov	al, RR
  5028 00002360 66BA0B00                        mov	dx, PI_CR_REG
  5029 00002364 660315[EC280000]        	add	dx, [NABMBAR]
  5030                                  	;out	dx, al
  5031                                  	; 29/05/2024
  5032                                  	; al = data, byte
  5033 0000236B B401                    	mov	ah, 1 ; write port, byte
  5034 0000236D CD34                    	int	34h
  5035                                  
  5036                                  	; 19/05/2024
  5037                                  	;call	delay1_4ms
  5038                                  
  5039 0000236F 66BA1B00                        mov	dx, PO_CR_REG
  5040 00002373 660315[EC280000]        	add	dx, [NABMBAR]
  5041                                  	;out	dx, al
  5042                                  	; 29/05/2024
  5043                                  	; al = data, byte
  5044 0000237A B401                    	mov	ah, 1 ; write port, byte
  5045 0000237C CD34                    	int	34h
  5046                                  
  5047                                  	; 19/05/2024
  5048                                  	;call	delay1_4ms
  5049                                  
  5050 0000237E 66BA2B00                        mov	dx, MC_CR_REG
  5051 00002382 660315[EC280000]        	add	dx, [NABMBAR]
  5052                                  	;out	dx, al
  5053                                  	; 29/05/2024
  5054                                  	; al = data, byte
  5055 00002389 B401                    	mov	ah, 1 ; write port, byte
  5056 0000238B CD34                    	int	34h
  5057                                  
  5058                                  	; 19/05/2024
  5059                                  	;call	delay1_4ms
  5060                                  
  5061 0000238D C3                      	retn
  5062                                  
  5063                                  reset_ac97_codec:
  5064                                  	; 29/05/2024 (TRDOS 386)
  5065                                  	; 11/11/2023
  5066                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  5067 0000238E 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  5068 00002392 660315[EC280000]        	add	dx, [NABMBAR]
  5069                                  	;in	eax, dx
  5070                                  	; 29/05/2024
  5071 00002399 B404                    	mov	ah, 4 ; read port, dword
  5072 0000239B CD34                    	int	34h
  5073                                  
  5074                                  	;test	eax, 2
  5075                                  	; 06/08/2022
  5076 0000239D A802                    	test	al, 2
  5077 0000239F 7407                    	jz	short _r_ac97codec_cold	
  5078                                  
  5079 000023A1 E80F000000              	call	warm_ac97codec_reset
  5080 000023A6 7308                    	jnc	short _r_ac97codec_ok
  5081                                  _r_ac97codec_cold:
  5082 000023A8 E845000000                      call	cold_ac97codec_reset
  5083 000023AD 7301                            jnc	short _r_ac97codec_ok
  5084                                  	
  5085                                  	; 16/04/2017
  5086                                          ;xor	eax, eax	; timeout error
  5087                                         	;stc
  5088 000023AF C3                      	retn
  5089                                  
  5090                                  _r_ac97codec_ok:
  5091 000023B0 31C0                            xor     eax, eax
  5092                                          ;mov	al, VIA_ACLINK_C00_READY ; 1
  5093 000023B2 FEC0                            inc	al
  5094 000023B4 C3                      	retn
  5095                                  
  5096                                  warm_ac97codec_reset:
  5097                                  	; 29/05/2024 (TRDOS 386)
  5098                                  	; 11/11/2023
  5099                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  5100                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  5101 000023B5 B806000000              	mov	eax, 6
  5102 000023BA 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  5103 000023BE 660315[EC280000]        	add	dx, [NABMBAR]
  5104                                  	;out	dx, eax
  5105                                  	; 29/05/2024
  5106 000023C5 53                      	push	ebx
  5107 000023C6 89C3                    	mov	ebx, eax  ; ebx = data, dword
  5108 000023C8 B405                    	mov	ah, 5 ; write port, dword
  5109 000023CA CD34                    	int	34h
  5110 000023CC 5B                      	pop	ebx
  5111                                  
  5112                                  	; 30/05/2024
  5113 000023CD B90A000000              	mov	ecx, 10	; total 1s
  5114                                  	; 29/05/2024
  5115                                  	;mov	ecx, 4000
  5116                                  _warm_ac97c_rst_wait:
  5117                                  	; 30/05/2024
  5118 000023D2 E893000000              	call	delay_100ms
  5119                                  
  5120 000023D7 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  5121 000023DB 660315[EC280000]        	add	dx, [NABMBAR]
  5122                                  	;in	eax, dx
  5123                                  	; 29/05/2024
  5124 000023E2 B404                    	mov	ah, 4 ; read port, dword
  5125 000023E4 CD34                    	int	34h
  5126                                  
  5127 000023E6 A900030010              	test	eax, CTRL_ST_CREADY
  5128 000023EB 7504                    	jnz	short _warm_ac97c_rst_ok
  5129                                  
  5130 000023ED 49                      	dec	ecx
  5131 000023EE 75E2                    	jnz	short _warm_ac97c_rst_wait
  5132                                  
  5133                                  _warm_ac97c_rst_fail:
  5134 000023F0 F9                              stc
  5135                                  _warm_ac97c_rst_ok:
  5136 000023F1 C3                      	retn
  5137                                  
  5138                                  cold_ac97codec_reset:
  5139                                  	; 11/11/2023
  5140                                  	; 06/08/2022 - TRDOS 386 v2.0.5
  5141                                  	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  5142 000023F2 B802000000                      mov	eax, 2
  5143 000023F7 66BA2C00                	mov	dx, GLOB_CNT_REG ; 2Ch
  5144 000023FB 660315[EC280000]        	add	dx, [NABMBAR]
  5145                                  	;out	dx, eax
  5146                                  	; 29/05/2024
  5147 00002402 53                      	push	ebx
  5148 00002403 89C3                    	mov	ebx, eax  ; ebx = data, dword
  5149 00002405 B405                    	mov	ah, 5 ; write port, dword
  5150 00002407 CD34                    	int	34h
  5151 00002409 5B                      	pop	ebx
  5152                                  
  5153                                  	; 30/05/2024
  5154 0000240A E85B000000              	call	delay_100ms 	; wait 100 ms
  5155 0000240F E856000000              	call	delay_100ms 	; wait 100 ms
  5156 00002414 E851000000              	call	delay_100ms 	; wait 100 ms
  5157 00002419 E84C000000              	call	delay_100ms 	; wait 100 ms
  5158                                  
  5159                                  	; 30/05/2024
  5160 0000241E B910000000              	mov	ecx, 16	; total 20*100 ms = 2s
  5161                                  	; 29/05/2024
  5162                                  	;mov	ecx, 16000
  5163                                  _cold_ac97c_rst_wait:
  5164 00002423 66BA3000                	mov	dx, GLOB_STS_REG ; 30h
  5165 00002427 660315[EC280000]        	add	dx, [NABMBAR]
  5166                                  	;in	eax, dx
  5167                                  	; 29/05/2024
  5168 0000242E B404                    	mov	ah, 4 ; read port, dword
  5169 00002430 CD34                    	int	34h
  5170                                  
  5171 00002432 A900030010              	test	eax, CTRL_ST_CREADY
  5172 00002437 7509                    	jnz	short _cold_ac97c_rst_ok
  5173                                  
  5174                                  	; 30/05/2024
  5175                                  	; 29/05/2024
  5176 00002439 E82C000000              	call	delay_100ms
  5177                                  
  5178 0000243E 49                      	dec	ecx
  5179 0000243F 75E2                    	jnz	short _cold_ac97c_rst_wait
  5180                                  
  5181                                  _cold_ac97c_rst_fail:
  5182 00002441 F9                              stc
  5183                                  _cold_ac97c_rst_ok:
  5184 00002442 C3                      	retn
  5185                                  
  5186                                  ; 30/05/2024
  5187                                  %if 1
  5188                                  check_vra:
  5189                                  	; 29/05/2024
  5190 00002443 C605[71280000]01        	mov	byte [VRA], 1
  5191                                  
  5192                                  	; 29/05/2024 - audio.s (TRDOS 386 Kernel) - 27/05/2024
  5193                                  	; 24/05/2024
  5194                                  	; 23/05/2024
  5195 0000244A 668B15[EA280000]        	mov	dx, [NAMBAR]
  5196 00002451 6683C228                	add	dx, CODEC_EXT_AUDIO_REG	; 28h
  5197                                  	;in	ax, dx
  5198                                  	; 29/05/2024
  5199 00002455 B402                    	mov	ah, 2 ; read port, word
  5200 00002457 CD34                    	int	34h
  5201                                  
  5202                                  	; 30/05/2024
  5203                                  	; 23/05/2024
  5204 00002459 E81B000000              	call	delay1_4ms
  5205                                  
  5206                                  	; 29/05/2024
  5207 0000245E A801                    	test	al, BIT0
  5208                                  	;test	al, 1 ; BIT0 ; Variable Rate Audio bit
  5209 00002460 7507                    	jnz	short check_vra_ok
  5210                                  
  5211                                  vra_not_supported:
  5212                                  	; 13/11/2023
  5213 00002462 C605[71280000]00        	mov	byte [VRA], 0
  5214                                  check_vra_ok:
  5215 00002469 C3                      	retn
  5216                                  %endif
  5217                                  
  5218                                  ; --------------------------------------------------------
  5219                                  
  5220                                  PORTB		EQU 061h
  5221                                  REFRESH_STATUS	EQU 010h	; Refresh signal status
  5222                                  
  5223                                  delay_100ms:
  5224 0000246A 51                      	push	ecx
  5225 0000246B B990010000              	mov	ecx, 400  ; 400*0.25ms
  5226                                  _delay_x_ms:
  5227 00002470 E804000000              	call	delay1_4ms
  5228 00002475 E2F9                            loop	_delay_x_ms
  5229 00002477 59                      	pop	ecx
  5230 00002478 C3                      	retn
  5231                                  
  5232                                  delay1_4ms:
  5233                                  	; 30/05/2024 (TRDOS 386)
  5234 00002479 50                              push    eax 
  5235 0000247A 51                              push    ecx
  5236 0000247B 53                      	push	ebx
  5237 0000247C 52                      	push	edx
  5238 0000247D B910000000                      mov     ecx, 16			; close enough.
  5239                                  	;in	al, PORTB
  5240                                  	; 30/05/2024
  5241 00002482 66BA6100                	mov	dx, PORTB
  5242 00002486 B400                    	mov	ah, 0  ; read port, byte
  5243 00002488 CD34                    	int	34h
  5244                                  
  5245 0000248A 2410                    	and	al, REFRESH_STATUS
  5246                                  	;mov	ah, al			; Start toggle state
  5247 0000248C 88C3                    	mov	bl, al
  5248 0000248E 09C9                    	or	ecx, ecx
  5249 00002490 7401                    	jz	short _d4ms1
  5250 00002492 41                      	inc	ecx			; Throwaway first toggle
  5251                                  _d4ms1:	
  5252                                  	;in	al, PORTB		; Read system control port
  5253                                  	; 30/05/2024
  5254 00002493 66BA6100                	mov	dx, PORTB
  5255 00002497 B400                    	mov	ah, 0  ; read port, byte
  5256 00002499 CD34                    	int	34h
  5257                                  
  5258 0000249B 2410                    	and	al, REFRESH_STATUS	; Refresh toggles 15.085 microseconds
  5259                                  	;cmp	ah, al
  5260 0000249D 38C3                    	cmp	bl, al
  5261 0000249F 74F2                    	je	short _d4ms1		; Wait for state change
  5262                                  
  5263                                  	;mov	ah, al			; Update with new state
  5264 000024A1 88C3                    	mov	bl, al
  5265 000024A3 49                      	dec	ecx
  5266 000024A4 75ED                    	jnz	short _d4ms1
  5267                                  
  5268 000024A6 5A                      	pop	edx
  5269 000024A7 5B                              pop	ebx
  5270 000024A8 59                      	pop	ecx
  5271 000024A9 58                              pop	eax
  5272 000024AA C3                              retn
  5273                                  
  5274                                  ; --------------------------------------------------------
  5275                                  ; 19/05/2024 - (playwav4.asm) ich_wav4.asm
  5276                                  ; --------------------------------------------------------
  5277                                  
  5278                                  check4keyboardstop:
  5279                                  	; 29/05/2024 (TRDOS 386)
  5280                                  	; 19/05/2024
  5281                                  	; 08/11/2023
  5282                                  	; 06/11/2023
  5283                                  	; 04/11/2023
  5284 000024AB B401                    	mov	ah, 1
  5285                                  	;int	16h
  5286 000024AD CD32                    	int	32h	; TRDOS 386
  5287                                  	;clc
  5288 000024AF 743E                    	jz	short _cksr
  5289                                  
  5290 000024B1 30E4                    	xor	ah, ah
  5291                                  	;int	16h
  5292 000024B3 CD32                    	int	32h	; TRDOS 386
  5293                                  
  5294                                  	;;;
  5295                                  	; 19/05/2024 (change PCM out volume)
  5296 000024B5 3C2B                    	cmp	al, '+'
  5297 000024B7 750D                    	jne	short p_1
  5298                                  	
  5299 000024B9 A0[50250000]            	mov	al, [volume]
  5300 000024BE 3C00                    	cmp	al, 0
  5301 000024C0 762E                    	jna	short p_3
  5302 000024C2 FEC8                    	dec	al
  5303 000024C4 EB0F                    	jmp	short p_2
  5304                                  p_1:
  5305 000024C6 3C2D                    	cmp	al, '-'
  5306 000024C8 7527                    	jne	short p_4
  5307                                  
  5308 000024CA A0[50250000]            	mov	al, [volume]
  5309 000024CF 3C1F                    	cmp	al, 31
  5310 000024D1 731D                    	jnb	short p_3
  5311 000024D3 FEC0                    	inc	al
  5312                                  p_2:
  5313 000024D5 A2[50250000]            	mov	[volume], al
  5314 000024DA 88C4                    	mov	ah, al
  5315 000024DC 668B15[EA280000]        	mov     dx, [NAMBAR]
  5316                                    	;add    dx, CODEC_MASTER_VOL_REG
  5317 000024E3 6683C218                	add	dx, CODEC_PCM_OUT_REG
  5318                                  	;out	dx, ax
  5319                                  	; 29/05/2024
  5320 000024E7 53                      	push	ebx
  5321 000024E8 89C3                    	mov	ebx, eax ; bx = data, word
  5322 000024EA B403                    	mov	ah, 3 ; write port, word
  5323 000024EC CD34                    	int	34h
  5324 000024EE 5B                      	pop	ebx
  5325                                  
  5326                                  	;call	delay1_4ms
  5327                                          ;call	delay1_4ms
  5328                                          ;call	delay1_4ms
  5329                                          ;call	delay1_4ms
  5330                                  _cksr:		; 19/05/2024
  5331 000024EF F8                      	clc
  5332                                  p_3:
  5333 000024F0 C3                      	retn
  5334                                  p_4:
  5335                                  	;;;
  5336                                  ;_cskr:	
  5337 000024F1 F9                      	stc
  5338 000024F2 C3                      	retn
  5339                                  
  5340                                  ; returns AL = current index value
  5341                                  getCurrentIndex:
  5342                                  	; 29/05/2024 (TRDOS 386)
  5343                                  	; 08/11/2023
  5344 000024F3 668B15[EC280000]        	mov	dx, [NABMBAR]
  5345 000024FA 6683C214                	add	dx, PO_CIV_REG
  5346                                  	;in	al, dx
  5347                                  	; 29/05/2024
  5348 000024FE B400                    	mov	ah, 0 ; read port, byte
  5349 00002500 CD34                    	int	34h
  5350                                  uLVI2:	;	06/11/2023
  5351 00002502 C3                      	retn
  5352                                  
  5353                                  updateLVI:
  5354                                  	; 29/05/2024 (TRDOS 386)
  5355                                  	; 08/11/2023
  5356                                  	; 07/11/2023
  5357                                  	; 06/11/2023
  5358 00002503 668B15[EC280000]        	mov	dx, [NABMBAR]
  5359 0000250A 6683C214                	add	dx, PO_CIV_REG
  5360                                  	; (Current Index Value and Last Valid Index value)
  5361                                  	;in	ax, dx
  5362                                  	; 29/05/2024
  5363 0000250E B402                    	mov	ah, 2 ; read port, word
  5364 00002510 CD34                    	int	34h
  5365                                  
  5366 00002512 38E0                    	cmp	al, ah ; is current index = last index ?
  5367 00002514 75EC                    	jne	short uLVI2
  5368                                  
  5369                                  	; 08/11/2023	
  5370 00002516 E8D8FFFFFF              	call	getCurrentIndex
  5371                                   
  5372 0000251B F605[70280000]01        	test	byte [flags], ENDOFFILE
  5373                                  	;jnz	short uLVI1
  5374 00002522 7418                    	jz	short uLVI0  ; 08/11/2023
  5375                                  
  5376                                  	; 08/11/2023
  5377 00002524 50                      	push	eax	; 29/05/2024 (32 bit)
  5378 00002525 668B15[EC280000]        	mov	dx, [NABMBAR]
  5379 0000252C 6683C216                	add	dx, PO_SR_REG  ; PCM out status register
  5380                                  	;in	ax, dx
  5381                                  	; 29/05/2024
  5382 00002530 B402                    	mov	ah, 2 ; read port, word
  5383 00002532 CD34                    	int	34h
  5384                                  
  5385 00002534 A803                    	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
  5386                                  		      ; (has been processed)
  5387                                  		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
  5388 00002536 58                      	pop	eax
  5389 00002537 7407                    	jz	short uLVI1
  5390                                  uLVI3:
  5391 00002539 31C0                    	xor	eax, eax
  5392                                  	; zf = 1
  5393 0000253B C3                      	retn
  5394                                  uLVI0:
  5395                                          ; not at the end of the file yet.
  5396 0000253C FEC8                    	dec	al
  5397 0000253E 241F                    	and	al, 1Fh
  5398                                  uLVI1:
  5399                                  	;call	setLastValidIndex
  5400                                  ;uLVI2:
  5401                                  	;retn
  5402                                  
  5403                                  ;input AL = index # to stop on
  5404                                  setLastValidIndex:
  5405                                  	; 29/05/2024 (TRDOS 386)
  5406                                  	; 08/11/2023
  5407 00002540 668B15[EC280000]        	mov	dx, [NABMBAR]
  5408 00002547 6683C215                	add	dx, PO_LVI_REG
  5409                                          ;out	dx, al
  5410                                  	; 29/05/2024
  5411                                  	; al = data, byte
  5412 0000254B B401                    	mov	ah, 1 ; write port, byte
  5413 0000254D CD34                    	int	34h
  5414 0000254F C3                      	retn
  5415                                  
  5416                                  ; 29/05/2024
  5417                                  ; 19/05/2024
  5418 00002550 02                      volume: db	02h
  5419                                  	
  5420                                  ; --------------------------------------------------------
  5421                                  
  5422                                  ; DATA
  5423                                  
  5424                                  FileHandle:	
  5425 00002551 FFFFFFFF                	dd	-1
  5426                                  
  5427                                  ; 30/05/2024
  5428 00002555 00                      reset:	db	0
  5429                                  
  5430                                  Credits:
  5431 00002556 54696E792057415620-     	db	'Tiny WAV Player for TRDOS 386 by Erdogan Tan. '
  5431 0000255F 506C6179657220666F-
  5431 00002568 72205452444F532033-
  5431 00002571 383620627920457264-
  5431 0000257A 6F67616E2054616E2E-
  5431 00002583 20                 
  5432                                  	;db	'August 2020.',10,13,0
  5433 00002584 4D617920323032342E-     	db	'May 2024.',10,13,0
  5433 0000258D 0A0D00             
  5434 00002590 31372F30362F323031-     	db	'17/06/2017', 10,13,0
  5434 00002599 370A0D00           
  5435 0000259D 31382F30382F323032-     	db	'18/08/2020', 10,13,0
  5435 000025A6 300A0D00           
  5436 000025AA 32372F31312F323032-     	db	'27/11/2023', 10,13,0
  5436 000025B3 330A0D00           
  5437 000025B7 32392F30352F323032-     	db	'29/05/2024', 10,13,0
  5437 000025C0 340A0D00           
  5438                                  
  5439                                  msgAudioCardInfo:
  5440 000025C4 666F7220496E74656C-     	db 	'for Intel AC97 (ICH) Audio Controller.', 10,13,0
  5440 000025CD 204143393720284943-
  5440 000025D6 482920417564696F20-
  5440 000025DF 436F6E74726F6C6C65-
  5440 000025E8 722E0A0D00         
  5441                                  
  5442                                  msg_usage:
  5443 000025ED 75736167653A20706C-     	db	'usage: playwav7 filename.wav',10,13,0 ; 29/05/2024
  5443 000025F6 617977617637206669-
  5443 000025FF 6C656E616D652E7761-
  5443 00002608 760A0D00           
  5444                                  
  5445                                  noDevMsg:
  5446 0000260C 4572726F723A20556E-     	db	'Error: Unable to find AC97 audio device!'
  5446 00002615 61626C6520746F2066-
  5446 0000261E 696E64204143393720-
  5446 00002627 617564696F20646576-
  5446 00002630 69636521           
  5447 00002634 0A0D00                  	db	10,13,0
  5448                                  
  5449                                  noFileErrMsg:
  5450 00002637 4572726F723A206669-     	db	'Error: file not found.',10,13,0
  5450 00002640 6C65206E6F7420666F-
  5450 00002649 756E642E0A0D00     
  5451                                  
  5452                                  msg_error:	; 29/05/2024
  5453                                  trdos386_err_msg:
  5454 00002650 5452444F5320333836-     	db	'TRDOS 386 System call error !',10,13,0
  5454 00002659 2053797374656D2063-
  5454 00002662 616C6C206572726F72-
  5454 0000266B 20210A0D00         
  5455                                  
  5456                                  ; 29/05/2024
  5457                                  ; 11/11/2023
  5458                                  msg_init_err:
  5459 00002670 0A0D                    	db	10,13
  5460 00002672 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  5460 0000267B 726F6C6C65722F436F-
  5460 00002684 64656320696E697469-
  5460 0000268D 616C697A6174696F6E-
  5460 00002696 206572726F722021   
  5461 0000269E 0A0D00                  	db	10,13,0 ; 01/06/2024
  5462                                  
  5463                                  ; 25/11/2023
  5464                                  msg_no_vra:
  5465 000026A1 0A0D                    	db	10,13
  5466 000026A3 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  5466 000026AC 70706F72742021204F-
  5466 000026B5 6E6C79203438206B48-
  5466 000026BE 5A2073616D706C6520-
  5466 000026C7 726174652073757070-
  5466 000026D0 6F727465642021     
  5467 000026D7 0A0D00                  	db	10,13,0
  5468                                  
  5469                                  ; 29/05/2024 (TRDOS 386)
  5470                                  ; 17/02/2017
  5471                                  ; Valid ICH device IDs
  5472                                  
  5473                                  valid_ids:
  5474 000026DA 86801524                dd	(ICH_DID << 16) + INTEL_VID  	 ; 8086h:2415h
  5475 000026DE 86802524                dd	(ICH0_DID << 16) + INTEL_VID 	 ; 8086h:2425h
  5476 000026E2 86804524                dd	(ICH2_DID << 16) + INTEL_VID 	 ; 8086h:2445h
  5477 000026E6 86808524                dd	(ICH3_DID << 16) + INTEL_VID 	 ; 8086h:2485h
  5478 000026EA 8680C524                dd	(ICH4_DID << 16) + INTEL_VID 	 ; 8086h:24C5h
  5479 000026EE 8680D524                dd	(ICH5_DID << 16) + INTEL_VID 	 ; 8086h:24D5h
  5480 000026F2 86806E26                dd	(ICH6_DID << 16) + INTEL_VID 	 ; 8086h:266Eh
  5481 000026F6 8680A625                dd	(ESB6300_DID << 16) + INTEL_VID  ; 8086h:25A6h
  5482 000026FA 86809826                dd	(ESB631X_DID << 16) + INTEL_VID  ; 8086h:2698h
  5483 000026FE 8680DE27                dd	(ICH7_DID << 16) + INTEL_VID 	 ; 8086h:27DEh
  5484                                  ; 03/11/2023 - Erdogan Tan
  5485 00002702 86809571                dd	(MX82440_DID << 16) + INTEL_VID  ; 8086h:7195h
  5486 00002706 39101270                dd	(SI7012_DID << 16)  + SIS_VID	 ; 1039h:7012h
  5487 0000270A DE10B101                dd 	(NFORCE_DID << 16)  + NVIDIA_VID ; 10DEh:01B1h
  5488 0000270E DE106A00                dd 	(NFORCE2_DID << 16) + NVIDIA_VID ; 10DEh:006Ah
  5489 00002712 22106D74                dd 	(AMD8111_DID << 16) + AMD_VID 	 ; 1022h:746Dh
  5490 00002716 22104574                dd 	(AMD768_DID << 16)  + AMD_VID 	 ; 1022h:7445h
  5491 0000271A DE105900                dd 	(CK804_DID << 16) + NVIDIA_VID	 ; 10DEh:0059h
  5492 0000271E DE103A00                dd 	(MCP04_DID << 16) + NVIDIA_VID	 ; 10DEh:003Ah
  5493 00002722 DE108A00                dd 	(CK8_DID << 16) + NVIDIA_VID	 ; 1022h:008Ah
  5494 00002726 DE10DA00                dd 	(NFORCE3_DID << 16) + NVIDIA_VID ; 10DEh:00DAh
  5495 0000272A DE10EA00                dd 	(CK8S_DID << 16) + NVIDIA_VID	 ; 10DEh:00EAh
  5496                                  
  5497                                  valid_id_count:	equ ($ - valid_ids)>>2 ; 05/11/2023
  5498                                  
  5499 0000272E 0D0A5741562046696C-     msgWavFileName:	db 0Dh, 0Ah, "WAV File Name: ",0
  5499 00002737 65204E616D653A2000 
  5500 00002740 0D0A53616D706C6520-     msgSampleRate:	db 0Dh, 0Ah, "Sample Rate: "
  5500 00002749 526174653A20       
  5501 0000274F 303030303020487A2C-     msgHertz:	db "00000 Hz, ", 0 
  5501 00002758 2000               
  5502 0000275A 3820626974732C2000      msg8Bits:	db "8 bits, ", 0 
  5503 00002763 4D6F6E6F0D0A00          msgMono:	db "Mono", 0Dh, 0Ah, 0
  5504 0000276A 313620626974732C20-     msg16Bits:	db "16 bits, ", 0 
  5504 00002773 00                 
  5505 00002774 53746572656F            msgStereo:	db "Stereo"
  5506 0000277A 0D0A00                  nextline:	db 0Dh, 0Ah, 0
  5507                                  
  5508                                  ; 03/06/2017
  5509 0000277D 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  5509 00002786 3941424344454600   
  5510 0000278E 0D0A                    msgAC97Info	db 0Dh, 0Ah
  5511 00002790 414339372041756469-     		db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  5511 00002799 6F20436F6E74726F6C-
  5511 000027A2 6C6572202620436F64-
  5511 000027AB 656320496E666F0D0A 
  5512 000027B4 56656E646F72204944-     		db "Vendor ID: "
  5512 000027BD 3A20               
  5513 000027BF 303030306820446576-     msgVendorId	db "0000h Device ID: "
  5513 000027C8 6963652049443A20   
  5514 000027D0 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  5515 000027D7 4275733A20              		db "Bus: "
  5516 000027DC 303068204465766963-     msgBusNo	db "00h Device: "
  5516 000027E5 653A20             
  5517 000027E8 3030682046756E6374-     msgDevNo	db "00h Function: "
  5517 000027F1 696F6E3A20         
  5518 000027F6 303068                  msgFncNo	db "00h"
  5519 000027F9 0D0A                    		db 0Dh, 0Ah
  5520 000027FB 4E414D4241523A20        		db "NAMBAR: "
  5521 00002803 30303030682020          msgNamBar	db "0000h  "
  5522 0000280A 4E41424D4241523A20      		db "NABMBAR: "
  5523 00002813 303030306820204952-     msgNabmBar	db "0000h  IRQ: "
  5523 0000281C 513A20             
  5524 0000281F 3030                    msgIRQ		dw 3030h
  5525 00002821 0D0A00                  		db 0Dh, 0Ah, 0
  5526                                  ; 25/11/2023
  5527 00002824 56524120737570706F-     msgVRAheader:	db "VRA support: "
  5527 0000282D 72743A20           
  5528 00002831 00                      		db 0	
  5529 00002832 5945530D0A00            msgVRAyes:	db "YES", 0Dh, 0Ah, 0
  5530 00002838 4E4F200D0A              msgVRAno:	db "NO ", 0Dh, 0Ah
  5531 0000283D 28496E746572706F6C-     		db "(Interpolated sample rate playing method)"
  5531 00002846 617465642073616D70-
  5531 0000284F 6C6520726174652070-
  5531 00002858 6C6179696E67206D65-
  5531 00002861 74686F6429         
  5532 00002866 0D0A00                  		db 0Dh, 0Ah, 0
  5533                                  EOF: 
  5534                                  
  5535                                  ; BSS
  5536                                  
  5537                                  bss_start:
  5538                                  
  5539                                  ABSOLUTE bss_start
  5540                                  
  5541 00002869 ??????                  alignb 4
  5542                                  
  5543 0000286C ??                      stmo:		resb 1 ; stereo or mono (1=stereo) 
  5544 0000286D ??                      bps:		resb 1 ; bits per sample (8,16)
  5545 0000286E ????                    sample_rate:	resw 1 ; Sample Frequency (Hz)
  5546                                  
  5547                                  ; 31/05/2024
  5548                                  ; 25/11/2023
  5549                                  ;bufferSize:	resd 1
  5550                                  
  5551 00002870 ??                      flags:		resb 1
  5552                                  
  5553                                  ; 29/05/2024
  5554                                  ;;cbs_busy:	resb 1
  5555                                  ;half_buff:	resb 1
  5556                                  ;srb:		resb 1
  5557                                  
  5558                                  ; 30/05/2024
  5559                                  ; 18/08/2020
  5560                                  ;volume_level:	resb 1
  5561                                  ; 25/11/2023
  5562 00002871 ??                      VRA:		resb 1	; Variable Rate Audio Support Status
  5563                                  
  5564 00002872 <res 1Ch>               smpRBuff:	resw 14 
  5565                                  
  5566                                  wav_file_name:
  5567 0000288E <res 50h>               		resb 80 ; wave file, path name (<= 80 bytes)
  5568                                  
  5569 000028DE ????                    		resw 1
  5570 000028E0 ??                      ac97_int_ln_reg: resb 1
  5571 000028E1 ??                      fbs_shift:	resb 1 ; 26/11/2023
  5572 000028E2 ????????                dev_vendor:	resd 1
  5573 000028E6 ????????                bus_dev_fn:	resd 1
  5574                                  ;ac97_NamBar:	resw 1
  5575                                  ;ac97_NabmBar:	resw 1
  5576                                  
  5577                                  ; 29/05/2024
  5578                                  ; 17/02/2017
  5579                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  5580                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  5581                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  5582                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  5583 000028EA ????                    NAMBAR:		resw 1			; BAR for mixer
  5584 000028EC ????                    NABMBAR:	resw 1			; BAR for bus master regs
  5585                                  
  5586                                  ; 29/05/2024
  5587 000028EE ????????                audio_buffer:	resd 1
  5588                                  ; 29/05/2024
  5589 000028F2 ????????                _bdl_buffer:	resd 1
  5590                                  ;wav_buffer1:	resd 1
  5591                                  ;wav_buffer2:	resd 1
  5592                                  
  5593                                  bss_end:
  5594                                  
  5595 000028F6 <res 70Ah>              alignb 4096
  5596                                  		; 256 byte buffer for descriptor list
  5597 00003000 <res 100h>              BDL_BUFFER:	resb 256
  5598                                  
  5599 00003100 <res F00h>              alignb 4096
  5600                                  
  5601                                  ;audio_buffer:	resb BUFFERSIZE ; DMA Buffer Size / 2 (32768)
  5602                                  ; 29/05/2024
  5603                                  ; 26/11/2023
  5604                                  ;audio_buffer:	resb 65536
  5605                                  ; 29/05/2024
  5606 00004000 <res 10000h>            WAVBUFFER_1:	resb 65536
  5607 00014000 <res 10000h>            WAVBUFFER_2:	resb 65536
  5608                                  ; 13/06/2017
  5609                                  ;temp_buffer:	resb BUFFERSIZE
  5610                                  ; 26/11/2023
  5611 00024000 <res 10000h>            temp_buffer:	resb 65536
