     1                                  ; ****************************************************************************
     2                                  ; PLAYWAV.ASM - ICH AC97 .wav player for DOS.			   PLAYWAV.COM
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 04/02/2025 (Previous: 19/05/2024)
     5                                  ; ----------------------------------------------------------------------------
     6                                  ; Beginning: 17/02/2017
     7                                  ; ----------------------------------------------------------------------------
     8                                  ; Assembler: NASM version 2.15
     9                                  ;	     nasm playwav.asm -l playwav.lst -o PLAYWAV.COM	
    10                                  ; ----------------------------------------------------------------------------
    11                                  ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002 
    12                                  ; ****************************************************************************
    13                                  ; Modidified from 'PLAYER.COM' for VIA VT8233 wav player source code by
    14                                  ; (PLAYER.ASM) by Erdogan Tan (07/11/2016 - 08/12/2016)
    15                                  
    16                                  ; TUNELOOP version (playing without AC97 interrupt) - 06/11/2023 - Erdogan Tan
    17                                  ; sample rate conversion version - 18/11/2023 - Erdogan Tan
    18                                  
    19                                  [BITS 16]
    20                                  
    21                                  [ORG 100h] 
    22                                  
    23                                  	%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
    24                                  
    25                                  _STARTUP:
    26                                  
    27                                  ; memory allocation
    28                                  
    29 00000000 E81D01                          call    setFree				; deallocate unused DOS mem
    30                                  
    31                                  	; 17/02/2017
    32                                  	; Clear BSS (uninitialized data) area
    33 00000003 31C0                    	xor	ax, ax ; 0
    34 00000005 B9156E                  	mov	cx, (EOF - bss_start)/2
    35 00000008 BF[411D]                	mov	di, bss_start
    36 0000000B F3AB                    	rep	stosw
    37                                  
    38                                  ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
    39                                  
    40 0000000D B81000                          mov     ax, BDL_SIZE / 16
    41 00000010 E81501                          call    memAlloc
    42 00000013 A3[661D]                        mov     [BDL_BUFFER], ax		; segment 
    43                                  
    44                                  ; allocate 2 buffers, 64k each for now.
    45                                  
    46 00000016 B80010                          mov     ax, BUFFERSIZE / 16		; 64k for .WAV file
    47 00000019 E80C01                          call    memAlloc
    48 0000001C A3[681D]                        mov     [WAV_BUFFER1], ax		; segment
    49                                  
    50 0000001F B80010                  	mov	ax, BUFFERSIZE / 16
    51 00000022 E80301                  	call	memAlloc
    52 00000025 A3[6A1D]                	mov	[WAV_BUFFER2], ax
    53                                  
    54                                  ; Detect/reset AC97 
    55                                  
    56 00000028 E87002                          call    pciFindDevice
    57 0000002B 7342                            jnc     short _1
    58                                  
    59                                  ; couldn't find the audio device!
    60                                  
    61 0000002D 0E                      	push	cs
    62 0000002E 1F                      	pop	ds
    63 0000002F BA[3900]                        mov     dx, noDevMsg
    64 00000032 B409                            mov     ah, 9
    65 00000034 CD21                            int     21h
    66 00000036 E9D700                          jmp     exit
    67                                  
    68                                  ; 17/02/2017
    69 00000039 4572726F723A20556E-     noDevMsg db "Error: Unable to find intel ICH based audio device!",CR,LF,"$"
    69 00000042 61626C6520746F2066-
    69 0000004B 696E6420696E74656C-
    69 00000054 204943482062617365-
    69 0000005D 6420617564696F2064-
    69 00000066 6576696365210D0A24 
    70                                  
    71                                  _1:
    72                                  	; eax = BUS/DEV/FN
    73                                  	;	00000000BBBBBBBBDDDDDFFF00000000
    74                                  	; edx = DEV/VENDOR
    75                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
    76                                  
    77 0000006F 66A3[6C1D]              	mov	[bus_dev_fn], eax
    78 00000073 668916[701D]            	mov	[dev_vendor], edx
    79                                  
    80                                  	; get ICH base address regs for mixer and bus master
    81                                  
    82 00000078 B010                            mov     al, NAMBAR_REG
    83 0000007A E89001                          call    pciRegRead16			; read PCI registers 10-11
    84                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
    85                                  	; 19/05/2024
    86 0000007D 80E2FE                  	and	dl, 0FEh
    87                                  
    88 00000080 8916[621D]                      mov     [NAMBAR], dx			; save audio mixer base addr
    89                                  
    90 00000084 B014                    	mov     al, NABMBAR_REG
    91 00000086 E88401                          call    pciRegRead16
    92                                          ;and    dx, IO_ADDR_MASK
    93                                  	; 19/05/2024
    94 00000089 80E2C0                  	and	dl, 0C0h
    95                                  
    96 0000008C 8916[641D]                      mov     [NABMBAR], dx			; save bus master base addr
    97                                  
    98                                  	; 06/11/2023
    99                                  	;; init controller
   100                                  	;; 17/02/2017
   101                                  	;mov	al, PCI_CMD_REG ; command register (04h)
   102                                  	;call	pciRegRead16 ; pciRegRead8
   103                                  	;
   104                                  	;; eax = BUS/DEV/FN/REG
   105                                  	;;  dx = PCI Command Register Content ; 17/02/2017
   106                                  	;; 	00000000CCCCCCCC
   107                                  	;mov	[stats_cmd], dx
   108                                  	;
   109                                  	; 06/11/2023
   110                                  	;mov	al, PCI_IO_BASE ; IO base address register (10h)
   111                                  	;call	pciRegRead32
   112                                  	;
   113                                  	;and	dx, 0FFC0h	; IO_ADDR_MASK (0FFFE) ?
   114                                          ;mov	[ac97_io_base], dx
   115                                  
   116 00000090 B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
   117 00000092 E87001                  	call	pciRegRead8 ; 17/02/2017
   118                                  
   119 00000095 8816[611D]              	mov     [ac97_int_ln_reg], dl
   120                                  
   121                                  ; 05/11/2023
   122                                  %if 0
   123                                  	; 28/11/2016
   124                                  	mov	bx, 1
   125                                  	xor	dh, dh 	 ; 17/02/2017
   126                                  	mov	cx, dx
   127                                  	shl	bx, cl
   128                                  
   129                                  	; 04/11/2023
   130                                  	cli
   131                                  
   132                                  	;not	bx
   133                                  	in	al, 0A1h ; irq 8-15
   134                                          mov	ah, al
   135                                          in	al, 21h  ; irq 0-7 
   136                                  
   137                                  	; 04/11/2023
   138                                  	; save IRQ status
   139                                  	mov	[IRQ_status], ax
   140                                  
   141                                  	;and	ax, bx   ; unmask
   142                                   	btr	ax, dx	 ; unmask
   143                                  	out	21h, al  ; enable interrupt (if irq <= 7)
   144                                  	mov	al, ah
   145                                  	out	0A1h, al ; enable interrupt (if irq > 7)
   146                                  	;not	bx
   147                                  
   148                                  	; 04/11/2023
   149                                  	;mov	dx, 4D1h			;8259 ELCR1
   150                                          ;in	al, dx
   151                                  	;mov	ah, al
   152                                  	;mov	dx, 4D0h 
   153                                          ;in	al, dx
   154                                  	;;or	ax, bx        
   155                                  	;bts	ax, cx
   156                                  	;mov	dx, 4D0h
   157                                  	;out	dx, al                          ;set level-triggered mode
   158                                  	;mov	al, ah
   159                                  	;mov	dx, 4D1h
   160                                  	;out	dx, al                          ;set level-triggered mode
   161                                  
   162                                  	; 24/11/2016 - Erdogan Tan
   163                                  	mov	bx, cx
   164                                  	;mov	bx, dx
   165                                  	mov	bl, [bx+irq_int]
   166                                  	shl	bx, 2 ; * 4
   167                                  
   168                                  	; set up interrupt vector
   169                                  	; 30/11/2016
   170                                  	push	es
   171                                  	xor	ax, ax
   172                                  	mov	es, ax
   173                                  	; 04/11/2023
   174                                  	; save interrupt vector
   175                                  	mov	ax, [es:bx]
   176                                  	mov	[IRQ_vector], ax
   177                                  	mov	ax, [es:bx+2]
   178                                  	mov	[IRQ_vector+2], ax
   179                                  
   180                                  	mov	word [es:bx], ac97_int_handler
   181                                  	mov	ax, cs
   182                                  	mov	[es:bx+2], ax
   183                                  	pop	es
   184                                  
   185                                  	; 04/11/2023
   186                                  	sti
   187                                  
   188                                  %endif
   189 00000099 E80319                  	call	write_ac97_dev_info 
   190                                  
   191                                  ; check the command line for a file to play
   192                                  
   193                                          ;push	ds
   194 0000009C E89200                          call    processCmdline			; get the filename
   195                                  
   196                                  ; open the file
   197 0000009F B002                            mov     al, OPEN                        ; open existing file
   198 000000A1 E8AD00                          call    openFile                        ; no error? ok.
   199                                          ;pop	ds
   200 000000A4 7322                            jnc     short _gsr
   201                                  
   202                                  ; file not found!
   203                                  
   204                                          ;push   cs
   205                                          ;pop    ds
   206 000000A6 BA[AF00]                        mov	dx, noFileErrMsg
   207 000000A9 B409                            mov     ah, 9
   208 000000AB CD21                            int     21h
   209 000000AD EB61                            jmp     exit
   210                                  
   211                                  noFileErrMsg:
   212 000000AF 4572726F723A206669-     	db "Error: file not found.",CR,LF,"$"
   212 000000B8 6C65206E6F7420666F-
   212 000000C1 756E642E0D0A24     
   213                                  
   214                                  _gsr:
   215 000000C8 E8AD00                          call    getSampleRate                   ; read the sample rate
   216                                                                                  ; pass it onto codec.
   217 000000CB 7243                    	jc	short exit ; 19/11/2016 - nothing to do
   218                                  
   219 000000CD A3[741D]                	mov	[sample_rate], ax
   220                                  	
   221                                  	; 19/11/2016
   222 000000D0 880E[761D]              	mov	[stmo], cl
   223 000000D4 8816[781D]              	mov	[bps], dl
   224                                  	
   225                                  	; 17/02/2017
   226 000000D8 C606[7A1D]00            	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   227 000000DD FEC9                    	dec	cl
   228 000000DF 7504                    	jnz	short _gsr_1 ; stereo
   229 000000E1 FE06[7A1D]              	inc	byte [fbs_shift] ; 1 = mono or 8 bit		
   230                                  _gsr_1:	
   231 000000E5 80FA08                  	cmp	dl, 8 
   232 000000E8 7704                    	ja	short _gsr_2 ; 16 bit samples
   233 000000EA FE06[7A1D]              	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   234                                  _gsr_2:	
   235 000000EE E8041A                  	call	write_sample_rate
   236                                  
   237                                  	; 05/11/2023
   238                                  _2:
   239 000000F1 E83507                  	call	check4keyboardstop  ; flush keyboard buffer
   240 000000F4 72FB                    	jc	short _2 	; 07/11/2023
   241                                  
   242                                  	; 05/11/2023
   243                                  	;mov	eax, [bus_dev_fn]
   244                                  	;mov	al, PCI_CMD_REG
   245                                  	;call	pciRegRead16			; read PCI command register
   246                                  	; 17/02/2017
   247                                  	;mov	dx, [stats_cmd]
   248                                          ;or	dl, IO_ENA+BM_ENA               ; enable IO and bus master
   249                                  	;call	pciRegWrite16 ; pciRegWrite8
   250                                  
   251                                  	; 19/05/2024
   252                                  	; 06/11/2023
   253                                  	;mov	eax, [bus_dev_fn]
   254                                  	;mov	al, PCI_CMD_REG
   255                                  	;call	pciRegRead8			; read PCI command register
   256                                  	;or	dl, IO_ENA+BM_ENA		; enable IO and bus master
   257                                  	;call	pciRegWrite8
   258                                  
   259                                  ; setup the Codec (actually mixer registers) 
   260 000000F6 E8E401                          call    codecConfig                     ; unmute codec, set rates.
   261                                  	; 11/11/2023
   262 000000F9 721C                    	jc	short init_err
   263                                  ;
   264                                  ; position file pointer to start in actual wav data
   265                                  ; MUCH improvement should really be done here to check if sample size is
   266                                  ; supported, make sure there are 2 channels, etc.  
   267                                  ;
   268 000000FB B442                            mov     ah, 42h
   269 000000FD B000                            mov     al, 0                           ; from start of file
   270 000000FF 8B1E[5E1D]                      mov     bx, [filehandle]
   271 00000103 31C9                            xor     cx, cx
   272 00000105 BA2C00                          mov     dx, 44                          ; jump past .wav/riff header
   273 00000108 CD21                            int     21h
   274                                  
   275                                  ; play the .wav file. Most of the good stuff is in here.
   276                                  
   277 0000010A E88503                          call    playWav
   278                                  
   279                                  ; close the .wav file and exit.
   280                                  
   281                                  close_exit:			; 11/11/2023
   282 0000010D E85300                          call    closeFile
   283                                  
   284                                  exit:
   285 00000110 B8004C                          mov     ax, 4c00h
   286 00000113 CD21                    	int 	21h
   287                                  
   288                                  here:
   289 00000115 EBFE                    	jmp	short here
   290                                  
   291                                  	; 11/11/2023
   292                                  init_err:
   293 00000117 BA[D71C]                	mov	dx, msg_init_err
   294                                  vra_err: ; 12/11/2023
   295 0000011A B409                            mov	ah, 9
   296 0000011C CD21                            int	21h
   297 0000011E EBED                    	jmp	short close_exit
   298                                  
   299                                  ; MEMALLOC.ASM
   300                                  ;-- SETFREE: Release memory not used  ----------------
   301                                  ;-- Input    : ES = address of PSP
   302                                  ;-- Output   : none
   303                                  ;-- Register : AX, BX, CL and FLAGS are changed 
   304                                  ;-- Info     : Since the stack-segment is always the last segment in an 
   305                                  ;              EXE-file, ES:0000 points to the beginning and SS:SP
   306                                  ;              to the end of the program in memory. Through this the
   307                                  ;              length of the program can be calculated 
   308                                  ; call this routine once at the beginning of the program to free up memory
   309                                  ; assigned to it by DOS.
   310                                  
   311                                  setFree:
   312 00000120 BB0010                  	  mov	bx, 65536/16	; 4K paragraphs ; 17/02/2017 (Erdogan Tan)		
   313                                  
   314 00000123 B44A                              mov	ah, 4ah		;pass new length to DOS
   315 00000125 CD21                              int	21h
   316                                  
   317 00000127 C3                                retn			; back to caller 
   318                                  				; new size (allocated memory) = 64KB
   319                                  
   320                                  memAlloc:
   321                                  ; input: AX = # of paragraphs required
   322                                  ; output: AX = segment of block to use
   323                                  
   324 00000128 53                      	push	bx
   325 00000129 89C3                    	mov	bx, ax
   326 0000012B B448                    	mov	ah, 48h
   327 0000012D CD21                    	int	21h
   328 0000012F 5B                      	pop	bx
   329 00000130 C3                      	retn
   330                                  
   331                                  ; CMDLINE.ASM
   332                                  ; parse the command line
   333                                  ; entry: none
   334                                  ; exit: DS:DX to the 1st supplied item on the command line 
   335                                  
   336                                  processCmdline:
   337 00000131 53                              push    bx
   338 00000132 56                              push    si
   339                                  
   340                                          ;mov    ah, 51h
   341                                          ;int    21h
   342                                          ;mov    ds, bx
   343                                  
   344 00000133 BE8000                          mov     si, 80h
   345 00000136 0FB61C                          movzx   bx, byte [si]
   346 00000139 01DE                            add     si, bx
   347 0000013B 46                              inc     si
   348                                  
   349 0000013C C60400                          mov     byte [si], NULL         ; zero terminate
   350                                  
   351 0000013F BE8100                          mov     si, 81h
   352                                  
   353                                  cmdlineloop:
   354 00000142 AC                              lodsb
   355                                  
   356 00000143 3C00                            cmp     al, NULL                ; found end of line?
   357 00000145 7404                            je      short exitpc
   358 00000147 3C20                            cmp     al, ' '                 ; found a space?
   359 00000149 74F7                            je      short cmdlineloop
   360                                  
   361                                          ; must be the filename here.
   362                                  exitpc:
   363 0000014B 4E                              dec     si                      ; point to start of filename
   364 0000014C 89F2                            mov     dx, si
   365 0000014E 5E                              pop     si
   366 0000014F 5B                              pop     bx
   367 00000150 C3                      	retn
   368                                  
   369                                  ; FILE.ASM
   370                                  ;open or create file
   371                                  ;
   372                                  ;input: ds:dx-->filename (asciiz)
   373                                  ;       al=file Mode (create or open)
   374                                  ;output: none  cs:[filehandle] filled
   375                                  ;
   376                                  openFile:
   377 00000151 50                      	push	ax
   378 00000152 51                      	push	cx
   379 00000153 B43B                    	mov	ah, 3bh			; start with a mode
   380 00000155 00C4                    	add	ah, al			; add in create or open mode
   381 00000157 31C9                    	xor	cx, cx
   382 00000159 CD21                    	int	21h
   383 0000015B 7203                    	jc	short _of1
   384                                  	;mov	[cs:filehandle], ax
   385 0000015D A3[5E1D]                	mov	[filehandle], ax
   386                                  _of1:
   387 00000160 59                      	pop	cx
   388 00000161 58                      	pop	ax
   389 00000162 C3                      	retn
   390                                  
   391                                  ; close the currently open file
   392                                  ; input: none, uses cs:[filehandle]
   393                                  closeFile:
   394 00000163 50                      	push	ax
   395 00000164 53                      	push	bx
   396 00000165 833E[5E1D]FF            	cmp	word [filehandle], -1
   397 0000016A 7409                    	jz	short _cf1
   398 0000016C 8B1E[5E1D]              	mov     bx, [filehandle]  
   399 00000170 B8003E                  	mov     ax,3e00h
   400 00000173 CD21                            int     21h              ;close file
   401                                  _cf1:
   402 00000175 5B                      	pop	bx
   403 00000176 58                      	pop	ax
   404 00000177 C3                      	retn
   405                                  
   406                                  getSampleRate:
   407                                  	; 08/12/2016
   408                                  ; reads the sample rate from the .wav file.
   409                                  ; entry: none - assumes file is already open
   410                                  	; 19/11/2016 - Erdogan Tan
   411                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   412                                  ;	cx = number of channels (mono=1, stereo=2)
   413                                  ;	dx = bits per sample (8, 16)
   414                                  
   415 00000178 53                      	push    bx
   416                                  
   417 00000179 B442                            mov     ah, 42h
   418 0000017B B000                            mov     al, 0				; from start of file
   419 0000017D 8B1E[5E1D]                      mov     bx, [filehandle]
   420 00000181 31C9                            xor     cx, cx
   421 00000183 BA0800                          mov     dx, 08h				; "WAVE"
   422 00000186 CD21                            int     21h
   423                                  
   424 00000188 BA[421D]                        mov     dx, smpRBuff
   425 0000018B B91C00                          mov     cx, 28				; 28 bytes
   426 0000018E B43F                    	mov	ah, 3fh
   427 00000190 CD21                            int     21h
   428                                  
   429 00000192 813E[421D]5741          	cmp	word [smpRBuff], 'WA'
   430 00000198 751C                    	jne	short gsr_stc
   431                                  
   432 0000019A 813E[441D]5645          	cmp	word [smpRBuff+2], 'VE'
   433 000001A0 7514                    	jne	short gsr_stc
   434                                  
   435 000001A2 833E[4E1D]01            	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   436 000001A7 750D                    	jne	short gsr_stc
   437                                  
   438                                  
   439 000001A9 8B0E[501D]              	mov	cx, [smpRBuff+14]	; return num of channels in CX
   440 000001AD A1[521D]                        mov     ax, [smpRBuff+16]	; return sample rate in AX
   441 000001B0 8B16[5C1D]              	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   442                                  gsr_retn:
   443 000001B4 5B                              pop     bx
   444 000001B5 C3                              retn
   445                                  
   446                                  gsr_stc:
   447 000001B6 F9                      	stc
   448 000001B7 EBFB                    	jmp	short gsr_retn
   449                                  
   450                                  ;%include 'ac97.asm' ; 29/11/2016 (AC97 codec configuration)
   451                                  %include 'ac97_vra.asm' ; 19/11/2023 (AC97 codec configuration)
     1                              <1> ; 19/05/2024
     2                              <1> ; 19/11/2023 
     3                              <1> ;	(ready status optimization -in order to prevent wrong init error- )
     4                              <1> ; 18/11/2023
     5                              <1> ; 15/11/2023
     6                              <1> ; 13/11/2023
     7                              <1> ; 12/11/2023
     8                              <1> ; 11/11/2023
     9                              <1> ; 03/11/2023 - 06/11/2023
    10                              <1> ; PCI and AC97 codec functions for wav player
    11                              <1> ; Erdogan Tan (17/02/2017)
    12                              <1> 
    13                              <1> ; ----------------------------------------------------------------------------
    14                              <1> ; PCI.ASM
    15                              <1> ; ----------------------------------------------------------------------------
    16                              <1> 
    17                              <1> ; PCI device register reader/writers.
    18                              <1> ; NASM version: Erdogan Tan (29/11/2016)
    19                              <1> ; 		Last Update: 17/02/2017
    20                              <1> 
    21                              <1> ;===============================================================
    22                              <1> ; 8/16/32bit PCI reader
    23                              <1> ;
    24                              <1> ; Entry: EAX=PCI Bus/Device/fn/register number
    25                              <1> ;           BIT30 set if 32 bit access requested
    26                              <1> ;           BIT29 set if 16 bit access requested
    27                              <1> ;           otherwise defaults to 8 bit read
    28                              <1> ;
    29                              <1> ; Exit:  DL,DX,EDX register data depending on requested read size
    30                              <1> ;
    31                              <1> ; Note: this routine is meant to be called via pciRegRead8, pciRegread16,
    32                              <1> ;	or pciRegRead32, listed below.
    33                              <1> ;
    34                              <1> ; Note2: don't attempt to read 32bits of data from a non dword aligned reg
    35                              <1> ;	 number. Likewise, don't do 16bit reads from non word aligned reg #
    36                              <1> ; 
    37                              <1> pciRegRead:
    38 000001B9 6653                <1> 	push	ebx
    39 000001BB 51                  <1> 	push	cx
    40 000001BC 6689C3              <1>         mov     ebx, eax                        ; save eax, dh
    41 000001BF 88F1                <1>         mov     cl, dh
    42 000001C1 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
    43 000001C7 660D00000080        <1>         or      eax, BIT31                      ; make a PCI access request
    44 000001CD 24FC                <1>         and     al, ~3 ; NOT 3                  ; force index to be dword
    45                              <1> 
    46 000001CF BAF80C              <1>         mov     dx, PCI_INDEX_PORT
    47 000001D2 66EF                <1>         out     dx, eax                         ; write PCI selector
    48                              <1> 
    49 000001D4 BAFC0C              <1>         mov     dx, PCI_DATA_PORT
    50 000001D7 88D8                <1>         mov     al, bl
    51 000001D9 2403                <1>         and     al, 3                           ; figure out which port to
    52 000001DB 00C2                <1>         add     dl, al                          ; read to
    53                              <1> 
    54 000001DD 66ED                <1> 	in      eax, dx                         ; do 32bit read
    55 000001DF 66F7C300000080      <1>         test    ebx, PCI32
    56 000001E6 7403                <1>         jz      short _pregr1
    57                              <1> 
    58 000001E8 6689C2              <1>         mov     edx, eax                        ; return 32bits of data
    59                              <1> _pregr1:
    60 000001EB 89C2                <1> 	mov     dx, ax                          ; return 16bits of data
    61 000001ED 66F7C3000000C0      <1>         test    ebx, PCI32+PCI16
    62 000001F4 7502                <1>         jnz     short _pregr2
    63 000001F6 88CE                <1>         mov     dh, cl                          ; restore dh for 8 bit read
    64                              <1> _pregr2:
    65 000001F8 6689D8              <1>         mov     eax, ebx                        ; restore eax
    66 000001FB 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
    67 00000201 59                  <1> 	pop	cx
    68 00000202 665B                <1> 	pop	ebx
    69 00000204 C3                  <1> 	retn
    70                              <1> 
    71                              <1> pciRegRead8:
    72 00000205 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32             ; set up 8 bit read size
    73 0000020B EBAC                <1>         jmp     short pciRegRead		; call generic PCI access
    74                              <1> 
    75                              <1> pciRegRead16:
    76 0000020D 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 16 bit read size
    77 00000213 660D00000040        <1>         or      eax, PCI16			; call generic PCI access
    78 00000219 EB9E                <1>         jmp     short pciRegRead
    79                              <1> 
    80                              <1> pciRegRead32:
    81 0000021B 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 32 bit read size
    82 00000221 660D00000080        <1>         or      eax, PCI32			; call generic PCI access
    83 00000227 EB90                <1>         jmp     short pciRegRead
    84                              <1> 
    85                              <1> ;===============================================================
    86                              <1> ; 8/16/32bit PCI writer
    87                              <1> ;
    88                              <1> ; Entry: EAX=PCI Bus/Device/fn/register number
    89                              <1> ;           BIT31 set if 32 bit access requested
    90                              <1> ;           BIT30 set if 16 bit access requested
    91                              <1> ;           otherwise defaults to 8bit read
    92                              <1> ;        DL/DX/EDX data to write depending on size
    93                              <1> ;
    94                              <1> ;
    95                              <1> ; note: this routine is meant to be called via pciRegWrite8, pciRegWrite16,
    96                              <1> ; 	or pciRegWrite32 as detailed below.
    97                              <1> ;
    98                              <1> ; Note2: don't attempt to write 32bits of data from a non dword aligned reg
    99                              <1> ;	 number. Likewise, don't do 16bit writes from non word aligned reg #
   100                              <1> ;
   101                              <1> pciRegWrite:
   102 00000229 6653                <1> 	push	ebx
   103 0000022B 51                  <1> 	push	cx
   104 0000022C 6689C3              <1>         mov     ebx, eax                        ; save eax, dx
   105 0000022F 89D1                <1>         mov     cx, dx
   106 00000231 660D00000080        <1>         or      eax, BIT31                      ; make a PCI access request
   107 00000237 6625FFFFFFBF        <1>         and     eax, ~PCI16 ; NOT PCI16         ; clear out data size request
   108 0000023D 24FC                <1>         and     al, ~3 ; NOT 3                  ; force index to be dword
   109                              <1> 
   110 0000023F BAF80C              <1>         mov     dx, PCI_INDEX_PORT
   111 00000242 66EF                <1>         out     dx, eax                         ; write PCI selector
   112                              <1> 
   113 00000244 BAFC0C              <1>         mov     dx, PCI_DATA_PORT
   114 00000247 88D8                <1>         mov     al, bl
   115 00000249 2403                <1>         and     al, 3                           ; figure out which port to
   116 0000024B 00C2                <1>         add     dl, al                          ; write to
   117                              <1> 
   118 0000024D 6689D0              <1>         mov     eax, edx                        ; put data into eax
   119 00000250 89C8                <1>         mov     ax, cx
   120                              <1> 
   121 00000252 EE                  <1>         out     dx, al
   122 00000253 66F7C3000000C0      <1>         test    ebx, PCI16+PCI32                ; only 8bit access? bail
   123 0000025A 740C                <1>         jz      short _pregw1
   124                              <1> 
   125 0000025C EF                  <1>         out     dx, ax                          ; write 16 bit value
   126 0000025D 66F7C300000040      <1>         test    ebx, PCI16                      ; 16bit requested?  bail
   127 00000264 7502                <1>         jnz     short _pregw1
   128                              <1> 
   129 00000266 66EF                <1>         out     dx, eax                         ; write full 32bit
   130                              <1> _pregw1:
   131 00000268 6689D8              <1>         mov     eax, ebx                        ; restore eax
   132 0000026B 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
   133 00000271 89CA                <1>         mov     dx, cx                          ; restore dx
   134 00000273 59                  <1> 	pop	cx
   135 00000274 665B                <1> 	pop	ebx
   136 00000276 C3                  <1> 	ret
   137                              <1> 
   138                              <1> pciRegWrite8:
   139 00000277 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 8 bit write size
   140 0000027D EBAA                <1>         jmp     short pciRegWrite		; call generic PCI access
   141                              <1> 
   142                              <1> pciRegWrite16:
   143 0000027F 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 16 bit write size
   144 00000285 660D00000040        <1>         or      eax, PCI16			; call generic PCI access
   145 0000028B EB9C                <1>         jmp     short pciRegWrite
   146                              <1> 
   147                              <1> pciRegWrite32:
   148 0000028D 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 32 bit write size
   149 00000293 660D00000080        <1>         or      eax, PCI32			; call generic PCI access
   150 00000299 EB8E                <1>         jmp     short pciRegWrite
   151                              <1> 
   152                              <1> ; 17/02/2017 (Modifed by Erdogan Tan for various ICH device IDs)
   153                              <1> ;===============================================================
   154                              <1> ; PCIFindDevice: scan through PCI space looking for a device+vendor ID
   155                              <1> ;
   156                              <1> ;  ENTRY: none
   157                              <1> ;; Entry: EAX=Device+Vendor ID
   158                              <1> ;
   159                              <1> ;  Exit: EAX=PCI address if device found
   160                              <1> ;	 EDX=Device+Vendor ID
   161                              <1> ;        CY clear if found, set if not found. EAX invalid if CY set.
   162                              <1> ;
   163                              <1> ; [old stackless] Destroys: ebx, esi, edi, cl
   164                              <1> ;
   165                              <1> pciFindDevice:
   166                              <1> 	;push	cx
   167                              <1> 	;push	eax ; *
   168                              <1> 	;push	esi
   169                              <1> 	;push	edi
   170                              <1> 
   171                              <1>  	;mov     esi, eax                ; save off vend+device ID
   172                              <1> 
   173                              <1> 	; 17/02/2017
   174 0000029B BE[9C1B]            <1> 	mov	si, valid_ids	; address of Valid ICH (AC97) Device IDs
   175 0000029E B91500              <1> 	mov	cx, valid_id_count
   176                              <1> pfd_0:
   177 000002A1 66BF00FFFF7F        <1>        	mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
   178                              <1> nextPCIdevice:
   179 000002A7 6681C700010000      <1>         add     edi, 100h
   180 000002AE 6681FF00F8FF80      <1>         cmp     edi, 80FFF800h		; scanned all devices?
   181                              <1>         ;stc
   182                              <1>         ;je 	short PCIScanExit       ; not found
   183 000002B5 720D                <1> 	jb	short pfd_1
   184 000002B7 66BF00000080        <1> 	mov     edi, 80000000h
   185 000002BD 83C604              <1> 	add	si, 4 ; scan for next device ID
   186 000002C0 E202                <1> 	loop	pfd_1	 
   187 000002C2 F9                  <1> 	stc	
   188                              <1> 	;jmp 	short PCIScanExit
   189 000002C3 C3                  <1> 	retn
   190                              <1> pfd_1:
   191 000002C4 6689F8              <1>         mov     eax, edi                ; read PCI registers
   192 000002C7 E851FF              <1>         call    pciRegRead32
   193                              <1>         ;cmp    edx, esi                ; found device?
   194 000002CA 663B14              <1>         cmp	edx, dword [si]
   195 000002CD 75D8                <1> 	jne     short nextPCIdevice
   196                              <1>         ;clc
   197                              <1> PCIScanExit:
   198                              <1> 	;pushf
   199 000002CF 66B800000080        <1> 	mov	eax, BIT31
   200 000002D5 66F7D0              <1> 	not	eax
   201 000002D8 6621F8              <1> 	and	eax, edi		; return only bus/dev/fn #
   202                              <1> 	;popf
   203                              <1> 
   204                              <1> 	;pop	edi
   205                              <1> 	;pop	esi
   206                              <1> 	;pop	edx ; *
   207                              <1> 	;pop	cx
   208 000002DB C3                  <1> 	retn
   209                              <1> 
   210                              <1> ; ----------------------------------------------------------------------------
   211                              <1> ; CODEC.ASM
   212                              <1> ; ----------------------------------------------------------------------------
   213                              <1> 
   214                              <1> ; codec configuration code. Not much here really.
   215                              <1> ; NASM version: Erdogan Tan (29/11/2016)
   216                              <1> 
   217                              <1> ; enable codec, unmute stuff, set output rate to 44.1
   218                              <1> ; entry: ax = desired sample rate
   219                              <1> 
   220                              <1> ; 19/05/2024
   221                              <1> ; 19/11/2023
   222                              <1> ; 11/11/2023
   223                              <1> ; 06/11/2023
   224                              <1> %if 1
   225                              <1> 
   226                              <1> ;	; 11/11/2023
   227                              <1> ;init_ac97_codec_err1:
   228                              <1> ;	stc
   229                              <1> ;init_ac97_codec_err2:
   230                              <1> ;	retn
   231                              <1> 
   232                              <1> 	; 13/11/2023
   233 000002DC 01                  <1> VRA:	db 1	
   234                              <1> 
   235                              <1> codecConfig:
   236                              <1> 	; 19/05/2024
   237                              <1> 	; 19/11/2023
   238                              <1> 	; 15/11/2023
   239                              <1> 	; 04/11/2023
   240                              <1> 	; 17/02/2017 
   241                              <1> 	; 07/11/2016 (Erdogan Tan)
   242                              <1> 	;PORT_NABM_GLB_CTRL_STAT equ 60h
   243                              <1> 
   244                              <1> 	; 03/11/2023 (MPXPLAY, 'SC_ICH.C', ac97_init)
   245                              <1>  	; 'AC97_DEF.H'
   246                              <1> 	;AC97_EXTENDED_STATUS equ 002Ah
   247                              <1> 	AC97_EA_SPDIF	equ 0002h
   248                              <1> 	AC97_EA_VRA	equ 0001h
   249                              <1> 	; 04/11/2023
   250                              <1> 	ICH_PO_CR_RESET equ 0002h  ; reset codec
   251                              <1> 	ICH_PCM_20BIT	equ 400000h ; 20-bit samples (ICH4)
   252                              <1> 	ICH_PCM_246_MASK equ 300000h ; 6 channels
   253                              <1> 
   254                              <1> 	; 04/11/2023
   255                              <1> init_ac97_controller:
   256 000002DD 66A1[6C1D]          <1> 	mov	eax, [bus_dev_fn]
   257 000002E1 B004                <1> 	mov	al, PCI_CMD_REG
   258 000002E3 E827FF              <1> 	call	pciRegRead16		; read PCI command register
   259 000002E6 80CA05              <1> 	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
   260 000002E9 E893FF              <1> 	call	pciRegWrite16
   261                              <1> 
   262 000002EC E89801              <1> 	call	delay_100ms
   263                              <1> 
   264                              <1> 	; 19/05/2024
   265                              <1> 	; ('PLAYMOD3.ASM', Erdogan Tan, 18/05/2024)
   266                              <1> 
   267                              <1> init_ac97_codec:
   268                              <1> 	; 18/11/2023
   269 000002EF BD2800              <1> 	mov	bp, 40
   270                              <1> _initc_1:
   271                              <1> 	; 11/11/2023
   272                              <1> 	; (TRDOS 386 v2.0.5, 'audio.s')
   273 000002F2 BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   274 000002F5 0316[641D]          <1> 	add	dx, [NABMBAR]
   275 000002F9 66ED                <1> 	in	eax, dx
   276                              <1> 
   277                              <1> 	; 19/05/2024
   278 000002FB E88116              <1> 	call	delay1_4ms
   279                              <1> 
   280                              <1> 	; ?
   281 000002FE BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   282 00000301 0316[641D]          <1> 	add	dx, [NABMBAR]
   283 00000305 66ED                <1> 	in	eax, dx
   284                              <1> 
   285                              <1> 	; 19/05/2024
   286 00000307 E87516              <1> 	call	delay1_4ms
   287                              <1> 
   288 0000030A 6683F8FF            <1> 	cmp	eax, 0FFFFFFFFh ; -1
   289 0000030E 7508                <1> 	jne	short _initc_3
   290                              <1> _initc_2:
   291                              <1> 	;dec	cx
   292 00000310 4D                  <1> 	dec	bp	; 18/11/2023
   293                              <1> 	;jz	short init_ac97_codec_err1
   294                              <1> 	; 19/11/2023
   295 00000311 7412                <1> 	jz	short _ac97_codec_ready
   296                              <1> 
   297 00000313 E87101              <1> 	call	delay_100ms
   298 00000316 EBDA                <1> 	jmp	short _initc_1
   299                              <1> _initc_3:
   300 00000318 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   301 0000031E 7505                <1> 	jnz	short _ac97_codec_ready
   302                              <1> 
   303 00000320 E8E400              <1> 	call	reset_ac97_codec
   304                              <1> 	; 15/11/2023
   305                              <1> 	;jc	short _initc_2
   306                              <1> 	; 19/05/2024
   307 00000323 EBEB                <1> 	jmp	short _initc_2
   308                              <1> 
   309                              <1> _ac97_codec_ready:
   310 00000325 8B16[621D]          <1> 	mov	dx, [NAMBAR]
   311                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
   312 00000329 EF                  <1> 	out	dx, ax
   313                              <1> 
   314 0000032A E85A01              <1> 	call	delay_100ms
   315                              <1> 
   316                              <1> 	; 19/11/2023
   317 0000032D 09ED                <1> 	or	bp, bp
   318 0000032F 751F                <1> 	jnz	short _ac97_codec_init_ok
   319                              <1> 
   320 00000331 6631C0              <1> 	xor	eax, eax ; 0
   321 00000334 8B16[621D]          <1> 	mov	dx, [NAMBAR]
   322 00000338 83C226              <1> 	add	dx, CODEC_REG_POWERDOWN
   323 0000033B EF                  <1> 	out	dx, ax
   324                              <1> 	
   325                              <1> 	; 19/11/2023
   326                              <1> 	; wait for 1 second
   327                              <1> 	; 19/05/2024
   328                              <1> 	;mov	ecx, 1000 ; 1000*4*0.25ms = 1s
   329                              <1> 	;mov	cx, 10
   330 0000033C B92800              <1> 	mov	cx, 40
   331                              <1> _ac97_codec_rloop:
   332                              <1> 	;call	delay1_4ms
   333                              <1> 	;call	delay1_4ms
   334                              <1> 	;call	delay1_4ms
   335                              <1> 	;call	delay1_4ms
   336 0000033F E84501              <1> 	call	delay_100ms
   337                              <1> 
   338                              <1> 	;mov	dx, [NAMBAR]
   339                              <1> 	;add	dx, CODEC_REG_POWERDOWN
   340 00000342 ED                  <1> 	in	ax, dx
   341                              <1> 
   342 00000343 E83916              <1> 	call	delay1_4ms
   343                              <1> 	
   344 00000346 83E00F              <1> 	and	ax, 0Fh
   345 00000349 3C0F                <1> 	cmp	al, 0Fh
   346 0000034B 7403                <1> 	je	short _ac97_codec_init_ok
   347 0000034D E2F0                <1> 	loop	_ac97_codec_rloop 
   348                              <1> 
   349                              <1> init_ac97_codec_err1:
   350                              <1> 	;stc	; cf = 1 ; 19/05/2024
   351                              <1> init_ac97_codec_err2:
   352 0000034F C3                  <1> 	retn
   353                              <1> 
   354                              <1> _ac97_codec_init_ok:
   355                              <1>         ; 11/11/2023
   356                              <1> 	;mov	al, 2 ; force set 16-bit 2-channel PCM
   357                              <1> 	;mov	dx, GLOB_CNT_REG ; 2Ch
   358                              <1> 	;add	dx, [NABMBAR]
   359                              <1> 	;out	dx, eax
   360                              <1> 
   361                              <1> 	;;call	delay1_4ms
   362                              <1> 
   363 00000350 E86D00              <1> 	call 	reset_ac97_controller
   364                              <1> 
   365                              <1> 	; 11/11/2023
   366                              <1> 	;call	delay1_4ms
   367                              <1> 	; 19/05/2024
   368 00000353 E83101              <1> 	call	delay_100ms
   369                              <1> 
   370                              <1> 	;call 	setup_ac97_codec
   371                              <1> 
   372                              <1> setup_ac97_codec:
   373                              <1> 	; 12/11/2023
   374 00000356 813E[741D]80BB      <1> 	cmp	word [sample_rate], 48000
   375 0000035C 7435                <1> 	je	short skip_rate
   376                              <1> 
   377                              <1> ; 11/11/2023
   378                              <1> ; 05/11/2023
   379                              <1> ;%if 1
   380                              <1> 	AC97_EA_VRA equ BIT0 ; 11/11/2023
   381                              <1> 
   382                              <1> 	; 19/05/2024
   383 0000035E E81E16              <1> 	call	delay1_4ms
   384                              <1> 
   385                              <1> 	;; 19/05/2024
   386                              <1> 	;;mov	dx, [NAMBAR]
   387                              <1> 	;;add	dx, CODEC_EXT_AUDIO_REG	; 28h
   388                              <1> 	;;in	ax, dx
   389                              <1> 	;
   390                              <1> 	;; 19/05/2024
   391                              <1> 	;;test	al, 1 ; BIT0 ; Variable Rate Audio bit
   392                              <1> 	;;jz	short vra_not_supported
   393                              <1> 	;
   394                              <1> 	;; 19/05/2024
   395                              <1> 	;;call	delay1_4ms
   396                              <1> 
   397                              <1> 	; 11/11/2023
   398 00000361 8B16[621D]          <1> 	mov    	dx, [NAMBAR]
   399 00000365 83C22A              <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
   400 00000368 ED                  <1> 	in     	ax, dx
   401                              <1> 
   402                              <1> 	; 19/05/2024
   403 00000369 E81316              <1> 	call	delay1_4ms
   404                              <1> 	
   405 0000036C 24FD                <1> 	and	al, ~BIT1 ; Clear DRA
   406 0000036E 0C01                <1> 	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
   407 00000370 EF                  <1> 	out	dx, ax			; Enable variable rate audio
   408                              <1> 	
   409 00000371 B90A00              <1> 	mov	cx, 10
   410                              <1> check_vra:
   411 00000374 E81001              <1> 	call	delay_100ms
   412                              <1> 
   413                              <1> 	; 11/11/2023
   414 00000377 ED                  <1> 	in	ax, dx
   415 00000378 A801                <1> 	test	al, AC97_EA_VRA ; 1
   416 0000037A 7509                <1> 	jnz	short set_rate
   417                              <1> 
   418                              <1> 	; 11/11/2023
   419 0000037C E2F6                <1> 	loop	check_vra
   420                              <1> 
   421                              <1> ;vra_not_supported:	; 19/05/2024
   422                              <1> 	; 13/11/2023
   423 0000037E C606[DC02]00        <1> 	mov	byte [VRA], 0
   424 00000383 EB0E                <1> 	jmp	short skip_rate	
   425                              <1> 
   426                              <1> 	; 19/05/2024
   427                              <1> ;;vra_not_supported:
   428                              <1> 	; 12/11/2023
   429                              <1> 	;pop	ax ; discard return address to the caller
   430                              <1> 	;mov	dx, msg_no_vra
   431                              <1> 	;jmp	vra_err
   432                              <1> 
   433                              <1> set_rate:
   434 00000385 A1[741D]            <1> 	mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
   435                              <1> 
   436 00000388 8B16[621D]          <1> 	mov    	dx, [NAMBAR]               	
   437 0000038C 83C22C              <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
   438 0000038F EF                  <1> 	out	dx, ax 			; PCM Front/Center Output Sample Rate
   439                              <1> 
   440 00000390 E8F400              <1> 	call	delay_100ms
   441                              <1> 
   442                              <1> 	; 12/11/2023
   443                              <1> skip_rate:
   444                              <1> 	; 11/11/2023 (temporary)
   445                              <1> 
   446                              <1> 	;mov   	dx, [NAMBAR]               	
   447                              <1> 	;add   	dx, CODEC_PCM_SURND_DACRATE_REG	; 2Eh  	  
   448                              <1> 	;out	dx, ax 			; PCM Surround Output Sample Rate
   449                              <1> 
   450                              <1> 	;call	delay_100ms
   451                              <1> 
   452                              <1> 	;mov   	dx, [NAMBAR]               	
   453                              <1> 	;add   	dx, CODEC_PCM_LFE_DACRATE_REG	; 30h  	  
   454                              <1> 	;out	dx, ax 			; PCM LFE Output Sample Rate
   455                              <1> 
   456                              <1> 	;call	delay_100ms
   457                              <1> 
   458                              <1> 	; 05/11/2023 (temporary)
   459                              <1> 	;mov	dx, [NAMBAR]               	
   460                              <1> 	;add	dx, CODEC_LR_ADCRATE_REG 	; 32h  	  
   461                              <1> 	;out	dx, ax 			; PCM Input Sample Rate
   462                              <1> 	;
   463                              <1> 	;call	delay_100ms
   464                              <1> 
   465 00000393 B80202              <1> 	mov	ax, 0202h
   466 00000396 8B16[621D]          <1>   	mov     dx, [NAMBAR]
   467 0000039A 83C202              <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
   468 0000039D EF                  <1> 	out     dx, ax
   469                              <1> 
   470                              <1> 	; 11/11/2023
   471                              <1>         ;call	delay1_4ms
   472                              <1>         ;call	delay1_4ms
   473                              <1>         ;call	delay1_4ms
   474                              <1>         ;call	delay1_4ms
   475                              <1>  	;
   476                              <1>   	;mov	dx, [NAMBAR]
   477                              <1>   	;add	dx, CODEC_MASTER_MONO_VOL_REG	;06h 
   478                              <1>   	;out	dx, ax
   479                              <1> 
   480                              <1> 	; 11/11/2023
   481                              <1>         ;call	delay1_4ms
   482                              <1>         ;call	delay1_4ms
   483                              <1>         ;call	delay1_4ms
   484                              <1>         ;call	delay1_4ms
   485                              <1> 	;
   486                              <1> 	;mov	ax, 02h
   487                              <1>   	;mov	dx, [NAMBAR]
   488                              <1>   	;add	dx, CODEC_PCBEEP_VOL_REG	;0Ah 
   489                              <1>   	;out	dx, ax
   490                              <1> 
   491 0000039E E8DE15              <1>         call    delay1_4ms
   492 000003A1 E8DB15              <1>         call    delay1_4ms
   493 000003A4 E8D815              <1>         call    delay1_4ms
   494 000003A7 E8D515              <1>         call    delay1_4ms
   495                              <1> 
   496                              <1> 	;mov	ax, 0202h
   497 000003AA 8B16[621D]          <1>   	mov     dx, [NAMBAR]
   498 000003AE 83C218              <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
   499 000003B1 EF                  <1>   	out     dx, ax
   500                              <1> 
   501 000003B2 E8CA15              <1>         call    delay1_4ms
   502 000003B5 E8C715              <1>         call    delay1_4ms
   503 000003B8 E8C415              <1>         call    delay1_4ms
   504 000003BB E8C115              <1>         call    delay1_4ms
   505                              <1> 
   506                              <1> 	; 11/11/2023
   507                              <1> 	;mov	ax, 8008h ; Mute
   508                              <1>   	;mov	dx, [NAMBAR]
   509                              <1> 	;add	dx, CODEC_PHONE_VOL_REG		;0Ch
   510                              <1> 	;			 ; AC97_PHONE_VOL ; TAD Input (Mono)
   511                              <1>   	;out	dx, ax
   512                              <1> 	;
   513                              <1>         ;call	delay1_4ms
   514                              <1>         ;call	delay1_4ms
   515                              <1>         ;call	delay1_4ms
   516                              <1> 	;call	delay1_4ms
   517                              <1> 
   518                              <1> 	;mov	ax, 0808h
   519                              <1> 	;mov	dx, [NAMBAR]
   520                              <1> 	;add	dx, CODEC_LINE_IN_VOL_REG ;10h ; Line Input (Stereo)
   521                              <1> 	;out	dx, ax
   522                              <1> 	;
   523                              <1>         ;call	delay1_4ms
   524                              <1>         ;call	delay1_4ms
   525                              <1>         ;call	delay1_4ms
   526                              <1> 	;call	delay1_4ms
   527                              <1> 
   528                              <1>   	;mov	dx, [NAMBAR]
   529                              <1>         ;add	dx, CODEC_CD_VOL_REG ;12h ; CD Input (Stereo)
   530                              <1>   	;out	dx, ax
   531                              <1> 	;
   532                              <1>   	;mov	dx, [NAMBAR]
   533                              <1>         ;add	dx, CODEC_AUX_VOL_REG ;16h ; Aux Input (Stereo)
   534                              <1>   	;out	dx, ax
   535                              <1> 	;
   536                              <1>         ;call	delay1_4ms
   537                              <1>         ;call	delay1_4ms
   538                              <1>         ;call	delay1_4ms
   539                              <1> 	;call	delay1_4ms
   540                              <1> 
   541                              <1> 	; 19/05/2024
   542 000003BE F8                  <1> 	clc
   543                              <1> 
   544                              <1> ;detect_ac97_codec:
   545 000003BF C3                  <1>         retn
   546                              <1> 
   547                              <1> reset_ac97_controller:
   548                              <1> 	; 19/05/2024
   549                              <1> 	; 11/11/2023
   550                              <1> 	; 10/06/2017
   551                              <1> 	; 29/05/2017
   552                              <1> 	; 28/05/2017
   553                              <1> 	; reset AC97 audio controller registers
   554 000003C0 31C0                <1> 	xor     ax, ax
   555 000003C2 BA0B00              <1>         mov	dx, PI_CR_REG
   556 000003C5 0316[641D]          <1> 	add	dx, [NABMBAR]
   557 000003C9 EE                  <1> 	out     dx, al
   558                              <1> 
   559                              <1> 	; 19/05/2024
   560 000003CA E8B215              <1> 	call	delay1_4ms
   561                              <1> 
   562 000003CD BA1B00              <1>         mov     dx, PO_CR_REG
   563 000003D0 0316[641D]          <1> 	add	dx, [NABMBAR]
   564 000003D4 EE                  <1> 	out     dx, al
   565                              <1> 
   566                              <1> 	; 19/05/2024
   567 000003D5 E8A715              <1> 	call	delay1_4ms
   568                              <1> 
   569 000003D8 BA2B00              <1>         mov     dx, MC_CR_REG
   570 000003DB 0316[641D]          <1> 	add	dx, [NABMBAR]
   571 000003DF EE                  <1> 	out     dx, al
   572                              <1> 
   573                              <1> 	; 19/05/2024
   574 000003E0 E89C15              <1> 	call	delay1_4ms
   575                              <1> 
   576 000003E3 B002                <1>         mov     al, RR
   577 000003E5 BA0B00              <1>         mov     dx, PI_CR_REG
   578 000003E8 0316[641D]          <1> 	add	dx, [NABMBAR]
   579 000003EC EE                  <1> 	out     dx, al
   580                              <1> 
   581                              <1> 	; 19/05/2024
   582 000003ED E88F15              <1> 	call	delay1_4ms
   583                              <1> 
   584 000003F0 BA1B00              <1>         mov     dx, PO_CR_REG
   585 000003F3 0316[641D]          <1> 	add	dx, [NABMBAR]
   586 000003F7 EE                  <1> 	out     dx, al
   587                              <1> 
   588                              <1> 	; 19/05/2024
   589 000003F8 E88415              <1> 	call	delay1_4ms
   590                              <1> 
   591 000003FB BA2B00              <1>         mov     dx, MC_CR_REG
   592 000003FE 0316[641D]          <1> 	add	dx, [NABMBAR]
   593 00000402 EE                  <1> 	out     dx, al
   594                              <1> 
   595                              <1> 	; 19/05/2024
   596 00000403 E87915              <1> 	call	delay1_4ms
   597                              <1> 
   598 00000406 C3                  <1> 	retn
   599                              <1> 
   600                              <1> reset_ac97_codec:
   601                              <1> 	; 11/11/2023
   602                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
   603 00000407 BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   604 0000040A 0316[641D]          <1> 	add	dx, [NABMBAR]
   605 0000040E 66ED                <1> 	in	eax, dx
   606                              <1> 
   607                              <1> 	;test	eax, 2
   608                              <1> 	; 06/08/2022
   609 00000410 A802                <1> 	test	al, 2
   610 00000412 7405                <1> 	jz	short _r_ac97codec_cold	
   611                              <1> 
   612 00000414 E80E00              <1> 	call	warm_ac97codec_reset
   613 00000417 7306                <1> 	jnc	short _r_ac97codec_ok
   614                              <1> _r_ac97codec_cold:
   615 00000419 E83400              <1>         call    cold_ac97codec_reset
   616 0000041C 7301                <1>         jnc     short _r_ac97codec_ok
   617                              <1> 	
   618                              <1> 	; 16/04/2017
   619                              <1>         ;xor	eax, eax	; timeout error
   620                              <1>        	;stc
   621 0000041E C3                  <1> 	retn
   622                              <1> 
   623                              <1> _r_ac97codec_ok:
   624 0000041F 6631C0              <1>         xor     eax, eax
   625                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
   626 00000422 FEC0                <1>         inc	al
   627 00000424 C3                  <1> 	retn
   628                              <1> 
   629                              <1> warm_ac97codec_reset:
   630                              <1> 	; 11/11/2023
   631                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   632                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
   633 00000425 66B806000000        <1> 	mov	eax, 6
   634 0000042B BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   635 0000042E 0316[641D]          <1> 	add	dx, [NABMBAR]
   636 00000432 66EF                <1> 	out	dx, eax
   637                              <1> 
   638 00000434 B90A00              <1> 	mov	cx, 10	; total 1s
   639                              <1> _warm_ac97c_rst_wait:
   640 00000437 E84D00              <1> 	call	delay_100ms
   641                              <1> 
   642 0000043A BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   643 0000043D 0316[641D]          <1> 	add	dx, [NABMBAR]
   644 00000441 66ED                <1> 	in	eax, dx
   645                              <1> 
   646 00000443 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   647 00000449 7504                <1> 	jnz	short _warm_ac97c_rst_ok
   648                              <1> 
   649 0000044B 49                  <1>         dec     cx
   650 0000044C 75E9                <1>         jnz     short _warm_ac97c_rst_wait
   651                              <1> 
   652                              <1> _warm_ac97c_rst_fail:
   653 0000044E F9                  <1>         stc
   654                              <1> _warm_ac97c_rst_ok:
   655 0000044F C3                  <1> 	retn
   656                              <1> 
   657                              <1> cold_ac97codec_reset:
   658                              <1> 	; 11/11/2023
   659                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   660                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
   661 00000450 66B802000000        <1>         mov	eax, 2
   662 00000456 BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   663 00000459 0316[641D]          <1> 	add	dx, [NABMBAR]
   664 0000045D 66EF                <1> 	out	dx, eax
   665                              <1> 
   666 0000045F E82500              <1> 	call	delay_100ms 	; wait 100 ms
   667 00000462 E82200              <1> 	call	delay_100ms 	; wait 100 ms
   668 00000465 E81F00              <1> 	call	delay_100ms 	; wait 100 ms
   669 00000468 E81C00              <1> 	call	delay_100ms 	; wait 100 ms
   670                              <1> 
   671 0000046B B91000              <1> 	mov	cx, 16	; total 20*100 ms = 2s
   672                              <1> 
   673                              <1> _cold_ac97c_rst_wait:
   674 0000046E BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   675 00000471 0316[641D]          <1> 	add	dx, [NABMBAR]
   676 00000475 66ED                <1> 	in	eax, dx
   677                              <1> 
   678 00000477 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   679 0000047D 7507                <1> 	jnz	short _cold_ac97c_rst_ok
   680                              <1> 
   681 0000047F E80500              <1> 	call	delay_100ms
   682                              <1> 
   683 00000482 49                  <1>         dec     cx
   684 00000483 75E9                <1>         jnz     short _cold_ac97c_rst_wait
   685                              <1> 
   686                              <1> _cold_ac97c_rst_fail:
   687 00000485 F9                  <1>         stc
   688                              <1> _cold_ac97c_rst_ok:
   689 00000486 C3                  <1> 	retn
   690                              <1> 
   691                              <1> delay_100ms:
   692                              <1> 	; 11/11/2023
   693                              <1> 	; 29/05/2017
   694                              <1> 	; 24/03/2017 ('codec.asm')
   695                              <1> 	; wait 100 ms
   696 00000487 51                  <1> 	push	cx
   697 00000488 B99001              <1> 	mov	cx, 400  ; 400*0.25ms
   698                              <1> _delay_x_ms:
   699 0000048B E8F114              <1> 	call	delay1_4ms
   700 0000048E E2FB                <1>         loop	_delay_x_ms
   701 00000490 59                  <1> 	pop	cx
   702 00000491 C3                  <1> 	retn
   703                              <1> 
   704                              <1> %endif
   705                              <1> 
   706                              <1> ; 11/11/2023
   707                              <1> %if 0
   708                              <1> 
   709                              <1> codecConfig:
   710                              <1> 	; 06/11/2023
   711                              <1> 	; TUNELOOP version (playing without interrupt)
   712                              <1> 	; 04/11/2023
   713                              <1> 	; 17/02/2017 
   714                              <1> 	; 07/11/2016 (Erdogan Tan)
   715                              <1> 
   716                              <1> 	mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
   717                              <1> 
   718                              <1> 	mov    	dx, [NAMBAR]               	
   719                              <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
   720                              <1> 	out	dx, ax 				; out sample rate
   721                              <1> 		
   722                              <1> 	; 05/11/2023 temp
   723                              <1> 	;mov	dx, [NAMBAR]               	
   724                              <1> 	;add	dx, CODEC_LR_ADCRATE_REG 	; 32h  	  
   725                              <1> 	;out	dx, ax 
   726                              <1> 
   727                              <1>         call    delay1_4ms
   728                              <1>         call    delay1_4ms
   729                              <1>         call    delay1_4ms
   730                              <1>         call    delay1_4ms
   731                              <1> 
   732                              <1> 	mov	eax, [dev_vendor]
   733                              <1>         cmp	eax, (SI7012_DID<<16)+SIS_VID
   734                              <1>         jne	short cConfig1
   735                              <1> 
   736                              <1> 	; Unmute quirk specifically for the SiS7012
   737                              <1> 
   738                              <1> 	CUSTOM_SIS_7012_REG equ 4Ch ; SiS7012-specific register
   739                              <1> 	
   740                              <1>         mov     dx, [NABMBAR]
   741                              <1>         add     dx, CUSTOM_SIS_7012_REG
   742                              <1>         in      ax, dx
   743                              <1>         or	al, 1
   744                              <1>         out     dx, ax
   745                              <1> 
   746                              <1> cConfig1:
   747                              <1> 	; 03/11/2023 (MPXPLAY, 'SC_ICH.C', ac97_init)
   748                              <1> 	; initial ac97 volumes (and clear mute flag)
   749                              <1> 		
   750                              <1>   	mov     dx, [NAMBAR]
   751                              <1>   	add     dx, CODEC_MASTER_VOL_REG        ;02h ; STEREO
   752                              <1>   	;xor	ax, ax ; volume attenuation = 0 (max. volume)
   753                              <1>   	; 03/11/2023
   754                              <1> 	mov	ax, 0202h
   755                              <1> 	out     dx, ax
   756                              <1> 
   757                              <1>         call    delay1_4ms	; delays because codecs are slow
   758                              <1>         call    delay1_4ms
   759                              <1>         call    delay1_4ms
   760                              <1>         call    delay1_4ms
   761                              <1>  
   762                              <1>   	mov     dx, [NAMBAR]
   763                              <1>   	add     dx, CODEC_PCM_OUT_REG		;18h
   764                              <1>   	;;xor	ax, ax
   765                              <1> 	;mov	ax, 0202h
   766                              <1>   	out     dx, ax
   767                              <1> 
   768                              <1>         call    delay1_4ms
   769                              <1>         call    delay1_4ms
   770                              <1>         call    delay1_4ms
   771                              <1>         call    delay1_4ms
   772                              <1>  
   773                              <1> 	retn
   774                              <1> 
   775                              <1> %endif
   452                                  ;%include 'ich_wav.asm' ; 17/02/2017 (ICH AC97 wav playing functions)
   453                                  %include 'ich_wav4.asm' ; 18/11/2023 (ICH AC97 wav playing functions)
     1                              <1> ; 04/02/2025
     2                              <1> ; 19/05/2024
     3                              <1> ; 18/11/2023
     4                              <1> ; 17/11/2023
     5                              <1> ; 15/11/2023 - 16/11/2023
     6                              <1> ; 13/11/2023 - 14/11/2023
     7                              <1> ; 03/11/2023 - 11/11/2023
     8                              <1> ; 03/11/2023 - 11/11/2023
     9                              <1> ; DOS based .WAV player using AC'97 and codec interface.
    10                              <1> ; ---------------------------------------------------------------
    11                              <1> ; NASM version: Erdogan Tan (29/11/2016)
    12                              <1> ; Last Update: 17/02/2017 (by Erdogan Tan)
    13                              <1> 
    14                              <1> ; TUNELOOP version (playing without interrupt) - 06/11/2023 - Erdogan Tan
    15                              <1> ; sample rate conversion version - 18/11/2023 - Erdogan Tan
    16                              <1> 
    17                              <1> ; ICHWAV.ASM
    18                              <1> 
    19                              <1> ; player internal variables and other equates.
    20                              <1> BUFFERSIZE      equ     64 * 1024       ; 64k file buffer size.
    21                              <1> ENDOFFILE       equ     BIT0            ; flag for knowing end of file
    22                              <1> 
    23                              <1> ;===========================================================================
    24                              <1> ; entry: none. File is already open and [filehandle] filled.
    25                              <1> ; exit:  not until the song is finished or the user aborts.
    26                              <1> ;
    27                              <1> playWav:
    28                              <1> 	; 18/11/2023 (ich_wav4.asm)
    29                              <1> 	; 13/11/2023 (ich_wav3.asm)
    30                              <1> 
    31 00000492 803E[DC02]01        <1> 	cmp	byte [VRA], 1
    32 00000497 720F                <1> 	jb	short chk_sample_rate
    33                              <1> playwav_48_khz:	
    34 00000499 C706[4806][2807]    <1> 	mov	word [loadfromwavfile], loadFromFile
    35                              <1> 	;mov	word [loadsize], 0 ; 65536
    36 0000049F C706[4C06]0080      <1> 	mov	word [buffersize], 32768 ; samples
    37 000004A5 E9A801              <1> 	jmp	playWav_vra
    38                              <1> 
    39                              <1> chk_sample_rate:
    40                              <1> 	; set conversion parameters
    41                              <1> 	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
    42 000004A8 A1[741D]            <1> 	mov	ax, [sample_rate]
    43 000004AB 3D80BB              <1> 	cmp	ax, 48000
    44 000004AE 74E9                <1> 	je	short playwav_48_khz
    45                              <1> chk_22khz:
    46 000004B0 3D2256              <1> 	cmp	ax, 22050
    47 000004B3 752F                <1> 	jne	short chk_11khz
    48 000004B5 803E[781D]08        <1> 	cmp	byte [bps], 8
    49 000004BA 760F                <1> 	jna	short chk_22khz_1
    50 000004BC BB[9C11]            <1> 	mov	bx, load_22khz_stereo_16_bit
    51 000004BF 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    52 000004C4 7512                <1> 	jne	short chk_22khz_2
    53 000004C6 BB[3311]            <1> 	mov	bx, load_22khz_mono_16_bit
    54 000004C9 EB0D                <1> 	jmp	short chk_22khz_2
    55                              <1> chk_22khz_1:
    56 000004CB BB[CE10]            <1> 	mov	bx, load_22khz_stereo_8_bit
    57 000004CE 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    58 000004D3 7503                <1> 	jne	short chk_22khz_2
    59 000004D5 BB[6510]            <1> 	mov	bx, load_22khz_mono_8_bit
    60                              <1> chk_22khz_2:
    61 000004D8 B85A1D              <1> 	mov	ax, 7514  ; (442*17)
    62 000004DB BA2500              <1> 	mov	dx, 37
    63 000004DE B91100              <1> 	mov	cx, 17 
    64 000004E1 E93301              <1> 	jmp	set_sizes	
    65                              <1> chk_11khz:
    66 000004E4 3D112B              <1> 	cmp	ax, 11025
    67 000004E7 752F                <1> 	jne	short chk_44khz
    68 000004E9 803E[781D]08        <1> 	cmp	byte [bps], 8
    69 000004EE 760F                <1> 	jna	short chk_11khz_1
    70 000004F0 BB[3013]            <1> 	mov	bx, load_11khz_stereo_16_bit
    71 000004F3 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    72 000004F8 7512                <1> 	jne	short chk_11khz_2
    73 000004FA BB[D512]            <1> 	mov	bx, load_11khz_mono_16_bit
    74 000004FD EB0D                <1> 	jmp	short chk_11khz_2
    75                              <1> chk_11khz_1:
    76 000004FF BB[7A12]            <1> 	mov	bx, load_11khz_stereo_8_bit
    77 00000502 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    78 00000507 7503                <1> 	jne	short chk_11khz_2
    79 00000509 BB[1C12]            <1> 	mov	bx, load_11khz_mono_8_bit
    80                              <1> chk_11khz_2:
    81 0000050C B8AD0E              <1> 	mov	ax, 3757  ; (221*17)
    82 0000050F BA4A00              <1> 	mov	dx, 74
    83 00000512 B91100              <1> 	mov	cx, 17
    84 00000515 E9FF00              <1> 	jmp	set_sizes 
    85                              <1> chk_44khz:
    86 00000518 3D44AC              <1> 	cmp	ax, 44100
    87 0000051B 752F                <1> 	jne	short chk_16khz
    88 0000051D 803E[781D]08        <1> 	cmp	byte [bps], 8
    89 00000522 760F                <1> 	jna	short chk_44khz_1
    90 00000524 BB[E114]            <1> 	mov	bx, load_44khz_stereo_16_bit
    91 00000527 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    92 0000052C 7512                <1> 	jne	short chk_44khz_2
    93 0000052E BB[8914]            <1> 	mov	bx, load_44khz_mono_16_bit
    94 00000531 EB0D                <1> 	jmp	short chk_44khz_2
    95                              <1> chk_44khz_1:
    96 00000533 BB[2B14]            <1> 	mov	bx, load_44khz_stereo_8_bit
    97 00000536 803E[761D]01        <1> 	cmp	byte [stmo], 1 
    98 0000053B 7503                <1> 	jne	short chk_44khz_2
    99 0000053D BB[CE13]            <1> 	mov	bx, load_44khz_mono_8_bit
   100                              <1> chk_44khz_2:
   101                              <1> 	;mov	ax, 15065 ; (655*23)
   102                              <1> 	; 18/11/2023 ((file size + bss + stack) <= 64KB)
   103 00000540 B8FC36              <1> 	mov	ax, 14076 ; (612 *23)
   104 00000543 BA1900              <1> 	mov	dx, 25
   105 00000546 B91700              <1> 	mov	cx, 23
   106 00000549 E9CB00              <1> 	jmp	set_sizes 
   107                              <1> chk_16khz:
   108 0000054C 3D803E              <1> 	cmp	ax, 16000
   109 0000054F 752F                <1> 	jne	short chk_8khz
   110 00000551 803E[781D]08        <1> 	cmp	byte [bps], 8
   111 00000556 760F                <1> 	jna	short chk_16khz_1
   112 00000558 BB[DD0C]            <1> 	mov	bx, load_16khz_stereo_16_bit
   113 0000055B 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   114 00000560 7512                <1> 	jne	short chk_16khz_2
   115 00000562 BB[7C0C]            <1> 	mov	bx, load_16khz_mono_16_bit
   116 00000565 EB0D                <1> 	jmp	short chk_16khz_2
   117                              <1> chk_16khz_1:
   118 00000567 BB[EC0B]            <1> 	mov	bx, load_16khz_stereo_8_bit
   119 0000056A 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   120 0000056F 7503                <1> 	jne	short chk_16khz_2
   121 00000571 BB[880B]            <1> 	mov	bx, load_16khz_mono_8_bit
   122                              <1> chk_16khz_2:
   123 00000574 B85515              <1> 	mov	ax, 5461
   124 00000577 BA0300              <1> 	mov	dx, 3
   125 0000057A B90100              <1> 	mov	cx, 1
   126 0000057D E99700              <1> 	jmp	set_sizes 
   127                              <1> chk_8khz:
   128 00000580 3D401F              <1> 	cmp	ax, 8000
   129 00000583 752E                <1> 	jne	short chk_24khz
   130 00000585 803E[781D]08        <1> 	cmp	byte [bps], 8
   131 0000058A 760F                <1> 	jna	short chk_8khz_1
   132 0000058C BB[A10A]            <1> 	mov	bx, load_8khz_stereo_16_bit
   133 0000058F 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   134 00000594 7512                <1> 	jne	short chk_8khz_2
   135 00000596 BB[100A]            <1> 	mov	bx, load_8khz_mono_16_bit
   136 00000599 EB0D                <1> 	jmp	short chk_8khz_2
   137                              <1> chk_8khz_1:
   138 0000059B BB[2009]            <1> 	mov	bx, load_8khz_stereo_8_bit
   139 0000059E 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   140 000005A3 7503                <1> 	jne	short chk_8khz_2
   141 000005A5 BB[6D08]            <1> 	mov	bx, load_8khz_mono_8_bit
   142                              <1> chk_8khz_2:
   143 000005A8 B8AA0A              <1> 	mov	ax, 2730
   144 000005AB BA0600              <1> 	mov	dx, 6
   145 000005AE B90100              <1> 	mov	cx, 1
   146 000005B1 EB64                <1> 	jmp	short set_sizes 
   147                              <1> chk_24khz:
   148 000005B3 3DC05D              <1> 	cmp	ax, 24000
   149 000005B6 752E                <1> 	jne	short chk_32khz
   150 000005B8 803E[781D]08        <1> 	cmp	byte [bps], 8
   151 000005BD 760F                <1> 	jna	short chk_24khz_1
   152 000005BF BB[750E]            <1> 	mov	bx, load_24khz_stereo_16_bit
   153 000005C2 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   154 000005C7 7512                <1> 	jne	short chk_24khz_2
   155 000005C9 BB[290E]            <1> 	mov	bx, load_24khz_mono_16_bit
   156 000005CC EB0D                <1> 	jmp	short chk_24khz_2
   157                              <1> chk_24khz_1:
   158 000005CE BB[C10D]            <1> 	mov	bx, load_24khz_stereo_8_bit
   159 000005D1 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   160 000005D6 7503                <1> 	jne	short chk_24khz_2
   161 000005D8 BB[720D]            <1> 	mov	bx, load_24khz_mono_8_bit
   162                              <1> chk_24khz_2:
   163                              <1> 	;mov	ax, 8192
   164                              <1> 	; 04/02/2025
   165 000005DB B8FE1F              <1> 	mov	ax, 8190
   166 000005DE BA0200              <1> 	mov	dx, 2
   167 000005E1 B90100              <1> 	mov	cx, 1
   168 000005E4 EB31                <1> 	jmp	short set_sizes 
   169                              <1> chk_32khz:
   170 000005E6 3D007D              <1> 	cmp	ax, 32000
   171 000005E9 7556                <1> 	jne	short vra_needed
   172 000005EB 803E[781D]08        <1> 	cmp	byte [bps], 8
   173 000005F0 760F                <1> 	jna	short chk_32khz_1
   174 000005F2 BB[FA0F]            <1> 	mov	bx, load_32khz_stereo_16_bit
   175 000005F5 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   176 000005FA 7512                <1> 	jne	short chk_32khz_2
   177 000005FC BB[AA0F]            <1> 	mov	bx, load_32khz_mono_16_bit
   178 000005FF EB0D                <1> 	jmp	short chk_32khz_2
   179                              <1> chk_32khz_1:
   180 00000601 BB[330F]            <1> 	mov	bx, load_32khz_stereo_8_bit
   181 00000604 803E[761D]01        <1> 	cmp	byte [stmo], 1 
   182 00000609 7503                <1> 	jne	short chk_32khz_2
   183 0000060B BB[DB0E]            <1> 	mov	bx, load_32khz_mono_8_bit
   184                              <1> chk_32khz_2:
   185 0000060E B8AA2A              <1> 	mov	ax, 10922
   186 00000611 BA0300              <1> 	mov	dx, 3
   187 00000614 B90200              <1> 	mov	cx, 2
   188                              <1> 	;jmp	short set_sizes 
   189                              <1> set_sizes:
   190 00000617 803E[761D]01        <1> 	cmp	byte [stmo], 1
   191 0000061C 7402                <1> 	je	short ss_1
   192 0000061E D1E0                <1> 	shl	ax, 1
   193                              <1> ss_1:
   194 00000620 803E[781D]08        <1> 	cmp	byte [bps], 8
   195 00000625 7602                <1> 	jna	short ss_2
   196                              <1> 	; 16 bit samples
   197 00000627 D1E0                <1> 	shl	ax, 1
   198                              <1> ss_2:
   199 00000629 A3[4A06]            <1> 	mov	[loadsize], ax
   200 0000062C F7E2                <1> 	mul	dx
   201                              <1> 	;cmp	cx, 1
   202                              <1> 	;je	short ss_3
   203                              <1> ;ss_3:
   204 0000062E F7F1                <1> 	div	cx
   205 00000630 8A0E[7A1D]          <1> 	mov	cl, [fbs_shift]
   206 00000634 D3E0                <1> 	shl	ax, cl
   207 00000636 D1E8                <1> 	shr	ax, 1	; buffer size is 16 bit sample count
   208 00000638 A3[4C06]            <1> 	mov	[buffersize], ax 
   209 0000063B 891E[4806]          <1> 	mov	[loadfromwavfile], bx
   210 0000063F EB0F                <1> 	jmp	short playWav_vra
   211                              <1> 
   212                              <1> vra_needed:
   213                              <1> 	; 13/11/2023
   214 00000641 58                  <1> 	pop	ax ; discard return address to the caller
   215 00000642 BA[081D]            <1> 	mov	dx, msg_no_vra
   216 00000645 E9D2FA              <1> 	jmp	vra_err
   217                              <1> 
   218                              <1> 	; 13/11/2023
   219                              <1> loadfromwavfile:
   220 00000648 [2807]              <1> 	dw	loadFromFile
   221                              <1> loadsize:	; read from wav file
   222 0000064A 0000                <1> 	dw	0
   223                              <1> buffersize:	; write to DMA buffer
   224 0000064C 00800000            <1> 	dd	32768 ; 16 bit samples (not bytes)
   225                              <1> 
   226                              <1> playWav_vra:
   227                              <1> 	; 07/11/2023
   228                              <1> 	; clear buffer 2
   229                              <1>         ;push	es
   230                              <1> 	;mov	ax, [WAV_BUFFER2]
   231                              <1> 	;mov	es, ax
   232                              <1> 	;sub	ax, ax
   233                              <1> 	;mov	di, ax ; 17/02/2017
   234                              <1> 	;mov	cx, (BUFFERSIZE/2)
   235                              <1> 	;rep	stosw
   236                              <1> 	;pop	es	     
   237                              <1> 	
   238                              <1> 	; load 64k into buffer 1
   239 00000650 A1[681D]            <1>         mov     ax, [WAV_BUFFER1]
   240                              <1>         ;call	loadFromFile
   241                              <1> 	; 13/11/2023
   242 00000653 FF16[4806]          <1> 	call	word [loadfromwavfile]
   243                              <1> 
   244                              <1> 	; and 64k into buffer 2
   245 00000657 A1[6A1D]            <1> 	mov     ax, [WAV_BUFFER2]
   246                              <1>        	;call	loadFromFile
   247                              <1> 	; 13/11/2023
   248 0000065A FF16[4806]          <1> 	call	word [loadfromwavfile]
   249                              <1> 
   250                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
   251                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
   252                              <1> ; reset.
   253                              <1> ;
   254                              <1> 	; 11/11/2023
   255                              <1>         ;mov	dx, [NABMBAR]
   256                              <1>         ;add	dx, PO_CR_REG		; set pointer to Ctrl reg
   257                              <1>         ;mov	al, RR			; set reset
   258                              <1> 	;out	dx, al			; self clearing bit
   259                              <1> 
   260                              <1> ; write last valid index to 31 to start with.
   261                              <1> ; The Last Valid Index register tells the DMA engine when to stop playing.
   262                              <1> ; 
   263                              <1> ; As we progress through the song we change the last valid index to always be
   264                              <1> ; something other than the index we're currently playing.  
   265                              <1> ;
   266                              <1> 	; 08/11/2023
   267                              <1> 	;; 07/11/2023
   268                              <1> 	;mov	al, 1
   269                              <1>         ;;mov	al, 31
   270                              <1> 	;call	setLastValidIndex
   271                              <1> 
   272                              <1> ; create Buffer Descriptor List
   273                              <1> ;
   274                              <1> ; A buffer descriptor list is a list of pointers and control bits that the
   275                              <1> ; DMA engine uses to know where to get the .wav data and how to play it.
   276                              <1> ;
   277                              <1> ; I set it up to use only 2 buffers of .wav data, and whenever 1 buffer is
   278                              <1> ; playing, I refresh the other one with good data.
   279                              <1> ;
   280                              <1> ;
   281                              <1> ; For the control bits, you can specify that the DMA engine fire an interrupt
   282                              <1> ; after a buffer has been processed, but I poll the current index register
   283                              <1> ; to know when it's safe to update the other buffer.
   284                              <1> ;
   285                              <1> ; I set the BUP bit, which tells the DMA engine to just play 0's (silence)
   286                              <1> ; if it ever runs out of data to play. Good for safety.
   287                              <1> ;
   288 0000065E 06                  <1>         push    es
   289 0000065F A1[661D]            <1>         mov     ax, [BDL_BUFFER]		; get segment # for BDL
   290 00000662 8EC0                <1>         mov     es, ax
   291                              <1> 
   292 00000664 B91000              <1>         mov     cx, 32 / 2                      ; make 32 entries in BDL
   293 00000667 31FF                <1>         xor     di, di                          
   294                              <1> _0:
   295                              <1> 
   296                              <1> ; set buffer descriptor 0 to start of data file in memory
   297 00000669 660FB706[681D]      <1>         movzx   eax, word [WAV_BUFFER1]
   298 0000066F 66C1E004            <1>         shl     eax, 4                          ; convert seg:off ->0:offset
   299 00000673 66AB                <1>         stosd                                   ; store pointer to wavbuffer1
   300                              <1> 
   301                              <1> ;
   302                              <1> ; set length to 32k samples. 1 sample is 16bits or 2bytes.
   303                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples.
   304                              <1> ; 
   305                              <1> 
   306                              <1> ; 17/02/2017 (Erdogan Tan)
   307                              <1> ; Intel® 82801AA (ICH) & Intel® 82801AB (ICH0) I/O Controller Hub AC’97
   308                              <1> ; Programmer’s Reference Manual
   309                              <1> 
   310                              <1> ; 2.2.1 Buffer Descriptor List  (on Page 13)
   311                              <1> 	;
   312                              <1> 	;  Generic Form of Buffer Descriptor
   313                              <1> 	;  ---------------------------------
   314                              <1> 	;  63   62    61-48    47-32   31-0
   315                              <1> 	;  ---  ---  --------  ------- -----
   316                              <1> 	;  IOC  BUP -reserved- Buffer  Buffer
   317                              <1> 	;		      Length   Pointer
   318                              <1> 	;		      [15:0]   [31:0]
   319                              <1> 	;
   320                              <1> 	;  IOC:	Interrupt On Completion. 
   321                              <1> 	;	1 = Enabled. 
   322                              <1> 	;	    When this is set, it means that the controller should
   323                              <1> 	;	    issue an interrupt upon completion of this buffer.
   324                              <1> 	;	    It should also set the IOC bit in the status register
   325                              <1> 	;	0 = Disabled	
   326                              <1> 	;
   327                              <1> 	;  BUP: Buffer Underrun Policy.
   328                              <1> 	;       0 = When this buffer is complete,
   329                              <1> 	;	    if the next buffer is not yet ready 
   330                              <1> 	;	    (i.e., the last valid buffer has been processed),
   331                              <1> 	;	    then continue to transmit the last valid sample.
   332                              <1> 	;	1 = When this buffer is complete,
   333                              <1> 	;     	    if this is the last valid buffer, transmit zeros after
   334                              <1> 	;	    this buffer has been processed completely.
   335                              <1> 	;	    This bit typically is set only if this is the last 
   336                              <1> 	;	    buffer in the current stream.
   337                              <1> 	;
   338                              <1> 	; [31:0]: Buffer pointer. This field points to the location of
   339                              <1> 	;	  the data buffer. Since samples can be as wide as one
   340                              <1> 	;	  word, the buffer must be aligned with word boundaries,
   341                              <1> 	;	  to prevent samples from straddling DWord boundaries.
   342                              <1> 	;
   343                              <1> 	; [15:0]: Buffer Length: This is the length of the data buffer,
   344                              <1> 	;	  in number of samples. The controller uses this data
   345                              <1> 	;	  to determine the length of the buffer, in bytes.
   346                              <1> 	;	  "0" indicates no sample to process.
   347                              <1> 
   348                              <1> ; ICH2AC97.INC
   349                              <1> 
   350                              <1> ;	IOC	equ     BIT31   ; Fire an interrupt whenever this
   351                              <1> 				; buffer is complete.
   352                              <1> 
   353                              <1> ;	BUP	equ     BIT30   ; Buffer Underrun Policy.
   354                              <1> 				; if this buffer is the last buffer
   355                              <1> 				; in a playback, fill the remaining
   356                              <1> 				; samples with 0 (silence) or not.
   357                              <1> 				; It's a good idea to set this to 1
   358                              <1> 				; for the last buffer in playback,
   359                              <1> 				; otherwise you're likely to get a lot
   360                              <1> 				; of noise at the end of the sound.
   361                              <1> ;
   362                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
   363                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
   364                              <1> ; Luckily for us, that's the same format as .wav files.
   365                              <1> ;
   366                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
   367                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
   368                              <1> ;
   369                              <1> ; A value of 0 in these bits means play no samples.
   370                              <1> ;
   371                              <1> 
   372                              <1> ; ICHWAV.ASM
   373                              <1> 				    ; 19/05/2024
   374                              <1> 	;mov	eax, BUFFERSIZE / 2 ; size of buffer (32K) in (16bit) words
   375                              <1> 	; 13/11/2023 (ich_wav3.asm) - 18/11/2023 (ich_wav4.asm)
   376 00000675 66A1[4C06]          <1> 	mov	eax, [buffersize]
   377                              <1> 
   378                              <1> 	;or	eax, IOC + BUP
   379                              <1> 	; 06/11/2023 (TUNELOOP version, without interrupt)
   380 00000679 660D00000040        <1> 	or	eax, BUP
   381 0000067F 66AB                <1> 	stosd
   382                              <1> 
   383                              <1> ; 2nd buffer:
   384                              <1> 
   385 00000681 660FB706[6A1D]      <1>         movzx   eax, word [WAV_BUFFER2]
   386 00000687 66C1E004            <1>         shl     eax, 4                          ; convert seg:off ->0:offset
   387 0000068B 66AB                <1>         stosd                                   ; store pointer to wavbuffer2
   388                              <1> 
   389                              <1> ; set length to 64k (32k of two 16 bit samples)
   390                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
   391                              <1> ; 
   392                              <1> 	;mov	eax, BUFFERSIZE / 2 ; size of half buffer (32K)
   393                              <1> 	; 13/11/2023 (ich_wav3.asm) - 18/11/2023 (ich_wav4.asm)
   394 0000068D 66A1[4C06]          <1> 	mov	eax, [buffersize]
   395                              <1> 
   396                              <1> 	;or	eax, IOC + BUP
   397                              <1> 	; 06/11/2023 (TUNELOOP version, without interrupt)
   398 00000691 660D00000040        <1> 	or	eax, BUP
   399 00000697 66AB                <1> 	stosd
   400                              <1> 
   401 00000699 E2CE                <1>         loop    _0
   402 0000069B 07                  <1>         pop     es
   403                              <1> 
   404                              <1> ;
   405                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
   406                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
   407                              <1> ;
   408                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
   409                              <1> ;
   410 0000069C 660FB706[661D]      <1>         movzx   eax, word [BDL_BUFFER]
   411 000006A2 66C1E004            <1> 	shl     eax, 4                          ; convert seg:off to 0:off
   412 000006A6 8B16[641D]          <1>         mov     dx, [NABMBAR]
   413 000006AA 83C210              <1>         add     dx, PO_BDBAR_REG                ; set pointer to BDL
   414 000006AD 66EF                <1>         out     dx, eax                         ; write to AC97 controller
   415                              <1> 
   416                              <1> 	; 19/05/2024
   417 000006AF E8CD12              <1> 	call	delay1_4ms
   418                              <1> 
   419                              <1> ;
   420                              <1> ; All set. Let's play some music.
   421                              <1> ;
   422                              <1> 
   423                              <1> 	; 08/11/2023
   424                              <1> 	; 07/11/2023
   425                              <1> 	; 08/12/2016
   426                              <1> 	; 07/10/2016
   427                              <1>         ;mov	al, 1
   428 000006B2 B01F                <1>         mov	al, 31
   429 000006B4 E86901              <1> 	call	setLastValidIndex
   430                              <1> 
   431                              <1> 	; 06/11/2023 (not neccessary)
   432                              <1> 	;; 05/11/2023
   433                              <1> 	;; reset current index
   434                              <1> 	;mov	al, 0
   435                              <1> 	;call	setCurrentIndex
   436                              <1> 
   437                              <1> 	; 06/11/2023
   438                              <1> 	;mov	byte [tLoop], 1 ; 30/11/2016
   439                              <1> 
   440                              <1> 	; 19/05/2024
   441 000006B7 E8C512              <1> 	call	delay1_4ms
   442                              <1> 
   443                              <1> 	; 17/02/2017
   444 000006BA 8B16[641D]          <1>         mov     dx, [NABMBAR]
   445 000006BE 83C21B              <1>         add     dx, PO_CR_REG                   ; PCM out Control Register
   446                              <1>         ;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
   447                              <1> 	;			; (LVBI interrupt will not be enabled)
   448                              <1> 	; 06/11/2023 (TUNELOOP version, without interrupt)
   449 000006C1 B001                <1> 	mov	al, RPBM
   450 000006C3 EE                  <1> 	out     dx, al                          ; Start bus master operation.
   451                              <1> 
   452                              <1> 	; 19/05/2024
   453                              <1> 	; 06/11/2023
   454 000006C4 E8B812              <1> 	call	delay1_4ms
   455 000006C7 E8B512              <1> 	call	delay1_4ms
   456 000006CA E8B212              <1> 	call	delay1_4ms
   457 000006CD E8AF12              <1> 	call	delay1_4ms
   458                              <1> 
   459                              <1> ; while DMA engine is running, examine current index and wait until it hits 1
   460                              <1> ; as soon as it's 1, we need to refresh the data in wavbuffer1 with another
   461                              <1> ; 64k. Likewise when it's playing buffer 2, refresh buffer 1 and repeat.
   462                              <1>    
   463                              <1> ; 06/11/2023 (TUNELOOP version, without interrupt)
   464                              <1> %if 0
   465                              <1> 	; 08/12/2016
   466                              <1> 	; 28/11/2016
   467                              <1> p_loop:
   468                              <1> 	call    check4keyboardstop      ; keyboard halt?
   469                              <1>         jc	short r_loop 	; no ; 05/11/2023
   470                              <1> 
   471                              <1> 	;mov	byte [tLoop], 0
   472                              <1> 	; 04/11/2023
   473                              <1> 	;mov	byte [audio_play_cmd], 0
   474                              <1> 	;call	ac97_stop
   475                              <1> 	;retn
   476                              <1> _exit_:
   477                              <1> 	; 04/11/2023
   478                              <1> 	; finished with song, stop everything
   479                              <1> 	call	ac97_stop
   480                              <1> 	
   481                              <1> 	; restore previous interrupt vector and interrupt_status
   482                              <1> 	cli
   483                              <1> 	in	al, 0A1h ; irq 8-15
   484                              <1> 	mov	al, [IRQ_status+1]
   485                              <1> 	out	0A1h, al 
   486                              <1> 	in	al, 021h ; irq 0-7
   487                              <1> 	mov	al, [IRQ_status]
   488                              <1> 	out	21h, al 
   489                              <1> 	; ...
   490                              <1> 	push	es
   491                              <1> 	xor	ax, ax
   492                              <1> 	mov	es, ax
   493                              <1> 	mov	ax, [IRQ_vector]
   494                              <1> 	mov	[es:bx], ax
   495                              <1> 	mov	ax, [IRQ_vector+2]
   496                              <1> 	mov	[es:bx+2], ax
   497                              <1> 	pop	es
   498                              <1> 	sti
   499                              <1> 	retn
   500                              <1> 
   501                              <1> r_loop:
   502                              <1> 	; 07/12/2016 - Erdogan Tan
   503                              <1> 	nop
   504                              <1> 	nop
   505                              <1> 	nop
   506                              <1> 	; 17/02/2017
   507                              <1> 	mov	al, [tBuff]
   508                              <1> 	dec	al ; 1-32 -> 0-31 or 0 -> 0FFh
   509                              <1> 	js	short  p_loop
   510                              <1> 	mov	byte [tBuff], 0 ; reset
   511                              <1> 	and	al, 1
   512                              <1> 	jnz	short q_loop
   513                              <1>         mov     ax, [WAV_BUFFER2] ; [tBuff]=2 (from tuneLoop)
   514                              <1> s_loop:
   515                              <1> 	;call	loadFromFile
   516                              <1> 	; 13/11/2023 - 18/11/2023
   517                              <1> 	call	[loadfromwavfile]
   518                              <1> 	;jc	short _exit_
   519                              <1> 	; 05/11/2023
   520                              <1> 	jc	short exit_loop
   521                              <1> 	jmp	short r_loop
   522                              <1> q_loop:
   523                              <1>      	mov     ax, [WAV_BUFFER1] ; [tBuff]=1 (from tuneLoop)
   524                              <1>         ;call	loadFromFile
   525                              <1> 	;jc	short _exit_
   526                              <1> 	;jmp	short r_loop
   527                              <1> 	; 05/11/2023
   528                              <1> 	jmp	short s_loop
   529                              <1> 
   530                              <1> exit_loop: 
   531                              <1> 	mov	byte [tLoop], 0
   532                              <1> 	retn
   533                              <1> 		
   534                              <1> tuneLoop:
   535                              <1> 	; 05/11/2023
   536                              <1> 	; 08/12/2016
   537                              <1> 	; 28/11/2016 - Erdogan Tan
   538                              <1> 	
   539                              <1> 	cmp	byte [tLoop], 1
   540                              <1> 	jb	short _exit_ ; 05/11/2023
   541                              <1> _tlp_1:	
   542                              <1> 	; 17/02/2017
   543                              <1> 	call	getCurrentIndex
   544                              <1> 	inc	al ; 0-31 -> 1-32
   545                              <1> 	mov	[tBuff], al
   546                              <1> 
   547                              <1> 	; 05/11/2023
   548                              <1> 	dec	ax
   549                              <1> 	dec	ax
   550                              <1> 	and	al, 1Fh
   551                              <1> 	call	setLastValidIndex
   552                              <1> 
   553                              <1> 	; 05/11/2023
   554                              <1> 	; 17/02/2017 - Buffer switch test (temporary)
   555                              <1> 	push	ds
   556                              <1> 	push	si 
   557                              <1> 	mov	si, 0B800h ; video display page segment
   558                              <1> 	mov	ds, si
   559                              <1> 	sub	si, si ; 0
   560                              <1> 	mov	ah, 4Eh
   561                              <1> 	and	al, 1
   562                              <1> 	add	al, '1'
   563                              <1> 	mov	[si], ax ; show current play buffer (1, 2)
   564                              <1> 	pop	si
   565                              <1> 	pop	ds
   566                              <1> 
   567                              <1> 	; 17/02/2017
   568                              <1> 
   569                              <1> 	;test	byte [irq_status], LVBCI ; last buff completion intr.
   570                              <1> 	;jz	short _tlp2 ; BCIS ; Buffer completion interrupt
   571                              <1> 
   572                              <1> 	; Last Valid Buffer Completion Interrupt (LVBCI).
   573                              <1> 	;   1 = Last valid buffer has been processed. 
   574                              <1> 	;	It remains active until cleared by software. 
   575                              <1> 	;	This bit indicates the occurrence of the event 
   576                              <1> 	;	signified by the last valid buffer being processed.
   577                              <1> 	;	Thus, this is an event status bit that can be cleared
   578                              <1> 	;	by software once this event has been recognized.
   579                              <1> 	;	This event causes an interrupt if the enable bit
   580                              <1> 	;	in the Control Register is set. The interrupt is
   581                              <1> 	;	cleared when the software clears this bit.
   582                              <1> 	;	In the case of Transmits (PCM out, Modem out) this bit
   583                              <1> 	;	is set, after the last valid buffer has been
   584                              <1> 	;	fetched (not after transmitting it).
   585                              <1> 	;	While in the case of Receives, this bit is set after
   586                              <1> 	;	the data for the last buffer has been written to memory.
   587                              <1> 	;   0 = Cleared by writing a "1" to this bit position.
   588                              <1> 
   589                              <1> 	; Note: We are not using LVBCI 
   590                              <1> 	;     Last Buffer Completion Interrupt !!!
   591                              <1> 
   592                              <1> 	; 17/02/2017
   593                              <1>         ;mov     dx, [NABMBAR]
   594                              <1>         ;add     dx, PO_SR_REG	; PCM out Status register
   595                              <1>         ;mov     al, [irq_status]
   596                              <1>         ;out     dx, al		; Clear (LVBCI) interrupt status
   597                              <1> 	;retn
   598                              <1> 
   599                              <1> ;_tlp2:
   600                              <1> 	; Buffer Completion Interrupt Status (BCIS).
   601                              <1> 	;   1 =	Set by the hardware after the last sample 
   602                              <1> 	; 	of a buffer has been processed, AND if the Interrupt
   603                              <1> 	; 	on Completion (IOC) bit is set in the command byte of 
   604                              <1> 	; 	the buffer descriptor. It remains active
   605                              <1> 	; 	until cleared by software.
   606                              <1> 	;   0 =	Cleared by writing a "1" to this bit position.
   607                              <1> 
   608                              <1> 	; 17/02/2017
   609                              <1>         mov     dx, [NABMBAR]
   610                              <1>         add     dx, PO_SR_REG	; PCM out Status register
   611                              <1>         mov     al, [pcm_irq_status] ; 05/11/2023
   612                              <1>         out     dx, al		; Clear (BCI) interrupt status
   613                              <1> 	retn
   614                              <1> 
   615                              <1> ;_exit_:
   616                              <1> ;	mov	byte [tLoop], 0
   617                              <1> ;_exit:
   618                              <1> ;       ; finished with song, stop everything
   619                              <1> ;	mov     dx, [NABMBAR]		
   620                              <1> ;       add     dx, PO_CR_REG           ; PCM out Control Register
   621                              <1> ;       mov     al, 0
   622                              <1> ;       out     dx, al                  ; stop player
   623                              <1> ;_return:
   624                              <1> ;	retn
   625                              <1> 
   626                              <1> %endif
   627                              <1> 
   628                              <1> ; while DMA engine is running, examine current index and wait until it hits 1
   629                              <1> ; as soon as it's 1, we need to refresh the data in wavbuffer1 with another
   630                              <1> ; 64k. Likewise when it's playing buffer 2, refresh buffer 1 and repeat.
   631                              <1> 
   632                              <1> ; 18/11/2023
   633                              <1> ; 08/11/2023
   634                              <1> ; 07/11/2023
   635                              <1> %if 1
   636                              <1> 
   637                              <1> tuneLoop:
   638                              <1> 	; 18/11/2023 (ich_wav4.asm)
   639                              <1> 	; 08/11/2023
   640                              <1> 	; 06/11/2023
   641 000006D0 B031                <1> 	mov	al, '1'
   642 000006D2 E84500              <1> 	call	tL0
   643                              <1> tL1:
   644 000006D5 E81D01              <1> 	call    updateLVI	; /set LVI != CIV/
   645 000006D8 7434                <1> 	jz	short _exit_	; 08/11/2023
   646 000006DA E84C01              <1> 	call    check4keyboardstop
   647 000006DD 722F                <1> 	jc	short _exit_
   648 000006DF E80A01              <1> 	call    getCurrentIndex
   649 000006E2 A801                <1> 	test	al, BIT0
   650 000006E4 74EF                <1> 	jz	short tL1	; loop if buffer 2 is not playing
   651                              <1> 
   652                              <1> 	; load buffer 1
   653 000006E6 A1[681D]            <1> 	mov     ax, [WAV_BUFFER1]
   654                              <1> 	;call	loadFromFile
   655                              <1> 	; 18/11/2023
   656 000006E9 FF16[4806]          <1> 	call	word [loadfromwavfile]
   657 000006ED 721F                <1> 	jc	short _exit_	; end of file
   658                              <1> 
   659 000006EF B032                <1> 	mov	al, '2'
   660 000006F1 E82600              <1> 	call	tL0
   661                              <1> tL2:
   662 000006F4 E8FE00              <1> 	call    updateLVI
   663 000006F7 7415                <1> 	jz	short _exit_	; 08/11/2023
   664 000006F9 E82D01              <1> 	call    check4keyboardstop
   665 000006FC 7210                <1> 	jc	short _exit_
   666 000006FE E8EB00              <1> 	call    getCurrentIndex
   667 00000701 A801                <1> 	test	al, BIT0
   668 00000703 75EF                <1> 	jnz	short tL2	; loop if buffer 1 is not playing
   669                              <1> 
   670                              <1> 	; load buffer 2
   671 00000705 A1[6A1D]            <1> 	mov     ax, [WAV_BUFFER2]
   672                              <1> 	;call	loadFromFile
   673                              <1> 	; 18/11/2023
   674 00000708 FF16[4806]          <1> 	call	word [loadfromwavfile]
   675 0000070C 73C2                <1> 	jnc	short tuneLoop
   676                              <1> _exit_:
   677 0000070E 8B16[641D]          <1> 	mov	dx, [NABMBAR]		
   678 00000712 83C21B              <1> 	add	dx, PO_CR_REG	; PCM out Control Register
   679 00000715 B000                <1> 	mov	al, 0
   680 00000717 EE                  <1> 	out	dx, al		; stop player
   681                              <1> 
   682 00000718 0430                <1> 	add	al, '0'
   683                              <1> 	;call	tL0
   684                              <1> 	;
   685                              <1> 	;retn
   686                              <1> 	; 06/11/2023
   687                              <1> 	;jmp	short tL0
   688                              <1> 	;retn
   689                              <1> 
   690                              <1> 	; 06/11/2023
   691                              <1> tL0:
   692                              <1> 	; 08/11/2023
   693                              <1> 	; 05/11/2023
   694                              <1> 	; 17/02/2017 - Buffer switch test (temporary)
   695                              <1> 	; 06/11/2023
   696                              <1> 	; al = buffer indicator ('1', '2' or '0' -stop- )
   697 0000071A 1E                  <1> 	push	ds
   698                              <1> 	;push	bx 
   699 0000071B BB00B8              <1> 	mov	bx, 0B800h ; video display page segment
   700 0000071E 8EDB                <1> 	mov	ds, bx
   701 00000720 29DB                <1> 	sub	bx, bx ; 0
   702 00000722 B44E                <1> 	mov	ah, 4Eh
   703 00000724 8907                <1> 	mov	[bx], ax ; show current play buffer (1, 2)
   704                              <1> 	;pop	bx
   705 00000726 1F                  <1> 	pop	ds
   706 00000727 C3                  <1> 	retn
   707                              <1> 
   708                              <1> %endif
   709                              <1> 
   710                              <1> ; 08/11/2023
   711                              <1> ; 07/11/2023
   712                              <1> %if 0
   713                              <1> 
   714                              <1> tuneLoop:
   715                              <1> 	; 07/11/2023
   716                              <1> 	;mov	dx, NABMBAR
   717                              <1> 	;add	dx, PO_CIV_REG ; 14h
   718                              <1> tL1:
   719                              <1> 	call    updateLVI	; set LVI != CIV
   720                              <1> 	call    check4keyboardstop
   721                              <1> 	jc	short _exit_
   722                              <1> 	call    getCurrentIndex
   723                              <1> 	test	al, BIT0
   724                              <1> 	jz	short tL1	; loop if buffer 2 is not playing
   725                              <1> 
   726                              <1> 	; load buffer 1
   727                              <1> 	mov     ax, [WAV_BUFFER1]
   728                              <1> 	call	loadFromFile
   729                              <1> 	jc	short _exit_	; end of file
   730                              <1> tL2:
   731                              <1> 	call    updateLVI
   732                              <1> 	call    check4keyboardstop
   733                              <1> 	jc	short _exit_
   734                              <1> 	call    getCurrentIndex
   735                              <1> 	test	al, BIT0
   736                              <1> 	jnz	short tL2	; loop if buffer 1 is not playing
   737                              <1> 
   738                              <1> 	; load buffer 2
   739                              <1> 	mov     ax, [WAV_BUFFER2]
   740                              <1> 	call	loadFromFile
   741                              <1> 	jnc	short tuneLoop
   742                              <1> _exit_:
   743                              <1> 	mov	dx, [NABMBAR]		
   744                              <1> 	add	dx, PO_CR_REG	; PCM out Control Register
   745                              <1> 	mov	al, 0
   746                              <1> 	out	dx, al		; stop player
   747                              <1> 	retn
   748                              <1> 
   749                              <1> %endif
   750                              <1> 
   751                              <1> ; load data from file in 32k chunks. Would be nice to load 1 64k chunk,
   752                              <1> ; but in DOS you can only load FFFF bytes at a time.
   753                              <1> ;
   754                              <1> ; entry: ax = segment to load data to
   755                              <1> ; exit: CY set if end of file reached.
   756                              <1> ; note: last file buffer is padded with 0's to avoid pops at the end of song.
   757                              <1> ; assumes file is already open. uses [filehandle]
   758                              <1> 
   759                              <1> ; 07/11/2023
   760                              <1> %if 0
   761                              <1> 
   762                              <1> loadFromFile:
   763                              <1> 	; 07/11/2023
   764                              <1> 	; 06/11/2023
   765                              <1> 	; 17/02/2017
   766                              <1> 	;push	ax
   767                              <1> 	;push	cx
   768                              <1> 	;push	dx
   769                              <1> 	;push	bx
   770                              <1> 
   771                              <1> 	;push	es
   772                              <1> 	;push	ds
   773                              <1> 	
   774                              <1>         test    byte [flags], ENDOFFILE	; have we already read the
   775                              <1> 	;stc				; last of the file?
   776                              <1> 	; 05/11/2023
   777                              <1> 	;jnz	endLFF
   778                              <1> 	jz	short lff_12	; 06/11/2023
   779                              <1> 	; 06/11/2023
   780                              <1> 	;;mov	byte [tLoop], 0
   781                              <1> 	;jmp	endLFF
   782                              <1> 	stc
   783                              <1> 	retn
   784                              <1> 
   785                              <1> lff_12:	; 06/11/2023    
   786                              <1> 	mov	[fbs_seg], ax ; save buffer segment
   787                              <1> 	xor	dx, dx
   788                              <1> lff_0:
   789                              <1> 	mov	[fbs_off], dx ; buffer offset
   790                              <1> 
   791                              <1> 	mov     bx, (BUFFERSIZE / 2)	; 32k chunk
   792                              <1> 	mov	cl, [fbs_shift]   
   793                              <1> 	and	cl, cl
   794                              <1> 	jz	short lff_1 ; stereo, 16 bit	
   795                              <1> 
   796                              <1> 	; fbs_shift =
   797                              <1> 	;	2 for mono and 8 bit sample (multiplier = 4)
   798                              <1> 	;	1 for mono or 8 bit sample (multiplier = 2)
   799                              <1> 	shr	bx, cl ; 32K / multiplier
   800                              <1> 
   801                              <1> 	mov	ax, cs
   802                              <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
   803                              <1> lff_1:
   804                              <1> 	; 17/02/2017 (stereo/mono, 8bit/16bit corrections)
   805                              <1> 	; load file into memory
   806                              <1>         mov	cx, bx                         
   807                              <1> 	mov	bx, [filehandle]
   808                              <1> 	mov     ds, ax
   809                              <1>        	mov	ah, 3fh
   810                              <1> 	int	21h
   811                              <1> 
   812                              <1> 	mov	bx, cs
   813                              <1> 	mov	ds, bx
   814                              <1> 
   815                              <1> 	jc	short lff_9 ; error !
   816                              <1> 
   817                              <1> 	and	ax, ax
   818                              <1> 	jz	short lff_10
   819                              <1> 	
   820                              <1> 	mov	bl, [fbs_shift] ; shift count  
   821                              <1> 	or	bl, bl
   822                              <1> 	jz	short lff_7 ; 16 bit stereo samples
   823                              <1> 
   824                              <1> 	push	es
   825                              <1> 	; 06/11/2023
   826                              <1> 	;push	di
   827                              <1> 	;push	si
   828                              <1> 	mov	di, [fbs_off]
   829                              <1> 	mov	si, [fbs_seg] ; buffer segment
   830                              <1> 	mov	es, si
   831                              <1> 	mov	si, temp_buffer ; temporary buffer address
   832                              <1> 	mov	cl, [bps] ; bits per sample (8 or 16)
   833                              <1> 	cmp	cl, 8
   834                              <1> 	jne	short lff_4 ; 16 bit samples
   835                              <1> 	; 8 bit samples
   836                              <1> 	mov	cx, ax ; byte count
   837                              <1> 	dec	bl  ; shift count, 1 = stereo, 2 = mono
   838                              <1> 	jz	short lff_3 ; 8 bit, stereo
   839                              <1> lff_2:
   840                              <1> 	; mono & 8 bit
   841                              <1> 	lodsb
   842                              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   843                              <1> 	stosw	; left channel
   844                              <1> 	stosw	; right channel
   845                              <1> 	loop	lff_2
   846                              <1> 	jmp	short lff_6	
   847                              <1> lff_3:
   848                              <1> 	; stereo & 8 bit
   849                              <1> 	lodsb
   850                              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   851                              <1> 	stosw
   852                              <1> 	loop	lff_3			
   853                              <1> 	jmp	short lff_6
   854                              <1> lff_4:
   855                              <1> 	; 16 bit mono samples
   856                              <1> 	mov	cx, ax ; word count
   857                              <1> lff_5:	
   858                              <1> 	lodsw
   859                              <1> 	stosw	; left channel
   860                              <1> 	stosw	; right channel
   861                              <1> 	loop	lff_5
   862                              <1> lff_6:
   863                              <1> 	mov	ax, di ; save next buffer offset/position
   864                              <1> 	; 06/11/2023
   865                              <1> 	;pop	si
   866                              <1> 	;pop	di
   867                              <1> 	pop	es
   868                              <1> ;lff_7:        
   869                              <1> 	; 06/11/2023
   870                              <1> 	and	ax, ax
   871                              <1> 	jz	short endLFF ; end of 2nd half
   872                              <1> 	mov	cx, (BUFFERSIZE / 2)
   873                              <1> lff_7:
   874                              <1> 	cmp	ax, cx
   875                              <1> 	je	short endLFF	 ; 06/11/2023
   876                              <1> 	;jb	short lff_11
   877                              <1> 	;xor	cx, cx
   878                              <1> 	;sub	cx, ax
   879                              <1> 	;neg	cx
   880                              <1> 	jmp	short lff_11
   881                              <1> lff_8:
   882                              <1> 	; 07/11/2023
   883                              <1> 	cmp	word [fbs_off], (BUFFERSIZE / 2) ; 32768
   884                              <1> 	jnb	short endLFF
   885                              <1> 	
   886                              <1> 	mov	dx, ax ; buffer offset
   887                              <1> 	mov	ax, [fbs_seg] ; buffer segment
   888                              <1> 	jmp	lff_0
   889                              <1> lff_9:  
   890                              <1> 	; 07/11/2023
   891                              <1> 	;; 06/11/2023 (temporary)
   892                              <1> 	;mov	al, '!'  ; error
   893                              <1> 	;call	tL0
   894                              <1> 
   895                              <1> 	xor	ax, ax
   896                              <1> lff_10:
   897                              <1> 	; 07/11/2023
   898                              <1> 	;mov	cx, (BUFFERSIZE / 2)  
   899                              <1> lff_11:
   900                              <1> 	call    padfill				; blank pad the remainder
   901                              <1>         ;clc					; don't exit with CY yet.
   902                              <1>         or	byte [flags], ENDOFFILE		; end of file flag
   903                              <1> endLFF:
   904                              <1>         ;pop	ds
   905                              <1> 	;pop	es
   906                              <1> 	; 06/11/2023
   907                              <1> 	;pop	bx
   908                              <1> 	;pop	dx
   909                              <1>         ;pop	cx
   910                              <1>         ;pop	ax
   911                              <1>         retn
   912                              <1> 
   913                              <1> %endif
   914                              <1> 
   915                              <1> ; 08/11/2023
   916                              <1> ; 07/11/2023
   917                              <1> %if 1
   918                              <1> 
   919                              <1> loadFromFile:
   920                              <1> 	; 07/11/2023
   921                              <1> 
   922 00000728 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
   923                              <1> 					; last of the file?
   924 0000072D 7402                <1> 	jz	short lff_0		; no
   925 0000072F F9                  <1> 	stc
   926 00000730 C3                  <1> 	retn
   927                              <1> 
   928                              <1> lff_0:
   929                              <1> 	; 08/11/2023
   930 00000731 89C5                <1> 	mov	bp, ax ; save buffer segment	
   931                              <1> 
   932 00000733 8A0E[7A1D]          <1> 	mov	cl, [fbs_shift]   
   933 00000737 20C9                <1> 	and	cl, cl
   934 00000739 7467                <1> 	jz	short lff_1 ; stereo, 16 bit	
   935                              <1> 
   936 0000073B BFFFFF              <1> 	mov	di, BUFFERSIZE - 1 ; 65535
   937                              <1> 
   938                              <1> 	; fbs_shift =
   939                              <1> 	;	2 for mono and 8 bit sample (multiplier = 4)
   940                              <1> 	;	1 for mono or 8 bit sample (multiplier = 2)
   941 0000073E D3EF                <1> 	shr	di, cl
   942 00000740 47                  <1> 	inc	di ; 16384 for 8 bit and mono	
   943                              <1> 		   ; 32768 for 8 bit or mono	
   944                              <1> 
   945 00000741 8CC8                <1> 	mov	ax, cs
   946 00000743 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
   947                              <1> 
   948                              <1> 	; 17/02/2017 (stereo/mono, 8bit/16bit corrections)
   949                              <1> 	; load file into memory
   950 00000746 89F9                <1>         mov	cx, di                       
   951 00000748 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
   952 0000074C 8ED8                <1> 	mov     ds, ax
   953 0000074E B43F                <1>        	mov	ah, 3Fh
   954 00000750 CD21                <1> 	int	21h
   955                              <1> 
   956 00000752 8CCB                <1> 	mov	bx, cs
   957 00000754 8EDB                <1> 	mov	ds, bx
   958                              <1> 
   959 00000756 727C                <1> 	jc	short lff_4 ; error !
   960                              <1> 
   961                              <1> 	; 08/11/2023
   962 00000758 31D2                <1> 	xor	dx, dx ; 0
   963                              <1> 
   964 0000075A 21C0                <1> 	and	ax, ax
   965 0000075C 746D                <1> 	jz	short lff_3
   966                              <1> 
   967 0000075E 8A1E[7A1D]          <1> 	mov	bl, [fbs_shift]
   968                              <1> 
   969 00000762 06                  <1> 	push	es
   970 00000763 89D7                <1> 	mov	di, dx ; 0 ; [fbs_off]
   971                              <1> 	;mov	bp, [fbs_seg] ; buffer segment
   972 00000765 8EC5                <1> 	mov	es, bp
   973 00000767 BE[7C1D]            <1> 	mov	si, temp_buffer ; temporary buffer address
   974 0000076A 89C1                <1> 	mov	cx, ax ; byte count
   975 0000076C 803E[781D]08        <1> 	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   976 00000771 751B                <1> 	jne	short lff_7 ; 16 bit samples
   977                              <1> 	; 8 bit samples
   978 00000773 FECB                <1> 	dec	bl  ; shift count, 1 = stereo, 2 = mono
   979 00000775 740C                <1> 	jz	short lff_6 ; 8 bit, stereo
   980                              <1> lff_5:
   981                              <1> 	; mono & 8 bit
   982 00000777 AC                  <1> 	lodsb
   983 00000778 2C80                <1> 	sub	al, 80h ; 08/11/2023
   984 0000077A C1E008              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   985 0000077D AB                  <1> 	stosw	; left channel
   986 0000077E AB                  <1> 	stosw	; right channel
   987 0000077F E2F6                <1> 	loop	lff_5
   988 00000781 EB12                <1> 	jmp	short lff_9	
   989                              <1> lff_6:
   990                              <1> 	; stereo & 8 bit
   991 00000783 AC                  <1> 	lodsb
   992 00000784 2C80                <1> 	sub	al, 80h ; 08/11/2023
   993 00000786 C1E008              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   994 00000789 AB                  <1> 	stosw
   995 0000078A E2F7                <1> 	loop	lff_6			
   996 0000078C EB07                <1> 	jmp	short lff_9
   997                              <1> lff_7:
   998 0000078E D1E9                <1> 	shr	cx, 1 ; word count
   999                              <1> lff_8:
  1000 00000790 AD                  <1> 	lodsw
  1001 00000791 AB                  <1> 	stosw	; left channel
  1002 00000792 AB                  <1> 	stosw	; right channel
  1003 00000793 E2FB                <1> 	loop	lff_8
  1004                              <1> lff_9:
  1005 00000795 07                  <1> 	pop	es
  1006 00000796 09FF                <1> 	or	di, di
  1007 00000798 7439                <1> 	jz	short endLFF ; 64KB ok 
  1008                              <1> 	
  1009 0000079A 89F8                <1> 	mov	ax, di ; [fbs_off]
  1010 0000079C 48                  <1> 	dec	ax
  1011 0000079D B9FFFF              <1> 	mov	cx, BUFFERSIZE - 1 ; 65535
  1012 000007A0 EB29                <1> 	jmp	short lff_3
  1013                              <1> 	
  1014                              <1> lff_1:  
  1015                              <1> 	;mov	bp, ax ; save buffer segment
  1016 000007A2 31D2                <1> 	xor	dx, dx
  1017                              <1> 	; load file into memory
  1018 000007A4 B90080              <1>         mov	cx, (BUFFERSIZE / 2)	; 32k chunk
  1019 000007A7 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1020 000007AB 8ED8                <1> 	mov     ds, ax
  1021 000007AD B43F                <1>        	mov	ah, 3Fh
  1022 000007AF CD21                <1> 	int	21h
  1023                              <1> 
  1024 000007B1 8CCF                <1> 	mov	di, cs
  1025 000007B3 8EDF                <1> 	mov	ds, di
  1026                              <1> 
  1027                              <1> 	; 07/11/2023
  1028 000007B5 721D                <1> 	jc	short lff_4 ; error !
  1029                              <1> 	
  1030 000007B7 39C8                <1> 	cmp	ax, cx
  1031 000007B9 7510                <1> 	jne	short lff_3
  1032                              <1> lff_2:
  1033                              <1> 	; 08/11/2023
  1034 000007BB 01C2                <1> 	add	dx, ax
  1035                              <1> 	;mov	cx, (BUFFERSIZE / 2)	; 32k chunk
  1036                              <1> 	;mov	bx, [filehandle]
  1037 000007BD 8EDD                <1> 	mov     ds, bp
  1038 000007BF B43F                <1>        	mov	ah, 3Fh
  1039 000007C1 CD21                <1> 	int	21h
  1040                              <1> 
  1041                              <1> 	;mov	di, cs
  1042 000007C3 8EDF                <1> 	mov	ds, di
  1043                              <1> 
  1044 000007C5 720D                <1> 	jc	short lff_4 ; error !
  1045                              <1> 
  1046 000007C7 39C8                <1> 	cmp	ax, cx
  1047 000007C9 7408                <1> 	je	short endLFF
  1048                              <1> lff_3:
  1049 000007CB E80F00              <1> 	call    padfill			; blank pad the remainder
  1050                              <1>         ;clc				; don't exit with CY yet.
  1051 000007CE 800E[601D]01        <1>         or	byte [flags], ENDOFFILE	; end of file flag
  1052                              <1> endLFF:
  1053 000007D3 C3                  <1>         retn
  1054                              <1> lff_4:
  1055                              <1> 	; 08/11/2023
  1056 000007D4 B021                <1> 	mov	al, '!'  ; error
  1057 000007D6 E841FF              <1> 	call	tL0
  1058                              <1> 
  1059 000007D9 31C0                <1> 	xor	ax, ax
  1060 000007DB EBEE                <1> 	jmp	short lff_3
  1061                              <1> 
  1062                              <1> %endif
  1063                              <1> 
  1064                              <1> ; entry ds:ax points to last byte in file
  1065                              <1> ; cx=target size
  1066                              <1> ; note: must do byte size fill
  1067                              <1> ; destroys bx, cx
  1068                              <1> ;
  1069                              <1> padfill:
  1070                              <1> 	; 07/11/2023
  1071                              <1> 	; 06/11/2023
  1072                              <1> 	; 17/02/2017
  1073 000007DD 06                  <1> 	push	es
  1074                              <1>         ;push	di
  1075                              <1> 	;mov	di, [fbs_seg]
  1076                              <1> 	;mov	es, di
  1077 000007DE 8EC5                <1>         mov	es, bp
  1078 000007E0 29C1                <1> 	sub	cx, ax
  1079                              <1> 	; 08/11/2023
  1080                              <1> 	;mov	di, ax ; (wrong)
  1081 000007E2 89D7                <1> 	mov	di, dx ; buffer offset
  1082 000007E4 01C7                <1> 	add	di, ax       	
  1083                              <1> 	; 07/11/2023
  1084                              <1> 	;add	di, [fbs_off]
  1085 000007E6 30C0                <1>         xor	al, al
  1086 000007E8 F3AA                <1> 	rep	stosb
  1087                              <1> 	;mov	[fbs_off], di
  1088                              <1> 	;pop	di
  1089 000007EA 07                  <1>         pop	es
  1090 000007EB C3                  <1> 	retn
  1091                              <1> 
  1092                              <1> ; returns AL = current index value
  1093                              <1> getCurrentIndex:
  1094                              <1> 	; 08/11/2023
  1095                              <1> 	;push	dx
  1096 000007EC 8B16[641D]          <1> 	mov	dx, [NABMBAR]      		
  1097 000007F0 83C214              <1> 	add	dx, PO_CIV_REG
  1098 000007F3 EC                  <1> 	in	al, dx
  1099                              <1> 	;pop	dx
  1100                              <1> uLVI2:	;	06/11/2023
  1101 000007F4 C3                  <1> 	retn
  1102                              <1> 
  1103                              <1> ; examines the CIV and the LVI. When they're the same, we set LVI <> CIV
  1104                              <1> ; that way, we never run out of buffers to play
  1105                              <1> 
  1106                              <1> ; 08/11/2023
  1107                              <1> %if 0
  1108                              <1> 	; 07/11/2023
  1109                              <1> updateLVI:
  1110                              <1> 	push	ax
  1111                              <1> 	push	dx
  1112                              <1> 	; 06/11/2023
  1113                              <1> 	mov	dx, [NABMBAR]
  1114                              <1> 	add	dx, PO_CIV_REG
  1115                              <1> 	; (Current Index Value and Last Valid Index value)
  1116                              <1> 	in	ax, dx
  1117                              <1> 
  1118                              <1> 	cmp	al, ah ; is current index = last index ?
  1119                              <1> 	jne	short uLVI1
  1120                              <1> 
  1121                              <1> 	call	setNewIndex
  1122                              <1> uLVI1:
  1123                              <1> 	pop	dx
  1124                              <1> 	pop	ax
  1125                              <1> 	retn
  1126                              <1> 
  1127                              <1> setNewIndex:
  1128                              <1> 	; 07/11/2023
  1129                              <1> 	push	ax
  1130                              <1>         call    getCurrentIndex                 ; get CIV
  1131                              <1>         test    byte [flags], ENDOFFILE
  1132                              <1>         jnz     short sni_1
  1133                              <1>         ; not at the end of the file yet.
  1134                              <1>         dec     al                              ; make new index <> current
  1135                              <1>         and     al, INDEX_MASK                  ; make sure new value is 0-31
  1136                              <1> sni_1:
  1137                              <1>         call    setLastValidIndex               ; write new value
  1138                              <1>         clc
  1139                              <1>         pop	ax
  1140                              <1> 	retn
  1141                              <1> 
  1142                              <1> %endif	
  1143                              <1> 
  1144                              <1> ; 08/11/2023
  1145                              <1> ; 07/11/2023
  1146                              <1> ;%if 1
  1147                              <1> updateLVI:
  1148                              <1> 	; 06/11/2023
  1149 000007F5 8B16[641D]          <1> 	mov	dx, [NABMBAR]      		
  1150 000007F9 83C214              <1> 	add	dx, PO_CIV_REG
  1151                              <1> 	; (Current Index Value and Last Valid Index value)
  1152 000007FC ED                  <1> 	in	ax, dx
  1153                              <1> 
  1154 000007FD 38E0                <1> 	cmp	al, ah ; is current index = last index ?
  1155 000007FF 75F3                <1> 	jne	short uLVI2
  1156                              <1> 
  1157                              <1> 	; 08/11/2023	
  1158 00000801 E8E8FF              <1> 	call	getCurrentIndex
  1159                              <1>  
  1160 00000804 F606[601D]01        <1> 	test	byte [flags], ENDOFFILE
  1161                              <1> 	;jnz	short uLVI1
  1162 00000809 7411                <1> 	jz	short uLVI0  ; 08/11/2023
  1163                              <1> 
  1164                              <1> 	; 08/11/2023
  1165 0000080B 50                  <1> 	push	ax
  1166 0000080C 8B16[641D]          <1> 	mov	dx, [NABMBAR]
  1167 00000810 83C216              <1> 	add	dx, PO_SR_REG  ; PCM out status register
  1168 00000813 ED                  <1> 	in	ax, dx
  1169                              <1> 
  1170 00000814 A803                <1> 	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
  1171                              <1> 		      ; (has been processed)
  1172                              <1> 		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
  1173 00000816 58                  <1> 	pop	ax
  1174 00000817 7407                <1> 	jz	short uLVI1
  1175                              <1> uLVI3:
  1176 00000819 31C0                <1> 	xor	ax, ax
  1177                              <1> 	; zf = 1
  1178 0000081B C3                  <1> 	retn
  1179                              <1> uLVI0:
  1180                              <1>         ; not at the end of the file yet.
  1181 0000081C FEC8                <1> 	dec	al
  1182 0000081E 241F                <1> 	and	al, 1Fh
  1183                              <1> uLVI1:
  1184                              <1> 	;call	setLastValidIndex
  1185                              <1> ;uLVI2:
  1186                              <1> 	;retn
  1187                              <1> 
  1188                              <1> ;%endif
  1189                              <1> 	
  1190                              <1> ;input AL = index # to stop on
  1191                              <1> setLastValidIndex:
  1192                              <1> 	; 08/11/2023
  1193                              <1> 	;push	dx
  1194 00000820 8B16[641D]          <1> 	mov	dx, [NABMBAR]
  1195 00000824 83C215              <1> 	add	dx, PO_LVI_REG
  1196 00000827 EE                  <1>         out     dx, al
  1197                              <1> 	;pop	dx
  1198 00000828 C3                  <1> 	retn
  1199                              <1> 
  1200                              <1> ; 06/11/2023
  1201                              <1> ;	; 05/11/2023
  1202                              <1> ;setCurrentIndex:
  1203                              <1> ;	;push	dx
  1204                              <1> ;	mov	dx, [NABMBAR]
  1205                              <1> ;	add	dx, PO_CIV_REG
  1206                              <1> ;	out	dx, al
  1207                              <1> ;	;pop	dx
  1208                              <1> ;	retn
  1209                              <1> 
  1210                              <1> ; checks if either shift key has been pressed. Exits with CY if so.
  1211                              <1> ; 
  1212                              <1> check4keyboardstop:
  1213                              <1> 
  1214                              <1> ; 06/11/2023
  1215                              <1> %if 1
  1216                              <1> 	; 19/05/2024
  1217                              <1> 	; 08/11/2023
  1218                              <1> 	; 04/11/2023
  1219 00000829 B401                <1> 	mov	ah, 1
  1220 0000082B CD16                <1> 	int	16h
  1221 0000082D 743C                <1> 	jz	short _cksr
  1222                              <1> 
  1223 0000082F 30E4                <1> 	xor	ah, ah
  1224 00000831 CD16                <1> 	int	16h
  1225                              <1> 
  1226                              <1> 	;;;
  1227                              <1> 	; 19/05/2024 (change PCM out volume)
  1228 00000833 3C2B                <1> 	cmp	al, '+'
  1229 00000835 750B                <1> 	jne	short p_1
  1230                              <1> 	
  1231 00000837 A0[6C08]            <1> 	mov	al, [volume]
  1232 0000083A 3C00                <1> 	cmp	al, 0
  1233 0000083C 762B                <1> 	jna	short p_3
  1234 0000083E FEC8                <1> 	dec	al
  1235 00000840 EB0D                <1> 	jmp	short p_2
  1236                              <1> p_1:
  1237 00000842 3C2D                <1> 	cmp	al, '-'
  1238 00000844 7524                <1> 	jne	short p_4
  1239                              <1> 
  1240 00000846 A0[6C08]            <1> 	mov	al, [volume]
  1241 00000849 3C1F                <1> 	cmp	al, 31
  1242 0000084B 731C                <1> 	jnb	short p_3
  1243 0000084D FEC0                <1> 	inc	al
  1244                              <1> p_2:
  1245 0000084F A2[6C08]            <1> 	mov	[volume], al
  1246 00000852 88C4                <1> 	mov	ah, al
  1247 00000854 8B16[621D]          <1> 	mov     dx, [NAMBAR]
  1248                              <1>   	;add    dx, CODEC_MASTER_VOL_REG
  1249 00000858 83C218              <1> 	add	dx, CODEC_PCM_OUT_REG
  1250 0000085B EF                  <1> 	out     dx, ax
  1251                              <1> 
  1252 0000085C E82011              <1> 	call    delay1_4ms
  1253 0000085F E81D11              <1>         call    delay1_4ms
  1254 00000862 E81A11              <1>         call    delay1_4ms
  1255 00000865 E81711              <1>         call    delay1_4ms
  1256                              <1> 
  1257 00000868 F8                  <1> 	clc
  1258                              <1> p_3:
  1259 00000869 C3                  <1> 	retn
  1260                              <1> p_4:
  1261                              <1> 	;;;
  1262                              <1> 	
  1263 0000086A F9                  <1> 	stc
  1264                              <1> _cksr:
  1265 0000086B C3                  <1> 	retn
  1266                              <1> 
  1267                              <1> ; 19/05/2024
  1268 0000086C 00                  <1> volume:	db 0
  1269                              <1> 
  1270                              <1> %endif
  1271                              <1> 
  1272                              <1> ; 04/02/2025
  1273                              <1> ; 18/11/2023 (ich_wav3.asm & ich_wav4.asm)
  1274                              <1> ; 15/11/2023 (ich_wav3.asm)	
  1275                              <1> ; 14/11/2023
  1276                              <1> ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1277                              <1> ; --------------------------------------------------------
  1278                              <1> 
  1279                              <1> ;;Note:	At the end of every buffer load,
  1280                              <1> ;;	during buffer switch/swap, there will be discontinuity
  1281                              <1> ;;	between the last converted sample and the 1st sample
  1282                              <1> ;;	of the next buffer.
  1283                              <1> ;;	(like as a dot noises vaguely between normal sound samples)
  1284                              <1> ;;	-To avoid this defect, the 1st sample of
  1285                              <1> ;;	the next buffer may be read from the wav file but
  1286                              <1> ;;	the file pointer would need to be set to 1 sample back
  1287                              <1> ;;	again via seek system call. Time comsumption problem! -
  1288                              <1> ;;
  1289                              <1> ;;	Erdogan Tan - 15/11/2023
  1290                              <1> ;;
  1291                              <1> ;;	((If entire wav data would be loaded at once.. conversion
  1292                              <1> ;;	defect/noise would disappear.. but for DOS, to keep
  1293                              <1> ;;	64KB buffer limit is important also it is important
  1294                              <1> ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1295                              <1> ;;	I have tested this program by using 2-30MB wav files.))
  1296                              <1> ;;
  1297                              <1> ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1298                              <1> ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1299                              <1> ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1300                              <1> ;;			Realtek ALC850 codec.
  1301                              <1> ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1302                              <1> 
  1303                              <1> load_8khz_mono_8_bit:
  1304                              <1> 	; 15/11/2023
  1305                              <1> 	; 14/11/2023
  1306                              <1> 	; 13/11/2023
  1307 0000086D F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1308                              <1> 					; last of the file?
  1309 00000872 7402                <1> 	jz	short lff8m_0		; no
  1310 00000874 F9                  <1> 	stc
  1311 00000875 C3                  <1> 	retn
  1312                              <1> 
  1313                              <1> lff8m_0:
  1314 00000876 8EC0                <1> 	mov	es, ax ; buffer segment
  1315 00000878 31FF                <1> 	xor	di, di
  1316 0000087A BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1317                              <1> 	; ds = cs
  1318                              <1> 
  1319                              <1> 	; load file into memory
  1320 0000087D 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1321 00000881 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1322 00000885 B43F                <1>        	mov	ah, 3Fh
  1323 00000887 CD21                <1> 	int	21h
  1324                              <1> 	;jc	short lff8m_5 ; error !
  1325                              <1> 	; 14/11/2023
  1326 00000889 7303                <1> 	jnc	short lff8m_6
  1327 0000088B E98B00              <1> 	jmp	lff8m_5
  1328                              <1> 
  1329                              <1> lff8m_6:
  1330 0000088E 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1331 00000890 21C0                <1> 	and	ax, ax
  1332                              <1> 	;jz	short lff8m_3
  1333                              <1> 	; 15/11/2023
  1334 00000892 747E                <1> 	jz	short lff8_eof
  1335                              <1> 
  1336 00000894 89C1                <1> 	mov	cx, ax	; byte count
  1337                              <1> lff8m_1:
  1338 00000896 AC                  <1> 	lodsb
  1339 00000897 A2[7619]            <1> 	mov	[previous_val], al
  1340 0000089A 2C80                <1> 	sub	al, 80h
  1341 0000089C C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1342 0000089F AB                  <1> 	stosw		; original sample (left channel)
  1343 000008A0 AB                  <1> 	stosw		; original sample (right channel)
  1344                              <1> 	;xor	ax, ax
  1345                              <1> 	; 14/11/2023
  1346 000008A1 B080                <1> 	mov	al, 80h
  1347 000008A3 49                  <1> 	dec	cx
  1348 000008A4 7402                <1> 	jz	short lff8m_2
  1349 000008A6 8A04                <1> 	mov	al, [si]
  1350                              <1> lff8m_2:
  1351                              <1> 	;mov	[next_val], ax
  1352 000008A8 88C7                <1> 	mov	bh, al	; [next_val]
  1353 000008AA 8A26[7619]          <1> 	mov	ah, [previous_val]
  1354 000008AE 00E0                <1> 	add	al, ah	; [previous_val]
  1355 000008B0 D0D8                <1> 	rcr	al, 1
  1356 000008B2 88C2                <1> 	mov	dl, al	; this is interpolated middle (3th) sample
  1357 000008B4 00E0                <1> 	add	al, ah	; [previous_val]
  1358 000008B6 D0D8                <1> 	rcr	al, 1	
  1359 000008B8 88C3                <1> 	mov	bl, al 	; this is temporary interpolation value
  1360 000008BA 00E0                <1> 	add	al, ah	; [previous_val]
  1361 000008BC D0D8                <1> 	rcr	al, 1
  1362 000008BE 2C80                <1> 	sub	al, 80h
  1363 000008C0 C1E008              <1> 	shl	ax, 8
  1364 000008C3 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1365 000008C4 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1366 000008C5 88D8                <1> 	mov	al, bl
  1367 000008C7 00D0                <1> 	add	al, dl
  1368 000008C9 D0D8                <1> 	rcr	al, 1
  1369 000008CB 2C80                <1> 	sub	al, 80h
  1370 000008CD C1E008              <1> 	shl	ax, 8
  1371 000008D0 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1372 000008D1 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1373 000008D2 88D0                <1> 	mov	al, dl
  1374 000008D4 2C80                <1> 	sub	al, 80h
  1375 000008D6 C1E008              <1> 	shl	ax, 8
  1376 000008D9 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1377 000008DA AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1378                              <1> 	;mov	al, [next_val]
  1379 000008DB 88F8                <1> 	mov	al, bh
  1380 000008DD 00D0                <1> 	add	al, dl
  1381 000008DF D0D8                <1> 	rcr	al, 1
  1382 000008E1 88C3                <1> 	mov	bl, al	; this is temporary interpolation value
  1383 000008E3 00D0                <1> 	add	al, dl
  1384 000008E5 D0D8                <1> 	rcr	al, 1
  1385 000008E7 2C80                <1> 	sub	al, 80h
  1386 000008E9 C1E008              <1> 	shl	ax, 8
  1387 000008EC AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1388 000008ED AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1389                              <1> 	;mov	al, [next_val]
  1390 000008EE 88F8                <1> 	mov	al, bh
  1391 000008F0 00D8                <1> 	add	al, bl
  1392 000008F2 D0D8                <1> 	rcr	al, 1
  1393 000008F4 2C80                <1> 	sub	al, 80h
  1394 000008F6 C1E008              <1> 	shl	ax, 8
  1395 000008F9 AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1396 000008FA AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1397                              <1> 	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1398 000008FB 09C9                <1> 	or	cx, cx
  1399 000008FD 7597                <1> 	jnz	short lff8m_1
  1400                              <1> 
  1401                              <1> 	; --------------
  1402                              <1> 
  1403                              <1> lff8s_3:
  1404                              <1> lff8m_3:
  1405                              <1> lff8s2_3:
  1406                              <1> lff8m2_3:
  1407                              <1> lff16s_3:
  1408                              <1> lff16m_3:
  1409                              <1> lff16s2_3:
  1410                              <1> lff16m2_3:
  1411                              <1> lff24_3:
  1412                              <1> lff32_3:
  1413                              <1> lff44_3:
  1414                              <1> lff22_3:
  1415                              <1> lff11_3:
  1416 000008FF 8B0E[4C06]          <1> 	mov	cx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1417 00000903 D1E1                <1> 	shl	cx, 1	; byte count
  1418 00000905 29F9                <1> 	sub	cx, di
  1419 00000907 7606                <1> 	jna	short lff8m_4
  1420                              <1> 	;inc	cx
  1421 00000909 D1E9                <1> 	shr	cx, 1
  1422 0000090B 31C0                <1> 	xor	ax, ax	; fill (remain part of) buffer with zeros
  1423 0000090D F3AB                <1> 	rep	stosw
  1424                              <1> lff8m_4:
  1425 0000090F 0E                  <1> 	push	cs
  1426 00000910 07                  <1> 	pop	es
  1427 00000911 C3                  <1> 	retn
  1428                              <1> 
  1429                              <1> lff8_eof:
  1430                              <1> lff16_eof:
  1431                              <1> lff24_eof:
  1432                              <1> lff32_eof:
  1433                              <1> lff44_eof:
  1434                              <1> lff22_eof:
  1435                              <1> lff11_eof:
  1436                              <1> 	; 15/11/2023
  1437 00000912 C606[601D]01        <1> 	mov	byte [flags], ENDOFFILE
  1438 00000917 EBE6                <1> 	jmp	short lff8m_3
  1439                              <1> 
  1440                              <1> lff8s_5:
  1441                              <1> lff8m_5:
  1442                              <1> lff8s2_5:
  1443                              <1> lff8m2_5:
  1444                              <1> lff16s_5:
  1445                              <1> lff16m_5:
  1446                              <1> lff16s2_5:
  1447                              <1> lff16m2_5:
  1448                              <1> lff24_5:
  1449                              <1> lff32_5:
  1450                              <1> lff44_5:
  1451                              <1> lff22_5:
  1452                              <1> lff11_5:
  1453 00000919 B021                <1> 	mov	al, '!'  ; error
  1454 0000091B E8FCFD              <1> 	call	tL0
  1455                              <1> 	
  1456                              <1> 	;jmp	short lff8m_3
  1457                              <1> 	; 15/11/2023
  1458 0000091E EBF2                <1> 	jmp	lff8_eof
  1459                              <1> 
  1460                              <1> 	; --------------
  1461                              <1> 
  1462                              <1> load_8khz_stereo_8_bit:
  1463                              <1> 	; 15/11/2023
  1464                              <1> 	; 14/11/2023
  1465                              <1> 	; 13/11/2023
  1466 00000920 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1467                              <1> 					; last of the file?
  1468 00000925 7402                <1> 	jz	short lff8s_0		; no
  1469 00000927 F9                  <1> 	stc
  1470 00000928 C3                  <1> 	retn
  1471                              <1> 
  1472                              <1> lff8s_0:
  1473 00000929 8EC0                <1> 	mov	es, ax ; buffer segment
  1474 0000092B 31FF                <1> 	xor	di, di
  1475 0000092D BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1476                              <1> 	; ds = cs
  1477                              <1> 
  1478                              <1> 	; load file into memory
  1479 00000930 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1480 00000934 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1481 00000938 B43F                <1>        	mov	ah, 3Fh
  1482 0000093A CD21                <1> 	int	21h
  1483 0000093C 72DB                <1> 	jc	short lff8s_5 ; error !
  1484                              <1> 
  1485 0000093E 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1486                              <1> 	
  1487 00000940 D1E8                <1> 	shr	ax, 1
  1488                              <1> 	;;and	ax, ax
  1489                              <1> 	;jz	short lff8s_3
  1490                              <1> 	; 15/11/2023
  1491 00000942 74CE                <1> 	jz	short lff8_eof
  1492                              <1> 
  1493 00000944 89C1                <1> 	mov	cx, ax	; word count
  1494                              <1> lff8s_1:
  1495 00000946 AC                  <1> 	lodsb
  1496 00000947 A2[7619]            <1> 	mov	[previous_val_l], al
  1497 0000094A 2C80                <1> 	sub	al, 80h
  1498 0000094C C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1499 0000094F AB                  <1> 	stosw		; original sample (L)
  1500 00000950 AC                  <1> 	lodsb
  1501 00000951 A2[7819]            <1> 	mov	[previous_val_r], al
  1502 00000954 2C80                <1> 	sub	al, 80h
  1503 00000956 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1504 00000959 AB                  <1> 	stosw		; original sample (R)
  1505                              <1> 
  1506                              <1> 	;xor	ax, ax
  1507                              <1> 	; 14/11/2023
  1508 0000095A B88080              <1> 	mov	ax, 8080h
  1509 0000095D 49                  <1> 	dec	cx
  1510 0000095E 7402                <1> 	jz	short lff8s_2
  1511                              <1> 		; convert 8 bit sample to 16 bit sample
  1512 00000960 8B04                <1> 	mov	ax, [si]
  1513                              <1> lff8s_2:
  1514 00000962 A2[7A19]            <1> 	mov	[next_val_l], al
  1515 00000965 8826[7C19]          <1> 	mov	[next_val_r], ah
  1516 00000969 8A26[7619]          <1> 	mov	ah, [previous_val_l]
  1517 0000096D 00E0                <1> 	add	al, ah
  1518 0000096F D0D8                <1> 	rcr	al, 1
  1519 00000971 88C2                <1> 	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1520 00000973 00E0                <1> 	add	al, ah
  1521 00000975 D0D8                <1> 	rcr	al, 1
  1522 00000977 88C3                <1> 	mov	bl, al	; this is temporary interpolation value (L)
  1523 00000979 00E0                <1> 	add	al, ah
  1524 0000097B D0D8                <1> 	rcr	al, 1
  1525 0000097D 2C80                <1> 	sub	al, 80h
  1526 0000097F C1E008              <1> 	shl	ax, 8
  1527 00000982 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1528 00000983 A0[7C19]            <1> 	mov	al, [next_val_r]
  1529 00000986 8A26[7819]          <1> 	mov	ah, [previous_val_r]
  1530 0000098A 00E0                <1> 	add	al, ah
  1531 0000098C D0D8                <1> 	rcr	al, 1
  1532 0000098E 88C6                <1> 	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1533 00000990 00E0                <1> 	add	al, ah
  1534 00000992 D0D8                <1> 	rcr	al, 1
  1535 00000994 88C7                <1> 	mov	bh, al	; this is temporary interpolation value (R)
  1536 00000996 00E0                <1> 	add	al, ah
  1537 00000998 D0D8                <1> 	rcr	al, 1
  1538 0000099A 2C80                <1> 	sub	al, 80h
  1539 0000099C C1E008              <1> 	shl	ax, 8
  1540 0000099F AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1541 000009A0 88D8                <1> 	mov	al, bl
  1542 000009A2 00D0                <1> 	add	al, dl
  1543 000009A4 D0D8                <1> 	rcr	al, 1
  1544 000009A6 2C80                <1> 	sub	al, 80h
  1545 000009A8 C1E008              <1> 	shl	ax, 8
  1546 000009AB AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1547 000009AC 88F8                <1> 	mov	al, bh
  1548 000009AE 00F0                <1> 	add	al, dh
  1549 000009B0 D0D8                <1> 	rcr	al, 1
  1550 000009B2 2C80                <1> 	sub	al, 80h
  1551 000009B4 C1E008              <1> 	shl	ax, 8
  1552 000009B7 AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1553 000009B8 88D0                <1> 	mov	al, dl
  1554 000009BA 2C80                <1> 	sub	al, 80h
  1555 000009BC C1E008              <1> 	shl	ax, 8
  1556 000009BF AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1557 000009C0 88F0                <1> 	mov	al, dh
  1558 000009C2 2C80                <1> 	sub	al, 80h
  1559 000009C4 C1E008              <1> 	shl	ax, 8
  1560 000009C7 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1561 000009C8 A0[7A19]            <1> 	mov	al, [next_val_l]
  1562 000009CB 00D0                <1> 	add	al, dl
  1563 000009CD D0D8                <1> 	rcr	al, 1
  1564 000009CF 88C3                <1> 	mov	bl, al	; this is temporary interpolation value (L)
  1565 000009D1 00D0                <1> 	add	al, dl
  1566 000009D3 D0D8                <1> 	rcr	al, 1
  1567 000009D5 2C80                <1> 	sub	al, 80h
  1568 000009D7 C1E008              <1> 	shl	ax, 8
  1569 000009DA AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1570 000009DB A0[7C19]            <1> 	mov	al, [next_val_r]
  1571 000009DE 00F0                <1> 	add	al, dh
  1572 000009E0 D0D8                <1> 	rcr	al, 1
  1573 000009E2 88C7                <1> 	mov	bh, al	; this is temporary interpolation value (R)
  1574 000009E4 00F0                <1> 	add	al, dh
  1575 000009E6 D0D8                <1> 	rcr	al, 1
  1576 000009E8 2C80                <1> 	sub	al, 80h
  1577 000009EA C1E008              <1> 	shl	ax, 8
  1578 000009ED AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1579 000009EE A0[7A19]            <1> 	mov	al, [next_val_l]
  1580 000009F1 00D8                <1> 	add	al, bl
  1581 000009F3 D0D8                <1> 	rcr	al, 1
  1582 000009F5 2C80                <1> 	sub	al, 80h
  1583 000009F7 C1E008              <1> 	shl	ax, 8
  1584 000009FA AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1585 000009FB A0[7C19]            <1> 	mov	al, [next_val_r]
  1586 000009FE 00F8                <1> 	add	al, bh
  1587 00000A00 D0D8                <1> 	rcr	al, 1
  1588 00000A02 2C80                <1> 	sub	al, 80h
  1589 00000A04 C1E008              <1> 	shl	ax, 8
  1590 00000A07 AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1591                              <1> 	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1592 00000A08 E303                <1> 	jcxz	lff8s_6
  1593 00000A0A E939FF              <1> 	jmp	lff8s_1
  1594                              <1> lff8s_6:
  1595 00000A0D E9EFFE              <1> 	jmp	lff8s_3
  1596                              <1> 
  1597                              <1> load_8khz_mono_16_bit:
  1598                              <1> 	; 13/11/2023
  1599 00000A10 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1600                              <1> 					; last of the file?
  1601 00000A15 7402                <1> 	jz	short lff8m2_0		; no
  1602 00000A17 F9                  <1> 	stc
  1603 00000A18 C3                  <1> 	retn
  1604                              <1> 
  1605                              <1> lff8m2_0:
  1606 00000A19 8EC0                <1> 	mov	es, ax ; buffer segment
  1607 00000A1B 31FF                <1> 	xor	di, di
  1608 00000A1D BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1609                              <1> 	; ds = cs
  1610                              <1> 
  1611                              <1> 	; load file into memory
  1612 00000A20 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1613 00000A24 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1614 00000A28 B43F                <1>        	mov	ah, 3Fh
  1615 00000A2A CD21                <1> 	int	21h
  1616 00000A2C 7270                <1> 	jc	short lff8m2_7 ; error !
  1617                              <1> 
  1618 00000A2E 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1619                              <1> 	
  1620 00000A30 D1E8                <1> 	shr	ax, 1
  1621                              <1> 	;and	ax, ax
  1622 00000A32 7503                <1> 	jnz	short lff8m2_8
  1623                              <1> 	;jmp	lff8m2_3
  1624                              <1> 	; 15/11/2023
  1625 00000A34 E9DBFE              <1> 	jmp	lff8_eof
  1626                              <1> 
  1627                              <1> lff8m2_8:
  1628 00000A37 89C1                <1> 	mov	cx, ax	; word count
  1629                              <1> lff8m2_1:
  1630 00000A39 AD                  <1> 	lodsw
  1631 00000A3A AB                  <1> 	stosw		; original sample (left channel)
  1632 00000A3B AB                  <1> 	stosw		; original sample (right channel)
  1633 00000A3C 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1634 00000A3F A3[7619]            <1> 	mov	[previous_val], ax
  1635 00000A42 31C0                <1> 	xor	ax, ax
  1636 00000A44 49                  <1> 	dec	cx
  1637 00000A45 7402                <1> 	jz	short lff8m2_2
  1638 00000A47 8B04                <1> 	mov	ax, [si]
  1639                              <1> lff8m2_2:
  1640 00000A49 80C480              <1> 	add	ah, 80h ; convert sound level to 0-65535 format
  1641 00000A4C 89C5                <1> 	mov	bp, ax	; [next_val]
  1642 00000A4E 0306[7619]          <1> 	add	ax, [previous_val]
  1643 00000A52 D1D8                <1> 	rcr	ax, 1
  1644 00000A54 89C2                <1> 	mov	dx, ax	; this is interpolated middle (3th) sample
  1645 00000A56 0306[7619]          <1> 	add	ax, [previous_val]
  1646 00000A5A D1D8                <1> 	rcr	ax, 1	; this is temporary interpolation value
  1647 00000A5C 89C3                <1> 	mov	bx, ax
  1648 00000A5E 0306[7619]          <1> 	add	ax, [previous_val]
  1649 00000A62 D1D8                <1> 	rcr	ax, 1
  1650 00000A64 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1651 00000A67 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1652 00000A68 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1653 00000A69 89D8                <1> 	mov	ax, bx
  1654 00000A6B 01D0                <1> 	add	ax, dx
  1655 00000A6D D1D8                <1> 	rcr	ax, 1
  1656 00000A6F 80EC80              <1> 	sub	ah, 80h
  1657 00000A72 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1658 00000A73 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1659 00000A74 89D0                <1> 	mov	ax, dx
  1660 00000A76 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1661 00000A79 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1662 00000A7A AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1663 00000A7B 89E8                <1> 	mov	ax, bp
  1664 00000A7D 01D0                <1> 	add	ax, dx
  1665 00000A7F D1D8                <1> 	rcr	ax, 1
  1666 00000A81 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value
  1667 00000A83 01D0                <1> 	add	ax, dx
  1668 00000A85 D1D8                <1> 	rcr	ax, 1
  1669 00000A87 80EC80              <1> 	sub	ah, 80h
  1670 00000A8A AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1671 00000A8B AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1672 00000A8C 89E8                <1> 	mov	ax, bp
  1673 00000A8E 01D8                <1> 	add	ax, bx
  1674 00000A90 D1D8                <1> 	rcr	ax, 1
  1675 00000A92 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1676 00000A95 AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1677 00000A96 AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1678                              <1> 	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1679 00000A97 09C9                <1> 	or	cx, cx
  1680 00000A99 759E                <1> 	jnz	short lff8m2_1
  1681 00000A9B E961FE              <1> 	jmp	lff8m2_3
  1682                              <1> 
  1683                              <1> lff8m2_7:
  1684                              <1> lff8s2_7:
  1685 00000A9E E978FE              <1> 	jmp	lff8m2_5  ; error
  1686                              <1> 
  1687                              <1> load_8khz_stereo_16_bit:
  1688                              <1> 	; 16/11/2023
  1689                              <1> 	; 15/11/2023
  1690                              <1> 	; 13/11/2023
  1691 00000AA1 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1692                              <1> 					; last of the file?
  1693 00000AA6 7402                <1> 	jz	short lff8s2_0		; no
  1694 00000AA8 F9                  <1> 	stc
  1695 00000AA9 C3                  <1> 	retn
  1696                              <1> 
  1697                              <1> lff8s2_0:
  1698 00000AAA 8EC0                <1> 	mov	es, ax ; buffer segment
  1699 00000AAC 31FF                <1> 	xor	di, di
  1700 00000AAE BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1701                              <1> 	; ds = cs
  1702                              <1> 
  1703                              <1> 	; load file into memory
  1704 00000AB1 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1705 00000AB5 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1706 00000AB9 B43F                <1>        	mov	ah, 3Fh
  1707 00000ABB CD21                <1> 	int	21h
  1708 00000ABD 72DF                <1> 	jc	short lff8s2_7 ; error !
  1709                              <1> 
  1710 00000ABF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1711                              <1> 	
  1712 00000AC1 C1E802              <1> 	shr	ax, 2	; 16/11/2023
  1713                              <1> 	;and	ax, ax
  1714 00000AC4 7503                <1> 	jnz	short lff8s2_8
  1715                              <1> 	;jmp	lff8s2_3
  1716                              <1> 	; 15/11/2023
  1717 00000AC6 E949FE              <1> 	jmp	lff8_eof
  1718                              <1> 
  1719                              <1> lff8s2_8:
  1720 00000AC9 89C1                <1> 	mov	cx, ax ; dword count
  1721                              <1> lff8s2_1:
  1722 00000ACB AD                  <1> 	lodsw
  1723 00000ACC AB                  <1> 	stosw		; original sample (L)
  1724                              <1> 	; 15/11/2023
  1725 00000ACD 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1726 00000AD0 A3[7619]            <1> 	mov	[previous_val_l], ax
  1727 00000AD3 AD                  <1> 	lodsw
  1728 00000AD4 AB                  <1> 	stosw		; original sample (R)
  1729 00000AD5 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1730 00000AD8 A3[7819]            <1> 	mov	[previous_val_r], ax
  1731 00000ADB 31D2                <1> 	xor	dx, dx
  1732 00000ADD 31C0                <1> 	xor	ax, ax
  1733                              <1> 	; 16/11/2023
  1734 00000ADF 49                  <1> 	dec	cx
  1735 00000AE0 7405                <1> 	jz	short lff8s2_2
  1736 00000AE2 8B04                <1> 	mov	ax, [si]
  1737 00000AE4 8B5402              <1> 	mov	dx, [si+2]
  1738                              <1> lff8s2_2:
  1739 00000AE7 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1740 00000AEA A3[7A19]            <1> 	mov	[next_val_l], ax
  1741 00000AED 80C680              <1> 	add	dh, 80h	; convert sound level to 0-65535 format
  1742 00000AF0 8916[7C19]          <1> 	mov	[next_val_r], dx
  1743 00000AF4 0306[7619]          <1> 	add	ax, [previous_val_l]
  1744 00000AF8 D1D8                <1> 	rcr	ax, 1
  1745 00000AFA 89C2                <1> 	mov	dx, ax	; this is interpolated middle (3th) sample (L)
  1746 00000AFC 0306[7619]          <1> 	add	ax, [previous_val_l]
  1747 00000B00 D1D8                <1> 	rcr	ax, 1
  1748 00000B02 89C3                <1> 	mov	bx, ax 	; this is temporary interpolation value (L)
  1749 00000B04 0306[7619]          <1> 	add	ax, [previous_val_l]
  1750 00000B08 D1D8                <1> 	rcr	ax, 1
  1751 00000B0A 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1752 00000B0D AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1753 00000B0E A1[7C19]            <1> 	mov	ax, [next_val_r]
  1754 00000B11 0306[7819]          <1> 	add	ax, [previous_val_r]
  1755 00000B15 D1D8                <1> 	rcr	ax, 1
  1756 00000B17 89C5                <1> 	mov	bp, ax	; this is interpolated middle (3th) sample (R)
  1757 00000B19 0306[7819]          <1> 	add	ax, [previous_val_r]
  1758 00000B1D D1D8                <1> 	rcr	ax, 1
  1759 00000B1F 50                  <1> 	push	ax ; *	; this is temporary interpolation value (R)
  1760 00000B20 0306[7819]          <1> 	add	ax, [previous_val_r]
  1761 00000B24 D1D8                <1> 	rcr	ax, 1
  1762 00000B26 80EC80              <1> 	sub	ah, 80h
  1763 00000B29 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1764 00000B2A 89D8                <1> 	mov	ax, bx
  1765 00000B2C 01D0                <1> 	add	ax, dx
  1766 00000B2E D1D8                <1> 	rcr	ax, 1
  1767 00000B30 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1768 00000B33 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1769 00000B34 58                  <1> 	pop	ax ; *
  1770 00000B35 01E8                <1> 	add	ax, bp
  1771 00000B37 D1D8                <1> 	rcr	ax, 1
  1772 00000B39 80EC80              <1> 	sub	ah, 80h
  1773 00000B3C AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1774 00000B3D 89D0                <1> 	mov	ax, dx
  1775 00000B3F 80EC80              <1> 	sub	ah, 80h
  1776 00000B42 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1777 00000B43 89E8                <1> 	mov	ax, bp
  1778 00000B45 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1779 00000B48 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1780 00000B49 A1[7A19]            <1> 	mov	ax, [next_val_l]
  1781 00000B4C 01D0                <1> 	add	ax, dx
  1782 00000B4E D1D8                <1> 	rcr	ax, 1
  1783 00000B50 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value (L)
  1784 00000B52 01D0                <1> 	add	ax, dx
  1785 00000B54 D1D8                <1> 	rcr	ax, 1
  1786 00000B56 80EC80              <1> 	sub	ah, 80h
  1787 00000B59 AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1788 00000B5A A1[7C19]            <1> 	mov	ax, [next_val_r]
  1789 00000B5D 01E8                <1> 	add	ax, bp
  1790 00000B5F D1D8                <1> 	rcr	ax, 1
  1791 00000B61 50                  <1> 	push	ax ; ** ; this is temporary interpolation value (R)
  1792 00000B62 01E8                <1> 	add	ax, bp
  1793 00000B64 D1D8                <1> 	rcr	ax, 1
  1794 00000B66 80EC80              <1> 	sub	ah, 80h
  1795 00000B69 AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1796 00000B6A A1[7A19]            <1> 	mov	ax, [next_val_l]
  1797 00000B6D 01D8                <1> 	add	ax, bx
  1798 00000B6F D1D8                <1> 	rcr	ax, 1
  1799 00000B71 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1800 00000B74 AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1801 00000B75 58                  <1> 	pop	ax ; **
  1802 00000B76 0306[7C19]          <1> 	add	ax, [next_val_r]
  1803 00000B7A D1D8                <1> 	rcr	ax, 1
  1804 00000B7C 80EC80              <1> 	sub	ah, 80h
  1805 00000B7F AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1806                              <1> 	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1807 00000B80 E303                <1> 	jcxz	lff8_s2_9
  1808 00000B82 E946FF              <1> 	jmp	lff8s2_1
  1809                              <1> lff8_s2_9:
  1810 00000B85 E977FD              <1> 	jmp	lff8s2_3
  1811                              <1> 
  1812                              <1> ; .....................
  1813                              <1> 
  1814                              <1> load_16khz_mono_8_bit:
  1815                              <1> 	; 14/11/2023
  1816                              <1> 	; 13/11/2023
  1817 00000B88 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1818                              <1> 					; last of the file?
  1819 00000B8D 7402                <1> 	jz	short lff16m_0		; no
  1820 00000B8F F9                  <1> 	stc
  1821 00000B90 C3                  <1> 	retn
  1822                              <1> 
  1823                              <1> lff16m_0:
  1824 00000B91 8EC0                <1> 	mov	es, ax ; buffer segment
  1825 00000B93 31FF                <1> 	xor	di, di
  1826 00000B95 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1827                              <1> 	; ds = cs
  1828                              <1> 
  1829                              <1> 	; load file into memory
  1830 00000B98 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1831 00000B9C 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1832 00000BA0 B43F                <1>        	mov	ah, 3Fh
  1833 00000BA2 CD21                <1> 	int	21h
  1834 00000BA4 7243                <1> 	jc	short lff16m_7 ; error !
  1835                              <1> 
  1836 00000BA6 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1837                              <1> 	
  1838 00000BA8 21C0                <1> 	and	ax, ax
  1839 00000BAA 7503                <1> 	jnz	short lff16m_8
  1840                              <1> 	;jmp	lff16m_3
  1841                              <1> 	; 15/11/2023
  1842 00000BAC E963FD              <1> 	jmp	lff16_eof
  1843                              <1> 
  1844                              <1> lff16m_8:
  1845 00000BAF 89C1                <1> 	mov	cx, ax	; byte count
  1846                              <1> lff16m_1:
  1847 00000BB1 AC                  <1> 	lodsb
  1848                              <1> 	;mov	[previous_val], al
  1849 00000BB2 88C3                <1> 	mov	bl, al
  1850 00000BB4 2C80                <1> 	sub	al, 80h
  1851 00000BB6 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1852 00000BB9 AB                  <1> 	stosw		; original sample (left channel)
  1853 00000BBA AB                  <1> 	stosw		; original sample (right channel)
  1854                              <1> 	;xor	ax, ax
  1855                              <1> 	; 14/11/22023
  1856 00000BBB B080                <1> 	mov	al, 80h
  1857 00000BBD 49                  <1> 	dec	cx
  1858 00000BBE 7402                <1> 	jz	short lff16m_2
  1859 00000BC0 8A04                <1> 	mov	al, [si]
  1860                              <1> lff16m_2:
  1861                              <1> 	;mov	[next_val], al
  1862 00000BC2 88C7                <1> 	mov	bh, al
  1863                              <1> 	;add	al, [previous_val]
  1864 00000BC4 00D8                <1> 	add	al, bl
  1865 00000BC6 D0D8                <1> 	rcr	al, 1
  1866 00000BC8 88C2                <1> 	mov	dl, al	; this is interpolated middle (temp) sample
  1867                              <1> 	;add	al, [previous_val]
  1868 00000BCA 00D8                <1> 	add	al, bl
  1869 00000BCC D0D8                <1> 	rcr	al, 1
  1870 00000BCE 2C80                <1> 	sub	al, 80h
  1871 00000BD0 C1E008              <1> 	shl	ax, 8
  1872 00000BD3 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1873 00000BD4 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1874                              <1> 	;mov	al, [next_val]
  1875 00000BD5 88F8                <1> 	mov	al, bh
  1876 00000BD7 00D0                <1> 	add	al, dl
  1877 00000BD9 D0D8                <1> 	rcr	al, 1
  1878 00000BDB 2C80                <1> 	sub	al, 80h
  1879 00000BDD C1E008              <1> 	shl	ax, 8
  1880 00000BE0 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1881 00000BE1 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1882                              <1> 	
  1883                              <1> 	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1884 00000BE2 09C9                <1> 	or	cx, cx
  1885 00000BE4 75CB                <1> 	jnz	short lff16m_1
  1886 00000BE6 E916FD              <1> 	jmp	lff16m_3
  1887                              <1> 
  1888                              <1> lff16m_7:
  1889                              <1> lff16s_7:
  1890 00000BE9 E92DFD              <1> 	jmp	lff16m_5  ; error
  1891                              <1> 
  1892                              <1> load_16khz_stereo_8_bit:
  1893                              <1> 	; 14/11/2023
  1894                              <1> 	; 13/11/2023
  1895 00000BEC F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1896                              <1> 					; last of the file?
  1897 00000BF1 7402                <1> 	jz	short lff16s_0		; no
  1898 00000BF3 F9                  <1> 	stc
  1899 00000BF4 C3                  <1> 	retn
  1900                              <1> 
  1901                              <1> lff16s_0:
  1902 00000BF5 8EC0                <1> 	mov	es, ax ; buffer segment
  1903 00000BF7 31FF                <1> 	xor	di, di
  1904 00000BF9 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1905                              <1> 	; ds = cs
  1906                              <1> 
  1907                              <1> 	; load file into memory
  1908 00000BFC 8B0E[4A06]          <1>         mov	cx, [loadsize]
  1909 00000C00 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  1910 00000C04 B43F                <1>        	mov	ah, 3Fh
  1911 00000C06 CD21                <1> 	int	21h
  1912 00000C08 72DF                <1> 	jc	short lff16s_7 ; error !
  1913                              <1> 
  1914 00000C0A 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1915                              <1> 	
  1916 00000C0C D1E8                <1> 	shr	ax, 1
  1917                              <1> 	;and	ax, ax
  1918 00000C0E 7503                <1> 	jnz	short lff16s_8
  1919                              <1> 	;jmp	lff16s_3
  1920                              <1> 	; 15/11/2023
  1921 00000C10 E9FFFC              <1> 	jmp	lff16_eof
  1922                              <1> 
  1923                              <1> lff16s_8:
  1924 00000C13 89C1                <1> 	mov	cx, ax	; word count
  1925                              <1> lff16s_1:
  1926 00000C15 AC                  <1> 	lodsb
  1927 00000C16 A2[7619]            <1> 	mov	[previous_val_l], al
  1928 00000C19 2C80                <1> 	sub	al, 80h
  1929 00000C1B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1930 00000C1E AB                  <1> 	stosw		; original sample (L)
  1931 00000C1F AC                  <1> 	lodsb
  1932 00000C20 A2[7819]            <1> 	mov	[previous_val_r], al
  1933 00000C23 2C80                <1> 	sub	al, 80h
  1934 00000C25 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1935 00000C28 AB                  <1> 	stosw		; original sample (R)
  1936                              <1> 
  1937                              <1> 	;xor	ax, ax
  1938                              <1> 	; 14/11/2023
  1939 00000C29 B88080              <1> 	mov	ax, 8080h
  1940 00000C2C 49                  <1> 	dec	cx
  1941 00000C2D 7402                <1> 	jz	short lff16s_2
  1942                              <1> 		; convert 8 bit sample to 16 bit sample
  1943 00000C2F 8B04                <1> 	mov	ax, [si]
  1944                              <1> lff16s_2:
  1945                              <1> 	;mov	[next_val_l], al
  1946                              <1> 	;mov	[next_val_r], ah
  1947 00000C31 89C3                <1> 	mov	bx, ax
  1948 00000C33 0206[7619]          <1> 	add	al, [previous_val_l]
  1949 00000C37 D0D8                <1> 	rcr	al, 1
  1950 00000C39 88C2                <1> 	mov	dl, al	; this is temporary interpolation value (L)
  1951 00000C3B 0206[7619]          <1> 	add	al, [previous_val_l]
  1952 00000C3F D0D8                <1> 	rcr	al, 1
  1953 00000C41 2C80                <1> 	sub	al, 80h
  1954 00000C43 C1E008              <1> 	shl	ax, 8
  1955 00000C46 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1956 00000C47 88F8                <1> 	mov	al, bh	; [next_val_r]
  1957 00000C49 0206[7819]          <1> 	add	al, [previous_val_r]
  1958 00000C4D D0D8                <1> 	rcr	al, 1
  1959 00000C4F 88C6                <1> 	mov	dh, al	; this is temporary interpolation value (R)
  1960 00000C51 0206[7819]          <1> 	add	al, [previous_val_r]
  1961 00000C55 D0D8                <1> 	rcr	al, 1
  1962 00000C57 2C80                <1> 	sub	al, 80h
  1963 00000C59 C1E008              <1> 	shl	ax, 8
  1964 00000C5C AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1965 00000C5D 88D0                <1> 	mov	al, dl
  1966 00000C5F 00D8                <1> 	add	al, bl	; [next_val_l]
  1967 00000C61 D0D8                <1> 	rcr	al, 1
  1968 00000C63 2C80                <1> 	sub	al, 80h
  1969 00000C65 C1E008              <1> 	shl	ax, 8
  1970 00000C68 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1971 00000C69 88F0                <1> 	mov	al, dh
  1972 00000C6B 00F8                <1> 	add	al, bh	; [next_val_r]
  1973 00000C6D D0D8                <1> 	rcr	al, 1
  1974 00000C6F 2C80                <1> 	sub	al, 80h
  1975 00000C71 C1E008              <1> 	shl	ax, 8
  1976 00000C74 AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1977                              <1> 	
  1978                              <1> 	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1979 00000C75 09C9                <1> 	or	cx, cx
  1980 00000C77 759C                <1> 	jnz	short lff16s_1
  1981 00000C79 E983FC              <1> 	jmp	lff16s_3
  1982                              <1> 
  1983                              <1> load_16khz_mono_16_bit:
  1984                              <1> 	; 15/11/2023
  1985                              <1> 	; 13/11/2023
  1986 00000C7C F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1987                              <1> 					; last of the file?
  1988 00000C81 7402                <1> 	jz	short lff16m2_0		; no
  1989 00000C83 F9                  <1> 	stc
  1990 00000C84 C3                  <1> 	retn
  1991                              <1> 
  1992                              <1> lff16m2_0:
  1993 00000C85 8EC0                <1> 	mov	es, ax ; buffer segment
  1994 00000C87 31FF                <1> 	xor	di, di
  1995 00000C89 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1996                              <1> 	; ds = cs
  1997                              <1> 
  1998                              <1> 	; load file into memory
  1999 00000C8C 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2000 00000C90 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2001 00000C94 B43F                <1>        	mov	ah, 3Fh
  2002 00000C96 CD21                <1> 	int	21h
  2003 00000C98 7240                <1> 	jc	short lff16m2_7 ; error !
  2004                              <1> 
  2005 00000C9A 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2006                              <1> 	
  2007 00000C9C D1E8                <1> 	shr	ax, 1
  2008                              <1> 	;and	ax, ax
  2009 00000C9E 7503                <1> 	jnz	short lff16m2_8
  2010                              <1> 	;jmp	lff16m2_3
  2011                              <1> 	; 15/11/2023
  2012 00000CA0 E96FFC              <1> 	jmp	lff16_eof
  2013                              <1> 
  2014                              <1> lff16m2_8:
  2015 00000CA3 89C1                <1> 	mov	cx, ax	; word count
  2016                              <1> lff16m2_1:
  2017 00000CA5 AD                  <1> 	lodsw
  2018 00000CA6 AB                  <1> 	stosw		; original sample (left channel)
  2019 00000CA7 AB                  <1> 	stosw		; original sample (right channel)
  2020 00000CA8 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2021                              <1> 	;mov	[previous_val], ax
  2022 00000CAB 89C3                <1> 	mov	bx, ax
  2023 00000CAD 31C0                <1> 	xor	ax, ax
  2024 00000CAF 49                  <1> 	dec	cx
  2025 00000CB0 7402                <1> 	jz	short lff16m2_2
  2026 00000CB2 8B04                <1> 	mov	ax, [si]
  2027                              <1> lff16m2_2:
  2028 00000CB4 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2029 00000CB7 89C5                <1> 	mov	bp, ax	; [next_val]
  2030                              <1> 	;add	ax, [previous_val]
  2031 00000CB9 01D8                <1> 	add	ax, bx
  2032 00000CBB D1D8                <1> 	rcr	ax, 1
  2033 00000CBD 89C2                <1> 	mov	dx, ax	; this is temporary interpolation value
  2034                              <1> 	;add	ax, [previous_val]
  2035 00000CBF 01D8                <1> 	add	ax, bx
  2036 00000CC1 D1D8                <1> 	rcr	ax, 1
  2037 00000CC3 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2038 00000CC6 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  2039 00000CC7 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  2040 00000CC8 89E8                <1> 	mov	ax, bp
  2041 00000CCA 01D0                <1> 	add	ax, dx
  2042 00000CCC D1D8                <1> 	rcr	ax, 1
  2043 00000CCE 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2044 00000CD1 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  2045 00000CD2 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  2046                              <1> 	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2047 00000CD3 09C9                <1> 	or	cx, cx
  2048 00000CD5 75CE                <1> 	jnz	short lff16m2_1
  2049 00000CD7 E925FC              <1> 	jmp	lff16m2_3
  2050                              <1> 
  2051                              <1> lff16m2_7:
  2052                              <1> lff16s2_7:
  2053 00000CDA E93CFC              <1> 	jmp	lff16m2_5  ; error
  2054                              <1> 
  2055                              <1> load_16khz_stereo_16_bit:
  2056                              <1> 	; 16/11/2023
  2057                              <1> 	; 15/11/2023
  2058                              <1> 	; 13/11/2023
  2059 00000CDD F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2060                              <1> 					; last of the file?
  2061 00000CE2 7402                <1> 	jz	short lff16s2_0		; no
  2062 00000CE4 F9                  <1> 	stc
  2063 00000CE5 C3                  <1> 	retn
  2064                              <1> 
  2065                              <1> lff16s2_0:
  2066 00000CE6 8EC0                <1> 	mov	es, ax ; buffer segment
  2067 00000CE8 31FF                <1> 	xor	di, di
  2068 00000CEA BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2069                              <1> 	; ds = cs
  2070                              <1> 
  2071                              <1> 	; load file into memory
  2072 00000CED 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2073 00000CF1 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2074 00000CF5 B43F                <1>        	mov	ah, 3Fh
  2075 00000CF7 CD21                <1> 	int	21h
  2076 00000CF9 72DF                <1> 	jc	short lff16s2_7 ; error !
  2077                              <1> 
  2078 00000CFB 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2079                              <1> 	
  2080                              <1> 	;shr	ax, 1
  2081 00000CFD C1E802              <1> 	shr	ax, 2	; 16/11/2023
  2082                              <1> 	;and	ax, ax
  2083 00000D00 7503                <1> 	jnz	short lff16s2_8
  2084                              <1> 	;jmp	lff16s2_3
  2085                              <1> 	; 15/11/2023
  2086 00000D02 E90DFC              <1> 	jmp	lff16_eof
  2087                              <1> 
  2088                              <1> lff16s2_8:
  2089 00000D05 89C1                <1> 	mov	cx, ax	; dword count
  2090                              <1> lff16s2_1:
  2091 00000D07 AD                  <1> 	lodsw
  2092 00000D08 AB                  <1> 	stosw		; original sample (L)
  2093 00000D09 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2094 00000D0C A3[7619]            <1> 	mov	[previous_val_l], ax
  2095 00000D0F AD                  <1> 	lodsw
  2096 00000D10 AB                  <1> 	stosw		; original sample (R)
  2097 00000D11 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2098 00000D14 A3[7819]            <1> 	mov	[previous_val_r], ax
  2099 00000D17 31D2                <1> 	xor	dx, dx
  2100 00000D19 31C0                <1> 	xor	ax, ax
  2101                              <1> 	; 16/11/2023
  2102 00000D1B 49                  <1> 	dec	cx
  2103 00000D1C 7405                <1> 	jz	short lff16s2_2
  2104 00000D1E 8B04                <1> 	mov	ax, [si]
  2105 00000D20 8B5402              <1> 	mov	dx, [si+2]
  2106                              <1> lff16s2_2:
  2107 00000D23 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2108                              <1> 	;mov	[next_val_l], ax
  2109 00000D26 89C5                <1> 	mov	bp, ax
  2110 00000D28 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format
  2111 00000D2B 8916[7C19]          <1> 	mov	[next_val_r], dx
  2112 00000D2F 0306[7619]          <1> 	add	ax, [previous_val_l]
  2113 00000D33 D1D8                <1> 	rcr	ax, 1
  2114 00000D35 89C2                <1> 	mov	dx, ax	; this is temporary interpolation value (L)
  2115 00000D37 0306[7619]          <1> 	add	ax, [previous_val_l]
  2116 00000D3B D1D8                <1> 	rcr	ax, 1
  2117 00000D3D 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  2118 00000D40 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  2119 00000D41 A1[7C19]            <1> 	mov	ax, [next_val_r]
  2120 00000D44 0306[7819]          <1> 	add	ax, [previous_val_r]
  2121 00000D48 D1D8                <1> 	rcr	ax, 1
  2122 00000D4A 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value (R)
  2123 00000D4C 0306[7819]          <1> 	add	ax, [previous_val_r]
  2124 00000D50 D1D8                <1> 	rcr	ax, 1
  2125 00000D52 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2126 00000D55 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  2127                              <1> 	;mov	ax, [next_val_l]
  2128 00000D56 89E8                <1> 	mov	ax, bp
  2129 00000D58 01D0                <1> 	add	ax, dx
  2130 00000D5A D1D8                <1> 	rcr	ax, 1
  2131 00000D5C 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2132 00000D5F AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  2133 00000D60 A1[7C19]            <1> 	mov	ax, [next_val_r]
  2134 00000D63 01D8                <1> 	add	ax, bx
  2135 00000D65 D1D8                <1> 	rcr	ax, 1
  2136 00000D67 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2137 00000D6A AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  2138                              <1> 	
  2139                              <1> 	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2140 00000D6B 09C9                <1> 	or	cx, cx
  2141 00000D6D 7598                <1> 	jnz	short lff16s2_1
  2142 00000D6F E98DFB              <1> 	jmp	lff16s2_3
  2143                              <1> 
  2144                              <1> ; .....................
  2145                              <1> 
  2146                              <1> load_24khz_mono_8_bit:
  2147                              <1> 	; 15/11/2023
  2148 00000D72 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2149                              <1> 					; last of the file?
  2150 00000D77 7402                <1> 	jz	short lff24m_0		; no
  2151 00000D79 F9                  <1> 	stc
  2152 00000D7A C3                  <1> 	retn
  2153                              <1> 
  2154                              <1> lff24m_0:
  2155 00000D7B 8EC0                <1> 	mov	es, ax ; buffer segment
  2156 00000D7D 31FF                <1> 	xor	di, di
  2157 00000D7F BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2158                              <1> 	; ds = cs
  2159                              <1> 
  2160                              <1> 	; load file into memory
  2161 00000D82 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2162 00000D86 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2163 00000D8A B43F                <1>        	mov	ah, 3Fh
  2164 00000D8C CD21                <1> 	int	21h
  2165 00000D8E 722E                <1> 	jc	short lff24m_7 ; error !
  2166                              <1> 
  2167 00000D90 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2168                              <1> 	
  2169 00000D92 21C0                <1> 	and	ax, ax
  2170 00000D94 7503                <1> 	jnz	short lff24m_8
  2171 00000D96 E979FB              <1> 	jmp	lff24_eof
  2172                              <1> 
  2173                              <1> lff24m_8:
  2174 00000D99 89C1                <1> 	mov	cx, ax	; byte count
  2175                              <1> lff24m_1:
  2176 00000D9B AC                  <1> 	lodsb
  2177                              <1> 	;mov	[previous_val], al
  2178 00000D9C 88C3                <1> 	mov	bl, al
  2179 00000D9E 2C80                <1> 	sub	al, 80h
  2180 00000DA0 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2181 00000DA3 AB                  <1> 	stosw		; original sample (left channel)
  2182 00000DA4 AB                  <1> 	stosw		; original sample (right channel)
  2183                              <1> 	;xor	ax, ax
  2184 00000DA5 B080                <1> 	mov	al, 80h
  2185 00000DA7 49                  <1> 	dec	cx
  2186 00000DA8 7402                <1> 	jz	short lff24m_2
  2187 00000DAA 8A04                <1> 	mov	al, [si]
  2188                              <1> lff24m_2:
  2189                              <1> 	;;mov	[next_val], al
  2190                              <1> 	;mov	bh, al
  2191                              <1> 	;add	al, [previous_val]
  2192 00000DAC 00D8                <1> 	add	al, bl
  2193 00000DAE D0D8                <1> 	rcr	al, 1
  2194 00000DB0 2C80                <1> 	sub	al, 80h
  2195 00000DB2 C1E008              <1> 	shl	ax, 8
  2196 00000DB5 AB                  <1> 	stosw		; this is interpolated sample (L)
  2197 00000DB6 AB                  <1> 	stosw		; this is interpolated sample (R)
  2198                              <1> 	
  2199                              <1> 	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2200 00000DB7 09C9                <1> 	or	cx, cx
  2201 00000DB9 75E0                <1> 	jnz	short lff24m_1
  2202 00000DBB E941FB              <1> 	jmp	lff24_3
  2203                              <1> 
  2204                              <1> lff24m_7:
  2205                              <1> lff24s_7:
  2206 00000DBE E958FB              <1> 	jmp	lff24_5  ; error
  2207                              <1> 
  2208                              <1> load_24khz_stereo_8_bit:
  2209                              <1> 	; 15/11/2023
  2210 00000DC1 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2211                              <1> 					; last of the file?
  2212 00000DC6 7402                <1> 	jz	short lff24s_0		; no
  2213 00000DC8 F9                  <1> 	stc
  2214 00000DC9 C3                  <1> 	retn
  2215                              <1> 
  2216                              <1> lff24s_0:
  2217 00000DCA 8EC0                <1> 	mov	es, ax ; buffer segment	
  2218 00000DCC 31FF                <1> 	xor	di, di
  2219 00000DCE BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2220                              <1> 	; ds = cs
  2221                              <1> 
  2222                              <1> 	; load file into memory
  2223 00000DD1 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2224 00000DD5 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2225 00000DD9 B43F                <1>        	mov	ah, 3Fh
  2226 00000DDB CD21                <1> 	int	21h
  2227 00000DDD 72DF                <1> 	jc	short lff24s_7 ; error !
  2228                              <1> 
  2229 00000DDF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2230                              <1> 	
  2231 00000DE1 D1E8                <1> 	shr	ax, 1
  2232                              <1> 	;and	ax, ax
  2233 00000DE3 7503                <1> 	jnz	short lff24s_8
  2234 00000DE5 E92AFB              <1> 	jmp	lff24_eof
  2235                              <1> 
  2236                              <1> lff24s_8:
  2237 00000DE8 89C1                <1> 	mov	cx, ax	; word count
  2238                              <1> lff24s_1:
  2239 00000DEA AC                  <1> 	lodsb
  2240 00000DEB A2[7619]            <1> 	mov	[previous_val_l], al
  2241 00000DEE 2C80                <1> 	sub	al, 80h
  2242 00000DF0 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2243 00000DF3 AB                  <1> 	stosw		; original sample (L)
  2244 00000DF4 AC                  <1> 	lodsb
  2245 00000DF5 A2[7819]            <1> 	mov	[previous_val_r], al
  2246 00000DF8 2C80                <1> 	sub	al, 80h
  2247 00000DFA C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2248 00000DFD AB                  <1> 	stosw		; original sample (R)
  2249                              <1> 
  2250                              <1> 	;xor	ax, ax
  2251 00000DFE B88080              <1> 	mov	ax, 8080h
  2252 00000E01 49                  <1> 	dec	cx
  2253 00000E02 7402                <1> 	jz	short lff24s_2
  2254                              <1> 		; convert 8 bit sample to 16 bit sample
  2255 00000E04 8B04                <1> 	mov	ax, [si]
  2256                              <1> lff24s_2:
  2257                              <1> 	;;mov	[next_val_l], al
  2258                              <1> 	;;mov	[next_val_r], ah
  2259                              <1> 	;mov	bx, ax
  2260 00000E06 88E7                <1> 	mov	bh, ah
  2261 00000E08 0206[7619]          <1> 	add	al, [previous_val_l]
  2262 00000E0C D0D8                <1> 	rcr	al, 1
  2263                              <1> 	;mov	dl, al
  2264 00000E0E 2C80                <1> 	sub	al, 80h
  2265 00000E10 C1E008              <1> 	shl	ax, 8
  2266 00000E13 AB                  <1> 	stosw		; this is interpolated sample (L)
  2267 00000E14 88F8                <1> 	mov	al, bh	; [next_val_r]
  2268 00000E16 0206[7819]          <1> 	add	al, [previous_val_r]
  2269 00000E1A D0D8                <1> 	rcr	al, 1
  2270                              <1> 	;mov	dh, al
  2271 00000E1C 2C80                <1> 	sub	al, 80h
  2272 00000E1E C1E008              <1> 	shl	ax, 8
  2273 00000E21 AB                  <1> 	stosw		; this is interpolated sample (R)
  2274                              <1> 		
  2275                              <1> 	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2276 00000E22 09C9                <1> 	or	cx, cx
  2277 00000E24 75C4                <1> 	jnz	short lff24s_1
  2278 00000E26 E9D6FA              <1> 	jmp	lff24_3
  2279                              <1> 
  2280                              <1> load_24khz_mono_16_bit:
  2281                              <1> 	; 15/11/2023
  2282 00000E29 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2283                              <1> 					; last of the file?
  2284 00000E2E 7402                <1> 	jz	short lff24m2_0		; no
  2285 00000E30 F9                  <1> 	stc
  2286 00000E31 C3                  <1> 	retn
  2287                              <1> 
  2288                              <1> lff24m2_0:
  2289 00000E32 8EC0                <1> 	mov	es, ax ; buffer segment
  2290 00000E34 31FF                <1> 	xor	di, di
  2291 00000E36 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2292                              <1> 	; ds = cs
  2293                              <1> 
  2294                              <1> 	; load file into memory
  2295 00000E39 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2296 00000E3D 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2297 00000E41 B43F                <1>        	mov	ah, 3Fh
  2298 00000E43 CD21                <1> 	int	21h
  2299 00000E45 722B                <1> 	jc	short lff24m2_7 ; error !
  2300                              <1> 
  2301 00000E47 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2302                              <1> 	
  2303 00000E49 D1E8                <1> 	shr	ax, 1
  2304                              <1> 	;and	ax, ax
  2305 00000E4B 7503                <1> 	jnz	short lff24m2_8
  2306 00000E4D E9C2FA              <1> 	jmp	lff24_eof
  2307                              <1> 
  2308                              <1> lff24m2_8:
  2309 00000E50 89C1                <1> 	mov	cx, ax	; word count
  2310                              <1> lff24m2_1:
  2311 00000E52 AD                  <1> 	lodsw
  2312 00000E53 AB                  <1> 	stosw		; original sample (left channel)
  2313 00000E54 AB                  <1> 	stosw		; original sample (right channel)
  2314 00000E55 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2315                              <1> 	;mov	[previous_val], ax
  2316                              <1> 	;mov	bx, ax
  2317                              <1> 	;xor	ax, ax
  2318 00000E58 31DB                <1> 	xor	bx, bx
  2319 00000E5A 49                  <1> 	dec	cx
  2320 00000E5B 7402                <1> 	jz	short lff24m2_2
  2321                              <1> 	;mov	ax, [si
  2322 00000E5D 8B1C                <1> 	mov	bx, [si]
  2323                              <1> lff24m2_2:
  2324                              <1> 	; 04/02/2025
  2325 00000E5F 80C780              <1> 	add	bh, 80h ; convert sound level 0 to 65535 format
  2326                              <1> 	;add	ah, 80h
  2327                              <1> 	;mov	bp, ax	; [next_val]
  2328                              <1> 	;add	ax, [previous_val]
  2329                              <1> 	; ax = [previous_val]
  2330                              <1> 	; bx = [next_val]
  2331 00000E62 01D8                <1> 	add	ax, bx
  2332 00000E64 D1D8                <1> 	rcr	ax, 1
  2333 00000E66 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2334 00000E69 AB                  <1> 	stosw		; this is interpolated sample (L)
  2335 00000E6A AB                  <1> 	stosw		; this is interpolated sample (R)
  2336                              <1> 	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2337 00000E6B 09C9                <1> 	or	cx, cx
  2338 00000E6D 75E3                <1> 	jnz	short lff24m2_1
  2339 00000E6F E98DFA              <1> 	jmp	lff24_3
  2340                              <1> 
  2341                              <1> lff24m2_7:
  2342                              <1> lff24s2_7:
  2343 00000E72 E9A4FA              <1> 	jmp	lff24_5  ; error
  2344                              <1> 
  2345                              <1> load_24khz_stereo_16_bit:
  2346                              <1> 	; 16/11/2023
  2347                              <1> 	; 15/11/2023
  2348 00000E75 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2349                              <1> 					; last of the file?
  2350 00000E7A 7402                <1> 	jz	short lff24s2_0		; no
  2351 00000E7C F9                  <1> 	stc
  2352 00000E7D C3                  <1> 	retn
  2353                              <1> 
  2354                              <1> lff24s2_0:
  2355 00000E7E 8EC0                <1> 	mov	es, ax ; buffer segment
  2356 00000E80 31FF                <1> 	xor	di, di
  2357 00000E82 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2358                              <1> 	; ds = cs
  2359                              <1> 
  2360                              <1> 	; load file into memory
  2361 00000E85 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2362 00000E89 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2363 00000E8D B43F                <1>        	mov	ah, 3Fh
  2364 00000E8F CD21                <1> 	int	21h
  2365 00000E91 72DF                <1> 	jc	short lff24s2_7 ; error !
  2366                              <1> 
  2367 00000E93 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2368                              <1> 	
  2369                              <1> 	;shr	ax, 1
  2370 00000E95 C1E802              <1> 	shr	ax, 2	; 16/11/2023
  2371                              <1> 	;and	ax, ax
  2372 00000E98 7503                <1> 	jnz	short lff24s2_8
  2373 00000E9A E975FA              <1> 	jmp	lff24_eof
  2374                              <1> 
  2375                              <1> lff24s2_8:
  2376 00000E9D 89C1                <1> 	mov	cx, ax	; dword count
  2377                              <1> lff24s2_1:
  2378 00000E9F AD                  <1> 	lodsw
  2379 00000EA0 AB                  <1> 	stosw		; original sample (L)
  2380 00000EA1 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2381 00000EA4 A3[7619]            <1> 	mov	[previous_val_l], ax
  2382 00000EA7 AD                  <1> 	lodsw
  2383 00000EA8 AB                  <1> 	stosw		; original sample (R)
  2384 00000EA9 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2385                              <1> 	;mov	[previous_val_r], ax
  2386 00000EAC 89C3                <1> 	mov	bx, ax
  2387 00000EAE 31D2                <1> 	xor	dx, dx
  2388 00000EB0 31C0                <1> 	xor	ax, ax
  2389                              <1> 	; 16/11/2023
  2390 00000EB2 49                  <1> 	dec	cx
  2391 00000EB3 7405                <1> 	jz	short lff24s2_2
  2392 00000EB5 8B04                <1> 	mov	ax, [si]
  2393 00000EB7 8B5402              <1> 	mov	dx, [si+2]
  2394                              <1> lff24s2_2:
  2395 00000EBA 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2396                              <1> 	;;mov	[next_val_l], ax
  2397                              <1> 	;mov	bp, ax
  2398 00000EBD 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format
  2399                              <1> 	;mov	[next_val_r], dx
  2400 00000EC0 0306[7619]          <1> 	add	ax, [previous_val_l]
  2401 00000EC4 D1D8                <1> 	rcr	ax, 1
  2402 00000EC6 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  2403 00000EC9 AB                  <1> 	stosw		; this is interpolated sample (L)
  2404                              <1> 	;mov	ax, [next_val_r]
  2405 00000ECA 89D0                <1> 	mov	ax, dx
  2406                              <1> 	;add	ax, [previous_val_r]
  2407 00000ECC 01D8                <1> 	add	ax, bx
  2408 00000ECE D1D8                <1> 	rcr	ax, 1
  2409 00000ED0 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2410 00000ED3 AB                  <1> 	stosw		; this is interpolated sample (R)
  2411                              <1> 	
  2412                              <1> 	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2413 00000ED4 09C9                <1> 	or	cx, cx
  2414 00000ED6 75C7                <1> 	jnz	short lff24s2_1
  2415 00000ED8 E924FA              <1> 	jmp	lff24_3
  2416                              <1> 
  2417                              <1> ; .....................
  2418                              <1> 
  2419                              <1> load_32khz_mono_8_bit:
  2420                              <1> 	; 15/11/2023
  2421 00000EDB F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2422                              <1> 					; last of the file?
  2423 00000EE0 7402                <1> 	jz	short lff32m_0		; no
  2424 00000EE2 F9                  <1> 	stc
  2425 00000EE3 C3                  <1> 	retn
  2426                              <1> 
  2427                              <1> lff32m_0:
  2428 00000EE4 8EC0                <1> 	mov	es, ax ; buffer segment
  2429 00000EE6 31FF                <1> 	xor	di, di
  2430 00000EE8 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2431                              <1> 	; ds = cs
  2432                              <1> 
  2433                              <1> 	; load file into memory
  2434 00000EEB 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2435 00000EEF 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2436 00000EF3 B43F                <1>        	mov	ah, 3Fh
  2437 00000EF5 CD21                <1> 	int	21h
  2438 00000EF7 7237                <1> 	jc	short lff32m_7 ; error !
  2439                              <1> 
  2440 00000EF9 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2441                              <1> 	
  2442 00000EFB 21C0                <1> 	and	ax, ax
  2443 00000EFD 7503                <1> 	jnz	short lff32m_8
  2444 00000EFF E910FA              <1> 	jmp	lff32_eof
  2445                              <1> 
  2446                              <1> lff32m_8:
  2447 00000F02 89C1                <1> 	mov	cx, ax	; byte count
  2448                              <1> lff32m_1:
  2449 00000F04 AC                  <1> 	lodsb
  2450                              <1> 	;mov	[previous_val], al
  2451 00000F05 88C3                <1> 	mov	bl, al
  2452 00000F07 2C80                <1> 	sub	al, 80h
  2453 00000F09 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2454 00000F0C AB                  <1> 	stosw		; original sample (left channel)
  2455 00000F0D AB                  <1> 	stosw		; original sample (right channel)
  2456                              <1> 	;xor	ax, ax
  2457 00000F0E B080                <1> 	mov	al, 80h
  2458 00000F10 49                  <1> 	dec	cx
  2459 00000F11 7402                <1> 	jz	short lff32m_2
  2460 00000F13 8A04                <1> 	mov	al, [si]
  2461                              <1> lff32m_2:
  2462                              <1> 	;;mov	[next_val], al
  2463                              <1> 	;mov	bh, al
  2464                              <1> 	;add	al, [previous_val]
  2465 00000F15 00D8                <1> 	add	al, bl
  2466 00000F17 D0D8                <1> 	rcr	al, 1
  2467 00000F19 2C80                <1> 	sub	al, 80h
  2468 00000F1B C1E008              <1> 	shl	ax, 8
  2469 00000F1E AB                  <1> 	stosw		; this is interpolated sample (L)
  2470 00000F1F AB                  <1> 	stosw		; this is interpolated sample (R)
  2471                              <1> 	
  2472                              <1> 	; different than 8-16-24 kHZ !
  2473                              <1> 	; 'original-interpolated-original' trio samples
  2474 00000F20 E30B                <1> 	jcxz	lff32m_3
  2475                              <1> 
  2476 00000F22 AC                  <1> 	lodsb
  2477 00000F23 2C80                <1> 	sub	al, 80h
  2478 00000F25 C1E008              <1> 	shl	ax, 8
  2479 00000F28 AB                  <1> 	stosw		; original sample (left channel)
  2480 00000F29 AB                  <1> 	stosw		; original sample (right channel)
  2481                              <1> 
  2482                              <1> 	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2483 00000F2A 49                  <1> 	dec	cx
  2484 00000F2B 75D7                <1> 	jnz	short lff32m_1
  2485                              <1> lff32m_3:
  2486 00000F2D E9CFF9              <1> 	jmp	lff32_3
  2487                              <1> 
  2488                              <1> lff32m_7:
  2489                              <1> lff32s_7:
  2490 00000F30 E9E6F9              <1> 	jmp	lff32_5  ; error
  2491                              <1> 
  2492                              <1> load_32khz_stereo_8_bit:
  2493                              <1> 	; 15/11/2023
  2494 00000F33 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2495                              <1> 					; last of the file?
  2496 00000F38 7402                <1> 	jz	short lff32s_0		; no
  2497 00000F3A F9                  <1> 	stc
  2498 00000F3B C3                  <1> 	retn
  2499                              <1> 
  2500                              <1> lff32s_0:
  2501 00000F3C 8EC0                <1> 	mov	es, ax ; buffer segment
  2502 00000F3E 31FF                <1> 	xor	di, di
  2503 00000F40 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2504                              <1> 	; ds = cs
  2505                              <1> 
  2506                              <1> 	; load file into memory
  2507 00000F43 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2508 00000F47 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2509 00000F4B B43F                <1>        	mov	ah, 3Fh
  2510 00000F4D CD21                <1> 	int	21h
  2511 00000F4F 72DF                <1> 	jc	short lff32s_7 ; error !
  2512                              <1> 
  2513 00000F51 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2514                              <1> 	
  2515 00000F53 D1E8                <1> 	shr	ax, 1
  2516                              <1> 	;and	ax, ax
  2517 00000F55 7503                <1> 	jnz	short lff32s_8
  2518 00000F57 E9B8F9              <1> 	jmp	lff32_eof
  2519                              <1> 
  2520                              <1> lff32s_8:
  2521 00000F5A 89C1                <1> 	mov	cx, ax	; word count
  2522                              <1> lff32s_1:
  2523 00000F5C AC                  <1> 	lodsb
  2524 00000F5D A2[7619]            <1> 	mov	[previous_val_l], al
  2525 00000F60 2C80                <1> 	sub	al, 80h
  2526 00000F62 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2527 00000F65 AB                  <1> 	stosw		; original sample (L)
  2528 00000F66 AC                  <1> 	lodsb
  2529 00000F67 A2[7819]            <1> 	mov	[previous_val_r], al
  2530 00000F6A 2C80                <1> 	sub	al, 80h
  2531 00000F6C C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2532 00000F6F AB                  <1> 	stosw		; original sample (R)
  2533                              <1> 
  2534                              <1> 	;xor	ax, ax
  2535 00000F70 B88080              <1> 	mov	ax, 8080h
  2536 00000F73 49                  <1> 	dec	cx
  2537 00000F74 7402                <1> 	jz	short lff32s_2
  2538                              <1> 		; convert 8 bit sample to 16 bit sample
  2539 00000F76 8B04                <1> 	mov	ax, [si]
  2540                              <1> lff32s_2:
  2541                              <1> 	;;mov	[next_val_l], al
  2542                              <1> 	;;mov	[next_val_r], ah
  2543                              <1> 	;mov	bx, ax
  2544 00000F78 88E7                <1> 	mov	bh, ah
  2545 00000F7A 0206[7619]          <1> 	add	al, [previous_val_l]
  2546 00000F7E D0D8                <1> 	rcr	al, 1
  2547                              <1> 	;mov	dl, al
  2548 00000F80 2C80                <1> 	sub	al, 80h
  2549 00000F82 C1E008              <1> 	shl	ax, 8
  2550 00000F85 AB                  <1> 	stosw		; this is interpolated sample (L)
  2551 00000F86 88F8                <1> 	mov	al, bh	; [next_val_r]
  2552 00000F88 0206[7819]          <1> 	add	al, [previous_val_r]
  2553 00000F8C D0D8                <1> 	rcr	al, 1
  2554                              <1> 	;mov	dh, al
  2555 00000F8E 2C80                <1> 	sub	al, 80h
  2556 00000F90 C1E008              <1> 	shl	ax, 8
  2557 00000F93 AB                  <1> 	stosw		; this is interpolated sample (R)
  2558                              <1> 
  2559                              <1> 	; different than 8-16-24 kHZ !
  2560                              <1> 	; 'original-interpolated-original' trio samples 
  2561 00000F94 E311                <1> 	jcxz	lff32s_3
  2562                              <1> 
  2563 00000F96 AC                  <1> 	lodsb
  2564 00000F97 2C80                <1> 	sub	al, 80h
  2565 00000F99 C1E008              <1> 	shl	ax, 8
  2566 00000F9C AB                  <1> 	stosw		; original sample (left channel)
  2567                              <1> 
  2568 00000F9D AC                  <1> 	lodsb
  2569 00000F9E 2C80                <1> 	sub	al, 80h
  2570 00000FA0 C1E008              <1> 	shl	ax, 8
  2571 00000FA3 AB                  <1> 	stosw		; original sample (right channel)
  2572                              <1> 		
  2573                              <1> 	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2574 00000FA4 49                  <1> 	dec	cx
  2575 00000FA5 75B5                <1> 	jnz	short lff32s_1
  2576                              <1> lff32s_3:
  2577 00000FA7 E955F9              <1> 	jmp	lff32_3
  2578                              <1> 
  2579                              <1> load_32khz_mono_16_bit:
  2580                              <1> 	; 15/11/2023
  2581 00000FAA F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2582                              <1> 					; last of the file?
  2583 00000FAF 7402                <1> 	jz	short lff32m2_0		; no
  2584 00000FB1 F9                  <1> 	stc
  2585 00000FB2 C3                  <1> 	retn
  2586                              <1> 
  2587                              <1> lff32m2_0:
  2588 00000FB3 8EC0                <1> 	mov	es, ax ; buffer segment
  2589 00000FB5 31FF                <1> 	xor	di, di
  2590 00000FB7 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2591                              <1> 	; ds = cs
  2592                              <1> 
  2593                              <1> 	; load file into memory
  2594 00000FBA 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2595 00000FBE 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2596 00000FC2 B43F                <1>        	mov	ah, 3Fh
  2597 00000FC4 CD21                <1> 	int	21h
  2598 00000FC6 722F                <1> 	jc	short lff32m2_7 ; error !
  2599                              <1> 
  2600 00000FC8 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2601                              <1> 	
  2602 00000FCA D1E8                <1> 	shr	ax, 1
  2603                              <1> 	;and	ax, ax
  2604 00000FCC 7503                <1> 	jnz	short lff32m2_8
  2605 00000FCE E941F9              <1> 	jmp	lff32_eof
  2606                              <1> 
  2607                              <1> lff32m2_8:
  2608 00000FD1 89C1                <1> 	mov	cx, ax	; word count
  2609                              <1> lff32m2_1:
  2610 00000FD3 AD                  <1> 	lodsw
  2611 00000FD4 AB                  <1> 	stosw		; original sample (left channel)
  2612 00000FD5 AB                  <1> 	stosw		; original sample (right channel)
  2613 00000FD6 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2614                              <1> 	;mov	[previous_val], ax
  2615                              <1> 	;mov	bx, ax
  2616                              <1> 	;xor	ax, ax
  2617 00000FD9 31DB                <1> 	xor	bx, bx
  2618 00000FDB 49                  <1> 	dec	cx
  2619 00000FDC 7402                <1> 	jz	short lff32m2_2
  2620                              <1> 	;mov	ax, [si
  2621 00000FDE 8B1C                <1> 	mov	bx, [si]
  2622                              <1> lff32m2_2:
  2623                              <1> 	; 04/02/2025
  2624 00000FE0 80C780              <1> 	add	bh, 80h ; convert sound level 0 to 65535 format
  2625                              <1> 	;add	ah, 80h
  2626                              <1> 	;mov	bp, ax	; [next_val]
  2627                              <1> 	;add	ax, [previous_val]
  2628                              <1> 	; ax = [previous_val]
  2629                              <1> 	; bx = [next_val]
  2630 00000FE3 01D8                <1> 	add	ax, bx
  2631 00000FE5 D1D8                <1> 	rcr	ax, 1
  2632 00000FE7 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2633 00000FEA AB                  <1> 	stosw		; this is interpolated sample (L)
  2634 00000FEB AB                  <1> 	stosw		; this is interpolated sample (R)
  2635                              <1> 
  2636                              <1> 	; different than 8-16-24 kHZ !
  2637                              <1> 	; 'original-interpolated-original' trio samples
  2638 00000FEC E306                <1> 	jcxz	lff32m2_3
  2639                              <1> 
  2640 00000FEE AD                  <1> 	lodsw
  2641 00000FEF AB                  <1> 	stosw		; original sample (left channel)
  2642 00000FF0 AB                  <1> 	stosw		; original sample (right channel)
  2643                              <1> 
  2644                              <1> 	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2645 00000FF1 49                  <1> 	dec	cx
  2646 00000FF2 75DF                <1> 	jnz	short lff32m2_1
  2647                              <1> lff32m2_3:
  2648 00000FF4 E908F9              <1> 	jmp	lff32_3
  2649                              <1> 
  2650                              <1> lff32m2_7:
  2651                              <1> lff32s2_7:
  2652 00000FF7 E91FF9              <1> 	jmp	lff32_5  ; error
  2653                              <1> 
  2654                              <1> load_32khz_stereo_16_bit:
  2655                              <1> 	 ;16/11/2023
  2656                              <1> 	; 15/11/2023
  2657 00000FFA F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2658                              <1> 					; last of the file?
  2659 00000FFF 7402                <1> 	jz	short lff32s2_0		; no
  2660 00001001 F9                  <1> 	stc
  2661 00001002 C3                  <1> 	retn
  2662                              <1> 
  2663                              <1> lff32s2_0:
  2664 00001003 8EC0                <1> 	mov	es, ax ; buffer segment	
  2665 00001005 31FF                <1> 	xor	di, di
  2666 00001007 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2667                              <1> 	; ds = cs
  2668                              <1> 
  2669                              <1> 	; load file into memory
  2670 0000100A 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2671 0000100E 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2672 00001012 B43F                <1>        	mov	ah, 3Fh
  2673 00001014 CD21                <1> 	int	21h
  2674 00001016 72DF                <1> 	jc	short lff32s2_7 ; error !
  2675                              <1> 
  2676 00001018 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2677                              <1> 	
  2678 0000101A C1E802              <1> 	shr	ax, 2	; 16/11/2023 (word left ch + word right ch)
  2679                              <1> 	;and	ax, ax
  2680 0000101D 7503                <1> 	jnz	short lff32s2_8
  2681 0000101F E9F0F8              <1> 	jmp	lff32_eof
  2682                              <1> 
  2683                              <1> lff32s2_8:
  2684 00001022 89C1                <1> 	mov	cx, ax	; dword count
  2685                              <1> lff32s2_1:
  2686 00001024 AD                  <1> 	lodsw
  2687 00001025 AB                  <1> 	stosw		; original sample (L)
  2688 00001026 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2689 00001029 A3[7619]            <1> 	mov	[previous_val_l], ax
  2690 0000102C AD                  <1> 	lodsw
  2691 0000102D AB                  <1> 	stosw		; original sample (R)
  2692 0000102E 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2693                              <1> 	;mov	[previous_val_r], ax
  2694 00001031 89C3                <1> 	mov	bx, ax
  2695 00001033 31D2                <1> 	xor	dx, dx
  2696 00001035 31C0                <1> 	xor	ax, ax
  2697                              <1> 	; 16/11/2023
  2698 00001037 49                  <1> 	dec	cx
  2699 00001038 7405                <1> 	jz	short lff32s2_2
  2700 0000103A 8B04                <1> 	mov	ax, [si]
  2701 0000103C 8B5402              <1> 	mov	dx, [si+2]
  2702                              <1> lff32s2_2:
  2703 0000103F 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  2704                              <1> 	;;mov	[next_val_l], ax
  2705                              <1> 	;mov	bp, ax
  2706 00001042 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format
  2707                              <1> 	;mov	[next_val_r], dx
  2708 00001045 0306[7619]          <1> 	add	ax, [previous_val_l]
  2709 00001049 D1D8                <1> 	rcr	ax, 1
  2710 0000104B 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  2711 0000104E AB                  <1> 	stosw		; this is interpolated sample (L)
  2712                              <1> 	;mov	ax, [next_val_r]
  2713 0000104F 89D0                <1> 	mov	ax, dx
  2714                              <1> 	;add	ax, [previous_val_r]
  2715 00001051 01D8                <1> 	add	ax, bx
  2716 00001053 D1D8                <1> 	rcr	ax, 1
  2717 00001055 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2718 00001058 AB                  <1> 	stosw		; this is interpolated sample (R)
  2719                              <1> 
  2720                              <1> 	; different than 8-16-24 kHZ !
  2721                              <1> 	; 'original-interpolated-original' trio samples
  2722 00001059 E307                <1> 	jcxz	lff32s2_3
  2723                              <1> 
  2724 0000105B AD                  <1> 	lodsw
  2725 0000105C AB                  <1> 	stosw	; original sample (L)
  2726 0000105D AD                  <1> 	lodsw
  2727 0000105E AB                  <1> 	stosw	; original sample (R)
  2728                              <1> 	
  2729                              <1> 	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2730 0000105F 49                  <1> 	dec	cx
  2731 00001060 75C2                <1> 	jnz	short lff32s2_1
  2732                              <1> lff32s2_3:
  2733 00001062 E99AF8              <1> 	jmp	lff32_3
  2734                              <1> 
  2735                              <1> ; .....................
  2736                              <1> 
  2737                              <1> load_22khz_mono_8_bit:
  2738                              <1> 	; 16/11/2023
  2739 00001065 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2740                              <1> 					; last of the file?
  2741 0000106A 7402                <1> 	jz	short lff22m_0		; no
  2742 0000106C F9                  <1> 	stc
  2743 0000106D C3                  <1> 	retn
  2744                              <1> 
  2745                              <1> lff22m_0:
  2746 0000106E 8EC0                <1> 	mov	es, ax ; buffer segment	
  2747 00001070 31FF                <1> 	xor	di, di
  2748 00001072 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2749                              <1> 	; ds = cs
  2750                              <1> 
  2751                              <1> 	; load file into memory
  2752 00001075 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2753 00001079 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2754 0000107D B43F                <1>        	mov	ah, 3Fh
  2755 0000107F CD21                <1> 	int	21h
  2756 00001081 7248                <1> 	jc	short lff22m_7 ; error !
  2757                              <1> 
  2758 00001083 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2759                              <1> 	
  2760 00001085 21C0                <1> 	and	ax, ax
  2761 00001087 7503                <1> 	jnz	short lff22m_8
  2762 00001089 E986F8              <1> 	jmp	lff22_eof
  2763                              <1> 
  2764                              <1> lff22m_8:
  2765 0000108C 89C1                <1> 	mov	cx, ax	; byte count
  2766                              <1> lff22m_9:
  2767 0000108E BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2768 00001091 C606[7E19]03        <1> 	mov	byte [faz], 3  ; 3 steps/phases
  2769                              <1> lff22m_1:
  2770                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2771 00001096 AC                  <1> 	lodsb
  2772 00001097 B280                <1> 	mov	dl, 80h
  2773 00001099 49                  <1> 	dec	cx
  2774 0000109A 7402                <1> 	jz	short lff22m_2_1
  2775 0000109C 8A14                <1> 	mov	dl, [si]
  2776                              <1> lff22m_2_1:	
  2777                              <1> 	; al = [previous_val]
  2778                              <1> 	; dl = [next_val]
  2779 0000109E E8A004              <1> 	call	interpolating_3_8bit_mono ; 1 of 17
  2780 000010A1 E325                <1> 	jcxz	lff22m_3
  2781                              <1> lff22m_2_2:
  2782 000010A3 AC                  <1> 	lodsb
  2783 000010A4 B280                <1> 	mov	dl, 80h
  2784 000010A6 49                  <1> 	dec	cx
  2785 000010A7 7402                <1> 	jz	short lff22m_2_3
  2786 000010A9 8A14                <1> 	mov	dl, [si]
  2787                              <1> lff22m_2_3:
  2788 000010AB E80805              <1>  	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2789 000010AE E318                <1> 	jcxz	lff22m_3
  2790 000010B0 4D                  <1> 	dec	bp
  2791 000010B1 75F0                <1> 	jnz	short lff22m_2_2
  2792                              <1> 
  2793 000010B3 A0[7E19]            <1> 	mov	al, [faz]
  2794 000010B6 FEC8                <1> 	dec	al
  2795 000010B8 74D4                <1> 	jz	short lff22m_9
  2796 000010BA FE0E[7E19]          <1> 	dec	byte [faz]
  2797 000010BE BD0400              <1> 	mov	bp, 4
  2798 000010C1 FEC8                <1> 	dec	al
  2799 000010C3 75D1                <1> 	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2800 000010C5 45                  <1> 	inc	bp ; 5
  2801 000010C6 EBCE                <1> 	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2802                              <1> 
  2803                              <1> lff22m_3:
  2804                              <1> lff22s_3:
  2805 000010C8 E934F8              <1> 	jmp	lff22_3	; padfill
  2806                              <1> 		; (put zeros in the remain words of the buffer)
  2807                              <1> lff22m_7:
  2808                              <1> lff22s_7:
  2809 000010CB E94BF8              <1> 	jmp	lff22_5  ; error
  2810                              <1> 
  2811                              <1> load_22khz_stereo_8_bit:
  2812                              <1> 	; 16/11/2023
  2813 000010CE F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2814                              <1> 					; last of the file?
  2815 000010D3 7402                <1> 	jz	short lff22s_0		; no
  2816 000010D5 F9                  <1> 	stc
  2817 000010D6 C3                  <1> 	retn
  2818                              <1> 
  2819                              <1> lff22s_0:
  2820 000010D7 8EC0                <1> 	mov	es, ax ; buffer segment
  2821 000010D9 31FF                <1> 	xor	di, di
  2822 000010DB BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2823                              <1> 	; ds = cs
  2824                              <1> 
  2825                              <1> 	; load file into memory
  2826 000010DE 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2827 000010E2 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2828 000010E6 B43F                <1>        	mov	ah, 3Fh
  2829 000010E8 CD21                <1> 	int	21h
  2830 000010EA 72DF                <1> 	jc	short lff22s_7 ; error !
  2831                              <1> 
  2832 000010EC 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2833                              <1> 	
  2834 000010EE D1E8                <1> 	shr	ax, 1
  2835                              <1> 	;and	ax, ax
  2836 000010F0 7503                <1> 	jnz	short lff22s_8
  2837 000010F2 E91DF8              <1> 	jmp	lff22_eof
  2838                              <1> 
  2839                              <1> lff22s_8:
  2840 000010F5 89C1                <1> 	mov	cx, ax	; word count
  2841                              <1> lff22s_9:
  2842 000010F7 BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2843 000010FA C606[7E19]03        <1> 	mov	byte [faz], 3  ; 3 steps/phase
  2844                              <1> lff22s_1:
  2845                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2846 000010FF AD                  <1> 	lodsw
  2847 00001100 BA8080              <1> 	mov	dx, 8080h
  2848 00001103 49                  <1> 	dec	cx
  2849 00001104 7402                <1> 	jz	short lff22s_2_1
  2850 00001106 8B14                <1> 	mov	dx, [si]
  2851                              <1> lff22s_2_1:	
  2852                              <1> 	; al = [previous_val_l]
  2853                              <1> 	; ah = [previous_val_r]
  2854                              <1> 	; dl = [next_val_l]
  2855                              <1> 	; dl = [next_val_r]
  2856 00001108 E86004              <1> 	call	interpolating_3_8bit_stereo ; 1 of 17 
  2857 0000110B E3BB                <1> 	jcxz	lff22s_3
  2858                              <1> lff22s_2_2:
  2859 0000110D AD                  <1> 	lodsw
  2860 0000110E BA8080              <1> 	mov	dx, 8080h
  2861 00001111 49                  <1> 	dec	cx
  2862 00001112 7402                <1> 	jz	short lff22s_2_3
  2863 00001114 8B14                <1> 	mov	dx, [si]
  2864                              <1> lff22s_2_3:
  2865 00001116 E8B404              <1>  	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2866 00001119 E3AD                <1> 	jcxz	lff22s_3
  2867 0000111B 4D                  <1> 	dec	bp
  2868 0000111C 75EF                <1> 	jnz	short lff22s_2_2
  2869                              <1> 
  2870 0000111E A0[7E19]            <1> 	mov	al, [faz]
  2871 00001121 FEC8                <1> 	dec	al
  2872 00001123 74D2                <1> 	jz	short lff22s_9
  2873 00001125 FE0E[7E19]          <1> 	dec	byte [faz]
  2874 00001129 BD0400              <1> 	mov	bp, 4
  2875 0000112C FEC8                <1> 	dec	al
  2876 0000112E 75CF                <1> 	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2877 00001130 45                  <1> 	inc	bp ; 5
  2878 00001131 EBCC                <1> 	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2879                              <1> 
  2880                              <1> load_22khz_mono_16_bit:
  2881                              <1> 	; 16/11/2023
  2882 00001133 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2883                              <1> 					; last of the file?
  2884 00001138 7402                <1> 	jz	short lff22m2_0		; no
  2885 0000113A F9                  <1> 	stc
  2886 0000113B C3                  <1> 	retn
  2887                              <1> 
  2888                              <1> lff22m2_0:
  2889 0000113C 8EC0                <1> 	mov	es, ax ; buffer segment
  2890 0000113E 31FF                <1> 	xor	di, di
  2891 00001140 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2892                              <1> 	; ds = cs
  2893                              <1> 
  2894                              <1> 	; load file into memory
  2895 00001143 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2896 00001147 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2897 0000114B B43F                <1>        	mov	ah, 3Fh
  2898 0000114D CD21                <1> 	int	21h
  2899 0000114F 7248                <1> 	jc	short lff22m2_7 ; error !
  2900                              <1> 
  2901 00001151 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2902                              <1> 	
  2903 00001153 D1E8                <1> 	shr	ax, 1
  2904                              <1> 	;and	ax, ax
  2905 00001155 7503                <1> 	jnz	short lff22m2_8
  2906 00001157 E9B8F7              <1> 	jmp	lff22_eof
  2907                              <1> 
  2908                              <1> lff22m2_8:
  2909 0000115A 89C1                <1> 	mov	cx, ax	; word count
  2910                              <1> lff22m2_9:
  2911 0000115C BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2912 0000115F C606[7E19]03        <1> 	mov	byte [faz], 3  ; 3 steps/phases
  2913                              <1> lff22m2_1:
  2914                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2915 00001164 AD                  <1> 	lodsw
  2916 00001165 31D2                <1> 	xor	dx, dx
  2917 00001167 49                  <1> 	dec	cx
  2918 00001168 7402                <1> 	jz	short lff22m2_2_1
  2919 0000116A 8B14                <1> 	mov	dx, [si]
  2920                              <1> lff22m2_2_1:	
  2921                              <1> 	; ax = [previous_val]
  2922                              <1> 	; dx = [next_val]
  2923 0000116C E88704              <1> 	call	interpolating_3_16bit_mono ; 1 of 17
  2924 0000116F E325                <1> 	jcxz	lff22m2_3
  2925                              <1> lff22m2_2_2:
  2926 00001171 AD                  <1> 	lodsw
  2927 00001172 31D2                <1> 	xor	dx, dx
  2928 00001174 49                  <1> 	dec	cx
  2929 00001175 7402                <1> 	jz	short lff22m2_2_3
  2930 00001177 8B14                <1> 	mov	dx, [si]
  2931                              <1> lff22m2_2_3:
  2932 00001179 E8E704              <1>  	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2933 0000117C E318                <1> 	jcxz	lff22m2_3
  2934 0000117E 4D                  <1> 	dec	bp
  2935 0000117F 75F0                <1> 	jnz	short lff22m2_2_2
  2936                              <1> 
  2937 00001181 A0[7E19]            <1> 	mov	al, [faz]
  2938 00001184 FEC8                <1> 	dec	al
  2939 00001186 74D4                <1> 	jz	short lff22m2_9
  2940 00001188 FE0E[7E19]          <1> 	dec	byte [faz]
  2941 0000118C BD0400              <1> 	mov	bp, 4
  2942 0000118F FEC8                <1> 	dec	al
  2943 00001191 75D1                <1> 	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2944 00001193 45                  <1> 	inc	bp ; 5
  2945 00001194 EBCE                <1> 	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2946                              <1> 
  2947                              <1> lff22m2_3:
  2948                              <1> lff22s2_3:
  2949 00001196 E966F7              <1> 	jmp	lff22_3	; padfill
  2950                              <1> 		; (put zeros in the remain words of the buffer)
  2951                              <1> lff22m2_7:
  2952                              <1> lff22s2_7:
  2953 00001199 E97DF7              <1> 	jmp	lff22_5  ; error
  2954                              <1> 
  2955                              <1> load_22khz_stereo_16_bit:
  2956                              <1> 	; 16/11/2023
  2957 0000119C F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2958                              <1> 					; last of the file?
  2959 000011A1 7402                <1> 	jz	short lff22s2_0		; no
  2960 000011A3 F9                  <1> 	stc
  2961 000011A4 C3                  <1> 	retn
  2962                              <1> 
  2963                              <1> lff22s2_0:
  2964 000011A5 8EC0                <1> 	mov	es, ax ; buffer segment
  2965 000011A7 31FF                <1> 	xor	di, di
  2966 000011A9 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2967                              <1> 	; ds = cs
  2968                              <1> 
  2969                              <1> 	; load file into memory
  2970 000011AC 8B0E[4A06]          <1>         mov	cx, [loadsize]
  2971 000011B0 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  2972 000011B4 B43F                <1>        	mov	ah, 3Fh
  2973 000011B6 CD21                <1> 	int	21h
  2974 000011B8 72DF                <1> 	jc	short lff22s2_7 ; error !
  2975                              <1> 
  2976 000011BA 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2977                              <1> 	
  2978 000011BC C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  2979                              <1> 	;and	ax, ax
  2980 000011BF 7503                <1> 	jnz	short lff22s2_8
  2981 000011C1 E94EF7              <1> 	jmp	lff22_eof
  2982                              <1> 
  2983                              <1> lff22s2_8:
  2984 000011C4 89C1                <1> 	mov	cx, ax	; dword count
  2985                              <1> lff22s2_9:
  2986 000011C6 BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2987 000011C9 C606[7E19]03        <1> 	mov	byte [faz], 3  ; 3 steps/phase
  2988                              <1> lff22s2_1:
  2989                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2990 000011CE AD                  <1> 	lodsw
  2991 000011CF 89C3                <1> 	mov	bx, ax
  2992 000011D1 AD                  <1> 	lodsw
  2993 000011D2 8B14                <1> 	mov	dx, [si]
  2994 000011D4 8916[7A19]          <1> 	mov	[next_val_l], dx
  2995 000011D8 8B5402              <1> 	mov	dx, [si+2]
  2996 000011DB 49                  <1> 	dec	cx
  2997 000011DC 7506                <1> 	jnz	short lff22s2_2_1
  2998 000011DE 31D2                <1> 	xor	dx, dx ; 0
  2999 000011E0 8916[7A19]          <1> 	mov	[next_val_l], dx
  3000                              <1> lff22s2_2_1:
  3001                              <1> 	; bx = [previous_val_l]
  3002                              <1> 	; ax = [previous_val_r]
  3003                              <1> 	; [next_val_l]
  3004                              <1> 	; dx = [next_val_r]
  3005 000011E4 E83304              <1> 	call	interpolating_3_16bit_stereo ; 1 of 17 
  3006 000011E7 E3AD                <1> 	jcxz	lff22s2_3
  3007                              <1> lff22s2_2_2:
  3008 000011E9 AD                  <1> 	lodsw
  3009 000011EA 89C3                <1> 	mov	bx, ax
  3010 000011EC AD                  <1> 	lodsw
  3011 000011ED 8B14                <1> 	mov	dx, [si]
  3012 000011EF 8916[7A19]          <1> 	mov	[next_val_l], dx
  3013 000011F3 8B5402              <1> 	mov	dx, [si+2]
  3014 000011F6 49                  <1> 	dec	cx
  3015 000011F7 7506                <1> 	jnz	short lff22s2_2_3
  3016 000011F9 31D2                <1> 	xor	dx, dx ; 0
  3017 000011FB 8916[7A19]          <1> 	mov	[next_val_l], dx
  3018                              <1> lff22s2_2_3:
  3019 000011FF E87304              <1>  	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  3020 00001202 E392                <1> 	jcxz	lff22s2_3
  3021 00001204 4D                  <1> 	dec	bp
  3022 00001205 75E2                <1> 	jnz	short lff22s2_2_2
  3023                              <1> 
  3024 00001207 A0[7E19]            <1> 	mov	al, [faz]
  3025 0000120A FEC8                <1> 	dec	al
  3026 0000120C 74B8                <1> 	jz	short lff22s2_9
  3027 0000120E FE0E[7E19]          <1> 	dec	byte [faz]
  3028 00001212 BD0400              <1> 	mov	bp, 4
  3029 00001215 FEC8                <1> 	dec	al
  3030 00001217 75B5                <1> 	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  3031 00001219 45                  <1> 	inc	bp ; 5
  3032 0000121A EBB2                <1> 	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  3033                              <1> 
  3034                              <1> ; .....................
  3035                              <1> 
  3036                              <1> load_11khz_mono_8_bit:
  3037                              <1> 	; 18/11/2023
  3038 0000121C F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3039                              <1> 					; last of the file?
  3040 00001221 7402                <1> 	jz	short lff11m_0		; no
  3041 00001223 F9                  <1> 	stc
  3042 00001224 C3                  <1> 	retn
  3043                              <1> 
  3044                              <1> lff11m_0:
  3045 00001225 8EC0                <1> 	mov	es, ax ; buffer segment
  3046 00001227 31FF                <1> 	xor	di, di
  3047 00001229 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3048                              <1> 	; ds = cs
  3049                              <1> 
  3050                              <1> 	; load file into memory
  3051 0000122C 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3052 00001230 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3053 00001234 B43F                <1>        	mov	ah, 3Fh
  3054 00001236 CD21                <1> 	int	21h
  3055 00001238 723D                <1> 	jc	short lff11m_7 ; error !
  3056                              <1> 
  3057 0000123A 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3058                              <1> 	
  3059 0000123C 21C0                <1> 	and	ax, ax
  3060 0000123E 7503                <1> 	jnz	short lff11m_8
  3061 00001240 E9CFF6              <1> 	jmp	lff11_eof
  3062                              <1> 
  3063                              <1> lff11m_8:
  3064 00001243 89C1                <1> 	mov	cx, ax	; byte count
  3065                              <1> lff11m_9:
  3066 00001245 BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3067                              <1> lff11m_1:
  3068                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3069 00001248 AC                  <1> 	lodsb
  3070 00001249 B280                <1> 	mov	dl, 80h
  3071 0000124B 49                  <1> 	dec	cx
  3072 0000124C 7402                <1> 	jz	short lff11m_2_1
  3073 0000124E 8A14                <1> 	mov	dl, [si]
  3074                              <1> lff11m_2_1:	
  3075                              <1> 	; al = [previous_val]
  3076                              <1> 	; dl = [next_val]
  3077 00001250 E84804              <1> 	call	interpolating_5_8bit_mono
  3078 00001253 E31F                <1> 	jcxz	lff11m_3
  3079                              <1> lff11m_2_2:
  3080 00001255 AC                  <1> 	lodsb
  3081 00001256 B280                <1> 	mov	dl, 80h
  3082 00001258 49                  <1> 	dec	cx
  3083 00001259 7402                <1> 	jz	short lff11m_2_3
  3084 0000125B 8A14                <1> 	mov	dl, [si]
  3085                              <1> lff11m_2_3:
  3086 0000125D E82405              <1>  	call	interpolating_4_8bit_mono
  3087 00001260 E312                <1> 	jcxz	lff11m_3
  3088                              <1> 
  3089 00001262 4D                  <1> 	dec	bp
  3090 00001263 74E0                <1> 	jz	short lff11m_9
  3091                              <1> 
  3092 00001265 AC                  <1> 	lodsb
  3093 00001266 B280                <1> 	mov	dl, 80h
  3094 00001268 49                  <1> 	dec	cx
  3095 00001269 7402                <1> 	jz	short lff11m_2_4
  3096 0000126B 8A14                <1> 	mov	dl, [si]
  3097                              <1> lff11m_2_4:
  3098 0000126D E81405              <1> 	call	interpolating_4_8bit_mono
  3099 00001270 E302                <1> 	jcxz	lff11m_3
  3100 00001272 EBD4                <1> 	jmp	short lff11m_1
  3101                              <1> 
  3102                              <1> lff11m_3:
  3103                              <1> lff11s_3:
  3104 00001274 E988F6              <1> 	jmp	lff11_3	; padfill
  3105                              <1> 		; (put zeros in the remain words of the buffer)
  3106                              <1> lff11m_7:
  3107                              <1> lff11s_7:
  3108 00001277 E99FF6              <1> 	jmp	lff11_5  ; error
  3109                              <1> 
  3110                              <1> load_11khz_stereo_8_bit:
  3111                              <1> 	; 18/11/2023
  3112 0000127A F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3113                              <1> 					; last of the file?
  3114 0000127F 7402                <1> 	jz	short lff11s_0		; no
  3115 00001281 F9                  <1> 	stc
  3116 00001282 C3                  <1> 	retn
  3117                              <1> 
  3118                              <1> lff11s_0:
  3119 00001283 8EC0                <1> 	mov	es, ax ; buffer segment
  3120 00001285 31FF                <1> 	xor	di, di
  3121 00001287 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3122                              <1> 	; ds = cs
  3123                              <1> 
  3124                              <1> 	; load file into memory
  3125 0000128A 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3126 0000128E 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3127 00001292 B43F                <1>        	mov	ah, 3Fh
  3128 00001294 CD21                <1> 	int	21h
  3129 00001296 72DF                <1> 	jc	short lff11s_7 ; error !
  3130                              <1> 
  3131 00001298 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3132                              <1> 	
  3133 0000129A D1E8                <1> 	shr	ax, 1
  3134                              <1> 	;and	ax, ax
  3135 0000129C 7503                <1> 	jnz	short lff11s_8
  3136 0000129E E971F6              <1> 	jmp	lff11_eof
  3137                              <1> 
  3138                              <1> lff11s_8:
  3139 000012A1 89C1                <1> 	mov	cx, ax	; word count
  3140                              <1> lff11s_9:
  3141 000012A3 BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3142                              <1> lff11s_1:
  3143                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3144 000012A6 AD                  <1> 	lodsw
  3145 000012A7 BA8080              <1> 	mov	dx, 8080h
  3146 000012AA 49                  <1> 	dec	cx
  3147 000012AB 7402                <1> 	jz	short lff11s_2_1 
  3148 000012AD 8B14                <1> 	mov	dx, [si]
  3149                              <1> lff11s_2_1:	
  3150                              <1> 	; al = [previous_val_l]
  3151                              <1> 	; ah = [previous_val_r]
  3152                              <1> 	; dl = [next_val_l]
  3153                              <1> 	; dl = [next_val_r]
  3154 000012AF E83904              <1> 	call	interpolating_5_8bit_stereo
  3155 000012B2 E3C0                <1> 	jcxz	lff11s_3
  3156                              <1> lff11s_2_2:
  3157 000012B4 AD                  <1> 	lodsw
  3158 000012B5 BA8080              <1> 	mov	dx, 8080h
  3159 000012B8 49                  <1> 	dec	cx
  3160 000012B9 7402                <1> 	jz	short lff11s_2_3
  3161 000012BB 8B14                <1> 	mov	dx, [si]
  3162                              <1> lff11s_2_3:
  3163 000012BD E8F704              <1>  	call	interpolating_4_8bit_stereo
  3164 000012C0 E3B2                <1> 	jcxz	lff11s_3
  3165                              <1> 	
  3166 000012C2 4D                  <1> 	dec	bp
  3167 000012C3 74DE                <1> 	jz	short lff11s_9
  3168                              <1> 
  3169 000012C5 AD                  <1> 	lodsw
  3170 000012C6 BA8080              <1> 	mov	dx, 8080h
  3171 000012C9 49                  <1> 	dec	cx
  3172 000012CA 7402                <1> 	jz	short lff11s_2_4
  3173 000012CC 8B14                <1> 	mov	dx, [si]
  3174                              <1> lff11s_2_4:
  3175 000012CE E8E604              <1> 	call	interpolating_4_8bit_stereo
  3176 000012D1 E3A1                <1> 	jcxz	lff11s_3
  3177 000012D3 EBD1                <1> 	jmp	short lff11s_1
  3178                              <1> 
  3179                              <1> load_11khz_mono_16_bit:
  3180                              <1> 	; 18/11/2023
  3181 000012D5 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3182                              <1> 					; last of the file?
  3183 000012DA 7402                <1> 	jz	short lff11m2_0		; no
  3184 000012DC F9                  <1> 	stc
  3185 000012DD C3                  <1> 	retn
  3186                              <1> 
  3187                              <1> lff11m2_0:
  3188 000012DE 8EC0                <1> 	mov	es, ax ; buffer segment
  3189 000012E0 31FF                <1> 	xor	di, di
  3190 000012E2 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3191                              <1> 	; ds = cs
  3192                              <1> 
  3193                              <1> 	; load file into memory
  3194 000012E5 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3195 000012E9 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3196 000012ED B43F                <1>        	mov	ah, 3Fh
  3197 000012EF CD21                <1> 	int	21h
  3198 000012F1 723A                <1> 	jc	short lff11m2_7 ; error !
  3199                              <1> 
  3200 000012F3 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3201                              <1> 	
  3202 000012F5 D1E8                <1> 	shr	ax, 1
  3203                              <1> 	;and	ax, ax
  3204 000012F7 7503                <1> 	jnz	short lff11m2_8
  3205 000012F9 E916F6              <1> 	jmp	lff11_eof
  3206                              <1> 
  3207                              <1> lff11m2_8:
  3208 000012FC 89C1                <1> 	mov	cx, ax	; word count
  3209                              <1> lff11m2_9:
  3210 000012FE BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3211                              <1> lff11m2_1:
  3212                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3213 00001301 AD                  <1> 	lodsw
  3214 00001302 31D2                <1> 	xor	dx, dx
  3215 00001304 49                  <1> 	dec	cx
  3216 00001305 7402                <1> 	jz	short lff11m2_2_1
  3217 00001307 8B14                <1> 	mov	dx, [si]
  3218                              <1> lff11m2_2_1:	
  3219                              <1> 	; ax = [previous_val]
  3220                              <1> 	; dx = [next_val]
  3221 00001309 E80805              <1> 	call	interpolating_5_16bit_mono
  3222 0000130C E34A                <1> 	jcxz	lff11m2_3
  3223                              <1> lff11m2_2_2:
  3224 0000130E AD                  <1> 	lodsw
  3225 0000130F 31D2                <1> 	xor	dx, dx
  3226 00001311 49                  <1> 	dec	cx
  3227 00001312 7402                <1> 	jz	short lff11m2_2_3
  3228 00001314 8B14                <1> 	mov	dx, [si]
  3229                              <1> lff11m2_2_3:
  3230 00001316 E8D605              <1>  	call	interpolating_4_16bit_mono
  3231 00001319 E33D                <1> 	jcxz	lff11m2_3
  3232                              <1> 
  3233 0000131B 4D                  <1> 	dec	bp
  3234 0000131C 74E0                <1> 	jz	short lff11m2_9
  3235                              <1> 
  3236 0000131E AD                  <1> 	lodsw
  3237 0000131F 31D2                <1> 	xor	dx, dx
  3238 00001321 49                  <1> 	dec	cx
  3239 00001322 7402                <1> 	jz	short lff11m2_2_4
  3240 00001324 8B14                <1> 	mov	dx, [si]
  3241                              <1> lff11m2_2_4:
  3242 00001326 E8C605              <1>  	call	interpolating_4_16bit_mono
  3243 00001329 E32D                <1> 	jcxz	lff11m2_3
  3244 0000132B EBD4                <1> 	jmp	short lff11m2_1
  3245                              <1> 
  3246                              <1> lff11m2_7:
  3247                              <1> lff11s2_7:
  3248 0000132D E9E9F5              <1> 	jmp	lff11_5  ; error
  3249                              <1> 
  3250                              <1> load_11khz_stereo_16_bit:
  3251                              <1> 	; 18/11/2023
  3252 00001330 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3253                              <1> 					; last of the file?
  3254 00001335 7402                <1> 	jz	short lff11s2_0		; no
  3255 00001337 F9                  <1> 	stc
  3256 00001338 C3                  <1> 	retn
  3257                              <1> 
  3258                              <1> lff11s2_0:
  3259 00001339 8EC0                <1> 	mov	es, ax ; buffer segment	
  3260 0000133B 31FF                <1> 	xor	di, di
  3261 0000133D BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3262                              <1> 	; ds = cs
  3263                              <1> 
  3264                              <1> 	; load file into memory
  3265 00001340 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3266 00001344 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3267 00001348 B43F                <1>        	mov	ah, 3Fh
  3268 0000134A CD21                <1> 	int	21h
  3269 0000134C 72DF                <1> 	jc	short lff11s2_7 ; error !
  3270                              <1> 
  3271 0000134E 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3272                              <1> 	
  3273 00001350 C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  3274                              <1> 	;and	ax, ax
  3275 00001353 7506                <1> 	jnz	short lff11s2_8
  3276 00001355 E9BAF5              <1> 	jmp	lff11_eof
  3277                              <1> 
  3278                              <1> lff11m2_3:
  3279                              <1> lff11s2_3:
  3280 00001358 E9A4F5              <1> 	jmp	lff11_3	; padfill
  3281                              <1> 		; (put zeros in the remain words of the buffer)
  3282                              <1> 
  3283                              <1> lff11s2_8:
  3284 0000135B 89C1                <1> 	mov	cx, ax	; dword count
  3285                              <1> lff11s2_9:
  3286 0000135D BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3287                              <1> lff11s2_1:
  3288                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3289 00001360 AD                  <1> 	lodsw
  3290 00001361 89C3                <1> 	mov	bx, ax
  3291 00001363 AD                  <1> 	lodsw
  3292 00001364 8B14                <1> 	mov	dx, [si]
  3293 00001366 8916[7A19]          <1> 	mov	[next_val_l], dx
  3294 0000136A 8B5402              <1> 	mov	dx, [si+2]
  3295 0000136D 8916[7C19]          <1> 	mov	[next_val_r], dx
  3296 00001371 49                  <1> 	dec	cx
  3297 00001372 750A                <1> 	jnz	short lff11s2_2_1
  3298 00001374 31D2                <1> 	xor	dx, dx ; 0
  3299 00001376 8916[7A19]          <1> 	mov	[next_val_l], dx
  3300 0000137A 8916[7C19]          <1> 	mov	[next_val_r], dx
  3301                              <1> lff11s2_2_1:
  3302                              <1> 	; bx = [previous_val_l]
  3303                              <1> 	; ax = [previous_val_r]
  3304                              <1> 	; [next_val_l]
  3305                              <1> 	; dx = [next_val_r]
  3306 0000137E E8D604              <1> 	call	interpolating_5_16bit_stereo
  3307 00001381 E3D5                <1> 	jcxz	lff11s2_3
  3308                              <1> lff11s2_2_2:
  3309 00001383 AD                  <1> 	lodsw
  3310 00001384 89C3                <1> 	mov	bx, ax
  3311 00001386 AD                  <1> 	lodsw
  3312 00001387 8B14                <1> 	mov	dx, [si]
  3313 00001389 8916[7A19]          <1> 	mov	[next_val_l], dx
  3314 0000138D 8B5402              <1> 	mov	dx, [si+2]
  3315 00001390 8916[7C19]          <1> 	mov	[next_val_r], dx
  3316 00001394 49                  <1> 	dec	cx
  3317 00001395 750A                <1> 	jnz	short lff11s2_2_3
  3318 00001397 31D2                <1> 	xor	dx, dx ; 0
  3319 00001399 8916[7A19]          <1> 	mov	[next_val_l], dx
  3320 0000139D 8916[7C19]          <1> 	mov	[next_val_r], dx
  3321                              <1> lff11s2_2_3:
  3322 000013A1 E87605              <1>  	call	interpolating_4_16bit_stereo
  3323 000013A4 E3B2                <1> 	jcxz	lff11s2_3
  3324                              <1> 	
  3325 000013A6 4D                  <1> 	dec	bp
  3326 000013A7 74B4                <1> 	jz	short lff11s2_9
  3327                              <1> 
  3328 000013A9 AD                  <1> 	lodsw
  3329 000013AA 89C3                <1> 	mov	bx, ax
  3330 000013AC AD                  <1> 	lodsw
  3331 000013AD 8B14                <1> 	mov	dx, [si]
  3332 000013AF 8916[7A19]          <1> 	mov	[next_val_l], dx
  3333 000013B3 8B5402              <1> 	mov	dx, [si+2]
  3334 000013B6 8916[7C19]          <1> 	mov	[next_val_r], dx
  3335 000013BA 49                  <1> 	dec	cx
  3336 000013BB 750A                <1> 	jnz	short lff11s2_2_4
  3337 000013BD 31D2                <1> 	xor	dx, dx ; 0
  3338 000013BF 8916[7A19]          <1> 	mov	[next_val_l], dx
  3339 000013C3 8916[7C19]          <1> 	mov	[next_val_r], dx
  3340                              <1> lff11s2_2_4:
  3341 000013C7 E85005              <1>  	call	interpolating_4_16bit_stereo
  3342 000013CA E38C                <1> 	jcxz	lff11s2_3
  3343 000013CC EB92                <1> 	jmp	short lff11s2_1
  3344                              <1> 
  3345                              <1> ; .....................
  3346                              <1> 
  3347                              <1> load_44khz_mono_8_bit:
  3348                              <1> 	; 18/11/2023
  3349 000013CE F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3350                              <1> 					; last of the file?
  3351 000013D3 7402                <1> 	jz	short lff44m_0		; no
  3352 000013D5 F9                  <1> 	stc
  3353 000013D6 C3                  <1> 	retn
  3354                              <1> 
  3355                              <1> lff44m_0:
  3356 000013D7 8EC0                <1> 	mov	es, ax ; buffer segment
  3357 000013D9 31FF                <1> 	xor	di, di
  3358 000013DB BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3359                              <1> 	; ds = cs
  3360                              <1> 
  3361                              <1> 	; load file into memory
  3362 000013DE 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3363 000013E2 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3364 000013E6 B43F                <1>        	mov	ah, 3Fh
  3365 000013E8 CD21                <1> 	int	21h
  3366 000013EA 723C                <1> 	jc	short lff44m_7 ; error !
  3367                              <1> 
  3368 000013EC 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3369                              <1> 	
  3370 000013EE 21C0                <1> 	and	ax, ax
  3371 000013F0 7503                <1> 	jnz	short lff44m_8
  3372 000013F2 E91DF5              <1> 	jmp	lff44_eof
  3373                              <1> 
  3374                              <1> lff44m_8:
  3375 000013F5 89C1                <1> 	mov	cx, ax	; byte count
  3376                              <1> lff44m_9:
  3377 000013F7 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3378 000013FA C606[7E19]02        <1> 	mov	byte [faz], 2  ; 2 steps/phases
  3379                              <1> lff44m_1:
  3380                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3381                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3382 000013FF AC                  <1> 	lodsb
  3383 00001400 B280                <1> 	mov	dl, 80h
  3384 00001402 49                  <1> 	dec	cx
  3385 00001403 7402                <1> 	jz	short lff44m_2_1
  3386 00001405 8A14                <1> 	mov	dl, [si]
  3387                              <1> lff44m_2_1:	
  3388                              <1> 	; al = [previous_val]
  3389                              <1> 	; dl = [next_val]
  3390 00001407 E8AC01              <1> 	call	interpolating_2_8bit_mono
  3391 0000140A E319                <1> 	jcxz	lff44m_3
  3392                              <1> lff44m_2_2:
  3393 0000140C AC                  <1> 	lodsb
  3394 0000140D 2C80                <1> 	sub	al, 80h
  3395 0000140F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3396 00001412 AB                  <1> 	stosw		; (L)
  3397 00001413 AB                  <1> 	stosw		; (R)
  3398                              <1> 
  3399 00001414 49                  <1> 	dec	cx
  3400 00001415 740E                <1> 	jz	short lff44m_3
  3401 00001417 4D                  <1> 	dec	bp
  3402 00001418 75F2                <1> 	jnz	short lff44m_2_2
  3403                              <1> 	
  3404 0000141A FE0E[7E19]          <1> 	dec	byte [faz]
  3405 0000141E 74D7                <1> 	jz	short lff44m_9 
  3406 00001420 BD0B00              <1> 	mov	bp, 11
  3407 00001423 EBDA                <1> 	jmp	short lff44m_1
  3408                              <1> 
  3409                              <1> lff44m_3:
  3410                              <1> lff44s_3:
  3411 00001425 E9D7F4              <1> 	jmp	lff44_3	; padfill
  3412                              <1> 		; (put zeros in the remain words of the buffer)
  3413                              <1> lff44m_7:
  3414                              <1> lff44s_7:
  3415 00001428 E9EEF4              <1> 	jmp	lff44_5  ; error
  3416                              <1> 
  3417                              <1> load_44khz_stereo_8_bit:
  3418                              <1> 	; 16/11/2023
  3419 0000142B F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3420                              <1> 					; last of the file?
  3421 00001430 7402                <1> 	jz	short lff44s_0		; no
  3422 00001432 F9                  <1> 	stc
  3423 00001433 C3                  <1> 	retn
  3424                              <1> 
  3425                              <1> lff44s_0:
  3426 00001434 8EC0                <1> 	mov	es, ax ; buffer segment
  3427 00001436 31FF                <1> 	xor	di, di
  3428 00001438 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3429                              <1> 	; ds = cs
  3430                              <1> 
  3431                              <1> 	; load file into memory
  3432 0000143B 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3433 0000143F 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3434 00001443 B43F                <1>        	mov	ah, 3Fh
  3435 00001445 CD21                <1> 	int	21h
  3436 00001447 72DF                <1> 	jc	short lff44s_7 ; error !
  3437                              <1> 
  3438 00001449 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3439                              <1> 	
  3440 0000144B D1E8                <1> 	shr	ax, 1
  3441                              <1> 	;and	ax, ax
  3442 0000144D 7503                <1> 	jnz	short lff44s_8
  3443 0000144F E9C0F4              <1> 	jmp	lff44_eof
  3444                              <1> 
  3445                              <1> lff44s_8:
  3446 00001452 89C1                <1> 	mov	cx, ax	; word count
  3447                              <1> lff44s_9:
  3448 00001454 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3449 00001457 C606[7E19]02        <1> 	mov	byte [faz], 2  ; 2 steps/phase
  3450                              <1> lff44s_1:
  3451                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3452                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3453 0000145C AD                  <1> 	lodsw
  3454 0000145D BA8080              <1> 	mov	dx, 8080h
  3455 00001460 49                  <1> 	dec	cx
  3456 00001461 7402                <1> 	jz	short lff44s_2_1 
  3457 00001463 8B14                <1> 	mov	dx, [si]
  3458                              <1> lff44s_2_1:	
  3459                              <1> 	; al = [previous_val_l]
  3460                              <1> 	; ah = [previous_val_r]
  3461                              <1> 	; dl = [next_val_l]
  3462                              <1> 	; dl = [next_val_r]	
  3463 00001465 E86501              <1> 	call	interpolating_2_8bit_stereo
  3464 00001468 E3BB                <1> 	jcxz	lff44s_3
  3465                              <1> lff44s_2_2:
  3466 0000146A AC                  <1> 	lodsb
  3467 0000146B 2C80                <1> 	sub	al, 80h
  3468 0000146D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3469 00001470 AB                  <1> 	stosw		; (L)
  3470 00001471 AC                  <1> 	lodsb
  3471 00001472 2C80                <1> 	sub	al, 80h
  3472 00001474 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3473 00001477 AB                  <1> 	stosw		; (R)
  3474                              <1> 
  3475 00001478 49                  <1> 	dec	cx
  3476 00001479 74AA                <1> 	jz	short lff44s_3
  3477 0000147B 4D                  <1> 	dec	bp
  3478 0000147C 75EC                <1> 	jnz	short lff44s_2_2
  3479                              <1> 	
  3480 0000147E FE0E[7E19]          <1> 	dec	byte [faz]
  3481 00001482 74D0                <1> 	jz	short lff44s_9
  3482 00001484 BD0B00              <1> 	mov	bp, 11
  3483 00001487 EBD3                <1> 	jmp	short lff44s_1
  3484                              <1> 
  3485                              <1> load_44khz_mono_16_bit:
  3486                              <1> 	; 18/11/2023
  3487 00001489 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3488                              <1> 					; last of the file?
  3489 0000148E 7402                <1> 	jz	short lff44m2_0		; no
  3490 00001490 F9                  <1> 	stc
  3491 00001491 C3                  <1> 	retn
  3492                              <1> 
  3493                              <1> lff44m2_0:
  3494 00001492 8EC0                <1> 	mov	es, ax ; buffer segment
  3495 00001494 31FF                <1> 	xor	di, di
  3496 00001496 BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3497                              <1> 	; ds = cs
  3498                              <1> 
  3499                              <1> 	; load file into memory
  3500 00001499 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3501 0000149D 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3502 000014A1 B43F                <1>        	mov	ah, 3Fh
  3503 000014A3 CD21                <1> 	int	21h
  3504 000014A5 7237                <1> 	jc	short lff44m2_7 ; error !
  3505                              <1> 
  3506 000014A7 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3507                              <1> 	
  3508 000014A9 D1E8                <1> 	shr	ax, 1
  3509                              <1> 	;and	ax, ax
  3510 000014AB 7503                <1> 	jnz	short lff44m2_8
  3511 000014AD E962F4              <1> 	jmp	lff44_eof
  3512                              <1> 
  3513                              <1> lff44m2_8:
  3514 000014B0 89C1                <1> 	mov	cx, ax	; word count
  3515                              <1> lff44m2_9:
  3516 000014B2 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3517 000014B5 C606[7E19]02        <1> 	mov	byte [faz], 2  ; 2 steps/phases
  3518                              <1> lff44m2_1:
  3519                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3520                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3521 000014BA AD                  <1> 	lodsw
  3522 000014BB 31D2                <1> 	xor	dx, dx
  3523 000014BD 49                  <1> 	dec	cx
  3524 000014BE 7402                <1> 	jz	short lff44m2_2_1
  3525 000014C0 8B14                <1> 	mov	dx, [si]
  3526                              <1> lff44m2_2_1:	
  3527                              <1> 	; ax = [previous_val]
  3528                              <1> 	; dx = [next_val]
  3529 000014C2 E89E01              <1> 	call	interpolating_2_16bit_mono
  3530 000014C5 E314                <1> 	jcxz	lff44m2_3
  3531                              <1> lff44m2_2_2:
  3532 000014C7 AD                  <1> 	lodsw
  3533 000014C8 AB                  <1> 	stosw		; (L)eft Channel
  3534 000014C9 AB                  <1> 	stosw		; (R)ight Channel
  3535                              <1> 
  3536 000014CA 49                  <1> 	dec	cx
  3537 000014CB 740E                <1> 	jz	short lff44m2_3	
  3538 000014CD 4D                  <1> 	dec	bp
  3539 000014CE 75F7                <1> 	jnz	short lff44m2_2_2
  3540                              <1> 	
  3541 000014D0 FE0E[7E19]          <1> 	dec	byte [faz]
  3542 000014D4 74DC                <1> 	jz	short lff44m2_9 
  3543 000014D6 BD0B00              <1> 	mov	bp, 11
  3544 000014D9 EBDF                <1> 	jmp	short lff44m2_1
  3545                              <1> 
  3546                              <1> lff44m2_3:
  3547                              <1> lff44s2_3:
  3548 000014DB E921F4              <1> 	jmp	lff44_3	; padfill
  3549                              <1> 		; (put zeros in the remain words of the buffer)
  3550                              <1> lff44m2_7:
  3551                              <1> lff44s2_7:
  3552 000014DE E938F4              <1> 	jmp	lff44_5  ; error
  3553                              <1> 
  3554                              <1> load_44khz_stereo_16_bit:
  3555                              <1> 	; 18/11/2023
  3556 000014E1 F606[601D]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3557                              <1> 					; last of the file?
  3558 000014E6 7402                <1> 	jz	short lff44s2_0		; no
  3559 000014E8 F9                  <1> 	stc
  3560 000014E9 C3                  <1> 	retn
  3561                              <1> 
  3562                              <1> lff44s2_0:
  3563 000014EA 8EC0                <1> 	mov	es, ax ; buffer segment
  3564 000014EC 31FF                <1> 	xor	di, di
  3565 000014EE BA[7C1D]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3566                              <1> 	; ds = cs
  3567                              <1> 
  3568                              <1> 	; load file into memory
  3569 000014F1 8B0E[4A06]          <1>         mov	cx, [loadsize]
  3570 000014F5 8B1E[5E1D]          <1> 	mov	bx, [filehandle]
  3571 000014F9 B43F                <1>        	mov	ah, 3Fh
  3572 000014FB CD21                <1> 	int	21h
  3573 000014FD 72DF                <1> 	jc	short lff44s2_7 ; error !
  3574                              <1> 
  3575 000014FF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3576                              <1> 	
  3577 00001501 C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  3578                              <1> 	;and	ax, ax
  3579 00001504 7503                <1> 	jnz	short lff44s2_8
  3580 00001506 E909F4              <1> 	jmp	lff44_eof
  3581                              <1> 
  3582                              <1> lff44s2_8:
  3583 00001509 89C1                <1> 	mov	cx, ax	; dword count
  3584                              <1> lff44s2_9:
  3585 0000150B BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3586 0000150E C606[7E19]02        <1> 	mov	byte [faz], 2  ; 2 steps/phase
  3587                              <1> lff44s2_1:
  3588                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3589                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3590 00001513 AD                  <1> 	lodsw
  3591 00001514 89C3                <1> 	mov	bx, ax
  3592 00001516 AD                  <1> 	lodsw
  3593 00001517 8B14                <1> 	mov	dx, [si]
  3594 00001519 8916[7A19]          <1> 	mov	[next_val_l], dx
  3595 0000151D 8B5402              <1> 	mov	dx, [si+2]
  3596 00001520 49                  <1> 	dec	cx
  3597 00001521 7506                <1> 	jnz	short lff44s2_2_1
  3598 00001523 31D2                <1> 	xor	dx, dx ; 0
  3599 00001525 8916[7A19]          <1> 	mov	[next_val_l], dx
  3600                              <1> lff44s2_2_1:
  3601                              <1> 	; bx = [previous_val_l]
  3602                              <1> 	; ax = [previous_val_r]
  3603                              <1> 	; [next_val_l]
  3604                              <1> 	; dx = [next_val_r]
  3605 00001529 E84901              <1> 	call	interpolating_2_16bit_stereo
  3606 0000152C E3AD                <1> 	jcxz	lff44s2_3
  3607                              <1> lff44s2_2_2:
  3608                              <1> 	;lodsw
  3609                              <1> 	;stosw		; (L)
  3610                              <1> 	;lodsw
  3611                              <1> 	;stosw		; (R)
  3612 0000152E A5                  <1> 	movsw		; (L)eft Channel
  3613 0000152F A5                  <1> 	movsw		; (R)ight Channel
  3614                              <1> 
  3615 00001530 49                  <1> 	dec	cx
  3616 00001531 74A8                <1> 	jz	short lff44s2_3
  3617 00001533 4D                  <1> 	dec	bp
  3618 00001534 75F8                <1> 	jnz	short lff44s2_2_2
  3619                              <1> 	
  3620 00001536 FE0E[7E19]          <1> 	dec	byte [faz]
  3621 0000153A 74CF                <1> 	jz	short lff44s2_9
  3622 0000153C BD0B00              <1> 	mov	bp, 11
  3623 0000153F EBD2                <1> 	jmp	short lff44s2_1
  3624                              <1> 
  3625                              <1> ; .....................
  3626                              <1> 
  3627                              <1> interpolating_3_8bit_mono:
  3628                              <1> 	; 04/02/2025
  3629                              <1> 	; 16/11/2023
  3630                              <1> 	; al = [previous_val]
  3631                              <1> 	; dl = [next_val]
  3632                              <1> 	; original-interpolated-interpolated
  3633 00001541 88C3                <1> 	mov	bl, al
  3634 00001543 2C80                <1> 	sub	al, 80h
  3635 00001545 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3636 00001548 AB                  <1> 	stosw		; original sample (L)
  3637 00001549 AB                  <1> 	stosw		; original sample (R)
  3638 0000154A 88D8                <1> 	mov	al, bl
  3639 0000154C 00D0                <1> 	add	al, dl
  3640 0000154E D0D8                <1> 	rcr	al, 1
  3641 00001550 88C7                <1> 	mov	bh, al	; interpolated middle (temporary)
  3642 00001552 00D8                <1> 	add	al, bl
  3643 00001554 D0D8                <1> 	rcr	al, 1
  3644 00001556 2C80                <1> 	sub	al, 80h
  3645 00001558 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3646 0000155B AB                  <1> 	stosw		; interpolated sample 1 (L)
  3647 0000155C AB                  <1> 	stosw		; interpolated sample 1 (R)
  3648 0000155D 88F8                <1> 	mov	al, bh
  3649 0000155F 00D0                <1> 	add	al, dl	; [next_val]
  3650 00001561 D0D8                <1> 	rcr	al, 1
  3651                              <1> 	; 04/02/2025
  3652 00001563 2C80                <1> 	sub	al, 80h
  3653 00001565 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3654 00001568 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3655 00001569 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3656 0000156A C3                  <1> 	retn
  3657                              <1> 
  3658                              <1> interpolating_3_8bit_stereo:
  3659                              <1> 	; 04/02/2025
  3660                              <1> 	; 16/11/2023
  3661                              <1> 	; al = [previous_val_l]
  3662                              <1> 	; ah = [previous_val_r]
  3663                              <1> 	; dl = [next_val_l]
  3664                              <1> 	; dh = [next_val_r]
  3665                              <1> 	; original-interpolated-interpolated
  3666 0000156B 89C3                <1> 	mov	bx, ax
  3667 0000156D 2C80                <1> 	sub	al, 80h
  3668 0000156F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3669 00001572 AB                  <1> 	stosw		; original sample (L)
  3670 00001573 88F8                <1> 	mov	al, bh
  3671 00001575 2C80                <1> 	sub	al, 80h
  3672 00001577 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3673 0000157A AB                  <1> 	stosw		; original sample (R)
  3674 0000157B 88D8                <1> 	mov	al, bl
  3675 0000157D 00D0                <1> 	add	al, dl	; [next_val_l]
  3676 0000157F D0D8                <1> 	rcr	al, 1
  3677 00001581 50                  <1> 	push	ax ; *	; al = interpolated middle (L) (temporary)
  3678 00001582 00D8                <1> 	add	al, bl	; [previous_val_l]
  3679 00001584 D0D8                <1> 	rcr	al, 1
  3680 00001586 2C80                <1> 	sub	al, 80h
  3681 00001588 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3682 0000158B AB                  <1> 	stosw		; interpolated sample 1 (L)
  3683 0000158C 88F8                <1> 	mov	al, bh
  3684 0000158E 00F0                <1> 	add	al, dh	; [next_val_r]
  3685 00001590 D0D8                <1> 	rcr	al, 1
  3686 00001592 50                  <1> 	push	ax ; ** ; al = interpolated middle (R) (temporary)
  3687 00001593 00F8                <1> 	add	al, bh	; [previous_val_r]
  3688 00001595 D0D8                <1> 	rcr	al, 1
  3689 00001597 2C80                <1> 	sub	al, 80h
  3690 00001599 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3691 0000159C AB                  <1> 	stosw		; interpolated sample 1 (R)
  3692 0000159D 5B                  <1> 	pop	bx ; **
  3693 0000159E 58                  <1> 	pop	ax ; *
  3694 0000159F 00D0                <1> 	add	al, dl	; [next_val_l]
  3695 000015A1 D0D8                <1> 	rcr	al, 1
  3696                              <1> 	; 04/02/2025
  3697 000015A3 2C80                <1> 	sub	al, 80h
  3698 000015A5 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3699 000015A8 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3700 000015A9 88D8                <1> 	mov	al, bl
  3701 000015AB 00F0                <1> 	add	al, dh	; [next_val_r]
  3702 000015AD D0D8                <1> 	rcr	al, 1
  3703                              <1> 	; 04/02/2025
  3704 000015AF 2C80                <1> 	sub	al, 80h
  3705 000015B1 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3706 000015B4 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3707 000015B5 C3                  <1> 	retn
  3708                              <1> 
  3709                              <1> interpolating_2_8bit_mono:
  3710                              <1> 	; 16/11/2023
  3711                              <1> 	; al = [previous_val]
  3712                              <1> 	; dl = [next_val]
  3713                              <1> 	; original-interpolated
  3714 000015B6 88C3                <1> 	mov	bl, al
  3715 000015B8 2C80                <1> 	sub	al, 80h
  3716 000015BA C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3717 000015BD AB                  <1> 	stosw		; original sample (L)
  3718 000015BE AB                  <1> 	stosw		; original sample (R)
  3719 000015BF 88D8                <1> 	mov	al, bl
  3720 000015C1 00D0                <1> 	add	al, dl
  3721 000015C3 D0D8                <1> 	rcr	al, 1
  3722 000015C5 2C80                <1> 	sub	al, 80h
  3723 000015C7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3724 000015CA AB                  <1> 	stosw		; interpolated sample (L)
  3725 000015CB AB                  <1> 	stosw		; interpolated sample (R)
  3726 000015CC C3                  <1> 	retn
  3727                              <1> 
  3728                              <1> interpolating_2_8bit_stereo:
  3729                              <1> 	; 16/11/2023
  3730                              <1> 	; al = [previous_val_l]
  3731                              <1> 	; ah = [previous_val_r]
  3732                              <1> 	; dl = [next_val_l]
  3733                              <1> 	; dh = [next_val_r]
  3734                              <1> 	; original-interpolated
  3735 000015CD 89C3                <1> 	mov	bx, ax
  3736 000015CF 2C80                <1> 	sub	al, 80h
  3737 000015D1 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3738 000015D4 AB                  <1> 	stosw		; original sample (L)
  3739 000015D5 88F8                <1> 	mov	al, bh
  3740 000015D7 2C80                <1> 	sub	al, 80h
  3741 000015D9 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3742 000015DC AB                  <1> 	stosw		; original sample (R)
  3743 000015DD 88D8                <1> 	mov	al, bl	; [previous_val_l]
  3744 000015DF 00D0                <1> 	add	al, dl	; [next_val_l]	
  3745 000015E1 D0D8                <1> 	rcr	al, 1
  3746 000015E3 2C80                <1> 	sub	al, 80h
  3747 000015E5 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3748 000015E8 AB                  <1> 	stosw		; interpolated sample (L)
  3749 000015E9 88F8                <1> 	mov	al, bh
  3750 000015EB 00F0                <1> 	add	al, dh	; [next_val_r]
  3751 000015ED D0D8                <1> 	rcr	al, 1
  3752 000015EF 2C80                <1> 	sub	al, 80h
  3753 000015F1 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3754 000015F4 AB                  <1> 	stosw		; interpolated sample (R)
  3755 000015F5 C3                  <1> 	retn
  3756                              <1> 
  3757                              <1> interpolating_3_16bit_mono:
  3758                              <1> 	; 16/11/2023
  3759                              <1> 	; ax = [previous_val]
  3760                              <1> 	; dx = [next_val]
  3761                              <1> 	; original-interpolated-interpolated
  3762                              <1> 
  3763 000015F6 AB                  <1> 	stosw		; original sample (L)
  3764 000015F7 AB                  <1> 	stosw		; original sample (R)
  3765 000015F8 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3766 000015FB 50                  <1> 	push	ax ; *	; [previous_val]
  3767 000015FC 80C680              <1> 	add	dh, 80h
  3768 000015FF 01D0                <1> 	add	ax, dx
  3769 00001601 D1D8                <1> 	rcr	ax, 1
  3770 00001603 5B                  <1> 	pop	bx ; *
  3771 00001604 93                  <1> 	xchg	bx, ax	; bx  = interpolated middle (temporary)
  3772 00001605 01D8                <1> 	add	ax, bx	; [previous_val] + interpolated middle
  3773 00001607 D1D8                <1> 	rcr	ax, 1
  3774 00001609 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3775 0000160C AB                  <1> 	stosw 		; interpolated sample 1 (L)
  3776 0000160D AB                  <1> 	stosw		; interpolated sample 1 (R)
  3777 0000160E 89D8                <1> 	mov	ax, bx
  3778 00001610 01D0                <1> 	add	ax, dx	 ;interpolated middle + [next_val]
  3779 00001612 D1D8                <1> 	rcr	ax, 1
  3780 00001614 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3781 00001617 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3782 00001618 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3783 00001619 C3                  <1> 	retn
  3784                              <1> 
  3785                              <1> interpolating_3_16bit_stereo:
  3786                              <1> 	; 16/11/2023
  3787                              <1> 	; bx = [previous_val_l]
  3788                              <1> 	; ax = [previous_val_r]
  3789                              <1> 	; [next_val_l]
  3790                              <1> 	; dx = [next_val_r]
  3791                              <1> 	; original-interpolated-interpolated
  3792                              <1> 
  3793 0000161A 93                  <1> 	xchg	ax, bx
  3794 0000161B AB                  <1> 	stosw		; original sample (L)
  3795 0000161C 93                  <1> 	xchg	ax, bx
  3796 0000161D AB                  <1> 	stosw		; original sample (R)
  3797 0000161E 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3798 00001621 50                  <1> 	push	ax ; *	; [previous_val_r]
  3799 00001622 80C780              <1> 	add	bh, 80h
  3800 00001625 8006[7B19]80        <1> 	add	byte [next_val_l+1], 80h
  3801 0000162A A1[7A19]            <1> 	mov	ax, [next_val_l]
  3802 0000162D 01D8                <1> 	add	ax, bx	; [previous_val_l]
  3803 0000162F D1D8                <1> 	rcr	ax, 1
  3804 00001631 93                  <1> 	xchg	ax, bx	; ax = [previous_val_l]	
  3805 00001632 01D8                <1> 	add	ax, bx	; bx = interpolated middle (L)
  3806 00001634 D1D8                <1> 	rcr	ax, 1
  3807 00001636 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3808 00001639 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  3809 0000163A 58                  <1> 	pop	ax  ; *
  3810 0000163B 80C680              <1> 	add	dh, 80h ; convert sound level 0 to 65535 format
  3811 0000163E 52                  <1> 	push	dx  ; * ; [next_val_r]
  3812 0000163F 92                  <1> 	xchg	ax, dx
  3813 00001640 01D0                <1> 	add	ax, dx	; [next_val_r] + [previous_val_r]
  3814 00001642 D1D8                <1> 	rcr	ax, 1	; / 2
  3815 00001644 50                  <1> 	push	ax ; ** ; interpolated middle (R)
  3816 00001645 01D0                <1> 	add	ax, dx	; + [previous_val_r]
  3817 00001647 D1D8                <1> 	rcr	ax, 1
  3818 00001649 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3819 0000164C AB                  <1> 	stosw 		; interpolated sample 1 (R)
  3820 0000164D A1[7A19]            <1> 	mov	ax, [next_val_l]
  3821 00001650 01D8                <1> 	add	ax, bx	; + interpolated middle (L)
  3822 00001652 D1D8                <1> 	rcr	ax, 1
  3823 00001654 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3824 00001657 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  3825 00001658 58                  <1> 	pop	ax ; **
  3826 00001659 5A                  <1> 	pop	dx ; *
  3827 0000165A 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val_r]
  3828 0000165C D1D8                <1> 	rcr	ax, 1	; / 2
  3829 0000165E 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3830 00001661 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  3831 00001662 C3                  <1> 	retn
  3832                              <1> 
  3833                              <1> interpolating_2_16bit_mono:
  3834                              <1> 	; 16/11/2023
  3835                              <1> 	; ax = [previous_val]
  3836                              <1> 	; dx = [next_val]
  3837                              <1> 	; original-interpolated
  3838                              <1> 
  3839 00001663 AB                  <1> 	stosw		; original sample (L)
  3840 00001664 AB                  <1> 	stosw		; original sample (R)
  3841 00001665 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3842 00001668 80C680              <1> 	add	dh, 80h
  3843 0000166B 01D0                <1> 	add	ax, dx
  3844 0000166D D1D8                <1> 	rcr	ax, 1
  3845 0000166F 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3846 00001672 AB                  <1> 	stosw		; interpolated sample (L)
  3847 00001673 AB                  <1> 	stosw		; interpolated sample (R)
  3848 00001674 C3                  <1> 	retn
  3849                              <1> 
  3850                              <1> interpolating_2_16bit_stereo:
  3851                              <1> 	; 16/11/2023
  3852                              <1> 	; bx = [previous_val_l]
  3853                              <1> 	; ax = [previous_val_r]
  3854                              <1> 	; [next_val_l]
  3855                              <1> 	; dx = [next_val_r]
  3856                              <1> 	; original-interpolated
  3857                              <1> 
  3858 00001675 93                  <1> 	xchg	ax, bx
  3859 00001676 AB                  <1> 	stosw		; original sample (L)
  3860 00001677 93                  <1> 	xchg	ax, bx
  3861 00001678 AB                  <1> 	stosw		; original sample (R)
  3862 00001679 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3863 0000167C 80C680              <1> 	add	dh, 80h
  3864 0000167F 01D0                <1> 	add	ax, dx	; [previous_val_r] + [next_val_r]
  3865 00001681 D1D8                <1> 	rcr	ax, 1	; / 2
  3866 00001683 50                  <1> 	push	ax ; *	; interpolated sample (R)
  3867 00001684 A1[7A19]            <1> 	mov	ax, [next_val_l]
  3868 00001687 80C480              <1> 	add	ah, 80h
  3869 0000168A 80C780              <1> 	add	bh, 80h
  3870 0000168D 01D8                <1> 	add	ax, bx	; [next_val_l] + [previous_val_l]
  3871 0000168F D1D8                <1> 	rcr	ax, 1	; / 2		
  3872 00001691 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3873 00001694 AB                  <1> 	stosw 		; interpolated sample (L)
  3874 00001695 58                  <1> 	pop	ax ; *	
  3875 00001696 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3876 00001699 AB                  <1> 	stosw 		; interpolated sample (R)
  3877 0000169A C3                  <1> 	retn
  3878                              <1> 
  3879                              <1> interpolating_5_8bit_mono:
  3880                              <1> 	; 17/11/2023
  3881                              <1> 	; al = [previous_val]
  3882                              <1> 	; dl = [next_val]
  3883                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  3884 0000169B 88C3                <1> 	mov	bl, al
  3885 0000169D 2C80                <1> 	sub	al, 80h
  3886 0000169F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3887 000016A2 AB                  <1> 	stosw		; original sample (L)
  3888 000016A3 AB                  <1> 	stosw		; original sample (R)
  3889 000016A4 88D8                <1> 	mov	al, bl
  3890 000016A6 00D0                <1> 	add	al, dl
  3891 000016A8 D0D8                <1> 	rcr	al, 1
  3892 000016AA 88C7                <1> 	mov	bh, al	; interpolated middle (temporary)
  3893 000016AC 00D8                <1> 	add	al, bl  ; [previous_val]
  3894 000016AE D0D8                <1> 	rcr	al, 1	
  3895 000016B0 88C6                <1> 	mov	dh, al	; interpolated 1st quarter (temporary)
  3896 000016B2 00D8                <1> 	add	al, bl
  3897 000016B4 D0D8                <1> 	rcr	al, 1
  3898 000016B6 2C80                <1> 	sub	al, 80h
  3899 000016B8 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3900 000016BB AB                  <1> 	stosw		; interpolated sample 1 (L)
  3901 000016BC AB                  <1> 	stosw		; interpolated sample 1 (R)
  3902 000016BD 88F8                <1> 	mov	al, bh
  3903 000016BF 00F0                <1> 	add	al, dh
  3904 000016C1 D0D8                <1> 	rcr	al, 1
  3905 000016C3 2C80                <1> 	sub	al, 80h
  3906 000016C5 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3907 000016C8 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3908 000016C9 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3909 000016CA 88F8                <1> 	mov	al, bh
  3910 000016CC 00D0                <1> 	add	al, dl	; [next_val]
  3911 000016CE D0D8                <1> 	rcr	al, 1
  3912 000016D0 88C6                <1> 	mov	dh, al	; interpolated 3rd quarter (temporary)
  3913 000016D2 00F8                <1> 	add	al, bh
  3914 000016D4 D0D8                <1> 	rcr	al, 1
  3915 000016D6 2C80                <1> 	sub	al, 80h
  3916 000016D8 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3917 000016DB AB                  <1> 	stosw		; interpolated sample 3 (L)
  3918 000016DC AB                  <1> 	stosw		; interpolated sample 3 (R)
  3919 000016DD 88F0                <1> 	mov	al, dh
  3920 000016DF 00D0                <1> 	add	al, dl
  3921 000016E1 D0D8                <1> 	rcr	al, 1
  3922 000016E3 2C80                <1> 	sub	al, 80h
  3923 000016E5 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3924 000016E8 AB                  <1> 	stosw		; interpolated sample 4 (L)
  3925 000016E9 AB                  <1> 	stosw		; interpolated sample 4 (R)
  3926 000016EA C3                  <1> 	retn
  3927                              <1> 
  3928                              <1> interpolating_5_8bit_stereo:
  3929                              <1> 	; 17/11/2023
  3930                              <1> 	; al = [previous_val_l]
  3931                              <1> 	; ah = [previous_val_r]
  3932                              <1> 	; dl = [next_val_l]
  3933                              <1> 	; dh = [next_val_r]
  3934                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  3935 000016EB 89C3                <1> 	mov	bx, ax
  3936 000016ED 2C80                <1> 	sub	al, 80h
  3937 000016EF C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3938 000016F2 AB                  <1> 	stosw		; original sample (L)
  3939 000016F3 88F8                <1> 	mov	al, bh
  3940 000016F5 2C80                <1> 	sub	al, 80h
  3941 000016F7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3942 000016FA AB                  <1> 	stosw		; original sample (R)
  3943 000016FB 52                  <1> 	push	dx ; *
  3944 000016FC 88D8                <1> 	mov	al, bl
  3945 000016FE 00D0                <1> 	add	al, dl	; [next_val_l]
  3946 00001700 D0D8                <1> 	rcr	al, 1
  3947 00001702 50                  <1> 	push	ax ; **	; al = interpolated middle (L) (temporary)
  3948 00001703 00D8                <1> 	add	al, bl	; [previous_val_l]
  3949 00001705 D0D8                <1> 	rcr	al, 1
  3950 00001707 86D8                <1> 	xchg	al, bl
  3951 00001709 00D8                <1> 	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  3952 0000170B D0D8                <1> 	rcr	al, 1
  3953 0000170D 2C80                <1> 	sub	al, 80h
  3954 0000170F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3955 00001712 AB                  <1> 	stosw		; interpolated sample 1 (L)
  3956 00001713 88F8                <1> 	mov	al, bh
  3957 00001715 00F0                <1> 	add	al, dh	; [next_val_r]
  3958 00001717 D0D8                <1> 	rcr	al, 1
  3959 00001719 50                  <1> 	push	ax ; *** ; al = interpolated middle (R) (temporary)
  3960 0000171A 00F8                <1> 	add	al, bh	; [previous_val_r]
  3961 0000171C D0D8                <1> 	rcr	al, 1
  3962 0000171E 86F8                <1> 	xchg	al, bh
  3963 00001720 00F8                <1> 	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  3964 00001722 D0D8                <1> 	rcr	al, 1
  3965 00001724 2C80                <1> 	sub	al, 80h
  3966 00001726 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3967 00001729 AB                  <1> 	stosw		; interpolated sample 1 (R)
  3968 0000172A 5A                  <1> 	pop	dx ; ***
  3969 0000172B 58                  <1> 	pop	ax ; **	; al = interpolated middle (L) (temporary)
  3970 0000172C 86D8                <1> 	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  3971 0000172E 00D8                <1> 	add	al, bl	; bl = interpolated middle (L) (temporary)
  3972 00001730 D0D8                <1> 	rcr	al, 1
  3973 00001732 2C80                <1> 	sub	al, 80h
  3974 00001734 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3975 00001737 AB                  <1> 	stosw		; interpolated sample 2 (L)	
  3976 00001738 88D0                <1> 	mov	al, dl 	; interpolated middle (R) (temporary)
  3977 0000173A 86F8                <1> 	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  3978 0000173C 00F8                <1> 	add	al, bh	; bh = interpolated middle (R) (temporary)
  3979 0000173E D0D8                <1> 	rcr	al, 1
  3980 00001740 2C80                <1> 	sub	al, 80h
  3981 00001742 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3982 00001745 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3983 00001746 5A                  <1> 	pop	dx ; *
  3984 00001747 88D8                <1> 	mov	al, bl	; interpolated middle (L) (temporary)
  3985 00001749 00D0                <1> 	add	al, dl	; [next_val_l]
  3986 0000174B D0D8                <1> 	rcr	al, 1
  3987 0000174D 86D8                <1> 	xchg	al, bl	; al = interpolated middle (R) (temporary)
  3988 0000174F 00D8                <1> 	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  3989 00001751 D0D8                <1> 	rcr	al, 1
  3990 00001753 2C80                <1> 	sub	al, 80h
  3991 00001755 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3992 00001758 AB                  <1> 	stosw		; interpolated sample 3 (L)
  3993 00001759 88F8                <1> 	mov	al, bh	
  3994 0000175B 00F0                <1> 	add	al, dh	; interpolated middle (R) + [next_val_r]
  3995 0000175D D0D8                <1> 	rcr	al, 1
  3996 0000175F 86F8                <1> 	xchg	al, bh	; al = interpolated middle (R)
  3997 00001761 00F8                <1> 	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  3998 00001763 D0D8                <1> 	rcr	al, 1
  3999 00001765 2C80                <1> 	sub	al, 80h
  4000 00001767 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4001 0000176A AB                  <1> 	stosw		; interpolated sample 3 (R)
  4002 0000176B 88D8                <1> 	mov	al, bl
  4003 0000176D 00D0                <1> 	add	al, dl	; [next_val_l]
  4004 0000176F D0D8                <1> 	rcr	al, 1
  4005 00001771 2C80                <1> 	sub	al, 80h
  4006 00001773 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4007 00001776 AB                  <1> 	stosw		; interpolated sample 4 (L)
  4008 00001777 88F8                <1> 	mov	al, bh
  4009 00001779 00F0                <1> 	add	al, dh	; [next_val_r]
  4010 0000177B D0D8                <1> 	rcr	al, 1
  4011 0000177D 2C80                <1> 	sub	al, 80h
  4012 0000177F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4013 00001782 AB                  <1> 	stosw		; interpolated sample 4 (R)
  4014 00001783 C3                  <1> 	retn
  4015                              <1> 
  4016                              <1> interpolating_4_8bit_mono:
  4017                              <1> 	; 17/11/2023
  4018                              <1> 	; al = [previous_val]
  4019                              <1> 	; dl = [next_val]
  4020                              <1> 	; original-interpolated-interpolated-interpolated
  4021 00001784 88C3                <1> 	mov	bl, al
  4022 00001786 2C80                <1> 	sub	al, 80h
  4023 00001788 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4024 0000178B AB                  <1> 	stosw		; original sample (L)
  4025 0000178C AB                  <1> 	stosw		; original sample (R)
  4026 0000178D 88D8                <1> 	mov	al, bl
  4027 0000178F 00D0                <1> 	add	al, dl	
  4028 00001791 D0D8                <1> 	rcr	al, 1
  4029 00001793 86D8                <1> 	xchg	al, bl  ; al = [previous_val]
  4030 00001795 00D8                <1> 	add	al, bl	; bl = interpolated middle (sample 2)
  4031 00001797 D0D8                <1> 	rcr	al, 1	
  4032 00001799 2C80                <1> 	sub	al, 80h
  4033 0000179B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4034 0000179E AB                  <1> 	stosw		; interpolated sample 1 (L)
  4035 0000179F AB                  <1> 	stosw		; interpolated sample 1 (R)
  4036 000017A0 88D8                <1> 	mov	al, bl	; interpolated middle (sample 2)
  4037 000017A2 2C80                <1> 	sub	al, 80h
  4038 000017A4 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4039 000017A7 AB                  <1> 	stosw		; interpolated sample 2 (L)
  4040 000017A8 AB                  <1> 	stosw		; interpolated sample 2 (R)
  4041 000017A9 88D8                <1> 	mov	al, bl
  4042 000017AB 00D0                <1> 	add	al, dl	; [next_val]
  4043 000017AD D0D8                <1> 	rcr	al, 1
  4044 000017AF 2C80                <1> 	sub	al, 80h
  4045 000017B1 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4046 000017B4 AB                  <1> 	stosw		; interpolated sample 3 (L)
  4047 000017B5 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4048 000017B6 C3                  <1> 	retn
  4049                              <1> 
  4050                              <1> interpolating_4_8bit_stereo:
  4051                              <1> 	; 17/11/2023
  4052                              <1> 	; al = [previous_val_l]
  4053                              <1> 	; ah = [previous_val_r]
  4054                              <1> 	; dl = [next_val_l]
  4055                              <1> 	; dh = [next_val_r]
  4056                              <1> 	; original-interpolated-interpolated-interpolated
  4057 000017B7 89C3                <1> 	mov	bx, ax
  4058 000017B9 2C80                <1> 	sub	al, 80h
  4059 000017BB C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4060 000017BE AB                  <1> 	stosw		; original sample (L)
  4061 000017BF 88F8                <1> 	mov	al, bh
  4062 000017C1 2C80                <1> 	sub	al, 80h
  4063 000017C3 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4064 000017C6 AB                  <1> 	stosw		; original sample (R)
  4065 000017C7 88D8                <1> 	mov	al, bl
  4066 000017C9 00D0                <1> 	add	al, dl	; [next_val_l]
  4067 000017CB D0D8                <1> 	rcr	al, 1
  4068 000017CD 86D8                <1> 	xchg	al, bl	; al = [previous_val_l]
  4069 000017CF 00D8                <1> 	add	al, bl	; bl = interpolated middle (L) (sample 2)
  4070 000017D1 D0D8                <1> 	rcr	al, 1
  4071 000017D3 2C80                <1> 	sub	al, 80h
  4072 000017D5 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4073 000017D8 AB                  <1> 	stosw		; interpolated sample 1 (L)
  4074 000017D9 88F8                <1> 	mov	al, bh
  4075 000017DB 00F0                <1> 	add	al, dh	; [next_val_r]
  4076 000017DD D0D8                <1> 	rcr	al, 1
  4077 000017DF 86F8                <1> 	xchg	al, bh	; al = [previous_val_h]
  4078 000017E1 00F8                <1> 	add	al, bh	; bh = interpolated middle (R) (sample 2)
  4079 000017E3 D0D8                <1> 	rcr	al, 1
  4080 000017E5 2C80                <1> 	sub	al, 80h
  4081 000017E7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4082 000017EA AB                  <1> 	stosw		; interpolated sample 1 (R)
  4083 000017EB 88D8                <1> 	mov	al, bl	; interpolated middle (L) (sample 2)
  4084 000017ED 2C80                <1> 	sub	al, 80h
  4085 000017EF C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4086 000017F2 AB                  <1> 	stosw		; interpolated sample 2 (L)
  4087 000017F3 88F8                <1> 	mov	al, bh	; interpolated middle (L) (sample 2)
  4088 000017F5 2C80                <1> 	sub	al, 80h
  4089 000017F7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4090 000017FA AB                  <1> 	stosw		; interpolated sample 2 (L)
  4091 000017FB 88D8                <1> 	mov	al, bl
  4092 000017FD 00D0                <1> 	add	al, dl	; [next_val_l]
  4093 000017FF D0D8                <1> 	rcr	al, 1
  4094 00001801 2C80                <1> 	sub	al, 80h
  4095 00001803 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4096 00001806 AB                  <1> 	stosw		; interpolated sample 3 (L)
  4097 00001807 88F8                <1> 	mov	al, bh
  4098 00001809 00F0                <1> 	add	al, dh	; [next_val_r]
  4099 0000180B D0D8                <1> 	rcr	al, 1
  4100 0000180D 2C80                <1> 	sub	al, 80h
  4101 0000180F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4102 00001812 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4103 00001813 C3                  <1> 	retn
  4104                              <1> 
  4105                              <1> interpolating_5_16bit_mono:
  4106                              <1> 	; 18/11/2023
  4107                              <1> 	; ax = [previous_val]
  4108                              <1> 	; dx = [next_val]
  4109                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  4110 00001814 AB                  <1> 	stosw		; original sample (L)
  4111 00001815 AB                  <1> 	stosw		; original sample (R)
  4112 00001816 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4113 00001819 89C3                <1> 	mov	bx, ax	; [previous_val]
  4114 0000181B 80C680              <1> 	add	dh, 80h
  4115 0000181E 01D0                <1> 	add	ax, dx
  4116 00001820 D1D8                <1> 	rcr	ax, 1
  4117 00001822 50                  <1> 	push	ax ; *	; interpolated middle (temporary)
  4118 00001823 01D8                <1> 	add	ax, bx	; interpolated middle + [previous_val]
  4119 00001825 D1D8                <1> 	rcr	ax, 1
  4120 00001827 50                  <1> 	push	ax ; **	; interpolated 1st quarter (temporary)
  4121 00001828 01D8                <1> 	add	ax, bx	; 1st quarter + [previous_val]
  4122 0000182A D1D8                <1> 	rcr	ax, 1	
  4123 0000182C 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4124 0000182F AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4125 00001830 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4126 00001831 58                  <1> 	pop	ax ; **
  4127 00001832 5B                  <1> 	pop	bx ; *
  4128 00001833 01D8                <1> 	add	ax, bx	; 1st quarter + middle
  4129 00001835 D1D8                <1> 	rcr	ax, 1	; / 2
  4130 00001837 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again	
  4131 0000183A AB                  <1> 	stosw		; interpolated sample 2 (L)
  4132 0000183B AB                  <1> 	stosw		; interpolated sample 2 (R)
  4133 0000183C 89D8                <1> 	mov	ax, bx
  4134 0000183E 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val]
  4135 00001840 D1D8                <1> 	rcr	ax, 1
  4136 00001842 50                  <1> 	push	ax ; *	; interpolated 3rd quarter (temporary)
  4137 00001843 01D8                <1> 	add	ax, bx	; + interpolated middle
  4138 00001845 D1D8                <1> 	rcr	ax, 1
  4139 00001847 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4140 0000184A AB                  <1> 	stosw		; interpolated sample 3 (L)
  4141 0000184B AB                  <1> 	stosw		; interpolated sample 3 (R)
  4142 0000184C 58                  <1> 	pop	ax ; *	
  4143 0000184D 01D0                <1> 	add	ax, dx	; 3rd quarter + [next_val]
  4144 0000184F D1D8                <1> 	rcr	ax, 1	; / 2
  4145 00001851 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4146 00001854 AB                  <1> 	stosw		; interpolated sample 4 (L)
  4147 00001855 AB                  <1> 	stosw		; interpolated sample 4 (R)
  4148 00001856 C3                  <1> 	retn
  4149                              <1> 
  4150                              <1> interpolating_5_16bit_stereo:
  4151                              <1> 	; 18/11/2023
  4152                              <1> 	; bx = [previous_val_l]
  4153                              <1> 	; ax = [previous_val_r]
  4154                              <1> 	; [next_val_l]
  4155                              <1> 	; [next_val_r]
  4156                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  4157 00001857 51                  <1> 	push	cx ; !
  4158 00001858 93                  <1> 	xchg	ax, bx
  4159 00001859 AB                  <1> 	stosw		; original sample (L)
  4160 0000185A 93                  <1> 	xchg	ax, bx
  4161 0000185B AB                  <1> 	stosw		; original sample (R)
  4162 0000185C 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4163 0000185F 50                  <1> 	push	ax ; *	; [previous_val_r]
  4164 00001860 80C780              <1> 	add	bh, 80h
  4165 00001863 8006[7B19]80        <1> 	add	byte [next_val_l+1], 80h
  4166 00001868 A1[7A19]            <1> 	mov	ax, [next_val_l]
  4167 0000186B 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4168 0000186D D1D8                <1> 	rcr	ax, 1
  4169 0000186F 89C1                <1> 	mov	cx, ax	; interpolated middle (L)
  4170 00001871 01D8                <1> 	add	ax, bx	
  4171 00001873 D1D8                <1> 	rcr	ax, 1
  4172 00001875 89C2                <1> 	mov	dx, ax	; interpolated 1st quarter (L)
  4173 00001877 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4174 00001879 D1D8                <1> 	rcr	ax, 1
  4175 0000187B 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4176 0000187E AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4177 0000187F 89C8                <1> 	mov	ax, cx
  4178 00001881 01D0                <1> 	add	ax, dx	; middle (L) + 1st quarter (L)
  4179 00001883 D1D8                <1> 	rcr	ax, 1	; / 2
  4180 00001885 89C3                <1> 	mov	bx, ax  ; interpolated sample 2 (L)
  4181 00001887 5A                  <1> 	pop	dx ; *	; [previous_val_r]
  4182 00001888 89D0                <1> 	mov	ax, dx
  4183 0000188A 8006[7D19]80        <1> 	add	byte [next_val_r+1], 80h
  4184 0000188F 0306[7C19]          <1> 	add	ax, [next_val_r]
  4185 00001893 D1D8                <1> 	rcr	ax, 1
  4186 00001895 50                  <1> 	push	ax ; *	; interpolated middle (R)
  4187 00001896 01D0                <1> 	add	ax, dx
  4188 00001898 D1D8                <1> 	rcr	ax, 1
  4189 0000189A 50                  <1> 	push	ax ; **	; interpolated 1st quarter (R)
  4190 0000189B 01D0                <1> 	add	ax, dx	; [previous_val_r]
  4191 0000189D D1D8                <1> 	rcr	ax, 1
  4192 0000189F 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4193 000018A2 AB                  <1> 	stosw 		; interpolated sample 1 (R)
  4194 000018A3 89D8                <1> 	mov	ax, bx
  4195 000018A5 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4196 000018A8 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4197 000018A9 58                  <1> 	pop	ax ; **
  4198 000018AA 5A                  <1> 	pop	dx ; *
  4199 000018AB 01D0                <1> 	add	ax, dx	; 1st quarter (R) + middle (R)
  4200 000018AD D1D8                <1> 	rcr	ax, 1	; / 2
  4201 000018AF 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4202 000018B2 AB                  <1> 	stosw 		; interpolated sample 2 (R)
  4203 000018B3 89C8                <1> 	mov	ax, cx
  4204 000018B5 0306[7A19]          <1> 	add	ax, [next_val_l]
  4205 000018B9 D1D8                <1> 	rcr	ax, 1
  4206 000018BB 50                  <1> 	push	ax ; * 	; interpolated 3rd quarter (L)
  4207 000018BC 01C8                <1> 	add	ax, cx	; interpolated middle (L)
  4208 000018BE D1D8                <1> 	rcr	ax, 1
  4209 000018C0 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4210 000018C3 AB                  <1> 	stosw 		; interpolated sample 3 (L)
  4211 000018C4 89D0                <1> 	mov	ax, dx
  4212 000018C6 0306[7C19]          <1> 	add	ax, [next_val_r]
  4213 000018CA D1D8                <1> 	rcr	ax, 1
  4214 000018CC 50                  <1> 	push	ax ; ** ; interpolated 3rd quarter (R)
  4215 000018CD 01D0                <1> 	add	ax, dx	; interpolated middle (R)
  4216 000018CF D1D8                <1> 	rcr	ax, 1
  4217 000018D1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4218 000018D4 AB                  <1> 	stosw 		; interpolated sample 3 (R)
  4219 000018D5 5B                  <1> 	pop	bx ; **
  4220 000018D6 58                  <1> 	pop	ax ; *
  4221 000018D7 0306[7A19]          <1> 	add	ax, [next_val_l]
  4222 000018DB D1D8                <1> 	rcr	ax, 1
  4223 000018DD 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4224 000018E0 AB                  <1> 	stosw 		; interpolated sample 4 (L)
  4225 000018E1 89D8                <1> 	mov	ax, bx	
  4226 000018E3 0306[7C19]          <1> 	add	ax, [next_val_r]
  4227 000018E7 D1D8                <1> 	rcr	ax, 1
  4228 000018E9 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4229 000018EC AB                  <1> 	stosw 		; interpolated sample 4 (R)
  4230 000018ED 59                  <1> 	pop	cx ; !
  4231 000018EE C3                  <1> 	retn
  4232                              <1> 
  4233                              <1> interpolating_4_16bit_mono:
  4234                              <1> 	; 18/11/2023
  4235                              <1> 	; ax = [previous_val]
  4236                              <1> 	; dx = [next_val]
  4237                              <1> 	; original-interpolated-interpolated-interpolated
  4238                              <1> 
  4239 000018EF AB                  <1> 	stosw		; original sample (L)
  4240 000018F0 AB                  <1> 	stosw		; original sample (R)
  4241 000018F1 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4242 000018F4 89C3                <1> 	mov	bx, ax	; [previous_val]
  4243 000018F6 80C680              <1> 	add	dh, 80h
  4244 000018F9 01D0                <1> 	add	ax, dx	; [previous_val] + [next_val]
  4245 000018FB D1D8                <1> 	rcr	ax, 1
  4246 000018FD 93                  <1> 	xchg	ax, bx	
  4247 000018FE 01D8                <1> 	add	ax, bx	; [previous_val] + interpolated middle
  4248 00001900 D1D8                <1> 	rcr	ax, 1
  4249 00001902 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4250 00001905 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4251 00001906 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4252 00001907 89D8                <1> 	mov	ax, bx	; interpolated middle
  4253 00001909 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4254 0000190C AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4255 0000190D AB                  <1> 	stosw		; interpolated sample 2 (R)
  4256 0000190E 89D8                <1> 	mov	ax, bx
  4257 00001910 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val]
  4258 00001912 D1D8                <1> 	rcr	ax, 1
  4259 00001914 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4260 00001917 AB                  <1> 	stosw		; interpolated sample 3 (L)
  4261 00001918 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4262 00001919 C3                  <1> 	retn
  4263                              <1> 
  4264                              <1> interpolating_4_16bit_stereo:
  4265                              <1> 	; 18/11/2023
  4266                              <1> 	; bx = [previous_val_l]
  4267                              <1> 	; ax = [previous_val_r]
  4268                              <1> 	; [next_val_l]
  4269                              <1> 	; [next_val_r]
  4270                              <1> 	; original-interpolated-interpolated-interpolated
  4271 0000191A 93                  <1> 	xchg	ax, bx
  4272 0000191B AB                  <1> 	stosw		; original sample (L)
  4273 0000191C 93                  <1> 	xchg	ax, bx
  4274 0000191D AB                  <1> 	stosw		; original sample (R)
  4275 0000191E 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4276 00001921 89C2                <1> 	mov	dx, ax	; [previous_val_r]
  4277 00001923 80C780              <1> 	add	bh, 80h
  4278 00001926 8006[7B19]80        <1> 	add	byte [next_val_l+1], 80h
  4279 0000192B A1[7A19]            <1> 	mov	ax, [next_val_l]
  4280 0000192E 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4281 00001930 D1D8                <1> 	rcr	ax, 1
  4282 00001932 93                  <1> 	xchg	ax, bx
  4283 00001933 01D8                <1> 	add	ax, bx	; bx = interpolated middle (L)
  4284 00001935 D1D8                <1> 	rcr	ax, 1
  4285 00001937 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4286 0000193A AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4287 0000193B 8006[7D19]80        <1> 	add	byte [next_val_r+1], 80h
  4288 00001940 89D0                <1> 	mov	ax, dx	; [previous_val_r]
  4289 00001942 0306[7C19]          <1> 	add	ax, [next_val_r]
  4290 00001946 D1D8                <1> 	rcr	ax, 1
  4291 00001948 92                  <1> 	xchg	ax, dx
  4292 00001949 01D0                <1> 	add	ax, dx	; dx = interpolated middle (R)
  4293 0000194B D1D8                <1> 	rcr	ax, 1
  4294 0000194D 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4295 00001950 AB                  <1> 	stosw 		; interpolated sample 1 (R)
  4296 00001951 89D8                <1> 	mov	ax, bx
  4297 00001953 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4298 00001956 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4299 00001957 89D0                <1> 	mov	ax, dx
  4300 00001959 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4301 0000195C AB                  <1> 	stosw 		; interpolated sample 2 (R)
  4302 0000195D 89D8                <1> 	mov	ax, bx
  4303 0000195F 0306[7A19]          <1> 	add	ax, [next_val_l]
  4304 00001963 D1D8                <1> 	rcr	ax, 1
  4305 00001965 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4306 00001968 AB                  <1> 	stosw 		; interpolated sample 3 (L)
  4307 00001969 89D0                <1> 	mov	ax, dx
  4308 0000196B 0306[7C19]          <1> 	add	ax, [next_val_r]
  4309 0000196F D1D8                <1> 	rcr	ax, 1
  4310 00001971 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4311 00001974 AB                  <1> 	stosw 		; interpolated sample 3 (R)
  4312 00001975 C3                  <1> 	retn
  4313                              <1> 
  4314                              <1> ; 13/11/2023
  4315                              <1> previous_val:
  4316 00001976 0000                <1> previous_val_l: dw 0
  4317 00001978 0000                <1> previous_val_r: dw 0
  4318                              <1> next_val:
  4319 0000197A 0000                <1> next_val_l: dw 0
  4320 0000197C 0000                <1> next_val_r: dw 0
  4321                              <1> 
  4322                              <1> ; 16/11/2023
  4323 0000197E 00                  <1> faz:	db 0
  4324                              <1> 
  4325                              <1> ; --------------------------------------------------------
   454                                  
   455                                  ; UTILS.ASM
   456                                  ;----------------------------------------------------------------------------
   457                                  ;       delay1_4ms - Delay for 1/4 millisecond.
   458                                  ;		    1mS = 1000us
   459                                  ;       Entry:
   460                                  ;         None
   461                                  ;       Exit:
   462                                  ;	  None
   463                                  ;
   464                                  ;       Modified:
   465                                  ;         None
   466                                  ;
   467                                  PORTB			EQU	061h
   468                                    REFRESH_STATUS	EQU	010h		; Refresh signal status
   469                                  
   470                                  delay1_4ms:
   471 0000197F 50                              push    ax 
   472 00001980 51                              push    cx
   473 00001981 B91000                          mov     cx, 16			; close enough.
   474 00001984 E461                    	in	al,PORTB
   475 00001986 2410                    	and	al,REFRESH_STATUS
   476 00001988 88C4                    	mov	ah,al			; Start toggle state
   477 0000198A 09C9                    	or	cx, cx
   478 0000198C 7401                    	jz	short _d4ms1
   479 0000198E 41                      	inc	cx			; Throwaway first toggle
   480                                  _d4ms1:	
   481 0000198F E461                    	in	al,PORTB		; Read system control port
   482 00001991 2410                    	and	al,REFRESH_STATUS	; Refresh toggles 15.085 microseconds
   483 00001993 38C4                    	cmp	ah,al
   484 00001995 74F8                    	je	short _d4ms1		; Wait for state change
   485                                  
   486 00001997 88C4                    	mov	ah,al			; Update with new state
   487 00001999 49                      	dec	cx
   488 0000199A 75F3                    	jnz	short _d4ms1
   489                                  
   490 0000199C 59                              pop     cx
   491 0000199D 58                              pop     ax
   492 0000199E C3                              retn
   493                                  
   494                                  	; 13/11/2016 - Erdogan Tan
   495                                  write_ac97_dev_info:
   496                                  	; BUS/DEV/FN
   497                                  	;	00000000BBBBBBBBDDDDDFFF00000000
   498                                  	; DEV/VENDOR
   499                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
   500                                  
   501 0000199F 30FF                    	xor	bh, bh
   502 000019A1 668B36[701D]            	mov	esi, [dev_vendor]
   503 000019A6 89F0                    	mov	ax, si
   504 000019A8 88C3                    	mov	bl, al
   505 000019AA 88DA                    	mov	dl, bl
   506 000019AC 80E30F                  	and	bl, 0Fh
   507 000019AF 8A87[F01B]              	mov	al, [bx+hex_chars]
   508 000019B3 A2[331C]                	mov	[msgVendorId+3], al
   509 000019B6 88D3                    	mov	bl, dl
   510 000019B8 C0EB04                  	shr	bl, 4
   511 000019BB 8A87[F01B]              	mov	al, [bx+hex_chars]
   512 000019BF A2[321C]                	mov	[msgVendorId+2], al
   513 000019C2 88E3                    	mov	bl, ah
   514 000019C4 88DA                    	mov	dl, bl
   515 000019C6 80E30F                  	and	bl, 0Fh
   516 000019C9 8A87[F01B]              	mov	al, [bx+hex_chars]
   517 000019CD A2[311C]                	mov	[msgVendorId+1], al
   518 000019D0 88D3                    	mov	bl, dl
   519 000019D2 C0EB04                  	shr	bl, 4
   520 000019D5 8A87[F01B]              	mov	al, [bx+hex_chars]
   521 000019D9 A2[301C]                	mov	[msgVendorId], al
   522 000019DC 66C1EE10                	shr	esi, 16
   523 000019E0 89F0                    	mov	ax, si
   524 000019E2 88C3                    	mov	bl, al
   525 000019E4 88DA                    	mov	dl, bl
   526 000019E6 80E30F                  	and	bl, 0Fh
   527 000019E9 8A87[F01B]              	mov	al, [bx+hex_chars]
   528 000019ED A2[441C]                	mov	[msgDevId+3], al
   529 000019F0 88D3                    	mov	bl, dl
   530 000019F2 C0EB04                  	shr	bl, 4
   531 000019F5 8A87[F01B]              	mov	al, [bx+hex_chars]
   532 000019F9 A2[431C]                	mov	[msgDevId+2], al
   533 000019FC 88E3                    	mov	bl, ah
   534 000019FE 88DA                    	mov	dl, bl
   535 00001A00 80E30F                  	and	bl, 0Fh
   536 00001A03 8A87[F01B]              	mov	al, [bx+hex_chars]
   537 00001A07 A2[421C]                	mov	[msgDevId+1], al
   538 00001A0A 88D3                    	mov	bl, dl
   539 00001A0C C0EB04                  	shr	bl, 4
   540 00001A0F 8A87[F01B]              	mov	al, [bx+hex_chars]
   541 00001A13 A2[411C]                	mov	[msgDevId], al
   542                                  
   543 00001A16 668B36[6C1D]            	mov	esi, [bus_dev_fn]
   544 00001A1B 66C1EE08                	shr	esi, 8
   545 00001A1F 89F0                    	mov	ax, si
   546 00001A21 88C3                    	mov	bl, al
   547 00001A23 88DA                    	mov	dl, bl
   548 00001A25 80E307                  	and	bl, 7 ; bit 0,1,2
   549 00001A28 8A87[F01B]              	mov	al, [bx+hex_chars]
   550 00001A2C A2[681C]                	mov	[msgFncNo+1], al
   551 00001A2F 88D3                    	mov	bl, dl
   552 00001A31 C0EB03                  	shr	bl, 3
   553 00001A34 88DA                    	mov	dl, bl
   554 00001A36 80E30F                  	and	bl, 0Fh
   555 00001A39 8A87[F01B]              	mov	al, [bx+hex_chars]
   556 00001A3D A2[5A1C]                	mov	[msgDevNo+1], al
   557 00001A40 88D3                    	mov	bl, dl
   558 00001A42 C0EB04                  	shr	bl, 4
   559 00001A45 8A87[F01B]              	mov	al, [bx+hex_chars]
   560 00001A49 A2[591C]                	mov	[msgDevNo], al
   561 00001A4C 88E3                    	mov	bl, ah
   562 00001A4E 88DA                    	mov	dl, bl
   563 00001A50 80E30F                  	and	bl, 0Fh
   564 00001A53 8A87[F01B]              	mov	al, [bx+hex_chars]
   565 00001A57 A2[4E1C]                	mov	[msgBusNo+1], al
   566 00001A5A 88D3                    	mov	bl, dl
   567 00001A5C C0EB04                  	shr	bl, 4
   568 00001A5F 8A87[F01B]              	mov	al, [bx+hex_chars]
   569 00001A63 A2[4D1C]                	mov	[msgBusNo], al
   570                                  
   571 00001A66 A1[621D]                	mov	ax, [NAMBAR]
   572 00001A69 88C3                    	mov	bl, al
   573 00001A6B 88DA                    	mov	dl, bl
   574 00001A6D 80E30F                  	and	bl, 0Fh
   575 00001A70 8A87[F01B]              	mov	al, [bx+hex_chars]
   576 00001A74 A2[771C]                	mov	[msgNamBar+3], al
   577 00001A77 88D3                    	mov	bl, dl
   578 00001A79 C0EB04                  	shr	bl, 4
   579 00001A7C 8A87[F01B]              	mov	al, [bx+hex_chars]
   580 00001A80 A2[761C]                	mov	[msgNamBar+2], al
   581 00001A83 88E3                    	mov	bl, ah
   582 00001A85 88DA                    	mov	dl, bl
   583 00001A87 80E30F                  	and	bl, 0Fh
   584 00001A8A 8A87[F01B]              	mov	al, [bx+hex_chars]
   585 00001A8E A2[751C]                	mov	[msgNamBar+1], al
   586 00001A91 88D3                    	mov	bl, dl
   587 00001A93 C0EB04                  	shr	bl, 4
   588 00001A96 8A87[F01B]              	mov	al, [bx+hex_chars]
   589 00001A9A A2[741C]                	mov	[msgNamBar], al
   590                                  
   591                                  	; 08/05/2024 (ebx->bx)
   592                                  	; 05/11/2023
   593 00001A9D A1[641D]                	mov	ax, [NABMBAR]
   594 00001AA0 88C3                    	mov	bl, al
   595 00001AA2 88DA                    	mov	dl, bl
   596 00001AA4 80E30F                  	and	bl, 0Fh
   597 00001AA7 8A87[F01B]              	mov	al, [bx+hex_chars]
   598 00001AAB A2[861C]                	mov	[msgNabmBar+3], al
   599 00001AAE 88D3                    	mov	bl, dl
   600 00001AB0 C0EB04                  	shr	bl, 4
   601 00001AB3 8A87[F01B]              	mov	al, [bx+hex_chars]
   602 00001AB7 A2[851C]                	mov	[msgNabmBar+2], al
   603 00001ABA 88E3                    	mov	bl, ah
   604 00001ABC 88DA                    	mov	dl, bl
   605 00001ABE 80E30F                  	and	bl, 0Fh
   606 00001AC1 8A87[F01B]              	mov	al, [bx+hex_chars]
   607 00001AC5 A2[841C]                	mov	[msgNabmBar+1], al
   608 00001AC8 88D3                    	mov	bl, dl
   609 00001ACA C0EB04                  	shr	bl, 4
   610 00001ACD 8A87[F01B]              	mov	al, [bx+hex_chars]
   611 00001AD1 A2[831C]                	mov	[msgNabmBar], al
   612                                  
   613                                  	; 24/11/2016
   614 00001AD4 30E4                    	xor	ah, ah
   615 00001AD6 A0[611D]                	mov	al, [ac97_int_ln_reg]
   616 00001AD9 B10A                    	mov	cl, 10
   617 00001ADB F6F1                    	div	cl
   618 00001ADD 0106[8E1C]              	add	[msgIRQ], ax
   619 00001AE1 20C0                    	and	al, al
   620 00001AE3 7508                    	jnz	short _pmi
   621 00001AE5 A0[8F1C]                	mov	al, [msgIRQ+1]
   622 00001AE8 B420                    	mov	ah, ' '
   623 00001AEA A3[8E1C]                	mov	[msgIRQ], ax
   624                                  _pmi:
   625 00001AED BA[011C]                        mov	dx, msgAC97Info
   626 00001AF0 B409                            mov     ah, 9
   627 00001AF2 CD21                            int     21h
   628 00001AF4 C3                              retn
   629                                  
   630                                  write_sample_rate:
   631                                  	; ax = sample rate (hertz)
   632                                  
   633 00001AF5 31D2                    	xor	dx, dx
   634 00001AF7 B90A00                  	mov	cx, 10
   635 00001AFA F7F1                    	div	cx
   636 00001AFC 0016[A41C]              	add	[msgHertz+4], dl
   637 00001B00 29D2                    	sub	dx, dx
   638 00001B02 F7F1                    	div	cx
   639 00001B04 0016[A31C]              	add	[msgHertz+3], dl
   640 00001B08 29D2                    	sub	dx, dx
   641 00001B0A F7F1                    	div	cx
   642 00001B0C 0016[A21C]              	add	[msgHertz+2], dl
   643 00001B10 29D2                    	sub	dx, dx
   644 00001B12 F7F1                    	div	cx
   645 00001B14 0016[A11C]              	add	[msgHertz+1], dl
   646 00001B18 0006[A01C]              	add	[msgHertz], al
   647                                  	
   648 00001B1C BA[931C]                        mov     dx, msgSampleRate
   649 00001B1F B409                            mov     ah, 9
   650 00001B21 CD21                            int     21h
   651                                  
   652                                  	; 19/11/2016
   653 00001B23 BA[B91C]                	mov	dx, msg16Bits
   654 00001B26 803E[781D]10            	cmp	byte [bps], 16
   655 00001B2B 7403                    	je	short wsr_1
   656 00001B2D BA[AA1C]                	mov	dx, msg8Bits
   657                                  wsr_1:
   658 00001B30 B409                            mov     ah, 9
   659 00001B32 CD21                            int     21h
   660                                  
   661 00001B34 BA[B21C]                	mov	dx, msgMono
   662 00001B37 803E[761D]01            	cmp	byte [stmo], 1
   663 00001B3C 7403                    	je	short wsr_2
   664 00001B3E BA[C21C]                	mov	dx, msgStereo		
   665                                  wsr_2:
   666 00001B41 B409                            mov     ah, 9
   667 00001B43 CD21                            int     21h
   668                                  
   669 00001B45 C3                              retn
   670                                  
   671                                  ;detect_codec:
   672                                  ;	; 13/11/2016 - Erdogan Tan (Ref: KolibriOS, codec.inc)
   673                                  ;	mov	eax, 7Ch
   674                                  ;	call	codec_read
   675                                  ;       shl     eax, 16
   676                                  ;       mov     [codec_id], eax
   677                                  ;
   678                                  ;	mov	eax, 7Eh
   679                                  ;       call	codec_read
   680                                  ;       or      eax, [codec_id]
   681                                  ;       mov     [codec_chip_id], eax
   682                                  ;       and     eax, 0FFFFFF00h
   683                                  ;
   684                                  ;       mov     edi, codecs
   685                                  ;_dcb:
   686                                  ;       mov     ebx, [di]
   687                                  ;       test    ebx, ebx
   688                                  ;       jz      short _dco_unknown
   689                                  ;
   690                                  ;       cmp     eax, ebx
   691                                  ;       jne     short _dco_next
   692                                  ;       mov     ax, [di+4]
   693                                  ;       mov     [codec_vendor_ids], ax
   694                                  ;       movzx   esi, ax
   695                                  ;       call	print_msg
   696                                  ;       
   697                                  ;	mov	ax, [di+6]
   698                                  ;	call	detect_chip
   699                                  ;       retn
   700                                  ;
   701                                  ;_dco_next:
   702                                  ;       add     di, 8
   703                                  ;       jmp     short _dcb
   704                                  ;
   705                                  ;_dco_unknown:
   706                                  ;       mov    word [codec_vendor_ids], ac_unknown
   707                                  ;       mov    word [codec_chip_ids], chip_unknown
   708                                  ;       mov     esi, chip_unknown
   709                                  ;	call	print_msg
   710                                  ;       mov     eax, [codec_chip_id]
   711                                  ;       call    dword2str
   712                                  ;       call	print_msg
   713                                  ;       retn
   714                                  
   715                                  ;detect_chip:
   716                                  ;	; 13/11/2016 - Erdogan Tan (Ref: KolibriOS, codec.inc)
   717                                  ;	mov	di, ax ; chip_tab
   718                                  ;       mov     eax, [codec_chip_id]
   719                                  ;       and     ax, 0FFh
   720                                  ;_dch1:
   721                                  ;       mov     bx, [di]
   722                                  ;       cmp     bx, 0FFh
   723                                  ;       je      short _dch_unknown
   724                                  ;
   725                                  ;       cmp     ax, bx
   726                                  ;       jne     short _dch_next
   727                                  ;       mov     ax, [di+2]
   728                                  ;       mov     [codec_chip_ids], ax
   729                                  ;       mov     si, ax
   730                                  ;       call	print_msg
   731                                  ;       retn
   732                                  
   733                                  ;_dch_next:
   734                                  ;       add     di, 4
   735                                  ;       jmp     short _dch1
   736                                  ;
   737                                  ;_dch_unknown:
   738                                  ;       mov    word [codec_chip_ids], chip_unknown
   739                                  ;       mov     si, chip_unknown
   740                                  ;       call	print_msg
   741                                  ;       mov     eax, [codec_chip_id]
   742                                  ;       call    dword2str
   743                                  ;       call	print_msg
   744                                  ;       retn
   745                                  
   746                                  ; 19/05/2024
   747                                  ; 16/05/2024
   748                                  %if 0
   749                                  	; 16/05/2024
   750                                  	; 15/05/2024
   751                                  ac97_int_handler:
   752                                  	; 13/05/2024
   753                                  	; 12/05/2024
   754                                  	; 11/05/2024
   755                                  	; 11/11/2023
   756                                  	; 10/11/2023
   757                                  	; 17/02/2016
   758                                  	push	ax ; +	; 16/05/2024
   759                                  	;push	eax ; *	; 11/11/2023
   760                                  	push	dx ; **
   761                                  	; 05/11/2023
   762                                  	;push	cx
   763                                  	;push	bx
   764                                  	;push	si
   765                                  	;push	di
   766                                  
   767                                  	; 16/05/2024
   768                                  	; 10/11/2023
   769                                  	; EOI at first
   770                                  	mov	al, 20h
   771                                  	test	byte [ac97_int_ln_reg], 8
   772                                  	jz	short _ih_0
   773                                  	out 	0A0h, al ; 20h	; EOI
   774                                  _ih_0:
   775                                  	out	20h, al  ; 20h	; EOI
   776                                  
   777                                  	; 16/05/2024
   778                                  ;	mov	dx, GLOB_STS_REG
   779                                  ;	add	dx, [NABMBAR]
   780                                  ;	in	eax, dx
   781                                  ;
   782                                  ;	inc	eax	; 0FFFFFFFFh
   783                                  ;	jz	short _ih_3
   784                                  ;	dec	eax	; 0
   785                                  ;	;jz	short _ih_3
   786                                  ;_ih_3:
   787                                  ;	; 16/05/2024
   788                                  ;	push	eax ; ***
   789                                  
   790                                  	; 16/05/2024
   791                                  	; 24/11/2023 (TRDOS386 'audio.s')
   792                                          mov	dx, [NABMBAR]
   793                                  	add	dx, PO_SR_REG
   794                                  	in	ax, dx
   795                                  
   796                                  	test	al, BCIS ; bit 3, 8
   797                                  	jz	short _ih_2
   798                                  
   799                                  	; 15/05/2024
   800                                  	cmp	byte [tLoop], 1
   801                                  	jb	short _ih_2
   802                                  _ih_1:
   803                                  	; 16/05/2024
   804                                  	; 13/05/2024
   805                                  	;mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
   806                                  	;add	dx, PO_SR_REG
   807                                          ;add	dx, [NABMBAR]
   808                                  	;out	dx, ax
   809                                  
   810                                  	; 16/05/2024
   811                                  	push	ax ; ****
   812                                  
   813                                  	; 13/05/2024
   814                                  	mov	dx, PO_CIV_REG
   815                                          add	dx, [NABMBAR]
   816                                  	in	al, dx
   817                                  	mov	ah, al
   818                                  	dec	al
   819                                  	and	al, 1Fh
   820                                          mov     dx, PO_LVI_REG
   821                                          add	dx, [NABMBAR]
   822                                          out	dx, al
   823                                  	and	ah, 1
   824                                  	; 13/05/2024
   825                                  	inc	ah
   826                                  	mov	[tBuff], ah ; 1 = Buffer 1, 2 = Buffer 2
   827                                  
   828                                  	; 13/05/2024
   829                                  	; 10/11/2023
   830                                  	; 28/11/2016 - Erdogan Tan
   831                                  	;call	tuneLoop
   832                                  
   833                                  	; 16/05/2024
   834                                  	pop	ax ; ****
   835                                  
   836                                  	; 16/05/2024
   837                                  _ih_2:
   838                                  	;mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
   839                                  	mov	dx, [NABMBAR]
   840                                  	add	dx, PO_SR_REG
   841                                  	out	dx, ax
   842                                  
   843                                  ;	; 16/05/2024
   844                                  ;	pop	eax ; ***
   845                                  ;	
   846                                  ;	or	eax, eax
   847                                  ;	jz	short _ih_4
   848                                  ;	
   849                                  ;	mov	dx, GLOB_STS_REG
   850                                  ;	add	dx, [NABMBAR]
   851                                  ;	out	dx, eax
   852                                  
   853                                  	; 16/05/2024
   854                                  _ih_4:
   855                                  	; 10/11/2023
   856                                  	;mov	al, 20h
   857                                  	;test	byte [ac97_int_ln_reg], 8
   858                                  	;jz	short _ih_5
   859                                  	;out 	0A0h, al ; 20h	; EOI
   860                                  ;_ih_5:
   861                                  	;out	20h, al  ; 20h	; EOI
   862                                  ;_ih_6:
   863                                  	;pop	di
   864                                  	;pop	si
   865                                  	;pop	bx
   866                                  	;pop	cx
   867                                  	pop	dx ; **
   868                                  	;pop	eax ; *	; 11/11/2023
   869                                  	pop	ax ; + ; 16/05/2024
   870                                  	iret
   871                                  %endif
   872                                  
   873                                  print_msg:
   874                                  	; 13/11/2016 - Erdogan Tan 
   875                                  	; esi = ASCIIZ text address
   876                                  	;
   877 00001B46 BB0700                  	mov	bx, 7h
   878 00001B49 B40E                    	mov	ah, 0Eh 
   879                                  pm_next_char:
   880 00001B4B AC                      	lodsb
   881 00001B4C 20C0                    	and	al, al
   882 00001B4E 7404                    	jz	short pm_retn
   883 00001B50 CD10                    	int	10h
   884 00001B52 EBF7                    	jmp	short pm_next_char
   885                                  pm_retn:
   886 00001B54 C3                      	retn
   887                                  
   888                                  ; 06/11/2023
   889                                  ;dword2str:
   890                                  ;	; 13/11/2016 - Erdogan Tan 
   891                                  ;	; eax = dword value
   892                                  ;	;
   893                                  ;	call	dwordtohex
   894                                  ;	mov	[dword_str], edx
   895                                  ;	mov	[dword_str+4], eax
   896                                  ;	mov	si, dword_str
   897                                  ;	retn
   898                                  
   899                                  	; trdos386.s (unix386.s) - 10/05/2015
   900                                  	; Convert binary number to hexadecimal string
   901                                  
   902                                  bytetohex:
   903                                  	; INPUT ->
   904                                  	; 	AL = byte (binary number)
   905                                  	; OUTPUT ->
   906                                  	;	AX = hexadecimal string
   907                                  	;
   908 00001B55 53                      	push	bx
   909 00001B56 30FF                    	xor	bh, bh
   910 00001B58 88C3                    	mov	bl, al
   911 00001B5A C0EB04                  	shr	bl, 4
   912 00001B5D 8A9F[F01B]              	mov	bl, [bx+hex_chars] 	 	
   913 00001B61 86C3                    	xchg	bl, al
   914 00001B63 80E30F                  	and	bl, 0Fh
   915 00001B66 8AA7[F01B]              	mov	ah, [bx+hex_chars] 
   916 00001B6A 5B                      	pop	bx	
   917 00001B6B C3                      	retn
   918                                  
   919                                  wordtohex:
   920                                  	; INPUT ->
   921                                  	; 	AX = word (binary number)
   922                                  	; OUTPUT ->
   923                                  	;	EAX = hexadecimal string
   924                                  	;
   925 00001B6C 53                      	push	bx
   926 00001B6D 30FF                    	xor	bh, bh
   927 00001B6F 86C4                    	xchg	ah, al
   928 00001B71 50                      	push	ax
   929 00001B72 88E3                    	mov	bl, ah
   930 00001B74 C0EB04                  	shr	bl, 4
   931 00001B77 8A87[F01B]              	mov	al, [bx+hex_chars] 	 	
   932 00001B7B 88E3                    	mov	bl, ah
   933 00001B7D 80E30F                  	and	bl, 0Fh
   934 00001B80 8AA7[F01B]              	mov	ah, [bx+hex_chars]
   935 00001B84 66C1E010                	shl	eax, 16
   936 00001B88 58                      	pop	ax
   937 00001B89 5B                      	pop	bx
   938 00001B8A EBC9                    	jmp	short bytetohex
   939                                  
   940                                  ; 06/11/2023
   941                                  ;dwordtohex:
   942                                  ;	; INPUT ->
   943                                  ;	; 	EAX = dword (binary number)
   944                                  ;	; OUTPUT ->
   945                                  ;	;	EDX:EAX = hexadecimal string
   946                                  ;	;
   947                                  ;	push	eax
   948                                  ;	shr	eax, 16
   949                                  ;	call	wordtohex
   950                                  ;	mov	edx, eax
   951                                  ;	pop	eax
   952                                  ;	call	wordtohex
   953                                  ;	retn
   954                                  
   955                                  _DATA:
   956                                  
   957                                  ; 24/11/2016
   958                                  ;	IRQ  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15 
   959 00001B8C 08090A0B0C0D0E0F70-     irq_int	 db 08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh,70h,71h,72h,73h,74h,75h,76h,77h
   959 00001B95 71727374757677     
   960                                  
   961                                  ; 17/02/2017
   962                                  ; Valid ICH device IDs
   963                                  
   964                                  valid_ids:
   965 00001B9C 86801524                dd	(ICH_DID << 16) + INTEL_VID  	 ; 8086h:2415h 
   966 00001BA0 86802524                dd	(ICH0_DID << 16) + INTEL_VID 	 ; 8086h:2425h 
   967 00001BA4 86804524                dd	(ICH2_DID << 16) + INTEL_VID 	 ; 8086h:2445h 
   968 00001BA8 86808524                dd	(ICH3_DID << 16) + INTEL_VID 	 ; 8086h:2485h 
   969 00001BAC 8680C524                dd	(ICH4_DID << 16) + INTEL_VID 	 ; 8086h:24C5h
   970 00001BB0 8680D524                dd	(ICH5_DID << 16) + INTEL_VID 	 ; 8086h:24D5h
   971 00001BB4 86806E26                dd	(ICH6_DID << 16) + INTEL_VID 	 ; 8086h:266Eh
   972 00001BB8 8680A625                dd	(ESB6300_DID << 16) + INTEL_VID  ; 8086h:25A6h
   973 00001BBC 86809826                dd	(ESB631X_DID << 16) + INTEL_VID  ; 8086h:2698h
   974 00001BC0 8680DE27                dd	(ICH7_DID << 16) + INTEL_VID 	 ; 8086h:27DEh
   975                                  ; 03/11/2023 - Erdogan Tan
   976 00001BC4 86809571                dd	(MX82440_DID << 16) + INTEL_VID  ; 8086h:7195h
   977 00001BC8 39101270                dd	(SI7012_DID << 16)  + SIS_VID	 ; 1039h:7012h
   978 00001BCC DE10B101                dd 	(NFORCE_DID << 16)  + NVIDIA_VID ; 10DEh:01B1h
   979 00001BD0 DE106A00                dd 	(NFORCE2_DID << 16) + NVIDIA_VID ; 10DEh:006Ah
   980 00001BD4 22106D74                dd 	(AMD8111_DID << 16) + AMD_VID 	 ; 1022h:746Dh
   981 00001BD8 22104574                dd 	(AMD768_DID << 16)  + AMD_VID 	 ; 1022h:7445h
   982 00001BDC DE105900                dd 	(CK804_DID << 16) + NVIDIA_VID	 ; 10DEh:0059h
   983 00001BE0 DE103A00                dd 	(MCP04_DID << 16) + NVIDIA_VID	 ; 10DEh:003Ah
   984 00001BE4 DE108A00                dd 	(CK8_DID << 16) + NVIDIA_VID	 ; 1022h:008Ah
   985 00001BE8 DE10DA00                dd 	(NFORCE3_DID << 16) + NVIDIA_VID ; 10DEh:00DAh
   986 00001BEC DE10EA00                dd 	(CK8S_DID << 16) + NVIDIA_VID	 ; 10DEh:00EAh
   987                                  
   988                                  valid_id_count:	equ ($ - valid_ids)>>2 ; 05/11/2023
   989                                  
   990                                  ; 13/11/2016
   991 00001BF0 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
   991 00001BF9 3941424344454600   
   992 00001C01 414339372041756469-     msgAC97Info	db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
   992 00001C0A 6F20436F6E74726F6C-
   992 00001C13 6C6572202620436F64-
   992 00001C1C 656320496E666F0D0A 
   993 00001C25 56656E646F72204944-     		db "Vendor ID: "
   993 00001C2E 3A20               
   994 00001C30 303030306820446576-     msgVendorId	db "0000h Device ID: "
   994 00001C39 6963652049443A20   
   995 00001C41 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
   996 00001C48 4275733A20              		db "Bus: "
   997 00001C4D 303068204465766963-     msgBusNo	db "00h Device: "
   997 00001C56 653A20             
   998 00001C59 3030682046756E6374-     msgDevNo	db "00h Function: "
   998 00001C62 696F6E3A20         
   999 00001C67 303068                  msgFncNo	db "00h"
  1000 00001C6A 0D0A                    		db 0Dh, 0Ah
  1001                                  ; 05/11/2023	
  1002 00001C6C 4E414D4241523A20        		db "NAMBAR: "
  1003 00001C74 303030306820            msgNamBar	db "0000h "
  1004 00001C7A 4E41424D4241523A20      		db "NABMBAR: "
  1005 00001C83 303030306820495251-     msgNabmBar	db "0000h IRQ: "
  1005 00001C8C 3A20               
  1006 00001C8E 3030                    msgIRQ		dw 3030h
  1007 00001C90 0D0A24                  		db 0Dh, 0Ah, "$"
  1008 00001C93 53616D706C65205261-     msgSampleRate	db "Sample Rate: "
  1008 00001C9C 74653A20           
  1009 00001CA0 303030303020487A20-     msgHertz	db "00000 Hz ", "$" 
  1009 00001CA9 24                 
  1010 00001CAA 3820626974732024        msg8Bits	db "8 bits ", "$" 
  1011 00001CB2 4D6F6E6F0D0A24          msgMono		db "Mono", 0Dh, 0Ah, "$"
  1012 00001CB9 313620626974732024      msg16Bits	db "16 bits ", "$" 
  1013 00001CC2 53746572656F0D0A24      msgStereo	db "Stereo", 0Dh, 0Ah, "$"
  1014                                  
  1015                                  ;; 13/11/2016 - Erdogan Tan (Ref: KolibriOS, codec.inc)
  1016                                  ;codec_id	dd 0
  1017                                  ;codec_chip_id	dd 0
  1018                                  ;codec_vendor_ids dw 0
  1019                                  ;codec_chip_ids	dw 0
  1020                                  
  1021 00001CCB 3030303030303030        dword_str	 dd 30303030h, 30303030h
  1022 00001CD3 680D0A00                		 db 'h', 0Dh, 0Ah, 0
  1023                                  
  1024                                  ;ac_unknown     db 'unknown manufacturer',13,10,0
  1025                                  ;ac_Realtek     db 'Realtek Semiconductor',13,10,0
  1026                                  ;ac_Analog      db 'Analog Devices',13,10,0
  1027                                  ;ac_CMedia      db 'C-Media Electronics',13,10,0
  1028                                  ;ac_Cirrus      db 'Cirrus Logic',13,10,0
  1029                                  ;ac_Wolfson     db 'Wolfson Microelectronics',13,10,0
  1030                                  ;ac_VIA         db 'VIA Technologies',13,10,0
  1031                                  ;ac_SigmaTel    db 'SigmaTel',13,10,0
  1032                                  ;ac_eMicro      db 'eMicro',13,10,0
  1033                                  ;
  1034                                  ;chip_unknown   db 'unknown codec id ', 0
  1035                                  
  1036                                  ;CHIP_REALTEK   equ 414C4700h
  1037                                  ;CHIP_CMEDIA    equ 434D4900h
  1038                                  ;CHIP_VIA       equ 56494100h
  1039                                  
  1040                                  ;codecs        dd CHIP_CMEDIA
  1041                                  ;	       dw ac_CMedia, chips_CMedia
  1042                                  ;              dd CHIP_REALTEK
  1043                                  ;	       dw ac_Realtek, chips_Realtek
  1044                                  ;              dd CHIP_VIA
  1045                                  ;	       dw ac_VIA, chips_VIA
  1046                                  ;              dd 0
  1047                                  
  1048                                  ;chips_Realtek dw 10h, chip_ALC201a
  1049                                  ;              dw 20h, chip_ALC650
  1050                                  ;              dw 21h, chip_ALC650D
  1051                                  ;              dw 22h, chip_ALC650E
  1052                                  ;              dw 23h, chip_ALC650F
  1053                                  ;              dw 60h, chip_ALC655
  1054                                  ;              dw 80h, chip_ALC658
  1055                                  ;              dw 81h, chip_ALC658D
  1056                                  ;              dw 90h, chip_ALC850
  1057                                  ;              dw 0FFh
  1058                                  
  1059                                  ;chips_CMedia  dw 41h, chip_CM9738
  1060                                  ;              dw 61h, chip_CM9739
  1061                                  ;              dw 69h, chip_CM9780
  1062                                  ;              dw 78h, chip_CM9761
  1063                                  ;              dw 82h, chip_CM9761
  1064                                  ;              dw 83h, chip_CM9761
  1065                                  ;              dw 0FFh
  1066                                  
  1067                                  ;chips_VIA     dw 61h, chip_VIA1612A
  1068                                  ;              dw 0FFh
  1069                                  
  1070                                  ;Realtek
  1071                                  ;chip_ALC201a    db 'ALC201a',0dh,0ah,00h
  1072                                  ;chip_ALC650     db 'ALC650 ',0dh,0ah,00h
  1073                                  ;chip_ALC650D    db 'ALC650D',0dh,0ah,00h
  1074                                  ;chip_ALC650E    db 'ALC650E',0dh,0ah,00h
  1075                                  ;chip_ALC650F    db 'ALC650F',0dh,0ah,00h
  1076                                  ;chip_ALC655     db 'ALC655 ',0dh,0ah,00h
  1077                                  ;chip_ALC658     db 'ALC658 ',0dh,0ah,00h
  1078                                  ;chip_ALC658D    db 'ALC658D',0dh,0ah,00h
  1079                                  ;chip_ALC850     db 'ALC850 ',0dh,0ah,00h
  1080                                  
  1081                                  ;CMedia
  1082                                  ;chip_CM9738     db 'CMI9738', 0dh,0ah,0
  1083                                  ;chip_CM9739     db 'CMI9739', 0dh,0ah,0
  1084                                  ;chip_CM9780     db 'CMI9780', 0dh,0ah,0
  1085                                  ;chip_CM9761     db 'CMI9761', 0dh,0ah,0
  1086                                  
  1087                                  ;VIA
  1088                                  ;chip_VIA1612A   db 'VIA1612A',13,10,0
  1089                                  
  1090                                  ; 11/11/2023
  1091                                  msg_init_err:
  1092 00001CD7 0D0A                    	db	CR, LF
  1093 00001CD9 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  1093 00001CE2 726F6C6C65722F436F-
  1093 00001CEB 64656320696E697469-
  1093 00001CF4 616C697A6174696F6E-
  1093 00001CFD 206572726F722021   
  1094 00001D05 0D0A24                  	db	CR, LF, "$"
  1095                                  
  1096                                  ; 12/11/2023
  1097                                  msg_no_vra:
  1098 00001D08 0D0A                    	db	CR, LF
  1099 00001D0A 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  1099 00001D13 70706F72742021204F-
  1099 00001D1C 6E6C79203438206B48-
  1099 00001D25 5A2073616D706C6520-
  1099 00001D2E 726174652073757070-
  1099 00001D37 6F727465642021     
  1100 00001D3E 0D0A24                  	db	CR, LF, "$"
  1101                                  
  1102                                  ; 17/02/2017
  1103                                  bss_start:
  1104                                  
  1105                                  ABSOLUTE bss_start
  1106                                  
  1107 00001D41 ??                      alignb 2
  1108                                  
  1109                                  ; 28/11/2016
  1110                                  
  1111 00001D42 <res 1Ch>               smpRBuff:	resw 14 ; 19/11/2016 - Erdogan Tan
  1112                                  
  1113 00001D5E ????                    filehandle:	resw 1
  1114                                  
  1115 00001D60 ??                      flags:		resb 1
  1116                                  ; 06/11/2023
  1117 00001D61 ??                      ac97_int_ln_reg: resb 1
  1118                                  
  1119                                  ; 06/11/2023
  1120                                  ;pcm_irq_status: resb 1	; 05/11/2023
  1121                                  ;
  1122                                  ;inside:	resb 1
  1123                                  ;tLoop:		resb 1
  1124                                  
  1125                                  ; 06/11/2023
  1126                                  ; 05/11/2023
  1127                                  ; 04/11/2023
  1128                                  ;IRQ_status:	resw 1	; IRQ status before enabling audio interrupt
  1129                                  ;IRQ_vector:	resd 1  ; Previous interrupt handler address	
  1130                                  
  1131                                  ; 17/02/2017
  1132                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  1133                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  1134                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  1135                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  1136 00001D62 ????                    NAMBAR:		resw 1			; BAR for mixer
  1137 00001D64 ????                    NABMBAR:	resw 1			; BAR for bus master regs
  1138                                  
  1139                                  ; 256 byte buffer for descriptor list
  1140 00001D66 ????                    BDL_BUFFER:	resw 1			; segment of our 256byte BDL buffer
  1141 00001D68 ????                    WAV_BUFFER1:	resw 1			; segment of our WAV storage
  1142                                  ; 64k buffers for wav file storage
  1143 00001D6A ????                    WAV_BUFFER2:	resw 1			; segment of 2nd wav buffer
  1144                                  
  1145                                  ; 06/11/2023
  1146                                  ;tBuff:		resb 1
  1147                                  ;ac97_int_ln_reg: resb 1
  1148                                  
  1149                                  ; 12/11/2016 - Erdogan Tan
  1150                                  
  1151 00001D6C ????????                bus_dev_fn:	resd 1
  1152 00001D70 ????????                dev_vendor:	resd 1
  1153                                  ; 06/11/2023
  1154                                  ;stats_cmd:	resw 1 ; 17/02/2017
  1155                                  ; 05/11/2023
  1156                                  ;ac97_io_base:	resw 1
  1157 00001D74 ????                    sample_rate:	resw 1
  1158                                  
  1159                                  ; 19/11/2016
  1160 00001D76 ????                    stmo:		resw 1 
  1161 00001D78 ????                    bps:		resw 1
  1162                                  
  1163                                  ; 08/11/2023
  1164                                  ; 07/11/2023
  1165 00001D7A ??                      fbs_shift:	resb 1
  1166 00001D7B ??                      		resb 1 ; 08/11/2023
  1167                                  
  1168                                  ;fbs_seg:	resw 1
  1169                                  ;fbs_off:	resw 1
  1170                                  
  1171                                  ;alignb 2
  1172                                  
  1173                                  ; 32 kilo bytes for temporay buffer
  1174                                  ; (for stereo-mono, 8bit/16bit corrections)
  1175                                  ;temp_buffer:	resb 32768
  1176                                  ; 18/11/2023
  1177 00001D7C <res DBF0h>             temp_buffer:	resb 56304  ; (44.1 kHZ stereo 14076 samples)	
  1178                                  
  1179                                  ;alignb 16
  1180                                  EOF:
