     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                                  ; AC97 interrupt version - 09/11/2023 - Erdogan Tan
    17                                  ; sample rate conversion version - 13/11/2023 - Erdogan Tan
    18                                  ; LVI interrupt version (instead of IOC) - 18/11/2023 - Erdogan Tan
    19                                  
    20                                  [BITS 16]
    21                                  
    22                                  [ORG 100h] 
    23                                  
    24                                  	%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
    25                                  
    26                                  _STARTUP:
    27                                  
    28                                  ; memory allocation
    29                                  
    30 00000000 E85401                          call    setFree				; deallocate unused DOS mem
    31                                  
    32                                  	; 17/02/2017
    33                                  	; Clear BSS (uninitialized data) area
    34 00000003 31C0                    	xor	ax, ax ; 0
    35 00000005 B91A6E                  	mov	cx, (EOF - bss_start)/2
    36 00000008 BF[6F1F]                	mov	di, bss_start
    37 0000000B F3AB                    	rep	stosw
    38                                  
    39                                  ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
    40                                  
    41 0000000D B81000                          mov     ax, BDL_SIZE / 16
    42 00000010 E84C01                          call    memAlloc
    43 00000013 A3[9C1F]                        mov     [BDL_BUFFER], ax		; segment
    44                                  
    45                                  ; allocate 2 buffers, 64k each for now.
    46                                  
    47 00000016 B80010                          mov     ax, BUFFERSIZE / 16		; 64k for .WAV file
    48 00000019 E84301                          call    memAlloc
    49 0000001C A3[9E1F]                        mov     [WAV_BUFFER1], ax		; segment
    50                                  
    51 0000001F B80010                  	mov	ax, BUFFERSIZE / 16
    52 00000022 E83A01                  	call	memAlloc
    53 00000025 A3[A01F]                	mov	[WAV_BUFFER2], ax
    54                                  
    55                                  ; Detect/reset AC97 
    56                                  
    57 00000028 E8A702                          call    pciFindDevice
    58 0000002B 7342                            jnc     short _1
    59                                  
    60                                  ; couldn't find the audio device!
    61                                  
    62 0000002D 0E                      	push	cs
    63 0000002E 1F                      	pop	ds
    64 0000002F BA[3900]                        mov     dx, noDevMsg
    65 00000032 B409                            mov     ah, 9
    66 00000034 CD21                            int     21h
    67 00000036 E90E01                          jmp     exit
    68                                  
    69                                  ; 17/02/2017
    70 00000039 4572726F723A20556E-     noDevMsg: db "Error: Unable to find intel ICH based audio device!",CR,LF,"$"
    70 00000042 61626C6520746F2066-
    70 0000004B 696E6420696E74656C-
    70 00000054 204943482062617365-
    70 0000005D 6420617564696F2064-
    70 00000066 6576696365210D0A24 
    71                                  
    72                                  _1:
    73                                  	; eax = BUS/DEV/FN
    74                                  	;	00000000BBBBBBBBDDDDDFFF00000000
    75                                  	; edx = DEV/VENDOR
    76                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
    77                                  
    78 0000006F 66A3[A21F]              	mov	[bus_dev_fn], eax
    79 00000073 668916[A61F]            	mov	[dev_vendor], edx
    80                                  
    81                                  	; get ICH base address regs for mixer and bus master
    82                                  
    83 00000078 B010                            mov     al, NAMBAR_REG
    84 0000007A E8C701                          call    pciRegRead16			; read PCI registers 10-11
    85                                          ;and    dx, IO_ADDR_MASK 		; mask off BIT0
    86                                  	; 19/05/2024
    87 0000007D 80E2FE                  	and	dl, 0FEh
    88                                  
    89 00000080 8916[981F]                      mov     [NAMBAR], dx			; save audio mixer base addr
    90                                  
    91 00000084 B014                    	mov     al, NABMBAR_REG
    92 00000086 E8BB01                          call    pciRegRead16
    93                                          ;and    dx, IO_ADDR_MASK
    94                                  	; 19/05/2024
    95 00000089 80E2C0                  	and	dl, 0C0h
    96                                  
    97 0000008C 8916[9A1F]                      mov     [NABMBAR], dx			; save bus master base addr
    98                                  
    99                                  	; 06/11/2023
   100                                  	;; init controller
   101                                  	;; 17/02/2017
   102                                  	;mov	al, PCI_CMD_REG ; command register (04h)
   103                                  	;call	pciRegRead16 ; pciRegRead8
   104                                  	;
   105                                  	;; eax = BUS/DEV/FN/REG
   106                                  	;;  dx = PCI Command Register Content ; 17/02/2017
   107                                  	;; 	00000000CCCCCCCC
   108                                  	;mov	[stats_cmd], dx
   109                                  	;
   110                                  	; 06/11/2023
   111                                  	;mov	al, PCI_IO_BASE ; IO base address register (10h)
   112                                  	;call	pciRegRead32
   113                                  	;
   114                                  	;and	dx, 0FFC0h	; IO_ADDR_MASK (0FFFE) ?
   115                                          ;mov	[ac97_io_base], dx
   116                                  
   117 00000090 B03C                    	mov	al, AC97_INT_LINE ; Interrupt line register (3Ch)
   118 00000092 E8A701                  	call	pciRegRead8 ; 17/02/2017
   119                                  
   120 00000095 8816[8F1F]              	mov     [ac97_int_ln_reg], dl
   121                                  
   122                                  ; 09/11/2023
   123                                  ; 05/11/2023
   124                                  %if 1
   125                                  	; 28/11/2016
   126                                  	;mov	bx, 1	; 08/05/2024
   127 00000099 30F6                    	xor	dh, dh	; 17/02/2017
   128                                  	; 10/11/2023
   129                                  	;mov	cx, dx
   130                                  	;shl	bx, cl
   131                                  
   132                                  	; 04/11/2023
   133 0000009B FA                      	cli
   134                                  
   135                                  	;not	bx
   136 0000009C E4A1                    	in	al, 0A1h ; irq 8-15
   137 0000009E 88C4                            mov	ah, al
   138 000000A0 E421                            in	al, 21h  ; irq 0-7
   139                                  
   140                                  	; 04/11/2023
   141                                  	; save IRQ status
   142 000000A2 A3[921F]                	mov	[IRQ_status], ax
   143                                  
   144                                  	; 12/05/2024 (enable AC97 IRQ)
   145                                  	;mov	cl, dl
   146                                  	;mov	bx, 1
   147                                  	;shl	bx, cl
   148                                  	;not	bx
   149                                  	;and	ax, bx
   150                                  	;out	21h, al
   151                                  	;mov	al, ah
   152                                  	;out	0A1h, al
   153                                  
   154                                  	;and	ax, bx   ; unmask
   155 000000A5 0FB3D0                   	btr	ax, dx	 ; unmask
   156 000000A8 E621                    	out	21h, al  ; enable interrupt (if irq <= 7)
   157 000000AA 88E0                    	mov	al, ah
   158 000000AC E6A1                    	out	0A1h, al ; enable interrupt (if irq > 7)
   159                                  	;not	bx
   160                                  
   161                                  	; 04/11/2023
   162                                  	;mov	dx, 4D1h			;8259 ELCR1
   163                                          ;in	al, dx
   164                                  	;mov	ah, al
   165                                  	;mov	dx, 4D0h
   166                                          ;in	al, dx
   167                                  	;;or	ax, bx
   168                                  	;bts	ax, cx
   169                                  	;mov	dx, 4D0h
   170                                  	;out	dx, al                          ;set level-triggered mode
   171                                  	;mov	al, ah
   172                                  	;mov	dx, 4D1h
   173                                  	;out	dx, al                          ;set level-triggered mode
   174                                  
   175                                  	; 24/11/2016 - Erdogan Tan
   176                                  	;mov	bx, cx
   177                                  	; 10/11/2023
   178 000000AE 89D3                    	mov	bx, dx
   179 000000B0 8A9F[6F1D]              	mov	bl, [bx+irq_int]
   180 000000B4 C1E302                  	shl	bx, 2 ; * 4
   181                                  
   182                                  	; set up interrupt vector
   183                                  	; 30/11/2016
   184 000000B7 06                      	push	es
   185 000000B8 31C0                    	xor	ax, ax
   186 000000BA 8EC0                    	mov	es, ax
   187                                  	; 04/11/2023
   188                                  	; save interrupt vector
   189                                  	;mov	ax, [es:bx]
   190                                  	; 13/05/2024
   191 000000BC B8[DE1C]                	mov	ax, ac97_int_handler
   192 000000BF 268707                  	xchg	ax, [es:bx]
   193 000000C2 A3[941F]                	mov	[IRQ_vector], ax
   194                                  	;mov	ax, [es:bx+2]
   195                                  	; 13/05/2024
   196 000000C5 8CC8                    	mov	ax, cs
   197 000000C7 26874702                	xchg	ax, [es:bx+2]
   198 000000CB A3[961F]                	mov	[IRQ_vector+2], ax
   199                                  
   200                                  	; 13/05/2024
   201                                  	;mov	word [es:bx], ac97_int_handler
   202                                  	;mov	ax, cs
   203                                  	;mov	[es:bx+2], ax
   204                                  
   205 000000CE 07                      	pop	es
   206                                  
   207                                  	; 04/11/2023
   208 000000CF FB                      	sti
   209                                  
   210                                  %endif
   211 000000D0 E8641A                  	call	write_ac97_dev_info
   212                                  
   213                                  ; check the command line for a file to play
   214                                  
   215                                          ;push	ds
   216 000000D3 E89200                          call    processCmdline			; get the filename
   217                                  
   218                                  ; open the file
   219 000000D6 B002                            mov     al, OPEN                        ; open existing file
   220 000000D8 E8AD00                          call    openFile                        ; no error? ok.
   221                                          ;pop	ds
   222 000000DB 7322                            jnc     short _gsr
   223                                  
   224                                  ; file not found!
   225                                  
   226                                          ;push   cs
   227                                          ;pop    ds
   228 000000DD BA[E600]                        mov	dx, noFileErrMsg
   229 000000E0 B409                            mov     ah, 9
   230 000000E2 CD21                            int     21h
   231 000000E4 EB61                            jmp     exit
   232                                  
   233                                  noFileErrMsg:
   234 000000E6 4572726F723A206669-     	db "Error: file not found.",CR,LF,"$"
   234 000000EF 6C65206E6F7420666F-
   234 000000F8 756E642E0D0A24     
   235                                  
   236                                  _gsr:
   237 000000FF E8AD00                          call    getSampleRate                   ; read the sample rate
   238                                                                                  ; pass it onto codec.
   239 00000102 7243                    	jc	short exit ; 19/11/2016 - nothing to do
   240                                  
   241 00000104 A3[AA1F]                	mov	[sample_rate], ax
   242                                  	
   243                                  	; 19/11/2016
   244 00000107 880E[AC1F]              	mov	[stmo], cl
   245 0000010B 8816[AE1F]              	mov	[bps], dl
   246                                  	
   247                                  	; 17/02/2017
   248 0000010F C606[B01F]00            	mov	byte [fbs_shift], 0 ; 0 = stereo and 16 bit 
   249 00000114 FEC9                    	dec	cl
   250 00000116 7504                    	jnz	short _gsr_1 ; stereo
   251 00000118 FE06[B01F]              	inc	byte [fbs_shift] ; 1 = mono or 8 bit
   252                                  _gsr_1:	
   253 0000011C 80FA08                  	cmp	dl, 8 
   254 0000011F 7704                    	ja	short _gsr_2 ; 16 bit samples
   255 00000121 FE06[B01F]              	inc	byte [fbs_shift] ; 2 = mono and 8 bit
   256                                  _gsr_2:	
   257 00000125 E8651B                  	call	write_sample_rate
   258                                  
   259                                  	; 05/11/2023
   260                                  _2:
   261 00000128 E88F07                  	call	check4keyboardstop  ; flush keyboard buffer
   262 0000012B 72FB                    	jc	short _2 	; 07/11/2023
   263                                  
   264                                  	; 09/11/2023
   265                                  	;; 05/11/2023
   266                                  	;mov	eax, [bus_dev_fn]
   267                                  	;mov	al, PCI_CMD_REG
   268                                  	;call	pciRegRead16			; read PCI command register
   269                                  	;; 17/02/2017
   270                                  	;;mov	dx, [stats_cmd]
   271                                          ;or	dl, IO_ENA+BM_ENA               ; enable IO and bus master
   272                                  	;call	pciRegWrite16 ; pciRegWrite8
   273                                  
   274                                  	;; 06/11/2023
   275                                  	;;mov	eax, [bus_dev_fn]
   276                                  	;;mov	al, PCI_CMD_REG
   277                                  	;;call	pciRegRead8                     ; read PCI command register
   278                                  	;;or	dl, IO_ENA+BM_ENA               ; enable IO and bus master
   279                                  	;;call	pciRegWrite8
   280                                  
   281                                  ; setup the Codec (actually mixer registers)
   282 0000012D E8E401                          call    codecConfig                     ; unmute codec, set rates.
   283                                  	; 11/11/2023
   284 00000130 721C                    	jc	short init_err
   285                                  ;
   286                                  ; position file pointer to start in actual wav data
   287                                  ; MUCH improvement should really be done here to check if sample size is
   288                                  ; supported, make sure there are 2 channels, etc.  
   289                                  ;
   290 00000132 B442                            mov     ah, 42h
   291 00000134 B000                            mov     al, 0                           ; from start of file
   292 00000136 8B1E[8C1F]                      mov     bx, [filehandle]
   293 0000013A 31C9                            xor     cx, cx
   294 0000013C BA2C00                          mov     dx, 44                          ; jump past .wav/riff header
   295 0000013F CD21                            int     21h
   296                                  
   297                                  ; play the .wav file. Most of the good stuff is in here.
   298                                  
   299 00000141 E88503                          call    playWav
   300                                  
   301                                  ; close the .wav file and exit.
   302                                  
   303                                  close_exit:			; 11/11/2023
   304 00000144 E85300                          call    closeFile
   305                                  
   306                                  exit:
   307 00000147 B8004C                          mov     ax, 4c00h
   308 0000014A CD21                    	int 	21h
   309                                  
   310                                  here:
   311 0000014C EBFE                    	jmp	short here
   312                                  
   313                                  	; 11/11/2023
   314                                  init_err:
   315 0000014E BA[BA1E]                	mov	dx, msg_init_err
   316                                  vra_err: ; 12/11/2023
   317 00000151 B409                            mov	ah, 9
   318 00000153 CD21                            int	21h
   319 00000155 EBED                    	jmp	short close_exit
   320                                  
   321                                  ; MEMALLOC.ASM
   322                                  ;-- SETFREE: Release memory not used  ----------------
   323                                  ;-- Input    : ES = address of PSP
   324                                  ;-- Output   : none
   325                                  ;-- Register : AX, BX, CL and FLAGS are changed 
   326                                  ;-- Info     : Since the stack-segment is always the last segment in an 
   327                                  ;              EXE-file, ES:0000 points to the beginning and SS:SP
   328                                  ;              to the end of the program in memory. Through this the
   329                                  ;              length of the program can be calculated 
   330                                  ; call this routine once at the beginning of the program to free up memory
   331                                  ; assigned to it by DOS.
   332                                  
   333                                  setFree:
   334 00000157 BB0010                  	  mov	bx, 65536/16	; 4K paragraphs ; 17/02/2017 (Erdogan Tan)
   335                                  
   336 0000015A B44A                              mov	ah, 4ah		; pass new length to DOS
   337 0000015C CD21                              int	21h
   338                                  
   339 0000015E C3                                retn			; back to caller 
   340                                  				; new size (allocated memory) = 64KB
   341                                  
   342                                  memAlloc:
   343                                  ; input: AX = # of paragraphs required
   344                                  ; output: AX = segment of block to use
   345                                  
   346 0000015F 53                      	push	bx
   347 00000160 89C3                    	mov	bx, ax
   348 00000162 B448                    	mov	ah, 48h
   349 00000164 CD21                    	int	21h
   350 00000166 5B                      	pop	bx
   351 00000167 C3                      	retn
   352                                  
   353                                  ; CMDLINE.ASM
   354                                  ; parse the command line
   355                                  ; entry: none
   356                                  ; exit: DS:DX to the 1st supplied item on the command line 
   357                                  
   358                                  processCmdline:
   359 00000168 53                              push    bx
   360 00000169 56                              push    si
   361                                  
   362                                          ;mov    ah, 51h
   363                                          ;int    21h
   364                                          ;mov    ds, bx
   365                                  
   366 0000016A BE8000                          mov     si, 80h
   367 0000016D 0FB61C                          movzx   bx, byte [si]
   368 00000170 01DE                            add     si, bx
   369 00000172 46                              inc     si
   370                                  
   371 00000173 C60400                          mov     byte [si], NULL         ; zero terminate
   372                                  
   373 00000176 BE8100                          mov     si, 81h
   374                                  
   375                                  cmdlineloop:
   376 00000179 AC                              lodsb
   377                                  
   378 0000017A 3C00                            cmp     al, NULL                ; found end of line?
   379 0000017C 7404                            je      short exitpc
   380 0000017E 3C20                            cmp     al, ' '                 ; found a space?
   381 00000180 74F7                            je      short cmdlineloop
   382                                  
   383                                          ; must be the filename here.
   384                                  exitpc:
   385 00000182 4E                              dec     si                      ; point to start of filename
   386 00000183 89F2                            mov     dx, si
   387 00000185 5E                              pop     si
   388 00000186 5B                              pop     bx
   389 00000187 C3                      	retn
   390                                  
   391                                  ; FILE.ASM
   392                                  ;open or create file
   393                                  ;
   394                                  ;input: ds:dx-->filename (asciiz)
   395                                  ;       al=file Mode (create or open)
   396                                  ;output: none  cs:[filehandle] filled
   397                                  ;
   398                                  openFile:
   399 00000188 50                      	push	ax
   400 00000189 51                      	push	cx
   401 0000018A B43B                    	mov	ah, 3bh			; start with a mode
   402 0000018C 00C4                    	add	ah, al			; add in create or open mode
   403 0000018E 31C9                    	xor	cx, cx
   404 00000190 CD21                    	int	21h
   405 00000192 7203                    	jc	short _of1
   406                                  	;mov	[cs:filehandle], ax
   407 00000194 A3[8C1F]                	mov	[filehandle], ax
   408                                  _of1:
   409 00000197 59                      	pop	cx
   410 00000198 58                      	pop	ax
   411 00000199 C3                      	retn
   412                                  
   413                                  ; close the currently open file
   414                                  ; input: none, uses cs:[filehandle]
   415                                  closeFile:
   416 0000019A 50                      	push	ax
   417 0000019B 53                      	push	bx
   418 0000019C 833E[8C1F]FF            	cmp	word [filehandle], -1
   419 000001A1 7409                    	jz	short _cf1
   420 000001A3 8B1E[8C1F]              	mov     bx, [filehandle]
   421 000001A7 B8003E                  	mov     ax,3e00h
   422 000001AA CD21                            int     21h              ;close file
   423                                  _cf1:
   424 000001AC 5B                      	pop	bx
   425 000001AD 58                      	pop	ax
   426 000001AE C3                      	retn
   427                                  
   428                                  getSampleRate:
   429                                  	; 08/12/2016
   430                                  ; reads the sample rate from the .wav file.
   431                                  ; entry: none - assumes file is already open
   432                                  	; 19/11/2016 - Erdogan Tan
   433                                  ; exit: ax = sample rate (11025, 22050, 44100, 48000)
   434                                  ;	cx = number of channels (mono=1, stereo=2)
   435                                  ;	dx = bits per sample (8, 16)
   436                                  
   437 000001AF 53                      	push    bx
   438                                  
   439 000001B0 B442                            mov     ah, 42h
   440 000001B2 B000                            mov     al, 0				; from start of file
   441 000001B4 8B1E[8C1F]                      mov     bx, [filehandle]
   442 000001B8 31C9                            xor     cx, cx
   443 000001BA BA0800                          mov     dx, 08h				; "WAVE"
   444 000001BD CD21                            int     21h
   445                                  
   446 000001BF BA[701F]                        mov     dx, smpRBuff
   447 000001C2 B91C00                          mov     cx, 28				; 28 bytes
   448 000001C5 B43F                    	mov	ah, 3fh
   449 000001C7 CD21                            int     21h
   450                                  
   451 000001C9 813E[701F]5741          	cmp	word [smpRBuff], 'WA'
   452 000001CF 751C                    	jne	short gsr_stc
   453                                  
   454 000001D1 813E[721F]5645          	cmp	word [smpRBuff+2], 'VE'
   455 000001D7 7514                    	jne	short gsr_stc
   456                                  
   457 000001D9 833E[7C1F]01            	cmp	word [smpRBuff+12], 1	; Offset 20, must be 1 (= PCM)
   458 000001DE 750D                    	jne	short gsr_stc
   459                                  
   460                                  
   461 000001E0 8B0E[7E1F]              	mov	cx, [smpRBuff+14]	; return num of channels in CX
   462 000001E4 A1[801F]                        mov     ax, [smpRBuff+16]	; return sample rate in AX
   463 000001E7 8B16[8A1F]              	mov	dx, [smpRBuff+26]	; return bits per sample value in DX
   464                                  gsr_retn:
   465 000001EB 5B                              pop     bx
   466 000001EC C3                              retn
   467                                  
   468                                  gsr_stc:
   469 000001ED F9                      	stc
   470 000001EE EBFB                    	jmp	short gsr_retn
   471                                  
   472                                  ;%include 'ac97.asm' ; 29/11/2016 (AC97 codec configuration)
   473                                  %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 000001F0 6653                <1> 	push	ebx
    39 000001F2 51                  <1> 	push	cx
    40 000001F3 6689C3              <1>         mov     ebx, eax                        ; save eax, dh
    41 000001F6 88F1                <1>         mov     cl, dh
    42 000001F8 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
    43 000001FE 660D00000080        <1>         or      eax, BIT31                      ; make a PCI access request
    44 00000204 24FC                <1>         and     al, ~3 ; NOT 3                  ; force index to be dword
    45                              <1> 
    46 00000206 BAF80C              <1>         mov     dx, PCI_INDEX_PORT
    47 00000209 66EF                <1>         out     dx, eax                         ; write PCI selector
    48                              <1> 
    49 0000020B BAFC0C              <1>         mov     dx, PCI_DATA_PORT
    50 0000020E 88D8                <1>         mov     al, bl
    51 00000210 2403                <1>         and     al, 3                           ; figure out which port to
    52 00000212 00C2                <1>         add     dl, al                          ; read to
    53                              <1> 
    54 00000214 66ED                <1> 	in      eax, dx                         ; do 32bit read
    55 00000216 66F7C300000080      <1>         test    ebx, PCI32
    56 0000021D 7403                <1>         jz      short _pregr1
    57                              <1> 
    58 0000021F 6689C2              <1>         mov     edx, eax                        ; return 32bits of data
    59                              <1> _pregr1:
    60 00000222 89C2                <1> 	mov     dx, ax                          ; return 16bits of data
    61 00000224 66F7C3000000C0      <1>         test    ebx, PCI32+PCI16
    62 0000022B 7502                <1>         jnz     short _pregr2
    63 0000022D 88CE                <1>         mov     dh, cl                          ; restore dh for 8 bit read
    64                              <1> _pregr2:
    65 0000022F 6689D8              <1>         mov     eax, ebx                        ; restore eax
    66 00000232 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
    67 00000238 59                  <1> 	pop	cx
    68 00000239 665B                <1> 	pop	ebx
    69 0000023B C3                  <1> 	retn
    70                              <1> 
    71                              <1> pciRegRead8:
    72 0000023C 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32             ; set up 8 bit read size
    73 00000242 EBAC                <1>         jmp     short pciRegRead		; call generic PCI access
    74                              <1> 
    75                              <1> pciRegRead16:
    76 00000244 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 16 bit read size
    77 0000024A 660D00000040        <1>         or      eax, PCI16			; call generic PCI access
    78 00000250 EB9E                <1>         jmp     short pciRegRead
    79                              <1> 
    80                              <1> pciRegRead32:
    81 00000252 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 32 bit read size
    82 00000258 660D00000080        <1>         or      eax, PCI32			; call generic PCI access
    83 0000025E 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 00000260 6653                <1> 	push	ebx
   103 00000262 51                  <1> 	push	cx
   104 00000263 6689C3              <1>         mov     ebx, eax                        ; save eax, dx
   105 00000266 89D1                <1>         mov     cx, dx
   106 00000268 660D00000080        <1>         or      eax, BIT31                      ; make a PCI access request
   107 0000026E 6625FFFFFFBF        <1>         and     eax, ~PCI16 ; NOT PCI16         ; clear out data size request
   108 00000274 24FC                <1>         and     al, ~3 ; NOT 3                  ; force index to be dword
   109                              <1> 
   110 00000276 BAF80C              <1>         mov     dx, PCI_INDEX_PORT
   111 00000279 66EF                <1>         out     dx, eax                         ; write PCI selector
   112                              <1> 
   113 0000027B BAFC0C              <1>         mov     dx, PCI_DATA_PORT
   114 0000027E 88D8                <1>         mov     al, bl
   115 00000280 2403                <1>         and     al, 3                           ; figure out which port to
   116 00000282 00C2                <1>         add     dl, al                          ; write to
   117                              <1> 
   118 00000284 6689D0              <1>         mov     eax, edx                        ; put data into eax
   119 00000287 89C8                <1>         mov     ax, cx
   120                              <1> 
   121 00000289 EE                  <1>         out     dx, al
   122 0000028A 66F7C3000000C0      <1>         test    ebx, PCI16+PCI32                ; only 8bit access? bail
   123 00000291 740C                <1>         jz      short _pregw1
   124                              <1> 
   125 00000293 EF                  <1>         out     dx, ax                          ; write 16 bit value
   126 00000294 66F7C300000040      <1>         test    ebx, PCI16                      ; 16bit requested?  bail
   127 0000029B 7502                <1>         jnz     short _pregw1
   128                              <1> 
   129 0000029D 66EF                <1>         out     dx, eax                         ; write full 32bit
   130                              <1> _pregw1:
   131 0000029F 6689D8              <1>         mov     eax, ebx                        ; restore eax
   132 000002A2 6625FFFFFFBF        <1>         and     eax, (~PCI32)+PCI16             ; clear out data size request
   133 000002A8 89CA                <1>         mov     dx, cx                          ; restore dx
   134 000002AA 59                  <1> 	pop	cx
   135 000002AB 665B                <1> 	pop	ebx
   136 000002AD C3                  <1> 	ret
   137                              <1> 
   138                              <1> pciRegWrite8:
   139 000002AE 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 8 bit write size
   140 000002B4 EBAA                <1>         jmp     short pciRegWrite		; call generic PCI access
   141                              <1> 
   142                              <1> pciRegWrite16:
   143 000002B6 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 16 bit write size
   144 000002BC 660D00000040        <1>         or      eax, PCI16			; call generic PCI access
   145 000002C2 EB9C                <1>         jmp     short pciRegWrite
   146                              <1> 
   147                              <1> pciRegWrite32:
   148 000002C4 6625FFFFFF3F        <1>         and     eax, (~PCI16)+PCI32		; set up 32 bit write size
   149 000002CA 660D00000080        <1>         or      eax, PCI32			; call generic PCI access
   150 000002D0 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 000002D2 BE[7F1D]            <1> 	mov	si, valid_ids	; address of Valid ICH (AC97) Device IDs
   175 000002D5 B91500              <1> 	mov	cx, valid_id_count
   176                              <1> pfd_0:
   177 000002D8 66BF00FFFF7F        <1>        	mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
   178                              <1> nextPCIdevice:
   179 000002DE 6681C700010000      <1>         add     edi, 100h
   180 000002E5 6681FF00F8FF80      <1>         cmp     edi, 80FFF800h		; scanned all devices?
   181                              <1>         ;stc
   182                              <1>         ;je 	short PCIScanExit       ; not found
   183 000002EC 720D                <1> 	jb	short pfd_1
   184 000002EE 66BF00000080        <1> 	mov     edi, 80000000h
   185 000002F4 83C604              <1> 	add	si, 4 ; scan for next device ID
   186 000002F7 E202                <1> 	loop	pfd_1	 
   187 000002F9 F9                  <1> 	stc	
   188                              <1> 	;jmp 	short PCIScanExit
   189 000002FA C3                  <1> 	retn
   190                              <1> pfd_1:
   191 000002FB 6689F8              <1>         mov     eax, edi                ; read PCI registers
   192 000002FE E851FF              <1>         call    pciRegRead32
   193                              <1>         ;cmp    edx, esi                ; found device?
   194 00000301 663B14              <1>         cmp	edx, dword [si]
   195 00000304 75D8                <1> 	jne     short nextPCIdevice
   196                              <1>         ;clc
   197                              <1> PCIScanExit:
   198                              <1> 	;pushf
   199 00000306 66B800000080        <1> 	mov	eax, BIT31
   200 0000030C 66F7D0              <1> 	not	eax
   201 0000030F 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 00000312 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 00000313 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 00000314 66A1[A21F]          <1> 	mov	eax, [bus_dev_fn]
   257 00000318 B004                <1> 	mov	al, PCI_CMD_REG
   258 0000031A E827FF              <1> 	call	pciRegRead16		; read PCI command register
   259 0000031D 80CA05              <1> 	or      dl, IO_ENA+BM_ENA	; enable IO and bus master
   260 00000320 E893FF              <1> 	call	pciRegWrite16
   261                              <1> 
   262 00000323 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 00000326 BD2800              <1> 	mov	bp, 40
   270                              <1> _initc_1:
   271                              <1> 	; 11/11/2023
   272                              <1> 	; (TRDOS 386 v2.0.5, 'audio.s')
   273 00000329 BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   274 0000032C 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   275 00000330 66ED                <1> 	in	eax, dx
   276                              <1> 
   277                              <1> 	; 19/05/2024
   278 00000332 E8E217              <1> 	call	delay1_4ms
   279                              <1> 
   280                              <1> 	; ?
   281 00000335 BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   282 00000338 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   283 0000033C 66ED                <1> 	in	eax, dx
   284                              <1> 
   285                              <1> 	; 19/05/2024
   286 0000033E E8D617              <1> 	call	delay1_4ms
   287                              <1> 
   288 00000341 6683F8FF            <1> 	cmp	eax, 0FFFFFFFFh ; -1
   289 00000345 7508                <1> 	jne	short _initc_3
   290                              <1> _initc_2:
   291                              <1> 	;dec	cx
   292 00000347 4D                  <1> 	dec	bp	; 18/11/2023
   293                              <1> 	;jz	short init_ac97_codec_err1
   294                              <1> 	; 19/11/2023
   295 00000348 7412                <1> 	jz	short _ac97_codec_ready
   296                              <1> 
   297 0000034A E87101              <1> 	call	delay_100ms
   298 0000034D EBDA                <1> 	jmp	short _initc_1
   299                              <1> _initc_3:
   300 0000034F 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   301 00000355 7505                <1> 	jnz	short _ac97_codec_ready
   302                              <1> 
   303 00000357 E8E400              <1> 	call	reset_ac97_codec
   304                              <1> 	; 15/11/2023
   305                              <1> 	;jc	short _initc_2
   306                              <1> 	; 19/05/2024
   307 0000035A EBEB                <1> 	jmp	short _initc_2
   308                              <1> 
   309                              <1> _ac97_codec_ready:
   310 0000035C 8B16[981F]          <1> 	mov	dx, [NAMBAR]
   311                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
   312 00000360 EF                  <1> 	out	dx, ax
   313                              <1> 
   314 00000361 E85A01              <1> 	call	delay_100ms
   315                              <1> 
   316                              <1> 	; 19/11/2023
   317 00000364 09ED                <1> 	or	bp, bp
   318 00000366 751F                <1> 	jnz	short _ac97_codec_init_ok
   319                              <1> 
   320 00000368 6631C0              <1> 	xor	eax, eax ; 0
   321 0000036B 8B16[981F]          <1> 	mov	dx, [NAMBAR]
   322 0000036F 83C226              <1> 	add	dx, CODEC_REG_POWERDOWN
   323 00000372 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 00000373 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 00000376 E84501              <1> 	call	delay_100ms
   337                              <1> 
   338                              <1> 	;mov	dx, [NAMBAR]
   339                              <1> 	;add	dx, CODEC_REG_POWERDOWN
   340 00000379 ED                  <1> 	in	ax, dx
   341                              <1> 
   342 0000037A E89A17              <1> 	call	delay1_4ms
   343                              <1> 	
   344 0000037D 83E00F              <1> 	and	ax, 0Fh
   345 00000380 3C0F                <1> 	cmp	al, 0Fh
   346 00000382 7403                <1> 	je	short _ac97_codec_init_ok
   347 00000384 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 00000386 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 00000387 E86D00              <1> 	call 	reset_ac97_controller
   364                              <1> 
   365                              <1> 	; 11/11/2023
   366                              <1> 	;call	delay1_4ms
   367                              <1> 	; 19/05/2024
   368 0000038A 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 0000038D 813E[AA1F]80BB      <1> 	cmp	word [sample_rate], 48000
   375 00000393 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 00000395 E87F17              <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 00000398 8B16[981F]          <1> 	mov    	dx, [NAMBAR]
   399 0000039C 83C22A              <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah
   400 0000039F ED                  <1> 	in     	ax, dx
   401                              <1> 
   402                              <1> 	; 19/05/2024
   403 000003A0 E87417              <1> 	call	delay1_4ms
   404                              <1> 	
   405 000003A3 24FD                <1> 	and	al, ~BIT1 ; Clear DRA
   406 000003A5 0C01                <1> 	or	al, AC97_EA_VRA ; 1 ; 04/11/2023
   407 000003A7 EF                  <1> 	out	dx, ax			; Enable variable rate audio
   408                              <1> 	
   409 000003A8 B90A00              <1> 	mov	cx, 10
   410                              <1> check_vra:
   411 000003AB E81001              <1> 	call	delay_100ms
   412                              <1> 
   413                              <1> 	; 11/11/2023
   414 000003AE ED                  <1> 	in	ax, dx
   415 000003AF A801                <1> 	test	al, AC97_EA_VRA ; 1
   416 000003B1 7509                <1> 	jnz	short set_rate
   417                              <1> 
   418                              <1> 	; 11/11/2023
   419 000003B3 E2F6                <1> 	loop	check_vra
   420                              <1> 
   421                              <1> ;vra_not_supported:	; 19/05/2024
   422                              <1> 	; 13/11/2023
   423 000003B5 C606[1303]00        <1> 	mov	byte [VRA], 0
   424 000003BA 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 000003BC A1[AA1F]            <1> 	mov	ax, [sample_rate] ; 17/02/2017 (Erdogan Tan)
   435                              <1> 
   436 000003BF 8B16[981F]          <1> 	mov    	dx, [NAMBAR]               	
   437 000003C3 83C22C              <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
   438 000003C6 EF                  <1> 	out	dx, ax 			; PCM Front/Center Output Sample Rate
   439                              <1> 
   440 000003C7 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 000003CA B80202              <1> 	mov	ax, 0202h
   466 000003CD 8B16[981F]          <1>   	mov     dx, [NAMBAR]
   467 000003D1 83C202              <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
   468 000003D4 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 000003D5 E83F17              <1>         call    delay1_4ms
   492 000003D8 E83C17              <1>         call    delay1_4ms
   493 000003DB E83917              <1>         call    delay1_4ms
   494 000003DE E83617              <1>         call    delay1_4ms
   495                              <1> 
   496                              <1> 	;mov	ax, 0202h
   497 000003E1 8B16[981F]          <1>   	mov     dx, [NAMBAR]
   498 000003E5 83C218              <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
   499 000003E8 EF                  <1>   	out     dx, ax
   500                              <1> 
   501 000003E9 E82B17              <1>         call    delay1_4ms
   502 000003EC E82817              <1>         call    delay1_4ms
   503 000003EF E82517              <1>         call    delay1_4ms
   504 000003F2 E82217              <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 000003F5 F8                  <1> 	clc
   543                              <1> 
   544                              <1> ;detect_ac97_codec:
   545 000003F6 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 000003F7 31C0                <1> 	xor     ax, ax
   555 000003F9 BA0B00              <1>         mov	dx, PI_CR_REG
   556 000003FC 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   557 00000400 EE                  <1> 	out     dx, al
   558                              <1> 
   559                              <1> 	; 19/05/2024
   560 00000401 E81317              <1> 	call	delay1_4ms
   561                              <1> 
   562 00000404 BA1B00              <1>         mov     dx, PO_CR_REG
   563 00000407 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   564 0000040B EE                  <1> 	out     dx, al
   565                              <1> 
   566                              <1> 	; 19/05/2024
   567 0000040C E80817              <1> 	call	delay1_4ms
   568                              <1> 
   569 0000040F BA2B00              <1>         mov     dx, MC_CR_REG
   570 00000412 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   571 00000416 EE                  <1> 	out     dx, al
   572                              <1> 
   573                              <1> 	; 19/05/2024
   574 00000417 E8FD16              <1> 	call	delay1_4ms
   575                              <1> 
   576 0000041A B002                <1>         mov     al, RR
   577 0000041C BA0B00              <1>         mov     dx, PI_CR_REG
   578 0000041F 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   579 00000423 EE                  <1> 	out     dx, al
   580                              <1> 
   581                              <1> 	; 19/05/2024
   582 00000424 E8F016              <1> 	call	delay1_4ms
   583                              <1> 
   584 00000427 BA1B00              <1>         mov     dx, PO_CR_REG
   585 0000042A 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   586 0000042E EE                  <1> 	out     dx, al
   587                              <1> 
   588                              <1> 	; 19/05/2024
   589 0000042F E8E516              <1> 	call	delay1_4ms
   590                              <1> 
   591 00000432 BA2B00              <1>         mov     dx, MC_CR_REG
   592 00000435 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   593 00000439 EE                  <1> 	out     dx, al
   594                              <1> 
   595                              <1> 	; 19/05/2024
   596 0000043A E8DA16              <1> 	call	delay1_4ms
   597                              <1> 
   598 0000043D 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 0000043E BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   604 00000441 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   605 00000445 66ED                <1> 	in	eax, dx
   606                              <1> 
   607                              <1> 	;test	eax, 2
   608                              <1> 	; 06/08/2022
   609 00000447 A802                <1> 	test	al, 2
   610 00000449 7405                <1> 	jz	short _r_ac97codec_cold	
   611                              <1> 
   612 0000044B E80E00              <1> 	call	warm_ac97codec_reset
   613 0000044E 7306                <1> 	jnc	short _r_ac97codec_ok
   614                              <1> _r_ac97codec_cold:
   615 00000450 E83400              <1>         call    cold_ac97codec_reset
   616 00000453 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 00000455 C3                  <1> 	retn
   622                              <1> 
   623                              <1> _r_ac97codec_ok:
   624 00000456 6631C0              <1>         xor     eax, eax
   625                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
   626 00000459 FEC0                <1>         inc	al
   627 0000045B 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 0000045C 66B806000000        <1> 	mov	eax, 6
   634 00000462 BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   635 00000465 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   636 00000469 66EF                <1> 	out	dx, eax
   637                              <1> 
   638 0000046B B90A00              <1> 	mov	cx, 10	; total 1s
   639                              <1> _warm_ac97c_rst_wait:
   640 0000046E E84D00              <1> 	call	delay_100ms
   641                              <1> 
   642 00000471 BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   643 00000474 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   644 00000478 66ED                <1> 	in	eax, dx
   645                              <1> 
   646 0000047A 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   647 00000480 7504                <1> 	jnz	short _warm_ac97c_rst_ok
   648                              <1> 
   649 00000482 49                  <1>         dec     cx
   650 00000483 75E9                <1>         jnz     short _warm_ac97c_rst_wait
   651                              <1> 
   652                              <1> _warm_ac97c_rst_fail:
   653 00000485 F9                  <1>         stc
   654                              <1> _warm_ac97c_rst_ok:
   655 00000486 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 00000487 66B802000000        <1>         mov	eax, 2
   662 0000048D BA2C00              <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
   663 00000490 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   664 00000494 66EF                <1> 	out	dx, eax
   665                              <1> 
   666 00000496 E82500              <1> 	call	delay_100ms 	; wait 100 ms
   667 00000499 E82200              <1> 	call	delay_100ms 	; wait 100 ms
   668 0000049C E81F00              <1> 	call	delay_100ms 	; wait 100 ms
   669 0000049F E81C00              <1> 	call	delay_100ms 	; wait 100 ms
   670                              <1> 
   671 000004A2 B91000              <1> 	mov	cx, 16	; total 20*100 ms = 2s
   672                              <1> 
   673                              <1> _cold_ac97c_rst_wait:
   674 000004A5 BA3000              <1> 	mov	dx, GLOB_STS_REG ; 30h
   675 000004A8 0316[9A1F]          <1> 	add	dx, [NABMBAR]
   676 000004AC 66ED                <1> 	in	eax, dx
   677                              <1> 
   678 000004AE 66A900030010        <1> 	test	eax, CTRL_ST_CREADY
   679 000004B4 7507                <1> 	jnz	short _cold_ac97c_rst_ok
   680                              <1> 
   681 000004B6 E80500              <1> 	call	delay_100ms
   682                              <1> 
   683 000004B9 49                  <1>         dec     cx
   684 000004BA 75E9                <1>         jnz     short _cold_ac97c_rst_wait
   685                              <1> 
   686                              <1> _cold_ac97c_rst_fail:
   687 000004BC F9                  <1>         stc
   688                              <1> _cold_ac97c_rst_ok:
   689 000004BD 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 000004BE 51                  <1> 	push	cx
   697 000004BF B99001              <1> 	mov	cx, 400  ; 400*0.25ms
   698                              <1> _delay_x_ms:
   699 000004C2 E85216              <1> 	call	delay1_4ms
   700 000004C5 E2FB                <1>         loop	_delay_x_ms
   701 000004C7 59                  <1> 	pop	cx
   702 000004C8 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
   474                                  ;;%include 'ich_wav.asm' ; 17/02/2017 (ICH AC97 wav playing functions)
   475                                  ;%include 'ich_wav3.asm' ; 13/11/2023 (ICH AC97 wav playing functions)
   476                                  %include 'ich_wav5.asm' ; 18/11/2023 (ICH AC97 wav playing functions)
     1                              <1> ; 04/02/2025
     2                              <1> ; 03/02/2025
     3                              <1> ; 02/02/2025
     4                              <1> ; 19/05/2024
     5                              <1> ; 19/11/2023
     6                              <1> ; 17/11/2023 - 18/11/2023
     7                              <1> ; 15/11/2023 - 16/11/2023
     8                              <1> ; 13/11/2023 - 14/11/2023
     9                              <1> ; 03/11/2023 - 11/11/2023
    10                              <1> ; DOS based .WAV player using AC'97 and codec interface.
    11                              <1> ; ---------------------------------------------------------------
    12                              <1> ; NASM version: Erdogan Tan (29/11/2016)
    13                              <1> ; Last Update: 17/02/2017 (by Erdogan Tan)
    14                              <1> 
    15                              <1> ; AC97 interrupt version - 09/11/2023 - Erdogan Tan
    16                              <1> ; sample rate conversion version - 13/11/2023 - Erdogan Tan
    17                              <1> ; LVI interrupt version (instead of IOC) - 18/11/2023 - Erdogan Tan
    18                              <1> 
    19                              <1> ; ICHWAV.ASM
    20                              <1> 
    21                              <1> ; player internal variables and other equates.
    22                              <1> BUFFERSIZE      equ     64 * 1024       ; 64k file buffer size.
    23                              <1> ENDOFFILE       equ     BIT0            ; flag for knowing end of file
    24                              <1> 
    25                              <1> ;===========================================================================
    26                              <1> ; entry: none. File is already open and [filehandle] filled.
    27                              <1> ; exit:  not until the song is finished or the user aborts.
    28                              <1> ;
    29                              <1> playWav:
    30                              <1> 	; 13/11/2023
    31                              <1> 
    32 000004C9 803E[1303]01        <1> 	cmp	byte [VRA], 1
    33 000004CE 720F                <1> 	jb	short chk_sample_rate
    34                              <1> playwav_48_khz:	
    35 000004D0 C706[B706][E107]    <1> 	mov	word [loadfromwavfile], loadFromFile
    36                              <1> 	;mov	word [loadsize], 0 ; 65536
    37 000004D6 C706[BB06]0080      <1> 	mov	word [buffersize], 32768 ; samples
    38 000004DC E9E001              <1> 	jmp	playWav_vra
    39                              <1> 
    40                              <1> 	; 02/02/2025
    41                              <1> chk_sample_rate:
    42                              <1> 	; set conversion parameters
    43                              <1> 	; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
    44 000004DF A1[AA1F]            <1> 	mov	ax, [sample_rate]
    45 000004E2 3D80BB              <1> 	cmp	ax, 48000
    46 000004E5 74E9                <1> 	je	short playwav_48_khz
    47                              <1> chk_22khz:
    48 000004E7 3D2256              <1> 	cmp	ax, 22050
    49 000004EA 752F                <1> 	jne	short chk_11khz
    50 000004EC 803E[AE1F]08        <1> 	cmp	byte [bps], 8
    51 000004F1 760F                <1> 	jna	short chk_22khz_1
    52 000004F3 BB[2D12]            <1> 	mov	bx, load_22khz_stereo_16_bit
    53 000004F6 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
    54 000004FB 7512                <1> 	jne	short chk_22khz_2
    55 000004FD BB[C411]            <1> 	mov	bx, load_22khz_mono_16_bit
    56 00000500 EB0D                <1> 	jmp	short chk_22khz_2
    57                              <1> chk_22khz_1:
    58 00000502 BB[5F11]            <1> 	mov	bx, load_22khz_stereo_8_bit
    59 00000505 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
    60 0000050A 7503                <1> 	jne	short chk_22khz_2
    61 0000050C BB[F610]            <1> 	mov	bx, load_22khz_mono_8_bit
    62                              <1> chk_22khz_2:
    63 0000050F B85A1D              <1> 	mov	ax, 7514  ; (442*17)
    64 00000512 BA2500              <1> 	mov	dx, 37
    65 00000515 B91100              <1> 	mov	cx, 17 
    66 00000518 E93301              <1> 	jmp	set_sizes	
    67                              <1> chk_11khz:
    68 0000051B 3D112B              <1> 	cmp	ax, 11025
    69 0000051E 752F                <1> 	jne	short chk_44khz
    70 00000520 803E[AE1F]08        <1> 	cmp	byte [bps], 8
    71 00000525 760F                <1> 	jna	short chk_11khz_1
    72 00000527 BB[C113]            <1> 	mov	bx, load_11khz_stereo_16_bit
    73 0000052A 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
    74 0000052F 7512                <1> 	jne	short chk_11khz_2
    75 00000531 BB[6613]            <1> 	mov	bx, load_11khz_mono_16_bit
    76 00000534 EB0D                <1> 	jmp	short chk_11khz_2
    77                              <1> chk_11khz_1:
    78 00000536 BB[0B13]            <1> 	mov	bx, load_11khz_stereo_8_bit
    79 00000539 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
    80 0000053E 7503                <1> 	jne	short chk_11khz_2
    81 00000540 BB[AD12]            <1> 	mov	bx, load_11khz_mono_8_bit
    82                              <1> chk_11khz_2:
    83 00000543 B8AD0E              <1> 	mov	ax, 3757  ; (221*17)
    84 00000546 BA4A00              <1> 	mov	dx, 74
    85 00000549 B91100              <1> 	mov	cx, 17
    86 0000054C E9FF00              <1> 	jmp	set_sizes 
    87                              <1> chk_44khz:
    88 0000054F 3D44AC              <1> 	cmp	ax, 44100
    89 00000552 752F                <1> 	jne	short chk_16khz
    90 00000554 803E[AE1F]08        <1> 	cmp	byte [bps], 8
    91 00000559 760F                <1> 	jna	short chk_44khz_1
    92 0000055B BB[7215]            <1> 	mov	bx, load_44khz_stereo_16_bit
    93 0000055E 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
    94 00000563 7512                <1> 	jne	short chk_44khz_2
    95 00000565 BB[1A15]            <1> 	mov	bx, load_44khz_mono_16_bit
    96 00000568 EB0D                <1> 	jmp	short chk_44khz_2
    97                              <1> chk_44khz_1:
    98 0000056A BB[BC14]            <1> 	mov	bx, load_44khz_stereo_8_bit
    99 0000056D 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   100 00000572 7503                <1> 	jne	short chk_44khz_2
   101 00000574 BB[5F14]            <1> 	mov	bx, load_44khz_mono_8_bit
   102                              <1> chk_44khz_2:
   103                              <1> 	;mov	ax, 15065 ; (655*23)
   104                              <1> 	; 18/11/2023 ((file size + bss + stack) <= 64KB)
   105 00000577 B8FC36              <1> 	mov	ax, 14076 ; (612 *23)
   106 0000057A BA1900              <1> 	mov	dx, 25
   107 0000057D B91700              <1> 	mov	cx, 23
   108 00000580 E9CB00              <1> 	jmp	set_sizes 
   109                              <1> chk_16khz:
   110 00000583 3D803E              <1> 	cmp	ax, 16000
   111 00000586 752F                <1> 	jne	short chk_8khz
   112 00000588 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   113 0000058D 760F                <1> 	jna	short chk_16khz_1
   114 0000058F BB[6E0D]            <1> 	mov	bx, load_16khz_stereo_16_bit
   115 00000592 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   116 00000597 7512                <1> 	jne	short chk_16khz_2
   117 00000599 BB[0D0D]            <1> 	mov	bx, load_16khz_mono_16_bit
   118 0000059C EB0D                <1> 	jmp	short chk_16khz_2
   119                              <1> chk_16khz_1:
   120 0000059E BB[7D0C]            <1> 	mov	bx, load_16khz_stereo_8_bit
   121 000005A1 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   122 000005A6 7503                <1> 	jne	short chk_16khz_2
   123 000005A8 BB[190C]            <1> 	mov	bx, load_16khz_mono_8_bit
   124                              <1> chk_16khz_2:
   125 000005AB B85515              <1> 	mov	ax, 5461
   126 000005AE BA0300              <1> 	mov	dx, 3
   127 000005B1 B90100              <1> 	mov	cx, 1
   128 000005B4 E99700              <1> 	jmp	set_sizes 
   129                              <1> chk_8khz:
   130 000005B7 3D401F              <1> 	cmp	ax, 8000
   131 000005BA 752E                <1> 	jne	short chk_24khz
   132 000005BC 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   133 000005C1 760F                <1> 	jna	short chk_8khz_1
   134 000005C3 BB[320B]            <1> 	mov	bx, load_8khz_stereo_16_bit
   135 000005C6 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   136 000005CB 7512                <1> 	jne	short chk_8khz_2
   137 000005CD BB[A10A]            <1> 	mov	bx, load_8khz_mono_16_bit
   138 000005D0 EB0D                <1> 	jmp	short chk_8khz_2
   139                              <1> chk_8khz_1:
   140 000005D2 BB[B109]            <1> 	mov	bx, load_8khz_stereo_8_bit
   141 000005D5 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   142 000005DA 7503                <1> 	jne	short chk_8khz_2
   143 000005DC BB[FE08]            <1> 	mov	bx, load_8khz_mono_8_bit
   144                              <1> chk_8khz_2:
   145 000005DF B8AA0A              <1> 	mov	ax, 2730
   146 000005E2 BA0600              <1> 	mov	dx, 6
   147 000005E5 B90100              <1> 	mov	cx, 1
   148 000005E8 EB64                <1> 	jmp	short set_sizes 
   149                              <1> chk_24khz:
   150 000005EA 3DC05D              <1> 	cmp	ax, 24000
   151 000005ED 752E                <1> 	jne	short chk_32khz
   152 000005EF 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   153 000005F4 760F                <1> 	jna	short chk_24khz_1
   154 000005F6 BB[060F]            <1> 	mov	bx, load_24khz_stereo_16_bit
   155 000005F9 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   156 000005FE 7512                <1> 	jne	short chk_24khz_2
   157 00000600 BB[BA0E]            <1> 	mov	bx, load_24khz_mono_16_bit
   158 00000603 EB0D                <1> 	jmp	short chk_24khz_2
   159                              <1> chk_24khz_1:
   160 00000605 BB[520E]            <1> 	mov	bx, load_24khz_stereo_8_bit
   161 00000608 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   162 0000060D 7503                <1> 	jne	short chk_24khz_2
   163 0000060F BB[030E]            <1> 	mov	bx, load_24khz_mono_8_bit
   164                              <1> chk_24khz_2:
   165                              <1> 	;mov	ax, 8192
   166                              <1> 	; 04/02/2025
   167 00000612 B8FE1F              <1> 	mov	ax, 8190
   168 00000615 BA0200              <1> 	mov	dx, 2
   169 00000618 B90100              <1> 	mov	cx, 1
   170 0000061B EB31                <1> 	jmp	short set_sizes 
   171                              <1> chk_32khz:
   172 0000061D 3D007D              <1> 	cmp	ax, 32000
   173                              <1> 	;jne	short vra_needed
   174                              <1> 	; 02/02/2025
   175 00000620 755B                <1> 	jne	short chk_12khz
   176 00000622 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   177 00000627 760F                <1> 	jna	short chk_32khz_1
   178 00000629 BB[8B10]            <1> 	mov	bx, load_32khz_stereo_16_bit
   179 0000062C 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   180 00000631 7512                <1> 	jne	short chk_32khz_2
   181 00000633 BB[3B10]            <1> 	mov	bx, load_32khz_mono_16_bit
   182 00000636 EB0D                <1> 	jmp	short chk_32khz_2
   183                              <1> chk_32khz_1:
   184 00000638 BB[C40F]            <1> 	mov	bx, load_32khz_stereo_8_bit
   185 0000063B 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   186 00000640 7503                <1> 	jne	short chk_32khz_2
   187 00000642 BB[6C0F]            <1> 	mov	bx, load_32khz_mono_8_bit
   188                              <1> chk_32khz_2:
   189 00000645 B8AA2A              <1> 	mov	ax, 10922
   190 00000648 BA0300              <1> 	mov	dx, 3
   191 0000064B B90200              <1> 	mov	cx, 2
   192                              <1> 	;jmp	short set_sizes
   193                              <1> 
   194                              <1> set_sizes:
   195 0000064E 803E[AC1F]01        <1> 	cmp	byte [stmo], 1
   196 00000653 7402                <1> 	je	short ss_1
   197 00000655 D1E0                <1> 	shl	ax, 1
   198                              <1> ss_1:
   199 00000657 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   200 0000065C 7602                <1> 	jna	short ss_2
   201                              <1> 	; 16 bit samples
   202 0000065E D1E0                <1> 	shl	ax, 1
   203                              <1> ss_2:
   204 00000660 A3[B906]            <1> 	mov	[loadsize], ax
   205 00000663 F7E2                <1> 	mul	dx
   206                              <1> 
   207                              <1> 	; 04/02/2025
   208 00000665 83F901              <1> 	cmp	cx, 1
   209 00000668 7402                <1> 	je	short ss_3
   210                              <1> 
   211 0000066A F7F1                <1> 	div	cx
   212                              <1> ss_3:
   213 0000066C 8A0E[B01F]          <1> 	mov	cl, [fbs_shift]
   214 00000670 D3E0                <1> 	shl	ax, cl
   215                              <1> 
   216                              <1> 	; 03/02/2025
   217 00000672 D1E8                <1> 	shr	ax, 1	; buffer size is 16 bit sample count
   218                              <1> 	; 65536 -> 32768
   219 00000674 A3[BB06]            <1> 	mov	[buffersize], ax
   220 00000677 891E[B706]          <1> 	mov	[loadfromwavfile], bx
   221 0000067B EB42                <1> 	jmp	short playWav_vra
   222                              <1> 
   223                              <1> 	;;;;
   224                              <1> 	; 02/02/2025
   225                              <1> chk_12khz:
   226 0000067D 3DE02E              <1> 	cmp	ax, 12000
   227 00000680 752E                <1> 	jne	short vra_needed
   228 00000682 803E[AE1F]08        <1> 	cmp	byte [bps], 8
   229 00000687 760F                <1> 	jna	short chk_12khz_1
   230 00000689 BB[8616]            <1> 	mov	bx, load_12khz_stereo_16_bit
   231 0000068C 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   232 00000691 7512                <1> 	jne	short chk_12khz_2
   233 00000693 BB[4A16]            <1> 	mov	bx, load_12khz_mono_16_bit
   234 00000696 EB0D                <1> 	jmp	short chk_12khz_2
   235                              <1> chk_12khz_1:
   236 00000698 BB[0A16]            <1> 	mov	bx, load_12khz_stereo_8_bit
   237 0000069B 803E[AC1F]01        <1> 	cmp	byte [stmo], 1 
   238 000006A0 7503                <1> 	jne	short chk_12khz_2
   239 000006A2 BB[D215]            <1> 	mov	bx, load_12khz_mono_8_bit
   240                              <1> chk_12khz_2:
   241                              <1> 	;mov	ax, 4096
   242                              <1> 	; 04/02/2025
   243 000006A5 B8FF0F              <1> 	mov	ax, 4095
   244 000006A8 BA0400              <1> 	mov	dx, 4
   245 000006AB B90100              <1> 	mov	cx, 1
   246 000006AE EB9E                <1> 	jmp	set_sizes 
   247                              <1> 	;;;;
   248                              <1> 
   249                              <1> vra_needed:
   250                              <1> 	; 13/11/2023
   251 000006B0 58                  <1> 	pop	ax ; discard return address to the caller
   252 000006B1 BA[EB1E]            <1> 	mov	dx, msg_no_vra
   253 000006B4 E99AFA              <1> 	jmp	vra_err
   254                              <1> 
   255                              <1> 	; 13/11/2023
   256                              <1> loadfromwavfile:
   257 000006B7 [E107]              <1> 	dw	loadFromFile
   258                              <1> loadsize:	; read from wav file
   259 000006B9 0000                <1> 	dw	0
   260                              <1> buffersize:	; write to DMA buffer
   261 000006BB 00800000            <1> 	dd	32768 ; 16 bit samples (not bytes)
   262                              <1> 
   263                              <1> playWav_vra:
   264                              <1> 	; 07/11/2023
   265                              <1> 	; clear buffer 2
   266                              <1>         ;push	es
   267                              <1> 	;mov	ax, [WAV_BUFFER2]
   268                              <1> 	;mov	es, ax
   269                              <1> 	;sub	ax, ax
   270                              <1> 	;mov	di, ax ; 17/02/2017
   271                              <1> 	;mov	cx, (BUFFERSIZE/2)
   272                              <1> 	;rep	stosw
   273                              <1> 	;pop	es	     
   274                              <1> 	
   275                              <1> 	; load 64k into buffer 1
   276 000006BF A1[9E1F]            <1>         mov     ax, [WAV_BUFFER1]
   277                              <1>         ;call	loadFromFile
   278                              <1> 	; 13/11/2023
   279 000006C2 FF16[B706]          <1> 	call	word [loadfromwavfile]
   280                              <1> 
   281                              <1> 	; and 64k into buffer 2
   282 000006C6 A1[A01F]            <1> 	mov     ax, [WAV_BUFFER2]
   283                              <1>        	;call	loadFromFile
   284                              <1> 	; 13/11/2023
   285 000006C9 FF16[B706]          <1> 	call	word [loadfromwavfile]
   286                              <1> 
   287                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
   288                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
   289                              <1> ; reset.
   290                              <1> 
   291                              <1> 	; 11/11/2023
   292                              <1>         ;mov	dx, [NABMBAR]
   293                              <1>         ;add	dx, PO_CR_REG		; set pointer to Ctrl reg
   294                              <1>         ;mov	al, RR			; set reset
   295                              <1> 	;out	dx, al			; self clearing bit
   296                              <1> 
   297                              <1> ; write last valid index to 31 to start with.
   298                              <1> ; The Last Valid Index register tells the DMA engine when to stop playing.
   299                              <1> ; 
   300                              <1> ; As we progress through the song we change the last valid index to always be
   301                              <1> ; something other than the index we're currently playing.  
   302                              <1> ;
   303                              <1> 	; 08/11/2023
   304                              <1> 	;; 07/11/2023
   305                              <1> 	;mov	al, 1
   306                              <1>         ;;mov	al, 31
   307                              <1> 	;call	setLastValidIndex
   308                              <1> 
   309                              <1> ; create Buffer Descriptor List
   310                              <1> ;
   311                              <1> ; A buffer descriptor list is a list of pointers and control bits that the
   312                              <1> ; DMA engine uses to know where to get the .wav data and how to play it.
   313                              <1> ;
   314                              <1> ; I set it up to use only 2 buffers of .wav data, and whenever 1 buffer is
   315                              <1> ; playing, I refresh the other one with good data.
   316                              <1> ;
   317                              <1> ;
   318                              <1> ; For the control bits, you can specify that the DMA engine fire an interrupt
   319                              <1> ; after a buffer has been processed, but I poll the current index register
   320                              <1> ; to know when it's safe to update the other buffer.
   321                              <1> ;
   322                              <1> ; I set the BUP bit, which tells the DMA engine to just play 0's (silence)
   323                              <1> ; if it ever runs out of data to play. Good for safety.
   324                              <1> ;
   325 000006CD 06                  <1>         push    es
   326 000006CE A1[9C1F]            <1>         mov     ax, [BDL_BUFFER]		; get segment # for BDL
   327 000006D1 8EC0                <1>         mov     es, ax
   328                              <1> 
   329 000006D3 B91000              <1>         mov     cx, 32 / 2                      ; make 32 entries in BDL
   330 000006D6 31FF                <1>         xor     di, di                          
   331                              <1> _0:
   332                              <1> 
   333                              <1> ; set buffer descriptor 0 to start of data file in memory
   334 000006D8 660FB706[9E1F]      <1>         movzx   eax, word [WAV_BUFFER1]
   335 000006DE 66C1E004            <1>         shl     eax, 4                          ; convert seg:off ->0:offset
   336 000006E2 66AB                <1>         stosd                                   ; store pointer to wavbuffer1
   337                              <1> 
   338                              <1> ;
   339                              <1> ; set length to 32k samples. 1 sample is 16bits or 2bytes.
   340                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples.
   341                              <1> ; 
   342                              <1> 
   343                              <1> ; 17/02/2017 (Erdogan Tan)
   344                              <1> ; Intel® 82801AA (ICH) & Intel® 82801AB (ICH0) I/O Controller Hub AC’97
   345                              <1> ; Programmer’s Reference Manual
   346                              <1> 
   347                              <1> ; 2.2.1 Buffer Descriptor List  (on Page 13)
   348                              <1> 	;
   349                              <1> 	;  Generic Form of Buffer Descriptor
   350                              <1> 	;  ---------------------------------
   351                              <1> 	;  63   62    61-48    47-32   31-0
   352                              <1> 	;  ---  ---  --------  ------- -----
   353                              <1> 	;  IOC  BUP -reserved- Buffer  Buffer
   354                              <1> 	;		      Length   Pointer
   355                              <1> 	;		      [15:0]   [31:0]
   356                              <1> 	;
   357                              <1> 	;  IOC:	Interrupt On Completion. 
   358                              <1> 	;	1 = Enabled. 
   359                              <1> 	;	    When this is set, it means that the controller should
   360                              <1> 	;	    issue an interrupt upon completion of this buffer.
   361                              <1> 	;	    It should also set the IOC bit in the status register
   362                              <1> 	;	0 = Disabled	
   363                              <1> 	;
   364                              <1> 	;  BUP: Buffer Underrun Policy.
   365                              <1> 	;       0 = When this buffer is complete,
   366                              <1> 	;	    if the next buffer is not yet ready 
   367                              <1> 	;	    (i.e., the last valid buffer has been processed),
   368                              <1> 	;	    then continue to transmit the last valid sample.
   369                              <1> 	;	1 = When this buffer is complete,
   370                              <1> 	;     	    if this is the last valid buffer, transmit zeros after
   371                              <1> 	;	    this buffer has been processed completely.
   372                              <1> 	;	    This bit typically is set only if this is the last 
   373                              <1> 	;	    buffer in the current stream.
   374                              <1> 	;
   375                              <1> 	; [31:0]: Buffer pointer. This field points to the location of
   376                              <1> 	;	  the data buffer. Since samples can be as wide as one
   377                              <1> 	;	  word, the buffer must be aligned with word boundaries,
   378                              <1> 	;	  to prevent samples from straddling DWord boundaries.
   379                              <1> 	;
   380                              <1> 	; [15:0]: Buffer Length: This is the length of the data buffer,
   381                              <1> 	;	  in number of samples. The controller uses this data
   382                              <1> 	;	  to determine the length of the buffer, in bytes.
   383                              <1> 	;	  "0" indicates no sample to process.
   384                              <1> 
   385                              <1> ; ICH2AC97.INC
   386                              <1> 
   387                              <1> ;	IOC	equ     BIT31   ; Fire an interrupt whenever this
   388                              <1> 				; buffer is complete.
   389                              <1> 
   390                              <1> ;	BUP	equ     BIT30   ; Buffer Underrun Policy.
   391                              <1> 				; if this buffer is the last buffer
   392                              <1> 				; in a playback, fill the remaining
   393                              <1> 				; samples with 0 (silence) or not.
   394                              <1> 				; It's a good idea to set this to 1
   395                              <1> 				; for the last buffer in playback,
   396                              <1> 				; otherwise you're likely to get a lot
   397                              <1> 				; of noise at the end of the sound.
   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> ; ICHWAV.ASM
   410                              <1> 				    ; 19/05/2024
   411                              <1> 	;mov	eax, BUFFERSIZE / 2 ; size of buffer (32K) in (16bit) words
   412                              <1> 	; 13/11/2023
   413 000006E4 66A1[BB06]          <1> 	mov	eax, [buffersize]
   414                              <1> 
   415                              <1> 	; 18/11/2023
   416                              <1> 	; 09/11/2023
   417                              <1> 	;or	eax, IOC + BUP
   418                              <1> 	; 06/11/2023
   419 000006E8 660D00000040        <1> 	or	eax, BUP
   420 000006EE 66AB                <1> 	stosd
   421                              <1> 
   422                              <1> ; 2nd buffer:
   423                              <1> 
   424 000006F0 660FB706[A01F]      <1>         movzx   eax, word [WAV_BUFFER2]
   425 000006F6 66C1E004            <1>         shl     eax, 4                          ; convert seg:off ->0:offset
   426 000006FA 66AB                <1>         stosd                                   ; store pointer to wavbuffer2
   427                              <1> 
   428                              <1> ; set length to 64k (32k of two 16 bit samples)
   429                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
   430                              <1> ; 
   431                              <1> 	;mov	eax, BUFFERSIZE / 2
   432                              <1> 	; 13/11/2023
   433 000006FC 66A1[BB06]          <1> 	mov	eax, [buffersize]
   434                              <1> 
   435                              <1> 	; 18/11/2023
   436                              <1> 	; 09/11/2023
   437                              <1> 	;or	eax, IOC + BUP
   438                              <1> 	; 06/11/2023
   439 00000700 660D00000040        <1> 	or	eax, BUP
   440 00000706 66AB                <1> 	stosd
   441                              <1> 
   442 00000708 E2CE                <1>         loop    _0
   443 0000070A 07                  <1>         pop     es
   444                              <1> 
   445                              <1> ;
   446                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
   447                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
   448                              <1> ;
   449                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
   450                              <1> ;
   451 0000070B 660FB706[9C1F]      <1>         movzx   eax, word [BDL_BUFFER]
   452 00000711 66C1E004            <1> 	shl     eax, 4                          ; convert seg:off to 0:off
   453 00000715 8B16[9A1F]          <1>         mov     dx, [NABMBAR]
   454 00000719 83C210              <1>         add     dx, PO_BDBAR_REG                ; set pointer to BDL
   455 0000071C 66EF                <1>         out     dx, eax                         ; write to AC97 controller
   456                              <1> 
   457                              <1> 	; 19/05/2024
   458 0000071E E8F613              <1> 	call	delay1_4ms
   459                              <1> 
   460                              <1> ;
   461                              <1> ; All set. Let's play some music.
   462                              <1> ;
   463                              <1> 
   464                              <1> 	; 18/11/2023
   465                              <1> 	; 10/11/2023
   466                              <1> 	; 08/11/2023
   467                              <1> 	; 07/11/2023
   468                              <1> 	; 08/12/2016
   469                              <1> 	; 07/10/2016
   470 00000721 B001                <1> 	mov	al, 1	; 18/11/2023
   471                              <1> 	;mov	al, 31
   472 00000723 A2[B21F]            <1> 	mov	[LVI], al ; 10/11/2023
   473 00000726 E88501              <1> 	call	setLastValidIndex
   474                              <1> 
   475                              <1> 	; 06/11/2023 (not neccessary)
   476                              <1> 	;; 05/11/2023
   477                              <1> 	;; reset current index
   478                              <1> 	;mov	al, 0
   479                              <1> 	;call	setCurrentIndex
   480                              <1> 
   481                              <1> 	; 06/11/2023
   482                              <1> 	;mov	byte [tLoop], 1 ; 30/11/2016
   483                              <1> 
   484                              <1> 	; 19/05/2024
   485 00000729 E8EB13              <1> 	call	delay1_4ms
   486                              <1> 
   487                              <1> 	; 17/02/2017
   488 0000072C 8B16[9A1F]          <1>         mov     dx, [NABMBAR]
   489 00000730 83C21B              <1>         add     dx, PO_CR_REG                   ; PCM out Control Register
   490                              <1>         ; 18/11/2023
   491 00000733 B005                <1> 	mov	al, LVBIE + RPBM ; Enable LVBI interrupt and run bus master
   492                              <1> 	; 09/11/2023
   493                              <1> 	;mov	al, IOCE + RPBM	; Enable 'Interrupt On Completion' + run
   494                              <1> 	;			; (LVBI interrupt will not be enabled)
   495                              <1> 	; 06/11/2023 (TUNELOOP version, without interrupt)
   496                              <1> 	;mov	al, RPBM
   497 00000735 EE                  <1> 	out     dx, al                          ; Start bus master operation.
   498                              <1> 
   499                              <1> 	; 09/11/2023
   500 00000736 C606[B11F]3F        <1> 	mov	byte [b_indicator], '?'	
   501                              <1> 
   502                              <1> 	; 19/05/2024
   503                              <1> 	; 06/11/2023
   504 0000073B E8D913              <1> 	call	delay1_4ms
   505 0000073E E8D613              <1> 	call	delay1_4ms
   506 00000741 E8D313              <1> 	call	delay1_4ms
   507 00000744 E8D013              <1> 	call	delay1_4ms
   508                              <1> 
   509                              <1> 	; 10/11/2023
   510                              <1> 	;mov	byte [tloop], 1
   511                              <1> 
   512                              <1> ; while DMA engine is running, examine current index and wait until it hits 1
   513                              <1> ; as soon as it's 1, we need to refresh the data in wavbuffer1 with another
   514                              <1> ; 64k. Likewise when it's playing buffer 2, refresh buffer 1 and repeat.
   515                              <1> 
   516                              <1> ; 04/02/2025
   517                              <1> ; 09/11/2023   
   518                              <1> ; 06/11/2023
   519                              <1> %if 1
   520                              <1> 	; 08/12/2016
   521                              <1> 	; 28/11/2016
   522                              <1> p_loop:
   523 00000747 E87001              <1> 	call    check4keyboardstop ; keyboard halt?
   524 0000074A 732C                <1>         jnc	short r_loop 	   ; no ; 09/11/2023
   525                              <1> 
   526                              <1> 	; 09/11/2023
   527                              <1> 	;or	byte [flags], ENDOFFILE
   528                              <1> 	;mov	byte [b_indicator], '0'
   529                              <1> q_loop:
   530                              <1> 	; 04/02/2025
   531 0000074C B030                <1> 	mov	al, '0'
   532 0000074E E88000              <1> 	call	tL0
   533                              <1> 
   534                              <1> 	; 04/11/2023
   535                              <1> 	; finished with song, stop everything
   536 00000751 E8B515              <1> 	call	ac97_stop
   537                              <1> 
   538                              <1> 	; 11/11/2023
   539                              <1> irq_restore:	
   540                              <1> 	; restore previous interrupt vector and interrupt_status
   541 00000754 FA                  <1> 	cli
   542 00000755 E4A1                <1> 	in	al, 0A1h ; irq 8-15
   543 00000757 A0[931F]            <1> 	mov	al, [IRQ_status+1]
   544 0000075A E6A1                <1> 	out	0A1h, al 
   545 0000075C E421                <1> 	in	al, 021h ; irq 0-7
   546 0000075E A0[921F]            <1> 	mov	al, [IRQ_status]
   547 00000761 E621                <1> 	out	21h, al 
   548                              <1> 	; ...
   549 00000763 06                  <1> 	push	es
   550 00000764 31C0                <1> 	xor	ax, ax
   551 00000766 8EC0                <1> 	mov	es, ax
   552 00000768 A1[941F]            <1> 	mov	ax, [IRQ_vector]
   553 0000076B 268907              <1> 	mov	[es:bx], ax
   554 0000076E A1[961F]            <1> 	mov	ax, [IRQ_vector+2]
   555 00000771 26894702            <1> 	mov	[es:bx+2], ax
   556 00000775 07                  <1> 	pop	es
   557 00000776 FB                  <1> 	sti
   558 00000777 C3                  <1> 	retn
   559                              <1> 
   560                              <1> r_loop:
   561                              <1> 	; 19/05/2024
   562                              <1> 	; 10/11/2023
   563 00000778 90                  <1> 	nop
   564 00000779 90                  <1> 	nop
   565 0000077A 90                  <1> 	nop
   566                              <1> 
   567                              <1> 	; 04/02/2025
   568                              <1> 	; 11/11/2023
   569                              <1> 	;mov	al, '0'
   570 0000077B 803E[911F]00        <1> 	cmp	byte [tloop], 0
   571 00000780 74C5                <1> 	je	short p_loop
   572 00000782 7CC8                <1> 	jl	short q_loop
   573                              <1> 
   574 00000784 FE0E[911F]          <1> 	dec	byte [tloop] ; 0
   575                              <1> 
   576 00000788 803E[B11F]31        <1> 	cmp	byte [b_indicator], '1' ; will be played
   577 0000078D 7511                <1> 	jne	short s_loop
   578                              <1> 	
   579                              <1> 	; 19/11/2023
   580                              <1> 	; load buffer 1
   581 0000078F A1[9E1F]            <1> 	mov	ax, [WAV_BUFFER1] ; will be played
   582                              <1> u_loop:
   583                              <1> 	;call	loadFromFile
   584                              <1> 	; 13/11/2023
   585 00000792 FF16[B706]          <1> 	call	word [loadfromwavfile]
   586                              <1> 	;jnc	short v_loop
   587                              <1> 	; 04/02/2025
   588 00000796 72B4                <1> 	jc	short q_loop
   589                              <1> 	
   590                              <1> 	; 19/11/2023
   591                              <1> 	;cmp	byte [tloop], -1
   592                              <1> 	;jne	short v_loop
   593                              <1> 	
   594                              <1> 	; 04/02/2025
   595                              <1> 	;mov	al, '0'
   596                              <1> 	;jmp	short q_loop
   597                              <1> v_loop:
   598                              <1> 	; 09/11/2023 - Erdogan Tan
   599                              <1> 	; (print buffer number on top left of the screen)
   600 00000798 A0[B11F]            <1> 	mov	al, [b_indicator] ; going to be played
   601 0000079B E83300              <1> 	call	tL0
   602 0000079E EBA7                <1> 	jmp	short p_loop
   603                              <1> s_loop:
   604                              <1> 	; load buffer 2
   605 000007A0 A1[A01F]            <1> 	mov	ax, [WAV_BUFFER2] ; will be played
   606 000007A3 EBED                <1> 	jmp	short u_loop
   607                              <1> 
   608                              <1> %endif
   609                              <1> 
   610                              <1> ; while DMA engine is running, examine current index and wait until it hits 1
   611                              <1> ; as soon as it's 1, we need to refresh the data in wavbuffer1 with another
   612                              <1> ; 64k. Likewise when it's playing buffer 2, refresh buffer 1 and repeat.
   613                              <1> 
   614                              <1> ; 18/11/2023
   615                              <1> %if 1
   616                              <1> 
   617                              <1> tuneLoop:
   618                              <1> 	; 04/02/2025
   619                              <1> 	; 19/11/2023
   620                              <1> 	; 18/11/2023
   621 000007A5 F606[8E1F]01        <1> 	test	byte [flags], ENDOFFILE
   622 000007AA 751E                <1> 	jnz	short tL3
   623                              <1> 
   624                              <1> 	; 19/11/2023
   625 000007AC C606[911F]01        <1> 	mov	byte [tloop], 1
   626                              <1> 	
   627                              <1> 	; set LVI to the next
   628                              <1> 	; (and then load audio data in that buffer) 
   629 000007B1 A0[B21F]            <1> 	mov	al, [LVI]
   630 000007B4 40                  <1> 	inc	ax
   631 000007B5 241F                <1> 	and	al, 1Fh
   632 000007B7 E8F400              <1> 	call	setLastValidIndex
   633                              <1> 	;mov	[LVI], al
   634                              <1> tL1:
   635                              <1> 	; al = next buffer index (not for the buffer being played)
   636 000007BA A801                <1> 	test	al, BIT0
   637 000007BC 7506                <1> 	jnz	short tL2
   638                              <1> 
   639                              <1> 	; 19/11/2023
   640                              <1> 	; load buffer 1
   641                              <1> 	;mov	ax, [WAV_BUFFER1] ; will be played
   642                              <1> 	;call	word [loadfromwavfile]
   643                              <1> 	;jc	short tL3
   644                              <1> 
   645 000007BE C606[B11F]31        <1> 	mov	byte [b_indicator], '1'
   646 000007C3 C3                  <1> 	retn
   647                              <1> tL2:
   648                              <1> 	; 19/11/2023
   649                              <1> 	; load buffer 2
   650                              <1> 	;mov	ax, [WAV_BUFFER2] ; will be played
   651                              <1> 	;call	word [loadfromwavfile]
   652                              <1> 	;jc	short tL3
   653                              <1> 
   654 000007C4 C606[B11F]32        <1> 	mov	byte [b_indicator], '2'
   655 000007C9 C3                  <1> 	retn
   656                              <1> tL3:
   657 000007CA C606[911F]FF        <1> 	mov	byte [tloop], -1
   658 000007CF F9                  <1> 	stc
   659 000007D0 C3                  <1> 	retn
   660                              <1> 
   661                              <1> 	; 18/11/2023
   662                              <1> tL0:
   663                              <1> 	; al = buffer indicator ('1', '2' or '0' -stop- )
   664 000007D1 1E                  <1> 	push	ds
   665                              <1> 	; 04/02/2025
   666 000007D2 53                  <1> 	push	bx 
   667 000007D3 BB00B8              <1> 	mov	bx, 0B800h ; video display page segment
   668 000007D6 8EDB                <1> 	mov	ds, bx
   669 000007D8 29DB                <1> 	sub	bx, bx ; 0
   670 000007DA B44E                <1> 	mov	ah, 4Eh
   671 000007DC 8907                <1> 	mov	[bx], ax ; show current play buffer (1, 2)
   672 000007DE 5B                  <1> 	pop	bx
   673 000007DF 1F                  <1> 	pop	ds
   674 000007E0 C3                  <1> 	retn
   675                              <1> 
   676                              <1> %endif
   677                              <1> 
   678                              <1> ; 11/11/2023
   679                              <1> ; 10/11/2023
   680                              <1> ; 09/11/2023
   681                              <1> ; 08/11/2023
   682                              <1> ; 07/11/2023
   683                              <1> %if 0	; 18/11/2023
   684                              <1> 
   685                              <1> tuneLoop:
   686                              <1> 	; 11/11/2023
   687                              <1> 	; 10/11/2023
   688                              <1> 	; 09/11/2023
   689                              <1> 	; 08/11/2023
   690                              <1> 	; 06/11/2023
   691                              <1> 	;mov	al, '1'
   692                              <1> 	;call	tL0
   693                              <1> tL1:
   694                              <1> 	; 10/11/2023
   695                              <1> 	;mov	byte [tloop], 1
   696                              <1> 
   697                              <1> 	; 11/11/2023
   698                              <1> 	;call    updateLVI	; set LVI != CIV
   699                              <1> 	;jz	short tL4	
   700                              <1> 
   701                              <1> 	; 11/11/2023
   702                              <1> 	mov	byte [tloop], 1
   703                              <1> 
   704                              <1> 	call    getCurrentIndex
   705                              <1> 
   706                              <1> 	; 10/11/2023
   707                              <1> 	cmp	al, [LVI]
   708                              <1> 	jne	short tL2
   709                              <1> 
   710                              <1> 	test	byte [flags], ENDOFFILE
   711                              <1> 	;jnz	short tL2
   712                              <1> 	jnz	short tL4
   713                              <1> 
   714                              <1> 	dec	ax
   715                              <1> 	and	al, 1Fh 
   716                              <1> 	call	setLastValidIndex	
   717                              <1> 	xchg	al, [LVI]
   718                              <1> tL2:
   719                              <1> 	test	al, BIT0
   720                              <1> 	jz	short tL3
   721                              <1> 
   722                              <1> 	mov	byte [b_indicator], '1'
   723                              <1> 	retn
   724                              <1> tL3:	
   725                              <1> 	mov	byte [b_indicator], '2'
   726                              <1> 	retn
   727                              <1> tL4:
   728                              <1> 	; 11/11/2023
   729                              <1> 	mov	byte [tloop], -1
   730                              <1> 	stc
   731                              <1> 	retn
   732                              <1> 
   733                              <1> 	; 06/11/2023
   734                              <1> tL0:
   735                              <1> 	; 08/11/2023
   736                              <1> 	; 05/11/2023
   737                              <1> 	; 17/02/2017 - Buffer switch test (temporary)
   738                              <1> 	; 06/11/2023
   739                              <1> 	; al = buffer indicator ('1', '2' or '0' -stop- )
   740                              <1> 	push	ds
   741                              <1> 	;push	bx 
   742                              <1> 	mov	bx, 0B800h ; video display page segment
   743                              <1> 	mov	ds, bx
   744                              <1> 	sub	bx, bx ; 0
   745                              <1> 	mov	ah, 4Eh
   746                              <1> 	mov	[bx], ax ; show current play buffer (1, 2)
   747                              <1> 	;pop	bx
   748                              <1> 	pop	ds
   749                              <1> 	retn
   750                              <1> 
   751                              <1> %endif
   752                              <1> 
   753                              <1> ; 08/11/2023
   754                              <1> ; 07/11/2023
   755                              <1> %if 1
   756                              <1> 
   757                              <1> loadFromFile:
   758                              <1> 	; 07/11/2023
   759                              <1> 
   760 000007E1 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
   761                              <1> 					; last of the file?
   762 000007E6 7402                <1> 	jz	short lff_0		; no
   763 000007E8 F9                  <1> 	stc
   764 000007E9 C3                  <1> 	retn
   765                              <1> 
   766                              <1> lff_0:
   767                              <1> 	; 08/11/2023
   768 000007EA 89C5                <1> 	mov	bp, ax ; save buffer segment
   769                              <1> 
   770 000007EC 8A0E[B01F]          <1> 	mov	cl, [fbs_shift]   
   771 000007F0 20C9                <1> 	and	cl, cl
   772 000007F2 7470                <1> 	jz	short lff_1 ; stereo, 16 bit
   773                              <1> 
   774 000007F4 BFFFFF              <1> 	mov	di, BUFFERSIZE - 1 ; 65535
   775                              <1> 
   776                              <1> 	; fbs_shift =
   777                              <1> 	;	2 for mono and 8 bit sample (multiplier = 4)
   778                              <1> 	;	1 for mono or 8 bit sample (multiplier = 2)
   779 000007F7 D3EF                <1> 	shr	di, cl
   780 000007F9 47                  <1> 	inc	di ; 16384 for 8 bit and mono
   781                              <1> 		   ; 32768 for 8 bit or mono
   782                              <1> 
   783 000007FA 8CC8                <1> 	mov	ax, cs
   784 000007FC BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
   785                              <1> 
   786                              <1> 	; 17/02/2017 (stereo/mono, 8bit/16bit corrections)
   787                              <1> 	; load file into memory
   788 000007FF 89F9                <1>         mov	cx, di
   789 00000801 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
   790 00000805 8ED8                <1> 	mov     ds, ax
   791 00000807 B43F                <1>        	mov	ah, 3Fh
   792 00000809 CD21                <1> 	int	21h
   793                              <1> 
   794 0000080B 8CCB                <1> 	mov	bx, cs
   795 0000080D 8EDB                <1> 	mov	ds, bx
   796                              <1> 
   797 0000080F 724A                <1> 	jc	short lff_4 ; error !
   798                              <1> 
   799                              <1> 	; 08/11/2023
   800 00000811 31D2                <1> 	xor	dx, dx ; 0
   801                              <1> 
   802 00000813 21C0                <1> 	and	ax, ax
   803 00000815 7476                <1> 	jz	short lff_3
   804                              <1> 
   805 00000817 8A1E[B01F]          <1> 	mov	bl, [fbs_shift]
   806                              <1> 
   807 0000081B 06                  <1> 	push	es
   808 0000081C 89D7                <1> 	mov	di, dx ; 0 ; [fbs_off]
   809                              <1> 	;mov	bp, [fbs_seg] ; buffer segment
   810 0000081E 8EC5                <1> 	mov	es, bp
   811 00000820 BE[B41F]            <1> 	mov	si, temp_buffer ; temporary buffer address
   812 00000823 89C1                <1> 	mov	cx, ax ; byte count
   813 00000825 803E[AE1F]08        <1> 	cmp	byte [bps], 8 ; bits per sample (8 or 16)
   814 0000082A 751B                <1> 	jne	short lff_7 ; 16 bit samples
   815                              <1> 	; 8 bit samples
   816 0000082C FECB                <1> 	dec	bl  ; shift count, 1 = stereo, 2 = mono
   817 0000082E 740C                <1> 	jz	short lff_6 ; 8 bit, stereo
   818                              <1> lff_5:
   819                              <1> 	; mono & 8 bit
   820 00000830 AC                  <1> 	lodsb
   821 00000831 2C80                <1> 	sub	al, 80h ; 08/11/2023
   822 00000833 C1E008              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   823 00000836 AB                  <1> 	stosw	; left channel
   824 00000837 AB                  <1> 	stosw	; right channel
   825 00000838 E2F6                <1> 	loop	lff_5
   826 0000083A EB12                <1> 	jmp	short lff_9
   827                              <1> lff_6:
   828                              <1> 	; stereo & 8 bit
   829 0000083C AC                  <1> 	lodsb
   830 0000083D 2C80                <1> 	sub	al, 80h ; 08/11/2023
   831 0000083F C1E008              <1> 	shl	ax, 8 ; convert 8 bit sample to 16 bit sample
   832 00000842 AB                  <1> 	stosw
   833 00000843 E2F7                <1> 	loop	lff_6
   834 00000845 EB07                <1> 	jmp	short lff_9
   835                              <1> lff_7:
   836 00000847 D1E9                <1> 	shr	cx, 1 ; word count
   837                              <1> lff_8:
   838 00000849 AD                  <1> 	lodsw
   839 0000084A AB                  <1> 	stosw	; left channel
   840 0000084B AB                  <1> 	stosw	; right channel
   841 0000084C E2FB                <1> 	loop	lff_8
   842                              <1> lff_9:
   843 0000084E 07                  <1> 	pop	es
   844 0000084F 09FF                <1> 	or	di, di
   845 00000851 7442                <1> 	jz	short endLFF ; 64KB ok 
   846                              <1> 	
   847 00000853 89F8                <1> 	mov	ax, di ; [fbs_off]
   848 00000855 48                  <1> 	dec	ax
   849 00000856 B9FFFF              <1> 	mov	cx, BUFFERSIZE - 1 ; 65535
   850 00000859 EB32                <1> 	jmp	short lff_3
   851                              <1> 
   852                              <1> lff_4:
   853                              <1> 	; 08/11/2023
   854 0000085B B021                <1> 	mov	al, '!'  ; error
   855 0000085D E871FF              <1> 	call	tL0
   856                              <1> 
   857 00000860 31C0                <1> 	xor	ax, ax
   858 00000862 EB29                <1> 	jmp	short lff_3
   859                              <1> 	
   860                              <1> lff_1:  
   861                              <1> 	;mov	bp, ax ; save buffer segment
   862 00000864 31D2                <1> 	xor	dx, dx
   863                              <1> 	; load file into memory
   864 00000866 B90080              <1>         mov	cx, (BUFFERSIZE / 2)	; 32k chunk
   865 00000869 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
   866 0000086D 8ED8                <1> 	mov     ds, ax
   867 0000086F B43F                <1>        	mov	ah, 3Fh
   868 00000871 CD21                <1> 	int	21h
   869                              <1> 
   870 00000873 8CCF                <1> 	mov	di, cs
   871 00000875 8EDF                <1> 	mov	ds, di
   872                              <1> 
   873                              <1> 	; 07/11/2023
   874 00000877 72E2                <1> 	jc	short lff_4 ; error !
   875                              <1> 	
   876 00000879 39C8                <1> 	cmp	ax, cx
   877 0000087B 7510                <1> 	jne	short lff_3
   878                              <1> lff_2:
   879                              <1> 	; 08/11/2023
   880 0000087D 01C2                <1> 	add	dx, ax
   881                              <1> 	;mov	cx, (BUFFERSIZE / 2)	; 32k chunk
   882                              <1> 	;mov	bx, [filehandle]
   883 0000087F 8EDD                <1> 	mov     ds, bp
   884 00000881 B43F                <1>        	mov	ah, 3Fh
   885 00000883 CD21                <1> 	int	21h
   886                              <1> 
   887                              <1> 	;mov	di, cs
   888 00000885 8EDF                <1> 	mov	ds, di
   889                              <1> 
   890 00000887 72D2                <1> 	jc	short lff_4 ; error !
   891                              <1> 
   892 00000889 39C8                <1> 	cmp	ax, cx
   893 0000088B 7408                <1> 	je	short endLFF
   894                              <1> lff_3:
   895 0000088D E80600              <1> 	call    padfill			; blank pad the remainder
   896                              <1>         ;clc				; don't exit with CY yet.
   897 00000890 800E[8E1F]01        <1>         or	byte [flags], ENDOFFILE	; end of file flag
   898                              <1> endLFF:
   899 00000895 C3                  <1>         retn
   900                              <1> 
   901                              <1> %endif
   902                              <1> 
   903                              <1> ; entry ds:ax points to last byte in file
   904                              <1> ; cx=target size
   905                              <1> ; note: must do byte size fill
   906                              <1> ; destroys bx, cx
   907                              <1> ;
   908                              <1> padfill:
   909                              <1> 	; 07/11/2023
   910                              <1> 	; 06/11/2023
   911                              <1> 	; 17/02/2017
   912 00000896 06                  <1> 	push	es
   913                              <1>         ;push	di
   914                              <1> 	;mov	di, [fbs_seg]
   915                              <1> 	;mov	es, di
   916 00000897 8EC5                <1>         mov	es, bp
   917 00000899 29C1                <1> 	sub	cx, ax
   918                              <1> 	; 08/11/2023
   919                              <1> 	;mov	di, ax ; (wrong)
   920 0000089B 89D7                <1> 	mov	di, dx ; buffer offset
   921 0000089D 01C7                <1> 	add	di, ax       	
   922                              <1> 	; 07/11/2023
   923                              <1> 	;add	di, [fbs_off]
   924 0000089F 30C0                <1>         xor	al, al
   925 000008A1 F3AA                <1> 	rep	stosb
   926                              <1> 	;mov	[fbs_off], di
   927                              <1> 	;pop	di
   928 000008A3 07                  <1>         pop	es
   929 000008A4 C3                  <1> 	retn
   930                              <1> 
   931                              <1> ; returns AL = current index value
   932                              <1> getCurrentIndex:
   933                              <1> 	; 08/11/2023
   934                              <1> 	;push	dx
   935 000008A5 8B16[9A1F]          <1> 	mov	dx, [NABMBAR]      		
   936 000008A9 83C214              <1> 	add	dx, PO_CIV_REG
   937 000008AC EC                  <1> 	in	al, dx
   938                              <1> 	;pop	dx
   939                              <1> uLVI2:	;	06/11/2023
   940 000008AD C3                  <1> 	retn
   941                              <1> 
   942                              <1> ; examines the CIV and the LVI. When they're the same, we set LVI <> CIV
   943                              <1> ; that way, we never run out of buffers to play
   944                              <1> 
   945                              <1> ; 08/11/2023
   946                              <1> ; 07/11/2023
   947                              <1> %if 0
   948                              <1> updateLVI:
   949                              <1> 	; 06/11/2023
   950                              <1> 	mov	dx, [NABMBAR]      		
   951                              <1> 	add	dx, PO_CIV_REG
   952                              <1> 	; (Current Index Value and Last Valid Index value)
   953                              <1> 	in	ax, dx
   954                              <1> 
   955                              <1> 	cmp	al, ah ; is current index = last index ?
   956                              <1> 	jne	short uLVI2
   957                              <1> 
   958                              <1> 	; 10/11/2023
   959                              <1> 	; 08/11/2023	
   960                              <1> 	call	getCurrentIndex
   961                              <1>  
   962                              <1> 	test	byte [flags], ENDOFFILE
   963                              <1> 	;jnz	short uLVI1
   964                              <1> 	jz	short uLVI0  ; 08/11/2023
   965                              <1> 
   966                              <1> 	; 08/11/2023
   967                              <1> 	push	ax
   968                              <1> 	mov	dx, [NABMBAR]
   969                              <1> 	add	dx, PO_SR_REG  ; PCM out status register
   970                              <1> 	in	ax, dx
   971                              <1> 
   972                              <1> 	;test	al, 2
   973                              <1> 	test	al, 3 ; bit 1 = Current Equals Last Valid (CELV)
   974                              <1> 		      ; (has been processed)
   975                              <1> 		      ; bit 0 = 1 -> DMA Controller Halted (DCH)
   976                              <1> 	pop	ax
   977                              <1> 	jz	short uLVI1
   978                              <1> uLVI3:
   979                              <1> 	xor	ax, ax
   980                              <1> 	; zf = 1
   981                              <1> 	retn
   982                              <1> uLVI0:
   983                              <1>         ; not at the end of the file yet.
   984                              <1> 	dec	al
   985                              <1> 	and	al, 1Fh
   986                              <1> uLVI1:
   987                              <1> 	;call	setLastValidIndex
   988                              <1> ;uLVI2:
   989                              <1> 	;retn
   990                              <1> 
   991                              <1> %endif
   992                              <1> 	
   993                              <1> ;input AL = index # to stop on
   994                              <1> setLastValidIndex:
   995                              <1> 	; 08/11/2023
   996                              <1> 	;push	dx
   997 000008AE 8B16[9A1F]          <1> 	mov	dx, [NABMBAR]
   998 000008B2 83C215              <1> 	add	dx, PO_LVI_REG
   999 000008B5 EE                  <1>         out     dx, al
  1000                              <1> 	; 18/11/2023
  1001 000008B6 A2[B21F]            <1> 	mov	[LVI], al
  1002                              <1> 	;pop	dx
  1003 000008B9 C3                  <1> 	retn
  1004                              <1> 
  1005                              <1> ; checks if either shift key has been pressed. Exits with CY if so.
  1006                              <1> ; 
  1007                              <1> check4keyboardstop:
  1008                              <1> 
  1009                              <1> ; 06/11/2023
  1010                              <1> %if 1
  1011                              <1> 	; 19/05/2024
  1012                              <1> 	; 08/11/2023
  1013                              <1> 	; 04/11/2023
  1014 000008BA B401                <1> 	mov	ah, 1
  1015 000008BC CD16                <1> 	int	16h
  1016                              <1> 	;clc
  1017 000008BE 7439                <1> 	jz	short _cksr
  1018                              <1> 
  1019 000008C0 30E4                <1> 	xor	ah, ah
  1020 000008C2 CD16                <1> 	int	16h
  1021                              <1> 
  1022                              <1> 	;;;
  1023                              <1> 	; 19/05/2024 (change PCM out volume)
  1024 000008C4 3C2B                <1> 	cmp	al, '+'
  1025 000008C6 750B                <1> 	jne	short p_1
  1026                              <1> 	
  1027 000008C8 A0[FD08]            <1> 	mov	al, [volume]
  1028 000008CB 3C00                <1> 	cmp	al, 0
  1029 000008CD 762B                <1> 	jna	short p_3
  1030 000008CF FEC8                <1> 	dec	al
  1031 000008D1 EB0D                <1> 	jmp	short p_2
  1032                              <1> p_1:
  1033 000008D3 3C2D                <1> 	cmp	al, '-'
  1034 000008D5 7524                <1> 	jne	short p_4
  1035                              <1> 
  1036 000008D7 A0[FD08]            <1> 	mov	al, [volume]
  1037 000008DA 3C1F                <1> 	cmp	al, 31
  1038 000008DC 731C                <1> 	jnb	short p_3
  1039 000008DE FEC0                <1> 	inc	al
  1040                              <1> p_2:
  1041 000008E0 A2[FD08]            <1> 	mov	[volume], al
  1042 000008E3 88C4                <1> 	mov	ah, al
  1043 000008E5 8B16[981F]          <1> 	mov     dx, [NAMBAR]
  1044                              <1>   	;add    dx, CODEC_MASTER_VOL_REG
  1045 000008E9 83C218              <1> 	add	dx, CODEC_PCM_OUT_REG
  1046 000008EC EF                  <1> 	out     dx, ax
  1047                              <1> 
  1048 000008ED E82712              <1> 	call    delay1_4ms
  1049 000008F0 E82412              <1>         call    delay1_4ms
  1050 000008F3 E82112              <1>         call    delay1_4ms
  1051 000008F6 E81E12              <1>         call    delay1_4ms
  1052                              <1> _cksr:		; 19/05/2024
  1053 000008F9 F8                  <1> 	clc
  1054                              <1> p_3:
  1055 000008FA C3                  <1> 	retn
  1056                              <1> p_4:
  1057                              <1> 	;;;
  1058                              <1> ;_cskr:	
  1059 000008FB F9                  <1> 	stc
  1060 000008FC C3                  <1> 	retn
  1061                              <1> 
  1062                              <1> ; 19/05/2024
  1063 000008FD 02                  <1> volume:	db 02h
  1064                              <1> 
  1065                              <1> %endif
  1066                              <1> 
  1067                              <1> ; 02/02/2025
  1068                              <1> ; 30/05/2024 (playwav6.asm)
  1069                              <1> ; 18/11/2023 (ich_wav3.asm & ich_wav4.asm)
  1070                              <1> ; 15/11/2023 (ich_wav3.asm)	
  1071                              <1> ; 14/11/2023
  1072                              <1> ; 13/11/2023 - Erdogan Tan - (VRA, sample rate conversion)
  1073                              <1> ; --------------------------------------------------------
  1074                              <1> 
  1075                              <1> ;;Note:	At the end of every buffer load,
  1076                              <1> ;;	during buffer switch/swap, there will be discontinuity
  1077                              <1> ;;	between the last converted sample and the 1st sample
  1078                              <1> ;;	of the next buffer.
  1079                              <1> ;;	(like as a dot noises vaguely between normal sound samples)
  1080                              <1> ;;	-To avoid this defect, the 1st sample of
  1081                              <1> ;;	the next buffer may be read from the wav file but
  1082                              <1> ;;	the file pointer would need to be set to 1 sample back
  1083                              <1> ;;	again via seek system call. Time comsumption problem! -
  1084                              <1> ;;
  1085                              <1> ;;	Erdogan Tan - 15/11/2023
  1086                              <1> ;;
  1087                              <1> ;;	((If entire wav data would be loaded at once.. conversion
  1088                              <1> ;;	defect/noise would disappear.. but for DOS, to keep
  1089                              <1> ;;	64KB buffer limit is important also it is important
  1090                              <1> ;;	for running under 1MB barrier without HIMEM.SYS or DPMI.
  1091                              <1> ;;	I have tested this program by using 2-30MB wav files.))
  1092                              <1> ;;
  1093                              <1> ;;	Test Computer:	ASUS desktop/mainboard, M2N4-SLI, 2010.
  1094                              <1> ;;			AMD Athlon 64 X2 2200 MHZ CPU.
  1095                              <1> ;;		       	NFORCE4 (CK804) AC97 audio hardware.
  1096                              <1> ;;			Realtek ALC850 codec.
  1097                              <1> ;;		       	Retro DOS v4.2 (MSDOS 6.22) operating system.
  1098                              <1> 
  1099                              <1> load_8khz_mono_8_bit:
  1100                              <1> 	; 02/02/2025
  1101                              <1> 	; 15/11/2023
  1102                              <1> 	; 14/11/2023
  1103                              <1> 	; 13/11/2023
  1104 000008FE F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1105                              <1> 					; last of the file?
  1106 00000903 7402                <1> 	jz	short lff8m_0		; no
  1107 00000905 F9                  <1> 	stc
  1108 00000906 C3                  <1> 	retn
  1109                              <1> 
  1110                              <1> lff8m_0:
  1111 00000907 8EC0                <1> 	mov	es, ax ; buffer segment
  1112 00000909 31FF                <1> 	xor	di, di
  1113 0000090B BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1114                              <1> 	; ds = cs
  1115                              <1> 
  1116                              <1> 	; load file into memory
  1117 0000090E 8B0E[B906]          <1>         mov	cx, [loadsize]
  1118 00000912 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1119 00000916 B43F                <1>        	mov	ah, 3Fh
  1120 00000918 CD21                <1> 	int	21h
  1121                              <1> 	;jc	short lff8m_5 ; error !
  1122                              <1> 	; 14/11/2023
  1123 0000091A 7303                <1> 	jnc	short lff8m_6
  1124 0000091C E98B00              <1> 	jmp	lff8m_5
  1125                              <1> 
  1126                              <1> lff8m_6:
  1127 0000091F 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1128 00000921 21C0                <1> 	and	ax, ax
  1129                              <1> 	;jz	short lff8m_3
  1130                              <1> 	; 15/11/2023
  1131 00000923 747E                <1> 	jz	short lff8_eof
  1132                              <1> 
  1133 00000925 89C1                <1> 	mov	cx, ax	; byte count
  1134                              <1> lff8m_1:
  1135 00000927 AC                  <1> 	lodsb
  1136 00000928 A2[0E1B]            <1> 	mov	[previous_val], al
  1137 0000092B 2C80                <1> 	sub	al, 80h
  1138 0000092D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1139 00000930 AB                  <1> 	stosw		; original sample (left channel)
  1140 00000931 AB                  <1> 	stosw		; original sample (right channel)
  1141                              <1> 	;xor	ax, ax
  1142                              <1> 	; 02/02/2025
  1143 00000932 8A04                <1> 	mov	al, [si]
  1144 00000934 49                  <1> 	dec	cx
  1145 00000935 7502                <1> 	jnz	short lff8m_2
  1146                              <1> 	; 14/11/2023
  1147 00000937 B080                <1> 	mov	al, 80h
  1148                              <1> lff8m_2:
  1149                              <1> 	;mov	[next_val], ax
  1150 00000939 88C7                <1> 	mov	bh, al	; [next_val]
  1151 0000093B 8A26[0E1B]          <1> 	mov	ah, [previous_val]
  1152 0000093F 00E0                <1> 	add	al, ah	; [previous_val]
  1153 00000941 D0D8                <1> 	rcr	al, 1
  1154 00000943 88C2                <1> 	mov	dl, al	; this is interpolated middle (3th) sample
  1155 00000945 00E0                <1> 	add	al, ah	; [previous_val]
  1156 00000947 D0D8                <1> 	rcr	al, 1	
  1157 00000949 88C3                <1> 	mov	bl, al 	; this is temporary interpolation value	
  1158 0000094B 00E0                <1> 	add	al, ah	; [previous_val]
  1159 0000094D D0D8                <1> 	rcr	al, 1
  1160 0000094F 2C80                <1> 	sub	al, 80h
  1161 00000951 C1E008              <1> 	shl	ax, 8
  1162 00000954 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1163 00000955 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1164 00000956 88D8                <1> 	mov	al, bl
  1165 00000958 00D0                <1> 	add	al, dl
  1166 0000095A D0D8                <1> 	rcr	al, 1
  1167 0000095C 2C80                <1> 	sub	al, 80h
  1168 0000095E C1E008              <1> 	shl	ax, 8
  1169 00000961 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1170 00000962 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1171 00000963 88D0                <1> 	mov	al, dl
  1172 00000965 2C80                <1> 	sub	al, 80h
  1173 00000967 C1E008              <1> 	shl	ax, 8
  1174 0000096A AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1175 0000096B AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1176                              <1> 	;mov	al, [next_val]
  1177 0000096C 88F8                <1> 	mov	al, bh
  1178 0000096E 00D0                <1> 	add	al, dl
  1179 00000970 D0D8                <1> 	rcr	al, 1
  1180 00000972 88C3                <1> 	mov	bl, al	; this is temporary interpolation value
  1181 00000974 00D0                <1> 	add	al, dl
  1182 00000976 D0D8                <1> 	rcr	al, 1
  1183 00000978 2C80                <1> 	sub	al, 80h
  1184 0000097A C1E008              <1> 	shl	ax, 8
  1185 0000097D AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1186 0000097E AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1187                              <1> 	;mov	al, [next_val]
  1188 0000097F 88F8                <1> 	mov	al, bh
  1189 00000981 00D8                <1> 	add	al, bl
  1190 00000983 D0D8                <1> 	rcr	al, 1
  1191 00000985 2C80                <1> 	sub	al, 80h
  1192 00000987 C1E008              <1> 	shl	ax, 8
  1193 0000098A AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1194 0000098B AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1195                              <1> 	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1196 0000098C 09C9                <1> 	or	cx, cx
  1197 0000098E 7597                <1> 	jnz	short lff8m_1
  1198                              <1> 
  1199                              <1> 	; --------------
  1200                              <1> 
  1201                              <1> lff8s_3:
  1202                              <1> lff8m_3:
  1203                              <1> lff8s2_3:
  1204                              <1> lff8m2_3:
  1205                              <1> lff16s_3:
  1206                              <1> lff16m_3:
  1207                              <1> lff16s2_3:
  1208                              <1> lff16m2_3:
  1209                              <1> lff24_3:
  1210                              <1> lff32_3:
  1211                              <1> lff44_3:
  1212                              <1> lff22_3:
  1213                              <1> lff11_3:
  1214                              <1> lff12_3:	; 02/02/2025
  1215 00000990 8B0E[BB06]          <1> 	mov	cx, [buffersize] ; 16 bit (48 kHZ, stereo) sample size
  1216 00000994 D1E1                <1> 	shl	cx, 1	; byte count
  1217 00000996 29F9                <1> 	sub	cx, di
  1218 00000998 7606                <1> 	jna	short lff8m_4
  1219                              <1> 	;inc	cx
  1220 0000099A D1E9                <1> 	shr	cx, 1
  1221 0000099C 31C0                <1> 	xor	ax, ax	; fill (remain part of) buffer with zeros
  1222 0000099E F3AB                <1> 	rep	stosw
  1223                              <1> lff8m_4:
  1224 000009A0 0E                  <1> 	push	cs
  1225 000009A1 07                  <1> 	pop	es
  1226 000009A2 C3                  <1> 	retn
  1227                              <1> 
  1228                              <1> lff8_eof:
  1229                              <1> lff16_eof:
  1230                              <1> lff24_eof:
  1231                              <1> lff32_eof:
  1232                              <1> lff44_eof:
  1233                              <1> lff22_eof:
  1234                              <1> lff11_eof:
  1235                              <1> lff12_eof:	; 02/02/2025
  1236                              <1> 	; 15/11/2023
  1237 000009A3 C606[8E1F]01        <1> 	mov	byte [flags], ENDOFFILE
  1238 000009A8 EBE6                <1> 	jmp	short lff8m_3
  1239                              <1> 
  1240                              <1> lff8s_5:
  1241                              <1> lff8m_5:
  1242                              <1> lff8s2_5:
  1243                              <1> lff8m2_5:
  1244                              <1> lff16s_5:
  1245                              <1> lff16m_5:
  1246                              <1> lff16s2_5:
  1247                              <1> lff16m2_5:
  1248                              <1> lff24_5:
  1249                              <1> lff32_5:
  1250                              <1> lff44_5:
  1251                              <1> lff22_5:
  1252                              <1> lff11_5:
  1253                              <1> lff12_5:	; 02/02/2025
  1254 000009AA B021                <1> 	mov	al, '!'  ; error
  1255 000009AC E822FE              <1> 	call	tL0
  1256                              <1> 	
  1257                              <1> 	;jmp	short lff8m_3
  1258                              <1> 	; 15/11/2023
  1259 000009AF EBF2                <1> 	jmp	lff8_eof
  1260                              <1> 
  1261                              <1> 	; --------------
  1262                              <1> 
  1263                              <1> load_8khz_stereo_8_bit:
  1264                              <1> 	; 02/02/2025
  1265                              <1> 	; 15/11/2023
  1266                              <1> 	; 14/11/2023
  1267                              <1> 	; 13/11/2023
  1268 000009B1 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1269                              <1> 					; last of the file?
  1270 000009B6 7402                <1> 	jz	short lff8s_0		; no
  1271 000009B8 F9                  <1> 	stc
  1272 000009B9 C3                  <1> 	retn
  1273                              <1> 
  1274                              <1> lff8s_0:
  1275 000009BA 8EC0                <1> 	mov	es, ax ; buffer segment
  1276 000009BC 31FF                <1> 	xor	di, di
  1277 000009BE BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1278                              <1> 	; ds = cs
  1279                              <1> 
  1280                              <1> 	; load file into memory
  1281 000009C1 8B0E[B906]          <1>         mov	cx, [loadsize]
  1282 000009C5 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1283 000009C9 B43F                <1>        	mov	ah, 3Fh
  1284 000009CB CD21                <1> 	int	21h
  1285 000009CD 72DB                <1> 	jc	short lff8s_5 ; error !
  1286                              <1> 
  1287 000009CF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1288                              <1> 	
  1289 000009D1 D1E8                <1> 	shr	ax, 1
  1290                              <1> 	;;and	ax, ax
  1291                              <1> 	;jz	short lff8s_3
  1292                              <1> 	; 15/11/2023
  1293 000009D3 74CE                <1> 	jz	short lff8_eof
  1294                              <1> 
  1295 000009D5 89C1                <1> 	mov	cx, ax	; word count
  1296                              <1> lff8s_1:
  1297 000009D7 AC                  <1> 	lodsb
  1298 000009D8 A2[0E1B]            <1> 	mov	[previous_val_l], al
  1299 000009DB 2C80                <1> 	sub	al, 80h
  1300 000009DD C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1301 000009E0 AB                  <1> 	stosw		; original sample (L)
  1302 000009E1 AC                  <1> 	lodsb
  1303 000009E2 A2[101B]            <1> 	mov	[previous_val_r], al
  1304 000009E5 2C80                <1> 	sub	al, 80h
  1305 000009E7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1306 000009EA AB                  <1> 	stosw		; original sample (R)
  1307                              <1> 
  1308                              <1> 	;xor	ax, ax
  1309                              <1> 	; 02/02/2025
  1310 000009EB 8B04                <1> 	mov	ax, [si]
  1311 000009ED 49                  <1> 	dec	cx
  1312 000009EE 7503                <1> 	jnz	short lff8s_2
  1313                              <1> 		; convert 8 bit sample to 16 bit sample
  1314                              <1> 	; 14/11/2023
  1315 000009F0 B88080              <1> 	mov	ax, 8080h
  1316                              <1> lff8s_2:
  1317 000009F3 A2[121B]            <1> 	mov	[next_val_l], al
  1318 000009F6 8826[141B]          <1> 	mov	[next_val_r], ah
  1319 000009FA 8A26[0E1B]          <1> 	mov	ah, [previous_val_l]
  1320 000009FE 00E0                <1> 	add	al, ah
  1321 00000A00 D0D8                <1> 	rcr	al, 1
  1322 00000A02 88C2                <1> 	mov	dl, al	; this is interpolated middle (3th) sample (L)
  1323 00000A04 00E0                <1> 	add	al, ah
  1324 00000A06 D0D8                <1> 	rcr	al, 1	
  1325 00000A08 88C3                <1> 	mov	bl, al	; this is temporary interpolation value (L)
  1326 00000A0A 00E0                <1> 	add	al, ah
  1327 00000A0C D0D8                <1> 	rcr	al, 1
  1328 00000A0E 2C80                <1> 	sub	al, 80h
  1329 00000A10 C1E008              <1> 	shl	ax, 8
  1330 00000A13 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1331 00000A14 A0[141B]            <1> 	mov	al, [next_val_r]
  1332 00000A17 8A26[101B]          <1> 	mov	ah, [previous_val_r]
  1333 00000A1B 00E0                <1> 	add	al, ah
  1334 00000A1D D0D8                <1> 	rcr	al, 1
  1335 00000A1F 88C6                <1> 	mov	dh, al	; this is interpolated middle (3th) sample (R)
  1336 00000A21 00E0                <1> 	add	al, ah
  1337 00000A23 D0D8                <1> 	rcr	al, 1
  1338 00000A25 88C7                <1> 	mov	bh, al	; this is temporary interpolation value (R)
  1339 00000A27 00E0                <1> 	add	al, ah
  1340 00000A29 D0D8                <1> 	rcr	al, 1
  1341 00000A2B 2C80                <1> 	sub	al, 80h
  1342 00000A2D C1E008              <1> 	shl	ax, 8
  1343 00000A30 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1344 00000A31 88D8                <1> 	mov	al, bl
  1345 00000A33 00D0                <1> 	add	al, dl
  1346 00000A35 D0D8                <1> 	rcr	al, 1
  1347 00000A37 2C80                <1> 	sub	al, 80h
  1348 00000A39 C1E008              <1> 	shl	ax, 8
  1349 00000A3C AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1350 00000A3D 88F8                <1> 	mov	al, bh
  1351 00000A3F 00F0                <1> 	add	al, dh
  1352 00000A41 D0D8                <1> 	rcr	al, 1
  1353 00000A43 2C80                <1> 	sub	al, 80h
  1354 00000A45 C1E008              <1> 	shl	ax, 8
  1355 00000A48 AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1356 00000A49 88D0                <1> 	mov	al, dl
  1357 00000A4B 2C80                <1> 	sub	al, 80h
  1358 00000A4D C1E008              <1> 	shl	ax, 8
  1359 00000A50 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1360 00000A51 88F0                <1> 	mov	al, dh
  1361 00000A53 2C80                <1> 	sub	al, 80h
  1362 00000A55 C1E008              <1> 	shl	ax, 8
  1363 00000A58 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1364 00000A59 A0[121B]            <1> 	mov	al, [next_val_l]
  1365 00000A5C 00D0                <1> 	add	al, dl
  1366 00000A5E D0D8                <1> 	rcr	al, 1
  1367 00000A60 88C3                <1> 	mov	bl, al	; this is temporary interpolation value (L)
  1368 00000A62 00D0                <1> 	add	al, dl
  1369 00000A64 D0D8                <1> 	rcr	al, 1
  1370 00000A66 2C80                <1> 	sub	al, 80h
  1371 00000A68 C1E008              <1> 	shl	ax, 8
  1372 00000A6B AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1373 00000A6C A0[141B]            <1> 	mov	al, [next_val_r]
  1374 00000A6F 00F0                <1> 	add	al, dh
  1375 00000A71 D0D8                <1> 	rcr	al, 1
  1376 00000A73 88C7                <1> 	mov	bh, al	; this is temporary interpolation value (R)
  1377 00000A75 00F0                <1> 	add	al, dh
  1378 00000A77 D0D8                <1> 	rcr	al, 1
  1379 00000A79 2C80                <1> 	sub	al, 80h
  1380 00000A7B C1E008              <1> 	shl	ax, 8
  1381 00000A7E AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1382 00000A7F A0[121B]            <1> 	mov	al, [next_val_l]
  1383 00000A82 00D8                <1> 	add	al, bl
  1384 00000A84 D0D8                <1> 	rcr	al, 1
  1385 00000A86 2C80                <1> 	sub	al, 80h
  1386 00000A88 C1E008              <1> 	shl	ax, 8
  1387 00000A8B AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1388 00000A8C A0[141B]            <1> 	mov	al, [next_val_r]
  1389 00000A8F 00F8                <1> 	add	al, bh
  1390 00000A91 D0D8                <1> 	rcr	al, 1
  1391 00000A93 2C80                <1> 	sub	al, 80h
  1392 00000A95 C1E008              <1> 	shl	ax, 8
  1393 00000A98 AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1394                              <1> 	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1395 00000A99 E303                <1> 	jcxz	lff8s_6
  1396 00000A9B E939FF              <1> 	jmp	lff8s_1
  1397                              <1> lff8s_6:
  1398 00000A9E E9EFFE              <1> 	jmp	lff8s_3
  1399                              <1> 
  1400                              <1> load_8khz_mono_16_bit:
  1401                              <1> 	; 02/02/2025
  1402                              <1> 	; 13/11/2023
  1403 00000AA1 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1404                              <1> 					; last of the file?
  1405 00000AA6 7402                <1> 	jz	short lff8m2_0		; no
  1406 00000AA8 F9                  <1> 	stc
  1407 00000AA9 C3                  <1> 	retn
  1408                              <1> 
  1409                              <1> lff8m2_0:
  1410 00000AAA 8EC0                <1> 	mov	es, ax ; buffer segment
  1411 00000AAC 31FF                <1> 	xor	di, di
  1412 00000AAE BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1413                              <1> 	; ds = cs
  1414                              <1> 
  1415                              <1> 	; load file into memory
  1416 00000AB1 8B0E[B906]          <1>         mov	cx, [loadsize]
  1417 00000AB5 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1418 00000AB9 B43F                <1>        	mov	ah, 3Fh
  1419 00000ABB CD21                <1> 	int	21h
  1420 00000ABD 7270                <1> 	jc	short lff8m2_7 ; error !
  1421                              <1> 
  1422 00000ABF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1423                              <1> 	
  1424 00000AC1 D1E8                <1> 	shr	ax, 1
  1425                              <1> 	;and	ax, ax
  1426 00000AC3 7503                <1> 	jnz	short lff8m2_8
  1427                              <1> 	;jmp	lff8m2_3
  1428                              <1> 	; 15/11/2023
  1429 00000AC5 E9DBFE              <1> 	jmp	lff8_eof
  1430                              <1> 
  1431                              <1> lff8m2_8:
  1432 00000AC8 89C1                <1> 	mov	cx, ax	; word count
  1433                              <1> lff8m2_1:
  1434 00000ACA AD                  <1> 	lodsw
  1435 00000ACB AB                  <1> 	stosw		; original sample (left channel)
  1436 00000ACC AB                  <1> 	stosw		; original sample (right channel)
  1437 00000ACD 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1438 00000AD0 A3[0E1B]            <1> 	mov	[previous_val], ax
  1439                              <1> 	; 02/02/2025
  1440 00000AD3 8B04                <1> 	mov	ax, [si]
  1441 00000AD5 49                  <1> 	dec	cx
  1442 00000AD6 7502                <1> 	jnz	short lff8m2_2
  1443 00000AD8 31C0                <1> 	xor	ax, ax
  1444                              <1> lff8m2_2:
  1445 00000ADA 80C480              <1> 	add	ah, 80h ; convert sound level to 0-65535 format
  1446 00000ADD 89C5                <1> 	mov	bp, ax	; [next_val]
  1447 00000ADF 0306[0E1B]          <1> 	add	ax, [previous_val]
  1448 00000AE3 D1D8                <1> 	rcr	ax, 1
  1449 00000AE5 89C2                <1> 	mov	dx, ax	; this is interpolated middle (3th) sample
  1450 00000AE7 0306[0E1B]          <1> 	add	ax, [previous_val]
  1451 00000AEB D1D8                <1> 	rcr	ax, 1	; this is temporary interpolation value
  1452 00000AED 89C3                <1> 	mov	bx, ax 		
  1453 00000AEF 0306[0E1B]          <1> 	add	ax, [previous_val]
  1454 00000AF3 D1D8                <1> 	rcr	ax, 1
  1455 00000AF5 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1456 00000AF8 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1457 00000AF9 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1458 00000AFA 89D8                <1> 	mov	ax, bx
  1459 00000AFC 01D0                <1> 	add	ax, dx
  1460 00000AFE D1D8                <1> 	rcr	ax, 1
  1461 00000B00 80EC80              <1> 	sub	ah, 80h
  1462 00000B03 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1463 00000B04 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1464 00000B05 89D0                <1> 	mov	ax, dx
  1465 00000B07 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1466 00000B0A AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1467 00000B0B AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1468 00000B0C 89E8                <1> 	mov	ax, bp
  1469 00000B0E 01D0                <1> 	add	ax, dx
  1470 00000B10 D1D8                <1> 	rcr	ax, 1
  1471 00000B12 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value
  1472 00000B14 01D0                <1> 	add	ax, dx
  1473 00000B16 D1D8                <1> 	rcr	ax, 1
  1474 00000B18 80EC80              <1> 	sub	ah, 80h
  1475 00000B1B AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1476 00000B1C AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1477 00000B1D 89E8                <1> 	mov	ax, bp
  1478 00000B1F 01D8                <1> 	add	ax, bx
  1479 00000B21 D1D8                <1> 	rcr	ax, 1
  1480 00000B23 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1481 00000B26 AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1482 00000B27 AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1483                              <1> 	; 8 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1484 00000B28 09C9                <1> 	or	cx, cx
  1485 00000B2A 759E                <1> 	jnz	short lff8m2_1
  1486 00000B2C E961FE              <1> 	jmp	lff8m2_3
  1487                              <1> 
  1488                              <1> lff8m2_7:
  1489                              <1> lff8s2_7:
  1490 00000B2F E978FE              <1> 	jmp	lff8m2_5  ; error
  1491                              <1> 
  1492                              <1> load_8khz_stereo_16_bit:
  1493                              <1> 	; 02/02/2025
  1494                              <1> 	; 16/11/2023
  1495                              <1> 	; 15/11/2023
  1496                              <1> 	; 13/11/2023
  1497 00000B32 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1498                              <1> 					; last of the file?
  1499 00000B37 7402                <1> 	jz	short lff8s2_0		; no
  1500 00000B39 F9                  <1> 	stc
  1501 00000B3A C3                  <1> 	retn
  1502                              <1> 
  1503                              <1> lff8s2_0:
  1504 00000B3B 8EC0                <1> 	mov	es, ax ; buffer segment
  1505 00000B3D 31FF                <1> 	xor	di, di
  1506 00000B3F BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1507                              <1> 	; ds = cs
  1508                              <1> 
  1509                              <1> 	; load file into memory
  1510 00000B42 8B0E[B906]          <1>         mov	cx, [loadsize]
  1511 00000B46 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1512 00000B4A B43F                <1>        	mov	ah, 3Fh
  1513 00000B4C CD21                <1> 	int	21h
  1514 00000B4E 72DF                <1> 	jc	short lff8s2_7 ; error !
  1515                              <1> 
  1516 00000B50 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1517                              <1> 	
  1518 00000B52 C1E802              <1> 	shr	ax, 2	; 16/11/2023
  1519                              <1> 	;and	ax, ax
  1520 00000B55 7503                <1> 	jnz	short lff8s2_8
  1521                              <1> 	;jmp	lff8s2_3
  1522                              <1> 	; 15/11/2023
  1523 00000B57 E949FE              <1> 	jmp	lff8_eof
  1524                              <1> 
  1525                              <1> lff8s2_8:
  1526 00000B5A 89C1                <1> 	mov	cx, ax ; dword count
  1527                              <1> lff8s2_1:
  1528 00000B5C AD                  <1> 	lodsw
  1529 00000B5D AB                  <1> 	stosw		; original sample (L)
  1530                              <1> 	; 15/11/2023
  1531 00000B5E 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1532 00000B61 A3[0E1B]            <1> 	mov	[previous_val_l], ax
  1533 00000B64 AD                  <1> 	lodsw
  1534 00000B65 AB                  <1> 	stosw		; original sample (R)
  1535 00000B66 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1536 00000B69 A3[101B]            <1> 	mov	[previous_val_r], ax
  1537                              <1> 	; 02/02/2025
  1538 00000B6C 8B04                <1> 	mov	ax, [si]
  1539 00000B6E 8B5402              <1> 	mov	dx, [si+2]
  1540                              <1> 	; 16/11/2023
  1541 00000B71 49                  <1> 	dec	cx
  1542 00000B72 7504                <1> 	jnz	short lff8s2_2
  1543 00000B74 31D2                <1> 	xor	dx, dx
  1544 00000B76 31C0                <1> 	xor	ax, ax
  1545                              <1> lff8s2_2:
  1546 00000B78 80C480              <1> 	add	ah, 80h	; convert sound level to 0-65535 format
  1547 00000B7B A3[121B]            <1> 	mov	[next_val_l], ax
  1548 00000B7E 80C680              <1> 	add	dh, 80h	; convert sound level to 0-65535 format
  1549 00000B81 8916[141B]          <1> 	mov	[next_val_r], dx
  1550 00000B85 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  1551 00000B89 D1D8                <1> 	rcr	ax, 1
  1552 00000B8B 89C2                <1> 	mov	dx, ax	; this is interpolated middle (3th) sample (L)
  1553 00000B8D 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  1554 00000B91 D1D8                <1> 	rcr	ax, 1	
  1555 00000B93 89C3                <1> 	mov	bx, ax 	; this is temporary interpolation value (L)
  1556 00000B95 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  1557 00000B99 D1D8                <1> 	rcr	ax, 1
  1558 00000B9B 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1559 00000B9E AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1560 00000B9F A1[141B]            <1> 	mov	ax, [next_val_r]
  1561 00000BA2 0306[101B]          <1> 	add	ax, [previous_val_r]
  1562 00000BA6 D1D8                <1> 	rcr	ax, 1
  1563 00000BA8 89C5                <1> 	mov	bp, ax	; this is interpolated middle (3th) sample (R)
  1564 00000BAA 0306[101B]          <1> 	add	ax, [previous_val_r]
  1565 00000BAE D1D8                <1> 	rcr	ax, 1
  1566 00000BB0 50                  <1> 	push	ax ; *	; this is temporary interpolation value (R)
  1567 00000BB1 0306[101B]          <1> 	add	ax, [previous_val_r]
  1568 00000BB5 D1D8                <1> 	rcr	ax, 1
  1569 00000BB7 80EC80              <1> 	sub	ah, 80h
  1570 00000BBA AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1571 00000BBB 89D8                <1> 	mov	ax, bx
  1572 00000BBD 01D0                <1> 	add	ax, dx
  1573 00000BBF D1D8                <1> 	rcr	ax, 1
  1574 00000BC1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1575 00000BC4 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1576 00000BC5 58                  <1> 	pop	ax ; *
  1577 00000BC6 01E8                <1> 	add	ax, bp
  1578 00000BC8 D1D8                <1> 	rcr	ax, 1
  1579 00000BCA 80EC80              <1> 	sub	ah, 80h
  1580 00000BCD AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1581 00000BCE 89D0                <1> 	mov	ax, dx
  1582 00000BD0 80EC80              <1> 	sub	ah, 80h
  1583 00000BD3 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (L)
  1584 00000BD4 89E8                <1> 	mov	ax, bp
  1585 00000BD6 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1586 00000BD9 AB                  <1> 	stosw		; this is middle (3th) interpolated sample (R)
  1587 00000BDA A1[121B]            <1> 	mov	ax, [next_val_l]
  1588 00000BDD 01D0                <1> 	add	ax, dx
  1589 00000BDF D1D8                <1> 	rcr	ax, 1
  1590 00000BE1 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value (L)
  1591 00000BE3 01D0                <1> 	add	ax, dx
  1592 00000BE5 D1D8                <1> 	rcr	ax, 1
  1593 00000BE7 80EC80              <1> 	sub	ah, 80h
  1594 00000BEA AB                  <1> 	stosw		; this is 4th interpolated sample (L)
  1595 00000BEB A1[141B]            <1> 	mov	ax, [next_val_r]
  1596 00000BEE 01E8                <1> 	add	ax, bp
  1597 00000BF0 D1D8                <1> 	rcr	ax, 1
  1598 00000BF2 50                  <1> 	push	ax ; ** ; this is temporary interpolation value (R)
  1599 00000BF3 01E8                <1> 	add	ax, bp
  1600 00000BF5 D1D8                <1> 	rcr	ax, 1
  1601 00000BF7 80EC80              <1> 	sub	ah, 80h
  1602 00000BFA AB                  <1> 	stosw		; this is 4th interpolated sample (R)
  1603 00000BFB A1[121B]            <1> 	mov	ax, [next_val_l]
  1604 00000BFE 01D8                <1> 	add	ax, bx
  1605 00000C00 D1D8                <1> 	rcr	ax, 1
  1606 00000C02 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1607 00000C05 AB                  <1> 	stosw		; this is 5th interpolated sample (L)
  1608 00000C06 58                  <1> 	pop	ax ; **
  1609 00000C07 0306[141B]          <1> 	add	ax, [next_val_r]
  1610 00000C0B D1D8                <1> 	rcr	ax, 1
  1611 00000C0D 80EC80              <1> 	sub	ah, 80h
  1612 00000C10 AB                  <1> 	stosw		; this is 5th interpolated sample (R)
  1613                              <1> 	; 8 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1614 00000C11 E303                <1> 	jcxz	lff8_s2_9
  1615 00000C13 E946FF              <1> 	jmp	lff8s2_1
  1616                              <1> lff8_s2_9:
  1617 00000C16 E977FD              <1> 	jmp	lff8s2_3
  1618                              <1> 
  1619                              <1> ; .....................
  1620                              <1> 
  1621                              <1> load_16khz_mono_8_bit:
  1622                              <1> 	; 02/02/2025
  1623                              <1> 	; 14/11/2023
  1624                              <1> 	; 13/11/2023
  1625 00000C19 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1626                              <1> 					; last of the file?
  1627 00000C1E 7402                <1> 	jz	short lff16m_0		; no
  1628 00000C20 F9                  <1> 	stc
  1629 00000C21 C3                  <1> 	retn
  1630                              <1> 
  1631                              <1> lff16m_0:
  1632 00000C22 8EC0                <1> 	mov	es, ax ; buffer segment
  1633 00000C24 31FF                <1> 	xor	di, di
  1634 00000C26 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1635                              <1> 	; ds = cs
  1636                              <1> 
  1637                              <1> 	; load file into memory
  1638 00000C29 8B0E[B906]          <1>         mov	cx, [loadsize]
  1639 00000C2D 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1640 00000C31 B43F                <1>        	mov	ah, 3Fh
  1641 00000C33 CD21                <1> 	int	21h
  1642 00000C35 7243                <1> 	jc	short lff16m_7 ; error !
  1643                              <1> 
  1644 00000C37 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1645                              <1> 	
  1646 00000C39 21C0                <1> 	and	ax, ax
  1647 00000C3B 7503                <1> 	jnz	short lff16m_8
  1648                              <1> 	;jmp	lff16m_3
  1649                              <1> 	; 15/11/2023
  1650 00000C3D E963FD              <1> 	jmp	lff16_eof
  1651                              <1> 
  1652                              <1> lff16m_8:
  1653 00000C40 89C1                <1> 	mov	cx, ax	; byte count
  1654                              <1> lff16m_1:
  1655 00000C42 AC                  <1> 	lodsb
  1656                              <1> 	;mov	[previous_val], al
  1657 00000C43 88C3                <1> 	mov	bl, al
  1658 00000C45 2C80                <1> 	sub	al, 80h
  1659 00000C47 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1660 00000C4A AB                  <1> 	stosw		; original sample (left channel)
  1661 00000C4B AB                  <1> 	stosw		; original sample (right channel)
  1662                              <1> 	;xor	ax, ax
  1663                              <1> 	; 02/02/2025
  1664 00000C4C 8A04                <1> 	mov	al, [si]
  1665 00000C4E 49                  <1> 	dec	cx
  1666 00000C4F 7502                <1> 	jnz	short lff16m_2
  1667                              <1> 	; 14/11/2023
  1668 00000C51 B080                <1> 	mov	al, 80h
  1669                              <1> lff16m_2:
  1670                              <1> 	;mov	[next_val], al
  1671 00000C53 88C7                <1> 	mov	bh, al
  1672                              <1> 	;add	al, [previous_val]
  1673 00000C55 00D8                <1> 	add	al, bl
  1674 00000C57 D0D8                <1> 	rcr	al, 1
  1675 00000C59 88C2                <1> 	mov	dl, al	; this is interpolated middle (temp) sample
  1676                              <1> 	;add	al, [previous_val]
  1677 00000C5B 00D8                <1> 	add	al, bl
  1678 00000C5D D0D8                <1> 	rcr	al, 1
  1679 00000C5F 2C80                <1> 	sub	al, 80h
  1680 00000C61 C1E008              <1> 	shl	ax, 8
  1681 00000C64 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1682 00000C65 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1683                              <1> 	;mov	al, [next_val]
  1684 00000C66 88F8                <1> 	mov	al, bh
  1685 00000C68 00D0                <1> 	add	al, dl
  1686 00000C6A D0D8                <1> 	rcr	al, 1
  1687 00000C6C 2C80                <1> 	sub	al, 80h
  1688 00000C6E C1E008              <1> 	shl	ax, 8
  1689 00000C71 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1690 00000C72 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1691                              <1> 	
  1692                              <1> 	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1693 00000C73 09C9                <1> 	or	cx, cx
  1694 00000C75 75CB                <1> 	jnz	short lff16m_1
  1695 00000C77 E916FD              <1> 	jmp	lff16m_3
  1696                              <1> 
  1697                              <1> lff16m_7:
  1698                              <1> lff16s_7:
  1699 00000C7A E92DFD              <1> 	jmp	lff16m_5  ; error
  1700                              <1> 
  1701                              <1> load_16khz_stereo_8_bit:
  1702                              <1> 	; 02/02/2025
  1703                              <1> 	; 14/11/2023
  1704                              <1> 	; 13/11/2023
  1705 00000C7D F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1706                              <1> 					; last of the file?
  1707 00000C82 7402                <1> 	jz	short lff16s_0		; no
  1708 00000C84 F9                  <1> 	stc
  1709 00000C85 C3                  <1> 	retn
  1710                              <1> 
  1711                              <1> lff16s_0:
  1712 00000C86 8EC0                <1> 	mov	es, ax ; buffer segment
  1713 00000C88 31FF                <1> 	xor	di, di
  1714 00000C8A BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1715                              <1> 	; ds = cs
  1716                              <1> 
  1717                              <1> 	; load file into memory
  1718 00000C8D 8B0E[B906]          <1>         mov	cx, [loadsize]
  1719 00000C91 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1720 00000C95 B43F                <1>        	mov	ah, 3Fh
  1721 00000C97 CD21                <1> 	int	21h
  1722 00000C99 72DF                <1> 	jc	short lff16s_7 ; error !
  1723                              <1> 
  1724 00000C9B 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1725                              <1> 	
  1726 00000C9D D1E8                <1> 	shr	ax, 1
  1727                              <1> 	;and	ax, ax
  1728 00000C9F 7503                <1> 	jnz	short lff16s_8
  1729                              <1> 	;jmp	lff16s_3
  1730                              <1> 	; 15/11/2023
  1731 00000CA1 E9FFFC              <1> 	jmp	lff16_eof
  1732                              <1> 
  1733                              <1> lff16s_8:
  1734 00000CA4 89C1                <1> 	mov	cx, ax	; word count
  1735                              <1> lff16s_1:
  1736 00000CA6 AC                  <1> 	lodsb
  1737 00000CA7 A2[0E1B]            <1> 	mov	[previous_val_l], al
  1738 00000CAA 2C80                <1> 	sub	al, 80h
  1739 00000CAC C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1740 00000CAF AB                  <1> 	stosw		; original sample (L)
  1741 00000CB0 AC                  <1> 	lodsb
  1742 00000CB1 A2[101B]            <1> 	mov	[previous_val_r], al
  1743 00000CB4 2C80                <1> 	sub	al, 80h
  1744 00000CB6 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1745 00000CB9 AB                  <1> 	stosw		; original sample (R)
  1746                              <1> 
  1747                              <1> 	;xor	ax, ax
  1748                              <1> 	; 02/02/2025
  1749 00000CBA 8B04                <1> 	mov	ax, [si]
  1750 00000CBC 49                  <1> 	dec	cx
  1751 00000CBD 7503                <1> 	jnz	short lff16s_2
  1752                              <1> 		; convert 8 bit sample to 16 bit sample
  1753                              <1> 	; 14/11/2023
  1754 00000CBF B88080              <1> 	mov	ax, 8080h
  1755                              <1> lff16s_2:
  1756                              <1> 	;mov	[next_val_l], al
  1757                              <1> 	;mov	[next_val_r], ah
  1758 00000CC2 89C3                <1> 	mov	bx, ax
  1759 00000CC4 0206[0E1B]          <1> 	add	al, [previous_val_l]
  1760 00000CC8 D0D8                <1> 	rcr	al, 1
  1761 00000CCA 88C2                <1> 	mov	dl, al	; this is temporary interpolation value (L)
  1762 00000CCC 0206[0E1B]          <1> 	add	al, [previous_val_l]
  1763 00000CD0 D0D8                <1> 	rcr	al, 1
  1764 00000CD2 2C80                <1> 	sub	al, 80h
  1765 00000CD4 C1E008              <1> 	shl	ax, 8
  1766 00000CD7 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1767 00000CD8 88F8                <1> 	mov	al, bh	; [next_val_r]
  1768 00000CDA 0206[101B]          <1> 	add	al, [previous_val_r]
  1769 00000CDE D0D8                <1> 	rcr	al, 1
  1770 00000CE0 88C6                <1> 	mov	dh, al	; this is temporary interpolation value (R)
  1771 00000CE2 0206[101B]          <1> 	add	al, [previous_val_r]
  1772 00000CE6 D0D8                <1> 	rcr	al, 1
  1773 00000CE8 2C80                <1> 	sub	al, 80h
  1774 00000CEA C1E008              <1> 	shl	ax, 8
  1775 00000CED AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1776 00000CEE 88D0                <1> 	mov	al, dl
  1777 00000CF0 00D8                <1> 	add	al, bl	; [next_val_l]
  1778 00000CF2 D0D8                <1> 	rcr	al, 1
  1779 00000CF4 2C80                <1> 	sub	al, 80h
  1780 00000CF6 C1E008              <1> 	shl	ax, 8
  1781 00000CF9 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1782 00000CFA 88F0                <1> 	mov	al, dh
  1783 00000CFC 00F8                <1> 	add	al, bh	; [next_val_r]
  1784 00000CFE D0D8                <1> 	rcr	al, 1
  1785 00000D00 2C80                <1> 	sub	al, 80h
  1786 00000D02 C1E008              <1> 	shl	ax, 8
  1787 00000D05 AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1788                              <1> 	
  1789                              <1> 	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1790 00000D06 09C9                <1> 	or	cx, cx
  1791 00000D08 759C                <1> 	jnz	short lff16s_1
  1792 00000D0A E983FC              <1> 	jmp	lff16s_3
  1793                              <1> 
  1794                              <1> load_16khz_mono_16_bit:
  1795                              <1> 	; 02/02/2025
  1796                              <1> 	; 15/11/2023
  1797                              <1> 	; 13/11/2023
  1798 00000D0D F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1799                              <1> 					; last of the file?
  1800 00000D12 7402                <1> 	jz	short lff16m2_0		; no
  1801 00000D14 F9                  <1> 	stc
  1802 00000D15 C3                  <1> 	retn
  1803                              <1> 
  1804                              <1> lff16m2_0:
  1805 00000D16 8EC0                <1> 	mov	es, ax ; buffer segment
  1806 00000D18 31FF                <1> 	xor	di, di
  1807 00000D1A BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1808                              <1> 	; ds = cs
  1809                              <1> 
  1810                              <1> 	; load file into memory
  1811 00000D1D 8B0E[B906]          <1>         mov	cx, [loadsize]
  1812 00000D21 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1813 00000D25 B43F                <1>        	mov	ah, 3Fh
  1814 00000D27 CD21                <1> 	int	21h
  1815 00000D29 7240                <1> 	jc	short lff16m2_7 ; error !
  1816                              <1> 
  1817 00000D2B 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1818                              <1> 	
  1819 00000D2D D1E8                <1> 	shr	ax, 1
  1820                              <1> 	;and	ax, ax
  1821 00000D2F 7503                <1> 	jnz	short lff16m2_8
  1822                              <1> 	;jmp	lff16m2_3
  1823                              <1> 	; 15/11/2023
  1824 00000D31 E96FFC              <1> 	jmp	lff16_eof
  1825                              <1> 
  1826                              <1> lff16m2_8:
  1827 00000D34 89C1                <1> 	mov	cx, ax	; word count
  1828                              <1> lff16m2_1:
  1829 00000D36 AD                  <1> 	lodsw
  1830 00000D37 AB                  <1> 	stosw		; original sample (left channel)
  1831 00000D38 AB                  <1> 	stosw		; original sample (right channel)
  1832 00000D39 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  1833                              <1> 	;mov	[previous_val], ax
  1834 00000D3C 89C3                <1> 	mov	bx, ax	
  1835                              <1> 	; 02/02/2025
  1836 00000D3E 8B04                <1> 	mov	ax, [si]
  1837 00000D40 49                  <1> 	dec	cx
  1838 00000D41 7502                <1> 	jnz	short lff16m2_2
  1839 00000D43 31C0                <1> 	xor	ax, ax
  1840                              <1> lff16m2_2:
  1841 00000D45 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  1842 00000D48 89C5                <1> 	mov	bp, ax	; [next_val]
  1843                              <1> 	;add	ax, [previous_val]
  1844 00000D4A 01D8                <1> 	add	ax, bx
  1845 00000D4C D1D8                <1> 	rcr	ax, 1
  1846 00000D4E 89C2                <1> 	mov	dx, ax	; this is temporary interpolation value
  1847                              <1> 	;add	ax, [previous_val]
  1848 00000D50 01D8                <1> 	add	ax, bx
  1849 00000D52 D1D8                <1> 	rcr	ax, 1
  1850 00000D54 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1851 00000D57 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1852 00000D58 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1853 00000D59 89E8                <1> 	mov	ax, bp
  1854 00000D5B 01D0                <1> 	add	ax, dx
  1855 00000D5D D1D8                <1> 	rcr	ax, 1
  1856 00000D5F 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1857 00000D62 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1858 00000D63 AB                  <1> 	stosw		; this is 2nd interpolated sample (R)
  1859                              <1> 	; 16 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  1860 00000D64 09C9                <1> 	or	cx, cx
  1861 00000D66 75CE                <1> 	jnz	short lff16m2_1
  1862 00000D68 E925FC              <1> 	jmp	lff16m2_3
  1863                              <1> 
  1864                              <1> lff16m2_7:
  1865                              <1> lff16s2_7:
  1866 00000D6B E93CFC              <1> 	jmp	lff16m2_5  ; error
  1867                              <1> 
  1868                              <1> load_16khz_stereo_16_bit:
  1869                              <1> 	; 02/02/2025
  1870                              <1> 	; 16/11/2023
  1871                              <1> 	; 15/11/2023
  1872                              <1> 	; 13/11/2023
  1873 00000D6E F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1874                              <1> 					; last of the file?
  1875 00000D73 7402                <1> 	jz	short lff16s2_0		; no
  1876 00000D75 F9                  <1> 	stc
  1877 00000D76 C3                  <1> 	retn
  1878                              <1> 
  1879                              <1> lff16s2_0:
  1880 00000D77 8EC0                <1> 	mov	es, ax ; buffer segment
  1881 00000D79 31FF                <1> 	xor	di, di
  1882 00000D7B BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1883                              <1> 	; ds = cs
  1884                              <1> 
  1885                              <1> 	; load file into memory
  1886 00000D7E 8B0E[B906]          <1>         mov	cx, [loadsize]
  1887 00000D82 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1888 00000D86 B43F                <1>        	mov	ah, 3Fh
  1889 00000D88 CD21                <1> 	int	21h
  1890 00000D8A 72DF                <1> 	jc	short lff16s2_7 ; error !
  1891                              <1> 
  1892 00000D8C 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1893                              <1> 	
  1894                              <1> 	;shr	ax, 1
  1895 00000D8E C1E802              <1> 	shr	ax, 2	; 16/11/2023
  1896                              <1> 	;and	ax, ax
  1897 00000D91 7503                <1> 	jnz	short lff16s2_8
  1898                              <1> 	;jmp	lff16s2_3
  1899                              <1> 	; 15/11/2023
  1900 00000D93 E90DFC              <1> 	jmp	lff16_eof
  1901                              <1> 
  1902                              <1> lff16s2_8:
  1903 00000D96 89C1                <1> 	mov	cx, ax	; dword count
  1904                              <1> lff16s2_1:
  1905 00000D98 AD                  <1> 	lodsw
  1906 00000D99 AB                  <1> 	stosw		; original sample (L)
  1907 00000D9A 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  1908 00000D9D A3[0E1B]            <1> 	mov	[previous_val_l], ax
  1909 00000DA0 AD                  <1> 	lodsw
  1910 00000DA1 AB                  <1> 	stosw		; original sample (R)
  1911 00000DA2 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  1912 00000DA5 A3[101B]            <1> 	mov	[previous_val_r], ax
  1913                              <1> 	; 02/02/2025
  1914 00000DA8 8B04                <1> 	mov	ax, [si]
  1915 00000DAA 8B5402              <1> 	mov	dx, [si+2]
  1916                              <1> 	; 16/11/2023
  1917 00000DAD 49                  <1> 	dec	cx
  1918 00000DAE 7504                <1> 	jnz	short lff16s2_2
  1919 00000DB0 31D2                <1> 	xor	dx, dx
  1920 00000DB2 31C0                <1> 	xor	ax, ax
  1921                              <1> lff16s2_2:
  1922 00000DB4 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format
  1923                              <1> 	;mov	[next_val_l], ax
  1924 00000DB7 89C5                <1> 	mov	bp, ax
  1925 00000DB9 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format
  1926 00000DBC 8916[141B]          <1> 	mov	[next_val_r], dx
  1927 00000DC0 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  1928 00000DC4 D1D8                <1> 	rcr	ax, 1
  1929 00000DC6 89C2                <1> 	mov	dx, ax	; this is temporary interpolation value (L)
  1930 00000DC8 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  1931 00000DCC D1D8                <1> 	rcr	ax, 1
  1932 00000DCE 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  1933 00000DD1 AB                  <1> 	stosw		; this is 1st interpolated sample (L)
  1934 00000DD2 A1[141B]            <1> 	mov	ax, [next_val_r]
  1935 00000DD5 0306[101B]          <1> 	add	ax, [previous_val_r]
  1936 00000DD9 D1D8                <1> 	rcr	ax, 1
  1937 00000DDB 89C3                <1> 	mov	bx, ax	; this is temporary interpolation value (R)
  1938 00000DDD 0306[101B]          <1> 	add	ax, [previous_val_r]
  1939 00000DE1 D1D8                <1> 	rcr	ax, 1
  1940 00000DE3 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1941 00000DE6 AB                  <1> 	stosw		; this is 1st interpolated sample (R)
  1942                              <1> 	;mov	ax, [next_val_l]
  1943 00000DE7 89E8                <1> 	mov	ax, bp
  1944 00000DE9 01D0                <1> 	add	ax, dx
  1945 00000DEB D1D8                <1> 	rcr	ax, 1
  1946 00000DED 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1947 00000DF0 AB                  <1> 	stosw		; this is 2nd interpolated sample (L)
  1948 00000DF1 A1[141B]            <1> 	mov	ax, [next_val_r]
  1949 00000DF4 01D8                <1> 	add	ax, bx
  1950 00000DF6 D1D8                <1> 	rcr	ax, 1
  1951 00000DF8 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  1952 00000DFB AB                  <1> 	stosw 		; this is 2nd interpolated sample (R)
  1953                              <1> 	
  1954                              <1> 	; 16 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  1955 00000DFC 09C9                <1> 	or	cx, cx
  1956 00000DFE 7598                <1> 	jnz	short lff16s2_1
  1957 00000E00 E98DFB              <1> 	jmp	lff16s2_3
  1958                              <1> 
  1959                              <1> ; .....................
  1960                              <1> 
  1961                              <1> load_24khz_mono_8_bit:
  1962                              <1> 	; 02/02/2025
  1963                              <1> 	; 15/11/2023
  1964 00000E03 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  1965                              <1> 					; last of the file?
  1966 00000E08 7402                <1> 	jz	short lff24m_0		; no
  1967 00000E0A F9                  <1> 	stc
  1968 00000E0B C3                  <1> 	retn
  1969                              <1> 
  1970                              <1> lff24m_0:
  1971 00000E0C 8EC0                <1> 	mov	es, ax ; buffer segment
  1972 00000E0E 31FF                <1> 	xor	di, di
  1973 00000E10 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  1974                              <1> 	; ds = cs
  1975                              <1> 
  1976                              <1> 	; load file into memory
  1977 00000E13 8B0E[B906]          <1>         mov	cx, [loadsize]
  1978 00000E17 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  1979 00000E1B B43F                <1>        	mov	ah, 3Fh
  1980 00000E1D CD21                <1> 	int	21h
  1981 00000E1F 722E                <1> 	jc	short lff24m_7 ; error !
  1982                              <1> 
  1983 00000E21 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  1984                              <1> 	
  1985 00000E23 21C0                <1> 	and	ax, ax
  1986 00000E25 7503                <1> 	jnz	short lff24m_8
  1987 00000E27 E979FB              <1> 	jmp	lff24_eof
  1988                              <1> 
  1989                              <1> lff24m_8:
  1990 00000E2A 89C1                <1> 	mov	cx, ax	; byte count
  1991                              <1> lff24m_1:
  1992 00000E2C AC                  <1> 	lodsb
  1993                              <1> 	;mov	[previous_val], al
  1994 00000E2D 88C3                <1> 	mov	bl, al
  1995 00000E2F 2C80                <1> 	sub	al, 80h
  1996 00000E31 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  1997 00000E34 AB                  <1> 	stosw		; original sample (left channel)
  1998 00000E35 AB                  <1> 	stosw		; original sample (right channel)
  1999                              <1> 	;xor	ax, ax
  2000                              <1> 	; 02/02/2025
  2001 00000E36 8A04                <1> 	mov	al, [si]
  2002 00000E38 49                  <1> 	dec	cx
  2003 00000E39 7502                <1> 	jnz	short lff24m_2
  2004 00000E3B B080                <1> 	mov	al, 80h
  2005                              <1> lff24m_2:
  2006                              <1> 	;;mov	[next_val], al
  2007                              <1> 	;mov	bh, al
  2008                              <1> 	;add	al, [previous_val]
  2009 00000E3D 00D8                <1> 	add	al, bl
  2010 00000E3F D0D8                <1> 	rcr	al, 1
  2011 00000E41 2C80                <1> 	sub	al, 80h
  2012 00000E43 C1E008              <1> 	shl	ax, 8
  2013 00000E46 AB                  <1> 	stosw		; this is interpolated sample (L)
  2014 00000E47 AB                  <1> 	stosw		; this is interpolated sample (R)
  2015                              <1> 	
  2016                              <1> 	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2017 00000E48 09C9                <1> 	or	cx, cx
  2018 00000E4A 75E0                <1> 	jnz	short lff24m_1
  2019 00000E4C E941FB              <1> 	jmp	lff24_3
  2020                              <1> 
  2021                              <1> lff24m_7:
  2022                              <1> lff24s_7:
  2023 00000E4F E958FB              <1> 	jmp	lff24_5  ; error
  2024                              <1> 
  2025                              <1> load_24khz_stereo_8_bit:
  2026                              <1> 	; 02/02/2025
  2027                              <1> 	; 15/11/2023
  2028 00000E52 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2029                              <1> 					; last of the file?
  2030 00000E57 7402                <1> 	jz	short lff24s_0		; no
  2031 00000E59 F9                  <1> 	stc
  2032 00000E5A C3                  <1> 	retn
  2033                              <1> 
  2034                              <1> lff24s_0:
  2035 00000E5B 8EC0                <1> 	mov	es, ax ; buffer segment
  2036 00000E5D 31FF                <1> 	xor	di, di
  2037 00000E5F BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2038                              <1> 	; ds = cs
  2039                              <1> 
  2040                              <1> 	; load file into memory
  2041 00000E62 8B0E[B906]          <1>         mov	cx, [loadsize]
  2042 00000E66 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2043 00000E6A B43F                <1>        	mov	ah, 3Fh
  2044 00000E6C CD21                <1> 	int	21h
  2045 00000E6E 72DF                <1> 	jc	short lff24s_7 ; error !
  2046                              <1> 
  2047 00000E70 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2048                              <1> 	
  2049 00000E72 D1E8                <1> 	shr	ax, 1
  2050                              <1> 	;and	ax, ax
  2051 00000E74 7503                <1> 	jnz	short lff24s_8
  2052 00000E76 E92AFB              <1> 	jmp	lff24_eof
  2053                              <1> 
  2054                              <1> lff24s_8:
  2055 00000E79 89C1                <1> 	mov	cx, ax	; word count
  2056                              <1> lff24s_1:
  2057 00000E7B AC                  <1> 	lodsb
  2058 00000E7C A2[0E1B]            <1> 	mov	[previous_val_l], al
  2059 00000E7F 2C80                <1> 	sub	al, 80h
  2060 00000E81 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2061 00000E84 AB                  <1> 	stosw		; original sample (L)
  2062 00000E85 AC                  <1> 	lodsb
  2063 00000E86 A2[101B]            <1> 	mov	[previous_val_r], al
  2064 00000E89 2C80                <1> 	sub	al, 80h
  2065 00000E8B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2066 00000E8E AB                  <1> 	stosw		; original sample (R)
  2067                              <1> 	;xor	ax, ax
  2068                              <1> 	; 02/02/2025
  2069 00000E8F 8B04                <1> 	mov	ax, [si]
  2070 00000E91 49                  <1> 	dec	cx
  2071 00000E92 7503                <1> 	jnz	short lff24s_2
  2072                              <1> 		; convert 8 bit sample to 16 bit sample
  2073 00000E94 B88080              <1> 	mov	ax, 8080h
  2074                              <1> lff24s_2:
  2075                              <1> 	;;mov	[next_val_l], al
  2076                              <1> 	;;mov	[next_val_r], ah
  2077                              <1> 	;mov	bx, ax
  2078 00000E97 88E7                <1> 	mov	bh, ah
  2079 00000E99 0206[0E1B]          <1> 	add	al, [previous_val_l]
  2080 00000E9D D0D8                <1> 	rcr	al, 1
  2081                              <1> 	;mov	dl, al
  2082 00000E9F 2C80                <1> 	sub	al, 80h
  2083 00000EA1 C1E008              <1> 	shl	ax, 8
  2084 00000EA4 AB                  <1> 	stosw		; this is interpolated sample (L)
  2085 00000EA5 88F8                <1> 	mov	al, bh	; [next_val_r]
  2086 00000EA7 0206[101B]          <1> 	add	al, [previous_val_r]
  2087 00000EAB D0D8                <1> 	rcr	al, 1
  2088                              <1> 	;mov	dh, al
  2089 00000EAD 2C80                <1> 	sub	al, 80h
  2090 00000EAF C1E008              <1> 	shl	ax, 8
  2091 00000EB2 AB                  <1> 	stosw		; this is interpolated sample (R)
  2092                              <1> 		
  2093                              <1> 	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2094 00000EB3 09C9                <1> 	or	cx, cx
  2095 00000EB5 75C4                <1> 	jnz	short lff24s_1
  2096 00000EB7 E9D6FA              <1> 	jmp	lff24_3
  2097                              <1> 
  2098                              <1> load_24khz_mono_16_bit:
  2099                              <1> 	; 02/02/2025
  2100                              <1> 	; 15/11/2023
  2101 00000EBA F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2102                              <1> 					; last of the file?
  2103 00000EBF 7402                <1> 	jz	short lff24m2_0		; no
  2104 00000EC1 F9                  <1> 	stc
  2105 00000EC2 C3                  <1> 	retn
  2106                              <1> 
  2107                              <1> lff24m2_0:
  2108 00000EC3 8EC0                <1> 	mov	es, ax ; buffer segment
  2109 00000EC5 31FF                <1> 	xor	di, di
  2110 00000EC7 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2111                              <1> 	; ds = cs
  2112                              <1> 
  2113                              <1> 	; load file into memory
  2114 00000ECA 8B0E[B906]          <1>         mov	cx, [loadsize]
  2115 00000ECE 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2116 00000ED2 B43F                <1>        	mov	ah, 3Fh
  2117 00000ED4 CD21                <1> 	int	21h
  2118 00000ED6 722B                <1> 	jc	short lff24m2_7 ; error !
  2119                              <1> 
  2120 00000ED8 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2121                              <1> 	
  2122 00000EDA D1E8                <1> 	shr	ax, 1
  2123                              <1> 	;and	ax, ax
  2124 00000EDC 7503                <1> 	jnz	short lff24m2_8
  2125 00000EDE E9C2FA              <1> 	jmp	lff24_eof
  2126                              <1> 
  2127                              <1> lff24m2_8:
  2128 00000EE1 89C1                <1> 	mov	cx, ax	; word count
  2129                              <1> lff24m2_1:
  2130 00000EE3 AD                  <1> 	lodsw
  2131 00000EE4 AB                  <1> 	stosw		; original sample (left channel)
  2132 00000EE5 AB                  <1> 	stosw		; original sample (right channel)
  2133 00000EE6 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2134                              <1> 	;mov	[previous_val], ax
  2135                              <1> 	;mov	bx, ax
  2136                              <1> 	;mov	ax, [si
  2137                              <1> 	; 02/02/2025
  2138 00000EE9 8B1C                <1> 	mov	bx, [si]
  2139 00000EEB 49                  <1> 	dec	cx
  2140 00000EEC 7502                <1> 	jnz	short lff24m2_2
  2141                              <1> 	;xor	ax, ax
  2142 00000EEE 31DB                <1> 	xor	bx, bx
  2143                              <1> lff24m2_2:
  2144                              <1> 	; 02/02/2025
  2145 00000EF0 80C780              <1> 	add	bh, 80h ; convert sound level 0 to 65535 format
  2146                              <1> 	;add	ah, 80h
  2147                              <1> 	;mov	bp, ax	; [next_val]
  2148                              <1> 	;add	ax, [previous_val]
  2149                              <1> 	; ax = [previous_val]
  2150                              <1> 	; bx = [next_val]
  2151 00000EF3 01D8                <1> 	add	ax, bx
  2152 00000EF5 D1D8                <1> 	rcr	ax, 1
  2153 00000EF7 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2154 00000EFA AB                  <1> 	stosw		; this is interpolated sample (L)
  2155 00000EFB AB                  <1> 	stosw		; this is interpolated sample (R)
  2156                              <1> 	; 24 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2157 00000EFC 09C9                <1> 	or	cx, cx
  2158 00000EFE 75E3                <1> 	jnz	short lff24m2_1
  2159 00000F00 E98DFA              <1> 	jmp	lff24_3
  2160                              <1> 
  2161                              <1> lff24m2_7:
  2162                              <1> lff24s2_7:
  2163 00000F03 E9A4FA              <1> 	jmp	lff24_5  ; error
  2164                              <1> 
  2165                              <1> load_24khz_stereo_16_bit:
  2166                              <1> 	; 02/02/2025
  2167                              <1> 	; 16/11/2023
  2168                              <1> 	; 15/11/2023
  2169 00000F06 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2170                              <1> 					; last of the file?
  2171 00000F0B 7402                <1> 	jz	short lff24s2_0		; no
  2172 00000F0D F9                  <1> 	stc
  2173 00000F0E C3                  <1> 	retn
  2174                              <1> 
  2175                              <1> lff24s2_0:
  2176 00000F0F 8EC0                <1> 	mov	es, ax ; buffer segment
  2177 00000F11 31FF                <1> 	xor	di, di
  2178 00000F13 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2179                              <1> 	; ds = cs
  2180                              <1> 
  2181                              <1> 	; load file into memory
  2182 00000F16 8B0E[B906]          <1>         mov	cx, [loadsize]
  2183 00000F1A 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2184 00000F1E B43F                <1>        	mov	ah, 3Fh
  2185 00000F20 CD21                <1> 	int	21h
  2186 00000F22 72DF                <1> 	jc	short lff24s2_7 ; error !
  2187                              <1> 
  2188 00000F24 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2189                              <1> 	
  2190                              <1> 	;shr	ax, 1
  2191 00000F26 C1E802              <1> 	shr	ax, 2	; 16/11/2023
  2192                              <1> 	;and	ax, ax
  2193 00000F29 7503                <1> 	jnz	short lff24s2_8
  2194 00000F2B E975FA              <1> 	jmp	lff24_eof
  2195                              <1> 
  2196                              <1> lff24s2_8:
  2197 00000F2E 89C1                <1> 	mov	cx, ax	; dword count
  2198                              <1> lff24s2_1:
  2199 00000F30 AD                  <1> 	lodsw
  2200 00000F31 AB                  <1> 	stosw		; original sample (L)
  2201 00000F32 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2202 00000F35 A3[0E1B]            <1> 	mov	[previous_val_l], ax
  2203 00000F38 AD                  <1> 	lodsw
  2204 00000F39 AB                  <1> 	stosw		; original sample (R)
  2205 00000F3A 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2206                              <1> 	;mov	[previous_val_r], ax
  2207 00000F3D 89C3                <1> 	mov	bx, ax
  2208                              <1> 	; 02/02/2025
  2209 00000F3F 8B04                <1> 	mov	ax, [si]
  2210 00000F41 8B5402              <1> 	mov	dx, [si+2]
  2211                              <1> 	; 16/11/2023
  2212 00000F44 49                  <1> 	dec	cx
  2213 00000F45 7504                <1> 	jnz	short lff24s2_2
  2214 00000F47 31D2                <1> 	xor	dx, dx
  2215 00000F49 31C0                <1> 	xor	ax, ax
  2216                              <1> lff24s2_2:
  2217 00000F4B 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2218                              <1> 	;;mov	[next_val_l], ax
  2219                              <1> 	;mov	bp, ax
  2220 00000F4E 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format 
  2221                              <1> 	;mov	[next_val_r], dx
  2222 00000F51 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  2223 00000F55 D1D8                <1> 	rcr	ax, 1
  2224 00000F57 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  2225 00000F5A AB                  <1> 	stosw		; this is interpolated sample (L)
  2226                              <1> 	;mov	ax, [next_val_r]
  2227 00000F5B 89D0                <1> 	mov	ax, dx
  2228                              <1> 	;add	ax, [previous_val_r]
  2229 00000F5D 01D8                <1> 	add	ax, bx
  2230 00000F5F D1D8                <1> 	rcr	ax, 1
  2231 00000F61 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2232 00000F64 AB                  <1> 	stosw		; this is interpolated sample (R)
  2233                              <1> 	
  2234                              <1> 	; 24 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2235 00000F65 09C9                <1> 	or	cx, cx
  2236 00000F67 75C7                <1> 	jnz	short lff24s2_1
  2237 00000F69 E924FA              <1> 	jmp	lff24_3
  2238                              <1> 
  2239                              <1> ; .....................
  2240                              <1> 
  2241                              <1> load_32khz_mono_8_bit:
  2242                              <1> 	; 02/02/2025
  2243                              <1> 	; 15/11/2023
  2244 00000F6C F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2245                              <1> 					; last of the file?
  2246 00000F71 7402                <1> 	jz	short lff32m_0		; no
  2247 00000F73 F9                  <1> 	stc
  2248 00000F74 C3                  <1> 	retn
  2249                              <1> 
  2250                              <1> lff32m_0:
  2251 00000F75 8EC0                <1> 	mov	es, ax ; buffer segment
  2252 00000F77 31FF                <1> 	xor	di, di
  2253 00000F79 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2254                              <1> 	; ds = cs
  2255                              <1> 
  2256                              <1> 	; load file into memory
  2257 00000F7C 8B0E[B906]          <1>         mov	cx, [loadsize]
  2258 00000F80 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2259 00000F84 B43F                <1>        	mov	ah, 3Fh
  2260 00000F86 CD21                <1> 	int	21h
  2261 00000F88 7237                <1> 	jc	short lff32m_7 ; error !
  2262                              <1> 
  2263 00000F8A 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2264                              <1> 	
  2265 00000F8C 21C0                <1> 	and	ax, ax
  2266 00000F8E 7503                <1> 	jnz	short lff32m_8
  2267 00000F90 E910FA              <1> 	jmp	lff32_eof
  2268                              <1> 
  2269                              <1> lff32m_8:
  2270 00000F93 89C1                <1> 	mov	cx, ax	; byte count
  2271                              <1> lff32m_1:
  2272 00000F95 AC                  <1> 	lodsb
  2273                              <1> 	;mov	[previous_val], al
  2274 00000F96 88C3                <1> 	mov	bl, al
  2275 00000F98 2C80                <1> 	sub	al, 80h
  2276 00000F9A C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2277 00000F9D AB                  <1> 	stosw		; original sample (left channel)
  2278 00000F9E AB                  <1> 	stosw		; original sample (right channel)
  2279                              <1> 	;xor	ax, ax
  2280                              <1> 	; 02/02/2025
  2281 00000F9F 8A04                <1> 	mov	al, [si]
  2282 00000FA1 49                  <1> 	dec	cx
  2283 00000FA2 7502                <1> 	jnz	short lff32m_2
  2284 00000FA4 B080                <1> 	mov	al, 80h
  2285                              <1> lff32m_2:
  2286                              <1> 	;;mov	[next_val], al
  2287                              <1> 	;mov	bh, al
  2288                              <1> 	;add	al, [previous_val]
  2289 00000FA6 00D8                <1> 	add	al, bl
  2290 00000FA8 D0D8                <1> 	rcr	al, 1
  2291 00000FAA 2C80                <1> 	sub	al, 80h
  2292 00000FAC C1E008              <1> 	shl	ax, 8
  2293 00000FAF AB                  <1> 	stosw		; this is interpolated sample (L)
  2294 00000FB0 AB                  <1> 	stosw		; this is interpolated sample (R)
  2295                              <1> 	
  2296                              <1> 	; different than 8-16-24 kHZ !
  2297                              <1> 	; 'original-interpolated-original' trio samples 
  2298 00000FB1 E30B                <1> 	jcxz	lff32m_3
  2299                              <1> 
  2300 00000FB3 AC                  <1> 	lodsb
  2301 00000FB4 2C80                <1> 	sub	al, 80h
  2302 00000FB6 C1E008              <1> 	shl	ax, 8
  2303 00000FB9 AB                  <1> 	stosw		; original sample (left channel)
  2304 00000FBA AB                  <1> 	stosw		; original sample (right channel)
  2305                              <1> 
  2306                              <1> 	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2307 00000FBB 49                  <1> 	dec	cx
  2308 00000FBC 75D7                <1> 	jnz	short lff32m_1
  2309                              <1> lff32m_3:
  2310 00000FBE E9CFF9              <1> 	jmp	lff32_3
  2311                              <1> 
  2312                              <1> lff32m_7:
  2313                              <1> lff32s_7:
  2314 00000FC1 E9E6F9              <1> 	jmp	lff32_5  ; error
  2315                              <1> 
  2316                              <1> load_32khz_stereo_8_bit:
  2317                              <1> 	; 02/02/2025
  2318                              <1> 	; 15/11/2023
  2319 00000FC4 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2320                              <1> 					; last of the file?
  2321 00000FC9 7402                <1> 	jz	short lff32s_0		; no
  2322 00000FCB F9                  <1> 	stc
  2323 00000FCC C3                  <1> 	retn
  2324                              <1> 
  2325                              <1> lff32s_0:
  2326 00000FCD 8EC0                <1> 	mov	es, ax ; buffer segment
  2327 00000FCF 31FF                <1> 	xor	di, di
  2328 00000FD1 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2329                              <1> 	; ds = cs
  2330                              <1> 
  2331                              <1> 	; load file into memory
  2332 00000FD4 8B0E[B906]          <1>         mov	cx, [loadsize]
  2333 00000FD8 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2334 00000FDC B43F                <1>        	mov	ah, 3Fh
  2335 00000FDE CD21                <1> 	int	21h
  2336 00000FE0 72DF                <1> 	jc	short lff32s_7 ; error !
  2337                              <1> 
  2338 00000FE2 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2339                              <1> 	
  2340 00000FE4 D1E8                <1> 	shr	ax, 1
  2341                              <1> 	;and	ax, ax
  2342 00000FE6 7503                <1> 	jnz	short lff32s_8
  2343 00000FE8 E9B8F9              <1> 	jmp	lff32_eof
  2344                              <1> 
  2345                              <1> lff32s_8:
  2346 00000FEB 89C1                <1> 	mov	cx, ax	; word count
  2347                              <1> lff32s_1:
  2348 00000FED AC                  <1> 	lodsb
  2349 00000FEE A2[0E1B]            <1> 	mov	[previous_val_l], al
  2350 00000FF1 2C80                <1> 	sub	al, 80h
  2351 00000FF3 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2352 00000FF6 AB                  <1> 	stosw		; original sample (L)
  2353 00000FF7 AC                  <1> 	lodsb
  2354 00000FF8 A2[101B]            <1> 	mov	[previous_val_r], al
  2355 00000FFB 2C80                <1> 	sub	al, 80h
  2356 00000FFD C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  2357 00001000 AB                  <1> 	stosw		; original sample (R)
  2358                              <1> 	; 02/02/2025
  2359 00001001 8B04                <1> 	mov	ax, [si]
  2360 00001003 49                  <1> 	dec	cx
  2361 00001004 7503                <1> 	jnz	short lff32s_2
  2362                              <1> 		; convert 8 bit sample to 16 bit sample
  2363                              <1> 	;xor	ax, ax
  2364 00001006 B88080              <1> 	mov	ax, 8080h
  2365                              <1> lff32s_2:
  2366                              <1> 	;;mov	[next_val_l], al
  2367                              <1> 	;;mov	[next_val_r], ah
  2368                              <1> 	;mov	bx, ax
  2369 00001009 88E7                <1> 	mov	bh, ah
  2370 0000100B 0206[0E1B]          <1> 	add	al, [previous_val_l]
  2371 0000100F D0D8                <1> 	rcr	al, 1
  2372                              <1> 	;mov	dl, al
  2373 00001011 2C80                <1> 	sub	al, 80h
  2374 00001013 C1E008              <1> 	shl	ax, 8
  2375 00001016 AB                  <1> 	stosw		; this is interpolated sample (L)
  2376 00001017 88F8                <1> 	mov	al, bh	; [next_val_r]
  2377 00001019 0206[101B]          <1> 	add	al, [previous_val_r]
  2378 0000101D D0D8                <1> 	rcr	al, 1
  2379                              <1> 	;mov	dh, al
  2380 0000101F 2C80                <1> 	sub	al, 80h
  2381 00001021 C1E008              <1> 	shl	ax, 8
  2382 00001024 AB                  <1> 	stosw		; this is interpolated sample (R)
  2383                              <1> 
  2384                              <1> 	; different than 8-16-24 kHZ !
  2385                              <1> 	; 'original-interpolated-original' trio samples 
  2386 00001025 E311                <1> 	jcxz	lff32s_3
  2387                              <1> 
  2388 00001027 AC                  <1> 	lodsb
  2389 00001028 2C80                <1> 	sub	al, 80h
  2390 0000102A C1E008              <1> 	shl	ax, 8
  2391 0000102D AB                  <1> 	stosw		; original sample (left channel)
  2392                              <1> 
  2393 0000102E AC                  <1> 	lodsb
  2394 0000102F 2C80                <1> 	sub	al, 80h
  2395 00001031 C1E008              <1> 	shl	ax, 8
  2396 00001034 AB                  <1> 	stosw		; original sample (right channel)
  2397                              <1> 		
  2398                              <1> 	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2399 00001035 49                  <1> 	dec	cx
  2400 00001036 75B5                <1> 	jnz	short lff32s_1
  2401                              <1> lff32s_3:
  2402 00001038 E955F9              <1> 	jmp	lff32_3
  2403                              <1> 
  2404                              <1> load_32khz_mono_16_bit:
  2405                              <1> 	; 02/02/2025
  2406                              <1> 	; 15/11/2023
  2407 0000103B F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2408                              <1> 					; last of the file?
  2409 00001040 7402                <1> 	jz	short lff32m2_0		; no
  2410 00001042 F9                  <1> 	stc
  2411 00001043 C3                  <1> 	retn
  2412                              <1> 
  2413                              <1> lff32m2_0:
  2414 00001044 8EC0                <1> 	mov	es, ax ; buffer segment
  2415 00001046 31FF                <1> 	xor	di, di
  2416 00001048 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2417                              <1> 	; ds = cs
  2418                              <1> 
  2419                              <1> 	; load file into memory
  2420 0000104B 8B0E[B906]          <1>         mov	cx, [loadsize]
  2421 0000104F 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2422 00001053 B43F                <1>        	mov	ah, 3Fh
  2423 00001055 CD21                <1> 	int	21h
  2424 00001057 722F                <1> 	jc	short lff32m2_7 ; error !
  2425                              <1> 
  2426 00001059 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2427                              <1> 	
  2428 0000105B D1E8                <1> 	shr	ax, 1
  2429                              <1> 	;and	ax, ax
  2430 0000105D 7503                <1> 	jnz	short lff32m2_8
  2431 0000105F E941F9              <1> 	jmp	lff32_eof
  2432                              <1> 
  2433                              <1> lff32m2_8:
  2434 00001062 89C1                <1> 	mov	cx, ax	; word count
  2435                              <1> lff32m2_1:
  2436 00001064 AD                  <1> 	lodsw
  2437 00001065 AB                  <1> 	stosw		; original sample (left channel)
  2438 00001066 AB                  <1> 	stosw		; original sample (right channel)
  2439 00001067 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  2440                              <1> 	;mov	[previous_val], ax
  2441                              <1> 	;mov	bx, ax
  2442                              <1> 	; 02/02/2025
  2443                              <1> 	;mov	ax, [si
  2444 0000106A 8B1C                <1> 	mov	bx, [si]
  2445 0000106C 49                  <1> 	dec	cx
  2446 0000106D 7502                <1> 	jnz	short lff32m2_2
  2447                              <1> 	;xor	ax, ax
  2448 0000106F 31DB                <1> 	xor	bx, bx
  2449                              <1> lff32m2_2:
  2450                              <1> 	; 02/02/2025
  2451 00001071 80C780              <1> 	add	bh, 80h ; convert sound level 0 to 65535 format
  2452                              <1> 	;add	ah, 80h
  2453                              <1> 	;mov	bp, ax	; [next_val]
  2454                              <1> 	;add	ax, [previous_val]
  2455                              <1> 	; ax = [previous_val]
  2456                              <1> 	; bx = [next_val]
  2457 00001074 01D8                <1> 	add	ax, bx
  2458 00001076 D1D8                <1> 	rcr	ax, 1
  2459 00001078 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2460 0000107B AB                  <1> 	stosw		; this is interpolated sample (L)
  2461 0000107C AB                  <1> 	stosw		; this is interpolated sample (R)
  2462                              <1> 
  2463                              <1> 	; different than 8-16-24 kHZ !
  2464                              <1> 	; 'original-interpolated-original' trio samples 
  2465 0000107D E306                <1> 	jcxz	lff32m2_3
  2466                              <1> 
  2467 0000107F AD                  <1> 	lodsw
  2468 00001080 AB                  <1> 	stosw		; original sample (left channel)
  2469 00001081 AB                  <1> 	stosw		; original sample (right channel)
  2470                              <1> 
  2471                              <1> 	; 32 kHZ mono to 48 kHZ stereo conversion of the sample is OK
  2472 00001082 49                  <1> 	dec	cx
  2473 00001083 75DF                <1> 	jnz	short lff32m2_1
  2474                              <1> lff32m2_3:
  2475 00001085 E908F9              <1> 	jmp	lff32_3
  2476                              <1> 
  2477                              <1> lff32m2_7:
  2478                              <1> lff32s2_7:
  2479 00001088 E91FF9              <1> 	jmp	lff32_5  ; error
  2480                              <1> 
  2481                              <1> load_32khz_stereo_16_bit:
  2482                              <1> 	; 02/02/2025
  2483                              <1> 	; 16/11/2023
  2484                              <1> 	; 15/11/2023
  2485 0000108B F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2486                              <1> 					; last of the file?
  2487 00001090 7402                <1> 	jz	short lff32s2_0		; no
  2488 00001092 F9                  <1> 	stc
  2489 00001093 C3                  <1> 	retn
  2490                              <1> 
  2491                              <1> lff32s2_0:
  2492 00001094 8EC0                <1> 	mov	es, ax ; buffer segment
  2493 00001096 31FF                <1> 	xor	di, di
  2494 00001098 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2495                              <1> 	; ds = cs
  2496                              <1> 
  2497                              <1> 	; load file into memory
  2498 0000109B 8B0E[B906]          <1>         mov	cx, [loadsize]
  2499 0000109F 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2500 000010A3 B43F                <1>        	mov	ah, 3Fh
  2501 000010A5 CD21                <1> 	int	21h
  2502 000010A7 72DF                <1> 	jc	short lff32s2_7 ; error !
  2503                              <1> 
  2504 000010A9 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2505                              <1> 	
  2506 000010AB C1E802              <1> 	shr	ax, 2	; 16/11/2023 (word left ch + word right ch) 
  2507                              <1> 	;and	ax, ax
  2508 000010AE 7503                <1> 	jnz	short lff32s2_8
  2509 000010B0 E9F0F8              <1> 	jmp	lff32_eof
  2510                              <1> 
  2511                              <1> lff32s2_8:
  2512 000010B3 89C1                <1> 	mov	cx, ax	; dword count
  2513                              <1> lff32s2_1:
  2514 000010B5 AD                  <1> 	lodsw
  2515 000010B6 AB                  <1> 	stosw		; original sample (L)
  2516 000010B7 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2517 000010BA A3[0E1B]            <1> 	mov	[previous_val_l], ax
  2518 000010BD AD                  <1> 	lodsw
  2519 000010BE AB                  <1> 	stosw		; original sample (R)
  2520 000010BF 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2521                              <1> 	;mov	[previous_val_r], ax
  2522 000010C2 89C3                <1> 	mov	bx, ax
  2523                              <1> 	; 02/02/2025
  2524 000010C4 8B04                <1> 	mov	ax, [si]
  2525 000010C6 8B5402              <1> 	mov	dx, [si+2]
  2526                              <1> 	; 16/11/2023
  2527 000010C9 49                  <1> 	dec	cx
  2528 000010CA 7504                <1> 	jnz	short lff32s2_2
  2529 000010CC 31D2                <1> 	xor	dx, dx
  2530 000010CE 31C0                <1> 	xor	ax, ax
  2531                              <1> lff32s2_2:
  2532 000010D0 80C480              <1> 	add	ah, 80h	; convert sound level 0 to 65535 format 
  2533                              <1> 	;;mov	[next_val_l], ax
  2534                              <1> 	;mov	bp, ax
  2535 000010D3 80C680              <1> 	add	dh, 80h	; convert sound level 0 to 65535 format 
  2536                              <1> 	;mov	[next_val_r], dx
  2537 000010D6 0306[0E1B]          <1> 	add	ax, [previous_val_l]
  2538 000010DA D1D8                <1> 	rcr	ax, 1
  2539 000010DC 80EC80              <1> 	sub	ah, 80h ; -32768 to +32767 format again
  2540 000010DF AB                  <1> 	stosw		; this is interpolated sample (L)
  2541                              <1> 	;mov	ax, [next_val_r]
  2542 000010E0 89D0                <1> 	mov	ax, dx
  2543                              <1> 	;add	ax, [previous_val_r]
  2544 000010E2 01D8                <1> 	add	ax, bx
  2545 000010E4 D1D8                <1> 	rcr	ax, 1
  2546 000010E6 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  2547 000010E9 AB                  <1> 	stosw		; this is interpolated sample (R)
  2548                              <1> 
  2549                              <1> 	; different than 8-16-24 kHZ !
  2550                              <1> 	; 'original-interpolated-original' trio samples 
  2551 000010EA E307                <1> 	jcxz	lff32s2_3
  2552                              <1> 
  2553 000010EC AD                  <1> 	lodsw
  2554 000010ED AB                  <1> 	stosw	; original sample (L)
  2555 000010EE AD                  <1> 	lodsw
  2556 000010EF AB                  <1> 	stosw	; original sample (R)
  2557                              <1> 	
  2558                              <1> 	; 32 kHZ stereo to 48 kHZ stereo conversion of the sample is OK
  2559 000010F0 49                  <1> 	dec	cx
  2560 000010F1 75C2                <1> 	jnz	short lff32s2_1
  2561                              <1> lff32s2_3:
  2562 000010F3 E99AF8              <1> 	jmp	lff32_3
  2563                              <1> 
  2564                              <1> ; .....................
  2565                              <1> 
  2566                              <1> load_22khz_mono_8_bit:
  2567                              <1> 	; 02/02/2025
  2568                              <1> 	; 16/11/2023
  2569 000010F6 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2570                              <1> 					; last of the file?
  2571 000010FB 7402                <1> 	jz	short lff22m_0		; no
  2572 000010FD F9                  <1> 	stc
  2573 000010FE C3                  <1> 	retn
  2574                              <1> 
  2575                              <1> lff22m_0:
  2576 000010FF 8EC0                <1> 	mov	es, ax ; buffer segment
  2577 00001101 31FF                <1> 	xor	di, di
  2578 00001103 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2579                              <1> 	; ds = cs
  2580                              <1> 
  2581                              <1> 	; load file into memory
  2582 00001106 8B0E[B906]          <1>         mov	cx, [loadsize]
  2583 0000110A 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2584 0000110E B43F                <1>        	mov	ah, 3Fh
  2585 00001110 CD21                <1> 	int	21h
  2586 00001112 7248                <1> 	jc	short lff22m_7 ; error !
  2587                              <1> 
  2588 00001114 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2589                              <1> 	
  2590 00001116 21C0                <1> 	and	ax, ax
  2591 00001118 7503                <1> 	jnz	short lff22m_8
  2592 0000111A E986F8              <1> 	jmp	lff22_eof
  2593                              <1> 
  2594                              <1> lff22m_8:
  2595 0000111D 89C1                <1> 	mov	cx, ax	; byte count
  2596                              <1> lff22m_9:
  2597 0000111F BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2598 00001122 C606[161B]03        <1> 	mov	byte [faz], 3  ; 3 steps/phases
  2599                              <1> lff22m_1:
  2600                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2601 00001127 AC                  <1> 	lodsb
  2602                              <1> 	; 02/02/2025
  2603 00001128 8A14                <1> 	mov	dl, [si]
  2604 0000112A 49                  <1> 	dec	cx
  2605 0000112B 7502                <1> 	jnz	short lff22m_2_1
  2606 0000112D B280                <1> 	mov	dl, 80h
  2607                              <1> lff22m_2_1:
  2608                              <1> 	; al = [previous_val]
  2609                              <1> 	; dl = [next_val]
  2610 0000112F E8A705              <1> 	call	interpolating_3_8bit_mono ; 1 of 17
  2611 00001132 E325                <1> 	jcxz	lff22m_3
  2612                              <1> lff22m_2_2:
  2613 00001134 AC                  <1> 	lodsb
  2614                              <1> 	; 02/02/2025
  2615 00001135 8A14                <1> 	mov	dl, [si]
  2616 00001137 49                  <1> 	dec	cx
  2617 00001138 7502                <1> 	jnz	short lff22m_2_3
  2618 0000113A B280                <1> 	mov	dl, 80h
  2619                              <1> lff22m_2_3:
  2620 0000113C E80F06              <1>  	call	interpolating_2_8bit_mono ; 2 of 17 .. 6 of 17
  2621 0000113F E318                <1> 	jcxz	lff22m_3
  2622 00001141 4D                  <1> 	dec	bp
  2623 00001142 75F0                <1> 	jnz	short lff22m_2_2
  2624                              <1> 
  2625 00001144 A0[161B]            <1> 	mov	al, [faz]
  2626 00001147 FEC8                <1> 	dec	al
  2627 00001149 74D4                <1> 	jz	short lff22m_9
  2628 0000114B FE0E[161B]          <1> 	dec	byte [faz]
  2629 0000114F BD0400              <1> 	mov	bp, 4
  2630 00001152 FEC8                <1> 	dec	al
  2631 00001154 75D1                <1> 	jnz	short lff22m_1 ; 3:2:2:2:2 ; 7-11 of 17
  2632 00001156 45                  <1> 	inc	bp ; 5
  2633 00001157 EBCE                <1> 	jmp	short lff22m_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2634                              <1> 
  2635                              <1> lff22m_3:
  2636                              <1> lff22s_3:
  2637 00001159 E934F8              <1> 	jmp	lff22_3	; padfill
  2638                              <1> 		; (put zeros in the remain words of the buffer)
  2639                              <1> lff22m_7:
  2640                              <1> lff22s_7:
  2641 0000115C E94BF8              <1> 	jmp	lff22_5  ; error
  2642                              <1> 
  2643                              <1> load_22khz_stereo_8_bit:
  2644                              <1> 	; 02/02/2025
  2645                              <1> 	; 16/11/2023
  2646 0000115F F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2647                              <1> 					; last of the file?
  2648 00001164 7402                <1> 	jz	short lff22s_0		; no
  2649 00001166 F9                  <1> 	stc
  2650 00001167 C3                  <1> 	retn
  2651                              <1> 
  2652                              <1> lff22s_0:
  2653 00001168 8EC0                <1> 	mov	es, ax ; buffer segment
  2654 0000116A 31FF                <1> 	xor	di, di
  2655 0000116C BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2656                              <1> 	; ds = cs
  2657                              <1> 
  2658                              <1> 	; load file into memory
  2659 0000116F 8B0E[B906]          <1>         mov	cx, [loadsize]
  2660 00001173 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2661 00001177 B43F                <1>        	mov	ah, 3Fh
  2662 00001179 CD21                <1> 	int	21h
  2663 0000117B 72DF                <1> 	jc	short lff22s_7 ; error !
  2664                              <1> 
  2665 0000117D 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2666                              <1> 
  2667 0000117F D1E8                <1> 	shr	ax, 1
  2668                              <1> 	;and	ax, ax
  2669 00001181 7503                <1> 	jnz	short lff22s_8
  2670 00001183 E91DF8              <1> 	jmp	lff22_eof
  2671                              <1> 
  2672                              <1> lff22s_8:
  2673 00001186 89C1                <1> 	mov	cx, ax	; word count
  2674                              <1> lff22s_9:
  2675 00001188 BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2676 0000118B C606[161B]03        <1> 	mov	byte [faz], 3  ; 3 steps/phase
  2677                              <1> lff22s_1:
  2678                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2679 00001190 AD                  <1> 	lodsw
  2680                              <1> 	; 02/02/2025
  2681 00001191 8B14                <1> 	mov	dx, [si]
  2682 00001193 49                  <1> 	dec	cx
  2683 00001194 7503                <1> 	jnz	short lff22s_2_1
  2684 00001196 BA8080              <1> 	mov	dx, 8080h
  2685                              <1> lff22s_2_1:
  2686                              <1> 	; al = [previous_val_l]
  2687                              <1> 	; ah = [previous_val_r]
  2688                              <1> 	; dl = [next_val_l]
  2689                              <1> 	; dl = [next_val_r]
  2690 00001199 E86705              <1> 	call	interpolating_3_8bit_stereo ; 1 of 17
  2691 0000119C E3BB                <1> 	jcxz	lff22s_3
  2692                              <1> lff22s_2_2:
  2693 0000119E AD                  <1> 	lodsw
  2694                              <1> 	; 02/02/2025
  2695 0000119F 8B14                <1> 	mov	dx, [si]
  2696 000011A1 49                  <1> 	dec	cx
  2697 000011A2 7503                <1> 	jnz	short lff22s_2_3
  2698 000011A4 BA8080              <1> 	mov	dx, 8080h
  2699                              <1> lff22s_2_3:
  2700 000011A7 E8BB05              <1>  	call	interpolating_2_8bit_stereo ; 2 of 17 .. 6 of 17
  2701 000011AA E3AD                <1> 	jcxz	lff22s_3
  2702 000011AC 4D                  <1> 	dec	bp
  2703 000011AD 75EF                <1> 	jnz	short lff22s_2_2
  2704                              <1> 
  2705 000011AF A0[161B]            <1> 	mov	al, [faz]
  2706 000011B2 FEC8                <1> 	dec	al
  2707 000011B4 74D2                <1> 	jz	short lff22s_9
  2708 000011B6 FE0E[161B]          <1> 	dec	byte [faz]
  2709 000011BA BD0400              <1> 	mov	bp, 4
  2710 000011BD FEC8                <1> 	dec	al
  2711 000011BF 75CF                <1> 	jnz	short lff22s_1 ; 3:2:2:2:2 ; 7-11 of 17
  2712 000011C1 45                  <1> 	inc	bp ; 5
  2713 000011C2 EBCC                <1> 	jmp	short lff22s_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2714                              <1> 
  2715                              <1> load_22khz_mono_16_bit:
  2716                              <1> 	; 02/02/2025
  2717                              <1> 	; 16/11/2023
  2718 000011C4 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2719                              <1> 					; last of the file?
  2720 000011C9 7402                <1> 	jz	short lff22m2_0		; no
  2721 000011CB F9                  <1> 	stc
  2722 000011CC C3                  <1> 	retn
  2723                              <1> 
  2724                              <1> lff22m2_0:
  2725 000011CD 8EC0                <1> 	mov	es, ax ; buffer segment
  2726 000011CF 31FF                <1> 	xor	di, di
  2727 000011D1 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2728                              <1> 	; ds = cs
  2729                              <1> 
  2730                              <1> 	; load file into memory
  2731 000011D4 8B0E[B906]          <1>         mov	cx, [loadsize]
  2732 000011D8 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2733 000011DC B43F                <1>        	mov	ah, 3Fh
  2734 000011DE CD21                <1> 	int	21h
  2735 000011E0 7248                <1> 	jc	short lff22m2_7 ; error !
  2736                              <1> 
  2737 000011E2 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2738                              <1> 	
  2739 000011E4 D1E8                <1> 	shr	ax, 1
  2740                              <1> 	;and	ax, ax
  2741 000011E6 7503                <1> 	jnz	short lff22m2_8
  2742 000011E8 E9B8F7              <1> 	jmp	lff22_eof
  2743                              <1> 
  2744                              <1> lff22m2_8:
  2745 000011EB 89C1                <1> 	mov	cx, ax	; word count
  2746                              <1> lff22m2_9:
  2747 000011ED BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2748 000011F0 C606[161B]03        <1> 	mov	byte [faz], 3  ; 3 steps/phases
  2749                              <1> lff22m2_1:
  2750                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2751 000011F5 AD                  <1> 	lodsw
  2752                              <1> 	; 02/02/2025
  2753 000011F6 8B14                <1> 	mov	dx, [si]
  2754 000011F8 49                  <1> 	dec	cx
  2755 000011F9 7502                <1> 	jnz	short lff22m2_2_1
  2756 000011FB 31D2                <1> 	xor	dx, dx
  2757                              <1> lff22m2_2_1:
  2758                              <1> 	; ax = [previous_val]
  2759                              <1> 	; dx = [next_val]
  2760 000011FD E88E05              <1> 	call	interpolating_3_16bit_mono ; 1 of 17
  2761 00001200 E325                <1> 	jcxz	lff22m2_3
  2762                              <1> lff22m2_2_2:
  2763 00001202 AD                  <1> 	lodsw
  2764                              <1> 	; 02/02/2025
  2765 00001203 8B14                <1> 	mov	dx, [si]
  2766 00001205 49                  <1> 	dec	cx
  2767 00001206 7502                <1> 	jnz	short lff22m2_2_3
  2768 00001208 31D2                <1> 	xor	dx, dx
  2769                              <1> lff22m2_2_3:
  2770 0000120A E8EE05              <1>  	call	interpolating_2_16bit_mono ; 2 of 17 .. 6 of 17
  2771 0000120D E318                <1> 	jcxz	lff22m2_3
  2772 0000120F 4D                  <1> 	dec	bp
  2773 00001210 75F0                <1> 	jnz	short lff22m2_2_2
  2774                              <1> 
  2775 00001212 A0[161B]            <1> 	mov	al, [faz]
  2776 00001215 FEC8                <1> 	dec	al
  2777 00001217 74D4                <1> 	jz	short lff22m2_9
  2778 00001219 FE0E[161B]          <1> 	dec	byte [faz]
  2779 0000121D BD0400              <1> 	mov	bp, 4
  2780 00001220 FEC8                <1> 	dec	al
  2781 00001222 75D1                <1> 	jnz	short lff22m2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2782 00001224 45                  <1> 	inc	bp ; 5
  2783 00001225 EBCE                <1> 	jmp	short lff22m2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2784                              <1> 
  2785                              <1> lff22m2_3:
  2786                              <1> lff22s2_3:
  2787 00001227 E966F7              <1> 	jmp	lff22_3	; padfill
  2788                              <1> 		; (put zeros in the remain words of the buffer)
  2789                              <1> lff22m2_7:
  2790                              <1> lff22s2_7:
  2791 0000122A E97DF7              <1> 	jmp	lff22_5  ; error
  2792                              <1> 
  2793                              <1> load_22khz_stereo_16_bit:
  2794                              <1> 	; 16/11/2023
  2795 0000122D F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2796                              <1> 					; last of the file?
  2797 00001232 7402                <1> 	jz	short lff22s2_0		; no
  2798 00001234 F9                  <1> 	stc
  2799 00001235 C3                  <1> 	retn
  2800                              <1> 
  2801                              <1> lff22s2_0:
  2802 00001236 8EC0                <1> 	mov	es, ax ; buffer segment
  2803 00001238 31FF                <1> 	xor	di, di
  2804 0000123A BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2805                              <1> 	; ds = cs
  2806                              <1> 
  2807                              <1> 	; load file into memory
  2808 0000123D 8B0E[B906]          <1>         mov	cx, [loadsize]
  2809 00001241 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2810 00001245 B43F                <1>        	mov	ah, 3Fh
  2811 00001247 CD21                <1> 	int	21h
  2812 00001249 72DF                <1> 	jc	short lff22s2_7 ; error !
  2813                              <1> 
  2814 0000124B 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2815                              <1> 	
  2816 0000124D C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  2817                              <1> 	;and	ax, ax
  2818 00001250 7503                <1> 	jnz	short lff22s2_8
  2819 00001252 E94EF7              <1> 	jmp	lff22_eof
  2820                              <1> 
  2821                              <1> lff22s2_8:
  2822 00001255 89C1                <1> 	mov	cx, ax	; dword count
  2823                              <1> lff22s2_9:
  2824 00001257 BD0500              <1> 	mov	bp, 5 ; interpolation (one step) loop count
  2825 0000125A C606[161B]03        <1> 	mov	byte [faz], 3  ; 3 steps/phase
  2826                              <1> lff22s2_1:
  2827                              <1> 	; 3:2:2:2:2:2::3:2:2:2:2::3:2:2:2:2:2  ; 37/17
  2828 0000125F AD                  <1> 	lodsw
  2829 00001260 89C3                <1> 	mov	bx, ax
  2830 00001262 AD                  <1> 	lodsw
  2831 00001263 8B14                <1> 	mov	dx, [si]
  2832 00001265 8916[121B]          <1> 	mov	[next_val_l], dx
  2833 00001269 8B5402              <1> 	mov	dx, [si+2]
  2834 0000126C 49                  <1> 	dec	cx
  2835 0000126D 7506                <1> 	jnz	short lff22s2_2_1
  2836 0000126F 31D2                <1> 	xor	dx, dx ; 0
  2837 00001271 8916[121B]          <1> 	mov	[next_val_l], dx
  2838                              <1> lff22s2_2_1:
  2839                              <1> 	; bx = [previous_val_l]
  2840                              <1> 	; ax = [previous_val_r]
  2841                              <1> 	; [next_val_l]
  2842                              <1> 	; dx = [next_val_r]
  2843 00001275 E83A05              <1> 	call	interpolating_3_16bit_stereo ; 1 of 17
  2844 00001278 E3AD                <1> 	jcxz	lff22s2_3
  2845                              <1> lff22s2_2_2:
  2846 0000127A AD                  <1> 	lodsw
  2847 0000127B 89C3                <1> 	mov	bx, ax
  2848 0000127D AD                  <1> 	lodsw
  2849 0000127E 8B14                <1> 	mov	dx, [si]
  2850 00001280 8916[121B]          <1> 	mov	[next_val_l], dx
  2851 00001284 8B5402              <1> 	mov	dx, [si+2]
  2852 00001287 49                  <1> 	dec	cx
  2853 00001288 7506                <1> 	jnz	short lff22s2_2_3
  2854 0000128A 31D2                <1> 	xor	dx, dx ; 0
  2855 0000128C 8916[121B]          <1> 	mov	[next_val_l], dx
  2856                              <1> lff22s2_2_3:
  2857 00001290 E87A05              <1>  	call	interpolating_2_16bit_stereo ; 2 of 17 .. 6 of 17
  2858 00001293 E392                <1> 	jcxz	lff22s2_3
  2859 00001295 4D                  <1> 	dec	bp
  2860 00001296 75E2                <1> 	jnz	short lff22s2_2_2
  2861                              <1> 
  2862 00001298 A0[161B]            <1> 	mov	al, [faz]
  2863 0000129B FEC8                <1> 	dec	al
  2864 0000129D 74B8                <1> 	jz	short lff22s2_9
  2865 0000129F FE0E[161B]          <1> 	dec	byte [faz]
  2866 000012A3 BD0400              <1> 	mov	bp, 4
  2867 000012A6 FEC8                <1> 	dec	al
  2868 000012A8 75B5                <1> 	jnz	short lff22s2_1 ; 3:2:2:2:2 ; 7-11 of 17
  2869 000012AA 45                  <1> 	inc	bp ; 5
  2870 000012AB EBB2                <1> 	jmp	short lff22s2_1 ; 3:2:2:2:2:2 ; 12-17 of 17
  2871                              <1> 
  2872                              <1> ; .....................
  2873                              <1> 
  2874                              <1> load_11khz_mono_8_bit:
  2875                              <1> 	; 02/02/2025
  2876                              <1> 	; 18/11/2023
  2877 000012AD F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2878                              <1> 					; last of the file?
  2879 000012B2 7402                <1> 	jz	short lff11m_0		; no
  2880 000012B4 F9                  <1> 	stc
  2881 000012B5 C3                  <1> 	retn
  2882                              <1> 
  2883                              <1> lff11m_0:
  2884 000012B6 8EC0                <1> 	mov	es, ax ; buffer segment
  2885 000012B8 31FF                <1> 	xor	di, di
  2886 000012BA BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2887                              <1> 	; ds = cs
  2888                              <1> 
  2889                              <1> 	; load file into memory
  2890 000012BD 8B0E[B906]          <1>         mov	cx, [loadsize]
  2891 000012C1 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2892 000012C5 B43F                <1>        	mov	ah, 3Fh
  2893 000012C7 CD21                <1> 	int	21h
  2894 000012C9 723D                <1> 	jc	short lff11m_7 ; error !
  2895                              <1> 
  2896 000012CB 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2897                              <1> 	
  2898 000012CD 21C0                <1> 	and	ax, ax
  2899 000012CF 7503                <1> 	jnz	short lff11m_8
  2900 000012D1 E9CFF6              <1> 	jmp	lff11_eof
  2901                              <1> 
  2902                              <1> lff11m_8:
  2903 000012D4 89C1                <1> 	mov	cx, ax	; byte count
  2904                              <1> lff11m_9:
  2905 000012D6 BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  2906                              <1> lff11m_1:
  2907                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2908 000012D9 AC                  <1> 	lodsb
  2909                              <1> 	; 02/02/2025
  2910 000012DA 8A14                <1> 	mov	dl, [si]
  2911 000012DC 49                  <1> 	dec	cx
  2912 000012DD 7502                <1> 	jnz	short lff11m_2_1
  2913 000012DF B280                <1> 	mov	dl, 80h
  2914                              <1> lff11m_2_1:
  2915                              <1> 	; al = [previous_val]
  2916                              <1> 	; dl = [next_val]
  2917 000012E1 E84F05              <1> 	call	interpolating_5_8bit_mono
  2918 000012E4 E31F                <1> 	jcxz	lff11m_3
  2919                              <1> lff11m_2_2:
  2920 000012E6 AC                  <1> 	lodsb
  2921                              <1> 	; 02/02/2025
  2922 000012E7 8A14                <1> 	mov	dl, [si]
  2923 000012E9 49                  <1> 	dec	cx
  2924 000012EA 7502                <1> 	jnz	short lff11m_2_3
  2925 000012EC B280                <1> 	mov	dl, 80h
  2926                              <1> lff11m_2_3:
  2927 000012EE E82B06              <1>  	call	interpolating_4_8bit_mono
  2928 000012F1 E312                <1> 	jcxz	lff11m_3
  2929                              <1> 
  2930 000012F3 4D                  <1> 	dec	bp
  2931 000012F4 74E0                <1> 	jz	short lff11m_9
  2932                              <1> 
  2933 000012F6 AC                  <1> 	lodsb
  2934                              <1> 	; 02/02/2025
  2935 000012F7 8A14                <1> 	mov	dl, [si]
  2936 000012F9 49                  <1> 	dec	cx
  2937 000012FA 7502                <1> 	jnz	short lff11m_2_4
  2938 000012FC B280                <1> 	mov	dl, 80h
  2939                              <1> lff11m_2_4:
  2940 000012FE E81B06              <1> 	call	interpolating_4_8bit_mono
  2941 00001301 E302                <1> 	jcxz	lff11m_3
  2942 00001303 EBD4                <1> 	jmp	short lff11m_1
  2943                              <1> 
  2944                              <1> lff11m_3:
  2945                              <1> lff11s_3:
  2946 00001305 E988F6              <1> 	jmp	lff11_3	; padfill
  2947                              <1> 		; (put zeros in the remain words of the buffer)
  2948                              <1> lff11m_7:
  2949                              <1> lff11s_7:
  2950 00001308 E99FF6              <1> 	jmp	lff11_5  ; error
  2951                              <1> 
  2952                              <1> load_11khz_stereo_8_bit:
  2953                              <1> 	; 02/02/2025
  2954                              <1> 	; 18/11/2023
  2955 0000130B F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  2956                              <1> 					; last of the file?
  2957 00001310 7402                <1> 	jz	short lff11s_0		; no
  2958 00001312 F9                  <1> 	stc
  2959 00001313 C3                  <1> 	retn
  2960                              <1> 
  2961                              <1> lff11s_0:
  2962 00001314 8EC0                <1> 	mov	es, ax ; buffer segment
  2963 00001316 31FF                <1> 	xor	di, di
  2964 00001318 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  2965                              <1> 	; ds = cs
  2966                              <1> 
  2967                              <1> 	; load file into memory
  2968 0000131B 8B0E[B906]          <1>         mov	cx, [loadsize]
  2969 0000131F 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  2970 00001323 B43F                <1>        	mov	ah, 3Fh
  2971 00001325 CD21                <1> 	int	21h
  2972 00001327 72DF                <1> 	jc	short lff11s_7 ; error !
  2973                              <1> 
  2974 00001329 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  2975                              <1> 
  2976 0000132B D1E8                <1> 	shr	ax, 1
  2977                              <1> 	;and	ax, ax
  2978 0000132D 7503                <1> 	jnz	short lff11s_8
  2979 0000132F E971F6              <1> 	jmp	lff11_eof
  2980                              <1> 
  2981                              <1> lff11s_8:
  2982 00001332 89C1                <1> 	mov	cx, ax	; word count
  2983                              <1> lff11s_9:
  2984 00001334 BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  2985                              <1> lff11s_1:
  2986                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  2987 00001337 AD                  <1> 	lodsw
  2988                              <1> 	; 02/02/2025
  2989 00001338 8B14                <1> 	mov	dx, [si]
  2990 0000133A 49                  <1> 	dec	cx
  2991 0000133B 7503                <1> 	jnz	short lff11s_2_1
  2992 0000133D BA8080              <1> 	mov	dx, 8080h
  2993                              <1> lff11s_2_1:
  2994                              <1> 	; al = [previous_val_l]
  2995                              <1> 	; ah = [previous_val_r]
  2996                              <1> 	; dl = [next_val_l]
  2997                              <1> 	; dl = [next_val_r]
  2998 00001340 E84005              <1> 	call	interpolating_5_8bit_stereo
  2999 00001343 E3C0                <1> 	jcxz	lff11s_3
  3000                              <1> lff11s_2_2:
  3001 00001345 AD                  <1> 	lodsw
  3002                              <1> 	; 02/02/2025
  3003 00001346 8B14                <1> 	mov	dx, [si]
  3004 00001348 49                  <1> 	dec	cx
  3005 00001349 7503                <1> 	jnz	short lff11s_2_3
  3006 0000134B BA8080              <1> 	mov	dx, 8080h
  3007                              <1> lff11s_2_3:
  3008 0000134E E8FE05              <1>  	call	interpolating_4_8bit_stereo
  3009 00001351 E3B2                <1> 	jcxz	lff11s_3
  3010                              <1> 	
  3011 00001353 4D                  <1> 	dec	bp
  3012 00001354 74DE                <1> 	jz	short lff11s_9
  3013                              <1> 
  3014 00001356 AD                  <1> 	lodsw
  3015                              <1> 	; 02/02/2025
  3016 00001357 8B14                <1> 	mov	dx, [si]
  3017 00001359 49                  <1> 	dec	cx
  3018 0000135A 7503                <1> 	jnz	short lff11s_2_4
  3019 0000135C BA8080              <1> 	mov	dx, 8080h
  3020                              <1> lff11s_2_4:
  3021 0000135F E8ED05              <1> 	call	interpolating_4_8bit_stereo
  3022 00001362 E3A1                <1> 	jcxz	lff11s_3
  3023 00001364 EBD1                <1> 	jmp	short lff11s_1
  3024                              <1> 
  3025                              <1> load_11khz_mono_16_bit:
  3026                              <1> 	; 02/02/2025
  3027                              <1> 	; 18/11/2023
  3028 00001366 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3029                              <1> 					; last of the file?
  3030 0000136B 7402                <1> 	jz	short lff11m2_0		; no
  3031 0000136D F9                  <1> 	stc
  3032 0000136E C3                  <1> 	retn
  3033                              <1> 
  3034                              <1> lff11m2_0:
  3035 0000136F 8EC0                <1> 	mov	es, ax ; buffer segment
  3036 00001371 31FF                <1> 	xor	di, di
  3037 00001373 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3038                              <1> 	; ds = cs
  3039                              <1> 
  3040                              <1> 	; load file into memory
  3041 00001376 8B0E[B906]          <1>         mov	cx, [loadsize]
  3042 0000137A 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3043 0000137E B43F                <1>        	mov	ah, 3Fh
  3044 00001380 CD21                <1> 	int	21h
  3045 00001382 723A                <1> 	jc	short lff11m2_7 ; error !
  3046                              <1> 
  3047 00001384 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3048                              <1> 	
  3049 00001386 D1E8                <1> 	shr	ax, 1
  3050                              <1> 	;and	ax, ax
  3051 00001388 7503                <1> 	jnz	short lff11m2_8
  3052 0000138A E916F6              <1> 	jmp	lff11_eof
  3053                              <1> 
  3054                              <1> lff11m2_8:
  3055 0000138D 89C1                <1> 	mov	cx, ax	; word count
  3056                              <1> lff11m2_9:
  3057 0000138F BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3058                              <1> lff11m2_1:
  3059                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3060 00001392 AD                  <1> 	lodsw
  3061                              <1> 	; 02/02/2025
  3062 00001393 8B14                <1> 	mov	dx, [si]
  3063 00001395 49                  <1> 	dec	cx
  3064 00001396 7502                <1> 	jnz	short lff11m2_2_1
  3065 00001398 31D2                <1> 	xor	dx, dx
  3066                              <1> lff11m2_2_1:
  3067                              <1> 	; ax = [previous_val]
  3068                              <1> 	; dx = [next_val]
  3069 0000139A E80F06              <1> 	call	interpolating_5_16bit_mono
  3070 0000139D E34A                <1> 	jcxz	lff11m2_3
  3071                              <1> lff11m2_2_2:
  3072 0000139F AD                  <1> 	lodsw
  3073                              <1> 	; 02/02/2025
  3074 000013A0 8B14                <1> 	mov	dx, [si]
  3075 000013A2 49                  <1> 	dec	cx
  3076 000013A3 7502                <1> 	jnz	short lff11m2_2_3
  3077 000013A5 31D2                <1> 	xor	dx, dx
  3078                              <1> lff11m2_2_3:
  3079 000013A7 E8DD06              <1>  	call	interpolating_4_16bit_mono
  3080 000013AA E33D                <1> 	jcxz	lff11m2_3
  3081                              <1> 
  3082 000013AC 4D                  <1> 	dec	bp
  3083 000013AD 74E0                <1> 	jz	short lff11m2_9
  3084                              <1> 
  3085 000013AF AD                  <1> 	lodsw
  3086                              <1> 	; 02/02/2025
  3087 000013B0 8B14                <1> 	mov	dx, [si]
  3088 000013B2 49                  <1> 	dec	cx
  3089 000013B3 7502                <1> 	jnz	short lff11m2_2_4
  3090 000013B5 31D2                <1> 	xor	dx, dx
  3091                              <1> lff11m2_2_4:
  3092 000013B7 E8CD06              <1>  	call	interpolating_4_16bit_mono
  3093 000013BA E32D                <1> 	jcxz	lff11m2_3
  3094 000013BC EBD4                <1> 	jmp	short lff11m2_1
  3095                              <1> 
  3096                              <1> lff11m2_7:
  3097                              <1> lff11s2_7:
  3098 000013BE E9E9F5              <1> 	jmp	lff11_5  ; error
  3099                              <1> 
  3100                              <1> load_11khz_stereo_16_bit:
  3101                              <1> 	; 18/11/2023
  3102 000013C1 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3103                              <1> 					; last of the file?
  3104 000013C6 7402                <1> 	jz	short lff11s2_0		; no
  3105 000013C8 F9                  <1> 	stc
  3106 000013C9 C3                  <1> 	retn
  3107                              <1> 
  3108                              <1> lff11s2_0:
  3109 000013CA 8EC0                <1> 	mov	es, ax ; buffer segment
  3110 000013CC 31FF                <1> 	xor	di, di
  3111 000013CE BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3112                              <1> 	; ds = cs
  3113                              <1> 
  3114                              <1> 	; load file into memory
  3115 000013D1 8B0E[B906]          <1>         mov	cx, [loadsize]
  3116 000013D5 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3117 000013D9 B43F                <1>        	mov	ah, 3Fh
  3118 000013DB CD21                <1> 	int	21h
  3119 000013DD 72DF                <1> 	jc	short lff11s2_7 ; error !
  3120                              <1> 
  3121 000013DF 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3122                              <1> 	
  3123 000013E1 C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  3124                              <1> 	;and	ax, ax
  3125 000013E4 7506                <1> 	jnz	short lff11s2_8
  3126 000013E6 E9BAF5              <1> 	jmp	lff11_eof
  3127                              <1> 
  3128                              <1> lff11m2_3:
  3129                              <1> lff11s2_3:
  3130 000013E9 E9A4F5              <1> 	jmp	lff11_3	; padfill
  3131                              <1> 		; (put zeros in the remain words of the buffer)
  3132                              <1> 
  3133                              <1> lff11s2_8:
  3134 000013EC 89C1                <1> 	mov	cx, ax	; dword count
  3135                              <1> lff11s2_9:
  3136 000013EE BD0600              <1> 	mov	bp, 6 ; interpolation (one step) loop count
  3137                              <1> lff11s2_1:
  3138                              <1> 	; 5:4:4::5:4:4::5:4:4::5:4:4::5:4:4::5:4  ; 74/17
  3139 000013F1 AD                  <1> 	lodsw
  3140 000013F2 89C3                <1> 	mov	bx, ax
  3141 000013F4 AD                  <1> 	lodsw
  3142 000013F5 8B14                <1> 	mov	dx, [si]
  3143 000013F7 8916[121B]          <1> 	mov	[next_val_l], dx
  3144 000013FB 8B5402              <1> 	mov	dx, [si+2]
  3145 000013FE 8916[141B]          <1> 	mov	[next_val_r], dx
  3146 00001402 49                  <1> 	dec	cx
  3147 00001403 750A                <1> 	jnz	short lff11s2_2_1
  3148 00001405 31D2                <1> 	xor	dx, dx ; 0
  3149 00001407 8916[121B]          <1> 	mov	[next_val_l], dx
  3150 0000140B 8916[141B]          <1> 	mov	[next_val_r], dx
  3151                              <1> lff11s2_2_1:
  3152                              <1> 	; bx = [previous_val_l]
  3153                              <1> 	; ax = [previous_val_r]
  3154                              <1> 	; [next_val_l]
  3155                              <1> 	; dx = [next_val_r]
  3156 0000140F E8DD05              <1> 	call	interpolating_5_16bit_stereo
  3157 00001412 E3D5                <1> 	jcxz	lff11s2_3
  3158                              <1> lff11s2_2_2:
  3159 00001414 AD                  <1> 	lodsw
  3160 00001415 89C3                <1> 	mov	bx, ax
  3161 00001417 AD                  <1> 	lodsw
  3162 00001418 8B14                <1> 	mov	dx, [si]
  3163 0000141A 8916[121B]          <1> 	mov	[next_val_l], dx
  3164 0000141E 8B5402              <1> 	mov	dx, [si+2]
  3165 00001421 8916[141B]          <1> 	mov	[next_val_r], dx
  3166 00001425 49                  <1> 	dec	cx
  3167 00001426 750A                <1> 	jnz	short lff11s2_2_3
  3168 00001428 31D2                <1> 	xor	dx, dx ; 0
  3169 0000142A 8916[121B]          <1> 	mov	[next_val_l], dx
  3170 0000142E 8916[141B]          <1> 	mov	[next_val_r], dx
  3171                              <1> lff11s2_2_3:
  3172 00001432 E87D06              <1>  	call	interpolating_4_16bit_stereo
  3173 00001435 E3B2                <1> 	jcxz	lff11s2_3
  3174                              <1> 
  3175 00001437 4D                  <1> 	dec	bp
  3176 00001438 74B4                <1> 	jz	short lff11s2_9
  3177                              <1> 
  3178 0000143A AD                  <1> 	lodsw
  3179 0000143B 89C3                <1> 	mov	bx, ax
  3180 0000143D AD                  <1> 	lodsw
  3181 0000143E 8B14                <1> 	mov	dx, [si]
  3182 00001440 8916[121B]          <1> 	mov	[next_val_l], dx
  3183 00001444 8B5402              <1> 	mov	dx, [si+2]
  3184 00001447 8916[141B]          <1> 	mov	[next_val_r], dx
  3185 0000144B 49                  <1> 	dec	cx
  3186 0000144C 750A                <1> 	jnz	short lff11s2_2_4
  3187 0000144E 31D2                <1> 	xor	dx, dx ; 0
  3188 00001450 8916[121B]          <1> 	mov	[next_val_l], dx
  3189 00001454 8916[141B]          <1> 	mov	[next_val_r], dx
  3190                              <1> lff11s2_2_4:
  3191 00001458 E85706              <1>  	call	interpolating_4_16bit_stereo
  3192 0000145B E38C                <1> 	jcxz	lff11s2_3
  3193 0000145D EB92                <1> 	jmp	short lff11s2_1
  3194                              <1> 
  3195                              <1> ; .....................
  3196                              <1> 
  3197                              <1> load_44khz_mono_8_bit:
  3198                              <1> 	; 02/02/2025
  3199                              <1> 	; 18/11/2023
  3200 0000145F F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3201                              <1> 					; last of the file?
  3202 00001464 7402                <1> 	jz	short lff44m_0		; no
  3203 00001466 F9                  <1> 	stc
  3204 00001467 C3                  <1> 	retn
  3205                              <1> 
  3206                              <1> lff44m_0:
  3207 00001468 8EC0                <1> 	mov	es, ax ; buffer segment
  3208 0000146A 31FF                <1> 	xor	di, di
  3209 0000146C BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3210                              <1> 	; ds = cs
  3211                              <1> 
  3212                              <1> 	; load file into memory
  3213 0000146F 8B0E[B906]          <1>         mov	cx, [loadsize]
  3214 00001473 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3215 00001477 B43F                <1>        	mov	ah, 3Fh
  3216 00001479 CD21                <1> 	int	21h
  3217 0000147B 723C                <1> 	jc	short lff44m_7 ; error !
  3218                              <1> 
  3219 0000147D 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3220                              <1> 
  3221 0000147F 21C0                <1> 	and	ax, ax
  3222 00001481 7503                <1> 	jnz	short lff44m_8
  3223 00001483 E91DF5              <1> 	jmp	lff44_eof
  3224                              <1> 
  3225                              <1> lff44m_8:
  3226 00001486 89C1                <1> 	mov	cx, ax	; byte count
  3227                              <1> lff44m_9:
  3228 00001488 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3229 0000148B C606[161B]02        <1> 	mov	byte [faz], 2  ; 2 steps/phases
  3230                              <1> lff44m_1:
  3231                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3232                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3233 00001490 AC                  <1> 	lodsb
  3234                              <1> 	; 02/02/2025
  3235 00001491 8A14                <1> 	mov	dl, [si]
  3236 00001493 49                  <1> 	dec	cx
  3237 00001494 7502                <1> 	jnz	short lff44m_2_1
  3238 00001496 B280                <1> 	mov	dl, 80h
  3239                              <1> lff44m_2_1:
  3240                              <1> 	; al = [previous_val]
  3241                              <1> 	; dl = [next_val]
  3242 00001498 E8B302              <1> 	call	interpolating_2_8bit_mono
  3243 0000149B E319                <1> 	jcxz	lff44m_3
  3244                              <1> lff44m_2_2:
  3245 0000149D AC                  <1> 	lodsb
  3246 0000149E 2C80                <1> 	sub	al, 80h
  3247 000014A0 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3248 000014A3 AB                  <1> 	stosw		; (L)
  3249 000014A4 AB                  <1> 	stosw		; (R)
  3250                              <1> 
  3251 000014A5 49                  <1> 	dec	cx
  3252 000014A6 740E                <1> 	jz	short lff44m_3
  3253 000014A8 4D                  <1> 	dec	bp
  3254 000014A9 75F2                <1> 	jnz	short lff44m_2_2
  3255                              <1> 
  3256 000014AB FE0E[161B]          <1> 	dec	byte [faz]
  3257 000014AF 74D7                <1> 	jz	short lff44m_9 
  3258 000014B1 BD0B00              <1> 	mov	bp, 11
  3259 000014B4 EBDA                <1> 	jmp	short lff44m_1
  3260                              <1> 
  3261                              <1> lff44m_3:
  3262                              <1> lff44s_3:
  3263 000014B6 E9D7F4              <1> 	jmp	lff44_3	; padfill
  3264                              <1> 		; (put zeros in the remain words of the buffer)
  3265                              <1> lff44m_7:
  3266                              <1> lff44s_7:
  3267 000014B9 E9EEF4              <1> 	jmp	lff44_5  ; error
  3268                              <1> 
  3269                              <1> load_44khz_stereo_8_bit:
  3270                              <1> 	; 02/02/2025
  3271                              <1> 	; 16/11/2023
  3272 000014BC F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3273                              <1> 					; last of the file?
  3274 000014C1 7402                <1> 	jz	short lff44s_0		; no
  3275 000014C3 F9                  <1> 	stc
  3276 000014C4 C3                  <1> 	retn
  3277                              <1> 
  3278                              <1> lff44s_0:
  3279 000014C5 8EC0                <1> 	mov	es, ax ; buffer segment
  3280 000014C7 31FF                <1> 	xor	di, di
  3281 000014C9 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3282                              <1> 	; ds = cs
  3283                              <1> 
  3284                              <1> 	; load file into memory
  3285 000014CC 8B0E[B906]          <1>         mov	cx, [loadsize]
  3286 000014D0 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3287 000014D4 B43F                <1>        	mov	ah, 3Fh
  3288 000014D6 CD21                <1> 	int	21h
  3289 000014D8 72DF                <1> 	jc	short lff44s_7 ; error !
  3290                              <1> 
  3291 000014DA 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3292                              <1> 
  3293 000014DC D1E8                <1> 	shr	ax, 1
  3294                              <1> 	;and	ax, ax
  3295 000014DE 7503                <1> 	jnz	short lff44s_8
  3296 000014E0 E9C0F4              <1> 	jmp	lff44_eof
  3297                              <1> 
  3298                              <1> lff44s_8:
  3299 000014E3 89C1                <1> 	mov	cx, ax	; word count
  3300                              <1> lff44s_9:
  3301 000014E5 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3302 000014E8 C606[161B]02        <1> 	mov	byte [faz], 2  ; 2 steps/phase
  3303                              <1> lff44s_1:
  3304                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3305                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3306 000014ED AD                  <1> 	lodsw
  3307                              <1> 	; 02/02/2025
  3308 000014EE 8B14                <1> 	mov	dx, [si]
  3309 000014F0 49                  <1> 	dec	cx
  3310 000014F1 7503                <1> 	jnz	short lff44s_2_1
  3311 000014F3 BA8080              <1> 	mov	dx, 8080h
  3312                              <1> lff44s_2_1:
  3313                              <1> 	; al = [previous_val_l]
  3314                              <1> 	; ah = [previous_val_r]
  3315                              <1> 	; dl = [next_val_l]
  3316                              <1> 	; dl = [next_val_r]
  3317 000014F6 E86C02              <1> 	call	interpolating_2_8bit_stereo
  3318 000014F9 E3BB                <1> 	jcxz	lff44s_3
  3319                              <1> lff44s_2_2:
  3320 000014FB AC                  <1> 	lodsb
  3321 000014FC 2C80                <1> 	sub	al, 80h
  3322 000014FE C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3323 00001501 AB                  <1> 	stosw		; (L)
  3324 00001502 AC                  <1> 	lodsb
  3325 00001503 2C80                <1> 	sub	al, 80h
  3326 00001505 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3327 00001508 AB                  <1> 	stosw		; (R)
  3328                              <1> 
  3329 00001509 49                  <1> 	dec	cx
  3330 0000150A 74AA                <1> 	jz	short lff44s_3
  3331 0000150C 4D                  <1> 	dec	bp
  3332 0000150D 75EC                <1> 	jnz	short lff44s_2_2
  3333                              <1> 	
  3334 0000150F FE0E[161B]          <1> 	dec	byte [faz]
  3335 00001513 74D0                <1> 	jz	short lff44s_9
  3336 00001515 BD0B00              <1> 	mov	bp, 11
  3337 00001518 EBD3                <1> 	jmp	short lff44s_1
  3338                              <1> 
  3339                              <1> load_44khz_mono_16_bit:
  3340                              <1> 	; 02/02/2025
  3341                              <1> 	; 18/11/2023
  3342 0000151A F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3343                              <1> 					; last of the file?
  3344 0000151F 7402                <1> 	jz	short lff44m2_0		; no
  3345 00001521 F9                  <1> 	stc
  3346 00001522 C3                  <1> 	retn
  3347                              <1> 
  3348                              <1> lff44m2_0:
  3349 00001523 8EC0                <1> 	mov	es, ax ; buffer segment
  3350 00001525 31FF                <1> 	xor	di, di
  3351 00001527 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3352                              <1> 	; ds = cs
  3353                              <1> 
  3354                              <1> 	; load file into memory
  3355 0000152A 8B0E[B906]          <1>         mov	cx, [loadsize]
  3356 0000152E 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3357 00001532 B43F                <1>        	mov	ah, 3Fh
  3358 00001534 CD21                <1> 	int	21h
  3359 00001536 7237                <1> 	jc	short lff44m2_7 ; error !
  3360                              <1> 
  3361 00001538 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3362                              <1> 
  3363 0000153A D1E8                <1> 	shr	ax, 1
  3364                              <1> 	;and	ax, ax
  3365 0000153C 7503                <1> 	jnz	short lff44m2_8
  3366 0000153E E962F4              <1> 	jmp	lff44_eof
  3367                              <1> 
  3368                              <1> lff44m2_8:
  3369 00001541 89C1                <1> 	mov	cx, ax	; word count
  3370                              <1> lff44m2_9:
  3371 00001543 BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3372 00001546 C606[161B]02        <1> 	mov	byte [faz], 2  ; 2 steps/phases
  3373                              <1> lff44m2_1:
  3374                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3375                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3376 0000154B AD                  <1> 	lodsw
  3377                              <1> 	; 02/02/2025
  3378 0000154C 8B14                <1> 	mov	dx, [si]
  3379 0000154E 49                  <1> 	dec	cx
  3380 0000154F 7502                <1> 	jnz	short lff44m2_2_1
  3381 00001551 31D2                <1> 	xor	dx, dx
  3382                              <1> lff44m2_2_1:
  3383                              <1> 	; ax = [previous_val]
  3384                              <1> 	; dx = [next_val]
  3385 00001553 E8A502              <1> 	call	interpolating_2_16bit_mono
  3386 00001556 E314                <1> 	jcxz	lff44m2_3
  3387                              <1> lff44m2_2_2:
  3388 00001558 AD                  <1> 	lodsw
  3389 00001559 AB                  <1> 	stosw		; (L)eft Channel
  3390 0000155A AB                  <1> 	stosw		; (R)ight Channel
  3391                              <1> 
  3392 0000155B 49                  <1> 	dec	cx
  3393 0000155C 740E                <1> 	jz	short lff44m2_3	
  3394 0000155E 4D                  <1> 	dec	bp
  3395 0000155F 75F7                <1> 	jnz	short lff44m2_2_2
  3396                              <1> 
  3397 00001561 FE0E[161B]          <1> 	dec	byte [faz]
  3398 00001565 74DC                <1> 	jz	short lff44m2_9 
  3399 00001567 BD0B00              <1> 	mov	bp, 11
  3400 0000156A EBDF                <1> 	jmp	short lff44m2_1
  3401                              <1> 
  3402                              <1> lff44m2_3:
  3403                              <1> lff44s2_3:
  3404 0000156C E921F4              <1> 	jmp	lff44_3	; padfill
  3405                              <1> 		; (put zeros in the remain words of the buffer)
  3406                              <1> lff44m2_7:
  3407                              <1> lff44s2_7:
  3408 0000156F E938F4              <1> 	jmp	lff44_5  ; error
  3409                              <1> 
  3410                              <1> load_44khz_stereo_16_bit:
  3411                              <1> 	; 18/11/2023
  3412 00001572 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3413                              <1> 					; last of the file?
  3414 00001577 7402                <1> 	jz	short lff44s2_0		; no
  3415 00001579 F9                  <1> 	stc
  3416 0000157A C3                  <1> 	retn
  3417                              <1> 
  3418                              <1> lff44s2_0:
  3419 0000157B 8EC0                <1> 	mov	es, ax ; buffer segment
  3420 0000157D 31FF                <1> 	xor	di, di
  3421 0000157F BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3422                              <1> 	; ds = cs
  3423                              <1> 
  3424                              <1> 	; load file into memory
  3425 00001582 8B0E[B906]          <1>         mov	cx, [loadsize]
  3426 00001586 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3427 0000158A B43F                <1>        	mov	ah, 3Fh
  3428 0000158C CD21                <1> 	int	21h
  3429 0000158E 72DF                <1> 	jc	short lff44s2_7 ; error !
  3430                              <1> 
  3431 00001590 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3432                              <1> 	
  3433 00001592 C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  3434                              <1> 	;and	ax, ax
  3435 00001595 7503                <1> 	jnz	short lff44s2_8
  3436 00001597 E909F4              <1> 	jmp	lff44_eof
  3437                              <1> 
  3438                              <1> lff44s2_8:
  3439 0000159A 89C1                <1> 	mov	cx, ax	; dword count
  3440                              <1> lff44s2_9:
  3441 0000159C BD0A00              <1> 	mov	bp, 10 ; interpolation (one step) loop count
  3442 0000159F C606[161B]02        <1> 	mov	byte [faz], 2  ; 2 steps/phase
  3443                              <1> lff44s2_1:
  3444                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1::	; 25/23
  3445                              <1> 	; 2:1:1:1:1:1:1:1:1:1:1:1
  3446 000015A4 AD                  <1> 	lodsw
  3447 000015A5 89C3                <1> 	mov	bx, ax
  3448 000015A7 AD                  <1> 	lodsw
  3449 000015A8 8B14                <1> 	mov	dx, [si]
  3450 000015AA 8916[121B]          <1> 	mov	[next_val_l], dx
  3451 000015AE 8B5402              <1> 	mov	dx, [si+2]
  3452 000015B1 49                  <1> 	dec	cx
  3453 000015B2 7506                <1> 	jnz	short lff44s2_2_1
  3454 000015B4 31D2                <1> 	xor	dx, dx ; 0
  3455 000015B6 8916[121B]          <1> 	mov	[next_val_l], dx
  3456                              <1> lff44s2_2_1:
  3457                              <1> 	; bx = [previous_val_l]
  3458                              <1> 	; ax = [previous_val_r]
  3459                              <1> 	; [next_val_l]
  3460                              <1> 	; dx = [next_val_r]
  3461 000015BA E85002              <1> 	call	interpolating_2_16bit_stereo
  3462 000015BD E3AD                <1> 	jcxz	lff44s2_3
  3463                              <1> lff44s2_2_2:
  3464                              <1> 	;lodsw
  3465                              <1> 	;stosw		; (L)
  3466                              <1> 	;lodsw
  3467                              <1> 	;stosw		; (R)
  3468 000015BF A5                  <1> 	movsw		; (L)eft Channel
  3469 000015C0 A5                  <1> 	movsw		; (R)ight Channel
  3470                              <1> 
  3471 000015C1 49                  <1> 	dec	cx
  3472 000015C2 74A8                <1> 	jz	short lff44s2_3
  3473 000015C4 4D                  <1> 	dec	bp
  3474 000015C5 75F8                <1> 	jnz	short lff44s2_2_2
  3475                              <1> 	
  3476 000015C7 FE0E[161B]          <1> 	dec	byte [faz]
  3477 000015CB 74CF                <1> 	jz	short lff44s2_9
  3478 000015CD BD0B00              <1> 	mov	bp, 11
  3479 000015D0 EBD2                <1> 	jmp	short lff44s2_1
  3480                              <1> 
  3481                              <1> ; .....................
  3482                              <1> 
  3483                              <1> 	; 02/02/2025
  3484                              <1> load_12khz_mono_8_bit:
  3485 000015D2 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3486                              <1> 					; last of the file?
  3487 000015D7 7402                <1> 	jz	short lff12m_0		; no
  3488 000015D9 F9                  <1> 	stc
  3489 000015DA C3                  <1> 	retn
  3490                              <1> 
  3491                              <1> lff12m_0:
  3492 000015DB 8EC0                <1> 	mov	es, ax ; buffer segment
  3493 000015DD 31FF                <1> 	xor	di, di
  3494 000015DF BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3495                              <1> 	; ds = cs
  3496                              <1> 
  3497                              <1> 	; load file into memory
  3498 000015E2 8B0E[B906]          <1>         mov	cx, [loadsize]
  3499 000015E6 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3500 000015EA B43F                <1>        	mov	ah, 3Fh
  3501 000015EC CD21                <1> 	int	21h
  3502 000015EE 7241                <1> 	jc	short lff12m_7 ; error !
  3503                              <1> 
  3504 000015F0 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3505                              <1> 
  3506 000015F2 21C0                <1> 	and	ax, ax
  3507 000015F4 7503                <1> 	jnz	short lff12m_8
  3508 000015F6 E9AAF3              <1> 	jmp	lff12_eof
  3509                              <1> 
  3510                              <1> lff12m_8:
  3511 000015F9 89C1                <1> 	mov	cx, ax	; byte count
  3512                              <1> lff12m_1:
  3513                              <1> 	; original-interpolated-interpolated-interpolated
  3514 000015FB AC                  <1> 	lodsb
  3515                              <1> 	; 02/02/2025
  3516 000015FC 8A14                <1> 	mov	dl, [si]
  3517 000015FE 49                  <1> 	dec	cx
  3518 000015FF 7502                <1> 	jnz	short lff12m_2
  3519 00001601 B280                <1> 	mov	dl, 80h
  3520                              <1> lff12m_2:
  3521                              <1> 	; al = [previous_val]
  3522                              <1> 	; dl = [next_val]
  3523 00001603 E81603              <1>  	call	interpolating_4_8bit_mono
  3524 00001606 E33F                <1> 	jcxz	lff12m_3
  3525 00001608 EBF1                <1> 	jmp	short lff12m_1
  3526                              <1> 
  3527                              <1> 	; 02/02/2025
  3528                              <1> load_12khz_stereo_8_bit:
  3529 0000160A F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3530                              <1> 					; last of the file?
  3531 0000160F 7402                <1> 	jz	short lff12s_0		; no
  3532 00001611 F9                  <1> 	stc
  3533 00001612 C3                  <1> 	retn
  3534                              <1> 
  3535                              <1> lff12s_0:
  3536 00001613 8EC0                <1> 	mov	es, ax ; buffer segment
  3537 00001615 31FF                <1> 	xor	di, di
  3538 00001617 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3539                              <1> 	; ds = cs
  3540                              <1> 
  3541                              <1> 	; load file into memory
  3542 0000161A 8B0E[B906]          <1>         mov	cx, [loadsize]
  3543 0000161E 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3544 00001622 B43F                <1>        	mov	ah, 3Fh
  3545 00001624 CD21                <1> 	int	21h
  3546 00001626 7209                <1> 	jc	short lff12s_7 ; error !
  3547                              <1> 
  3548 00001628 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3549                              <1> 	
  3550 0000162A D1E8                <1> 	shr	ax, 1
  3551                              <1> 	;and	ax, ax
  3552 0000162C 7506                <1> 	jnz	short lff12s_8
  3553 0000162E E972F3              <1> 	jmp	lff12_eof
  3554                              <1> 
  3555                              <1> lff12m_7:
  3556                              <1> lff12s_7:
  3557 00001631 E976F3              <1> 	jmp	lff12_5  ; error
  3558                              <1> 
  3559                              <1> lff12s_8:
  3560 00001634 89C1                <1> 	mov	cx, ax	; word count
  3561                              <1> lff12s_1:
  3562                              <1> 	; original-interpolated-interpolated-interpolated
  3563 00001636 AD                  <1> 	lodsw
  3564                              <1> 	; 02/02/2025
  3565 00001637 8B14                <1> 	mov	dx, [si]
  3566 00001639 49                  <1> 	dec	cx
  3567 0000163A 7503                <1> 	jnz	short lff12s_2
  3568 0000163C BA8080              <1> 	mov	dx, 8080h
  3569                              <1> lff12s_2:
  3570                              <1> 	; al = [previous_val_l]
  3571                              <1> 	; ah = [previous_val_r]
  3572                              <1> 	; dl = [next_val_l]
  3573                              <1> 	; dh = [next_val_r]
  3574 0000163F E80D03              <1> 	call	interpolating_4_8bit_stereo
  3575 00001642 67E302              <1> 	jecxz	lff12s_3
  3576 00001645 EBEF                <1> 	jmp	short lff12s_1
  3577                              <1> 
  3578                              <1> lff12m_3:
  3579                              <1> lff12s_3:
  3580 00001647 E946F3              <1> 	jmp	lff12_3	; padfill
  3581                              <1> 		; (put zeros in the remain words of the buffer)
  3582                              <1> 
  3583                              <1> 	; 02/02/2025
  3584                              <1> load_12khz_mono_16_bit:
  3585 0000164A F606[8E1F]01        <1> 	test    byte [flags], ENDOFFILE	; have we already read the
  3586                              <1> 					; last of the file?
  3587 0000164F 7402                <1> 	jz	short lff12m2_0		; no
  3588 00001651 F9                  <1> 	stc
  3589 00001652 C3                  <1> 	retn
  3590                              <1> 
  3591                              <1> lff12m2_0:
  3592 00001653 8EC0                <1> 	mov	es, ax ; buffer segment
  3593 00001655 31FF                <1> 	xor	di, di
  3594 00001657 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3595                              <1> 	; ds = cs
  3596                              <1> 
  3597                              <1> 	; load file into memory
  3598 0000165A 8B0E[B906]          <1>         mov	cx, [loadsize]
  3599 0000165E 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3600 00001662 B43F                <1>        	mov	ah, 3Fh
  3601 00001664 CD21                <1> 	int	21h
  3602 00001666 721B                <1> 	jc	short lff12m2_7 ; error !
  3603                              <1> 
  3604 00001668 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3605                              <1> 	
  3606 0000166A D1E8                <1> 	shr	ax, 1
  3607                              <1> 	;and	ax, ax
  3608 0000166C 7503                <1> 	jnz	short lff12m2_8
  3609 0000166E E932F3              <1> 	jmp	lff12_eof
  3610                              <1> 
  3611                              <1> lff12m2_8:
  3612 00001671 89C1                <1> 	mov	cx, ax	; word count
  3613                              <1> lff12m2_1:
  3614                              <1> 	; original-interpolated-interpolated-interpolated
  3615 00001673 AD                  <1> 	lodsw
  3616                              <1> 	; 02/02/2025
  3617 00001674 8B14                <1> 	mov	dx, [si]
  3618 00001676 49                  <1> 	dec	cx
  3619 00001677 7502                <1> 	jnz	short lff12m2_2
  3620 00001679 31D2                <1> 	xor	dx, dx
  3621                              <1> lff12m2_2:
  3622                              <1> 	; ax = [previous_val]
  3623                              <1> 	; dx = [next_val]
  3624 0000167B E80904              <1>  	call	interpolating_4_16bit_mono
  3625 0000167E 67E3C6              <1> 	jecxz	lff12m_3
  3626 00001681 EBF0                <1> 	jmp	short lff12m2_1
  3627                              <1> 
  3628                              <1> lff12m2_7:
  3629                              <1> lff12s2_7:
  3630 00001683 E924F3              <1> 	jmp	lff12_5  ; error
  3631                              <1> 
  3632                              <1> 	; 02/02/2025
  3633                              <1> load_12khz_stereo_16_bit:
  3634 00001686 F606[8E1F]01        <1>         test    byte [flags], ENDOFFILE	; have we already read the
  3635                              <1> 					; last of the file?
  3636 0000168B 7402                <1> 	jz	short lff12s2_0		; no
  3637 0000168D F9                  <1> 	stc
  3638 0000168E C3                  <1> 	retn
  3639                              <1> 
  3640                              <1> lff12s2_0:
  3641 0000168F 8EC0                <1> 	mov	es, ax ; buffer segment
  3642 00001691 31FF                <1> 	xor	di, di
  3643 00001693 BA[B41F]            <1> 	mov	dx, temp_buffer ; temporary buffer for wav data
  3644                              <1> 	; ds = cs
  3645                              <1> 
  3646                              <1> 	; load file into memory
  3647 00001696 8B0E[B906]          <1>         mov	cx, [loadsize]
  3648 0000169A 8B1E[8C1F]          <1> 	mov	bx, [filehandle]
  3649 0000169E B43F                <1>        	mov	ah, 3Fh
  3650 000016A0 CD21                <1> 	int	21h
  3651 000016A2 72DF                <1> 	jc	short lff12s2_7 ; error !
  3652                              <1> 
  3653 000016A4 89D6                <1> 	mov	si, dx ; temp_buffer ; temporary buffer address
  3654                              <1> 	
  3655 000016A6 C1E802              <1> 	shr	ax, 2	; dword (left chan word + right chan word)
  3656                              <1> 	;and	ax, ax
  3657 000016A9 7506                <1> 	jnz	short lff12s2_8
  3658 000016AB E9F5F2              <1> 	jmp	lff12_eof
  3659                              <1> 
  3660                              <1> lff12m2_3:
  3661                              <1> lff12s2_3:
  3662 000016AE E9DFF2              <1> 	jmp	lff12_3	; padfill
  3663                              <1> 		; (put zeros in the remain words of the buffer)
  3664                              <1> 
  3665                              <1> lff12s2_8:
  3666 000016B1 89C1                <1> 	mov	cx, ax	; dword count
  3667                              <1> lff12s2_1:
  3668                              <1> 	; original-interpolated-interpolated-interpolated
  3669 000016B3 AD                  <1> 	lodsw
  3670 000016B4 89C3                <1> 	mov	bx, ax
  3671 000016B6 AD                  <1> 	lodsw
  3672                              <1> 	; 02/02/2025
  3673 000016B7 8B14                <1> 	mov	dx, [si]
  3674 000016B9 8916[121B]          <1> 	mov	[next_val_l], dx
  3675 000016BD 8B5402              <1> 	mov	dx, [si+2]
  3676 000016C0 8916[141B]          <1> 	mov	[next_val_r], dx
  3677 000016C4 49                  <1> 	dec	cx
  3678 000016C5 750A                <1> 	jnz	short lff12s2_2
  3679 000016C7 31D2                <1> 	xor	dx, dx ; 0
  3680 000016C9 8916[121B]          <1> 	mov	[next_val_l], dx
  3681 000016CD 8916[141B]          <1> 	mov	[next_val_r], dx
  3682                              <1> lff12s2_2:
  3683                              <1> 	; bx = [previous_val_l]
  3684                              <1> 	; ax = [previous_val_r]
  3685                              <1> 	; [next_val_l]
  3686                              <1> 	; [next_val_r]
  3687 000016D1 E8DE03              <1> 	call	interpolating_4_16bit_stereo
  3688 000016D4 67E3D7              <1> 	jecxz	lff12s2_3
  3689 000016D7 EBDA                <1> 	jmp	short lff12s2_1
  3690                              <1> 
  3691                              <1> ; .....................
  3692                              <1> 
  3693                              <1> interpolating_3_8bit_mono:
  3694                              <1> 	; 02/02/2025
  3695                              <1> 	; 16/11/2023
  3696                              <1> 	; al = [previous_val]
  3697                              <1> 	; dl = [next_val]
  3698                              <1> 	; original-interpolated-interpolated
  3699 000016D9 88C3                <1> 	mov	bl, al
  3700 000016DB 2C80                <1> 	sub	al, 80h
  3701 000016DD C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3702 000016E0 AB                  <1> 	stosw		; original sample (L)
  3703 000016E1 AB                  <1> 	stosw		; original sample (R)
  3704 000016E2 88D8                <1> 	mov	al, bl
  3705 000016E4 00D0                <1> 	add	al, dl
  3706 000016E6 D0D8                <1> 	rcr	al, 1
  3707 000016E8 88C7                <1> 	mov	bh, al	; interpolated middle (temporary)
  3708 000016EA 00D8                <1> 	add	al, bl
  3709 000016EC D0D8                <1> 	rcr	al, 1
  3710 000016EE 2C80                <1> 	sub	al, 80h
  3711 000016F0 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3712 000016F3 AB                  <1> 	stosw		; interpolated sample 1 (L)
  3713 000016F4 AB                  <1> 	stosw		; interpolated sample 1 (R)
  3714 000016F5 88F8                <1> 	mov	al, bh
  3715 000016F7 00D0                <1> 	add	al, dl	; [next_val]
  3716 000016F9 D0D8                <1> 	rcr	al, 1
  3717                              <1> 	; 02/02/2025
  3718 000016FB 2C80                <1> 	sub	al, 80h
  3719 000016FD C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3720 00001700 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3721 00001701 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3722 00001702 C3                  <1> 	retn
  3723                              <1> 
  3724                              <1> interpolating_3_8bit_stereo:
  3725                              <1> 	; 02/02/2025
  3726                              <1> 	; 16/11/2023
  3727                              <1> 	; al = [previous_val_l]
  3728                              <1> 	; ah = [previous_val_r]
  3729                              <1> 	; dl = [next_val_l]
  3730                              <1> 	; dh = [next_val_r]
  3731                              <1> 	; original-interpolated-interpolated
  3732 00001703 89C3                <1> 	mov	bx, ax
  3733 00001705 2C80                <1> 	sub	al, 80h
  3734 00001707 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3735 0000170A AB                  <1> 	stosw		; original sample (L)
  3736 0000170B 88F8                <1> 	mov	al, bh
  3737 0000170D 2C80                <1> 	sub	al, 80h
  3738 0000170F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3739 00001712 AB                  <1> 	stosw		; original sample (R)
  3740 00001713 88D8                <1> 	mov	al, bl
  3741 00001715 00D0                <1> 	add	al, dl	; [next_val_l]
  3742 00001717 D0D8                <1> 	rcr	al, 1
  3743 00001719 50                  <1> 	push	ax ; *	; al = interpolated middle (L) (temporary)
  3744 0000171A 00D8                <1> 	add	al, bl	; [previous_val_l]
  3745 0000171C D0D8                <1> 	rcr	al, 1
  3746 0000171E 2C80                <1> 	sub	al, 80h
  3747 00001720 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3748 00001723 AB                  <1> 	stosw		; interpolated sample 1 (L)
  3749 00001724 88F8                <1> 	mov	al, bh
  3750 00001726 00F0                <1> 	add	al, dh	; [next_val_r]
  3751 00001728 D0D8                <1> 	rcr	al, 1
  3752 0000172A 50                  <1> 	push	ax ; ** ; al = interpolated middle (R) (temporary)
  3753 0000172B 00F8                <1> 	add	al, bh	; [previous_val_r]
  3754 0000172D D0D8                <1> 	rcr	al, 1
  3755 0000172F 2C80                <1> 	sub	al, 80h
  3756 00001731 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3757 00001734 AB                  <1> 	stosw		; interpolated sample 1 (R)
  3758 00001735 5B                  <1> 	pop	bx ; **
  3759 00001736 58                  <1> 	pop	ax ; *
  3760 00001737 00D0                <1> 	add	al, dl	; [next_val_l]
  3761 00001739 D0D8                <1> 	rcr	al, 1
  3762                              <1> 	; 02/02/2025
  3763 0000173B 2C80                <1> 	sub	al, 80h
  3764 0000173D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3765 00001740 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3766 00001741 88D8                <1> 	mov	al, bl
  3767 00001743 00F0                <1> 	add	al, dh	; [next_val_r]
  3768 00001745 D0D8                <1> 	rcr	al, 1
  3769                              <1> 	; 02/02/2025
  3770 00001747 2C80                <1> 	sub	al, 80h
  3771 00001749 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3772 0000174C AB                  <1> 	stosw		; interpolated sample 2 (R)
  3773 0000174D C3                  <1> 	retn
  3774                              <1> 
  3775                              <1> interpolating_2_8bit_mono:
  3776                              <1> 	; 16/11/2023
  3777                              <1> 	; al = [previous_val]
  3778                              <1> 	; dl = [next_val]
  3779                              <1> 	; original-interpolated
  3780 0000174E 88C3                <1> 	mov	bl, al
  3781 00001750 2C80                <1> 	sub	al, 80h
  3782 00001752 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3783 00001755 AB                  <1> 	stosw		; original sample (L)
  3784 00001756 AB                  <1> 	stosw		; original sample (R)
  3785 00001757 88D8                <1> 	mov	al, bl
  3786 00001759 00D0                <1> 	add	al, dl
  3787 0000175B D0D8                <1> 	rcr	al, 1
  3788 0000175D 2C80                <1> 	sub	al, 80h
  3789 0000175F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3790 00001762 AB                  <1> 	stosw		; interpolated sample (L)
  3791 00001763 AB                  <1> 	stosw		; interpolated sample (R)
  3792 00001764 C3                  <1> 	retn
  3793                              <1> 
  3794                              <1> interpolating_2_8bit_stereo:
  3795                              <1> 	; 16/11/2023
  3796                              <1> 	; al = [previous_val_l]
  3797                              <1> 	; ah = [previous_val_r]
  3798                              <1> 	; dl = [next_val_l]
  3799                              <1> 	; dh = [next_val_r]
  3800                              <1> 	; original-interpolated
  3801 00001765 89C3                <1> 	mov	bx, ax
  3802 00001767 2C80                <1> 	sub	al, 80h
  3803 00001769 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3804 0000176C AB                  <1> 	stosw		; original sample (L)
  3805 0000176D 88F8                <1> 	mov	al, bh
  3806 0000176F 2C80                <1> 	sub	al, 80h
  3807 00001771 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3808 00001774 AB                  <1> 	stosw		; original sample (R)
  3809 00001775 88D8                <1> 	mov	al, bl	; [previous_val_l]
  3810 00001777 00D0                <1> 	add	al, dl	; [next_val_l]	
  3811 00001779 D0D8                <1> 	rcr	al, 1
  3812 0000177B 2C80                <1> 	sub	al, 80h
  3813 0000177D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3814 00001780 AB                  <1> 	stosw		; interpolated sample (L)
  3815 00001781 88F8                <1> 	mov	al, bh
  3816 00001783 00F0                <1> 	add	al, dh	; [next_val_r]
  3817 00001785 D0D8                <1> 	rcr	al, 1
  3818 00001787 2C80                <1> 	sub	al, 80h
  3819 00001789 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3820 0000178C AB                  <1> 	stosw		; interpolated sample (R)
  3821 0000178D C3                  <1> 	retn
  3822                              <1> 
  3823                              <1> interpolating_3_16bit_mono:
  3824                              <1> 	; 16/11/2023
  3825                              <1> 	; ax = [previous_val]
  3826                              <1> 	; dx = [next_val]
  3827                              <1> 	; original-interpolated-interpolated
  3828                              <1> 
  3829 0000178E AB                  <1> 	stosw		; original sample (L)
  3830 0000178F AB                  <1> 	stosw		; original sample (R)
  3831 00001790 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3832 00001793 50                  <1> 	push	ax ; *	; [previous_val]
  3833 00001794 80C680              <1> 	add	dh, 80h
  3834 00001797 01D0                <1> 	add	ax, dx
  3835 00001799 D1D8                <1> 	rcr	ax, 1
  3836 0000179B 5B                  <1> 	pop	bx ; *
  3837 0000179C 93                  <1> 	xchg	bx, ax	; bx  = interpolated middle (temporary)
  3838 0000179D 01D8                <1> 	add	ax, bx	; [previous_val] + interpolated middle
  3839 0000179F D1D8                <1> 	rcr	ax, 1
  3840 000017A1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3841 000017A4 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  3842 000017A5 AB                  <1> 	stosw		; interpolated sample 1 (R)
  3843 000017A6 89D8                <1> 	mov	ax, bx
  3844 000017A8 01D0                <1> 	add	ax, dx	 ;interpolated middle + [next_val]
  3845 000017AA D1D8                <1> 	rcr	ax, 1
  3846 000017AC 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3847 000017AF AB                  <1> 	stosw		; interpolated sample 2 (L)
  3848 000017B0 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3849 000017B1 C3                  <1> 	retn
  3850                              <1> 
  3851                              <1> interpolating_3_16bit_stereo:
  3852                              <1> 	; 16/11/2023
  3853                              <1> 	; bx = [previous_val_l]
  3854                              <1> 	; ax = [previous_val_r]
  3855                              <1> 	; [next_val_l]
  3856                              <1> 	; dx = [next_val_r]
  3857                              <1> 	; original-interpolated-interpolated
  3858                              <1> 
  3859 000017B2 93                  <1> 	xchg	ax, bx
  3860 000017B3 AB                  <1> 	stosw		; original sample (L)
  3861 000017B4 93                  <1> 	xchg	ax, bx
  3862 000017B5 AB                  <1> 	stosw		; original sample (R)
  3863 000017B6 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3864 000017B9 50                  <1> 	push	ax ; *	; [previous_val_r]
  3865 000017BA 80C780              <1> 	add	bh, 80h
  3866 000017BD 8006[131B]80        <1> 	add	byte [next_val_l+1], 80h
  3867 000017C2 A1[121B]            <1> 	mov	ax, [next_val_l]
  3868 000017C5 01D8                <1> 	add	ax, bx	; [previous_val_l]
  3869 000017C7 D1D8                <1> 	rcr	ax, 1
  3870 000017C9 93                  <1> 	xchg	ax, bx	; ax = [previous_val_l]	
  3871 000017CA 01D8                <1> 	add	ax, bx	; bx = interpolated middle (L)
  3872 000017CC D1D8                <1> 	rcr	ax, 1
  3873 000017CE 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3874 000017D1 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  3875 000017D2 58                  <1> 	pop	ax  ; *
  3876 000017D3 80C680              <1> 	add	dh, 80h ; convert sound level 0 to 65535 format
  3877 000017D6 52                  <1> 	push	dx  ; * ; [next_val_r]
  3878 000017D7 92                  <1> 	xchg	ax, dx
  3879 000017D8 01D0                <1> 	add	ax, dx	; [next_val_r] + [previous_val_r]
  3880 000017DA D1D8                <1> 	rcr	ax, 1	; / 2
  3881 000017DC 50                  <1> 	push	ax ; ** ; interpolated middle (R)
  3882 000017DD 01D0                <1> 	add	ax, dx	; + [previous_val_r]
  3883 000017DF D1D8                <1> 	rcr	ax, 1
  3884 000017E1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3885 000017E4 AB                  <1> 	stosw 		; interpolated sample 1 (R)
  3886 000017E5 A1[121B]            <1> 	mov	ax, [next_val_l]
  3887 000017E8 01D8                <1> 	add	ax, bx	; + interpolated middle (L)
  3888 000017EA D1D8                <1> 	rcr	ax, 1
  3889 000017EC 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3890 000017EF AB                  <1> 	stosw 		; interpolated sample 2 (L)
  3891 000017F0 58                  <1> 	pop	ax ; **
  3892 000017F1 5A                  <1> 	pop	dx ; *
  3893 000017F2 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val_r]
  3894 000017F4 D1D8                <1> 	rcr	ax, 1	; / 2
  3895 000017F6 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3896 000017F9 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  3897 000017FA C3                  <1> 	retn
  3898                              <1> 
  3899                              <1> 
  3900                              <1> interpolating_2_16bit_mono:
  3901                              <1> 	; 16/11/2023
  3902                              <1> 	; ax = [previous_val]
  3903                              <1> 	; dx = [next_val]
  3904                              <1> 	; original-interpolated
  3905                              <1> 
  3906 000017FB AB                  <1> 	stosw		; original sample (L)
  3907 000017FC AB                  <1> 	stosw		; original sample (R)
  3908 000017FD 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3909 00001800 80C680              <1> 	add	dh, 80h
  3910 00001803 01D0                <1> 	add	ax, dx
  3911 00001805 D1D8                <1> 	rcr	ax, 1
  3912 00001807 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3913 0000180A AB                  <1> 	stosw		; interpolated sample (L)
  3914 0000180B AB                  <1> 	stosw		; interpolated sample (R)
  3915 0000180C C3                  <1> 	retn
  3916                              <1> 
  3917                              <1> interpolating_2_16bit_stereo:
  3918                              <1> 	; 16/11/2023
  3919                              <1> 	; bx = [previous_val_l]
  3920                              <1> 	; ax = [previous_val_r]
  3921                              <1> 	; [next_val_l]
  3922                              <1> 	; dx = [next_val_r]
  3923                              <1> 	; original-interpolated
  3924                              <1> 
  3925 0000180D 93                  <1> 	xchg	ax, bx
  3926 0000180E AB                  <1> 	stosw		; original sample (L)
  3927 0000180F 93                  <1> 	xchg	ax, bx
  3928 00001810 AB                  <1> 	stosw		; original sample (R)
  3929 00001811 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  3930 00001814 80C680              <1> 	add	dh, 80h
  3931 00001817 01D0                <1> 	add	ax, dx	; [previous_val_r] + [next_val_r]
  3932 00001819 D1D8                <1> 	rcr	ax, 1	; / 2
  3933 0000181B 50                  <1> 	push	ax ; *	; interpolated sample (R)
  3934 0000181C A1[121B]            <1> 	mov	ax, [next_val_l]
  3935 0000181F 80C480              <1> 	add	ah, 80h
  3936 00001822 80C780              <1> 	add	bh, 80h
  3937 00001825 01D8                <1> 	add	ax, bx	; [next_val_l] + [previous_val_l]
  3938 00001827 D1D8                <1> 	rcr	ax, 1	; / 2		
  3939 00001829 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3940 0000182C AB                  <1> 	stosw 		; interpolated sample (L)
  3941 0000182D 58                  <1> 	pop	ax ; *	
  3942 0000182E 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  3943 00001831 AB                  <1> 	stosw 		; interpolated sample (R)
  3944 00001832 C3                  <1> 	retn
  3945                              <1> 
  3946                              <1> interpolating_5_8bit_mono:
  3947                              <1> 	; 17/11/2023
  3948                              <1> 	; al = [previous_val]
  3949                              <1> 	; dl = [next_val]
  3950                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  3951 00001833 88C3                <1> 	mov	bl, al
  3952 00001835 2C80                <1> 	sub	al, 80h
  3953 00001837 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3954 0000183A AB                  <1> 	stosw		; original sample (L)
  3955 0000183B AB                  <1> 	stosw		; original sample (R)
  3956 0000183C 88D8                <1> 	mov	al, bl
  3957 0000183E 00D0                <1> 	add	al, dl
  3958 00001840 D0D8                <1> 	rcr	al, 1
  3959 00001842 88C7                <1> 	mov	bh, al	; interpolated middle (temporary)
  3960 00001844 00D8                <1> 	add	al, bl  ; [previous_val]
  3961 00001846 D0D8                <1> 	rcr	al, 1 	
  3962 00001848 88C6                <1> 	mov	dh, al	; interpolated 1st quarter (temporary)
  3963 0000184A 00D8                <1> 	add	al, bl
  3964 0000184C D0D8                <1> 	rcr	al, 1
  3965 0000184E 2C80                <1> 	sub	al, 80h
  3966 00001850 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3967 00001853 AB                  <1> 	stosw		; interpolated sample 1 (L)
  3968 00001854 AB                  <1> 	stosw		; interpolated sample 1 (R)
  3969 00001855 88F8                <1> 	mov	al, bh
  3970 00001857 00F0                <1> 	add	al, dh
  3971 00001859 D0D8                <1> 	rcr	al, 1
  3972 0000185B 2C80                <1> 	sub	al, 80h
  3973 0000185D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3974 00001860 AB                  <1> 	stosw		; interpolated sample 2 (L)
  3975 00001861 AB                  <1> 	stosw		; interpolated sample 2 (R)
  3976 00001862 88F8                <1> 	mov	al, bh
  3977 00001864 00D0                <1> 	add	al, dl	; [next_val]
  3978 00001866 D0D8                <1> 	rcr	al, 1
  3979 00001868 88C6                <1> 	mov	dh, al	; interpolated 3rd quarter (temporary)
  3980 0000186A 00F8                <1> 	add	al, bh
  3981 0000186C D0D8                <1> 	rcr	al, 1
  3982 0000186E 2C80                <1> 	sub	al, 80h
  3983 00001870 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3984 00001873 AB                  <1> 	stosw		; interpolated sample 3 (L)
  3985 00001874 AB                  <1> 	stosw		; interpolated sample 3 (R)
  3986 00001875 88F0                <1> 	mov	al, dh
  3987 00001877 00D0                <1> 	add	al, dl
  3988 00001879 D0D8                <1> 	rcr	al, 1
  3989 0000187B 2C80                <1> 	sub	al, 80h
  3990 0000187D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  3991 00001880 AB                  <1> 	stosw		; interpolated sample 4 (L)
  3992 00001881 AB                  <1> 	stosw		; interpolated sample 4 (R)
  3993 00001882 C3                  <1> 	retn
  3994                              <1> 
  3995                              <1> interpolating_5_8bit_stereo:
  3996                              <1> 	; 17/11/2023
  3997                              <1> 	; al = [previous_val_l]
  3998                              <1> 	; ah = [previous_val_r]
  3999                              <1> 	; dl = [next_val_l]
  4000                              <1> 	; dh = [next_val_r]
  4001                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  4002 00001883 89C3                <1> 	mov	bx, ax
  4003 00001885 2C80                <1> 	sub	al, 80h
  4004 00001887 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4005 0000188A AB                  <1> 	stosw		; original sample (L)
  4006 0000188B 88F8                <1> 	mov	al, bh
  4007 0000188D 2C80                <1> 	sub	al, 80h
  4008 0000188F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4009 00001892 AB                  <1> 	stosw		; original sample (R)
  4010 00001893 52                  <1> 	push	dx ; *
  4011 00001894 88D8                <1> 	mov	al, bl
  4012 00001896 00D0                <1> 	add	al, dl	; [next_val_l]
  4013 00001898 D0D8                <1> 	rcr	al, 1
  4014 0000189A 50                  <1> 	push	ax ; **	; al = interpolated middle (L) (temporary)
  4015 0000189B 00D8                <1> 	add	al, bl	; [previous_val_l]
  4016 0000189D D0D8                <1> 	rcr	al, 1
  4017 0000189F 86D8                <1> 	xchg	al, bl
  4018 000018A1 00D8                <1> 	add	al, bl	; bl = interpolated 1st quarter (L) (temp)
  4019 000018A3 D0D8                <1> 	rcr	al, 1
  4020 000018A5 2C80                <1> 	sub	al, 80h
  4021 000018A7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4022 000018AA AB                  <1> 	stosw		; interpolated sample 1 (L)
  4023 000018AB 88F8                <1> 	mov	al, bh
  4024 000018AD 00F0                <1> 	add	al, dh	; [next_val_r]
  4025 000018AF D0D8                <1> 	rcr	al, 1
  4026 000018B1 50                  <1> 	push	ax ; *** ; al = interpolated middle (R) (temporary)
  4027 000018B2 00F8                <1> 	add	al, bh	; [previous_val_r]
  4028 000018B4 D0D8                <1> 	rcr	al, 1
  4029 000018B6 86F8                <1> 	xchg	al, bh	
  4030 000018B8 00F8                <1> 	add	al, bh	; bh = interpolated 1st quarter (R) (temp)
  4031 000018BA D0D8                <1> 	rcr	al, 1
  4032 000018BC 2C80                <1> 	sub	al, 80h
  4033 000018BE C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4034 000018C1 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4035 000018C2 5A                  <1> 	pop	dx ; ***
  4036 000018C3 58                  <1> 	pop	ax ; **	; al = interpolated middle (L) (temporary)
  4037 000018C4 86D8                <1> 	xchg	al, bl	; al = interpolated 1st quarter (L) (temp)
  4038 000018C6 00D8                <1> 	add	al, bl	; bl = interpolated middle (L) (temporary)
  4039 000018C8 D0D8                <1> 	rcr	al, 1
  4040 000018CA 2C80                <1> 	sub	al, 80h
  4041 000018CC C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4042 000018CF AB                  <1> 	stosw		; interpolated sample 2 (L)	
  4043 000018D0 88D0                <1> 	mov	al, dl 	; interpolated middle (R) (temporary)
  4044 000018D2 86F8                <1> 	xchg	al, bh	; al = interpolated 1st quarter (R) (temp)
  4045 000018D4 00F8                <1> 	add	al, bh	; bh = interpolated middle (R) (temporary)
  4046 000018D6 D0D8                <1> 	rcr	al, 1
  4047 000018D8 2C80                <1> 	sub	al, 80h
  4048 000018DA C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4049 000018DD AB                  <1> 	stosw		; interpolated sample 2 (R)
  4050 000018DE 5A                  <1> 	pop	dx ; *
  4051 000018DF 88D8                <1> 	mov	al, bl	; interpolated middle (L) (temporary)
  4052 000018E1 00D0                <1> 	add	al, dl	; [next_val_l]
  4053 000018E3 D0D8                <1> 	rcr	al, 1
  4054 000018E5 86D8                <1> 	xchg	al, bl	; al = interpolated middle (R) (temporary)
  4055 000018E7 00D8                <1> 	add	al, bl	; bl = interpolated 3rd quarter (L) (temp)
  4056 000018E9 D0D8                <1> 	rcr	al, 1
  4057 000018EB 2C80                <1> 	sub	al, 80h
  4058 000018ED C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4059 000018F0 AB                  <1> 	stosw		; interpolated sample 3 (L)
  4060 000018F1 88F8                <1> 	mov	al, bh	
  4061 000018F3 00F0                <1> 	add	al, dh	; interpolated middle (R) + [next_val_r]
  4062 000018F5 D0D8                <1> 	rcr	al, 1
  4063 000018F7 86F8                <1> 	xchg	al, bh	; al = interpolated middle (R)
  4064 000018F9 00F8                <1> 	add	al, bh	; bh = interpolated 3rd quarter (R) (temp)
  4065 000018FB D0D8                <1> 	rcr	al, 1
  4066 000018FD 2C80                <1> 	sub	al, 80h
  4067 000018FF C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4068 00001902 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4069 00001903 88D8                <1> 	mov	al, bl
  4070 00001905 00D0                <1> 	add	al, dl	; [next_val_l]
  4071 00001907 D0D8                <1> 	rcr	al, 1
  4072 00001909 2C80                <1> 	sub	al, 80h
  4073 0000190B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4074 0000190E AB                  <1> 	stosw		; interpolated sample 4 (L)
  4075 0000190F 88F8                <1> 	mov	al, bh
  4076 00001911 00F0                <1> 	add	al, dh	; [next_val_r]
  4077 00001913 D0D8                <1> 	rcr	al, 1
  4078 00001915 2C80                <1> 	sub	al, 80h
  4079 00001917 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4080 0000191A AB                  <1> 	stosw		; interpolated sample 4 (R)
  4081 0000191B C3                  <1> 	retn
  4082                              <1> 
  4083                              <1> interpolating_4_8bit_mono:
  4084                              <1> 	; 17/11/2023
  4085                              <1> 	; al = [previous_val]
  4086                              <1> 	; dl = [next_val]
  4087                              <1> 	; original-interpolated-interpolated-interpolated
  4088 0000191C 88C3                <1> 	mov	bl, al
  4089 0000191E 2C80                <1> 	sub	al, 80h
  4090 00001920 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4091 00001923 AB                  <1> 	stosw		; original sample (L)
  4092 00001924 AB                  <1> 	stosw		; original sample (R)
  4093 00001925 88D8                <1> 	mov	al, bl
  4094 00001927 00D0                <1> 	add	al, dl
  4095 00001929 D0D8                <1> 	rcr	al, 1
  4096 0000192B 86D8                <1> 	xchg	al, bl  ; al = [previous_val]
  4097 0000192D 00D8                <1> 	add	al, bl	; bl = interpolated middle (sample 2)
  4098 0000192F D0D8                <1> 	rcr	al, 1
  4099 00001931 2C80                <1> 	sub	al, 80h
  4100 00001933 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4101 00001936 AB                  <1> 	stosw		; interpolated sample 1 (L)
  4102 00001937 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4103 00001938 88D8                <1> 	mov	al, bl	; interpolated middle (sample 2)
  4104 0000193A 2C80                <1> 	sub	al, 80h
  4105 0000193C C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4106 0000193F AB                  <1> 	stosw		; interpolated sample 2 (L)
  4107 00001940 AB                  <1> 	stosw		; interpolated sample 2 (R)
  4108 00001941 88D8                <1> 	mov	al, bl
  4109 00001943 00D0                <1> 	add	al, dl	; [next_val]
  4110 00001945 D0D8                <1> 	rcr	al, 1
  4111 00001947 2C80                <1> 	sub	al, 80h
  4112 00001949 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4113 0000194C AB                  <1> 	stosw		; interpolated sample 3 (L)
  4114 0000194D AB                  <1> 	stosw		; interpolated sample 3 (R)
  4115 0000194E C3                  <1> 	retn
  4116                              <1> 
  4117                              <1> interpolating_4_8bit_stereo:
  4118                              <1> 	; 17/11/2023
  4119                              <1> 	; al = [previous_val_l]
  4120                              <1> 	; ah = [previous_val_r]
  4121                              <1> 	; dl = [next_val_l]
  4122                              <1> 	; dh = [next_val_r]
  4123                              <1> 	; original-interpolated-interpolated-interpolated
  4124 0000194F 89C3                <1> 	mov	bx, ax
  4125 00001951 2C80                <1> 	sub	al, 80h
  4126 00001953 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4127 00001956 AB                  <1> 	stosw		; original sample (L)
  4128 00001957 88F8                <1> 	mov	al, bh
  4129 00001959 2C80                <1> 	sub	al, 80h
  4130 0000195B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4131 0000195E AB                  <1> 	stosw		; original sample (R)
  4132 0000195F 88D8                <1> 	mov	al, bl
  4133 00001961 00D0                <1> 	add	al, dl	; [next_val_l]
  4134 00001963 D0D8                <1> 	rcr	al, 1
  4135 00001965 86D8                <1> 	xchg	al, bl	; al = [previous_val_l]
  4136 00001967 00D8                <1> 	add	al, bl	; bl = interpolated middle (L) (sample 2)
  4137 00001969 D0D8                <1> 	rcr	al, 1
  4138 0000196B 2C80                <1> 	sub	al, 80h
  4139 0000196D C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4140 00001970 AB                  <1> 	stosw		; interpolated sample 1 (L)
  4141 00001971 88F8                <1> 	mov	al, bh
  4142 00001973 00F0                <1> 	add	al, dh	; [next_val_r]
  4143 00001975 D0D8                <1> 	rcr	al, 1
  4144 00001977 86F8                <1> 	xchg	al, bh	; al = [previous_val_h]
  4145 00001979 00F8                <1> 	add	al, bh	; bh = interpolated middle (R) (sample 2)
  4146 0000197B D0D8                <1> 	rcr	al, 1
  4147 0000197D 2C80                <1> 	sub	al, 80h
  4148 0000197F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4149 00001982 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4150 00001983 88D8                <1> 	mov	al, bl	; interpolated middle (L) (sample 2)
  4151 00001985 2C80                <1> 	sub	al, 80h
  4152 00001987 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4153 0000198A AB                  <1> 	stosw		; interpolated sample 2 (L)
  4154 0000198B 88F8                <1> 	mov	al, bh	; interpolated middle (L) (sample 2)
  4155 0000198D 2C80                <1> 	sub	al, 80h
  4156 0000198F C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4157 00001992 AB                  <1> 	stosw		; interpolated sample 2 (L)
  4158 00001993 88D8                <1> 	mov	al, bl
  4159 00001995 00D0                <1> 	add	al, dl	; [next_val_l]
  4160 00001997 D0D8                <1> 	rcr	al, 1
  4161 00001999 2C80                <1> 	sub	al, 80h
  4162 0000199B C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4163 0000199E AB                  <1> 	stosw		; interpolated sample 3 (L)
  4164 0000199F 88F8                <1> 	mov	al, bh
  4165 000019A1 00F0                <1> 	add	al, dh	; [next_val_r]
  4166 000019A3 D0D8                <1> 	rcr	al, 1
  4167 000019A5 2C80                <1> 	sub	al, 80h
  4168 000019A7 C1E008              <1> 	shl	ax, 8	; convert 8 bit sample to 16 bit sample
  4169 000019AA AB                  <1> 	stosw		; interpolated sample 3 (R)
  4170 000019AB C3                  <1> 	retn
  4171                              <1> 
  4172                              <1> interpolating_5_16bit_mono:
  4173                              <1> 	; 18/11/2023
  4174                              <1> 	; ax = [previous_val]
  4175                              <1> 	; dx = [next_val]
  4176                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  4177 000019AC AB                  <1> 	stosw		; original sample (L)
  4178 000019AD AB                  <1> 	stosw		; original sample (R)
  4179 000019AE 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4180 000019B1 89C3                <1> 	mov	bx, ax	; [previous_val]
  4181 000019B3 80C680              <1> 	add	dh, 80h
  4182 000019B6 01D0                <1> 	add	ax, dx
  4183 000019B8 D1D8                <1> 	rcr	ax, 1
  4184 000019BA 50                  <1> 	push	ax ; *	; interpolated middle (temporary)
  4185 000019BB 01D8                <1> 	add	ax, bx	; interpolated middle + [previous_val] 
  4186 000019BD D1D8                <1> 	rcr	ax, 1
  4187 000019BF 50                  <1> 	push	ax ; **	; interpolated 1st quarter (temporary)
  4188 000019C0 01D8                <1> 	add	ax, bx	; 1st quarter + [previous_val]
  4189 000019C2 D1D8                <1> 	rcr	ax, 1	
  4190 000019C4 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4191 000019C7 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4192 000019C8 AB                  <1> 	stosw		; interpolated sample 1 (R)
  4193 000019C9 58                  <1> 	pop	ax ; **
  4194 000019CA 5B                  <1> 	pop	bx ; *
  4195 000019CB 01D8                <1> 	add	ax, bx	; 1st quarter + middle
  4196 000019CD D1D8                <1> 	rcr	ax, 1	; / 2
  4197 000019CF 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again	
  4198 000019D2 AB                  <1> 	stosw		; interpolated sample 2 (L)
  4199 000019D3 AB                  <1> 	stosw		; interpolated sample 2 (R)		
  4200 000019D4 89D8                <1> 	mov	ax, bx
  4201 000019D6 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val]
  4202 000019D8 D1D8                <1> 	rcr	ax, 1
  4203 000019DA 50                  <1> 	push	ax ; *	; interpolated 3rd quarter (temporary)
  4204 000019DB 01D8                <1> 	add	ax, bx	; + interpolated middle
  4205 000019DD D1D8                <1> 	rcr	ax, 1
  4206 000019DF 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4207 000019E2 AB                  <1> 	stosw		; interpolated sample 3 (L)
  4208 000019E3 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4209 000019E4 58                  <1> 	pop	ax ; *	
  4210 000019E5 01D0                <1> 	add	ax, dx	; 3rd quarter + [next_val]
  4211 000019E7 D1D8                <1> 	rcr	ax, 1	; / 2
  4212 000019E9 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4213 000019EC AB                  <1> 	stosw		; interpolated sample 4 (L)
  4214 000019ED AB                  <1> 	stosw		; interpolated sample 4 (R)
  4215 000019EE C3                  <1> 	retn
  4216                              <1> 
  4217                              <1> interpolating_5_16bit_stereo:
  4218                              <1> 	; 18/11/2023
  4219                              <1> 	; bx = [previous_val_l]
  4220                              <1> 	; ax = [previous_val_r]
  4221                              <1> 	; [next_val_l]
  4222                              <1> 	; [next_val_r]
  4223                              <1> 	; original-interpltd-interpltd-interpltd-interpltd
  4224 000019EF 51                  <1> 	push	cx ; !
  4225 000019F0 93                  <1> 	xchg	ax, bx
  4226 000019F1 AB                  <1> 	stosw		; original sample (L)
  4227 000019F2 93                  <1> 	xchg	ax, bx
  4228 000019F3 AB                  <1> 	stosw		; original sample (R)
  4229 000019F4 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4230 000019F7 50                  <1> 	push	ax ; *	; [previous_val_r]
  4231 000019F8 80C780              <1> 	add	bh, 80h
  4232 000019FB 8006[131B]80        <1> 	add	byte [next_val_l+1], 80h
  4233 00001A00 A1[121B]            <1> 	mov	ax, [next_val_l]
  4234 00001A03 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4235 00001A05 D1D8                <1> 	rcr	ax, 1
  4236 00001A07 89C1                <1> 	mov	cx, ax	; interpolated middle (L)
  4237 00001A09 01D8                <1> 	add	ax, bx	
  4238 00001A0B D1D8                <1> 	rcr	ax, 1
  4239 00001A0D 89C2                <1> 	mov	dx, ax	; interpolated 1st quarter (L)
  4240 00001A0F 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4241 00001A11 D1D8                <1> 	rcr	ax, 1
  4242 00001A13 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4243 00001A16 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4244 00001A17 89C8                <1> 	mov	ax, cx
  4245 00001A19 01D0                <1> 	add	ax, dx	; middle (L) + 1st quarter (L)
  4246 00001A1B D1D8                <1> 	rcr	ax, 1	; / 2
  4247 00001A1D 89C3                <1> 	mov	bx, ax  ; interpolated sample 2 (L)
  4248 00001A1F 5A                  <1> 	pop	dx ; *	; [previous_val_r]
  4249 00001A20 89D0                <1> 	mov	ax, dx
  4250 00001A22 8006[151B]80        <1> 	add	byte [next_val_r+1], 80h
  4251 00001A27 0306[141B]          <1> 	add	ax, [next_val_r]
  4252 00001A2B D1D8                <1> 	rcr	ax, 1
  4253 00001A2D 50                  <1> 	push	ax ; *	; interpolated middle (R)
  4254 00001A2E 01D0                <1> 	add	ax, dx
  4255 00001A30 D1D8                <1> 	rcr	ax, 1
  4256 00001A32 50                  <1> 	push	ax ; **	; interpolated 1st quarter (R)
  4257 00001A33 01D0                <1> 	add	ax, dx	; [previous_val_r]
  4258 00001A35 D1D8                <1> 	rcr	ax, 1
  4259 00001A37 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4260 00001A3A AB                  <1> 	stosw 		; interpolated sample 1 (R)
  4261 00001A3B 89D8                <1> 	mov	ax, bx
  4262 00001A3D 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4263 00001A40 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4264 00001A41 58                  <1> 	pop	ax ; **
  4265 00001A42 5A                  <1> 	pop	dx ; *
  4266 00001A43 01D0                <1> 	add	ax, dx	; 1st quarter (R) + middle (R)
  4267 00001A45 D1D8                <1> 	rcr	ax, 1	; / 2
  4268 00001A47 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4269 00001A4A AB                  <1> 	stosw 		; interpolated sample 2 (R)
  4270 00001A4B 89C8                <1> 	mov	ax, cx
  4271 00001A4D 0306[121B]          <1> 	add	ax, [next_val_l]
  4272 00001A51 D1D8                <1> 	rcr	ax, 1
  4273 00001A53 50                  <1> 	push	ax ; * 	; interpolated 3rd quarter (L)
  4274 00001A54 01C8                <1> 	add	ax, cx	; interpolated middle (L)
  4275 00001A56 D1D8                <1> 	rcr	ax, 1
  4276 00001A58 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4277 00001A5B AB                  <1> 	stosw 		; interpolated sample 3 (L)
  4278 00001A5C 89D0                <1> 	mov	ax, dx
  4279 00001A5E 0306[141B]          <1> 	add	ax, [next_val_r]
  4280 00001A62 D1D8                <1> 	rcr	ax, 1
  4281 00001A64 50                  <1> 	push	ax ; ** ; interpolated 3rd quarter (R)
  4282 00001A65 01D0                <1> 	add	ax, dx	; interpolated middle (R)
  4283 00001A67 D1D8                <1> 	rcr	ax, 1
  4284 00001A69 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4285 00001A6C AB                  <1> 	stosw 		; interpolated sample 3 (R)
  4286 00001A6D 5B                  <1> 	pop	bx ; **
  4287 00001A6E 58                  <1> 	pop	ax ; *
  4288 00001A6F 0306[121B]          <1> 	add	ax, [next_val_l]
  4289 00001A73 D1D8                <1> 	rcr	ax, 1
  4290 00001A75 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4291 00001A78 AB                  <1> 	stosw 		; interpolated sample 4 (L)
  4292 00001A79 89D8                <1> 	mov	ax, bx
  4293 00001A7B 0306[141B]          <1> 	add	ax, [next_val_r]
  4294 00001A7F D1D8                <1> 	rcr	ax, 1
  4295 00001A81 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4296 00001A84 AB                  <1> 	stosw 		; interpolated sample 4 (R)
  4297 00001A85 59                  <1> 	pop	cx ; !
  4298 00001A86 C3                  <1> 	retn
  4299                              <1> 
  4300                              <1> interpolating_4_16bit_mono:
  4301                              <1> 	; 18/11/2023
  4302                              <1> 	; ax = [previous_val]
  4303                              <1> 	; dx = [next_val]
  4304                              <1> 	; 02/02/2025
  4305                              <1> 	; original-interpolated-interpolated-interpolated
  4306                              <1> 
  4307 00001A87 AB                  <1> 	stosw		; original sample (L)
  4308 00001A88 AB                  <1> 	stosw		; original sample (R)
  4309 00001A89 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4310 00001A8C 89C3                <1> 	mov	bx, ax	; [previous_val]
  4311 00001A8E 80C680              <1> 	add	dh, 80h
  4312 00001A91 01D0                <1> 	add	ax, dx	; [previous_val] + [next_val]
  4313 00001A93 D1D8                <1> 	rcr	ax, 1
  4314 00001A95 93                  <1> 	xchg	ax, bx
  4315 00001A96 01D8                <1> 	add	ax, bx	; [previous_val] + interpolated middle
  4316 00001A98 D1D8                <1> 	rcr	ax, 1
  4317 00001A9A 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4318 00001A9D AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4319 00001A9E AB                  <1> 	stosw		; interpolated sample 1 (R)
  4320 00001A9F 89D8                <1> 	mov	ax, bx	; interpolated middle
  4321 00001AA1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4322 00001AA4 AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4323 00001AA5 AB                  <1> 	stosw		; interpolated sample 2 (R)
  4324 00001AA6 89D8                <1> 	mov	ax, bx
  4325 00001AA8 01D0                <1> 	add	ax, dx	; interpolated middle + [next_val]
  4326 00001AAA D1D8                <1> 	rcr	ax, 1
  4327 00001AAC 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4328 00001AAF AB                  <1> 	stosw		; interpolated sample 3 (L)
  4329 00001AB0 AB                  <1> 	stosw		; interpolated sample 3 (R)
  4330 00001AB1 C3                  <1> 	retn
  4331                              <1> 
  4332                              <1> interpolating_4_16bit_stereo:
  4333                              <1> 	; 18/11/2023
  4334                              <1> 	; bx = [previous_val_l]
  4335                              <1> 	; ax = [previous_val_r]
  4336                              <1> 	; [next_val_l]
  4337                              <1> 	; [next_val_r]
  4338                              <1> 	; original-interpolated-interpolated-interpolated
  4339 00001AB2 93                  <1> 	xchg	ax, bx
  4340 00001AB3 AB                  <1> 	stosw		; original sample (L)
  4341 00001AB4 93                  <1> 	xchg	ax, bx
  4342 00001AB5 AB                  <1> 	stosw		; original sample (R)
  4343 00001AB6 80C480              <1> 	add	ah, 80h ; convert sound level 0 to 65535 format
  4344 00001AB9 89C2                <1> 	mov	dx, ax	; [previous_val_r]
  4345 00001ABB 80C780              <1> 	add	bh, 80h
  4346 00001ABE 8006[131B]80        <1> 	add	byte [next_val_l+1], 80h
  4347 00001AC3 A1[121B]            <1> 	mov	ax, [next_val_l]
  4348 00001AC6 01D8                <1> 	add	ax, bx	; [previous_val_l]
  4349 00001AC8 D1D8                <1> 	rcr	ax, 1
  4350 00001ACA 93                  <1> 	xchg	ax, bx
  4351 00001ACB 01D8                <1> 	add	ax, bx	; bx = interpolated middle (L)
  4352 00001ACD D1D8                <1> 	rcr	ax, 1
  4353 00001ACF 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4354 00001AD2 AB                  <1> 	stosw 		; interpolated sample 1 (L)
  4355 00001AD3 8006[151B]80        <1> 	add	byte [next_val_r+1], 80h
  4356 00001AD8 89D0                <1> 	mov	ax, dx	; [previous_val_r]
  4357 00001ADA 0306[141B]          <1> 	add	ax, [next_val_r]
  4358 00001ADE D1D8                <1> 	rcr	ax, 1
  4359 00001AE0 92                  <1> 	xchg	ax, dx
  4360 00001AE1 01D0                <1> 	add	ax, dx	; dx = interpolated middle (R)
  4361 00001AE3 D1D8                <1> 	rcr	ax, 1
  4362 00001AE5 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4363 00001AE8 AB                  <1> 	stosw 		; interpolated sample 1 (R)
  4364 00001AE9 89D8                <1> 	mov	ax, bx
  4365 00001AEB 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4366 00001AEE AB                  <1> 	stosw 		; interpolated sample 2 (L)
  4367 00001AEF 89D0                <1> 	mov	ax, dx
  4368 00001AF1 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4369 00001AF4 AB                  <1> 	stosw 		; interpolated sample 2 (R)
  4370 00001AF5 89D8                <1> 	mov	ax, bx
  4371 00001AF7 0306[121B]          <1> 	add	ax, [next_val_l]
  4372 00001AFB D1D8                <1> 	rcr	ax, 1
  4373 00001AFD 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4374 00001B00 AB                  <1> 	stosw 		; interpolated sample 3 (L)
  4375 00001B01 89D0                <1> 	mov	ax, dx
  4376 00001B03 0306[141B]          <1> 	add	ax, [next_val_r]
  4377 00001B07 D1D8                <1> 	rcr	ax, 1
  4378 00001B09 80EC80              <1> 	sub	ah, 80h	; -32768 to +32767 format again
  4379 00001B0C AB                  <1> 	stosw 		; interpolated sample 3 (R)
  4380 00001B0D C3                  <1> 	retn
  4381                              <1> 
  4382                              <1> ; 13/11/2023
  4383                              <1> previous_val:
  4384 00001B0E 0000                <1> previous_val_l: dw 0
  4385 00001B10 0000                <1> previous_val_r: dw 0
  4386                              <1> next_val:
  4387 00001B12 0000                <1> next_val_l: dw 0
  4388 00001B14 0000                <1> next_val_r: dw 0
  4389                              <1> 
  4390                              <1> ; 16/11/2023
  4391 00001B16 00                  <1> faz:	db 0
  4392                              <1> 	
  4393                              <1> ; --------------------------------------------------------
   477                                  
   478                                  ; UTILS.ASM
   479                                  ;----------------------------------------------------------------------------
   480                                  ;       delay1_4ms - Delay for 1/4 millisecond.
   481                                  ;		    1mS = 1000us
   482                                  ;       Entry:
   483                                  ;         None
   484                                  ;       Exit:
   485                                  ;	  None
   486                                  ;
   487                                  ;       Modified:
   488                                  ;         None
   489                                  ;
   490                                  PORTB			EQU	061h
   491                                    REFRESH_STATUS	EQU	010h		; Refresh signal status
   492                                  
   493                                  delay1_4ms:
   494 00001B17 50                              push    ax 
   495 00001B18 51                              push    cx
   496 00001B19 B91000                          mov     cx, 16			; close enough.
   497 00001B1C E461                    	in	al,PORTB
   498 00001B1E 2410                    	and	al,REFRESH_STATUS
   499 00001B20 88C4                    	mov	ah,al			; Start toggle state
   500 00001B22 09C9                    	or	cx, cx
   501 00001B24 7401                    	jz	short _d4ms1
   502 00001B26 41                      	inc	cx			; Throwaway first toggle
   503                                  _d4ms1:	
   504 00001B27 E461                    	in	al,PORTB		; Read system control port
   505 00001B29 2410                    	and	al,REFRESH_STATUS	; Refresh toggles 15.085 microseconds
   506 00001B2B 38C4                    	cmp	ah,al
   507 00001B2D 74F8                    	je	short _d4ms1		; Wait for state change
   508                                  
   509 00001B2F 88C4                    	mov	ah,al			; Update with new state
   510 00001B31 49                      	dec	cx
   511 00001B32 75F3                    	jnz	short _d4ms1
   512                                  
   513 00001B34 59                              pop     cx
   514 00001B35 58                              pop     ax
   515 00001B36 C3                              retn
   516                                  
   517                                  	; 13/11/2016 - Erdogan Tan
   518                                  write_ac97_dev_info:
   519                                  	; BUS/DEV/FN
   520                                  	;	00000000BBBBBBBBDDDDDFFF00000000
   521                                  	; DEV/VENDOR
   522                                  	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
   523                                  
   524 00001B37 30FF                    	xor	bh, bh
   525 00001B39 668B36[A61F]            	mov	esi, [dev_vendor]
   526 00001B3E 89F0                    	mov	ax, si
   527 00001B40 88C3                    	mov	bl, al
   528 00001B42 88DA                    	mov	dl, bl
   529 00001B44 80E30F                  	and	bl, 0Fh
   530 00001B47 8A87[D31D]              	mov	al, [bx+hex_chars]
   531 00001B4B A2[161E]                	mov	[msgVendorId+3], al
   532 00001B4E 88D3                    	mov	bl, dl
   533 00001B50 C0EB04                  	shr	bl, 4
   534 00001B53 8A87[D31D]              	mov	al, [bx+hex_chars]
   535 00001B57 A2[151E]                	mov	[msgVendorId+2], al
   536 00001B5A 88E3                    	mov	bl, ah
   537 00001B5C 88DA                    	mov	dl, bl
   538 00001B5E 80E30F                  	and	bl, 0Fh
   539 00001B61 8A87[D31D]              	mov	al, [bx+hex_chars]
   540 00001B65 A2[141E]                	mov	[msgVendorId+1], al
   541 00001B68 88D3                    	mov	bl, dl
   542 00001B6A C0EB04                  	shr	bl, 4
   543 00001B6D 8A87[D31D]              	mov	al, [bx+hex_chars]
   544 00001B71 A2[131E]                	mov	[msgVendorId], al
   545 00001B74 66C1EE10                	shr	esi, 16
   546 00001B78 89F0                    	mov	ax, si
   547 00001B7A 88C3                    	mov	bl, al
   548 00001B7C 88DA                    	mov	dl, bl
   549 00001B7E 80E30F                  	and	bl, 0Fh
   550 00001B81 8A87[D31D]              	mov	al, [bx+hex_chars]
   551 00001B85 A2[271E]                	mov	[msgDevId+3], al
   552 00001B88 88D3                    	mov	bl, dl
   553 00001B8A C0EB04                  	shr	bl, 4
   554 00001B8D 8A87[D31D]              	mov	al, [bx+hex_chars]
   555 00001B91 A2[261E]                	mov	[msgDevId+2], al
   556 00001B94 88E3                    	mov	bl, ah
   557 00001B96 88DA                    	mov	dl, bl
   558 00001B98 80E30F                  	and	bl, 0Fh
   559 00001B9B 8A87[D31D]              	mov	al, [bx+hex_chars]
   560 00001B9F A2[251E]                	mov	[msgDevId+1], al
   561 00001BA2 88D3                    	mov	bl, dl
   562 00001BA4 C0EB04                  	shr	bl, 4
   563 00001BA7 8A87[D31D]              	mov	al, [bx+hex_chars]
   564 00001BAB A2[241E]                	mov	[msgDevId], al
   565                                  
   566 00001BAE 668B36[A21F]            	mov	esi, [bus_dev_fn]
   567 00001BB3 66C1EE08                	shr	esi, 8
   568 00001BB7 89F0                    	mov	ax, si
   569 00001BB9 88C3                    	mov	bl, al
   570 00001BBB 88DA                    	mov	dl, bl
   571 00001BBD 80E307                  	and	bl, 7 ; bit 0,1,2
   572 00001BC0 8A87[D31D]              	mov	al, [bx+hex_chars]
   573 00001BC4 A2[4B1E]                	mov	[msgFncNo+1], al
   574 00001BC7 88D3                    	mov	bl, dl
   575 00001BC9 C0EB03                  	shr	bl, 3
   576 00001BCC 88DA                    	mov	dl, bl
   577 00001BCE 80E30F                  	and	bl, 0Fh
   578 00001BD1 8A87[D31D]              	mov	al, [bx+hex_chars]
   579 00001BD5 A2[3D1E]                	mov	[msgDevNo+1], al
   580 00001BD8 88D3                    	mov	bl, dl
   581 00001BDA C0EB04                  	shr	bl, 4
   582 00001BDD 8A87[D31D]              	mov	al, [bx+hex_chars]
   583 00001BE1 A2[3C1E]                	mov	[msgDevNo], al
   584 00001BE4 88E3                    	mov	bl, ah
   585 00001BE6 88DA                    	mov	dl, bl
   586 00001BE8 80E30F                  	and	bl, 0Fh
   587 00001BEB 8A87[D31D]              	mov	al, [bx+hex_chars]
   588 00001BEF A2[311E]                	mov	[msgBusNo+1], al
   589 00001BF2 88D3                    	mov	bl, dl
   590 00001BF4 C0EB04                  	shr	bl, 4
   591 00001BF7 8A87[D31D]              	mov	al, [bx+hex_chars]
   592 00001BFB A2[301E]                	mov	[msgBusNo], al
   593                                  
   594 00001BFE A1[981F]                	mov	ax, [NAMBAR]
   595 00001C01 88C3                    	mov	bl, al
   596 00001C03 88DA                    	mov	dl, bl
   597 00001C05 80E30F                  	and	bl, 0Fh
   598 00001C08 8A87[D31D]              	mov	al, [bx+hex_chars]
   599 00001C0C A2[5A1E]                	mov	[msgNamBar+3], al
   600 00001C0F 88D3                    	mov	bl, dl
   601 00001C11 C0EB04                  	shr	bl, 4
   602 00001C14 8A87[D31D]              	mov	al, [bx+hex_chars]
   603 00001C18 A2[591E]                	mov	[msgNamBar+2], al
   604 00001C1B 88E3                    	mov	bl, ah
   605 00001C1D 88DA                    	mov	dl, bl
   606 00001C1F 80E30F                  	and	bl, 0Fh
   607 00001C22 8A87[D31D]              	mov	al, [bx+hex_chars]
   608 00001C26 A2[581E]                	mov	[msgNamBar+1], al
   609 00001C29 88D3                    	mov	bl, dl
   610 00001C2B C0EB04                  	shr	bl, 4
   611 00001C2E 8A87[D31D]              	mov	al, [bx+hex_chars]
   612 00001C32 A2[571E]                	mov	[msgNamBar], al
   613                                  
   614                                  	; 08/05/2024 (ebx->bx)
   615                                  	; 05/11/2023
   616 00001C35 A1[9A1F]                	mov	ax, [NABMBAR]
   617 00001C38 88C3                    	mov	bl, al
   618 00001C3A 88DA                    	mov	dl, bl
   619 00001C3C 80E30F                  	and	bl, 0Fh
   620 00001C3F 8A87[D31D]              	mov	al, [bx+hex_chars]
   621 00001C43 A2[691E]                	mov	[msgNabmBar+3], al
   622 00001C46 88D3                    	mov	bl, dl
   623 00001C48 C0EB04                  	shr	bl, 4
   624 00001C4B 8A87[D31D]              	mov	al, [bx+hex_chars]
   625 00001C4F A2[681E]                	mov	[msgNabmBar+2], al
   626 00001C52 88E3                    	mov	bl, ah
   627 00001C54 88DA                    	mov	dl, bl
   628 00001C56 80E30F                  	and	bl, 0Fh
   629 00001C59 8A87[D31D]              	mov	al, [bx+hex_chars]
   630 00001C5D A2[671E]                	mov	[msgNabmBar+1], al
   631 00001C60 88D3                    	mov	bl, dl
   632 00001C62 C0EB04                  	shr	bl, 4
   633 00001C65 8A87[D31D]              	mov	al, [bx+hex_chars]
   634 00001C69 A2[661E]                	mov	[msgNabmBar], al
   635                                  
   636                                  	; 24/11/2016
   637 00001C6C 30E4                    	xor	ah, ah
   638 00001C6E A0[8F1F]                	mov	al, [ac97_int_ln_reg]
   639 00001C71 B10A                    	mov	cl, 10
   640 00001C73 F6F1                    	div	cl
   641 00001C75 0106[711E]              	add	[msgIRQ], ax
   642 00001C79 20C0                    	and	al, al
   643 00001C7B 7508                    	jnz	short _pmi
   644 00001C7D A0[721E]                	mov	al, [msgIRQ+1]
   645 00001C80 B420                    	mov	ah, ' '
   646 00001C82 A3[711E]                	mov	[msgIRQ], ax
   647                                  _pmi:
   648 00001C85 BA[E41D]                        mov	dx, msgAC97Info
   649 00001C88 B409                            mov     ah, 9
   650 00001C8A CD21                            int     21h
   651 00001C8C C3                              retn
   652                                  
   653                                  write_sample_rate:
   654                                  	; ax = sample rate (hertz)
   655                                  
   656 00001C8D 31D2                    	xor	dx, dx
   657 00001C8F B90A00                  	mov	cx, 10
   658 00001C92 F7F1                    	div	cx
   659 00001C94 0016[871E]              	add	[msgHertz+4], dl
   660 00001C98 29D2                    	sub	dx, dx
   661 00001C9A F7F1                    	div	cx
   662 00001C9C 0016[861E]              	add	[msgHertz+3], dl
   663 00001CA0 29D2                    	sub	dx, dx
   664 00001CA2 F7F1                    	div	cx
   665 00001CA4 0016[851E]              	add	[msgHertz+2], dl
   666 00001CA8 29D2                    	sub	dx, dx
   667 00001CAA F7F1                    	div	cx
   668 00001CAC 0016[841E]              	add	[msgHertz+1], dl
   669 00001CB0 0006[831E]              	add	[msgHertz], al
   670                                  	
   671 00001CB4 BA[761E]                        mov     dx, msgSampleRate
   672 00001CB7 B409                            mov     ah, 9
   673 00001CB9 CD21                            int     21h
   674                                  
   675                                  	; 19/11/2016
   676 00001CBB BA[9C1E]                	mov	dx, msg16Bits
   677 00001CBE 803E[AE1F]10            	cmp	byte [bps], 16
   678 00001CC3 7403                    	je	short wsr_1
   679 00001CC5 BA[8D1E]                	mov	dx, msg8Bits
   680                                  wsr_1:
   681 00001CC8 B409                            mov     ah, 9
   682 00001CCA CD21                            int     21h
   683                                  
   684 00001CCC BA[951E]                	mov	dx, msgMono
   685 00001CCF 803E[AC1F]01            	cmp	byte [stmo], 1
   686 00001CD4 7403                    	je	short wsr_2
   687 00001CD6 BA[A51E]                	mov	dx, msgStereo
   688                                  wsr_2:
   689 00001CD9 B409                            mov     ah, 9
   690 00001CDB CD21                            int     21h
   691                                  
   692 00001CDD C3                              retn
   693                                  
   694                                  ; 19/05/2024
   695                                  ; 10/11/2023
   696                                  ; 09/11/2023
   697                                  ; 06/11/2023
   698                                  %if 1
   699                                  
   700                                  ac97_int_handler:
   701                                  	; 19/05/2024
   702                                  	; 16/05/2024 ('PLAYMOD3.ASM', 18/05/2024, Erdogan Tan)
   703                                  	; 11/11/2023
   704                                  	; 10/11/2023
   705                                  	; 17/02/2016
   706 00001CDE 50                      	push	ax ; +	; 16/05/2024
   707                                  	;push	eax ; *	; 11/11/2023
   708 00001CDF 52                      	push	dx ; **
   709                                  	; 05/11/2023
   710                                  	;push	cx
   711                                  	;push	bx
   712                                  	;push	si
   713                                  	;push	di
   714                                  
   715                                  	; 10/11/2023
   716                                  	; EOI at first
   717 00001CE0 B020                    	mov	al, 20h
   718 00001CE2 F606[8F1F]08            	test	byte [ac97_int_ln_reg], 8
   719 00001CE7 7402                    	jz	short _ih_0
   720 00001CE9 E6A0                    	out 	0A0h, al ; 20h	; EOI
   721                                  _ih_0:
   722 00001CEB E620                    	out	20h, al  ; 20h	; EOI
   723                                  
   724                                  	; 16/05/2024
   725                                  ;	mov	dx, GLOB_STS_REG
   726                                  ;	add	dx, [NABMBAR]
   727                                  ;	in	eax, dx
   728                                  ;
   729                                  ;	inc	eax	; 0FFFFFFFFh
   730                                  ;	jz	short _ih_3
   731                                  ;	dec	eax	; 0
   732                                  ;	;jz	short _ih_3
   733                                  ;_ih_3:
   734                                  ;	; 16/05/2024
   735                                  ;	push	eax ; ***
   736                                  
   737                                  	; 16/05/2024
   738                                  	; 24/11/2023 (TRDOS386 'audio.s')
   739 00001CED 8B16[9A1F]                      mov	dx, [NABMBAR]
   740 00001CF1 83C216                  	add	dx, PO_SR_REG
   741 00001CF4 ED                      	in	ax, dx
   742                                  
   743                                  	; 04/02/2025
   744 00001CF5 A80C                    	test	al, BCIS + LVBCI ; bit 3, 2
   745                                  	;test	al, BCIS ; bit 3
   746 00001CF7 7405                    	jz	short _ih_2
   747                                  
   748                                  	; 19/05/2024
   749                                  	; 15/05/2024
   750                                  	;cmp	byte [tLoop], 1
   751                                  	;jb	short _ih_2
   752                                  
   753                                  _ih_1:
   754                                  	; 19/05/2024
   755 00001CF9 50                      	push	ax ; ****
   756                                  
   757                                  	; 10/11/2023
   758                                  	; 28/11/2016 - Erdogan Tan
   759 00001CFA E8A8EA                  	call	tuneLoop
   760                                  
   761                                  	; 19/05/2024
   762 00001CFD 58                      	pop	ax ; ****
   763                                  
   764                                  	; 16/05/2024
   765                                  _ih_2:
   766                                  	;mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
   767 00001CFE 8B16[9A1F]              	mov	dx, [NABMBAR]
   768 00001D02 83C216                  	add	dx, PO_SR_REG
   769 00001D05 EF                      	out	dx, ax
   770                                  
   771                                  ;	; 16/05/2024
   772                                  ;	pop	eax ; ***
   773                                  ;	
   774                                  ;	or	eax, eax
   775                                  ;	jz	short _ih_4
   776                                  ;	
   777                                  ;	mov	dx, GLOB_STS_REG
   778                                  ;	add	dx, [NABMBAR]
   779                                  ;	out	dx, eax
   780                                  
   781                                  	; 16/05/2024
   782                                  _ih_4:
   783                                  	; 10/11/2023
   784                                  	;mov	al, 20h
   785                                  	;test	byte [ac97_int_ln_reg], 8
   786                                  	;jz	short _ih_5
   787                                  	;out 	0A0h, al ; 20h	; EOI
   788                                  ;_ih_5:
   789                                  	;out	20h, al  ; 20h	; EOI
   790                                  ;_ih_6:
   791                                  	;pop	di
   792                                  	;pop	si
   793                                  	;pop	bx
   794                                  	;pop	cx
   795 00001D06 5A                      	pop	dx ; **
   796                                  	;pop	eax ; *	; 11/11/2023
   797 00001D07 58                      	pop	ax ; + ; 16/05/2024
   798 00001D08 CF                      	iret
   799                                  
   800                                  %else
   801                                  
   802                                  ac97_int_handler:
   803                                  	; 19/11/2023
   804                                  	; 18/11/2023
   805                                  	; 11/11/2023
   806                                  	; 10/11/2023
   807                                  	; 17/02/2016
   808                                  	push	eax	; 11/11/2023
   809                                  	push	dx
   810                                  	; 05/11/2023
   811                                  	;push	cx
   812                                  	;push	bx
   813                                  	;push	si
   814                                  	;push	di
   815                                  
   816                                  ;	; 10/11/2023
   817                                  ;	; EOI at first
   818                                  ;	mov	al, 20h
   819                                  ;	test	byte [ac97_int_ln_reg], 8
   820                                  ;	jz	short _ih_0
   821                                  ;	out 	0A0h, al ; 20h	; EOI
   822                                  ;_ih_0:
   823                                  ;	out	20h, al  ; 20h	; EOI
   824                                  
   825                                  	; 11/11/2023
   826                                  	; 09/11/2023
   827                                  	mov	dx, GLOB_STS_REG
   828                                          add	dx, [NABMBAR]
   829                                  	in	eax, dx
   830                                  	
   831                                  	; 09/11/2023,
   832                                          cmp	eax, 0FFFFFFFFh ; -1
   833                                  	je	short _ih_2
   834                                  	
   835                                  	test	al, 40h		; PCM Out Interrupt
   836                                  	jnz	short _ih_1
   837                                  
   838                                  	test	eax, eax
   839                                  	jz	short _ih_2
   840                                  
   841                                   	;mov	dx, GLOB_STS_REG
   842                                          ;add	dx, [NABMBAR]
   843                                  	out	dx, eax
   844                                  	jmp	short _ih_2
   845                                  _ih_1:
   846                                  	; 11/11/2023
   847                                  	push	eax
   848                                  
   849                                  	;mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
   850                                  	;mov	dx, PO_SR_REG
   851                                          ;add	dx, [NABMBAR]
   852                                  	;out	dx, ax
   853                                  
   854                                  	; 10/11/2023
   855                                  	; 28/11/2016 - Erdogan Tan
   856                                  	call	tuneLoop
   857                                  
   858                                  	; 11/11/2023
   859                                  	pop	eax
   860                                  	
   861                                  	mov	dx, GLOB_STS_REG
   862                                          add	dx, [NABMBAR]
   863                                  	out	dx, eax
   864                                  _ih_2:
   865                                  	; 11/11/2023
   866                                  	mov	dx, [NABMBAR]
   867                                  	add	dx, PO_SR_REG	; set pointer to Status reg
   868                                  	mov	ax, 1Ch ; clear FIFOE, BCIS, LVBCI
   869                                  	out	dx, ax
   870                                  
   871                                  _ih_3:	; 19/11/2023
   872                                  	mov	al, 20h
   873                                  	test	byte [ac97_int_ln_reg], 8
   874                                  	jz	short _ih_0
   875                                  	out 	0A0h, al ; 20h	; EOI
   876                                  _ih_0:
   877                                  	out	20h, al  ; 20h	; EOI
   878                                  
   879                                  	pop	dx
   880                                  	pop	eax
   881                                  	iret
   882                                  
   883                                  %endif
   884                                  
   885                                  ac97_stop:
   886                                  	; 11/11/2023
   887                                  	; 09/11/2023
   888                                  	; 05/11/2023
   889                                  	; 04/11/2023 
   890                                  	; 28/05/2017 (TRDOS 386 v2, 'audio.s')
   891                                  	;mov	byte [tLoop], 0 ; stop ! ; 05/11/2023
   892                                  ;_ac97_stop:
   893                                  
   894                                  	; 11/11/2023
   895 00001D09 8B16[981F]              	mov	dx, [NAMBAR]
   896                                  	;add	dx, 0 ; ac_reg_0 ; reset register
   897 00001D0D EF                      	out	dx, ax
   898                                  
   899                                  	; 04/11/2023
   900                                  	; 09/10/2017 (TRDOS 386 v2, 'audio.s')
   901                                  	; 11/06/2017
   902 00001D0E 30C0                    	xor	al, al ; 0
   903 00001D10 E80D00                  	call	ac97_po_cmd
   904                                  
   905                                  	; (Ref: KolibriOS, intelac97.asm, 'stop:')
   906                                  	; Clear FIFOE, BCIS, LVBCI (Ref: Intel ICH hub manual)
   907 00001D13 B81C00                  	mov     ax, 1Ch
   908 00001D16 8B16[9A1F]              	mov     dx, [NABMBAR]
   909 00001D1A 83C216                  	add     dx, PO_SR_REG
   910 00001D1D EF                      	out     dx, ax
   911                                  
   912                                  	; 11/06/2017
   913 00001D1E B002                    	mov     al, RR
   914                                  ac97_po_cmd:
   915                                  	; 11/06/2017
   916                                  	; 29/05/2017
   917 00001D20 8B16[9A1F]              	mov     dx, [NABMBAR]
   918 00001D24 83C21B                          add     dx, PO_CR_REG		; PCM out control register
   919 00001D27 EE                      	out	dx, al
   920 00001D28 C3                      	retn
   921                                  
   922                                  print_msg:
   923                                  	; 13/11/2016 - Erdogan Tan 
   924                                  	; esi = ASCIIZ text address
   925                                  	;
   926 00001D29 BB0700                  	mov	bx, 7h
   927 00001D2C B40E                    	mov	ah, 0Eh 
   928                                  pm_next_char:
   929 00001D2E AC                      	lodsb
   930 00001D2F 20C0                    	and	al, al
   931 00001D31 7404                    	jz	short pm_retn
   932 00001D33 CD10                    	int	10h
   933 00001D35 EBF7                    	jmp	short pm_next_char
   934                                  pm_retn:
   935 00001D37 C3                      	retn
   936                                  
   937                                  ; 06/11/2023
   938                                  ;dword2str:
   939                                  ;	; 13/11/2016 - Erdogan Tan
   940                                  ;	; eax = dword value
   941                                  ;	;
   942                                  ;	call	dwordtohex
   943                                  ;	mov	[dword_str], edx
   944                                  ;	mov	[dword_str+4], eax
   945                                  ;	mov	si, dword_str
   946                                  ;	retn
   947                                  
   948                                  	; trdos386.s (unix386.s) - 10/05/2015
   949                                  	; Convert binary number to hexadecimal string
   950                                  
   951                                  bytetohex:
   952                                  	; INPUT ->
   953                                  	; 	AL = byte (binary number)
   954                                  	; OUTPUT ->
   955                                  	;	AX = hexadecimal string
   956                                  	;
   957 00001D38 53                      	push	bx
   958 00001D39 30FF                    	xor	bh, bh
   959 00001D3B 88C3                    	mov	bl, al
   960 00001D3D C0EB04                  	shr	bl, 4
   961 00001D40 8A9F[D31D]              	mov	bl, [bx+hex_chars]
   962 00001D44 86C3                    	xchg	bl, al
   963 00001D46 80E30F                  	and	bl, 0Fh
   964 00001D49 8AA7[D31D]              	mov	ah, [bx+hex_chars]
   965 00001D4D 5B                      	pop	bx	
   966 00001D4E C3                      	retn
   967                                  
   968                                  wordtohex:
   969                                  	; INPUT ->
   970                                  	; 	AX = word (binary number)
   971                                  	; OUTPUT ->
   972                                  	;	EAX = hexadecimal string
   973                                  	;
   974 00001D4F 53                      	push	bx
   975 00001D50 30FF                    	xor	bh, bh
   976 00001D52 86C4                    	xchg	ah, al
   977 00001D54 50                      	push	ax
   978 00001D55 88E3                    	mov	bl, ah
   979 00001D57 C0EB04                  	shr	bl, 4
   980 00001D5A 8A87[D31D]              	mov	al, [bx+hex_chars]
   981 00001D5E 88E3                    	mov	bl, ah
   982 00001D60 80E30F                  	and	bl, 0Fh
   983 00001D63 8AA7[D31D]              	mov	ah, [bx+hex_chars]
   984 00001D67 66C1E010                	shl	eax, 16
   985 00001D6B 58                      	pop	ax
   986 00001D6C 5B                      	pop	bx
   987 00001D6D EBC9                    	jmp	short bytetohex
   988                                  
   989                                  ; 06/11/2023
   990                                  ;dwordtohex:
   991                                  ;	; INPUT ->
   992                                  ;	; 	EAX = dword (binary number)
   993                                  ;	; OUTPUT ->
   994                                  ;	;	EDX:EAX = hexadecimal string
   995                                  ;	;
   996                                  ;	push	eax
   997                                  ;	shr	eax, 16
   998                                  ;	call	wordtohex
   999                                  ;	mov	edx, eax
  1000                                  ;	pop	eax
  1001                                  ;	call	wordtohex
  1002                                  ;	retn
  1003                                  
  1004                                  _DATA:
  1005                                  
  1006                                  ; 24/11/2016
  1007                                  ;	IRQ  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15 
  1008 00001D6F 08090A0B0C0D0E0F70-     irq_int	 db 08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh,70h,71h,72h,73h,74h,75h,76h,77h
  1008 00001D78 71727374757677     
  1009                                  
  1010                                  ; 17/02/2017
  1011                                  ; Valid ICH device IDs
  1012                                  
  1013                                  valid_ids:
  1014 00001D7F 86801524                dd	(ICH_DID << 16) + INTEL_VID  	 ; 8086h:2415h
  1015 00001D83 86802524                dd	(ICH0_DID << 16) + INTEL_VID 	 ; 8086h:2425h
  1016 00001D87 86804524                dd	(ICH2_DID << 16) + INTEL_VID 	 ; 8086h:2445h
  1017 00001D8B 86808524                dd	(ICH3_DID << 16) + INTEL_VID 	 ; 8086h:2485h
  1018 00001D8F 8680C524                dd	(ICH4_DID << 16) + INTEL_VID 	 ; 8086h:24C5h
  1019 00001D93 8680D524                dd	(ICH5_DID << 16) + INTEL_VID 	 ; 8086h:24D5h
  1020 00001D97 86806E26                dd	(ICH6_DID << 16) + INTEL_VID 	 ; 8086h:266Eh
  1021 00001D9B 8680A625                dd	(ESB6300_DID << 16) + INTEL_VID  ; 8086h:25A6h
  1022 00001D9F 86809826                dd	(ESB631X_DID << 16) + INTEL_VID  ; 8086h:2698h
  1023 00001DA3 8680DE27                dd	(ICH7_DID << 16) + INTEL_VID 	 ; 8086h:27DEh
  1024                                  ; 03/11/2023 - Erdogan Tan
  1025 00001DA7 86809571                dd	(MX82440_DID << 16) + INTEL_VID  ; 8086h:7195h
  1026 00001DAB 39101270                dd	(SI7012_DID << 16)  + SIS_VID	 ; 1039h:7012h
  1027 00001DAF DE10B101                dd 	(NFORCE_DID << 16)  + NVIDIA_VID ; 10DEh:01B1h
  1028 00001DB3 DE106A00                dd 	(NFORCE2_DID << 16) + NVIDIA_VID ; 10DEh:006Ah
  1029 00001DB7 22106D74                dd 	(AMD8111_DID << 16) + AMD_VID 	 ; 1022h:746Dh
  1030 00001DBB 22104574                dd 	(AMD768_DID << 16)  + AMD_VID 	 ; 1022h:7445h
  1031 00001DBF DE105900                dd 	(CK804_DID << 16) + NVIDIA_VID	 ; 10DEh:0059h
  1032 00001DC3 DE103A00                dd 	(MCP04_DID << 16) + NVIDIA_VID	 ; 10DEh:003Ah
  1033 00001DC7 DE108A00                dd 	(CK8_DID << 16) + NVIDIA_VID	 ; 1022h:008Ah
  1034 00001DCB DE10DA00                dd 	(NFORCE3_DID << 16) + NVIDIA_VID ; 10DEh:00DAh
  1035 00001DCF DE10EA00                dd 	(CK8S_DID << 16) + NVIDIA_VID	 ; 10DEh:00EAh
  1036                                  
  1037                                  valid_id_count:	equ ($ - valid_ids)>>2 ; 05/11/2023
  1038                                  
  1039                                  ; 13/11/2016
  1040 00001DD3 303132333435363738-     hex_chars	db "0123456789ABCDEF", 0
  1040 00001DDC 3941424344454600   
  1041 00001DE4 414339372041756469-     msgAC97Info	db "AC97 Audio Controller & Codec Info", 0Dh, 0Ah 
  1041 00001DED 6F20436F6E74726F6C-
  1041 00001DF6 6C6572202620436F64-
  1041 00001DFF 656320496E666F0D0A 
  1042 00001E08 56656E646F72204944-     		db "Vendor ID: "
  1042 00001E11 3A20               
  1043 00001E13 303030306820446576-     msgVendorId	db "0000h Device ID: "
  1043 00001E1C 6963652049443A20   
  1044 00001E24 30303030680D0A          msgDevId	db "0000h", 0Dh, 0Ah
  1045 00001E2B 4275733A20              		db "Bus: "
  1046 00001E30 303068204465766963-     msgBusNo	db "00h Device: "
  1046 00001E39 653A20             
  1047 00001E3C 3030682046756E6374-     msgDevNo	db "00h Function: "
  1047 00001E45 696F6E3A20         
  1048 00001E4A 303068                  msgFncNo	db "00h"
  1049 00001E4D 0D0A                    		db 0Dh, 0Ah
  1050                                  ; 05/11/2023	
  1051 00001E4F 4E414D4241523A20        		db "NAMBAR: "
  1052 00001E57 303030306820            msgNamBar	db "0000h "
  1053 00001E5D 4E41424D4241523A20      		db "NABMBAR: "
  1054 00001E66 303030306820495251-     msgNabmBar	db "0000h IRQ: "
  1054 00001E6F 3A20               
  1055 00001E71 3030                    msgIRQ		dw 3030h
  1056 00001E73 0D0A24                  		db 0Dh, 0Ah, "$"
  1057 00001E76 53616D706C65205261-     msgSampleRate	db "Sample Rate: "
  1057 00001E7F 74653A20           
  1058 00001E83 303030303020487A20-     msgHertz	db "00000 Hz ", "$" 
  1058 00001E8C 24                 
  1059 00001E8D 3820626974732024        msg8Bits	db "8 bits ", "$" 
  1060 00001E95 4D6F6E6F0D0A24          msgMono		db "Mono", 0Dh, 0Ah, "$"
  1061 00001E9C 313620626974732024      msg16Bits	db "16 bits ", "$" 
  1062 00001EA5 53746572656F0D0A24      msgStereo	db "Stereo", 0Dh, 0Ah, "$"
  1063                                  
  1064                                  ;; 13/11/2016 - Erdogan Tan (Ref: KolibriOS, codec.inc)
  1065                                  ;codec_id	dd 0
  1066                                  ;codec_chip_id	dd 0
  1067                                  ;codec_vendor_ids dw 0
  1068                                  ;codec_chip_ids	dw 0
  1069                                  
  1070 00001EAE 3030303030303030        dword_str	 dd 30303030h, 30303030h
  1071 00001EB6 680D0A00                		 db 'h', 0Dh, 0Ah, 0
  1072                                  
  1073                                  ;ac_unknown     db 'unknown manufacturer',13,10,0
  1074                                  ;ac_Realtek     db 'Realtek Semiconductor',13,10,0
  1075                                  ;ac_Analog      db 'Analog Devices',13,10,0
  1076                                  ;ac_CMedia      db 'C-Media Electronics',13,10,0
  1077                                  ;ac_Cirrus      db 'Cirrus Logic',13,10,0
  1078                                  ;ac_Wolfson     db 'Wolfson Microelectronics',13,10,0
  1079                                  ;ac_VIA         db 'VIA Technologies',13,10,0
  1080                                  ;ac_SigmaTel    db 'SigmaTel',13,10,0
  1081                                  ;ac_eMicro      db 'eMicro',13,10,0
  1082                                  ;
  1083                                  ;chip_unknown   db 'unknown codec id ', 0
  1084                                  
  1085                                  ;CHIP_REALTEK   equ 414C4700h
  1086                                  ;CHIP_CMEDIA    equ 434D4900h
  1087                                  ;CHIP_VIA       equ 56494100h
  1088                                  
  1089                                  ;codecs        dd CHIP_CMEDIA
  1090                                  ;	       dw ac_CMedia, chips_CMedia
  1091                                  ;              dd CHIP_REALTEK
  1092                                  ;	       dw ac_Realtek, chips_Realtek
  1093                                  ;              dd CHIP_VIA
  1094                                  ;	       dw ac_VIA, chips_VIA
  1095                                  ;              dd 0
  1096                                  
  1097                                  ;chips_Realtek dw 10h, chip_ALC201a
  1098                                  ;              dw 20h, chip_ALC650
  1099                                  ;              dw 21h, chip_ALC650D
  1100                                  ;              dw 22h, chip_ALC650E
  1101                                  ;              dw 23h, chip_ALC650F
  1102                                  ;              dw 60h, chip_ALC655
  1103                                  ;              dw 80h, chip_ALC658
  1104                                  ;              dw 81h, chip_ALC658D
  1105                                  ;              dw 90h, chip_ALC850
  1106                                  ;              dw 0FFh
  1107                                  
  1108                                  ;chips_CMedia  dw 41h, chip_CM9738
  1109                                  ;              dw 61h, chip_CM9739
  1110                                  ;              dw 69h, chip_CM9780
  1111                                  ;              dw 78h, chip_CM9761
  1112                                  ;              dw 82h, chip_CM9761
  1113                                  ;              dw 83h, chip_CM9761
  1114                                  ;              dw 0FFh
  1115                                  
  1116                                  ;chips_VIA     dw 61h, chip_VIA1612A
  1117                                  ;              dw 0FFh
  1118                                  
  1119                                  ;Realtek
  1120                                  ;chip_ALC201a    db 'ALC201a',0dh,0ah,00h
  1121                                  ;chip_ALC650     db 'ALC650 ',0dh,0ah,00h
  1122                                  ;chip_ALC650D    db 'ALC650D',0dh,0ah,00h
  1123                                  ;chip_ALC650E    db 'ALC650E',0dh,0ah,00h
  1124                                  ;chip_ALC650F    db 'ALC650F',0dh,0ah,00h
  1125                                  ;chip_ALC655     db 'ALC655 ',0dh,0ah,00h
  1126                                  ;chip_ALC658     db 'ALC658 ',0dh,0ah,00h
  1127                                  ;chip_ALC658D    db 'ALC658D',0dh,0ah,00h
  1128                                  ;chip_ALC850     db 'ALC850 ',0dh,0ah,00h
  1129                                  
  1130                                  ;CMedia
  1131                                  ;chip_CM9738     db 'CMI9738', 0dh,0ah,0
  1132                                  ;chip_CM9739     db 'CMI9739', 0dh,0ah,0
  1133                                  ;chip_CM9780     db 'CMI9780', 0dh,0ah,0
  1134                                  ;chip_CM9761     db 'CMI9761', 0dh,0ah,0
  1135                                  
  1136                                  ;VIA
  1137                                  ;chip_VIA1612A   db 'VIA1612A',13,10,0
  1138                                  
  1139                                  ; 11/11/2023
  1140                                  msg_init_err:
  1141 00001EBA 0D0A                    	db	CR, LF
  1142 00001EBC 4143393720436F6E74-     	db	"AC97 Controller/Codec initialization error !"
  1142 00001EC5 726F6C6C65722F436F-
  1142 00001ECE 64656320696E697469-
  1142 00001ED7 616C697A6174696F6E-
  1142 00001EE0 206572726F722021   
  1143 00001EE8 0D0A24                  	db	CR, LF, "$"
  1144                                  
  1145                                  ; 12/11/2023
  1146                                  msg_no_vra:
  1147 00001EEB 0D0A                    	db	CR, LF
  1148 00001EED 4E6F20565241207375-     	db	"No VRA support ! Only 48 kHZ sample rate supported !"
  1148 00001EF6 70706F72742021204F-
  1148 00001EFF 6E6C79203438206B48-
  1148 00001F08 5A2073616D706C6520-
  1148 00001F11 726174652073757070-
  1148 00001F1A 6F727465642021     
  1149 00001F21 0D0A24                  	db	CR, LF, "$"
  1150                                  
  1151                                  ; 02/02/2025 (signature)
  1152                                  Credits:
  1153 00001F24 54696E792057415620-     	db	'Tiny WAV Player for Retro DOS by Erdogan Tan. '
  1153 00001F2D 506C6179657220666F-
  1153 00001F36 7220526574726F2044-
  1153 00001F3F 4F5320627920457264-
  1153 00001F48 6F67616E2054616E2E-
  1153 00001F51 20                 
  1154 00001F52 466562727561727920-     	db	'February 2025.',10,13,"$"
  1154 00001F5B 323032352E0A0D24   
  1155 00001F63 0030342F30322F3230-     	db	0, '04/02/2025', 0
  1155 00001F6C 323500             
  1156                                  
  1157                                  ; 17/02/2017
  1158                                  bss_start:
  1159                                  
  1160                                  ABSOLUTE bss_start
  1161                                  
  1162 00001F6F ??                      alignb 2
  1163                                  
  1164                                  ; 28/11/2016
  1165                                  
  1166 00001F70 <res 1Ch>               smpRBuff:	resw 14 ; 19/11/2016 - Erdogan Tan
  1167                                  
  1168 00001F8C ????                    filehandle:	resw 1
  1169                                  
  1170 00001F8E ??                      flags:		resb 1
  1171                                  ; 06/11/2023
  1172 00001F8F ??                      ac97_int_ln_reg: resb 1
  1173                                  
  1174                                  ; 09/11/2023
  1175                                  ; 06/11/2023
  1176                                  ;pcm_irq_status: resb 1	; 05/11/2023
  1177 00001F90 ??                      inside:		resb 1
  1178 00001F91 ??                      tloop:		resb 1	; 10/11/2023
  1179                                  
  1180                                  ; 09/11/2023
  1181                                  ; 04/11/2023 - 06/11/2023
  1182 00001F92 ????                    IRQ_status:	resw 1	; IRQ status before enabling audio interrupt
  1183 00001F94 ????????                IRQ_vector:	resd 1  ; Previous interrupt handler address
  1184                                  
  1185                                  ; 17/02/2017
  1186                                  ; NAMBAR:  Native Audio Mixer Base Address Register
  1187                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 10h-13h
  1188                                  ; NABMBAR: Native Audio Bus Mastering Base Address register
  1189                                  ;    (ICH, Audio D31:F5, PCI Config Space) Address offset: 14h-17h
  1190 00001F98 ????                    NAMBAR:		resw 1			; BAR for mixer
  1191 00001F9A ????                    NABMBAR:	resw 1			; BAR for bus master regs
  1192                                  
  1193                                  ; 256 byte buffer for descriptor list
  1194 00001F9C ????                    BDL_BUFFER:	resw 1			; segment of our 256byte BDL buffer
  1195 00001F9E ????                    WAV_BUFFER1:	resw 1			; segment of our WAV storage
  1196                                  ; 64k buffers for wav file storage
  1197 00001FA0 ????                    WAV_BUFFER2:	resw 1			; segment of 2nd wav buffer
  1198                                  
  1199                                  ; 06/11/2023
  1200                                  ;tBuff:		resb 1
  1201                                  ;ac97_int_ln_reg: resb 1
  1202                                  
  1203                                  ; 12/11/2016 - Erdogan Tan
  1204                                  
  1205 00001FA2 ????????                bus_dev_fn:	resd 1
  1206 00001FA6 ????????                dev_vendor:	resd 1
  1207                                  ; 06/11/2023
  1208                                  ;stats_cmd:	resw 1 ; 17/02/2017
  1209                                  ; 05/11/2023
  1210                                  ;ac97_io_base:	resw 1
  1211 00001FAA ????                    sample_rate:	resw 1
  1212                                  
  1213                                  ; 19/11/2016
  1214 00001FAC ????                    stmo:		resw 1
  1215 00001FAE ????                    bps:		resw 1
  1216                                  
  1217                                  ; 08/11/2023
  1218                                  ; 07/11/2023
  1219 00001FB0 ??                      fbs_shift:	resb 1
  1220                                  ; 09/11/2023
  1221 00001FB1 ??                      b_indicator:	resb 1
  1222                                  ; 10/11/2023
  1223 00001FB2 ??                      LVI:		resb 1
  1224 00001FB3 ??                      		resb 1 ; 10/11/2023 
  1225                                  
  1226                                  ;fbs_seg:	resw 1
  1227                                  ;fbs_off:	resw 1
  1228                                  
  1229                                  ;alignb 2
  1230                                  
  1231                                  ; 32 kilo bytes for temporay buffer
  1232                                  ; (for stereo-mono, 8bit/16bit corrections)
  1233                                  ;temp_buffer:	resb 32768
  1234                                  ; 18/11/2023
  1235 00001FB4 <res DBF0h>             temp_buffer:	resb 56304  ; (44.1 kHZ stereo 14076 samples)
  1236                                  
  1237                                  ;alignb 16
  1238                                  EOF:
