     1                                  ; ****************************************************************************
     2                                  ; tmodplay.s (for TRDOS 386)
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; TMODPLAY.PRG ! SOUND BLASTER 16 MOD PLAYER & VGA DEMO program by Erdogan TAN
     5                                  ;
     6                                  ; 21/10/2017
     7                                  ;
     8                                  ; [ Last Modification: 27/10/2017 ]  !!! STEREO MOD PLAYING !!!
     9                                  ;
    10                                  ; For 640x480x16 display, 'TNYPL211' source code ('EX1A.ASM' and 'EX1B.ASM'
    11                                  ; by Carlos Hasan, 1994) is modified in order to use previous ('modplay7.s')
    12                                  ; scope method as stereo. (Track/channel scope method -in TNYPL211 files- 
    13                                  ; is/was not applied because TRDOS 386 adaption of the tiny mod player uses 
    14                                  ; dma buffer for immediate -synchronized- displaying of sound waves.
    15                                  ; So, stereo wave display -two waves, two scopes- is normally applicable.)
    16                                  ;
    17                                  ; Modified from 'modplay7.s' (MODPLAY7.PRG) source code by Erdogan Tan
    18                                  ; (20/10/2017). ((Stereo mod playing with TRDOS 386 audio system calls...))
    19                                  ;
    20                                  ; Derived from source code of 'PLAY.EXE' (TINYPLAY) by Carlos Hasan (1993)
    21                                  ;          PLAY.EXE: PLAY.ASM, MODLOAD.ASM, MODPLAY.ASM, SB.ASM
    22                                  ;
    23                                  ; Stereophonic mod playing code prototype: 
    24                                  ;		'modplay6.s' (AC97) by Erdogan Tan (18/10/2017)
    25                                  ;
    26                                  ; Modified by using the source code of 'tinyply3.s' ('TINYPLY3.PRG') 
    27                                  ; by Erdogan Tan (07/10/2017)
    28                                  ;
    29                                  ; Modified from 'playwav3.s' (13/06/2017)
    30                                  ;
    31                                  ; Modified from 'PLAYMOD.PRG' ('playmod.s') source code by Erdogan Tan
    32                                  ;			                     (23/06/2017)
    33                                  ;
    34                                  ; Derived from source code of 'TINYPLAY.COM' ('TINYPLAY.ASM') by Erdogan Tan
    35                                  ;				      (04/03/2017) 
    36                                  ; Assembler: NASM 2.11
    37                                  ; ----------------------------------------------------------------------------
    38                                  ;	   nasm  modplay.s -l modplay.txt -o MODPLAY.PRG	
    39                                  ; ****************************************************************************
    40                                  ; PLAYMOD.ASM by Erdogan Tan (for MSDOS) (15/02/2017)
    41                                  ; TMODPLAY.ASM by Erdogan Tan (for MSDOS) (01/10/2017)
    42                                  
    43                                  ; 01/03/2017
    44                                  ; 16/10/2016
    45                                  ; 29/04/2016
    46                                  ; TRDOS 386 system calls (temporary list!)
    47                                  _ver 	equ 0
    48                                  _exit 	equ 1
    49                                  _fork 	equ 2
    50                                  _read 	equ 3
    51                                  _write	equ 4
    52                                  _open	equ 5
    53                                  _close 	equ 6
    54                                  _wait 	equ 7
    55                                  _creat 	equ 8
    56                                  _link 	equ 9
    57                                  _unlink	equ 10
    58                                  _exec	equ 11
    59                                  _chdir	equ 12
    60                                  _time 	equ 13
    61                                  _mkdir 	equ 14
    62                                  _chmod	equ 15
    63                                  _chown	equ 16
    64                                  _break	equ 17
    65                                  _stat	equ 18
    66                                  _seek	equ 19
    67                                  _tell 	equ 20
    68                                  _mount	equ 21
    69                                  _umount	equ 22
    70                                  _setuid	equ 23
    71                                  _getuid	equ 24
    72                                  _stime	equ 25
    73                                  _quit	equ 26	
    74                                  _intr	equ 27
    75                                  _fstat	equ 28
    76                                  _emt 	equ 29
    77                                  _mdate 	equ 30
    78                                  _video 	equ 31
    79                                  _audio	equ 32
    80                                  _timer	equ 33
    81                                  _sleep	equ 34
    82                                  _msg    equ 35
    83                                  _geterr	equ 36
    84                                  _fpsave	equ 37
    85                                  _pri	equ 38
    86                                  _rele	equ 39
    87                                  _fff	equ 40
    88                                  _fnf	equ 41
    89                                  _alloc	equ 42
    90                                  _dalloc equ 43
    91                                  _calbac equ 44		
    92                                  
    93                                  %macro sys 1-4
    94                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    95                                      ; 03/09/2015	
    96                                      ; 13/04/2015
    97                                      ; Retro UNIX 386 v1 system call.	
    98                                      %if %0 >= 2   
    99                                          mov ebx, %2
   100                                          %if %0 >= 3    
   101                                              mov ecx, %3
   102                                              %if %0 = 4
   103                                                 mov edx, %4   
   104                                              %endif
   105                                          %endif
   106                                      %endif
   107                                      mov eax, %1
   108                                      ;int 30h
   109                                      int 40h ; TRDOS 386 (TRDOS v2.0)	   
   110                                  %endmacro
   111                                  
   112                                  ; TRDOS 386 (and Retro UNIX 386 v1) system call format:
   113                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
   114                                  
   115                                  ; 19/06/2017
   116                                  BUFFERSIZE equ 32768
   117                                  
   118                                  ; ----------------------------------------------------------------------------
   119                                  ; Tiny MOD Player v0.1b by Carlos Hasan.
   120                                  ;	July 14th, 1993.
   121                                  
   122                                  ;=============================================================================
   123                                  ;  
   124                                  ;=============================================================================
   125                                  
   126                                  [BITS 32]
   127                                  [org 0]
   128                                  
   129                                  Start:
   130                                  	; clear bss
   131 00000000 B9[00000800]            	mov	ecx, EOF
   132 00000005 BF[55500000]            	mov	edi, bss_start
   133 0000000A 29F9                    	sub	ecx, edi
   134 0000000C D1E9                    	shr	ecx, 1
   135 0000000E 31C0                    	xor	eax, eax
   136 00000010 F366AB                  	rep	stosw
   137                                  
   138                                  	; Detect (& Enable) Sound Blaster 16 Audio Device
   139 00000013 E813020000              	call    DetectSB16
   140 00000018 731B                    	jnc     short GetFileName
   141                                  
   142                                  _dev_not_ready:
   143                                  ; couldn't find the audio device!
   144                                  	sys	_msg, MsgNotFound, 255, 0Fh
   144                              <1> 
   144                              <1> 
   144                              <1> 
   144                              <1> 
   144                              <1>  %if %0 >= 2
   144 0000001A BB[C24F0000]        <1>  mov ebx, %2
   144                              <1>  %if %0 >= 3
   144 0000001F B9FF000000          <1>  mov ecx, %3
   144                              <1>  %if %0 = 4
   144 00000024 BA0F000000          <1>  mov edx, %4
   144                              <1>  %endif
   144                              <1>  %endif
   144                              <1>  %endif
   144 00000029 B823000000          <1>  mov eax, %1
   144                              <1> 
   144 0000002E CD40                <1>  int 40h
   145 00000030 E9D5010000                      jmp     Exit
   146                                  
   147                                  GetFileName:
   148                                  	;cmp	ah, 1 ; SB16 Sound card
   149                                  	;jne	_dev_not_ready	
   150                                  	  
   151 00000035 89E6                    	mov	esi, esp
   152 00000037 AD                      	lodsd
   153 00000038 83F802                  	cmp	eax, 2 ; two arguments 
   154                                  		; (program file name & mod file name)
   155 0000003B 0F82D2010000            	jb	pmsg_usage ; nothing to do
   156                                  
   157 00000041 AD                      	lodsd ; program file name address 
   158 00000042 AD                      	lodsd ; mod file name address (file to be read)
   159 00000043 89C6                    	mov	esi, eax
   160 00000045 BF[B0DD0000]            	mov	edi, mod_file_name
   161                                  ScanName:       
   162 0000004A AC                      	lodsb
   163 0000004B 84C0                    	test	al, al
   164 0000004D 0F84C0010000            	je	pmsg_usage
   165 00000053 3C20                    	cmp	al, 20h
   166 00000055 74F3                    	je	short ScanName	; scan start of name.
   167 00000057 AA                      	stosb
   168 00000058 B4FF                    	mov	ah, 0FFh
   169                                  a_0:	
   170 0000005A FEC4                    	inc	ah
   171                                  a_1:
   172 0000005C AC                      	lodsb
   173 0000005D AA                      	stosb
   174 0000005E 3C2E                    	cmp	al, '.'
   175 00000060 74F8                    	je	short a_0	
   176 00000062 20C0                    	and	al, al
   177 00000064 75F6                    	jnz	short a_1
   178                                  
   179 00000066 08E4                    	or	ah, ah		 ; if period NOT found,
   180 00000068 750B                    	jnz	short PrintPMesg ; then add a .MOD extension.
   181                                  SetExt:
   182 0000006A 4F                      	dec	edi
   183 0000006B C7072E4D4F44            	mov	dword [edi], '.MOD'
   184 00000071 C6470400                	mov	byte [edi+4], 0
   185                                  PrintPMesg:      
   186                                  	; Prints the Credits Text.
   187                                  	sys	_msg, Credits, 255, 0Fh
   187                              <1> 
   187                              <1> 
   187                              <1> 
   187                              <1> 
   187                              <1>  %if %0 >= 2
   187 00000075 BB[714F0000]        <1>  mov ebx, %2
   187                              <1>  %if %0 >= 3
   187 0000007A B9FF000000          <1>  mov ecx, %3
   187                              <1>  %if %0 = 4
   187 0000007F BA0F000000          <1>  mov edx, %4
   187                              <1>  %endif
   187                              <1>  %endif
   187                              <1>  %endif
   187 00000084 B823000000          <1>  mov eax, %1
   187                              <1> 
   187 00000089 CD40                <1>  int 40h
   188                                  _1:
   189                                  	; 19/06/2017
   190                                  	; Allocate Audio Buffer (for user)
   191                                  	sys	_audio, 0200h, BUFFERSIZE, Audio_Buffer
   191                              <1> 
   191                              <1> 
   191                              <1> 
   191                              <1> 
   191                              <1>  %if %0 >= 2
   191 0000008B BB00020000          <1>  mov ebx, %2
   191                              <1>  %if %0 >= 3
   191 00000090 B900800000          <1>  mov ecx, %3
   191                              <1>  %if %0 = 4
   191 00000095 BA[00E00000]        <1>  mov edx, %4
   191                              <1>  %endif
   191                              <1>  %endif
   191                              <1>  %endif
   191 0000009A B820000000          <1>  mov eax, %1
   191                              <1> 
   191 0000009F CD40                <1>  int 40h
   192 000000A1 0F820C010000            	jc	error_exit
   193                                  _2:
   194                                  	;; Initialize Audio Device (bl = 1 -> Interrupt method)
   195                                  	;sys	_audio, 0301h, 0, sb16_int_handler 
   196                                  	;jc	error_exit
   197                                  	
   198                                  	; 20/10/2017
   199                                  	; Initialize Audio Device (bl = 0 -> SRB method)
   200                                  	sys	_audio, 0300h, 1, srb 
   200                              <1> 
   200                              <1> 
   200                              <1> 
   200                              <1> 
   200                              <1>  %if %0 >= 2
   200 000000A7 BB00030000          <1>  mov ebx, %2
   200                              <1>  %if %0 >= 3
   200 000000AC B901000000          <1>  mov ecx, %3
   200                              <1>  %if %0 = 4
   200 000000B1 BA[79500000]        <1>  mov edx, %4
   200                              <1>  %endif
   200                              <1>  %endif
   200                              <1>  %endif
   200 000000B6 B820000000          <1>  mov eax, %1
   200                              <1> 
   200 000000BB CD40                <1>  int 40h
   201 000000BD 0F82F0000000            	jc	error_exit
   202                                  
   203                                  LoadMod:  
   204 000000C3 BF[B0DD0000]            	mov	edi, mod_file_name
   205 000000C8 E814020000              	call    LoadModule		; Load the MODule...
   206                                  	; 08/10/2017
   207 000000CD 731B                    	jnc	short _3		; any error loading?
   208                                  
   209                                  	; yes, print error and Exit.
   210                                  
   211                                  	sys	_msg, ErrorMesg, 255, 0Fh
   211                              <1> 
   211                              <1> 
   211                              <1> 
   211                              <1> 
   211                              <1>  %if %0 >= 2
   211 000000CF BB[A54F0000]        <1>  mov ebx, %2
   211                              <1>  %if %0 >= 3
   211 000000D4 B9FF000000          <1>  mov ecx, %3
   211                              <1>  %if %0 = 4
   211 000000D9 BA0F000000          <1>  mov edx, %4
   211                              <1>  %endif
   211                              <1>  %endif
   211                              <1>  %endif
   211 000000DE B823000000          <1>  mov eax, %1
   211                              <1> 
   211 000000E3 CD40                <1>  int 40h
   212 000000E5 E920010000              	jmp     Exit
   213                                  _3:
   214                                  	; 24/06/2017
   215                                  	sys	_audio, 0E00h ; get audio controller info
   215                              <1> 
   215                              <1> 
   215                              <1> 
   215                              <1> 
   215                              <1>  %if %0 >= 2
   215 000000EA BB000E0000          <1>  mov ebx, %2
   215                              <1>  %if %0 >= 3
   215                              <1>  mov ecx, %3
   215                              <1>  %if %0 = 4
   215                              <1>  mov edx, %4
   215                              <1>  %endif
   215                              <1>  %endif
   215                              <1>  %endif
   215 000000EF B820000000          <1>  mov eax, %1
   215                              <1> 
   215 000000F4 CD40                <1>  int 40h
   216 000000F6 0F82B7000000            	jc	error_exit
   217                                  
   218                                  	; EAX = IRQ Number in AL
   219                                  	;	Audio Device Number in AH 
   220                                  	; EBX = DEV/VENDOR ID
   221                                  	;       (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
   222                                  	; ECX = BUS/DEV/FN 
   223                                  	;       (00000000BBBBBBBBDDDDDFFF00000000)
   224                                  	; EDX = Base IO Addr (DX) for SB16 & VT8233
   225                                  	; EDX = NABMBAR/NAMBAR (for AC97)
   226                                  	;      (Low word, DX = NAMBAR address)
   227                                  
   228 000000FC 668915[3D500000]        	mov	[SbAddr], dx
   229 00000103 A2[3F500000]            	mov	[SbIrq], al
   230                                  
   231                                  	; Print Sucessful message.
   232                                  	;mov	dx, [SbAddr]
   233                                  	;mov	al, [SbIrq]
   234 00000108 C0EA04                  	shr     dl, 4
   235 0000010B 80C230                  	add     dl, '0'
   236 0000010E 8815[0A500000]          	mov     [PortText], dl
   237 00000114 0430                    	add     al, '0'
   238 00000116 A2[13500000]            	mov     [IrqText], al
   239                                  
   240                                  	sys	_msg, MsgFound, 255, 0Fh
   240                              <1> 
   240                              <1> 
   240                              <1> 
   240                              <1> 
   240                              <1>  %if %0 >= 2
   240 0000011B BB[EA4F0000]        <1>  mov ebx, %2
   240                              <1>  %if %0 >= 3
   240 00000120 B9FF000000          <1>  mov ecx, %3
   240                              <1>  %if %0 = 4
   240 00000125 BA0F000000          <1>  mov edx, %4
   240                              <1>  %endif
   240                              <1>  %endif
   240                              <1>  %endif
   240 0000012A B823000000          <1>  mov eax, %1
   240                              <1> 
   240 0000012F CD40                <1>  int 40h
   241                                  
   242                                  PlayNow: 
   243 00000131 E884090000              	call    StartPlaying
   244                                  
   245                                          ; load 32768 bytes into audio buffer
   246 00000136 BF[00E00000]            	mov	edi, Audio_Buffer
   247                                  	; 19/10/2017
   248                                  	;mov	ebx, BUFFERSIZE
   249 0000013B BB00200000              	mov	ebx, BUFFERSIZE/4  ; 16 bits, stereo sound buffer
   250 00000140 E823080000              	call	GetSamples
   251 00000145 726C                    	jc	error_exit
   252                                  
   253                                  ;	;mov	ecx, 128	; Make a lookup table
   254                                  ;	mov	cl, 128
   255                                  ;	xor     ebx, ebx	; for fastest pixel
   256                                  ;	mov     edx, 320*(100-64)	; addressing.
   257                                  ;MakeOfs:        
   258                                  ;	mov     [RowOfs+ebx], dx
   259                                  ;	mov     [RowOfs+ebx+2], dx
   260                                  ;	add     dx, 320
   261                                  ;	add     ebx, 4
   262                                  ;	loop    MakeOfs
   263                                  
   264                                  ;	; 23/10/2017
   265                                  ;	mov	ebx, 64
   266                                  ;	mov	edi, RowOfs
   267                                  ;	xor	eax, eax 
   268                                  ;MakeOfs:
   269                                  ;	mov	cl, 4
   270                                  ;	rep	stosw
   271                                  ;	add	ax, 80 ; 640 pixels (80*8 bits)
   272                                  ;	dec	ebx
   273                                  ;	jnz	short MakeOfs
   274                                  
   275                                  	; 27/10/2017
   276 00000147 66B90001                	mov	cx, 256
   277 0000014B 31DB                    	xor	ebx, ebx
   278 0000014D BF[B0D30000]            	mov	edi, RowOfs
   279                                  MakeOfs:
   280 00000152 66B88000                	mov	ax, 128
   281 00000156 66F7E3                  	mul	bx
   282 00000159 88E0                    	mov	al, ah
   283 0000015B B450                    	mov	ah, 80
   284 0000015D F6E4                    	mul	ah
   285 0000015F 66AB                    	stosw
   286 00000161 43                      	inc	ebx
   287 00000162 E2EE                    	loop	MakeOfs
   288                                  	
   289                                  	;; 23/06/2017
   290                                  	;; Map DMA buffer to user's memory space
   291                                  	;sys	_audio, 0D00h, 65536, DMA_Buffer
   292                                  	;;jc	error_exit
   293                                  
   294                                  	; 24/06/2017
   295                                  	; Set Master Volume Level (BL=0 or 80h)
   296                                  	; 	 	for next playing (BL>=80h)
   297                                  	sys	_audio, 0B80h, 1D1Dh
   297                              <1> 
   297                              <1> 
   297                              <1> 
   297                              <1> 
   297                              <1>  %if %0 >= 2
   297 00000164 BB800B0000          <1>  mov ebx, %2
   297                              <1>  %if %0 >= 3
   297 00000169 B91D1D0000          <1>  mov ecx, %3
   297                              <1>  %if %0 = 4
   297                              <1>  mov edx, %4
   297                              <1>  %endif
   297                              <1>  %endif
   297                              <1>  %endif
   297 0000016E B820000000          <1>  mov eax, %1
   297                              <1> 
   297 00000173 CD40                <1>  int 40h
   298                                  
   299                                  	; 20/10/2017
   300 00000175 C605[01DE0000]1D        	mov	byte [volume_level], 1Dh
   301                                  
   302                                  	;mov	word [MixSpeed], 22050	; Mixing at 22.050 kHz
   303                                  	
   304                                  	; Start	to play
   305 0000017C A0[41500000]            	mov	al, [bps]
   306 00000181 C0E804                  	shr	al, 4 ; 8 -> 0, 16 -> 1
   307 00000184 D0E0                    	shl	al, 1 ; 16 -> 2, 8 -> 0
   308 00000186 8A1D[40500000]          	mov	bl, [stmo]
   309 0000018C FECB                    	dec	bl
   310 0000018E 08C3                    	or	bl, al
   311 00000190 668B0D[42500000]        	mov	cx, [MixSpeed] ; [Sample_Rate] ; Hz 
   312 00000197 B704                    	mov	bh, 4 ; start to play	
   313                                  	sys	_audio
   313                              <1> 
   313                              <1> 
   313                              <1> 
   313                              <1> 
   313                              <1>  %if %0 >= 2
   313                              <1>  mov ebx, %2
   313                              <1>  %if %0 >= 3
   313                              <1>  mov ecx, %3
   313                              <1>  %if %0 = 4
   313                              <1>  mov edx, %4
   313                              <1>  %endif
   313                              <1>  %endif
   313                              <1>  %endif
   313 00000199 B820000000          <1>  mov eax, %1
   313                              <1> 
   313 0000019E CD40                <1>  int 40h
   314                                      
   315                                  	;; SETUP SIGNAL RESPONSE BYTE
   316                                  	;; 06/03/2017
   317                                  	;mov	bl, [ac97_int_ln_reg] ; IRQ number
   318                                  	;mov	bh, 1 ; Link IRQ to user for Signal Response Byte
   319                                  	;mov	edx, srb  ; Signal Response/Return Byte address  
   320                                  	;mov	ecx, 0FFh ; Signal Response/Return Byte value  
   321                                  	;sys	_calbac
   322                                  	;jc	short error_exit
   323                                  
   324                                  	; DIRECT VGA MEMORY ACCESS
   325                                  	; bl = 0, bh = 5
   326                                  	; Direct access/map to VGA memory (0A0000h)
   327                                  
   328                                  	sys	_video, 0500h
   328                              <1> 
   328                              <1> 
   328                              <1> 
   328                              <1> 
   328                              <1>  %if %0 >= 2
   328 000001A0 BB00050000          <1>  mov ebx, %2
   328                              <1>  %if %0 >= 3
   328                              <1>  mov ecx, %3
   328                              <1>  %if %0 = 4
   328                              <1>  mov edx, %4
   328                              <1>  %endif
   328                              <1>  %endif
   328                              <1>  %endif
   328 000001A5 B81F000000          <1>  mov eax, %1
   328                              <1> 
   328 000001AA CD40                <1>  int 40h
   329 000001AC 3D00000A00              	cmp	eax, 0A0000h
   330 000001B1 7418                    	je	short _a3
   331                                  error_exit:
   332                                  	sys	_msg, trdos386_err_msg, 255, 0Eh
   332                              <1> 
   332                              <1> 
   332                              <1> 
   332                              <1> 
   332                              <1>  %if %0 >= 2
   332 000001B3 BB[18500000]        <1>  mov ebx, %2
   332                              <1>  %if %0 >= 3
   332 000001B8 B9FF000000          <1>  mov ecx, %3
   332                              <1>  %if %0 = 4
   332 000001BD BA0E000000          <1>  mov edx, %4
   332                              <1>  %endif
   332                              <1>  %endif
   332                              <1>  %endif
   332 000001C2 B823000000          <1>  mov eax, %1
   332                              <1> 
   332 000001C7 CD40                <1>  int 40h
   333 000001C9 EB3F                    	jmp	short Exit
   334                                  
   335                                  ; Note: Normally IRQ 0 calls the ModPlay Polling at 18.2Hz thru
   336                                  ;       the software interrupt 1Ch. If the IRQ 0 is disabled, then
   337                                  ;       the INT 1Ch MUST BE CALLED at least MixSpeed/1024 times per
   338                                  ;       second, or the module will sound "looped".
   339                                  ;       Because we need better sync with the ModPlayer to draw the scope,
   340                                  ;       the polling is called from my routine, and then the irq 0 must be
   341                                  ;       disabled. The [DmaBuffer] points to the current buffer of 8-bit
   342                                  ;       samples played by the Sound Blaster. Note that some samples are
   343                                  ;       discarded in the next code, just for fun!
   344                                  
   345                                  _a3:
   346                                  	;mov     ax, 0013h	; Set Mode 320x200x256
   347                                  	;int     31h
   348                                  
   349                                  	; 21/10/2017
   350                                  	;mov	ax, 0012h	; Set Mode 640x480x16
   351                                  	;int	31h
   352                                  
   353                                  	; 22/10/2017
   354 000001CB E8CB090000              	call	setgraphmode	; Set video mode to 640*480x16
   355                                  
   356                                  	; 22/10/2017
   357                                  	;call	loadlbm
   358                                  	;jc	short loadlbm_err
   359                                  
   360 000001D0 BE[CE0D0000]            	mov	esi, LOGO_ADDRESS
   361 000001D5 E8B90A0000              	call	putlbm
   362                                  	;jnc	short loadlbm_ok
   363 000001DA 731F                    	jnc	short _a4 ; 
   364                                  
   365                                  	;mov	byte [error_color], 0Eh ; Yellow
   366                                  
   367                                  loadlbm_err:
   368                                  	; 21/10/2017
   369                                  	;mov	ax, 0003h	; Set Text Mode 80x25x16
   370                                  	;int	31h
   371                                  	; 22/10/2017
   372 000001DC E8D7090000              	call	settextmode
   373                                  
   374                                  	sys	_msg, LOGO_ERROR_MSG, 255, [error_color]
   374                              <1> 
   374                              <1> 
   374                              <1> 
   374                              <1> 
   374                              <1>  %if %0 >= 2
   374 000001E1 BB[A10D0000]        <1>  mov ebx, %2
   374                              <1>  %if %0 >= 3
   374 000001E6 B9FF000000          <1>  mov ecx, %3
   374                              <1>  %if %0 = 4
   374 000001EB 8B15[FA010000]      <1>  mov edx, %4
   374                              <1>  %endif
   374                              <1>  %endif
   374                              <1>  %endif
   374 000001F1 B823000000          <1>  mov eax, %1
   374                              <1> 
   374 000001F6 CD40                <1>  int 40h
   375 000001F8 EB10                    	jmp	short Exit
   376                                  
   377                                  	; 21/10/2017
   378                                  error_color:
   379 000001FA 0C                      	db	0Ch  ; Light Red
   380                                  	
   381                                  loadlbm_ok: 
   382                                  	; 21/10/2017
   383                                  _a4:
   384                                  	; 24/06/2017
   385 000001FB E838000000              	call	PlayMod ; 13/02/2017 (ModPlay)
   386                                  
   387                                  _s_exit:
   388 00000200 E865090000              	call	StopPlaying	; STOP!
   389                                  	
   390                                  	; 22/10/2017
   391                                  	;mov	ax, 0003h	; Set Text Mode 80x25x16
   392                                  	;int	31h
   393 00000205 E8AE090000              	call	settextmode
   394                                  Exit:           
   395                                  	;call	FreeModule	; Free MODule core.
   396                                  	
   397                                  	sys 	_exit	; Bye !
   397                              <1> 
   397                              <1> 
   397                              <1> 
   397                              <1> 
   397                              <1>  %if %0 >= 2
   397                              <1>  mov ebx, %2
   397                              <1>  %if %0 >= 3
   397                              <1>  mov ecx, %3
   397                              <1>  %if %0 = 4
   397                              <1>  mov edx, %4
   397                              <1>  %endif
   397                              <1>  %endif
   397                              <1>  %endif
   397 0000020A B801000000          <1>  mov eax, %1
   397                              <1> 
   397 0000020F CD40                <1>  int 40h
   398                                  here:
   399 00000211 EBFE                    	jmp	short here
   400                                  
   401                                  pmsg_usage:
   402                                  	sys	_msg, msg_usage, 255, 0Fh
   402                              <1> 
   402                              <1> 
   402                              <1> 
   402                              <1> 
   402                              <1>  %if %0 >= 2
   402 00000213 BB[084F0000]        <1>  mov ebx, %2
   402                              <1>  %if %0 >= 3
   402 00000218 B9FF000000          <1>  mov ecx, %3
   402                              <1>  %if %0 = 4
   402 0000021D BA0F000000          <1>  mov edx, %4
   402                              <1>  %endif
   402                              <1>  %endif
   402                              <1>  %endif
   402 00000222 B823000000          <1>  mov eax, %1
   402                              <1> 
   402 00000227 CD40                <1>  int 40h
   403 00000229 EBDF                    	jmp	short Exit
   404                                  
   405                                  DetectSB16:
   406                                  	; 24/06/2017
   407                                  	; Detect (BH=1) SB16 (BL=1) Sound Card
   408                                          sys	_audio, 0101h
   408                              <1> 
   408                              <1> 
   408                              <1> 
   408                              <1> 
   408                              <1>  %if %0 >= 2
   408 0000022B BB01010000          <1>  mov ebx, %2
   408                              <1>  %if %0 >= 3
   408                              <1>  mov ecx, %3
   408                              <1>  %if %0 = 4
   408                              <1>  mov edx, %4
   408                              <1>  %endif
   408                              <1>  %endif
   408                              <1>  %endif
   408 00000230 B820000000          <1>  mov eax, %1
   408                              <1> 
   408 00000235 CD40                <1>  int 40h
   409 00000237 C3                      	retn
   410                                  
   411                                  ;sb16_int_handler:
   412                                  ;	; 24/06/2017
   413                                  ;	mov	byte [srb], 1 ; interrupt (or signal response byte)
   414                                  ;
   415                                  ;	sys	_rele ; return from callback service 
   416                                  ;	; we must not come here !
   417                                  ;	sys	_exit
   418                                  
   419                                  ;=============================================================================
   420                                  ;      
   421                                  ;=============================================================================
   422                                  
   423                                  PlayMod:
   424                                  	; 19/10/2017
   425                                  	; 23/06/2017   
   426                                  	; 21/06/2017
   427                                  	; 19/06/2017
   428                                  
   429                                  	; 05/03/2017 (TRDOS 386)
   430                                  	; 14/02/2017
   431                                  	; 13/02/2017
   432                                  	; 08/12/2016
   433                                  	; 28/11/2016
   434                                  
   435 00000238 EB10                         	jmp	short modp_gs ; 23/06/2017
   436                                  p_loop:
   437 0000023A 803D[79500000]00        	cmp	byte [srb], 0
   438 00000241 761C                    	jna	short q_loop
   439 00000243 C605[79500000]00        	mov	byte [srb], 0
   440                                  modp_gs:
   441 0000024A BF[00E00000]            	mov	edi, Audio_Buffer
   442                                  	; 19/10/2017
   443                                  	;mov	ebx, BUFFERSIZE ; 32768 bytes ; 14/03/2017
   444 0000024F BB00200000              	mov	ebx, BUFFERSIZE/4  ; 16 bits, stereo sound buffer
   445 00000254 E80F070000              	call	GetSamples
   446 00000259 0F8254FFFFFF            	jc	error_exit
   447                                  q_loop:
   448 0000025F B401                    	mov     ah, 1		; any key pressed?
   449 00000261 CD32                    	int     32h		; no, Loop.
   450 00000263 745C                    	jz	short r_loop
   451                                  
   452 00000265 B400                    	mov     ah, 0		; flush key buffer...
   453 00000267 CD32                    	int     32h
   454                                  
   455                                  	; 19/10/2017 (modplay6.s)
   456 00000269 3C20                    	cmp	al, 20h
   457 0000026B 740E                    	je	short change_pan
   458                                  	; 09/10/2017 (playmod5.s)
   459 0000026D 3C2B                    	cmp	al, '+' ; increase sound volume
   460 0000026F 741D                    	je	short inc_volume_level
   461 00000271 3C2D                    	cmp	al, '-'
   462 00000273 743C                    	je	short dec_volume_level
   463                                  
   464                                  	; 19/10/2017 (modplay6.s)
   465 00000275 24DF                    	and	al, 0DFh
   466 00000277 3C50                    	cmp	al, 'P'
   467 00000279 7545                    	jne	short q_return
   468                                  
   469                                  change_pan:
   470                                  	; 19/10/2017 (modplay6.s)
   471 0000027B 8A0D[00DE0000]          	mov	cl, [pan_shift]
   472 00000281 FEC1                    	inc	cl
   473 00000283 80E103                  	and	cl, 3
   474 00000286 880D[00DE0000]          	mov	[pan_shift], cl
   475 0000028C EB33                    	jmp	short r_loop
   476                                  
   477                                  	; 09/10/2017 (playmod5.s)
   478                                  	; 24/06/2017 (wavplay2.s)
   479                                  inc_volume_level:
   480 0000028E 8A0D[01DE0000]          	mov	cl, [volume_level]
   481 00000294 80F91F                  	cmp	cl, 1Fh ; 31
   482 00000297 7328                    	jnb	short r_loop
   483 00000299 FEC1                    	inc	cl
   484                                  change_volume_level:
   485 0000029B 880D[01DE0000]          	mov	[volume_level], cl
   486 000002A1 88CD                    	mov	ch, cl
   487                                  	; Set Master Volume Level
   488                                  	sys	_audio, 0B00h
   488                              <1> 
   488                              <1> 
   488                              <1> 
   488                              <1> 
   488                              <1>  %if %0 >= 2
   488 000002A3 BB000B0000          <1>  mov ebx, %2
   488                              <1>  %if %0 >= 3
   488                              <1>  mov ecx, %3
   488                              <1>  %if %0 = 4
   488                              <1>  mov edx, %4
   488                              <1>  %endif
   488                              <1>  %endif
   488                              <1>  %endif
   488 000002A8 B820000000          <1>  mov eax, %1
   488                              <1> 
   488 000002AD CD40                <1>  int 40h
   489 000002AF EB10                    	jmp	short r_loop
   490                                  dec_volume_level:
   491 000002B1 8A0D[01DE0000]          	mov	cl, [volume_level]
   492 000002B7 80F901                  	cmp	cl, 1 ; 1
   493 000002BA 7605                    	jna	short r_loop
   494 000002BC FEC9                    	dec	cl
   495 000002BE EBDB                    	jmp	short change_volume_level
   496                                  
   497                                  q_return:
   498 000002C0 C3                      	retn
   499                                  r_loop:
   500                                  	; Get Current DMA buffer Pointer 
   501                                  	; 23/06/2017
   502                                  	; bh = 15, get current pointer (DMA buffer offset)
   503                                  	; bl = 0, for PCM OUT
   504                                  	; ecx = 0
   505                                  	;
   506                                  	;sys	_audio, 0F00h, 0
   507                                  	
   508                                  	; Get Current Sound Data (in DMA buffer) ((320 bytes)) 
   509                                  	; 25/06/2017
   510                                  	; 22/06/2017
   511                                  	; bh = 15, get current sound data/samples
   512                                  	; bl = 0, for PCM OUT
   513                                  	; ecx = count of sample/data bytes (1 to 4096)
   514                                  	; edx = destination buffer address 
   515                                  	;	(page aligned address is better)
   516                                  	;
   517                                  	sys	_audio, 0F00h, 256*4, g_buff ; 23/10/2017 (256*4)
   517                              <1> 
   517                              <1> 
   517                              <1> 
   517                              <1> 
   517                              <1>  %if %0 >= 2
   517 000002C1 BB000F0000          <1>  mov ebx, %2
   517                              <1>  %if %0 >= 3
   517 000002C6 B900040000          <1>  mov ecx, %3
   517                              <1>  %if %0 = 4
   517 000002CB BA[00600100]        <1>  mov edx, %4
   517                              <1>  %endif
   517                              <1>  %endif
   517                              <1>  %endif
   517 000002D0 B820000000          <1>  mov eax, %1
   517                              <1> 
   517 000002D5 CD40                <1>  int 40h
   518                                  	
   519                                  	; 23/10/2017
   520 000002D7 E8E3080000              	call	drawscopes
   521                                  
   522 000002DC E959FFFFFF              	jmp	p_loop
   523                                  
   524                                  ;=============================================================================
   525                                  ;               MODLOAD.ASM
   526                                  ;=============================================================================
   527                                  
   528                                  ; Amiga Module Loader v0.1b by Carlos Hasan.
   529                                  ;	July 10th, 1993.
   530                                  
   531                                  ; STRUCTURES
   532                                  
   533                                  struc ModSample
   534 00000000 <res 00000016>          .msName:	resb 22
   535 00000016 <res 00000002>          .msLength:	resw 1
   536 00000018 <res 00000001>          .msFinetune:	resb 1
   537 00000019 <res 00000001>          .msVolume:	resb 1
   538 0000001A <res 00000002>          .msRepeat:	resw 1
   539 0000001C <res 00000002>          .msRepLen:	resw 1
   540                                  .size:		; 30 bytes
   541                                  endstruc
   542                                  
   543                                  struc ModHeader
   544 00000000 <res 00000014>          .mhName:	resb 20
   545 00000014 <res 000003A2>          .mhSamples:	resb ModSample.size*31
   546 000003B6 <res 00000001>          .mhOrderLen:	resb 1
   547 000003B7 <res 00000001>          .mhReStart:	resb 1
   548 000003B8 <res 00000080>          .mhOrder:	resb 128
   549 00000438 <res 00000004>          .mhSign:	resw 2
   550                                  .size:		; 1084 bytes
   551                                  endstruc
   552                                  
   553                                  struc ModInfoRec
   554 00000000 <res 00000001>          .OrderLen:	resb 1
   555 00000001 <res 00000001>          .ReStart:	resb 1
   556 00000002 <res 00000080>          .Order:		resb 128
   557 00000082 <res 00000004>          .Patterns:	resd 1
   558 00000086 <res 0000003E>          .SampOfs:	resw 31
   559 000000C4 <res 0000003E>          .SampSeg:	resw 31
   560 00000102 <res 0000003E>          .SampLen:	resw 31
   561 00000140 <res 0000003E>          .SampRep:	resw 31
   562 0000017E <res 0000003E>          .SampRepLen:	resw 31
   563 000001BC <res 0000003E>          .SampVol:	resw 31
   564                                  .size:		; 506 bytes	
   565                                  endstruc
   566                                  
   567                                  ; CODE
   568                                  
   569                                  ; modplay5.s
   570                                  ; 07/10/2017
   571                                  ; tinyply3.s
   572                                  ; 06/10/2017
   573                                  ; 04/10/2017
   574                                  ; /* MOD FileFormat */
   575                                  
   576                                  ID_MK	equ 2E4B2E4Dh ; "M.K."
   577                                  ID_FLT4 equ 34544C46h ; "FLT4"
   578                                  ID_8CHN equ 4E484338h ; "8CHN"
   579                                  ID_FLT8 equ 34544C46h ; "FLT8"
   580                                  
   581                                  ; CODE
   582                                  
   583                                  LoadModule:
   584                                  	; edi = file name address
   585                                  
   586 000002E1 60                      	pushad
   587                                  
   588 000002E2 E878010000              	call    ClearModInfo
   589                                  OpenFile:       
   590                                  	; ebx = ASCIIZ file name address
   591                                  	; ecx = open mode (0 = open for read)	
   592                                  	sys	_open, edi, 0 ; open for reading
   592                              <1> 
   592                              <1> 
   592                              <1> 
   592                              <1> 
   592                              <1>  %if %0 >= 2
   592 000002E7 89FB                <1>  mov ebx, %2
   592                              <1>  %if %0 >= 3
   592 000002E9 B900000000          <1>  mov ecx, %3
   592                              <1>  %if %0 = 4
   592                              <1>  mov edx, %4
   592                              <1>  %endif
   592                              <1>  %endif
   592                              <1>  %endif
   592 000002EE B805000000          <1>  mov eax, %1
   592                              <1> 
   592 000002F3 CD40                <1>  int 40h
   593 000002F5 0F8262010000            	jc	Failed
   594 000002FB A3[7A500000]            	mov     [FileHandle], eax
   595                                  ReadHeader:
   596                                  	; ebx = File handle
   597                                  	; ecx = Buffer address
   598                                  	; edx = Byte count
   599                                  	sys	_read, [FileHandle], Header, ModHeader.size
   599                              <1> 
   599                              <1> 
   599                              <1> 
   599                              <1> 
   599                              <1>  %if %0 >= 2
   599 00000300 8B1D[7A500000]      <1>  mov ebx, %2
   599                              <1>  %if %0 >= 3
   599 00000306 B9[7E500000]        <1>  mov ecx, %3
   599                              <1>  %if %0 = 4
   599 0000030B BA3C040000          <1>  mov edx, %4
   599                              <1>  %endif
   599                              <1>  %endif
   599                              <1>  %endif
   599 00000310 B803000000          <1>  mov eax, %1
   599                              <1> 
   599 00000315 CD40                <1>  int 40h
   600 00000317 0F8231010000            	jc      CloseFile
   601                                  CheckMK:  
   602                                  	; 04/10/2017
   603 0000031D A1[B6540000]            	mov	eax, [Header+ModHeader.mhSign]
   604                                        
   605 00000322 3D4D2E4B2E              	cmp	eax, ID_MK   ; cmp eax, '.K.M'
   606                                  	;je	short Is4chnMod
   607 00000327 742B                    	je	short IsModFile
   608                                  CheckFLT4:
   609 00000329 3D464C5434              	cmp	eax, ID_FLT4 ; cmp eax, '4TLF'
   610                                  	;je	short Is4chnMod
   611 0000032E 7424                    	je	short IsModFile
   612                                  Check8CHN:
   613 00000330 3D3843484E              	cmp	eax, ID_8CHN ; cmp eax,	'NHC8'
   614 00000335 740D                    	je	short Is8chnMod
   615                                  CheckFLT8:
   616 00000337 3D464C5434              	cmp	eax, ID_FLT8 ; cmp eax, '8TLF'
   617                                  	; 06/10/2017
   618 0000033C 7406                    	je	short Is8chnMod
   619 0000033E F9                      	stc
   620 0000033F E90A010000              	jmp	CloseFile
   621                                  Is8chnMod:
   622 00000344 C605[39500000]08        	mov	byte [numtracks], 8	; 8-CHANNEL-MOD
   623 0000034B C605[38500000]0B        	mov	byte [pattern_shift], 11 ; Pattern Size = 2048 bytes
   624 00000352 EB00                    	jmp	short IsModFile
   625                                  ;Is4chnMod:
   626                                  ;	mov	byte [numtracks], 4	; 4-CHANNEL-MOD
   627                                  ;	mov	byte [pattern_shift], 11 ; Pattern Size = 1024 bytes
   628                                  
   629                                  IsModFile:
   630 00000354 A0[34540000]            	mov     al, [Header+ModHeader.mhOrderLen]
   631 00000359 A2[BA540000]            	mov     [ModInfo.OrderLen], al
   632                                  
   633 0000035E A0[35540000]            	mov     al, [Header+ModHeader.mhReStart]
   634 00000363 3A05[34540000]          	cmp     al, [Header+ModHeader.mhOrderLen]
   635 00000369 7202                    	jb      short SetReStart
   636 0000036B B07F                    	mov     al, 7Fh
   637                                  SetReStart:
   638 0000036D A2[BB540000]            	mov     [ModInfo.ReStart], al
   639                                  
   640                                  	;mov	ecx, 128
   641 00000372 66B98000                	mov	cx, 128
   642 00000376 31D2                    	xor     edx, edx
   643 00000378 31DB                    	xor     ebx, ebx
   644                                  CopyOrder:
   645 0000037A 8AB3[36540000]          	mov     dh, [Header+ModHeader.mhOrder+ebx]
   646 00000380 88B3[BC540000]          	mov     [ModInfo.Order+ebx], dh
   647 00000386 38D6                    	cmp     dh, dl
   648 00000388 7202                    	jb      short NextOrder
   649 0000038A 88F2                    	mov     dl, dh ; Max. pattern number ; 04/10/2017
   650                                  NextOrder:
   651 0000038C 43                      	inc     ebx
   652 0000038D E2EB                    	loop    CopyOrder
   653                                  AllocPatterns:  
   654 0000038F 81E2FF000000            	and	edx, 0FFh
   655                                  	; 04/10/2017
   656                                  	;inx	dx  ; 12/03/2017
   657 00000395 FEC2                    	inc	dl
   658                                  	; dl = number of patterns (04/07/2017)
   659 00000397 8A0D[38500000]          	mov	cl, [pattern_shift] ; 10 for 4 channels, 11 for 8 channels
   660 0000039D D3E2                    	shl	edx, cl ; 10 ; *1024 ; (byte count of patterns *64*4*4)
   661                                  		     	     ; *2048 ; (byte count of patterns *64*8*4)
   662                                  	;
   663 0000039F 89D5                    	mov	ebp, edx ; offset of samples (04/07/2017)
   664                                  	;mov	ecx, 10000h ; next 64K (4096*16)
   665 000003A1 B9[00000200]            	mov	ecx, file_buffer ; 12/03/2017
   666                                  	;
   667 000003A6 890D[3C550000]          	mov	[ModInfo.Patterns], ecx
   668                                  	;
   669 000003AC 01CD                    	add	ebp, ecx ; next offset for samples
   670                                  ReadPatterns:  
   671                                  	;mov	ebx, [FileHandle] 
   672                                  	; ebx = File handle
   673                                  	; ecx = Buffer address
   674                                  	; edx = Byte count
   675                                  	sys	_read, [FileHandle]
   675                              <1> 
   675                              <1> 
   675                              <1> 
   675                              <1> 
   675                              <1>  %if %0 >= 2
   675 000003AE 8B1D[7A500000]      <1>  mov ebx, %2
   675                              <1>  %if %0 >= 3
   675                              <1>  mov ecx, %3
   675                              <1>  %if %0 = 4
   675                              <1>  mov edx, %4
   675                              <1>  %endif
   675                              <1>  %endif
   675                              <1>  %endif
   675 000003B4 B803000000          <1>  mov eax, %1
   675                              <1> 
   675 000003B9 CD40                <1>  int 40h
   676 000003BB 0F828D000000            	jc      CloseFile
   677                                  
   678                                  	; patterns have been loaded here... (04/07/2017)
   679                                  
   680 000003C1 BE[92500000]            	mov	esi, Header+ModHeader.mhSamples
   681 000003C6 31FF                    	xor     edi, edi
   682                                  CopySamples:
   683 000003C8 668B4616                	mov     ax, [esi+ModSample.msLength]
   684 000003CC 86C4                    	xchg    al, ah
   685 000003CE 66D1E0                  	shl     ax, 1
   686 000003D1 668987[BC550000]        	mov     [ModInfo.SampLen+edi], ax
   687 000003D8 8A4619                  	mov     al, [esi+ModSample.msVolume]
   688 000003DB 30E4                    	xor     ah, ah
   689 000003DD 668987[76560000]        	mov     [ModInfo.SampVol+edi], ax
   690 000003E4 668B461A                	mov     ax, [esi+ModSample.msRepeat]
   691 000003E8 86C4                    	xchg    al, ah
   692 000003EA 66D1E0                  	shl     ax, 1
   693 000003ED 668987[FA550000]        	mov     [ModInfo.SampRep+edi], ax
   694 000003F4 668B461C                	mov     ax, [esi+ModSample.msRepLen]
   695 000003F8 86C4                    	xchg    al, ah
   696 000003FA 66D1E0                  	shl     ax, 1
   697 000003FD 668987[38560000]        	mov     [ModInfo.SampRepLen+edi], ax
   698 00000404 83C61E                  	add     esi, ModSample.size
   699 00000407 6683C702                	add     di, 2
   700 0000040B 6683FF3E                	cmp     di, 2*31
   701 0000040F 72B7                    	jb      short CopySamples
   702                                  
   703 00000411 31F6                    	xor     esi, esi
   704                                  AllocSamples:
   705 00000413 0FB796[BC550000]        	movzx	edx, word [ModInfo.SampLen+esi]
   706                                  	; 07/10/2017
   707                                  	;shr	dx, 4 ; ***
   708 0000041A 21D2                    	and	edx, edx
   709 0000041C 7426                    	jz      short NextSample
   710                                  	;inc	dx  ; number of paragraphs ; ***
   711                                  	;shl	dx, 4 ; ***
   712 0000041E 89E8                    	mov	eax, ebp
   713 00000420 668986[40550000]        	mov	[ModInfo.SampOfs+esi], ax
   714 00000427 C1E810                  	shr	eax, 16
   715 0000042A 668986[7E550000]        	mov	[ModInfo.SampSeg+esi], ax
   716 00000431 89E9                    	mov	ecx, ebp
   717 00000433 01D5                    	add	ebp, edx ; next offset for sample 
   718                                  ReadSample:
   719                                  	;mov	ebx, [FileHandle]
   720                                  	;movzx  edx, [ModInfo.SampLen+esi]
   721                                  	;mov    ecx, [ModInfo.SampOfs+esi]
   722                                  
   723                                  	; ebx = File handle
   724                                  	; ecx = Buffer address
   725                                  	; edx = Byte count
   726                                  	sys	_read, [FileHandle]
   726                              <1> 
   726                              <1> 
   726                              <1> 
   726                              <1> 
   726                              <1>  %if %0 >= 2
   726 00000435 8B1D[7A500000]      <1>  mov ebx, %2
   726                              <1>  %if %0 >= 3
   726                              <1>  mov ecx, %3
   726                              <1>  %if %0 = 4
   726                              <1>  mov edx, %4
   726                              <1>  %endif
   726                              <1>  %endif
   726                              <1>  %endif
   726 0000043B B803000000          <1>  mov eax, %1
   726                              <1> 
   726 00000440 CD40                <1>  int 40h
   727 00000442 720A                    	jc      short CloseFile
   728                                  
   729                                  NextSample:
   730 00000444 6683C602                	add     si, 2
   731 00000448 6683FE3E                	cmp     si, 2*31
   732 0000044C 72C5                    	jb      short AllocSamples
   733                                  CloseFile:      
   734 0000044E 9C                      	pushf
   735                                  	sys	_close, [FileHandle]
   735                              <1> 
   735                              <1> 
   735                              <1> 
   735                              <1> 
   735                              <1>  %if %0 >= 2
   735 0000044F 8B1D[7A500000]      <1>  mov ebx, %2
   735                              <1>  %if %0 >= 3
   735                              <1>  mov ecx, %3
   735                              <1>  %if %0 = 4
   735                              <1>  mov edx, %4
   735                              <1>  %endif
   735                              <1>  %endif
   735                              <1>  %endif
   735 00000455 B806000000          <1>  mov eax, %1
   735                              <1> 
   735 0000045A CD40                <1>  int 40h
   736 0000045C 9D                      	popf
   737                                  Failed:       
   738 0000045D 61                      	popad
   739 0000045E C3                      	retn
   740                                  
   741                                  FreeModule:
   742                                  	; Erdogan Tan (13/02/2017)
   743                                  	; nothing to do here for memory de-allocation
   744                                  ClearModInfo:
   745 0000045F 57                      	push	edi
   746 00000460 BF[BA540000]            	mov	edi, ModInfo
   747 00000465 B9FA010000              	mov     ecx, ModInfoRec.size
   748                                  	;cld
   749 0000046A 30C0                    	xor     al, al
   750 0000046C F3AA                    	rep     stosb
   751 0000046E 5F                      	pop	edi
   752 0000046F C3                      	retn
   753                                  
   754                                  ;=============================================================================
   755                                  ;               MODPLAY.ASM
   756                                  ;=============================================================================
   757                                  
   758                                  ; Amiga Module Loader v0.3b by Carlos Hasan.
   759                                  ;	July 23th, 1993.
   760                                  
   761                                  ; EQUATES
   762                                  
   763                                  ;NumTracks	equ 4 ; 07/10/2017 ([numtracks])
   764                                  DefTempo        equ 6
   765                                  DefBpm          equ 125
   766                                  MidCRate        equ 8448
   767                                  MixBufSize	equ 4096
   768                                  ;MixBufSize	equ 7680 ; 17/10/2017 ; ((48000/50)*8)
   769                                  
   770                                  ; STRUCTURES
   771                                  
   772                                  struc TrackInfo  ; 01/10/2017 (TMODPLAY.ASM) modif. by Erdogan Tan
   773 00000000 <res 00000004>          .Samples:	resd 1
   774                                  ;.Position:	resw 1
   775 00000004 <res 00000004>          .Position:	resd 1 ; 01/10/2017 - TRDOS 386 modification ! 
   776 00000008 <res 00000002>          .Len:		resw 1
   777 0000000A <res 00000002>          .Repeat:	resw 1
   778 0000000C <res 00000002>          .RepLen:	resw 1
   779 0000000E <res 00000001>          .Volume: 	resb 1 ; Volume
   780 0000000F <res 00000001>          .VolDiff:	resb 1 ; 01/10/2017 ; Volume difference (Tremolo)
   781                                  ;.Error:	resb 1
   782                                  ;.Reserved:	resb 1 ; 01/10/2017
   783 00000010 <res 00000002>          .Period:	resw 1 ; Period
   784 00000012 <res 00000002>          .Pitch:		resw 1 
   785 00000014 <res 00000002>          .Effect:	resw 1 ; Effect
   786 00000016 <res 00000002>          .PortTo:	resw 1 ; Toneporta wanted period
   787 00000018 <res 00000001>          .PortParm:	resb 1 ; Toneporta speed
   788 00000019 <res 00000001>          .VibPos:	resb 1 ; Vibrato wave position 
   789 0000001A <res 00000001>          .VibParm:	resb 1 ; Vibrato depth/rate
   790 0000001B <res 00000001>          .TremPos:	resb 1 ; 01/10/2017 ; Tremolo wave position
   791 0000001C <res 00000001>          .TremParm:	resb 1 ; 01/10/2017 ; Tremolo depth/rate
   792                                  ;.OldSampOfs:	resb 1 ; ******* ; 01/10/2017
   793 0000001D <res 00000001>          .Error:		resb 1 ; 01/10/2017
   794 0000001E <res 00000006>          .Arp:		resw 3
   795 00000024 <res 00000002>          .ArpIndex:	resw 1
   796                                  .size:		; 38 bytes ; 01/10/2017 -  TRDOS 386
   797                                  endstruc
   798                                  
   799                                  ; CODE
   800                                  
   801                                  ;--------------------------------------------------------------------------
   802                                  ; updatechannel - update the track using the current effect
   803                                  ;--------------------------------------------------------------------------
   804                                  ; 
   805                                  ;--------------------------------------------------------------------------
   806                                  ; 	Track:  Process the next 	 in one track.
   807                                  ;  In:
   808                                  ;    ds:di -  Track info Address.
   809                                  ;--------------------------------------------------------------------------
   810                                  
   811                                  ; edi = Track info address
   812                                  
   813                                  updatechannel:
   814                                  BeatTrack:	; updatechannel ; 01/10/2017 (TMODPLAY.ASM)
   815                                  
   816 00000470 668B5714                	mov     dx, [edi+TrackInfo.Effect]
   817                                  
   818                                  	;test   dx, dx
   819                                  	;je     short None
   820                                  	;cmp    dh, 00h
   821                                  	;je     short Arpeggio
   822                                  	;cmp    dh, 01h
   823                                  	;je     short PortUp
   824                                  	;cmp    dh, 02h
   825                                  	;je     short PortDown
   826                                  	;cmp    dh, 03h
   827                                  	;je     TonePort
   828                                  	;cmp    dh, 04h
   829                                  	;je     Vibrato
   830                                  	;cmp    dh, 05h
   831                                  	;je     PortSlide
   832                                  	;cmp    dh, 06h
   833                                  	;je     VibSlide
   834                                  	;cmp    dh, 0Ah
   835                                  	;je     VolSlide
   836                                  	;retn
   837                                  
   838 00000474 0FB6C6                  	movzx	eax, dh
   839 00000477 240F                    	and	al, 0Fh
   840 00000479 FF2485[004E0000]        	jmp	dword [4*eax+efxtable2] ; TRDOS 386 ! (32 bits)
   841                                  efxnull:
   842                                  None:           
   843 00000480 C3                      	retn
   844                                  efxarpeggio2:
   845                                  	; 01/10/2017
   846 00000481 84D2                    	test    dl, dl
   847 00000483 74FB                    	jz      short efxnull
   848                                  Arpeggio:
   849 00000485 0FB75F24                	movzx   ebx, word [edi+TrackInfo.ArpIndex]
   850 00000489 668B441F1E              	mov     ax, [edi+TrackInfo.Arp+ebx]
   851 0000048E 66894712                	mov     [edi+TrackInfo.Pitch], ax
   852 00000492 6683C302                	add     bx, 2
   853 00000496 6683FB06                	cmp     bx, 6
   854 0000049A 7202                    	jb      short SetArpIndex
   855 0000049C 31DB                    	xor     ebx, ebx
   856                                  SetArpIndex:
   857 0000049E 66895F24                	mov     [edi+TrackInfo.ArpIndex], bx
   858 000004A2 C3                      	retn
   859                                  efxportaup:
   860                                  PortUp:
   861 000004A3 30F6                    	xor     dh, dh
   862                                  	;mov	bx, [edi+TrackInfo.Period]
   863 000004A5 0FB75F10                	movzx	ebx, word [edi+TrackInfo.Period] ; 02/10/2017
   864 000004A9 6629D3                  	sub     bx, dx
   865                                  	;cmp	bx, 113
   866 000004AC 6683FB1C                	cmp	bx, 28 ; 01/10/2017 
   867 000004B0 7D04                    	jge     short NotSmall
   868                                  	;mov	bx, 113
   869 000004B2 66BB1C00                	mov	bx, 28 ; 01/10/2017
   870                                  NotSmall:
   871 000004B6 66895F10                	mov     [edi+TrackInfo.Period], bx
   872 000004BA 6601DB                  	add     bx, bx
   873                                  	;mov	ax, [PitchTable+bx]
   874 000004BD 668B83[B4560000]        	mov	ax, [PitchTable+ebx]  ; 02/10/2017
   875 000004C4 66894712                	mov     [edi+TrackInfo.Pitch], ax
   876 000004C8 C3                      	retn
   877                                  efxportadown:
   878                                  PortDown:
   879 000004C9 30F6                    	xor     dh, dh
   880                                  	;mov	bx, [edi+TrackInfo.Period]
   881 000004CB 0FB75F10                	movzx	ebx, word [edi+TrackInfo.Period] ; 02/10/2017
   882 000004CF 6601D3                  	add     bx, dx
   883 000004D2 6681FB600D              	cmp	bx, 3424 ; 01/10/2017 
   884                                  	;cmp	bx, 856
   885 000004D7 7E04                    	jle     short NotBig
   886                                  	;mov	bx, 856
   887 000004D9 66BB600D                	mov	bx, 3424 ; 01/10/2017
   888                                  NotBig:         
   889 000004DD 66895F10                	mov     [edi+TrackInfo.Period], bx
   890 000004E1 6601DB                  	add     bx, bx
   891                                  	;mov	ax, [PitchTable+bx]
   892 000004E4 668B83[B4560000]        	mov	ax, [PitchTable+ebx]  ; 02/10/2017
   893 000004EB 66894712                	mov     [edi+TrackInfo.Pitch], ax
   894 000004EF C3                      	retn
   895                                  efxtoneporta2:
   896                                  TonePort:
   897 000004F0 30F6                    	xor     dh, dh
   898 000004F2 668B4716                	mov     ax, [edi+TrackInfo.PortTo]
   899                                  	;mov	bx, [edi+TrackInfo.Period]
   900 000004F6 0FB75F10                	movzx	ebx, word [edi+TrackInfo.Period] ; 02/10/2017
   901 000004FA 6639C3                  	cmp     bx, ax
   902 000004FD 7429                    	je      short NoPort
   903 000004FF 7F0D                    	jg      short PortToUp
   904                                  PortToDown:     
   905 00000501 6601D3                  	add     bx, dx
   906 00000504 6639C3                  	cmp     bx, ax
   907 00000507 7E0D                    	jle     short SetPort
   908                                  FixPort:        
   909 00000509 6689C3                  	mov     bx, ax
   910 0000050C EB08                    	jmp     short SetPort
   911                                  PortToUp:
   912 0000050E 6629D3                  	sub     bx, dx
   913 00000511 6639C3                  	cmp     bx, ax
   914 00000514 7CF3                    	jl      short FixPort
   915                                  SetPort:        
   916 00000516 66895F10                	mov     [edi+TrackInfo.Period], bx
   917 0000051A 6601DB                  	add     bx, bx
   918                                  	;mov	ax, [PitchTable+bx]
   919 0000051D 668B83[B4560000]        	mov	ax, [PitchTable+ebx]  ; 02/10/2017
   920 00000524 66894712                	mov     [edi+TrackInfo.Pitch], ax
   921                                  NoPort:         
   922 00000528 C3                      	retn
   923                                  efxvibrato2:
   924                                  	; 01/10/2017
   925                                  Vibrato:
   926 00000529 88D6                    	mov     dh, dl
   927                                  	;and	dl, 0Fh
   928                                  	;shr	dh, 4
   929                                  	;shl	dh, 2
   930 0000052B 6681E20FF0              	and     dx, 0F00Fh
   931 00000530 C0EE02                  	shr     dh, 2
   932                                  	;add	[edi+TrackInfo.VibPos], dh
   933                                  	;mov	dh, [edi+TrackInfo.VibPos]
   934                                  	;mov	bl, dh
   935 00000533 8A5F19                  	mov	bl, [edi+TrackInfo.VibPos]  ; 01/10/2017
   936 00000536 007719                  	add	[edi+TrackInfo.VibPos], dh
   937 00000539 88DE                    	mov	dh, bl ; 01/10/2017
   938 0000053B C0EB02                  	shr     bl, 2
   939                                  	;and	bx, 1Fh
   940                                  	;mov	al, [SinTable+bx]
   941 0000053E 83E31F                  	and	ebx, 1Fh
   942 00000541 8A83[E84E0000]          	mov	al, [SinTable+ebx]
   943 00000547 F6E2                    	mul     dl
   944                                  	;rol	ax, 1
   945                                  	;xchg	al, ah
   946                                  	;and	ah, 1
   947 00000549 66C1E807                	shr	ax, 7
   948 0000054D 84F6                    	test    dh, dh
   949 0000054F 7903                    	jns     short VibUp
   950 00000551 66F7D8                  	neg     ax
   951                                  VibUp:          
   952 00000554 66034710                	add     ax, [edi+TrackInfo.Period]
   953 00000558 6689C3                  	mov	bx, ax
   954                                  	;movzx	ebx, ax
   955 0000055B 6683FB71                	cmp     bx, 113
   956                                  	;cmp	bx, 113
   957 0000055F 6683FB1C                	cmp	bx, 28  ; 01/10/2017
   958 00000563 7D06                    	jge     short NoLoVib
   959                                  	;mov	bx, 113
   960 00000565 66BB1C00                	mov	bx, 28	; 01/10/2017
   961 00000569 EB0B                    	jmp	short NoHiVib ; 01/10/2017	
   962                                  NoLoVib:        
   963 0000056B 6681FB600D              	cmp	bx, 3424 ; 01/10/2017 
   964                                  	;cmp	bx, 856
   965 00000570 7E04                    	jle     short NoHiVib
   966                                  	;mov	bx, 856
   967 00000572 66BB600D                	mov	bx, 3424 ; 01/10/2017
   968                                  NoHiVib:        
   969 00000576 6601DB                  	add     bx, bx
   970                                  	;mov	ax, [PitchTable+bx]
   971 00000579 668B83[B4560000]        	mov	ax, [PitchTable+ebx] ; 01/10/2017
   972 00000580 66894712                	mov     [edi+TrackInfo.Pitch], ax
   973 00000584 C3                      	retn
   974                                  efxtoneslide:
   975                                  PortSlide:
   976 00000585 E812000000              	call    VolSlide
   977 0000058A 8A5718                  	mov     dl, [edi+TrackInfo.PortParm]  ; .tonespeed
   978 0000058D E95EFFFFFF              	jmp     TonePort  ; efxtoneporta2
   979                                  efxvibslide:
   980                                  VibSlide:
   981 00000592 E805000000              	call    VolSlide
   982 00000597 8A571A                  	mov     dl, [edi+TrackInfo.VibParm]
   983 0000059A EB8D                    	jmp     short Vibrato  ; efxvibrato2
   984                                  efxvolslide:
   985                                  VolSlide:
   986 0000059C 88D6                    	mov     dh, dl
   987 0000059E 80E20F                  	and     dl, 0Fh
   988 000005A1 C0EE04                  	shr     dh, 4
   989 000005A4 8A470E                  	mov     al, [edi+TrackInfo.Volume]
   990 000005A7 28D0                    	sub     al, dl
   991 000005A9 7D02                    	jge     short NoLoVol
   992 000005AB 30C0                    	xor     al, al
   993                                  NoLoVol:        
   994 000005AD 00F0                    	add     al, dh
   995 000005AF 3C40                    	cmp     al, 64
   996 000005B1 7602                    	jbe     short NoHiVol
   997 000005B3 B040                    	mov     al, 64
   998                                  NoHiVol:        
   999 000005B5 88470E                  	mov     [edi+TrackInfo.Volume], al
  1000 000005B8 C3                      	retn
  1001                                  
  1002                                  efxtremolo2:
  1003                                  	; 01/10/2017 (TMODPLAY.ASM)
  1004                                  Tremolo:
  1005 000005B9 88D6                    	mov     dh, dl
  1006 000005BB 6681E20FF0              	and     dx, 0F00Fh
  1007 000005C0 C0EE02                  	shr     dh, 2
  1008 000005C3 8A5F1B                  	mov	bl, [edi+TrackInfo.TremPos]
  1009 000005C6 00771B                  	add	[edi+TrackInfo.TremPos], dh
  1010 000005C9 88DE                    	mov	dh, bl
  1011 000005CB C0EB02                  	shr     bl, 2
  1012                                  	; 01/10/2017 - TRDOS 386
  1013                                  	;and	bx, 1Fh
  1014 000005CE 83E31F                  	and	ebx, 1Fh 
  1015                                  	;mov	al, [SinTable+bx]
  1016 000005D1 8A83[E84E0000]          	mov     al, [SinTable+ebx]
  1017 000005D7 F6E2                    	mul     dl
  1018 000005D9 66C1E806                	shr	ax, 6
  1019 000005DD 84F6                    	test    dh, dh
  1020 000005DF 7D03                    	jge	short Tremolo_1 ; efxtremolof2
  1021 000005E1 66F7D8                  	neg     ax
  1022                                  efxtremolof2:
  1023                                  Tremolo_1:      
  1024 000005E4 8A670E                  	mov	ah, [edi+TrackInfo.Volume]    
  1025 000005E7 00E0                    	add     al, ah
  1026 000005E9 7D02                    	jge     short Tremolo_2 ; efxtremolof3
  1027 000005EB 30C0                    	xor     al, al
  1028                                  efxtremolof3:
  1029                                  Tremolo_2:       
  1030 000005ED 3C40                    	cmp     al, 64 ; 40h
  1031 000005EF 7E02                    	jle     short Tremolo_3 ; efxtremolof4
  1032 000005F1 B040                    	mov     al, 64 ; 40h
  1033                                  efxtremolof4:
  1034                                  Tremolo_3:       
  1035 000005F3 28E0                    	sub	al, ah  ; ****** 
  1036 000005F5 88470F                  	mov     [edi+TrackInfo.VolDiff], al
  1037 000005F8 C3                      	retn	
  1038                                  
  1039                                  ;--------------------------------------------------------------------------
  1040                                  ; readchannel - read the next note event from the pattern sheet
  1041                                  ;--------------------------------------------------------------------------
  1042                                  ;
  1043                                  ;--------------------------------------------------------------------------
  1044                                  ; GetTrack:   Get the next Note from a pattern.
  1045                                  ;  In:
  1046                                  ;    ds:di -  Track info Address.
  1047                                  ;    es:si -  Pattern Note Address.
  1048                                  ; Out:
  1049                                  ;    es:si -  The Next Pattern Note address.
  1050                                  ;--------------------------------------------------------------------------
  1051                                  
  1052                                  ; esi = Pattern note address
  1053                                  ; edi = Track info address
  1054                                  
  1055                                  readchannel:
  1056                                  GetTrack: 	; readchannel ; 01/10/2017 (TMODPLAY.ASM)
  1057 000005F9 66AD                    	lodsw
  1058 000005FB 86C4                    	xchg    al, ah
  1059 000005FD 88E3                    	mov	bl, ah
  1060 000005FF 80E40F                  	and     ah, 0Fh
  1061 00000602 6689C1                  	mov     cx, ax
  1062 00000605 66AD                    	lodsw
  1063 00000607 86C4                    	xchg    al, ah
  1064 00000609 88E7                    	mov     bh, ah
  1065 0000060B 80E40F                  	and     ah, 0Fh
  1066 0000060E 6689C2                  	mov     dx, ax
  1067 00000611 66895714                	mov     [edi+TrackInfo.Effect], dx
  1068                                  	; 01/10/2017 - TRDOS 386
  1069                                  	;and	bl, 0F0h
  1070 00000615 81E3F0FF0000            	and	ebx, 0FFF0h
  1071 0000061B C0EF04                  	shr     bh, 4
  1072 0000061E 08FB                    	or      bl, bh
  1073 00000620 7446                    	jz      short SetPeriod
  1074                                  SetSample:
  1075 00000622 30FF                    	xor	bh, bh
  1076                                  	;and	ebx, 0FFh
  1077 00000624 FECB                    	dec     bl
  1078 00000626 01DB                    	add     ebx, ebx
  1079 00000628 668B83[76560000]        	mov     ax, [ModInfo.SampVol+ebx]
  1080 0000062F 88470E                  	mov     [edi+TrackInfo.Volume], al
  1081 00000632 668B83[40550000]        	mov     ax, [ModInfo.SampOfs+ebx]
  1082 00000639 668907                  	mov     [edi+TrackInfo.Samples], ax
  1083 0000063C 668B83[7E550000]        	mov     ax, [ModInfo.SampSeg+ebx]
  1084 00000643 66894702                	mov     [edi+TrackInfo.Samples+2], ax
  1085 00000647 668B83[BC550000]        	mov     ax, [ModInfo.SampLen+ebx]
  1086 0000064E 66894708                	mov     [edi+TrackInfo.Len], ax
  1087 00000652 668B83[FA550000]        	mov     ax, [ModInfo.SampRep+ebx]
  1088 00000659 6689470A                	mov     [edi+TrackInfo.Repeat], ax
  1089 0000065D 668B83[38560000]        	mov     ax, [ModInfo.SampRepLen+ebx]
  1090 00000664 6689470C                	mov     [edi+TrackInfo.RepLen], ax
  1091                                  SetPeriod:      
  1092 00000668 6685C9                  	test    cx, cx
  1093 0000066B 7425                    	jz      short SetEffect
  1094                                  
  1095 0000066D 66894F16                	mov     [edi+TrackInfo.PortTo], cx ; *
  1096                                  	
  1097 00000671 80FE03                  	cmp     dh, 03h
  1098                                  	;je	short SetEffect
  1099 00000674 7428                    	je	short efxtoneporta ; 01/10/2017
  1100                                  
  1101 00000676 66894F10                	mov     [edi+TrackInfo.Period], cx
  1102                                  	;movzx	ebx, cx
  1103 0000067A 6689CB                  	mov     bx, cx
  1104 0000067D 6601DB                  	add     bx, bx
  1105                                  	;mov	ax, [PitchTable+bx]
  1106 00000680 668B83[B4560000]        	mov	ax, [PitchTable+ebx] ; 01/10/2017
  1107 00000687 66894712                	mov     [edi+TrackInfo.Pitch], ax
  1108 0000068B C7470400000000          	mov     dword [edi+TrackInfo.Position], 0
  1109                                  SetEffect:
  1110                                  	;test	dx, dx
  1111                                  	;je	short InitNone
  1112                                  	;cmp	dh, 00h
  1113                                  	;je	InitArpeggio
  1114                                  	;cmp	dh, 03h
  1115                                  	;je	short InitTonePort
  1116                                  	;cmp	dh, 04h
  1117                                  	;je	short InitVibrato
  1118                                  	;cmp	dh, 09h
  1119                                  	;je	short SampleOfs
  1120                                  	;cmp	dh, 0Bh
  1121                                  	;je	short PosJump
  1122                                  	;cmp	dh, 0Ch
  1123                                  	;je	short SetVolume
  1124                                  	;cmp	dh, 0Dh
  1125                                  	;je	short Break
  1126                                  	;cmp	dh, 0Fh
  1127                                  	;je	SetSpeed
  1128                                  	;retn
  1129                                  
  1130                                  	; 01/10/2017 (TMODPLAY.ASM)
  1131                                  	
  1132                                  	; dx = [di+TrackInfo.Effect]
  1133                                  	
  1134 00000692 0FB6C6                  	movzx	eax, dh
  1135 00000695 240F                    	and	al, 0Fh
  1136 00000697 FF2485[C04D0000]        	jmp	dword [4*eax+efxtable] ; TRDOS 386 ! (32 bits)
  1137                                  ;efxnull:
  1138                                  ;InitNone:
  1139                                  ;	retn
  1140                                  efxtoneporta:
  1141                                  	; 01/10/2017
  1142                                  	; cx = period
  1143                                  	;mov	[edi+TrackInfo.PortTo], cx ; *
  1144                                  InitTonePort:
  1145 0000069E 84D2                    	test    dl, dl
  1146 000006A0 7503                    	jnz     short SetPortParm
  1147 000006A2 8A5718                  	mov     dl, [edi+TrackInfo.PortParm] ; .tonespeed
  1148                                  SetPortParm:    
  1149 000006A5 885718                  	mov     [edi+TrackInfo.PortParm], dl
  1150 000006A8 66895714                	mov     [edi+TrackInfo.Effect], dx
  1151 000006AC C3                      	retn
  1152                                  efxvibrato:
  1153                                  InitVibrato:
  1154 000006AD 8A471A                  	mov     al, [edi+TrackInfo.VibParm]
  1155 000006B0 88C4                    	mov     ah, al
  1156                                  	;and	al, 0Fh
  1157                                  	;and	ah, 0F0h
  1158 000006B2 66250FF0                	and	ax, 0F00Fh
  1159 000006B6 F6C20F                  	test    dl, 0Fh
  1160 000006B9 7502                    	jne     short OkDepth
  1161 000006BB 08C2                    	or      dl, al
  1162                                  OkDepth:        
  1163 000006BD F6C2F0                  	test    dl, 0F0h
  1164 000006C0 7502                    	jnz     short OkRate
  1165 000006C2 08E2                    	or      dl, ah
  1166                                  OkRate:         
  1167 000006C4 88571A                  	mov     [edi+TrackInfo.VibParm], dl
  1168 000006C7 66895714                	mov     [edi+TrackInfo.Effect], dx
  1169 000006CB 6685C9                  	test    cx, cx
  1170 000006CE 7404                    	jz      short OkPos
  1171 000006D0 C6471900                	mov     byte [edi+TrackInfo.VibPos], 0
  1172                                  OkPos:          
  1173 000006D4 C3                      	retn
  1174                                  efxsampoffset:
  1175                                  	; 01/10/2017 ; *******
  1176                                  SampleOfs:         
  1177                                  ;	test    dl, dl
  1178                                  ;	jnz     short SetSampleOfs
  1179                                  ;	mov     dl, [edi+TrackInfo.OldSampOfs]
  1180                                  ;SetSampleOfs:
  1181                                  ;	mov     [edi+TrackInfo.OldSampOfs], dl
  1182 000006D5 88D6                    	mov     dh, dl
  1183 000006D7 81E200FF0000            	and 	edx, 0FF00h ; 05/03/2017
  1184 000006DD 895704                  	mov     [edi+TrackInfo.Position], edx
  1185 000006E0 C3                      	retn
  1186                                  efxpattjump:
  1187                                  PosJump:
  1188 000006E1 8815[62D20000]          	mov     [OrderPos], dl
  1189 000006E7 C605[66D20000]40        	mov     byte [Row], 64
  1190 000006EE C3                      	retn
  1191                                  efxsetvolume:
  1192                                  SetVolume:
  1193 000006EF 80FA40                  	cmp     dl, 64
  1194 000006F2 7602                    	jbe     short OkVol
  1195 000006F4 B240                    	mov     dl, 64
  1196                                  OkVol:
  1197                                  	; 01/10/2017 (TrackInfo.VolDiff, tremolo effect)
  1198 000006F6 30F6                    	xor	dh, dh ; reset TrackInfo.VolDiff ; Not necessary !?
  1199                                  	;mov	[edi+TrackInfo.Volume], dl
  1200 000006F8 6689570E                	mov	[edi+TrackInfo.Volume], dx 
  1201 000006FC C3                      	retn
  1202                                  efxbreak:
  1203                                  Break:
  1204 000006FD 88D6                    	mov     dh, dl
  1205 000006FF 80E20F                  	and     dl, 0Fh
  1206 00000702 C0EE04                  	shr     dh, 4
  1207 00000705 00F6                    	add     dh, dh
  1208 00000707 00F2                    	add     dl, dh
  1209 00000709 C0E602                  	shl     dh, 2
  1210 0000070C 00F2                    	add     dl, dh
  1211 0000070E 8815[67D20000]          	mov     [BreakRow], dl
  1212 00000714 C605[66D20000]40        	mov     byte [Row], 64
  1213 0000071B C3                      	retn
  1214                                  efxsetspeed:
  1215                                  SetSpeed:
  1216 0000071C 84D2                    	test    dl,dl
  1217 0000071E 7432                    	je      Skip
  1218 00000720 80FA1F                  	cmp     dl,31
  1219 00000723 770D                    	ja      short SetBpm
  1220                                  SetTempo:       
  1221 00000725 8815[63D20000]          	mov     [Tempo], dl
  1222 0000072B 8815[64D20000]          	mov     [TempoWait], dl
  1223 00000731 C3                      	retn
  1224                                  SetBpm:
  1225 00000732 8815[65D20000]          	mov     [Bpm], dl
  1226 00000738 B067                    	mov     al, 103
  1227 0000073A F6E2                    	mul     dl
  1228 0000073C 88E3                    	mov     bl, ah
  1229 0000073E 30FF                    	xor     bh, bh
  1230 00000740 66A1[42500000]          	mov     ax, [MixSpeed]
  1231 00000746 6631D2                  	xor     dx, dx
  1232 00000749 66F7F3                  	div     bx
  1233 0000074C 66A3[68D20000]          	mov     [BpmSamples], ax
  1234                                  Skip:           
  1235 00000752 C3                      	retn
  1236                                  efxarpeggio:
  1237                                  	; 01/10/2017
  1238 00000753 84D2                    	test    dl, dl
  1239                                  	;je	efxnull
  1240 00000755 74FB                    	je	short Skip
  1241                                  InitArpeggio:
  1242 00000757 88D6                    	mov     dh, dl
  1243 00000759 80E20F                  	and     dl, 0Fh
  1244 0000075C C0EE04                  	shr     dh, 4
  1245                                  	; 01/10/2017
  1246                                  	;mov	cx, 36
  1247 0000075F 66B95400                	mov	cx, 84 ; 84 notes/periods
  1248 00000763 31DB                    	xor     ebx, ebx
  1249 00000765 668B4710                	mov     ax, [edi+TrackInfo.Period]
  1250                                  gt_ScanPeriod:
  1251                                  	;cmp	ax, [PeriodTable+bx]
  1252 00000769 663B83[404E0000]        	cmp	ax, [PeriodTable+ebx]
  1253 00000770 7306                    	jae     short SetArp
  1254 00000772 6683C302                	add     bx, 2
  1255 00000776 E2F1                    	loop    gt_ScanPeriod
  1256                                  SetArp:         
  1257 00000778 6601D2                  	add     dx, dx
  1258 0000077B 00DE                    	add     dh, bl
  1259 0000077D 00DA                    	add     dl, bl
  1260                                  	; 01/10/2017
  1261                                  	;mov	bx, [PeriodTable+bx]
  1262 0000077F 668B9B[404E0000]        	mov	bx, [PeriodTable+ebx]
  1263                                  	;add	bx, bx
  1264 00000786 01DB                    	add	ebx, ebx
  1265                                  	;mov	ax, [PitchTable+bx]
  1266 00000788 668B83[B4560000]        	mov	ax, [PitchTable+ebx]
  1267 0000078F 6689471E                	mov     [edi+TrackInfo.Arp], ax
  1268 00000793 88F3                    	mov     bl, dh
  1269 00000795 30FF                    	xor     bh, bh
  1270 00000797 668B9B[404E0000]        	mov	bx, [PeriodTable+ebx]
  1271                                  	;add	bx, bx
  1272 0000079E 01DB                    	add	ebx, ebx
  1273                                  	;mov	ax, [PitchTable+bx]
  1274 000007A0 668B83[B4560000]        	mov	ax, [PitchTable+ebx]
  1275 000007A7 66894720                	mov     [edi+TrackInfo.Arp+2], ax
  1276 000007AB 88D3                    	mov     bl, dl
  1277 000007AD 30FF                    	xor     bh, bh
  1278 000007AF 668B9B[404E0000]        	mov	bx, [PeriodTable+ebx]
  1279                                  	;add	bx, bx
  1280 000007B6 01DB                    	add	ebx, ebx
  1281                                  	;mov	ax, [PitchTable+bx]
  1282 000007B8 668B83[B4560000]        	mov	ax, [PitchTable+ebx]
  1283 000007BF 66894722                	mov     [edi+TrackInfo.Arp+4], ax
  1284 000007C3 66C747240000            	mov     word [edi+TrackInfo.ArpIndex], 0
  1285 000007C9 C3                      	retn
  1286                                  
  1287                                  efxtremolo:
  1288                                  	; 01/10/2017 (TMODPLAY.ASM)
  1289                                  InitTremolo:
  1290 000007CA 8A471C                  	mov     al, [edi+TrackInfo.TremParm]
  1291 000007CD 88C4                    	mov     ah, al
  1292 000007CF 66250FF0                	and     ax, 0F00Fh
  1293 000007D3 F6C20F                  	test    dl, 0Fh
  1294 000007D6 7502                    	jnz     short InitTremolo_1 ; efxtremolof0
  1295 000007D8 08C2                    	or      dl, al
  1296                                  efxtremolof0:
  1297                                  InitTremolo_1: 
  1298 000007DA F6C2F0                  	test    dl, 0F0h
  1299 000007DD 7502                    	jnz     short InitTremolo_2 ; efxtremolof1
  1300 000007DF 08E2                    	or      dl, ah
  1301                                  efxtremolof1:
  1302                                  InitTremolo_2:
  1303 000007E1 88571C                  	mov     [edi+TrackInfo.TremParm], dl
  1304 000007E4 66895714                	mov     [edi+TrackInfo.Effect], dx
  1305 000007E8 C3                      	retn
  1306                                  
  1307                                  ;--------------------------------------------------------------------------
  1308                                  ; pollmodule - polls the module player
  1309                                  ;--------------------------------------------------------------------------
  1310                                  ;--------------------------------------------------------------------------
  1311                                  ; UpdateTracks:  Main code to process the next tick to be played.
  1312                                  ;--------------------------------------------------------------------------
  1313                                  
  1314                                  pollmodule:
  1315                                  UpdateTracks:	; polmodule ; 01/10/2017 (TMODPLAY.ASM)
  1316 000007E9 FE0D[64D20000]          	dec     byte [TempoWait]
  1317 000007EF 7417                    	jz      short GetTracks
  1318                                  
  1319                                  	;mov	ecx, NumTracks
  1320 000007F1 0FB70D[39500000]        	movzx	ecx, word [numtracks] ; 06/10/2017
  1321 000007F8 BF[78D20000]            	mov	edi, Tracks
  1322                                  BeatTracks:
  1323 000007FD E86EFCFFFF              	call	BeatTrack	
  1324 00000802 83C726                  	add	edi, TrackInfo.size
  1325 00000805 E2F6                    	loop	BeatTracks
  1326 00000807 C3                      	retn
  1327                                  GetTracks:
  1328 00000808 A0[63D20000]            	mov     al, [Tempo]
  1329 0000080D A2[64D20000]            	mov     [TempoWait], al
  1330                                  
  1331 00000812 8B35[74D20000]          	mov	esi, [Note]
  1332 00000818 803D[66D20000]40        	cmp     byte [Row], 64
  1333 0000081F 7268                    	jb      short NoPattWrap
  1334                                  
  1335 00000821 8B35[3C550000]          	mov	esi, [ModInfo.Patterns]
  1336 00000827 8A1D[62D20000]          	mov     bl, [OrderPos]
  1337 0000082D 3A1D[BA540000]          	cmp     bl, [ModInfo.OrderLen]
  1338 00000833 7214                    	jb      short NoOrderWrap
  1339 00000835 8A1D[BB540000]          	mov     bl, [ModInfo.ReStart]
  1340 0000083B 881D[62D20000]          	mov     [OrderPos], bl
  1341 00000841 3A1D[BA540000]          	cmp     bl, [ModInfo.OrderLen]
  1342 00000847 7364                    	jae     short NoUpdate
  1343                                  NoOrderWrap:    
  1344                                  	;xor	bh, bh
  1345 00000849 81E3FF000000            	and	ebx, 0FFh
  1346 0000084F 8A9B[BC540000]          	mov     bl, [ModInfo.Order+ebx]
  1347                                  	; 05/10/2017
  1348                                  	;shl	ebx, 10 ; *1024
  1349 00000855 8A0D[38500000]          	mov	cl, [pattern_shift] ; 10 or 11
  1350 0000085B D3E3                    	shl	ebx, cl ; *1024 or *2048
  1351                                  	;
  1352 0000085D 01DE                    	add     esi, ebx
  1353 0000085F 8A1D[67D20000]          	mov     bl, [BreakRow]
  1354 00000865 881D[66D20000]          	mov     [Row], bl
  1355                                  	;xor	bh, bh
  1356 0000086B 81E3FF000000            	and	ebx, 0FFh
  1357 00000871 883D[67D20000]          	mov     [BreakRow], bh ; 0
  1358 00000877 66C1E304                	shl     bx, 4
  1359 0000087B 01DE                    	add     esi, ebx
  1360 0000087D 8935[74D20000]          	mov     [Note], esi
  1361 00000883 FE05[62D20000]          	inc     byte [OrderPos]
  1362                                  NoPattWrap:     
  1363 00000889 FE05[66D20000]          	inc     byte [Row]
  1364                                  
  1365                                  	;cld
  1366                                  	;mov	ecx, NumTracks
  1367 0000088F 0FB70D[39500000]        	movzx	ecx, word [numtracks] ; 06/10/2017
  1368 00000896 BF[78D20000]            	mov	edi, Tracks
  1369                                  GetTracks_next:
  1370 0000089B 51                      	push	ecx	
  1371 0000089C E858FDFFFF              	call	GetTrack ; readchannel
  1372 000008A1 59                      	pop	ecx
  1373 000008A2 83C726                  	add	edi, TrackInfo.size
  1374 000008A5 E2F4                    	loop	GetTracks_next
  1375                                  
  1376 000008A7 8935[74D20000]          	mov     [Note], esi
  1377                                  NoUpdate:
  1378 000008AD C3                      	retn
  1379                                  
  1380                                  ;--------------------------------------------------------------------------
  1381                                  ; MixTrack:  Mixes one track into a CLEAN buffer.
  1382                                  ;  In:
  1383                                  ;   ds:si -  Track Info Address.
  1384                                  ;   ds:di -  Buffer Address.
  1385                                  ;    cx   -  Buffer Size.
  1386                                  ;--------------------------------------------------------------------------
  1387                                  
  1388                                  ; esi = Track info address
  1389                                  ; edi = Buffer address
  1390                                  ; ecx = Buffer size
  1391                                  
  1392                                  MixTrack:
  1393 000008AE 66837E0C02              	cmp     word [esi+TrackInfo.RepLen], 2
  1394 000008B3 7757                    	ja      short MixLooped
  1395                                  MixNonLooped:   
  1396 000008B5 8B16                    	mov	edx, [esi+TrackInfo.Samples]
  1397 000008B7 8B5E04                  	mov	ebx, [esi+TrackInfo.Position]
  1398 000008BA 0FB76E08                	movzx   ebp, word [esi+TrackInfo.Len]
  1399 000008BE 52                      	push    edx
  1400 000008BF 56                      	push    esi
  1401 000008C0 01D3                    	add     ebx, edx
  1402 000008C2 01D5                    	add     ebp, edx
  1403 000008C4 668B5612                	mov     dx, [esi+TrackInfo.Pitch]
  1404                                  	; 01/10/2017
  1405                                  	;mov	al, [esi+TrackInfo.Volume]
  1406 000008C8 668B460E                	mov	ax, [esi+TrackInfo.Volume]
  1407                                  	; ah = [esi+TrackInfo.VolDiff]
  1408 000008CC 00E0                    	add	al, ah ; ****** 
  1409 000008CE C6460F00                	mov	byte [esi+TrackInfo.VolDiff], 0
  1410 000008D2 8A661D                  	mov     ah, [esi+TrackInfo.Error]
  1411 000008D5 89DE                    	mov     esi, ebx
  1412 000008D7 31DB                    	xor	ebx, ebx ; 01/10/2017 ; *
  1413 000008D9 88C7                    	mov     bh, al
  1414 000008DB 88D0                    	mov     al, dl
  1415 000008DD 88F2                    	mov     dl, dh
  1416                                  	;xor	dh, dh
  1417 000008DF 81E2FF000000            	and	edx, 0FFh
  1418                                  nlMixSamp:      
  1419 000008E5 39EE                    	cmp     esi, ebp
  1420 000008E7 7316                    	jae     short nlMixBye
  1421 000008E9 8A1E                    	mov     bl, [esi]
  1422                                  	;mov	bl, [VolTable+bx]
  1423 000008EB 8A9B[76710000]          	mov	bl, [VolTable+ebx] ; 01/10/2017 ; *	
  1424                                  	; 17/10/2017
  1425 000008F1 001F                    	add     [edi], bl
  1426                                  	; 18/10/2017
  1427 000008F3 00C4                    	add     ah, al
  1428 000008F5 11D6                    	adc     esi, edx
  1429 000008F7 033D[39500000]          	add	edi, [numtracks]
  1430 000008FD E2E6                    	loop    nlMixSamp
  1431                                  nlMixBye:       
  1432 000008FF 89F3                    	mov     ebx, esi
  1433 00000901 5E                      	pop     esi
  1434 00000902 5A                      	pop     edx
  1435 00000903 29D3                    	sub     ebx, edx
  1436 00000905 895E04                  	mov     [esi+TrackInfo.Position], ebx
  1437 00000908 88661D                  	mov     [esi+TrackInfo.Error], ah
  1438 0000090B C3                      	retn
  1439                                  MixLooped:
  1440 0000090C 8B16                    	mov	edx, [esi+TrackInfo.Samples]
  1441 0000090E 8B5E04                  	mov	ebx, [esi+TrackInfo.Position]
  1442 00000911 0FB76E0C                	movzx	ebp, word [esi+TrackInfo.RepLen]
  1443 00000915 892D[70D20000]          	mov     [BufRep], ebp
  1444                                  	;add	ebp, [esi+TrackInfo.Repeat] ; BUG !
  1445 0000091B 66036E0A                	add     bp, [esi+TrackInfo.Repeat] ; 07/10/2017 (BUGfix!)
  1446 0000091F 52                      	push    edx
  1447 00000920 56                      	push    esi
  1448 00000921 01D3                    	add     ebx, edx
  1449 00000923 01D5                    	add     ebp, edx
  1450 00000925 668B5612                	mov     dx, [esi+TrackInfo.Pitch]
  1451                                  	; 01/10/2017
  1452                                  	;mov	al, [esi+TrackInfo.Volume]
  1453 00000929 668B460E                	mov	ax, [esi+TrackInfo.Volume]
  1454                                  	; ah = [esi+TrackInfo.VolDiff]
  1455 0000092D 00E0                    	add	al, ah ; ****** 
  1456 0000092F C6460F00                	mov	byte [esi+TrackInfo.VolDiff], 0
  1457 00000933 8A661D                  	mov     ah, [esi+TrackInfo.Error]
  1458                                  	;mov	si, bx
  1459 00000936 89DE                    	mov	esi, ebx ; 04/09/2017
  1460 00000938 31DB                    	xor	ebx, ebx ; 01/10/2017 ; *
  1461 0000093A 88C7                    	mov     bh, al
  1462 0000093C 88D0                    	mov     al, dl
  1463 0000093E 88F2                    	mov     dl, dh
  1464                                  	;xor	dh, dh
  1465 00000940 81E2FF000000            	and	edx, 0FFh
  1466                                  lpMixSamp:      
  1467 00000946 39EE                    	cmp     esi, ebp
  1468 00000948 7206                    	jb      short lpMixNow
  1469 0000094A 2B35[70D20000]          	sub     esi, [BufRep]
  1470                                  lpMixNow:       
  1471 00000950 8A1E                    	mov     bl, [esi]
  1472                                  	;mov	bl, [VolTable+bx]
  1473 00000952 8A9B[76710000]          	mov	bl, [VolTable+ebx] ; 01/10/2017 ; *
  1474                                  	; 17/10/2017
  1475 00000958 001F                    	add     [edi], bl
  1476                                  	; 18/10/2017
  1477 0000095A 00C4                    	add     ah, al
  1478 0000095C 11D6                    	adc     esi, edx
  1479 0000095E 033D[39500000]          	add	edi, [numtracks]
  1480 00000964 E2E0                    	loop    lpMixSamp
  1481                                  lpMixBye:       
  1482                                  ;	mov     ebx, esi
  1483                                  ;	pop     esi
  1484                                  ;	pop     edx
  1485                                  ;	sub     ebx, edx
  1486                                  ;	mov     [esi+TrackInfo.Position], ebx
  1487                                  ;	mov     [esi+TrackInfo.Error], ah
  1488                                  ;	retn
  1489 00000966 EB97                    	jmp	short nlMixBye
  1490                                  
  1491                                  ;--------------------------------------------------------------------------
  1492                                  ; mixpoll - updates the output buffer
  1493                                  ;--------------------------------------------------------------------------
  1494                                  ;
  1495                                  ;--------------------------------------------------------------------------
  1496                                  ; GetSamples:  Returns the next chunk of samples to be played.
  1497                                  ;  In:
  1498                                  ;    Buffer  - Buffer Address.
  1499                                  ;    Count   - Buffer Size.
  1500                                  ;--------------------------------------------------------------------------
  1501                                  
  1502                                  mixpoll:
  1503                                  GetSamples:	; mixpoll ; 01/10/2017 (TMODPLAY.ASM)
  1504                                  	; edi = buffer address
  1505                                  	; ebx = count
  1506                                  
  1507 00000968 60                      	pushad
  1508                                  
  1509                                  	;cld
  1510                                  NextChunk:      
  1511 00000969 66833D[6ED20000]00      	cmp     word [BufLen], 0
  1512 00000971 756B                    	jne     short CopyChunk
  1513                                  
  1514 00000973 53                      	push    ebx
  1515 00000974 57                      	push    edi
  1516                                  MixChunk:       
  1517 00000975 BF[76B20000]            	mov	edi, MixBuffer
  1518                                  
  1519                                  	; 17/10/2017
  1520 0000097A 0FB70D[68D20000]        	movzx	ecx, word [BpmSamples]
  1521                                  	;mov	cx, [BpmSamples]
  1522 00000981 893D[6AD20000]          	mov     [BufPtr], edi
  1523 00000987 66890D[6ED20000]        	mov	[BufLen], cx
  1524                                  
  1525 0000098E 803D[39500000]04        	cmp	byte [numtracks], 4
  1526 00000995 7603                    	jna	short ch_silence
  1527 00000997 66D1E1                  	shl	cx, 1 
  1528                                  ch_silence:
  1529 0000099A B880808080              	mov	eax, 80808080h
  1530 0000099F F3AB                    	rep	stosd
  1531                                  
  1532                                  	;mov	cx, NumTracks
  1533                                  	;mov	cl, NumTracks ; 01/10/2017
  1534 000009A1 8A0D[39500000]          	mov	cl, [numtracks] ; 06/10/2017
  1535 000009A7 BE[52D20000]            	mov	esi, Tracks - TrackInfo.size
  1536                                  GetSamples_next:
  1537 000009AC 51                      	push	ecx
  1538 000009AD 83C626                  	add	esi, TrackInfo.size
  1539 000009B0 668B0D[6ED20000]        	mov	cx, [BufLen]
  1540 000009B7 8B3D[6AD20000]          	mov	edi, [BufPtr]
  1541 000009BD E8ECFEFFFF              	call	MixTrack
  1542 000009C2 59                      	pop	ecx
  1543 000009C3 FF05[6AD20000]          	inc	dword [BufPtr] ; 18/10/2017
  1544 000009C9 E2E1                    	loop	GetSamples_next
  1545                                  
  1546                                   	; 18/10/2017	
  1547 000009CB 8B1D[39500000]          	mov	ebx, [numtracks]
  1548 000009D1 291D[6AD20000]          	sub	dword [BufPtr], ebx
  1549                                  
  1550 000009D7 E80DFEFFFF              	call    UpdateTracks
  1551                                  
  1552 000009DC 5F                      	pop     edi
  1553 000009DD 5B                      	pop     ebx
  1554                                  CopyChunk:      
  1555                                  	;mov	cx, [BufLen]
  1556 000009DE 0FB70D[6ED20000]        	movzx	ecx, word [BufLen]
  1557 000009E5 39D9                    	cmp	ecx, ebx
  1558                                  	;cmp	cx, bx
  1559 000009E7 7602                    	jbe     short MoveChunk
  1560                                  	;mov	cx, bx
  1561 000009E9 89D9                    	mov     ecx, ebx
  1562                                  MoveChunk:
  1563 000009EB 8B35[6AD20000]          	mov     esi, [BufPtr]
  1564 000009F1 010D[6AD20000]          	add     [BufPtr], ecx
  1565 000009F7 66290D[6ED20000]        	sub     [BufLen], cx
  1566 000009FE 29CB                    	sub     ebx, ecx
  1567                                  	; 17/10/2017 ; STEREO MIXING
  1568                                  	;rep	movsb
  1569                                  	; 18/10/2017
  1570 00000A00 803D[39500000]04        	cmp	byte [numtracks], 4
  1571                                  	;jna	short _4_channels_mix
  1572 00000A07 762F                    	jna	_4_channels_mix
  1573                                  	
  1574                                  _8_channels_mix:
  1575                                  	; 18/10/2017
  1576 00000A09 AD                      	lodsd 
  1577 00000A0A 89C2                    	mov	edx, eax ; ch1 (al), ch2 (ah)
  1578 00000A0C C1EA10                  	shr	edx, 16 ; ch3 (dl), ch4 (dh)
  1579 00000A0F 00C6                    	add	dh, al ; ch1 + ch4
  1580 00000A11 00E2                    	add	dl, ah ; ch2 + ch3
  1581                                  
  1582 00000A13 AD                      	lodsd
  1583 00000A14 00C6                    	add	dh, al ; ch1 + ch4 + ch5
  1584 00000A16 00E2                    	add	dl, ah ; ch2 + ch3 + ch6
  1585 00000A18 C1E810                  	shr	eax, 16 ; ch7 (al), ch8 (ah)
  1586                                  	; 19/10/2017
  1587 00000A1B 00E6                    	add	dh, ah ; ch1 + ch4 + ch5 + ch8
  1588 00000A1D 00C2                    	add	dl, al ; ch2 + ch3 + ch6 + ch7
  1589                                  
  1590                                  	; L = ch1 + ch4 + ch5 + ch8
  1591                                  	; R = ch2 + ch3 + ch6 + ch7
  1592                                  
  1593 00000A1F 6681C28080              	add	dx, 8080h
  1594                                  
  1595                                  	; 19/10/2017
  1596 00000A24 88F4                    	mov	ah, dh
  1597 00000A26 80EC80                  	sub	ah, 80h
  1598 00000A29 30C0                    	xor	al, al
  1599 00000A2B 66AB                    	stosw ; Left Channel
  1600 00000A2D 88D4                    	mov	ah, dl
  1601 00000A2F 80EC80                  	sub	ah, 80h
  1602 00000A32 66AB                    	stosw ; Right Channel
  1603                                  
  1604 00000A34 E2D3                    	loop	_8_channels_mix
  1605                                  	
  1606 00000A36 EB21                    	jmp	short channel_mix_ok
  1607                                  	
  1608                                  _4_channels_mix:
  1609                                  	; 18/10/2017
  1610 00000A38 AD                      	lodsd 
  1611 00000A39 89C2                    	mov	edx, eax ; ch1 (al), ch2 (ah)
  1612                                  	; 19/10/2017
  1613 00000A3B C1E810                  	shr	eax, 16 ; ch3 (al), ch4 (ah)
  1614 00000A3E 00E2                    	add	dl, ah ; ch1 + ch4
  1615 00000A40 00C6                    	add	dh, al ; ch2 + ch3
  1616                                  
  1617                                  	; L = ch1 + ch4
  1618                                  	; R = ch2 + ch3
  1619                                  
  1620                                  	; 19/10/2017
  1621 00000A42 6681C28080              	add	dx, 8080h
  1622                                  
  1623                                  	; 19/10/2017
  1624 00000A47 88D4                    	mov	ah, dl
  1625 00000A49 80EC80                  	sub	ah, 80h
  1626 00000A4C 30C0                    	xor	al, al
  1627 00000A4E 66AB                    	stosw ; Left Channel
  1628 00000A50 88F4                    	mov	ah, dh
  1629 00000A52 80EC80                  	sub	ah, 80h
  1630 00000A55 66AB                    	stosw ; Right Channel
  1631                                  	
  1632 00000A57 E2DF                    	loop	_4_channels_mix
  1633                                  
  1634                                  channel_mix_ok:
  1635 00000A59 85DB                    	test    ebx, ebx
  1636                                  	;jnz	short NextChunk
  1637 00000A5B 0F8508FFFFFF            	jnz	NextChunk ; 17/10/2017
  1638                                  
  1639                                  	; 20/10/2017
  1640                                  	; 19/10/2017
  1641                                  	; Pan Control
  1642 00000A61 8A0D[00DE0000]          	mov	cl, [pan_shift]
  1643 00000A67 08C9                    	or	cl, cl
  1644 00000A69 744D                    	jz	short c_smpl_2
  1645                                  
  1646                                  	; 20/10/2017
  1647 00000A6B BB00200000              	mov	ebx, BUFFERSIZE/4 ; 8192
  1648 00000A70 BF[00E00000]            	mov	edi, Audio_Buffer
  1649                                  
  1650 00000A75 B508                    	mov	ch, 8
  1651 00000A77 D2E5                    	shl	ch, cl
  1652                                  c_smpl_1:
  1653 00000A79 8B17                    	mov	edx, [edi]
  1654 00000A7B 6689D0                  	mov	ax, dx
  1655 00000A7E 80FC80                  	cmp	ah, 80h
  1656 00000A81 7208                    	jb	short _cs1	
  1657 00000A83 00EC                    	add	ah, ch
  1658 00000A85 730A                    	jnc	short _cs2
  1659 00000A87 B4FF                    	mov	ah, 255
  1660 00000A89 EB06                    	jmp	short _cs2
  1661                                  _cs1:
  1662 00000A8B 28EC                    	sub	ah, ch
  1663 00000A8D 7302                    	jnc	short _cs2
  1664 00000A8F B400                    	mov	ah, 0
  1665                                  _cs2:
  1666 00000A91 C1CA10                  	ror	edx, 16 ; dx = [edi+2]
  1667 00000A94 00F4                    	add	ah, dh
  1668 00000A96 6692                    	xchg	dx, ax ; xchg [edi+2], ax
  1669 00000A98 80FC80                  	cmp	ah, 80h
  1670 00000A9B 7208                    	jb	short _cs3	
  1671 00000A9D 00EC                    	add	ah, ch
  1672 00000A9F 730A                    	jnc	short _cs4
  1673 00000AA1 B4FF                    	mov	ah, 255
  1674 00000AA3 EB06                    	jmp	short _cs4
  1675                                  _cs3:
  1676 00000AA5 28EC                    	sub	ah, ch
  1677 00000AA7 7302                    	jnc	short _cs4
  1678 00000AA9 B400                    	mov	ah, 0
  1679                                  _cs4:
  1680 00000AAB C1CA10                  	ror	edx, 16 ; dx = [edi]
  1681 00000AAE 00E6                    	add	dh, ah
  1682 00000AB0 8917                    	mov	[edi], edx
  1683                                  _cs5:
  1684                                  	; 20/10/2017
  1685 00000AB2 83C704                  	add	edi, 4
  1686 00000AB5 4B                      	dec	ebx
  1687 00000AB6 75C1                    	jnz	short c_smpl_1	
  1688                                  c_smpl_2:
  1689 00000AB8 61                      	popad	
  1690 00000AB9 C3                      	retn
  1691                                  
  1692                                  ;--------------------------------------------------------------------------
  1693                                  ; StartPlaying: Initializes the Sound System.
  1694                                  ;  In:
  1695                                  ;   Module Information Resources.
  1696                                  ;--------------------------------------------------------------------------
  1697                                  
  1698                                  StartPlaying:
  1699 00000ABA 60                      	pushad
  1700                                  SetModParms:    
  1701 00000ABB C605[62D20000]00        	mov     byte [OrderPos], 0
  1702 00000AC2 C605[63D20000]06        	mov     byte [Tempo], DefTempo
  1703 00000AC9 C605[64D20000]06        	mov     byte [TempoWait], DefTempo
  1704 00000AD0 C605[65D20000]7D        	mov     byte [Bpm], DefBpm
  1705 00000AD7 C605[66D20000]40        	mov     byte [Row], 64
  1706 00000ADE C605[67D20000]00        	mov     byte [BreakRow], 0
  1707 00000AE5 66A1[42500000]          	mov     ax, [MixSpeed]
  1708 00000AEB 31D2                    	xor     edx, edx
  1709 00000AED 66BB3200                	mov     bx, 24*DefBpm/60
  1710 00000AF1 66F7F3                  	div     bx
  1711 00000AF4 66A3[68D20000]          	mov     [BpmSamples], ax
  1712                                  ClearTracks:    
  1713 00000AFA BF[78D20000]            	mov     edi, Tracks
  1714                                  	; 07/10/2017
  1715                                  	;mov	ecx, NumTracks*TrackInfo.size
  1716 00000AFF B826000000              	mov	eax, TrackInfo.size
  1717 00000B04 0FB70D[39500000]        	movzx	ecx, word [numtracks]
  1718 00000B0B F7E1                    	mul	ecx
  1719 00000B0D 89C1                    	mov	ecx, eax
  1720 00000B0F 31C0                    	xor     eax, eax
  1721                                  	;cld
  1722 00000B11 F3AA                    	rep     stosb
  1723                                  
  1724 00000B13 A3[6AD20000]            	mov     [BufPtr], eax
  1725 00000B18 66A3[6ED20000]          	mov     [BufLen], ax
  1726                                  MakePitch:
  1727 00000B1E 66B80021                	mov     ax, MidCRate
  1728 00000B22 66BBAC01                	mov     bx, 428
  1729 00000B26 66F7E3                  	mul     bx
  1730 00000B29 66F735[42500000]        	div     word [MixSpeed]
  1731 00000B30 30F6                    	xor     dh, dh
  1732 00000B32 88E2                    	mov     dl, ah
  1733 00000B34 88C4                    	mov     ah, al
  1734 00000B36 30C0                    	xor     al, al
  1735                                  	;mov	cx, 857
  1736 00000B38 66B9610D                	mov	cx, 3425  ; 01/10/2017 (TMODPLAY.ASM)
  1737 00000B3C 31DB                    	xor     ebx, ebx
  1738 00000B3E BF[B4560000]            	mov     edi, PitchTable
  1739                                  PitchLoop:      
  1740 00000B43 50                      	push    eax
  1741 00000B44 52                      	push    edx
  1742 00000B45 6639DA                  	cmp     dx, bx
  1743 00000B48 7303                    	jae     short NoDiv
  1744 00000B4A 66F7F3                  	div     bx
  1745                                  NoDiv:          
  1746 00000B4D 66AB                    	stosw
  1747 00000B4F 5A                      	pop     edx
  1748 00000B50 58                      	pop     eax
  1749                                  	;inc	bx
  1750 00000B51 43                      	inc	ebx
  1751 00000B52 E2EF                    	loop    PitchLoop
  1752                                  MakeVolume:     
  1753 00000B54 66B90041                	mov     cx, 16640
  1754 00000B58 89CB                    	mov     ebx, ecx
  1755                                  VolLoop:
  1756 00000B5A 664B                    	dec     bx
  1757 00000B5C 88D8                    	mov     al, bl
  1758 00000B5E F6EF                    	imul    bh
  1759                                  	;mov	[VolTable+bx], ah
  1760 00000B60 88A3[76710000]          	mov     [VolTable+ebx], ah
  1761 00000B66 E2F2                    	loop    VolLoop
  1762                                  
  1763 00000B68 61                      	popad
  1764 00000B69 C3                      	retn
  1765                                  
  1766                                  ;--------------------------------------------------------------------------
  1767                                  ; StopPlaying: ShutDown the Sound System.
  1768                                  ;--------------------------------------------------------------------------
  1769                                  
  1770                                  StopPlaying:
  1771                                  	; 19/06/2017
  1772                                  	; Stop Playing
  1773                                  	sys	_audio, 0700h
  1773                              <1> 
  1773                              <1> 
  1773                              <1> 
  1773                              <1> 
  1773                              <1>  %if %0 >= 2
  1773 00000B6A BB00070000          <1>  mov ebx, %2
  1773                              <1>  %if %0 >= 3
  1773                              <1>  mov ecx, %3
  1773                              <1>  %if %0 = 4
  1773                              <1>  mov edx, %4
  1773                              <1>  %endif
  1773                              <1>  %endif
  1773                              <1>  %endif
  1773 00000B6F B820000000          <1>  mov eax, %1
  1773                              <1> 
  1773 00000B74 CD40                <1>  int 40h
  1774                                  	; Cancel callback service (for user)
  1775                                  	sys	_audio, 0900h
  1775                              <1> 
  1775                              <1> 
  1775                              <1> 
  1775                              <1> 
  1775                              <1>  %if %0 >= 2
  1775 00000B76 BB00090000          <1>  mov ebx, %2
  1775                              <1>  %if %0 >= 3
  1775                              <1>  mov ecx, %3
  1775                              <1>  %if %0 = 4
  1775                              <1>  mov edx, %4
  1775                              <1>  %endif
  1775                              <1>  %endif
  1775                              <1>  %endif
  1775 00000B7B B820000000          <1>  mov eax, %1
  1775                              <1> 
  1775 00000B80 CD40                <1>  int 40h
  1776                                  	; Deallocate Audio Buffer (for user)
  1777                                  	sys	_audio, 0A00h
  1777                              <1> 
  1777                              <1> 
  1777                              <1> 
  1777                              <1> 
  1777                              <1>  %if %0 >= 2
  1777 00000B82 BB000A0000          <1>  mov ebx, %2
  1777                              <1>  %if %0 >= 3
  1777                              <1>  mov ecx, %3
  1777                              <1>  %if %0 = 4
  1777                              <1>  mov edx, %4
  1777                              <1>  %endif
  1777                              <1>  %endif
  1777                              <1>  %endif
  1777 00000B87 B820000000          <1>  mov eax, %1
  1777                              <1> 
  1777 00000B8C CD40                <1>  int 40h
  1778                                  	; Disable Audio Device
  1779                                  	sys	_audio, 0C00h
  1779                              <1> 
  1779                              <1> 
  1779                              <1> 
  1779                              <1> 
  1779                              <1>  %if %0 >= 2
  1779 00000B8E BB000C0000          <1>  mov ebx, %2
  1779                              <1>  %if %0 >= 3
  1779                              <1>  mov ecx, %3
  1779                              <1>  %if %0 = 4
  1779                              <1>  mov edx, %4
  1779                              <1>  %endif
  1779                              <1>  %endif
  1779                              <1>  %endif
  1779 00000B93 B820000000          <1>  mov eax, %1
  1779                              <1> 
  1779 00000B98 CD40                <1>  int 40h
  1780                                  
  1781 00000B9A C3                      	retn
  1782                                  
  1783                                  
  1784                                  ;=============================================================================
  1785                                  ;	gfx.asm - draw scopes in VGA 640x480x16 mode      
  1786                                  ;=============================================================================
  1787                                  
  1788                                  ; EX1A.ASM (21/6/1994, Carlos Hasan; MSDOS, 'RUNME.EXE', 'TNYPL211')
  1789                                  
  1790                                  ;-----------------------------------------------------------------------------
  1791                                  ; setgraphmode - setup the VGA 640x480x16 graphics mode
  1792                                  ;-----------------------------------------------------------------------------
  1793                                  	; 22/10/2017
  1794                                  setgraphmode:
  1795                                  	;pushad
  1796 00000B9B 66B81200                	mov	ax,0012h
  1797                                  	;int	10h
  1798 00000B9F CD31                    	int 	31h
  1799 00000BA1 66BAC003                	mov	dx,3C0h
  1800 00000BA5 30C0                    	xor	al,al
  1801                                  setgraphmodel0:
  1802                                  	;out	dx,al
  1803 00000BA7 B401                    	mov	ah, 1 ; outb
  1804 00000BA9 CD34                    	int	34h
  1805                                  	;out	dx, al
  1806                                  	;mov	ah, 1
  1807 00000BAB CD34                    	int	34h
  1808 00000BAD FEC0                    	inc	al
  1809 00000BAF 3C10                    	cmp	al, 10h
  1810 00000BB1 72F4                    	jb	short setgraphmodel0
  1811 00000BB3 B020                    	mov	al, 20h
  1812                                  	;out	dx, al
  1813                                  	;mov	ah, 1
  1814 00000BB5 CD34                    	int	34h
  1815                                  	;popad
  1816 00000BB7 C3                      	retn
  1817                                  
  1818                                  ;-----------------------------------------------------------------------------
  1819                                  ; settextmode - restore the VGA 80x25x16 text mode
  1820                                  ;-----------------------------------------------------------------------------
  1821                                  	; 22/10/2017
  1822                                  settextmode:
  1823                                  	;pushad
  1824 00000BB8 66B80300                	mov	ax, 0003h
  1825                                  	;int	10h
  1826 00000BBC CD31                    	int	31h
  1827                                  	;popad
  1828 00000BBE C3                      	retn
  1829                                  
  1830                                  ;-----------------------------------------------------------------------------
  1831                                  ; drawscopes - draw the track voices sample scopes
  1832                                  ; In:
  1833                                  ;  EDX = (current) sample buffer
  1834                                  ;-----------------------------------------------------------------------------
  1835                                  	; 27/10/2017
  1836                                  	; 26/10/2017
  1837                                  	; 23/10/2017
  1838                                  drawscopes:
  1839                                  	;pushad
  1840                                    	;mov	esi, g_buff
  1841 00000BBF 89D6                    	mov	esi, edx
  1842 00000BC1 31C9                    	xor     ecx, ecx	
  1843 00000BC3 31D2                    	xor     edx, edx
  1844 00000BC5 31FF                    	xor	edi, edi
  1845                                  drawscope0:
  1846 00000BC7 66AD                    	lodsw
  1847 00000BC9 80F480                  	xor	ah, 80h
  1848 00000BCC 0FB6DC                  	movzx	ebx, ah  ; Left Channel
  1849 00000BCF 66D1E3                  	shl	bx, 1
  1850 00000BD2 668B83[B0D30000]        	mov	ax, [RowOfs+ebx]
  1851 00000BD9 668987[B0D50000]        	mov	[NewScope_L+edi], ax
  1852 00000BE0 30FF                    	xor	bh, bh
  1853 00000BE2 66AD                    	lodsw
  1854 00000BE4 80F480                  	xor	ah, 80h
  1855 00000BE7 88E3                    	mov	bl, ah	; Right Channel
  1856 00000BE9 66D1E3                  	shl	bx, 1
  1857 00000BEC 668B83[B0D30000]        	mov	ax, [RowOfs+ebx]
  1858 00000BF3 668987[B0D70000]        	mov	[NewScope_R+edi], ax
  1859 00000BFA 6683C702                	add	di, 2
  1860 00000BFE FEC1                    	inc	cl
  1861 00000C00 75C5                    	jnz	short drawscope0	
  1862                                  
  1863 00000C02 66BAC403                        mov	dx, 3C4h
  1864                                          ;mov	ax, 0802h
  1865                                          ;out	dx, ax
  1866 00000C06 66BB0208                        mov	bx, 0802h
  1867 00000C0A B403                    	mov	ah, 3 ; outw
  1868 00000C0C CD34                    	int	34h
  1869 00000C0E 66BACE03                	mov	dx, 3CEh
  1870 00000C12 B008                            mov	al, 08h
  1871                                         ;out	dx, al
  1872 00000C14 B401                            mov	ah, 1 ; outb
  1873 00000C16 CD34                    	int	34h
  1874 00000C18 6642                    	inc	dx
  1875                                  
  1876                                  	; 26/10/2017
  1877 00000C1A 31F6                            xor	esi, esi
  1878 00000C1C 31FF                            xor	edi, edi
  1879 00000C1E BB45060A00                      mov     ebx, 0A0645h
  1880                                  drawscopel4:
  1881 00000C23 B080                            mov     al, 80h
  1882                                  drawscopel2:
  1883 00000C25 50                              push    eax ; *
  1884 00000C26 52                              push    edx ; **
  1885                                  	;out	dx, al
  1886 00000C27 B401                    	mov	ah, 1 ; outb
  1887 00000C29 CD34                    	int	34h
  1888                                  
  1889 00000C2B B4FF                            mov	ah, 0FFh
  1890                                          ;mov	ecx, 32
  1891 00000C2D 66B92000                	mov	cx, 32
  1892 00000C31 28C0                            sub     al, al
  1893                                  drawscopel3:
  1894                                  	; 23/10/2017
  1895 00000C33 668B96[B0D90000]                mov	dx, [OldScope_L+esi]
  1896 00000C3A 663B96[B0D50000]                cmp	dx, [NewScope_L+esi]
  1897 00000C41 7414                            je	short drawscopef3
  1898 00000C43 88041A                          mov	[edx+ebx], al ; L
  1899 00000C46 668B96[B0D50000]                mov     dx, [NewScope_L+esi]
  1900 00000C4D 88241A                  	mov	[edx+ebx], ah ; L
  1901 00000C50 668996[B0D90000]                mov     [OldScope_L+esi], dx
  1902                                  drawscopef3:
  1903                                  	; 27/10/2017
  1904 00000C57 668B96[B0DB0000]                mov	dx, [OldScope_R+esi]
  1905 00000C5E 663B96[B0D70000]                cmp	dx, [NewScope_R+esi]
  1906 00000C65 7416                            je	short drawscopef4
  1907 00000C67 88441A26                	mov	[edx+ebx+38], al ; R
  1908 00000C6B 668B96[B0D70000]                mov     dx, [NewScope_R+esi]
  1909 00000C72 88641A26                        mov	[edx+ebx+38], ah ; R
  1910 00000C76 668996[B0DB0000]                mov     [OldScope_R+esi], dx
  1911                                  drawscopef4:
  1912 00000C7D 83C610                          add	esi, 2*8
  1913 00000C80 43                              inc	ebx
  1914 00000C81 E2B0                            loop    drawscopel3
  1915                                  
  1916 00000C83 5A                              pop     edx ; **
  1917 00000C84 58                              pop     eax ; *
  1918 00000C85 81EEFE010000                    sub	esi, 2*256-2
  1919 00000C8B 83EB20                          sub	ebx, 32
  1920 00000C8E D0E8                            shr     al, 1
  1921 00000C90 7593                            jnz	short drawscopel2
  1922                                  	;popad
  1923 00000C92 C3                              retn
  1924                                  
  1925                                  ;=============================================================================
  1926                                  ;	Load IFF/ILBM files for VGA 640x480x16 graphics mode       
  1927                                  ;=============================================================================
  1928                                  
  1929                                  ; EX1B.ASM (21/6/1994, Carlos Hasan; MSDOS, 'RUNME.EXE', 'TNYPL211')
  1930                                  
  1931                                  ; 21/10/2017 (TRDOS 386, 'tmodplay.s', Erdogan Tan, NASM syntax)
  1932                                  
  1933                                  ;-----------------------------------------------------------------------------
  1934                                  ; EQUATES AND STRUCTURES
  1935                                  ;-----------------------------------------------------------------------------
  1936                                  
  1937                                  ID_FORM equ 4D524F46h		; IFF/ILBM chunk IDs
  1938                                  ID_ILBM equ 4D424C49h
  1939                                  ID_BMHD equ 44484D42h
  1940                                  ID_CMAP equ 50414D43h
  1941                                  ID_BODY equ 59444F42h
  1942                                  
  1943                                  struc Form			; IFF/ILBM header file format
  1944 00000000 <res 00000004>            .ID:		resd 1
  1945 00000004 <res 00000004>            .Length:	resd 1
  1946 00000008 <res 00000004>            .Type:	resd 1
  1947                                    .size:
  1948                                  endstruc
  1949                                  
  1950                                  struc Chunk			; IFF/ILBM header chunk format
  1951 00000000 <res 00000004>            .ID:		resd 1
  1952 00000004 <res 00000004>            .Length:	resd 1
  1953                                    .size:	
  1954                                  endstruc
  1955                                  
  1956                                  struc BMHD			; IFF/ILBM BMHD chunk format
  1957 00000000 <res 00000002>            .Width: 	resw 1
  1958 00000002 <res 00000002>            .Height:	resw 1
  1959 00000004 <res 00000002>            .PosX:	resw 1
  1960 00000006 <res 00000002>            .PosY:	resw 1
  1961 00000008 <res 00000001>            .Planes:	resb 1
  1962 00000009 <res 00000001>            .Masking:	resb 1
  1963 0000000A <res 00000001>            .Compression:	resb 1
  1964 0000000B <res 00000001>            .Pad:		resb 1
  1965 0000000C <res 00000002>            .Transparent:	resw 1
  1966 0000000E <res 00000001>            .AspectX	resb 1
  1967 0000000F <res 00000001>            .AspectY:	resb 1
  1968 00000010 <res 00000002>            .PageWidth:	resw 1
  1969 00000012 <res 00000002>            .PageHeight:	resw 1
  1970                                    .size:	
  1971                                  endstruc
  1972                                  
  1973                                  struc CMAP			; IFF/ILBM CMAP chunk format
  1974 00000000 <res 00000300>            .Colors:	resb 768
  1975                                    .size:	
  1976                                  endstruc
  1977                                  
  1978                                  ;LOGO_ADDRESS	equ 100000h	; virtual address at the end of the 1st 1MB
  1979                                  
  1980                                  ;------------------------------------------------------------------------------
  1981                                  ; bswap - macro to reverse the byte order of a 32-bit register, converting
  1982                                  ;         a value in little/big endian form to big/little endian form.
  1983                                  ;------------------------------------------------------------------------------
  1984                                  %macro	bswap   1
  1985                                          xchg    al, ah
  1986                                          rol     eax, 16
  1987                                          xchg    al, ah
  1988                                  %endmacro
  1989                                  
  1990                                  ;------------------------------------------------------------------------------
  1991                                  ; putlbm - draw the IFF/ILBM picture on VGA 640x480x16 graphics mode
  1992                                  ; In:
  1993                                  ;  ESI = IFF/ILBM image file address
  1994                                  ;------------------------------------------------------------------------------
  1995                                  putlbm:
  1996 00000C93 60                              pushad
  1997                                  
  1998                                  ; check if this is a valid IFF/ILBM Deluxe Paint file
  1999                                  
  2000 00000C94 813E464F524D                    cmp     dword [esi+Form.ID], ID_FORM
  2001 00000C9A 7551                            jne     short putlbmd0
  2002 00000C9C 817E08494C424D                  cmp     dword [esi+Form.Type], ID_ILBM
  2003 00000CA3 7548                            jne     short putlbmd0
  2004                                  
  2005                                  ; get the IFF/ILBM file length in bytes
  2006                                  
  2007 00000CA5 8B4604                          mov     eax, [esi+Form.Length]
  2008                                          bswap   eax
  2008 00000CA8 86C4                <1>  xchg al, ah
  2008 00000CAA C1C010              <1>  rol eax, 16
  2008 00000CAD 86C4                <1>  xchg al, ah
  2009 00000CAF 89C1                            mov     ecx, eax
  2010                                  
  2011                                  ; decrease the file length and updates the file pointer
  2012                                  
  2013 00000CB1 83E904                          sub     ecx, 4
  2014 00000CB4 83C60C                          add     esi, Form.size
  2015                                  
  2016                                  ; IFF/ILBM main parser body loop
  2017                                  
  2018                                  putlbml0:
  2019 00000CB7 85C9                            test    ecx, ecx
  2020 00000CB9 7E64                            jle     short putlbmd1
  2021                                  
  2022                                  ; get the next chunk ID and length in bytes
  2023                                  
  2024 00000CBB 8B1E                            mov     ebx, [esi+Chunk.ID]
  2025 00000CBD 8B4604                          mov     eax, [esi+Chunk.Length]
  2026                                          bswap   eax
  2026 00000CC0 86C4                <1>  xchg al, ah
  2026 00000CC2 C1C010              <1>  rol eax, 16
  2026 00000CC5 86C4                <1>  xchg al, ah
  2027 00000CC7 93                              xchg    ebx, eax
  2028 00000CC8 83C608                          add     esi, Chunk.size
  2029                                  
  2030                                  ; word align the chunk length and decrease the file length counter
  2031                                  
  2032 00000CCB 43                              inc     ebx
  2033 00000CCC 80E3FE                          and     bl, 0FEh ; ~1
  2034 00000CCF 83E908                          sub     ecx, Chunk.size
  2035 00000CD2 29D9                            sub     ecx, ebx
  2036                                  
  2037                                  ; check for the BMHD/CMAP/BODY chunk headers
  2038                                  
  2039 00000CD4 3D424D4844                      cmp     eax, ID_BMHD
  2040 00000CD9 7415                            je      short putlbmf0
  2041 00000CDB 3D434D4150                      cmp     eax, ID_CMAP
  2042 00000CE0 7440                            je      short putlbmf1
  2043 00000CE2 3D424F4459                      cmp     eax, ID_BODY
  2044 00000CE7 7455                            je      short putlbmf2
  2045                                  
  2046                                  ; advance to the next IFF/ILBM chunk structure
  2047                                  
  2048                                  putlbmc0:
  2049 00000CE9 01DE                            add     esi, ebx
  2050 00000CEB EBCA                            jmp     short putlbml0
  2051                                  
  2052                                  putlbmd0:
  2053 00000CED F9                              stc
  2054 00000CEE 61                              popad
  2055 00000CEF C3                              retn
  2056                                  
  2057                                  ; process the BMHD bitmap header chunk
  2058                                  
  2059                                  putlbmf0:
  2060 00000CF0 807E0804                        cmp     byte [esi+BMHD.Planes], 4
  2061 00000CF4 75F7                            jne     short putlbmd0
  2062 00000CF6 807E0A01                        cmp     byte [esi+BMHD.Compression], 1
  2063 00000CFA 75F1                            jne     short putlbmd0
  2064 00000CFC 807E0B00                        cmp     byte [esi+BMHD.Pad], 0
  2065 00000D00 75EB                            jne     short putlbmd0
  2066 00000D02 0FB706                          movzx   eax, word [esi+BMHD.Width]
  2067 00000D05 86C4                            xchg    al, ah
  2068 00000D07 83C007                          add     eax, 7
  2069 00000D0A C1E803                          shr     eax, 3
  2070 00000D0D A3[60500000]                    mov     [picture.width], eax
  2071 00000D12 0FB74602                        movzx   eax, word [esi+BMHD.Height]
  2072 00000D16 86C4                            xchg    al, ah
  2073 00000D18 A3[64500000]                    mov     [picture.height], eax
  2074 00000D1D EBCA                            jmp     short putlbmc0
  2075                                  
  2076                                  putlbmd1:
  2077 00000D1F F8                              clc
  2078 00000D20 61                              popad
  2079 00000D21 C3                              retn
  2080                                  
  2081                                  ; process the CMAP colormap chunk
  2082                                  
  2083                                  putlbmf1:
  2084 00000D22 66BAC803                        mov     dx, 3C8h
  2085 00000D26 30C0                            xor     al, al
  2086                                          ;out	dx, al
  2087 00000D28 B401                    	mov	ah, 1 ; outb
  2088 00000D2A CD34                    	int	34h
  2089 00000D2C 6642                            inc     dx
  2090                                  putlbml1:
  2091 00000D2E 8A06                            mov     al, [esi]
  2092 00000D30 C0E802                          shr     al, 2
  2093                                          ;out	dx, al
  2094                                  	;mov	ah, 1 ; outb
  2095 00000D33 CD34                    	int	34h ; IOCTL interrupt (IN/OUT)
  2096 00000D35 46                              inc     esi
  2097 00000D36 4B                              dec     ebx
  2098 00000D37 7FF5                            jg      short putlbml1
  2099 00000D39 E979FFFFFF                      jmp     putlbml0
  2100                                  
  2101                                  ; process the BODY bitmap body chunk
  2102                                  
  2103                                  putlbmf2:
  2104 00000D3E 60                              pushad
  2105 00000D3F BF00000A00                      mov     edi, 0A0000h
  2106                                          ;cld
  2107 00000D44 66BACE03                        mov     dx, 3CEh
  2108                                          ;mov	ax, 0FF08h
  2109                                          ;out	dx, ax
  2110 00000D48 66BB08FF                	mov	bx, 0FF08h
  2111 00000D4C B403                    	mov	ah, 3 ; outw
  2112 00000D4E CD34                    	int	34h ; IOCTL interrupt (IN/OUT)
  2113 00000D50 66BAC403                        mov     dx, 3C4h
  2114 00000D54 B002                            mov     al, 02h
  2115                                          ;out	dx, al
  2116 00000D56 B401                    	mov	ah, 1 ; outb
  2117 00000D58 CD34                    	int	34h ; IOCTL interrupt (IN/OUT)
  2118 00000D5A 6642                            inc     dx
  2119 00000D5C 8B0D[64500000]                  mov     ecx, [picture.height]
  2120                                  putlbml2:
  2121 00000D62 51                              push    ecx
  2122 00000D63 B011                            mov     al, 11h
  2123                                  putlbml3:
  2124 00000D65 50                              push    eax
  2125 00000D66 57                              push    edi
  2126                                          ;out	dx, al
  2127 00000D67 B401                    	mov	ah, 1 ; outb
  2128 00000D69 CD34                    	int	34h ; IOCTL interrupt (IN/OUT)
  2129 00000D6B 8B1D[60500000]                  mov     ebx, [picture.width]
  2130                                  putlbml4:
  2131 00000D71 AC                              lodsb
  2132 00000D72 84C0                            test    al, al
  2133 00000D74 7C0A                            jl      short putlbmf3
  2134 00000D76 0FB6C8                          movzx   ecx, al
  2135 00000D79 41                              inc     ecx
  2136 00000D7A 29CB                            sub     ebx, ecx
  2137 00000D7C F3A4                            rep     movsb
  2138 00000D7E EB0B                            jmp     short putlbmc4
  2139                                  putlbmf3:
  2140 00000D80 F6D8                            neg     al
  2141 00000D82 0FB6C8                          movzx   ecx, al
  2142 00000D85 41                              inc     ecx
  2143 00000D86 29CB                            sub     ebx, ecx
  2144 00000D88 AC                              lodsb
  2145 00000D89 F3AA                            rep     stosb
  2146                                  putlbmc4:
  2147 00000D8B 85DB                            test    ebx, ebx
  2148 00000D8D 7FE2                            jg      short putlbml4
  2149 00000D8F 5F                              pop     edi
  2150 00000D90 58                              pop     eax
  2151 00000D91 00C0                            add     al, al
  2152 00000D93 73D0                            jnc     short putlbml3
  2153 00000D95 83C750                          add     edi, 80
  2154 00000D98 59                              pop     ecx
  2155 00000D99 E2C7                            loop    putlbml2
  2156 00000D9B 61                      	popad
  2157 00000D9C E948FFFFFF                      jmp	putlbmc0
  2158                                  
  2159                                  ; EX1.C (Carlos Hasan, 21/06/1994)
  2160                                  ;------------------------------------------------------------------------------
  2161                                  ; loadlbm - load the IFF/ILBM image file ("LOGO.LBM") at memory
  2162                                  ;  ESI = IFF/ILBM image file address
  2163                                  ;------------------------------------------------------------------------------
  2164                                  
  2165                                  ;if ((Logo = loadlbm("LOGO.LBM")) == NULL) {
  2166                                  ;       printf("Error loading the IFF/ILBM logo picture\n");
  2167                                  ;       MODStopModule();
  2168                                  ;       MODFreeModule(Song);
  2169                                  ;       return;
  2170                                  ;   }
  2171                                  ;   setgraphmode();
  2172                                  ;   putlbm(Logo);
  2173                                  ;   while (!kbhit())
  2174                                  ;       drawscopes(Song->NumTracks);
  2175                                  ;   settextmode();
  2176                                  ;   free(Logo);
  2177                                  ;   MODStopModule();
  2178                                  ;   MODFreeModule(Song);
  2179                                  
  2180                                  ;loadlbm:
  2181                                  ;	; ebx = ASCIIZ file name address
  2182                                  ;	; ecx = open mode (0 = open for read)	
  2183                                  ;	sys	_open, LOGO_FILE_NAME, 0 ; open for reading
  2184                                  ;	jc	short loadlbm_retn
  2185                                  ;
  2186                                  ;	mov     [LBM_FileHandle], eax
  2187                                  ;
  2188                                  ;	; get file size by moving file pointer to the end of file
  2189                                  ;	; ebx = file handle/number
  2190                                  ;	; ecx : offset = 0
  2191                                  ;	; edx : switch = 2 (move fp to end of file + offset)
  2192                                  ;	sys	_seek, eax, 0, 2
  2193                                  ;	jc	short loadlbm_cf
  2194                                  ;
  2195                                  ;	mov	[LBM_FileSize], eax
  2196                                  ;
  2197                                  ;	; move file pointer to the beginning of the file
  2198                                  ;	; ecx = 0
  2199                                  ;	; edx = 0
  2200                                  ;	;xor	ecx, ecx
  2201                                  ; 	xor	dl, dl
  2202                                  ;	; ebx = [LBM_FileHandle]
  2203                                  ;	sys	_seek
  2204                                  ;	;jc	short loadlbm_cf
  2205                                  ;
  2206                                  ;	; ebx = File handle
  2207                                  ;	; ecx = Buffer address
  2208                                  ;	; edx = Byte count
  2209                                  ;	;sys	_read, [LBM_FileHandle], LOGO_ADDRESS, [LBM_FileSize]
  2210                                  ;	mov	ecx, LOGO_ADDRESS
  2211                                  ;	mov	edx, [LBM_FileSize]
  2212                                  ;	sys	_read
  2213                                  ;	jc	short loadlbm_cf
  2214                                  ;
  2215                                  ;	cmp	eax, edx  ; read count = file size ?
  2216                                  ;	;jb	short loadlbm_cf		 
  2217                                  ;loadlbm_cf:
  2218                                  ;	pushf
  2219                                  ;	sys	_close, [LBM_FileHandle]	
  2220                                  ;	popf
  2221                                  ;loadlbm_retn:
  2222                                  ;	retn	
  2223                                  ;
  2224                                  ;LOGO_FILE_NAME:
  2225                                  ;	db	"LOGO.LBM", 0
  2226                                  
  2227                                  LOGO_ERROR_MSG:
  2228 00000DA1 4572726F72206C6F61-     	db	"Error loading the IFF/ILBM logo picture !", 0Dh, 0Ah, 0 
  2228 00000DAA 64696E672074686520-
  2228 00000DB3 4946462F494C424D20-
  2228 00000DBC 6C6F676F2070696374-
  2228 00000DC5 75726520210D0A00   
  2229                                  
  2230 00000DCD 90                      align 2
  2231                                  ; 22/10/2017
  2232                                  LOGO_ADDRESS:
  2233                                  ;incbin "LOGO.LBM"	  	 
  2234                                  ; 27/10/2017
  2235 00000DCE <incbin>                incbin "TINYPLAY.LBM"
  2236                                  
  2237                                  ;=============================================================================
  2238                                  ;               preinitialized data
  2239                                  ;=============================================================================
  2240                                  
  2241                                  ;=============================================================================
  2242                                  ; Protracker effects stuff
  2243                                  ;=============================================================================
  2244                                  
  2245                                  ;-----------------------------------------------------------------------------
  2246                                  ; Effect jump tables
  2247                                  ;-----------------------------------------------------------------------------
  2248                                  
  2249 00004DBE 90<rept>                align 4
  2250                                  
  2251                                  efxtable:
  2252 00004DC0 [53070000]              	dd      efxarpeggio	; 0 - arpeggio
  2253 00004DC4 [80040000]              	dd      efxnull		; 1 - porta up
  2254 00004DC8 [80040000]              	dd      efxnull		; 2 - porta down
  2255 00004DCC [9E060000]              	dd      efxtoneporta	; 3 - tone porta
  2256 00004DD0 [AD060000]              	dd      efxvibrato	; 4 - vibrato
  2257 00004DD4 [80040000]              	dd      efxnull		; 5 - tone+slide
  2258 00004DD8 [80040000]              	dd      efxnull		; 6 - vibrato+slide
  2259 00004DDC [CA070000]              	dd      efxtremolo	; 7 - tremolo
  2260 00004DE0 [80040000]              	dd      efxnull		; 8 - unused
  2261 00004DE4 [D5060000]              	dd      efxsampoffset	; 9 - sample offset
  2262 00004DE8 [80040000]              	dd      efxnull		; A - volume slide
  2263 00004DEC [E1060000]              	dd      efxpattjump	; B - pattern jump
  2264 00004DF0 [EF060000]              	dd      efxsetvolume	; C - set volume
  2265 00004DF4 [FD060000]              	dd      efxbreak	; D - break pattern
  2266 00004DF8 [80040000]              	dd      efxnull		; E - extra effects
  2267 00004DFC [1C070000]              	dd      efxsetspeed	; F - set speed
  2268                                  
  2269                                  efxtable2:
  2270 00004E00 [81040000]              	dd      efxarpeggio2	; 0 - arpeggio
  2271 00004E04 [A3040000]              	dd      efxportaup	; 1 - porta up
  2272 00004E08 [C9040000]              	dd      efxportadown	; 2 - porta down
  2273 00004E0C [F0040000]              	dd      efxtoneporta2	; 3 - tone porta
  2274 00004E10 [29050000]              	dd      efxvibrato2	; 4 - vibrato
  2275 00004E14 [85050000]              	dd      efxtoneslide	; 5 - tone+slide
  2276 00004E18 [92050000]              	dd      efxvibslide	; 6 - vibrato+slide
  2277 00004E1C [B9050000]              	dd      efxtremolo2	; 7 - tremolo
  2278 00004E20 [80040000]              	dd      efxnull		; 8 - unused
  2279 00004E24 [80040000]              	dd      efxnull		; 9 - sample offset
  2280 00004E28 [9C050000]              	dd      efxvolslide	; A - volume slide
  2281 00004E2C [80040000]              	dd      efxnull		; B - pattern jump
  2282 00004E30 [80040000]              	dd      efxnull		; C - set volume
  2283 00004E34 [80040000]              	dd      efxnull		; D - break pattern
  2284 00004E38 [80040000]              	dd      efxnull		; E - extra effects
  2285 00004E3C [80040000]              	dd      efxnull		; F - set speed
  2286                                  
  2287                                  ;-----------------------------------------------------------------------------
  2288                                  ; Amiga period table
  2289                                  ;-----------------------------------------------------------------------------
  2290                                  
  2291                                  ;PeriodTable0:	
  2292                                  ;	dw	0
  2293                                  PeriodTable:
  2294 00004E40 600DA00CE80B400B98-     	dw	3424,3232,3048,2880,2712,2560,2416,2280,2152,2032,1920,1812
  2294 00004E49 0A000A7009E8086808-
  2294 00004E52 F00780071407       
  2295 00004E58 B0065006F405A0054C-     	dw	1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,906
  2295 00004E61 050005B80474043404-
  2295 00004E6A F803C0038A03       
  2296 00004E70 58032803FA02D002A6-     	dw	856,808,762,720,678,640,604,570,538,508,480,453
  2296 00004E79 0280025C023A021A02-
  2296 00004E82 FC01E001C501       
  2297 00004E88 AC0194017D01680153-     	dw	428,404,381,360,339,320,302,285,269,254,240,226
  2297 00004E91 0140012E011D010D01-
  2297 00004E9A FE00F000E200       
  2298 00004EA0 D600CA00BE00B400AA-     	dw	214,202,190,180,170,160,151,143,135,127,120,113
  2298 00004EA9 00A00097008F008700-
  2298 00004EB2 7F0078007100       
  2299 00004EB8 6B0065005F005A0055-     	dw	107,101,95,90,85,80,75,71,67,63,60,56
  2299 00004EC1 0050004B0047004300-
  2299 00004ECA 3F003C003800       
  2300 00004ED0 350032002F002D002A-     	dw	53,50,47,45,42,40,37,35,33,31,30,28
  2300 00004ED9 002800250023002100-
  2300 00004EE2 1F001E001C00       
  2301                                  
  2302                                  ;-----------------------------------------------------------------------------
  2303                                  ; Sinus wave table
  2304                                  ;-----------------------------------------------------------------------------
  2305                                  
  2306                                  SinTable:
  2307 00004EE8 0019324A62788EA2B4-     	db	0,25,50,74,98,120,142,162,180,197,212,225
  2307 00004EF1 C5D4E1             
  2308 00004EF4 ECF4FAFEFFFEFAF4EC-     	db	236,244,250,254,255,254,250,244,236,225
  2308 00004EFD E1                 
  2309 00004EFE D4C5B4A28E78624A32-     	db	212,197,180,162,142,120,98,74,50,25
  2309 00004F07 19                 
  2310                                  
  2311                                  ;=============================================================================
  2312                                  ;               PLAY.ASM - DATA
  2313                                  ;=============================================================================
  2314                                  
  2315                                  msg_usage:
  2316 00004F08 54696E79204D4F4420-     		db 'Tiny MOD Player for TRDOS 386 by Erdogan Tan. '
  2316 00004F11 506C6179657220666F-
  2316 00004F1A 72205452444F532033-
  2316 00004F23 383620627920457264-
  2316 00004F2C 6F67616E2054616E2E-
  2316 00004F35 20                 
  2317 00004F36 4F63746F6265722032-     		db 'October 2017.',10,13
  2317 00004F3F 3031372E0A0D       
  2318 00004F45 75736167653A20746D-     		db 'usage: tmodplay filename.mod', 10,13,0
  2318 00004F4E 6F64706C6179206669-
  2318 00004F57 6C656E616D652E6D6F-
  2318 00004F60 640A0D00           
  2319 00004F64 32372F31302F323031-     		db '27/10/2017',10,13,0
  2319 00004F6D 370A0D00           
  2320                                  
  2321 00004F71 54696E79204D4F4420-     Credits:	db 'Tiny MOD Player v0.1b by Carlos Hasan. July 1993.'
  2321 00004F7A 506C61796572207630-
  2321 00004F83 2E3162206279204361-
  2321 00004F8C 726C6F732048617361-
  2321 00004F95 6E2E204A756C792031-
  2321 00004F9E 3939332E           
  2322 00004FA2 0A0D00                  		db 10,13,0
  2323 00004FA5 4572726F72206C6F61-     ErrorMesg:	db 'Error loading Module file.',10,13,0
  2323 00004FAE 64696E67204D6F6475-
  2323 00004FB7 6C652066696C652E0A-
  2323 00004FC0 0D00               
  2324 00004FC2 536F756E6420426C61-     MsgNotFound:	db 'Sound Blaster not found or IRQ error.',10,13,0
  2324 00004FCB 73746572206E6F7420-
  2324 00004FD4 666F756E64206F7220-
  2324 00004FDD 495251206572726F72-
  2324 00004FE6 2E0A0D00           
  2325 00004FEA 536F756E6420426C61-     MsgFound:	db 'Sound Blaster found at Address 2'
  2325 00004FF3 7374657220666F756E-
  2325 00004FFC 642061742041646472-
  2325 00005005 6573732032         
  2326 0000500A 7830682C2049525120      PortText:	db 'x0h, IRQ '
  2327 00005013 782E0A0D00              IrqText:	db 'x.',10,13,0
  2328                                  
  2329                                  trdos386_err_msg:
  2330 00005018 5452444F5320333836-     		db 'TRDOS 386 System call error !', 10, 13,0
  2330 00005021 2053797374656D2063-
  2330 0000502A 616C6C206572726F72-
  2330 00005033 20210A0D00         
  2331                                  
  2332                                  ; 07/10/2017
  2333 00005038 0A                      pattern_shift:	db 10
  2334                                  ;numtracks:	dw 4
  2335                                  ; 18/10/2017
  2336 00005039 04000000                numtracks:	dd 4
  2337                                  
  2338                                  ;=============================================================================
  2339                                  ;               SB.ASM - DATA
  2340                                  ;=============================================================================
  2341                                  
  2342 0000503D 2002                    SbAddr:		dw 220h
  2343 0000503F 07                      SbIrq:		db 7
  2344                                  
  2345                                  ;=============================================================================
  2346                                  ;               PLAYER.ASM - DATA
  2347                                  ;=============================================================================
  2348                                  
  2349                                  ;stmo:		db 1 ; stereo (2) or mono (1)  
  2350                                  ;bps:		db 8 ; bits per sample (8 or 16)
  2351                                  
  2352                                  ;19/10/2017
  2353 00005040 02                      stmo:		db 2 ; stereo (2) or mono (1)  
  2354 00005041 10                      bps:		db 16 ; bits per sample (8 or 16)
  2355                                  
  2356                                  Sample_Rate:
  2357 00005042 2256                    MixSpeed:	dw 22050 ; Hz ; 19/10/2017
  2358                                  ;MixSpeed:	dw 22222 ; Hz ; 07/10/2017
  2359                                  
  2360                                  ; 13/11/2016
  2361 00005044 303132333435363738-     hex_chars:	db "0123456789ABCDEF", 0
  2361 0000504D 3941424344454600   
  2362                                  ;
  2363                                  ;; 13/11/2016 - Erdogan Tan (Ref: KolibriOS, codec.inc)
  2364                                  ;codec_id:	   dd 0
  2365                                  ;codec_chip_id:	   dd 0
  2366                                  ;codec_vendor_ids: dw 0
  2367                                  ;codec_chip_ids:   dw 0
  2368                                  
  2369                                  ;dword_str:	dd 30303030h, 30303030h
  2370                                  ;	 	db 'h', 0Dh, 0Ah, 0
  2371                                  
  2372                                  ;=============================================================================
  2373                                  ;        	uninitialized data
  2374                                  ;=============================================================================
  2375                                  
  2376                                  bss_start:
  2377                                  
  2378                                  ABSOLUTE bss_start
  2379                                  
  2380 00005055 <res 00000003>          alignb 4
  2381                                  
  2382                                  ;------------------------------------------------------------------------------
  2383                                  ; IFF/ILBM DATA
  2384                                  ;------------------------------------------------------------------------------
  2385                                  
  2386 00005058 <res 00000004>          LBM_FileHandle:	resd 1
  2387 0000505C <res 00000004>          LBM_FileSize:	resd 1
  2388                                  ;
  2389 00005060 <res 00000004>          picture.width:	resd 1 		; current picture width and height
  2390 00005064 <res 00000004>          picture.height:	resd 1
  2391                                  
  2392                                  ;------------------------------------------------------------------------------
  2393                                  
  2394 00005068 <res 00000004>          dev_vendor:	resd 1
  2395 0000506C <res 00000004>          bus_dev_fn:	resd 1
  2396 00005070 <res 00000004>          stats_cmd:	resd 1
  2397 00005074 <res 00000002>          ac97_NamBar:	resw 1
  2398 00005076 <res 00000002>          ac97_NabmBar:	resw 1
  2399 00005078 <res 00000001>          ac97_int_ln_reg: resb 1
  2400 00005079 <res 00000001>          srb:		resb 1
  2401                                  
  2402                                  ; MODLOAD.ASM
  2403 0000507A <res 00000004>          FileHandle:	resd 1
  2404 0000507E <res 0000043C>          Header:		resb ModHeader.size
  2405                                  
  2406                                  ; MODPLAY.ASM
  2407                                  ;MixSpeed:	    resw 1
  2408                                  
  2409                                  ModInfo:
  2410 000054BA <res 00000001>          ModInfo.OrderLen:   resb 1
  2411 000054BB <res 00000001>          ModInfo.ReStart:    resb 1
  2412 000054BC <res 00000080>          ModInfo.Order:	    resb 128
  2413 0000553C <res 00000004>          ModInfo.Patterns:   resd 1
  2414                                  
  2415 00005540 <res 0000003E>          ModInfo.SampOfs:    resw 31
  2416 0000557E <res 0000003E>          ModInfo.SampSeg:    resw 31
  2417 000055BC <res 0000003E>          ModInfo.SampLen:    resw 31
  2418 000055FA <res 0000003E>          ModInfo.SampRep:    resw 31
  2419 00005638 <res 0000003E>          ModInfo.SampRepLen: resw 31
  2420 00005676 <res 0000003E>          ModInfo.SampVol:    resw 31
  2421                                  
  2422                                  ; MODPLAY.ASM
  2423                                  PitchTable:	;resw 857
  2424 000056B4 <res 00001AC2>          		resw 3425 ; 01/10/2017 (TMODPLAY.ASM)
  2425 00007176 <res 00004100>          VolTable:	resb 16640
  2426 0000B276 <res 00001FEC>          MixBuffer       resb 8172 ; MixBufSize ; 7680 (960*8) ; 18/10/2017
  2427                                  
  2428                                  ; MODPLAY.ASM
  2429 0000D262 <res 00000001>          OrderPos:	resb 1
  2430 0000D263 <res 00000001>          Tempo:		resb 1
  2431 0000D264 <res 00000001>          TempoWait:	resb 1
  2432 0000D265 <res 00000001>          Bpm:		resb 1
  2433 0000D266 <res 00000001>          Row:		resb 1
  2434 0000D267 <res 00000001>          BreakRow:	resb 1
  2435 0000D268 <res 00000002>          BpmSamples:	resw 1
  2436 0000D26A <res 00000004>          BufPtr:		resd 1
  2437 0000D26E <res 00000002>          BufLen:		resw 1
  2438 0000D270 <res 00000004>          BufRep:		resd 1
  2439 0000D274 <res 00000004>          Note:		resd 1
  2440                                  ;Tracks:	resb TrackInfo.size*NumTracks
  2441                                  ; 07/10/2017
  2442 0000D278 <res 00000130>          Tracks:		resb TrackInfo.size*8
  2443                                  
  2444 0000D3A8 <res 00000008>          alignb 16
  2445                                  
  2446                                  ; PLAY.ASM
  2447                                  ;Scope:		resw 320
  2448 0000D3B0 <res 00000200>          RowOfs:		resw 256
  2449                                  
  2450                                  ; 23/10/2017
  2451 0000D5B0 <res 00000200>          NewScope_L:	resw 256 ; ?
  2452 0000D7B0 <res 00000200>          NewScope_R:	resw 256 ; ?
  2453 0000D9B0 <res 00000200>          OldScope_L:	resw 256 ; ?
  2454 0000DBB0 <res 00000200>          OldScope_R:	resw 256 ; ?
  2455                                  
  2456                                  mod_file_name:
  2457 0000DDB0 <res 00000050>          		resb 80
  2458                                  
  2459                                  ; 20/10/2017 (modplay7.s, SB16)
  2460                                  ; 19/10/2017 (modplay6.s, AC97)
  2461 0000DE00 <res 00000001>          pan_shift:	resb 1
  2462 0000DE01 <res 00000001>          volume_level:	resb 1
  2463                                  
  2464 0000DE02 <res 000001FE>          alignb 4096
  2465                                  
  2466                                  Audio_Buffer:
  2467 0000E000 <res 00008000>          		resb BUFFERSIZE ; DMA Buffer Size / 2  (32768)
  2468                                  
  2469                                  g_buff:
  2470 00016000 <res 00000400>          		resb 256 * 4 ; 23/10/2017 (stereo, 16 bits)
  2471                                  
  2472 00016400 <res 00009C00>          alignb 65536
  2473                                  
  2474                                  ;DMA_Buffer:
  2475                                  ;		resb 65536	
  2476                                  file_buffer:
  2477 00020000 <res 00060000>          		resb 65536*6
  2478                                  EOF:
